Skip to content

Commit ec73246

Browse files
docs(adr): ADR-0139 note, planReadScope is a second engine path that plans a ReadableIds leaf (#39124)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBKDusA48kJAMM6qbAVTGANT)_ Part of #39080 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户看不到任何变化:这是一条架构记录(ADR-0139)的补记,只记事实,不改任何决定。 - 记的是:#39100 已落地的引擎方法 `planReadScope`,是第二条为调用方条件规划「可读 id 子查询」的引擎路径,后面列表页评论的读取口(#39084)会用它;请求能写的东西一点没变。 - 属于「列表页对象评论」专题的记账,按专题裁决第 6 条由落地席补记。 - 要你做一件事:`docs/adr/**` 只能你批,看过没问题就批准,席位来合并。 ## What changes One file, `docs/adr/0139-engine-internal-semi-join-leaf-readable-parent-ids.md`: a dated `Note (2026-12-02, #39080 — PR #39100)` added under D3, after the ADR-0155 amendment note and before `### D4`. No other line of the ADR moves: the Status header, D1 to D6 and the README index are untouched. The note records: - `ObjectQL#planReadScope(object, target, { where, context })` (#39100) is a second engine path that plans a `ReadableIds` leaf for a `$in` comparand. The first is the nested-relation lowering. It is that same planned read, entered by the target's name, for a column that is not a declared relation. - Its outcomes, those of a nested-relation condition: the planned leaf where the subquery is provably the caller-run id read; otherwise the id list under `RELATION_FILTER_ID_CAP` (1,000), refused `INVALID_FILTER` / 400 past it; refused `INVALID_FILTER` / 400 before anything is read on a driver without `DriverCapabilities.readableIdsLeaf`; `OBJECT_NOT_FOUND` for an unregistered object. - Nothing a request can write changes: D1's leaf under D1's brand, no operator, no wire key; a JSON or spread copy is refused; a write verb refuses the leaf in D3's envelope. - D4's and D5's consumer count stands. For a planned leaf the executor boundary asks the security service nothing; the scope is the planned read's, so the caller places it under the context it was planned under. - It was built for the comment read path (#39084, epic #39077), which has not landed; on `main` at `1e87dc17e8` only tests call the method. Claim amendment 7341556804 on #39080 names this PR's surface (this ADR only) and its tier: Tier H (`docs/adr/**`), the maintainer approves and the seat lands it. Epic ruling 7338398195 item 6 gives this bookkeeping to the landing seat. ## Acceptance notes - The note is not an "add-only note" for the governed-merge Tier S arm (it sits under `## Decision`, and some lines carry anchors and lists), so it goes to the maintainer as Tier H, as the amendment says. - Not changed here, recorded for the weekly ADR-revisions card: D2's "every leaf is composed from `canReadObject` and `getReadFilter`" does not describe a planned leaf (true since the nested-relation semi-join, before #39100); the 2026-11-17 Status entry's "the engine reads the bit for author-written conditions only" now has two more readers (`planReadScope`, `closed-state-lock.ts`). The code comment at the `RELATION_SCOPE_PLAN` branch in `engine-find.ts` says only the lowering sets that option; `planReadScope` sets it too. ## Verification Read the note against the code: `packages/objectql/src/engine-query-lowering.ts#planReadScope` and `packages/objectql/src/relation-semi-join.ts` (`planRelationSemiJoinLeaf`, `relationSemiJoinServes`, `plannedRelationLeafVerdict`, `readScopeCapError`, `readScopeDriverRefusal`). Every code anchor in the note resolves (`pnpm check:adr-symbol-anchors`, nine anchors). <details><summary>Local readings (head 2ee5c58, tree = main 1e87dc1 + this note)</summary> Derived gate set (`dispatch-gates.mjs --commands`, 21 commands), exit 0 each: `check-adr-links.mjs` (and `--self-test`), `check-closing-keyword-parity.mjs` (and `--self-test`), `plan-test-core-shards.mjs --self-test`, `check:adr-anchors`, `check:adr-index`, `check:adr-symbol-anchors`, `check:ci-filter-parity`, `check:closed-ceremony-text`, `check:cross-package-test-inputs`, `check:doc-authoring`, `check:driver-memory-census`, `check:gitlink-declared`, `check:nul-bytes`, `check:pm-governed-merges`, `check:pm-prior-rulings`, `check:refd-timer-probe`, `check:watch-hint-literal`, `check-comment-mask-corpus.mjs`. NOT MEASURED: `@objectstack/lint check:doc-formula-expressions` (needs a build; CI runs it). </details> --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufziSQiNb9xKWTy1uFgY --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent a533126 commit ec73246

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

‎docs/adr/0139-engine-internal-semi-join-leaf-readable-parent-ids.md‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,42 @@ restriction".
248248
> says about `ReadableIds`. It records a decision that ADR-0155's execution cards will implement: until they land,
249249
> `main` has no such declaration and no such leaf.
250250
251+
> **Note (2026-12-02, [#39080](https://github.com/objectstack-ai/objectstack/issues/39080) — PR
252+
> [#39100](https://github.com/objectstack-ai/objectstack/pull/39100)) — a second engine path plans a `ReadableIds`
253+
> leaf for a `$in` comparand.** The first is the nested-relation lowering
254+
> (`packages/objectql/src/engine-query-lowering.ts#lowerRelationConditions`). For a condition beneath a single-valued
255+
> relation on a read verb it may plan the related object's read: the read runs as the caller and stops at its driver
256+
> call, and its final `where`, the condition and every scope its pipeline injected, becomes the scope of the leaf. The
257+
> second is `ObjectQL#planReadScope(object, target, { where, context })`
258+
> (`packages/objectql/src/engine-query-lowering.ts#planReadScope`): that same planned read, entered by the target's
259+
> name, for a column of `object` that is not a declared relation. It answers the comparand, and its in-process caller
260+
> places it. Its outcomes are a nested-relation condition's:
261+
> - a planned leaf, where the subquery is provably the same read as the caller-run id read of `target`
262+
> (`packages/objectql/src/relation-semi-join.ts#relationSemiJoinServes`, `#planRelationSemiJoinLeaf`);
263+
> - in every other case, D5.2's and D5.3's classes of `target` among them, the ids of `target` the caller reads, at
264+
> most `RELATION_FILTER_ID_CAP` (1,000). They are read at the call, or at the executor boundary when a planned leaf
265+
> meets a read whose driver options are not the planned read's own. Past the cap the answer is a refusal,
266+
> `INVALID_FILTER` / 400, never a cut-off list (`packages/objectql/src/relation-semi-join.ts#readScopeCapError`);
267+
> - a refusal, `INVALID_FILTER` / 400, before anything is planned or read, when the driver of `object` does not
268+
> declare `DriverCapabilities.readableIdsLeaf` (`packages/objectql/src/relation-semi-join.ts#readScopeDriverRefusal`);
269+
> - `OBJECT_NOT_FOUND` when `object` is not registered.
270+
>
271+
> Nothing a request can write changes. The leaf is D1's, under D1's brand, and the method adds no operator and no
272+
> wire key. A JSON or spread copy of the leaf loses the brand and is refused `INVALID_FILTER` / 400, as D1 says. In a
273+
> write verb's `where` the leaf is refused in D3's envelope (`INTERNAL_ERROR` / 500). The member is public on the
274+
> exported `ObjectQL` class, for in-process callers. `packages/spec/src/contracts/objectql-engine.ts#IObjectQLEngine`
275+
> does not carry it, and `packages/objectql/src/index.ts` does not export its option types.
276+
>
277+
> D4's consumers and D5's seventh are another kind of use, and their count stands. There a read rule writes
278+
> `ReadableIds.of(P)` and the engine composes it from the security service's answers (D2). For a planned leaf the
279+
> executor boundary asks the security service nothing: the scope is the planned read's
280+
> (`packages/objectql/src/relation-semi-join.ts#plannedRelationLeafVerdict`). So its caller places it in a read under
281+
> the context it was planned under. The method was built for the comment read path of the list-page comments epic
282+
> ([#39084](https://github.com/objectstack-ai/objectstack/issues/39084), under
283+
> [#39077](https://github.com/objectstack-ai/objectstack/issues/39077)), whose column is the platform-stamped
284+
> `sys_comment.record_id`. That path has not landed: on `main` at `1e87dc17e8` only tests call the method. This note
285+
> records a use of the leaf and changes no decision, D1 to D6.
286+
251287
### D4 — The six consumers emit one leaf per parent object, and no pre-scan
252288

253289
- **The activity stream and the compliance ledger** keep

0 commit comments

Comments
 (0)