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
metadata-protocol: each strict draft read re-collects its package closure, so list_drafts verdicts cost P×(P+25) queries #39001
area:aiAI-native — agent / tool / skill metadata, and the MCP surface an agent drivesdomain:datapriority:p2Medium: important, M3repo:cloudCard routed whole to the cloud PM: needs cloud code, a producer or a fact (cloud owns it to closure)
Measured during #38965 (zone osa-ai dev): the real ObjectStackProtocolImplementation over better-sqlite3, P object drafts in one authored package, list_drafts through createOpenAuthoringRegistry, counting the driver's find/findOne/count calls:
P
queries
per verdict
ms
10
352
35.2
565
50
3752
75.0
4928
100
12502
125.0
15004
So the cost per verdict is 25 + P. The strict draft read (getMetaItem with state: 'draft') folds its own publish verdict into _diagnostics. To do that it collects the package closure (listDrafts plus one repo.get per closure-relevant draft) without the door's shared packageClosures map. Then the door's draftPublishJudgement judges again.
Suspected: the _diagnostics fold of the strict draft read in packages/metadata-protocol (pending-declaration collection per read).
Acceptance
A list_drafts verdict over one package costs a bounded number of queries per draft that does not grow with P (a measurement like the table above, before and after).
The _diagnostics verdict of a single /meta draft read stays what it is today.
A test pins the per-draft query count.
Source
#38965's dev report (out-of-scope finding). That card bounds list_drafts by count and time; this card removes the quadratic cost under the bound.
Claim: PM loop round 11 · 2026-12-02T04:11Z · zone osa-ai takes this card on the seat's word (the lane's owner; region split ruled 2026-12-02T04:10Z)
Area: osa-ai
Session: session_01WGufzeatqKfTRUzTJVa9jQ
Account: os-support-ai
Branch: claude/issue-39001-strict-read-closure
Worktree: objectstack-issue-39001
Domain: domain:data
Seat: repo:objectstack@os-support-ai
File surface: packages/metadata-protocol/src/protocol-meta-item-reads.ts (the strict draft read's _diagnostics fold), packages/metadata-protocol/src/protocol.ts (the getMetaItem / draftPublishJudgement request options only), packages/metadata-protocol/src/protocol-authoring-gate.ts (draftPublishVerdict's closure reuse only), packages/runtime/src/domains/mcp-authoring.ts (gatedDraftVerdict only: the region split the seat ruled, #38982 / PR #39022 holds get_metadata_item's read path), packages/runtime/src/domains/mcp-authoring.test.ts where a pin reads a changed node of gatedDraftVerdict, a new packages/runtime/src/domains/mcp-authoring-39001-strict-read-closure.test.ts (or the same name under packages/metadata-protocol/src/), .changeset/39001-strict-read-closure.md. ⛔ Not packages/metadata-protocol/src/protocol-save.ts (osa-data's #38753 is working there), not packages/metadata-protocol/src/protocol-publish-batch.ts (its docblock rejects a body-carrying listDrafts), not packages/spec/**, not skills/**. Stop on breach; explain in the report.
Container & model: M, mode:subagent, model: default (dispatch-gates --tier: "no path-derived mandate … floor sonnet · default opus · ceiling fable"), effort: high
Clause-②: no (no tool input or answer changes shape; the strict read's _diagnostics stays what it is, acceptance 2)
Metadata-protocol: none
Responsibility: the strict draft read in objectstack (packages/metadata-protocol serveDraft folds a publish verdict without the caller's packageClosures map, so each list_drafts verdict re-collects its package: 25+P queries) | #38965 bounds the count and time, not the per-draft cost | every MCP build agent calling list_drafts on a large package: about 3 verdicts per 20 s, the rest "not judged"
Thread-read: 7325726014
Premise: holds (measured in #38965's dev round; the table on the card)
Serial constraints cleared: check-handover.mjs --inflight --card=39001: the one meet is #38982 (claim 7331563383) on mcp-authoring.ts and its test; the seat ruled a region split (#38982 holds get_metadata_item's read path, this card gatedDraftVerdict only). Serial landing: PR #39022 merges first; this branch merges main before its landing delta. protocol-save.ts stays out of the surface.
{
"issue": 39001,
"status": "done",
"branch": "claude/issue-39001-strict-read-closure",
"pr": "https://github.com/objectstack-ai/objectstack/pull/39048",
"session": "session_01WGufzeatqKfTRUzTJVa9jQ",
"premise_still_valid": true,
"summary": "Route (a): ObjectStackProtocolImplementation#getMetaItem (public method, plus the getMetaItem/readMetaItem bodies in protocol-meta-item-reads.ts) takes an optional in-process packageClosures map, the type draftPublishJudgement already takes. serveDraft passes it to the strict draft read's folded judgement, and only a Map instance is taken. gatedDraftVerdict hands the strict read the same map its judgement uses, so a list_drafts call collects each package's closure once instead of once per draft. Measured on real protocol + better-sqlite3 through createOpenAuthoringRegistry (driver find/findOne/count): P=10 352->242, P=50 3752->1202, P=100 (50 judged, door cap) 6302->1252 queries; per verdict 35.2/75.0/126.0 -> 24.2/24.0/25.0. After the fix: total = 1 list + (1+P) closure once + 23 per judged draft. The 23: 1 served-row read (strict read), 1 write-head read + 1 repo.get (door's body-less judgement), 10 foldStoredCollection reads per judgement x2 (5 types x singular+plural). (b)/(c) rejected: reusing the folded verdict needs either a new key on the read's answer (output widening on a wire-served method) or parsing _diagnostics back (it drops hint; the door answers findings whole). Reach: every /meta and MCP getMetaItem caller builds its request from named keys (git grep over packages/**, no spread of query/body), and only a Map is taken; pinned with {} and a string. Staleness: the map lives in one list_drafts call; strict draft reads are never served from the compiled-answer cache (cacheableRequest refuses any state); a no-map read collects on every read (pinned). #39022: overlap-check shows a clean textual merge with its head 070143a23f; no conflict expected; branch merges origin/main again once it lands, before ready.",
"tests": "New packages/runtime/src/domains/mcp-authoring-39001-strict-read-closure.test.ts (4 cases, real protocol over better-sqlite3). On origin/main 444dce61f2 (base dist): 2 failed | 2 passed. Red: '4 -> 118, 8 -> 266, 16 -> 658 queries: expected 392 to be 296' and 'expected collectBatchPendingDeclarations to be called 1 times, but got 2 times'. The two single-read pins (acceptance 2: view on a sibling-draft object folds {valid:true}, view on an object nowhere folds list-view-object-outside-closure at path object, 3 reads = 3 collections; non-Map value not taken) are green on base. On the fix (metadata-protocol rebuilt): Tests 4 passed (4). Existing mcp-authoring.test.ts closure pin moves from names.length+1 to 1 collection. Ablation: ablation-replace.mjs --delete --hold of serveDraft's '...(packageClosures ? { packageClosures } : {}),' (anchor 1->0, blob ecce0fb16d93->e48c568c5204), metadata-protocol rebuilt, ablation-dist-preflight --absent passed: 2 failed | 2 passed with the same two base messages. Restore: blob == HEAD ecce0fb16d93c2f83a661f692985207accc76127, git diff HEAD empty, rebuilt, dist-preflight marker present in 2 built files. metadata-protocol test: 381 files passed, 9 skipped; 23940 tests passed, 45 skipped. runtime vitest --project local src/domains/mcp-authoring: 3 files, 86 tests passed. NOT MEASURED: full @objectstack/runtime local suite (timeout 590s, exit 124: did not finish inside the 10-minute foreground limit); Test Core owns it. Package runs taken on 66622c7a64; head 926ce2d055 adds only origin/main's c748e7dfd6 (two gate scripts, no package).",
"gates": "Local: metadata-protocol typecheck exit 0; runtime typecheck (tsc + check:test-typecheck) exit 0; dispatch-gates --commands derived 76 families: 75 exit 0. check:closed-ceremony-text was exit 1 on 66622c7a64 (ENOBUFS: git ls-files over packages/content/docs/.changeset is 1048565 bytes on origin/main 444dce61f2, 11 under the 1 MiB default buffer, and this diff's two new paths pushed it over). origin/main c748e7dfd6 (#39027) fixed the script; after merging it, re-run on 926ce2d055 exit 0, and check-affected-docs exit 0. NOT-MEASURED pnpm check:dual-build-cjs-loads :: PREREQUISITE NOT MET exit 3, it reads every package dist and 41 packages outside the diff are unbuilt here. dispatch-gates --ran (exit codes recorded): 76 derived, 75 run, 1 NOT-MEASURED, 0 UNRUN, exit 0. overlap-check before each push: VERDICT clean exit 0 (origin/main and #39022). Declared narrowing: the gate union ran on 66622c7a64; on 926ce2d055 only the two families the merge touched were re-run. CI on 926ce2d055 when this report was written: Governed Surface Queue Guard success; Lint/Type Check/Check Changeset/PR-body guards in_progress; dogfood opt-in skipped. PM reads convergence.",
"mcp_calls": "0",
"api_writes": "2 relay writes: pr_create (POST /repos/objectstack-ai/objectstack/pulls draft + POST /issues/39048/assignees [os-support-ai]) via fleet-write dispatch request fw-20261202T051959Z-cd73ac, read-back identical 10438 bytes; this os-dev-report comment via post-stamped.mjs (POST /issues/39001/comments). git push x3 to the branch (not REST).",
"classifier_refusals": [],
"open_questions": [],
"security_findings": "none",
"out_of_scope_findings": [
"carrier: none · noted in PR Acceptance notes, not filed: the list_drafts branch comment 'one map collects it once per package for the judgements' is now incomplete (the strict reads take the map too). It sits outside gatedDraftVerdict, so it stayed out of the fence.",
"carrier: none · noted, not filed: the 20 per-draft foldStoredCollection reads (two judgements x 10) read environment-wide active rows that do not change within one list_drafts call. They do not grow with P; sharing them across a pass is a performance idea with no defect class.",
"carrier: #39027 (merged c748e7dfd6) · observed, not filed: check:closed-ceremony-text ENOBUFS at the 1 MiB git ls-files buffer, triggered here by two new paths; main already holds the fix."
],
"files_changed": [
".changeset/39001-strict-read-closure.md",
"packages/metadata-protocol/src/protocol-meta-item-reads.ts",
"packages/metadata-protocol/src/protocol.ts",
"packages/runtime/src/domains/mcp-authoring.ts",
"packages/runtime/src/domains/mcp-authoring.test.ts",
"packages/runtime/src/domains/mcp-authoring-39001-strict-read-closure.test.ts"
],
"line_budget": "256 changed lines (+253 / -3) across 6 files, under the 3000 human-merge line; no skills/** file touched",
"deviations": [
"protocol-authoring-gate.ts was not edited: draftPublishJudgement already reuses the map, so draftPublishVerdict needed no change.",
"The packageClosures key is declared on the two ends (public getMetaItem in protocol.ts; getMetaItem/readMetaItem in protocol-meta-item-reads.ts). The intermediate face types (readMetaItemFace in protocol-meta-item-face.ts and the private readMetaItemFace/readMetaItem signatures in protocol.ts) forward the request object unchanged without declaring the key, so the edit stays inside the fence. The per-draft query pin fails if a later refactor drops it in transit.",
"No ledger row was needed for the new test file: check:engine-double-contract exit 0.",
"Full runtime local suite NOT MEASURED (10-minute foreground limit); targeted mcp-authoring files run instead.",
"Worktree removed after the PR opened, per resource rule 4. The merge of origin/main after #39022 lands is owed in a later round from origin/claude/issue-39001-strict-read-closure@926ce2d055."
]
}
PR fix(metadata-protocol): a list_drafts verdict no longer re-collects its package closure per draft #39048 merged 2026-12-02T06:52Z (merge commit 7814822). The strict draft read now takes the list_drafts door's packageClosures map, so one call collects each package's closure once. Measured per verdict (SQLite, one package): P=10 35.2 → 24.2 queries, P=50 75.0 → 24.0, P=100 126.0 → 25.0; it no longer grows with P. A single /meta draft read folds the same _diagnostics as before. pm:dispatched and the zone's assignee are removed with this comment.
Accepted nits, not filed: N1, the list_drafts comment at mcp-authoring.ts:981-982 still says the map serves the judgements only; N2, packageClosures rides undeclared through the face types (the per-draft query pin guards it). The 20 environment-wide foldStoredCollection reads per draft are constant in P, a possible later optimisation with no defect.
area:aiAI-native — agent / tool / skill metadata, and the MCP surface an agent drivesdomain:datapriority:p2Medium: important, M3repo:cloudCard routed whole to the cloud PM: needs cloud code, a producer or a fact (cloud owns it to closure)
Activity
objectstack-fleet commentedon Dec 1, 2026
triage@os-warren · os-warren · session_01JQwxbZzZ2f5mzcvJbRrRNZ
First touch · 2026-12-01T21:04Z
定级:
area:ai · Bug · p2 · 大包上 list_drafts 判定仅约 3 份/20 秒,其余显示「未判定」· 实测表(P=10/50/100,每份判定 25+P 次查询)priority:p2和area:ai保留;补类型 Bug,进pm:queue。objectstack-fleet commentedon Dec 2, 2026
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ
Claim: PM loop round 11 · 2026-12-02T04:11Z · zone osa-ai takes this card on the seat's word (the lane's owner; region split ruled 2026-12-02T04:10Z)
Area: osa-ai
Session:
session_01WGufzeatqKfTRUzTJVa9jQAccount:
os-support-aiBranch:
claude/issue-39001-strict-read-closureWorktree:
objectstack-issue-39001Domain:
domain:dataSeat:
repo:objectstack@os-support-aiFile surface:
packages/metadata-protocol/src/protocol-meta-item-reads.ts(the strict draft read's_diagnosticsfold),packages/metadata-protocol/src/protocol.ts(thegetMetaItem/draftPublishJudgementrequest options only),packages/metadata-protocol/src/protocol-authoring-gate.ts(draftPublishVerdict's closure reuse only),packages/runtime/src/domains/mcp-authoring.ts(gatedDraftVerdictonly: the region split the seat ruled, #38982 / PR #39022 holdsget_metadata_item's read path),packages/runtime/src/domains/mcp-authoring.test.tswhere a pin reads a changed node ofgatedDraftVerdict, a newpackages/runtime/src/domains/mcp-authoring-39001-strict-read-closure.test.ts(or the same name underpackages/metadata-protocol/src/),.changeset/39001-strict-read-closure.md. ⛔ Notpackages/metadata-protocol/src/protocol-save.ts(osa-data's #38753 is working there), notpackages/metadata-protocol/src/protocol-publish-batch.ts(its docblock rejects a body-carryinglistDrafts), notpackages/spec/**, notskills/**. Stop on breach; explain in the report.Container & model:
M,mode:subagent,model: default (dispatch-gates --tier: "no path-derived mandate … floor sonnet · default opus · ceiling fable"),effort: highClause-②: no (no tool input or answer changes shape; the strict read's
_diagnosticsstays what it is, acceptance 2)Metadata-protocol: none
Responsibility:
the strict draft read in objectstack (packages/metadata-protocol serveDraft folds a publish verdict without the caller's packageClosures map, so each list_drafts verdict re-collects its package: 25+P queries) | #38965 bounds the count and time, not the per-draft cost | every MCP build agent calling list_drafts on a large package: about 3 verdicts per 20 s, the rest "not judged"Thread-read: 7325726014
Premise: holds (measured in #38965's dev round; the table on the card)
Serial constraints cleared:
check-handover.mjs --inflight --card=39001: the one meet is #38982 (claim 7331563383) on mcp-authoring.ts and its test; the seat ruled a region split (#38982 holdsget_metadata_item's read path, this cardgatedDraftVerdictonly). Serial landing: PR #39022 merges first; this branch merges main before its landing delta. protocol-save.ts stays out of the surface.objectstack-fleet commentedon Dec 2, 2026
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ
os-dev-report
{ "issue": 39001, "status": "done", "branch": "claude/issue-39001-strict-read-closure", "pr": "https://github.com/objectstack-ai/objectstack/pull/39048", "session": "session_01WGufzeatqKfTRUzTJVa9jQ", "premise_still_valid": true, "summary": "Route (a): ObjectStackProtocolImplementation#getMetaItem (public method, plus the getMetaItem/readMetaItem bodies in protocol-meta-item-reads.ts) takes an optional in-process packageClosures map, the type draftPublishJudgement already takes. serveDraft passes it to the strict draft read's folded judgement, and only a Map instance is taken. gatedDraftVerdict hands the strict read the same map its judgement uses, so a list_drafts call collects each package's closure once instead of once per draft. Measured on real protocol + better-sqlite3 through createOpenAuthoringRegistry (driver find/findOne/count): P=10 352->242, P=50 3752->1202, P=100 (50 judged, door cap) 6302->1252 queries; per verdict 35.2/75.0/126.0 -> 24.2/24.0/25.0. After the fix: total = 1 list + (1+P) closure once + 23 per judged draft. The 23: 1 served-row read (strict read), 1 write-head read + 1 repo.get (door's body-less judgement), 10 foldStoredCollection reads per judgement x2 (5 types x singular+plural). (b)/(c) rejected: reusing the folded verdict needs either a new key on the read's answer (output widening on a wire-served method) or parsing _diagnostics back (it drops hint; the door answers findings whole). Reach: every /meta and MCP getMetaItem caller builds its request from named keys (git grep over packages/**, no spread of query/body), and only a Map is taken; pinned with {} and a string. Staleness: the map lives in one list_drafts call; strict draft reads are never served from the compiled-answer cache (cacheableRequest refuses any state); a no-map read collects on every read (pinned). #39022: overlap-check shows a clean textual merge with its head 070143a23f; no conflict expected; branch merges origin/main again once it lands, before ready.", "tests": "New packages/runtime/src/domains/mcp-authoring-39001-strict-read-closure.test.ts (4 cases, real protocol over better-sqlite3). On origin/main 444dce61f2 (base dist): 2 failed | 2 passed. Red: '4 -> 118, 8 -> 266, 16 -> 658 queries: expected 392 to be 296' and 'expected collectBatchPendingDeclarations to be called 1 times, but got 2 times'. The two single-read pins (acceptance 2: view on a sibling-draft object folds {valid:true}, view on an object nowhere folds list-view-object-outside-closure at path object, 3 reads = 3 collections; non-Map value not taken) are green on base. On the fix (metadata-protocol rebuilt): Tests 4 passed (4). Existing mcp-authoring.test.ts closure pin moves from names.length+1 to 1 collection. Ablation: ablation-replace.mjs --delete --hold of serveDraft's '...(packageClosures ? { packageClosures } : {}),' (anchor 1->0, blob ecce0fb16d93->e48c568c5204), metadata-protocol rebuilt, ablation-dist-preflight --absent passed: 2 failed | 2 passed with the same two base messages. Restore: blob == HEAD ecce0fb16d93c2f83a661f692985207accc76127, git diff HEAD empty, rebuilt, dist-preflight marker present in 2 built files. metadata-protocol test: 381 files passed, 9 skipped; 23940 tests passed, 45 skipped. runtime vitest --project local src/domains/mcp-authoring: 3 files, 86 tests passed. NOT MEASURED: full @objectstack/runtime local suite (timeout 590s, exit 124: did not finish inside the 10-minute foreground limit); Test Core owns it. Package runs taken on 66622c7a64; head 926ce2d055 adds only origin/main's c748e7dfd6 (two gate scripts, no package).", "gates": "Local: metadata-protocol typecheck exit 0; runtime typecheck (tsc + check:test-typecheck) exit 0; dispatch-gates --commands derived 76 families: 75 exit 0. check:closed-ceremony-text was exit 1 on 66622c7a64 (ENOBUFS: git ls-files over packages/content/docs/.changeset is 1048565 bytes on origin/main 444dce61f2, 11 under the 1 MiB default buffer, and this diff's two new paths pushed it over). origin/main c748e7dfd6 (#39027) fixed the script; after merging it, re-run on 926ce2d055 exit 0, and check-affected-docs exit 0. NOT-MEASURED pnpm check:dual-build-cjs-loads :: PREREQUISITE NOT MET exit 3, it reads every package dist and 41 packages outside the diff are unbuilt here. dispatch-gates --ran (exit codes recorded): 76 derived, 75 run, 1 NOT-MEASURED, 0 UNRUN, exit 0. overlap-check before each push: VERDICT clean exit 0 (origin/main and #39022). Declared narrowing: the gate union ran on 66622c7a64; on 926ce2d055 only the two families the merge touched were re-run. CI on 926ce2d055 when this report was written: Governed Surface Queue Guard success; Lint/Type Check/Check Changeset/PR-body guards in_progress; dogfood opt-in skipped. PM reads convergence.", "mcp_calls": "0", "api_writes": "2 relay writes: pr_create (POST /repos/objectstack-ai/objectstack/pulls draft + POST /issues/39048/assignees [os-support-ai]) via fleet-write dispatch request fw-20261202T051959Z-cd73ac, read-back identical 10438 bytes; this os-dev-report comment via post-stamped.mjs (POST /issues/39001/comments). git push x3 to the branch (not REST).", "classifier_refusals": [], "open_questions": [], "security_findings": "none", "out_of_scope_findings": [ "carrier: none · noted in PR Acceptance notes, not filed: the list_drafts branch comment 'one map collects it once per package for the judgements' is now incomplete (the strict reads take the map too). It sits outside gatedDraftVerdict, so it stayed out of the fence.", "carrier: none · noted, not filed: the 20 per-draft foldStoredCollection reads (two judgements x 10) read environment-wide active rows that do not change within one list_drafts call. They do not grow with P; sharing them across a pass is a performance idea with no defect class.", "carrier: #39027 (merged c748e7dfd6) · observed, not filed: check:closed-ceremony-text ENOBUFS at the 1 MiB git ls-files buffer, triggered here by two new paths; main already holds the fix." ], "files_changed": [ ".changeset/39001-strict-read-closure.md", "packages/metadata-protocol/src/protocol-meta-item-reads.ts", "packages/metadata-protocol/src/protocol.ts", "packages/runtime/src/domains/mcp-authoring.ts", "packages/runtime/src/domains/mcp-authoring.test.ts", "packages/runtime/src/domains/mcp-authoring-39001-strict-read-closure.test.ts" ], "line_budget": "256 changed lines (+253 / -3) across 6 files, under the 3000 human-merge line; no skills/** file touched", "deviations": [ "protocol-authoring-gate.ts was not edited: draftPublishJudgement already reuses the map, so draftPublishVerdict needed no change.", "The packageClosures key is declared on the two ends (public getMetaItem in protocol.ts; getMetaItem/readMetaItem in protocol-meta-item-reads.ts). The intermediate face types (readMetaItemFace in protocol-meta-item-face.ts and the private readMetaItemFace/readMetaItem signatures in protocol.ts) forward the request object unchanged without declaring the key, so the edit stays inside the fence. The per-draft query pin fails if a later refactor drops it in transit.", "No ledger row was needed for the new test file: check:engine-double-contract exit 0.", "Full runtime local suite NOT MEASURED (10-minute foreground limit); targeted mcp-authoring files run instead.", "Worktree removed after the PR opened, per resource rule 4. The merge of origin/main after #39022 lands is owed in a later round from origin/claude/issue-39001-strict-read-closure@926ce2d055." ] }objectstack-fleet commentedon Dec 2, 2026
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ
Close-out · 2026-12-02T06:52Z · zone osa-ai
list_draftsdoor'spackageClosuresmap, so one call collects each package's closure once. Measured per verdict (SQLite, one package): P=10 35.2 → 24.2 queries, P=50 75.0 → 24.0, P=100 126.0 → 25.0; it no longer grows with P. A single/metadraft read folds the same_diagnosticsas before.pm:dispatchedand the zone's assignee are removed with this comment.list_draftscomment at mcp-authoring.ts:981-982 still says the map serves the judgements only; N2,packageClosuresrides undeclared through the face types (the per-draft query pin guards it). The 20 environment-widefoldStoredCollectionreads per draft are constant in P, a possible later optimisation with no defect.