Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ Three write-time refusals so a persisted share always means something:
2. **`grant()` validates the object is in an enforcing posture** — `effectiveSharingModel` is `private` or `read` **and** the object has an `owner_id` field. Otherwise → **422** (`SHARING_NOT_ENABLED`): a share on a public / bypass / owner-less object enforces nothing. `controlled_by_parent` is refused explicitly (Salesforce parity — a detail record is not independently shareable; its access follows the master).

*Amended 2026-10-24 (ruling 6377844010 on objectstack-ai/objectstack#25549, letter A; landed in #25591).* An external principal meets an owner-only floor on every object (ruling 6355206139, letter B), so a share row on a public object IS consulted for that population. On an object whose effective model is `public` and whose `owner_id` is real (not a federated phantom anchor), `grant()` therefore admits a `user` recipient whose `sys_member.role` in the record's organization is exactly `external`; every other recipient keeps the 422. The verdict reads the object and the recipient's population, never the granter. A sharing rule materialises rows for its external recipients only and reports the skipped half in one line. `controlled_by_parent` stays refused for every recipient.

*Amendment note 2026-11-17 ([ADR-0155](./0155-sharing-scope-share-grants-lower-to-an-engine-internal-semi-join-leaf.md), Accepted; ruling record [`6942854600`](https://github.com/objectstack-ai/objectstack/issues/33787#issuecomment-6942854600) on #33787, its ② ruled R2).* This rule gains one more arm. A share on an object whose evaluator cannot run ADR-0155's share-grant leaf (`driver-mongodb`, `driver-odata`, a driver this repository does not ship that does not declare it evaluates the leaf, or an object bound to another datasource than `sys_record_share`) enforces nothing, so `grant()` and the sharing-rule save door refuse it as inert with the same **422** (`SHARING_NOT_ENABLED`), and no gate consults existing grants on that object; owner, queue and approval access is unchanged. The arm takes effect with ADR-0155's plugin-sharing switch, with the boot report and changelog entry D10 asks for, and not before. Nothing else in D7 moves.
3. **Manual and rule shares coexist by `source`.** The upsert key becomes `(object, record, recipient, source)` so a manual grant no longer clobbers a `source: 'rule'` row and vice versa. When multiple rows grant the same recipient, the widest `access_level` wins (Salesforce's RowCause model — grants are additive, never subtractive).

### D8 — Share-link re-share semantics are made explicit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,16 @@ any position but a `$in` comparand, the engine refuses it loudly. ⛔ No second
> `FIELD in current_user.org_user_ids` names, under its own brand, never as a mode of `ReadableIds`. "No `EXISTS`, no
> correlated form" stands. So does everything this D1 says about `ReadableIds`.

> **Amendment note (2026-11-17, [ADR-0155](./0155-sharing-scope-share-grants-lower-to-an-engine-internal-semi-join-leaf.md) — ruling record [`6942854600`](https://github.com/objectstack-ai/objectstack/issues/33787#issuecomment-6942854600) on #33787).**
> ADR-0155 (Accepted) revisits "No second leaf" for **one** more leaf and nothing else: the record ids that
> `sys_record_share` grants one user on one object (provisionally `SharedRecordIds`), under its own brand, never as a
> mode of `ReadableIds` or of ADR-0147's leaf. It is the second record to do so, and a new leaf still needs a Tier H
> record of its own. It also revisits this D1's read-verbs sentence for that leaf alone (its ③, ruled A): the leaf's
> write form is legal in the `where` of a predicate `update`, and nowhere else. For `ReadableIds`, for ADR-0147's leaf
> and on `delete`, the sentence stands as written. "No `EXISTS`, no correlated form" stands. This note records a
> decision that ADR-0155's execution cards will implement: until they land, `main` admits no such leaf, and this D1
> holds as written for every verb.

### D2 — ObjectQL composes the scope, once per parent object per request, fail closed

At the engine's executor boundary — on the final AST, after ingress parsing, the comparand doors, the middleware chain
Expand Down Expand Up @@ -203,6 +213,17 @@ restriction".
- The leaf joins the per-driver conformance case-sets, so a driver that compiles it is measured and one that refuses
is recorded as refusing.

> **Amendment note (2026-11-17, [ADR-0155](./0155-sharing-scope-share-grants-lower-to-an-engine-internal-semi-join-leaf.md) — ruling record [`6942854600`](https://github.com/objectstack-ai/objectstack/issues/33787#issuecomment-6942854600) on #33787).**
> The refusal bullet's "⛔ No `DriverCapabilities` bit returns" is revisited for ADR-0155's leaf alone, as ADR-0147
> (Proposed) revisits it for its own. Under ADR-0155's ②, ruled R2 for the storage that cannot run that leaf, a driver declares
> whether it evaluates such leaves, and the declaration is read up front: on an object whose evaluator does not
> declare it, the producer writes no share arm and share grants are refused as inert (ADR-0111 D7, as noted there).
> A leaf that still reaches a driver that cannot run it is refused in the refusal bullet's envelope (status 500,
> `INTERNAL_ERROR`, logged at `error` once per driver; ADR-0155's R1). The declaration's name is ADR-0155's O1, and
> where ADR-0147's declaration is the same one, it is built once (ADR-0155 D4). This note moves nothing this section
> says about `ReadableIds`. It records a decision that ADR-0155's execution cards will implement: until they land,
> `main` has no such declaration and no such leaf.

### D4 — The six consumers emit one leaf per parent object, and no pre-scan

- **The activity stream and the compliance ledger** keep
Expand Down Expand Up @@ -373,6 +394,13 @@ change is #33696's, and by the ruling it lands only after this amendment merges.
- **O3** — `driver-mongodb`: the cost of a pipeline form is unprototyped; it refuses until measured.
- **O4** — `packages/plugins/plugin-sharing/src/sharing-service.ts` reads a caller's record-share grants at
`limit: 5000` with no warning; that scope rides into the subquery unchanged. A separate finding, not this record's.
**Answered** (2026-11-17): [ADR-0155](./0155-sharing-scope-share-grants-lower-to-an-engine-internal-semi-join-leaf.md)
(Accepted; ruling record
[`6942854600`](https://github.com/objectstack-ai/objectstack/issues/33787#issuecomment-6942854600) on #33787) decides
that the share arm will lower to its own engine-internal semi-join leaf over `sys_record_share`, with no cap, so
every grant counts. The amendment notes under D1 and D3 say what that record revisits here. This records a decision
that ADR-0155's execution cards will implement: the capped read above stands until the plugin-sharing switch under
#33787 lands, and not before.
- **O5** — whether `controlled_by_parent`'s id set becomes a seventh consumer (D6). **Answered** (2026-10-21): the
ruling is recorded verbatim in D6, as amended.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ when the read runs, where the array was read when the request was resolved ([Con
With no active organization the leaf composes to the plain `$in: [caller]`, and no subquery is issued.
- **The name.** `OrgMemberIds` is the proposed name, a new export of `@objectstack/spec` beside `ReadableIds` (O1).

> **Amendment note (2026-11-17, [ADR-0155](./0155-sharing-scope-share-grants-lower-to-an-engine-internal-semi-join-leaf.md) — ruling record [`6942854600`](https://github.com/objectstack-ai/objectstack/issues/33787#issuecomment-6942854600) on #33787).**
> ADR-0155 (Accepted) adds a third leaf over `sys_record_share`, and the executor seam that passes an
> arrives-composed leaf through is built once for both leaves (its D4, "Built once"). That seam holds one recipient
> rule for both: every identity a composed leaf names is compared with what the reading context itself carries. For
> this record's leaf it compares the anchor's caller and organization, together, with the anchor the reading context
> carries (D-e), and admits the leaf only when both are equal; a system context is exempt; a mismatch, or a reading
> context that carries no anchor, is a composition fault refused in ADR-0139 D3's envelope. Nothing is re-derived from
> the context's `userId` or `tenantId`, and the delegator's rebuilt context of D-c carries the live principal's anchor
> and is admitted under it. The rule checks the anchor; it changes neither what the anchor carries nor where it is
> captured (this D-a and D-c), and nothing else in this record moves. Its cases are pinned on the card that adds this
> leaf to the seam (ADR-0155 plan step 2).

### D-b — The inner filter: exactly today's read

The subquery is the resolver's own read, restated as SQL, with nothing added:
Expand Down
Loading
Loading