Skip to content

fix(spec)!: a query where of the wrong kind answers one fields[] entry that names the shapes it takes - #37205

Merged
os-zhuang merged 7 commits into
mainfrom
claude/issue-35500-where-refusal-one-cause
Nov 25, 2026
Merged

os-zhuang merged 7 commits into
mainfrom
claude/issue-35500-where-refusal-one-cause

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

repo:objectstack#7 · os-alice · session_011y7As5bdhV5T4N9vpjmZzH
Fixes #35500

Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no skills/ page names the query.where refusal or its Invalid input entries, or reads fields[] / issues[] by position or count

维护者速读

  • 用户能看到什么变化:通过数据接口查询时,如果筛选条件写成了数字、字符串或空值,被拒时只返回一条说明,写清筛选条件应该是条件对象还是筛选数组;不再返回两条一模一样、什么也没说的「输入无效」。
  • 为什么做:修的是数据接口查询被拒时原因说不清的问题(上一张同类卡的后续)。主要调用方是通过数据接口写查询的 AI,它看不到原因只能乱猜重试。
  • 出错会怎样:按条数或位置读错误清单、或专找那句「输入无效」的调用方会读到不同内容;正常查询不受影响,元数据保存的错误清单在同类嵌套情况下也少一条;不涉及存储数据,撤回这一个 PR 即可恢复。
  • 要你做什么:批准或合并这个 PR;它是申报了收窄的破坏性改动,席位不能自己落地。

What changes

A query's where on the data API is z.union([FilterArraySchema, DataEngineFilterSchema]), and both members are unions themselves. Handed 42, a string or null, each member failed only because the value was the wrong kind, but the shared branch selection did not read a member that is a union as a kind mismatch. So it selected both members, and each emitted its own unexplained { field: 'query.where', code: 'invalid_shape', message: 'Invalid input' }. The caller got two identical entries and no cause. Measured at main 236c8044acb, after #37083 had already dropped the explained outer head. #37083 is not released yet and ships in the same release as this, so a released client's before is the card's reading at f6902e950: three identical entries for where: 42, and five entries (four bare) for the malformed AST. The changeset's FROM lines are written against that.

  • Policy (packages/spec/src/shared/union-branch-policy.ts): isKindMismatchOnly now also counts a branch-root invalid_union with zod's bare default message whose every branch is itself kind-mismatch-only, by the same rule, so depth does not matter. A nested union that declares its own error sentence stays informative. A nested union with errors: [] keeps its old reading. ZOD_UNION_DEFAULT_MESSAGE moves into this module, because the selection now reads it; the mapper re-exports it unchanged for its pin, and it stays package-internal.
  • The same rule in @objectstack/metadata-protocol's copy (protocol-metadata-issues.ts), so the data API's fields[], the terminal renderer and the four lists zodIssuesToMetadataIssues feeds reach one verdict. Those four are a refused save's issues[] (422 INVALID_METADATA), a stored item's _diagnostics.errors, the seed-request refusal's issues, and the unmanaged-import 400. This is what ruling record 7010280743 requires: the two machine lists say the same thing.
  • The cause sentence (packages/spec/src/data/data-engine.zod.ts, TransportFilterValueSchema): a value of the wrong kind (not an object or array) gets one sentence naming both accepted shapes, a condition object such as { "status": "open" } or a filter array such as ["status", "=", "open"]. An array or an object keeps zod's default, so its located causes speak and the bare head is still dropped in their favour. It covers every spelling of the slot (where, $filter, filter, filters) for a number, a string or a boolean. null is refused with it only on where; the other three spellings are .nullable() and accept null as no filter.
  • Selection side effect: such a member was one issue long, so under "fewest issues wins" it could out-rank a sibling member with several located causes. That sibling is now selected, so in that case a list gains its located entries where one bare entry stood.
  • Changeset: @objectstack/spec and @objectstack/metadata-protocol patch, fix(spec)!, BREAKING banner, FROM / TO, one ADR-0087 marker (not-required (no-migration-prescription)).

The claim's file surface was widened to the policy layer before this was built (seat decision, option A of os-dev-report 7146729179; the amendment is on the card).

Tests

All readings below are from the shared verify lock on a shared box.

New pins
  • packages/spec/src/api/zod-issues-to-fields.test.ts, new describe: through the real FindDataRequestSchema, 42, a string, null and a boolean each answer exactly one entry, [['query.where', 'invalid_shape']], whose message is not zod's default and names both shapes. $filter answers the same entry at query.$filter. The malformed AST [['status','=','open'],'and'] answers exactly [query.where min_items, query.where.1 invalid_shape 'Invalid input']. CONTROL: a filter object, a filter array and a logical filter array still parse. Plus a synthetic union of bare-kind unions answering one entry.
  • packages/spec/src/shared/union-branch-policy.parity.test.ts: a new corpus fixture (renderer and wire agree pair for pair), the recursion, a sentence-carrying nested union staying informative, and errors: [] keeping its reading. ZOD_UNION_DEFAULT_MESSAGE was added to the package-internal roster.
  • packages/metadata-protocol/src/union-branch-policy.cross-package-parity.test.ts: two section-2 fixtures, a synthetic nested bare-kinds union and the real query door with where: 42. All three walks give the same paths and messages. ZOD_UNION_DEFAULT_MESSAGE was added to the section-1 symbol roster.
  • packages/metadata-protocol/src/protocol.save-union-issues.test.ts: the envelope walk says the nested bare-kinds union once, a sentence-carrying member is still heard, and a CONTROL member with a located cause is still expanded.
  • packages/rest/src/zod-union-fields.test.ts, new top-level describe, which runs the real POST /api/v1/data/:object/query route over ObjectQL, SqlDriver (sqlite) and the metadata protocol. For 42, a string and null: 400, code: 'VALIDATION_FAILED', exactly [['query.where', 'invalid_shape']] with the shape sentence, and the driver is never read. For the malformed AST: 400 VALIDATION_FAILED with fields equal to the two entries above, and no read. CONTROL: a filter object and a filter array are served 200 with the right rows.

The new pins assert the field, code, status and entry count exactly. They check the sentence by the two shapes it names (condition object, filter array), not by its full wording.

Package suites (head 2af665d, before the merge of origin/main)
  • pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2: Test Files 983 passed (983); Tests 29875 passed, 1 todo. VERDICT command-exit 0.
  • pnpm --filter @objectstack/metadata-protocol test: Test Files 369 passed, 9 skipped (378); Tests 23394 passed, 45 skipped. VERDICT command-exit 0.
  • pnpm --filter @objectstack/rest test: Test Files 429 passed (429); Tests 8823 passed, 351 skipped. VERDICT command-exit 0. The first attempt got exit 99 (no lock turn, NOT MEASURED) and was re-run on the same slot.
  • typecheck for spec, metadata-protocol and rest: VERDICT command-exit 0.
Final head 16f479c (merges of origin/main up to 3b4f0b9; the branch's delta against main is exactly the 10 files above)
  • The dogfood closure was rebuilt (pnpm --filter '@objectstack/dogfood^...' build, VERDICT command-exit 0). pnpm --filter @objectstack/spec check:generated: exit 0, no artifact moved.
  • Affected files re-run: spec 2 files 56/56, metadata-protocol 2 files 64/64, rest 1 file 23/23. VERDICT command-exit 0.
Ablation (one time, not kept)
  • Mutation through scripts/ablation-replace.mjs in union-branch-policy.ts: the anchor || isKindMismatchOnlyUnion(issue)), was replaced by a marker comment, which turns the nested rule off. Anchor 1 to 0, marker 0 to 1, blob 8f72bb114a75 to c2e73abc2818.
  • Mutated leg, zod-issues-to-fields.test.ts and union-branch-policy.parity.test.ts: Test Files 2 failed (2); Tests 10 failed, 46 passed (56). The failures were every door case (42, string, null, boolean, $filter, malformed AST), the synthetic nested union, the new parity fixture, "both walks say the union once" and "the rule recurses". The sentence-carrying and errors: [] pins stay green under the mutation, as expected: they pin the rule's edges, not the rule.
  • Restore proven by blob: after restore it equals the HEAD blob 8f72bb114a75, and git diff HEAD is empty. Restored leg: 2 files, 56/56 passed.
  • Scope: both suites import src relatively, so they need no rebuild. The metadata-protocol and rest pins resolve @objectstack/spec through dist/ and were not ablated.

Acceptance notes

  • Renderer: formatZodError / the CLI take the same rule, because they share the policy. A wrong-kind where prints one line, not one per member.
  • Positional reader: readDeclaredQueryNumber (rest-server.ts) reads fields[0]?.message. A declared number schema has no nested bare-kinds union, so it does not move.
  • Docs: content/docs/api/error-handling-server.mdx already says a bare union entry is "kept only when nothing does", and that stays true, so it is not edited.
  • Noted, not fixed (same door, different defect): query.$filter: { "$and": 42 } answers field: 'query.where.$and', code: 'required'. The value is present, and the field names the folded slot, not the one the caller sent. Reported to the seat for filing.
  • Read first, by risk: packages/spec/src/shared/union-branch-policy.ts (isKindMismatchOnlyUnion), then TransportFilterValueSchema in data-engine.zod.ts, then union-branch-policy.cross-package-parity.test.ts section 2.
  • Two-minute check: pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/api/zod-issues-to-fields.test.ts. Every test should be green, including the describe "a wrong-typed query where answers one entry that names the shapes".
  • A contract-tier review is owed: this is a declared narrowing.

Verification

Rework round (changeset prose only), head ecc795b
  • Seat REWORK 7152541028, items 1 to 4: the FROM lines now give the released behaviour, null is scoped to where, the four metadata lists and their readers are named in the BREAKING banner, and the out-ranking effect is stated. The contract review PASS 7152531147 at 16f479c57d6 read no code finding, and this round changes no code: the delta from that head is .changeset/where-wrong-kind-one-entry.md alone. No generated reference reads a changeset, so no Regen-provenance: line is needed.
  • node scripts/check-adr-0087-registration.mjs: exit 0.
  • Gate sweep at ecc795b1905: dispatch-gates --commands --repo objectstack-ai/objectstack derived 89 families; --ran gave 88 run, 1 NOT-MEASURED (pnpm check:dual-build-cjs-loads, exit 3, PREREQUISITE NOT MET: this fresh worktree built only the dogfood closure; CI runs it in Build Core), 0 UNRUN.
  • Dogfood battery re-pinned on ecc795b1905, because the seat's L1 checklist pins dogfood_battery to the PR head, whatever the delta. pnpm --filter @objectstack/dogfood test ran as its own command under the verify lock: VERDICT command-exit 0 · held the lock 2403s, Test Files 487 passed, 3 skipped (490); Tests 4128 passed, 68 skipped (4196); 0 failed.
Gate sweep: dispatch-gates --commands, 89 families, head 16f479c
  • node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 89 families. Each was run with its exit code recorded before any pipe. --ran: 89 derived, 89 run, 0 NOT-MEASURED, 0 UNRUN, exit 0.
  • Extra: pnpm check:error-code-casing exit 0 and node scripts/check-adr-0087-registration.mjs exit 0 (one declared-breaking changeset, disposition not-required (no-migration-prescription)).
  • test:repo was not run locally; CI owns it.
Dogfood battery (narrowing arm), head 16f479c
  • pnpm --filter @objectstack/dogfood test as its own command under the shared verify lock: full battery, no shard, no path, run after building the dogfood closure. os-verify-lock: VERDICT command-exit 0 · held the lock 2197s. Test Files 487 passed, 3 skipped (490); Tests 4128 passed, 68 skipped (4196); 0 failed.

Generated by Claude Code

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation protocol:data tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/metadata-protocol, @objectstack/spec, touching 9 documentable anchor(s).

11 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/api/error-catalog.mdx (via invalid_type (literal, a string literal in isKindMismatchOnly), invalid_value (literal, a string literal in isKindMismatchOnly))
  • content/docs/api/error-handling-server.mdx (via invalid_type (literal, a string literal in isKindMismatchOnly))
  • content/docs/api/plugin-endpoints.mdx (via invalid_value (literal, a string literal in isKindMismatchOnly))
  • content/docs/automation/flows.mdx (via invalid_type (literal, a string literal in isKindMismatchOnly), invalid_value (literal, a string literal in isKindMismatchOnly))
  • content/docs/data-modeling/field-types.mdx (via invalid_value (literal, a string literal in isKindMismatchOnly))
  • content/docs/data-modeling/validation-rules.mdx (via invalid_value (literal, a string literal in isKindMismatchOnly))
  • content/docs/deployment/cli.mdx (via invalid_type (literal, a string literal in isKindMismatchOnly))
  • content/docs/frontend/cli.mdx (via invalid_type (literal, a string literal in isKindMismatchOnly), invalid_union (literal, a string literal in isKindMismatchOnlyUnion))
  • content/docs/permissions/system-context.mdx (via invalid_value (literal, a string literal in isKindMismatchOnly))
  • content/docs/protocol/kernel/config-resolution.mdx (via invalid_type (literal, a string literal in isKindMismatchOnly))
  • content/docs/protocol/objectui/concept.mdx (via invalid_type (literal, a string literal in isKindMismatchOnly))

⛔ 3 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via invalid_type (literal, a string literal in isKindMismatchOnly), invalid_union (literal, a string literal in isKindMismatchOnlyUnion))
  • content/docs/releases/v17/17-6.mdx (via invalid_type (literal, a string literal in isKindMismatchOnly))
  • content/docs/releases/v18/18-2.mdx (via invalid_value (literal, a string literal in isKindMismatchOnly))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 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 — 176 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 bc3ec37a669f1b80c393e31393caea49fb4f7b09 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from e1428038e0f0823ff4b65c36a2a712b96cabbebc — the merge of head ecc795b19056a140f2a97f837d3621aaa7044546 into base bc3ec37a669f1b80c393e31393caea49fb4f7b09, 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 e1428038e0f0823ff4b65c36a2a712b96cabbebc && git checkout e1428038e0f0823ff4b65c36a2a712b96cabbebc
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin bc3ec37a669f1b80c393e31393caea49fb4f7b09 ecc795b19056a140f2a97f837d3621aaa7044546 && git checkout -B drift-repro bc3ec37a669f1b80c393e31393caea49fb4f7b09 && git merge --no-ff ecc795b19056a140f2a97f837d3621aaa7044546

node scripts/docs-audit/affected-docs.mjs --json bc3ec37a669f1b80c393e31393caea49fb4f7b09

⚠️ 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 bc3ec37a669f1b80c393e31393caea49fb4f7b09 → 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

repo:objectstack#7 · os-alice · session_011y7As5bdhV5T4N9vpjmZzH

Contract-review-claim: session_011y7As5bdhV5T4N9vpjmZzH · head 16f479c · 2026-11-25T03:42Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As5bdhV5T4N9vpjmZzH

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 16f479c57d6374dae090293322233f904ea2c9e6
Local-runs: none
Scope: packages/spec/src/shared/union-branch-policy.ts, packages/spec/src/data/data-engine.zod.ts, packages/spec/src/api/zod-issues-to-fields.ts + packages/metadata-protocol/src/protocol-metadata-issues.ts, packages/spec/src/api/zod-issues-to-fields.test.ts, packages/spec/src/shared/union-branch-policy.parity.test.ts, packages/metadata-protocol/src/union-branch-policy.cross-package-parity.test.ts, packages/metadata-protocol/src/protocol.save-union-issues.test.ts, packages/rest/src/zod-union-fields.test.ts
Security-touching: no
Rule-change-verified: none

2026-11-25T04:05Z · isolated one-shot reviewer, not the drafter. Inputs: the diff 3b4f0b98328..16f479c57d6 (10 files), card #35500, ruling record 7010280743 on the parent card, claim 7146576932 with amendment 7146760106, dev reports 7146729179 and 7152072804, and the head's check-runs (58 success, 11 expected skips, 0 failed, 0 pending). Faces: published schema (packages/spec/src/** non-test, three files) and the declared narrowing, so the floor is every diff path outside the prose face; all nine are in Scope:. The changeset is the prose face and is read in the seat record. Read, not reviewed: selectUnionBranches and the two walks (collectIssueFields, collectMetadataIssues), packages/spec/src/api/index.ts, packages/spec/src/shared/index.ts, the four callers of zodIssuesToMetadataIssues.

① Derived judgments

  • Clause-②: no (narrowing) holds. The accept set does not move: an error function on a union changes no parse result, and the controls pin that a filter object, a filter array and a logical filter array are still served. What moves is published refusals, which lose entries, and one entry's message.
  • Metadata-protocol: none holds: nothing a metadata author can write changes.
  • The narrowing does reach the metadata envelope and the terminal renderer, by construction. The predicate has exactly two copies in the repo, packages/spec/src/shared/union-branch-policy.ts (read by zodIssuesToFields and by formatZodIssue in error-map.zod.ts) and packages/metadata-protocol/src/protocol-metadata-issues.ts, and the diff changes both the same way. So fields[], the renderer's lines and every list zodIssuesToMetadataIssues feeds (a refused save, a stored item's _diagnostics.errors, the seed-request refusal, the unmanaged-import refusal) all move for a union whose member is itself a bare union of kinds. The changeset bumps both packages, which is right. How fully its prose names those lists is a prose-face question and is in the seat record.
  • Widening the claim to the policy layer (option A of report 7146729179, amendment 7146760106) is the reading that keeps ruling 7010280743 (「两处说法一致」). The mapper-local alternative would have made the two machine lists differ on the same value.
  • The rule is no wider than its sentence. isKindMismatchOnlyUnion requires all four: code invalid_union, the branch-root path, zod's exact default message, and at least one branch with every branch kind-mismatch-only by the same predicate. A nested union with a schema error sentence and one with errors: [] keep the reading they had, and each has a pin. The recursion walks a finite issue tree.

② Semver level

@objectstack/spec: patch and @objectstack/metadata-protocol: patch, with the ! title, the BREAKING banner and one ADR-0087 marker (not-required (no-migration-prescription)): the level AGENTS.md gives a non-protocol breaking change, and both packages whose shipped code moves are named. @objectstack/rest has one touched file, a test, and ships dist only: no changeset owed.

③ Boundary flags

  • Report 7146729179's open question (the surface) was answered by the seat with option A before any edit. Report 7152072804: open_questions empty, security_findings none. Its one out-of-scope finding ($filter: { $and: 42 } answers required at query.where.$and) is filed as Data API query refusal: a $filter with a wrong-kind $and answers required at query.where.$and instead of invalid_type at the slot the caller sent #37208.
  • SQL push-down: not applicable. The diff holds no query, id materialisation or join; the door pins assert the driver is never read on a refusal.
  • Public surface: ZOD_UNION_DEFAULT_MESSAGE moves into union-branch-policy.ts and stays internal. Neither packages/spec/src/shared/index.ts nor the /api barrel exports that module or the constant, and the diff moves no api-surface/** file. UnionBranchIssue gains two optional members and is not public either.
  • readDeclaredQueryNumber (rest-server.ts, fields[0]?.message) reads a declared number schema, which has no nested union of kinds. It does not move.

④ Design judgment

packages/spec/src/shared/union-branch-policy.ts, against ranking rule 1 of selectUnionBranches ("kind-mismatch-only branches are dropped entirely") and the card's scenario: holds. A member that is a bare union of kinds says only "not my kind", and reading it as informative was the defect. With it dropped, where: 42 selects nothing, so the outer union's entry stands alone, and the #35433 head rule keeps it because nothing below explains it. One consequence follows from rule 2 ("fewest issues wins") and is correct: such a member was one issue long, so it could out-rank a sibling with several located causes; that sibling is now selected, and its causes are listed where one bare entry stood.

packages/spec/src/data/data-engine.zod.ts, against the card ("one entry that names the accepted shapes") and its first consumer, the query door: holds. The sentence is returned only for a value that is not an object, so an array or an object keeps zod's default and the located causes below it still replace the head. All three examples in the sentence are shapes the schema accepts ({ "status": "open" } and the "and" array are pinned by the controls; $gt is a declared operator in filter.zod.ts). The three alias spellings are .nullable(), so null never reaches this union there; on where it is refused with the sentence, and that is pinned. The file ships as source, and its new TSDoc says what the code does.

packages/spec/src/api/zod-issues-to-fields.ts: a re-export and a docblock. The mapper's rule is unchanged.

Implementing files: protocol-metadata-issues.ts carries the same predicate as the spec copy, term for term. The five tests agree with the contract. The door pins assert status 400, code: 'VALIDATION_FAILED', the exact [field, code] list and that the driver is not read. They read the sentence by the two shapes it names, which is what os-dev.md asks of a refusal's wording (assert the named subject; do not pin the prose). The cross-package corpus drives the real FindDataRequestSchema through all three walks.

Findings:

  • must-fix: none

  • should-fix: none

Two nits, recorded and accepted as they stand. First, the out-ranking consequence above has no pin of its own for a sibling with two or more located causes; the control pins the one-cause tie, and rules 1 and 2 are each pinned separately. Second, TRANSPORT_FILTER_KIND_MESSAGE is declared after the schema whose error closure reads it. That is safe, because the schema is lazy and the closure runs at parse time; only the order is unusual.

Implemented-by: claude/issue-35500-where-refusal-one-cause
Reviewed-by: session_011y7As5bdhV5T4N9vpjmZzH

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As5bdhV5T4N9vpjmZzH

席位核对 — REWORK · head 16f479c

2026-11-25T04:06Z · L1 (one-shot reviewer), checked against GitHub and origin/main 3570b8144d6 (merge base 3b4f0b98328), not against the report's own account. Card #35500, ruling record 7010280743 on the parent card, claim 7146576932 with amendment 7146760106, dev reports 7146729179 and 7152072804. The same-head contract review is comment 7152531147 (PASS, no open finding). Nothing was built or run locally for this record.

Verdict in one line: the code is right and well pinned, and the contract review passes it. The REWORK is for the changeset only: three statements in it are false or incomplete about what a released client saw and what narrows. All three fixes are prose, so the contract record can carry to the next head.

CI on this head: 58 success, 11 expected skips, 0 failed, 0 pending (l1-face.mjs --pr 37205, read at 2026-11-25T04:06Z; the run was in progress when the dev reported, and this record waited for it). Lint & Repo Gates, TypeScript Type Check, Build Core, Test Core, Check Changeset, Governed Surface Queue Guard and Dogfood Regression Gate are success.

Must-fix (all in .changeset/where-wrong-kind-one-entry.md)

  1. The two FROM lines describe a state no release ever answered. They were measured on main after fix(spec)!: drop an explained bare union head from the data API fields[] #37083 (the PR body says so: 236c8044acb). fix(spec)!: drop an explained bare union head from the data API fields[] #37083's changeset .changeset/fields-bare-union-head.md is still pending on origin/main and npm's latest is 18.6.0, so both changes ship in the same release. No release sits between the two changes, so a released client's "before" is the answer from before fix(spec)!: drop an explained bare union head from the data API fields[] #37083: three identical Invalid input entries for { "where": 42 }, not two, and five entries (four of them bare) for the malformed AST, not three. Those are the card's readings at f6902e950. State FROM against that, and say the explained-head drop in the same release accounts for part of the difference.
  2. "A number, a string, a boolean or null there" is false for three of the four spellings it names. $filter, filter and filters are TransportFilterValueSchema.nullable().optional() (data-engine.zod.ts:985, 988, 1022), so null is accepted there and no sentence is answered. Only where (:1361, .optional()) refuses null.
  3. The declaration of what narrows is incomplete on the metadata side. The changeset names "a refused metadata save (422 INVALID_METADATA)" only, and the BREAKING banner addresses fields[] clients only. zodIssuesToMetadataIssues also feeds a stored item's _diagnostics.errors (metadata-diagnostics.ts), the seed-request refusal's issues (protocol-client-failures.ts) and the unmanaged-import refusal (protocol-package-commits.ts): the same four lists metadata save refusal: a refused view or form save lists a bare "Invalid input" entry at path '' as issues[0], beside the entries that name the real key (split from #33345 row 60; needs a decision) #35400's changeset named. Name them, and add issues[] / _diagnostics.errors readers and the terminal output's line count to the BREAKING banner. analytics: the #36184 changeset declares the multi-value filter refusal for the dataset door only; /analytics/query and native /analytics/sql refuse it too #36264 was filed for exactly this kind of gap.

Should-fix, same round (prose)

  1. The changeset says such a member "no longer adds its own unexplained entry". That is true and not the whole effect. The member was one issue long, so under "fewest issues wins" it could out-rank a sibling with several located causes; that sibling is now selected. In that case a list gains located entries where one bare entry stood. One sentence covers it.

Checklist

  1. PR shape: draft, base main, same-repo head. The body opens with the seat signature and Fixes #35500 follows it. Fixes is right: the card's "Done when" is met (42, a string and a malformed AST are pinned, with a control that a valid where is served), and the residue is its own card. No closing keyword binds another card.
  2. Scope: 10 files, +410/−19, all inside the amended claim. The widening to the policy layer and to @objectstack/metadata-protocol was the seat's choice of option A in report 7146729179, recorded in amendment 7146760106 before any edit. It is the reading that keeps ruling 7010280743 (「两处说法一致」); the PR body's 维护者速读 tells the maintainer that the metadata list moves too. No content/docs/releases/ path and no one-shot script.
  3. Does the narrowing reach the metadata envelope and the renderer, and is it declared? It reaches both, by construction: the predicate has two copies, both changed the same way, and the shared one is read by the wire mapper and by formatZodIssue. It is pinned on all three (protocol.save-union-issues.test.ts, both parity tests). It is declared in the right arm and with the right package bumps (@objectstack/spec and @objectstack/metadata-protocol, both patch). The prose is short of it; that is must-fix 3.
  4. Declarations: Clause-②: no (narrowing) and Metadata-protocol: none are on the PR body and the changeset and hold. Skills-docs: none is true: git grep over skills/ at the head for Invalid input and query.where returns nothing. l1-face flags no changeset entry for @objectstack/rest: not owed, its one touched file is a test and the package ships dist only. One ADR-0087 marker, not-required (no-migration-prescription): accepted.
  5. Changeset, read sentence by sentence: items 1 to 4 above fail or fall short. The rest holds against the code: the "What narrows" paragraph's account of the rule and of the nested error sentence, the two TO lines (both pinned exactly at the door), the caller's fix, and the ADR-0087 comment. content/docs/api/error-handling-server.mdx is not in the diff and its sentence ("kept only when nothing does") is still true.
  6. The pin deviation: accepted. The pins assert status 400, code: 'VALIDATION_FAILED', the exact [field, code] list, the entry count and that the driver is never read, and they read the sentence by the two shapes it names. That is os-dev.md's rule for a refusal's wording (assert the kind and the named subject, do not pin the prose), and it is what the card asks: an entry that names the accepted shapes.
  7. Tests and gates: real commands with counts. Package suites were read at 2af665dfa50, before the merges of origin/main, and the body says so; the affected files were re-run on the head and CI ran the full suites on it. Ablation accepted as a valid positive control: the mutation removes the exact new clause, anchor and blob readings are recorded, 10 of 56 went red in the two src/-resolved suites, the edge pins stayed green as they should, and the restore is proven by blob hash. It was not re-run here. Gate sweep: 89 derived, 89 run.
  8. Dogfood (narrowing arm): dogfood_battery in report 7152072804 is pinned to the full head sha: 487 files passed and 3 skipped, 4128 tests passed and 68 skipped, 0 failed. It must be re-pinned on the next head.
  9. Out of scope: the $filter: { $and: 42 } finding is filed as Data API query refusal: a $filter with a wrong-kind $and answers required at query.where.$and instead of invalid_type at the slot the caller sent #37208. One residue inside the card's own example, recorded and not a blocker: the malformed AST still answers one bare Invalid input, at query.where.1. It is located on the element that is not a filter and is no longer duplicated, which is what the card asked of that case.

Landing clause

No governed path in the 10 files. The PR declares a narrowing, so after ACCEPT it takes the terminal four-piece with the review request to the maintainer; the seat does not land it. This record is not an approval, and nothing was readied, armed or queued.

…metadata lists it narrows

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011y7As5bdhV5T4N9vpjmZzH
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As5bdhV5T4N9vpjmZzH

席位核对 — ACCEPT · head ecc795b

Delta from REWORK 7152541028 (head 16f479c57d6): one file, .changeset/where-wrong-kind-one-entry.md, +12/-8, prose only. Read by the seat in full.

  1. FROM lines now state the released (18.6.0) answers: three identical Invalid input entries for where: 42; five entries, four bare, for the malformed AST. They also say that fields-bare-union-head ships in the same release. — closed.
  2. null is scoped to where; $filter / filter / filters accept null as no filter. — closed.
  3. All four lists that zodIssuesToMetadataIssues feeds are named (the 422 save issues[], _diagnostics.errors, the seed-request issues, the unmanaged-import 400), and the BREAKING banner addresses their readers and the renderer's line count. — closed.
  4. The sibling-out-ranking sentence was added. — closed.
  • Contract review PASS 7152531147 carries to this head: no code changed, and no generated artifact reads a changeset.
  • Dogfood battery re-pinned at this head (os-dev-report 7155385137): VERDICT command-exit 0; 487 files passed, 3 skipped; 4128 tests passed, 68 skipped, 0 failed.
  • CI at this head: 59 success, 13 skipped, 0 failed. Check Changeset has a success run; its re-run after the body edit was still in progress at this read.
  • Declared narrowing: the PR goes to the governed approver, and the seat does not land it.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As5bdhV5T4N9vpjmZzH

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: ecc795b19056a140f2a97f837d3621aaa7044546
Local-runs: none
Scope: packages/spec/src/shared/union-branch-policy.ts, packages/spec/src/data/data-engine.zod.ts, packages/spec/src/api/zod-issues-to-fields.ts + packages/metadata-protocol/src/protocol-metadata-issues.ts, packages/spec/src/api/zod-issues-to-fields.test.ts, packages/spec/src/shared/union-branch-policy.parity.test.ts, packages/metadata-protocol/src/union-branch-policy.cross-package-parity.test.ts, packages/metadata-protocol/src/protocol.save-union-issues.test.ts, packages/rest/src/zod-union-fields.test.ts
Security-touching: no
Rule-change-verified: none

2026-11-25 · isolated one-shot reviewer, not the drafter. This is the delta reading on the record 7152531147 (PASS at 16f479c57d6). git diff 16f479c57d6 ecc795b19056 --stat names one file, .changeset/where-wrong-kind-one-entry.md (+12/−8). The nine paths in Scope: are byte-identical to the head that record reviewed, so its ①–④ judgments stand as written and are not repeated here. The changeset is the prose face; it is read below only because it is the whole move and it answers REWORK 7152541028 items 1 to 4. Nothing was built or run, and CI was not read for this record.

① Derived judgments

  • Clause-②: no (narrowing) and Metadata-protocol: none are unchanged on the changeset and still hold. The delta moves no code, so the accept set and the refusal lists are what record 7152531147 judged.
  • Item 2 (null): true against the code. $filter, filters and filter are TransportFilterValueSchema.nullable().optional() (data-engine.zod.ts:985, 988, 1022), and where is .optional() only (:1361). The new sentence says exactly that: a number, a string or a boolean on any spelling, and null on where alone.
  • Item 3 (the four lists): true against the code. zodIssuesToMetadataIssues has four callers outside tests: protocol-save.ts:1612 (the refused save), metadata-diagnostics.ts:371 (_diagnostics.errors), protocol-client-failures.ts:676 (seedRequestValidationError) and protocol-package-commits.ts:664 (the unmanaged-import refusal, thrown with statusCode: 400 and issues). The changeset names those four and no other. The BREAKING banner now addresses their readers and the terminal renderer's line count.
  • Item 1 (FROM lines): the new FROM lines are the card's readings at f6902e950 (three identical entries for 42; five entries, four of them bare, for the malformed AST). .changeset/fields-bare-union-head.md is still pending on origin/main (d7f299c0b1e), so "ships in the same release" holds, and the added paragraph attributes the explained-head drop to that change.
  • Item 4 (out-ranking): the added paragraph states the consequence ④ of record 7152531147 already derived from ranking rule 2, and the closing sentence on the metadata lists carries it.

② Semver level

Unchanged: @objectstack/spec: patch and @objectstack/metadata-protocol: patch, the ! title, the BREAKING banner and one ADR-0087 marker (not-required (no-migration-prescription)). The marker's text now adds "every diagnostics read" and "field (or path)"; both are true (_diagnostics.errors is computed from a parse at read, and metadata issues are keyed by path).

③ Boundary flags

  • No new flag. The delta holds no query, id materialisation or join, and moves no api-surface/** file.
  • The two TO lines and the caller's fix are byte-identical to the previous head.

④ Design judgment

No hits file moved, so the design judgment of record 7152531147 on union-branch-policy.ts, data-engine.zod.ts and zod-issues-to-fields.ts carries unchanged to this head. The changeset now describes the same behaviour that judgment found in the code, on all four points the seat record raised.

Findings:

  • must-fix: none

  • should-fix: none

Implemented-by: claude/issue-35500-where-refusal-one-cause
Reviewed-by: session_011y7As5bdhV5T4N9vpjmZzH

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As5bdhV5T4N9vpjmZzH

维护者速读

  • 用户可感:通过数据接口查询时,筛选条件如果写成了数字、字符串或空值,被拒时只返回一条说明,写清它应该是条件对象还是筛选数组;不再返回几条一模一样、什么也没说的「输入无效」。
  • 为什么做:data API refusal: fields[] lists the union head as an "Invalid input" invalid_shape entry ahead of the entries that explain it (sibling of #35400) #35433 的后续卡;查询接口的主要调用方是 AI,看不到原因只能乱猜重试。修在三处共用的分支选择规则上,所以数据接口、元数据保存的错误清单和命令行输出说法一致。
  • 出错会怎样:按条数或位置读错误清单、或专找那句「输入无效」的调用方会读到不同内容;元数据侧(保存被拒、已存项诊断、seed 请求、非托管导入)在同类嵌套联合上也少条目;正常查询不受影响,不涉及存储数据,撤回这一个 PR 即可恢复。
  • 要你做什么:批准或合并这个 PR;它是申报了收窄的破坏性改动,席位不能自己落地。

Review request — declared narrowing (Clause-②: no (narrowing), Metadata-protocol: none, BREAKING): a wrong-kind query where is refused with one entry naming both accepted shapes; the shared union-branch verdict no longer selects a member that is a bare union of kinds.

  • Seat record: ## 席位核对 — ACCEPT on the current head ecc795b19056a140f2a97f837d3621aaa7044546 (newest comment).
  • Contract review: same-head PASS 7155457416 (CONTRACT_REVIEW_TIER, no open finding), after the first-round PASS 7152531147; the delta since is one changeset file, prose only.
  • Dogfood battery pinned to this head: VERDICT command-exit 0, 487 files passed, 3 skipped; 4128 tests passed, 68 skipped, 0 failed.
  • What to approve: isKindMismatchOnly in packages/spec/src/shared/union-branch-policy.ts and its metadata-protocol copy (kept equal by the cross-package parity test), the TransportFilterValueSchema sentence, and the changeset. The surface widened to the policy layer by seat choice (claim amendment, option A), to keep ruling 7010280743's "two places say the same thing".
  • CI at this head: 59 success, 13 skipped, 0 failed. After approval, the seat arms it.

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 25, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 25, 2026 07:09
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 660e7cd Nov 25, 2026
79 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-35500-where-refusal-one-cause branch November 25, 2026 07:38
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 pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue protocol:data size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data API query refusal: a where of the wrong type answers three identical bare "Invalid input" entries and no cause

3 participants