Repository navigation
test: strengthen assertions and reconcile mutation coverage (#71) - #195
Conversation
abogartz
left a comment
There was a problem hiding this comment.
Review: APPROVED_WITH_NITS
Reviewed adversarially at head 70d17ee on macOS / Bun 1.4.3 (CI pin is 1.4.4), against base 525ed89. I check the tree, not the body — here is what each claim was checked with.
Verified against the tree
| Body claim | How it was checked | Result |
|---|---|---|
| 17 files, production runtime code unchanged | git diff 525ed89 HEAD -- src/ e2e/ package.json → empty |
confirmed |
| No tests deleted | leaf-title multiset diff of test/ between the two trees: 1 rename (command.test.ts missing-source → missing-command-source) + 2 new in sweep-output.test.ts; unit count moves 722 → 724, exactly +2 |
confirmed |
| Strengthens ten existing tests | decision:"strengthened" = 10 identifiers over 9 files; verdicts.json 9 Strengthened + 65 Keep, 74/74 files, no strays |
confirmed |
| The old "missing source" test never exercised a missing source | base test was loadPlugin(cwd) + expect(Object.keys(hooks.tool).length).toBeGreaterThan(0); head calls ensureCommand with a deliberately absent command and asserts null + no directory created |
confirmed |
| The temp-path guard now fails its test instead of aborting the suite | base really was requireTempPath(...); expect(true).toBe(true) — a tautology whose failure mode was process.exit(2) killing the run; head asserts a child's exitCode === 0 and empty stderr |
confirmed |
| Nine probes (eight distinct perturbations), old test PASS → new test FAIL | replayed two myself in a clean tree at 525ed89: path-trailing-slash (old 4 pass → new 1 fail on expect(n.endsWith("/")).toBe(false)) and command-missing-throws (old 3 pass while ensureCommand rethrew → new fails on the ENOENT). Both match the recorded baselineExit=0 / candidateExit=1. The remaining seven were replayed on the same method and reproduce, including that each failure lands on the intended new assertion rather than a crash |
confirmed |
| Five mutation anchors had drifted | bun scripts/test-sweep.ts --validate at 525ed89 fails with exactly prune-repofloor-off, undo-force-safety-after-publish, restore-merge-drops, repo-floor-off, gate-dupes-promoted; at head 45 patterns, all one site. The base sweeper was not merely drifted — it aborted, so no sweep could have been produced at the stated base |
confirmed |
| Report generator refuses incomplete/mismatched input | synthetic logs: all five refusals fire (verdict completeness, absent witness, unaccounted removed test, missing/stray file verdict, killed→survived) with exit 1 and no output; green control exit 0 | confirmed |
| Per-file verdict table | regenerated from the committed artifact with triage-71.ts's own logic → byte-identical, 74/74 rows |
confirmed |
| Gate numbers | locally: base58 typecheck clean, lint exit 0 / 409 warnings, 722 pass / 12 skip / 0 fail, e2e 11; head: typecheck clean, lint exit 0 / 410 warnings, 724 / 12 / 0, e2e 11 | confirmed |
| Determinism | the 11 changed files 5× forward (113 pass every run), 3× reversed, and the full suite with a reversed file list 2× (724/12/0 both) | confirmed |
No existing assertion got weaker. expect( counts per changed file never decrease (e.g. concurrency 21→21, epoch 90→90, scenarios 155→155, command 4→6, status 84→85). The substitutions are all tightenings: toBeGreaterThan(0) → exact lengths, a tautology → toBe(false), toContain(row) → full-byte toBe(before), cumChars > 0 → === expectedChars. No new swallowing try/catch, no .catch(() => {}), no widened timeouts.
Nits
- N1 — a positive control was dropped where this PR's own standard applies.
test/concurrency.test.ts:76-99: base'sexpect(reads).toBeGreaterThan(0)is replaced byexpect(incompleteReads).toBe(0), so a reader loop that ran zero times would pass vacuously. It is only safe today because the loop is structurally unconditional (400 reads). Please addexpect(reads).toBe(400), or say in the comment that the loop itself is the control — your own per-file prose argues "positive workload controls are necessary premises". - N2 — +1 lint warning (
test/status.test.ts:406,block!.length; measured 409 → 410). Narrowingblockonce would make a missing delivery report itself by name instead of as an arithmetic mismatch. Cosmetic. - N3 — the instrument's identifier harvest is bun-build-dependent.
scripts/sweep-output.tsparses(pass)/(skip)lines andtest-sweep.tsspawns plainbun test ./test/; this host's Bun prints neither, so the pipeline fails closed attriage-71.tswith "expected one green baseline with test identifiers". A one-line message inmain()whenpass > 0 && passed.length === 0would save the next operator the archaeology. - N4 — two sweep reports now sit in
bench/with different denominators.bench/test-sweep-results.mdstill advertises 43 mutants / 483 pass on Bun 1.3.10 @7bfe99b(staleness predates this PR); one pointer line tobench/test-integrity-71.jsonat the top would keep a reader from quoting the old number.
Residual (not blocking, worth one line in the thread)
The 38/43 score itself rests on your machine: the artifact is internally consistent and I regenerated it bit-exactly from a synthetic log pair, but before.jsonl/after.jsonl are neither committed nor hashed, and --selftest spawns git worktrees so it was out of scope in this review setup. Committing the two logs (or their SHA-256) would make the score re-derivable by the next person. Also: four tests changed kill sets between the two runs while all 38 mutants stayed killed — "no previously detected mutant was lost" is true, but per-test kill columns are not a stable quantity and I would not cite them as such.
What I could not verify: that the two Windows sweeps ran as described (repeat=1, jobs 2/4, 120 s/180 s, Bun 1.4.4); --selftest calibration; the Bun failure-recap misattribution trigger (reproduced the old parser's fabricated witness and proved the two new tests kill five parser mutations, but Bun 1.4.3/macOS emits no recap even at 60 failures); Windows behaviour of the trailing-slash and empty-stderr pins (mitigated by test-windows passing at head, not proven here).
Artifact note: the matrix is measured on a tree 7 commits behind main (main's skip count is now 11, not 12, because #194 removed the pre-#194 rejection spec — your body already names that skip). Regenerate when convenient; no rebase required for correctness.
|
Addressed N1–N4 in
For the residual reproducibility concern, committed the actual original Validation: 39 focused tests pass; full Windows/Bun 1.4.4 gate passes (724 unit tests, 12 skipped; 11 E2E tests; typecheck and lint). No production runtime change, rebase, or mutation-score change. Hosted checks are running for the new head. |
abogartz
left a comment
There was a problem hiding this comment.
Round 2: APPROVED
Re-verified at 224ea37. All four nits are closed, and the residual — the one thing that kept my own approval hedged — is closed harder than I asked.
The score is now re-derivable by anyone. You committed the two sweep logs and the pointer sentence, and I took the documented command literally:
bun scripts/triage-71.ts bench/test-integrity-71/before.jsonl bench/test-integrity-71/after.jsonl out.json
→ byte-identical to bench/test-integrity-71.json (219,362 bytes, cmp clean)
That is the strongest form the claim could take, and it holds on my machine, on Bun 1.4.3 / macOS — the same build whose missing (pass) lines were the reason I could not regenerate in round 1. So the 38/43 number is no longer resting on your host; the input/output pair is checked in and the derivation is deterministic across builds.
Nits, one by one:
- N1 —
expect(reads).toBe(400)intest/concurrency.test.ts. The reader loop is now its own positive control, soincompleteReads === 0can never again be earned by a reader that did not run. - N2 —
test/status.test.tsnarrows once and throwsprovider request N did not receive its durable memory block, and theblock!is gone. Measured consequence: biome is back to 409 warnings, flat versus main (my round-1 report was 409 → 410). - N3 —
scripts/test-sweep.tsnow warns when the baseline reports passes but yields no harvested identifiers, names the consequence fortriage-71.ts, and says which build was validated. That message is exactly the archaeology I did. - N4 — the pointer line at the top of
test-sweep-results.mdis there, and the sentence I would have written myself is the one about denominators: "describe different trees/catalogs and must not be combined."
Two sentences in the new prose are worth calling out because they foreclose the misuse I was worried about: the logs "reproduce the original pinned report, not a new sweep of subsequent changes", and per-test kill sets are "observations from those runs, not stable coverage quantities". My round-1 complaint was that 4 tests changed kill sets while all 38 mutants stayed killed; the artifact now says that in its own words rather than waiting for a reviewer to notice.
Gates at this head: typecheck clean, biome exit 0 at 409 warnings, unit 724 pass / 12 skip / 0 fail, real-host e2e 11 pass / 0 fail. Round-1 verification stands (no assertion weakened anywhere in the sweep diff, --validate still reproduces the five drifted anchors at 525ed89, two probes replayed personally).
Leftovers, honestly weighted: +390 KB of committed logs is real, and it is the right trade — a mutation-catalog artifact nobody can re-derive is worth more than a fifth of a megabyte. And the two Windows-only claims in "what I could not verify" stay unverifiable from here, with test-windows green at head as the substitute evidence.
|
🎉 This PR is included in version 0.15.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fixes #71.
The listed weak assertions could accept parseable data loss, damaged snapshot identity, cropped memory rows, and invented accounting numbers. This strengthens ten existing tests, replaces a missing-source test that never exercised a missing source, prevents a symlink test from swallowing its own failed assertion, and makes the temp-path guard fail its test rather than aborting the suite. It also corrects the promised capture-session control comment.
Nine targeted probe cases (eight distinct source perturbations) pass their old selected test and fail the strengthened test. Exact source replacements, selectors, and outcomes are in
bench/test-integrity-71-probes.json. These are additional probes, separate from the scored 44-mutant catalog.No tests were deleted. The matrix records a decision for every printed test identifier, and the table below gives the per-file reasons requested by the issue. A test with no observed failure under this catalog is not automatically redundant: reporting, host envelopes, capture boundaries, dataset validity, and several identity/accounting paths have no corresponding mutants here.
Measurement method
The old 231/288 figure was measured against a different tree and a 24-mutant catalog. This measurement is pinned to production base
525ed89, with instrumented baseline8f97437and strengthened tests at96b7d3d.The instrument needed repair first: five mutation anchors had drifted; the duplicate-verdict mutant now returns a valid result shape; and Bun's final failure recap could incorrectly attribute earlier failures to the last test file. Two parser regression tests are included in both measurements. Logs now expose passing/skipped identifiers and final mutant verdicts, allowing
scripts/triage-71.tsto rebuild the ledger and reject incomplete or mismatched inputs.Both runs use Bun 1.4.4 on Windows, repeat=1 with the existing confirmation policy for timing-only kills. Baseline: two workers, 120-second suite limit. Candidate: four workers, 180-second limit. They ran concurrently in independent scratch worktrees; these timings are not a performance benchmark. Calibration (
--selftest) detected its planted defect. The matrix describes observed witnesses, not a claim that every incidental failure establishes causality.Both complete sweeps detect 38 of 43 non-equivalent mutants (88.4%), with the same five survivors, one equivalent, and no load errors or timeouts. No previously detected mutant was lost. The candidate matrix contains 724 passing identifiers and 12 declared skips across 74 files; 483 passing identifiers have no observed kill in this catalog. The extra observed witness compared with the baseline is an unchanged capture test, so it is not credited as an assertion improvement. The nine controlled probes above demonstrate the assertion changes independently.
Validation and limits
bun run gate: typecheck and lint pass; 724 unit/scenario tests pass, 12 skip; all 11 terminal E2E tests pass. Test assertions were checked with the nine additional old-pass/new-fail probes above. Production runtime code is unchanged.The 12 declared skips are seven platform-specific containment cases, four live-repository cases, and the pre-#194 rejection acceptance spec. Some chmod/ACL capability probes can also return early and print as passed; the ledger does not claim branch coverage from that outcome.
The retained survivors need distinct treatment:
The report generator refuses missing final verdicts, unknown witnesses, unaccounted test removals, missing file decisions, and loss of a previously detected mutant. Reproduction commands and the exact per-test kill sets are in
bench/test-integrity-71.json.Review follow-up
The original Windows sweep inputs are committed at
bench/test-integrity-71/before.jsonlandbench/test-integrity-71/after.jsonl. Runningbun scripts/triage-71.ts bench/test-integrity-71/before.jsonl bench/test-integrity-71/after.jsonl <output.json>regenerates the pinned report byte-for-byte (SHA-2562a88f6076f06fa0147f38de4ba8c87c10b00e7f2e7d1488918c7a185a37c9ebe). These are the original measurements, not a new sweep of the review follow-up or current main. Per-test kill sets are observations that varied across runs, not stable coverage quantities.At
224ea37, the reader test explicitly requires 400 observations; missing status deliveries name the request before arithmetic; the sweeper warns when Bun reports passing totals without test identifiers; and the older sweep report points to this newer pinned catalog. The full Windows gate passes: 724 unit tests, 12 skips, 11 E2E tests, typecheck and lint. The added non-null-assertion lint warning is removed (409 existing warnings remain).Per-file verdicts
Optional contribution—please feel free to decline or close this if the approach does not fit your plans.