Skip to content

docs(spec): FilterCondition form 4 says per verb and driver how a nested-relation condition is served - #35777

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/issue-35592-form4-driver-docblock
Nov 20, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/issue-35592-form4-driver-docblock

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Tesla · project thread
Fixes #35592
Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户无感:规格包里"关联条件过滤"的说明文字改为按查询动作与数据库驱动分别说明,运行行为不变。
  • 属于过滤语法文档准确性收口,替用 MongoDB 等驱动写过滤条件的开发者和 AI 助手解决被旧说明误导的问题。
  • 只改说明文字,出错时最坏是文字仍不准确,不影响任何数据或请求,可直接撤回。
  • 无。

What changes

The form 4 (nested relation) paragraph of the FilterCondition docblock in packages/spec/src/data/filter.zod.ts, prose only, measured against origin/main cceb5c6:

  • "the same on every driver" removed. On a read verb (find, findOne, count, aggregate) a single-valued relation is one subquery inside the read's own statement where that is provably the same read; a multi-valued relation, update, delete, and a read the subquery cannot prove read the related ids. Measured: SEMI_JOIN_READ_VERBS and the !site.multiple test in packages/objectql/src/relation-filter-lowering.ts (relationReadDriverRefusal) and packages/objectql/src/engine-query-lowering.ts (lowerRelationConditions, the semi-join branch).
  • Refusal named. A driver without DriverCapabilities.readableIdsLeaf (MongoDB, OData) refuses a single-valued condition on a read verb up front, INVALID_FILTER / 400, citing ADR-0139 D3 as amended 2026-11-17 ("A nested-relation condition beneath a single-valued relation on a read verb is refused up front on a driver without it, INVALID_FILTER / 400"). A multi-valued relation and the write verbs keep the capped id read there (relationReadDriverRefusal returns early for both).
  • Cap sentence scoped to "Where ids are read", naming RELATION_FILTER_ID_CAP.

content/docs/kernel/contracts/data-engine.mdx already states the same (its "the same on every driver that serves it" paragraph and the readableIdsLeaf refusal paragraph) and was measured correct, so it is untouched. No generated reference copies the sentence (git grep "same on every driver" hits only this file and unrelated pages). One patch changeset on @objectstack/spec (the file ships in files[]).

Read first: packages/spec/src/data/filter.zod.ts form 4 paragraph (the only risk: a sentence that disagrees with the engine).

Two-minute check: git grep -n "same on every driver" packages/spec/src answers nothing.

Tests

Text only; no tests added and no ablation (no tested behaviour changed). pnpm --filter @objectstack/spec build under the verify lock: VERDICT command-exit 0.

Acceptance notes

  • ADR-0155 D1 (named by the dispatch) governs the share-grant leaf, not this author-written form; nothing from it is quoted in the docblock.

Verification

At head 981517ac (tree objectstack-ai/objectstack, merge base cceb5c6). Changed lines: 36 (+27 / -9, 2 files).

Local derived gates: 83 derived, 79 run green, 4 NOT MEASURED

node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack re-derived from this branch (the dispatch's list included data-engine.mdx, which this PR does not touch): 83 commands. Each run with its exit code captured before any pipe; reconciliation --ran: "83 derived, 79 run, 4 NOT-MEASURED, 0 UNRUN".

  • exit 0 on 79, including check:docs, check:api-surface, check:authorable-surface, check:spec-docblock-symbol-anchors, check:doc-authoring, check:issue-citations, check:nul-bytes, check:adr-anchors, check-adr-0087-registration --base origin/main, check-empty-changeset, check-changeset-no-major.
  • NOT MEASURED (exit 3, prerequisite not met, CI runs them): check:dual-build-cjs-loads and check:lean-entry-closure (need a whole-repo build), check:doc-formula-expressions (needs @objectstack/formula and @objectstack/lint built), check-plugin-teardown-shape --self-test (needs an unshallow clone).
  • pnpm --filter @objectstack/spec build under the verify lock: VERDICT command-exit 0.
  • node scripts/pm/overlap-check.mjs: VERDICT clean exit 0.

Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb

…ted-relation condition is served

The docblock said 'the same on every driver' by an id read, with an
unscoped cap sentence. A read verb's single-valued condition is one
subquery on a driver declaring readableIdsLeaf and refused up front on
one without it; the capped id read serves the rest.

Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/s documentation Improvements or additions to documentation protocol:data tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

⚠️ 1 changed file(s) yielded no anchor (packages/spec/src/data/filter.zod.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files. Nothing else in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 1 changed package(s)).

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/spec/src/data/filter.zod.ts) — pages documenting those are invisible to this run
  • 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 — 174 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 0e2de25149ec81ecb00094300ad2f1e506ddc1fd → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb

Final green head: 981517acbfe32bdf26472731a3d577e12df39d4c (2026-11-20T07:08Z): 58 check-runs success, 11 skipped, 0 failed or pending. L1 requested from L1-a; one CONTRACT_REVIEW_TIER review owed (packages/spec/src/**), run by this area as an isolated reviewer.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH

Seat check

L1: ACCEPT (L1-a, for area d7-C) at head 981517acbfe32bdf26472731a3d577e12df39d4c, read 2026-11-20T07:10Z. The diff touches a published schema file (packages/spec/src/**), so it owes a CONTRACT_REVIEW_TIER L2, which d7-C runs as an isolated reviewer in parallel. This ACCEPT does not replace it.

Shape and declarations

  • Draft, base main, 1 commit, 2 files (+27/−9).
  • Fixes #35592 is the only closing keyword, and it fits. The card's three falsehoods are each corrected:
    • "the same on every driver" is gone;
    • the subquery push-down is stated;
    • the cap is scoped to the id read.
  • It also agrees with data-engine.mdx.
  • Clause-②: no / Metadata-protocol: none is right. This is comment prose only: no .describe(), key, type or behaviour moves.
  • Changeset. A '@objectstack/spec': patch changeset is right for a comment-only *.zod.ts edit, because the file ships verbatim in files[]. It is a patch, never skip-changeset, which is the docs(spec): FilterCondition form 4 states the engine's three-relationship hop limit #35574 ruling.

Prose, sentence by sentence against the code at the head

  • "SERVES it in where: it reads the related object … AS THE CALLER … and matches the relation field against what that read selects." True. See relation-filter-lowering.ts's "As the caller" note. The new ending, "what that read selects", replaces "the ids it returns", so it covers the planned read too, which the subquery case needs.
  • "On a read verb (find, findOne, count, aggregate) a single-valued relation is one subquery inside the read's own statement where that is provably the same read." True:
    • the verb list is SEMI_JOIN_READ_VERBS;
    • the condition is the module's "A subquery on a read verb, where it is provably the same read".
  • "Everywhere else (a multi-valued relation, update, delete, or a read the subquery cannot prove) the related ids are read and matched ($in … $or of $contains …)." True. lowerRelationSite gives $in for a single-valued relation, and the any-member $or otherwise. The write verbs are outside SEMI_JOIN_READ_VERBS.
  • "The subquery needs a driver that declares DriverCapabilities.readableIdsLeaf (ADR-0139 D3, as amended): on one without it (MongoDB, OData) a single-valued condition on a read verb is refused up front (INVALID_FILTER / 400)." True, including the "regardless of provability" reading:
    • relationReadDriverRefusal refuses the first single-valued site on a read verb whenever the driver does not compile the leaf, before any related read is planned (relationSemiJoinDriverRefusal, invalidFilterError);
    • driver.zod.ts:477 describes the bit the same way;
    • multi-valued sites and write verbs are not refused there, and the sentence names neither.
  • "Where ids are read, a condition matching more related records than the engine's cap (RELATION_FILTER_ID_CAP) is refused rather than truncated." True. RELATION_FILTER_ID_CAP = 1000 is in packages/objectql/src/relation-filter-lowering.ts:96, and the module's "Bounded, loudly, where ids are read" note covers this.
  • Unchanged lines. The hop limit, key admission, aggregation filter / having and JSON / scalar refusals were re-read in context and still read correctly next to the new text.
  • Agreement with content/docs/kernel/contracts/data-engine.mdx (:192–:225). The same verb split, provability condition, capability bit, MongoDB / OData refusal and id-read cap. No sentence contradicts the page, and the dev's call to leave the page untouched is right.
  • Other copies. git grep "same on every driver" over packages/, content/docs/ and skills/ at the head finds no other copy of the old sentence. The remaining hits are about other subjects: hook bodies, the grant seam, and the leaf refusal in CHANGELOGs.

Changeset prose

Each sentence matches the docblock diff:

  • the before quote ("the same on every driver", the related-id read, the cap);
  • the verb and provability split;
  • the MongoDB / OData refusal with its envelope;
  • "the cap sentence now applies only where ids are read";
  • "Text only: no schema, type or behaviour change".

Nit (not owed)

The cap now names RELATION_FILTER_ID_CAP with no path. The hop limit two lines above names RELATION_CONDITION_MAX_HOPS with its file. Both constants live in the same file, so "(same file)" would make the cap greppable from the docblock alone.

Gates and routing

  • CI at 981517ac: 69 check runs, 58 success and 11 skipped, none red.
  • After d7-C's CONTRACT_REVIEW_TIER L2 PASS on this head, check-governed-merges.mjs --pr 35777 decides the landing route.

Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 981517acbfe32bdf26472731a3d577e12df39d4c
Local-runs: none
Scope: packages/spec/src/data/filter.zod.ts + none
Security-touching: yes

PR #35777, card #35592. Inputs: the card body and its three comments (triage 7015926451, claim 7032066229, os-dev-report 7032492440), the PR body and file list, the net diff against main (merge base cceb5c6; 2 files, +27 / -9), and the 69 check-runs on the head. The diff holds no implementing file, so + none; the changeset is a prose face and is judged in ② only.

Read to judge the text, never reviewed, all outside the diff and all on main at d1ebe86 (three commits past the merge base, none touching a file named here): packages/objectql/src/relation-filter-lowering.ts, packages/objectql/src/relation-semi-join.ts, lowerRelationConditions in packages/objectql/src/engine-query-lowering.ts, the read verbs' executor boundary (engine-find.ts, engine-count-aggregate.ts, engine-delete-and-aggregate.ts, engine-readable-ids-permission-formula.ts), packages/spec/src/data/driver.zod.ts, the SQL compile (applyFilterCondition and readableIdsSubquery in packages/drivers/driver-sql/src), the supports of the four driver classes, ADR-0139 D3 with its 2026-11-17 note, and content/docs/kernel/contracts/data-engine.mdx.

① Derived judgments

  • Accept-set: no change. Right. The one non-changeset hunk (lines 2214 to 2241 at the head) lies wholly inside the JSDoc above export type FilterCondition. No Zod schema, .describe() string, type member, export or runtime string moves.
  • Public surface: published text only. Right. The paragraph ships in src/data/filter.zod.ts (the package's files[] carries src/**/*.zod.ts) and, as JSDoc on a type exported from @objectstack/spec/data, in the declarations built from it. No export is added, removed or retyped.
  • Generated artifacts: none owed. Right. On the head tree the paragraph exists in the source file alone (its opening words are found in one file), and JSON-schema descriptions come from .describe(), which the diff does not touch. The card's "reaches the generated schema descriptions" is not what the tree shows; the reach is the shipped source and its declarations, which carries the card's grade on its own.
  • Behaviour: none. Right. No file under packages/objectql or a driver is in the diff. The subquery, the id read and the refusal the text now describes are on main already.
  • Derived gates: answered by the head's check-runs. 69 runs: 58 success, 11 skipped, none red, none pending. Check Changeset, Governed Surface Queue Guard, Spec property liveness, every Lint and Type Check job, Test Core 10/10 and Test UI 16/16 are among the 58.

② Semver level

  • '@objectstack/spec': patch matches what the diff publishes: corrected text in a released package and nothing an author can write changes, so the kind is none and the level is patch (AGENTS.md, Post-Task Checklist step 3). skip-changeset would be wrong, because the file ships.
  • The Clause-②: no declaration is right, with no arm, and it reads the same on the claim, the PR body and the changeset body. Nothing widens the accept-set or the public surface. No (narrowing) either: the refusal the text now states was narrowed by the change that introduced readableIdsLeaf, not by this one. Metadata-protocol: none is right for the same reason.
  • The changeset body says what the hunk says (the four verbs, the bit, INVALID_FILTER / 400, the cap's scope) and carries no tracker number.

③ Boundary flags

  • open_questions: empty. Nothing to answer.
  • out_of_scope_findings: empty, and that holds. The one sibling text found stale in the same way, the Relation Filters section of skills/objectstack-query/rules/filters.md, is already carded (skills(objectstack-query): the nested-relation condition is one subquery per relationship on a read verb, up to three relationships — retire the "up to 1000 related ids" / one-level text #33875, open). This PR leaves nothing uncarded.
  • security_findings: none: agreed. ④ reads the as-the-caller sentence on both paths.
  • Deviation, the gate loop cut by a container restart (77 of 83, the last 6 rerun in the foreground): moot. The head's check-runs are the gate answers and they are green.
  • Deviation, four gates not measured locally, and the spec tests and typecheck left to CI: answered by the same check-runs.
  • Deviation, the commit trailer: the model-free pair is what AGENTS.md prescribes, and the head commit ends with exactly that pair. Not a deviation.
  • Deviation, ADR-0155 D1 read and not quoted: right. D1 there declares a leaf of its own brand for share grants, and ADR-0139's note on it says it moves nothing about ReadableIds and that main holds no such declaration yet. The form is ADR-0139 D3's alone.
  • Deviation, L2 owed and not requested: this record.
  • File surface: both changed files sit inside the claim's surface. data-engine.mdx is untouched, which the claim allowed when the two texts already agree.
  • SQL push-down: the diff adds no code, so no new id materialisation and no in-app join. The id reads the text describes are the ones on main, each with its reason in the cited code: a multi-valued relation is a JSON list column with no IN test on the SQL family, a write verb's where reaches no executor boundary, and the read cases are those where the subquery is not provably the related read. No finding.
  • Author: the PR's user.login is objectstack-fleet[bot], so no named-login note is owed.

④ Design judgment

No must-fix, no should-fix.

The paragraph at the head, sentence by sentence, against main:

  1. "SERVES it in where: it reads the related object with the condition AS THE CALLER … and matches the relation field against what that read selects." Holds. Both paths hand the condition to the engine's own find on the related object under the caller's context: readIds, and the planned read carrying RELATION_SCOPE_PLAN. The planned read runs the whole chain (the CRUD gate, every read middleware with the filter-oracle guard, beforeFind) and stops only at the driver call, so a condition on a field the caller cannot read is refused there exactly as on the id read, and the row scope it captured becomes the subquery's own WHERE. "what that read selects" is true of both paths, which "the ids it returns" was not. "the same on every driver" is gone.
  2. "On a read verb (find, findOne, count, aggregate) a single-valued relation is one subquery inside the read's own statement where that is provably the same read". Holds. SEMI_JOIN_READ_VERBS is exactly those four, and they are the four verbs that lower their where under a read operation name. The branch is !site.multiple && SEMI_JOIN_READ_VERBS.has(operation) && relationSemiJoinServes(…). driver-sql compiles the composed leaf as field IN (SELECT id FROM related WHERE scope AND tenant wall) inside the outer statement.
  3. "everywhere else (a multi-valued relation, update, delete, or a read the subquery cannot prove) the related ids are read and matched ($in …; an $or of $contains per id …)". Holds. Every site that does not take the branch above goes to readIds and then lowerRelationSite. update and delete pass their own operation names, which are not in the set. The unprovable reads are relationSemiJoinServes answering false, planRelationSemiJoinLeaf answering null, and the executor boundary's read answer when the driver options differ; each ends in the same id read.
  4. "The subquery needs a driver that declares DriverCapabilities.readableIdsLeaf (ADR-0139 D3, as amended): on one without it (MongoDB, OData) a single-valued condition on a read verb is refused up front (INVALID_FILTER / 400)." Holds. relationReadDriverRefusal returns early for a write verb and for a where with no single-valued site; otherwise it refuses the first single-valued site when driverCompilesReadableIdsLeaf is false, before any related read is planned or run. invalidFilterError sets INVALID_FILTER and 400. driver-sql (Turso and the WASM face by inheritance) and driver-memory declare the bit; driver-mongodb and driver-odata do not. ADR-0139's 2026-11-17 amendment and its D3 note say the same. Tried against it: a nested single-valued hop beneath a multi-valued relation, or beneath update / delete, on a driver without the bit. The related read refuses it, and that read is itself a find, so the sentence's letter covers it.
  5. "Up to three relationships deep … refused (INVALID_FILTER / 400)." Not changed by this diff, and still true: RELATION_CONDITION_MAX_HOPS is 3 and lives where the text says; admitRelationCondition refuses hop-limit, dotted-key and undeclared-key, and admits the three provisioned columns.
  6. "Where ids are read, a condition matching more related records than the engine's cap (RELATION_FILTER_ID_CAP) is refused rather than truncated; filter the related object yourself then, and match its ids the same way." Holds. The cap is 1000 and is applied inside readIds alone: the read asks for one more, and relationFilterCapError is raised on getting it. The planned read's limit never reaches the subquery, which binds no id. The executor boundary's fallback reads through the same readIds, so "where ids are read" covers it. "the same way" keeps its referent, two sentences up.
  7. "An aggregation's own filter and having do not serve the form. …" Not changed, and still true.

Against data-engine.mdx (lines 190 to 240 on main): no disagreement. The page says "the same on every driver that serves it", the same subquery sentence word for word, the same refusal with the same drivers, code and status, the same hop limit, and the cap "where ids are read" at 1,000, which is the constant's value. The page says more (the list of fallback cases, PERMISSION_DENIED / 403, the in-memory driver, the two-step example) and the docblock contradicts none of it. The card's Done-when is met.

Nothing in the paragraph is left untrue, and nothing in it is newly untrue. The other mentions of the form in the file (the walk's comment near line 2154, the type member's comment, the Filter helper) say only "served in where, up to three relationships" and stay true.

The yes on the security line is meant. The hunk's added lines restate the as-the-caller permission sentence, and by replacing "the ids it returns" with "what that read selects" they extend it to the subquery path. The extension is true on main: item 1 above, plus the tenant wall the driver applies under the outer read's options, with the leaf composed only when those options are the related read's own (plannedRelationLeafVerdict). The permission claim itself is not changed.

Nits. None moves correctness or the contract. filter.zod.ts is not a prose face, so none is to be fixed on this PR: each is left as an accepted deviation.

  • N1 (nit): "one subquery inside the read's own statement" is the SQL family's form. driver-memory also declares the bit and evaluates the leaf in process (the bit's own docblock in driver.zod.ts; the contract page says so in one clause). An author sees the same thing on both: served, with no cap.
  • N2 (nit): "a single-valued condition" means a condition beneath a single-valued relation; the contract page writes "a single-valued relation condition". The sentence before it fixes the reading.
  • N3 (nit): "a driver … on one without it" does not say whose driver. It is the queried object's (relationReadDriver(object)), not the related object's: a related object on another datasource is one of the id-read cases. The contract page words it the same way, and the refusal's own message says "this read's driver".

Implemented-by: claude/issue-35592-form4-driver-docblock
Reviewed-by: session_01L9qibvVRcFWKrfWeG5jzPb

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb

Landing (2026-11-20T07:22Z), area d7-C under the standing go-ahead for pm-dispatch-reviewed PRs.

  • L1: ACCEPT 7033001753 at 981517ac (one nit, not owed).
  • L2 (CONTRACT_REVIEW_TIER, published-schema face): PASS 7033194713 at 981517ac; no must-fix, no should-fix; nits N1–N3 left as accepted deviations. Security-touching: yes because the paragraph restates the as-the-caller permission sentence for the subquery path; the reviewer verified it true on main and the permission claim itself is unchanged.
  • Checks at 981517acbfe32bdf26472731a3d577e12df39d4c: 58 success, 11 skipped, 0 failed or pending; mergeable clean; check-governed-merges --pr 35777: NOT governed, 36 lines; landing-k: K = 3.
    Marking ready and arming auto-merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 20, 2026 07:23
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 7ee7a61 Nov 20, 2026
70 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-35592-form4-driver-docblock branch November 20, 2026 07:55
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 protocol:data size/s tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants