Skip to content

fix(update): metadata fidelity and truthful partial results (#154 #155) - #158

Merged
abogartz merged 11 commits into
abogartz:mainfrom
WhollyMindless:fix/security-154-155
Oct 29, 2026
Merged

abogartz merged 11 commits into
abogartz:mainfrom
WhollyMindless:fix/security-154-155

Conversation

@WhollyMindless

Copy link
Copy Markdown
Contributor

What this is

Two defects in the same tool — memory_update — from the 2026-10-28 adversarial batch, one review. #154: a prose edit silently discarded the target's metadata (an update of an [via import] row laundered its provenance marker, issue link, and keywords out of existence). #155: a failure in the write_promoted audit line AFTER the append made the tool declare "Nothing was written" while the replacement row sat on disk un-superseded — two active versions of the row, and a retry reported "Duplicate ignored" about a write that had actually happened. Both probes are verified red on ed5ecde (0.14.14, current main, rebased over the just-merged #157); probes land first, fix second.

#154 — an update is built FROM the row it replaces

The replacement candidate is now { ...args-named fields, kw: args.kw ?? target.kw, tags: target.tags, issue: target.issue } — omitted metadata carries over, an explicit kw still replaces (or clears with []), pinned both ways. The tool description says so. Deliberately no trust-promotion semantics: a prose edit never upgrades an unverified row's standing; it just stops destroying the marker. (Same preservation principle #129 applied to viewer edits; UpdateArgs gains no new fields.)

#155 — post-append failures can no longer lie

The leak's exact anatomy: gates.ts appends, then awaits rec("write_promoted") — and the entry's catch still asserted "only the fail-closed lock timeout throws here", a premise that died when the gate began auditing after the append. 156e887 already fixed this shape for merge_review; this is its memory_update twin.

  • runWriteGate: everything after the append is durable state, so the audit rec is wrapped and the failure rides the outcome as GateOutcome.evidenceError. Pre-append faults keep throwing — there, nothing was written. For plain writers (remember/capture) this converts a mid-write crash into a truthful "Remembered" (the row IS stored); only the audit line is missing, visible via memory_evidence.
  • memory_update: on evidenceError it still completes the supersession (markSuperseded is first-call-wins, so completing in the failure path is safe) and reports the merge_review PARTIAL shape; a markSuperseded throw itself gets the same PARTIAL; the catch's stale comment is corrected and a mutated flag makes its "Nothing was written" claim conditional on it being true.
  • Retry-after-partial: naming a superseded row whose visible active successor already carries exactly this content now returns Duplicate ignored: ... was already updated to exactly this content (<ts>) instead of a dead-end not_found — the chain walk stays inside the caller's reader-visible rows.
  • Fail-closed preserved at every pre-write point: lock timeout, the P1: unresolved named sessions publish private memories into the last repo or globally #152 choke-point refusal (this branch is rebased over fix(security): an unresolved session has no write target (#152) #157 — its entry-level ownerless check is a pre-write return, untouched), pre-append evidence faults.

Boundaries

Evidence

  • Red at base: test/update-provenance.test.ts 1/2 red (metadata drop; explicit-kw-replaces control green), test/update-partial-failure.test.ts 1/2 red (the false "Nothing was written" + two-active-rows; pre-mutation fail-closed control green) — on 91f7a56 and again on ed5ecde.
  • Green at fix: 4/4. Full local suite 604 pass / 10 skip / 2 fail — the 2 reds are containment.test.ts symlink-EPERMs, this machine's unprivileged-Windows environment per test/containment.test.ts: 2 of 7 symlink tests miss the file's win32 skip guard and EPERM on unprivileged Windows #147 (unrelated files; green on ubuntu CI).
  • tsc --noEmit clean; bun run lint (the CI gate) exit 0.

Related: #157 (merged — the write-scope twin in the same entry), #152 (its choke-point refusal this branch defers to), 156e887 (merge_review PARTIAL precedent), #129 (viewer-edit metadata preservation).

Closes #154
Closes #155

…artial (abogartz#154 abogartz#155)

Red at 91f7a56: a prose edit drops the target's import tags/issue/kw; a write_promoted audit failure after the append makes memory_update claim nothing was written while the replacement sits on disk un-superseded (two active rows). Controls green: explicit kw replaces rather than unions, pre-mutation failures stay fail-closed.
…#154 abogartz#155)

memory_update's replacement candidate is built FROM the row it replaces: tags and issue carry over (an update of an imported row no longer launders away its provenance marker or issue link), and kw keeps target.kw when omitted while an explicit kw still replaces. A prose edit is not a metadata reset.

runWriteGate no longer throws AFTER the append when the write_promoted audit line fails - the row is durable at that point, and a throw made memory_update's catch declare 'Nothing was written' while the replacement sat on disk un-superseded (two active rows; retry said 'Duplicate ignored' about a write that happened). The failure rides the promoted outcome as GateOutcome.evidenceError; pre-append faults keep throwing fail-closed. The update entry completes the supersession on that outcome (markSuperseded is first-call-wins, safe to complete), reports the merge_review PARTIAL shape from 156e887, catches a markSuperseded throw the same way, and gains a duplicate-aware resolution: naming a superseded row whose active successor already carries exactly this content reports the duplicate verdict instead of a dead end. Pre-write failures - lock timeout, the 152 choke-point refusal, pre-append evidence faults - stay fail-closed with the truthful Nothing-was-written message; the catch's stale 'only the lock timeout throws' premise is corrected.

Rebased onto ed5ecde (0.14.14): abogartz#157's ownerless-writer refusal is a pre-write entry check and is untouched - this fix keeps it fail-closed in the catch's unmoved branch.
@WhollyMindless

Copy link
Copy Markdown
Contributor Author

@abogartz Review of a88e65d: #154 looks fixed, but I recommend holding #158 for two remaining #155 failure paths.

The original post-append audit-failure test now passes and supersession completes. Metadata preservation also passes, including my additional recall-provenance and explicit kw:[] controls. The broader failure handling still has two reproducible gaps:

1. P2 — retirement failure leaves two active versions, and the suggested retry cannot recover.
Inject an I/O exception from markSuperseded after the gate appends the replacement. The tool correctly says PARTIAL. Remove the fault and repeat the identical update. The original is still active, so the new stale-target chain branch is never reached; GATE-3 collapses against the already-appended replacement and the tool returns Duplicate ignored. Both versions remain active.

first: PARTIAL ... retiring <old> failed ... Re-running this update reports the duplicate.
retry: Duplicate ignored: context/planning
active: ["...every evening", "...every morning"]

Please make this incomplete update recoverable (or return accurate, actionable recovery guidance instead of implying that a duplicate completes it). Preserve the deliberately pinned behavior for an unrelated pre-existing duplicate: simply retiring the target on EVERY collapsed outcome would break that contract. The fix needs to know this replacement belongs to this interrupted update.

2. P2 — “pre-append” is not “pre-mutation”: gate neutralization still produces a false no-op report.
runWriteGate can persist drift/canonical supersession markers before it appends a replacement. I seeded queue backend redis, a matching canonical registry entry for backend=postgres, then updated toward queue backend postgres. Throwing at the subsequent record("superseded_by") leaves the original retired on disk, no replacement, and zero active rows, while the update returns:

memory_update blocked: EIO: injected neutralization audit failure Nothing was written.

The new outer mutated flag is set only after runWriteGate returns a promoted outcome, so it misses this earlier durable mutation. Please propagate mutation information from the gate's supersession steps as well and report the persisted retirement truthfully. This behavior predates the PR, but the new catch comment and “fail-closed at every pre-write point” claim explicitly retain the incorrect assumption.

Both are deterministic fault-injection tests: real gate/store/tool execution, with exceptions injected only at the specified boundary. They do not claim that this machine suffered actual disk faults.

Verification: your two new test files + existing update-targeting suite + my five probes = 24 pass / 2 fail. Controls verify a true gate_start failure leaves every row unchanged, omitted metadata survives while explicit empty keywords clear, and retry cannot follow a supersession into a foreign repository. No product code was modified or pushed.

Runnable additional probes (save at repository root as review-158-extra.test.ts)

Run bun test ./review-158-extra.test.ts. Expected on this head: 3 pass / 2 fail.

import { afterEach, beforeEach, expect, spyOn, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { basename, dirname, join, resolve } from "node:path";
import { loadPlugin, type LoadedPlugin } from "./test/harness.ts";
import * as memory from "./src/memory.ts";
import * as evidence from "./src/evidence.ts";
import { canonicalFile } from "./src/config.ts";
import { formatLine } from "./src/logfmt.ts";
import { resetSessionScopes, resolveRepo, setRepoScope } from "./src/repokey.ts";
import { resetState } from "./src/state.ts";
let root: string, a: string, b: string, p: LoadedPlugin;
beforeEach(async () => {
  root = mkdtempSync(join(tmpdir(), "osi-review158-"));
  a = join(root,"a"); b = join(root,"b"); mkdirSync(a); mkdirSync(b);
  process.env.OPENCODE_MEMORY_DIR = join(root,"memory"); process.env.OPENCODE_COMMANDS_DIR = join(root,"commands");
  resetState(); resetSessionScopes(); setRepoScope(null); p = await loadPlugin(a);
});
afterEach(async () => {
  await p.cleanup(); resetState(); resetSessionScopes(); setRepoScope(null);
  delete process.env.OPENCODE_MEMORY_DIR; delete process.env.OPENCODE_COMMANDS_DIR;
  if(dirname(resolve(root))!==resolve(tmpdir())||!basename(root).startsWith("osi-review158-"))throw new Error("Unexpected cleanup target");
  rmSync(root,{recursive:true,force:true,maxRetries:5,retryDelay:20});
});
async function seed(content: string, dir=a, extra: Record<string,unknown>={}) {
  const scope=resolveRepo(dir);
  return memory.appendMemory({type:"context",scope:"planning",content,status:"open",repo:scope.key,repoPath:scope.path,...extra});
}
const ctx={sessionID:"ses-a",id:"review"};
const update=(query:string,content:string,extra:Record<string,unknown>={})=>p.tools.memory_update.execute({type:"context",scope:"planning",query,content,status:"open",...extra},ctx);

test("retry after failed retirement must recover the two active versions",async()=>{
  const old=await seed("Plan to prune aged queue entries every evening");
  const next="Plan to prune aged queue entries every morning";
  const spy=spyOn(memory,"markSuperseded").mockImplementation(async()=>{throw new Error("EIO: injected retirement write failure");});
  let first: {content:string};
  try {first=await update(old,next);} finally {spy.mockRestore();}
  expect(first.content).toContain("PARTIAL");
  expect((await memory.loadAll()).filter(memory.isActive)).toHaveLength(2);
  const retry=await update(old,next);
  const rows=(await memory.loadAll()).filter(memory.isActive);
  console.log("retirement-failure",JSON.stringify({first:first.content,retry:retry.content,active:rows.map(m=>m.content)}));
  expect(rows).toHaveLength(1);
  expect(rows[0].content).toBe(next);
});

test("an audit failure after gate neutralization must not claim no mutation",async()=>{
  const old=await seed("queue backend redis");
  writeFileSync(canonicalFile(),formatLine({ts:"2026-01-01T00:00:00.000Z",type:"canonical",scope:"planning",entity:"backend",value:"postgres",source:"fixture"})+"\n");
  const record=evidence.record;
  const spy=spyOn(evidence,"record").mockImplementation(async(...args:Parameters<typeof record>)=>{
    if(args[0]==="superseded_by")throw new Error("EIO: injected neutralization audit failure");
    return record(...args);
  });
  let result: {content:string};
  try {result=await update(old,"queue backend postgres");} finally {spy.mockRestore();}
  const rows=await memory.loadAll();
  expect(rows.find(m=>m.ts===old)?.superseded_by).toBeDefined();
  console.log("gate-neutralization-failure",JSON.stringify({result:result.content,rows:rows.map(m=>({content:m.content,superseded_by:m.superseded_by})),active:rows.filter(memory.isActive).length}));
  expect(result.content).not.toContain("Nothing was written");
});

test("control: failure at gate_start truly leaves all rows untouched",async()=>{
  const old=await seed("Original schedule");
  const before=await memory.loadAll(); const record=evidence.record;
  const spy=spyOn(evidence,"record").mockImplementation(async(...args:Parameters<typeof record>)=>{
    if(args[0]==="gate_start")throw new Error("EIO: injected initial audit failure");
    return record(...args);
  });
  let result:{content:string};
  try{result=await update(old,"Replacement schedule");}finally{spy.mockRestore();}
  expect(result.content).toContain("Nothing was written"); expect(await memory.loadAll()).toEqual(before);
});

test("metadata survives recall and an explicit empty kw clears aliases",async()=>{
  const old=await seed("Plan to prune aged queue entries every evening",a,{tags:["import","auto-capture"],issue:"SOURCE-123",kw:["retention"]});
  const result=await update(old,"Plan to prune aged queue entries every morning",{kw:[]});
  expect(result.content).toContain("Updated");
  const rows=(await memory.loadAll()).filter(memory.isActive); expect(rows).toHaveLength(1);
  expect(rows[0].kw??[]).toEqual([]); expect(rows[0].issue).toBe("SOURCE-123");
  const recalled=await p.tools.memory_recall.execute({scope:"planning"},ctx);
  expect(recalled.content).toContain("[via auto-capture+import]");
});

test("retry cannot follow a supersession chain into another repository",async()=>{
  const old=await seed("A's old row"); const foreign=await seed("B's private row",b);
  await memory.markSuperseded(old,{superseded_by:foreign,reason:"fixture"});
  const before=await memory.loadAll(); const out=await update(old,"B's private row");
  expect(out.content).not.toContain("Duplicate ignored"); expect(out.content).not.toContain(foreign);
  expect(await memory.loadAll()).toEqual(before);
});

abogartz and others added 4 commits October 28, 2026 14:48
abogartz#155 follow-up review)

Eleven probes red at 59f537e + one green control re-pinning the abogartz#154 carry:
- markSuperseded's false return was printed as a clean Updated: the GATE-2
  drift/canonical passes could stamp the update's own target (chain-id pointer
  the retry cannot walk), and a parallel non-locking writer could retire it
  mid-call - both end in a retry claiming 'Nothing was written' about a write
  that happened (merge_review checks exactly this boolean; memory_update did
  not),
- evidenceError = (err as Error).message turned a messageless or non-Error
  audit fault into a falsy lie,
- the successor-duplicate verdict compared RAW retry prose against the
  REDACTED successor, dead-ending exactly the retry it exists for, claimed
  'exactly' over metadata the retry still changes (dropping the kw edit),
  wrote no evidence line, and left a supersede-fault retry with two active
  rows forever,
- the abogartz#129 five-field carry stopped at three: a prose edit settled open
  frontier rows and re-housed global rows into the editor's repo,
- GATE-3's byte-exact rule made metadata-only updates impossible.
…artz#155)

The follow-up review found the replacement row durable on every fault path
but the VERDICT lying on four of them, and the carry stopping at three of
the five fields the abogartz#129 viewer precedent established:

- GATE-2's drift and canonical passes could retire the update's OWN target
  first-call-wins before the update's markSuperseded ran: the tool printed
  'Updated (superseded T)' about a retirement it did not perform, the
  chain-id pointer was not walkable, and the retry dead-ended with 'no
  active row ... Nothing was written' about a write that had happened.
  The update's target now retires only in the update's hand (the same
  principle GATE-3 applies to rivalry). markSuperseded's false return is
  finally CHECKED (the merge_review precedent at 156e887): a target retired
  by a parallel non-locking writer mid-call reports PARTIAL, not Updated.
- evidenceError = (err as Error).message turned a messageless Error or a
  non-Error rejection into a falsy LIE - a clean 'Updated' with no
  write_promoted line. It is now always a truthful string, and callers test
  presence, not truthiness.
- The successor-duplicate verdict compared RAW retry prose against the
  REDACTED successor (dead-ending the exact retry abogartz#155 added it for),
  claimed 'exactly' over metadata the retry still changes, and wrote no
  evidence line. It now scrubs before comparing, demands metadata be
  restated (a retry that also names new kw continues against the chain
  head instead of having the edit dropped), and records dedup_collapse.
- A retry that COLLAPSED while the row it names was still active (the
  supersede step of a PARTIAL attempt never landed) printed 'Duplicate
  ignored' and left two active rows forever. The outcome now carries
  collapsedWith and the retry COMPLETES the retirement in the survivor's
  favor - idempotent, converges to one active row.
- The carry completes to five fields: status (an open frontier row stays
  open across a prose edit instead of silently becoming settled and
  vanishing from the frontier) and repo (updating a global row no longer
  re-houses it into the caller's repository, reversing README's
  follow-you-everywhere promise with a typo fix).
- GATE-3's byte-exact rule made a metadata-only update impossible (same
  prose + new kw = 'Duplicate ignored', edit dropped). Same prose with
  different metadata against the row being replaced is now an EDIT.

Wording: PARTIAL names memory_undo merge/force (not bare 'recovers'); the
tool description and README carry the completed contract. F5 disclosed on
the PR: credential-shaped CARRIED tags still dead-end a retry - fixing it
means scrub-or-reject on inherited metadata, which is abogartz#74's namespace.
@WhollyMindless

Copy link
Copy Markdown
Contributor Author

@abogartz Fix round for the HOLD recommendation — the confirmed P1 and every actionable finding from the review of a88e65d are now addressed, probes-first.

42bea18 (probes). test/update-supersede-truth.test.ts: 12 contracts, 11 red at 59f537e + 1 green control re-pinning the #154 carry. The probeB/B2 shape from the review reproduces exactly at that head ("Updated pattern in ctl (superseded ...)" with reason=drift on the target; the retry then answering "no active pattern row ... Nothing was written").

7d9aa61 (fixes), finding by finding:

  • F1 (P1 — the lying "Updated"): two root causes, both fixed. (a) GATE-2's drift/canonical passes could stamp the update's own target first-call-wins before the update's markSuperseded ran — leaving a chain-id pointer the retry cannot walk while the tool printed "(superseded T)" about a retirement it did not perform. The target now retires only in the update's hand (same principle GATE-3 already applies to rivalry: the target is never a contender). (b) markSuperseded's boolean — checked by merge_review since 156e887, ignored here — is now checked: a target retired by a parallel non-locking writer mid-call reports PARTIAL naming the foreign successor, never a clean "Updated". The retry converges to exactly one active row.
  • F2: evidenceError = (err as Error).message made a messageless Error / non-Error rejection a falsy lie; now always a truthful string, and the caller tests presence (!== undefined), not truthiness.
  • F3: the successor verdict now compares redactSecrets(args.content) (rows are stored scrubbed — the raw-vs-redacted compare dead-ended exactly the retry it exists for), demands metadata be restated (a retry naming new kw continues against the chain head instead of having the edit silently dropped), and writes a dedup_collapse line like every other verdict. The collapsed outcome carries collapsedWith, so a retry after a supersede-step fault completes the retirement in the survivor's favor instead of printing "Duplicate ignored" over two active rows forever.
  • F4: the carry completes to security: editing a repo-private memory in the viewer makes it global (high) #129's five fields — status (an open frontier row stays open across a prose edit) and repo/repoPath (a global row edited from one repository stays global for every other).
  • F6–F9 (P3s): GATE-3's byte-exact rule gets an update-only carve-out (same prose + different metadata is an edit, not a duplicate — the tool could previously never edit kw/status); PARTIAL wording names memory_undo merge/force; tool description + README updated to the completed contract; UpdateArgs.status documents the omit-keeps-standing rule (wire capture in boundaries.test.ts updated accordingly — intentional description addition).
  • F5 — deferred, disclosed: credential-shaped carried tags (inherited from the target, never typed by the caller) still dead-end a retry at credential_in_metadata. Fixing it means scrub-or-reject on inherited metadata, which is exactly Secrets already in the store are never scrubbed, and memory_export writes them verbatim #74's open namespace — I'd rather land that decision once, there.

Two existing pins flipped deliberately, as their own comments anticipated: the #125 ADVERSARIAL pin ("if collapsed updates are ever folded into a real supersede, this pin flips") now pins the fold, and the wire capture records the status description.

Full suite 631/631 green on Windows after merging main (d176654, v0.14.16) in; typecheck + lint clean.

One housekeeping ask: #143 is fixed and merged (via #156, verified comment on the issue) but still open — the PR body referenced it without a Closes keyword so linkage missed it. Could you close it when convenient? (My account is read-only upstream, can't close issues.)

One overlap: the GATE-4 promoted block. Both sides survive — abogartz#165's
noteAuthored bookkeeping lands first (synchronous, cannot throw), then
the never-throw audit wrap carrying evidenceError, so a post-append audit
fault still cannot escape as a throw from an update's write.
@WhollyMindless

Copy link
Copy Markdown
Contributor Author

main (e32327a, v0.14.17) crossed this branch mid-review — merged it in as d308742. One real overlap, resolved keeping both sides: the GATE-4 promoted block, where #165's noteAuthored bookkeeping now runs first (synchronous, cannot throw) ahead of this PR's never-throw audit wrap carrying evidenceError — so a post-append audit fault still cannot escape as a throw from an update's write, and the writing session still gets its riding-bytes attribution. src/index.ts auto-merged (their epoch work, our update-handler — disjoint regions). Full suite 636/636 green on the merge (their five new epoch tests included); typecheck + lint clean.

@abogartz abogartz left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First: what I verified myself, so this isn't taken on trust

  • 14 of your 16 new tests are red on main, and the two that stay green are the deliberate controls. I checked by reverting src/ to origin/main under your tests, not by reading your evidence section.
  • Full suite on this branch, on top of 0.14.17: 636 pass / 12 skip / 0 fail. That includes test/epoch.test.ts, so #162 and #165 are intact here — I was specifically looking for that, see the invariants below.
  • err instanceof Error && err.message ? err.message : String(err) — I'd have written String(err) and not thought twice. A messageless Error making evidenceError falsy would have resurrected the exact lie this field exists to kill, through the truthiness test. Good catch.
  • Skipping ctx.supersedesTs in the GATE-2 drift plan and the canonical plan is right, and it's a subtle one: first-call-wins means the gate would otherwise stamp the retirement and the tool would then print (superseded X) naming a retirement it didn't perform.
  • repo: target.repo ?? "global" — I came at this expecting a visibility widening and found the opposite. isVisibleTo treats !m.repo as visible to every reader, so the old behavior was the hazard: updating a legacy unstamped row re-housed a world-visible row into the caller's repo and silently narrowed it. Your comment is correct and I was wrong.
  • The flipped adversarial pin in update-targeting.test.ts is the fork the #125 pin predicted in its own comment. Noted as a deliberate fork, not a quiet weakening.

Requesting changes for one reason, with a second smaller one below it. Both are open to argument — if you think I've got either wrong, push back and say why, and tell me what evidence would settle it. I'd rather be corrected here than merge a shape that's right and merely looks wrong to me.

1. The collapse-completion drops the named row's metadata — the class of bug #154 exists to kill

GATE-3's new carve-out says same prose + different metadata is an edit, not a duplicate. That condition applies when the match is the update's own target. When the match is a different live row, the new completion retires the named target in that survivor's favor with no metadata condition at all.

I probed it against this branch (scratch test, not left in the tree):

memory_update(query = A, content = BETA)
  A: status=open,  issue=GH-9001, kw=[widget,arm64]
  B: status=settled, no issue, no kw

→ "Duplicate: pattern/revprobe already stands active as …094Z;
   …092Z was retired in its favor. Nothing new was written."

  survivor status: settled | issue: - | kw: -
  NAMED row had:   status=open  | issue=GH-9001 | kw=[widget,arm64]

The user asked to edit A. Afterwards A is retired and the row that stands carries none of its issue link, keywords, or open standing — so an open frontier thread silently leaves the frontier, and the metadata the call never named is destroyed anyway. That is #154's principle ("an update is built FROM the row it replaces") arriving inverted through the path added for #155.

The two rules also just disagree in the store: exact refuses to call same-prose-different-metadata a duplicate, while the completion treats same prose as sufficient to retire.

What would satisfy me, cheapest first — argue for a different one:

  • Gate the auto-retire on the same predicate you already wrote: sameStrList(target.kw, survivor.kw) && sameStrList(target.tags, survivor.tags) && target.issue === survivor.issue && (target.status ?? "settled") === (survivor.status ?? "settled"). On mismatch, report the duplicate without retiring and name both ids, so a human decides.
  • Or carry the target's metadata onto the survivor when they merge, which is more in the spirit of #154 and keeps convergence.
  • Or, if you'd rather keep the unconditional retire: make it say what it cost. …was retired in its favor (its open standing, issue GH-9001 and 2 keywords did not carry).

Where I might be wrong: if your position is "two active rows stating one fact is worse than losing the metadata of the redundant one, and convergence is worth the price," that is a coherent stance and I'd want it written down in the test comment and the tool message rather than only in this review. My objection is partly that the current message reads as a clean no-op — "Nothing new was written" — while an open thread just disappeared.

2. evidenceError is read in exactly one place

memory_update handles it. memory_remember (src/index.ts:485), import (:1094) and capture (:1775) ignore it and return a plain Remembered. The PR body justifies that as "only the audit line is missing, visible via memory_evidence" — but the missing thing is the audit line, so memory_evidence shows nothing for that write. The row is on disk with no evidence trail and the caller was told a clean success.

I'm not asking for a throw — throwing is what started this. Minimum: append the caveat to the reply (Remembered … (its audit line was not recorded: <err>)) or bump a distinct counter. There's no test for this path today; the spyOn(evidence, "record") technique you used would cover all three writers cheaply.

Invariants to keep intact while you rework this

This branch is the first one to sit on top of #162/#165, so these are the ones I'd hate to trade away:

  • A write the session authored must not bust its prompt cache. noteAuthored fires in runWriteGate before the audit rec, so your try block didn't disturb it — confirmed. Please keep it ahead of anything that can fail.
  • A removal or rewrite of a riding row must still bust. Your markSuperseded completions are removals, so they should bust, and that's correct behavior, not a regression to smooth over.
  • test/epoch.test.ts is green here today. If a rework makes any of its five #165 cases red, that's the signal to stop and talk rather than adjust the test.
  • #154's carry and #155's "never claim nothing was written over a durable row" both still hold across your full suite — nothing I ran contradicts them.

Not blocking

  • sameStrList is order-sensitive, so kw: ["a","b"] vs ["b","a"] counts as a metadata edit and appends a row. Conservative and safe, but worth one comment line so the next reader doesn't "fix" it into a set comparison.
  • The stale-query path does a second full loadAll() inside the update lock. Correct; just an extra read per retry.

Neither needs action. Nice work on the anatomy of #155 — the rec-after-append shape and the stale comment asserting a premise that had already died is a nasty one to find.

…he audit fault

Review point 1 - the collapse-completion retired the named row into ANY
survivor whose prose matched, so an update of an OPEN row with an issue
link and keywords onto prose a DIFFERENT live row held destroyed exactly
the metadata no call named, behind a 'Nothing new was written' message.
The fold now requires the survivor to already carry the named row's
status/issue/kw/tags - the same predicate GATE-3 uses to call
same-prose-different-metadata an edit - so the store's two rules agree.
On disagreement NOTHING retires: the message names both rows and what
differs, and a human (or an update on the survivor) decides. Two active
rows stating one fact beats one row that quietly lost its standing.
(The alternative stances - carry-forward onto the survivor, or the
cost-naming unconditional retire - were rejected for writing MORE
metadata fictions: carry invents whose kw wins on conflict, and the
unconditional retire still buries the open thread, one message later.)

Review point 2 - evidenceError had exactly one reader. memory_remember
(both reply sites) now appends '(its audit line was not recorded: ...)';
memory_import tallies unaudited rows and names the fault; auto-capture -
which has no reply to caveat - carries audit_error on its
auto_capture_* evidence line, and memory_init counts them in its record,
result and report. The row is durable on all of these; only the
visibility of the missing trail was at stake, which is memory_evidence's
whole purpose.

Not-blocking: sameStrList's order-sensitivity gets the comment line the
review asked for, so nobody 'fixes' it into a set comparison. Tally
shape pins updated for the new unaudited field.
@WhollyMindless

Copy link
Copy Markdown
Contributor Author

Both points accepted — the probes were written and confirmed red against d308742 first (4 red + 1 green control pinning the convergence path the guard must not break), then the fixes; they land together as c95c919 (single commit — reverting src/ under test/outcome-truth-audit.test.ts reproduces the red set exactly as you verified #158's first round).

1. The fold now carries the predicate. Option 1, because it's the one where the store's rules stop disagreeing: the completion retires only when the survivor already carries the named row's status/issue/kw/tags — literally the sameStrList-based predicate GATE-3 applies — and on disagreement nothing retires: the message names both rows and lists the fields that differ (status open vs settled; issue GH-9001 vs -; kw [widget, arm64] vs [-]), and a human decides. The other two options were rejected for writing MORE metadata fictions, not fewer: carrying forward needs a tie-breaker nobody can justify when both rows' metadata is real (whose kw wins a conflict?), and the unconditional-retire-with-cost still buries the open frontier thread one honest message later. "Two active rows stating one fact" is worse than the PARTIAL shape's two-active-rows only in count, not in information — nothing is destroyed, memory_update on the survivor is a one-step resolution, and the retry is a stable verdict rather than a step, so it stays honest on repeat. If you still prefer the carry, say so and I'll build it, but the predicate felt like your actual principle rather than your cheapest shape.

2. evidenceError now has four more readers.

  • memory_remember (both Remembered reply sites): appends (its audit line was not recorded: <err>).
  • memory_import: ImportTally.unaudited + first fault message — "N promoted rows landed without their write_promoted audit line (…); memory_evidence will miss them."
  • auto-capture: no reply exists to caveat, so the auto_capture[_compaction]_promoted line itself carries audit_error — the trail now records that the trail is incomplete.
  • memory_init (fourth writer, not in your list): counts unaudited into init_complete, the InitSummary, and the report line.

One discovery from building the capture probe, in the interest of the map: transcripts under 200 chars skip capture before the model call (silently, captureSession's thin-transcript floor), so the probe needed a realistically thick transcript — worth knowing if you ever probe capture outcomes and see nothing at all.

Non-blocking items: sameStrList got its order-sensitivity comment; the extra loadAll() in the stale-query path now also appears in the collapse-completion (it needs the survivor's live metadata for the predicate — same rare-path cost note applies).

Your invariants, checked on this head: noteAuthored still runs ahead of anything that can throw (the GATE-4 block order is untouched); the fold's markSuperseded remains a busting removal — the new mismatch path retires nothing and thus busts nothing, which is right; test/epoch.test.ts 23/23 green; 641/641 full suite (5 tally-shape pins updated for the new unaudited field — deliberate, the field is part of the import contract now), typecheck + lint clean.

@WhollyMindless

Copy link
Copy Markdown
Contributor Author

@abogartz Independent recheck of c95c919, Windows / Bun 1.4.4: substantial progress, but please keep the hold for the remaining cases below.

What now passes: all five probes from my earlier review, including retry after a failed retirement, the original single-target canonical-neutralization case, metadata/empty-keyword controls, and foreign-successor refusal. The new committed tests also verify the metadata-mismatch guard and audit-fault reporting for remember, import, and capture. Full committed suite: 641 pass / 12 skip / 0 fail; typecheck passes; lint exits 0 (warnings remain). All four CI checks are green on this head. These are real fixes, not just replies to the review.

Three additional probes expose two remaining areas of the same #154/#155 work. No new issue needed.

1. P2 — collapse-completion still compares an incomplete, pre-edit state

At src/index.ts:790, the guard compares target metadata to the survivor. It does not compare the requested replacement (args.kw ?? target.kw, args.status ?? target.status) or preserve the target's repository visibility.

Explicit keyword edit is silently consumed: seed A with old prose and kw:["old-alias"], and B with the requested new prose and the same old keyword. Call update on A with B's prose and kw:["new-alias"]. The guard passes, retires A into B, and reports was retired in its favor. Nothing new was written. The only active row still has old-alias; the requested edit never landed. Please compare the effective requested metadata before deciding the fold satisfies the update, or explicitly refuse the fold without retiring the source. The same old-target comparison also omits an explicitly requested status change (the supplied probe exercises keywords).

Global row disappears from other repositories: seed global A, plus repo-A-private B with the requested prose and matching status/tags/issue/kw. Updating global A collapses into private B and retires A. A real memory_recall from repo B changes from returning A to No memories found. No I/O injection is needed. The normal promotion path correctly preserves global visibility, but the fold bypasses that guarantee. Require compatible ownership/visibility as well as metadata before retiring; otherwise retain the global source and report the conflict.

Both preservation probes pass on current main e32327a because the old duplicate no-op retains the source; both fail here because the new fold retires it. This is not a claim that main successfully applied the keyword edit: it did not, but it also did not consume the source row.

2. P2 — the gate can still mutate a DIFFERENT row before throwing

The ctx.supersedesTs exclusion fixes my original one-row case, but does not establish the outer catch's premise that every thrown gate failure is pre-mutation.

Seed target queue backend redis and another active row worker backend mysql, then the canonical registry entry backend=postgres in that scope. Update the target toward queue backend postgres; inject a failure only in record("superseded_by"). GATE-2 skips the named target, but has already persisted retirement of the OTHER row. The reply is still:

memory_update blocked: EIO: injected neutralization audit failure Nothing was written.

The target stays active, the other row is retired, and no replacement was appended. This reporting defect is inherited from main, not introduced by this commit; it is the unresolved broader form of the earlier #155 finding. Please propagate durable-mutation information from the gate's drift/canonical steps, rather than setting mutated only after a promoted outcome. A failed audit after a persisted retirement needs a truthful partial result.

Independent probes: original set 5/5 pass; the additional set below 0/3 pass. On main the additional set is 2 pass / 1 fail (only the inherited reporting case fails). Fixtures use temporary stores and the real registered tools; only the third case injects a synthetic audit exception. No product code was modified or pushed. #154/#155 should remain open until the corrected PR merges.

Runnable additional probes: save as review-158-round2.test.ts at the repository root

Run bun test ./review-158-round2.test.ts.

import { afterEach, beforeEach, expect, spyOn, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { basename, dirname, join, resolve } from "node:path";
import { loadPlugin, type LoadedPlugin } from "./test/harness.ts";
import * as memory from "./src/memory.ts";
import * as evidence from "./src/evidence.ts";
import { canonicalFile } from "./src/config.ts";
import { formatLine } from "./src/logfmt.ts";
import { resetSessionScopes, resolveRepo, setRepoScope } from "./src/repokey.ts";
import { resetState } from "./src/state.ts";
let root: string, a: string, b: string, p: LoadedPlugin;
beforeEach(async () => {
  root = mkdtempSync(join(tmpdir(), "osi-review158-r2-"));
  a = join(root, "a"); b = join(root, "b"); mkdirSync(a); mkdirSync(b);
  process.env.OPENCODE_MEMORY_DIR = join(root, "memory");
  process.env.OPENCODE_COMMANDS_DIR = join(root, "commands");
  resetState(); resetSessionScopes(); setRepoScope(null); p = await loadPlugin(a);
});
afterEach(async () => {
  await p.cleanup(); resetState(); resetSessionScopes(); setRepoScope(null);
  delete process.env.OPENCODE_MEMORY_DIR; delete process.env.OPENCODE_COMMANDS_DIR;
  if (dirname(resolve(root)) !== resolve(tmpdir()) || !basename(root).startsWith("osi-review158-r2-")) throw new Error("Unexpected cleanup target");
  rmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 20 });
});
async function seed(content: string, extra: Record<string, unknown> = {}) {
  const scope = resolveRepo(a);
  return memory.appendMemory({ type: "context", scope: "planning", content, status: "open", repo: scope.key, repoPath: scope.path, ...extra });
}
const ctx = { sessionID: "ses-a", id: "review-round2" };
const update = (query: string, content: string, extra: Record<string, unknown> = {}) => p.tools.memory_update.execute({ type: "context", scope: "planning", query, content, ...extra }, ctx);

test("collapse must not discard explicit keyword changes while retiring the named row", async () => {
  const old = await seed("Plan to prune aged queue entries every evening", { kw: ["old-alias"] });
  const prose = "Plan to prune aged queue entries every morning";
  await seed(prose, { kw: ["old-alias"] });
  const result = await update(old, prose, { kw: ["new-alias"] });
  const rows = await memory.loadAll();
  console.log("explicit-kw-fold", JSON.stringify({ reply: result.content, rows: rows.map(m => ({ ts: m.ts, kw: m.kw, retired: m.superseded_by })) }));
  // Either fulfill the requested edit, or preserve the source and report the conflict.
  const requestedLanded = rows.some(m => memory.isActive(m) && m.content === prose && m.kw?.includes("new-alias"));
  expect(requestedLanded || memory.isActive(rows.find(m => m.ts === old)!)).toBe(true);
});

test("collapse of a global target must preserve visibility to other repositories", async () => {
  const old = await seed("Plan to prune aged queue entries every evening", { repo: "global", repoPath: undefined });
  const prose = "Plan to prune aged queue entries every morning";
  await seed(prose);
  // Check visibility through the registered tool in a second repository.
  const pb = await loadPlugin(b);
  try {
    const before = await pb.tools.memory_recall.execute({ scope: "planning" }, { sessionID: "ses-b", id: "before" });
    expect(before.content).toContain("every evening");
    const result = await update(old, prose);
    const after = await pb.tools.memory_recall.execute({ scope: "planning" }, { sessionID: "ses-b", id: "after" });
    console.log("global-fold", JSON.stringify({ reply: result.content, before: before.content, after: after.content, rows: (await memory.loadAll()).map(m => ({ repo: m.repo, retired: m.superseded_by })) }));
    expect(after.content).toContain("Plan to prune");
  } finally { await pb.cleanup(); }
});

test("gate mutation of a different row must not be reported as nothing written", async () => {
  const old = await seed("queue backend redis");
  const other = await seed("worker backend mysql");
  writeFileSync(canonicalFile(), formatLine({ ts: "2026-01-01T00:00:00.000Z", type: "canonical", scope: "planning", entity: "backend", value: "postgres", source: "fixture" }) + "\n");
  const record = evidence.record;
  const spy = spyOn(evidence, "record").mockImplementation(async (...args: Parameters<typeof record>) => {
    if (args[0] === "superseded_by") throw new Error("EIO: injected neutralization audit failure");
    return record(...args);
  });
  let result: { content: string };
  try { result = await update(old, "queue backend postgres"); } finally { spy.mockRestore(); }
  const rows = await memory.loadAll();
  expect(rows.find(m => m.ts === other)?.superseded_by).toBeDefined();
  console.log("other-row-neutralization", JSON.stringify({ reply: result.content, rows: rows.map(m => ({ content: m.content, retired: m.superseded_by })) }));
  expect(result.content).not.toContain("Nothing was written");
});

…t own its durable steps

Three probes from the independent recheck of c95c919 (all red at c95c919,
the first two green on main e32327a — my fold regressed them):

- an update naming kw:new-alias onto prose a live row already held folded
  the named row into that survivor and consumed the keyword edit — the
  guard compared the PRE-EDIT target, not the requested state;
- folding a GLOBAL row into a repo-private survivor retired the global
  row, silently narrowing visibility the promotion path exists to
  preserve (recall from another repo flipped to "No memories found");
- a canonical neutralization that persisted a retirement and then lost
  its audit line still printed "Nothing was written" while another row
  sat retired — inherited from main, the unresolved broader form of
  abogartz#155 (fails there too).
…rts its own tombstones

Review round 3, both findings accepted — the probes were the reviewer's,
run red at c95c919 first (3 red, and the two fold cases green on main:
my fold regressed them).

1. The collapse-completion compared the PRE-EDIT target against the
survivor, so an update that named kw:["new-alias"] onto prose a live row
already held folded the named row away and consumed the edit behind a
"Nothing new was written" line — and folding a GLOBAL row into a
repo-private survivor retired the global row, silently narrowing the
visibility the promotion path exists to preserve. The guard now judges
the REQUESTED state — args.kw ?? target.kw, args.status ?? target.status,
the carried tags/issue — plus repo visibility, and refuses the fold when
any of it differs: nothing retires, the message names both rows and the
diverging fields (visibility included), and the source stays recallable.
Refuse-not-fulfill was chosen over teaching the gate's GATE-3 carve-out
to compare candidates against UNNAMED rows: byte-exact prose collapsing
(Principle 2) is documented behavior for every other writer, and making
metadata-difference an edit everywhere would change what `remember`
writes for a whole population of writes to satisfy one update path. The
fold path stays the honest place to decide, and it now has the same
predicate the promote path enforces: an edit must neither narrow nor
widen visibility.

2. The catch's premise that every thrown gate failure is pre-mutation
was false the way abogartz#155's was: GATE-2's drift/canonical batches persist
their retirements BEFORE their audit lines, so a failed superseded_by
record after a persisted retirement printed "Nothing was written" over
rows that were already tombstones. markManySupersededReport now returns
WHICH rows it retired (rows already superseded out-of-band are absent —
the ledger never claims a retirement the call did not perform), GATE-2
pushes them into a caller-owned ctx.durable ledger immediately after the
publish and before the records, and the catch composes the truth:
blocked, no replacement, but N other retirements ARE on disk, named.

Suite: 644/644 (3 probes added, assertions kept theirs), typecheck 0,
lint 0. GATE-4 block order and the epoch tests untouched.
@WhollyMindless

Copy link
Copy Markdown
Contributor Author

All three probes accepted, committed as 2c9420d (probes, red at c95c919 — verified with your method: git checkout c95c919 -- src under test/outcome-truth-audit.test.ts gives exactly 3 red + 5 green) and fixed in 4229018. The assertions in the committed tests are yours verbatim; only the spy.mockRestore line was mine to adapt.

1. The fold now judges the REQUESTED state, and visibility is part of the predicate. The guard compared the pre-edit target because that was the state I could name — the effective candidate (args.kw ?? target.kw, args.status ?? target.status, the carried tags/issue) is what the fold has to agree with, and it now compares exactly that, plus repo: the fold requires requested.repo === survivor.repo ?? "global". Any difference → nothing retires, both ids named, diverging fields listed (a mismatch now reads kw [new-alias] vs [old-alias] or visibility global vs a0b485…).

Why refuse-rather-than-fulfill, since you left both open: fulfilling properly means teaching GATE-3's carve-out to compare candidates against UNNAMED rows, but the carve-out's target-scope is deliberate — byte-exact prose collapse is Principle 2 for every writer, and making metadata-difference-an-edit everywhere would silently change what remember writes (no longer collapsing "same fact, retagged") to serve one update path. The fold is the place that already decides a retirement, so the truth lives there now. Both your preservation probes pass via the preserve-and-report branch; the requested edit is NOT silently applied, it's explicitly declined with the survivor named — a retry with memory_update onto the survivor's id lands it. If you'd rather see the fulfill-in-the-gate shape, that's a GATE-3 semantics conversation and I'd take it as its own issue.

2. ctx.durable — the gate reports its own tombstones. markManySupersededReport returns WHICH rows retired (batch-skipped, already-retired rows are absent — the ledger can only name retirements the call actually performed); both GATE-2 batches push the ids into a caller-owned ledger immediately after the publish and BEFORE their superseded_by records; the update's catch composes from it:

memory_update blocked: <err> No replacement was written, but the gate had ALREADY retired 1 other row(s) (<ts>): those retirements ARE on disk and their audit lines may not all have landed. Re-running this update will not undo them — reconcile with memory_evidence / memory_undo before retrying.

Your third probe passes on both assertions (the other row IS retired, and the string "Nothing was written" is gone from that path). Agreed it's the inherited #155 form — the ledger design means any future caller that passes a durable array gets the same truth for free; only update is wired today, since only update made a claim the ledger contradicted.

Checked on this head: 644/644 full suite (+3), typecheck 0, lint 0, epoch tests untouched, GATE-4 noteAuthored ordering untouched, all four CI checks will tell you the rest. #154/#155 staying open until merge noted.

@WhollyMindless

Copy link
Copy Markdown
Contributor Author

Quick follow-up on 4229018: the failed Linux and Windows jobs are both failing exactly the three newly added round-3 probes. The described implementation appears to be missing from the pushed commits:

  • git diff c95c919..4229018 -- src is empty; both commits have the same src tree (441e3d13aa6eabaaa23320bb608da11a19c177b7).
  • 2c9420d adds the probes; 4229018 itself only changes the test cleanup call to spy.mockRestore().

Could you check whether the implementation is still local or was restored during the red-on-base check? I cannot tell which happened from the remote tree. This looks like a missing-source-commit problem, not a new finding or a reason to change the tests. Once the implementation is pushed, we can verify the intended fixes against that head.

CI run with the three failures.

…rts its own tombstones

Review round 3, both findings accepted — the probes were the reviewer's,
run red at c95c919 first (3 red, and the two fold cases green on main:
my fold regressed them).

1. The collapse-completion compared the PRE-EDIT target against the
survivor, so an update that named kw:["new-alias"] onto prose a live row
already held folded the named row away and consumed the edit behind a
"Nothing new was written" line — and folding a GLOBAL row into a
repo-private survivor retired the global row, silently narrowing the
visibility the promotion path exists to preserve. The guard now judges
the REQUESTED state — args.kw ?? target.kw, args.status ?? target.status,
the carried tags/issue — plus repo visibility, and refuses the fold when
any of it differs: nothing retires, the message names both rows and the
diverging fields (visibility included), and the source stays recallable.
Refuse-not-fulfill was chosen over teaching the gate's GATE-3 carve-out
to compare candidates against UNNAMED rows: byte-exact prose collapsing
(Principle 2) is documented behavior for every other writer, and making
metadata-difference an edit everywhere would change what `remember`
writes for a whole population of writes to satisfy one update path. The
fold path stays the honest place to decide, and it now has the same
predicate the promote path enforces: an edit must neither narrow nor
widen visibility.

2. The catch's premise that every thrown gate failure is pre-mutation
was false the way abogartz#155's was: GATE-2's drift/canonical batches persist
their retirements BEFORE their audit lines, so a failed superseded_by
record after a persisted retirement printed "Nothing was written" over
rows that were already tombstones. markManySupersededReport now returns
WHICH rows it retired (rows already superseded out-of-band are absent —
the ledger never claims a retirement the call did not perform), GATE-2
pushes them into a caller-owned ctx.durable ledger immediately after the
publish and before the records, and the catch composes the truth:
blocked, no replacement, but N other retirements ARE on disk, named.

Suite: 644/644 (3 probes added, assertions kept theirs), typecheck 0,
lint 0. GATE-4 block order and the epoch tests untouched.
@WhollyMindless

Copy link
Copy Markdown
Contributor Author

My mistake, and the tests caught it exactly as designed: 4229018 was effectively an empty fix commit. The red-reproduction check I ran before committing (git checkout <prev> -- src under the tests, then restore) reverted src/ to HEAD — but unlike round 2, the fixes were not yet committed at that moment, so the restore silently discarded them. The one line that survived into 4229018 was a spy.mockRestore typo fix in the test file; CI then faithfully ran the committed probes against the un-fixed source and failed all three. 644/644 locally was real at the time — it just described an uncommitted tree.

Re-applied verbatim, re-verified (644 pass / typecheck 0 / lint 0), and this time the commit's own --stat is the gate: src/gates.ts, src/index.ts, src/memory.ts all in 0a6999e. The process lesson — red-verify before the fix commit, never after a checkout HEAD -- src that trusts HEAD to hold uncommitted work — is noted; the round-2 sequence was safe only because the fix was committed before the check there.

@WhollyMindless

Copy link
Copy Markdown
Contributor Author

Confirmed: implementation was local, restored-away by my own red-on-base check exactly as you suspected — the git checkout HEAD -- src restore ran before the fix commit existed, so HEAD's src was the old tree. Nothing about the tests or findings changed.

The implementation is now pushed as 0a6999e (git diff 4229018..0a6999e -- src carries all of it: markManySupersededReport in memory.ts, the ctx.durable ledger wiring in gates.ts, the requested-state + visibility predicate and the ledger-aware catch in index.ts). CI on that head: test/smoke/lint green — your three probes are among the passes; Windows rerunning. The two duplicate-recovery regressions (consumed metadata edit, global row disappearing from other repos) both terminate in the fold's refusal path, and the durable-mutation reporting case terminates in the ledger. Happy to have the re-verify against 0a6999e whenever you spin it.

@WhollyMindless

Copy link
Copy Markdown
Contributor Author

@abogartz Rechecked 0a6999e: the implementation is now in the pushed source, and the findings behind my earlier hold recommendation are resolved on this head.

Independent verification on Windows / Bun 1.4.4: 80 focused tests pass, 0 fail, including all eight of my original/additional probes, the committed update and audit regressions, batch supersession, and prompt-cache epoch tests. Typecheck passes. GitHub reports all four checks green on this same head (Linux tests, Windows tests, lint, smoke).

  • Explicit metadata and global/private visibility mismatches now preserve both rows and explain the refusal; they do not silently apply the requested edit or retire its source.
  • An audit exception after the gate retires another row now names the durable retirement and no longer claims nothing was written.
  • The earlier retry, provenance, and audit-reporting controls remain green.

This supersedes my hold on c95c919 and the missing-source note on 4229018. From this review, the reported findings are ready for your re-review and merge consideration. The existing changes-requested review is yours to resolve; release timing remains your call. No further implementation request from this review at this head.

@abogartz abogartz left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — both findings resolved, and #1 resolved better than my suggestion

Re-verified against 0a6999ec0681ab7ae3bf2963573c986ceb4b4887 rather than taking the reply on trust.

Independent checks

  • CI 4/4 green on this head; full local suite 644 pass / 12 skip / 0 fail.
  • Our cache pins (epoch, status, injection-framing, gated-injection, frontier): 97 pass / 0 fail. #162 and #165 are intact on this branch.
  • test/outcome-truth-audit.test.ts: 6 of 8 red on main, green here. I ran that in a clean worktree at origin/main instead of a git checkout -- src revert — the exact trap you hit and disclosed on 4229018. Worth making that the house method for red-on-base checks; your version of the mistake is easy to repeat and silently produces a green base.
  • Re-ran my original probe: the named row stays active with issue=GH-9001 and status=open, and the refusal names each differing field plus the two ways out.
  • Convergence control still holds — matching metadata folds to exactly one active row.

Where you went past what I asked, and it matters

  • Judging requested state vs survivor instead of target vs survivor. My proposed predicate was subtly wrong: an update naming kw:["new-alias"] against a survivor holding ["old-alias"] is not "already standing," and my version would have folded the edit away. That is the same class of loss I filed, reintroduced by my own fix.
  • Adding visibility to the predicate — folding a global row into a repo-private survivor would narrow visibility, the reverse leaks. Neither of us had raised it.
  • gateDurable is a deeper instance of the lie than the one I reported: GATE-2's drift and canonical retirements land on disk before their audit lines, so a blocked update could already have tombstones and still say "Nothing was written." Recording them ahead of the rec loop is the right ordering.
  • auditCaveat covers remember, update, import, capture and runInit — a fifth writer I never mentioned.

My error, recorded so it doesn't follow the branch around: my first re-run appeared to show convergence breaking — an update naming an active row's exact ts returned "no active row matches" with two active rows left. That was my probe leaking store state between two tests in one file, not your code. Isolated, it converges. Flagging it as mine because the shadow is otherwise attached to this head.

Checked and dropped (so nobody spends time on them): biome format drift is not a repo norm — main drifts identically; init.ts has no trailing newline on main either.

Two nits, non-blocking, no need to hold the merge

  1. The fold's survivor lookup (await loadAll()).find(m => m.ts === survivorTs && !m.superseded_by) has no isVisibleTo filter. Safe today only because collapsedWith originates in the gate's reader-visible poll — a dependency two files away with nothing stating it. A one-line comment or an isVisibleTo guard would stop the next reader from relying on it accidentally.
  2. The predicate compares repo but not repoPath, which holds only while a repo key implies its path.

I'll file these as a follow-up rather than reopen anything here.

Good exchange — the round-3 probe on the thrown-gate tombstones is the best catch in the batch.

@abogartz
abogartz merged commit 7bef31a into abogartz:main Oct 29, 2026
4 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.14.18 🎉

The release is available on:

Your semantic-release bot 📦🚀

abogartz added a commit to WhollyMindless/opencode-self-improvement that referenced this pull request Oct 29, 2026
Conflicts:
	src/gates.ts

Resolved the write_promoted hunk as the PR body prescribes: keep main's
(abogartz#158) try/catch and evidenceError result, and apply this branch's bounded
evidence_refs plus the new evidence_refs_count field inside that block.
No other change to either side.
abogartz-opencode-self-improvement Bot pushed a commit that referenced this pull request Nov 4, 2026
## [0.15.20](v0.15.19...v0.15.20) (2026-11-04)

### Bug Fixes

* **gate:** attribute only supersessions the call actually performed ([#208](#208)) ([d9819a8](d9819a8)), closes [#158](#158)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

2 participants