@beehexa/hexasync-template-validate 2608.20.18 → 2608.20.32
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 +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/validate/agentAnswers.d.ts +48 -0
- package/dist/validate/agentAnswers.d.ts.map +1 -0
- package/dist/validate/agentAnswers.js +84 -0
- package/dist/validate/agentAnswers.js.map +1 -0
- package/dist/validate/agentTools.d.ts +37 -0
- package/dist/validate/agentTools.d.ts.map +1 -0
- package/dist/validate/agentTools.js +141 -0
- package/dist/validate/agentTools.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 +117 -0
- package/dist/validate/context.d.ts.map +1 -0
- package/dist/validate/context.js +96 -0
- package/dist/validate/context.js.map +1 -0
- package/dist/validate/contextFromGraph.d.ts +70 -0
- package/dist/validate/contextFromGraph.d.ts.map +1 -0
- package/dist/validate/contextFromGraph.js +82 -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 +116 -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 +97 -0
- package/dist/validate/model.js.map +1 -0
- package/dist/validate/registry.d.ts +24 -0
- package/dist/validate/registry.d.ts.map +1 -0
- package/dist/validate/registry.js +105 -0
- package/dist/validate/registry.js.map +1 -0
- package/dist/validate/retrieve.d.ts +125 -0
- package/dist/validate/retrieve.d.ts.map +1 -0
- package/dist/validate/retrieve.js +272 -0
- package/dist/validate/retrieve.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 +492 -0
- package/dist/validate/ruleCatalog.js.map +1 -0
- package/dist/validate/rules/apiShape.d.ts +51 -0
- package/dist/validate/rules/apiShape.d.ts.map +1 -0
- package/dist/validate/rules/apiShape.js +150 -0
- package/dist/validate/rules/apiShape.js.map +1 -0
- package/dist/validate/rules/arguments.d.ts +3 -0
- package/dist/validate/rules/arguments.d.ts.map +1 -0
- package/dist/validate/rules/arguments.js +301 -0
- package/dist/validate/rules/arguments.js.map +1 -0
- package/dist/validate/rules/connectorIdentity.d.ts +3 -0
- package/dist/validate/rules/connectorIdentity.d.ts.map +1 -0
- package/dist/validate/rules/connectorIdentity.js +347 -0
- package/dist/validate/rules/connectorIdentity.js.map +1 -0
- package/dist/validate/rules/context.d.ts +42 -0
- package/dist/validate/rules/context.d.ts.map +1 -0
- package/dist/validate/rules/context.js +92 -0
- package/dist/validate/rules/context.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 +27 -0
- package/dist/validate/rules/duplicates.d.ts.map +1 -0
- package/dist/validate/rules/duplicates.js +337 -0
- package/dist/validate/rules/duplicates.js.map +1 -0
- package/dist/validate/rules/flow.d.ts +57 -0
- package/dist/validate/rules/flow.d.ts.map +1 -0
- package/dist/validate/rules/flow.js +714 -0
- package/dist/validate/rules/flow.js.map +1 -0
- package/dist/validate/rules/missingInclude.d.ts +27 -0
- package/dist/validate/rules/missingInclude.d.ts.map +1 -0
- package/dist/validate/rules/missingInclude.js +29 -0
- package/dist/validate/rules/missingInclude.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 +92 -0
- package/dist/validate/rules/pullerKind.js.map +1 -0
- package/dist/validate/rules/querySelect.d.ts +24 -0
- package/dist/validate/rules/querySelect.d.ts.map +1 -0
- package/dist/validate/rules/querySelect.js +102 -0
- package/dist/validate/rules/querySelect.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 +405 -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 +235 -0
- package/dist/validate/rules/referenceKind.js.map +1 -0
- package/dist/validate/rules/retiredType.d.ts +149 -0
- package/dist/validate/rules/retiredType.d.ts.map +1 -0
- package/dist/validate/rules/retiredType.js +235 -0
- package/dist/validate/rules/retiredType.js.map +1 -0
- package/dist/validate/rules/stepData.d.ts +122 -0
- package/dist/validate/rules/stepData.d.ts.map +1 -0
- package/dist/validate/rules/stepData.js +249 -0
- package/dist/validate/rules/stepData.js.map +1 -0
- package/dist/validate/rules/stepIterations.d.ts +49 -0
- package/dist/validate/rules/stepIterations.d.ts.map +1 -0
- package/dist/validate/rules/stepIterations.js +156 -0
- package/dist/validate/rules/stepIterations.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 +6 -6
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { isDynamic, isRefEmpty, makeTokenResolver, } from './reference.js';
|
|
2
|
+
import { NEW_KIND_PHASES } from '../harvestPullerTaskIds.js';
|
|
3
|
+
import { DIRECTIVE_KEYS } from '@beehexa/hexasync-template-compose';
|
|
4
|
+
function arr(cnf, key) {
|
|
5
|
+
const v = cnf?.[key];
|
|
6
|
+
return Array.isArray(v) ? v : [];
|
|
7
|
+
}
|
|
8
|
+
/** Count occurrences per key (from `keyOf`), returning only those with count > 1.
|
|
9
|
+
* Skips null / dynamic `{{…}}` / empty ids. */
|
|
10
|
+
function countDupes(items, keyOf) {
|
|
11
|
+
const counts = new Map();
|
|
12
|
+
for (const it of items) {
|
|
13
|
+
const raw = keyOf(it);
|
|
14
|
+
if (raw == null || isRefEmpty(raw) || isDynamic(raw))
|
|
15
|
+
continue;
|
|
16
|
+
// Only primitive ids count — a non-scalar id would coerce to "[object Object]"/""
|
|
17
|
+
// and produce a spurious "duplicate" (mirrors reference.ts's checkVal guard).
|
|
18
|
+
if (typeof raw !== 'string' && typeof raw !== 'number')
|
|
19
|
+
continue;
|
|
20
|
+
counts.set(String(raw), (counts.get(String(raw)) ?? 0) + 1);
|
|
21
|
+
}
|
|
22
|
+
const dupes = new Map();
|
|
23
|
+
for (const [k, c] of counts)
|
|
24
|
+
if (c > 1)
|
|
25
|
+
dupes.set(k, c);
|
|
26
|
+
return dupes;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Order-independent JSON, so two identical declarations that list their fields differently compare
|
|
30
|
+
* equal. Depth-bounded and non-mutating.
|
|
31
|
+
*
|
|
32
|
+
* Written here rather than reusing the composer's `sortKeysRecursively`, which looks like the same
|
|
33
|
+
* function and is not: it MUTATES its argument in place and, by its own comment, does not sort
|
|
34
|
+
* object keys at all. Calling it on a document would reorder the caller's arrays — and in the
|
|
35
|
+
* editor, where snapshots are deep-frozen, throw.
|
|
36
|
+
*/
|
|
37
|
+
function stableJson(value, resolve, depth = 0) {
|
|
38
|
+
if (depth > 12)
|
|
39
|
+
return '"…"';
|
|
40
|
+
// Tokens are RESOLVED before comparison, throughout the content and not only at the id.
|
|
41
|
+
//
|
|
42
|
+
// Skipping this produced a false positive on a real project, and it is the same mistake
|
|
43
|
+
// `makeTokenResolver` was written to prevent: `sample-profile` declares one connector with a
|
|
44
|
+
// literal `providerId` and another with `**SelfConnectorProviderId**` bound to that same GUID.
|
|
45
|
+
// Compared as token text the two look like diverging components, so the rule graded a harmless
|
|
46
|
+
// alias as data loss — on the only corpus case where it claimed harm.
|
|
47
|
+
if (typeof value === 'string')
|
|
48
|
+
return JSON.stringify(resolve(value));
|
|
49
|
+
if (value === null || typeof value !== 'object')
|
|
50
|
+
return JSON.stringify(value) ?? 'null';
|
|
51
|
+
if (Array.isArray(value))
|
|
52
|
+
return `[${value.map((v) => stableJson(v, resolve, depth + 1)).join(',')}]`;
|
|
53
|
+
const entries = Object.entries(value).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
54
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${stableJson(v, resolve, depth + 1)}`).join(',')}}`;
|
|
55
|
+
}
|
|
56
|
+
/** A component's content with its own identifier removed, so two names for one component match. */
|
|
57
|
+
function contentSignature(value, resolve) {
|
|
58
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
59
|
+
return stableJson(value ?? null, resolve);
|
|
60
|
+
const rest = {};
|
|
61
|
+
for (const [k, v] of Object.entries(value)) {
|
|
62
|
+
// `id`/`key` is the thing that DIFFERS in the case this exists to judge — two token names
|
|
63
|
+
// bound to one value. Comparing it would make every alias look like a distinct component.
|
|
64
|
+
if (k === 'id' || k === 'key')
|
|
65
|
+
continue;
|
|
66
|
+
rest[k] = v;
|
|
67
|
+
}
|
|
68
|
+
return stableJson(rest, resolve);
|
|
69
|
+
}
|
|
70
|
+
/** The token-form identifiers a collection declares, in document order, deduped. */
|
|
71
|
+
function declaredIds(collectionValue) {
|
|
72
|
+
const out = [];
|
|
73
|
+
const take = (raw, value) => {
|
|
74
|
+
if (raw == null || isRefEmpty(raw) || isDynamic(raw))
|
|
75
|
+
return;
|
|
76
|
+
// A non-scalar id would coerce to "[object Object]", and two of them would then look like
|
|
77
|
+
// duplicates of each other — the same guard, for the same reason, as `countDupes` above.
|
|
78
|
+
if (typeof raw !== 'string' && typeof raw !== 'number')
|
|
79
|
+
return;
|
|
80
|
+
// No empty-string check here: `isRefEmpty` already covers `''` and whitespace, so one was dead
|
|
81
|
+
// code that no mutation could make fail.
|
|
82
|
+
out.push({ id: String(raw), value });
|
|
83
|
+
};
|
|
84
|
+
if (Array.isArray(collectionValue)) {
|
|
85
|
+
for (const item of collectionValue) {
|
|
86
|
+
if (!item || typeof item !== 'object')
|
|
87
|
+
continue;
|
|
88
|
+
take(item.id ?? item.key, item);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else if (collectionValue && typeof collectionValue === 'object') {
|
|
92
|
+
// A map collection is keyed by its own keys — `objectAssociations`, `transformations`.
|
|
93
|
+
for (const [key, value] of Object.entries(collectionValue))
|
|
94
|
+
take(key, value);
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* DUP-1 — two DISTINCT component identities that resolve to the SAME id.
|
|
100
|
+
*
|
|
101
|
+
* The case the merge cannot collapse, and therefore the only top-level duplicate that reaches the
|
|
102
|
+
* composed document. `**SelfConnector**` and `**SelfConnectorId**` are different keys, so the merge
|
|
103
|
+
* keeps both; the variable pool binds both to one GUID, so `output.yaml` carries the same connector
|
|
104
|
+
* id twice and HexaSync sees one entity declared twice. Measured in the corpus: 4 projects, all
|
|
105
|
+
* `connectors`, every one of them a value-aliased pair.
|
|
106
|
+
*
|
|
107
|
+
* Sameness is judged by RESOLVED CONTENT, not by name, and that is the story's "unless it is the
|
|
108
|
+
* same component" clause read properly. All four corpus cases declare the same connector under two
|
|
109
|
+
* names: nothing is lost when one is dropped, so an error there would be crying wolf on 100% of the
|
|
110
|
+
* rule's real occurrences, which is how a rule gets switched off. A pair that genuinely DIFFERS is a
|
|
111
|
+
* different matter — one of the two declarations is silently discarded and its fields go with it —
|
|
112
|
+
* and it carries `high`. The corpus contains no instance of it, so that path is unit-tested only;
|
|
113
|
+
* said plainly here because "corpus-verified" would be a claim about a case the corpus lacks.
|
|
114
|
+
*
|
|
115
|
+
* A component arriving through inheritance under ONE id never reaches here: the merge folds the
|
|
116
|
+
* ancestor and the inheritor into a single entry, so the rule sees one component and says nothing.
|
|
117
|
+
* That exemption is structural rather than a special case, which is why it cannot rot.
|
|
118
|
+
*/
|
|
119
|
+
function checkResolvedCollisions(ctx, push) {
|
|
120
|
+
const cnf = ctx.tokenForm;
|
|
121
|
+
if (!cnf || typeof cnf !== 'object')
|
|
122
|
+
return;
|
|
123
|
+
const resolve = makeTokenResolver(ctx.variables);
|
|
124
|
+
for (const [collection, value] of Object.entries(cnf)) {
|
|
125
|
+
if (DIRECTIVE_KEYS.has(collection))
|
|
126
|
+
continue;
|
|
127
|
+
// resolved id -> the distinct token identities that produce it
|
|
128
|
+
const byResolved = new Map();
|
|
129
|
+
for (const { id, value: componentValue } of declaredIds(value)) {
|
|
130
|
+
const resolved = resolve(id);
|
|
131
|
+
if (!resolved)
|
|
132
|
+
continue;
|
|
133
|
+
const group = byResolved.get(resolved) ?? [];
|
|
134
|
+
// No dedup by token here.
|
|
135
|
+
//
|
|
136
|
+
// A first cut skipped a token already in the group, on the reasoning that only DISTINCT tokens
|
|
137
|
+
// are this rule's subject. It made two guards below unobservable: two non-scalar ids both
|
|
138
|
+
// coerce to "[object Object]", so the dedup swallowed them and no mutation of the guard that
|
|
139
|
+
// exists to stop them could fail a test. In a MERGED document the same key cannot appear twice
|
|
140
|
+
// in one collection anyway — for a map it is impossible, and for an array the merge collapses
|
|
141
|
+
// it — so the branch protected nothing and hid something.
|
|
142
|
+
group.push({
|
|
143
|
+
token: id,
|
|
144
|
+
signature: contentSignature(componentValue, resolve),
|
|
145
|
+
});
|
|
146
|
+
byResolved.set(resolved, group);
|
|
147
|
+
}
|
|
148
|
+
for (const [resolved, group] of byResolved) {
|
|
149
|
+
if (group.length < 2)
|
|
150
|
+
continue;
|
|
151
|
+
const identical = new Set(group.map((g) => g.signature)).size === 1;
|
|
152
|
+
const singular = collection.replace(/s$/, '');
|
|
153
|
+
for (const { token } of group) {
|
|
154
|
+
// The OTHER declarations, never this one. Including it produced a message that read
|
|
155
|
+
// `"30aa1dee-…" and its aliases resolve to the same connector id "30aa1dee-…"` on the one
|
|
156
|
+
// corpus project where a literal GUID collides with a token — true, and circular.
|
|
157
|
+
const others = group
|
|
158
|
+
.filter((g) => g.token !== token)
|
|
159
|
+
.map((g) => `"${g.token}"`)
|
|
160
|
+
.join(', ');
|
|
161
|
+
push('DUP-1', identical ? 'low' : 'high', collection, token, identical
|
|
162
|
+
? `${singular} "${token}" is also declared as ${others} — all of them resolve to the id "${resolved}"`
|
|
163
|
+
: `${singular} "${token}" resolves to the id "${resolved}", and so does ${others}, with DIFFERENT content`, identical
|
|
164
|
+
? 'the same component is declared under several names; the duplicate entry is redundant rather than harmful, because the declarations match'
|
|
165
|
+
: 'both entries reach output.yaml with one id — HexaSync keeps one and the other declaration is silently discarded', token);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Duplicate-identifier rule (DUP family). Detects duplicates that SURVIVE the merge —
|
|
172
|
+
* top-level identities that collide only after variable substitution (DUP-1), and duplicates
|
|
173
|
+
* within a single component's nested arrays: duplicate step keys in a workflow
|
|
174
|
+
* (DUP-3, CRITICAL — nondeterministic routing) and duplicate ids among an object's
|
|
175
|
+
* metrics or a task's transformations/validations (DUP-4, MEDIUM — last-wins overwrite).
|
|
176
|
+
*
|
|
177
|
+
* NOTE: top-level duplicates of the SAME token id (DUP-2) collapse during the merge
|
|
178
|
+
* (last-wins) and are therefore not present in the token-form — they are surfaced by the
|
|
179
|
+
* merge-integrity report instead, and deferred here. DUP-1 covers the case that does NOT
|
|
180
|
+
* collapse, because the keys differ and only their resolved values coincide.
|
|
181
|
+
*
|
|
182
|
+
* Two known limitations (documented, by design):
|
|
183
|
+
* - If a component is CUSTOMIZED across inheritance files, the merge deep-merges its
|
|
184
|
+
* nested arrays too (last-wins), so nested duplicates authored in one file collapse
|
|
185
|
+
* before this rule sees them — the merge-integrity report owns that silent-collapse case.
|
|
186
|
+
* - DUP-3 checks each phase array (before/main/after) in isolation, matching how the
|
|
187
|
+
* worker fetches step lists; a key reused ACROSS phases is flagged separately, as DUP-5.
|
|
188
|
+
* ⛔ This line claimed the cross-phase case *"is not flagged (would risk a false positive
|
|
189
|
+
* under unconfirmed cross-phase `next` semantics)"* until 2026-08-12, and it was false when
|
|
190
|
+
* checked: `beforePushSteps:[{key:'X'}], pushSteps:[{key:'X'}]` yields
|
|
191
|
+
* `DUP-5 high step key "X" appears in multiple step-lists (beforePushSteps, pushSteps)`.
|
|
192
|
+
* A reader trusting it would add a second rule for a case already covered.
|
|
193
|
+
*/
|
|
194
|
+
export const duplicatesRule = {
|
|
195
|
+
id: 'DUP',
|
|
196
|
+
family: 'DUP',
|
|
197
|
+
run(ctx) {
|
|
198
|
+
const cnf = ctx.tokenForm;
|
|
199
|
+
if (!cnf || typeof cnf !== 'object')
|
|
200
|
+
return [];
|
|
201
|
+
const issues = [];
|
|
202
|
+
const push = (ruleId, severity, parentKey, idOrKey, message, why, locateValue) => issues.push({
|
|
203
|
+
ruleId,
|
|
204
|
+
family: 'DUP',
|
|
205
|
+
severity,
|
|
206
|
+
parentKey,
|
|
207
|
+
idOrKey,
|
|
208
|
+
message,
|
|
209
|
+
why,
|
|
210
|
+
locateValue,
|
|
211
|
+
});
|
|
212
|
+
checkResolvedCollisions(ctx, push);
|
|
213
|
+
const idKey = (it) => it && typeof it === 'object' ? (it.id ?? it.key) : undefined;
|
|
214
|
+
// DUP-3 — duplicate step keys within a workflow (steps survive the merge verbatim).
|
|
215
|
+
const checkStepDupes = (steps, parentKey, ownerId, label) => {
|
|
216
|
+
if (!Array.isArray(steps))
|
|
217
|
+
return;
|
|
218
|
+
for (const [k, count] of countDupes(steps, (s) => s?.key)) {
|
|
219
|
+
push('DUP-3', 'critical', parentKey, ownerId, `duplicate step key "${k}" (${label}) — ${count} occurrences`, 'next routing is nondeterministic (ambiguous step key)', k);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
// DUP-5 — a step key reused ACROSS a workflow's step-lists combined (cross-list collision). The generic
|
|
223
|
+
// Workflow engine keys `_outputs` by step key GLOBALLY within an entity and resolves `next` by key, so the
|
|
224
|
+
// SAME key in two lists (e.g. steps + finalSteps, or pullSteps + beforePullSteps) is ambiguous. HIGH.
|
|
225
|
+
// (DUP-3 above catches duplicates WITHIN one list; DUP-5 catches the cross-list case.)
|
|
226
|
+
const checkCrossListDupes = (entity, parentKey, ownerId, lists) => {
|
|
227
|
+
const seenIn = new Map();
|
|
228
|
+
for (const ln of lists) {
|
|
229
|
+
const steps = entity?.[ln];
|
|
230
|
+
if (!Array.isArray(steps))
|
|
231
|
+
continue;
|
|
232
|
+
for (const s of steps) {
|
|
233
|
+
const raw = s?.key;
|
|
234
|
+
if (raw == null || isRefEmpty(raw) || isDynamic(raw))
|
|
235
|
+
continue;
|
|
236
|
+
if (typeof raw !== 'string' && typeof raw !== 'number')
|
|
237
|
+
continue;
|
|
238
|
+
const key = String(raw);
|
|
239
|
+
let set = seenIn.get(key);
|
|
240
|
+
if (!set) {
|
|
241
|
+
set = new Set();
|
|
242
|
+
seenIn.set(key, set);
|
|
243
|
+
}
|
|
244
|
+
set.add(ln);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
for (const [key, inLists] of seenIn) {
|
|
248
|
+
if (inLists.size > 1) {
|
|
249
|
+
push('DUP-5', 'high', parentKey, ownerId, `step key "${key}" appears in multiple step-lists (${[...inLists].join(', ')})`, 'the workflow engine keys _outputs and resolves next by a GLOBAL step key within the entity — a cross-list collision is ambiguous', key);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
for (const p of arr(cnf, 'pullers')) {
|
|
254
|
+
const pid = idKey(p) != null ? String(idKey(p)) : undefined;
|
|
255
|
+
for (const ph of ['beforePullSteps', 'pullSteps', 'afterPullSteps'])
|
|
256
|
+
checkStepDupes(p?.[ph], 'pullers', pid, ph);
|
|
257
|
+
// Story 7.6 — duplicate-step-key check across the new-kind puller phases too
|
|
258
|
+
// (inert for old-kind pullers whose new arrays are absent).
|
|
259
|
+
for (const ph of NEW_KIND_PHASES)
|
|
260
|
+
checkStepDupes(p?.[ph], 'pullers', pid, ph);
|
|
261
|
+
// DUP-5 — cross-list collision across ALL a puller's step-lists (old-kind + new-kind).
|
|
262
|
+
checkCrossListDupes(p, 'pullers', pid, [
|
|
263
|
+
'beforePullSteps',
|
|
264
|
+
'pullSteps',
|
|
265
|
+
'afterPullSteps',
|
|
266
|
+
'finalSteps',
|
|
267
|
+
...NEW_KIND_PHASES,
|
|
268
|
+
]);
|
|
269
|
+
}
|
|
270
|
+
for (const p of arr(cnf, 'pushers')) {
|
|
271
|
+
const pid = idKey(p) != null ? String(idKey(p)) : undefined;
|
|
272
|
+
// `finalSteps` — the worker runs it for a pusher too (Story 4.5 review, H2), so duplicate step keys there were
|
|
273
|
+
// going unreported.
|
|
274
|
+
for (const ph of [
|
|
275
|
+
'beforePushSteps',
|
|
276
|
+
'pushSteps',
|
|
277
|
+
'afterPushSteps',
|
|
278
|
+
// ⛔ Listed TWICE until 2026-08-12 (Epic 4 close review), so `checkStepDupes` ran twice over the same list and
|
|
279
|
+
// every duplicate key in a pusher's final stage was reported twice — nothing dedupes issues downstream.
|
|
280
|
+
// Measured: one pair of duplicate keys produced two identical `DUP-3 … (finalSteps) — 2 occurrences` findings.
|
|
281
|
+
// The stage itself was added correctly, and the copy-paste rode along, which is why every test asserting the
|
|
282
|
+
// stage IS covered stayed green.
|
|
283
|
+
'finalSteps',
|
|
284
|
+
])
|
|
285
|
+
checkStepDupes(p?.[ph], 'pushers', pid, ph);
|
|
286
|
+
checkCrossListDupes(p, 'pushers', pid, [
|
|
287
|
+
'beforePushSteps',
|
|
288
|
+
'pushSteps',
|
|
289
|
+
'afterPushSteps',
|
|
290
|
+
'finalSteps',
|
|
291
|
+
]);
|
|
292
|
+
}
|
|
293
|
+
for (const w of arr(cnf, 'webhooks')) {
|
|
294
|
+
const wid = idKey(w) != null ? String(idKey(w)) : undefined;
|
|
295
|
+
const targets = w?.targets && typeof w.targets === 'object' && !Array.isArray(w.targets)
|
|
296
|
+
? w.targets
|
|
297
|
+
: {};
|
|
298
|
+
// DUP-3 only, and PER TARGET. A webhook target is its own execution scope: step keys are unique
|
|
299
|
+
// WITHIN a target, not across a webhook's targets.
|
|
300
|
+
//
|
|
301
|
+
// DUP-5 used to run across all targets combined, and it was wrong — confirmed by the reviewer who
|
|
302
|
+
// owns the runtime, and corroborated by the corpus: 16 of the rule's 30 findings were webhooks,
|
|
303
|
+
// and every one was the same shape (a `FORWARD` step plus a `PUSH_*` step repeated in two
|
|
304
|
+
// targets) across four unrelated projects. A pattern repeated identically like that is a
|
|
305
|
+
// convention, not four independent mistakes.
|
|
306
|
+
//
|
|
307
|
+
// There is also no cross-LIST case to check here: a target declares exactly one list,
|
|
308
|
+
// `pullSteps`. DUP-5's premise — several step-lists sharing one `_outputs` namespace within an
|
|
309
|
+
// entity — is a puller/pusher shape, and applying it to targets assumed a namespace they do not
|
|
310
|
+
// share.
|
|
311
|
+
for (const [tk, t] of Object.entries(targets))
|
|
312
|
+
checkStepDupes(t?.pullSteps, 'webhooks', wid, `target ${tk}`);
|
|
313
|
+
}
|
|
314
|
+
// DUP-4 — duplicate ids within a component's nested item array.
|
|
315
|
+
for (const o of arr(cnf, 'objects')) {
|
|
316
|
+
const oid = idKey(o) != null ? String(idKey(o)) : undefined;
|
|
317
|
+
for (const [id, count] of countDupes(arr(o, 'metrics'), (it) => it?.id)) {
|
|
318
|
+
push('DUP-4', 'medium', 'objects', oid, `duplicate metric id "${id}" — ${count} occurrences`, 'the metric is overwritten (last wins)', id);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
for (const mapKey of ['transformations', 'validations']) {
|
|
322
|
+
const m = cnf[mapKey];
|
|
323
|
+
if (!m || typeof m !== 'object' || Array.isArray(m))
|
|
324
|
+
continue;
|
|
325
|
+
const singular = mapKey === 'transformations' ? 'transformation' : 'validation';
|
|
326
|
+
for (const [tid, items] of Object.entries(m)) {
|
|
327
|
+
if (!Array.isArray(items))
|
|
328
|
+
continue;
|
|
329
|
+
for (const [id, count] of countDupes(items, (it) => it?.id)) {
|
|
330
|
+
push('DUP-4', 'medium', mapKey, tid, `duplicate ${singular} id "${id}" — ${count} occurrences`, 'the item is overwritten (last wins)', id);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return issues;
|
|
335
|
+
},
|
|
336
|
+
};
|
|
337
|
+
//# sourceMappingURL=duplicates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duplicates.js","sourceRoot":"","sources":["../../../src/validate/rules/duplicates.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,SAAS,EACT,UAAU,EACV,iBAAiB,GAElB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,M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AC,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;oBAC5D,IAAI,CACF,OAAO,EACP,QAAQ,EACR,MAAM,EACN,GAAG,EACH,aAAa,QAAQ,QAAQ,EAAE,OAAO,KAAK,cAAc,EACzD,qCAAqC,EACrC,EAAE,CACH,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ValidationRule } from '../rule.js';
|
|
2
|
+
import { ValidationSeverity } from '@beehexa/hexasync-template-report-model';
|
|
3
|
+
/** Options that switch on NEW-KIND puller semantics (Stories 7.3–7.5). Defaulting them
|
|
4
|
+
* off keeps every legacy (old-kind) caller byte-identical: old steps carry no `onError`
|
|
5
|
+
* / `fromStep` / EXCEPTION fields, so the extra edges are inert, and the FLOW-5 cycle
|
|
6
|
+
* behaviour and FLOW-7 checks below only change when `newKind` is set. */
|
|
7
|
+
export interface AnalyzeOptions {
|
|
8
|
+
/** Enables the guarded-escapable back-edge refinement (FLOW-5) + Exception.fromStep
|
|
9
|
+
* validation (FLOW-7). Set only when analyzing a new-kind puller's combined graph. */
|
|
10
|
+
newKind?: boolean;
|
|
11
|
+
/** Extra entry step keys (e.g. the heads of onErrorSteps / finalSteps, which are
|
|
12
|
+
* scheduled independently and so are not reached by a `next` edge). */
|
|
13
|
+
extraEntryKeys?: string[];
|
|
14
|
+
/** Whether the puller declares a loop bound (`maxIterations`) — required for a guarded
|
|
15
|
+
* back-edge to be considered VALID. */
|
|
16
|
+
hasMaxIterations?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* True when a status value includes the Removed bit, across EVERY ItemStatusParser form
|
|
20
|
+
* (worker-data-raw-enhancement AD-3): a name array, a numeric bitfield, a numeric string, or enum
|
|
21
|
+
* text (a single name or a comma-combined set, case-insensitive). This intentionally also detects
|
|
22
|
+
* the legacy integer form (`2`/`3`) that the previous string-only check missed.
|
|
23
|
+
*/
|
|
24
|
+
export declare function statusHasRemoved(raw: unknown): boolean;
|
|
25
|
+
/** One finding from analyzing a single workflow (step array). */
|
|
26
|
+
export interface FlowFinding {
|
|
27
|
+
ruleId: string;
|
|
28
|
+
severity: ValidationSeverity;
|
|
29
|
+
message: string;
|
|
30
|
+
/** step key to highlight (or undefined for workflow-level findings). */
|
|
31
|
+
locateValue?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Why it matters, when the family's own line would overstate it.
|
|
34
|
+
*
|
|
35
|
+
* Every FLOW finding used to carry *"the workflow does not execute as authored"* — true of a dangling `next` or an
|
|
36
|
+
* unreachable step, and NOT true of an old-kind back-edge, which is how a correct paginating loop came to be
|
|
37
|
+
* reported as a document that does not run (2026-08-11). A rule that can only say *"look at this"* must not borrow a
|
|
38
|
+
* sentence that says *"this is broken"*.
|
|
39
|
+
*/
|
|
40
|
+
why?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Analyze one workflow's step array for graph-integrity problems (FLOW-3/4/5/6).
|
|
44
|
+
* Pure over the array; returns findings (attribution/rendering is the caller's job).
|
|
45
|
+
*
|
|
46
|
+
* Entry model matches the composer's own flowChart.ts: EVERY `rootStep: true` step is
|
|
47
|
+
* an entry node (multiple roots = multiple valid entry chains, a real pattern in shipped
|
|
48
|
+
* profiles); if none carry `rootStep`, the first step is the entry. There is intentionally
|
|
49
|
+
* NO "multiple roots" or "no root" finding — both are valid per the runtime.
|
|
50
|
+
*/
|
|
51
|
+
export declare function analyzeWorkflow(steps: any[], opts?: AnalyzeOptions): FlowFinding[];
|
|
52
|
+
export declare function danglingOutputRefs(steps: readonly any[]): {
|
|
53
|
+
key: string;
|
|
54
|
+
at: string;
|
|
55
|
+
}[];
|
|
56
|
+
export declare const flowRule: ValidationRule;
|
|
57
|
+
//# sourceMappingURL=flow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../../src/validate/rules/flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAEL,kBAAkB,EACnB,MAAM,yCAAyC,CAAC;AAWjD;;;2EAG2E;AAC3E,MAAM,WAAW,cAAc;IAC7B;2FACuF;IACvF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;4EACwE;IACxE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;4CACwC;IACxC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAmCD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAetD;AAeD,iEAAiE;AACjE,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;OAOG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAqFD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,GAAG,EAAE,EACZ,IAAI,GAAE,cAAmB,GACxB,WAAW,EAAE,CAuWf;AA+BD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,GAAG,EAAE,GACpB;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,CA0C/B;AAED,eAAO,MAAM,QAAQ,EAAE,cAoJtB,CAAC"}
|