@owlmeans/agent-common 0.1.18-rc.47 → 0.1.18-rc.49
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/README.md +174 -13
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/agent-common/SKILL.md +1 -1
- package/build/consts.d.ts +20 -0
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +103 -0
- package/build/consts.js.map +1 -1
- package/build/errors.d.ts +1 -1
- package/build/errors.js +1 -1
- package/build/helpers/conversation.d.ts +0 -9
- package/build/helpers/conversation.d.ts.map +1 -1
- package/build/helpers/conversation.js +0 -28
- package/build/helpers/conversation.js.map +1 -1
- package/build/helpers/truncate.d.ts +10 -0
- package/build/helpers/truncate.d.ts.map +1 -0
- package/build/helpers/truncate.js +29 -0
- package/build/helpers/truncate.js.map +1 -0
- package/build/index.d.ts +4 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/models/pipeline-spec/types.d.ts +57 -0
- package/build/models/pipeline-spec/types.d.ts.map +1 -0
- package/build/models/pipeline-spec/types.js +2 -0
- package/build/models/pipeline-spec/types.js.map +1 -0
- package/build/models/pipeline-spec.d.ts +4 -0
- package/build/models/pipeline-spec.d.ts.map +1 -0
- package/build/models/pipeline-spec.js +171 -0
- package/build/models/pipeline-spec.js.map +1 -0
- package/build/pipeline.d.ts +4 -43
- package/build/pipeline.d.ts.map +1 -1
- package/build/pipeline.js +9 -205
- package/build/pipeline.js.map +1 -1
- package/build/results/types.d.ts +211 -0
- package/build/results/types.d.ts.map +1 -0
- package/build/results/types.js +2 -0
- package/build/results/types.js.map +1 -0
- package/build/results.d.ts +3 -55
- package/build/results.d.ts.map +1 -1
- package/build/results.js +202 -250
- package/build/results.js.map +1 -1
- package/build/types.d.ts +1 -137
- package/build/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/consts.ts +113 -0
- package/src/errors.ts +1 -1
- package/src/helpers/conversation.ts +0 -32
- package/src/helpers/truncate.ts +31 -0
- package/src/index.ts +4 -1
- package/src/models/pipeline-spec/types.ts +58 -0
- package/src/models/pipeline-spec.ts +202 -0
- package/src/pipeline.ts +10 -231
- package/src/results/types.ts +221 -0
- package/src/results.ts +229 -274
- package/src/types.ts +2 -147
- package/tests/pipeline.spec.ts +26 -29
- package/tests/results.spec.ts +24 -26
- package/build/flows.d.ts +0 -21
- package/build/flows.d.ts.map +0 -1
- package/build/flows.js +0 -105
- package/build/flows.js.map +0 -1
- package/src/flows.ts +0 -113
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/models/pipeline-spec/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEpE,4FAA4F;AAC5F,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED,iGAAiG;AACjG,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;IAC7B;;;;;;;;OAQG;IACH,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB;;;;;;;;OAQG;IACH,UAAU,EAAE,MAAM,MAAM,EAAE,CAAA;IAC1B;;;;;;;OAOG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAAE,CAAA;IACvC;;;;;;;;;;;OAWG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,iBAAiB,EAAE,CAAA;IAC/C,6GAA6G;IAC7G,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAAE,CAAA;IACrC,sFAAsF;IACtF,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,gBAAgB,GAAG,IAAI,CAAA;CAClD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/models/pipeline-spec/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-spec.d.ts","sourceRoot":"","sources":["../../src/models/pipeline-spec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,aAAa,CAAA;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,0BAA0B,CAAA;AAEpF,eAAO,MAAM,qBAAqB,SAAU,YAAY,KAAG,iBAoM1D,CAAA"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { DEFAULT_STEP_ATTEMPTS } from '../consts.js';
|
|
2
|
+
import { PipelineSpecError, PipelineUnknownStepError } from '../errors.js';
|
|
3
|
+
export const makePipelineSpecModel = (spec) => {
|
|
4
|
+
const fault = (faults, message) => {
|
|
5
|
+
faults.push(message);
|
|
6
|
+
};
|
|
7
|
+
const validate = () => {
|
|
8
|
+
const faults = [];
|
|
9
|
+
if (spec.alias == null || spec.alias.trim() === '') {
|
|
10
|
+
fault(faults, 'alias is empty');
|
|
11
|
+
}
|
|
12
|
+
if (!Number.isInteger(spec.version) || spec.version < 1) {
|
|
13
|
+
fault(faults, `version must be a positive integer, got ${String(spec.version)}`);
|
|
14
|
+
}
|
|
15
|
+
if (!Array.isArray(spec.steps) || spec.steps.length === 0) {
|
|
16
|
+
fault(faults, 'no steps declared');
|
|
17
|
+
throw new PipelineSpecError(`${spec.alias ?? '?'}: ${faults.join('; ')}`);
|
|
18
|
+
}
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
for (const step of spec.steps) {
|
|
21
|
+
if (step.step == null || step.step.trim() === '') {
|
|
22
|
+
fault(faults, 'a step has an empty name');
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (seen.has(step.step)) {
|
|
26
|
+
fault(faults, `duplicate step "${step.step}"`);
|
|
27
|
+
}
|
|
28
|
+
seen.add(step.step);
|
|
29
|
+
}
|
|
30
|
+
for (const step of spec.steps) {
|
|
31
|
+
for (const dependency of step.after ?? []) {
|
|
32
|
+
if (dependency === step.step) {
|
|
33
|
+
fault(faults, `step "${step.step}" declares itself in \`after\``);
|
|
34
|
+
}
|
|
35
|
+
else if (!seen.has(dependency)) {
|
|
36
|
+
fault(faults, `step "${step.step}" waits on unknown step "${dependency}"`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const attempts = step.attempts ?? DEFAULT_STEP_ATTEMPTS;
|
|
40
|
+
if (!Number.isInteger(attempts) || attempts < 1) {
|
|
41
|
+
fault(faults, `step "${step.step}" declares attempts ${String(step.attempts)}`);
|
|
42
|
+
}
|
|
43
|
+
if (step.nonIdempotent === true && attempts > 1) {
|
|
44
|
+
fault(faults, `step "${step.step}" is nonIdempotent and declares attempts ${attempts} — an automatic `
|
|
45
|
+
+ 'retry is exactly what that flag says must not happen');
|
|
46
|
+
}
|
|
47
|
+
if (step.timeout != null && (!Number.isFinite(step.timeout) || step.timeout <= 0)) {
|
|
48
|
+
fault(faults, `step "${step.step}" declares timeout ${String(step.timeout)}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// A cycle is reported here rather than left to the sort, so one message carries every fault.
|
|
52
|
+
if (faults.every(entry => !entry.includes('unknown step'))) {
|
|
53
|
+
const cycle = detectCycle();
|
|
54
|
+
if (cycle != null) {
|
|
55
|
+
fault(faults, `cycle: ${cycle.join(' → ')}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (faults.length > 0) {
|
|
59
|
+
throw new PipelineSpecError(`${spec.alias}: ${faults.join('; ')}`);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const detectCycle = () => {
|
|
63
|
+
const after = new Map(spec.steps.map(step => [step.step, step.after ?? []]));
|
|
64
|
+
const state = new Map();
|
|
65
|
+
const path = [];
|
|
66
|
+
const walk = (name) => {
|
|
67
|
+
const mark = state.get(name);
|
|
68
|
+
if (mark === 2)
|
|
69
|
+
return null;
|
|
70
|
+
if (mark === 1)
|
|
71
|
+
return [...path.slice(path.indexOf(name)), name];
|
|
72
|
+
state.set(name, 1);
|
|
73
|
+
path.push(name);
|
|
74
|
+
for (const dependency of after.get(name) ?? []) {
|
|
75
|
+
const found = walk(dependency);
|
|
76
|
+
if (found != null)
|
|
77
|
+
return found;
|
|
78
|
+
}
|
|
79
|
+
path.pop();
|
|
80
|
+
state.set(name, 2);
|
|
81
|
+
return null;
|
|
82
|
+
};
|
|
83
|
+
for (const step of spec.steps) {
|
|
84
|
+
const found = walk(step.step);
|
|
85
|
+
if (found != null)
|
|
86
|
+
return found.reverse();
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
};
|
|
90
|
+
const orderSteps = () => {
|
|
91
|
+
const names = spec.steps.map(step => step.step);
|
|
92
|
+
const known = new Set(names);
|
|
93
|
+
const pending = new Map();
|
|
94
|
+
const dependents = new Map();
|
|
95
|
+
for (const step of spec.steps) {
|
|
96
|
+
const dependencies = new Set();
|
|
97
|
+
for (const dependency of step.after ?? []) {
|
|
98
|
+
if (!known.has(dependency)) {
|
|
99
|
+
throw new PipelineSpecError(`${spec.alias}: step "${step.step}" waits on unknown step "${dependency}"`);
|
|
100
|
+
}
|
|
101
|
+
dependencies.add(dependency);
|
|
102
|
+
dependents.set(dependency, [...(dependents.get(dependency) ?? []), step.step]);
|
|
103
|
+
}
|
|
104
|
+
pending.set(step.step, dependencies);
|
|
105
|
+
}
|
|
106
|
+
const ordered = [];
|
|
107
|
+
const emitted = new Set();
|
|
108
|
+
while (ordered.length < names.length) {
|
|
109
|
+
// Declaration order among everything currently ready — never a set's own order.
|
|
110
|
+
const ready = names.filter(name => !emitted.has(name) && (pending.get(name)?.size ?? 0) === 0);
|
|
111
|
+
if (ready.length === 0) {
|
|
112
|
+
const cycle = detectCycle();
|
|
113
|
+
throw new PipelineSpecError(`${spec.alias}: cycle: ${(cycle ?? names.filter(name => !emitted.has(name))).join(' → ')}`);
|
|
114
|
+
}
|
|
115
|
+
for (const name of ready) {
|
|
116
|
+
ordered.push(name);
|
|
117
|
+
emitted.add(name);
|
|
118
|
+
for (const dependent of dependents.get(name) ?? []) {
|
|
119
|
+
pending.get(dependent)?.delete(name);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return ordered;
|
|
124
|
+
};
|
|
125
|
+
const descendants = (step) => {
|
|
126
|
+
if (!spec.steps.some(entry => entry.step === step)) {
|
|
127
|
+
throw new PipelineUnknownStepError(`${spec.alias}:${step}`);
|
|
128
|
+
}
|
|
129
|
+
const reached = new Set([step]);
|
|
130
|
+
let grew = true;
|
|
131
|
+
while (grew) {
|
|
132
|
+
grew = false;
|
|
133
|
+
for (const entry of spec.steps) {
|
|
134
|
+
if (reached.has(entry.step))
|
|
135
|
+
continue;
|
|
136
|
+
if ((entry.after ?? []).some(dependency => reached.has(dependency))) {
|
|
137
|
+
reached.add(entry.step);
|
|
138
|
+
grew = true;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return orderSteps().filter(name => reached.has(name));
|
|
143
|
+
};
|
|
144
|
+
const ancestry = (step) => {
|
|
145
|
+
if (!spec.steps.some(entry => entry.step === step)) {
|
|
146
|
+
throw new PipelineUnknownStepError(`${spec.alias}:${step}`);
|
|
147
|
+
}
|
|
148
|
+
const after = new Map(spec.steps.map(entry => [entry.step, entry.after ?? []]));
|
|
149
|
+
const depths = new Map();
|
|
150
|
+
let frontier = [step];
|
|
151
|
+
for (let depth = 1; frontier.length > 0; ++depth) {
|
|
152
|
+
const next = [];
|
|
153
|
+
for (const name of frontier) {
|
|
154
|
+
for (const dependency of after.get(name) ?? []) {
|
|
155
|
+
if (dependency !== step && !depths.has(dependency)) {
|
|
156
|
+
depths.set(dependency, depth);
|
|
157
|
+
next.push(dependency);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
frontier = next;
|
|
162
|
+
}
|
|
163
|
+
return orderSteps()
|
|
164
|
+
.filter(name => depths.has(name))
|
|
165
|
+
.map(name => ({ step: name, depth: depths.get(name) }));
|
|
166
|
+
};
|
|
167
|
+
const ancestors = (step) => ancestry(step).map(entry => entry.step);
|
|
168
|
+
const stepOf = (step) => spec.steps.find(entry => entry.step === step) ?? null;
|
|
169
|
+
return { record: spec, validate, orderSteps, descendants, ancestry, ancestors, stepOf };
|
|
170
|
+
};
|
|
171
|
+
//# sourceMappingURL=pipeline-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-spec.js","sourceRoot":"","sources":["../../src/models/pipeline-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAI1E,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAkB,EAAqB,EAAE;IAC7E,MAAM,KAAK,GAAG,CAAC,MAAgB,EAAE,OAAe,EAAQ,EAAE;QACxD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACtB,CAAC,CAAA;IAED,MAAM,QAAQ,GAAG,GAAS,EAAE;QAC1B,MAAM,MAAM,GAAa,EAAE,CAAA;QAE3B,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACnD,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;QACjC,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;YACxD,KAAK,CAAC,MAAM,EAAE,2CAA2C,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAClF,CAAC;QACD,IAAI,CAAC,KAAK,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,CAAC,IAAY,EAA2B,EAAE,CACvD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,CAAA;IAEvD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,CAAA;AACzF,CAAC,CAAA"}
|
package/build/pipeline.d.ts
CHANGED
|
@@ -1,49 +1,10 @@
|
|
|
1
1
|
import type { PipelineSpec, PipelineStepSpec } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Every fault in one message, or nothing.
|
|
4
|
-
*
|
|
5
|
-
* Total and IO-free, so a spec can be checked by a test in microseconds and by the runner at build
|
|
6
|
-
* time. It reports EVERY fault it finds rather than the first, because a spec is authored once and
|
|
7
|
-
* a build that names one fault per run turns a five-minute edit into five builds.
|
|
8
|
-
*/
|
|
2
|
+
/** @deprecated compat:factory-refactor — use `makePipelineSpecModel(spec).validate()` */
|
|
9
3
|
export declare const validatePipelineSpec: (spec: PipelineSpec) => void;
|
|
10
|
-
/**
|
|
11
|
-
* The steps in an order that respects every `after`, with declaration order as the tie-break.
|
|
12
|
-
*
|
|
13
|
-
* Deterministic on purpose: the order decides what a progress report calls "step 3 of 16" and what
|
|
14
|
-
* a resume considers already behind it, and an order that depends on a `Set`'s iteration would make
|
|
15
|
-
* both drift between processes.
|
|
16
|
-
*
|
|
17
|
-
* @throws {PipelineSpecError} on a cycle or an unknown `after`.
|
|
18
|
-
*/
|
|
4
|
+
/** @deprecated compat:factory-refactor — use `makePipelineSpecModel(spec).orderSteps()` */
|
|
19
5
|
export declare const orderPipelineSteps: (spec: PipelineSpec) => string[];
|
|
20
|
-
/**
|
|
21
|
-
* `step` and everything that transitively waits on it.
|
|
22
|
-
*
|
|
23
|
-
* What a resume has to re-run when an operator names a step: re-entering a step without re-entering
|
|
24
|
-
* what read its output leaves the run describing a state that no longer follows from itself.
|
|
25
|
-
*
|
|
26
|
-
* @throws {PipelineUnknownStepError} when the spec does not declare `step`.
|
|
27
|
-
*/
|
|
6
|
+
/** @deprecated compat:factory-refactor — use `makePipelineSpecModel(spec).descendants(…)` */
|
|
28
7
|
export declare const pipelineDescendants: (spec: PipelineSpec, step: string) => string[];
|
|
29
|
-
/**
|
|
30
|
-
* Every step `step` transitively waits on, with its DEPTH — the fewest `after` edges between the
|
|
31
|
-
* two — in topological order.
|
|
32
|
-
*
|
|
33
|
-
* The mirror of {@link pipelineDescendants}, with one deliberate asymmetry: the named step itself
|
|
34
|
-
* is NOT included. A re-run re-enters the step it names, so the descendants include it; nothing is
|
|
35
|
-
* its own predecessor, so the ancestors do not. The depth is what a consumer uses to decide how
|
|
36
|
-
* much of a predecessor's output it needs to be told — a direct predecessor is depth 1 however far
|
|
37
|
-
* apart the two sit in the topological order.
|
|
38
|
-
*
|
|
39
|
-
* @throws {PipelineUnknownStepError} when the spec does not declare `step`.
|
|
40
|
-
*/
|
|
41
|
-
export declare const pipelineAncestry: (spec: PipelineSpec, step: string) => Array<{
|
|
42
|
-
step: string;
|
|
43
|
-
depth: number;
|
|
44
|
-
}>;
|
|
45
|
-
/** The names from {@link pipelineAncestry}: what must finish before `step` may start, in order. */
|
|
46
|
-
export declare const pipelineAncestors: (spec: PipelineSpec, step: string) => string[];
|
|
47
|
-
/** The declaration of one step, by name. `null` when the spec does not declare it. */
|
|
8
|
+
/** @deprecated compat:factory-refactor — use `makePipelineSpecModel(spec).stepOf(…)` */
|
|
48
9
|
export declare const pipelineStep: (spec: PipelineSpec, step: string) => PipelineStepSpec | null;
|
|
49
10
|
//# sourceMappingURL=pipeline.d.ts.map
|
package/build/pipeline.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAEhE,yFAAyF;AACzF,eAAO,MAAM,oBAAoB,SAAU,YAAY,KAAG,IAA8C,CAAA;AAExG,2FAA2F;AAC3F,eAAO,MAAM,kBAAkB,SAAU,YAAY,KAAG,MAAM,EAA8C,CAAA;AAE5G,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,SAAU,YAAY,QAAQ,MAAM,KAAG,MAAM,EAC9B,CAAA;AAE/C,wFAAwF;AACxF,eAAO,MAAM,YAAY,SAAU,YAAY,QAAQ,MAAM,KAAG,gBAAgB,GAAG,IACzC,CAAA"}
|
package/build/pipeline.js
CHANGED
|
@@ -1,206 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* time. It reports EVERY fault it finds rather than the first, because a spec is authored once and
|
|
11
|
-
* a build that names one fault per run turns a five-minute edit into five builds.
|
|
12
|
-
*/
|
|
13
|
-
export const validatePipelineSpec = (spec) => {
|
|
14
|
-
const faults = [];
|
|
15
|
-
if (spec.alias == null || spec.alias.trim() === '') {
|
|
16
|
-
fault(faults, 'alias is empty');
|
|
17
|
-
}
|
|
18
|
-
if (!Number.isInteger(spec.version) || spec.version < 1) {
|
|
19
|
-
fault(faults, `version must be a positive integer, got ${String(spec.version)}`);
|
|
20
|
-
}
|
|
21
|
-
if (!Array.isArray(spec.steps) || spec.steps.length === 0) {
|
|
22
|
-
fault(faults, 'no steps declared');
|
|
23
|
-
throw new PipelineSpecError(`${spec.alias ?? '?'}: ${faults.join('; ')}`);
|
|
24
|
-
}
|
|
25
|
-
const seen = new Set();
|
|
26
|
-
for (const step of spec.steps) {
|
|
27
|
-
if (step.step == null || step.step.trim() === '') {
|
|
28
|
-
fault(faults, 'a step has an empty name');
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
if (seen.has(step.step)) {
|
|
32
|
-
fault(faults, `duplicate step "${step.step}"`);
|
|
33
|
-
}
|
|
34
|
-
seen.add(step.step);
|
|
35
|
-
}
|
|
36
|
-
for (const step of spec.steps) {
|
|
37
|
-
for (const dependency of step.after ?? []) {
|
|
38
|
-
if (dependency === step.step) {
|
|
39
|
-
fault(faults, `step "${step.step}" declares itself in \`after\``);
|
|
40
|
-
}
|
|
41
|
-
else if (!seen.has(dependency)) {
|
|
42
|
-
fault(faults, `step "${step.step}" waits on unknown step "${dependency}"`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const attempts = step.attempts ?? DEFAULT_STEP_ATTEMPTS;
|
|
46
|
-
if (!Number.isInteger(attempts) || attempts < 1) {
|
|
47
|
-
fault(faults, `step "${step.step}" declares attempts ${String(step.attempts)}`);
|
|
48
|
-
}
|
|
49
|
-
if (step.nonIdempotent === true && attempts > 1) {
|
|
50
|
-
fault(faults, `step "${step.step}" is nonIdempotent and declares attempts ${attempts} — an automatic `
|
|
51
|
-
+ 'retry is exactly what that flag says must not happen');
|
|
52
|
-
}
|
|
53
|
-
if (step.timeout != null && (!Number.isFinite(step.timeout) || step.timeout <= 0)) {
|
|
54
|
-
fault(faults, `step "${step.step}" declares timeout ${String(step.timeout)}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
// A cycle is reported here rather than left to the sort, so one message carries every fault.
|
|
58
|
-
if (faults.every(entry => !entry.includes('unknown step'))) {
|
|
59
|
-
const cycle = detectCycle(spec);
|
|
60
|
-
if (cycle != null) {
|
|
61
|
-
fault(faults, `cycle: ${cycle.join(' → ')}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (faults.length > 0) {
|
|
65
|
-
throw new PipelineSpecError(`${spec.alias}: ${faults.join('; ')}`);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const detectCycle = (spec) => {
|
|
69
|
-
const after = new Map(spec.steps.map(step => [step.step, step.after ?? []]));
|
|
70
|
-
const state = new Map();
|
|
71
|
-
const path = [];
|
|
72
|
-
const walk = (name) => {
|
|
73
|
-
const mark = state.get(name);
|
|
74
|
-
if (mark === 2)
|
|
75
|
-
return null;
|
|
76
|
-
if (mark === 1)
|
|
77
|
-
return [...path.slice(path.indexOf(name)), name];
|
|
78
|
-
state.set(name, 1);
|
|
79
|
-
path.push(name);
|
|
80
|
-
for (const dependency of after.get(name) ?? []) {
|
|
81
|
-
const found = walk(dependency);
|
|
82
|
-
if (found != null)
|
|
83
|
-
return found;
|
|
84
|
-
}
|
|
85
|
-
path.pop();
|
|
86
|
-
state.set(name, 2);
|
|
87
|
-
return null;
|
|
88
|
-
};
|
|
89
|
-
for (const step of spec.steps) {
|
|
90
|
-
const found = walk(step.step);
|
|
91
|
-
if (found != null)
|
|
92
|
-
return found.reverse();
|
|
93
|
-
}
|
|
94
|
-
return null;
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* The steps in an order that respects every `after`, with declaration order as the tie-break.
|
|
98
|
-
*
|
|
99
|
-
* Deterministic on purpose: the order decides what a progress report calls "step 3 of 16" and what
|
|
100
|
-
* a resume considers already behind it, and an order that depends on a `Set`'s iteration would make
|
|
101
|
-
* both drift between processes.
|
|
102
|
-
*
|
|
103
|
-
* @throws {PipelineSpecError} on a cycle or an unknown `after`.
|
|
104
|
-
*/
|
|
105
|
-
export const orderPipelineSteps = (spec) => {
|
|
106
|
-
const names = spec.steps.map(step => step.step);
|
|
107
|
-
const known = new Set(names);
|
|
108
|
-
const pending = new Map();
|
|
109
|
-
const dependents = new Map();
|
|
110
|
-
for (const step of spec.steps) {
|
|
111
|
-
const dependencies = new Set();
|
|
112
|
-
for (const dependency of step.after ?? []) {
|
|
113
|
-
if (!known.has(dependency)) {
|
|
114
|
-
throw new PipelineSpecError(`${spec.alias}: step "${step.step}" waits on unknown step "${dependency}"`);
|
|
115
|
-
}
|
|
116
|
-
dependencies.add(dependency);
|
|
117
|
-
dependents.set(dependency, [...(dependents.get(dependency) ?? []), step.step]);
|
|
118
|
-
}
|
|
119
|
-
pending.set(step.step, dependencies);
|
|
120
|
-
}
|
|
121
|
-
const ordered = [];
|
|
122
|
-
const emitted = new Set();
|
|
123
|
-
while (ordered.length < names.length) {
|
|
124
|
-
// Declaration order among everything currently ready — never a set's own order.
|
|
125
|
-
const ready = names.filter(name => !emitted.has(name) && (pending.get(name)?.size ?? 0) === 0);
|
|
126
|
-
if (ready.length === 0) {
|
|
127
|
-
const cycle = detectCycle(spec);
|
|
128
|
-
throw new PipelineSpecError(`${spec.alias}: cycle: ${(cycle ?? names.filter(name => !emitted.has(name))).join(' → ')}`);
|
|
129
|
-
}
|
|
130
|
-
for (const name of ready) {
|
|
131
|
-
ordered.push(name);
|
|
132
|
-
emitted.add(name);
|
|
133
|
-
for (const dependent of dependents.get(name) ?? []) {
|
|
134
|
-
pending.get(dependent)?.delete(name);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return ordered;
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* `step` and everything that transitively waits on it.
|
|
142
|
-
*
|
|
143
|
-
* What a resume has to re-run when an operator names a step: re-entering a step without re-entering
|
|
144
|
-
* what read its output leaves the run describing a state that no longer follows from itself.
|
|
145
|
-
*
|
|
146
|
-
* @throws {PipelineUnknownStepError} when the spec does not declare `step`.
|
|
147
|
-
*/
|
|
148
|
-
export const pipelineDescendants = (spec, step) => {
|
|
149
|
-
if (!spec.steps.some(entry => entry.step === step)) {
|
|
150
|
-
throw new PipelineUnknownStepError(`${spec.alias}:${step}`);
|
|
151
|
-
}
|
|
152
|
-
const reached = new Set([step]);
|
|
153
|
-
let grew = true;
|
|
154
|
-
while (grew) {
|
|
155
|
-
grew = false;
|
|
156
|
-
for (const entry of spec.steps) {
|
|
157
|
-
if (reached.has(entry.step))
|
|
158
|
-
continue;
|
|
159
|
-
if ((entry.after ?? []).some(dependency => reached.has(dependency))) {
|
|
160
|
-
reached.add(entry.step);
|
|
161
|
-
grew = true;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return orderPipelineSteps(spec).filter(name => reached.has(name));
|
|
166
|
-
};
|
|
167
|
-
/**
|
|
168
|
-
* Every step `step` transitively waits on, with its DEPTH — the fewest `after` edges between the
|
|
169
|
-
* two — in topological order.
|
|
170
|
-
*
|
|
171
|
-
* The mirror of {@link pipelineDescendants}, with one deliberate asymmetry: the named step itself
|
|
172
|
-
* is NOT included. A re-run re-enters the step it names, so the descendants include it; nothing is
|
|
173
|
-
* its own predecessor, so the ancestors do not. The depth is what a consumer uses to decide how
|
|
174
|
-
* much of a predecessor's output it needs to be told — a direct predecessor is depth 1 however far
|
|
175
|
-
* apart the two sit in the topological order.
|
|
176
|
-
*
|
|
177
|
-
* @throws {PipelineUnknownStepError} when the spec does not declare `step`.
|
|
178
|
-
*/
|
|
179
|
-
export const pipelineAncestry = (spec, step) => {
|
|
180
|
-
if (!spec.steps.some(entry => entry.step === step)) {
|
|
181
|
-
throw new PipelineUnknownStepError(`${spec.alias}:${step}`);
|
|
182
|
-
}
|
|
183
|
-
const after = new Map(spec.steps.map(entry => [entry.step, entry.after ?? []]));
|
|
184
|
-
const depths = new Map();
|
|
185
|
-
let frontier = [step];
|
|
186
|
-
for (let depth = 1; frontier.length > 0; ++depth) {
|
|
187
|
-
const next = [];
|
|
188
|
-
for (const name of frontier) {
|
|
189
|
-
for (const dependency of after.get(name) ?? []) {
|
|
190
|
-
if (dependency !== step && !depths.has(dependency)) {
|
|
191
|
-
depths.set(dependency, depth);
|
|
192
|
-
next.push(dependency);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
frontier = next;
|
|
197
|
-
}
|
|
198
|
-
return orderPipelineSteps(spec)
|
|
199
|
-
.filter(name => depths.has(name))
|
|
200
|
-
.map(name => ({ step: name, depth: depths.get(name) }));
|
|
201
|
-
};
|
|
202
|
-
/** The names from {@link pipelineAncestry}: what must finish before `step` may start, in order. */
|
|
203
|
-
export const pipelineAncestors = (spec, step) => pipelineAncestry(spec, step).map(entry => entry.step);
|
|
204
|
-
/** The declaration of one step, by name. `null` when the spec does not declare it. */
|
|
205
|
-
export const pipelineStep = (spec, step) => spec.steps.find(entry => entry.step === step) ?? null;
|
|
1
|
+
import { makePipelineSpecModel } from './models/pipeline-spec.js';
|
|
2
|
+
/** @deprecated compat:factory-refactor — use `makePipelineSpecModel(spec).validate()` */
|
|
3
|
+
export const validatePipelineSpec = (spec) => makePipelineSpecModel(spec).validate();
|
|
4
|
+
/** @deprecated compat:factory-refactor — use `makePipelineSpecModel(spec).orderSteps()` */
|
|
5
|
+
export const orderPipelineSteps = (spec) => makePipelineSpecModel(spec).orderSteps();
|
|
6
|
+
/** @deprecated compat:factory-refactor — use `makePipelineSpecModel(spec).descendants(…)` */
|
|
7
|
+
export const pipelineDescendants = (spec, step) => makePipelineSpecModel(spec).descendants(step);
|
|
8
|
+
/** @deprecated compat:factory-refactor — use `makePipelineSpecModel(spec).stepOf(…)` */
|
|
9
|
+
export const pipelineStep = (spec, step) => makePipelineSpecModel(spec).stepOf(step);
|
|
206
10
|
//# sourceMappingURL=pipeline.js.map
|
package/build/pipeline.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAGjE,yFAAyF;AACzF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAkB,EAAQ,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAA;AAExG,2FAA2F;AAC3F,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAkB,EAAY,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAA;AAE5G,6FAA6F;AAC7F,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAkB,EAAE,IAAY,EAAY,EAAE,CAChF,qBAAqB,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;AAE/C,wFAAwF;AACxF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAkB,EAAE,IAAY,EAA2B,EAAE,CACxF,qBAAqB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA"}
|