|
| 1 | +--- |
| 2 | +'@objectstack/spec': minor |
| 3 | +'@objectstack/lint': minor |
| 4 | +--- |
| 5 | + |
| 6 | +fix(spec)!: a `decision` branch with no `expression` — the key absent, or `null` — is refused at authoring (#19961) |
| 7 | + |
| 8 | +Clause-②: no (narrowing) |
| 9 | + |
| 10 | +<!-- adr-0087: registered flow-decision-branch-expression-absent-refused --> |
| 11 | + |
| 12 | +**BREAKING** — an accept-set narrowing on one authored flow-node slot, shipped as |
| 13 | +`minor` under the launch-window convention (`check-changeset-no-major` refuses |
| 14 | +`major` until GA; breaking-ness is carried by this banner and the ADR-0087 |
| 15 | +disposition above, not by the level). |
| 16 | + |
| 17 | +**What changed.** `DecisionConditionSchema` declares a branch `{ label, expression }` |
| 18 | +with `expression` a required `z.string()`. Nothing enforced that: a decision node's |
| 19 | +`config` is an open record no schema is parsed against, and the expression ledger's |
| 20 | +resolver skipped an absent value as "not authored". So `conditions: [{ label: 'y' }]` |
| 21 | +passed `FlowSchema.parse`, `AutomationEngine.registerFlow` and `objectstack validate`, |
| 22 | +and the run then failed at that branch — the executor evaluates every branch it |
| 23 | +reaches, and a branch with no `expression` is a condition with no `source`, which |
| 24 | +`evaluateCondition` refuses. The ledger now marks the slot `required` (reconciled |
| 25 | +against the schema's own `required` list), and the branch is refused at all three |
| 26 | +doors through the walk and the function that already refuse a blank one — by |
| 27 | +`FlowSchema.parse` with a `custom` issue anchored at the slot (for example |
| 28 | +`nodes.1.config.conditions.0.expression`), by `registerFlow` and `objectstack validate` |
| 29 | +through that same parse, and by `validateStackExpressions` for a stack handed to it |
| 30 | +directly — with one message, led by the published `PREDICATE_SLOT_STRING_REFUSAL` |
| 31 | +sentence. `expression: null` is refused the same way, and so is a branch that wrote |
| 32 | +its predicate under `condition` (the edge's spelling), which has no `expression` |
| 33 | +either. The Studio flow designer writes the refused shape when a branch row's |
| 34 | +expression cell is left empty. Where such a branch already sits, the whole flow is |
| 35 | +refused: registered from the metadata |
| 36 | +registry or `sys_metadata` at boot, it is skipped with a `failed to register flow` |
| 37 | +warn naming it while the flows beside it register; a `defineStack({ flows })` source |
| 38 | +throws `StackSchemaInvalidError` for the whole stack; an artifact file is refused |
| 39 | +whole at load. |
| 40 | + |
| 41 | +## FROM → TO |
| 42 | + |
| 43 | +| you wrote | write instead | |
| 44 | +|:--|:--| |
| 45 | +| `conditions: [{ label: 'high' }]` on a `decision` node | the predicate you meant — `{ label: 'high', expression: 'record.amount > 10000' }` | |
| 46 | +| `conditions: [{ label: 'high', condition: 'record.amount > 10000' }]` | the same predicate under `expression` | |
| 47 | +| `conditions: [{ label: 'high', expression: null }]` | the predicate you meant, or `expression: 'false'` to keep the branch and never take it | |
| 48 | + |
| 49 | +**One-line fix:** write the predicate under `expression`. `expression: 'false'` keeps |
| 50 | +the branch and its label and never takes it — a change of behaviour, not a preserved |
| 51 | +one: a run that reached the branch used to FAIL there, and now routes on to the next |
| 52 | +branch or the declared fallback. ⚠️ Do not drop a decision's only branch: the node |
| 53 | +then routes by its out-edges alone, and the out-edge that branch labelled is no |
| 54 | +longer held back. |
| 55 | + |
| 56 | +**Unchanged.** A branch carrying a non-blank predicate parses, registers and |
| 57 | +validates as before; a blank one keeps its refusal and its own prescription |
| 58 | +(`flow-predicate-slot-blank-string-refused`); a `decision` with no `conditions`, or |
| 59 | +an empty list, still routes by its out-edges; an absent screen field `visibleWhen` |
| 60 | +is still legal (that slot is not required); and `PREDICATE_SLOT_STRING_REFUSAL` |
| 61 | +keeps its name and its text. |
0 commit comments