Repository navigation
Description
Reframing after discussion (this is the current shape)
Scenarios are the net; the sweep is the auditor. My first proposal put mutation testing first and
that was the wrong order: what would have caught the #60 fake fix is a scenario that replays the
situation — several sessions writing one store while a human restores a snapshot — and that is red
on the broken build and green on the fix. Unit tests cannot certify that the whole composes, and a
mutation score computed over unit tests measures sensitivity, not whether the user-visible promise
holds. So: #69 builds the scenario suite; #70 keeps the sweep, demoted to auditing whether those
scenarios actually bite. The measurements below still stand, because they are what proved two
existing tests (one of them an end-to-end HTTP test) were fiction.
Why
PR #60 shipped a fix that did not fix the thing (force restore could still drop rows with no
recoverability), and the suite was green. On review I did not find it by reading harder — I found
it by asking what the tests actually depend on. That question is measurable, so this epic makes
it measurable instead of a matter of opinion.
Instrument: a mutation sweep. Break exactly one claimed invariant at a time in a detached
git worktree of HEAD, run the suite, report whether anything died. A mutation nobody dies on is
an unpinned invariant — whatever the test titles claim. The prototype already exists
(scripts/test-sweep.ts, currently uncommitted in the working tree) and has been validated and
run once:
bun run scripts/test-sweep.ts --validate # every mutation applies to exactly one site
bun run scripts/test-sweep.ts --repeat=3 # 24 mutants x full suite, ~11 min
Baseline — main @ 4643ec4, --repeat=3
- 21/24 invariants pinned (87.5% mutation score)
- 57 of 288 tests killed at least one mutation → 231 tests never observed a broken invariant
- Line coverage 96.04% / functions 96.13% at the same time as atomic publish being unpinned.
Coverage records that a line ran; it never records that a test depends on the behaviour. This
class of defect was never going to be found by a coverage number. - Weak assertions are not the problem: 23 of ~921
expect(calls are
toBeTruthy/toBeDefined/toBeGreaterThan(0)shaped. The failure is seam and dependence,
not assertion verbosity.
The four defect classes this epic is designed to catch
| instance found in this repo | ||
|---|---|---|
| D1 wrong seam | the primitive is tested, not the caller sequence holding the bug | restoreSnapshot was tested per-mode; the bug was the pair "snapshot, then restore" that src/viewer/server.ts performed outside the lock |
| D2 unreached window | a race test that never produces the interleaving it claims to cover | prune-vs-append and restore-vs-append passed on main before the fix, by timing luck |
| D3 pass-for-the-wrong-reason | the assertion holds through an unrelated path, so the named guard is never observed | viewer.test.ts "a ..-bearing snapshot name is refused" still passes with the grammar check deleted — basename() yields planted.logfmt, it is not in snapshots/, and the thrown "snapshot not found" arrives with the server's default 400 |
| D4 no conservation | assertions say what one mode should do locally, never that nothing vanishes globally | the merge-restore test asserted appended rows survive merge; nothing asserted "no row lands nowhere" for force, the mode that drops rows |
Children
- Testing-1: acceptance scenario suite for the destructive seams — red on the pre-fix commit, green on main #69 — acceptance scenario suite for the destructive seams: red on the pre-fix commit, green on
main. First two scenarios written and measured — fail 6/6 on357ecaf^(10–16 of 100
appended rows in neither the store nor any snapshot; 26–30 of 60 supersede writes never
landed) and pass 4/4 onmain - Testing-2: the mutation sweep audits the scenarios (instrument, status classes, four audit findings) #70 — the sweep as auditor: commit the instrument, one mutant per scenario, honest status
classes,equivalentflag, plus the four findings the audit produced - Testing-3: triage the 231 tests that pin nothing — strengthen or delete #71 — triage the 231 tests that pin nothing: strengthen or delete (blocked on Testing-1: acceptance scenario suite for the destructive seams — red on the pre-fix commit, green on main #69 and Testing-2: the mutation sweep audits the scenarios (instrument, status classes, four audit findings) #70)
- Testing-4: pre-release sweep with a published mutation score and unpinned-invariant list #72 — pre-release sweep with a published mutation score and unpinned-invariant list
Order matters: #69 is the net itself, #70 verifies the net has teeth and closes the audit's
findings, #71 is the fix-or-remove pass and must come after both, #72 keeps it true afterwards.
Design rules this epic establishes (apply to every child, and to new work)
- Conservation over expectation. Any path that can drop data is tested as "the row is in the
store, or in the snapshot, or in the safety copy — never nowhere". - Deterministic interleaving, never race-and-hope. Hold the store lock in the test to make
"another writer is mid-section" a fact; exploit filesystem semantics (immutable target,O_EXCL
collision) as discriminators; order cross-process steps by signal (child prints after
acquiring), never by sleep. A test that kills in fewer than 5/5 runs is D2 and gets rewritten. - Boundary tests assert the boundary — status and reason, plus one case where that guard is
the only thing that can reject. - Red-then-green is the definition of done, at scenario level. Every defect gets a failing
scenario committed first — red against the pre-fix commit where history has one (this repo's
git history makes that checkable, which is why the standard is enforceable rather than
rhetorical), otherwise red against a named mutant. If nothing dies, the test is fiction and the
invariant goes on the unpinned list instead. - Right level for the claim. Composition claims ("nothing is lost when two sessions write")
belong in scenarios across real processes. Pure-function claims (path containment, budget
trimming, logfmt escaping) stay unit tests, where they are cheap and deterministic. - Purity for reachability. Guards unreachable by construction are extracted into pure
functions and tested there, or deleted — not left invisible behind a caller chain.
Second meta-lesson (operational, from building #69)
Bun.spawn does not inherit the parent environment by default. The first version of the scenario
suite relied on inheritance and its child processes wrote 140 rows into the developer's real
memory store while the test "passed". Any test that spawns a process must pin the store by argv and
refuse a non-temporary root. A test that can touch real state is a defect regardless of what it
asserts.
Meta-lesson (keep this one, it recurs)
The first calibration harness reported "0 partial writes detected" for a mutant that was
detectable, because its reader loop used readFileSync with no await and starved the writers
until after the publishes finished. A measurement that cannot fail. Every harness added under
this epic ships with a negative control that must go red, and a harness that reports success on
a mutated tree gets treated as a finding in its own right.
Activity
WhollyMindless commentedon Oct 25, 2026
Happy to take this epic in hand if a second implementer helps: #70 (commit the sweep instrument + one mutant per scenario, honest status classes), then #71 (the fix-or-delete pass over the 231 tests that pin nothing), then #72 (pre-release gate with the published mutation score). The design rules here are the same discipline we've worked in on #69/#86 and the cross-platform verification batch (the "a test that can touch real state is a defect" lesson was load-bearing in our temp-dir cleanup too), so this is work we'd genuinely enjoy. Every PR red-first, verified on Windows + Linux across both embedded-Bun pins. Your call on ordering — we can hold until the retrieval PRs land to keep your diffs unconflicted.
test(#70): the mutation sweep grows a baseline and inherits the shipp…
WhollyMindless commentedon Oct 30, 2026
Follow-up from the maintainer's approval of #187 (nit 3): identify the slow phase in the Windows ACL lock fixture before treating its 30-second outer deadline as permanent.
On head 14dd130, test-windows reported the existing ACL test at 6700 ms against Bun's five-second outer deadline. The log does not identify whether whoami, icacls setup, the lock operation, or icacls cleanup was slow. All nine new reader tests passed. Ten local repetitions exercised all four ACL assertions and passed; the full local gate's ACL case took 131 ms. The outer deadline was raised to 30 seconds in 843d69e, and all four hosted checks then passed.
Suggested next measurement: record elapsed time for identity lookup, ACL deny/probe, withStoreLock, and ACL restoration on the shared Windows runner. Retain the existing <2000 ms assertion around the lock itself, permission-error assertion, and guarantee that the writer never runs. Use measured phase timings to decide whether the outer budget should be reduced or fixture setup changed. No production lock timeout or retry policy changed.
Review: #187 (review)
Failure: https://github.com/abogartz/opencode-self-improvement/actions/runs/40973340736/job/123795239865
WhollyMindless commentedon Oct 30, 2026
Starting the Windows ACL phase-timing follow-up from #187. I will add bounded, non-sensitive phase diagnostics to the existing fixture (identity lookup, deny/probe, lock, restore) so a hosted timeout shows where it stalled. Lock assertions, production behavior, and the current outer timeout stay unchanged. This is instrumentation to collect evidence, not a claim that the old slow phase has been identified. Please redirect if this overlaps unposted work.
test(abogartz#35): pin the UPPER side of the near-match guard band
abogartz commentedon Nov 1, 2026
Synthesis update (2026-11-01): the e2e tool surface was measured - 22 scenario blocks exercise five of the fourteen registered tools on a real host (
remember,recall,forget,list,status). Nine tools (update,undo,export,import,decay,consolidate,merge_review,evidence,init) and every viewer route have no host-level scenario.Filed as #241, which extends the #69 scenario approach to the full tool surface and adds a mechanical gate check that every registered tool and hook has a named e2e scenario. Also filed #235 (report-only coverage measurement): reach gaps like this one hid because nothing measures reach.
ocsi-triager commentedon Nov 5, 2026
All 4 sub-issues closed as completed: #69, #70, #71, #72. Closing the epic.