Skip to content

Commit eda7ee2

Browse files
committed
docs(qa): retire the write-without-reading-the-parent persona
The records-forms predicate-relationship-traversal item takes revision 7: a member who cannot read the lookup parent may not name it, and is answered reference_not_found for a tripping and a non-tripping parent alike. The dogfood case is rewritten to that rule, and the changeset states the refused writes and the delegate's business-unit read. Claude-Session: https://claude.ai/code/session_01Utp6CYQjMkN514R78sCrTT Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6602814 commit eda7ee2

3 files changed

Lines changed: 46 additions & 32 deletions

File tree

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
---
22
'@objectstack/objectql': patch
3+
'@objectstack/plugin-security': patch
34
---
45

56
fix(objectql)!: a non-system write may name, in a `lookup` or `user` field, only a record the caller can read (#29029)
67

7-
Clause-②: yes (narrowing) — a non-system write whose `lookup` or `user` value names a record the caller's own read door does not return is refused with `reference_not_found`, which it admitted before. Nothing is widened.
8+
Clause-②: yes (narrowing) — the write's reference check narrows: a non-system `lookup` or `user` value naming a record the caller cannot read is refused. The business-unit read widens: a delegated admin reads the business units inside the admin scope it holds, and no other.
89
Metadata-protocol: none
910

10-
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export or type changes: the reference check the write already runs for a master_detail header now runs for lookup and user values too. The refusal is the engine's own localized reference_not_found, so there is nothing for a migration to rewrite and no tombstone. -->
11+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export or type changes. The refusal is the engine's own localized reference_not_found, so there is nothing for a migration to rewrite and no tombstone. -->
1112

12-
**BREAKING** accept-set narrowing at the write's reference check (`@objectstack/objectql`), served by every write door (REST, MCP, flows run as the user, `ctx.api` in hooks).
13+
**BREAKING** accept-set narrowing at the write's reference check (`@objectstack/objectql`), served by every write door.
1314

14-
After the upgrade, an insert or update that carries no `isSystem` is refused when a `lookup` or `user` value it supplies names a record the caller cannot read: the answer is `400 VALIDATION_FAILED` with the field's `reference_not_found`, localized, exactly the answer for a record that exists nowhere. This is the rule `master_detail` already follows.
15+
After the upgrade, an insert or update that is not a system write is refused with `400 VALIDATION_FAILED` and the field's localized `reference_not_found` when a `lookup` or `user` value it supplies names a record the caller cannot read, before the record's validation rules run.
1516

16-
- **Each value is judged.** A multi-valued `lookup` or `user` field is refused when any one of its values names a record the caller cannot read.
17-
- **Unchanged.** System writes (`isSystem`: seed replay, boot, package install) stay exempt, as before; a flow run's elevated write keeps its existence check. An update that carries back a value the row already stores is not judged again. An empty value is not a reference. A `readonly` field is not the caller's to answer for. A `tree` parent keeps the existence check alone.
18-
- **Who sees it.** An app whose users write a reference to a record their own access does not return. A user can still reference every record they can read.
19-
20-
**The remedy.** None for an app that meant its read access as the boundary. An app that wrote its own `beforeInsert` / `beforeUpdate` hook to refuse a reference to an unreadable record can delete it: the engine now refuses it, localized. A flow that must link records the acting user cannot read runs with `runAs: 'system'`.
17+
A delegated admin whose admin scope covers a business-unit subtree can read the business units in that subtree, and no business unit outside it (`@objectstack/plugin-security`).

‎docs/qa/platform-checklist/areas/records-forms.json‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5546,12 +5546,12 @@
55465546
"title": "A validation rule reads a parent field one hop through a lookup",
55475547
"since": "v17",
55485548
"status": "active",
5549-
"revision": 6,
5549+
"revision": 7,
55505550
"priority": "P1",
55515551
"surface": "api",
55525552
"personas": [
55535553
"seeded admin (admin@objectos.ai / admin123)",
5554-
"a member with create/edit on a child object and NO read on its lookup parent — the persona the rule exists to constrain. ⚠ No stock showcase persona is one (fixtures.knownGaps): acceptance[3] is scored from the engine pin or on a scratch pair"
5554+
"a member with create/edit on a child object and NO read on its lookup parent — who may not name that parent at all: a non-system write may name, in a lookup, only a record the caller's own read door returns. ⚠ No stock showcase persona is one (fixtures.knownGaps): acceptance[3] is scored on a scratch pair"
55555555
],
55565556
"fixtures": {
55575557
"app": "showcase",
@@ -5561,14 +5561,14 @@
55615561
"at least one churned account and one non-churned account to invoice against"
55625562
],
55635563
"knownGaps": [
5564-
"No stock persona has showcase_invoice CRUD WITHOUT showcase_account read, and none can be made from the stock showcase objects: showcase_member_default, the everyone baseline every member holds, grants showcase_account allowRead (examples/app-showcase/src/security/permission-sets.ts), and permission sets only ever ADD grants, so no extra set takes it away (QA run #21720, parked on #22017 row 14). An earlier revision of this item said the opposite, reading packages/qa/dogfood/test/showcase-d3-d4-capabilities.dogfood.test.ts. That test's persona is its own injected fallback set, not a stock persona, and it never writes against a churned account. So acceptance[3] is scored from the ENGINE pin in `automated`, which proves the mechanism the clause rests on: the related row is read under SYSTEM authority with the acting identity carried, and the write path accepts and refuses by the parent field. Or it is scored live on the scratch substitute #21720 measured, which is runtime-only on a stock boot (QA run #27438 built and drove it at c4c515ad): POST /api/v1/packages with a declared namespace; PUT /api/v1/meta/object for a parent object, and for a child object carrying a one-hop script validation over its lookup to the parent; PUT /api/v1/meta/permission for a set granting the member the CHILD only, bound with POST /api/v1/data/sys_user_permission_set; then, as that member, write against a tripping and a non-tripping parent. The control is the member's GET of a parent row, which must answer 403: without it the leg proves nothing about an unreadable parent"
5564+
"No stock persona has showcase_invoice CRUD WITHOUT showcase_account read, and none can be made from the stock showcase objects: showcase_member_default, the everyone baseline every member holds, grants showcase_account allowRead (examples/app-showcase/src/security/permission-sets.ts), and permission sets only ever ADD grants, so no extra set takes it away (QA run #21720, parked on #22017 row 14). An earlier revision of this item said the opposite, reading packages/qa/dogfood/test/showcase-d3-d4-capabilities.dogfood.test.ts. That test's persona is its own injected fallback set, not a stock persona, and it never writes against a churned account. So acceptance[3] is scored on a scratch pair: the dogfood pin in `automated` builds one at boot, or it is scored live on the scratch substitute #21720 measured, which is runtime-only on a stock boot (QA run #27438 built and drove it at c4c515ad): POST /api/v1/packages with a declared namespace; PUT /api/v1/meta/object for a parent object, and for a child object carrying a one-hop script validation over its lookup to the parent; PUT /api/v1/meta/permission for a set granting the member the CHILD only, bound with POST /api/v1/data/sys_user_permission_set; then, as that member, write against a tripping and a non-tripping parent. The control is the member's GET of a parent row, which must answer 403: without it the leg proves nothing about an unreadable parent"
55655565
]
55665566
},
55675567
"steps": [
55685568
"POST /api/v1/data/showcase_invoice with `account` pointing at a NON-churned account",
55695569
"POST /api/v1/data/showcase_invoice with `account` pointing at a CHURNED account",
55705570
"PATCH an existing invoice to REPOINT it at a churned account (the update path reads the FK off the merged record, not the patch alone)",
5571-
"as a persona with NO read on the parent (none exists on stock — fixtures.knownGaps): run the engine pin, or on the scratch substitute write against a non-tripping parent, then a tripping one"
5571+
"as a member with NO read on the parent (none exists on stock — fixtures.knownGaps), on the scratch pair: write against a non-tripping parent, then a tripping one"
55725572
],
55735573
"acceptance": [
55745574
{
@@ -5590,23 +5590,23 @@
55905590
"evidence": "the patch response"
55915591
},
55925592
{
5593-
"clause": "a rule whose parent the acting user cannot read still ENFORCES, and still lets a legitimate write through — the read is system-authority, bounded by the fields the predicate names",
5593+
"clause": "a member who cannot read the parent cannot name it: the write answers reference_not_found on the lookup, before the record's rules, whether or not the parent trips one",
55945594
"oracle": "api",
5595-
"verify": "on stock showcase no such persona exists (fixtures.knownGaps), so score this from the engine pin in `automated` or live on the scratch substitute. The engine-pin verdict is a layer exception this item declares (fixtures.knownGaps), not a RUNNER rule 6 pass of this api clause: the run record says the verdict rests on the engine layer. With such a persona, the non-churned write is 2xx and the churned write is 400 carrying the AUTHORED message; an unevaluable-rule envelope for this persona is the defect this clause exists to catch, and so is a 2xx on the churned account",
5595+
"verify": "on stock showcase no such persona exists (fixtures.knownGaps), so score this on the scratch pair. For the member who cannot read the parent, the write naming the non-tripping parent and the write naming the tripping parent are each 400 VALIDATION_FAILED with exactly one fields[] entry, { field: <the lookup>, code: 'reference_not_found' } — the answer for a parent that exists nowhere — and nothing is stored. Neither answer carries the rule's authored message or the unevaluable-rule fault, and the member's own GET of the parent answers 403 (the control)",
55965596
"evidence": "both responses for the restricted persona"
55975597
}
55985598
],
55995599
"negative": [
56005600
"a 2xx on the churned-account create is a FAIL — the rule did not run",
56015601
"a rejection whose text is the unevaluable-rule fault on the READABLE-parent cases is a FAIL: the related row was not preloaded and the rule is rejecting every write, which is the pre-capability behaviour",
5602-
"a 400 unevaluable-rule envelope for the persona who cannot read the parent is a FAIL: it means the related read was not system-authority, and the rule cannot be authored for the persona it exists to constrain. A 2xx on the CHURNED account is also a FAIL — the rule did not enforce"
5602+
"for the member who cannot read the parent, a 2xx is a FAIL — it named a record it cannot read — and so is a refusal carrying the rule's authored message or the unevaluable-rule fault instead of the lookup's reference_not_found: the write answered for a parent its caller cannot read"
56035603
],
56045604
"traps": [
56055605
"seed-data-thin"
56065606
],
56075607
"automated": {
56085608
"kind": "dogfood",
5609-
"ref": "packages/qa/dogfood/test/predicate-relationship-traversal.dogfood.test.ts, at the REST data door of a booted stack: on the showcase as shipped, acceptance[0] (an invoice on an active account is 2xx and reads back, no unevaluable fault), acceptance[1] and negative[0] (an invoice on a churned account is 400 VALIDATION_FAILED with one _record rule_violation entry carrying the authored message, and nothing is stored), acceptance[2] (a PATCH carrying only the repointed account is refused and the stored account is unchanged) and negative[1] (no readable-parent case answers the unevaluable fault); on a scratch pair, acceptance[3] and negative[2] for the persona no stock showcase persona is (fixtures.knownGaps): a member with create/edit on the child and no grant on the parent, whose parent read is the control (403 PERMISSION_DENIED), writes 2xx against a non-tripping parent and 400 with the authored message against a tripping one. packages/objectql/src/engine-predicate-relationship.test.ts stays engine-layer evidence of the mechanism ('reads the related row under SYSTEM authority' and its two siblings)"
5609+
"ref": "packages/qa/dogfood/test/predicate-relationship-traversal.dogfood.test.ts, at the REST data door of a booted stack: on the showcase as shipped, acceptance[0] (an invoice on an active account is 2xx and reads back, no unevaluable fault), acceptance[1] and negative[0] (an invoice on a churned account is 400 VALIDATION_FAILED with one _record rule_violation entry carrying the authored message, and nothing is stored), acceptance[2] (a PATCH carrying only the repointed account is refused and the stored account is unchanged) and negative[1] (no readable-parent case answers the unevaluable fault); on a scratch pair, acceptance[3] and negative[2] for a member no stock showcase persona is (fixtures.knownGaps): a member with create/edit on the child and no grant on the parent, whose parent read is the control (403 PERMISSION_DENIED), is answered 400 VALIDATION_FAILED with the lookup's reference_not_found against a non-tripping and a tripping parent alike, never the authored message, and nothing is stored. packages/objectql/src/engine-predicate-relationship.test.ts stays engine-layer evidence of the mechanism ('reads the related row under SYSTEM authority' and its two siblings)"
56105610
},
56115611
"source": [
56125612
"examples/app-showcase/src/data/objects/invoice.object.ts (no_invoice_for_churned_account)",
@@ -5649,6 +5649,12 @@
56495649
"date": "2026-10-31",
56505650
"change": "fixtures.knownGaps[0] no longer says the restricted persona cannot be provisioned. From QA run #27438 (W3-C2b, at c4c515ad; wave anchor #27377, wave-3 accuracy slice S1). It still holds that no STOCK persona has invoice CRUD without account read. But the scratch substitute is runtime-only on a stock boot: the run installed a package, authored a parent and a child (a one-hop script validation on the child), granted the member the child alone and bound the set, with the member's 403 on a parent read as the control. The gap now spells that sequence and the control. acceptance[3] keeps both of its routes (the engine pin, or the live substitute); no clause changed",
56515651
"ref": "#27438"
5652+
},
5653+
{
5654+
"revision": 7,
5655+
"date": "2026-11-05",
5656+
"change": "the persona that wrote a child without reading its lookup parent is retired: a non-system write may name, in a lookup or user field, only a record the caller's own read door returns, and that reference check runs before the record's validation rules (ruling records 6573561091 and 6663849489). acceptance[3], its verify, negative[2], step 4, the second persona and automated.ref now state that rule: the member who cannot read the parent is answered reference_not_found against a tripping and a non-tripping parent alike. acceptance[0]–[2] are unchanged",
5657+
"ref": "#29029"
56525658
}
56535659
]
56545660
},

‎packages/qa/dogfood/test/predicate-relationship-traversal.dogfood.test.ts‎

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414
// invoice against each (acceptance[0], acceptance[1], negative[0],
1515
// negative[1]) and repoints a stored invoice at a churned account with a
1616
// patch that carries no status (acceptance[2]).
17-
// - A scratch pair for the persona the rule exists to constrain, which no
18-
// stock showcase persona is (the item's fixtures.knownGaps): a member with
19-
// create/edit on the child object and NO grant at all on the lookup's
20-
// parent. The member writes against a non-tripping and a tripping parent
21-
// (acceptance[3], negative[2]); a read of the parent as that member is the
22-
// control that the persona really cannot read it.
17+
// - A scratch pair for a member with create/edit on the child object and NO
18+
// grant at all on the lookup's parent, which no stock showcase persona is
19+
// (the item's fixtures.knownGaps). Such a member may not name the parent at
20+
// all (#29029, revision 7): a write naming a parent the caller's own read
21+
// door does not return answers `reference_not_found` on the lookup, before
22+
// the record's rules, whether or not the parent trips one (acceptance[3],
23+
// negative[2]). A read of the parent as that member is the control that the
24+
// member really cannot read it.
2325
//
24-
// The refusal is scored on the envelope — 400 VALIDATION_FAILED, the
26+
// The rule's refusal is scored on the envelope — 400 VALIDATION_FAILED, the
2527
// `_record` / `rule_violation` entry — and on the AUTHORED message, which is
2628
// the one place the item names wording as the contract. A refusal that reads
2729
// "could not be evaluated" is the pre-capability fault, and every case below
@@ -54,6 +56,14 @@ function expectRuleRefusal(answer: Answer, message: string) {
5456
expect(JSON.stringify(answer.json)).not.toContain(UNEVALUABLE);
5557
}
5658

59+
/** The refusal acceptance[3] names: the lookup's own `reference_not_found`, and no rule entry. */
60+
function expectReferenceRefusal(answer: Answer, field: string) {
61+
expect(answer.status, JSON.stringify(answer.json)).toBe(400);
62+
expect(answer.json?.code, JSON.stringify(answer.json)).toBe('VALIDATION_FAILED');
63+
expect(ruleEntries(answer.json).map((f) => ({ field: f.field, code: f.code }))).toEqual([{ field, code: 'reference_not_found' }]);
64+
expect(JSON.stringify(answer.json)).not.toContain(UNEVALUABLE);
65+
}
66+
5767
function expectAdmitted(answer: Answer) {
5868
expect(answer.status, JSON.stringify(answer.json)).toBeLessThan(300);
5969
expect(JSON.stringify(answer.json)).not.toContain(UNEVALUABLE);
@@ -122,7 +132,7 @@ describe('records-forms.predicate-relationship-traversal — the showcase invoic
122132
});
123133
});
124134

125-
// ── The persona the rule exists to constrain ───────────────────────────────
135+
// ── A member who cannot read the parent ────────────────────────────────────
126136

127137
const PARENT = 'prt_parent';
128138
const CHILD = 'prt_child';
@@ -162,7 +172,7 @@ const prtStack = defineStack({
162172
],
163173
} as never);
164174

165-
describe('records-forms.predicate-relationship-traversal — a member who cannot read the parent', () => {
175+
describe('records-forms.predicate-relationship-traversal — a member who cannot read the parent cannot name it', () => {
166176
let stack: VerifyStack;
167177
let member = '';
168178
let openId = '';
@@ -196,14 +206,15 @@ describe('records-forms.predicate-relationship-traversal — a member who cannot
196206
expect(read.json.code).toBe('PERMISSION_DENIED');
197207
});
198208

199-
it('acceptance[3]: a legitimate write against a non-tripping parent goes through', async () => {
200-
const created = await call('POST', `/data/${CHILD}`, { name: 'prt-open', parent: openId });
201-
expectAdmitted(created);
202-
expect(await stack.rows(CHILD, { name: 'prt-open' })).toHaveLength(1);
209+
it('acceptance[3]: a write naming a non-tripping parent the member cannot read answers reference_not_found, and stores nothing', async () => {
210+
expectReferenceRefusal(await call('POST', `/data/${CHILD}`, { name: 'prt-open', parent: openId }), 'parent');
211+
expect(await stack.rows(CHILD, { name: 'prt-open' })).toHaveLength(0);
203212
});
204213

205-
it('acceptance[3], negative[2]: a write against a tripping parent is refused with the authored message, never the unevaluable fault', async () => {
206-
expectRuleRefusal(await call('POST', `/data/${CHILD}`, { name: 'prt-blocked', parent: blockedId }), BLOCKED_MESSAGE);
214+
it('acceptance[3], negative[2]: a write naming a tripping parent the member cannot read answers the same, never the rule\'s message', async () => {
215+
const answer = await call('POST', `/data/${CHILD}`, { name: 'prt-blocked', parent: blockedId });
216+
expectReferenceRefusal(answer, 'parent');
217+
expect(JSON.stringify(answer.json)).not.toContain(BLOCKED_MESSAGE);
207218
expect(await stack.rows(CHILD, { name: 'prt-blocked' })).toHaveLength(0);
208219
});
209220
});

0 commit comments

Comments
 (0)