Skip to content

Commit 4148722

Browse files
committed
fix(automation): the preview's refusals are named in full, and its caller limit reads both ways
Claude-Session: https://claude.ai/code/session_01QsR2jVTYADzVWfarACx5j3 Co-authored-by: Claude <noreply@anthropic.com>
1 parent d2279e6 commit 4148722

5 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎.changeset/35928-record-update-starts-read.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ Skills-docs: none — no skill under `skills/**` teaches the console's stage con
1515
The console's stage confirms now name the flows a move would start (objectstack#35928, ruling record 7073655354). They ask the server:
1616

1717
- **Request** `{ object, recordId, changes }`; **response** `{ success, data: { flows: [{ name, label, startsApproval }] } }`.
18-
- **Who is answered:** a signed-in caller who can read the record. The record is read as the caller through the `/data` door's own `get`, so a record they cannot read answers `404 RECORD_NOT_FOUND` exactly as an absent one, and the engine is never asked. Anonymous `401`; a malformed body `400 VALIDATION_FAILED`; any query parameter `400 VALIDATION_ERROR`; an engine without the read `501`.
18+
- **Who is answered:** a signed-in caller who can read the record. The record is read as the caller through the `/data` door's own `get`, so a record they cannot read answers `404 RECORD_NOT_FOUND` exactly as an absent one, and the engine is never asked. Anonymous `401`; a malformed body `400 VALIDATION_FAILED`; a `changes` key that is not a declared field of the object `400 VALIDATION_FAILED` on that key, the engine never asked; a read that answers no record `404 RECORD_NOT_FOUND`; any query parameter `400 VALIDATION_ERROR`; an engine without the read `501`.
1919
- **Which flows:** enabled `record_change` flows of the object, armed on their trigger, whose `triggerType` binds an update, and whose start condition holds for the record read with `changes` applied (`previous` is the record read). The condition goes through the engine's one start-condition gate, the one every run passes; the token grammar `@objectstack/trigger-record-change` binds hooks by moved into the spec (`recordChangeTriggerHookEvents`) so the preview reads the same rule, with no second copy. A condition that cannot be evaluated against the record is not listed. Hooks are never listed.
2020
- **Per flow:** `name`, the authored `label` (a client translates it by name) and `startsApproval`, true for a flow holding an `approval` node (ADR-0019). No description, condition or nodes.

‎content/docs/automation/flows.mdx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2626,7 +2626,9 @@ happens, and a condition that reads a field the caller cannot see is judged
26262626
here on what the caller sees. Of the caller, the preview binds the user id and
26272627
the tenant only. A live save also binds the writer's positions, the request's
26282628
params and its expand, so a condition that reads those is judged here without
2629-
them and the preview can list fewer flows than the save starts.
2629+
them, and the preview can differ from the save in either direction: it can miss
2630+
a flow the save starts, or list one the save does not (a negated test of the
2631+
writer reads true here).
26302632

26312633
## Expressions in flows
26322634

‎packages/runtime/src/domains/automation-record-update-starts.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ describe('POST /automation/_record-starts (#35928)', () => {
104104
const result = await dispatcher.handleAutomation('/_record-starts', 'POST', BODY, ANONYMOUS());
105105

106106
expect(result.response?.status).toBe(401);
107+
expect(result.response?.body?.error?.code).toBe('UNAUTHENTICATED');
107108
expect(getData).not.toHaveBeenCalled();
108109
expect(listRecordUpdateStarts).not.toHaveBeenCalled();
109110
});
@@ -138,6 +139,7 @@ describe('POST /automation/_record-starts (#35928)', () => {
138139
const result = await dispatcher.handleAutomation('/_record-starts', 'POST', BODY, MEMBER());
139140

140141
expect(result.response?.status).toBe(501);
142+
expect(result.response?.body?.error?.code).toBe('NOT_IMPLEMENTED');
141143
});
142144

143145
it('is not read as a flow name: a GET of the literal is not this door', async () => {

‎packages/spec/src/api/automation-api.zod.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,8 +907,8 @@ export type GetRunResponseParsed = z.infer<typeof GetRunResponseSchema>;
907907
*
908908
* What the preview binds of the caller: their user id and tenant only. A live
909909
* run also binds the writer's positions, request params and expand, so a
910-
* start condition that reads those is judged without them here and the
911-
* preview can under-list (it never runs a flow).
910+
* start condition that reads those is judged without them here, and the
911+
* preview can differ from the save in either direction (it never runs a flow).
912912
*
913913
* @example POST /api/v1/automation/_record-starts
914914
* { object: 'showcase_project', recordId: 'p_1', changes: { status: 'completed' } }

‎packages/spec/src/contracts/automation-service.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,8 +956,8 @@ export interface ResumeSignal {
956956
*
957957
* Of the writer it carries the user id and tenant only. A live save also
958958
* binds the writer's positions, request params and expand into the run, so a
959-
* start condition reading those is judged here without them and the preview
960-
* can under-list.
959+
* start condition reading those is judged here without them, and the preview
960+
* can differ from the save in either direction.
961961
*/
962962
export interface RecordUpdateStartsInput {
963963
/** Machine name of the record's object. */

0 commit comments

Comments
 (0)