@beehexa/hexasync-template-worker-flow 2608.15.1 → 2608.20.18

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.
package/dist/routes.js DELETED
@@ -1,155 +0,0 @@
1
- /**
2
- * Where a step goes next — Story 4.1 AC-2, all five kinds, in the MODEL rather than in a renderer.
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.
6
- *
7
- * | kind | where it is declared | who drew it before |
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 |
14
- *
15
- * ### The back-reference is why routing has to live here
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.
22
- *
23
- * ### An unresolvable route is REPORTED, not dropped
24
- *
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
- * 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.
28
- */
29
- /** Every `"QUOTED_KEY"` in an expression. */
30
- export function quotedKeys(expression) {
31
- return [...expression.matchAll(/"([A-Za-z0-9_]+)"/g)].map((m) => m[1]);
32
- }
33
- /** Is this route text an expression rather than a step key? */
34
- export function looksLikeExpression(text) {
35
- return (text.includes('{{') || text.includes('}}') || /"[A-Za-z0-9_]+"/.test(text));
36
- }
37
- /**
38
- * Every edge the steps of ONE stage declare.
39
- *
40
- * Iterative, never recursive: `then`/`else` nest without bound and a document is untrusted input, so a deep branch
41
- * must not be able to exhaust the stack. (The same rule the puller step standards state: *no recursion — stack or
42
- * loop*.)
43
- */
44
- export function routeEdges(steps) {
45
- // `String`, because the exported function is callable with a non-string `key` (Story 4.1 review, LOW-3): the raw
46
- // value leaked into `RouteEdge.from`, typed `string`, and a route to step `5` was reported as a dead end because
47
- // `known` held the number while the route text was `'5'`. `workerFlow` filters these out; a direct caller cannot.
48
- const known = new Set(steps.map((s) => String(s.key)));
49
- const edges = [];
50
- const walk = (from, value, label) => {
51
- /**
52
- * Branch objects already entered on THIS step's walk — the cycle guard.
53
- *
54
- * ⛔ Added at the Epic 4 close (2026-08-12). `routeGraph.ts` and the frontend twin both carry this guard, with the
55
- * reason recorded: a cyclic branch does not loop, it **kills the process** with an uncatchable V8 fatal, and this
56
- * code is bundled into the VS Code extension host. This walker never received it, and it is the one the
57
- * extension's fallback SVG still consumes on every preview — so the guarded packages closed the hole on the new
58
- * path and left it open on the shipped one.
59
- *
60
- * Measured: `const a = {}; a.then = a;` walked through here under `--max-old-space-size=200` gives
61
- * `FATAL ERROR: … heap out of memory`, process aborted. A `try/catch` around the preview does not help.
62
- *
63
- * REACHABLE FROM YAML with the parser the CLI already uses — a recursive anchor is all it takes:
64
- *
65
- * ```yaml
66
- * next: &loop
67
- * if: "x"
68
- * then: *loop
69
- * ```
70
- *
71
- * Identity, not path: the same object reached twice is the cycle, however long the path to it.
72
- */
73
- const entered = new WeakSet();
74
- const stack = [
75
- { value, ...(label !== undefined ? { label } : {}) },
76
- ];
77
- while (stack.length > 0) {
78
- const { value: node, label: current } = stack.pop();
79
- if (node === null || node === undefined || node === '')
80
- continue;
81
- const labelled = current !== undefined ? { label: current } : {};
82
- if (typeof node === 'object' && !Array.isArray(node)) {
83
- if (entered.has(node))
84
- continue;
85
- entered.add(node);
86
- const branch = node;
87
- // `else` pushed first so `then` is walked first — a reader expects YES before NO.
88
- stack.push({ value: branch.else, label: 'NO' });
89
- stack.push({ value: branch.then, label: 'YES' });
90
- continue;
91
- }
92
- const text = String(node);
93
- if (known.has(text)) {
94
- edges.push({ from, to: text, ...labelled });
95
- continue;
96
- }
97
- if (looksLikeExpression(text)) {
98
- const targets = quotedKeys(text).filter((k) => known.has(k));
99
- for (const target of targets) {
100
- edges.push({ from, to: target, raw: text, ...labelled });
101
- }
102
- // Resolving to nothing is still a route, and the expression is the only thing that can be shown about it.
103
- if (targets.length === 0)
104
- edges.push({ from, raw: text, ...labelled });
105
- continue;
106
- }
107
- // Names no step in this stage. Kept so the reader sees the dead end.
108
- edges.push({ from, raw: text, ...labelled });
109
- }
110
- };
111
- for (const rawStep of steps) {
112
- const step = { ...rawStep, key: String(rawStep.key) };
113
- const type = String(step.stepType ?? '').toUpperCase();
114
- const data = step.data && typeof step.data === 'object' && !Array.isArray(step.data)
115
- ? step.data
116
- : undefined;
117
- if (type === 'IF' && data) {
118
- // `IfStepExecutor` passes `StepData` to the builder, so an IF routes from its `data`.
119
- if (data.then !== null && data.then !== undefined) {
120
- walk(step.key, data.then, 'YES');
121
- }
122
- if (data.else !== null && data.else !== undefined) {
123
- walk(step.key, data.else, 'NO');
124
- }
125
- // An IF declaring neither branch falls back to `next` — otherwise a partly-written IF loses its only edge.
126
- if ((data.then === null || data.then === undefined) &&
127
- (data.else === null || data.else === undefined)) {
128
- walk(step.key, step.next);
129
- }
130
- }
131
- else if (type === 'SWITCH' && data) {
132
- // A SWITCH's branches are its `data` KEYS, each labelled with itself.
133
- for (const branch of Object.keys(data))
134
- walk(step.key, branch, branch);
135
- }
136
- else {
137
- walk(step.key, step.next);
138
- }
139
- if (step.onError !== null && step.onError !== undefined) {
140
- walk(step.key, step.onError, 'onError');
141
- }
142
- /**
143
- * The exception BACK-REFERENCE — an edge INTO this step, from the one that threw.
144
- *
145
- * Reversed relative to every other kind, which is why a renderer that owned routing kept forgetting it. Only
146
- * drawn when `fromStep` names a step in this stage: an exception handler pointing outside its own stage is a
147
- * document error, and inventing a node for it would draw a step the stage does not contain.
148
- */
149
- if (step.fromStep && known.has(step.fromStep)) {
150
- edges.push({ from: step.fromStep, to: step.key, label: 'Exception' });
151
- }
152
- }
153
- return edges;
154
- }
155
- //# sourceMappingURL=routes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routes.js","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAkCH,6CAA6C;AAC7C,MAAM,UAAU,UAAU,CAAC,UAAkB;IAC3C,OAAO,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC;AAC1E,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,OAAO,CACL,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAC3E,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,KAA8B;IAE9B,iHAAiH;IACjH,iHAAiH;IACjH,kHAAkH;IAClH,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACvD,MAAM,KAAK,GAAgB,EAAE,CAAC;IAE9B,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,KAAc,EAAE,KAAc,EAAQ,EAAE;QAClE;;;;;;;;;;;;;;;;;;;;;WAqBG;Q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AAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC1C,CAAC;QAED;;;;;;WAMG;QACH,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9C,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/stages.d.ts DELETED
@@ -1,112 +0,0 @@
1
- /**
2
- * A worker component's stages, and the arrows between the ones it actually has — Story 4.1 AC-1.
3
- *
4
- * ### Three shapes, one vocabulary
5
- *
6
- * A pusher, a **legacy** puller (`beforePullSteps`/`pullSteps`/`afterPullSteps`) and a **steps-based** puller
7
- * (`steps`/`onErrorSteps`/`finalSteps`). Two vocabularies existed before this and they disagreed three ways; each
8
- * disagreement is settled below by evidence rather than preference.
9
- *
10
- * **1. PRESENCE decides the shape, not a flag.** The CLI's `provenance.ts` picks between two stage lists using a
11
- * `newKind` boolean. AC-1 says stage edges come from *"the stages actually present"*, and a boolean is a second
12
- * source of truth for something the document already states by having the key. The extension's structure — one list
13
- * per collection, presence deciding — is adopted. It also lets both puller kinds be listed together, which only
14
- * works because the new kind's main stage is named `steps` outright and so cannot collide with the legacy three.
15
- *
16
- * **2. ⛔ A pusher DOES have `finalSteps` — this decision was WRONG and is reversed.** The original reasoning is kept
17
- * below because the way it failed is instructive:
18
- *
19
- * > *"`assets/pushers/pusher.json` declares exactly `beforePushSteps`, `pushSteps`, `afterPushSteps`. The extension's
20
- * > `STAGE_ORDER` lists a fourth, so it carries a stage that can never populate — a third vocabulary disagreeing with
21
- * > the one authority. Dropped. Measured, so the drop costs nothing: 0 authored corpus pushers declare `finalSteps`."*
22
- *
23
- * The schema was treated as the authority, and the schema was itself wrong. **`PushStepAccessor` reads
24
- * `$.finalSteps[*]` → `StepType.Final`** — the RUNTIME runs the stage. So the "third vocabulary" was the only one
25
- * telling the truth, and the corpus count of 0 measured what authors could express through tooling that denied the
26
- * stage, not what the platform supports. `WORKER_STAGES.pushers` declares it (Story 4.5 review, H2), and by Story 4.7
27
- * the same omission had been found in **five** independent places, dashboard's `pusherPhases()` last.
28
- *
29
- * The transferable rule: **when a schema and the runtime disagree, the runtime is the authority.** A schema is a claim
30
- * about the runtime and can be stale; `PushStepAccessor` is the thing that actually runs.
31
- *
32
- * **3. `label` and `phase` are carried.** A renderer needs a human label, and `phase` is what tells an error stage
33
- * from a sequence stage without string-matching the key. The CLI has neither and its report is poorer for it.
34
- *
35
- * ### ⚠️ The steps-based puller is exercised by NOTHING real
36
- *
37
- * Measured over the authored corpus (`output.yaml` excluded), counting array-valued stage keys on every `pullers[]`
38
- * and `pushers[]` entry:
39
- *
40
- * | stage | authored occurrences |
41
- * | --- | --- |
42
- * | `pullSteps` / `beforePullSteps` / `afterPullSteps` | 970 / 715 / 509 |
43
- * | `pushSteps` / `beforePushSteps` / `afterPushSteps` | 925 / 756 / 767 |
44
- * | `steps` / `onErrorSteps` / `finalSteps` | **0 / 0 / 0** |
45
- *
46
- * Story 4.1 says `onErrorSteps` and `finalSteps` appear in zero corpus files. That is true and it understates the
47
- * position: **the whole steps-based kind has no authored instance anywhere**, so the shape is supported by the
48
- * tooling and exercised by nothing. Fixture `03` is the only exercise it gets, which makes it the fixture most
49
- * likely to drift and the one to treat as load-bearing rather than as an afterthought.
50
- */
51
- /** What a stage is FOR, so a renderer never has to string-match a key to find out. */
52
- export type StagePhase = 'sequence' | 'error' | 'final';
53
- /** One stage a component may declare. */
54
- export interface StageDefinition {
55
- /** The document key: `pullSteps`, `onErrorSteps`. */
56
- readonly key: string;
57
- /** For a human: `Before pull`. */
58
- readonly label: string;
59
- readonly phase: StagePhase;
60
- }
61
- /** The collections this package models. A frontend workflow is Story 4.2's, deliberately separate (AD-21). */
62
- export type WorkerCollection = 'pullers' | 'pushers';
63
- /**
64
- * Every stage each collection may declare, in run order.
65
- *
66
- * ⛔ These keys mirror `assets/pullers/puller.json` and `assets/pushers/pusher.json`, which are the authority.
67
- *
68
- * ⚠️ **Mirrored, not DERIVED, and Task 2 asked for derived** (Story 4.1 review, M5). Deriving would mean reading a
69
- * schema file, which AD-3 forbids this package from doing and NFR-4 forbids in the extension's host — so the schemas
70
- * are the authority for a *test*, not for the runtime value. `stageSchemaParity.spec.ts` asserts this table against
71
- * them in both directions, which is arguably stronger than derivation (it catches a stage the schema drops as well as
72
- * one the table invents); it is nonetheless a deviation from the task as written, and it is skippable when the
73
- * sibling repo is absent — which is why that spec also hardcodes the pusher expectation so something always runs.
74
- */
75
- export declare const WORKER_STAGES: Readonly<Record<WorkerCollection, readonly StageDefinition[]>>;
76
- /**
77
- * Which kind of puller a component is — reported, never used to CHOOSE the stage list.
78
- *
79
- * Worth having because a consumer may want to say so, and worth computing from presence: `legacy` and `steps` are
80
- * observations about the document, and `unknown` is the honest answer for a puller declaring no stage at all rather
81
- * than a guess at which kind it meant to be.
82
- */
83
- export type PullerKind = 'legacy' | 'steps' | 'unknown';
84
- export declare function pullerKindOf(component: Record<string, unknown>): PullerKind;
85
- /** The stages a component actually declares, in run order. */
86
- export declare function stagesPresent(collection: WorkerCollection, component: Record<string, unknown>): readonly StageDefinition[];
87
- /** One arrow between two stages. */
88
- export interface StageEdge {
89
- readonly from: string;
90
- readonly to: string;
91
- /** Absent for a plain sequence arrow; a renderer draws the label only where there is one. */
92
- readonly label?: string;
93
- }
94
- /**
95
- * The arrows between the stages a component HAS.
96
- *
97
- * Three rules, and the second and third are why this is not a `zip` of the ordered list:
98
- *
99
- * 1. **Sequence stages chain in order.** Computed from what is present, so a puller declaring only `pullSteps` has
100
- * **no stage edges at all** — which fixture 02's baseline records verbatim as *"stage edges: none"*. An arrow
101
- * into a stage that is not drawn points at nothing.
102
- * 2. **An `error` stage is reachable from EVERY sequence stage**, labelled, because that is what an error stage
103
- * means: any of them can fail into it. Drawing it as one more link in the chain would say the opposite — that it
104
- * runs after the last sequence stage, on success.
105
- * 3. **A `final` stage runs always**, from the last sequence stage and from the error stage, labelled `always`. It
106
- * is the one stage a component reaches whichever way the run ends.
107
- *
108
- * The labels are the extension's, which is the only implementation that has stage *semantics* rather than only
109
- * geometry.
110
- */
111
- export declare function stageEdges(collection: WorkerCollection, component: Record<string, unknown>): readonly StageEdge[];
112
- //# sourceMappingURL=stages.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stages.d.ts","sourceRoot":"","sources":["../src/stages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,sFAAsF;AACtF,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC;AAExD,yCAAyC;AACzC,MAAM,WAAW,eAAe;IAC9B,qDAAqD;IACrD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC5B;AAED,8GAA8G;AAC9G,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,CAAC;AAErD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAClC,MAAM,CAAC,gBAAgB,EAAE,SAAS,eAAe,EAAE,CAAC,CAmCrD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AA8BxD,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CAa3E;AAED,8DAA8D;AAC9D,wBAAgB,aAAa,CAC3B,UAAU,EAAE,gBAAgB,EAC5B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,SAAS,eAAe,EAAE,CAI5B;AAED,oCAAoC;AACpC,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,6FAA6F;IAC7F,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CACxB,UAAU,EAAE,gBAAgB,EAC5B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,SAAS,SAAS,EAAE,CAqBtB"}
package/dist/stages.js DELETED
@@ -1,178 +0,0 @@
1
- /**
2
- * A worker component's stages, and the arrows between the ones it actually has — Story 4.1 AC-1.
3
- *
4
- * ### Three shapes, one vocabulary
5
- *
6
- * A pusher, a **legacy** puller (`beforePullSteps`/`pullSteps`/`afterPullSteps`) and a **steps-based** puller
7
- * (`steps`/`onErrorSteps`/`finalSteps`). Two vocabularies existed before this and they disagreed three ways; each
8
- * disagreement is settled below by evidence rather than preference.
9
- *
10
- * **1. PRESENCE decides the shape, not a flag.** The CLI's `provenance.ts` picks between two stage lists using a
11
- * `newKind` boolean. AC-1 says stage edges come from *"the stages actually present"*, and a boolean is a second
12
- * source of truth for something the document already states by having the key. The extension's structure — one list
13
- * per collection, presence deciding — is adopted. It also lets both puller kinds be listed together, which only
14
- * works because the new kind's main stage is named `steps` outright and so cannot collide with the legacy three.
15
- *
16
- * **2. ⛔ A pusher DOES have `finalSteps` — this decision was WRONG and is reversed.** The original reasoning is kept
17
- * below because the way it failed is instructive:
18
- *
19
- * > *"`assets/pushers/pusher.json` declares exactly `beforePushSteps`, `pushSteps`, `afterPushSteps`. The extension's
20
- * > `STAGE_ORDER` lists a fourth, so it carries a stage that can never populate — a third vocabulary disagreeing with
21
- * > the one authority. Dropped. Measured, so the drop costs nothing: 0 authored corpus pushers declare `finalSteps`."*
22
- *
23
- * The schema was treated as the authority, and the schema was itself wrong. **`PushStepAccessor` reads
24
- * `$.finalSteps[*]` → `StepType.Final`** — the RUNTIME runs the stage. So the "third vocabulary" was the only one
25
- * telling the truth, and the corpus count of 0 measured what authors could express through tooling that denied the
26
- * stage, not what the platform supports. `WORKER_STAGES.pushers` declares it (Story 4.5 review, H2), and by Story 4.7
27
- * the same omission had been found in **five** independent places, dashboard's `pusherPhases()` last.
28
- *
29
- * The transferable rule: **when a schema and the runtime disagree, the runtime is the authority.** A schema is a claim
30
- * about the runtime and can be stale; `PushStepAccessor` is the thing that actually runs.
31
- *
32
- * **3. `label` and `phase` are carried.** A renderer needs a human label, and `phase` is what tells an error stage
33
- * from a sequence stage without string-matching the key. The CLI has neither and its report is poorer for it.
34
- *
35
- * ### ⚠️ The steps-based puller is exercised by NOTHING real
36
- *
37
- * Measured over the authored corpus (`output.yaml` excluded), counting array-valued stage keys on every `pullers[]`
38
- * and `pushers[]` entry:
39
- *
40
- * | stage | authored occurrences |
41
- * | --- | --- |
42
- * | `pullSteps` / `beforePullSteps` / `afterPullSteps` | 970 / 715 / 509 |
43
- * | `pushSteps` / `beforePushSteps` / `afterPushSteps` | 925 / 756 / 767 |
44
- * | `steps` / `onErrorSteps` / `finalSteps` | **0 / 0 / 0** |
45
- *
46
- * Story 4.1 says `onErrorSteps` and `finalSteps` appear in zero corpus files. That is true and it understates the
47
- * position: **the whole steps-based kind has no authored instance anywhere**, so the shape is supported by the
48
- * tooling and exercised by nothing. Fixture `03` is the only exercise it gets, which makes it the fixture most
49
- * likely to drift and the one to treat as load-bearing rather than as an afterthought.
50
- */
51
- /**
52
- * Every stage each collection may declare, in run order.
53
- *
54
- * ⛔ These keys mirror `assets/pullers/puller.json` and `assets/pushers/pusher.json`, which are the authority.
55
- *
56
- * ⚠️ **Mirrored, not DERIVED, and Task 2 asked for derived** (Story 4.1 review, M5). Deriving would mean reading a
57
- * schema file, which AD-3 forbids this package from doing and NFR-4 forbids in the extension's host — so the schemas
58
- * are the authority for a *test*, not for the runtime value. `stageSchemaParity.spec.ts` asserts this table against
59
- * them in both directions, which is arguably stronger than derivation (it catches a stage the schema drops as well as
60
- * one the table invents); it is nonetheless a deviation from the task as written, and it is skippable when the
61
- * sibling repo is absent — which is why that spec also hardcodes the pusher expectation so something always runs.
62
- */
63
- export const WORKER_STAGES = {
64
- pullers: [
65
- { key: 'beforePullSteps', label: 'Before pull', phase: 'sequence' },
66
- { key: 'pullSteps', label: 'Pull', phase: 'sequence' },
67
- { key: 'afterPullSteps', label: 'After pull', phase: 'sequence' },
68
- // The steps-based kind's main stage. Named `steps` outright, which is why both kinds can share one list.
69
- { key: 'steps', label: 'Steps', phase: 'sequence' },
70
- { key: 'onErrorSteps', label: 'On error', phase: 'error' },
71
- { key: 'finalSteps', label: 'Final', phase: 'final' },
72
- ],
73
- pushers: [
74
- { key: 'beforePushSteps', label: 'Before push', phase: 'sequence' },
75
- { key: 'pushSteps', label: 'Push', phase: 'sequence' },
76
- { key: 'afterPushSteps', label: 'After push', phase: 'sequence' },
77
- /**
78
- * ⛔ ABSENT until Story 4.5's review (H2), and the worker has always run it.
79
- *
80
- * `hexasync.api/Pushers/PushStepAccessor.cs:50` reads `$.finalSteps[*]` for `StepType.Final`, and the enum's own
81
- * comment says *"`finalSteps` (StepType.Final) is shared with the old-kind puller and runs in the finally"* — shared
82
- * with the PUSHER as well. The pullers list above has carried it since Story 4.1; this one did not, so a pusher
83
- * declaring only `finalSteps` produced a model with ZERO nodes and the extension's preview drew no chart at all
84
- * while still printing a Flow heading.
85
- *
86
- * Found by putting the two stage lists side by side, which is what this epic is for: the extension's own
87
- * `STAGE_ORDER.pushers` had it right. Four other places were wrong the same way — `provenance.ts`'s `FLOW_PHASES`
88
- * (so the composition report omitted the stage), `duplicates.ts` (duplicate keys there went unreported),
89
- * `reference.ts` (references there went unvalidated) and `flow.ts` (routing rules never saw it) — plus
90
- * `assets/pushers/pusher.json`, which did not declare the property at all.
91
- *
92
- * There is deliberately NO `onErrorSteps` here: `PushStepAccessor` has no `OnError` case, and `StepType.OnError` is
93
- * the steps-based puller's. A stage a pusher cannot run must not be drawable.
94
- */
95
- { key: 'finalSteps', label: 'Final', phase: 'final' },
96
- ],
97
- };
98
- const LEGACY_PULLER_STAGES = new Set([
99
- 'beforePullSteps',
100
- 'pullSteps',
101
- 'afterPullSteps',
102
- ]);
103
- const STEPS_PULLER_STAGES = new Set(['steps', 'onErrorSteps', 'finalSteps']);
104
- /**
105
- * An array-valued key **with something in it** — which is what AC-1's *"actually present"* means.
106
- *
107
- * ⚠️ REVERSED by the Story 4.1 review (MEDIUM-1). This read `Array.isArray` alone, with a docblock arguing that
108
- * *"an empty array counts: it was declared"*. Measured against the corpus, that argument costs **4,519** empty
109
- * stage arrays — `afterPushSteps: []` is the common one — each of which drew a stage arrow into a stage containing
110
- * nothing. That is precisely what `stageEdges`' own docblock forbids two paragraphs later: *"an arrow into a stage
111
- * that is not drawn points at nothing."* Declared-and-empty is a fact about the document; it is not a stage a
112
- * reader can be sent to.
113
- *
114
- * `pullerKindOf` uses the same predicate deliberately: a puller whose only `steps` key is `[]` has not told us
115
- * which kind it is, and `unknown` is the honest answer.
116
- */
117
- function declaresStage(component, key) {
118
- const value = component[key];
119
- return Array.isArray(value) && value.length > 0;
120
- }
121
- export function pullerKindOf(component) {
122
- const legacy = [...LEGACY_PULLER_STAGES].some((k) => declaresStage(component, k));
123
- const steps = [...STEPS_PULLER_STAGES].some((k) => declaresStage(component, k));
124
- // Both is possible in a malformed document. Reporting `steps` would hide the legacy stages a consumer can see, so
125
- // `unknown` is the answer that does not assert something the document contradicts.
126
- if (legacy && steps)
127
- return 'unknown';
128
- if (legacy)
129
- return 'legacy';
130
- if (steps)
131
- return 'steps';
132
- return 'unknown';
133
- }
134
- /** The stages a component actually declares, in run order. */
135
- export function stagesPresent(collection, component) {
136
- return WORKER_STAGES[collection].filter((stage) => declaresStage(component, stage.key));
137
- }
138
- /**
139
- * The arrows between the stages a component HAS.
140
- *
141
- * Three rules, and the second and third are why this is not a `zip` of the ordered list:
142
- *
143
- * 1. **Sequence stages chain in order.** Computed from what is present, so a puller declaring only `pullSteps` has
144
- * **no stage edges at all** — which fixture 02's baseline records verbatim as *"stage edges: none"*. An arrow
145
- * into a stage that is not drawn points at nothing.
146
- * 2. **An `error` stage is reachable from EVERY sequence stage**, labelled, because that is what an error stage
147
- * means: any of them can fail into it. Drawing it as one more link in the chain would say the opposite — that it
148
- * runs after the last sequence stage, on success.
149
- * 3. **A `final` stage runs always**, from the last sequence stage and from the error stage, labelled `always`. It
150
- * is the one stage a component reaches whichever way the run ends.
151
- *
152
- * The labels are the extension's, which is the only implementation that has stage *semantics* rather than only
153
- * geometry.
154
- */
155
- export function stageEdges(collection, component) {
156
- const present = stagesPresent(collection, component);
157
- const sequence = present.filter((s) => s.phase === 'sequence');
158
- const error = present.find((s) => s.phase === 'error');
159
- const final = present.find((s) => s.phase === 'final');
160
- const edges = [];
161
- for (let i = 0; i < sequence.length - 1; i += 1) {
162
- edges.push({ from: sequence[i].key, to: sequence[i + 1].key });
163
- }
164
- if (error) {
165
- for (const stage of sequence) {
166
- edges.push({ from: stage.key, to: error.key, label: 'on error' });
167
- }
168
- }
169
- if (final) {
170
- const last = sequence.at(-1);
171
- if (last)
172
- edges.push({ from: last.key, to: final.key, label: 'always' });
173
- if (error)
174
- edges.push({ from: error.key, to: final.key, label: 'always' });
175
- }
176
- return edges;
177
- }
178
- //# sourceMappingURL=stages.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stages.js","sourceRoot":"","sources":["../src/stages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAiBH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,aAAa,GAEtB;IACF,OAAO,EAAE;QACP,EAAE,GAAG,EAAE,iBAAiB,EAAE,KAAK,EAAE,aAAa,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