Skip to content

feat(objectql): a nested-relation condition on a read verb is one read-scoped in-database subquery per relationship, up to three, where it is provably the same read as the id read - #33652

Merged
objectstack-fleet[bot] merged 30 commits into
mainfrom
claude/area-A3-33626
Nov 16, 2026
Merged

objectstack-fleet[bot] merged 30 commits into
mainfrom
claude/area-A3-33626

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread

Part of #33626 — the engine and analytics halves land here; the card stays open until #33876 lands maintainer ruling Q2 (the engine's INVALID_FILTER / 400 for MongoDB / OData, with the ADR-0139 capability bit). The other parts are their own follow-up cards citing #33626 and its rulings: #33875 (skills text, Tier H), #33876 (above, Tier H), #33877 (multi-valued relation as a JSON-membership semi-join), #33878 (a dataset measure's own filter).

Clause-②: yes (widening) — { account: { status: { $ne: 'cancelled' } } } on find, findOne, count and aggregate (and so every analytics face that hands the engine the nested form) is served whatever the number of matching related records on a driver that compiles the subquery (the SQL drivers; the in-memory driver evaluates it in process), where more than 1,000 answered INVALID_FILTER / 400. The related read is planned through its whole pipeline as the caller and its final where becomes the subquery's scope; related-object read restrictions the planned read observes are carried into the subquery, or the hop falls back to the id read (the related object read as the caller, then $in, under the 1,000 cap). A relation key inside the condition may now carry a condition of its own, down to ADR-0071's three relationships ({ contact: { account: { region: { name: 'NA' } } } }), where a second level answered INVALID_FILTER / 400; each hop is that object's own read, and a fourth relationship is refused by name. On the analytics engine-aggregate path a dotted where leaf through up to three relationships (order.customer.tier), and a cross-object leaf in a compiled dataset's own definition-level filter, reach the engine as that nested condition, where both answered INVALID_FIELD / 400. Still the id read, under the 1,000 cap: a related object on another datasource, a federated related object, a driver that compiles no subquery (MongoDB, OData), a related object an object-scoped middleware or an afterFind hook shapes, a related object read under different driver options than the outer object (decided before planning where the registry answers it: the two objects' tenancy class under a walled posture), a related read that a middleware answers itself, a multi-valued relation and the update / delete verbs. A hop that falls back after planning dispatches the related read twice: its middleware chain and beforeFind hooks run for the planned read and again for the id read. A per-measure filter carrying a cross-object leaf stays refused. The SQL echo of a dataset filter carrying a served cross-object leaf refuses INVALID_FILTER / 400 where it refused INVALID_FIELD / 400; neither printed a statement.
Metadata-protocol: added — a compiled dataset's definition-level filter (@objectstack/service-analytics) now accepts a cross-object leaf on the engine-aggregate path, where it answered INVALID_FIELD / 400: a new accepted value for a dataset author.
Skills-docs: content/docs/protocol/objectql/query-syntax.mdx and content/docs/kernel/contracts/data-engine.mdx describe the subquery, the three-relationship limit, where the id read and its cap still apply and which drivers compile the subquery. skills/objectstack-query still says "up to 1000 related ids" and one level for every relation; that is now stricter than the engine for a single-valued relation on a read verb (a follow-up skills-only change, governed).

Area-lease pilot #33059, area A3. Contract record 6898853007 (PASS on 96c23127, no must-fix) is answered on this head: S2–S5 and N2 below. The L2 record 6900638852 (PASS on 2d2eaa73) is answered too: S1 by the seat's option C (the author-facing rule on both docs pages, the planned-leaf docblock), S2 by this body, S3 by the seat's rulings (Acceptance notes), N2 in the pin.

维护者速读

  • 改了什么:在上一版「只在可证明等同时走库内子查询」的基础上,把注册表能直接判定的回退提前到规划之前:关联对象是联邦对象(external),或在有组织墙的租户姿态下两个对象的租户类别不同,直接走 id 读取,关联读取只执行一次;changeset 与两篇文档列全了所有仍走 id 读取(及 1000 上限)的情形,并写明:在驱动调用之后收窄关联对象行的读规则,只有注册在该对象上(对象级中间件或 afterFind 钩子)才约束关系条件。本轮合并 main,解决与 perf(objectql): drop a required master's parent chain for a View All reader over unrestricted hops #33897(View All 读者丢弃必填主表的父链)在 engine-readable-ids-permission-formula.ts 的冲突:两者都保留,先执行 View All 丢弃,再只对丢弃后仍保留的关系条件叶子做 id 预读;调用者写在必填主表上的关系条件永不随主表自身的读取范围一起被丢弃。
  • 为什么改:合同评审 6898853007 指出联邦关联对象的子查询不能证明等同、回退时关联对象的中间件与 beforeFind 钩子会执行两次、驱动选项比较只钉了一个方向、文档漏列两种回退情形。
  • 风险与回滚:所有改动都只把更多情形导向 main 原有的 id 读取(更保守);规划后才能判定的回退(中间件自行应答、只有本次请求决定的驱动选项差异)仍会二次执行,已在文档与 changeset 声明并钉住次数。冲突解决改变了两项改动交汇处的行为,属于已解决的冲突,需补 delta L1 与 L2 评审。回滚即 revert 本 PR。
  • 先看:packages/objectql/src/engine-readable-ids-permission-formula.ts(composeReadableIdsChain 末尾:View All 丢弃与关系条件叶子的交汇)、packages/objectql/src/relation-semi-join.ts(relationSemiJoinServes 的两条规划前判定)、packages/rest/src/data-nested-object-door.test.ts(真实 SQLite / PG 上两个方向的驱动选项与租户类别钉子)。
  • 两分钟验证:pnpm --filter @objectstack/rest exec vitest run src/data-nested-object-door.test.ts,预期全部通过(PG 单元需 OS_TEST_POSTGRES_URL,未设时跳过)。
  • 需要你做的:无,席位落地(卡片保持打开,等 objectql: refuse a cross-object where up front with INVALID_FILTER / 400 on a driver that compiles no semi-join (MongoDB, OData) — ADR-0139 capability-bit amendment #33876;注册时声明的裁决见 objectql: a registration-time declaration so the engine can tell which read middleware may narrow rows after the driver call #34155)。

What changes

  • The registry-answered fallbacks are decided before planning (relationSemiJoinServes), so the related read is dispatched once, as the id read: a federated related object (ADR-0015 external), and, under a posture that walls organizations, a related object of another tenancy class than the read's object (one tenant-scoped, the other platform-global or federated, isDriverTenantScopedSchema in engine-driver-options.ts, the one spelling buildDriverOptions also reads).
  • What is still decided after planning dispatches the related read twice, declared in the changeset and both docs pages and pinned by count: a related read a middleware answers itself or adds rows to (after planning), and driver options that differ only by what the request records per object (at the executor boundary). Under the single posture two tenancy classes read under the same options and still compose (CONTROL).
  • The driver-options comparison is pinned in both directions on a real driver (SQLite, PostgreSQL 16): the outer read unscoped with the related read scoped, and the opposite; and the tenancy-class decision in its other direction (a tenant-scoped read on a related object that is no tenant's), with the related read dispatched once.
  • Docs and changeset list every case that keeps the id read and its 1,000 cap, adding the two missing ones (a related object read under different driver options than the read's own object, most commonly its tenant scope; a related read a middleware answers itself) and the federated related object.
  • The author-facing rule for after-driver read rules is on both docs pages and in the planRelationSemiJoinLeaf docblock: a read rule that narrows a related object's rows after its driver call bounds a relation condition on that object only when it is registered for that object, as an object-keyed middleware or an afterFind hook (the bound ADR-0139 D5.2 sets for a ReadableIds parent).
  • Behaviour on every other path is unchanged from 96c23127.

Tests

On head 6062ec9c (the merge of origin/main at 86350e12, conflict resolved against #33897): @objectstack/objectql full suite 598/598 files, 13278/13278 tests, typecheck exit 0; @objectstack/rest full suite with OS_TEST_POSTGRES_URL (private PostgreSQL 16) 413/413 files, 8672 passed / 144 skipped, typecheck exit 0; @objectstack/service-analytics full suite 215/215 files, 5229 passed / 335 skipped, typecheck exit 0; #33897's two @objectstack/plugin-security pin files (security-plugin-cbp-read-filter.test.ts, controlled-by-parent-leaf-switch.test.ts) 35/35; engine-readable-ids-nested-composition.test.ts (#33897's harness, with the new interaction pin) and engine-nested-relation-lowering.test.ts 48/48. ESLint --no-inline-config on the two changed TS files exit 0.

Ablation of the interaction (one-shot, not kept)

With the merge committed, the line that keeps a planned relation leaf out of the View-All drop was removed with scripts/ablation-replace.mjs (anchor 1 to 0, blob 4bf1bd36 to e2e97ca8): engine-readable-ids-nested-composition.test.ts 1 failed / 17 passed, the one red being the new interaction pin. Restored to the HEAD blob 4bf1bd36, git diff HEAD empty. The pin reads src/, so no rebuild leg.

Earlier heads, below. Counts on head 2d2eaa73 (the merge of origin/main at 63db7240 included) unless marked; local box, shared verify lock, private PostgreSQL 16 for the live cells. On 6cf1ce0e (docs, a docblock and one pin's counter): data-nested-object-door.test.ts 30 passed / 15 skipped, engine-nested-relation-lowering.test.ts 30/30, objectql and rest typecheck exit 0, ESLint --no-inline-config on the two changed TS files exit 0, and every docs family of the derived list exit 0 (check:skill-examples NOT MEASURED locally: client SDK dist not built in this worktree; it passed on 2d2eaa73).

  • @objectstack/objectql full suite: 598/598 files, 13258/13258 tests; typecheck (tsc --noEmit plus check:test-typecheck) exit 0.
  • @objectstack/rest full suite with OS_TEST_POSTGRES_URL: 413/413 files, 8672 passed / 144 skipped; typecheck exit 0. data-nested-object-door.test.ts: 30 passed / 15 skipped (the MySQL cell, no server), SQLite and PostgreSQL cells each running the two-tenant describe (now with the other tenancy direction) and the new executor-boundary describe (both directions).
  • @objectstack/service-analytics full suite: 215/215 files, 5229 passed / 335 skipped; typecheck exit 0.
  • engine-nested-relation-lowering.test.ts: 30/30 — the federated and the two tenancy-class fallbacks decided before planning with one dispatch, the single-posture CONTROL that still composes, the boundary fallback and the middleware-answered fallback with two dispatches each.
Ablation (one-shot, not kept)

Each guard of this round was mutated with scripts/ablation-replace.mjs (anchor hit, blob checked), the pins run, and the file restored to the HEAD blob (9231631f, git diff HEAD empty) before the next leg; where a pin reads dist/, objectql was rebuilt and ablation-dist-preflight.mjs confirmed the marker (exit 0), and after the last leg a rebuild with --absent confirmed all four markers gone.

  • The federated check in relationSemiJoinServes: objectql 1 red (the federated pin).
  • The tenancy-class check: objectql 2 red (both directions, dispatch count 2 where 1 is pinned); rest 2 red (the other tenancy direction, SQLite and PostgreSQL, dispatch count).
  • sameReadDriverOptions reading the outer read's keys only: objectql 1 red (the boundary pin); rest 2 red ("the outer read is unscoped, the related read scoped", both cells).
  • sameReadDriverOptions reading the related read's keys only: rest 2 red ("the outer read is scoped, the related read unscoped", both cells); the objectql boundary pin stays green, as that pin's direction predicts.

Acceptance notes

Resume-from: claude/area-A3-33626@6062ec9c411903fa920343fde05537b5c46a4d9a

Verification

Gate families (dispatch-gates --commands / --ran)

On 6062ec9c: 106 families derived from the merge-base diff; --ran with an exit code per family: 106 accounted, 104 run exit 0, 2 NOT MEASURED (derived from a recorded exit 3, PREREQUISITE NOT MET: check:skill-examples and check:dual-build-cjs-loads read the dist/ of packages outside this diff's build closure, not built in this worktree; both are CI's, in Lint & Repo Gates). check:nul-bytes exit 0.

On 2d2eaa73: 106 accounted, 106 run, 0 NOT MEASURED.

No CI ran on 6cf1ce0e: the PR was not mergeable against main (the conflict above). CI on 6062ec9c: see the PR checks.

CI on 2d2eaa7 (an earlier head)

53 check-runs, all completed: 36 success, 15 skipped, 2 failure. Lint & Repo Gates, TypeScript Type Check, Build Core, Check Changeset, Governed Surface Queue Guard, Dogfood Regression Gate and Test Core 1–3 and 5–8 are success. Test Core (4/8) (and the Test Core roll-up) is red on @objectstack/scenarios test/runner/run-date.test.ts, two cases "Test timed out in 5000ms"; that package is outside this diff (tracked as #34081). Every other package in that shard passed.

Declaration lines and merges

The Clause-②: and Metadata-protocol: lines are copied byte for byte from .changeset/33626-relation-semi-join.md. git merge-tree --write-tree of 6062ec9c against origin/main at 0d1443d0: no conflict.


Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_01QsR2jUg7BKfRBcTPyMxbLh

…in-database semi-join

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4d1QwJJ5KGZTThP4fnq
…relation condition

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4d1QwJJ5KGZTThP4fnq
…gle-valued cap at the public doors

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4d1QwJJ5KGZTThP4fnq
…ition, where the cap still applies, and add the changeset

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4d1QwJJ5KGZTThP4fnq
@objectstack-fleet objectstack-fleet Bot added the domain:server Domain lane — seat card indexed by label:pm:seat label Nov 15, 2026
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/objectql, @objectstack/service-analytics, touching 65 documentable anchor(s). ⚠️ 2 changed file(s) yielded no anchor (packages/objectql/src/engine-count-aggregate.ts, packages/objectql/src/number-comparand-declared-type-door.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

36 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 dfb8ed3570b3be1cfbc3758ff791ace7c31fa1a2.

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

What this run could not see
  • 2 changed file(s) yielded no anchor (packages/objectql/src/engine-count-aggregate.ts, packages/objectql/src/number-comparand-declared-type-door.ts) — pages documenting those are invisible to this run
  • 1 anchor(s) matched too much of the corpus to be a work list: ObjectQL (symbol, 81 pages)
  • 5 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 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; 123 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 — 27 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 dfb8ed3570b3be1cfbc3758ff791ace7c31fa1a2 → packageMentionDocs.

Which tree this was computed on

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

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

⚠️ 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 dfb8ed3570b3be1cfbc3758ff791ace7c31fa1a2 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

…ableIds leaf in process

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4d1QwJJ5KGZTThP4fnq
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · os-elon-musk · session_016WV4d1QwJJ5KGZTThP4fnq

Resume-from correction (area A3, 2026-11-15T04:54Z): the body's Resume-from line names aa6187f1, an older head. The head to resume from is:

Resume-from: claude/area-A3-33626@bc5ef48640785272dc6804b27ef992cdd20234a3

This PR stays a draft (Part of #33626). The two open decisions (driver-memory in-process evaluation, MongoDB/OData refusal code) are with the maintainer; answers will be posted on #33626.

This was referenced Nov 15, 2026
@github-actions github-actions Bot added size/l and removed size/m labels Nov 15, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#1 · os-elon-musk · session_016WV4cy7hQ5MvQ83ByNZ8ZH

Contract-review-claim: session_016WV4cy7hQ5MvQ83ByNZ8ZH · head e96278a · 2026-11-15T13:00Z

… $ne, and the second hop's read scope

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4d1QwJJ5KGZTThP4fnq
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh

Request: review · PR #33652 · area S2 (A3) · Part of #33626 · head 6cf1ce0e2cd0e77109124a517126fb0fe6a5509b (declared final) · L1 review-b, L2 delta review#2

Resolves the conflict in packages/objectql/src/engine-readable-ids-permission-formula.ts
against the View-All drop of a required master's leaf over unrestricted hops.
Both are kept: the drop runs first; a leaf the nested-relation lowering planned
is the caller's own condition on the master, never the master's read scope, so
the drop never removes it; the planned-leaf id read runs only for leaves that
survive the drop; the composition then runs over the pruned tree. One pin covers
a View All reader over an unrestricted required master with a planned relation
leaf in the same where.

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

Copy link
Copy Markdown
Contributor Author

domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh

Request: review (delta) · PR #33652 · area S2 (A3) · Part of #33626 · head 6062ec9c411903fa920343fde05537b5c46a4d9a (declared final) · L1 review-b, L2 delta review#2 (os-tesla)

  • The superseded request is the one at 6cf1ce0e: that head conflicted with main and ran no CI.
  • 6062ec9c merges origin/main into 6cf1ce0e. The merge resolved a conflict in packages/objectql/src/engine-readable-ids-permission-formula.ts against perf(objectql): drop a required master's parent chain for a View All reader over unrestricted hops #33897 (View-All required-master prune), so the patch-id moved and both delta reviews are owed.
    • Both sides are kept. The prune runs first. The planned-leaf pre-read covers only the leaves still in pruned. vacuous() answers false for a planned relation leaf, so a View-All reader's own condition on the required master is never dropped with the master's leaf.
    • The new interaction pin goes red when that line is ablated, and it was restored to blob == HEAD.
  • Since L2 PASS 6900638852 (2d2eaa73): the S1 C / S3 A rule-level docs and docblock, N2, and this merge. The os-dev report for this round is 6903561395.
  • CI at head: 40 success / 17 skipped / 0 failure. Locally: objectql 13278/13278, rest 8672 (live PG 16), service-analytics 5229, and perf(objectql): drop a required master's parent chain for a View All reader over unrestricted hops #33897's plugin-security pins 35/35.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · zhuangjianguo · session_01QsR2jTyY9BGjj9WBi7QgH6

Review claim · head 6062ec9 · 2026-11-16T00:55Z

review (review-b, areas S2+S4): L1 ordinary ACCEPT read per review-checklist.md (first L1 on this PR; the L2 records are review#2's); the verdict follows on this PR.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · zhuangjianguo · session_01QsR2jTyY9BGjj9WBi7QgH6

Review — PASS

Head-sha: 6062ec9c411903fa920343fde05537b5c46a4d9a
Area: S2 / A3 · Part of #33626 · delta L1 (ordinary ACCEPT read per review-checklist.md) since L2 PASS 6900638852 on 2d2eaa73. The contract face (Clause-② yes) stays with the L2 record, and its delta on this head is owed separately.

  1. The delta is what the request says. 2d2eaa73..6cf1ce0e is two docs paragraphs (data-engine.mdx, query-syntax.mdx), the planRelationSemiJoinLeaf docblock (S1 option C), and one pin in data-nested-object-door.test.ts. That pin now counts the grid read with a package-scoped beforeFind hook that is unregistered in finally. The old version used an unscoped registerMiddleware that was never removed. The pin asserts the same thing (one dispatch, two-step parity, count), and it no longer leaks a middleware into later cells.
  2. The conflict resolution against perf(objectql): drop a required master's parent chain for a View All reader over unrestricted hops #33897 is correct. I read git diff 86350e12 6062ec9c -- engine-readable-ids-permission-formula.ts.
    • Both import sets are kept.
    • Step 5's vacuous() answers false for a planned relation leaf, so the View All drop removes only the master's own read-scope leaf. It never removes the caller's { opp: { … } } condition.
    • The id pre-read runs only for leaves that survive the drop, so the drop cannot remove a leaf after its ids were read.
    • Leaf identity holds across the prune. unrestrictedRequiredMasterLeavesDropped copies containers on write but keeps each ReadableIds leaf by reference, and composeReadableIdsLeaves passes that same reference to answer. So surviving, readIdsFor and the final rewrite key on the same objects. A planned read leaf cannot miss its ids and fall through to [].
    • The walk that fills surviving uses composeReadableIdsLeaves for its traversal only and discards the copy-on-write result. It has no side effect on node.
  3. The interaction pin is real. The new case in engine-readable-ids-nested-composition.test.ts has a View All reader send the master's leaf and a caller condition on the same master. It asserts one driver call, $and of length 1, and a composed leaf on rid_r4_opp with scope { name: 'x' }. The body's ablation (removing the planned-leaf exclusion from vacuous) turns exactly that pin red (1 failed / 17 passed), and the file was restored to blob 4bf1bd36.
  4. The body is brought to the current head, which answers L2 S2.
  5. Declarations are unchanged since L2. The Part of #33626 spelling has no closing verb. There is no ! and no narrowing arm, so no dogfood battery is owed. The Skills-docs: line is present. The delta adds no refusal, so there is no new code and status assertion to check.
  6. Live-PG cells. data-nested-object-door.test.ts runs its PostgreSQL cell in CI only on push and schedule (Temporal Conformance is skipped on this PR). The area ran it locally on PostgreSQL 16: rest 8672 passed / 144 skipped. I accept that local run as the reading for this head.
  7. Check-runs on the head: 40 success, 17 skipped, none failed or pending. Test Core 1–8, Dogfood Regression Gate, Lint & Repo Gates, TypeScript Type Check, Build Core, Check Changeset and Governed Surface Queue Guard are all success. mergeable_state is clean, and git merge-tree against current origin/main is clean.

The patch-id is f1868717783a6343571bac872b3acfa51e7bc5b9. A clean main merge that keeps it keeps this PASS.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW

Contract-review-claim: session_01L9qibxTeW8xHnxoHxWNHWW · head 6062ec9 · 2026-11-16T01:00Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 6062ec9c411903fa920343fde05537b5c46a4d9a
Local-runs: none
Scope: packages/objectql/src/engine-count-aggregate.ts, packages/objectql/src/engine-delete-and-aggregate.ts, packages/objectql/src/engine-driver-options.ts, packages/objectql/src/engine-find.ts, packages/objectql/src/engine-nested-relation-lowering.test.ts, packages/objectql/src/engine-query-lowering.ts, packages/objectql/src/engine-readable-ids-nested-composition.test.ts, packages/objectql/src/engine-readable-ids-permission-formula.ts, packages/objectql/src/engine-security-resolvers.ts, packages/objectql/src/engine-top-level.ts, packages/objectql/src/engine.ts, packages/objectql/src/federated-injected-column-readers.test.ts, packages/objectql/src/number-comparand-declared-type-door.ts, packages/objectql/src/query-expression-conformance.test.ts, packages/objectql/src/relation-condition-prescription-cap.test.ts, packages/objectql/src/relation-filter-lowering.ts, packages/objectql/src/relation-semi-join.ts, packages/rest/src/analytics-nested-relation-filter.test.ts, packages/rest/src/data-nested-object-door.test.ts, packages/rest/src/data-nested-relation-permission.test.ts, packages/services/service-analytics/src/tests/crossobject-conjunct-refusal.test.ts, packages/services/service-analytics/src/read-scope-sql.ts, packages/services/service-analytics/src/strategies/cross-object-where.ts, packages/services/service-analytics/src/strategies/objectql-strategy.ts + packages/objectql/src/filter-comparand-shape.ts, scripts/pm/record-recognisers.mjs (cited code, read at this head, not reviewed; the prose faces .changeset/33626-relation-semi-join.md and the two content/docs pages were read against the code and are judged in ④)

Read at 2026-11-16T01:09Z. Delta review of this head against PASS 6900638852 at 2d2eaa7; claim: comment 6904419883; no lane request (owed per check-owed-reviews). Independence: implemented in an os-elon-musk project thread for domain:server#5; reviewed by os-tesla, who neither dispatched nor implemented it.

① Derived judgments

Read: the previous record (6900638852), card #33626 and its comments, the PR body, title and comments, the dev commit 6cf1ce0e whole, the merge 6062ec9c as a combined diff, the net diff of each merge base to its head compared path by path (old base 63db7240 to 2d2eaa73 and to 6cf1ce0e; new base 86350e12 to this head), the main range 63db7240..86350e12 on packages/objectql, packages/plugins/plugin-security and packages/core/src/security, and the code the new lines cite. Nothing built or run. The lane's account was not taken as evidence; each prior finding is judged on the tree. The check tool reads this head's face as declaration; the review was served above that, with the wider scope and section ④ the earlier rounds carried, because the diff sits on a read rule.

What moved since 2d2eaa73, as found, which is more than one docs commit and a merge:

The resolution, judged. Main's new step removes, for one class of reader, the read-scope condition a detail object carries over its required master. A relation condition the caller writes on that same master is, after this PR's lowering, a condition of the same form on the same field. The resolution keeps the two apart by origin: the step never removes a condition the lowering built, so the caller's own filter is always applied, and the read-scope condition is removed exactly where main removes it. Both arms of the PR's rule survive the step: the related read is still run as the caller through the related object's own pipeline, so main's step applies inside it exactly as it does inside the id read, and "provably the same read as the id read" holds with #33897 in the tree. The exclusion sits in the one predicate that both triggers the step and selects what it removes, so there is no second place to forget it. The new case fails without the exclusion.

Clause-②: yes (widening) stays true at this head: nothing served on main at 86350e12, #33897's answer included, is refused or answered with other rows.

Prior findings (record 6900638852), by id:

  • S1 (a read rule a related object applies after its driver call; the docs do not say what form a rule must take) — closed. By the route the record offered: both docs pages and the planRelationSemiJoinLeaf docblock now state the author-facing rule, that such a rule bounds a relation condition on the object only when it is registered for that object, as an object-keyed middleware or an afterFind hook, and that the hop then keeps the id read. The sentence is true of the code at this head (relationSemiJoinServes answers the id read for each of the two registrations; it is conservative for a hook registered for every object, which also keeps the id read). It states the form a rule takes and publishes nothing beyond the rule. The docblock no longer states as fact what the engine cannot check. A registration-time fact the engine could read instead is objectql: a registration-time declaration so the engine can tell which read middleware may narrow rows after the driver call #34155, open, needs-user-decision.
  • S2 (the PR body described an earlier head) — closed. The body is at 6062ec9c: counts, Resume-from:, the federated and tenancy-class cases, the conflict and its resolution, and the statement that delta reviews are owed on this head. Its Clause-②: line is the changeset's, byte for byte.
  • S3 (the card's item 1 not reached for two cases, no carrier) — closed. The cross-tenancy-class hop is carried by objectql: the relation semi-join keeps the 1,000-id cap for a single-valued hop across tenancy classes under an organization wall #34157 (open, queued); the federated related object keeps the cap by the seat's ruling, named in the body.
  • N1 (one hop limit, two constants) — open, accepted as a nit. Unchanged; continued as N1.
  • N2 (a test case left a global middleware on a shared engine) — closed. The case now counts with a hook registered under its own package id and removes it in a finally.

New at this head: S1 and N2 below, both on the merge resolution.

② Semver level

@objectstack/objectql patch, @objectstack/service-analytics minor, Metadata-protocol: added, Clause-②: yes (widening). No major, and none owed: nothing served on main is refused or narrowed, so no ADR-0087 disposition and no migration is owed. The changeset is unchanged since 2d2eaa73; #33897 ships under its own changeset from main.

Check-runs on 6062ec9c411903fa920343fde05537b5c46a4d9a, read from the API during this review: 57 runs, all completed, none in progress, none failed; 40 success, 17 skipped. The Test Core shard that was red on 2d2eaa73 (a timeout in a file from main, outside this diff) is green here. The PR reads as mergeable against main with a clean state. No CI ran on 6cf1ce0e alone (it conflicted with main); its content is covered by the run on this head.

③ Boundary flags

④ Design judgment

  • packages/objectql/src/engine-readable-ids-permission-formula.ts — the resolution holds against both contracts it joins: ruling 6893666857 (the step fires for the same reader, the same master, the same positions as on main, and for no condition the caller wrote) and this PR's own sentence (the caller's relation condition is applied as the related object's own read, or as the id read). Order is right: the step first, the planned-leaf id read second, composition over what is left. The filter on the id read by "leaves that survived the step" selects nothing the exclusion does not already keep (N2).
  • packages/objectql/src/engine-readable-ids-nested-composition.test.ts — the new case is a real pin of the exclusion: it asserts one driver call, the read-scope condition gone and the caller's condition present as its subquery with the caller's own where. It runs against a stand-in security service, as the rest of that file does; the rows are not measured on the real stack for this crossing (S1).
  • packages/objectql/src/relation-semi-join.ts — the docblock paragraph now agrees with relationSemiJoinServes; no executable change.
  • content/docs/kernel/contracts/data-engine.mdx, content/docs/protocol/objectql/query-syntax.mdx — the added sentence is the same on both pages and true of the tree. The changeset body does not repeat it; it lists the cases that keep the id read, which the sentence's two registrations are already among, so the three faces do not disagree.
  • packages/rest/src/data-nested-object-door.test.ts — the counter moved from a global middleware to a scoped hook that is removed; the assertion (one dispatch, two-step parity, count) is unchanged.
  • Every other scope file — byte-identical net diff to the one judged at 2d2eaa73; the earlier judgments stand.

Findings (numbered fresh for this round):

  • S1 (should-fix) — new. The crossing of perf(objectql): drop a required master's parent chain for a View All reader over unrestricted hops #33897 with a caller's relation condition on the required master is pinned only against a stand-in security service. plugin-security measures perf(objectql): drop a required master's parent chain for a View All reader over unrestricted hops #33897's rows on the real stack and this PR measures its own on real drivers; no case measures the two together (the security plugin mounted, a compiling driver, a reader the step applies to, the caller's condition on the master, rows compared with the two-step route). The reading above says the rows are right; a pin would keep them right. Add it here or name a carrier.
  • N1 (nit) — continues prior N1. One hop limit, two constants in two packages, tied by docblocks.
  • N2 (nit) — new. In composeReadableIdsChain the surviving set and its extra walk skip only leaves that have no planned verdict anyway; the exclusion already guarantees a planned leaf is never removed. Inert, and it reads as if it guarded something.

No must-fix.

Implemented-by: claude/area-A3-33626
Reviewed-by: session_01L9qibxTeW8xHnxoHxWNHWW

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh

席位核对

Head-sha: cc52339417450a00bf16496849a0f83d573c2b6f · 读于 2026-11-16T02:11Z

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 16, 2026 02:11
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 16, 2026
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
…reader over unrestricted hops (objectstack-ai#33897)

<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbSUQWB2j9eHYsRcrCiq1X1C)_

**Do not land before objectstack-ai#33820 (ADR-0139 status-line amendment) merges.**

## 维护者速读

-
改了什么:对"受控于父对象"且主从字段必填的明细对象,只有同时持有明细"查看全部"、且每一级主对象读取范围都不受限的读者(典型是单租户管理员),读取时不再带父链子查询;其他读者完全不变;所有写操作(条件更新/删除、按
id 写、钩子里的读取)仍带父链,行为与 main 完全一致。
- 为什么改:这类读者的父链子查询挡不住任何有主记录的行,只拖慢管理员的列表、计数和汇总(卡上 1M 行实测快 29% 到 42%,本 PR
未重测)。
-
风险与回滚:该类读者的合计、计数、汇总可能包含孤儿行(主记录缺失或为空的明细),这是维护者裁决接受的;限制读者、仅有明细查看全部的读者、普通成员仍看不到孤儿行;回滚即
revert 本 PR。
- 先看:`engine-readable-ids-permission-formula.ts` 第 5
步、`readerViewsAllOf` 与
`READABLE_IDS_WRITE_IN_FLIGHT`;`engine-middleware-and-context.ts`
新增的写作用域;`security-plugin-cbp-read-filter.test.ts` 的反向钉子与写路径钉子。
- 两分钟验证:`pnpm --filter @objectstack/plugin-security exec vitest run
--maxWorkers=2 src/security-plugin-cbp-read-filter.test.ts`,预期 12 个测试全绿。
- 需要你做的:等 objectstack-ai#33820(ADR-0139 状态行修订)合并后再合并本 PR。

Fixes objectstack-ai#33696

Clause-②: no
Metadata-protocol: none

## Ruling

Ruling record 6893666857 (replaces 6893097935), quoted verbatim as it
binds this card:

> - The parent chain is dropped only for a reader who holds view-all on
the detail AND whose every master hop answers unrestricted (the engine's
per-hop scope, not `hasSuperuserReadBypass`), with a required master FK.
That reader sees null and dangling-FK rows inside its own tenant wall,
consistent with objectstack-ai#30905 ruling A. Every other reader, members included,
keeps the chain unchanged.
> - This deliberately lifts objectstack-ai#24932 ruling B item 4 and ADR-0139 D6's ⛔
for that reader class only. **The PR must not land before the ADR-0139
status-line amendment** (citing this record; ADR-0055's 10-22 note in
step) merges. That amendment is a docs/adr/** card for the skills lane,
which the seat files.
> - Pins: the three controlled-by-parent-leaf-switch tests are rewritten
for the view-all + unrestricted reader. Reverse pins stay: a reader with
a restricted master hop, and a reader with view-all on the detail only,
still never see null or dangling rows.
> - Release note: totals, counts and aggregates for that reader may
include orphan rows. A follow-up card to close the orphan sources
(option B of the original request) is owed as the PR's one loose-ends
card.
> - Multi-tenant deployments: a tenant admin's master scope is the
tenant wall, so it is not unrestricted. No speed-up there, by design;
widening that is a separate decision.

## Review 6895328067: route (a), write doors unchanged

The review found that the drop reached the write doors. The security
plugin's predicate-write narrowing, its 2.8 gate's predicate leg and its
step-2.7 by-id read all ask `ql.find`/`findOne` under the caller's
context. The seat ruled route (a), claim amendments 6895345175 and
6895620230: the write paths stay byte-identical to main. A write's
middleware chain now runs inside an engine async scope, and step 5 drops
nothing inside it. No plugin-security write-door source file changes.

## What changes

- `packages/objectql/src/engine-readable-ids-permission-formula.ts`:
`composeReadableIdsChain` gains step 5. A leaf over the REQUIRED master
of a `controlled_by_parent` object, in an AND position and as the whole
comparand of a `$in` on its `master_detail` field, is dropped instead of
composed. Two conditions must both hold:
- the master's answered scope is `undefined` (admitted, no row
condition), per hop: a nested scope left empty once its own leaves are
dropped answers `undefined`, so a chain drops whole only when every hop
is unrestricted;
- the caller holds View All (`viewAllRecords` or `modifyAllRecords`) on
the detail, read from `ISecurityService.getEffectiveObjectPermissions`
(`readerViewsAllOf`, asked once per read). A delegated caller, a service
without that member, or a call that throws keeps the chain. A failure
costs the subquery, never a row.

An optional master, a leaf inside `$or` or `$not`, and every
non-`controlled_by_parent` object compose exactly as before.
- `packages/objectql/src/engine-middleware-and-context.ts`: **approved
widening** (claim amendment 6895620230, `executeWithMiddleware` only,
+4/−1). For a write-epoch operation (insert, update, delete, purge,
restore), the middleware chain runs inside
`READABLE_IDS_WRITE_IN_FLIGHT`, an `AsyncLocalStorage` exported from
`engine-readable-ids-permission-formula.ts`. `readerViewsAllOf` answers
false inside it, so every read made while a write runs keeps the chain:
the security write-door reads, hook reads and cascade reads. It is an
async scope rather than a context stamp, for the reason
`SecurityPlugin.engineOperationScope` gives: a context is shared and
spread across those very reads.
- `packages/objectql/src/engine.ts`: **approved widening** (coordinator,
2 lines). The private `composeReadableIdsChain` host literal gains a
`_registry` getter, the same getter shape the neighbouring host literals
use.
- `packages/plugins/plugin-security/src/security-plugin.ts`: a
prose-only paragraph in the `computeControlledByParentFilter` docblock
(review should-fix 2). It says the drop is read-only and that write
paths keep the chain.
-
`packages/plugins/plugin-security/src/security-plugin-cbp-read-filter.ts`:
a docblock paragraph only. The leaf is still written for every caller,
and the engine drops it. View All on the detail alone never drops it.
-
`packages/plugins/plugin-security/src/controlled-by-parent-leaf-switch.test.ts`:
**approved widening**. The existing pins are unchanged. A new reader
(View All on the account, contact, quote and line objects) gets legs in
the three leaf-switch tests, and those legs see the dangling and null
rows and run one statement with no `in (select`.
- `.changeset/33696-drop-unrestricted-cbp-chain.md`: patch for
`@objectstack/objectql`, with the ruling's release-note sentence.

Perf, the card's measurement, not re-run here (1M rows): page SQLite 397
to 281 ms, PG 97 to 56 ms; total SQLite 217 to 136 ms, PG 78 to 54 ms.

## Tests

Pins on a real stack (`security-plugin-cbp-read-filter.test.ts`:
ObjectQL, SqlDriver on better-sqlite3, the real SecurityPlugin and
SharingService, orphan rows seeded through the driver), 8 tests:

- (a) View All on the detail over unrestricted hops: no parent-chain
subquery, every stored row including the orphans, count 7, `findOne` of
a dangling row. Plus parity on the rows whose chain resolves, and the
analytics door (the `getReadFilter` scope passed as `where`) composing
the same way.
- (b) a reader with a restricted master hop keeps the whole chain and
sees no orphan.
- (c) a reader with View All on the detail only keeps the whole chain
and sees no orphan.
- (d) a plain member keeps the chain over a restricted master and over
an unrestricted (`public_read_write`) one. The admin control on the same
object drops it.
- (e) isolated tenancy: org A and org B never read each other's rows,
and the tenant wall keeps the chain.
- An optional master keeps its leaf.

Write-door pins (review 6895328067, route (a)), in the same file, 4
tests. The View All admin reads over unrestricted hops, and the set it
writes holds orphans:

- a hook's read inside a write, under the caller's context, keeps the
chain and sees no orphan (control: the same caller's plain read drops
it);
- a predicate delete over a set holding an empty-required-master orphan
lands on the other row and leaves the orphan;
- a predicate update over a set holding an empty-master orphan and a
dangling-master orphan lands on the other row and leaves both;
- a by-id update of a dangling orphan and a by-id delete of an
empty-master orphan both still answer `RECORD_NOT_FOUND` / 404.

Measured on head 2c6025c's objectql source (the three objectql files
set back to 2c6025c, then restored with `git diff HEAD` empty), all 4
are red:

| Pin | Red on 2c6025c |
|---|---|
| hook read | it sees the 4 orphans (`line_a_ghost`,
`line_a_ghost_account`, `line_a_null`, `line_b_ghost`) |
| predicate delete | refused: `MISSING_REQUIRED_FIELD` / 422 |
| predicate update | refused: `MISSING_REQUIRED_FIELD` / 422 |
| by-id write | refused: `PERMISSION_DENIED` / 403, not
`RECORD_NOT_FOUND` / 404 |

On origin/main's objectql source, the 3 write pins pass and the hook
pin's write leg passes. Its plain-read control leg fails there, as it
should, because main drops nothing. Ablations (`ablation-replace`, every
restore checked as blob == HEAD):

- deleting the `READABLE_IDS_WRITE_IN_FLIGHT` guard in
`readerViewsAllOf` turns all 4 red;
- running a write's chain outside the scope in `executeWithMiddleware`
turns all 4 red.

Unit pins (`engine-readable-ids-nested-composition.test.ts`, a new
describe, 17 tests in the file): the drop at the root, in an `$and` and
in a merged-key position; a restricted hop keeps both leaves; `$or`,
optional and non-cbp positions compose; five kinds of caller without
View All on the detail keep the chain (no View All, View All on another
object, no service member, a service that throws, delegated); a
non-readable master gives `$in: []`.

Ablations, on the committed implementation (`node
scripts/ablation-replace.mjs`, every restore proven `blob == HEAD
8ec17d5` and `git diff HEAD` empty):

| Mutation | Real-stack pins red | Unit pins red |
|---|---|---|
| per-hop check removed (drop whenever the master answered) | (b), (c) |
restricted hop keeps; caller without View All keeps |
| `readerViewsAllOf` answers `true` | (d) | caller without View All
keeps |
| step 5 disabled | (a), parity, analytics, (d) admin control | drop at
root and `$and`; `$or`/optional/non-cbp |

<details><summary>Full suites</summary>

Runs were under `scripts/pm/os-verify-lock.sh`, with each exit captured
before any pipe.

On head `df3fb3b9` (the implementation plus origin/main at c59198f,
which includes objectstack-ai#33884's step-2.8 changes):

- `@objectstack/plugin-security`: `pnpm test` exit 0, 269/269 files,
6705 passed and 45 skipped. `typecheck` exit 0.
- `@objectstack/objectql`: `pnpm test` exit 0, 598/598 files, 13238
tests. `typecheck` exit 0.

On head `3089656f` (the same implementation, one main merge earlier),
the direct runtime dependents of objectql, after `pnpm --filter
'PKG^...' build` (exit 0). All exits 0:

- example-embed-objectql 1/1 files, 2 tests
- plugin-audit 94/94, 1541
- plugin-email 53/53, 1018
- plugin-pinyin-search 4/4, 39
- plugin-sharing 74/74, 1525
- plugin-webhooks 25/25, 307
- runtime 605/605, 10958 (19 skipped)
- scenarios 34/34, 859
- service-automation 282/282, 3982
- cloud-connection 82/82, 1224
- example-todo 9/9, 249
- plugin-dev 10/10, 89
- verify 52/52, 439
- cli `vitest run --project unit` 422/422 files, 6002 tests

The second main merge touches none of this PR's files.

Packages that depend on objectql only as a devDependency, the cli
integration tier, and dogfood are left to CI. The PR title has no `!`,
so the full dogfood battery is not owed.

</details>

## Acceptance notes

- Loose-ends card owed (the ruling's one): stop orphan rows at their
sources (option B of the original request). Measured sources: a
system-context insert or update that names a missing master is stored
(the documented residual in `engine-referential-integrity.ts`), and
promoting an optional master to required leaves rows with a NULL foreign
key. The seat files it.
- objectstack-ai#33820 (skills lane) carries the ADR-0139 status-line amendment. This
PR does not touch `docs/adr/**`.
- Under walled tenancy the tenant admin's master scope carries the
Layer-0 tenant equality, so nothing is dropped there, by design. Pin (e)
measures this.
- Open PR objectstack-ai#33652 (another seat) edits the same function in
`engine-readable-ids-permission-formula.ts`: the import line and the
final `composeReadableIdsLeaves` call. The two PRs conflict as text, and
whichever lands second rebases. They do not conflict in meaning. Its
planned relation-semi-join leaves are never asked into `chain.answers`,
and step 5 drops only a leaf whose master has an answer, so it leaves
them alone. objectstack-ai#33703 touches `engine.ts` far from this literal.

## Verification

- At head `df3fb3b9`, `dispatch-gates --commands --repo
objectstack-ai/objectstack` derived 77 gate families.
- 74 of them ran locally, every one exit 0. `--ran` reconciliation: "77
derived, 74 run, 0 NOT-MEASURED, 3 UNRUN". The 3 are whole-repo families
left to CI: `check:i18n`, `check:dual-build-cjs-loads`,
`check:type-check-debt`.
- `node scripts/check-nul-bytes.mjs` exit 0. `pnpm lint` (whole-repo
eslint) is left to CI.
- `git merge-tree --write-tree --name-only` from `df3fb3b9`:
- origin/main: clean. Main is now 18 commits ahead, and none of them
touches this PR's files.
- objectstack-ai#33887 (`engine-middleware-and-context.ts`, its
`claimReferentialCascadeDelete`): clean. This PR's hunk stays inside
`executeWithMiddleware`.
  - objectstack-ai#33884: merged into main as c59198f and included in this head.
- objectstack-ai#33652: conflicts in `engine-readable-ids-permission-formula.ts`, in
two hunks: the import block and the step-5 / final
`composeReadableIdsLeaves` lines. That overlap was known before. The two
changes do not conflict in meaning, and whichever lands second rebases.

---

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
<!-- signed: domain:server#5 · zhuangjianguo ·
session_01QsR2jVPGBoi3MCGoKbW1Hv -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW

Contract-review-claim: session_01L9qibxTeW8xHnxoHxWNHWW · head cc52339 · 2026-11-16T03:01Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: cc52339417450a00bf16496849a0f83d573c2b6f
Local-runs: none
Scope: packages/objectql/src/engine-count-aggregate.ts, packages/objectql/src/engine-delete-and-aggregate.ts, packages/objectql/src/engine-driver-options.ts, packages/objectql/src/engine-find.ts, packages/objectql/src/engine-nested-relation-lowering.test.ts, packages/objectql/src/engine-query-lowering.ts, packages/objectql/src/engine-readable-ids-nested-composition.test.ts, packages/objectql/src/engine-readable-ids-permission-formula.ts, packages/objectql/src/engine-security-resolvers.ts, packages/objectql/src/engine-top-level.ts, packages/objectql/src/engine.ts, packages/objectql/src/federated-injected-column-readers.test.ts, packages/objectql/src/number-comparand-declared-type-door.ts, packages/objectql/src/query-expression-conformance.test.ts, packages/objectql/src/relation-condition-prescription-cap.test.ts, packages/objectql/src/relation-filter-lowering.ts, packages/objectql/src/relation-semi-join.ts, packages/rest/src/analytics-nested-relation-filter.test.ts, packages/rest/src/data-nested-object-door.test.ts, packages/rest/src/data-nested-relation-permission.test.ts, packages/services/service-analytics/src/tests/crossobject-conjunct-refusal.test.ts, packages/services/service-analytics/src/read-scope-sql.ts, packages/services/service-analytics/src/strategies/cross-object-where.ts, packages/services/service-analytics/src/strategies/objectql-strategy.ts + packages/objectql/src/engine-references-and-master-detail.ts, packages/objectql/src/formula-option-labels.ts, packages/objectql/src/engine-execution-plumbing.ts, packages/services/service-analytics/src/plugin.ts, scripts/pm/record-recognisers.mjs (code from main read at this head for the merge, not reviewed; the prose faces .changeset/33626-relation-semi-join.md and the two content/docs pages are byte-identical to the ones judged at 6062ec9c)

Read at 2026-11-16T03:07Z. Delta review of this head against PASS 6904536137 at 6062ec9; claim: comment 6906088531; no lane request (owed per check-owed-reviews). Independence: implemented in an os-elon-musk project thread for domain:server#5; reviewed by os-tesla, who neither dispatched nor implemented it.

① Derived judgments

Read: the previous record (6904536137), the PR body, title and comments, card #33626 and its comments, the merge commit cc523394 against each of its two parents over every PR path and as a whole tree, the main range 86350e12..dfb8ed35 (50 commits) on packages/objectql, packages/drivers, packages/plugins/plugin-security, packages/core/src/security, packages/rest, packages/services/service-analytics, packages/spec/src, the two docs trees and skills/objectstack-query, and the main code the one merged hunk cites. Nothing built or run. The lane's and the seat's accounts were not taken as evidence; each statement below is from the tree.

The merge, judged against both parents:

  • Parents: 6062ec9c (the head of the previous record) and dfb8ed35 (main). The merge base is 86350e12.
  • The merge tree is the mechanical three-way merge and nothing else: git merge-tree --write-tree of the two parents gives tree 01fc122c, which is the tree of cc523394. The combined diff of the merge has no hunk. No hand-written line this time.
  • Against the PR parent, over the 27 PR paths, one file differs: packages/objectql/src/engine.ts, +2 lines, the getSourceLocale member on the two i18n-service type literals. Main's own change to that file over 86350e12..dfb8ed35 is exactly those two lines. Main changed no other PR path in the range, so there is no main hunk to drop.
  • Against the main parent, the files that differ are exactly the PR's 27, +1623/-223. The PR's net change has the same patch-id (f1868717) from 86350e12 to 6062ec9c and from dfb8ed35 to cc523394. No PR hunk is lost and none is added.

What main brought in, against the PR's subquery path, declaration, pins and docs:

So nothing main brought in meets the relation condition, its read rule, its declaration, its pins or its docs. Clause-②: yes (widening) stays true at this head: nothing served on main at dfb8ed35 is refused or answered with other rows.

Prior findings (record 6904536137), by id:

  • S1 (the crossing of perf(objectql): drop a required master's parent chain for a View All reader over unrestricted hops #33897 with a caller's relation condition on the required master is pinned only against a stand-in security service) — open, unchanged. The merge touches neither side of it; no pin was added and no carrier is named in the body, the card or the comments. Continued as S1.
  • N1 (one hop limit, two constants) — open, unchanged. Continued as N1.
  • N2 (the inert surviving walk in composeReadableIdsChain) — open, unchanged. Continued as N2.

New at this head: N3 below.

② Semver level

@objectstack/objectql patch, @objectstack/service-analytics minor, Metadata-protocol: added, Clause-②: yes (widening). No major, and none owed. The changeset is byte-identical to the one at 6062ec9c; everything main brought ships under main's own changesets.

Check-runs on cc52339417450a00bf16496849a0f83d573c2b6f, read from the API during this review: 54 runs, all completed, none in progress, none failed; 39 success, 15 skipped. This PASS waits on no check. git merge-tree of this head against main at 7be32d39 is clean; main has one newer objectql commit this head does not carry (#34156, the packaged object base of a code extender, a /meta translation path), not read here beyond its subject.

③ Boundary flags

④ Design judgment

  • packages/objectql/src/engine.ts — the only scope file whose bytes moved. The two added lines are main's, a type-only widening of the i18n service shape; the PR's own hunks on the file are unchanged and do not meet them.
  • Every other scope file, the changeset and the two docs pages — byte-identical to 6062ec9c. The judgments of record 6904536137 stand, including that of the perf(objectql): drop a required master's parent chain for a View All reader over unrestricted hops #33897 resolution in engine-readable-ids-permission-formula.ts and its pin.
  • The declaration and the docs sentences were re-read against what main added: none of the 50 commits makes a sentence of the changeset or of either docs page untrue.

Findings (numbered fresh for this round):

  • S1 (should-fix) — continues prior S1. The crossing of perf(objectql): drop a required master's parent chain for a View All reader over unrestricted hops #33897 with a caller's relation condition on the required master is pinned only against a stand-in security service; no case measures it with the security plugin mounted on a compiling driver, rows compared with the two-step route. Add it here or name a carrier.
  • N1 (nit) — continues prior N1. One hop limit, two constants in two packages, tied by docblocks.
  • N2 (nit) — continues prior N2. The surviving set in composeReadableIdsChain is inert and reads as if it guarded something.
  • N3 (nit) — new. The PR body still describes 6062ec9c: its Resume-from: line, its test counts and its merge-tree statement name that head and an older main. The patch is the same one and the seat's check on this head says so, so nothing in the body is untrue of the change; it does not name the head that will land.

No must-fix.

CI completed before posting: 54 check-runs on this head, 39 success, 15 skipped, none failed.

Implemented-by: claude/area-A3-33626
Reviewed-by: session_01L9qibxTeW8xHnxoHxWNHWW

VERDICT: PASS

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 domain:server Domain lane — seat card indexed by label:pm:seat size/xl 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.

2 participants