Repository navigation
fix(update): metadata fidelity and truthful partial results (#154 #155) - #158
Conversation
…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.
|
@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 1. P2 — retirement failure leaves two active versions, and the suggested retry cannot recover. 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. The new outer 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 Runnable additional probes (save at repository root as review-158-extra.test.ts)Run 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#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.
|
@abogartz Fix round for the HOLD recommendation — the confirmed P1 and every actionable finding from the review of
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 ( 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 |
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.
|
main ( |
abogartz
left a comment
There was a problem hiding this comment.
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 revertingsrc/toorigin/mainunder 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 writtenString(err)and not thought twice. A messagelessErrormakingevidenceErrorfalsy would have resurrected the exact lie this field exists to kill, through the truthiness test. Good catch.- Skipping
ctx.supersedesTsin 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.isVisibleTotreats!m.repoas 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.tsis 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.
noteAuthoredfires inrunWriteGatebefore the auditrec, so yourtryblock 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
markSupersededcompletions are removals, so they should bust, and that's correct behavior, not a regression to smooth over. test/epoch.test.tsis 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
sameStrListis order-sensitive, sokw: ["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.
|
Both points accepted — the probes were written and confirmed red against 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 2.
One discovery from building the capture probe, in the interest of the map: transcripts under 200 chars skip capture before the model call (silently, Non-blocking items: Your invariants, checked on this head: |
|
@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 stateAt Explicit keyword edit is silently consumed: seed A with old prose and 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 Both preservation probes pass on current main 2. P2 — the gate can still mutate a DIFFERENT row before throwingThe Seed target 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 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 rootRun 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.
|
All three probes accepted, committed as 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 ( 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 2.
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 Checked on this head: 644/644 full suite (+3), typecheck 0, lint 0, epoch tests untouched, GATE-4 |
|
Quick follow-up on
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. |
…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.
|
My mistake, and the tests caught it exactly as designed: Re-applied verbatim, re-verified (644 pass / typecheck 0 / lint 0), and this time the commit's own |
|
Confirmed: implementation was local, restored-away by my own red-on-base check exactly as you suspected — the The implementation is now pushed as |
|
@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).
This supersedes my hold on |
abogartz
left a comment
There was a problem hiding this comment.
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 onmain, green here. I ran that in a clean worktree atorigin/maininstead of agit checkout -- srcrevert — the exact trap you hit and disclosed on4229018. 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-9001andstatus=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.
gateDurableis 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 therecloop is the right ordering.auditCaveatcovers remember, update, import, capture andrunInit— 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
- The fold's survivor lookup
(await loadAll()).find(m => m.ts === survivorTs && !m.superseded_by)has noisVisibleTofilter. Safe today only becausecollapsedWithoriginates in the gate's reader-visible poll — a dependency two files away with nothing stating it. A one-line comment or anisVisibleToguard would stop the next reader from relying on it accidentally. - The predicate compares
repobut notrepoPath, 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.
|
🎉 This PR is included in version 0.14.18 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
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 thewrite_promotedaudit 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 oned5ecde(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 explicitkwstill 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;UpdateArgsgains no new fields.)#155 — post-append failures can no longer lie
The leak's exact anatomy:
gates.tsappends, then awaitsrec("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.156e887already fixed this shape formerge_review; this is itsmemory_updatetwin.runWriteGate: everything after the append is durable state, so the auditrecis wrapped and the failure rides the outcome asGateOutcome.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 viamemory_evidence.memory_update: onevidenceErrorit still completes the supersession (markSupersededis first-call-wins, so completing in the failure path is safe) and reports themerge_reviewPARTIAL shape; amarkSupersededthrow itself gets the same PARTIAL; the catch's stale comment is corrected and amutatedflag makes its "Nothing was written" claim conditional on it being true.Duplicate ignored: ... was already updated to exactly this content (<ts>)instead of a dead-endnot_found— the chain walk stays inside the caller's reader-visible rows.Boundaries
UpdateArgsschema change, no gate verdict change (candidates with carried-overtagspass the same metadata validation; the gate's onlytagslogic is sanitization/secret-scan).Evidence
test/update-provenance.test.ts1/2 red (metadata drop; explicit-kw-replaces control green),test/update-partial-failure.test.ts1/2 red (the false "Nothing was written" + two-active-rows; pre-mutation fail-closed control green) — on91f7a56and again oned5ecde.containment.test.tssymlink-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 --noEmitclean;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_reviewPARTIAL precedent), #129 (viewer-edit metadata preservation).Closes #154
Closes #155