You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 50d4ae8
Browse filesBrowse the repository at this point in the historyBrowse files
fix(lint): state-machine-no-initial-states judges only machines that run on insert
An update-only state machine (events without insert) never runs on create,
so the engine never reads its initialStates; the rule no longer refuses it.
The three showcase machines that carried a declaration-only initialStates
list to pass the rule drop it.
Claude-Session: https://claude.ai/code/session_01L6bhgUZrkMKgGrXXe8zPGq
Co-authored-by: Claude <noreply@anthropic.com>
fix(lint): `state-machine-no-initial-states` judges only state machines that run on insert
7
+
8
+
Clause-②: yes (widening)
9
+
Metadata-protocol: added
10
+
11
+
The publish-time rule `state-machine-no-initial-states` now refuses an active `state_machine` validation with no (or an empty) `initialStates` only when the machine runs on insert: its `events` include `insert`, or are left to the default `['insert', 'update']`. The engine runs a rule only on the write contexts its `events` name, so a machine declared `events: ['update']` (or `events: []`) never runs on create and never reads `initialStates`. Such a machine is accepted at publish and by `os validate` again, with no `initialStates`; adding one to satisfy the rule produced metadata the runtime ignores. A machine that runs on insert without `initialStates` is still refused, with the same fix.
12
+
13
+
`@objectstack/spec` changes only the description of a state machine validation's `initialStates`, which now says the rule judges a machine that runs on insert.
Copy file name to clipboardExpand all lines: content/docs/references/data/validation.mdx
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -192,7 +192,7 @@ const result = ConditionalValidationSchema.parse(data);
192
192
|**type**|`'state_machine'`| ✅ ||
193
193
|**field**|`string`| ✅ | State field (e.g. status) |
194
194
|**transitions**|`Record<string, string[]>`| ✅ | Map of `{ OldState: [AllowedNewStates] }`|
195
-
|**initialStates**|`string[]`| optional | States a record may be CREATED in. When set, an INSERT whose state field carries a value outside this list is rejected (server-enforced) — the FSM entry point. `transitions` only governs UPDATE, and a `select` field permits ANY declared option as an initial value, so without this a record could be born mid-flow (e.g. created already `approved`). Omitted or empty, insert is not checked; the author-time rule `state-machine-no-initial-states` refuses an active machine declared that way at publish and in `os validate`. |
195
+
|**initialStates**|`string[]`| optional | States a record may be CREATED in. When set, an INSERT whose state field carries a value outside this list is rejected (server-enforced) — the FSM entry point. `transitions` only governs UPDATE, and a `select` field permits ANY declared option as an initial value, so without this a record could be born mid-flow (e.g. created already `approved`). Omitted or empty, insert is not checked; the author-time rule `state-machine-no-initial-states` refuses an active machine declared that way at publish and in `os validate` when its `events` include `insert` (the default). An update-only machine never runs on create, so it needs no `initialStates`. |
@@ -313,7 +313,7 @@ const result = ConditionalValidationSchema.parse(data);
313
313
|**type**|`'state_machine'`| ✅ ||
314
314
|**field**|`string`| ✅ | State field (e.g. status) |
315
315
|**transitions**|`Record<string, string[]>`| ✅ | Map of `{ OldState: [AllowedNewStates] }`|
316
-
|**initialStates**|`string[]`| optional | States a record may be CREATED in. When set, an INSERT whose state field carries a value outside this list is rejected (server-enforced) — the FSM entry point. `transitions` only governs UPDATE, and a `select` field permits ANY declared option as an initial value, so without this a record could be born mid-flow (e.g. created already `approved`). Omitted or empty, insert is not checked; the author-time rule `state-machine-no-initial-states` refuses an active machine declared that way at publish and in `os validate`. |
316
+
|**initialStates**|`string[]`| optional | States a record may be CREATED in. When set, an INSERT whose state field carries a value outside this list is rejected (server-enforced) — the FSM entry point. `transitions` only governs UPDATE, and a `select` field permits ANY declared option as an initial value, so without this a record could be born mid-flow (e.g. created already `approved`). Omitted or empty, insert is not checked; the author-time rule `state-machine-no-initial-states` refuses an active machine declared that way at publish and in `os validate` when its `events` include `insert` (the default). An update-only machine never runs on create, so it needs no `initialStates`. |
@@ -532,7 +532,7 @@ const result = ConditionalValidationSchema.parse(data);
532
532
|**type**|`'state_machine'`| ✅ ||
533
533
|**field**|`string`| ✅ | State field (e.g. status) |
534
534
|**transitions**|`Record<string, string[]>`| ✅ | Map of `{ OldState: [AllowedNewStates] }`|
535
-
|**initialStates**|`string[]`| optional | States a record may be CREATED in. When set, an INSERT whose state field carries a value outside this list is rejected (server-enforced) — the FSM entry point. `transitions` only governs UPDATE, and a `select` field permits ANY declared option as an initial value, so without this a record could be born mid-flow (e.g. created already `approved`). Omitted or empty, insert is not checked; the author-time rule `state-machine-no-initial-states` refuses an active machine declared that way at publish and in `os validate`. |
535
+
|**initialStates**|`string[]`| optional | States a record may be CREATED in. When set, an INSERT whose state field carries a value outside this list is rejected (server-enforced) — the FSM entry point. `transitions` only governs UPDATE, and a `select` field permits ANY declared option as an initial value, so without this a record could be born mid-flow (e.g. created already `approved`). Omitted or empty, insert is not checked; the author-time rule `state-machine-no-initial-states` refuses an active machine declared that way at publish and in `os validate` when its `events` include `insert` (the default). An update-only machine never runs on create, so it needs no `initialStates`. |
536
536
537
537
538
538
---
@@ -599,7 +599,7 @@ This schema accepts one of the following structures:
599
599
|**type**|`'state_machine'`| ✅ ||
600
600
|**field**|`string`| ✅ | State field (e.g. status) |
601
601
|**transitions**|`Record<string, string[]>`| ✅ | Map of `{ OldState: [AllowedNewStates] }`|
602
-
|**initialStates**|`string[]`| optional | States a record may be CREATED in. When set, an INSERT whose state field carries a value outside this list is rejected (server-enforced) — the FSM entry point. `transitions` only governs UPDATE, and a `select` field permits ANY declared option as an initial value, so without this a record could be born mid-flow (e.g. created already `approved`). Omitted or empty, insert is not checked; the author-time rule `state-machine-no-initial-states` refuses an active machine declared that way at publish and in `os validate`. |
602
+
|**initialStates**|`string[]`| optional | States a record may be CREATED in. When set, an INSERT whose state field carries a value outside this list is rejected (server-enforced) — the FSM entry point. `transitions` only governs UPDATE, and a `select` field permits ANY declared option as an initial value, so without this a record could be born mid-flow (e.g. created already `approved`). Omitted or empty, insert is not checked; the author-time rule `state-machine-no-initial-states` refuses an active machine declared that way at publish and in `os validate` when its `events` include `insert` (the default). An update-only machine never runs on create, so it needs no `initialStates`. |
field: z.string().describe('State field (e.g. status)'),
196
196
transitions: z.record(z.string(),z.array(z.string())).describe('Map of { OldState: [AllowedNewStates] }'),
197
-
initialStates: z.array(z.string()).optional().describe('States a record may be CREATED in. When set, an INSERT whose state field carries a value outside this list is rejected (server-enforced) — the FSM entry point. `transitions` only governs UPDATE, and a `select` field permits ANY declared option as an initial value, so without this a record could be born mid-flow (e.g. created already `approved`). Omitted or empty, insert is not checked; the author-time rule `state-machine-no-initial-states` refuses an active machine declared that way at publish and in `os validate`.'),
197
+
initialStates: z.array(z.string()).optional().describe('States a record may be CREATED in. When set, an INSERT whose state field carries a value outside this list is rejected (server-enforced) — the FSM entry point. `transitions` only governs UPDATE, and a `select` field permits ANY declared option as an initial value, so without this a record could be born mid-flow (e.g. created already `approved`). Omitted or empty, insert is not checked; the author-time rule `state-machine-no-initial-states` refuses an active machine declared that way at publish and in `os validate` when its `events` include `insert` (the default). An update-only machine never runs on create, so it needs no `initialStates`.'),
+'a flow node whose `type` no executor in the deployment runs (`flow-node-type-no-executor`, judged at publish '
15
15
+'against the automation engine\'s sealed node-type vocabulary); an `approval` node whose decision out-edges are '
16
16
+'not labelled `approve` and `reject` (`flow-approval-decision-unrouted`); an `http` node with no `timeoutMs` '
17
-
+'(`flow-http-timeout-missing`, a warning); an active `state_machine` validation with no or an empty '
18
-
+'`initialStates` (`state-machine-no-initial-states`); a standalone action that declares `locations` but no `objectName` '
17
+
+'(`flow-http-timeout-missing`, a warning); an active `state_machine` validation that runs on insert (its `events` '
18
+
+'include `insert`, the default) with no or an empty `initialStates` (`state-machine-no-initial-states`); a standalone action that declares `locations` but no `objectName` '
19
19
+'(`action-no-object-binding`)',
20
20
replacement:
21
21
'Give the node a type the deployment runs (or install the plugin that contributes it); label the approval node\'s '
0 commit comments