Skip to content

Commit f4f0dfa

Browse files
docs(adr): ADR-0155 share-grant semi-join leaf for the sharing read scope (Proposed) (#34064)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9VCZLyrZ96UhCiXnoPFeMpp)_ Fixes #33899 Clause-②: no Metadata-protocol: none Unblocks #33787: that card is `Blocked-by: #33899` (ruling record 6895275749) and stays open until the plugin-sharing switch in this record's execution plan lands. ## 维护者速读 - 改了什么:新增 ADR-0155(Proposed),提议把共享记录的读权限从「先读出最多 5000 个授权 id 再拼列表」改为数据库内的子查询(引擎内部的第二种 semi-join 叶子),只有文档,没有代码。 - 为什么改:您对 #33787 裁定「只做根治」;今天超过 5000 条共享授权的成员会静默失去访问(失败为关闭),而现有编译路径表达不了这个子查询,需先有 ADR。 - 风险与回滚:纯文档、受管面,不改任何运行时行为;回滚即撤掉本 PR。执行卡要等您批准后才切(约 5–7 个 PR、二点五千到四千行)。 - 先看:`docs/adr/0155-…md` 的「Questions for the maintainer」节(Q1–Q3),再看 TL;DR 与 D-0/D3/D5。 - 两分钟验证:`node scripts/adr-index.mjs --check && node scripts/check-adr-symbol-anchors.mjs`,预期两者都 OK、无 0155 的发现。 - 需要你做的:暂无。第 6 轮复审意见已在新 head `0913316313` 上改完,还欠 review#2 对新 head 做一次增量复审;复审通过后再请您回答下面三问并批准本 PR(Tier H)。 - ① 子查询是否不加租户隔离(推荐:不加,与今天读共享的方式一致)。 - ② Mongo、OData、跨数据源对象等跑不了子查询的地方:保留 id 列表兜底,还是拒绝(推荐:按您「首先保sql」的原则不留列表;这些存储上的共享授权将不再生效并给出明确提示)。 - 在 `sys_record_share` 上注册了中间件或 find hook 的宿主也归入这一问:推荐从切换卡起、启动时就拒绝,直到撤掉该注册。本仓库没有包单独在这张表上注册;但宿主若把 `sys_record_share` 纳入 plugin-audit 的记录查看审计,就属于这一类,撤掉该注册即放弃对共享行的查看审计。ADR 把这一类整体保留,「豁免声明跳过系统读的注册」作为另一选项留给您在这一问里定。不点名任何对象的全局注册不算这一类(与 ADR-0139 D5.2 同一条线),改为告知宿主:按表名注册在 `sys_record_share` 上的收窄永不被绕开,宿主得到 ② 对这一类裁定的答案;不点名对象的收窄从切换起不在共享授权读上运行。例外与代价:宿主若有不点名对象、却改了 `sys_record_share` 系统读的注册,切换后共享授权的行可能不同,宿主会被告知;这时「行不变」只靠告知维持,运行时不拒绝、不报告、不记日志。这条边界也请您在这一问里一并定。 - 内存驱动(driver-memory)目前在 ADR 里定为进程内精确求值;您也可以把它一并归入这一问。 - ③ 按条件批量更新(update)是否也允许用这个叶子(推荐:只在 update 上放开写形态,其它写动词不放)。 ## What changes One new decision record, `docs/adr/0155-sharing-scope-share-grants-lower-to-an-engine-internal-semi-join-leaf.md` (Status: **Proposed**, questions ①–③ open), and its generated row in `docs/adr/README.md` (`node scripts/adr-index.mjs`; no other row moved). No code, no changeset (`skip-changeset`). The record proposes that the sharing scope's share-grant arm (`buildReadFilter`, and `buildWriteFilter` for predicate `update`) lower to one more engine-internal, never-authorable branded comparand, provisionally `SharedRecordIds`, on the ADR-0147 pattern: its own brand, a fixed inner read of `sys_record_share` under system authority, compiled by SQL drivers as `id IN (SELECT record_id FROM sys_record_share WHERE …)`. It revisits ADR-0139 D1 ("No second leaf") for this one leaf and answers ADR-0139 open item O4. - **D-0** the same-set invariant: same rows up to 5,000 grants, the corrected set above, nothing else moves. - **D1** the leaf and its brand; **D2** the inner read (today's grant read, uncapped); **D3** every arm stays in the same filter (approval ids become their own disjunct, the queue arm stays a sibling and never enters the subquery, delete stays owner-only). - **D4** the engine seam and what is built once with ADR-0147; **D5** the evaluator census (decided rows: driver-sql family, Turso remote, driver-memory); **D6** what the switch PR must show (parity at 5,000, corrected at 5,001 and 6,000, list total and GET, SQLite and PostgreSQL, approval and queue arms, the plan and timing for a caller with no grant, the nested and delegated positions, ablated; the R9 figure quoted narrowly per 6893239331 item 3). - **D4's recipient rule** (former open item O10, now decided here): the seam admits a composed share-grant leaf only when its recipient is the reading context's user or that context's delegator; a system context is the stated exemption; any other recipient is a composition fault answered with D4's envelope. The shared seam compares every identity a composed anchor names with the reading context: for ADR-0147's anchor both its caller and its organization (the reading context's active organization); ADR-0147 takes this through its cross-reference note. The anchor check compares the leaf's anchor with the anchor the reading context itself carries, caller and organization together, never re-derived from the context's user or tenant (ADR-0147 D-a), so ADR-0147 D-c's rebuilt context for a delegated controlled-by-parent write is admitted. On the analytics native-SQL path a security item is with the owner seat; the record states the design rule only. A registration that names no object is outside the host class, on ADR-0139 D5.2's line. The `ISharingService` prose and the switch card's changeset tell the host one thing: a narrowing registered for `sys_record_share` by name is never read around and gets the second class's answer as ② is ruled; one that names no object is not run on the share arm from the switch on. D-0 states the exception: on a host with a registration that names no object and changes a system read of `sys_record_share`, the share arm's rows can differ after the switch, and the host is told; the price, among Q2's costs, is that D-0's same rows there rest on the telling alone. Open items are now O1-O9. O8's census, which also reads registrations that name no object, is produced by the seat that cuts the switch card, as a condition of cutting it, and recorded in that card's body. - **Questions put, not decided**: ① tenant scope of the subquery; ② what an evaluator that cannot run the leaf answers (MongoDB, OData, other-datasource objects, the analytics native-SQL compiler, the explainer), with the maintainer's standing principle quoted verbatim; ③ the leaf on a predicate `update`. The record states the design and the parity rule only; on today's behaviour it repeats the card's words and adds none. ## Tests None: a docs-only diff. Anchor resolution is the test of its source readings: 55 distinct `path#symbol` anchors plus file-level path anchors, all resolving at the head below (rounds 1 and 2 added `readable-ids.ts#ComposedReadableIds`, `sharing-service.ts#resolveSystemGrantOrganization`, `analytics-service.ts#callCtx`, `engine.ts#registerHook`, `read-audit.ts#installReadAuditWriter` and `security-service.ts#getReadFilter`; round 3 added `explain-engine.ts#resolveDelegatorContext` and `security-plugin-cbp-write-gate.ts#assertControlledByParentChainEditable`). ## Acceptance notes - **Authoring route (deviation, declared).** This thread is not served at the contract-review tier that `dispatch-gates --tier` mandates for `docs/adr/**`; per the dispatch order the record was authored by an isolated `os-dev` subagent pinned to that tier, on this branch, through fix round 3. Fix rounds 4 to 6 were written in the card thread at its default tier, by the seat's order; the at-tier review of those rounds is review#2's. - **Not in this diff, owed after acceptance**: dated pointer notes on ADR-0139 (D1, O4; D3 if ② is ruled L or R2), on ADR-0111 D7 (if ② is ruled R2) and a cross-reference on ADR-0147 D-a. The carrier is the governed edit that records the maintainer's rulings in this record's Status line, which also decides which notes are owed. - **Readings that refine the card**: the write scope's share arm exists on predicate `update` only and also covers `public_read` objects; plugin-security already narrows addressed predicate writes to at most 10,000 readable rows; "share rows can carry a NULL organization" holds only for ADR-0131 D1's exceptions; two callers admit `ReadableIds` today, not one. - Noted, not filed: `scripts/adr-index.mjs` strips underscores from identifiers in titles (ADR-0147's index row reads `currentuser.orguserids`), which is why this title says "record-share table". ## Verification Head `0913316313` (record 832 lines): the ADR commit `5993103131`, fix round 1 `066925797b` (contract review 6899302526: S1-S3, N1-N13 taken), fix round 2 `1f6f9718d9` (delta review 6900428326: S4-S6, N14-N17 taken), fix round 3 `11d7d354ca` (delta review 6901557418: M1 option 1, S7-S9 taken), fix round 4 `b0b45bcc32` (delta review 6902450506: S1, N2-N4 taken in the record, N1 here), fix round 5 `ea5e72ef87` (delta review 6902721135: S1 remainder, N1, N2 in the record, N3 here), fix round 6 `0913316313` (delta review 6902940583: S1, N1, N2) and merges of `origin/main`, the last at `0d1443d0bf` (merge `97210679bc`). <details><summary>Derived gates: 21 derived, 21 run, all exit 0; --ran reconciles 21/21, 0 NOT-MEASURED</summary> ```text node scripts/check-adr-links.mjs :: exit 0 node scripts/check-adr-links.mjs --self-test :: exit 0 node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0 pnpm --filter @objectstack/lint run check:doc-formula-expressions :: exit 0 pnpm check:adr-anchors :: exit 0 pnpm check:adr-index :: exit 0 pnpm check:adr-symbol-anchors :: exit 0 pnpm check:ci-filter-parity :: exit 0 pnpm check:closed-ceremony-text :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:doc-authoring :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:pm-governed-merges :: exit 0 pnpm check:pm-prior-rulings :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:watch-hint-literal :: exit 0 ``` `check:doc-formula-expressions` ran after `turbo run build --filter=@objectstack/formula --filter=@objectstack/lint` under `os-verify-lock` (VERDICT command-exit 0, 96 s). </details> Tier H (`docs/adr/**`): this PR stays draft until a `GOVERNED_APPROVERS` approval. <!-- signed: domain:skills#2 · os-steve · session_01ADHkmSrxgDeeJWnQpVfLcX --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent d10f652 commit f4f0dfa

2 files changed

Lines changed: 836 additions & 3 deletions

File tree

0 commit comments

Comments
 (0)