@beehexa/hexasync-template-worker-flow 2610.12.3 → 2611.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,33 +6,42 @@
6
6
  * ⛔ The first version of this package had `routeEdges` only, and `flow.ts` synthesised a decision node beside it
7
7
  * without connecting the two. The Story 4.1 review measured what that produced: a diamond with **zero** edges
8
8
  * touching it, while the YES/NO arms left the step — so the diamond was unreachable and undrawable, and the step
9
- * carried arms it does not have. Worse, it synthesised for the ~22 corpus steps with an object-valued `next` and
10
- * produced **no** node for the **3,480** with an expression-valued one, which is exactly where both shipped
11
- * surfaces DO synthesise (`_EXPR_<n>` in `flowChart.ts:145-155`, in the golden baseline for fixture 01).
9
+ * carried arms it does not have.
12
10
  *
13
- * `routeEdges` is kept because it answers a genuinely different question — *"what routes where"*, flat, which is
14
- * what `flowEdges` answers and what `routeParity.spec.ts` compares. This answers *"how is it drawn"*, and
15
- * `routeGraph.spec.ts` asserts the two agree about reachability so they cannot drift.
11
+ * `routeEdges` is kept because it answers a genuinely different question — *"what routes where"*, flat. This answers
12
+ * *"how is it drawn"*. Both read the step's route through the same `declaredRoute` / `resolveRouteTarget` semantics,
13
+ * and `routeGraph.spec.ts` asserts the two agree about reachability so they cannot drift.
16
14
  *
17
- * ### The three synthesised kinds, from the shipped baseline
15
+ * ### The synthesised kinds
18
16
  *
19
- * | kind | when | drawn as | label |
20
- * | --- | --- | --- | --- |
21
- * | `if` | an object route `{ if, then, else }` | diamond | the `if` text, or `?` |
22
- * | `expression` | a Scriban route naming ≥1 real step | diamond | the expression |
23
- * | `unknown` | a route naming no step at all | stadium | the route text |
17
+ * | kind | when | label (a controlled caption, never payload) |
18
+ * | --- | --- | --- |
19
+ * | `if` | a conditional `{ if, then, else }` | `If` |
20
+ * | `switch` | an exact `SWITCH` with an object payload | `Switch` |
21
+ * | `expression` | a dynamic route naming ≥1 real step | `Possible route` |
22
+ * | `unknown` | a literal naming no step, a dynamic route naming none, a rejected value, a recursive alias | the literal key, `Unresolved route`, `Invalid route`, `cycle: …` |
23
+ *
24
+ * No condition, expression or description text is copied into a label: those are step payload and are never evaluated.
25
+ *
26
+ * ### Every edge says what it is
27
+ *
28
+ * `role` is the declaring field (`next`, the IF/SWITCH payload `branch`, `onError` `recovery`, `fromStep`
29
+ * `exception`); `arm` says which conditional/switch arm it leaves by; `certainty` is `definite` for a statically
30
+ * declared transition and `possible` for a dynamic candidate or a SWITCH case (zero or several cases may match, so no
31
+ * case is a guaranteed choice). Identical edges are emitted once, so a legal self/back/convergence route appears once.
24
32
  *
25
33
  * ### Addressed by PATH, per AD-33 rule 4
26
34
  *
27
- * A structural node is *"named by the keys that reach it"*. So the junction for a step's object `next` is
28
- * `<step>:next:if` — AD-33's own example — a nested arm is `<step>:next:then:if`, an `IF` branching through `data`
29
- * is `<step>:data:if`, and an expression is `<step>:next:expression`. No counter anywhere, so inserting a step above
30
- * renumbers nothing. The path also disambiguates naturally: two dead ends leaving one step reach it by different
31
- * keys (`:next:unknown` and `:onError:unknown`), so neither needs an index.
35
+ * A structural node is *"named by the keys that reach it"*: `<step>:next:if`, a nested arm `<step>:next:then:if`, an
36
+ * IF branching through its payload `<step>:data:if` (or `:input:if` for a legacy payload), a switch point
37
+ * `<step>:data:switch`. Paths contain only document keys and the fixed synthetic words above — never a SWITCH arm or
38
+ * route text — so two differently-written targets that normalise alike cannot collapse onto one node. Unresolved
39
+ * SWITCH cases share `<step>:data:switch:unknown` and stay distinct as edges labelled by their exact keys.
32
40
  */
33
41
  import { keySegment, entrySegment, nodeAddress, } from '@beehexa/hexasync-template-model';
34
- import { looksLikeExpression, quotedKeys, } from './routes.js';
42
+ import { declaredRoute, isConditionalRoute, resolveRouteTarget, } from './routes.js';
35
43
  const step_ = (key) => ({ kind: 'step', key });
44
+ const CYCLE_LABEL = 'cycle: this branch refers to itself';
36
45
  /**
37
46
  * Every junction and every edge for the steps of ONE stage.
38
47
  *
@@ -45,160 +54,146 @@ export function routeGraph(steps) {
45
54
  const edges = [];
46
55
  /** Junctions already created, so two routes reaching the same path share one node. */
47
56
  const seen = new Set();
57
+ const emitted = new Set();
58
+ const endId = (end) => end.kind === 'step' ? ['step', end.key] : ['junction', end.owner, ...end.path];
48
59
  const junction = (owner, path, kind, label) => {
49
- const id = `${owner} ${path.join(' ')}`;
60
+ const id = JSON.stringify([owner, ...path]);
50
61
  if (!seen.has(id)) {
51
62
  seen.add(id);
52
63
  junctions.push({ owner, path, kind, label });
53
64
  }
54
65
  return { kind: 'junction', owner, path };
55
66
  };
56
- for (const step of steps) {
57
- const owner = String(step.key);
58
- const type = String(step.stepType ?? '').toUpperCase();
59
- const isBranchObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
60
- /**
61
- * Branch objects already entered on THIS step's walk — the cycle guard.
62
- *
63
- * ⛔ Without it a cyclic branch does not merely loop, it **kills the process**. Found by the Story 4.2 review and
64
- * confirmed here: `const a = {}; a.then = a; routeGraph([{ key: 'A', next: a }])` exits **134**, `FATAL ERROR:
65
- * heap out of memory`, in a few seconds. The `path` grows by two segments per iteration, `seen` is keyed by that
66
- * path so it never repeats, and both `junctions` and the work list grow without bound.
67
- *
68
- * This module's own docblock argued *"iterative, never recursive — a document is untrusted input"*. Iteration was
69
- * the right call and it removed the only thing that had been bounding this: the reference implementation recurses
70
- * and throws a **catchable** `RangeError`. An uncatchable V8 fatal is strictly worse, and this package is bundled
71
- * into the VS Code extension host, so the blast radius is the editor process.
72
- *
73
- * REACHABLE FROM YAML with the parser the CLI already uses — a recursive anchor is all it takes:
74
- *
75
- * ```yaml
76
- * next: &loop
77
- * if: "x"
78
- * then: *loop
79
- * ```
80
- *
81
- * Identity, not path: the same object reached twice is the cycle, however long the path to it.
82
- */
83
- const entered = new WeakSet();
84
- /** Work list of routes still to place: where the arrow leaves, the value, the path, the label. */
85
- const pending = [];
86
- // ── Which route(s) this step declares, and under which key ──
87
- //
88
- // An IF whose `data` is an object but declares NEITHER `then` NOR `else` falls back to `next`. Without the
89
- // fallback a partly-written IF loses its only edge and its target is orphaned in the diagram — `data:
90
- // { expression: '…' }` with `next: 'DONE'` drew `CHECK → <diamond>` and nothing else, leaving `DONE` floating.
91
- //
92
- // This mirrors `routes.ts`, the flat twin, which has always had the fallback and says why in the same words. The
93
- // two disagreed until Story 4.7's review measured it; this module's own docblock claimed the case "routed
94
- // correctly through its `next`", which was aspiration rather than behaviour. `type` comes from `provider`, then
95
- // `displayType` (`flow.ts` `stepOf`), and every UI-served step carries one, so the divergence was reachable from a
96
- // real surface.
97
- const branching = (type === 'IF' || type === 'SWITCH') && isBranchObject(step.data);
98
- const ifWithoutBranch = type === 'IF' &&
99
- branching &&
100
- step.data.then == null &&
101
- step.data.else == null;
102
- if (branching && !ifWithoutBranch) {
103
- pending.push({ from: step_(owner), value: step.data, path: ['data'] });
104
- }
105
- else {
106
- pending.push({ from: step_(owner), value: step.next, path: ['next'] });
107
- }
108
- if (step.onError !== null && step.onError !== undefined) {
109
- pending.push({
110
- from: step_(owner),
111
- value: step.onError,
112
- path: ['onError'],
113
- label: 'onError',
114
- });
115
- }
67
+ const edge = (next) => {
68
+ const id = JSON.stringify([
69
+ endId(next.from), endId(next.to), next.role, next.arm ?? null, next.label ?? null, next.certainty,
70
+ ]);
71
+ if (emitted.has(id))
72
+ return;
73
+ emitted.add(id);
74
+ edges.push(next);
75
+ };
76
+ /**
77
+ * Conditional objects on the CURRENT path, and every conditional already placed with its junction (per owner).
78
+ *
79
+ * ⛔ A recursive YAML anchor (`next: &loop` / `if: x` / `then: *loop`) makes an object its own descendant. An
80
+ * unguarded walk does not merely loop, it **kills the process** (uncatchable V8 heap fatal) — and this package is
81
+ * bundled into the VS Code extension host. Only an object on the ACTIVE path is a cycle, drawn as a labelled dead
82
+ * end. A completed object reached again — a harmless alias such as `then: *x` / `else: *x` — is a convergence
83
+ * edge onto the junction already placed for it: neither a false cycle nor a re-expansion, so repeated aliases
84
+ * stay linear in distinct objects.
85
+ */
86
+ const active = new Set();
87
+ const placed = new Map();
88
+ const pending = [];
89
+ const walk = (owner, start) => {
90
+ pending.push(start);
116
91
  while (pending.length > 0) {
117
- const { from, value, path, label } = pending.pop();
118
- if (value === null || value === undefined || value === '')
92
+ const item = pending.pop();
93
+ if ('leave' in item) {
94
+ active.delete(item.leave);
119
95
  continue;
120
- const labelled = label !== undefined ? { label } : {};
121
- // ── An object route: a diamond, and its arms leave the DIAMOND, not the step ──
122
- if (isBranchObject(value)) {
123
- const branch = value;
124
- if (entered.has(branch)) {
125
- /**
126
- * A cycle. Reported as a dead end labelled for what it is, rather than dropped: a route that loops back on
127
- * itself is a real document defect, and a diagram that simply stops there tells the reader nothing.
128
- */
129
- const point = junction(owner, [...path, 'cycle'], 'unknown', 'cycle: this branch refers to itself');
130
- edges.push({ from, to: point, ...labelled });
96
+ }
97
+ const { from: source, value, path, role, label, arm } = item;
98
+ const base = {
99
+ role,
100
+ ...(label !== undefined ? { label } : {}),
101
+ ...(arm !== undefined ? { arm } : {}),
102
+ };
103
+ // ── A conditional: a diamond, and its arms leave the DIAMOND, not the step ──
104
+ if (item.conditional && isConditionalRoute(value)) {
105
+ if (active.has(value)) {
106
+ const point = junction(owner, [...path, 'cycle'], 'unknown', CYCLE_LABEL);
107
+ edge({ from: source, to: point, ...base, certainty: 'definite' });
131
108
  continue;
132
109
  }
133
- entered.add(branch);
134
- const isSwitch = type === 'SWITCH' && path.length === 1 && path[0] === 'data';
135
- if (isSwitch) {
136
- // A SWITCH's arms are its data KEYS. The junction is the switch point itself.
137
- const point = junction(owner, [...path, 'switch'], 'if', 'SWITCH');
138
- edges.push({ from, to: point, ...labelled });
139
- for (const arm of Object.keys(branch)) {
140
- pending.push({
141
- from: point,
142
- value: arm,
143
- path: [...path, arm],
144
- label: arm,
145
- });
146
- }
110
+ const existing = placed.get(value);
111
+ if (existing !== undefined) {
112
+ edge({ from: source, to: existing, ...base, certainty: 'definite' });
147
113
  continue;
148
114
  }
149
- const condition = branch.if === null || branch.if === undefined
150
- ? '?'
151
- : String(branch.if);
152
- const point = junction(owner, [...path, 'if'], 'if', condition);
153
- edges.push({ from, to: point, ...labelled });
154
- // `else` first so `then` is placed first — a reader expects YES before NO.
115
+ const point = junction(owner, [...path, 'if'], 'if', 'If');
116
+ placed.set(value, point);
117
+ active.add(value);
118
+ edge({ from: source, to: point, ...base, certainty: 'definite' });
119
+ // Both arms are declared alternatives; an absent arm ends. `else` first so `then` is placed first.
120
+ pending.push({ leave: value });
155
121
  pending.push({
156
- from: point,
157
- value: branch.else,
158
- path: [...path, 'else'],
159
- label: 'NO',
122
+ from: point, value: value.else, path: [...path, 'else'], role, conditional: true, label: 'NO', arm: 'else',
160
123
  });
161
124
  pending.push({
162
- from: point,
163
- value: branch.then,
164
- path: [...path, 'then'],
165
- label: 'YES',
125
+ from: point, value: value.then, path: [...path, 'then'], role, conditional: true, label: 'YES', arm: 'then',
166
126
  });
167
127
  continue;
168
128
  }
169
- const text = String(value);
170
- // ── A direct step key: a plain edge, no synthesis ──
171
- if (known.has(text)) {
172
- edges.push({ from, to: step_(text), ...labelled });
173
- continue;
174
- }
175
- // ── An expression naming real steps: a diamond, then one arrow per target ──
176
- if (looksLikeExpression(text)) {
177
- const targets = quotedKeys(text).filter((k) => known.has(k));
178
- if (targets.length > 0) {
179
- const point = junction(owner, [...path, 'expression'], 'expression', text);
180
- edges.push({ from, to: point, ...labelled });
181
- // Unlabelled, as the baseline draws them: which target it takes is a run-time fact.
182
- for (const target of targets) {
183
- edges.push({ from: point, to: step_(target) });
129
+ const target = resolveRouteTarget(value, known);
130
+ switch (target.kind) {
131
+ case 'end':
132
+ break;
133
+ case 'step':
134
+ edge({ from: source, to: step_(target.key), ...base, certainty: 'definite' });
135
+ break;
136
+ case 'dynamic': {
137
+ // Nothing is evaluated: the candidates are possible, and an expression naming none is unresolved.
138
+ if (target.candidates.length === 0) {
139
+ const point = junction(owner, [...path, 'unknown'], 'unknown', 'Unresolved route');
140
+ edge({ from: source, to: point, ...base, certainty: 'possible' });
141
+ break;
184
142
  }
185
- continue;
143
+ const point = junction(owner, [...path, 'expression'], 'expression', 'Possible route');
144
+ edge({ from: source, to: point, ...base, certainty: 'possible' });
145
+ for (const candidate of target.candidates) {
146
+ edge({ from: point, to: step_(candidate), role, certainty: 'possible' });
147
+ }
148
+ break;
149
+ }
150
+ case 'missing': {
151
+ // A literal key is not payload: naming it is how the reader finds the typo.
152
+ const point = junction(owner, [...path, 'unknown'], 'unknown', target.text);
153
+ edge({ from: source, to: point, ...base, certainty: 'definite' });
154
+ break;
155
+ }
156
+ case 'invalid': {
157
+ const point = junction(owner, [...path, 'unknown'], 'unknown', 'Invalid route');
158
+ edge({ from: source, to: point, ...base, certainty: 'definite' });
159
+ break;
186
160
  }
187
161
  }
188
- // ── Naming nothing: a terminal, kept so the reader sees the dead end ──
189
- const point = junction(owner, [...path, 'unknown'], 'unknown', text);
190
- edges.push({ from, to: point, ...labelled });
162
+ }
163
+ };
164
+ for (const step of steps) {
165
+ const owner = String(step.key);
166
+ const from = step_(owner);
167
+ // Junctions are owned by one step: an object shared between two steps' routes is placed once per owner.
168
+ placed.clear();
169
+ if (step.onError !== null && step.onError !== undefined) {
170
+ walk(owner, { from, value: step.onError, path: ['onError'], role: 'recovery', conditional: false, label: 'onError' });
171
+ }
172
+ const route = declaredRoute(step);
173
+ if (route.mode === 'switch') {
174
+ // The arms are the payload KEYS — exact target keys, never rendered, each only a possible choice.
175
+ const point = junction(owner, [route.field, 'switch'], 'switch', 'Switch');
176
+ edge({ from, to: point, role: 'branch', certainty: 'definite' });
177
+ for (const arm of Object.keys(route.value)) {
178
+ const to = known.has(arm)
179
+ ? step_(arm)
180
+ : junction(owner, [route.field, 'switch', 'unknown'], 'unknown', 'Unresolved route');
181
+ edge({ from: point, to, role: 'branch', certainty: 'possible', arm: 'case', label: arm });
182
+ }
183
+ }
184
+ else if (route.mode === 'invalid') {
185
+ const point = junction(owner, [route.field, 'unknown'], 'unknown', 'Invalid route');
186
+ edge({ from, to: point, role: route.role, certainty: 'definite' });
187
+ }
188
+ else {
189
+ walk(owner, { from, value: route.value, path: [route.field], role: route.role, conditional: true });
191
190
  }
192
191
  /**
193
192
  * The exception BACK-REFERENCE, which is reversed: an edge INTO this step from the one that threw. No junction —
194
193
  * it is a direct edge between two authored steps.
195
194
  */
196
195
  if (step.fromStep && known.has(step.fromStep)) {
197
- edges.push({
198
- from: step_(step.fromStep),
199
- to: step_(owner),
200
- label: 'Exception',
201
- });
196
+ edge({ from: step_(step.fromStep), to: step_(owner), label: 'Exception', role: 'exception', certainty: 'definite' });
202
197
  }
203
198
  }
204
199
  return { junctions, edges };
@@ -207,8 +202,7 @@ export function routeGraph(steps) {
207
202
  export function junctionAddress(ownerAddress, path) {
208
203
  return nodeAddress([
209
204
  keySegment(ownerAddress),
210
- // A path element is a document key where it is one (`next`, `then`, `if`) and a dictionary tail where it is a
211
- // SWITCH arm — `entrySegment` normalises both and refuses a `!`-prefixed one.
205
+ // Path elements are document keys (`next`, `then`, `data`) or fixed synthetic words (`if`, `switch`, `unknown`).
212
206
  ...path.map((element) => entrySegment(element) ?? keySegment(element)),
213
207
  ]);
214
208
  }
@@ -1 +1 @@
1
- {"version":3,"file":"routeGraph.js","sourceRoot":"","sources":["../src/routeGraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EACL,UAAU,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,mBAAmB,EACnB,UAAU,GAEX,MAAM,aAAa,CAAC;AAoCrB,MAAM,KAAK,GAAG,CAAC,GAAW,EAAW,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAA8B;IACvD,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,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AAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC;QACrE,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QACtG,CAAC;QAED;;;WAGG;QACH,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9C,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC;QACvH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,eAAe,CAC7B,YAAoB,EACpB,IAAuB;IAEvB,OAAO,WAAW,CAAC;QACjB,UAAU,CAAC,YAAY,CAAC;QACxB,iHAAiH;QACjH,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;KACvE,CAAC,CAAC;AACL,CAAC"}
package/dist/routes.d.ts CHANGED
@@ -1,40 +1,42 @@
1
1
  /**
2
2
  * Where a step goes next — Story 4.1 AC-2, all five kinds, in the MODEL rather than in a renderer.
3
3
  *
4
- * The semantics are the runtime's: `core.api/hexasync.steps/Execution/NextStepBuilder.cs` and `IfStepExecutor`.
5
- * This package does not invent them; NFR-1 says the editor invents no semantics the runtime lacks.
4
+ * The semantics are the runtime's (`assets/docs/routing/NEXT.md`, `steps/IF.md`, `steps/SWITCH.md`). This package
5
+ * does not invent them; NFR-1 says the editor invents no semantics the runtime lacks.
6
6
  *
7
- * | kind | where it is declared | who drew it before |
7
+ * | kind | where it is declared | static meaning |
8
8
  * | --- | --- | --- |
9
- * | by step TYPE | `IF` / `SWITCH` read their `data` | CLI only — dashboard reads only `step.next` |
10
- * | by step DATA | `{ if, then, else }` on `next` or `data` | CLI |
11
- * | an EXPRESSION | a Scriban `next` naming keys in quotes | CLI |
12
- * | an ERROR route | `onError` | CLI |
13
- * | an exception BACK-REFERENCE | `fromStep` → this step | **nobody** — see below |
9
+ * | by step TYPE | exact `IF` routes its WHOLE payload; exact `SWITCH` reads payload KEYS | declared `next` is ignored |
10
+ * | by step DATA | `{ if, then, else }` on `next` or an IF payload | both arms are declared alternatives |
11
+ * | an EXPRESSION | a Scriban/rendered route string | quoted known keys are POSSIBLE candidates only |
12
+ * | an ERROR route | `onError` (`<KEY \| null>`) | recovery |
13
+ * | an exception BACK-REFERENCE | `fromStep` → this step | exception |
14
14
  *
15
- * ### The back-reference is why routing has to live here
15
+ * ### IF and SWITCH route through their payload, never through `next`
16
16
  *
17
- * `fromStep` produces an edge *into* the exception step from the step that threw. It exists **only in the CLI's
18
- * drawing path** (`flowChart.ts:199-201` emits `fromStep --|"Exception"|-> this`) and **not** in the shared
19
- * `flowEdges`. The VS Code extension imports `flowEdges`, so it has never drawn that edge at all — a whole route
20
- * kind missing from one surface because the renderer, not the model, owned it. Moving routing into the model is what
21
- * makes AC-2's last clause true everywhere, and it is the concrete argument for this package existing.
17
+ * An `IF` evaluates its whole payload as one route node: `null` ends the flow, a string routes to that string, an
18
+ * object is a conditional. The step's own `next` is never a fallback — not when the payload is `null`, and not when a
19
+ * conditional omits both arms. A `SWITCH` payload is a map whose property NAMES are exact target keys (no `cases`
20
+ * wrapper, no list, no default); zero matches end and several matches fail, so every arm is only a possible route.
21
+ * A non-object SWITCH payload fails the step. Step types are exact: `If` and `switch` are ordinary steps.
22
22
  *
23
23
  * ### An unresolvable route is REPORTED, not dropped
24
24
  *
25
25
  * A route naming no step in the stage yields an edge with `raw` and no `to`. A reader needs to see the dead end:
26
26
  * silently dropping it draws a flow that terminates where the document does not say it terminates, which is the
27
- * more expensive error. Same for an expression whose quoted keys match nothing.
27
+ * more expensive error. Same for an expression whose quoted keys match nothing, and for a value the grammar rejects.
28
28
  */
29
29
  /** A step as routing needs to see it. Deliberately structural — this package reads no schema and no file. */
30
30
  export interface RoutableStep {
31
31
  readonly key: string;
32
32
  /** Raw `next`: a step key, a `{ if, then, else }` branch, a Scriban expression, or absent. */
33
33
  readonly next?: unknown;
34
- /** The step's declared type, e.g. `IF`, `SWITCH`. Compared case-insensitively. */
34
+ /** The exact selected executor; case-sensitive, with no trimming. */
35
35
  readonly stepType?: string;
36
- /** For `IF`/`SWITCH`, the runtime passes `data` to the route builder. */
36
+ /** The SELECTED payload (own `data`, even `null`, else legacy `input`); `IF`/`SWITCH` route through it. */
37
37
  readonly data?: unknown;
38
+ /** Which authored field supplied `data`, so a branch is addressed where it is written. Defaults to `data`. */
39
+ readonly payloadField?: 'data' | 'input';
38
40
  /** A recovery target. */
39
41
  readonly onError?: unknown;
40
42
  /** An Exception step's back-reference: the step whose failure reaches this one. */
@@ -46,7 +48,7 @@ export interface RouteEdge {
46
48
  readonly from: string;
47
49
  /** The step it reaches, when that step exists in this stage. */
48
50
  readonly to?: string;
49
- /** `YES`, `NO`, a SWITCH branch name, `onError`, `Exception`. */
51
+ /** `YES`, `NO`, a SWITCH target key, `onError`, `Exception`. */
50
52
  readonly label?: string;
51
53
  /**
52
54
  * The route text when it does not name a known step — an expression, or a dead end.
@@ -55,13 +57,65 @@ export interface RouteEdge {
55
57
  * a static view cannot know, and showing the expression is how the reader learns that.
56
58
  */
57
59
  readonly raw?: string;
60
+ /**
61
+ * The grammar REJECTED the route value — a scalar, list or object where a key is required, or a non-object SWITCH
62
+ * payload — so the run fails if it is taken. `raw` then carries only a flat description (`true`, `7`, `list`,
63
+ * `object`), which is why this marker exists: `data: true` and a literal missing key `'true'` share the same `raw`.
64
+ */
65
+ readonly invalid?: true;
58
66
  }
59
- /** Every `"QUOTED_KEY"` in an expression. */
67
+ /** Every `"QUOTED_KEY"` in an expression, once each, in first-appearance order. */
60
68
  export declare function quotedKeys(expression: string): readonly string[];
61
- /** Is this route text an expression rather than a step key? */
69
+ /**
70
+ * Is this route text DYNAMIC — rendered by Scriban into something other than itself?
71
+ *
72
+ * Scriban (`{{ … }}` / `{% … %}`) or a rendered conditional object (trimmed text beginning with `{`). Plain text,
73
+ * including text with quotes in it, renders to itself and is a literal key.
74
+ */
62
75
  export declare function looksLikeExpression(text: string): boolean;
76
+ /** A `{ if, then, else }` route node. Arrays and scalars are not conditionals. */
77
+ export declare function isConditionalRoute(value: unknown): value is Readonly<Record<string, unknown>>;
78
+ /** What one non-conditional route value statically resolves to. */
79
+ export type RouteTarget =
80
+ /** Absent, `null` or blank: the branch ends normally. */
81
+ {
82
+ readonly kind: 'end';
83
+ }
84
+ /** An exact literal key of a step in this list. */
85
+ | {
86
+ readonly kind: 'step';
87
+ readonly key: string;
88
+ }
89
+ /** Rendered at run time; `candidates` are the known keys it names, which are POSSIBLE, never definite. */
90
+ | {
91
+ readonly kind: 'dynamic';
92
+ readonly text: string;
93
+ readonly candidates: readonly string[];
94
+ }
95
+ /** A literal naming no step in this list: the run fails if it is taken. */
96
+ | {
97
+ readonly kind: 'missing';
98
+ readonly text: string;
99
+ }
100
+ /** A number, boolean, list or object where the grammar does not allow one: the run fails. */
101
+ | {
102
+ readonly kind: 'invalid';
103
+ };
104
+ /** Resolve one route value that is not walked as a conditional. No expression is evaluated. */
105
+ export declare function resolveRouteTarget(value: unknown, known: ReadonlySet<string>): RouteTarget;
106
+ /** The route a step declares for its successful completion, chosen by its exact executor. */
107
+ export interface DeclaredRoute {
108
+ /** The authored field the route is read from: `next`, or the IF/SWITCH payload field. */
109
+ readonly field: 'next' | 'data' | 'input';
110
+ readonly value: unknown;
111
+ /** `next` for a declared successor; `branch` for an IF/SWITCH payload route. */
112
+ readonly role: 'next' | 'branch';
113
+ /** `route` walks the `next` grammar; `switch` reads target KEYS; `invalid` is a payload that fails the step. */
114
+ readonly mode: 'route' | 'switch' | 'invalid';
115
+ }
116
+ export declare function declaredRoute(step: RoutableStep): DeclaredRoute;
63
117
  /**
64
- * Every edge the steps of ONE stage declare.
118
+ * Every edge the steps of ONE stage declare, flat.
65
119
  *
66
120
  * Iterative, never recursive: `then`/`else` nest without bound and a document is untrusted input, so a deep branch
67
121
  * must not be able to exhaust the stack. (The same rule the puller step standards state: *no recursion — stack or
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,6GAA6G;AAC7G,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,8FAA8F;IAC9F,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,kFAAkF;IAClF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,yEAAyE;IACzE,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,yBAAyB;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,mCAAmC;AACnC,MAAM,WAAW,SAAS;IACxB,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;O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