@beehexa/hexasync-template-validate 2608.7.4
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/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/validate/buildValidationModel.d.ts +31 -0
- package/dist/validate/buildValidationModel.d.ts.map +1 -0
- package/dist/validate/buildValidationModel.js +68 -0
- package/dist/validate/buildValidationModel.js.map +1 -0
- package/dist/validate/context.d.ts +97 -0
- package/dist/validate/context.d.ts.map +1 -0
- package/dist/validate/context.js +90 -0
- package/dist/validate/context.js.map +1 -0
- package/dist/validate/contextFromGraph.d.ts +60 -0
- package/dist/validate/contextFromGraph.d.ts.map +1 -0
- package/dist/validate/contextFromGraph.js +77 -0
- package/dist/validate/contextFromGraph.js.map +1 -0
- package/dist/validate/harvestPullerTaskIds.d.ts +60 -0
- package/dist/validate/harvestPullerTaskIds.d.ts.map +1 -0
- package/dist/validate/harvestPullerTaskIds.js +115 -0
- package/dist/validate/harvestPullerTaskIds.js.map +1 -0
- package/dist/validate/model.d.ts +14 -0
- package/dist/validate/model.d.ts.map +1 -0
- package/dist/validate/model.js +92 -0
- package/dist/validate/model.js.map +1 -0
- package/dist/validate/registry.d.ts +20 -0
- package/dist/validate/registry.d.ts.map +1 -0
- package/dist/validate/registry.js +58 -0
- package/dist/validate/registry.js.map +1 -0
- package/dist/validate/rule.d.ts +18 -0
- package/dist/validate/rule.d.ts.map +1 -0
- package/dist/validate/rule.js +2 -0
- package/dist/validate/rule.js.map +1 -0
- package/dist/validate/ruleCatalog.d.ts +22 -0
- package/dist/validate/ruleCatalog.d.ts.map +1 -0
- package/dist/validate/ruleCatalog.js +263 -0
- package/dist/validate/ruleCatalog.js.map +1 -0
- package/dist/validate/rules/dependencyIntegrity.d.ts +60 -0
- package/dist/validate/rules/dependencyIntegrity.d.ts.map +1 -0
- package/dist/validate/rules/dependencyIntegrity.js +296 -0
- package/dist/validate/rules/dependencyIntegrity.js.map +1 -0
- package/dist/validate/rules/duplicates.d.ts +23 -0
- package/dist/validate/rules/duplicates.d.ts.map +1 -0
- package/dist/validate/rules/duplicates.js +321 -0
- package/dist/validate/rules/duplicates.js.map +1 -0
- package/dist/validate/rules/flow.d.ts +41 -0
- package/dist/validate/rules/flow.d.ts.map +1 -0
- package/dist/validate/rules/flow.js +559 -0
- package/dist/validate/rules/flow.js.map +1 -0
- package/dist/validate/rules/overwriteLoss.d.ts +23 -0
- package/dist/validate/rules/overwriteLoss.d.ts.map +1 -0
- package/dist/validate/rules/overwriteLoss.js +40 -0
- package/dist/validate/rules/overwriteLoss.js.map +1 -0
- package/dist/validate/rules/pullerKind.d.ts +3 -0
- package/dist/validate/rules/pullerKind.d.ts.map +1 -0
- package/dist/validate/rules/pullerKind.js +83 -0
- package/dist/validate/rules/pullerKind.js.map +1 -0
- package/dist/validate/rules/reference.d.ts +44 -0
- package/dist/validate/rules/reference.d.ts.map +1 -0
- package/dist/validate/rules/reference.js +370 -0
- package/dist/validate/rules/reference.js.map +1 -0
- package/dist/validate/rules/referenceKind.d.ts +25 -0
- package/dist/validate/rules/referenceKind.d.ts.map +1 -0
- package/dist/validate/rules/referenceKind.js +230 -0
- package/dist/validate/rules/referenceKind.js.map +1 -0
- package/dist/validate/rules/retiredType.d.ts +142 -0
- package/dist/validate/rules/retiredType.d.ts.map +1 -0
- package/dist/validate/rules/retiredType.js +228 -0
- package/dist/validate/rules/retiredType.js.map +1 -0
- package/dist/validate/rules/tables.d.ts +8 -0
- package/dist/validate/rules/tables.d.ts.map +1 -0
- package/dist/validate/rules/tables.js +116 -0
- package/dist/validate/rules/tables.js.map +1 -0
- package/dist/validate/rules/variableDrift.d.ts +63 -0
- package/dist/validate/rules/variableDrift.d.ts.map +1 -0
- package/dist/validate/rules/variableDrift.js +132 -0
- package/dist/validate/rules/variableDrift.js.map +1 -0
- package/dist/validate/rules/variables.d.ts +12 -0
- package/dist/validate/rules/variables.d.ts.map +1 -0
- package/dist/validate/rules/variables.js +207 -0
- package/dist/validate/rules/variables.js.map +1 -0
- package/dist/validate/sourceLocator.d.ts +32 -0
- package/dist/validate/sourceLocator.d.ts.map +1 -0
- package/dist/validate/sourceLocator.js +166 -0
- package/dist/validate/sourceLocator.js.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
import { isNewKindPuller, stepType as stepKind, } from '../harvestPullerTaskIds.js';
|
|
2
|
+
function arr(cnf, key) {
|
|
3
|
+
const v = cnf?.[key];
|
|
4
|
+
return Array.isArray(v) ? v : [];
|
|
5
|
+
}
|
|
6
|
+
function isDynamic(v) {
|
|
7
|
+
return typeof v === 'string' && /\{\{[\s\S]*\}\}/.test(v);
|
|
8
|
+
}
|
|
9
|
+
// blank = unset for routing purposes (null/undefined or an empty/whitespace string).
|
|
10
|
+
function isBlank(v) {
|
|
11
|
+
return v == null || (typeof v === 'string' && v.trim() === '');
|
|
12
|
+
}
|
|
13
|
+
/** Every real step key in an array. Used to mark EACH step of an independently-scheduled
|
|
14
|
+
* phase (onErrorSteps / finalSteps) as a valid graph entry (F4): those phases are step
|
|
15
|
+
* lists the engine runs in sequence (with next/branch control flow), so a step that is
|
|
16
|
+
* not the head — and is reached only by fall-through, not a `next` edge — is still
|
|
17
|
+
* legitimately reachable and must not be reported as a FLOW-3 orphan. */
|
|
18
|
+
function allStepKeys(steps) {
|
|
19
|
+
const a = Array.isArray(steps) ? steps : [];
|
|
20
|
+
const out = [];
|
|
21
|
+
for (const s of a)
|
|
22
|
+
if (s && typeof s === 'object' && s.key != null)
|
|
23
|
+
out.push(String(s.key));
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
/** True when the puller declares a loop bound at the PULLER level (`maxIterations`). A
|
|
27
|
+
* step-level bound is NOT considered here (F3): a step's maxIterations only counts when
|
|
28
|
+
* the step is ON the cycle path, which analyzeWorkflow decides against `cycleSet` — a
|
|
29
|
+
* bound on some unrelated step in another phase must not satisfy an unrelated cycle. */
|
|
30
|
+
function pullerHasMaxIterations(p) {
|
|
31
|
+
return p?.maxIterations != null && String(p.maxIterations).trim() !== '';
|
|
32
|
+
}
|
|
33
|
+
/** True when a step is an UPDATE_TASK_DATA_STATUS removal recipe (statusToAdd → Removed). */
|
|
34
|
+
function isRemovalSweep(s) {
|
|
35
|
+
if (stepKind(s) !== 'UPDATE_TASK_DATA_STATUS')
|
|
36
|
+
return false;
|
|
37
|
+
const raw = s?.statusToAdd ?? s?.data?.statusToAdd;
|
|
38
|
+
const list = Array.isArray(raw) ? raw : raw != null ? [raw] : [];
|
|
39
|
+
return list.some((x) => String(x).toLowerCase() === 'removed');
|
|
40
|
+
}
|
|
41
|
+
/** Collect outgoing targets from a `next`-shaped value (string key, dynamic, or if/then/else). */
|
|
42
|
+
function nextTargets(next, into) {
|
|
43
|
+
if (isBlank(next))
|
|
44
|
+
return;
|
|
45
|
+
if (typeof next === 'string') {
|
|
46
|
+
into.push(isDynamic(next) ? { dynamic: true } : { key: next });
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (typeof next === 'object') {
|
|
50
|
+
const n = next;
|
|
51
|
+
nextTargets(n.then, into);
|
|
52
|
+
nextTargets(n.else, into);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Defects in a `next` TREE, per the step schema's own contract (reported 2026-08-06).
|
|
57
|
+
*
|
|
58
|
+
* `assets/steps/step.json` models `next` as `oneOf`, and `NextStepBuilder.ResolveNext` implements it:
|
|
59
|
+
*
|
|
60
|
+
* * a **string** — a step key, or a scriban expression that renders to one. The runtime transforms it and
|
|
61
|
+
* returns the result unless it parses as a nested conditional, so a string is a ROUTE and asks nothing;
|
|
62
|
+
* * an **object** `{ description?, if, then, else }` with **`required: ['if','then','else']`**, whose `then`
|
|
63
|
+
* and `else` each `$ref` back to `next` — so the two forms nest arbitrarily.
|
|
64
|
+
*
|
|
65
|
+
* An EMPTY branch is not a missing one: it resolves to the empty string, which is "no next step", and the flow
|
|
66
|
+
* ends there deliberately.
|
|
67
|
+
*
|
|
68
|
+
* So the rule is exactly what was reported: *"if there is `if`, then `then` and `else` are required; but if it
|
|
69
|
+
* is just a string, it is as is."* A string is a route and needs nothing; an object is a branch and needs all
|
|
70
|
+
* three, at every depth.
|
|
71
|
+
*
|
|
72
|
+
* Iterative, with an explicit stack: `then`/`else` recurse without bound and this walks authored data.
|
|
73
|
+
*
|
|
74
|
+
* Returns one entry per defective conditional — what is missing, and the `if` expression that identifies it,
|
|
75
|
+
* so a report can point at the line the defect is ON rather than at the step's first textual mention.
|
|
76
|
+
*/
|
|
77
|
+
function conditionalDefects(next) {
|
|
78
|
+
const out = [];
|
|
79
|
+
const stack = [next];
|
|
80
|
+
const seen = new Set();
|
|
81
|
+
while (stack.length > 0) {
|
|
82
|
+
const node = stack.pop();
|
|
83
|
+
// A STRING (or a blank) is a route, not a branch. Nothing is required of it — this is the false positive
|
|
84
|
+
// the report was about, in one line.
|
|
85
|
+
if (node == null || typeof node !== 'object' || Array.isArray(node))
|
|
86
|
+
continue;
|
|
87
|
+
if (seen.has(node))
|
|
88
|
+
continue;
|
|
89
|
+
seen.add(node);
|
|
90
|
+
const n = node;
|
|
91
|
+
/**
|
|
92
|
+
* All three keys are required — and an EMPTY one is not missing.
|
|
93
|
+
*
|
|
94
|
+
* Corrected against the runtime (`core.api/hexasync.steps/Execution/NextStepBuilder.cs`), which the report
|
|
95
|
+
* named as the authority. `ResolveNext` transforms a string branch and, when the result does not parse as
|
|
96
|
+
* a nested conditional, RETURNS it — so `else: ""` resolves to the empty string, which is "no next step":
|
|
97
|
+
* the flow ends there. That is a deliberate terminator and appears in the corpus as one.
|
|
98
|
+
*
|
|
99
|
+
* My first version of this rule tested `isBlank`, which would have reported every authored `else: ""` as
|
|
100
|
+
* a defect — the same false positive the report was about, reintroduced one layer down. The schema agrees
|
|
101
|
+
* with the runtime: all three keys are `required`, and `then`/`else` `$ref` a `next` whose string form has
|
|
102
|
+
* no minimum length.
|
|
103
|
+
*/
|
|
104
|
+
const missing = ['if', 'then', 'else'].filter((k) => !Object.prototype.hasOwnProperty.call(n, k));
|
|
105
|
+
if (missing.length > 0) {
|
|
106
|
+
out.push({
|
|
107
|
+
missing: [...missing],
|
|
108
|
+
...(typeof n.if === 'string' && n.if.trim() !== '' ? { at: n.if } : {}),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
stack.push(n.then, n.else);
|
|
112
|
+
}
|
|
113
|
+
return out;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Analyze one workflow's step array for graph-integrity problems (FLOW-3/4/5/6).
|
|
117
|
+
* Pure over the array; returns findings (attribution/rendering is the caller's job).
|
|
118
|
+
*
|
|
119
|
+
* Entry model matches the composer's own flowChart.ts: EVERY `rootStep: true` step is
|
|
120
|
+
* an entry node (multiple roots = multiple valid entry chains, a real pattern in shipped
|
|
121
|
+
* profiles); if none carry `rootStep`, the first step is the entry. There is intentionally
|
|
122
|
+
* NO "multiple roots" or "no root" finding — both are valid per the runtime.
|
|
123
|
+
*/
|
|
124
|
+
export function analyzeWorkflow(steps, opts = {}) {
|
|
125
|
+
const findings = [];
|
|
126
|
+
const valid = steps.filter((s) => s && typeof s === 'object');
|
|
127
|
+
if (valid.length === 0)
|
|
128
|
+
return findings;
|
|
129
|
+
const keyOf = (s) => (s.key != null ? String(s.key) : undefined);
|
|
130
|
+
// Step-type read (F2): match harvest/toFlowStep/isRemovalSweep, which all read
|
|
131
|
+
// `displayType ?? type ?? provider`, so a guard authored as `{type:'IF'}` gets its
|
|
132
|
+
// then/else edges built and every rule agrees on the same step. The `type` field is
|
|
133
|
+
// honoured ONLY for new-kind graphs — old-kind edge building stays byte-identical
|
|
134
|
+
// (old steps carry displayType/provider, never `type`, but we gate to be certain).
|
|
135
|
+
const typeOf = (s) => String((opts.newKind
|
|
136
|
+
? (s.displayType ?? s.type ?? s.provider)
|
|
137
|
+
: (s.displayType ?? s.provider)) ?? '');
|
|
138
|
+
const keySet = new Set();
|
|
139
|
+
for (const s of valid) {
|
|
140
|
+
const k = keyOf(s);
|
|
141
|
+
if (k != null)
|
|
142
|
+
keySet.add(k);
|
|
143
|
+
}
|
|
144
|
+
// Entries = all rootStep steps (like flowChart.ts); else the first step. Plus any
|
|
145
|
+
// caller-supplied extra entries (new-kind onErrorSteps / finalSteps heads, which run
|
|
146
|
+
// independently and so legitimately have no inbound `next` edge).
|
|
147
|
+
const entrySet = new Set();
|
|
148
|
+
for (const s of valid) {
|
|
149
|
+
if (s.rootStep === true) {
|
|
150
|
+
const k = keyOf(s);
|
|
151
|
+
if (k != null)
|
|
152
|
+
entrySet.add(k);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (entrySet.size === 0) {
|
|
156
|
+
const first = keyOf(valid[0]);
|
|
157
|
+
if (first != null)
|
|
158
|
+
entrySet.add(first);
|
|
159
|
+
}
|
|
160
|
+
for (const k of opts.extraEntryKeys ?? [])
|
|
161
|
+
if (keySet.has(k))
|
|
162
|
+
entrySet.add(k);
|
|
163
|
+
// Build outgoing edges per step (FIRST occurrence wins, matching keySet dedupe).
|
|
164
|
+
const edges = new Map();
|
|
165
|
+
// Exception steps (new-kind): an `EXCEPTION` step (or any step carrying `fromStep`)
|
|
166
|
+
// is entered when its `fromStep` throws — a back-reference edge fromStep → this step.
|
|
167
|
+
const exceptionSteps = [];
|
|
168
|
+
let hasDynamic = false;
|
|
169
|
+
for (const s of valid) {
|
|
170
|
+
const sk = keyOf(s);
|
|
171
|
+
if (sk == null || edges.has(sk))
|
|
172
|
+
continue;
|
|
173
|
+
const targets = [];
|
|
174
|
+
const dt = typeOf(s);
|
|
175
|
+
if (dt === 'SWITCH') {
|
|
176
|
+
const data = s.data;
|
|
177
|
+
const branchKeys = data && typeof data === 'object' && !Array.isArray(data)
|
|
178
|
+
? Object.keys(data)
|
|
179
|
+
: [];
|
|
180
|
+
if (branchKeys.length === 0) {
|
|
181
|
+
findings.push({
|
|
182
|
+
ruleId: 'FLOW-6',
|
|
183
|
+
severity: 'medium',
|
|
184
|
+
message: `SWITCH step "${sk}" has no branches`,
|
|
185
|
+
locateValue: sk,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
for (const bk of branchKeys)
|
|
189
|
+
targets.push({ key: bk });
|
|
190
|
+
}
|
|
191
|
+
else if (dt === 'IF') {
|
|
192
|
+
const data = s.data;
|
|
193
|
+
const then = data && typeof data === 'object' ? data.then : undefined;
|
|
194
|
+
const els = data && typeof data === 'object' ? data.else : undefined;
|
|
195
|
+
/**
|
|
196
|
+
* An IF step's `data` IS its conditional next — verified in the runtime, not inferred.
|
|
197
|
+
*
|
|
198
|
+
* `IfStepExecutor.ExecuteAsync` passes `StepData` — the step's own `data` block — straight into
|
|
199
|
+
* `NextStepBuilder.BuildWithTrace`. So `data: { if, then, else }` is resolved by exactly the same
|
|
200
|
+
* `ResolveNext` walk as a `next:` object, and the two forms are one thing wearing two names.
|
|
201
|
+
*
|
|
202
|
+
* A branch may therefore live in `data` or on `next`, and an EMPTY branch is a terminator rather than a
|
|
203
|
+
* defect (see `conditionalDefects`). What remains worth reporting is a step that declares no routing at
|
|
204
|
+
* all: no `next`, and no `then`/`else` keys in `data`.
|
|
205
|
+
*/
|
|
206
|
+
const dataObject = data && typeof data === 'object' && !Array.isArray(data)
|
|
207
|
+
? data
|
|
208
|
+
: undefined;
|
|
209
|
+
const declaresBranch = dataObject !== undefined &&
|
|
210
|
+
(Object.prototype.hasOwnProperty.call(dataObject, 'then') ||
|
|
211
|
+
Object.prototype.hasOwnProperty.call(dataObject, 'else'));
|
|
212
|
+
if (!declaresBranch && isBlank(s.next)) {
|
|
213
|
+
findings.push({
|
|
214
|
+
ruleId: 'FLOW-6',
|
|
215
|
+
severity: 'medium',
|
|
216
|
+
message: `IF step "${sk}" routes nowhere — no \`next\`, and no \`then\`/\`else\``,
|
|
217
|
+
locateValue: sk,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
// The SAME contract as a `next:` object, because it is the same structure — one missing key, reported
|
|
221
|
+
// once, wherever the conditional was written.
|
|
222
|
+
for (const defect of conditionalDefects(dataObject)) {
|
|
223
|
+
findings.push({
|
|
224
|
+
ruleId: 'FLOW-6',
|
|
225
|
+
severity: 'medium',
|
|
226
|
+
message: `IF step "${sk}" is missing ` +
|
|
227
|
+
defect.missing.map((k) => `\`${k}\``).join(' and '),
|
|
228
|
+
locateValue: defect.at ?? sk,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
nextTargets(then, targets);
|
|
232
|
+
nextTargets(els, targets);
|
|
233
|
+
nextTargets(s.next, targets);
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
nextTargets(s.next, targets);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* The CONDITIONAL contract, for every step — the check the schema states and the rule never made.
|
|
240
|
+
*
|
|
241
|
+
* `next: { if, then, else }` requires all three at every depth. Reported as its own finding per defective
|
|
242
|
+
* conditional, and located by the `if` EXPRESSION rather than by the step key: the other half of the
|
|
243
|
+
* report was that the excerpt pointed at a `next:` line belonging to a different step, because a step key
|
|
244
|
+
* matches its first textual mention — usually somebody else's reference to it — long before its own
|
|
245
|
+
* declaration.
|
|
246
|
+
*/
|
|
247
|
+
for (const defect of conditionalDefects(s.next)) {
|
|
248
|
+
findings.push({
|
|
249
|
+
ruleId: 'FLOW-6',
|
|
250
|
+
severity: 'medium',
|
|
251
|
+
message: `step "${sk}" has a conditional \`next\` missing ` +
|
|
252
|
+
defect.missing.map((k) => `\`${k}\``).join(' and '),
|
|
253
|
+
locateValue: defect.at ?? sk,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
// New-kind per-step `onError` recovery edge (a step key to route to on failure).
|
|
257
|
+
// Inert for legacy steps (no `onError`), so old-kind graphs are unchanged.
|
|
258
|
+
nextTargets(s.onError, targets);
|
|
259
|
+
// Register EXCEPTION steps (or any step declaring `fromStep`) for the back-reference
|
|
260
|
+
// edge + FLOW-7 fromStep validation below.
|
|
261
|
+
if (dt.toUpperCase() === 'EXCEPTION' || s.fromStep != null) {
|
|
262
|
+
const fromStep = s.fromStep;
|
|
263
|
+
exceptionSteps.push({
|
|
264
|
+
key: sk,
|
|
265
|
+
fromStep: fromStep != null ? String(fromStep) : undefined,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
if (targets.some((t) => 'dynamic' in t))
|
|
269
|
+
hasDynamic = true;
|
|
270
|
+
edges.set(sk, targets);
|
|
271
|
+
}
|
|
272
|
+
// Exception back-reference edges: an EXCEPTION step is reached from its `fromStep`, so
|
|
273
|
+
// add fromStep → exceptionStep. This keeps the exception step from being a false orphan
|
|
274
|
+
// and lets a downstream throw be seen as routing into the handler.
|
|
275
|
+
for (const ex of exceptionSteps) {
|
|
276
|
+
if (ex.fromStep && keySet.has(ex.fromStep)) {
|
|
277
|
+
const t = edges.get(ex.fromStep) ?? [];
|
|
278
|
+
t.push({ key: ex.key });
|
|
279
|
+
edges.set(ex.fromStep, t);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
// FLOW-4 - dangling targets (attribute to the SOURCE step, which is locatable).
|
|
283
|
+
const danglingSeen = new Set();
|
|
284
|
+
for (const [sk, targets] of edges) {
|
|
285
|
+
for (const t of targets) {
|
|
286
|
+
if ('dynamic' in t || keySet.has(t.key))
|
|
287
|
+
continue;
|
|
288
|
+
const dedupe = `${sk}->${t.key}`;
|
|
289
|
+
if (danglingSeen.has(dedupe))
|
|
290
|
+
continue;
|
|
291
|
+
danglingSeen.add(dedupe);
|
|
292
|
+
findings.push({
|
|
293
|
+
ruleId: 'FLOW-4',
|
|
294
|
+
severity: 'high',
|
|
295
|
+
message: `step "${sk}" routes to missing step "${t.key}"`,
|
|
296
|
+
locateValue: sk,
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// In-degree over static, resolvable edges.
|
|
301
|
+
const inDegree = new Map();
|
|
302
|
+
for (const k of keySet)
|
|
303
|
+
inDegree.set(k, 0);
|
|
304
|
+
for (const targets of edges.values()) {
|
|
305
|
+
for (const t of targets) {
|
|
306
|
+
if ('dynamic' in t)
|
|
307
|
+
continue;
|
|
308
|
+
if (inDegree.has(t.key))
|
|
309
|
+
inDegree.set(t.key, inDegree.get(t.key) + 1);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
// FLOW-3 - orphan (a non-entry step with no incoming edge), once per key. Every
|
|
313
|
+
// rootStep is an entry, so extra roots are never flagged. Suppressed when the
|
|
314
|
+
// workflow has any dynamic next (a step could be reached dynamically).
|
|
315
|
+
if (!hasDynamic) {
|
|
316
|
+
for (const k of keySet) {
|
|
317
|
+
if (entrySet.has(k))
|
|
318
|
+
continue;
|
|
319
|
+
if ((inDegree.get(k) ?? 0) === 0) {
|
|
320
|
+
findings.push({
|
|
321
|
+
ruleId: 'FLOW-3',
|
|
322
|
+
severity: 'high',
|
|
323
|
+
message: `step "${k}" is unreachable (no incoming edge)`,
|
|
324
|
+
locateValue: k,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
// FLOW-5 - a static cycle (iterative DFS with an explicit stack; no recursion so a
|
|
330
|
+
// long chain can't overflow — mirrors reference.ts's cycle-safe walk precedent).
|
|
331
|
+
const color = new Map(); // 0 unseen, 1 in-stack, 2 done
|
|
332
|
+
let cycleAt;
|
|
333
|
+
let cycleStackKeys = [];
|
|
334
|
+
for (const start of keySet) {
|
|
335
|
+
if (color.get(start))
|
|
336
|
+
continue;
|
|
337
|
+
const stack = [{ key: start, i: 0 }];
|
|
338
|
+
color.set(start, 1);
|
|
339
|
+
while (stack.length) {
|
|
340
|
+
const frame = stack[stack.length - 1];
|
|
341
|
+
const targets = edges.get(frame.key) ?? [];
|
|
342
|
+
let advanced = false;
|
|
343
|
+
while (frame.i < targets.length) {
|
|
344
|
+
const t = targets[frame.i++];
|
|
345
|
+
if ('dynamic' in t || !keySet.has(t.key))
|
|
346
|
+
continue;
|
|
347
|
+
const c = color.get(t.key) ?? 0;
|
|
348
|
+
if (c === 1) {
|
|
349
|
+
cycleAt = t.key;
|
|
350
|
+
cycleStackKeys = stack.map((f) => f.key);
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
if (c === 0) {
|
|
354
|
+
color.set(t.key, 1);
|
|
355
|
+
stack.push({ key: t.key, i: 0 });
|
|
356
|
+
advanced = true;
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (cycleAt)
|
|
361
|
+
break;
|
|
362
|
+
if (!advanced) {
|
|
363
|
+
color.set(frame.key, 2);
|
|
364
|
+
stack.pop();
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (cycleAt)
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
if (cycleAt) {
|
|
371
|
+
if (!opts.newKind) {
|
|
372
|
+
// Old-kind: ANY back-edge is a potential infinite loop (byte-identical to before).
|
|
373
|
+
findings.push({
|
|
374
|
+
ruleId: 'FLOW-5',
|
|
375
|
+
severity: 'high',
|
|
376
|
+
message: `the workflow has a next-cycle through step "${cycleAt}" (risk of an infinite loop)`,
|
|
377
|
+
locateValue: cycleAt,
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
// New-kind (Story 7.4): a guarded pagination loop is VALID. A back-edge is only a
|
|
382
|
+
// finding when it is unguarded (no conditional on the cycle gates re-entry),
|
|
383
|
+
// inescapable (no conditional on the cycle has a branch that leaves the loop), or
|
|
384
|
+
// unbounded (no maxIterations governs the cycle).
|
|
385
|
+
const idxC = cycleStackKeys.indexOf(cycleAt);
|
|
386
|
+
const cycleSet = new Set(idxC >= 0 ? cycleStackKeys.slice(idxC) : cycleStackKeys);
|
|
387
|
+
// Guarded/escapable (F1): decided by the conditional(s) ON the cycle path, NOT by
|
|
388
|
+
// the back-edge's source step. A valid guard-at-top loop (guard IF → body → back to
|
|
389
|
+
// guard) has a non-IF back-edge owner but is still correctly gated by the IF; the
|
|
390
|
+
// old source-type test false-flagged it. A cycle is GUARDED when it contains an
|
|
391
|
+
// IF/SWITCH node, and ESCAPABLE when such a node has a branch that leaves the cycle
|
|
392
|
+
// — an explicit target outside cycleSet, or an implicit fall-through (a missing IF
|
|
393
|
+
// then/else, or a SWITCH with no default) that ends the loop when re-entry is not
|
|
394
|
+
// chosen.
|
|
395
|
+
let guarded = false;
|
|
396
|
+
let escapable = false;
|
|
397
|
+
for (const cs of valid) {
|
|
398
|
+
const ck = keyOf(cs);
|
|
399
|
+
if (ck == null || !cycleSet.has(ck))
|
|
400
|
+
continue;
|
|
401
|
+
const ct = typeOf(cs).toUpperCase();
|
|
402
|
+
if (ct !== 'IF' && ct !== 'SWITCH')
|
|
403
|
+
continue;
|
|
404
|
+
guarded = true;
|
|
405
|
+
const csTargets = edges.get(ck) ?? [];
|
|
406
|
+
const hasExitTarget = csTargets.some((t) => !('dynamic' in t) && keySet.has(t.key) && !cycleSet.has(t.key));
|
|
407
|
+
let implicitExit = false;
|
|
408
|
+
const d = cs.data;
|
|
409
|
+
if (ct === 'IF') {
|
|
410
|
+
const hasThen = d && typeof d === 'object' && !isBlank(d.then);
|
|
411
|
+
const hasElse = d && typeof d === 'object' && !isBlank(d.else);
|
|
412
|
+
implicitExit = !(hasThen && hasElse);
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
const hasDefault = d && typeof d === 'object' && !isBlank(d.default);
|
|
416
|
+
implicitExit = !hasDefault;
|
|
417
|
+
}
|
|
418
|
+
if (hasExitTarget || implicitExit) {
|
|
419
|
+
escapable = true;
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
// Bounded (F3): a maxIterations governs THIS cycle only when declared at the puller
|
|
424
|
+
// level (opts.hasMaxIterations) OR on a step that is ON the cycle path — a bound on
|
|
425
|
+
// some unrelated step in another phase must not satisfy this cycle.
|
|
426
|
+
const cycleStepBound = valid.some((s) => {
|
|
427
|
+
const sk2 = keyOf(s);
|
|
428
|
+
if (sk2 == null || !cycleSet.has(sk2))
|
|
429
|
+
return false;
|
|
430
|
+
const m = s?.maxIterations ?? s?.data?.maxIterations;
|
|
431
|
+
return m != null && String(m).trim() !== '';
|
|
432
|
+
});
|
|
433
|
+
const bounded = !!opts.hasMaxIterations || cycleStepBound;
|
|
434
|
+
if (!(guarded && escapable && bounded)) {
|
|
435
|
+
const reasons = [];
|
|
436
|
+
if (!guarded)
|
|
437
|
+
reasons.push('the back-edge is not guarded by a conditional');
|
|
438
|
+
else if (!escapable)
|
|
439
|
+
reasons.push('the loop has no reachable exit branch');
|
|
440
|
+
if (!bounded)
|
|
441
|
+
reasons.push('no maxIterations is declared');
|
|
442
|
+
findings.push({
|
|
443
|
+
ruleId: 'FLOW-5',
|
|
444
|
+
severity: 'high',
|
|
445
|
+
message: `the workflow loops back through step "${cycleAt}" — ${reasons.join('; ')} (risk of an unbounded loop)`,
|
|
446
|
+
locateValue: cycleAt,
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
// FLOW-7 (Story 7.5) — an Exception step whose `fromStep` names no existing step in the
|
|
452
|
+
// workflow. New-kind only (old-kind has no Exception steps).
|
|
453
|
+
if (opts.newKind) {
|
|
454
|
+
for (const ex of exceptionSteps) {
|
|
455
|
+
if (!ex.fromStep || !keySet.has(ex.fromStep)) {
|
|
456
|
+
findings.push({
|
|
457
|
+
ruleId: 'FLOW-7',
|
|
458
|
+
severity: 'high',
|
|
459
|
+
message: `Exception step "${ex.key}" fromStep "${ex.fromStep ?? ''}" names no existing step`,
|
|
460
|
+
locateValue: ex.key,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return findings;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Workflow graph-integrity rule (FLOW family). Runs analyzeWorkflow over every step
|
|
469
|
+
* array and attributes findings to the owning puller/pusher/webhook.
|
|
470
|
+
*/
|
|
471
|
+
export const flowRule = {
|
|
472
|
+
id: 'FLOW',
|
|
473
|
+
family: 'FLOW',
|
|
474
|
+
run(ctx) {
|
|
475
|
+
const cnf = ctx.tokenForm;
|
|
476
|
+
if (!cnf || typeof cnf !== 'object')
|
|
477
|
+
return [];
|
|
478
|
+
const issues = [];
|
|
479
|
+
const emit = (parentKey, idOrKey, label, f) => issues.push({
|
|
480
|
+
ruleId: f.ruleId,
|
|
481
|
+
family: 'FLOW',
|
|
482
|
+
severity: f.severity,
|
|
483
|
+
parentKey,
|
|
484
|
+
idOrKey,
|
|
485
|
+
message: `${label}: ${f.message}`,
|
|
486
|
+
why: 'the workflow does not execute as authored',
|
|
487
|
+
locateValue: f.locateValue,
|
|
488
|
+
});
|
|
489
|
+
const check = (steps, parentKey, idOrKey, label) => {
|
|
490
|
+
if (!Array.isArray(steps) || steps.length === 0)
|
|
491
|
+
return;
|
|
492
|
+
for (const f of analyzeWorkflow(steps))
|
|
493
|
+
emit(parentKey, idOrKey, label, f);
|
|
494
|
+
};
|
|
495
|
+
for (const p of arr(cnf, 'pullers')) {
|
|
496
|
+
const pid = p?.id != null ? String(p.id) : undefined;
|
|
497
|
+
if (isNewKindPuller(p)) {
|
|
498
|
+
// New-kind (Stories 7.3–7.5): steps / onErrorSteps / finalSteps form ONE graph —
|
|
499
|
+
// `onError` links steps → recovery, and `Exception.fromStep` links back into the
|
|
500
|
+
// main flow — so analyze the union. onErrorSteps / finalSteps heads are extra
|
|
501
|
+
// entries (scheduled independently, not reached by a `next` edge).
|
|
502
|
+
const combined = [
|
|
503
|
+
...arr(p, 'steps'),
|
|
504
|
+
...arr(p, 'onErrorSteps'),
|
|
505
|
+
...arr(p, 'finalSteps'),
|
|
506
|
+
];
|
|
507
|
+
// Every onErrorSteps / finalSteps step is a valid entry (F4): these phases are
|
|
508
|
+
// step lists the engine runs in sequence, so steps reached by fall-through (not a
|
|
509
|
+
// `next` edge) are legitimately reachable — marking them all as entries prevents
|
|
510
|
+
// spurious FLOW-3 orphans on a multi-headed phase.
|
|
511
|
+
const extraEntryKeys = [
|
|
512
|
+
...allStepKeys(p?.onErrorSteps),
|
|
513
|
+
...allStepKeys(p?.finalSteps),
|
|
514
|
+
];
|
|
515
|
+
for (const f of analyzeWorkflow(combined, {
|
|
516
|
+
newKind: true,
|
|
517
|
+
extraEntryKeys,
|
|
518
|
+
hasMaxIterations: pullerHasMaxIterations(p),
|
|
519
|
+
}))
|
|
520
|
+
emit('pullers', pid, 'steps', f);
|
|
521
|
+
// FLOW-7 (Story 7.5) — a removal-recipe UPDATE_TASK_DATA_STATUS
|
|
522
|
+
// (statusToAdd includes Removed) in finalSteps would sweep un-pulled pages on a
|
|
523
|
+
// partial/mid-loop run; it belongs in `steps`.
|
|
524
|
+
for (const s of arr(p, 'finalSteps')) {
|
|
525
|
+
if (!s || typeof s !== 'object' || !isRemovalSweep(s))
|
|
526
|
+
continue;
|
|
527
|
+
const key = s.key != null ? String(s.key) : '(step)';
|
|
528
|
+
emit('pullers', pid, 'finalSteps', {
|
|
529
|
+
ruleId: 'FLOW-7',
|
|
530
|
+
severity: 'high',
|
|
531
|
+
message: `removal step "${key}" (statusToAdd includes Removed) is in finalSteps — a partial run would sweep un-pulled pages`,
|
|
532
|
+
locateValue: key,
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
check(p?.beforePullSteps, 'pullers', pid, 'beforePullSteps');
|
|
538
|
+
check(p?.pullSteps, 'pullers', pid, 'pullSteps');
|
|
539
|
+
check(p?.afterPullSteps, 'pullers', pid, 'afterPullSteps');
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
for (const p of arr(cnf, 'pushers')) {
|
|
543
|
+
const pid = p?.id != null ? String(p.id) : undefined;
|
|
544
|
+
check(p?.beforePushSteps, 'pushers', pid, 'beforePushSteps');
|
|
545
|
+
check(p?.pushSteps, 'pushers', pid, 'pushSteps');
|
|
546
|
+
check(p?.afterPushSteps, 'pushers', pid, 'afterPushSteps');
|
|
547
|
+
}
|
|
548
|
+
for (const w of arr(cnf, 'webhooks')) {
|
|
549
|
+
const wid = w?.id != null ? String(w.id) : undefined;
|
|
550
|
+
const targets = w?.targets && typeof w.targets === 'object' && !Array.isArray(w.targets)
|
|
551
|
+
? w.targets
|
|
552
|
+
: {};
|
|
553
|
+
for (const [tk, t] of Object.entries(targets))
|
|
554
|
+
check(t?.pullSteps, 'webhooks', wid, `target ${tk} pullSteps`);
|
|
555
|
+
}
|
|
556
|
+
return issues;
|
|
557
|
+
},
|
|
558
|
+
};
|
|
559
|
+
//# sourceMappingURL=flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow.js","sourceRoot":"","sources":["../../../src/validate/rules/flow.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,eAAe,EACf,QAAQ,IAAI,QAAQ,GACrB,MAAM,4BAA4B,CAAC;AAEpC,SAAS,GAAG,CAAC,GAAQ,EAAE,GAAW;IAChC,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IACrB,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnC,CAAC;AAkBD,SAAS,SAAS,CAAC,CAAU;IAC3B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,qFAAqF;AACrF,SAAS,OAAO,CAAC,CAAU;IACzB,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACjE,CAAC;AAED;;;;0EAI0E;AAC1E,SAAS,WAAW,CAAC,KAAc;IACjC,MAAM,CAAC,GAAG,KAAK,C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E,gBAAgB,CAAC,CAAC;QAC7D,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE,CAAC;YACrC,MAAM,GAAG,GAAG,CAAC,EAAE,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACrD,MAAM,OAAO,GACX,CAAC,EAAE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;gBACtE,CAAC,CAAC,CAAC,CAAC,OAAO;gBACX,CAAC,CAAC,EAAE,CAAC;YACT,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAM,OAAO,CAAC;gBAChD,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inherited components dropped by a wholesale array overwrite (Phase 2 Story 1.9, FR-56).
|
|
3
|
+
*
|
|
4
|
+
* The only inheritance loss that leaves NOTHING to point at.
|
|
5
|
+
*
|
|
6
|
+
* The merge matches array elements by `id`/`key`. When an override array's items carry neither, it
|
|
7
|
+
* cannot match element-by-element, so it replaces the entire array — and every inherited component
|
|
8
|
+
* that array held is gone from the merged document. There is no `!` removal to read, no duplicate,
|
|
9
|
+
* no dangling reference: the components simply do not exist. Every other rule in this registry works
|
|
10
|
+
* by reading the composed document, and by construction none of them can see this.
|
|
11
|
+
*
|
|
12
|
+
* So the evidence has to come from the MERGE ITSELF, and AC 4 says to use the records that already
|
|
13
|
+
* exist rather than re-derive what was dropped. It is the same `OverwriteRecord` set the CLI's
|
|
14
|
+
* merge-integrity report has rendered all along; the editor now receives it through the merge's
|
|
15
|
+
* `onOverwrite` hook, because the index builds without the CLI's tracer.
|
|
16
|
+
*
|
|
17
|
+
* Only depth-0 records with `hadComponents` reach here — the collectors filter — because a nested
|
|
18
|
+
* id-less config array being replaced is ordinary customization and reporting it would bury the real
|
|
19
|
+
* case under noise.
|
|
20
|
+
*/
|
|
21
|
+
import type { ValidationRule } from '../rule.js';
|
|
22
|
+
export declare const overwriteLossRule: ValidationRule;
|
|
23
|
+
//# sourceMappingURL=overwriteLoss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overwriteLoss.d.ts","sourceRoot":"","sources":["../../../src/validate/rules/overwriteLoss.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIjD,eAAO,MAAM,iBAAiB,EAAE,cA4C/B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const overwriteLossRule = {
|
|
2
|
+
id: 'OVW',
|
|
3
|
+
family: 'OVW',
|
|
4
|
+
run(ctx) {
|
|
5
|
+
const issues = [];
|
|
6
|
+
for (const record of ctx.overwrites ?? []) {
|
|
7
|
+
// Defensive: the collectors filter already, and a caller supplying raw records must not get a
|
|
8
|
+
// finding for a nested config array replaced on purpose.
|
|
9
|
+
if (record.depth !== 0 || !record.hadComponents)
|
|
10
|
+
continue;
|
|
11
|
+
const dropped = (Array.isArray(record.oldValue) ? record.oldValue : [])
|
|
12
|
+
.filter((item) => !!item && typeof item === 'object')
|
|
13
|
+
.map((item) => item['id'] ?? item['key'])
|
|
14
|
+
.filter((id) => id !== undefined && id !== null)
|
|
15
|
+
.map((id) => String(id));
|
|
16
|
+
if (dropped.length === 0)
|
|
17
|
+
continue;
|
|
18
|
+
issues.push({
|
|
19
|
+
ruleId: 'OVW-1',
|
|
20
|
+
family: 'OVW',
|
|
21
|
+
// HIGH, not critical: the project may genuinely intend to replace the collection, and the
|
|
22
|
+
// rule cannot know. But it is not merely advisory either — the components are gone from what
|
|
23
|
+
// will deploy, and nothing else in the report says so.
|
|
24
|
+
severity: 'high',
|
|
25
|
+
parentKey: record.parentKey,
|
|
26
|
+
idOrKey: dropped[0],
|
|
27
|
+
message: `this file replaces the whole "${record.parentKey}" array, dropping ` +
|
|
28
|
+
`${dropped.length} inherited component(s): ${dropped.join(', ')}`,
|
|
29
|
+
why: "the override array's items declare no `id`, so the merge cannot match them against the " +
|
|
30
|
+
'inherited ones and replaces the entire array. The dropped components are absent from the ' +
|
|
31
|
+
'composed output with nothing left to point at — no `!` removal and no dangling reference. ' +
|
|
32
|
+
'Give the override items their `id` to merge onto the inherited components instead.',
|
|
33
|
+
sourceFile: record.sourceFile,
|
|
34
|
+
locateValue: record.parentKey,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return issues;
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=overwriteLoss.js.map
|