Repository navigation
perf(metadata-protocol): one form request reads the view list and each type's stored rows once - #38164
Conversation
…ws once per form request (wip) Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude <noreply@anthropic.com>
…once each Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude <noreply@anthropic.com>
… reads, so test doubles of those reads still answer Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude <noreply@anthropic.com>
… doors' request reading Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude <noreply@anthropic.com>
… ceiling Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 10 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 8 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 26 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 65fd034ff3777d5d6f357cea1ddfcdde65f6f5b1 && git checkout 65fd034ff3777d5d6f357cea1ddfcdde65f6f5b1
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 33a0d4fa625cdfb69873a89a1e0f5d9f49fea744 c1aaf1cee64e259ab228c6a69d83df4f7d35ddc7 && git checkout -B drift-repro 33a0d4fa625cdfb69873a89a1e0f5d9f49fea744 && git merge --no-ff c1aaf1cee64e259ab228c6a69d83df4f7d35ddc7
node scripts/docs-audit/affected-docs.mjs --json 33a0d4fa625cdfb69873a89a1e0f5d9f49fea744
|
…ublished protocol class Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8 Contract reviewServed-tier: Face: the ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8 L1: ACCEPT · head 席位核对
Landing — non-governed, ≤3000 lines, L2 PASS on this head: the seat lands it through the ordinary queue. |
|
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8 Landing · 2026-11-28T05:40Z · head
State: ready for review + auto-merge (L1 ACCEPT 7234807820). |
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 46113210720 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 46114725605 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 46115033565 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 46119645478 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
|
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8 Dequeue (seat asks) · 2026-11-28T07:30Z · head Signature: Test Core (9/10) · Next: the dev's fix round, already ordered, measures the test's wall time on this head against the merge base and reports |
|
Relay Merge-queue dequeue of #38164 — cause
The relay sends |
|
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8 Re-queue · 2026-11-28T08:42Z · head unchanged. Fix round verdict (os-dev-report on #37709, 07:53Z): not this PR. The |
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 46129984241 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
|
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8 Re-queue · 2026-11-28T10:29Z · head
Landing rule: a known signature whose fix has landed on |
Fixes #37709
Clause-②: yes (widening) — ObjectStackProtocolImplementation.readFormRequest
Metadata-protocol: none
维护者速读
What changes
The effective
formread (ADR-0159 D5) resolves over both types: the genericformlist, the projection of theviewlist, and the cross-type resolution (step 3) over the stored rows of both types. Each of those readings, and each of the five reads an anonymous form door makes, asked the store for the same rows again.packages/metadata-protocol/src/protocol-form-reads.ts.formRequestScope(host): one request's reading, over which each stored row set (per type and package binding) and each flattened list (per request, audience and layer) is read once.readEffectiveFormListreads through it, so the genericformlist and step 3 share one reading of theformrows, and theviewlist and step 3 share one reading of theviewrows.readInFormRequest(read)runsreadas one request reading (an AsyncLocalStorage store): every protocol list read inside it over the same host shares one scope, and oncereadsettles the scope memoizes nothing, so nothing outlives the request. The stored rows of step 3 stay read whole (a container row's name is not the name its expansion writes); they are read once per request. ThereadEffectiveFormListdocblock now states that.packages/metadata-protocol/src/protocol-meta-list-reads.ts.readFlattenedMetaItemstakes an optional stored-row reader (the scope's);getMetaItemsandgetMetaItemsPerPackageread through the open request reading when there is one; the package-scopedformlist face reads its envelope through the same scope.packages/metadata-protocol/src/protocol.ts. The privatereadFlattenedMetaItemspasses the row reader on. New server-only extensionreadFormRequest(read)(feature-detected by the doors, likegetMetaItemsPerPackageandgetUnreadableFormBodies): runsreadas one request reading.packages/rest/src/form-routes.ts(outside the claim's file surface; the measured producer of the repeated door reads, see Acceptance notes).resolveFormBySlugmakes its five reads insidereadFormRequestwhen the protocol serves it, and exactly as before otherwise. Both doors (GET /forms/:slug,POST /forms/:slug/submit) go through it.packages/metadata-protocol/src/protocol-meta-item-reads.ts. Comment only atreadEffectiveFormItem: on this tree it callsreadEffectiveFormsonce (not up to three times), and that one call now reads each row set once.Every answer is unchanged: the same items, in the same order, from the same served-row order. The ADR-0159 D5 cross-type resolution is untouched;
namesandpackageIdhandling is untouched (nameswas already pushed into both generic reads, and the reasonpackageIdis not pushed down was already stated in thereadEffectiveFormListdocblock, both landed in #37422's rework; confirmed on this tree, not redone).Measured counts (real protocol, real
ObjectQL+ SQLite store,OS_METADATA_OVERLAY_CACHE_TTL_MS=0, one warm-up request)"Row-set read" = one
readActiveOverlayRowscall (onesys_metadatastatement under the singular type, plus one under the plural when the singular answers no row).viewlist (effective) before → afterviewrow sets before → afterformrow sets before → afterformreadformitemformreadformViewsentryformitemformViewsentryBefore =
origin/main93fa911 (with #37422 merged); after = this branch. The by-name read also issues one row read predicated on the name (the generic by-name read's own,readItemActiveRows), before and after. The door reads theformlist, the per-packageformlayer and the per-packageviewlayer once each, before and after. With the row cache on (default 30 s) the repeated reads were cache hits at the SQL level, but each still ran its parse and merge; with it off (or on a cold or invalidated cache) each was a statement.Tests
packages/rest/src/public-form-reads-once-37709.test.ts(8 cases, both form shapes): the by-name read and the door GET read theviewlist once and each type's row sets once (exact counts, answers asserted); CONTROL 1, two requests read twice (the scope never spans requests); CONTROL 2, the five door calls outside one reading (a protocol withoutreadFormRequest) read theviewlist twice and theviewrows four times, so the counter sees a repeated read when there is one.packages/rest/src/rest-write-route-hook-refusal-sentence.ledger.test.ts: its catch-all protocol double rejects every method it does not list, and the door now feature-detectsreadFormRequest, so the double's reads table gains one pass-through entry, as it gainedgetMetaItemsPerPackageandgetUnreadableFormBodieswhen those door extensions landed. No assertion changed. Every other form-door and D5 test is unchanged and green.Suites on f97bc7d (merged with origin/main)
@objectstack/metadata-protocolvitest run: Test Files 372 passed, 9 skipped (381); Tests 23605 passed, 45 skipped.@objectstack/restvitest run --project local: Test Files 433 passed (433); Tests 8981 passed, 351 skipped.pnpm --filter @objectstack/metadata-protocol typecheck,pnpm --filter @objectstack/rest typecheck: exit 0.protocol.tstext after that run (thereadFlattenedMetaItemsdocblock reflowed and the new method's docblock made one line, so the facade stays at its 11705-line ceiling,check:facade-delegation-only). On it: rebuilt, both typechecks exit 0, and the pin plus 11 form-door files: Test Files 12 passed (12), Tests 898 passed (898).Ablations on 6178fb1 (scripts/ablation-replace.mjs, each leg built and checked in dist with scripts/ablation-dist-preflight.mjs)
formread without its scope (drophost = formRequestScope(host)inreadEffectiveFormList): 2 failed / 6 passed (the by-name read of an authoredformitem, and CONTROL 1).readFormRequestopens no reading (readInFormRequest(read)replaced by callingreaddirectly): 4 failed / 4 passed (the door GET in both shapes, and CONTROL 1 in both).Local gates on 73983ef (the 75 families `dispatch-gates.mjs --commands` derives for this diff)
pnpm check:dual-build-cjs-loadsfirst answered PREREQUISITE NOT MET (exit 3: it reads every package'sdist/), and exit 0 when re-run aftercheck:type-check-debt's full build on the same head (126 require entry points across 74 packages load).check:facade-delegation-onlyheld the line:protocol.tsis at its 11705-line ceiling (it went red at 11719 on f97bc7d, fixed in 73983ef).dispatch-gates.mjs --ran: 75 derived, 75 run, 0 NOT-MEASURED, 0 UNRUN.Acceptance notes
packages/rest/src/form-routes.ts. Measurement shows the door's repeatedview-list and row reads come from its five separate protocol calls; no change insidepackages/metadata-protocolalone can share a reading across them. A first cut answered the five reads through one new protocol call; it bypassed the doubles four existing door tests install by overridinggetMetaItems/getMetaItemsPerPackage/getUnreadableFormBodieson a real protocol, so the door keeps its five calls and runs them inside one request reading instead.readEffectiveFormItemcallsreadEffectiveFormsonce (the card's "up to three times" no longer holds); the repeats were inside that one call (theformandviewrow sets twice each).readFormRequestis a new public method onObjectStackProtocolImplementation(server-only, feature-detected), andmetadata-protocolnow usesAsyncLocalStorage(node:async_hooks; the package is already node-only).Verification
First read, by risk:
packages/metadata-protocol/src/protocol-form-reads.ts,formRequestScopeandreadInFormRequest: a memoized list is one object handed to several callers in the same request (every caller reads it, none writes it), and thelive()check that stops memoizing once the request settles.packages/rest/src/form-routes.ts,resolveFormBySlug: the five reads insideinOneReading, in their old order.packages/metadata-protocol/src/protocol-meta-list-reads.ts:readRowsat the active-row read ofreadFlattenedMetaItems, andinFormRequestScopeingetMetaItems/getMetaItemsPerPackage.Two-minute check:
pnpm --filter @objectstack/metadata-protocol build && pnpm --filter @objectstack/rest exec vitest run src/public-form-reads-once-37709.test.tsprintsTests 8 passed (8).Generated by Claude Code