Repository navigation
fix(metadata-protocol): a list_drafts verdict no longer re-collects its package closure per draft - #39048
Conversation
…age closures list_drafts judged each draft with a strict draft read and a publish judgement. The door shared one package closure between its judgements, but the strict read folded its own publish verdict into _diagnostics without the map, so it collected the package closure again on every draft: about 25 + P queries per verdict. getMetaItem now takes an in-process packageClosures map (only a Map is honoured; no wire door states the key), threaded into the strict draft read's folded judgement. gatedDraftVerdict hands the read the same map its judgement uses, so the closure is collected once per package per list_drafts call. A read naming no map collects its own closure on every read, as before, and folds the same verdict. Claude-Session: https://claude.ai/code/session_01WGufzeatqKfTRUzTJVa9jQ Co-authored-by: Claude <noreply@anthropic.com>
…read's shared closure Claude-Session: https://claude.ai/code/session_01WGufzeatqKfTRUzTJVa9jQ Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 6 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 3 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 35 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 19ff49431d9bf7330ea7bb8af6ff41c5aaa1fc1d && git checkout 19ff49431d9bf7330ea7bb8af6ff41c5aaa1fc1d
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 4a3b5321ed7f7fefc7363cba17cc4feb4174371a d8c2d8cb2ee3306b50e77c9e016e01e7eee2eefb && git checkout -B drift-repro 4a3b5321ed7f7fefc7363cba17cc4feb4174371a && git merge --no-ff d8c2d8cb2ee3306b50e77c9e016e01e7eee2eefb
node scripts/docs-audit/affected-docs.mjs --json 4a3b5321ed7f7fefc7363cba17cc4feb4174371a
|
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm L1 review · PR #39048 (#39001) · head 926ce2d · 2026-12-02T05:25ZREWORK. One must-fix, in the declaration only. The code reads right, and CI was still running at my read (13 success, 23 pending). Must-fix
Read and right (pending CI)
Next: fix the declaration lines. Once CI is green on the fix head, I run the declaration review and post an L1 delta. Landing then follows #39022 and a merge of main. |
…public-type widening Claude-Session: https://claude.ai/code/session_01WGufzeatqKfTRUzTJVa9jQ Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm Contract-review-claim: session_01WGufzhGA3zoCFquQgku4pm · head d8c2d8c · 2026-12-02T06:15Z |
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm Contract reviewServed-tier: Declaration review of PR #39048 (card #39001). Inputs: the card body and every comment on it (triage, claim, dev report), the PR body and its comments, the six-file net diff ① Derived judgments
② Semver level
③ Boundary flags
No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm L1 delta · PR #39048 (#39001) · head d8c2d8c · 2026-12-02T06:20ZACCEPT, on head
Next: zone landing. The merge closes #39001. |
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ 落地
State change: ready for review + auto-merge, by zone osa-ai (2026-12-02T06:21Z). |
Requested by Yibo Wang · project thread
Fixes #39001
Claim for this branch: #39001 comment 7334650660
Clause-②: yes (widening: the exported
ObjectStackProtocolImplementation#getMetaItemrequest type gains one optional in-process member,packageClosures; a caller that omits it behaves exactly as before)Metadata-protocol: none
维护者速读
What changes
list_draftsjudges each draft withgatedDraftVerdict: type admission, a strict draft read (getMetaItemwithstate: 'draft'), the item gate, thendraftPublishJudgement. The judgement already took the door's per-callpackageClosuresmap, so the package's publish closure (onelistDraftsplus onerepo.getper closure-relevant draft) was collected once for the judgements. The strict read did not: itsserveDraftfolds its own publish verdict into_diagnosticsby callingdraftPublishJudgementwith no map, so it collected the closure again for every draft. One verdict cost about 25 + P queries.packages/metadata-protocol:getMetaItem(the public method, and thegetMetaItem/readMetaItembodies inprotocol-meta-item-reads.ts) takes an optional in-processpackageClosuresmap, the same typedraftPublishJudgementtakes.serveDrafthands it to its folded judgement. Only aMapinstance is taken. Absent, the read collects its own closure, as before.packages/runtime(gatedDraftVerdictonly): the strict draft read gets the same map the judgement gets.Design points
_diagnosticsholds the refusals as diagnostics without theirhint, and the door answers each finding whole (verdictOf). That means a new key on the read's answer (an output widening on a wire-served method) or parsing_diagnosticsback, so (b) and (c) are out. What remains per verdict, traced on the driver for one draft: 1 served-row read for the strict read, 1 write-head read plus 1 stored-row read (repo.get) for the door's body-less judgement, and 10 stored-collection reads for each of the two judgements (foldStoredCollection: object, permission, book, dataset, flow, each in singular and plural spelling): about 23 per draft. Plus, once per call, the list read and the closure (1 + P). None of the per-draft part depends on P./metaread (packages/restmeta-item-read-routes.ts,rest-server.ts,meta-qualified-item-route.ts;packages/runtimedomains/meta.ts) and the MCPget_metadata_itemread builds itsgetMetaItemrequest from named keys; none spreads a query or body into it (checked withgit grepoverpackages/**). On top of that,serveDrafttakes the value only when it is aMap, which no JSON body or query string decodes to; a test pins that{}and a string are not taken. No tool or route input changes. The exported TypeScript request type ofgetMetaItemdoes gain the optional member, so Clause-② readsyes (widening)(L1 review 7335931058).list_draftscall and dropped with it, as before. The strict draft read is never served from the compiled-answer cache (cacheableRequestrefuses any request withstate), and a read with no map collects on every read (pinned: three reads, three collections).overlap-check.mjson this head: the branch merges textually clean with origin/main and with fix(runtime): get_metadata_item without state answers the version a following save takes #39022's head (they sharemcp-authoring.tsandmcp-authoring.test.ts; this branch edits onlygatedDraftVerdictand the closure-count pin, fix(runtime): get_metadata_item without state answers the version a following save takes #39022 theget_metadata_itemdescription and branch). I expect no conflict. The branch merges origin/main again once fix(runtime): get_metadata_item without state answers the version a following save takes #39022 lands, before it leaves draft.Read first (by risk)
packages/metadata-protocol/src/protocol-meta-item-reads.ts: thepackageClosuresguard and theserveDraftjudgement call. The risky part is the read-path change for every strict draft read; with no map the call is byte-for-byte the old one.packages/runtime/src/domains/mcp-authoring.ts:gatedDraftVerdict'sgetMetaItemcall now carries the map.packages/runtime/src/domains/mcp-authoring-39001-strict-read-closure.test.ts: the per-draft query pin and the single-read pins.Two-minute check
pnpm --filter @objectstack/metadata-protocol build && pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/mcp-authoring-39001-strict-read-closure.test.ts, expected: 4 passed. On origin/main the first case fails with4 → 118, 8 → 266, 16 → 658 queries: expected 392 to be 296.Tests
packages/runtime/src/domains/mcp-authoring-39001-strict-read-closure.test.ts, the realObjectStackProtocolImplementationover better-sqlite3, throughcreateOpenAuthoringRegistry, counting the driver'sfind/findOne/count:/metadraft read with no map: a view draft bound to an object that exists only as a sibling draft folds{ valid: true }; one bound to an object nowhere foldslist-view-object-outside-closureonobject; each read collects its own closure (3 reads, 3 collections). Green on origin/main and on this branch: the verdict did not change._diagnosticsas without one, and a second read takes the closure the first collected.packageClosuresvalue that is not aMapis not taken.mcp-authoring.test.ts: the existing closure-count pin goes fromnames.length + 1collections to1. Its other half, each listed verdict equal to the draft judged alone, still holds.Ablation (fix removed from the protocol, rebuilt)
node scripts/ablation-replace.mjs --delete --holdon the...(packageClosures ? { packageClosures } : {}),line ofserveDraft(anchor 1 → 0, blob ecce0fb16d93 → e48c568c5204);pnpm --filter @objectstack/metadata-protocol build;ablation-dist-preflight.mjs --absentpassed (the runtime suite reads metadata-protocol throughdist/).4 → 118, 8 → 266, 16 → 658 queries: expected 392 to be 296andexpected "collectBatchPendingDeclarations" to be called 1 times, but got 2 times. The two single-read pins stayed green, as they should.ablation-replace.mjs --restore: blob == HEAD (ecce0fb16d93c2f83a661f692985207accc76127),git diff HEADempty; rebuilt;ablation-dist-preflight.mjsfound the marker present in 2 built files.Measurement (P object drafts in one authored package, one list_drafts call)
After: total = 1 (list) + (1 + P) (closure, once) + 23 × judged.
Verification
Readings on
926ce2d055unless noted (the test and gate runs were taken on66622c7a64; the one commit merged since then is origin/main'sc748e7dfd6, which changes two gate scripts and no package).Package tests and typecheck
pnpm --filter @objectstack/metadata-protocol typecheck: exit 0.pnpm --filter @objectstack/metadata-protocol test: 381 files passed, 9 skipped; 23940 tests passed, 45 skipped; exit 0.pnpm --filter @objectstack/runtime typecheck(tsc pluscheck:test-typecheck): exit 0.pnpm --filter @objectstack/runtime exec vitest run --project local --maxWorkers=2 src/domains/mcp-authoring: 3 files, 86 tests passed.@objectstack/runtimelocal suite. It did not finish inside the container's 10-minute foreground limit.Test Coreruns it.Derived gate families (dispatch-gates --commands, 76)
check:closed-ceremony-textexited 1 on the first run (ENOBUFS: itsgit ls-filesread past the 1 MiB default buffer; origin/main lists 1048565 bytes, 11 under the limit, and this diff's two new files pushed it over). origin/main'sc748e7dfd6fixed that script; re-run after the merge: exit 0.check:dual-build-cjs-loads(PREREQUISITE NOT MET: it reads every package'sdist/, and 41 packages outside this diff are not built here). CI runs it.dispatch-gates --ran: 76 derived, 75 run, 1 NOT-MEASURED, 0 UNRUN.Acceptance notes
list_drafts("one map collects it once per package for the judgements") is now incomplete: the reads take the map too. It sits outsidegatedDraftVerdict, so this PR leaves it alone.list_draftscall. They do not grow with P; sharing them across a pass would be a separate change.Generated by Claude Code