Repository navigation
refactor(metadata-protocol): type the six query-options erasures in protocol.ts data reads - #29834
Conversation
…rotocol.ts data reads findData (find, count, aggregate), getData, cloneData and probeRecord now hand the engine a bag typed as IDataEngine declares it (EngineQueryOptions, EngineCountOptions, EngineAggregateOptions) instead of an `any`. The find bag is copied key by key from the normalized request bag, so the engine sees the same keys as before. protocol.ts leaves the query-options erasure baseline: its count reached 0. Claude-Session: https://claude.ai/code/session_01JQwxbYv9aJAo6MEAcF1dRK Co-authored-by: Claude <noreply@anthropic.com>
…the engine call The projection helpers answer `unknown`, so getData's working bag cannot carry the engine's declared type; the bag handed to engine.findOne is built key by key at the call instead, as findData's find bag is. Adds the patch changeset. Claude-Session: https://claude.ai/code/session_01JQwxbYv9aJAo6MEAcF1dRK Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 24 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 8 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. 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 1879d6f3aa1196dad15c1867e2b647ea3153593f && git checkout 1879d6f3aa1196dad15c1867e2b647ea3153593f
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 64646aed2ef5ebb2c628c50d9f3fab19a43c62df e16c71d28179f23f04345b95fcbe6a066ebadf52 && git checkout -B drift-repro 64646aed2ef5ebb2c628c50d9f3fab19a43c62df && git merge --no-ff e16c71d28179f23f04345b95fcbe6a066ebadf52
node scripts/docs-audit/affected-docs.mjs --json 64646aed2ef5ebb2c628c50d9f3fab19a43c62df
|
|
domain:server#4 · os-warren · session_01JQwxbacSXJQqAztgt4UMrS 席位核对ACCEPT ·
|
Requested by Warren · project thread
Fixes #29764
Clause-②: no
Metadata-protocol: none
维护者速读
protocol.ts数据读取里六处把引擎查询参数擦成any的调用点(findData的 find、count、aggregate,getData,cloneData,probeRecord)改为按引擎声明的类型传参(EngineQueryOptions、EngineCountOptions、EngineAggregateOptions);protocol.ts从擦除基线中移除(计数归零)。src/protocol.ts(33,065 lines, +10,169 in 30 days) along itsObjectStackProtocolImplementationseams, one move-only slice per PR #25467 席位裁决 A(6594932448):基线按文件登记且只减不增,这四个方法体带着擦除点搬不出类。类型化之后,[maintainer] refactor(metadata-protocol): splitsrc/protocol.ts(33,065 lines, +10,169 in 30 days) along itsObjectStackProtocolImplementationseams, one move-only slice per PR #25467 才能把剩下四个方法体作为下一刀搬走。groupBy/aggregations,引擎本来就把 null 读作缺省。回滚即整体 revert。protocol.ts中findQuery的构造(findData里);getData的findOneQuery;scripts/query-options-erasure-baseline.json删掉的一行。pnpm check:query-options-erasure,预期✓ … holds,且输出里不再出现protocol.ts。What changes
scripts/query-options-erasure-baseline.jsongrandfathered sixquery-options/no-any-erasuresites inpackages/metadata-protocol/src/protocol.ts. Measured onorigin/maineb05ea2fwith the rule run over the file and the grandfathering lifted:findDataaggregate{ where, groupBy, aggregations, having, search, searchFields, context } as anyEngineAggregateOptionsfindDatafindoptions, declaredconst options: anyEngineQueryOptionsfindDatacount{ where, search, searchFields, context } as anyEngineCountOptionsgetDatafindOnequeryOptions, declaredconst queryOptions: anyEngineQueryOptionscloneDatafindOne{ where: { id }, ...(ctxOpt as any) } as anyEngineQueryOptionsprobeRecordfindOne{ where: { id }, context: { isSystem: true } } as anyEngineQueryOptionsEach type is the one
IDataEnginedeclares for that method (packages/spec/src/contracts/data-engine.ts). How each site is typed:aggregateandcount: the literal is bound to a typed const (aggregateQuery,countQuery) and the assertion is gone.cloneDataandprobeRecord: the assertions are dropped. The literals already matchfindOne's parameter.findinfindData:optionsis the caller's raw request bag, normalized in place over about 600 lines, so it keeps its working type. The bag handed to the engine is now a typedfindQuery, built from the nine keys the engine's find set holds (context,where,fields,orderBy,limit,offset,search,searchFields,expand). Each key is copied only when it is present. By that line every other key has been folded (top,selectand the other aliases), deleted (object,count,joins,windowFunctions,cursor,distinct,having) or moved intowhere(the implicit field filters).groupByandaggregationscan only be null there: a non-empty one takes the aggregate branch, an empty one is refused, and a non-array is refused. The engine already reads a null option as absent (rejectUnknownEngineOptionsskips it, and nothing on the find path reads either key), so leaving them out changes nothing.findOneingetData:queryOptionsstays the working bag, because the two projection helpers it calls (projectionFieldsValue,storedMetadataBodyProjection) answerunknown. The bag handed to the engine is a typedfindOneQuerybuilt the same way from its four keys (where,context,fields,expand).protocol.tsleaves the baseline: its count is 0, and its key is removed, as the ratchet asks of a fixed file.eslint.config.mjsneeds no edit, since the rule'signoresare read from the baseline's keys. No body moves: that is #25467's next cut.Tests
No pin needed an edit, and no new pin was added: the change is in types plus a key-by-key copy that hands the engine the same keys. A reverse check shows the types reach the six bags. With one wrong key planted in each (
directioninfindQueryand inprobeRecord,limitinaggregateQuery,orderByincountQuery,sortinfindOneQuery,filterincloneData's literal), the package typecheck exited 2 with sixTS2353errors, one per site. The file was restored fromHEADandgit diff HEADwas empty afterwards.Acceptance notes
getData's working bag andfindData's raw request bag still holdanyvalues. What tsc now checks at all six sites is the key set the engine receives, which is the failure the rule exists for. TypinggetData's working bag itself would needprojectionFieldsValueandstoredMetadataBodyProjectionto answerstring[]when they are givenstring[]. Those are type-only signature changes inprotocol-list-query-params.tsandmetadata-redaction.ts, outside this card's surface, and they are noted here, not filed.plugin-approvals/src/approval-service.tsfalling 10 → 4 on main. That row belongs to another file and is left as it is.Verification
On
e16c71d2(the branch merged withorigin/mainb0ef25f5; no file of this diff moved on main):eb05ea2f, the rule run overprotocol.tswith the grandfathering lifted: 6 sites (the table above). On this head: 0.@objectstack/objectql, package typecheck and package test, each through os-verify-lock:VERDICT command-exit 0. Test Files 310 passed, 4 skipped (314); Tests 22305 passed, 26 skipped (22331).pnpm check:query-options-erasureexits 0:✓ query-options-erasure ratchet holds: 38 unswept non-test site(s) in 14 file(s), none new, baseline key set verified againstb0ef25f, no files added.pnpm lintexits 0, andeslint packages/metadata-protocol --no-inline-configexits 0 withprotocol.tsnow under the rule.index.d.tsis byte-identical. Built from main'sprotocol.tsand from this head with the same dependency build: sha2563a15d153…f48075on both sides, ESM equal to CJS.node scripts/pm/dispatch-gates.mjs --commandsderived 63 commands.--ranreports 63 derived, 61 run, 2 NOT-MEASURED, 0 UNRUN, and each run family exits 0. The two NOT-MEASURED exit 3 on a prerequisite, so their reading is CI's:check:dual-build-cjs-loadsneeds every package built, andcheck-plugin-teardown-shape.mjs --self-testneeds an unshallowed clone.Human Minimum
packages/specholds no runtime logic. (untouched)pnpm lintpasses.main, one pull request.packages/spectouched: n/a.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code