Skip to content

refactor(metadata-protocol): type the six query-options erasures in protocol.ts data reads - #29834

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-bzwi04
Nov 3, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-bzwi04

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread

Fixes #29764

Clause-②: no
Metadata-protocol: none

维护者速读

What changes

scripts/query-options-erasure-baseline.json grandfathered six query-options/no-any-erasure sites in packages/metadata-protocol/src/protocol.ts. Measured on origin/main eb05ea2f with the rule run over the file and the grandfathering lifted:

line on main member engine call erased expression declared type now
6124 findData aggregate { where, groupBy, aggregations, having, search, searchFields, context } as any EngineAggregateOptions
6220 findData find options, declared const options: any EngineQueryOptions
6296 findData count { where, search, searchFields, context } as any EngineCountOptions
6371 getData findOne queryOptions, declared const queryOptions: any EngineQueryOptions
6455 cloneData findOne { where: { id }, ...(ctxOpt as any) } as any EngineQueryOptions
6612 probeRecord findOne { where: { id }, context: { isSystem: true } } as any EngineQueryOptions

Each type is the one IDataEngine declares for that method (packages/spec/src/contracts/data-engine.ts). How each site is typed:

  • aggregate and count: the literal is bound to a typed const (aggregateQuery, countQuery) and the assertion is gone.
  • cloneData and probeRecord: the assertions are dropped. The literals already match findOne's parameter.
  • find in findData: options is 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 typed findQuery, 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, select and the other aliases), deleted (object, count, joins, windowFunctions, cursor, distinct, having) or moved into where (the implicit field filters). groupBy and aggregations can 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 (rejectUnknownEngineOptions skips it, and nothing on the find path reads either key), so leaving them out changes nothing.
  • findOne in getData: queryOptions stays the working bag, because the two projection helpers it calls (projectionFieldsValue, storedMetadataBodyProjection) answer unknown. The bag handed to the engine is a typed findOneQuery built the same way from its four keys (where, context, fields, expand).

protocol.ts leaves the baseline: its count is 0, and its key is removed, as the ratchet asks of a fixed file. eslint.config.mjs needs no edit, since the rule's ignores are 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 (direction in findQuery and in probeRecord, limit in aggregateQuery, orderBy in countQuery, sort in findOneQuery, filter in cloneData's literal), the package typecheck exited 2 with six TS2353 errors, one per site. The file was restored from HEAD and git diff HEAD was empty afterwards.

Acceptance notes

  • getData's working bag and findData's raw request bag still hold any values. What tsc now checks at all six sites is the key set the engine receives, which is the failure the rule exists for. Typing getData's working bag itself would need projectionFieldsValue and storedMetadataBodyProjection to answer string[] when they are given string[]. Those are type-only signature changes in protocol-list-query-params.ts and metadata-redaction.ts, outside this card's surface, and they are noted here, not filed.
  • The ratchet also reports plugin-approvals/src/approval-service.ts falling 10 → 4 on main. That row belongs to another file and is left as it is.

Verification

On e16c71d2 (the branch merged with origin/main b0ef25f5; no file of this diff moved on main):

  • Measure on main eb05ea2f, the rule run over protocol.ts with the grandfathering lifted: 6 sites (the table above). On this head: 0.
  • Build of the package's dependency closure plus @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-erasure exits 0: ✓ query-options-erasure ratchet holds: 38 unswept non-test site(s) in 14 file(s), none new, baseline key set verified against b0ef25f, no files added.
  • pnpm lint exits 0, and eslint packages/metadata-protocol --no-inline-config exits 0 with protocol.ts now under the rule.
  • The published index.d.ts is byte-identical. Built from main's protocol.ts and from this head with the same dependency build: sha256 3a15d153…f48075 on both sides, ESM equal to CJS.
  • node scripts/pm/dispatch-gates.mjs --commands derived 63 commands. --ran reports 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-loads needs every package built, and check-plugin-teardown-shape.mjs --self-test needs an unshallowed clone.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (untouched)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: n/a.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English (the 维护者速读 block is the dispatch template's).

Generated by Claude Code

…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>
@github-actions github-actions Bot added size/s documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/metadata-protocol, touching 18 documentable anchor(s).

24 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 64646aed2ef5ebb2c628c50d9f3fab19a43c62df.

⛔ 8 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 1 cross-cutting symbol(s) contributed no route anchor: findData (4 routes)
  • the SDK route bridge reached 61 of 219 client-bound route-ledger rows — the other 158 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 158: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 103 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 10 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 64646aed2ef5ebb2c628c50d9f3fab19a43c62df → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 1879d6f3aa1196dad15c1867e2b647ea3153593f — the merge of head e16c71d28179f23f04345b95fcbe6a066ebadf52 into base 64646aed2ef5ebb2c628c50d9f3fab19a43c62df, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 64646aed2ef5ebb2c628c50d9f3fab19a43c62df → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#4 · os-warren · session_01JQwxbacSXJQqAztgt4UMrS

席位核对

ACCEPT · domain:server#4 · head e16c71d28179f23f04345b95fcbe6a066ebadf52 · 2026-11-03T07:10Z · seat review of record at TIER_DEFAULT for the whole PR. Clause-②: no and Metadata-protocol: none stand (types only; index.d.ts byte-identical to main), so no contract review is owed. Not governed: check-governed-merges --pr 29834 0 of 3 paths, +53/−9.

  1. Shape: draft, base main, Fixes #29764. 3 files: the six query-options/no-any-erasure sites in protocol.ts (findData find / count / aggregate, getData, cloneData, probeRecord) pass EngineQueryOptions / EngineCountOptions / EngineAggregateOptions as IDataEngine declares them, with no casts; protocol.ts leaves scripts/query-options-erasure-baseline.json; one patch changeset. No body moves, no packages/spec. Inside claim 6596359196.
  2. Premise measured: the seat read the two rebuilt bags against the code above them on this head. findData's findQuery copies context, where, fields, orderBy, limit, offset, search, searchFields and expand when present. Every other key is folded first (top → limit, $ aliases, implicit filters → where) or deleted by the strip of object / count / joins / windowFunctions / cursor / distinct / having. The only key left out is a null groupBy / aggregations; a non-empty one took the aggregate branch and an empty one was refused. getData's bag only ever holds where, context, fields and expand. The engine sees the same keys as before.
  3. Gates on this head: check-runs pinned to e16c71d2: 48 runs, 35 success, 13 skipped, none failed; git merge-tree against origin/main clean. Dev (report 6597359173): typecheck, metadata-protocol suite 22,305 passed, check:query-options-erasure holds with protocol.ts at 0, pnpm lint 0; dispatch-gates --ran 63 derived / 61 run / 2 NOT MEASURED (exit-3 prerequisites, covered by CI) / 0 UNRUN.
  4. Accepted deviations: eslint.config.mjs unchanged, because its ignores derive from the baseline keys.
  5. Out of scope: typing getData's working bag itself needs two helper signatures outside the surface (PR Acceptance notes). It is noted, not carded: nothing is erased once the bag is handed on. Next, [maintainer] refactor(metadata-protocol): split src/protocol.ts (33,065 lines, +10,169 in 30 days) along its ObjectStackProtocolImplementation seams, one move-only slice per PR #25467 moves the four remaining data-read bodies as one E2 cut. Skills-docs: not owed.
  6. Landing: not governed, under 3000 lines, no contract review owed ⇒ the seat lands it (pr_ready + automerge_enable). At MERGED: landing record on metadata-protocol: type the six query-options erasures in protocol.ts data reads (findData, getData, cloneData, probeRecord) so their bodies can leave the class #29764; [maintainer] refactor(metadata-protocol): split src/protocol.ts (33,065 lines, +10,169 in 30 days) along its ObjectStackProtocolImplementation seams, one move-only slice per PR #25467's next cut is ordered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/s tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

1 participant