Repository navigation
fix: memory_undo force omits tombstoned rejections (#307) - #312
Conversation
restoreSnapshot consulted no rejection tombstone in any mode, so force reinstated values memory_forget had tombstoned — the store ended up holding an active row it also recorded as rejected, contradicting #35. FORCE now reads the tombstones inside the restore lock and omits snapshot rows whose content carries one, reporting them in a new rejectedOmitted field separate from deletedOmitted. The tool description and check-mode refusal state the contract; the tombstone file stays read-only to a restore (decision #214 A).
WhollyMindless
left a comment
There was a problem hiding this comment.
Reviewed 181328e8a6ab036e578fccc228fed4c1225d118e on Windows / Bun 1.4.4. I raised the original policy question in #214; I did not author this implementation. The force-mode fix works, including ordinary-deletion recovery and unchanged tombstones. One remaining route contradicts accepted option A and the new tool description's promise that no mode resurrects rejected content.
F1 — default and merge undo can restore an older copy of a rejected value (P2). At src/store/undo.ts:281-284, tombstones are read only for force mode. The other modes protect deleted row identities, while rejection is keyed on content. An older snapshot identity can therefore escape the deletion audit.
Reproduced with temporary-store fixtures and the real memory_undo, memory_forget, and memory_recall tools:
- Snapshot an empty day file as S0. Put value X in it as row T1 and snapshot as S1.
- Force-undo S0: T1 disappears through legitimate rollback, with no human-deletion audit for T1.
- Store a later copy T2 of X, then
memory_forgetits scope/type. This audits T2 and tombstones X; the store is empty. - Undo S1 in default mode, or independently with
merge=true. Both returnRestored; T1 becomes active andmemory_recallreturns X. The rejection file remains byte-identical. - Control:
force=trueon S1 correctly omits T1 and recall finds nothing.
This is a remaining pre-existing bypass, not a regression introduced by the force fix. The assumption in the new comment that only force republishes deleted rows does not hold for unaudited rollback followed by rejection of a later copy. Please enforce the content-hash rejection floor on the caller-owned rows published by every mode, including merge's final reconciliation, while preserving the existing foreign-live-row contract. Add an older-identity regression alongside the same-identity forget test.
Validation: existing undo/ownership suites 26 pass, 102 assertions. Independent rejection-invariant probe: 2 fail (default/merge), 1 pass (force); tool responses, recall results and unchanged tombstone bytes were observed in each case. Initial row/snapshot state was a synthetic fixture; no live-host or production-incident claim. No tracked source changed in my checkout. Happy for you to narrow or defer this residual explicitly if the intended scope differs.
There was a problem hiding this comment.
Reviewed head 181328e. Contract #307 (abogartz authored + agent:ready adopted; spec hash 9cae4ed762e6a814 == anchor osi-spec-hash comment 6645262222 — frozen). Closes footer present.
Criterion 1 — RED: "scenario test — store a decision, snapshot its day file, memory_forget it, then memory_undo with force=true: the row comes back recallable. Fails on main for exactly that reason."
Evidence: differential at merge-base 06e4e28 with the PR's test/undo.test.ts over base source: 3 tests fail — force omits a forgotten row instead of reviving it (Expected -1 / Received +3: the tombstoned row republished), merge does not resurrect a forgotten row either; force omits it (#307) (Expected -3 / Received +1: base force revived row(1)), and the ordinary-deletion test (Expected -0 / Received +2: rejected rows present). All fail for exactly the resurrection reason, none for another.
Criterion 2 — GREEN: "force omits the tombstoned row, names it in rejectedOmitted, and the row stays non-recallable; a force undo of a snapshot containing rows deleted by ordinary means still restores those; blocklisted rows stay hidden in every mode; the tombstone evidence line is byte-identical before and after."
Evidence per clause at head:
- Omits + names:
restoreSnapshotreads tombstones inside the restore lock only in force mode (src/store/undo.ts:281-284), filters snapshot lines by exactch = contentHash(content)(src/store/undo.ts:355-363); test assertsrejectedOmittedequals the two rejected ts values. - Non-recallable:
expect(await loadAll()).toHaveLength(0)and ts-list equality in test/undo.test.ts. - Ordinary deletions restored: second new test — row 3 (no audit, no tombstone) comes back while two rejected rows stay out.
- Blocklist: existing
test/undo.test.tsblocklist test +test/undo-ownership.test.tspass unchanged in the full run. - Byte-identical tombstone file:
expect(readFileSync(rejectedFile())).toEqual(tombstonesBefore). - Exact-match-only verified against the module:
tombstones(): Promise<Tombstone[]>withch(src/store/tombstones/tombstone.ts:252,113) andcontentHash= sha1[0:12] (src/evidence/record.ts:139-141) — same hash, no fuzzy omission.
Criterion 3: "No existing assertion weakened; bun run typecheck && bun run lint && bun run test green, bun run test:e2e since src/ changed."
Evidence: the one rewritten assertion (expect(lines()).toEqual([row(1)]) → rejectedOmitted + lines()==[] + loadAll()==0) pins the contract decision #214 A explicitly overturned, with strictly stronger assertions; all other test changes additive, no skip, no tolerance change. Measured at head: typecheck exit 0; lint 229 files, no fixes applied; test 1011 pass / 19 skip / 0 fail (12549 expect calls); test:e2e 30 pass / 0 fail.
Final gate re-check at filing: gh pr view 312 --json headRefOid → 181328e (unchanged); gh pr checks → lint pass, test pass, test-windows pass, smoke pass.
Findings: none P0/P1. Nit (non-blocking, pre-existing surface): the omission applies to the admin reader too — deliberate and documented in the code comment (undo.ts:385-390), consistent with "a rejection is absolute, not per-repository".
Human merges.
There was a problem hiding this comment.
My APPROVED review 5779640204 at this head is superseded. WhollyMindless's CHANGES_REQUESTED 5779615356 is open at head 181328e and its F1 holds against the tree; the block is WhollyMindless's to clear, and whether the residual is fixed here or deferred is the owner's scope call.
F1 verified — agreed, with my own reproduction. Mechanism, read at this head: src/store/undo.ts:281-284 sets rejected only for mode === "force"; the tombstone filter at :357-365 therefore never runs for default/merge. The only guard republishing snapshot rows is auditedDeletions() (:196-205), keyed on row identity (original_ts), while rejection is keyed on content. A force-undo rollback writes no deletion audit, so an older identity of a later-rejected value passes both guards.
Probe (temporary fixture at this head, same route as the reported repro):
- DEFAULT:
restored=true,loadAll→["secret X"], tombstone file byte-identical. - MERGE:
restored=true,loadAll→["secret X"]. - FORCE control:
restored=true,rejectedOmitted=["2026-01-01T00:00:01.000Z"],loadAll→[].
So the tool description's promise that no mode resurrects rejected content is false for default/merge via unaudited-rollback-then-reject, exactly as reported. This is a pre-existing bypass route, not a regression of the force fix; the force-mode fix itself, the ordinary-deletion recovery, and the byte-identical tombstone guarantee all verified correct in my prior review and remain so.
Fix direction as proposed: enforce the content-hash rejection floor on rows published by every mode (including merge's final reconciliation at :381-383), preserving the foreign-live-row contract, plus an older-identity regression test alongside the same-identity forget test.
Re-check at filing: headRefOid 181328e (unchanged since review); checks lint pass, test pass, test-windows fail, smoke pass.
|
Correction to my COMMENTED review above. Its re-check line read "test-windows fail" — that was copied from #308 without measuring this PR. Measured at filing, #312 CI is fully green: lint pass, test pass, test-windows pass, smoke pass (gh pr checks 312, 2026-11-05T04:16Z). Head and verdict unchanged: my APPROVE is superseded by WhollyMindless's open CHANGES_REQUESTED 5779615356, whose F1 I reproduced independently. |
F1: default (check) and merge restores keyed the deletion audit on row identity, so an older snapshot identity carrying a value a human later rejected through a different row escaped the audit and was republished. Read the rejection tombstones in every mode and apply the content-hash floor to the caller-owned rows each mode publishes (merge's final reconciliation included), while foreign rows stay carried verbatim. Add an older-identity regression test.
|
Rework at head F1 — default and merge undo restoring an older copy of a rejected value. The rejection floor now reads the tombstones in every mode and filters the caller-owned rows each mode publishes, not just force. Regression test Proof (measured): |
There was a problem hiding this comment.
Reviewed at head bb55b23d1b9934ef05e8ba5c8ac896c8742c0680 (diff key 3a29db460b92bb8efcfd4d7476c7a66dfc0dfb6d19c9cd2a288b776bd1155629).
Verdict: COMMENTED — not an approve while WhollyMindless's CHANGES_REQUESTED 5779615356 stands. It is their latest review and only they can clear it. The finding it rested on (F1) is resolved at this head; evidence below. Had no human block stood, this would be an APPROVE.
Contract
Closes #307 (abogartz authored, agent:ready applied by abogartz — trusted contract). Spec anchor: recomputed body hash 9cae4ed762e6a814 == newest osi-spec-hash: comment (2026-11-04T23:38:10Z) — frozen.
F1 resolution (the CR's finding)
Fix direction from the CR: content-hash rejection floor in every mode incl. merge reconciliation. Implemented:
restoreSnapshotreads rejection tombstones inside the lock:src/store/undo.ts:284(new Set((await tombstones()).map(t => t.ch))).- Published caller-owned rows
pubOwnare computed for every mode — snapshot rows for check/force, the merge superset (current versions of snapshot keys + current rows the snapshot never saw) for merge:src/store/undo.ts:355-358. - The floor
contentHash(content) ∈ rejected → omit + report in rejectedOmittedruns onpubOwnbefore publishing, in every mode:src/store/undo.ts:373-381. Exactch = contentHash(content)match only; no fuzzy omission. - Regression test
default and merge undo do not resurrect a rejected value through an older identity (#307 F1)(test/undo.test.ts:414) encodes the exact CR scenario: force rollback drops T1 with no deletion audit, a later copy T2 is forgotten and tombstones the value, then check- and merge-undo of the older snapshot both omit T1 (rejectedOmitted ["2026-01-01T00:00:01.000Z"],loadAll0).
Acceptance criteria (#307, verbatim) with evidence
- "RED: scenario test — store a decision, snapshot its day file,
memory_forgetit, thenmemory_undowithforce=true: the row comes back recallable. Fails on main for exactly that reason." — Measured at merge-base06e4e28with the PR's test file: 4 fail / 17 pass;force omits a forgotten row instead of reviving itfails for the resurrection reason; the F1 test fails (rejectedOmittedundefined attest/undo.test.ts:450— no floor exists). - "GREEN: force omits the tombstoned row, names it in
rejectedOmitted, and the row stays non-recallable; a force undo of a snapshot containing rows deleted by ordinary means still restores those; blocklisted rows stay hidden in every mode; the tombstone evidence line is byte-identical before and after." — Measured at head: 1012 pass / 19 skip / 0 fail (12564 expect).force reports rejectedOmitted, leaves the tombstone file byte-identical, and still restores ordinary deletionsassertsrejectedOmitted= both rejected ts,loadAll= only the ordinarily-deleted row, andreadFileSync(rejectedFile())equality before/after. Blocklist tests (undo.test.ts,undo-ownership.test.ts) pass unchanged. - "No existing assertion weakened;
bun run typecheck && bun run lint && bun run testgreen,bun run test:e2esincesrc/changed." — Measured at head: typecheck exit 0; lint 229 files clean; test 1012/19/0; e2e 30/0 (256 expect). One assertion changed:merge does not resurrect a forgotten row either; force doesflipped to the #214 A contract with stronger assertions (rejectedOmitted+loadAllnon-recallability) — the ticket explicitly sanctions this flip. No.skip, no widened tolerance, no raised timeout.
Fix-direction surface: check-mode refusal and the memory_undo description updated in src/tools/undo.ts (ticket names src/index.ts, its pre-#168-split location; the contract text now sits where agents read it).
Findings
- No P0/P1.
- nit: foreign rows are appended verbatim and bypass the floor (
src/store/undo.ts:397). Consistent with #153 — a restore must not delete another repository's live rows, and rejected content is hidden at read time by the tombstone filter. The write-site comment "applies to every reader" is exact for admin (curForeignempty) and slightly overstates for non-admin foreign lines. Not blocking.
Final gate (same breath as filing)
gh pr view 312 --json headRefOid → bb55b23d1b9934ef05e8ba5c8ac896c8742c0680 (unchanged from reviewed head). gh pr checks 312: lint pass, test pass, test-windows pass, smoke pass.
@WhollyMindless your CR rests on F1; F1 is fixed at bb55b23 as evidenced above, with your scenario as a permanent regression test. The block is yours to clear — re-review or dismiss at your discretion. With CI 4/4 and the contract fully evidenced, I see no remaining defect on my side.
WhollyMindless
left a comment
There was a problem hiding this comment.
Approved at bb55b23d1b9934ef05e8ba5c8ac896c8742c0680. F1 is resolved; this supersedes my changes-requested review of 181328e. I raised #214's underlying policy question, but did not author this implementation.
Independently reran the original older-identity probe through memory_undo, memory_forget, and memory_recall: default, merge, and force now all omit the rejected value, report it, and leave recall empty with the tombstone file byte-identical. The floor runs after merge reconciliation on caller-owned rows; foreign live rows remain preserved. Existing ordinary-deletion recovery, blocklist, divergence and ownership controls still pass.
Validation on Windows / Bun 1.4.4: 30 pass, 0 fail, 141 assertions across the independent probe and undo/ownership suites. The new checked-in regression is additive; no existing assertion weakened in this rework. All four hosted checks pass at this head, and #307's contract is unchanged. No further code blocker from me; merge timing remains the maintainer's decision. Synthetic stores only; no live-host claim.
There was a problem hiding this comment.
APPROVE at head bb55b23d1b9934ef05e8ba5c8ac896c8742c0680.
WhollyMindless's CHANGES_REQUESTED 5779615356 (raised at 181328e) is cleared by their own APPROVED 5780389751 at this head (2026-11-05T05:42:16Z), with independent probe evidence matching my verification. My prior COMMENTED review 5780155465 stated the block was theirs to clear; it is cleared, so this review carries the corrected verdict at the same head.
Contract — #307 (abogartz authored and adopted; spec hash 9cae4ed762e6a814 recomputed this pass == anchor comment of 2026-11-04T23:38:10Z, frozen). Acceptance verbatim, per-criterion evidence:
- "RED: scenario test — store a decision, snapshot its day file,
memory_forgetit, thenmemory_undowithforce=true: the row comes back recallable. Fails on main for exactly that reason."
— Evidenced at merge-base06e4e28: 4 fail / 17 pass, failure reason is the stated resurrection (rejectedOmittedundefined atundo.test.ts:450, tombstoned row recallable). - "GREEN: force omits the tombstoned row, names it in
rejectedOmitted, and the row stays non-recallable; a force undo of a snapshot containing rows deleted by ordinary means still restores those; blocklisted rows stay hidden in every mode; the tombstone evidence line is byte-identical before and after."
— Evidenced at head: force omits and names via the content-hash rejection floor applied to pubOwn in every mode (undo.ts:284tombstones read,:355-358merge superset,:373-381floor); regression testundo.test.ts:414encodes the WhollyMindless scenario exactly; ordinary-deletion recovery, blocklist and tombstone byte-identity controls green inbun run test(1012 pass / 19 skip / 0 fail). Independently re-verified by WhollyMindless on Windows / Bun 1.4.4: 30 pass, 0 fail, 141 assertions, tombstone file byte-identical. - "No existing assertion weakened;
bun run typecheck && bun run lint && bun run testgreen,bun run test:e2esincesrc/changed."
— Measured at head: typecheck 0, lint 229 clean, test 1012/19/0, e2e 30/0. The updated test is the #214 accept-A contract flip with stronger assertions; no.skip, no widened tolerance.
Findings: no P0/P1. Nit (carried, non-blocking): foreign live lines bypass the floor at undo.ts:397 — consistent with #153 ownership semantics, read-time tombstone filter covers.
Final gate re-check, verbatim (filed in one breath before this review):
$ gh pr view 312 --json headRefOid
{"headRefOid":"bb55b23d1b9934ef05e8ba5c8ac896c8742c0680"}
$ gh pr checks 312 --json name,bucket
[{"bucket":"pass","name":"lint"},{"bucket":"pass","name":"test"},{"bucket":"pass","name":"test-windows"},{"bucket":"pass","name":"smoke"}]
Head reviewed equals head at filing; all four required contexts pass. Human merges.
|
🎉 This PR is included in version 0.15.36 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Closes #307
Implements accepted decision #214 A: rejection is absolute —
memory_undoforce omits tombstoned values.Change
restoreSnapshot(src/store/undo.ts) consulted no rejection tombstone in any mode: force reinstated valuesmemory_forgettombstoned, leaving the store holding an active row it also records as rejected (#35's stated property, contradicted). FORCE now reads the tombstones inside the restore lock — like the deletion audit, so a forget that finished just before the restore is honoured — and omits snapshot rows whose content hash carries one. Omissions are reported in a newrejectedOmittedfield onRestoreResult, separate fromdeletedOmitted: a deliberately-deleted row stays force-recoverable, a rejected one is not. The tombstone file itself is read-only to a restore; mis-forget recovery stays human (lift the tombstone, then restore).src/tools/undo.ts(where thememory_undodescription and check-mode refusal live since the #168 split — the ticket namedsrc/index.ts, its pre-split location; the contract is now stated where agents read it): description states the absolute-rejection rule, the check-mode refusal says rejected rows stay omitted in every mode, and a force restore names omitted rejected rows with their ts.Matching is exact
ch = contentHash(content)only — the near-match sketch belongs to the write gate; fuzzy-omitting a restore would drop rows no human rejected.Acceptance criteria — evidence
force omits a forgotten row instead of reviving it; it stays non-recallable— seed a row, snapshot its day file,memory_forgetit,memory_undowithforce=true. At merge-base06e4e28both new tests fail for exactly the stated reason (diff showed the tombstoned rows republished). 2 fail on main.rejectedOmitted, and the row stays non-recallable (loadAllcheck); a force undo of a snapshot containing rows deleted by ordinary means (no audit, no tombstone) still restores those (second new test: ordinarily-deleted row comes back, two rejected ones do not); blocklisted rows stay hidden in every mode (existingtest/undo.test.ts+test/undo-ownership.test.tspass unchanged); the tombstone evidence file is byte-identical before and after (asserted viareadFileSync(rejectedFile())).merge does not resurrect a forgotten row either; force doespinned the exact behavior decision Policy: define force-undo behavior for forgotten, still-rejected values #214 A overturned; it is updated to the new contract with stronger assertions (rejectedOmitted+ non-recallability), not weakened. No other assertion changed, skipped, or loosened.Commands run (measured)
bun run typecheck— exit 0bun run lint— 229 files checked, no fixes appliedbun run test— 1011 pass, 19 skip, 0 fail (12549 expect calls)bun run test:e2e— 30 pass, 0 fail (src/ changed)Deliberately unchanged
deletedOmittedsemantics and the check/merge refusal logic: untouched;rejectedOmittedis empty in check and merge, which never republish deletions.src/store/tombstones/*): read-only consumer added; no tombstone is ever written, edited, or deleted by a restore.undo.tsnotes the historical byte-for-byte admin restore now carries this exception).