diff --git a/.changeset/38992-unconditional-sibling-wording.md b/.changeset/38992-unconditional-sibling-wording.md new file mode 100644 index 00000000000..f539755389b --- /dev/null +++ b/.changeset/38992-unconditional-sibling-wording.md @@ -0,0 +1,19 @@ +--- +'@objectstack/lint': patch +'@objectstack/skills': patch +--- + +fix(lint): the `flow-decision-unconditional-branch` advice and the automation skill say when an unconditional out-edge beside guarded ones runs + +Clause-②: no +Metadata-protocol: none + +Words only: the rule's id, verdict (a warning) and trigger are unchanged. + +Both texts said an out-edge with no `condition` runs "in parallel" with the guarded branch beside it. The engine takes a node's out-edges in a fixed order, each one finished before the next: its conditioned edges in the order they are declared (a `decision` takes only the first whose condition holds, unless it declares `mode: 'inclusive'`), then its `isDefault` edge when no condition held, then its unconditional edges, and only those run together. So an unconditional sibling runs after the guarded branch, on every pass; and when the guarded branch parks the run (an `approval`, a `screen`, a `wait`), the run resumes from the step it parked at and the unconditional edge is never taken, a shape the flow schema refuses at save (`flow-sequential-branch-durable-pause-refused`). + +- `flow-decision-unconditional-branch`, the message for a decision with guarded and unconditional out-edges: "traversed on EVERY pass, in parallel with whichever guarded branch matched" becomes "traversed on EVERY pass, after whichever guarded branch matched has run", followed by one sentence on the branch that parks the run. The hint is unchanged, and so is the message for a decision that gates no out-edge at all (there every out-edge is unconditional, and they do run together). +- `skills/objectstack-automation/references/state-machines-and-approvals.md`, the approvals example: "the engine evaluates each out-edge's `condition` and follows every match — and an out-edge with NO condition ALWAYS runs (all such edges execute in PARALLEL)" becomes "a `decision` takes the FIRST out-edge whose `condition` holds. One with none runs AFTER it, every pass, or never if that branch parks the run (refused at save)". The old sentence was also wrong about "every match": a `decision` is exclusive unless it declares `mode: 'inclusive'`. The file's size is unchanged (23708 bytes before and after). +- The plain-language text of `flow-decision-unconditional-branch` for that same shape, in all eleven locales it is written in (en, zh-Hans, zh-Hant, es, ar, fr, pt-BR, ru, de, ja, ko): "runs every time, alongside whichever path matched" becomes "runs every time, after whichever path matched", and each locale's "together with" or "at the same time as" wording becomes its "after". +- `flow-multiple-default-edges`, message and docblock: several `isDefault` edges were said to be "traversed together … a parallel fan-out". The engine takes them one after another in declaration order, and the message now says so. The rule's id, verdict (a warning), trigger and hint are unchanged. +- `skills/objectstack-automation/evals/flows-triggers-approvals.json`, the expected answer of the onboarding-wizard case: "an unguarded out-edge always runs, in parallel" becomes "an unguarded out-edge is no otherwise-branch: it runs after the guarded one, or never once that one parks at its `screen`, a shape the flow schema refuses". diff --git a/packages/lint/src/lint-flow-patterns.test.ts b/packages/lint/src/lint-flow-patterns.test.ts index f90504fc0a2..cc952bfbe91 100644 --- a/packages/lint/src/lint-flow-patterns.test.ts +++ b/packages/lint/src/lint-flow-patterns.test.ts @@ -1055,8 +1055,12 @@ describe('flow-branch-label-unmatched (#4414)', () => { }); describe('flow-decision-unconditional-branch (#4414)', () => { - // The actual hole: `e_no` has no condition and no `isDefault`, so it is - // traversed on every pass — the abort screen AND the wizard behind it. + // The actual hole: `e_no` has no condition and no `isDefault`, so the + // decision does not exclude it: the engine takes it AFTER `e_yes`'s branch, + // not instead of it — the abort step AND then the wizard behind it. (With + // `abort` a `screen`, as in this fixture, the run parks there and `e_no` is + // never taken, which the flow schema refuses; the rule reads the edges only + // and reports either way.) it('flags an unconditional out-edge alongside a guarded one', () => { const fnds = lintFlowPatterns(guardFlow()).filter( (f) => f.rule === FLOW_DECISION_UNCONDITIONAL_BRANCH, diff --git a/packages/lint/src/lint-flow-patterns.ts b/packages/lint/src/lint-flow-patterns.ts index eda0f0d5c7a..d3d45e06d1d 100644 --- a/packages/lint/src/lint-flow-patterns.ts +++ b/packages/lint/src/lint-flow-patterns.ts @@ -1213,8 +1213,14 @@ function scanErrorLabelledEdges( * both branches. * (2) `flow-decision-unconditional-branch` — an out-edge nothing can gate: no * `condition`, no `isDefault`, and no label the decision can select. It is - * traversed on EVERY pass, in parallel with whichever branch did match, so - * the guard next to it does not guard. #16093 gave the same id a second + * traversed on EVERY pass, AFTER whichever guarded branch did match has + * run (the engine awaits the conditioned out-edges in declaration order, + * then an `isDefault` one when none held, and only then takes the + * unconditional out-edges, those together), so the guard next to it does + * not guard. The one pass it is not traversed on is the one where the + * guarded branch parks the run: the pause unwinds the traversal before + * the unconditional out-edges are reached and the resume does not come + * back to this node, a shape the flow schema refuses. #16093 gave the same id a second * message for the strictly worse shape it could not previously see: NO * out-edge gated and no `conditions[]` declared either. The rule was framed * as "an unconditional edge undercuts a guarded one", so zero guarded edges @@ -1230,8 +1236,9 @@ function scanErrorLabelledEdges( * matched"; a condition on the same edge contradicts it (BPMN forbids a * conditional default flow). The condition wins and the marker is inert. * (4) `flow-multiple-default-edges` — two fallbacks out of one node. Both are - * traversed when nothing matched, which is a parallel fan-out, not the - * exclusive "otherwise" the marker promises. + * traversed when nothing matched, one after the other in declaration + * order (the engine awaits each default edge before the next), which is + * a fan-out, not the exclusive "otherwise" the marker promises. * (5) `flow-inert-node-condition` — `config.condition` on a node that never * reads it. The key is the trigger gate on `start` and dead on every other * builtin, so the predicate reads like a guard and gates nothing. @@ -1308,8 +1315,8 @@ function scanBranchRouting( message: `${defaults.length} out-edges are marked \`isDefault: true\` (${defaults .map((e) => `'${String(e.target)}'`) - .join(', ')}) — a node has at most ONE default path. All of them are traversed together ` + - `when no condition matches, which is a parallel fan-out, not an "otherwise".`, + .join(', ')}) — a node has at most ONE default path. All of them are traversed ` + + `when no condition matches, one after another in declaration order, which is a fan-out, not an "otherwise".`, hint: `Keep \`isDefault: true\` on the single fallback edge and give the others a \`condition\` ` + `(or leave them unconditional if the fan-out really is intended).`, @@ -1513,8 +1520,10 @@ function scanBranchRouting( message: `has guarded out-edge(s) alongside unconditional one(s) ` + `(${ungated.map((e) => `'${String(e.target)}'`).join(', ')}) — an unconditional out-edge is ` + - `traversed on EVERY pass, in parallel with whichever guarded branch matched, so the ` + - `decision does not actually exclude it. A \`label\` alone does not select a path unless the ` + + `traversed on EVERY pass, after whichever guarded branch matched has run, so the ` + + `decision does not actually exclude it. (Where that guarded branch parks the run — an ` + + `approval, a screen, a wait — the unconditional out-edge is never taken at all, and the flow ` + + `schema refuses the flow.) A \`label\` alone does not select a path unless the ` + `decision declares a matching \`conditions[].label\`.`, hint: `Mark the fallback \`isDefault: true\` so it is taken only when no sibling condition matched ` + diff --git a/packages/lint/src/lint-flow-patterns.user-text.ts b/packages/lint/src/lint-flow-patterns.user-text.ts index c978ee1f291..2b79fc968af 100644 --- a/packages/lint/src/lint-flow-patterns.user-text.ts +++ b/packages/lint/src/lint-flow-patterns.user-text.ts @@ -46,27 +46,27 @@ export const FLOW_PATTERNS_USER_TEXT: UserTextCatalog = Object.freeze({ `(${targetList(p, '"', '"', ', ')}), so every path runs every time and the step chooses nothing. ` + `Give each path a condition, and mark one of them as the default path.` : `The branch step "${p.node}" in flow "${p.flow}" has a path to ${targetList(p, '"', '"', ', ')} with ` + - `no condition, so that path runs every time, alongside whichever path matched. Give it a ` + + `no condition, so that path runs every time, after whichever path matched. Give it a ` + `condition, or mark it as the default path.`, 'zh-Hans': (p) => p.shape === 'none' ? `流程“${p.flow}”中的条件分支“${p.node}”没有为任何一条连线(${targetList(p, '“', '”', '、')})设置条件,` + `因此每次运行都会走所有连线,这个分支起不到选择作用。请为每条连线设置条件,并把其中一条设为默认分支。` : `流程“${p.flow}”中的条件分支“${p.node}”通往${targetList(p, '“', '”', '、')}的连线没有设置条件,` + - `因此每次运行都会走这条连线,同时还会走条件成立的那一条。请为它设置条件,或把它设为默认分支。`, + `因此每次运行都会走这条连线,排在条件成立的那一条之后。请为它设置条件,或把它设为默认分支。`, 'zh-Hant': (p) => p.shape === 'none' ? `流程「${p.flow}」中的條件分支「${p.node}」沒有為任何一條連線(${targetList(p, '「', '」', '、')})設定條件,` + `因此每次執行都會走所有連線,這個分支起不到選擇作用。請為每條連線設定條件,並把其中一條設為預設分支。` : `流程「${p.flow}」中的條件分支「${p.node}」通往${targetList(p, '「', '」', '、')}的連線沒有設定條件,` + - `因此每次執行都會走這條連線,同時還會走條件成立的那一條。請為它設定條件,或把它設為預設分支。`, + `因此每次執行都會走這條連線,排在條件成立的那一條之後。請為它設定條件,或把它設為預設分支。`, es: (p) => p.shape === 'none' ? `El paso de bifurcación "${p.node}" del flujo "${p.flow}" no pone condición en ninguno de sus caminos ` + `(${targetList(p, '"', '"', ', ')}), así que todos los caminos se recorren siempre y el paso no elige ` + `nada. Ponga una condición a cada camino y marque uno de ellos como camino predeterminado.` : `El paso de bifurcación "${p.node}" del flujo "${p.flow}" tiene un camino hacia ` + - `${targetList(p, '"', '"', ', ')} sin condición, así que ese camino se recorre siempre, junto con el ` + + `${targetList(p, '"', '"', ', ')} sin condición, así que ese camino se recorre siempre, después del ` + `que haya coincidido. Póngale una condición o márquelo como camino predeterminado.`, ar: (p) => p.shape === 'none' @@ -74,7 +74,7 @@ export const FLOW_PATTERNS_USER_TEXT: UserTextCatalog = Object.freeze({ `(${targetList(p, '"', '"', '، ')})، لذلك تُسلك كل المسارات في كل مرة ولا تختار الخطوة شيئًا. ` + `ضع شرطًا لكل مسار، واجعل أحدها المسار الافتراضي.` : `خطوة التفرّع "${p.node}" في التدفق "${p.flow}" لها مسار إلى ${targetList(p, '"', '"', '، ')} بلا ` + - `شرط، لذلك يُسلك هذا المسار في كل مرة إلى جانب المسار الذي تحقق شرطه. ضع له شرطًا، أو اجعله ` + + `شرط، لذلك يُسلك هذا المسار في كل مرة بعد المسار الذي تحقق شرطه. ضع له شرطًا، أو اجعله ` + `المسار الافتراضي.`, fr: (p) => p.shape === 'none' @@ -82,7 +82,7 @@ export const FLOW_PATTERNS_USER_TEXT: UserTextCatalog = Object.freeze({ `chemins (${targetList(p, '« ', ' »', ', ')}) : tous les chemins sont suivis à chaque fois et l’étape ` + `ne choisit rien. Donnez une condition à chaque chemin et marquez l’un d’eux comme chemin par défaut.` : `L’étape d’embranchement « ${p.node} » du flux « ${p.flow} » a un chemin vers ` + - `${targetList(p, '« ', ' »', ', ')} sans condition : ce chemin est suivi à chaque fois, en plus de ` + + `${targetList(p, '« ', ' »', ', ')} sans condition : ce chemin est suivi à chaque fois, après ` + `celui dont la condition est vraie. Donnez-lui une condition, ou marquez-le comme chemin par défaut.`, 'pt-BR': (p) => p.shape === 'none' @@ -90,15 +90,15 @@ export const FLOW_PATTERNS_USER_TEXT: UserTextCatalog = Object.freeze({ `caminhos (${targetList(p, '"', '"', ', ')}), então todos os caminhos são percorridos sempre e a ` + `etapa não escolhe nada. Dê uma condição a cada caminho e marque um deles como caminho padrão.` : `A etapa de ramificação "${p.node}" do fluxo "${p.flow}" tem um caminho para ` + - `${targetList(p, '"', '"', ', ')} sem condição, então esse caminho é percorrido sempre, junto com ` + - `aquele cuja condição foi atendida. Dê a ele uma condição ou marque-o como caminho padrão.`, + `${targetList(p, '"', '"', ', ')} sem condição, então esse caminho é percorrido sempre, depois ` + + `daquele cuja condição foi atendida. Dê a ele uma condição ou marque-o como caminho padrão.`, ru: (p) => p.shape === 'none' ? `Шаг ветвления «${p.node}» в потоке «${p.flow}» не задаёт условия ни для одного из своих путей ` + `(${targetList(p, '«', '»', ', ')}), поэтому каждый раз выполняются все пути и шаг ничего не ` + `выбирает. Задайте условие для каждого пути и отметьте один из них как путь по умолчанию.` : `У шага ветвления «${p.node}» в потоке «${p.flow}» есть путь к ${targetList(p, '«', '»', ', ')} без ` + - `условия, поэтому этот путь выполняется каждый раз, вместе с тем, чьё условие выполнилось. Задайте ` + + `условия, поэтому этот путь выполняется каждый раз, после того, чьё условие выполнилось. Задайте ` + `для него условие или отметьте его как путь по умолчанию.`, de: (p) => p.shape === 'none' @@ -107,7 +107,7 @@ export const FLOW_PATTERNS_USER_TEXT: UserTextCatalog = Object.freeze({ `der Schritt wählt nichts aus. Geben Sie jedem Pfad eine Bedingung und markieren Sie einen davon als ` + `Standardpfad.` : `Der Verzweigungsschritt „${p.node}“ im Flow „${p.flow}“ hat einen Pfad zu ` + - `${targetList(p, '„', '“', ', ')} ohne Bedingung, daher läuft dieser Pfad jedes Mal, zusätzlich zu ` + + `${targetList(p, '„', '“', ', ')} ohne Bedingung, daher läuft dieser Pfad jedes Mal, nach ` + `dem Pfad, dessen Bedingung zutrifft. Geben Sie ihm eine Bedingung oder markieren Sie ihn als ` + `Standardpfad.`, ja: (p) => @@ -116,7 +116,7 @@ export const FLOW_PATTERNS_USER_TEXT: UserTextCatalog = Object.freeze({ `条件を設定していないため、毎回すべての経路が実行され、このステップは何も選択しません。` + `各経路に条件を設定し、そのうち 1 つを既定の経路にしてください。` : `フロー「${p.flow}」の分岐ステップ「${p.node}」には、条件のない${targetList(p, '「', '」', '、')}への` + - `経路があるため、その経路は条件が一致した経路と並んで毎回実行されます。条件を設定するか、既定の経路に` + + `経路があるため、その経路は条件が一致した経路の後に毎回実行されます。条件を設定するか、既定の経路に` + `してください。`, ko: (p) => p.shape === 'none' @@ -124,7 +124,7 @@ export const FLOW_PATTERNS_USER_TEXT: UserTextCatalog = Object.freeze({ `설정하지 않아 매번 모든 경로가 실행되고, 이 단계는 아무것도 선택하지 않습니다. 각 경로에 조건을 ` + `설정하고 그중 하나를 기본 경로로 지정하세요.` : `플로우 "${p.flow}"의 분기 단계 "${p.node}"에는 조건 없이 ${targetList(p, '"', '"', ', ')}(으)로 ` + - `가는 경로가 있어, 조건이 맞은 경로와 함께 매번 실행됩니다. 조건을 설정하거나 기본 경로로 ` + + `가는 경로가 있어, 조건이 맞은 경로 다음에 매번 실행됩니다. 조건을 설정하거나 기본 경로로 ` + `지정하세요.`, }, }); diff --git a/skills/objectstack-automation/evals/flows-triggers-approvals.json b/skills/objectstack-automation/evals/flows-triggers-approvals.json index d3cb3a78f22..95f52c4d209 100644 --- a/skills/objectstack-automation/evals/flows-triggers-approvals.json +++ b/skills/objectstack-automation/evals/flows-triggers-approvals.json @@ -63,7 +63,7 @@ { "id": 4, "prompt": "Build a guided 'new client onboarding' wizard: step 1 collects company details, step 2 asks whether a credit check is needed (if yes, a credit-check screen; else skip), then creates the `account` record.", - "expected_output": "The steps BRANCH, so a `screen` flow (`type: 'screen'`), not a form-view wizard: a `screen` node per step, a `decision` whose out-edges carry mutually exclusive `condition` predicates (an unguarded out-edge always runs, in parallel), a `create_record`, explicit `variables` entries (`{ name, type, isInput, isOutput }`), every path reaching an `end`; `runAs: 'user'`.", + "expected_output": "The steps BRANCH, so a `screen` flow (`type: 'screen'`), not a form-view wizard: a `screen` node per step, a `decision` whose out-edges carry mutually exclusive `condition` predicates (an unguarded out-edge is no otherwise-branch: it runs after the guarded one, or never once that one parks at its `screen`, a shape the flow schema refuses), a `create_record`, explicit `variables` entries (`{ name, type, isInput, isOutput }`), every path reaching an `end`; `runAs: 'user'`.", "files": [], "assertions": { "must_contain": [ diff --git a/skills/objectstack-automation/references/state-machines-and-approvals.md b/skills/objectstack-automation/references/state-machines-and-approvals.md index a9d0ee5c085..0962014de42 100644 --- a/skills/objectstack-automation/references/state-machines-and-approvals.md +++ b/skills/objectstack-automation/references/state-machines-and-approvals.md @@ -76,9 +76,9 @@ the same literal goes inside `defineFlow(...)`, and `` cel`…` `` builds each `{ dialect, source }` envelope. - The trigger is the START node's config. -- Decision routing lives on the OUT-EDGES, not in node config: the engine - evaluates each out-edge's `condition` and follows every match — and an - out-edge with NO condition ALWAYS runs (all such edges execute in PARALLEL). +- Decision routing lives on the OUT-EDGES, not in node config: a `decision` + takes the FIRST out-edge whose `condition` holds. One with none runs AFTER + it, every pass, or never if that branch parks the run (refused at save). Guard every branch with a condition — `e4` / `e5`. - Entry criteria re-home onto the edge entering the approval node — `e1`.