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 |
… in batches, not 1200 serial inserts (objectstack-ai#38235) <!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu3fvgcmTNiNVgQgr2PxiD85)_ Fixes objectstack-ai#38223 Clause-②: no Metadata-protocol: none ## 维护者速读 - 是什么:用户无感,只改一个测试文件。审批插件里“超过 500 条已决审批后仍能报出卡住的请求”这组用例,造数据从 1200 次逐行插入改成每批 200 行的批量写。 - 为什么:属于「CI 稳定与合并队列提速」专题(objectstack-ai#38081)。这条用例在忙的队列机器上跑到 5.8 到 13 秒,超过 5 秒上限,已经把不相关的 PR(objectstack-ai#38164、objectstack-ai#38167)弹出合并队列。量下来九成时间花在逐行插入上,扫描本身只要约 50 毫秒。 - 出错会怎样:只影响测试。数据规模、顺序和断言都没变,还多了一条“601 行全部被读到”的断言;撤掉 objectstack-ai#37808 的修法时,两条用例照样变红。 - 要你做的:无。 ## What changes `packages/plugins/plugin-approvals/src/stranded-request-inspection.test.ts`, the `objectstack-ai#37808 — past 500 decided requests` block only: - `insertAll` seeds through the engine's own array insert, `engine.insert('sys_approval_request', rows[], …)`, in batches of `SEED_BATCH = 200` rows, instead of one `engine.insert` per row. Same rows, same insertion order, same `isSystem` context, same real `ObjectQL` over `SqlDriver` (better-sqlite3, in-memory). - The batch is 200, not the whole set: one multi-row INSERT of 600 or 1200 rows is refused by SQLite with `too many terms in compound SELECT` (its default 500-term compound limit; knex emits a multi-row insert as a compound SELECT there). A comment beside `insertAll` says why the batch exists and why it is 200. - The 600-row case also asserts `out.scanned === 601`: the newest window (ids 102–601) plus the first walk page (ids 1–500) read every seeded row, so a short batch write cannot pass it silently. This only adds an assertion; none is removed or loosened. No timeout was raised, nothing is skipped, and the scale (600 and 1201 decided requests, 500 per window, 3 + 3 sweeps) is unchanged. ## Why The card's evidence (comment 7236773117): the case took about 1 s locally and 5.8 to 13 s on queue runners, against the 5000 ms default. Measured here, on the case "an older strand outside the newest window is reached by the cursor": | | seeding 1201 rows | 6 sweeps | case total | |---|---|---|---| | before (serial inserts) | 789 / 1146 ms | 53 / 63 ms | ~1000 ms | | after (batches of 200) | 93 / 99 / 103 ms | 41 / 54 / 52 ms | 149–178 ms | The 600-row case went from about 570 ms to 100–170 ms. The whole file's 39 tests are unchanged and green. ## Verification Ablation (the cases still detect the bug they pin): with `inspectStrandedRequests` reverted to the pre-objectstack-ai#37808 read (no `orderBy` on the newest window, no id cursor on the walk), the 600-row and 1201-row cases both fail under the new seeding, exactly as they fail under the old one; CONTROL passes in both. Restored, 3/3. <details><summary>runs</summary> Head 19eeab6. - `pnpm turbo run build --filter='@objectstack/plugin-approvals^...'`: exit 0. - `npx vitest run src/stranded-request-inspection.test.ts` (in the package), three times: 39/39 passed each time. - `npx vitest run` (whole package): 131 files, 1979 tests passed. - `pnpm typecheck` (package, includes `check:test-typecheck`): exit 0. - `node scripts/pm/dispatch-gates.mjs --commands --changed`: 54 derived; 51 exit 0; 3 exit 3 (PREREQUISITE NOT MET), so NOT MEASURED locally and left to CI: `node scripts/check-plugin-teardown-shape.mjs --self-test` (its fixture commit is out of this shallow clone), `pnpm check:dual-build-cjs-loads` and `pnpm check:i18n` (both read every package's `dist/`; only this package's closure is built here). `--ran` reconcile: 54 accounted, 0 UNRUN. - `npx eslint` on the changed file: exit 0. </details> ## Acceptance notes - Found on the way, not fixed here (out of this card's test-only scope): an `ObjectQL` array insert of more than about 500 rows on SQLite throws `too many terms in compound SELECT` from `SqlDriver.bulkCreate`, which does not chunk. Reported to the seat as a follow-up candidate. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (not touched) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; eslint on the changed file passes (the full `pnpm lint` was not run locally; CI runs it). - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. (branch `claude/project-thread-4xkl1n` is the harness-assigned name) - [x] 5. A change that publishes carries a changeset: this diff is a test file only and publishes nothing, so no changeset (`skip-changeset`). - [x] 6. `packages/spec` touched: no. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English (the 维护者速读 block is the maintainer summary). - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgVv7fqmna3sqqbjzf2 Co-authored-by: Claude <noreply@anthropic.com>
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