You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Supersede in batch: decay rewrites and snapshots the store file once per row #61
Multi-row supersession is done one row at a time. memory_decay snapshots the affected files and then calls markSuperseded(ts) per row (src/index.ts), and the gate's canonical-neutralization loop (src/gates.ts) does the same. Each call is: read the whole daily file, rewrite one line, snapshot the file, publish it. So N stale rows cost N full reads, N snapshots and N renames, each taking and releasing the store lock in between.
That was tolerable when it was unlocked. Now that #60 put a per-file lock around these paths it is worth fixing rather than merely untidy: one pass over the file under one lock is cheaper, produces one undo point instead of N, and removes the windows where two decay runs interleave and each pays twice for the other's file.
Proposal
markManySuperseded(entries: { ts: string; fields: SupersedeFields }[]): Promise<number> in src/memory.ts — one lock, one read, stamp every matching line, one snapshot, one atomic publish. Keep markSuperseded as the single-row wrapper (stampRow already factors the shape).
Point memory_decay and the canonical-neutralization loop at it.
Test: N rows superseded in one pass → exactly one snapshot, all N stamped, and a concurrent append during that pass survives.
Cost / scope
~30 lines plus a test. No semantic change: per-row idempotence stays (a row already carrying superseded_by is skipped, so a repeat run is still a no-op).
Found while reviewing #60; deliberately kept out of that PR, which was already changing every write path.
Happy to take this if it's unclaimed. The acceptance test ("a concurrent append during the batch pass survives") builds directly on the rename-handover semantics in #89, so the clean sequence is: branch off main after #89 lands, markManySuperseded with one lock / one snapshot / one publish, decay + canonical-neutralization pointed at it, red-first scenario for the interleaving. Say the word.
Decay now retires via markManySuperseded in a single batched call (src/index.ts:794 on main), and the gate's drift/canon plans batch through the same primitive (src/gates.ts:411, :453). The per-row rewrite-and-snapshot behavior this issue was filed against is gone.
Activity
WhollyMindless commentedon Oct 25, 2026
Happy to take this if it's unclaimed. The acceptance test ("a concurrent append during the batch pass survives") builds directly on the rename-handover semantics in #89, so the clean sequence is: branch off
mainafter #89 lands,markManySupersededwith one lock / one snapshot / one publish, decay + canonical-neutralization pointed at it, red-first scenario for the interleaving. Say the word.perf(store): batch supersession - one pass per file for decay and gates
Merge pull request #102 from WhollyMindless/fix/batch-supersede
abogartz commentedon Oct 27, 2026
Closed as completed — the batch path shipped.
Decay now retires via
markManySupersededin a single batched call (src/index.ts:794on main), and the gate's drift/canon plans batch through the same primitive (src/gates.ts:411,:453). The per-row rewrite-and-snapshot behavior this issue was filed against is gone.