owenloop 0.5.7 → 0.5.9
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/CHANGELOG.md +41 -0
- package/README.md +7 -8
- package/dist/packages/work/src/agent/capability-model.d.ts +64 -82
- package/dist/packages/work/src/agent/capability-model.js +94 -91
- package/dist/packages/work/src/agent/loop.d.ts +55 -26
- package/dist/packages/work/src/agent/loop.js +144 -50
- package/dist/packages/work/src/bundle/types.d.ts +3 -3
- package/dist/packages/work/src/consumed-verifier.js +6 -17
- package/dist/packages/work/src/exec/loop.d.ts +1 -1
- package/dist/packages/work/src/exec/loop.js +206 -35
- package/dist/packages/work/src/exec/receipt.d.ts +7 -7
- package/dist/packages/work/src/exec/receipt.js +6 -6
- package/dist/packages/work/src/harness/child-env.js +4 -5
- package/dist/packages/work/src/harness/claude.js +100 -0
- package/dist/packages/work/src/harness/codex.js +3 -4
- package/dist/packages/work/src/harness/session-store.d.ts +63 -3
- package/dist/packages/work/src/harness/session-store.js +104 -9
- package/dist/packages/work/src/hub/client.d.ts +19 -4
- package/dist/packages/work/src/hub/client.js +7 -3
- package/dist/packages/work/src/hub/types.d.ts +87 -3
- package/dist/packages/work/src/main.js +1 -0
- package/dist/packages/work/src/roles/agent-run.js +46 -43
- package/dist/packages/work/src/roles/exec.js +2 -0
- package/dist/packages/work/src/roles/sessions.d.ts +3 -2
- package/dist/packages/work/src/roles/sessions.js +9 -2
- package/dist/packages/work/src/roles/settings.js +3 -1
- package/dist/packages/work/src/roles/shift.js +14 -2
- package/dist/packages/work/src/roles/util.d.ts +1 -0
- package/dist/packages/work/src/roles/util.js +10 -0
- package/dist/packages/work/src/settings/hub-roster-cache.d.ts +68 -0
- package/dist/packages/work/src/settings/hub-roster-cache.js +370 -0
- package/dist/packages/work/src/settings/roster.d.ts +105 -0
- package/dist/packages/work/src/settings/roster.js +439 -0
- package/dist/packages/work/src/settings/serving.d.ts +17 -0
- package/dist/packages/work/src/settings/serving.js +79 -0
- package/dist/packages/work/src/settings/settings.d.ts +25 -24
- package/dist/packages/work/src/settings/settings.js +29 -33
- package/dist/packages/work/src/shift/loop.d.ts +108 -5
- package/dist/packages/work/src/shift/loop.js +299 -51
- package/dist/packages/work/src/shift/protocol.d.ts +7 -5
- package/dist/packages/work/src/shift/runtime.d.ts +15 -0
- package/dist/packages/work/src/shift/runtime.js +95 -13
- package/dist/packages/work/src/shift/server.js +2 -0
- package/dist/packages/work/src/shift/spawn.d.ts +18 -50
- package/dist/packages/work/src/shift/spawn.js +30 -65
- package/dist/packages/work/src/shift/state.d.ts +29 -2
- package/dist/packages/work/src/shift/state.js +45 -15
- package/dist/packages/work/src/usage.d.ts +1 -1
- package/dist/packages/work/src/usage.js +10 -5
- package/dist/packages/work/src/util/modifier-init.d.ts +7 -0
- package/dist/packages/work/src/util/modifier-init.js +73 -0
- package/dist/src/bundle/tar.d.ts +9 -4
- package/dist/src/bundle/tar.js +9 -4
- package/dist/src/capabilities.d.ts +50 -0
- package/dist/src/capabilities.js +38 -0
- package/dist/src/cli.d.ts +15 -1
- package/dist/src/cli.js +1099 -32
- package/dist/src/config-dir.d.ts +14 -19
- package/dist/src/config-dir.js +16 -24
- package/dist/src/credentials.d.ts +1 -1
- package/dist/src/credentials.js +1 -1
- package/dist/src/crypto/index.d.ts +1 -1
- package/dist/src/crypto/index.js +1 -1
- package/dist/src/crypto/org-root.d.ts +30 -12
- package/dist/src/crypto/org-root.js +162 -14
- package/dist/src/crypto/records.d.ts +3 -0
- package/dist/src/crypto/records.js +8 -0
- package/dist/src/crypto/trust-roots.d.ts +2 -2
- package/dist/src/crypto/trust-roots.js +2 -2
- package/dist/src/defs.d.ts +6 -1
- package/dist/src/defs.js +203 -8
- package/dist/src/engine.d.ts +55 -6
- package/dist/src/engine.js +172 -22
- package/dist/src/global-config.d.ts +4 -7
- package/dist/src/global-config.js +4 -7
- package/dist/src/hub.d.ts +207 -5
- package/dist/src/hub.js +263 -3
- package/dist/src/index.d.ts +5 -5
- package/dist/src/index.js +3 -3
- package/dist/src/mcp/serve.d.ts +22 -0
- package/dist/src/mcp/serve.js +88 -8
- package/dist/src/model.d.ts +2 -0
- package/dist/src/model.js +32 -25
- package/dist/src/order-resolver.d.ts +1 -0
- package/dist/src/order-resolver.js +8 -1
- package/dist/src/schemas/index.d.ts +19 -0
- package/dist/src/schemas/order.v1.schema.json +13 -2
- package/dist/src/store/pre-commit-verifier.js +1 -1
- package/dist/src/store.d.ts +5 -0
- package/dist/src/store.js +43 -8
- package/dist/src/types.d.ts +64 -7
- package/dist/src/work-settings.d.ts +2 -4
- package/dist/src/work-settings.js +2 -4
- package/docs/agent-runner.md +2 -2
- package/docs/authoring.md +90 -2
- package/docs/bundles.md +29 -3
- package/docs/cli.md +456 -120
- package/docs/crypto.md +32 -16
- package/docs/design.md +70 -1
- package/docs/routing.md +762 -0
- package/docs/shift-logs.md +37 -10
- package/docs/wire-contracts.md +50 -7
- package/examples/workflows/delivery.yaml +31 -14
- package/examples/workflows/ship.yaml +10 -2
- package/package.json +1 -1
- package/plugins/claude-code/plugin/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/plugin/.mcp.json +1 -1
- package/plugins/claude-code/plugin/skills/author/SKILL.md +1 -2
- package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +1 -1
- package/plugins/codex/plugins/owenloop/.mcp.json +1 -1
- package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +1 -2
package/dist/src/defs.js
CHANGED
|
@@ -32,7 +32,7 @@ import { MODIFIER_SEPARATOR } from "./capabilities.js";
|
|
|
32
32
|
/** Hand-maintained key allowlist for RawInput — kept next to the interface so
|
|
33
33
|
* the two can't silently drift (§27 unknown-key rejection). */
|
|
34
34
|
const RAW_INPUT_KEYS = ['name', 'producer', 'seedOwed', 'schema'];
|
|
35
|
-
const RAW_PRODUCE_KEYS = ['name', 'schema', 'judges', 'maxAttempts', 'maxSchemaFailures'];
|
|
35
|
+
const RAW_PRODUCE_KEYS = ['name', 'schema', 'judges', 'maxAttempts', 'maxSchemaFailures', 'bind'];
|
|
36
36
|
/** Hand-maintained key allowlist for RawGroup — a `group:` entry is a
|
|
37
37
|
* DIFFERENT (smaller) shape than RawProduce, not a produce with extra
|
|
38
38
|
* fields, so it gets its own allowlist rather than folding into
|
|
@@ -45,7 +45,7 @@ const RAW_STEP_KEYS = [
|
|
|
45
45
|
'maxRunsPerDay', 'parallel', 'maxAttempts', 'maxSchemaFailures', 'model',
|
|
46
46
|
'workdir', 'workdirFrom', 'terminal', 'effect', 'on', 'idleAfter', 'body', 'bodyFile',
|
|
47
47
|
'calls', 'reapTtl', 'capabilities', 'maxLease', 'x', 'executor', 'command', 'spec',
|
|
48
|
-
'escalation',
|
|
48
|
+
'escalation', 'onCancel',
|
|
49
49
|
];
|
|
50
50
|
/** Keys valid on a calls: step entry — a DIFFERENT (smaller) shape than RawStep;
|
|
51
51
|
* the `calls:` key is what routes an entry here instead of RAW_STEP_KEYS. */
|
|
@@ -113,7 +113,8 @@ function assertAuthoredCapability(value, ctx) {
|
|
|
113
113
|
*
|
|
114
114
|
* Order is NOT preserved as meaning: the list is a vocabulary, and nothing in
|
|
115
115
|
* the engine compares two modifiers or treats one as higher than another. The
|
|
116
|
-
* array shape is only YAML's way of writing a set.
|
|
116
|
+
* array shape is only YAML's way of writing a set. The vocabulary is fixed
|
|
117
|
+
* here; every downstream gate checks membership in it and nothing else.
|
|
117
118
|
*/
|
|
118
119
|
function parseModifiers(v, ctx) {
|
|
119
120
|
const values = asStringArray(v, ctx);
|
|
@@ -125,6 +126,11 @@ function parseModifiers(v, ctx) {
|
|
|
125
126
|
if (value.trim().length === 0) {
|
|
126
127
|
throw new DefError(`${ctx}: modifier names must not be empty or whitespace`);
|
|
127
128
|
}
|
|
129
|
+
if (/\s/.test(value)) {
|
|
130
|
+
throw new DefError(`${ctx}: modifier '${value}' must not contain whitespace — ` +
|
|
131
|
+
'a modifier is composed onto every authored capability as ' +
|
|
132
|
+
`'<capability>${MODIFIER_SEPARATOR}<modifier>' and travels as a routing key`);
|
|
133
|
+
}
|
|
128
134
|
if (value.includes(MODIFIER_SEPARATOR)) {
|
|
129
135
|
throw new DefError(`${ctx}: modifier '${value}' must not contain '${MODIFIER_SEPARATOR}' — ` +
|
|
130
136
|
'it is the separator the engine composes with');
|
|
@@ -157,6 +163,19 @@ function parseEscalation(v, ctx) {
|
|
|
157
163
|
throw new DefError(`${ctx}.modifier must not be empty`);
|
|
158
164
|
return { after, modifier };
|
|
159
165
|
}
|
|
166
|
+
/** Parse a step's `onCancel:` block. Stem-membership cross-checks live in
|
|
167
|
+
* validateDef because they need the step's parsed consumes. */
|
|
168
|
+
function parseOnCancel(v, ctx) {
|
|
169
|
+
if (typeof v !== 'object' || v === null || Array.isArray(v)) {
|
|
170
|
+
throw new DefError(`${ctx} must be a mapping of { consumes }`);
|
|
171
|
+
}
|
|
172
|
+
const raw = v;
|
|
173
|
+
assertNoUnknownKeys(raw, ['consumes'], ctx);
|
|
174
|
+
if (raw['consumes'] === undefined) {
|
|
175
|
+
throw new DefError(`${ctx} must set 'consumes' (the subset of the step's consumes the cancel-path firing requires; use [] for none)`);
|
|
176
|
+
}
|
|
177
|
+
return { consumes: asStringArray(raw['consumes'], `${ctx}.consumes`) };
|
|
178
|
+
}
|
|
160
179
|
function asNumber(v, fallback, ctx) {
|
|
161
180
|
if (v === undefined)
|
|
162
181
|
return fallback;
|
|
@@ -372,6 +391,14 @@ function parseGroup(v, ctx) {
|
|
|
372
391
|
const of = v.of.map((s, i) => asString(s, `group '${group}'.of[${i}]`));
|
|
373
392
|
return { group, mode, of };
|
|
374
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* The `from` a bind gets when its author omits one: the final segment of
|
|
396
|
+
* `to`. A shorthand `bind: modifier` therefore reads the accepted
|
|
397
|
+
* object's `modifier` key, while `bind: meta.customer` reads `customer`.
|
|
398
|
+
*/
|
|
399
|
+
function defaultBindFrom(to) {
|
|
400
|
+
return to.slice(to.lastIndexOf('.') + 1);
|
|
401
|
+
}
|
|
375
402
|
/**
|
|
376
403
|
* Parse a step's `produces` list. Each entry is either a bare pattern string
|
|
377
404
|
* (`plan`, `gather.source[]`), a mapping `{ name, schema, judges, maxAttempts,
|
|
@@ -423,10 +450,29 @@ function parseProduces(v, ctx, baseDir) {
|
|
|
423
450
|
throw new DefError(`produce '${name}'.maxSchemaFailures must be a non-negative number`);
|
|
424
451
|
pat.maxSchemaFailures = v;
|
|
425
452
|
}
|
|
453
|
+
if (raw.bind !== undefined) {
|
|
454
|
+
// bind.from is always a dot-separated object path. When omitted, it
|
|
455
|
+
// defaults to the final segment of bind.to; missing paths are refused.
|
|
456
|
+
if (typeof raw.bind === 'string') {
|
|
457
|
+
pat.bind = { to: raw.bind, from: defaultBindFrom(raw.bind) };
|
|
458
|
+
}
|
|
459
|
+
else if (typeof raw.bind === 'object' && raw.bind !== null && !Array.isArray(raw.bind)) {
|
|
460
|
+
const bind = raw.bind;
|
|
461
|
+
assertNoUnknownKeys(bind, ['to', 'from'], `produce '${name}'.bind`);
|
|
462
|
+
const to = asString(bind.to, `produce '${name}'.bind.to`);
|
|
463
|
+
const from = bind.from === undefined
|
|
464
|
+
? defaultBindFrom(to)
|
|
465
|
+
: asString(bind.from, `produce '${name}'.bind.from`);
|
|
466
|
+
pat.bind = { to, from };
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
throw new DefError(`produce '${name}'.bind must be a string or a { to, from } mapping`);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
426
472
|
patterns.push(pat);
|
|
427
473
|
return;
|
|
428
474
|
}
|
|
429
|
-
throw new DefError(`${ctx}[${i}] must be a string or a { name, schema, judges, maxAttempts, maxSchemaFailures } mapping`);
|
|
475
|
+
throw new DefError(`${ctx}[${i}] must be a string or a { name, schema, judges, maxAttempts, maxSchemaFailures, bind } mapping`);
|
|
430
476
|
});
|
|
431
477
|
return { patterns, groups };
|
|
432
478
|
}
|
|
@@ -717,6 +763,12 @@ function prefixStep(step, prefix, defInputs = []) {
|
|
|
717
763
|
// judges: marker names a local stem (unlike calls:, which names an external
|
|
718
764
|
// workflow) — it must be prefixed to keep pointing at the (now-prefixed) produce.
|
|
719
765
|
const newJudges = step.judges !== undefined ? prefixStem(step.judges) : undefined;
|
|
766
|
+
// onCancel consumes name local stems, so they must follow the same prefixing
|
|
767
|
+
// rule as ordinary consumes. Build a fresh object to avoid aliasing a child
|
|
768
|
+
// definition into an expanded parent.
|
|
769
|
+
const newOnCancel = step.onCancel !== undefined
|
|
770
|
+
? { consumes: step.onCancel.consumes.map(prefixStem) }
|
|
771
|
+
: undefined;
|
|
720
772
|
// workdirFrom names a local consumed stem or a declared input of the included
|
|
721
773
|
// definition, followed by a dotted value path. Prefix only the stem; the value
|
|
722
774
|
// path is a field path inside that artifact's value.
|
|
@@ -744,6 +796,8 @@ function prefixStep(step, prefix, defInputs = []) {
|
|
|
744
796
|
result.effect = newEffect;
|
|
745
797
|
if (newJudges !== undefined)
|
|
746
798
|
result.judges = newJudges;
|
|
799
|
+
if (newOnCancel !== undefined)
|
|
800
|
+
result.onCancel = newOnCancel;
|
|
747
801
|
if (newWorkdirFrom !== undefined)
|
|
748
802
|
result.workdirFrom = newWorkdirFrom;
|
|
749
803
|
return result;
|
|
@@ -831,7 +885,20 @@ export function expandIncludes(def, resolve, stack) {
|
|
|
831
885
|
if (parsed && outer !== undefined)
|
|
832
886
|
rewrittenWorkdirFrom = `${outer}.${parsed.path}`;
|
|
833
887
|
}
|
|
834
|
-
|
|
888
|
+
// onCancel consume stems follow ordinary consume rewrites for mapped
|
|
889
|
+
// child inputs; otherwise the expanded step would name a stem it no
|
|
890
|
+
// longer consumes.
|
|
891
|
+
const rewrittenOnCancel = l.onCancel === undefined
|
|
892
|
+
? undefined
|
|
893
|
+
: { consumes: l.onCancel.consumes.map((stem) => inputRewrites.get(stem) ?? stem) };
|
|
894
|
+
const rewrittenStep = {
|
|
895
|
+
...l,
|
|
896
|
+
consumes: rewrittenConsumes,
|
|
897
|
+
workdirFrom: rewrittenWorkdirFrom,
|
|
898
|
+
};
|
|
899
|
+
if (rewrittenOnCancel !== undefined)
|
|
900
|
+
rewrittenStep.onCancel = rewrittenOnCancel;
|
|
901
|
+
return rewrittenStep;
|
|
835
902
|
});
|
|
836
903
|
resultSteps.push(...rewrittenSteps);
|
|
837
904
|
// (g) merge child outputs
|
|
@@ -1054,7 +1121,8 @@ function buildStep(rl, i, baseDir) {
|
|
|
1054
1121
|
}
|
|
1055
1122
|
for (const tok of rawOn) {
|
|
1056
1123
|
if (tok !== 'inputsGreen' && tok !== 'allGreen' && tok !== 'idle') {
|
|
1057
|
-
throw new DefError(`step '${name}': on: token '${tok}' is not supported; supported: 'inputsGreen', 'allGreen', 'idle'`
|
|
1124
|
+
throw new DefError(`step '${name}': on: token '${tok}' is not supported; supported: 'inputsGreen', 'allGreen', 'idle'. ` +
|
|
1125
|
+
'Cleanup that must still run when the run is cancelled is declared with the step-level onCancel: key, not a firing trigger.');
|
|
1058
1126
|
}
|
|
1059
1127
|
}
|
|
1060
1128
|
step.on = rawOn;
|
|
@@ -1080,6 +1148,9 @@ function buildStep(rl, i, baseDir) {
|
|
|
1080
1148
|
if (rl.escalation !== undefined) {
|
|
1081
1149
|
step.escalation = parseEscalation(rl.escalation, `step '${name}'.escalation`);
|
|
1082
1150
|
}
|
|
1151
|
+
if (rl.onCancel !== undefined) {
|
|
1152
|
+
step.onCancel = parseOnCancel(rl.onCancel, `step '${name}'.onCancel`);
|
|
1153
|
+
}
|
|
1083
1154
|
// A3: per-step max total lease lifetime (duration string, same as reapTtl).
|
|
1084
1155
|
if (rl.maxLease !== undefined) {
|
|
1085
1156
|
step.maxLeaseMs = parseDurationMs(asString(rl.maxLease, `step '${name}'.maxLease`));
|
|
@@ -1343,7 +1414,7 @@ export function validateDef(def) {
|
|
|
1343
1414
|
for (const tok of l.on) {
|
|
1344
1415
|
if (tok !== 'inputsGreen' && tok !== 'allGreen' && tok !== 'idle') {
|
|
1345
1416
|
errors.push(`step '${l.name}': on: token '${tok}' is not supported; ` +
|
|
1346
|
-
`supported: 'inputsGreen', 'allGreen', 'idle'.`);
|
|
1417
|
+
`supported: 'inputsGreen', 'allGreen', 'idle'. Cleanup that must still run when the run is cancelled is declared with the step-level onCancel: key, not a firing trigger.`);
|
|
1347
1418
|
}
|
|
1348
1419
|
}
|
|
1349
1420
|
}
|
|
@@ -1368,6 +1439,30 @@ export function validateDef(def) {
|
|
|
1368
1439
|
errors.push(`evaluator step ${l.name} (on: allGreen/idle) must not declare consumes; its firings carry no input fingerprint`);
|
|
1369
1440
|
}
|
|
1370
1441
|
}
|
|
1442
|
+
// onCancel: cross-checks. A cancel-path firing is keyless and fires once, so
|
|
1443
|
+
// it can require only the step's own plain consumes.
|
|
1444
|
+
for (const l of def.steps) {
|
|
1445
|
+
if (l.onCancel === undefined)
|
|
1446
|
+
continue;
|
|
1447
|
+
const seen = new Set();
|
|
1448
|
+
for (const stem of l.onCancel.consumes) {
|
|
1449
|
+
if (seen.has(stem)) {
|
|
1450
|
+
errors.push(`step '${l.name}': onCancel.consumes lists '${stem}' more than once`);
|
|
1451
|
+
continue;
|
|
1452
|
+
}
|
|
1453
|
+
seen.add(stem);
|
|
1454
|
+
const consume = l.consumes.find((candidate) => candidate.stem === stem);
|
|
1455
|
+
if (consume === undefined) {
|
|
1456
|
+
errors.push(`step '${l.name}': onCancel.consumes names '${stem}', which is not one of the step's consumes ` +
|
|
1457
|
+
`[${l.consumes.map((candidate) => candidate.stem).join(', ')}]`);
|
|
1458
|
+
continue;
|
|
1459
|
+
}
|
|
1460
|
+
if (consume.mode !== 'plain') {
|
|
1461
|
+
errors.push(`step '${l.name}': onCancel.consumes names '${stem}', which the step consumes in ${consume.mode} mode ` +
|
|
1462
|
+
`('${consume.raw}'); the cancel-path firing is keyless, so only plain consumes may be listed`);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1371
1466
|
// M2-VALIDATE: calls: step per-def rules.
|
|
1372
1467
|
// Note: cross-def checks (target-def existence, child input-key validity) cannot be done here
|
|
1373
1468
|
// because validateDef is a pure per-def function with no resolver. Those checks live in loadDefs
|
|
@@ -1379,6 +1474,14 @@ export function validateDef(def) {
|
|
|
1379
1474
|
if (l.produces.length !== 1) {
|
|
1380
1475
|
errors.push(`calls: step '${l.name}' must produce exactly one output (got ${l.produces.length})`);
|
|
1381
1476
|
}
|
|
1477
|
+
// A calls: outcome is published by the composition machinery rather than
|
|
1478
|
+
// accepted through green(), so it has no transactional bind write path.
|
|
1479
|
+
// Refuse it at definition load instead of allowing a silently stale route.
|
|
1480
|
+
for (const produce of l.produces) {
|
|
1481
|
+
if (produce.bind !== undefined) {
|
|
1482
|
+
errors.push(`calls: step '${l.name}' produce '${produce.raw}' declares bind, which is not supported on calls: outcomes`);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1382
1485
|
// (b) callsInputs VALUES must be real parent artifacts (inputs or step-produced stems)
|
|
1383
1486
|
for (const [, parentArtifact] of Object.entries(l.callsInputs ?? {})) {
|
|
1384
1487
|
if (!producerOf.has(parentArtifact)) {
|
|
@@ -1472,6 +1575,33 @@ export function validateDef(def) {
|
|
|
1472
1575
|
// "defs without `modifiers:` run exactly as today". Opting into the
|
|
1473
1576
|
// new routing vocabulary is what turns the stricter rule on.
|
|
1474
1577
|
const declaredModifiers = new Set(def.modifiers ?? []);
|
|
1578
|
+
const modifierBinds = [];
|
|
1579
|
+
for (const l of def.steps) {
|
|
1580
|
+
for (const p of l.produces) {
|
|
1581
|
+
const bind = p.bind;
|
|
1582
|
+
if (bind === undefined)
|
|
1583
|
+
continue;
|
|
1584
|
+
if (p.kind === 'collection') {
|
|
1585
|
+
errors.push(`step '${l.name}' produce '${p.raw}' bind is not supported on collection produces`);
|
|
1586
|
+
continue;
|
|
1587
|
+
}
|
|
1588
|
+
if (bind.to === 'modifier') {
|
|
1589
|
+
if (declaredModifiers.size === 0) {
|
|
1590
|
+
errors.push(`step '${l.name}' produce '${p.stem}' binds modifier but workflow '${def.name}' declares no modifiers:`);
|
|
1591
|
+
}
|
|
1592
|
+
modifierBinds.push({ step: l.name, artifact: p.stem });
|
|
1593
|
+
}
|
|
1594
|
+
else if (!/^meta\.[A-Za-z_][A-Za-z0-9_-]*$/.test(bind.to)) {
|
|
1595
|
+
errors.push(`step '${l.name}' produce '${p.stem}' bind.to '${bind.to}' must be 'modifier' or 'meta.<key>'`);
|
|
1596
|
+
}
|
|
1597
|
+
if (!/^[A-Za-z_][A-Za-z0-9_-]*(?:\.[A-Za-z_][A-Za-z0-9_-]*)*$/.test(bind.from)) {
|
|
1598
|
+
errors.push(`step '${l.name}' produce '${p.stem}' bind.from '${bind.from}' must be a non-empty dot-path of identifier segments`);
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
if (modifierBinds.length > 1) {
|
|
1603
|
+
errors.push(`workflow '${def.name}' binds modifier more than once: ${modifierBinds.map((b) => `'${b.step}.${b.artifact}'`).join(', ')}`);
|
|
1604
|
+
}
|
|
1475
1605
|
for (const l of def.steps) {
|
|
1476
1606
|
if (l.escalation === undefined)
|
|
1477
1607
|
continue;
|
|
@@ -1705,6 +1835,64 @@ function danglingReduceSuffixWarnings(def) {
|
|
|
1705
1835
|
}
|
|
1706
1836
|
return warnings;
|
|
1707
1837
|
}
|
|
1838
|
+
/**
|
|
1839
|
+
* Whether a consume can receive a value produced by this exact pattern.
|
|
1840
|
+
*
|
|
1841
|
+
* Keeping map suffixes here is essential: `items[$i].review` does not make a
|
|
1842
|
+
* consumer of `items[*].analysis` (or bare `items[*]`) downstream merely
|
|
1843
|
+
* because both lanes share the `items` stem.
|
|
1844
|
+
*/
|
|
1845
|
+
function consumesProducedPattern(consume, produce) {
|
|
1846
|
+
if (consume.stem !== produce.stem)
|
|
1847
|
+
return false;
|
|
1848
|
+
if (produce.kind === 'singleton')
|
|
1849
|
+
return consume.mode === 'plain';
|
|
1850
|
+
if (produce.kind === 'collection') {
|
|
1851
|
+
return consume.mode !== 'plain' && consume.suffix === '';
|
|
1852
|
+
}
|
|
1853
|
+
return consume.mode !== 'plain' && consume.suffix === produce.suffix;
|
|
1854
|
+
}
|
|
1855
|
+
/** Warn when routed work can run before the artifact that writes the modifier. */
|
|
1856
|
+
function unroutedCapabilityWarnings(def) {
|
|
1857
|
+
let bindingStep;
|
|
1858
|
+
let boundArtifact;
|
|
1859
|
+
for (const step of def.steps) {
|
|
1860
|
+
const bound = step.produces.find((p) => p.bind?.to === 'modifier');
|
|
1861
|
+
if (bound !== undefined) {
|
|
1862
|
+
bindingStep = step;
|
|
1863
|
+
boundArtifact = bound;
|
|
1864
|
+
break;
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
if (bindingStep === undefined || boundArtifact === undefined)
|
|
1868
|
+
return [];
|
|
1869
|
+
// Forward graph closure from the bound artifact. The binding step itself is
|
|
1870
|
+
// exempt, but its unbound sibling outputs must not make a branch downstream.
|
|
1871
|
+
const reachedSteps = new Set([bindingStep.name]);
|
|
1872
|
+
const reachedArtifacts = [boundArtifact];
|
|
1873
|
+
let changed = true;
|
|
1874
|
+
while (changed) {
|
|
1875
|
+
changed = false;
|
|
1876
|
+
for (const step of def.steps) {
|
|
1877
|
+
if (reachedSteps.has(step.name))
|
|
1878
|
+
continue;
|
|
1879
|
+
if (!step.consumes.some((consume) => reachedArtifacts.some((produce) => consumesProducedPattern(consume, produce))))
|
|
1880
|
+
continue;
|
|
1881
|
+
reachedSteps.add(step.name);
|
|
1882
|
+
reachedArtifacts.push(...step.produces);
|
|
1883
|
+
changed = true;
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
const warnings = [];
|
|
1887
|
+
for (const step of def.steps) {
|
|
1888
|
+
if (step.capabilities === undefined || step.capabilities.length === 0)
|
|
1889
|
+
continue;
|
|
1890
|
+
if (reachedSteps.has(step.name))
|
|
1891
|
+
continue;
|
|
1892
|
+
warnings.push(`step '${step.name}' declares capabilities (${step.capabilities.join(', ')}) but is not downstream of artifact '${boundArtifact.raw}' bound to modifier`);
|
|
1893
|
+
}
|
|
1894
|
+
return warnings;
|
|
1895
|
+
}
|
|
1708
1896
|
/**
|
|
1709
1897
|
* Static lint over a workflow definition. Returns both the hard errors from
|
|
1710
1898
|
* `validateDef` (which `parseDef` / `loadDefFile` would throw on) and
|
|
@@ -1718,10 +1906,17 @@ function danglingReduceSuffixWarnings(def) {
|
|
|
1718
1906
|
export function lintDef(def) {
|
|
1719
1907
|
const errors = validateDef(def);
|
|
1720
1908
|
const warnings = errors.length === 0
|
|
1721
|
-
? [...deadEndWarnings(def), ...danglingReduceSuffixWarnings(def)]
|
|
1909
|
+
? [...deadEndWarnings(def), ...danglingReduceSuffixWarnings(def), ...unroutedCapabilityWarnings(def)]
|
|
1722
1910
|
: [];
|
|
1723
1911
|
return { errors, warnings };
|
|
1724
1912
|
}
|
|
1913
|
+
/**
|
|
1914
|
+
* The steps a def declares as cleanup-on-cancel, in definition order. The
|
|
1915
|
+
* control plane calls this when it cancels a run.
|
|
1916
|
+
*/
|
|
1917
|
+
export function cancelCleanupSteps(def) {
|
|
1918
|
+
return def.steps.filter((step) => step.onCancel !== undefined);
|
|
1919
|
+
}
|
|
1725
1920
|
// ---- WS-6: scope-aware calls: target resolution -------------------------------
|
|
1726
1921
|
/** Stable private-map key for one installed coordinate at one verified digest. */
|
|
1727
1922
|
export function digestScopedCallsTargetKey(digest, target) {
|
package/dist/src/engine.d.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { WorkflowStatus } from './model.ts';
|
|
13
13
|
import type { SchemaIssue } from './schema.ts';
|
|
14
|
+
import type { CapabilityRewrites, CrewStamps } from './capabilities.ts';
|
|
14
15
|
import type { MatchMode } from './capabilities.ts';
|
|
15
16
|
import type { Store } from './store.ts';
|
|
16
17
|
import type { Author, Fingerprint, Order, WorkflowDef } from './types.ts';
|
|
@@ -159,14 +160,16 @@ export interface CreateOpts {
|
|
|
159
160
|
parentPath: string;
|
|
160
161
|
};
|
|
161
162
|
/**
|
|
162
|
-
* The ONE routing modifier this instance carries
|
|
163
|
-
*
|
|
163
|
+
* The ONE routing modifier this instance carries at a time. Must be a member
|
|
164
|
+
* of the def's declared `modifiers` set — `createInstance` throws
|
|
164
165
|
* {@link ModifierRefusalError} otherwise, rather than starting a run that
|
|
165
|
-
* would compose capabilities no crew was ever bound to.
|
|
166
|
+
* would compose capabilities no crew was ever bound to. After creation, the
|
|
167
|
+
* engine may replace it only through a def-declared artifact bind during
|
|
168
|
+
* acceptance.
|
|
166
169
|
*
|
|
167
170
|
* Absent = an unmodified run: every step is offered on bare capabilities.
|
|
168
|
-
*
|
|
169
|
-
*
|
|
171
|
+
* An escalated re-offer carries its own target modifier per-offer without
|
|
172
|
+
* rewriting this stored value.
|
|
170
173
|
*/
|
|
171
174
|
modifier?: string;
|
|
172
175
|
}
|
|
@@ -545,6 +548,25 @@ export declare class Engine {
|
|
|
545
548
|
* decides a mode, it only enforces the one it is handed.
|
|
546
549
|
*/
|
|
547
550
|
matchModes?: Record<string, MatchMode>;
|
|
551
|
+
/**
|
|
552
|
+
* Per-offered-capability reroute, keyed by the COMPOSED capability the
|
|
553
|
+
* offer would otherwise carry. Supplied by the same caller that supplies
|
|
554
|
+
* `matchModes` and for the same reason — choosing a reroute target means
|
|
555
|
+
* reading crew bindings, which the pure engine cannot see. Substitution
|
|
556
|
+
* is a single hop; the caller resolves any chain before calling. See
|
|
557
|
+
* `applyCapabilityRewrites`.
|
|
558
|
+
*
|
|
559
|
+
* A rewrite changes what the offer IS, not what the run asked for: the
|
|
560
|
+
* instance's stored modifier is never touched, so re-reading the run
|
|
561
|
+
* record still shows the grade of service that was requested.
|
|
562
|
+
*/
|
|
563
|
+
capabilityRewrites?: CapabilityRewrites;
|
|
564
|
+
/**
|
|
565
|
+
* Per-offered-capability crews matched by the caller that owns routing
|
|
566
|
+
* bindings. The pure engine cannot compute this; it stamps the supplied
|
|
567
|
+
* match result onto the order that is actually served.
|
|
568
|
+
*/
|
|
569
|
+
crewStamps?: CrewStamps;
|
|
548
570
|
}): TickResult;
|
|
549
571
|
/**
|
|
550
572
|
* The recursive tick worker. Runs this instance's own maintain → reap →
|
|
@@ -694,6 +716,33 @@ export declare class Engine {
|
|
|
694
716
|
* the order's digest — before any caller can execute a prompt or command.
|
|
695
717
|
*/
|
|
696
718
|
resolveOrder(order: Order): ResolvedInstructions;
|
|
719
|
+
/** Return the binding declaration that owns this artifact path, if any. */
|
|
720
|
+
private artifactBind;
|
|
721
|
+
/** Resolve a declared dot-path of object keys against an accepted artifact value. */
|
|
722
|
+
private boundValue;
|
|
723
|
+
/**
|
|
724
|
+
* The bind-time and reject-time modifier gate: membership in the def's
|
|
725
|
+
* declared `modifiers` set, and nothing else — byte for byte the rule the
|
|
726
|
+
* start path applies in `createInstanceInTx`. One value cannot be legal to
|
|
727
|
+
* start a run with and illegal to bind.
|
|
728
|
+
*
|
|
729
|
+
* `def` here is the PINNED snapshot, so the vocabulary checked is the one
|
|
730
|
+
* stamped on this run, not a later republish.
|
|
731
|
+
*
|
|
732
|
+
* The SHAPE of a name is constrained where a name is authored:
|
|
733
|
+
* `parseModifiers` in `src/defs.ts` refuses an empty name, a name containing
|
|
734
|
+
* whitespace, a name containing `MODIFIER_SEPARATOR`, and a duplicate.
|
|
735
|
+
* Re-testing shape here is what split the vocabulary in the first place — a
|
|
736
|
+
* value the parser admitted and `start_run` accepted, refused at bind.
|
|
737
|
+
*/
|
|
738
|
+
private assertBoundModifier;
|
|
739
|
+
/** Validate extraction before an acceptance branch changes an artifact. */
|
|
740
|
+
private validateArtifactBind;
|
|
741
|
+
/**
|
|
742
|
+
* Persist a declared instance-routing write and its single artifact-level
|
|
743
|
+
* audit event. Call only from an already-accepted branch inside its tx.
|
|
744
|
+
*/
|
|
745
|
+
private applyArtifactBind;
|
|
697
746
|
/**
|
|
698
747
|
* Commit a singleton/map output green — or born-reject it if an input moved.
|
|
699
748
|
*
|
|
@@ -755,7 +804,7 @@ export declare class Engine {
|
|
|
755
804
|
* See `docs/design.md` §24.9 for the full writeup and operator mitigations
|
|
756
805
|
* (`parallel: 1`, a generous `reapTtl:` on slow judge steps).
|
|
757
806
|
*/
|
|
758
|
-
reject(workflow: string, path: string, by: Author, text: string): {
|
|
807
|
+
reject(workflow: string, path: string, by: Author, text: string, requested?: string): {
|
|
759
808
|
outcome: 'rejected' | 'born-rejected';
|
|
760
809
|
reason?: string;
|
|
761
810
|
};
|