Skip to content

Commit 8b12303

Browse files
committed
test(runtime): pin the declarative update refusal order across both doors on a booted kernel
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4czxVZYV4CcMiCbofw3
1 parent e7d7cc1 commit 8b12303

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/runtime': patch
3+
---
4+
5+
fix(runtime): a declarative update action refuses a caller with no edit grant `403 PERMISSION_DENIED`, as the data door does, whether or not the record exists or is visible to them
6+
7+
Clause-②: no — no request that succeeded is refused and no shape changes: one refusal's code moves from `404 RECORD_NOT_FOUND` to the data door's `403 PERMISSION_DENIED`, for a caller who may not update the object
8+
Metadata-protocol: none
9+
10+
An `operation: 'update'` action (REST `POST /actions/:object/:action/:id`, MCP `run_action`) now judges the caller's update permission on the object before it answers on the record lookup, the order the data door already keeps ("Refusals come before the record lookup"). A caller who may read the object but holds no edit grant on it, writing a record their access hides or an id that names no record, was answered `404 RECORD_NOT_FOUND` by the action and `403 PERMISSION_DENIED` by `PATCH /data` and MCP `update_record` for the same write. Both doors now answer `403 PERMISSION_DENIED`, with the data door's sentence.
11+
12+
A caller who may update the object keeps `404 RECORD_NOT_FOUND`, one answer for a hidden record and a missing id, so neither door tells a caller whether a record it cannot see exists. A record the caller can read but not edit was already answered `403` by both doors and is unchanged.

‎packages/runtime/src/declarative-update-refusal-order.pin.test.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
* `200` on its row and `404 RECORD_NOT_FOUND` on the other two;
2828
* 2. ⭐ no existence oracle: within each door, for each caller, the hidden
2929
* row and the missing id get the same answer, body included, once the
30-
* id the caller sent is written out;
30+
* id the caller sent is written out; and the reader's refusal on the row
31+
* it can see is that same answer too;
3132
* 3. a refused write leaves the row untouched.
3233
*
3334
* The MCP leg drives the runtime's bridge (`buildMcpBridge`, served at `/mcp`)
@@ -86,7 +87,7 @@ const PIN_APP: any = {
8687
label: 'Decide',
8788
operation: 'update',
8889
patch: PATCH,
89-
ai: { exposed: true, description: 'Approve this step.' },
90+
ai: { exposed: true, description: 'Approve this approval step on behalf of its approver.' },
9091
},
9192
],
9293
},
@@ -347,4 +348,15 @@ describe('[#30848] no existence oracle: a hidden row and a missing id answer ali
347348
});
348349
}
349350
}
351+
352+
// The reader's refusal is the write's, whatever the row: the row it can see
353+
// gets the same answer, sentence included, as the two it cannot.
354+
for (const door of DOORS) {
355+
it(`reader through ${door}: the visible row's refusal is the same answer`, async () => {
356+
const visibleId = idOf('reader', 'visible');
357+
const visible = withoutId(await knock(door, 'reader', visibleId), visibleId);
358+
const missing = withoutId(await knock(door, 'reader', MISSING), MISSING);
359+
expect(visible).toEqual(missing);
360+
});
361+
}
350362
});

0 commit comments

Comments
 (0)