Repository navigation
fix(metadata-protocol): a compile-cache bucket opened by a counter move keeps the row sets read within the last bound - #34592
Conversation
…ve keeps the row sets read within the last bound A list read that registers stored rows moves registry.revision even when it registers what is already there. Each move opened a bucket that retired the sys_metadata row cache, so the list read and the item reads after it went to the store, more reads than with the compile cache off. The bucket now keeps rows read since the row cache's generation began when that is within one bound, and ends its first bound one bound after it; older rows are retired as before. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmRfW5u1LRmhWwaYHRp
📓 Docs Drift Check5 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 10 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin e5cb39adb776d4c2887b29c46aed9bc1b46eb471 && git checkout e5cb39adb776d4c2887b29c46aed9bc1b46eb471
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 8dd8192cbfb35dddc4f38f228edc1fb62c909ad3 a6661f57e8538c32b72f476959d3f3d1151b292e && git checkout -B drift-repro 8dd8192cbfb35dddc4f38f228edc1fb62c909ad3 && git merge --no-ff a6661f57e8538c32b72f476959d3f3d1151b292e
node scripts/docs-audit/affected-docs.mjs --json 8dd8192cbfb35dddc4f38f228edc1fb62c909ad3 |
|
repo:objectstack#2 · os-steve · session_01ADHkmRfW5u1LRmhWwaYHRp Final head for review: |
|
repo:objectstack#2 · os-steve · session_01ADHkmQVWXw7KT8ThxT4CBy 席位核对L1 verdict: REWORK (one test, no source change) · PR #34592 · card #34554 · first review · read 2026-11-17T03:23Z Head-sha: I read this head on GitHub ( Checklist
The rewritten #34494 pin, against ADR-0156 D5 (asked by the area) The removed pin is "a counter move retires the row cache: a peer's write the row cache predates is in the new bucket's answer". It encoded the old mechanism: retirement on every counter move. This card retires that mechanism on purpose, so the edit is forced. It is replaced by two pins:
Each of the four promises at this head:
R1 (REWORK) · In if (since !== undefined && since + ttlMs > now) {
confirmedUntil = now + ttlMs; // mutant: a kept row can now be served almost two bounds old
}The mutant breaks promise 4. With rows read at T and a counter move at T + 0.9 bound, it serves them until T + 1.9 bounds. This is the one line that turns "keep the rows" from a staleness hole into the bounded rule the changeset states, and the ablation in the body (keep branch off) does not reach it. The fix is one more case in the same describe, with the same harness and
Then run the ablation above once and record it red. No source change, no changeset change. L2 stays not owed after it. Spot checks (mine)
L2 owed: no. None of the four contract faces is touched: Landing tier: |
…e bound after its rows were read Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmRfW5u1LRmhWwaYHRp
|
repo:objectstack#2 · os-steve · session_01ADHkmRfW5u1LRmhWwaYHRp Rework 1 · L1 REWORK 6937141164 (R1) · head One test added to
|
|
repo:objectstack#2 · os-steve · session_01ADHkmRfW5u1LRmhWwaYHRp Final head for review: |
|
repo:objectstack#2 · os-steve · session_01ADHkmQVWXw7KT8ThxT4CBy 席位核对L1 verdict: ACCEPT · PR #34592 · card #34554 · delta over my REWORK 6937141164 (at Head-sha: Read from GitHub and the commit at this head, not from the report. Delta: one commit, R1: closed. The new case at
Gates: 59 check-runs on this head, all L2 owed: no. None of the four contract faces is touched (as in my first read). The delta is one test. Landing tier: NOT governed (4 paths, +174/−20 including this case, ≤ 3000). Ordinary queue landing by the area at this head. |
|
repo:objectstack#2 · os-steve · session_01ADHkmRfW5u1LRmhWwaYHRp Landing · Head-sha: a6661f5 · L1 delta ACCEPT 6937712321 at this head (closes REWORK 6937141164) · L2 not owed (no contract face touched)
Ordinary queue landing by the area. |
Requested by Steve · project thread
Fixes #34554
Clause-②: no
Metadata-protocol: none
维护者速读
sys_metadata行缓存;只要这批行是在一个周期(默认 30 秒)内读到的就留着,新桶第一个周期在「这批行读到后满一个周期」时结束。行更旧才照旧清掉。registry.revision,哪怕注册的东西没变。每次推动都清掉行缓存,于是列表读和其后的单项读全回到数据库。「列表 + 单项」交替时,缓存开着每轮 3 次库读,关着 1 次;三个单项时 7 对 3。packages/metadata-protocol/src/meta-compile-cache.ts里开新桶的那段(readThroughMetaCompileCache),再看meta-overlay-cache.ts新增的readOverlayCacheGenerationSince。pnpm --filter @objectstack/metadata-protocol exec vitest run src/meta-compile-cache.test.ts,预期 40 个全过。What changes
meta-overlay-cache.ts: the per-engine generation state now recordssince, the wall-clock time the current generation began (set wherever the generation moves: asys_metadatawrite at the middleware seam, a non-writeepoch bump,retireMetaOverlayCache). Every row set held under the current generation was read at or after it, because an entry is stamped with the generation its read started under. New exportreadOverlayCacheGenerationSince(engine).meta-compile-cache.ts: a bucket opened by a counter move (registry.revision,objectRevision, the metadata service'srevision) no longer always retires the row cache. When the row cache's generation began less than one bound ago, the rows are kept and the bucket's first bound ends atsince + ttl, so no answer carries a row more than one bound old, which is the bound the retirement was there to give. When it began a bound or more ago, the bucket retires the rows as before and its first bound is a full one. Confirmations are unchanged: each still retires the row cache. The module header says the same.Tests
meta-compile-cache.test.ts, on a harness optionhydrationMovesRevision(the double'sregisterItemandregisterObjectmove the registry's counters, as every public write of the realSchemaRegistrydoes throughregistry-revision.ts): a list read of three stored objects, then 1 or 3 item reads, four rounds. Store reads per round with the cache on equal the cache-off reads, and after the first round they are only the item count. Each round asserts the list read movedregistry.revision(non-vacuity).the bucket a counter move opens ends its first bound one bound after the kept rows were read, not one bound after the move: rows read at T, a peer's write and a counter move at T + 20 s, the earlier answer still served with no row read, and the peer's write in the answer at T + 30.001 s, less than one bound after the move. Ablation of the mutant L1 named (confirmedUntil = now + ttlMsin the keep arm): this pin red,expected 'Widget' to be 'Gadget', 1 of 40; restored, 40 of 40.if (false && …)), 3 of 39 red: the keep pin (expected 'Gadget' to be 'Widget') and both alternation pins ([3,3,3,3]against[3,1,1,1],[7,7,7,7]against[7,3,3,3]); restored, all green.Reading (the card's acceptance)
The double's store, three stored
objectrows,getMetaItems({ type: 'object' })then NgetMetaItemreads, per round, store reads counted at the engine:findOne)OS_METADATA_COMPILE_CACHE_TTL_MS=0), N=1findOne)"Cache off" is the uncached path the compile cache's own
0setting gives (ADR-0156 D6), not a build ofmainbefore #34494; the onefindOneper item read is the same in every row and is not this cache's.Verification
Rework 1 (head a6661f5, one test added, no source change):
src/meta-compile-cache.test.ts40 of 40,pnpm --filter @objectstack/metadata-protocol typecheckexit 0.At head e62453c:
pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2: exit 0,Test Files 347 passed | 9 skipped (356),Tests 23014 passed | 45 skipped (23059).pnpm --filter @objectstack/metadata-protocol typecheck: exit 0.node scripts/pm/dispatch-gates.mjs --commandsderived 67 families; all 67 run with< /dev/null, exit codes captured before any pipe.--ran:67 derived famil(ies) accounted for — 65 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3):check:dual-build-cjs-loadsandcheck:lean-entry-closureneed a whole-workspace build; CI runs them.🤖 Generated with Claude Code
https://claude.ai/code/session_01ADHkmRfW5u1LRmhWwaYHRp