Repository navigation
feat(security, verify): a controlled_by_parent row with no master is written by its owner or by Modify All on the detail - #31082
Conversation
…e optional master is empty WIP: the owner rule (owner or Modify All on the detail) on a by-id write, on each row a predicate write selects and on a chain hop; an insert that names no optional master is admitted; emptying an optional master asks edit on the master it leaves, never the ownerMayEdit leg. Claude-Session: https://claude.ai/code/session_017xRBcTJTE7kSbcMoJQ4Txf Co-authored-by: Claude <noreply@anthropic.com>
…'s null-master records WIP. Claude-Session: https://claude.ai/code/session_017xRBcTJTE7kSbcMoJQ4Txf Co-authored-by: Claude <noreply@anthropic.com>
…ter detail Claude-Session: https://claude.ai/code/session_017xRBcTJTE7kSbcMoJQ4Txf Co-authored-by: Claude <noreply@anthropic.com>
…ptional master Claude-Session: https://claude.ai/code/session_017xRBcTJTE7kSbcMoJQ4Txf Co-authored-by: Claude <noreply@anthropic.com>
…r write refusal Claude-Session: https://claude.ai/code/session_017xRBcTJTE7kSbcMoJQ4Txf Co-authored-by: Claude <noreply@anthropic.com>
…ll-master-write-gate
📓 Docs Drift CheckThis PR changes 2 package(s): 22 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 8 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin b5e6d04c89b4d3261874cc3819922b0417a9a25f && git checkout b5e6d04c89b4d3261874cc3819922b0417a9a25f
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin d6b88f19f5bf9df334fa6ee95c5f88c67f7943a3 5fe5cdb46222e16b232765d98f8bfafd1448b653 && git checkout -B drift-repro d6b88f19f5bf9df334fa6ee95c5f88c67f7943a3 && git merge --no-ff 5fe5cdb46222e16b232765d98f8bfafd1448b653
node scripts/docs-audit/affected-docs.mjs --json d6b88f19f5bf9df334fa6ee95c5f88c67f7943a3
|
…a null optional-master insert is refused The verify family's ParentWriteReachReach (re-exported from the package entry) widens, so the changeset declares Clause-② yes. The comment on omissionRefusedByValidation said the write gate still refuses an insert that leaves an optional master empty; the gate now admits it. Comment only. Claude-Session: https://claude.ai/code/session_017xRBcTJTE7kSbcMoJQ4Txf Co-authored-by: Claude <noreply@anthropic.com>
|
domain:server#1 · sunhaolin · session_017xRBcTJTE7kSbcMoJQ4Txf Contract reviewServed-tier: The face is the ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:server#1 · sunhaolin · session_017xRBcTJTE7kSbcMoJQ4Txf 席位核对ACCEPT · Head-sha
Spot checks of the diff: refusals assert 席位意见:可落地。只对「可选主表且引用为空」的行放宽,按您的裁决「A」只给属主或有「修改全部」的人;必填主表的行为不变。 |
Fixes #30906
Clause-②: yes
Metadata-protocol: semantic
Skills-docs: follow-up #30907
维护者速读
required: false)的controlled_by_parent子对象里,主表引用为空的行现在可以写了:它的属主(owner_id)或对该子对象有「修改全部」的人可以改、删,其他人(包括只有「查看全部」的人)一律 403;新建一条不挂主表的行直接放行,创建者就是属主;给这种行挂上主表,要对那条主记录有编辑权;把已挂的主表清空,要对原主记录有编辑权,「属主可编辑」开关不覆盖清空。链式子对象(如联系人下的备注)在联系人没挂客户时,同样按联系人的属主规则判。os verify的父级写入证明同时覆盖「挂主表」和「不挂主表」两种行,security/explain会说明这条属主规则。packages/plugins/plugin-security/src/security-plugin-cbp-write-gate.ts里的nullMasterRowWritable,以及assertControlledByParentWrite中masterId == null && rel.optional那一段;再看controlled-by-parent-optional-master.test.ts末尾的真实引擎用例块。pnpm --filter @objectstack/plugin-security exec vitest run src/controlled-by-parent-optional-master.test.ts,预期 47 个全部通过;把nullMasterRowWritable改成恒返回 true 再跑,会红 10 个(见下文消融)。What changes
@objectstack/plugin-security— the write gate (ADR-0055 §3, step 2.8). A row of an OPTIONAL master (CbpRelation.optional) whose master reference is empty used to answer422 MISSING_REQUIRED_FIELDon every write. It is now judged, on every shape the gate judges:nullMasterRowWritable, new): such a row is written by its owner (owner_id, non-null, equal to the principal'suserId) and by a holder ofmodifyAllRecordson its object (PermissionEvaluator.hasSuperuserWriteBypass). Everyone else is refused403 PERMISSION_DENIED,details: { operation, object, recordId }naming the row, legmaster_chain. A queue row (no owner) and every row of an object without anowner_idcolumn are Modify All's alone.multi: true):controlledByParentPredicateWriteMastersreturns the selected null-master rows beside the masters (CbpPredicateWriteSelection) instead of throwing; each is judged by the owner rule, and a body naming a master is asked even when every selected row names none.ownerMayEditleg steps aside for a body that empties an optional master (card item 4).controlled_by_parentwith an optional master of its own, left empty, ends the chain and asks the owner rule of that row (card item 5).ISecurityService.checkControlledByParentWriteanswersallowordeny/master_chainfor such a row.#9137branch is untouched: the new block runs ahead of it and only forrel.optional, which none of the three frozen shapes can be (a master with norequiredderives no relation at all;readonly/systemis refused bymasterNotWritablefirst). A required master is answered byte for byte as before. Ownership transfer stays onallowTransfer.security/explainnames the owner rule when the served check refuses a null-master record (it would otherwise narrate the refusal as an unwalkable chain).@objectstack/verify— the ADR-0054 proof.deriveParentWriteReachCasesmarks an optional-master detail (optionalMaster: true, via the spec'scontrolledByParentMasterOf).runParentWriteReachProofsproves it in both cases: its records under a master as every detail, and a newmasters: 'none'reach per persona where the expectation is the owner rule — edit/delete allowed iff the persona holds the verb AND (owns the record OR holds Modify All on the object); create naming no master allowed iff it holds create. A null-master record the persona cannot read is listed inunreadableDetails, not probed.Tests
packages/plugins/plugin-security/src/controlled-by-parent-optional-master.test.ts: card 1's "write gate is unchanged" block now pins the admitted insert; a new top-level block on the real engine (SQL driver, real sharing service,member_defaultfloor) pins create, by-id update/delete (owner, View-All reader, Modify All, queue row, no owner column, non-reader), setting and emptying a master (with and without the opt-in), the chain hop, predicate update/delete, both on-behalf-of passes, the served member, and a required-master control. Every refusal assertscode+status+detailsand the stored row. Two explain pins for the narration.packages/verify/src/parent-write-reach.test.ts:pwr_contact(optional master) joins the fixture; a new case proves the null-master reach per persona (View All on the detail is refused another's record, Modify All writes it, the owner writes its own); the count pins move to the measured totals.Every negative pin was ablated: forbidden behaviour put back through
scripts/ablation-replace.mjs(anchor must hit, restore proven against HEAD), suite red, restored.ownerMayEditleg covers an emptying bodydist/pwr_contactCONTRADICTED on 2 of 64 writesA4's first attempt was a no-op (the tool refused it: the replacement text already occurred, so the mutation did not count as landed); it was re-run in
--deletemode and went red. The verify ablation was built intodist/and checked byablation-dist-preflight.mjson both legs (marker present after mutate, absent after restore).Acceptance notes
controlled_by_parentdetail (masterGateCoversThisWrite = !delegatorSets,platformFloorYieldsToObjectWriteModel): A1 shows a View-All reader's update of a row created by another principal LANDS once the owner rule is removed, so the rule has to live inside the gate. (2)@objectstack/verifysynthesis does skip non-required relations (seedRecord), but every probe pinned the master explicitly, so the family produced no null-master record before this change; the new reach seeds the empty reference explicitly.master_chain.ControlledByParentWriteDenialLegis a closed spec vocabulary andpackages/spec/**is outside this card;master_chainis the leg its text already gives "a master that is itself controlled_by_parent ... has an empty master reference", and here the chain ends at the row itself. A dedicated leg would be a spec contract change.404 RECORD_NOT_FOUND) before the gate, as for every hidden row. Pinned.owner_idcolumn is admitted (card item 2), and its creator cannot read it back: such rows are View All's to read and Modify All's to write, as card 1 reads them.docs/adr/**, Tier H); the spec contract docs ofmaster_chainandmaster_reference_missingdo not mention the optional master. Card 3 (controlled_by_parent admits an optional master (3/3): docs and the authoring skills teach it instead of a copied owner field #30907) teaches the docs and skills.Verification
Full package suites, on head e6bb523
pnpm --filter @objectstack/plugin-security exec vitest run --maxWorkers=2: Test Files 248 passed (248), Tests 5796 passed, 45 skipped (5841). VERDICT command-exit 0.pnpm --filter @objectstack/verify exec vitest run --maxWorkers=2: Test Files 48 passed (48), Tests 409 passed (409). VERDICT command-exit 0.pnpm --filter @objectstack/plugin-security typecheckandpnpm --filter @objectstack/verify typecheck(each with its test layer): exit 0.pnpm exec eslint --no-inline-configover the six changed source files: exit 0.Derived gate families, on head e6bb523
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 63 commands from the 7 changed paths (1085 changed lines, under the 3000 threshold). Each was run with its exit code recorded before any pipe, then--ranreconciled: 63 derived, 61 run, 2 NOT MEASURED, 0 UNRUN.pnpm check:dual-build-cjs-loads(exit 3, PREREQUISITE NOT MET: needs every package'sdist/, a whole-tree build) andpnpm check:i18n(exit 3, PREREQUISITE NOT MET: needs the built CLI and its extract closure). Both run in CI'sLint & Repo Gates.node scripts/check-plugin-teardown-shape.mjs --self-testfirst exited 3 (its positive control is pinned to a commit this shallow checkout lacked); the one commit was fetched and the re-run exited 0.Generated by Claude Code