Skip to content

fix(plugin-sharing)!: every share grant counts; the sharing scopes carry the share-grant leaf instead of a list capped at 5,000 (ADR-0155 step 6) - #36116

Merged
os-zhuang merged 8 commits into
mainfrom
claude/project-thread-thptm0
Nov 21, 2026
Merged

os-zhuang merged 8 commits into
mainfrom
claude/project-thread-thptm0

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

Requested by Tesla · project thread

Fixes #33787

Clause-②: yes (narrowing)
Metadata-protocol: none
Skills-docs: updated here

维护者速读

  • 用户能看到什么变化:开了按记录共享的对象上,成员此前最多只算五千条共享给他的记录,合并后每一条都算;放在另一个数据源、或存储不能在库内核对共享的对象(内存、MongoDB、OData 三类)上,共享不再生效,新建共享和共享规则会被明确拒绝,启动时点名;为共享表按名挂了读取拦截的部署会拒绝启动;PostgreSQL 上一条共享都没有的成员,列表总数会变慢(十万行约 1.5 毫秒到 7.3 毫秒,百万行约 7.9 毫秒到 42 毫秒,翻页本身不变,SQLite 不受影响),后续卡 driver-sql: measure id = ANY(ARRAY(SELECT …)) against the share-grant semi-join for a caller with no grant on PostgreSQL (ADR-0155 step 6 cost) #36034 去实测一种可能让总数重新走索引的写法。
  • 为什么做:这是「共享范围改走库内子查询」这组改动的收尾一步,替在同一对象上持有大量共享的成员解决静默少看:持有六千条共享的成员今天只看得到其中五千条,打开没算进去的那条显示不存在。
  • 出错会怎样:若这一步出错,受影响的是开了共享的对象的列表、计数和详情(可能多看或少看);本次不改任何存储数据,撤回这次合并即可恢复。
  • 要你做的:这次改动修订了共享那篇架构决策记录,并收紧了上面说的两类部署的行为,需要你本人批准后才能合并。

What changes

ADR-0155 plan step 6, the switch. Steps 1, 2, 3 and 5 are merged, as are #35906, #35946 and #35952 (Oracle RAW(16), PR #36001). This branch is the local build replayed by cherry-pick onto main 78437e2, with patch-ids identical commit for commit (git range-diff: 6 of 6 =). The readings below name the local commits, built on c00be39: 6f658cd302→6b71a89a1d, a246e87044→8c94ebc0e6, 57e0485c08→60865ad7d6, 9e7a65585e→56a0828d3e, 28dbd3fdf1→76a4bc74f2, f789fb96e2→53f788e776. Between the two bases, main changed plugin-security (#36085, viewAllFields); overlap-check against 78437e2 is clean, and this head's CI is the reading of record. Round 4, which answers contract review 7064569198, adds one commit built on this branch, 4f11b21. Its readings are taken at that head. It lands last.

  • The two scopes carry the share-grant leaf (packages/plugins/plugin-sharing/src/sharing-service.ts). buildReadFilter writes { $or: [ownerMatch, queueMatch?, { id: { $in: SharedRecordIds.read(object, user) } }, { id: { $in: pendingApprovalIds } }?] }; buildWriteFilter writes the update form with SharedRecordIds.write(object, user, ['edit', 'full']) and no approval arm; delete stays the owner match alone. The capped grant read (grantedRecordIds, limit 5000) is gone: no grant is read into memory, nothing binds one parameter per grant, and the pending-approval ids are a disjunct of their own (ruling 6942854600: Q1 A, Q2 the recommended column, Q3 A; ruling 6895275749, root fix only).
  • The AST filter mirror is removed (sharing-plugin.ts, the read and bulk-write paths, and, in round 4, the sys_record_share self-scope branch): every scope is composed into where only, the key the engine's executor seam judges. Pinned: ctx.ast.filter is undefined on both paths and on the self-scope's plain-user and principal-less cases (sharing-service.test.ts).
  • ADR-0155 ② R2, the storage rows. SharingService.shareGrantsInertReason(object) answers why share grants cannot count on an object: the engine's recognition says other-datasource, or the object's driver does not list SharedRecordIds in supports.fixedReadLeaves (today: driver-memory, driver-mongodb, driver-odata). An engine that cannot say answers null, and the leaf is written. In ADR-0111 D7's inert-grant verdict this arm is asked last, so every refusal that shipped keeps its attribution (a public or phantom-anchored federated object still refuses for that reason); it also stops the public arm's external floor (sharing: a share or sharing rule to an external member is refused as inert on a public_read_write or model-less system object, though the external OWD floor would consult it #25549) from lifting there. Where it answers a reason: neither scope carries the share arm (owner, queue and approval arms unchanged), the edit gate reads no grant, the grant door refuses SHARING_NOT_ENABLED with the reason (grantAccess / createGrant, as SYSTEM and as a direct caller), the sharing-rule save door refuses SHARING_NOT_ENABLED / 422 with the remedy, the boot names at warn, once, every such object holding sys_record_share rows (inertShareGrantHolders, share-arm-boot.ts#reportInertShareGrantHolders), and security/explain reports each share on such a record as evaluated and neutral and says why (plugin-security/src/explain-engine.ts).
  • ADR-0155 ② R1 at boot, the host row. A kernel:bootstrapped hook in SharingServicePlugin asks the engine's own recognition of D4's class, engine.fixedReadLeafClassOf(SharedRecordIds.read('sys_record_share', probe)). Class registration-by-name (an object-scoped middleware, or a beforeFind / afterFind hook, for sys_record_share) throws the seam's own fixedReadLeafRefusal, INTERNAL_ERROR / 500, naming the registration, before kernel:listening. No exemption for a handler that skips system reads. A registration made after boot meets the engine's refusal at read, with the same envelope. A registration naming no object, or '*', is outside the class and is told in the changeset. No new package edge: @objectstack/spec and @objectstack/core were already dependencies.
  • Test doubles that resolve the leaf. plugin-security/src/shared-record-ids-in-memory.testkit.ts resolves a fixed-read leaf over a double's own sys_record_share rows under the leaf's own fixedInnerReadOf, once per statement (a faulted share table fails the statement), and throws on a leaf outside an $in comparand. readable-ids-in-memory.testkit.ts uses it. plugin-sharing/src/shared-record-ids.testkit.ts does the same for plugin-sharing's doubles.
  • The texts the switch makes due (claim amendment 7060526112, seat 7's call 2026-11-21):
    • docs/adr/0155-...md: a dated, append-only note (2026-11-21) says grantedRecordIds is gone and its filter is now the leaf's blank-id guard, anchored packages/spec/src/data/fixed-read-leaf.ts#FixedInnerRead. The grant-read bullet at line 160 named the removed symbol as an anchor; it now names it bare, as D2 does, and the note carries the live anchor. Nothing else in the ADR moves.
    • packages/spec/src/contracts/sharing-service.ts, prose only, no type change. The section on the share arm now states the leaf in the present tense ("The read scope's share arm is an engine-internal leaf"), says what the list was before the switch, and says that share grants count only where the leaf can be evaluated: elsewhere no share arm, no grant row read, and the grant and rule doors refuse SHARING_NOT_ENABLED / 422 (R2). The host bullet compares with what the engine read returned before the switch, and buildReadFilter's and grant's jsdoc say the same.
    • packages/spec/src/data/fixed-read-leaf-conformance.test.ts: the D-0 comment that named grantedRecordIds now describes the read before the switch and points at the blank-id guard. Comment only.
    • skills/objectstack-data/rules/datasources.md: one sentence, made exact in round 4 (N2): "Share grants count only on sys_record_share's datasource under a SQL driver; elsewhere a grant or rule save is refused SHARING_NOT_ENABLED (422), and a sharingRules reconcile aborts on it." The 422 is what the grant door and the rule-save door answer. A rule declared in a stack's sharingRules meets no door: its reconcile pass aborts on the same code, in the log. Paid for in the same file by cutting restatement (readings under Verification).
  • Round 4, ADR-0155's second note (S1). A second dated, append-only note follows D5. It says the switch landed before plan step 4 (ADR-0155 step 4 (driver-memory): evaluate the share-grant leaf in process, on reads and the predicate update path #35873, on hold), which ruling 7045701086 made no prerequisite, and that seat 7's call in claim amendment 7060526112 confirmed the consequence. driver-memory declares no fixedReadLeaves, so it answers as R2: its grants go inert, stop counting and fail closed, and the grant and rule doors refuse SHARING_NOT_ENABLED / 422. Step 4, once it lands, makes those grants count again with no change to plugin-sharing. The D5 row, Q2's closing sentence and plan step 6's "lands last" stand as written, and the note says why.
  • Changeset .changeset/33787-shared-record-ids-switch.md: the three BREAKING tightenings with each host remedy, the no-object telling (plan step 1's ISharingService prose), the three preconditions, the cost quoted no wider than the ADR, and the PostgreSQL 16 total for a caller with no grant, measured, with follow-up driver-sql: measure id = ANY(ARRAY(SELECT …)) against the share-grant semi-join for a caller with no grant on PostgreSQL (ADR-0155 step 6 cost) #36034.

Read first (by risk)

  1. packages/plugins/plugin-sharing/src/sharing-service.ts, the shareGrantsInertReason hunk and its two callers in buildReadFilter / buildWriteFilter. It decides whether the leaf is written at all: a wrong null writes a leaf the driver refuses with 500, a wrong reason hides every share on the object.
  2. packages/plugins/plugin-sharing/src/sharing-plugin.ts, the first new kernel:bootstrapped hook, with share-arm-boot.ts#shareGrantRegistrationRefusal. It refuses a boot.
  3. packages/plugins/plugin-security/src/explain-engine.ts, the sharing-layer hunk (sharesInertReason). It changes what the explainer says admits a record.

Two-minute check

pnpm --filter @objectstack/plugin-sharing exec vitest run --maxWorkers=2 src/shared-record-ids-switch.test.ts. Expect Tests 11 passed | 11 skipped (22): the SQLite cell runs, and the PostgreSQL cell runs too when OS_TEST_POSTGRES_URL is set (then 22 passed). The 6,000-grant pin reads 7,000 visible rows where the capped list reads 6,000.

Tests

D6 pins, packages/plugins/plugin-sharing/src/shared-record-ids-switch.test.ts. Real ObjectQL, the real SqlDriver and the real sys_record_share. Two cells: SQLite, and PostgreSQL 16 when OS_TEST_POSTGRES_URL is set (a schema of its own, dropped after). Fixture: 1,000 owned rows, up to 6,000 granted rows (every thousandth grant read-level, the rest edit-level), a queued row, a pending-approval row, and 50 rows never admitted. Noise grants go to another user, another object, a team recipient and the agent. "Today's list" is the pre-switch read rebuilt: a system read of sys_record_share at limit: 5000, plus the approval id.

  • PREMISE: the driver evaluates the leaf, and the queue arm is a real column.
  • 5,000 grants, parity, every arm: leaf and today's list both count 6,002 and admit the same ids; GET by id agrees per arm (owner, queue, approval, share, plus three rows refused).
  • 5,000 grants, write form: a predicate update touches the same rows through the leaf as through today's list (1,000 owned + 1 queued + 4,995 edit-level grants), never the approval row, never a read-level grant.
  • 5,000 grants, nested (round 4, N4). A line item is scoped by a composed ReadableIds of the deal. With the leaf as the parent scope, it admits the same 6,002 lines, and the same count, as the same composition handed today's list: the security service gives the composition the rebuilt list instead of the sharing scope.
  • 5,000 grants, delegated (round 4, N4). The agent's and the delegator's leaves, AND-ed, admit the same 150 rows as the two rebuilt lists AND-ed, and the update form touches the same 50.
  • 5,001 grants: the leaf counts 6,001; today's list 6,000.
  • 6,000 grants: 7,000 visible, the 6,000th granted record read by id; today's list 6,000.
  • 6,000 grants, write form: 1,000 + 5,994 edit-level grants reached; today's list stops at 1,000 + 5,000.
  • Nested: a line item scoped by ReadableIds of the deal counts 7,000, and the 6,000th grant's line is read by id.
  • Delegated: the agent's and the delegator's leaves, AND-ed, admit 150; the update form touches exactly the agent's 50 edit grants.
  • 6,000 grants with the queue and approval arms: 7,002, each arm its own disjunct.

R2 and R1 pins, packages/plugins/plugin-sharing/src/share-arm-boot.test.ts (18 tests). R2 runs on a real ObjectQL with SqlDriver as the default datasource and a second datasource whose driver declares nothing. The pins cover:

  • the reason, naming both datasources;
  • neither scope carrying the share arm there, while the control keeps it;
  • the edit gate consulting no grant;
  • the grant door, as SYSTEM and as a direct caller;
  • the sharing-rule save door, SHARING_NOT_ENABLED / 422 with the remedy;
  • the boot report, which names only the object holding rows, once, at warn, and stays silent when there are none;
  • a driver beside sys_record_share that does not declare the leaf, named by its driver;
  • an engine that cannot say, which answers null;
  • the order: the storage arm is asked last, so a shipped refusal keeps its own reason.

R1:

  • a clean host;
  • an object-scoped middleware;
  • beforeFind and afterFind hooks (one whose handler skips system reads included), each refused INTERNAL_ERROR / 500;
  • '*' and no-object registrations, not refused;
  • a missing or throwing recognition, which warns and refuses nothing;
  • a read after boot, refused INTERNAL_ERROR / 500 by the engine;
  • and at the plugin: SharingServicePlugin through kernel:bootstrapped refuses a host with an afterFind hook for sys_record_share, INTERNAL_ERROR / 500 naming it, and boots a clean one.

Explainer, packages/plugins/plugin-security/src/explain-fixed-read-leaf.test.ts, now on the real producer. On an object stored by a driver that does not evaluate share grants: the shares are neutral, the record is excluded, and the detail carries the sentence and the driver's name. On the control, the same shares admit.

Updated for the new shape: the plugin-sharing scope tests (sharing-service.test.ts, including ctx.ast.filter undefined on both paths) and the plugin-security tests whose doubles read the scope. Those doubles resolve the leaf through shared-record-ids-in-memory.testkit.ts under its own fixedInnerReadOf, never restating the predicate. The resolution happens where the scoped where reaches the double, not inside its find or matcher. check:objectql-double-limit and check:where-matcher lift those functions out of the file to drive them, and an imported call or a closure over the double's tables leaves them undrivable (UNJUDGED). Both gates' baselines never grow, so two doubles and one matcher were returned to their base text. The SQL-compiling tests count the semi-join: controlled-by-parent-leaf-switch.test.ts, and readable-ids-nested-compose.test.ts, which asserts no statement reads sys_record_share on its own.

Ablations, each through scripts/ablation-replace.mjs after committing, each restored to the HEAD blob with git diff HEAD empty:

# Mutation Predicted Observed
1 the read leaf's disjunct removed from buildReadFilter (both cells) read pins red; write-form and premise pins green 12 failed, 6 passed (18)
2 the write leaf's disjunct removed from buildWriteFilter (SQLite) the two write-form pins and the delegated pin red 3 failed, 6 passed, 9 skipped (18)
3 shareGrantsInertReason returns null first every R2 pin red; R1, the null answer and the silent report green 7 failed, 10 passed (17)
4 the kernel:bootstrapped refusal's throw deleted only the plugin-level boot pin red 1 failed, 16 passed (17)
5 the explainer's R2 arm forced to admit the R2 explainer pin red, its control green 1 failed, 11 passed (12)
3′ as 3, rerun after the arm moved last the 7 R2 pins and the order pin red 8 failed, 10 passed (18)
6 the storage arm put back above the public check only the order pin red 1 failed, 17 passed (18)
A round 4: the rebuilt list read at limit: 4999 (SQLite) read and write parity, nested parity, and the 5,001 and 6,000 list counts red; delegated parity green 5 failed, 6 passed, 11 skipped (22): read parity, nested parity, 5,001, and both 6,000 pins. The prediction missed one pin: the 5,000 write-form pin stays green, because its list reads 4,995 edit grants, under either cap.
B round 4: the rebuilt list ignores its user and reads the delegator's grants (SQLite) only the delegated parity pin red 1 failed, 10 passed, 11 skipped (22)

A and B mutate the control, not the code, and show that the two new parity pins read the rebuilt list they claim to. Both ran at 4f11b21 and were restored to the HEAD blob (git hash-object equal to HEAD: for the file).

Ablations 1 to 5 ran before the arm moved and before both rebases; 3′ and 6 ran after the arm moved, before the second rebase. The lines they mutate are unchanged since. Ablation 3's first attempt was refused before anything ran: its replacement contained the anchor, so the anchor count could not drop. It was restored, re-anchored, and the run above is the second. The round-2 commit (28dbd3fdf1) changes prose, comments, an ADR and a skill line only, so it carries no ablation.

Round 4, at 4f11b21 (this branch, the dogfood closure rebuilt first: VERDICT command-exit 0). PostgreSQL 16.15 ran in a private cluster for these runs and was removed after.

  • pnpm --filter @objectstack/plugin-sharing typecheck: exit 0, check:test-typecheck: OK.
  • pnpm --filter @objectstack/plugin-sharing test, PostgreSQL on: Test Files 77 passed (77), Tests 1637 passed (1637).
  • D6 on PostgreSQL (S2): shared-record-ids-switch.test.ts gave 22 passed (22), 11 per cell, none skipped. Posted as comment 7064863601.
  • pnpm --filter @objectstack/plugin-security typecheck: exit 0, check:test-typecheck: OK.
  • pnpm --filter @objectstack/plugin-security test: 281 files passed. The five PostgreSQL-gated files failed with ECONNREFUSED, because the server had stopped mid-run. Its checkpointer reopens pg_control by absolute path, and the session re-locks its scratchpad's parent directories, so the reopen was refused and the server shut down. Rerun with the server up, in one window, those five files gave 171 passed (171): controlled-by-parent-leaf-switch, explain-cross-class-refusal, explain-json-column-refusal, rls-boolean-comparand-door and rls-check-cross-class-field-refused.
  • No spec file changed in round 4. The spec readings below are the local build's.

Suites and typecheck at the local head, 28dbd3fdf1 (rebased onto c00be39, the dogfood closure rebuilt first: VERDICT command-exit 0):

  • pnpm --filter @objectstack/spec typecheck: exit 0, check:test-typecheck: OK. The spec tests that read the edited files, src/contracts/sharing-service.test.ts, src/data/fixed-read-leaf-conformance.test.ts and src/data/shared-record-ids.test.ts: Test Files 3 passed (3), Tests 109 passed (109).
  • pnpm --filter @objectstack/plugin-sharing typecheck: exit 0, check:test-typecheck: OK. pnpm --filter @objectstack/plugin-sharing test: Test Files 77 passed (77), Tests 1624 passed, 9 skipped (1633). The 9 are the PostgreSQL cells.
  • pnpm --filter @objectstack/plugin-security typecheck: exit 0, check:test-typecheck: OK. pnpm --filter @objectstack/plugin-security test: Test Files 286 passed (286), Tests 7113 passed, 45 skipped (7158). The skips are the PostgreSQL cells.
  • PostgreSQL: OS_TEST_POSTGRES_URL was unset for these runs. The PostgreSQL cells last ran before the second rebase, with no failure (plugin-sharing 1633 passed, plugin-security 7181 passed). Between the two bases main changed no file under packages/drivers, packages/objectql or packages/plugins.

The final head, f789fb96e2, adds one commit on top of 28dbd3fdf1: the dogfood pin (Acceptance notes). No package source changed, so the suites above stand for it.

Dogfood battery at 4f11b21, this branch's head

Owed by the (narrowing) arm. Command: pnpm --filter @objectstack/dogfood test under the verify lock, no shard and no path, on the closure rebuilt at this head. Result: VERDICT command-exit 0. Test Files 483 passed, 3 skipped (486). Tests 4101 passed, 68 skipped (4169).

Dogfood battery at f789fb96e2, the local head before the cherry-pick

Owed by the (narrowing) arm. Command: pnpm --filter @objectstack/dogfood test under the verify lock, no shard and no path, on the closure built at 28dbd3fdf1; the final commit changes only a dogfood test file, which no dist carries. Result: VERDICT command-exit 0. Test Files 482 passed, 3 skipped (485). Tests 4098 passed, 68 skipped (4166).

The run at 28dbd3fdf1, before the pin commit, read VERDICT command-exit 1: Test Files 1 failed, 481 passed, 3 skipped (485). Its one failure was the [integrity] pin.

Acceptance notes

The dogfood [integrity] pin, updated. packages/qa/dogfood/test/authored-row-write-scope.dogfood.test.ts:284-287 pinned the bare owner match: buildReadFilter(CLOSED, bobCtx) toMatchObject { owner_id: bobId }. Under this PR the scope is $or of the owner match and the leaf, so the pin went red. The next assertion (Bob reads only his own row on the private object) held throughout. The pin now asserts the owner disjunct, a one-line change and nothing else in the file (f789fb96e2):

).toMatchObject({ $or: expect.arrayContaining([{ owner_id: bobId }]) });

The file was outside this claim's file surface. Seat 7 asked the maintainer at 2026-11-21T09:22Z to authorize changing lines 284-287, and the maintainer (Tesla) answered verbatim at 2026-11-21T11:09:38Z: 「同意」. The file alone passes: Test Files 1 passed (1), Tests 12 passed (12).

driver-memory: share grants become inert there. driver-memory does not declare that it evaluates the share-grant leaf, so it gets R2's answer, as driver-mongodb and driver-odata do. On an object it stores, share grants stop counting: the read and update scopes fail closed to the owner, queue and approval arms, and the edit gate reads no grant. Nothing is silent about it. The grant door and the sharing-rule save door refuse a new grant or rule loudly, SHARING_NOT_ENABLED / 422 with the reason, and the boot names, at warn, each such object that holds share rows. No read is refused with a 500. This is the ruled behaviour: ruling 6942854600 on #33787 (② ruled R2, the storage rows), and ADR-0111 D7's amendment note of 2026-11-17, which gives D7 this arm and says it takes effect with this switch. Seat 7 confirmed the reading on 2026-11-21. Plan step 4 (an in-process evaluation of the leaf on driver-memory) would make these grants count again with no change here. Since round 4 the record says so too: ADR-0155's second dated note, after D5 (S1). The dogfood stacks boot on sqlite-wasm, which extends SqlDriver and inherits its declaration, so they are not affected.

Preconditions inherited from #35906 (close-out 7057616561), each carried into the changeset:

  1. On PostgreSQL, a statement holding the leaf whose catalog read fails, or finds no such relation, answers INTERNAL_ERROR / 500, where step 3 ran it uncast.
  2. Each transaction pays one savepoint and one catalog read per table it compares a leaf against, when the table has no pooled reading.
  3. A failed catalog read inside that savepoint rolls back the caller's concurrent statements on the same transaction. Read for this PR: plugin-sharing issues no statement of its own that carries the leaf (the leaf is written into the caller's where, and the caller's statement carries it); sharing-service.ts and sharing-plugin.ts hold 0 references to transaction; the plugin's own reads are sequential system reads, and its one Promise.all over reads (ownership-queue-service.ts:441) runs under the system context outside any transaction. So no producer here issues concurrent statements on one transaction while a leaf statement is primed. A caller that runs its own statements concurrently on one transaction is the precondition's case and is told in the changeset.

The speed figure, quoted no wider than ADR-0155 "What it costs": for the scope statements alone (the account page, its total and the two grant reads), at 1M rows and 5,000 grants, the id-list scope against the semi-join scope read PostgreSQL 21.6 → 7.0 ms and SQLite 18.3 → 12.1 ms. It is not a whole-request figure.

The caller with no grant (D6), measured on this tree. Before the switch the statement was the bare owner match; now it is $or of the owner match and the leaf. Medians of 25 runs, a page of 50 and its total, 50,000 grants held by other users, the caller holding none:

Dialect · rows page before → after total before → after Plan
SQLite · 100k 1.01 → 1.09 ms 0.08 → 0.13 ms MULTI-INDEX OR: idx_..._owner_id kept on page and total
SQLite · 1M 5.85 → 7.36 ms 0.28 → 0.60 ms same
PostgreSQL 16 · 100k 1.59 → 1.72 ms 1.46 → 7.29 ms page: pkey index scan both; total: Bitmap on idx_..._owner_id → Seq Scan with a hashed SubPlan
PostgreSQL 16 · 1M 1.65 → 1.58 ms 7.88 → 42.21 ms total: Parallel Seq Scan

SQLite still serves both from the owner index. PostgreSQL serves the page as before but plans the total as a sequential scan, which grows with the table; this agrees with step 3's reading (close-out 7048322381), whose L2 named id = ANY(ARRAY(SELECT ...)) as an alternative. The cost ships stated in the changeset and the 速读 (seat 7's call, 2026-11-21); follow-up #36034 measures that form against the semi-join for this caller on PostgreSQL. It is named here as a cost, not changed.

O8 census, this repository at 8c8ff0f. No site changes a system read of sys_record_share; no registration names it by name; no default opts it into record-view auditing. No D-0 finding. The registrations that name no object (organizations, approvals, audit, auth, security, sharing, runtime app-plugin, mailbox, messaging) were each read: none changes that read. objectstack-ai/hotcrm (e7fe77f0) was read by the card thread: nothing. O8 census: the platform half is measured (this repository and hotcrm, recorded in #33787's body). The cloud half has moved to #36115 (area:cloud) on the maintainer's word, 2026-11-21 14:43 UTC, verbatim: 「需要 cloud 仓库的任务,分配到 area:cloud」. cloud pins objectstack by version, so any adaptation lands on its own bump.

Mirror. The AST filter mirror stopped carrying the scope at all, rather than being pinned as unread (plan step 6 allows either). In round 4 (N1) the sys_record_share self-scope branch stopped mirroring too, so no branch of the sharing middleware writes filter now. That branch never carried the leaf. Nothing in the repository reads ast.filter: git grep finds only a test double that falls back to it, write-denial-user-copy.test.ts, on an object this branch never scopes.

Left as written. In fixed-read-leaf-conformance.test.ts the D-0 describe and it titles still say "today's list" and "reads it today"; the amendment names the comment, and test titles are not prose a reader takes as the contract. The ADR-0155 bullet at line 160 keeps its wording as a reading of b8ac0e24; only its anchor became a bare name.

Docs drift (advisory comment 7064411467), read in round 4. I re-derived the list on 4f11b21 against 78437e2 with node scripts/docs-audit/affected-docs.mjs --json 78437e20d7. It gives 45 pages: 28 hand-written and 17 release-owned, the same counts the bot gave. I re-read only the pages that name SHARING_NOT_ENABLED, and two of them list its causes without the one this PR adds: the share table's datasource is not under a SQL driver, so grants and rule saves are refused on every object.

  • content/docs/kernel/runtime-services/sharing-service.mdx, Typical Errors.
  • content/docs/permissions/sharing-rules.mdx, the paragraph on refusals at save.

Neither page is edited in this round. A docs edit would move the head past the one S2 was read at. Both pages are prose faces, so this is the seat's call: edit them in this PR or in a docs-only follow-up. I did not re-read the other 26 hand-written pages this round.

Seen in the dogfood log, not from this change. The showcase stack logs Schema sync FAILED for object 'showcase_invoice' on sqlite-wasm (alter table ... add column invoice_date date default (strftime('%Y-%m-%d', 'now')): "Cannot add a column with non-constant default"), followed by a SeedLoader stale roll-up error. It appears 20 times in each battery: at 4f11b21, at the local heads, and in the pre-rebase run. Nothing here touches schema sync, the showcase app or sqlite-wasm. Noted, not filed.

Oracle, after #36001. For a key the RAW(16) prime names, the leaf projects the list's HEXTORAW conversion. A grant the list admits gives the list's rows. A grant the list would refuse (INVALID_FILTER / 400, before SQL) now fails the statement with ORA-01465, 500. An unprimed key, such as the parent scope inside a composed ReadableIds subquery (#35960), compiles as the list's text binds do, so the switch leaves that path exactly as it is.

Verification

This head's CI check-runs are the reading of record. The families below are this tree's derivation, run locally.

Round 4, at 4f11b21:

  • Gate union. dispatch-gates --commands --repo objectstack-ai/objectstack derives 121 families against merge base 78437e2 and 32 paths. Round 4's paths add none. All 121 ran, each exit code captured before any pipe, and all 121 exit 0. check:type-check-debt first answered exit 3: its build queued behind the dogfood battery on the verify lock. Rerun under the lock, it re-measured clean. --ran: "121 derived famil(ies) accounted for — 121 run, 0 NOT-MEASURED".
  • Readings that bear on round 4.
    • check:adr-symbol-anchors: 3865 anchors resolve. The new note adds no anchor.
    • check-adr-links: 1165 links resolve.
    • check-skills-token-ratchet: datasources.md is 911 of 911.
    • check:skill-identifier-liveness: 548 citations, up from 547, with sharingRules live.
    • check:objectql-double-limit, check:where-matcher and check:query-options-erasure: each "baseline key set verified against 78437e2: no files added".
    • check:nul-bytes: OK.
  • Overlap. node scripts/pm/overlap-check.mjs --branch=claude/project-thread-thptm0: VERDICT clean exit 0 against origin/main 3c06fc5, five commits past this branch's base, one of them in driver-sql (fix(driver-sql): name the safe column entries' remedy per object kind #36101).
  • node scripts/check-platform-checklist.mjs --changed-from 78437e20d7: OK, 2 anchors judged, 0 lost.

The local build, before the cherry-pick:

  • Gate union. node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derives 121 families, against merge base c00be39 and 32 paths. The dogfood pin's path added no family to the 121 derived at 28dbd3fdf1. The 38 families that are new since the first round come from the spec, ADR and skills paths. At f789fb96e2 all 121 ran, each exit code captured before any pipe, and all 121 exit 0. check:type-check-debt waited its turn on the verify lock and re-measured clean: OK — 0 ledger entr(ies) re-measured … none above its recorded number. --ran over the record: "121 derived famil(ies) accounted for — 121 run, 0 NOT-MEASURED (a DERIVED zero — all 121 recorded an exit code and none of them is 3)". At 28dbd3fdf1 the same 121 were also all green; there, check:type-check-debt first hit a lock queue-timeout and passed when rerun under the lock.
  • The anchor, now green. check:adr-symbol-anchors: "3865 anchors across 160 records resolve … 0 line anchors survive".
  • Named by the dispatch. pnpm check:query-options-erasure: exit 0. pnpm check:nul-bytes: exit 0. node scripts/pm/overlap-check.mjs --branch=local-33787: VERDICT clean exit 0 at f789fb96e2, against origin/main 8145424. That is nine commits past this branch's base (ui/, platform-objects, plugin-approvals, service-messaging, client, cli tests, one spec source), and none of them shares a file with this branch.
  • node scripts/check-platform-checklist.mjs --changed-from c00be39b74: OK, 2 anchors judged, 0 lost.
  • Local-only families.
    • pnpm check:skill-frame-freshness: exit 0. The frame is byte-identical to the ref.
    • pnpm check:dev-prereqs: exit 1. 35 ui/ workspace packages have no dist in this checkout, because they are outside the dogfood closure built here. This reading is about the box, not the change.

Skills readings (skills/** diff, the PR's whole skills change, round 4 included):

Measure Before (78437e2) After (4f11b21)
skills/objectstack-data/rules/datasources.md, lines 81 82
the same file, bytes and ratchet tokens 3629 bytes, 908 tokens 3643 bytes, 911 tokens
its ceiling 911 911, unchanged, headroom 0
the package, all SKILL.md summed 4945 lines 4945 lines
every published skills/**/*.md 18653 lines 18654 lines

The sentence, and N2's longer wording of it in round 4, are paid for in the same file by deleting restatement. Round 2's cuts:

  • " (object name may differ)": the example's two names show it.
  • " everywhere": it restates "on ANY object".
  • "is connected automatically at boot" becomes "connects at boot": the heading says Auto-connect.
  • "An object on an external datasource" becomes "Each": it restates the heading.
  • "Federation is read-only by default." and "both gates must be on:" go: the heading says double opt-in, and the line says and.

Round 4's cuts, for N2's wording:

  • The validate-only row's "instead of failing boot": the external row above it says a mismatch fails the boot, and "but … warns" is the contrast.
  • "optional" in the commented-out remoteSchema line: the line is commented out, which is what marks it optional, as the columnMap line beside it shows with no such word.

"Federation is read-only by default." stays cut (N2). It restates the section it sat in: "Writes — double opt-in" names the default (nothing is on until opted in), and "To write, set datasource.external.allowWrites: true and the object's external.writable: true" names the only way on. Eval case 3 expects the write gate left closed (no allowWrites, no writable). That is an absence, which the remaining text teaches. No eval case grades on the sentence, and no published skill or doc reads it from this file. content/docs/data-modeling/external-datasources.mdx carries its own copy of the sentence, unchanged.

No ceiling moved. check-skills-token-ratchet: "datasources.md is 911 tokens (ceiling 911; headroom 0)". Also green: check:skill-identifier-liveness, check:skill-links, check:skill-frame-sync, check:skill-compatibility, and spec check:skill-refs / check:skill-served-sections.

The objectstack-data eval cases: pnpm --filter @objectstack/scenarios skill-evals --skills objectstack-data --dry-run exits 0 and plans 66 cases, so the catalog loads. The eval round itself is NOT MEASURED. It drives a model through a login for 125 turns and is not a CI gate or a merge gate. The datasource cases (3 and 11) grade on defineDatasource, datasource, remoteName, columnMap, schemaMode, OS_DATASOURCE_ENV_CREDENTIALS, _PASSWORD, ObjectSchema.create and sharingModel: 'public_read'. The file still teaches every one of them, and none of the deleted text carried one.


Generated by Claude Code

…so every grant counts

buildReadFilter and buildWriteFilter write the share arm as the
SharedRecordIds leaf (the read form, and the write form on the update
scope) in place of the id list they read from sys_record_share under
limit 5000. The approval ids stand as a disjunct of their own, delete
keeps the owner match alone, and the AST filter mirror no longer
carries the scope.

On an object whose storage cannot evaluate the leaf (another datasource
than sys_record_share, or a driver that does not declare it), share
grants stop counting: no scope carries the arm, the edit gate reads no
grant, the grant and rule-save doors refuse SHARING_NOT_ENABLED, the
explainer says why, and the boot names every such object holding share
rows. A host that registers a middleware or a find hook for
sys_record_share by name has its boot refused (INTERNAL_ERROR / 500).

ADR-0155 plan step 6, with the D6 pins on SQLite and PostgreSQL.

Claude-Session: https://claude.ai/code/session_01L9qibyXo4gSy8DJPNz4ANz
Co-authored-by: Claude <noreply@anthropic.com>
…where reaches the double

Two engine doubles resolved the leaf inside their own `find`, which
check:objectql-double-limit cannot drive: it lifts a `find` double out of
its file, and the imported resolver call in its body is stubbed, so both
doubles read UNJUDGED and the gate's baseline would have grown. Each
double's `find` is back to its base text, and the leaf is resolved once
for the statement at the request path that hands the scoped `where` to
it. The testkit's header says where to call it.

Claude-Session: https://claude.ai/code/session_01L9qibyXo4gSy8DJPNz4ANz
Co-authored-by: Claude <noreply@anthropic.com>
…ked last

The R2 arm sat above the public check, so a shipped object that is both
federated and public (or phantom-anchored) had its grant refusal
re-attributed to the storage arm: the dogfood control that guards that
order went red. It is now asked after every arm that shipped, and only
lifts nothing where the public arm's external floor would otherwise
admit. The sharing-rule remedy follows the same order. Pinned in
share-arm-boot.test.ts with a declaring-driver control.

Claude-Session: https://claude.ai/code/session_01L9qibyXo4gSy8DJPNz4ANz
Co-authored-by: Claude <noreply@anthropic.com>
…ack to its base text

No statement in that suite hands the double a share-grant leaf (the
predicate-update pin reads the scope off the AST, never through the
matcher), so the leaf resolution added there was dead, and it made the
matcher unliftable for check:where-matcher: naming the double's own
`tables` pulled module fixtures into the lift out of order. A leaf that
did reach the matcher would throw on `.includes`, loudly.

Claude-Session: https://claude.ai/code/session_01L9qibyXo4gSy8DJPNz4ANz
Co-authored-by: Claude <noreply@anthropic.com>
… the share-grant leaf switch

- ADR-0155: a dated note repoints the grant-read bullet's anchor from the
  removed grantedRecordIds to the leaf's blank-id guard (FixedInnerRead);
  the bullet names the symbol bare.
- ISharingService prose states the share arm as the leaf, in the present
  tense, and that grants do not count (no share arm, grant and rule doors
  refuse SHARING_NOT_ENABLED) where the leaf cannot be evaluated (R2).
  Prose only, no type change.
- The D-0 conformance comment describes the pre-switch read in the past.
- objectstack-data datasources rule: one sentence on where share grants
  count, paid by cutting restatement in the same file (908 -> 909 tokens,
  ceiling 911 unchanged).
- Changeset: the PostgreSQL 16 no-grant total cost, measured, and the
  follow-up measurement.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibyXo4gSy8DJPNz4ANz
…ed with the share arm

The [integrity] pin matched the bare owner match. The sharing read scope
is now an $or whose owner disjunct is the same match, beside the
share-grant leaf, so the pin asserts that disjunct. The next assertion
(Bob reads only his own row) is unchanged.

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

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/plugin-security, @objectstack/plugin-sharing, @objectstack/spec, touching 40 documentable anchor(s).

28 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 2212b16988df69afb7272a2829099ac9ad0ca98d.

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

What this run could not see
  • 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 — 177 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 2212b16988df69afb7272a2829099ac9ad0ca98d → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 2212b16988df69afb7272a2829099ac9ad0ca98d

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

Contract-review-claim: session_01L9qibyXo4gSy8DJPNz4ANz · head 53f788e · 2026-11-21T14:50Z

This PR has three faces: a spec contract (packages/spec/src/contracts/sharing-service.ts), governed ADR text (docs/adr/0155-…) and a declared narrowing (Clause-②: yes (narrowing)). That puts the review at CONTRACT_REVIEW_TIER. It runs as an isolated sub-agent of this card thread, and its scope is the hits plus the whole non-prose diff (contract-review.md line 10). L1 is asked once CI is green. The record and the filled brief will follow on this PR. Because the ADR path is governed, landing goes back to seat 7 (Tier H).

@objectstack-fleet objectstack-fleet Bot added the needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides label Nov 21, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 53f788e776ac01562a4cb2569a67b912b7de0260
Local-runs: none
Scope: packages/spec/src/contracts/sharing-service.ts, docs/adr/0155-sharing-scope-share-grants-lower-to-an-engine-internal-semi-join-leaf.md, skills/objectstack-data/rules/datasources.md + packages/plugins/plugin-sharing/src/sharing-service.ts, packages/plugins/plugin-sharing/src/sharing-plugin.ts, packages/plugins/plugin-sharing/src/share-arm-boot.ts, packages/plugins/plugin-sharing/src/objects/sys-record-share.object.ts, packages/plugins/plugin-sharing/src/shared-record-ids.testkit.ts, packages/plugins/plugin-sharing/src/share-arm-boot.test.ts, packages/plugins/plugin-sharing/src/shared-record-ids-switch.test.ts, packages/plugins/plugin-sharing/src/sharing-service.test.ts, packages/plugins/plugin-sharing/src/authored-row-write-deferral.test.ts, packages/plugins/plugin-sharing/src/external-owd-floor.test.ts, packages/plugins/plugin-sharing/src/federated-phantom-owner-scoping.test.ts, packages/plugins/plugin-sharing/src/field-recipient.test.ts, packages/plugins/plugin-sharing/src/system-caller-inert-grant.test.ts, packages/plugins/plugin-sharing/src/system-write-materialisation.test.ts, packages/plugins/plugin-security/src/explain-engine.ts, packages/plugins/plugin-security/src/security-plugin-explain-access.ts, packages/plugins/plugin-security/src/shared-record-ids-in-memory.testkit.ts, packages/plugins/plugin-security/src/readable-ids-in-memory.testkit.ts, packages/plugins/plugin-security/src/explain-fixed-read-leaf.test.ts, packages/plugins/plugin-security/src/explain-dependency-fault.test.ts, packages/plugins/plugin-security/src/explain-read-verdict-inputs.test.ts, packages/plugins/plugin-security/src/controlled-by-parent-sharing.test.ts, packages/plugins/plugin-security/src/controlled-by-parent-leaf-switch.test.ts, packages/plugins/plugin-security/src/readable-ids-nested-compose.test.ts, packages/qa/dogfood/test/authored-row-write-scope.dogfood.test.ts, packages/spec/src/data/fixed-read-leaf-conformance.test.ts, scripts/adr-anchors/packages__plugins__plugin-sharing__src__sharing-service.ts.json, scripts/adr-anchors/packages__plugins__plugin-sharing__src__share-arm-boot.ts.json
Security-touching: yes

Inputs: card #33787 (body and all 30 comments), PR #36116 (body, 32-file list, net diff of merge base 78437e20d7 against the head) and the head's check-runs. The narrowing arm is declared, so the whole diff outside the changeset is in scope. Code outside the diff was read, not reviewed: packages/objectql/src/fixed-read-leaf-seam.ts, fixed-read-leaf-position.ts, engine-secrets-and-routing.ts, engine-datasource-routing.ts, packages/core/src/hook-dispatch.ts, kernel.ts, security/lifecycle-verb-rls-operation.ts, packages/spec/src/data/shared-record-ids.ts, fixed-read-leaf.ts, packages/plugins/plugin-audit/src/audit-plugin.ts, read-audit.ts, packages/plugins/plugin-sharing/src/sharing-rule-service.ts, rule-hooks.ts, and .github/workflows/ci.yml.

① Derived judgments

  • The two scopes change shape for every sharing-scoped caller. buildReadFilter answers $or of the owner match, the queue match, { id: { $in: SharedRecordIds.read(object, user) } } and the approval ids; buildWriteFilter answers the update form with .write(object, user, WRITE_ACCESS_LEVELS), and delete the owner match alone. This is ADR-0155 D3 as written, the approval ids a disjunct of their own. A caller with no grant now gets the $or where it got the bare owner match. Right, and a narrowing for any consumer that matched the old shape (the dogfood pin was one).
  • Grants past 5,000 count. The capped read and grantedRecordIds are gone from both builders; no other gate read the list. Right: the card's defect.
  • R2: share grants stop counting where storage cannot evaluate the leaf. shareGrantsInertReason answers for an object on another datasource (the engine's own fixedReadLeafClassOf) and for a driver without the declaration (the seam's own driverEvaluatesFixedReadLeaf); both are the readings passFixedReadLeaves makes at read, so the producer and the seam cannot disagree on a top-level read. There: no share arm on either scope, checkEdit reads no grant, grant refuses for system and direct callers, the rule save door refuses (sharingRuleObjectRefusal, 422), the object picker drops the object, and the boot names holders once at warn. Right, a narrowing, ruled (6942854600, with 7045701086 and seat call 7060526112 for driver-memory).
  • The D7 order is kept. The storage arm is asked last in inertGrantReason, so bypass, controlled_by_parent, public, owner-less and phantom-anchor refusals keep their shipped reason; on a public object the external floor (sharing: a share or sharing rule to an external member is refused as inert on a public_read_write or model-less system object, though the external OWD floor would consult it #25549) lifts only where storage evaluates the leaf. Right.
  • R1 at boot. A kernel:bootstrapped handler throws fixedReadLeafRefusal (INTERNAL_ERROR / 500) when the engine recognises a registration for sys_record_share by name. The boot-phase dispatch propagates the first throw on both kernels (dispatchHookPropagating), so the boot does fail. plugin-audit installs its afterFind hook in kernel:ready, before this handler, so the opt-in named in the contract is caught at boot. Right, a narrowing, ruled.
  • A registration naming no object no longer runs on the share arm. Nothing refuses or logs it; the contract and the changeset tell it. Right as ruled (D4's boundary).
  • ctx.ast.filter is no longer written by the read and bulk-write merges. Plan step 6 allows it. Right.
  • SharingService gains two public members (shareGrantsInertReason, inertShareGrantHolders) and SharingEngine two optional ones. Additive. plugin-security reaches shareGrantsInertReason by feature test, as it already reaches listApprovalReadGrants; neither is on ISharingService. Right.
  • security/explain output. On an R2 object each share is neutral and the sharing layer's detail gains one sentence with the reason; the record's rowFilter there is the owner match. Right.
  • packages/spec: comments only. The 31+ / 24- in contracts/sharing-service.ts is jsdoc; no type, schema or export moves. Right.
  • Inherited envelopes. On an Oracle RAW(16) key a grant whose record_id the list refused with 400 now fails the statement with 500 (feat(driver-sql): the share-grant subquery converts a RAW(16) uuid key on Oracle as the list binds it (ADR-0155 O2) #36001, seat-accepted in 7058138586 and 7058625670). Right as inherited.

② Semver level

@objectstack/plugin-sharing: patch and @objectstack/plugin-security: patch. Right: AGENTS.md Post-Task step 3 ships a non-protocol change, breaking included, as patch with its BREAKING banner and ADR-0087 disposition, and both are present (fix(plugin-sharing)!, three BREAKING bullets each with its host remedy, marker not-required (no-migration-prescription)).

Metadata-protocol: none is right: no authorable key, accepted value or default moves (ADR-0155 "Leaves unchanged"), and the change is a service's enforcement.

Clause-②: yes (narrowing), line-initial in the PR body and in the changeset body, the same value in both. Right: R2, the two doors' refusals and the boot refusal each take away something that worked.

@objectstack/spec (jsdoc) and the published skills text move without being named; both sit in the fixed group and version with the two named packages. Check Changeset is green twice on this head.

③ Boundary flags

  • Dogfood pin outside the claim's surface: answered. Maintainer 「同意」 (amendment 7061720534); the diff is the one line named there.
  • driver-memory under R2: answered by ruling 7045701086 and seat call 7060526112. The ADR text was not brought along: see S1.
  • PostgreSQL 16 plans the total of a caller with no grant as a sequential scan (1.46 to 7.29 ms at 100k, 7.88 to 42.21 ms at 1M): answered by seat call 7060526112, stated in the changeset, follow-up driver-sql: measure id = ANY(ARRAY(SELECT …)) against the share-grant semi-join for a caller with no grant on PostgreSQL (ADR-0155 step 6 cost) #36034. ADR-0155 D6 asks the switch to quote that reading, and it does.
  • The three [Decision] ADR-0155 O2: the share-grant subquery on PostgreSQL for an object whose id is not text (integer, uuid) #35906 preconditions: carried into the changeset. The Oracle RAW(16) envelope change (7058138586, 7058625670, 7060497587) is in the PR body only; the changeset is the seat's ACCEPT to read.
  • O8 census, cloud half: escalated. ADR-0155's acceptance criteria and plan step 6 say the switch card is not cut without the census, and amendment 7061720534 says the push stays held until the cloud half is in. The card body records objectstack and hotcrm, and says the cloud half moved to cloud: the O8 census of objectstack-ai/cloud for ADR-0155 step 6 (the 5,000-grant cap retirement) #36115 on the maintainer's word of 2026-11-21 14:43 UTC. No card comment records that word or releases the hold; the body's quotation is the only record in this review's inputs. The hand that lands this Tier H PR confirms it. cloud pins objectstack by version, so nothing reaches it before its own bump.
  • Dogfood battery (owed by the narrowing arm): the PR body's run is of the local build on base c00be39b74, not of this head. On a pull_request event the three dogfood shards are skipped by design and Dogfood Regression Gate is a rollup, so this head's battery is the merge queue's.
  • Showcase Schema sync FAILED seen in the dogfood log, not filed: outside this diff; the seat's filing gate decides.
  • PR author: objectstack-fleet[bot].
  • SQL push-down: no new id materialisation and no in-app join. The diff removes the one this card is about: no grant is read into memory and nothing binds a parameter per grant. The approval ids stay a list (ADR-0155 D3, O4). inertShareGrantHolders makes one limit 1 read per R2 object at boot and none on a host whose objects all sit beside sys_record_share on a SQL driver. checkEdit keeps its one-record probe.
  • Check-runs on this head, read 2026-11-21T15:02Z. Success: Lint & Repo Gates and all eight Lint · jobs, Type Check · source gates, Type Check · debt ledger, Check Changeset, Governed Surface Queue Guard, PR-body guards, Spec property liveness, Check Documentation Links, Check PR Size, Flag docs affected by code changes, Plan Test Core shards, Plan Test UI shards, Build UI Deps, Live E2E UI, Test Core (4/10), (6/10), (7/10), (8/10), and the Dogfood Regression Gate rollup. Still in progress, so no verdict yet: Build Core; Test Core 1, 2, 3, 5, 9 and 10 of 10; Type Check · workspace; Type Check · consumer gates; Type Check UI; Build & E2E UI; Test UI 1 to 16 of 16. Skipped on this event: the dogfood shards, Dogfood Verify CLI, Temporal Conformance (live PG + MySQL), Build Docs, Lint UI, UI Published Artifacts. No check-run has failed. The verdict below is of the tree; the suites that pin it have not all reported.

④ Design judgment

packages/spec/src/contracts/sharing-service.ts holds, sentence by sentence, against plugin-sharing/src/sharing-service.ts and share-arm-boot.ts.

  • "carries the read scope's share arm as a SharedRecordIds leaf" and "the predicate-update scope carries the write form": buildReadFilter, buildWriteFilter.
  • "writes no share arm and reads no grant row": both builders and checkEdit ask shareGrantsInertReason first.
  • "its grant and sharing-rule doors refuse": assertNotInertGrant runs for system callers too; sharingRuleObjectRefusal at defineRule and at the sys_sharing_rule hook.
  • "R1 at boot, so the host does not start": holds, see ①.
  • The no-object paragraph: no engine read of sys_record_share remains in either builder.
  • buildReadFilter's and grant's jsdoc say the same as the code.

docs/adr/0155-...md. The dated note is true: grantedRecordIds is gone from the tree outside this record, D2 names it bare, and the blank-id guard is declared with fixed-read-leaf.ts#FixedInnerRead. The line-160 edit removes only the dead anchor and the note says so. Against its first consumer the record does not hold in one place:

S1 (should-fix) — ADR-0155 still records driver-memory as evaluating the leaf, and this head ships it under R2 with no note. D5's row reads "evaluates in process" and "the row stands as stated here"; Q2 closes with "driver-memory is not in this census; its row stands as D5 states it"; plan step 6 says "⛔ It lands last". At this head driver-memory declares no fixedReadLeaves, so shareGrantsInertReason makes its share grants inert, and the changeset names the in-memory driver beside MongoDB and OData. The authority exists (maintainer 7045701086, step 4 on hold; seat call 7060526112) but lives on the card only. Prime Directive 13 asks a moved decision to be recorded on the record. This PR already edits the file under Tier H: it owes a second dated, append-only note saying that step 4 (#35873) is on hold, that the switch landed before it on ruling 7045701086, and that driver-memory takes R2 until a driver declares the leaf.

skills/objectstack-data/rules/datasources.md. The sentence is true of the code: grants count only beside sys_record_share on a driver that declares the leaf, and today only the SQL family does (driver-sql, with sqlite-wasm and Turso inheriting). It sits in the paragraph that tells an author when to declare a separate datasource, which is where the consequence belongs. It teaches sharing behaviour, hence Security-touching: yes. The trims keep every identifier eval cases 3 and 11 grade on. The card carries no eval prompt, and the PR states the eval round was not run.

Implementing files.

  • sharing-service.ts: agrees with D3, R2 and ADR-0111 D7. A recognition that throws counts as no answer and the leaf is written with the seam behind it; an engine with no driver for the object answers R2. sharingRuleObjectRemedy follows the verdict's order.
  • sharing-plugin.ts and share-arm-boot.ts: the R1 handler is registered ahead of the plugin's other kernel:bootstrapped passes; the report runs in a handler of its own and cannot fail the boot. The bulk-write merge reaches only update and delete: restore and purge dispatch with no AST and return early, so the write form never lands on a verb the seam refuses.
  • explain-engine.ts, security-plugin-explain-access.ts: the reason is asked of the sharing service, never restated; a throw is no answer.
  • Testkits and updated tests: each double resolves the leaf under fixedInnerReadOf, not a restated predicate, and throws on a leaf outside $in. shared-record-ids-switch.test.ts carries every D6 pin: 5,000 parity on list total and GET per arm, 5,001, 6,000, both scopes, nested, delegated.
  • The two anchor files and the conformance-test comment say what the code does.

Attempts to break it that did not: a stale AST-keyed cache (none in objectql, driver-sql, rest, runtime or plugin-security); an in-process matcher fed the scope in production code (only the explainer, which resolves the leaf at the record); a hook that names the share table registered after the boot check (the seam refuses at read, as the contract says); the delegator leg's recipient (the seam admits onBehalfOf.userId).

S2 (should-fix) — D6's PostgreSQL cell has no reading at this head. Ruling 6895275749 and ADR-0155 D6 ask for parity "on SQLite and on PostgreSQL". The cell is describe.skipIf on OS_TEST_POSTGRES_URL, and no job provisions that variable for plugin-sharing (the test file's own header says so; Temporal Conformance (live PG + MySQL) is skipped on this event and does not run this package). The only PostgreSQL run is the dev's, taken before both rebases. Owed: the 18-test file run with the variable set at the head that lands, its reading recorded on the PR. That needs no tree change; S1's fix moves the head anyway. Wiring the cell into the live-PG job is a workflow edit and a follow-up card.

Nits, none affecting correctness or the contract:

  • N1 — sharing-plugin.ts: the sys_record_share self-scope branch still mirrors its scope under ast.filter, while the two new comments say no driver reads that key. No leaf sits there, so plan step 6 is met. Follow-up or accepted.
  • N2 — the skill sentence's "(422)" is what the grant door and the rule save door answer. A rule declared in a stack's sharingRules meets no door: its reconcile pass aborts with the same code in the log (sharing-rule-service.ts#grantOrAbsorbOrganizationRefusal). The takeaway holds. The same hunk deletes "Federation is read-only by default.", leaving the default to the heading "double opt-in"; eval case 3 expects the write gate left closed. Accepted, or a follow-up with an eval round.
  • N3 — spec and engine prose outside this diff still speaks of the list in the present: packages/spec/src/data/shared-record-ids.ts ("where today's list of granted ids sits", "the list the share arm binds today holds at most 5,000") and packages/objectql/src/fixed-read-leaf-seam.ts ("until then nothing on main writes the leaf"). The same class as the four texts amendment 7060526112 called due. Follow-up card.
  • N4 — the nested and delegated pins assert absolute counts above the cap, where D6 words them as "the rows today's lists answer below the cap". The expected values are fixed by the fixture. Accepted.

No must-fix. Two should-fix, S1 and S2, open on this head.

Implemented-by: claude/project-thread-thptm0
Reviewed-by: session_01L9qibyXo4gSy8DJPNz4ANz

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

The filled brief the CONTRACT_REVIEW_TIER sub-agent reviewed under (record above):

Contract review brief — PR #36116 @ 53f788e776ac01562a4cb2569a67b912b7de0260 (card #33787)

You review at CONTRACT_REVIEW_TIER. Render ONE ## Contract review record on this head — its shape is
node scripts/pm/record-recognisers.mjs --template --paths packages/spec/src/contracts/sharing-service.ts docs/adr/0155-sharing-scope-share-grants-lower-to-an-engine-internal-semi-join-leaf.md skills/objectstack-data/rules/datasources.md — with a PASS or FAIL verdict, and post it as ONE comment
on the PR or its card.

Inputs — these and nothing else:
· card #33787: its body and EVERY comment (rulings and earlier records included)
· PR #36116: its body, its file list, and the net diff against main at 53f788e776ac01562a4cb2569a67b912b7de0260
· the check-runs on 53f788e776ac01562a4cb2569a67b912b7de0260: their conclusions ARE the gate verdicts
⛔ Not the dispatch order, ⛔ not the dispatching seat's own conclusions — this brief is adversarial by design.

Scope — the paths reviewFace returns as hits on this PR's file list: packages/spec/src/contracts/sharing-service.ts, docs/adr/0155-sharing-scope-share-grants-lower-to-an-engine-internal-semi-join-leaf.md, skills/objectstack-data/rules/datasources.md;
plus every file IN THIS DIFF that directly implements or enforces them — the gate that enforces a rule, the code
a jsdoc or schema line describes, the validator a skill teaches — reviewed for agreement with the contract.
Widen it freely, ⛔ never below hits; the record's Scope: line names the implementing files apart from hits.
The rest of the diff (tests, unrelated modules, lockfiles, generated output, changesets) is the lane seat's
ACCEPT at TIER_DEFAULT, exactly as a standalone PR of those files.
④ judges the hits files and those implementing files ONLY:
lockfiles, generated output, changesets and prose elsewhere in the PR are not reviewed;
code outside the diff is READ to judge them, never reviewed.

Security — a hits path sits on the low-risk skills arm: when the change teaches security, auth or permission
behaviour the path name doesn't show, the record says so and the seat adopting the record adds the security label.
The record says so on its Security-touching: line, and the arm lands on no alone: write no ONLY when no changed
hunk teaches permission, sharing, credential, token, authentication or other security behaviour, else yes.

⛔ READ-ONLY. No worktree, no checkout, no build, no test run, no gate re-run, no ablation: the check-runs
on the head already answered every derived gate family, and a local run costs more than it returns.
If ONE probe is unavoidable, the record's Local-runs: line says probe — REASON; otherwise none.
Scratch space is /tmp/claude-0/-home-user/1cb35bdc-0d81-5349-bc14-73d1d05fc076/scratchpad/pr-36116/ alone; nothing there you did not write this round is read.

Judge, in the record's own sections:
① Derived judgments — every accept-set and public-surface change the diff implies, each named right or wrong.
② Semver level — the changeset (or skip-changeset) matches what the diff publishes, and the Clause-②: line.
③ Boundary flags — every dev flag and every open_questions entry answered, or escalated.
On every face, SQL push-down: a new id materialisation or in-app join where SQL could push down is a
finding unless a reason is given (AGENTS.md, Prime Directive 5: SQL first).
④ Design judgment — for EVERY hits file: does the change hold against the code it cites and the
scenario it is accepted against? A skill file against the card's eval prompt and the spec it teaches
on main; a schema file against the ruling or ADR it implements and its first consumer; an ADR
against its first consumer and its execution plan. For EVERY implementing file in the diff: does the
code agree with the contract, sentence by sentence? Read the cited code in the live tree, and try to
break the design.
Grade each finding must-fix, should-fix or nit — a nit has no effect on correctness or the contract.
A must-fix is a FAIL; a must-fix or should-fix earns a delta review of its fix; nits alone end the round.
Spell a must-fix or should-fix with its id and grade, S1 (should-fix) — …, and a clean round as
No must-fix, no should-fix.: the queue guard reads a graded finding as OPEN on this head and
refuses the record; the delta record names those it closes by id alone, S1: closed.
A nit is fixed only on the prose faces, or left as an accepted deviation or a follow-up card: a fix
anywhere else moves the head, and this record no longer covers it.
⛔ Judge the tree, never the PR body's account of it.
Sign Implemented-by: with the dev's branch and Reviewed-by: with your session id — the value is the FIRST
thing after each colon.

Face note (seat-filled): this PR also declares the narrowing arm (Clause-②: yes (narrowing)). By references/contract-review.md line 10, a declared narrowing is judged at this tier across the whole diff outside the prose faces. Scope is therefore hits plus every non-prose file in the diff: packages/plugins/plugin-sharing/src/**, packages/plugins/plugin-security/src/**, and packages/qa/dogfood/test/authored-row-write-scope.dogfood.test.ts. Rulings to judge against are on the card: 6942854600, 6895275749, 7045701086, the seat's calls in claim amendment 7060526112, and the maintainer's 「同意」 in amendment 2. The dev's branch is claude/project-thread-thptm0.

…parity pins below the cap; the record and the skill line follow

- sharing-plugin: the sys_record_share self-scope branch no longer
  mirrors its scope under the AST's filter key, as the general read
  merge already does not; pinned for the plain and principal-less cases.
- shared-record-ids-switch: at 5,000 grants, the nested position (a
  composed ReadableIds scope whose parent scope is the leaf, against the
  same composition handed the rebuilt capped list) and the delegated
  position (the two leaves AND-ed against the two rebuilt lists, read and
  update) admit the same rows. The counts above the cap are unchanged.
- ADR-0155: a second dated, append-only note that the switch landed
  before plan step 4, so driver-memory takes R2 until a driver declares
  the leaf.
- objectstack-data datasources rule: the 422 is the grant and rule-save
  doors'; a declared sharingRules rule aborts its reconcile instead.
  Paid in the same file (909 -> 911 tokens, ceiling 911 unchanged).

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

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

D6 on PostgreSQL at the landing head · 2026-11-21T15:25Z

This answers S2 of contract review 7064569198.

Head. 4f11b215c37f3e276d901369bd314735f9de627b, pushed to claude/project-thread-thptm0 this round. It adds one commit to the reviewed head 53f788e776, which carries S1, N1, N2 and N4.

Server. PostgreSQL 16.15 (Ubuntu 16.15-0ubuntu0.24.04.1) on x86_64-pc-linux-gnu. It was a private cluster in the session's scratchpad, listening on 127.0.0.1 only, created for this reading, then stopped and removed.

Command. OS_TEST_POSTGRES_URL named a database on that cluster, and the test ran under the verify lock:

pnpm --filter @objectstack/plugin-sharing exec vitest run --maxWorkers=2 --reporter=verbose src/shared-record-ids-switch.test.ts

The run ended VERDICT command-exit 0, with Test Files 1 passed (1) and Tests 22 passed (22):

Cell Passed Skipped Failed
sqlite 11 0 0
postgres 11 0 0

Each cell runs the nine D6 pins this review read:

  • the premise;
  • parity at 5,000 grants, read and write;
  • 5,001 grants;
  • 6,000 grants, read and write;
  • nested;
  • delegated;
  • the queue and approval arms.

Each cell also runs the two parity pins below the cap that N4 asked for, both at 5,000 grants:

  • Nested. A composed ReadableIds scope whose parent scope is the leaf admits the same lines, and the same count, as the same composition handed the rebuilt capped list.
  • Delegated. The agent's and the delegator's leaves, AND-ed, admit and update the same rows as their two rebuilt lists.

A second run, same head. It ran beside the five PostgreSQL-gated plugin-security files and read the same 22 passed. Those files: 171 passed (171).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

Hand-off to repo:objectstack#4 · 2026-11-21T16:12Z

The maintainer's order, 2026-11-21T15:26Z: 「在做的5张,开发完成后,用信箱交接给 4 号座位(座位贴 #34830,新信箱 #36124),让他负责审核落地。」 Development is finished. This PR is still a draft: ready has not been flipped, auto-merge is not armed, and no reviewers are requested. Review and landing are seat 4's.

Card and ruling.

Head. 4f11b215c37f3e276d901369bd314735f9de627b. CI: 61 success, 13 skipped, 0 failed, 0 in progress. Mergeable clean. +1,574/−255 over 32 files.

Reviews so far.

  • L1: none. L1-a was never asked, because seat 7 stopped new rounds at the hand-off.
  • L2 at CONTRACT_REVIEW_TIER: record 7064569198 on 53f788e776. PASS, no must-fix. Open: S1 (ADR-0155 says driver-memory evaluates the leaf) and S2 (D6's PG cell has no reading at the head), plus nits N1–N4. Brief: 7064575353. Security-touching: yes, so the seat adopting the record adds the security label.
  • Round 4 (4f11b215c3) answers S1, S2, N1, N2 and N4. N3 went to spec/objectql: the SharedRecordIds and seam docblocks still describe the share-grant list in the present tense after the switch #36121. The S2 reading is 7064863601: PG 16.15, 22 passed (11 sqlite + 11 postgres). The round's account is 7065426485 on the card. The L2 delta on 4f11b215c3 is owed and must close S1 and S2 by id. Its scope is the round-4 commit alone (5 files).

Owed before landing.

  • Clause-②: yes (narrowing), in the PR body and the changeset. Narrowings: on storage rows that cannot evaluate the leaf (another datasource, mongodb, odata, driver-memory), grants stop counting under R2, and the grant door and the rule door answer SHARING_NOT_ENABLED/422. A host that registers a sys_record_share middleware or find hook by name refuses boot with 500 under R1. Metadata-protocol: none. Skills-docs: updated here.
  • check-governed-merges --pr 36116: GOVERNED. 2 of 32 paths hit the register (the ADR and skills/**), so this is Tier H. The low-risk skills arm does not apply: the ADR edit removes one line (the line-160 anchor was reduced in place, ADR-0113 precedent, explained in the round-2 note), code paths are present, and the line reads Clause-②: yes (narrowing). Size is 1,829 lines, under 3,000.
  • The four pieces are needed: seat record (速读 + 席位意见 + ## 席位核对) before pr_ready, pm:awaiting-merge, reviewers os-zhuang and hotlong, and the final 速读 in the body. The maintainer Approves. The PG16 no-grant total cost (7.88 → 42.21 ms at 1M rows; the page is flat) is stated in the changeset and the 速读 for his weighing. Follow-up driver-sql: measure id = ANY(ARRAY(SELECT …)) against the share-grant semi-join for a caller with no grant on PostgreSQL (ADR-0155 step 6 cost) #36034 tracks it.
  • Open should-fix / nits: S1 and S2 are pending the delta. N3 is filed as spec/objectql: the SharedRecordIds and seam docblocks still describe the share-grant list in the present tense after the switch #36121. A docs gap was found in round 4 and not filed: content/docs/kernel/runtime-services/sharing-service.mdx (Typical Errors) and content/docs/permissions/sharing-rules.mdx do not list the new SHARING_NOT_ENABLED cause (the share table's datasource is not under a SQL driver). The dev recommends a two-clause prose round in this PR. Seat 4 decides.
  • ADR index row: docs/adr/README.md's ADR-0155 row is unchanged. The status stays Accepted, and the two new notes are dated and append-only.

Landing steps and traps.

  • The dogfood shards and Temporal Conformance (live PG + MySQL) skip on pull_request. Their reading for this head comes from the merge queue / first push run. The local battery at 4f11b215c3 was green (483 files passed, 3 skipped).
  • The PG cell of shared-record-ids-switch.test.ts runs only with OS_TEST_POSTGRES_URL set, and no CI job sets it (ci: run plugin-sharing's share-grant switch test against live PostgreSQL (OS_TEST_POSTGRES_URL) in CI #36120). Re-read it by hand if the head moves.
  • post-stamped refuses a body patch while newer comments are unacknowledged: pass --ack-through=<id>. A relay body patch must open with the signature line.
  • The branch claude/project-thread-thptm0 belongs to this card thread, and the worktree is kept clean at the head. A main merge, if needed, goes on this branch with a merge, not a rebase.
  • origin/main is at 3c06fc53ae, 5 commits past base 78437e20d7. overlap-check is clean.

Follow-up cards filed:

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5nbzs5iP1HcMCFhZo5

L1 verdict (L1-a): REWORK, two text items (no code) at head 4f11b215c37f3e276d901369bd314735f9de627b (Fixes #33787, ADR-0155 plan step 6). This is a full read of the diff against main (32 files, +1,574/-255) and the first L1 on record. Tier H (docs/adr/**, skills/**) and Clause-②: yes (narrowing), so after ACCEPT and the contract delta the seat hands it to approvers.

席位核对

Shape and gates.

  • l1-face --pr 36116 at 4f11b21:
    • Shape: draft against main, first line Fixes #33787, and no closing keyword binds another card.
    • Declarations: Clause-②: yes (narrowing), Metadata-protocol: none, Skills-docs: updated here.
    • Floors: Lint & Repo Gates and TypeScript Type Check are success.
    • Check-runs: 61 success, 13 expected skip, 0 failed, 0 pending. mergeable_state is clean.
  • Two flags:
    • changeset: @objectstack/spec is touched with no entry. See R2.
    • dogfood: owed by the ! and the (narrowing) arm. The PR body records the full battery at 4f11b21 (pnpm --filter @objectstack/dogfood test, no shard: 483 files passed, 3 skipped). The dogfood shards skip on pull_request, so their first CI reading is the queue run.
  • Size: 1,829 lines, under 3,000.

Fixes is right. ADR-0155 D6 says "The plugin-sharing switch is where #33787 ends". The cloud half of the O8 census is #36115, and the remaining follow-ups are #36034, #36120 and #36121.

The code against the rulings (holds).

  • buildReadFilter / buildWriteFilter (sharing-service.ts):
    • The limit: 5000 grant reads are gone. The share arm is now SharedRecordIds.read(object, user) on reads and .write(object, user, WRITE_ACCESS_LEVELS) on the predicate-update scope (③ ruled A).
    • Approval ids are their own disjunct, and delete still returns the owner match alone.
    • The arm is written only where shareGrantsInertReason(object) === null (② R2).
    • checkEdit reads no grant row where that reason is set, so the read scope, the bulk-write scope and the edit gate cannot disagree.
  • shareGrantsInertReason:
  • share-arm-boot.ts and its two kernel:bootstrapped hooks:
    • R1: a registration for sys_record_share by name throws the seam's fixedReadLeafRefusal, INTERNAL_ERROR / 500, before kernel:listening. There is no system-read exemption, and a no-object or '*' registration is outside the class (D4's boundary, told in the changeset and the contract prose).
    • R2's report: a warn, once, never failing the boot. Its read failures are logged, not swallowed.
  • buildSharingMiddleware no longer mirrors the scope under ast.filter (N1, closed in round 4). I checked that nothing reads it after the middleware has run:
    • The engine folds filter as an alias only where where is null (metadata-core/src/engine-findone-predicate.ts#foldedWhere, the canonical spelling wins).
    • The middleware always sets where.
    • No driver reads ast.filter (git grep over packages/objectql/src and the drivers).
  • explain: shareGrantsInertReason is passed through from the sharing service and not re-derived (security-plugin-explain-access.ts).
  • Refusal assertions:
    • The boot refusal asserts { code: 'INTERNAL_ERROR', status: 500 } at the plugin level.
    • The rule-save door asserts code: 'SHARING_NOT_ENABLED' and status: 422.
    • The grant door asserts the SHARING_NOT_ENABLED: message prefix, which is that door's existing convention: sharing-routes.ts maps it to 422, and the ERROR_CODE_LEDGER row is asserted.
  • The cap tests (shared-record-ids-switch.test.ts):
    • At 5,000 grants the leaf and the retired list agree.
    • At 5,001 and 6,000 the leaf counts every grant (7,000 rows; the 6,000th is read by id), while the list's control reads 5,000. Each case has its positive control.
    • Nested, delegated, queue and approval arms are each a case.
  • The dogfood [integrity] pin moved from { owner_id: bobId } to the owner disjunct inside the $or. The behavioural assertion after it (Bob reads only his own row) is unchanged.

ADR, skills and contract prose, sentence by sentence.

  • ADR-0155 note 1 (grantedRecordIds gone; its blank-id filter is FixedInnerRead's guard) is true of the diff.
  • Note 2 (S1: the switch landed before step 4, so driver-memory takes R2) is true. driver-memory declares no fixedReadLeaves, and ruling 7045701086 is cited.
  • The in-place edit of line 160 (removing the dead anchor) is explained in note 1. It is the approver's to weigh under the append-only discipline.
  • The skills/objectstack-data/rules/datasources.md addition is exact (contract N2). The cuts are restatement, and the "double opt-in" heading still carries the federation default, so the value density for a customer agent holds.
  • The ISharingService prose in packages/spec/src/contracts/sharing-service.ts now states the leaf in the present tense, R2's refusals and the D4 boundary. All of it is true of the diff.

REWORK. One os-dev text round, one commit. Both items are text, so the contract delta reads the same round.

  • R1, the docs gap (seat 4 asked whether to hold): hold, fix in this PR.
    • Two published pages list the causes of SHARING_NOT_ENABLED as a closed list, and this PR adds a cause they do not name.
    • The pages: content/docs/kernel/runtime-services/sharing-service.mdx:67 (Typical Errors: the grant causes and the rule-save sentence) and content/docs/permissions/sharing-rules.mdx:161-169 (the rule-save refusal list).
    • The new cause: the object is stored on another datasource than sys_record_share, or by a driver that does not evaluate share grants (today MongoDB, in-memory, OData).
    • This round turns both lists false, and it is the BREAKING tightening a host meets first. The checklist rule "a published defect this round makes false must be fixed" applies.
    • Two clauses, plus the remedy sentence the changeset already has ("store it on the datasource of sys_record_share, on a driver that evaluates share grants").
    • Tier H already waits on an approver, so holding costs one short round.
  • R2, the changeset does not name @objectstack/spec.
    • packages/spec/src/contracts/sharing-service.ts changes published TSDoc. The .d.ts in dist carries it, and grant()'s doc now names the R2 refusal.
    • @objectstack/spec is public. The fixed group versions it with plugin-sharing, so the version is not the issue. But the checklist asks for a changeset entry for every published package touched, and a missing one is not enqueued.
    • Add '@objectstack/spec': patch to .changeset/33787-shared-record-ids-switch.md. If a spec-changeset gate then asks for more, the dev reports the gate verbatim and the seat decides.
  • After the round I will read only the delta.

Not L1's: the contract delta on S1/S2 (S2's PG reading 7064863601), the four pieces of the Tier H hand-off, the security label from adopting the record, and the queue-run dogfood shards.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 4f11b215c37f3e276d901369bd314735f9de627b
Local-runs: none
Scope: docs/adr/0155-*.md, skills/objectstack-data/rules/datasources.md, packages/spec/src/contracts/sharing-service.ts + packages/plugins/plugin-sharing/src/sharing-service.ts, packages/plugins/plugin-sharing/src/sharing-plugin.ts, packages/plugins/plugin-sharing/src/sharing-rule-service.ts, packages/plugins/plugin-sharing/src/shared-record-ids-switch.test.ts, packages/plugins/plugin-sharing/src/sharing-service.test.ts
Security-touching: yes

Delta review of record 7064569198 (PASS at 53f788e776, S1 and S2 open) after seat 7's hand-over to seat 4. Delta 53f788e776..4f11b215c3: one commit, 5 files, +68/−13. Run by an isolated subagent at the contract tier, fed the prior record, the round-4 account 7065426485, the PG reading 7064863601 and the diff, not the seat's or the dev's conclusions. Nothing built or run.

① Derived judgments

② Semver level

Clause-②: yes (narrowing) and Metadata-protocol: none stand; the only runtime change in the delta removes an unread mirror. L1-a's R2 (7065619919): @objectstack/spec's published TSDoc changes, so the changeset owes a patch line for it.

③ Boundary flags

  • ADR edit acceptable. Two dated blockquote notes (:197-204, :532-542) plus one in-place edit at :160 (path#grantedRecordIds → bare grantedRecordIds), forced by scripts/check-adr-symbol-anchors.mjs once the symbol is removed, meaning-preserving and disclosed in the note at :197-204. The ADR-0113 precedent cited for it was not located; the edit stands on the gate.
  • Docs gap. content/docs/kernel/runtime-services/sharing-service.mdx:67 and content/docs/permissions/sharing-rules.mdx:161-165 list SHARING_NOT_ENABLED causes without the storage cause. This reviewer graded it an acceptable follow-up; L1-a (7065619919 R1) holds the PR for it because the lists read as closed. The seat folds it into this PR; the fix must name both causes (nit C).
  • Security. No hole found: the leaf's inner read is the retired capped read's predicate (packages/spec/src/data/shared-record-ids.ts; old sharing-service.ts:818-827, :940-950); noise grants (other recipient, other object, team) do not count; approval ids are a read-only disjunct, empty for a delegated principal (:835-836, :862); delete stays owner-scoped (:931); phantom-anchor objects get no leaf (:803-806, :923); the delegator's filter is AND-ed (sharing-plugin.ts:1541-1553); an engine that cannot classify the leaf refuses with 500.
  • Author. objectstack-fleet[bot]. Tier H: lands on the maintainer's approval.

④ Design judgment

  • Nit A. ADR note title :532 "until a driver declares the leaf" vs body "the driver"; the note does not list :492 or :629, neither a state claim about step 6.
  • Nit B. The changeset does not say the AST filter key is no longer written (the PR body does); same class the prior record accepted.
  • Nit C. The hand-off and PR body describe the new cause as "the share table's datasource is not under a SQL driver"; the code has two causes (sharing-service.ts:1751-1768): a different datasource from sys_record_share (even a SQL one), or a driver that does not declare the leaf. The docs fold must name both.

Implemented-by: claude/project-thread-thptm0
Reviewed-by: session_01FEkQ5krBqrrgxCYgjXmfbv

VERDICT: PASS

…changeset names @objectstack/spec (#33787)

L1-a 7065619919 R1/R2 and contract record 7065677186 nit C: the two pages
that list SHARING_NOT_ENABLED causes now name the ADR-0155 R2 cause (another
datasource than sys_record_share, or a driver that does not evaluate the
share-grant subquery) and the remedy; the changeset adds the
@objectstack/spec patch line for the published contract TSDoc.

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

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv

Prose-only head move · 2026-11-21T16:29Z

Regen-provenance: 7065677186 · 4f11b21 → 4bfe46d · git diff --stat 4f11b21 4bfe46d -- ':!content/docs/' ':!.changeset/' → (empty)

The seat's commit 4bfe46dc53 answers L1-a's REWORK 7065619919 (R1: sharing-service.mdx Typical Errors and sharing-rules.mdx now name the ADR-0155 R2 storage cause of SHARING_NOT_ENABLED, both halves per contract nit C, with the remedy; R2: the changeset adds '@objectstack/spec': patch). It touches only content/docs/** and .changeset/**, so contract record 7065677186 continues at the new head, and the PG cell reading 7064863601 stands: no source or test file moved.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5nbzs5iP1HcMCFhZo5

L1 verdict (L1-a): ACCEPT at head 4bfe46dc534ebaea879becc8879f40c5f3316da0 (Fixes #33787, ADR-0155 plan step 6). This is a delta read of 4f11b215c3..4bfe46dc53: one commit, 3 files, +7/-3, docs and changeset only. It closes R1 and R2 of my REWORK 7065619919. That record's code reading stands, because no package source moved.

席位核对

  • R1, closed. Each sentence was checked against SharingService.shareGrantsInertReason at this head.
    • content/docs/kernel/runtime-services/sharing-service.mdx:67 (Typical Errors, the grant causes) adds "an object whose share grants cannot count where it is stored".
      • "another datasource than sys_record_share, even a SQL one" is the other-datasource class from the engine's fixedReadLeafClassOf.
      • "a driver that does not evaluate the share-grant subquery, today MongoDB, in-memory and OData" matches driverEvaluatesFixedReadLeaf and the drivers' declarations.
      • The remedy ("store it on the datasource of sys_record_share, on a driver that evaluates share grants, as the SQL drivers do") is the rule-save door's own remedy text.
    • The rule-surface sentence after it ("one no gate consults for any recipient") now covers the new cause through the grant list it refers to.
    • content/docs/permissions/sharing-rules.mdx:161-168 adds the same cause to the closed list of rule-save refusals, with ADR-0155 R2 cited. The page's next sentence ("a sentence that names the object and how to turn record sharing on for it") is true of sharingRuleRefusalRemedy's R2 branch.
  • R2, closed. '@objectstack/spec': patch is added to the changeset frontmatter. This is consistent with the fixed group, and Check Changeset is success at this head.
  • Gates at 4bfe46d.
    • When read: 47 success, 10 expected skip, 0 failed, 11 pending (Test Core 1, 9 and 10 of 10, and eight Test UI shards).
    • Lint and type-check floors had reported success.
    • Landing needs every check green at this head. That is the landing seat's read.
  • Dogfood. The battery recorded in the PR body is at 4f11b215c3 (483 files passed, 3 skipped). This delta changes only content/docs/** and a .changeset file. No dist and no dogfood stack loads either, so that reading carries to this head. The dogfood shards' first CI reading is still the queue run.

Landing (not L1's):

  • The contract delta on this head (S1/S2, and the record's Regen-provenance 7065695779 for the prose).
  • The security label.
  • The Tier H hand-off to approvers (the four pieces).

Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv

席位核对

Awaiting a governed merge · 2026-11-21T16:58Z · head 4bfe46dc534ebaea879becc8879f40c5f3316da0

@objectstack-fleet objectstack-fleet Bot added pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue security labels Nov 21, 2026
@objectstack-fleet objectstack-fleet Bot removed the needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides label Nov 21, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 21, 2026 17:31
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit 52a2398 Nov 21, 2026
83 of 85 checks passed
@os-zhuang
os-zhuang deleted the claude/project-thread-thptm0 branch November 21, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue protocol:data security 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

2 participants