Skip to content

Commit 30c3ee0

Browse files
committed
wip: flip the objectName liveness row, docs and changeset
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CbNMpDS92ifzhDw9vf
1 parent 36585e7 commit 30c3ee0

5 files changed

Lines changed: 73 additions & 47 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@objectstack/runtime': patch
3+
'@objectstack/spec': patch
4+
---
5+
6+
fix(runtime): a flow start input declared a record id (`objectName`) is loaded in the caller's own scope from the declared object at every door that starts the flow by name, before the run exists
7+
8+
Clause-②: yes (narrowing) — a start that ran before is now refused when it hands a declared record-id input an id the caller cannot read in the declared object, an id that names no record there, or a value that is not one id. No flow shipped in this repository declares the key, and an input without the declaration answers exactly as before.
9+
Metadata-protocol: none
10+
11+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped: `objectName` on a flow variable already parses, and what moves is the answer a start door gives to a caller who hands such an input a value it cannot read. Nothing at rest records that answer, so there is nothing for a migration to rewrite. -->
12+
13+
**The rule.** A flow start input may declare that its value is the id of a record of a named object, with `objectName` on the variable (`{ name: 'accountId', type: 'text', isInput: true, objectName: 'crm_account' }`). Every door that starts the flow by name now loads such an input from the declared object in the caller's own scope before the run exists, whether or not the flow's definition reads the input in plain sight. A record the caller cannot read there and an id that names no record get the same answer, `404 RECORD_NOT_FOUND` (the action door's own refusal), and no run is created. A value that is not one id (a string or a number) is refused `400` naming the input: `VALIDATION_FAILED` from the start check, or, at an action whose param declares a type, `VALIDATION_ERROR` from that param's own contract, which answers first. The system principal is not judged.
14+
15+
**Which doors.** `POST /api/v1/automation/:name/trigger` and the legacy `POST /api/v1/automation/trigger/:name`; a declared endpoint of `type: 'flow'`; an action of `type: 'flow'` over the REST action route and the MCP `run_action` tool. All of them ask the one check they already shared for inputs a definition reads in plain sight.
16+
17+
**Beside the definition's own reads, never in place of them.** An input declared a record id of one object and also read by the definition as an id of another (a `get_record` node's `filter.id`, say) is loaded from both, so the caller must be able to read both rows. A parent flow that hands its input on, unchanged, to a `subflow` or `map` callee whose input carries the declaration is judged by that declaration too. A `loop` or `map` that later rebinds the name does not withdraw the declaration: it is the author's word about the value the caller sent.
18+
19+
**What stays as it was.** An input without the declaration keeps the visible-read rule: it is judged only where the definition reads it as a record id. A start whose caller can read the declared record starts as before.
20+
21+
**If a start now answers 404 or 400.** Hand the declared input the id of a record the caller can read in the object the input names, or start the flow as the system principal.
22+
23+
`@objectstack/spec`: the `objectName` describe on a flow variable no longer says that no door applies it, and its liveness row is `live`, so `os validate` no longer warns `liveness-planned-property` on a flow that declares it.

‎content/docs/automation/flows.mdx‎

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,23 +2184,25 @@ export const CloseAccount = defineFlow({
21842184
});
21852185
```
21862186

2187-
<Callout type="warn">
2188-
**Planned — no door applies this yet.** The declaration parses, is refused on a
2189-
variable that is not an input, and is linted, but no start door loads a
2190-
declared input today: a start that hands it an id the caller cannot read still
2191-
runs. `os validate` warns on every flow that writes it
2192-
(`liveness-planned-property`). The contract below is what the start doors will
2193-
enforce.
2194-
</Callout>
2195-
2196-
The contract: every door that starts the flow by name (the trigger route, an
2197-
action of `type: 'flow'` over REST and MCP `run_action`, a declared endpoint of
2187+
Every door that starts the flow by name (the trigger route, an action of
2188+
`type: 'flow'` over REST and MCP `run_action`, a declared endpoint of
21982189
`type: 'flow'`) loads a declared input from the named object in the caller's
2199-
own scope before the run exists. An id the caller cannot read there is refused
2200-
`404` `RECORD_NOT_FOUND`; a value that is not an id is refused `400`
2201-
`VALIDATION_FAILED` naming the input. An input without the declaration is
2202-
judged as a record only where the flow's own definition reads it as a record id
2203-
(see the `404` row under [running a flow via the API](#run-a-flow-via-api)).
2190+
own scope before the run exists. An id the caller cannot read there, or one
2191+
that names no record, is refused `404` `RECORD_NOT_FOUND`, and no run is
2192+
created; a value that is not an id is refused `400` naming the input
2193+
(`VALIDATION_FAILED`; at an action, a param's own declared type answers first
2194+
with `VALIDATION_ERROR`). An input without the declaration is judged as a
2195+
record only where the flow's own definition reads it as a record id (see the
2196+
`404` row under [running a flow via the API](#run-a-flow-via-api)). The system
2197+
principal is not judged.
2198+
2199+
- **Beside the definition's own reads, never in place of them.** When the flow
2200+
also reads the input as an id of another object (a `get_record` node's
2201+
`filter.id`, say), the door loads it from both, and the caller must be able
2202+
to read both rows.
2203+
- **Followed into sub-flows.** A parent that hands its input on, unchanged, to
2204+
a `subflow` or `map` callee whose input carries the declaration is judged by
2205+
that declaration too.
22042206

22052207
- **Inputs only.** A variable that is not `isInput: true` receives nothing from
22062208
a caller, so `objectName` there is refused at parse.
@@ -2606,7 +2608,7 @@ door's own admission check, made before anything is dispatched:
26062608
| `404` | — | No flow by that name in this deployment | Check the name; nothing was dispatched |
26072609
| `403` | `PERMISSION_DENIED` | The caller is not the system principal, and the flow is declared `runAs: 'system'` with a self-triggered `type` (`autolaunched`, `record_change`, `schedule`). The same answer at every door that starts a flow by name: this route, a `type: 'flow'` action (REST and MCP `run_action`) and a declared `type: 'flow'` endpoint | Let it run on its own trigger, or call it from a parent flow's `subflow` node. If members are meant to start it, declare it `type: 'screen'` (or `'api'` for a signed inbound hook) |
26082610
| `403` | `PERMISSION_DENIED` | The flow declares `requiredPermissions` and the caller, not the system principal, does not hold every capability it names. Checked after the row above, at the same doors; the message names the declared and the missing capabilities | Grant the capability through a permission set's `systemPermissions`, or start the flow as someone who holds it |
2609-
| `404` | `RECORD_NOT_FOUND` | The start names a record (`recordId`, or the object's id alias such as `crmLeadId`) that the caller, not the system principal, cannot read in its own scope, or that does not exist: the two get one answer, the one the action door gives. Checked after the two rows above, at the same doors. A record key that is not one id, or a record named with no `objectName` for a flow declared `runAs: 'system'`, is refused `400` `VALIDATION_FAILED` naming the key. Where the flow's own definition reads a start input as the id of a record of a fixed object (a `get_record`, `update_record` or `delete_record` node with a literal `objectName` whose `filter.id` or `filter.id.$eq` is the input, or whose `filter.id.$in` is; a `screen` node with a literal `objectName` whose `recordId` is the input; a `subflow` or `map` node that hands the input to a callee input the callee reads so), that input is also loaded in the caller's own scope from THAT object, whatever object the start names, or none, and whatever the flow runs as: a value the caller cannot read there gets this `404`, and a value that is not one id (or a list of ids, where the definition reads a list) is refused `400` `VALIDATION_FAILED` naming the input | Start the flow on a record the caller can read, and name the record's object (`objectName`) beside `recordId`. Hand an input the flow reads as a record id the id of a record the caller can read in the object the flow reads it from, in the shape the flow reads (one id, or a list of ids) |
2611+
| `404` | `RECORD_NOT_FOUND` | The start names a record (`recordId`, or the object's id alias such as `crmLeadId`) that the caller, not the system principal, cannot read in its own scope, or that does not exist: the two get one answer, the one the action door gives. Checked after the two rows above, at the same doors. A record key that is not one id, or a record named with no `objectName` for a flow declared `runAs: 'system'`, is refused `400` `VALIDATION_FAILED` naming the key. Where the flow's own definition reads a start input as the id of a record of a fixed object (a `get_record`, `update_record` or `delete_record` node with a literal `objectName` whose `filter.id` or `filter.id.$eq` is the input, or whose `filter.id.$in` is; a `screen` node with a literal `objectName` whose `recordId` is the input; a `subflow` or `map` node that hands the input to a callee input the callee reads so), that input is also loaded in the caller's own scope from THAT object, whatever object the start names, or none, and whatever the flow runs as: a value the caller cannot read there gets this `404`, and a value that is not one id (or a list of ids, where the definition reads a list) is refused `400` `VALIDATION_FAILED` naming the input. An input the flow declares a record id (`objectName` on the variable, [above](#a-start-input-that-is-a-record-id)) is loaded from the declared object the same way, whether or not the definition reads it | Start the flow on a record the caller can read, and name the record's object (`objectName`) beside `recordId`. Hand an input the flow reads as a record id the id of a record the caller can read in the object the flow reads it from, in the shape the flow reads (one id, or a list of ids) |
26102612
| `409` | `FLOW_DISABLED` | The flow exists but is switched off | Enable it — the identical request then succeeds |
26112613
| `422` | `FLOW_NO_START_NODE` | The stored definition has no `start` node | Fix the flow; retrying cannot help |
26122614
| `422` | `FLOW_INPUT_SCHEMA_INVALID` | A node's `config` violates the `inputSchema` its own definition declares | Fix the flow; the refusal is non-retryable — even under `errorHandling.strategy: 'retry'` the engine refuses once and never enters the retry loop |

‎packages/runtime/src/flow-start-declared-record-reads.test.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,15 @@ describe('a start input declared a record id is loaded from the declared object
676676
}
677677
},
678678
};
679+
/**
680+
* The code a value that is not an id is refused with, per door. The trigger
681+
* routes and the endpoint hand every param to the start check, which answers
682+
* `VALIDATION_FAILED`. The action doors type each declared param first
683+
* (ADR-0104 D2), so a `text` param holding an object, a list or a boolean
684+
* is refused there, `400 VALIDATION_ERROR` naming the same param, before
685+
* the start check is reached: one more gate in front, never a gap.
686+
*/
687+
const NOT_AN_ID_CODE = (door: string): string => (door.includes('action') ? 'VALIDATION_ERROR' : 'VALIDATION_FAILED');
679688
/** Every `crm_contract` row the start loaded. */
680689
const contractReads = (ql: any) => ql.find.mock.calls.filter((c: any[]) => c[0] === CONTRACT).map((c: any[]) => c[1]?.where?.id);
681690

@@ -728,12 +737,12 @@ describe('a start input declared a record id is loaded from the declared object
728737
['an object', { id: BOTH }],
729738
['a list', [BOTH]],
730739
['a boolean', true],
731-
])('a declared input given %s: 400 VALIDATION_FAILED naming the input, nothing loaded from the declared object, no run', async (_label, value) => {
740+
])('a declared input given %s: 400 naming the input, nothing loaded from the declared object, no run', async (_label, value) => {
732741
const got = await start(DECLARED, value);
733742

734743
expect(got.status).toBe(400);
735-
expect(got.error.code).toBe('VALIDATION_FAILED');
736-
expect(String(got.error.message)).toContain('`contractId`');
744+
expect(got.error.code).toBe(NOT_AN_ID_CODE(door));
745+
expect(String(got.error.message)).toContain('contractId');
737746
expect(contractReads(got.ql)).toHaveLength(0);
738747
expect(got.automation.execute).not.toHaveBeenCalled();
739748
});

‎packages/spec/liveness/flow.json‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,10 @@
9191
"evidence": "packages/services/service-automation/src/dag-traversal.ts#seedDeclaredVariables (bound when no param supplies the name, #4697)"
9292
},
9393
"objectName": {
94-
"status": "planned",
95-
"verifiedAt": "2026-11-02",
96-
"evidence": "packages/spec/src/automation/flow.zod.ts#FlowVariableSchema (the superRefine that refuses `objectName` on a variable that is not an input — the one place the key is read today)",
97-
"authorWarn": true,
98-
"authorHint": "Keep it, but nothing reads it yet: no start door loads a declared input from its object until the start doors ship that check, so an id the caller cannot read still starts a run.",
99-
"note": "PLANNED RECORD (#29442, the spec half of #29425 ruling A 6580257050): an input's declaration that its value is the id of one record of the named object. Parsed, refused on a non-input (the evidence above) and linted (`flow-input-unknown-object` in packages/lint/src/validate-flow-trigger-readiness.ts). No door reads it: the start doors' third question (packages/runtime/src/flow-start-admission.ts, `flowDeclaredRecordReads` / `refuseUnreadableFlowStartRecords` in action-execution.ts) judges only inputs the definition reads in plain sight. Carrier: the #29425 server half, Blocked-by #29442 (every start door loads a declared input in the caller's scope, 404 RECORD_NOT_FOUND / 400 VALIDATION_FAILED). Flip to `live` on the commit that cites that reader, drop `authorWarn` / `authorHint` and the describe's planned sentence in that same edit."
94+
"status": "live",
95+
"verifiedAt": "2026-11-05",
96+
"evidence": "packages/runtime/src/flow-start-admission.ts#flowDeclaredRecordReads (a declared input is one read of the declared object, asked by `refuseUnreadableFlowStartRecords` in action-execution.ts at every door that starts a flow by name: loaded in the caller's scope before the run exists, 404 RECORD_NOT_FOUND / 400 naming the input)",
97+
"note": "#29425 ruling A: an input's declaration that its value is the id of one record of the named object. Added beside every read the definition makes in plain sight, never in place of one, and followed into a callee through subflow / map hand-offs. Also refused on a non-input (packages/spec/src/automation/flow.zod.ts#FlowVariableSchema) and linted (`flow-input-unknown-object` in packages/lint/src/validate-flow-trigger-readiness.ts)."
10098
}
10199
}
102100
},

‎packages/spec/src/automation/flow.zod.ts‎

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -233,23 +233,17 @@ export const FLOW_PAUSE_CAPABLE_NODE_TYPES: readonly string[] = [
233233
*
234234
* ## `objectName` — a start input that is a record id (#29425 ruling A)
235235
*
236-
* [planned] An input may declare that its value is the id of a record of a
237-
* named object. The contract the declaration states: every door that starts
238-
* the flow by name judges the input as a record, whether or not the definition
239-
* reads it as one in plain sight — the door loads it from the named object in
240-
* the caller's own scope before the run exists, refusing an unreadable id
241-
* `404 RECORD_NOT_FOUND` and a value that is not an id
242-
* `400 VALIDATION_FAILED` naming the input. An input without the declaration
243-
* keeps the visible-read rule (`flowDeclaredRecordReads` in
244-
* `packages/runtime/src/flow-start-admission.ts`).
245-
*
246-
* ⛔ No door applies it yet. This is the spec half; the start doors read the
247-
* declaration in the ruling's server half (Blocked-by #29442). Until then the
248-
* key is parsed, refused on a non-input (below) and linted
249-
* (`flow-input-unknown-object`), and its liveness row is `planned` with an
250-
* author warning (`packages/spec/liveness/flow.json` › `variables.objectName`),
251-
* so an author who writes it is told. Flip the row, drop the warning and the
252-
* describe's planned sentence in the commit that lands the reader.
236+
* An input may declare that its value is the id of a record of a named
237+
* object. Every door that starts the flow by name judges the input as a
238+
* record, whether or not the definition reads it as one in plain sight: the
239+
* door loads it from the named object in the caller's own scope before the
240+
* run exists, refusing an unreadable id `404 RECORD_NOT_FOUND` and a value
241+
* that is not an id `400` naming the input. The declaration adds that load
242+
* beside any read the definition makes in plain sight, never in place of one.
243+
* An input without the declaration keeps the visible-read rule. The reader is
244+
* `flowDeclaredRecordReads` in `packages/runtime/src/flow-start-admission.ts`;
245+
* the key is also refused on a non-input (below) and linted
246+
* (`flow-input-unknown-object`).
253247
*
254248
* The spelling is `objectName`, the word the CRUD nodes already use for the
255249
* object they read, and ⛔ not a `type: 'record'` beside it: `type` already
@@ -299,14 +293,14 @@ export const FlowVariableSchema = lazySchema(() => strictObject(
299293
.meta({ title: 'Default Value' }),
300294
objectName: z.string().regex(/^[a-z_][a-z0-9_]*$/).optional()
301295
.describe(
302-
'[planned] Declares this input a record reference: its value is the id of one record of the named object ' +
296+
'Declares this input a record reference: its value is the id of one record of the named object ' +
303297
'(the object\'s snake_case name, e.g. `crm_account`). Only on an input (`isInput: true`). The contract: ' +
304298
'every door that starts the flow by name (the trigger route, an action of type flow over REST and MCP ' +
305299
'run_action, a declared endpoint of type flow) loads a declared input from this object in the caller\'s ' +
306300
'own scope before the run exists; an id the caller cannot read there is refused 404 RECORD_NOT_FOUND, and ' +
307-
'a value that is not an id is refused 400 VALIDATION_FAILED naming the input. No door applies it yet: ' +
308-
'today the key is parsed and checked, and a start with an id the caller cannot read still runs. An input ' +
309-
'without this declaration is judged as a record only where the flow\'s own definition reads it as a ' +
301+
'a value that is not an id is refused 400 naming the input. The load is added beside any read the ' +
302+
'flow\'s own definition makes of the input, never in place of one. An input without this declaration ' +
303+
'is judged as a record only where the flow\'s own definition reads it as a ' +
310304
'record id. `type` stays the data type: the variable holds the id the caller sent.',
311305
)
312306
.meta({ title: 'Record Object' }),

0 commit comments

Comments
 (0)