test: mandate positive controls on every corpus assertion (fifth near-miss of the vacuity class) #44
Labels
No labels
code-review
correctness
dos
performance
security
severity/high
severity/low
severity/medium
tech-debt
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
h-dv/code-index#44
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
P2 — process rule with a concrete enforcement mechanism.
The pattern
This project has now had five incidents where a test passed without testing anything:
precision_gatedecoys all sat in multi-candidate pools, so the entire tier-1b disjunction could be disabled with every language gate green. Fixed by a structural anti-vacuity guard.--no-daemon, so 5 RPC arms were deletable with CI green.changed_symbolspermanently and CI stayed green.2>/dev/null). Reported 4/4 green. Caught only by an ad-hocedited_syms_before == edited_syms_aftercheck. Re-run correctly (syms 30→31, 51→52, 242→243, 151→152) it was still green — but it could have hidden a real defect and nothing in the harness would have said so.Five times is not bad luck; it is a missing invariant in how tests are written here.
The rule
Every corpus assertion must ship with a positive control that fails if the setup did not take effect.
Not "did the assertion pass" but "did the thing I am asserting about actually happen":
Enforcement, not just documentation
A convention nobody can check will decay. Options to evaluate:
positive_control!helper that records into the run manifest, plus a harness-level assertion that every corpus test registered at least one control2>/dev/nullon a mutation step in a test; capture and assert the exit statusAcceptance
Landed — enforced in the harness, not just documented
corpus::Controls::require(label, held, detail)records a control and fails immediately if it does not hold.Coverage::finishtakes theControlsand refuses a run that graded repos while registering none.The two rules had to be coupled rather than checked separately: a standalone
Controls::finishpanicked on a legitimate skip, because with no corpus present every repo skips and no control can be registered. So:COSI_CORPUS_REQUIRE=1.Documented in
CONTRIBUTING.mdunder "Positive controls are mandatory", with all five incidents as rationale.It earned its keep immediately — three catches during implementation
*.renamed; the walker selects a language by extension, so the file left the index entirely instead of moving. The assertion under test would have passed. The control (file_present(new) && !file_present(old)) failed on the first run.git name-status shapes seen: {'A', 'M'}and0 new-directory commit(s) in the replayed range. Without the controls both would have passed while testing far less than they claimed.Registered per suite as landed: determinism 7, path-invariance 14, cold-vs-incremental 7 each, mutation 14 each, watcher replay 3 each.
Acceptance boxes 1–4 met.
Closing — verified in-tree.
The rule is enforced, not documented, which was the explicit bar this issue set:
corpus::Controls::requireasserts the setup took effect, with the vacuity rationale in its own doc comment ("any assertion built on it would be vacuous").Coverage::finishfails a corpus test that registers no control: "corpus[{}]: graded {} repo(s) but registered NO positive controls. Every … controls can pass without testing anything." That is acceptance item 3.#39/#41/#42/#43suites route throughCoverage/Controls, so item 2 is structural rather than conventional — a new corpus test cannot opt out without failing.CONTRIBUTING.mdcarries the rule.Independent evidence the mechanism actually bites, observed this session: running the ratchet with
COSI_CORPUS_REQUIRE=1and no corpus producedThat is the sixth incident of this class being caught by the mechanism built for the first five — and it caught a real one: my own baseline run had
COSI_CORPUS_DIRunset, so every corpus gate was grading nothing while reporting green. Worth noting for anyone reading this later: the guard only fires whenCOSI_CORPUS_REQUIRE=1, so a local run without it still silently skips. CI sets it; humans often won't.