Repository navigation
fix(gates): floor conflictProne rivalry, thread update target, honest block surface (#122) - #125
Conversation
… block surface GATE-3 review-gated the second decision/preference in any scope regardless of topical distance: any divergent live row set overlapMatch and the jaccard score was recorded but never consulted. Distinct preferences (measured 0.25) were blocked, memory_update could never rewrite a decision/preference row (its own supersession target was cited as the rival, 0.74), and the advertised memory_merge_review resolution was unreachable for a candidate that was never stored. - rivalry now requires clearing a floor: 0.9 rephrase band for all types, a dedicated 0.3 conflict floor for decision/preference value swaps - GateContext.supersedesTs excludes the row an update replaces from the contender set (also closes the >=0.9 reworded-update family) - superseded_overlap blocks cite the actual rival ts + score, carry a hint naming the working remedies (memory_update query=<rival ts>, distinct scope), and merge_proposal is advisory with incoming_stored=false since no loser row exists to resolve
Adversarial-review tests from the #122/#125 mutation battery. All 10 targeted mutants (floor drift x3, floor inclusivity, first-over-floor rival, newest-cited flag, exclusion drop, exclusion overreach, canon skip, evidence-field drop) are now killed; four of them survived the suite as submitted. S4e (scenarios): - preference pairs constructed to EXACT jaccard over the tokenizer: 0.25 / 0.2632 / 0.28 store clean (pins the production false-block claim the body cites; the submitted suite only pinned >0.044), 0.30 exactly is review-gated (floor inclusivity, 6/20 >= 0.3), and the rephrase floor inclusive at 0.90 / clean under at 0.8667. - multi-rival scopes pin that the block cites the BEST rival, not the first over the floor (pre-PR defect) and not the newest row (also pre-PR defect); documents merge_proposal canonical = newest quirk. - supersedesTs excludes ONLY the target: an update still contends with any other live rival. update-targeting (tool level): - documented pins for two reviewed edges: an update replaces its rival target with review-gate-worthy content (rivalry gate is advisory for updates; hint advertises this), and a collapsed update silently no-ops leaving the target live. - RED (test.failing): two concurrent memory_update calls resolving the same target both succeed and leave TWO active replacement rows (deterministic 5/5 on the PR branch); goes unexpectedly-green when resolve->gate->markSuperseded becomes atomic per target.
Adversarial review follow-up — test-only commit
|
Two concurrent memory_update calls that both resolved the same still-active target both promoted and both claimed success; markSuperseded is first-call- wins, so one replacement row survived un-superseded with no pointer anywhere (measured 5/5 deterministic). The advertised remedy for gate-3 rivalry, the resolve -> gate -> supersede sequence was not atomic per store. memory_update now runs the whole sequence under one UPDATE-ORDER lock (a distinct file from anything runWriteGate/markSuperseded take — sections run flat, never re-enter a held file). Acquisition order is always update-order then store, and plain writers never take the update-order lock, so the wait-for graph stays acyclic. The lock FAILS closed on timeout: proceeding unlocked is the race itself. The loser re-resolves under the lock, finds its target retired, and hits the documented not_found path — "Nothing was written". Promoted the test.failing race pin to a normal test asserting winner + fail-closed loser + exactly one live replacement and no orphan row. Stress-verified: 6-way same-target contention (1 winner / 5 rejections), concurrent updates to different targets all land, and update-vs-remember interleaves keep the store intact (3/3 repeat runs each).
|
Fixed the concurrent double-swap in |
…cord evidence Probed the resolve->mark->clear sequence after the update-lock fix. Three defects, all confirmed live through the tool surface: 1. PHANTOM SURVIVOR (data loss): merge_review validated nothing about the survivor id. Marking a real loser with a survivor ts that names no row returned "X is canonical" while the scope ended with ZERO active rows - the loser was retired toward a pointer to nothing. Existence is now checked before touching the loser; the call fails closed and writes nothing (the description always advertised fail-closed - the code now matches it, including the loser===survivor self-round-trip that used to report full success while doing nothing). 2. FALSE EVIDENCE CLAIM: the success text says "Evidence recorded for reason='...'" but the handler recorded nothing - the host tool_result hook covers grep/glob/read/edit/write/bash/shell only. A successful merge now emits a merge_resolved evidence row (loser, survivor, revived, reason). Same honesty family as the #125 block-surface fixes. 3. RACING: concurrent merge + update on one survivor measured 20/20 benign in-process (the interleavings serialize on the daily-store lock), but the deterministic worst case exists WITHOUT a race: a stale review applied after a completed update revives the update's retired target (both versions end live). That is the pinned survivor-revival contract (existing test deliberately clears a third row's drift marker) - flagged to the maintainer, semantics left unchanged here. Pins: phantom survivor retires nothing; self-merge rejected; successful merge leaves an auditable row. 3/3 mutants dropping each guard killed. Suite 519 pass / 0 fail; tsc + biome clean.
|
Probed Fixed: phantom survivor = silent data loss. No validation existed on the survivor id: Fixed: "Evidence recorded" was false. The success text claimed evidence; the handler wrote none — the host Reported, NOT changed — stale-merge revival. The worst case needs no race: apply a review resolution after a completed update rewrote the survivor, and Pins: 3 new tests, all red-before-green, 3/3 drop-the-guard mutants killed. Suite 519 pass / 0 fail / 12 skip. |
## [0.14.8](v0.14.7...v0.14.8) (2026-10-26) ### Bug Fixes * **gates:** floor conflictProne rivalry, thread update target, honest block surface ([254b8d1](254b8d1)) * **merge_review:** validate survivor existence, refuse self-merge, record evidence ([98b6820](98b6820)), closes [#125](#125) * **update:** close the concurrent double-swap with an update-order lock ([53faf60](53faf60))
|
🎉 This PR is included in version 0.14.8 🎉 The release is available on: Your semantic-release bot 📦🚀 |
…bogartz#125 main's abogartz#125 (gate3 conflict floor) rewrote the rivalry logic around the very call sites this branch renames record->rec, so the conflict was textual, not semantic. Resolution: take main's gates.ts wholesale, re-apply the threading verbatim - helpers after chainId(), then the 19-site rename. Audited abogartz#125's diff first: still exactly 19 record/recordWriteBlocked sites inside runWriteGate (no new audit lines to thread), and its new ctx.supersedesTs is orthogonal to sessionID threading. Verified at the merge shape: capture-sid-race 3/3 (hijack red-shape stays dead under the new conflict logic - blocked-path pin exercises abogartz#125's recordWriteBlocked routes with threaded sid), full suite 515/0/5, tsc clean.
…bogartz#125 main's abogartz#125 (gate3 conflict floor) rewrote the rivalry logic around the very call sites this branch renames record->rec, so the conflict was textual, not semantic. Resolution: take main's gates.ts wholesale, re-apply the threading verbatim - helpers after chainId(), then the 19-site rename. Audited abogartz#125's diff first: still exactly 19 record/recordWriteBlocked sites inside runWriteGate (no new audit lines to thread), and its new ctx.supersedesTs is orthogonal to sessionID threading. Verified at the merge shape: capture-sid-race 3/3 (hijack red-shape stays dead under the new conflict logic - blocked-path pin exercises abogartz#125's recordWriteBlocked routes with threaded sid), full suite 515/0/5, tsc clean.
…redact-before-crop capture The three mediums from the 2026-10-26 security review (abogartz#130, abogartz#131, abogartz#132), each pinned by regression tests that are red on the reviewed revision (cf9b73c, 0.14.9) and green on this commit. - memory_evidence (abogartz#130): `date` is a date, not a path. A regex at the schema boundary plus evidenceFileFor() — real calendar dates only, resolved INSIDE the evidence dir, impossible dates refused rather than rolled, symlinked day files not followed — so neither `../../outside` nor `../YYYY-MM-DD` (the raw daily store, visibility filters and all) can be read. The wire pin in boundaries.test.ts records the (intentional) date pattern; the `~standard` key in that diff is a non-enumerable zod annotation present on every tool, as before. - memory_merge_review (abogartz#131): a row id is a pointer, not authority. Both seats resolve through the caller's Reader — captured at entry, never re-read after an await (abogartz#127) — and the resolve/check/mutate runs under the update-order lock memory_update serializes on (abogartz#125), so authorization is revalidated under the mutation lock. A foreign repo's row is refused in either seat (including superseded-survivor revival) with nothing mutated and no evidence written; global rows stay mergeable from anywhere, stated in the tool description instead of granted implicitly by store-wide reach. Success now also records the session the merge ran FOR. - auto-capture (abogartz#132): redact the COMPLETE transcript, THEN crop to the 8,000-char budget. Cropping first could start the window inside a credential — a PEM body whose BEGIN marker fell off, a token whose prefix fell off — and buildCapturePrompt's own scrub (kept, defense in depth) cannot recognize a fragment. The tests drive the real compaction hook and assert on the prompt actually handed to the capture model. Full suite: 537 pass / 5 skip / 0 fail; typecheck clean; `biome lint` 0 errors.
…redact-before-crop capture The three mediums from the 2026-10-26 security review (abogartz#130, abogartz#131, abogartz#132), each pinned by regression tests that are red on the reviewed revision (cf9b73c, 0.14.9) and green on this commit. - memory_evidence (abogartz#130): `date` is a date, not a path. A regex at the schema boundary plus evidenceFileFor() — real calendar dates only, resolved INSIDE the evidence dir, impossible dates refused rather than rolled, symlinked day files not followed — so neither `../../outside` nor `../YYYY-MM-DD` (the raw daily store, visibility filters and all) can be read. The wire pin in boundaries.test.ts records the (intentional) date pattern; the `~standard` key in that diff is a non-enumerable zod annotation present on every tool, as before. - memory_merge_review (abogartz#131): a row id is a pointer, not authority. Both seats resolve through the caller's Reader — captured at entry, never re-read after an await (abogartz#127) — and the resolve/check/mutate runs under the update-order lock memory_update serializes on (abogartz#125), so authorization is revalidated under the mutation lock. A foreign repo's row is refused in either seat (including superseded-survivor revival) with nothing mutated and no evidence written; global rows stay mergeable from anywhere, stated in the tool description instead of granted implicitly by store-wide reach. Success now also records the session the merge ran FOR. - auto-capture (abogartz#132): redact the COMPLETE transcript, THEN crop to the 8,000-char budget. Cropping first could start the window inside a credential — a PEM body whose BEGIN marker fell off, a token whose prefix fell off — and buildCapturePrompt's own scrub (kept, defense in depth) cannot recognize a fragment. The tests drive the real compaction hook and assert on the prompt actually handed to the capture model. Full suite: 537 pass / 5 skip / 0 fail; typecheck clean; `biome lint` 0 errors.
…redact-before-crop capture The three mediums from the 2026-10-26 security review (abogartz#130, abogartz#131, abogartz#132), each pinned by regression tests that are red on the reviewed revision (cf9b73c, 0.14.9) and green on this commit. - memory_evidence (abogartz#130): `date` is a date, not a path. A regex at the schema boundary plus evidenceFileFor() — real calendar dates only, resolved INSIDE the evidence dir, impossible dates refused rather than rolled, symlinked day files not followed — so neither `../../outside` nor `../YYYY-MM-DD` (the raw daily store, visibility filters and all) can be read. The wire pin in boundaries.test.ts records the (intentional) date pattern; the `~standard` key in that diff is a non-enumerable zod annotation present on every tool, as before. - memory_merge_review (abogartz#131): a row id is a pointer, not authority. Both seats resolve through the caller's Reader — captured at entry, never re-read after an await (abogartz#127) — and the resolve/check/mutate runs under the update-order lock memory_update serializes on (abogartz#125), so authorization is revalidated under the mutation lock. A foreign repo's row is refused in either seat (including superseded-survivor revival) with nothing mutated and no evidence written; global rows stay mergeable from anywhere, stated in the tool description instead of granted implicitly by store-wide reach. Success now also records the session the merge ran FOR. - auto-capture (abogartz#132): redact the COMPLETE transcript, THEN crop to the 8,000-char budget. Cropping first could start the window inside a credential — a PEM body whose BEGIN marker fell off, a token whose prefix fell off — and buildCapturePrompt's own scrub (kept, defense in depth) cannot recognize a fragment. The tests drive the real compaction hook and assert on the prompt actually handed to the capture model. Full suite: 537 pass / 5 skip / 0 fail; typecheck clean; `biome lint` 0 errors.
…redact-before-crop capture The three mediums from the 2026-10-26 security review (abogartz#130, abogartz#131, abogartz#132), each pinned by regression tests that are red on the reviewed revision (cf9b73c, 0.14.9) and green on this commit. - memory_evidence (abogartz#130): `date` is a date, not a path. A regex at the schema boundary plus evidenceFileFor() — real calendar dates only, resolved INSIDE the evidence dir, impossible dates refused rather than rolled, symlinked day files not followed — so neither `../../outside` nor `../YYYY-MM-DD` (the raw daily store, visibility filters and all) can be read. The wire pin in boundaries.test.ts records the (intentional) date pattern; the `~standard` key in that diff is a non-enumerable zod annotation present on every tool, as before. - memory_merge_review (abogartz#131): a row id is a pointer, not authority. Both seats resolve through the caller's Reader — captured at entry, never re-read after an await (abogartz#127) — and the resolve/check/mutate runs under the update-order lock memory_update serializes on (abogartz#125), so authorization is revalidated under the mutation lock. A foreign repo's row is refused in either seat (including superseded-survivor revival) with nothing mutated and no evidence written; global rows stay mergeable from anywhere, stated in the tool description instead of granted implicitly by store-wide reach. Success now also records the session the merge ran FOR. - auto-capture (abogartz#132): redact the COMPLETE transcript, THEN crop to the 8,000-char budget. Cropping first could start the window inside a credential — a PEM body whose BEGIN marker fell off, a token whose prefix fell off — and buildCapturePrompt's own scrub (kept, defense in depth) cannot recognize a fragment. The tests drive the real compaction hook and assert on the prompt actually handed to the capture model. Full suite: 537 pass / 5 skip / 0 fail; typecheck clean; `biome lint` 0 errors.
## [0.14.13](v0.14.12...v0.14.13) (2026-10-28) ### Bug Fixes * **security:** date-shaped evidence reads, ownership-checked merges, redact-before-crop capture ([bc9eebd](bc9eebd)), closes [#130](#130) [#131](#131) [#132](#132) [#130](#130) [#131](#131) [#127](#127) [#125](#125) [#132](#132) * **security:** merge_review reports a post-mutation failure as partial ([156e887](156e887))
Closes #122.
Three related gate-semantics defects, one branch. Design rulings from the maintainer: dedicated 0.3 conflict floor (option 1 of the filed choices), and advisory + hint (not merge_review-for-blocked).
1. conflictProne overlap gets a similarity floor (
src/gates.ts)For
decision/preference, any active divergent same-type row setoverlapMatch— the jaccard score was recorded but never used. The second preference in any scope was review-gated forever (measured false-block: a genuinely new preference at 0.25, chainf03c9f6e).Now rivalry must clear a floor:
OVERLAP_FLOOR = 0.9— reworded near-duplicates of any type (unchanged).CONFLICT_OVERLAP_FLOOR = 0.3— decisions/preferences: a value swap on the same subject is a genuine rivalry well below the rephrase band (ExpressvsFastify= 0.67, the sharding rival = 0.32, both stay review-gated), while topically distinct statements in a shared scope (measured 0.25) store clean.The scan is now a single pass picking the best rival above the floor (was:
divergent[0]for conflictProne, a second scan for the rest). The exact-restatement collapse keeps its S4/S4b semantics — the exception now testsrival(over the floor) instead of "any divergence".2.
memory_updatecan finally update a decision/preference rowGateContext.supersedesTsthreads the resolved target through to GATE-3, where it is excluded from the contender set: the update IS the sanctioned supersession, the gate must not cite it as the conflict (the 0.74 self-block, chain60b8d3bc). As a side effect this also unblocks ≥0.9 reworded updates of any type, which previously collapsed into the same generic overlap block.memory_updatepasses{ ...gateContext(), supersedesTs: target.ts }.3. Honest block surface
superseded_overlapnow carries ahint(it previously had none) naming the remedies that actually work:memory_updatewithquery="<rival ts>"to replace the rival, a distinct scope to coexist — and states plainly thatmemory_merge_reviewresolves stored rows only.merge_proposalevidence:review=required→review=advisoryplusincoming_stored=false— a blocked candidate was never persisted, so it can never be amerge_reviewloser.MergeReviewArgsdocs corrected:loser/survivorare ts ids of stored rows, not evidence ids.Tests
S4c— distinct second preference stores clean (dedup_clean, promoted); rival preference at 0.8 still review-gated with hint + advisory evidence + exact flags.S4d— ≥0.9 rewording: blocked with no target named; promoted whensupersedesTsnames the row.update-targeting— tool-level regression: a reworded preference update lands and supersedes its target (pre-fix this returnedWrite blocked at GATE (superseded_overlap)).S4assertions updated for the new semantics (review=advisory,incoming_stored=false, hint present);boundarieswire capture updated for the correctedmerge_reviewarg descriptions.Gate:
bun run gateall green — 504 unit pass / 12 skip / 0 fail, 11 e2e scenarios (real opencode host), tsc + biome clean.Follow-up 2 (commit 53faf60): fixed the concurrent double-swap
memory_updatenow runs resolve → gate → supersede under one per-store update-order lock. The loser re-resolves its (now-retired) target under the lock and hits the existing fail-closednot_foundpath — "Nothing was written". The lock fails closed on timeout (proceeding unlocked is the race itself), and the acquisition order is always update-order then store, so it can't deadlock against a plain writer. Thetest.failingRED is promoted to a normal test asserting winner + fail-closed loser + exactly one live replacement and no orphan row. Stress-verified 3/3 repeat runs each: 6-way contention on one target (1 winner / 5 rejections), concurrent updates to different targets all land, and update-vs-remember interleaves stay intact. Suite 516 pass / 0 fail / 12 skip.Follow-up (test-only commit cbbfc75, post adversarial review)
Mutation battery added 12 tests: exact-jaccard floor-band pins (0.25/0.2632/0.28 pass, 0.30 blocks inclusively; learning 0.90 inclusive / 0.8667 clean), multi-rival best-vs-first-vs-newest citation pins, a supersedesTs-excludes-only-target guard, documented pins for the update-as-sanctioned-supersession asymmetry and the collapsed-update no-op. 10/10 mutants killed. See the review comment for details. (A
test.failingRED for the double-swap surfaced here was fixed in commit 53faf60 above.)