@beehexa/hexasync-template-worker-flow 2608.15.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.
package/dist/stages.js ADDED
@@ -0,0 +1,178 @@
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
@@ -0,0 +1 @@
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,EAAE,KAAK,EAAE,UAAU,EAAE;QACnE,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAA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AC;IACvD,MAAM,KAAK,GAAgB,EAAE,CAAC;IAE9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAE,CAAC,GAAG,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IACnE,CAAC;IACD,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;IACD,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACzE,IAAI,KAAK;YAAE,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@beehexa/hexasync-template-worker-flow",
3
+ "version": "2608.15.1",
4
+ "description": "The flow model for a worker component — pullers and pushers, computed once for every consumer.",
5
+ "license": "SEE LICENSE IN ../../LICENSE",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ }
12
+ },
13
+ "main": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "typecheck": "tsc --noEmit",
20
+ "build": "tsc -p tsconfig.build.json"
21
+ },
22
+ "dependencies": {
23
+ "@beehexa/hexasync-template-model": "2608.15.1"
24
+ },
25
+ "hexasync": {
26
+ "layer": "core"
27
+ },
28
+ "devDependencies": {
29
+ "yaml": "^2.8.0"
30
+ }
31
+ }