From 0fcd5b1bba7323baff0810f57386797536deffde Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 16:44:06 +0000 Subject: [PATCH 1/3] docs(spec): the cbp-optional-master-admitted entry states the current write rule for an empty optional master The entry's replacement and its step-18 upgrade-guide paragraph still said a write leaving an optional controlled_by_parent master empty is refused with 422. The write gate now admits it by the owner rule: the owner or Modify All on the detail writes such a row, everyone else is refused 403 PERMISSION_DENIED, and only an empty required master reference still answers 422 MISSING_REQUIRED_FIELD. Text only; id, surface and reason unchanged. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5odNVgHTd2MQbQCp5t --- ...69-cbp-optional-master-entry-write-text.md | 10 ++++++++++ .../18.cbp-optional-master-admitted.ts | 19 ++++++++++++++++--- .../spec/src/migrations/registry.ts.template | 6 ++++-- 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 .changeset/31169-cbp-optional-master-entry-write-text.md diff --git a/.changeset/31169-cbp-optional-master-entry-write-text.md b/.changeset/31169-cbp-optional-master-entry-write-text.md new file mode 100644 index 00000000000..32d4882beb3 --- /dev/null +++ b/.changeset/31169-cbp-optional-master-entry-write-text.md @@ -0,0 +1,10 @@ +--- +'@objectstack/spec': patch +--- + +docs(spec): the semantic migration entry `cbp-optional-master-admitted` states the current write rule for an empty optional master + +Clause-②: no +Metadata-protocol: none + +The entry's `replacement`, and its paragraph in the protocol upgrade guide, still said that a write leaving an optional `controlled_by_parent` master empty is refused with 422. The write gate admits such writes since the owner rule landed (ADR-0055 §3 as amended): an insert that names no master is admitted and its creator owns the row; its owner and a holder of Modify All on the detail update or delete a row whose master reference is empty, and everyone else, View All included, is refused `403 PERMISSION_DENIED`; an update that empties a named master asks edit access on the master it leaves. Only a required master's empty stored reference is still refused with `422 MISSING_REQUIRED_FIELD`. Text only: the entry's `id`, `surface`, `reason` and `acceptanceCriteria`, and every schema and runtime answer, are unchanged. diff --git a/packages/spec/src/migrations/entries/semantic/18.cbp-optional-master-admitted.ts b/packages/spec/src/migrations/entries/semantic/18.cbp-optional-master-admitted.ts index 749282bf3b9..987207a9966 100644 --- a/packages/spec/src/migrations/entries/semantic/18.cbp-optional-master-admitted.ts +++ b/packages/spec/src/migrations/entries/semantic/18.cbp-optional-master-admitted.ts @@ -13,6 +13,13 @@ import type { SemanticMigration } from '../../types.js'; // its meaning where the spec sees the omission (the builder force and the D2 // conversion cbp-master-detail-required-defaulted, both unchanged). No D2 // conversion: nothing is rewritten. +// +// The write side followed under ADR-0055 §3 as amended (same ruling A, PR +// #31082), and the `replacement` below records it beside the read side: a +// detail row whose OPTIONAL master reference is empty is written by its owner +// and by Modify All on the detail and refused `403 PERMISSION_DENIED` for +// everyone else, an insert naming no master is admitted, and only a REQUIRED +// master's empty stored reference still answers `422 MISSING_REQUIRED_FIELD`. export const entry: SemanticMigration = { id: 'cbp-optional-master-admitted', surface: 'object.sharingModel = \'controlled_by_parent\' together with object.fields — a `master_detail` ' @@ -21,9 +28,15 @@ export const entry: SemanticMigration = { + 'field with `required: false`, an optional master. A detail row that names its master is read exactly as ' + 'before, by whoever can read that master. A row whose master reference is empty is read by its owner ' + '(`owner_id`) and by a holder of View All on the detail, and by nobody else: a row with no owner, or on ' - + 'an object that carries no `owner_id` column, is read through View All alone. Writes are unchanged by ' - + 'this entry: an insert or update that leaves the master reference empty is still refused with 422. ' - + 'Declare `required: true` when every row must name its master; an omitted `required` keeps meaning ' + + 'an object that carries no `owner_id` column, is read through View All alone. Writes follow the same ' + + 'owner: an insert that names no master is admitted, and its creator owns the row; its owner and a ' + + 'holder of Modify All on the detail update or delete a row whose master reference is empty, and ' + + 'everyone else who reaches the write gate, View All included, is refused `403 PERMISSION_DENIED`; a ' + + 'row with no owner, or on an object that carries no `owner_id` column, is written through Modify All ' + + 'alone. An update that empties a named master asks edit access on the master it leaves. A required ' + + 'master is unchanged: a row whose stored required master reference is empty is still refused with ' + + '`422 MISSING_REQUIRED_FIELD`. Declare `required: true` when every row must name its master; an ' + + 'omitted `required` keeps meaning ' + 'required through `ObjectSchema.create()` and on stored rows, and `os lint` reports it at `error` so the ' + 'author writes one of the two.', reason: diff --git a/packages/spec/src/migrations/registry.ts.template b/packages/spec/src/migrations/registry.ts.template index 71d70652a96..0495e153dc3 100644 --- a/packages/spec/src/migrations/registry.ts.template +++ b/packages/spec/src/migrations/registry.ts.template @@ -1327,8 +1327,10 @@ const STEP18_RATIONALE: readonly RationaleFragment[] = [ + 'master from it, and a detail row that names no master is read by its owner and by View All on the ' + 'detail, never through a master, while a row that names one is read through it as before. The builder ' + 'keeps an explicit `required: false` as written and still forces an omitted one to `true`, and the ' - + 'stored-row listing stops naming the shape. Writes are unchanged: an empty master reference is still ' - + 'refused with 422. Its D3 record is the semantic entry `cbp-optional-master-admitted`.', + + 'stored-row listing stops naming the shape. A detail row that names no master is written by its ' + + 'owner and by Modify All on the detail, and refused with 403 for everyone else; only an empty ' + + 'required master reference is still refused with 422. Its D3 record is the semantic entry ' + + '`cbp-optional-master-admitted`.', }, { id: 'chart-config-aria-retired', From d3adb0d1cdbf4bebe67ae162616037ecf1f31d0a Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 17:11:41 +0000 Subject: [PATCH 2/3] docs(spec): the security-service contract names the ownerMayEdit owner leg of the controlled_by_parent write check The allow bullet of ControlledByParentWriteOutcome and the docblock of ISecurityService.checkControlledByParentWrite read as if every by-id update of a controlled_by_parent record needed edit access to its master. A detail declaring sharing.controlledByParent.ownerMayEdit: true lets the record's owner, not on behalf of another user, update it by id with read access to the master, unless the body empties an optional master (ADR-0055 section 3 as amended). Both docblocks now say so. The changeset covers this and the migration-entry text. JSDoc only. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5odNVgHTd2MQbQCp5t --- ...69-cbp-optional-master-entry-write-text.md | 7 +++++-- .../spec/src/contracts/security-service.ts | 21 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.changeset/31169-cbp-optional-master-entry-write-text.md b/.changeset/31169-cbp-optional-master-entry-write-text.md index 32d4882beb3..9419822668a 100644 --- a/.changeset/31169-cbp-optional-master-entry-write-text.md +++ b/.changeset/31169-cbp-optional-master-entry-write-text.md @@ -2,9 +2,12 @@ '@objectstack/spec': patch --- -docs(spec): the semantic migration entry `cbp-optional-master-admitted` states the current write rule for an empty optional master +docs(spec): the semantic migration entry `cbp-optional-master-admitted` states the current write rule for an empty optional master, and the security-service contract names the `ownerMayEdit` owner leg Clause-②: no Metadata-protocol: none -The entry's `replacement`, and its paragraph in the protocol upgrade guide, still said that a write leaving an optional `controlled_by_parent` master empty is refused with 422. The write gate admits such writes since the owner rule landed (ADR-0055 §3 as amended): an insert that names no master is admitted and its creator owns the row; its owner and a holder of Modify All on the detail update or delete a row whose master reference is empty, and everyone else, View All included, is refused `403 PERMISSION_DENIED`; an update that empties a named master asks edit access on the master it leaves. Only a required master's empty stored reference is still refused with `422 MISSING_REQUIRED_FIELD`. Text only: the entry's `id`, `surface`, `reason` and `acceptanceCriteria`, and every schema and runtime answer, are unchanged. +- **Migration entry `cbp-optional-master-admitted`.** Its `replacement`, and its paragraph in the protocol upgrade guide, still said that a write leaving an optional `controlled_by_parent` master empty is refused with 422. The write gate admits such writes since the owner rule landed (ADR-0055 §3 as amended): an insert that names no master is admitted and its creator owns the row; its owner and a holder of Modify All on the detail update or delete a row whose master reference is empty, and everyone else, View All included, is refused `403 PERMISSION_DENIED`; an update that empties a named master asks edit access on the master it leaves. Only a required master's empty stored reference is still refused with `422 MISSING_REQUIRED_FIELD`. The entry's `id`, `surface`, `reason` and `acceptanceCriteria` are unchanged. +- **`ISecurityService.checkControlledByParentWrite` and `ControlledByParentWriteOutcome` (JSDoc).** Both now name the `sharing.controlledByParent.ownerMayEdit: true` opt-in (ADR-0055 §3 as amended 2026-10-26): a by-id update by the record's owner, not on behalf of another user, that does not empty an optional master, needs only read access to the master the record names, so the check answers `allow` for such an owner who can read it. Every other caller and every other write keeps the master-edit rule. + +Text only: no schema, type, export or runtime answer changes. diff --git a/packages/spec/src/contracts/security-service.ts b/packages/spec/src/contracts/security-service.ts index 9c85060e670..b88ea203521 100644 --- a/packages/spec/src/contracts/security-service.ts +++ b/packages/spec/src/contracts/security-service.ts @@ -405,8 +405,14 @@ export type ControlledByParentWriteUnresolvedReason = * chain for the principal (and, on an on-behalf-of context, for the delegator * too), and where the chain ends at a row whose OPTIONAL master reference is * empty (the record itself, or a master above it) that row's owner rule - * admits them too. Or the context is a system one, which the write path - * never checks. + * admits them too. Or the detail opts in with + * `sharing.controlledByParent.ownerMayEdit: true` (ADR-0055 §3 as amended + * 2026-10-26) and its owner leg admits the principal in place of the walk: + * the context is not on behalf of another user, the record's stored + * `owner_id` is the principal's own `userId`, and the principal can READ the + * master the record names, so no leg asks EDIT on that master or any master + * above it. Or the context is a system one, which the write path never + * checks. * - `deny`: the check refuses, on the {@link ControlledByParentWriteDenialLeg} * it names. * - `not_applicable`: the object does not declare `controlled_by_parent`, so @@ -1086,7 +1092,16 @@ export interface ISecurityService { * security, and record sharing (whose refusal an app-authored update policy * on the master can lift, {@link checkAuthoredRowWrite}). A master whose own * optional master reference is empty ends the chain, and the same owner rule - * is asked of it on its own object. This member exposes that check + * is asked of it on its own object. A detail that declares + * `sharing.controlledByParent.ownerMayEdit: true` relaxes the edit rule for + * one write (ADR-0055 §3 as amended 2026-10-26): a by-id update by the + * record's owner (its stored `owner_id` is the caller's own `userId`), not on + * behalf of another user, that does not empty an optional master, needs only + * READ access to the master the record names, asked of the read door under + * the caller's own context, and walks no chain. Every other caller, and every + * insert, delete, predicate update and on-behalf-of write, keeps the edit + * rule. The leg is part of the check, so such an owner who can read the + * master gets `allow` here as on the update. This member exposes that check * to code outside the write path, such as a gate on a record's attachments or * comments that must judge the record as its own update is judged. It adds no * verdict: every outcome it resolves with is one the check already reaches, From 082e8bf80665184fce72aa9120aaea14e3b9bcb5 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 17:57:27 +0000 Subject: [PATCH 3/3] docs(spec): scope the ownerMayEdit "walks no chain" sentence and supersede the pending read-side changeset's write line The checkControlledByParentWrite docblock said the owner leg walks no chain; it walks none for the master the record names, while a body that re-points the row under another master still asks edit on that master (askBodyNamedMaster). The spec changeset now names the stale "Writes are unchanged ... 422" sentence of the pending 30905 changeset as superseded by the write rule. Text only. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5odNVgHTd2MQbQCp5t --- .changeset/31169-cbp-optional-master-entry-write-text.md | 2 +- packages/spec/src/contracts/security-service.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.changeset/31169-cbp-optional-master-entry-write-text.md b/.changeset/31169-cbp-optional-master-entry-write-text.md index 9419822668a..aec49589ffc 100644 --- a/.changeset/31169-cbp-optional-master-entry-write-text.md +++ b/.changeset/31169-cbp-optional-master-entry-write-text.md @@ -7,7 +7,7 @@ docs(spec): the semantic migration entry `cbp-optional-master-admitted` states t Clause-②: no Metadata-protocol: none -- **Migration entry `cbp-optional-master-admitted`.** Its `replacement`, and its paragraph in the protocol upgrade guide, still said that a write leaving an optional `controlled_by_parent` master empty is refused with 422. The write gate admits such writes since the owner rule landed (ADR-0055 §3 as amended): an insert that names no master is admitted and its creator owns the row; its owner and a holder of Modify All on the detail update or delete a row whose master reference is empty, and everyone else, View All included, is refused `403 PERMISSION_DENIED`; an update that empties a named master asks edit access on the master it leaves. Only a required master's empty stored reference is still refused with `422 MISSING_REQUIRED_FIELD`. The entry's `id`, `surface`, `reason` and `acceptanceCriteria` are unchanged. +- **Migration entry `cbp-optional-master-admitted`.** Its `replacement`, and its paragraph in the protocol upgrade guide, still said that a write leaving an optional `controlled_by_parent` master empty is refused with 422. The write gate admits such writes since the owner rule landed (ADR-0055 §3 as amended): an insert that names no master is admitted and its creator owns the row; its owner and a holder of Modify All on the detail update or delete a row whose master reference is empty, and everyone else, View All included, is refused `403 PERMISSION_DENIED`; an update that empties a named master asks edit access on the master it leaves. Only a required master's empty stored reference is still refused with `422 MISSING_REQUIRED_FIELD`. This supersedes the sentence "Writes are unchanged: an insert or update that leaves the master reference empty is still refused with 422" in the `@objectstack/plugin-security` note of `.changeset/30905-cbp-optional-master.md`: that was the state before the write gate followed, and the rule above is the one that ships. The entry's `id`, `surface`, `reason` and `acceptanceCriteria` are unchanged. - **`ISecurityService.checkControlledByParentWrite` and `ControlledByParentWriteOutcome` (JSDoc).** Both now name the `sharing.controlledByParent.ownerMayEdit: true` opt-in (ADR-0055 §3 as amended 2026-10-26): a by-id update by the record's owner, not on behalf of another user, that does not empty an optional master, needs only read access to the master the record names, so the check answers `allow` for such an owner who can read it. Every other caller and every other write keeps the master-edit rule. Text only: no schema, type, export or runtime answer changes. diff --git a/packages/spec/src/contracts/security-service.ts b/packages/spec/src/contracts/security-service.ts index b88ea203521..9bf15285a19 100644 --- a/packages/spec/src/contracts/security-service.ts +++ b/packages/spec/src/contracts/security-service.ts @@ -1098,7 +1098,9 @@ export interface ISecurityService { * record's owner (its stored `owner_id` is the caller's own `userId`), not on * behalf of another user, that does not empty an optional master, needs only * READ access to the master the record names, asked of the read door under - * the caller's own context, and walks no chain. Every other caller, and every + * the caller's own context, and walks no chain for that master; a body that + * re-points the row under another master still asks EDIT on that master, as + * every body naming a new master does. Every other caller, and every * insert, delete, predicate update and on-behalf-of write, keeps the edit * rule. The leg is part of the check, so such an owner who can read the * master gets `allow` here as on the update. This member exposes that check