owenloop 0.4.0 → 0.5.0
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 +45 -0
- package/README.md +98 -25
- package/bin/owenloop.mjs +2 -2
- package/dist/packages/work/src/agent/brief.d.ts +172 -0
- package/dist/packages/work/src/agent/brief.js +193 -0
- package/dist/packages/work/src/agent/loop.d.ts +135 -0
- package/dist/packages/work/src/agent/loop.js +542 -0
- package/dist/packages/work/src/agent/workdir.d.ts +210 -0
- package/dist/packages/work/src/agent/workdir.js +319 -0
- package/dist/packages/work/src/bundle/cache.d.ts +90 -0
- package/dist/packages/work/src/bundle/cache.js +324 -0
- package/dist/packages/work/src/bundle/fetch.d.ts +85 -0
- package/dist/packages/work/src/bundle/fetch.js +325 -0
- package/dist/packages/work/src/bundle/types.d.ts +160 -0
- package/dist/packages/work/src/bundle/types.js +1 -0
- package/dist/packages/work/src/credentials/owenloop.d.ts +11 -0
- package/dist/packages/work/src/credentials/owenloop.js +28 -0
- package/dist/packages/work/src/credentials/reader.d.ts +36 -0
- package/dist/packages/work/src/credentials/reader.js +32 -0
- package/dist/packages/work/src/credentials/resolve.d.ts +19 -0
- package/dist/packages/work/src/credentials/resolve.js +56 -0
- package/dist/packages/work/src/exec/loop.d.ts +29 -0
- package/dist/packages/work/src/exec/loop.js +215 -0
- package/dist/packages/work/src/exec/receipt.d.ts +38 -0
- package/dist/packages/work/src/exec/receipt.js +21 -0
- package/dist/packages/work/src/exec/runner.d.ts +65 -0
- package/dist/packages/work/src/exec/runner.js +185 -0
- package/dist/packages/work/src/harness/child-env.d.ts +100 -0
- package/dist/packages/work/src/harness/child-env.js +127 -0
- package/dist/packages/work/src/harness/claude.d.ts +128 -0
- package/dist/packages/work/src/harness/claude.js +635 -0
- package/dist/packages/work/src/harness/codex.d.ts +110 -0
- package/dist/packages/work/src/harness/codex.js +896 -0
- package/dist/packages/work/src/harness/contract.d.ts +283 -0
- package/dist/packages/work/src/harness/contract.js +32 -0
- package/dist/packages/work/src/harness/fake.d.ts +59 -0
- package/dist/packages/work/src/harness/fake.js +90 -0
- package/dist/packages/work/src/harness/jsonrpc-stdio.d.ts +108 -0
- package/dist/packages/work/src/harness/jsonrpc-stdio.js +344 -0
- package/dist/packages/work/src/harness/permissions.d.ts +62 -0
- package/dist/packages/work/src/harness/permissions.js +93 -0
- package/dist/packages/work/src/harness/registry.d.ts +47 -0
- package/dist/packages/work/src/harness/registry.js +45 -0
- package/dist/packages/work/src/harness/session-store.d.ts +163 -0
- package/dist/packages/work/src/harness/session-store.js +319 -0
- package/dist/packages/work/src/harness/types.d.ts +29 -0
- package/dist/packages/work/src/harness/types.js +14 -0
- package/dist/packages/work/src/harnesses.d.ts +38 -0
- package/dist/packages/work/src/harnesses.js +38 -0
- package/dist/packages/work/src/hold/loop.d.ts +36 -0
- package/dist/packages/work/src/hold/loop.js +23 -0
- package/dist/packages/work/src/hold/mcp.d.ts +55 -0
- package/dist/packages/work/src/hold/mcp.js +149 -0
- package/dist/packages/work/src/hub/client.d.ts +22 -0
- package/dist/packages/work/src/hub/client.js +78 -0
- package/dist/packages/work/src/hub/types.d.ts +290 -0
- package/dist/packages/work/src/hub/types.js +28 -0
- package/dist/packages/work/src/lease/loop.d.ts +94 -0
- package/dist/packages/work/src/lease/loop.js +277 -0
- package/dist/packages/work/src/main.d.ts +1 -0
- package/dist/packages/work/src/main.js +48 -0
- package/dist/packages/work/src/mcp/server.d.ts +125 -0
- package/dist/packages/work/src/mcp/server.js +320 -0
- package/dist/packages/work/src/roles/agent-run.d.ts +118 -0
- package/dist/packages/work/src/roles/agent-run.js +447 -0
- package/dist/packages/work/src/roles/exec.d.ts +40 -0
- package/dist/packages/work/src/roles/exec.js +203 -0
- package/dist/packages/work/src/roles/hold.d.ts +68 -0
- package/dist/packages/work/src/roles/hold.js +324 -0
- package/dist/packages/work/src/roles/join.d.ts +18 -0
- package/dist/packages/work/src/roles/join.js +204 -0
- package/dist/packages/work/src/roles/lint.d.ts +59 -0
- package/dist/packages/work/src/roles/lint.js +200 -0
- package/dist/packages/work/src/roles/prepare.d.ts +1 -0
- package/dist/packages/work/src/roles/prepare.js +249 -0
- package/dist/packages/work/src/roles/release.d.ts +48 -0
- package/dist/packages/work/src/roles/release.js +137 -0
- package/dist/packages/work/src/roles/sessions.d.ts +61 -0
- package/dist/packages/work/src/roles/sessions.js +180 -0
- package/dist/packages/work/src/roles/settings.d.ts +6 -0
- package/dist/packages/work/src/roles/settings.js +66 -0
- package/dist/packages/work/src/roles/shift.d.ts +12 -0
- package/dist/packages/work/src/roles/shift.js +228 -0
- package/dist/packages/work/src/roles/signals.d.ts +55 -0
- package/dist/packages/work/src/roles/signals.js +62 -0
- package/dist/packages/work/src/settings/provision.d.ts +21 -0
- package/dist/packages/work/src/settings/provision.js +47 -0
- package/dist/packages/work/src/settings/settings.d.ts +120 -0
- package/dist/packages/work/src/settings/settings.js +116 -0
- package/dist/packages/work/src/shift/client.d.ts +24 -0
- package/dist/packages/work/src/shift/client.js +124 -0
- package/dist/packages/work/src/shift/loop.d.ts +120 -0
- package/dist/packages/work/src/shift/loop.js +468 -0
- package/dist/packages/work/src/shift/protocol.d.ts +91 -0
- package/dist/packages/work/src/shift/protocol.js +24 -0
- package/dist/packages/work/src/shift/routing.d.ts +35 -0
- package/dist/packages/work/src/shift/routing.js +50 -0
- package/dist/packages/work/src/shift/runtime.d.ts +43 -0
- package/dist/packages/work/src/shift/runtime.js +274 -0
- package/dist/packages/work/src/shift/server.d.ts +23 -0
- package/dist/packages/work/src/shift/server.js +716 -0
- package/dist/packages/work/src/shift/spawn.d.ts +86 -0
- package/dist/packages/work/src/shift/spawn.js +100 -0
- package/dist/packages/work/src/shift/state.d.ts +77 -0
- package/dist/packages/work/src/shift/state.js +162 -0
- package/dist/packages/work/src/usage.d.ts +6 -0
- package/dist/packages/work/src/usage.js +175 -0
- package/dist/{add.d.ts → src/add.d.ts} +12 -40
- package/dist/{add.js → src/add.js} +11 -176
- package/dist/src/cli.d.ts +147 -0
- package/dist/{cli.js → src/cli.js} +1643 -353
- package/dist/src/credentials.d.ts +280 -0
- package/dist/src/credentials.js +697 -0
- package/dist/{defs.js → src/defs.js} +59 -36
- package/dist/{engine.d.ts → src/engine.d.ts} +8 -8
- package/dist/{engine.js → src/engine.js} +29 -20
- package/dist/{hub.d.ts → src/hub.d.ts} +330 -2
- package/dist/{hub.js → src/hub.js} +531 -1
- package/dist/{index.d.ts → src/index.d.ts} +3 -1
- package/dist/{index.js → src/index.js} +2 -1
- package/dist/src/lock.d.ts +80 -0
- package/dist/src/lock.js +217 -0
- package/dist/src/mcp/serve.d.ts +85 -0
- package/dist/src/mcp/serve.js +702 -0
- package/dist/src/mcp/server.d.ts +132 -0
- package/dist/src/mcp/server.js +327 -0
- package/dist/{model.d.ts → src/model.d.ts} +59 -4
- package/dist/{model.js → src/model.js} +149 -22
- package/dist/{types.d.ts → src/types.d.ts} +66 -24
- package/dist/{util.d.ts → src/util.d.ts} +25 -0
- package/dist/{util.js → src/util.js} +26 -0
- package/dist/src/work-settings.d.ts +57 -0
- package/dist/src/work-settings.js +84 -0
- package/docs/authoring.md +102 -53
- package/docs/cli.md +883 -29
- package/docs/design.md +119 -45
- package/docs/embedding.md +39 -14
- package/examples/workflows/{command-worker.yaml → command-executor.yaml} +15 -15
- package/examples/workflows/compile-dev-playbook.yaml +338 -0
- package/examples/workflows/judges/gate-sharpness.md +39 -0
- package/examples/workflows/judges/security.md +34 -0
- package/package.json +17 -8
- package/dist/cli.d.ts +0 -83
- /package/dist/{defs.d.ts → src/defs.d.ts} +0 -0
- /package/dist/{factory.d.ts → src/factory.d.ts} +0 -0
- /package/dist/{factory.js → src/factory.js} +0 -0
- /package/dist/{paths.d.ts → src/paths.d.ts} +0 -0
- /package/dist/{paths.js → src/paths.js} +0 -0
- /package/dist/{schema.d.ts → src/schema.d.ts} +0 -0
- /package/dist/{schema.js → src/schema.js} +0 -0
- /package/dist/{store.d.ts → src/store.d.ts} +0 -0
- /package/dist/{store.js → src/store.js} +0 -0
- /package/dist/{types.js → src/types.js} +0 -0
- /package/dist/{untar.d.ts → src/untar.d.ts} +0 -0
- /package/dist/{untar.js → src/untar.js} +0 -0
|
@@ -35,13 +35,13 @@ const RAW_PRODUCE_KEYS = ['name', 'schema', 'judges', 'maxAttempts', 'maxSchemaF
|
|
|
35
35
|
* fields, so it gets its own allowlist rather than folding into
|
|
36
36
|
* RAW_PRODUCE_KEYS (§27 unknown-key rejection). */
|
|
37
37
|
const RAW_GROUP_KEYS = ['group', 'mode', 'of'];
|
|
38
|
-
const RAW_JUDGE_KEYS = ['name', 'body', 'bodyFile', 'model', 'inputs', 'cadence', 'maxRunsPerDay', '
|
|
38
|
+
const RAW_JUDGE_KEYS = ['name', 'body', 'bodyFile', 'model', 'inputs', 'cadence', 'maxRunsPerDay', 'executor', 'command', 'spec'];
|
|
39
39
|
/** Keys valid on a normal (non-calls:, non-include:) step entry. */
|
|
40
40
|
const RAW_STEP_KEYS = [
|
|
41
41
|
'name', 'consumes', 'produces', 'generates', 'invalidates', 'cadence',
|
|
42
42
|
'maxRunsPerDay', 'parallel', 'maxAttempts', 'maxSchemaFailures', 'model',
|
|
43
43
|
'workdir', 'terminal', 'effect', 'on', 'idleAfter', 'body', 'bodyFile',
|
|
44
|
-
'calls', 'reapTtl', '
|
|
44
|
+
'calls', 'reapTtl', 'capabilities', 'maxLease', 'x', 'executor', 'command', 'spec',
|
|
45
45
|
];
|
|
46
46
|
/** Keys valid on a calls: step entry — a DIFFERENT (smaller) shape than RawStep;
|
|
47
47
|
* the `calls:` key is what routes an entry here instead of RAW_STEP_KEYS. */
|
|
@@ -49,7 +49,7 @@ const RAW_CALLS_KEYS = ['name', 'calls', 'inputs', 'produces'];
|
|
|
49
49
|
/** Keys valid on an include: directive entry — the `include:` key is the
|
|
50
50
|
* discriminator that routes an entry here instead of RAW_STEP_KEYS/RAW_CALLS_KEYS. */
|
|
51
51
|
const RAW_INCLUDE_KEYS = ['include', 'as', 'inputs'];
|
|
52
|
-
const RAW_DEF_KEYS = ['name', 'title', 'description', 'inputs', 'steps', 'outputs', 'invariants', 'engine', 'x', '
|
|
52
|
+
const RAW_DEF_KEYS = ['name', 'title', 'description', 'inputs', 'steps', 'outputs', 'invariants', 'engine', 'x', 'executors'];
|
|
53
53
|
// ---- defaults ----------------------------------------------------------------
|
|
54
54
|
const DEFAULTS = {
|
|
55
55
|
cadence: '0s',
|
|
@@ -263,8 +263,8 @@ function parseJudges(v, ctx, baseDir) {
|
|
|
263
263
|
if (raw.maxRunsPerDay !== undefined) {
|
|
264
264
|
judge.maxRunsPerDay = asNumber(raw.maxRunsPerDay, DEFAULTS.maxRunsPerDay, `judge '${name}'.maxRunsPerDay`);
|
|
265
265
|
}
|
|
266
|
-
if (raw.
|
|
267
|
-
judge.
|
|
266
|
+
if (raw.executor !== undefined)
|
|
267
|
+
judge.executor = asString(raw.executor, `judge '${name}'.executor`);
|
|
268
268
|
if (raw.command !== undefined)
|
|
269
269
|
judge.command = asString(raw.command, `judge '${name}'.command`);
|
|
270
270
|
if (raw.spec !== undefined)
|
|
@@ -574,8 +574,8 @@ export function buildDef(raw, source, baseDir) {
|
|
|
574
574
|
}
|
|
575
575
|
if (r.x !== undefined)
|
|
576
576
|
def.x = asExtension(r.x, `workflow '${name}'.x`);
|
|
577
|
-
if (r.
|
|
578
|
-
def.
|
|
577
|
+
if (r.executors !== undefined)
|
|
578
|
+
def.executors = asStringArray(r.executors, `workflow '${name}'.executors`);
|
|
579
579
|
return def;
|
|
580
580
|
}
|
|
581
581
|
// ---- Mode 1 expand helpers (M1-EXPAND) ----------------------------------------
|
|
@@ -780,8 +780,8 @@ function synthesizeJudgeSteps(producerStepName, pat, producerConsumeStems) {
|
|
|
780
780
|
};
|
|
781
781
|
if (j.model !== undefined)
|
|
782
782
|
step.model = j.model;
|
|
783
|
-
if (j.
|
|
784
|
-
step.
|
|
783
|
+
if (j.executor !== undefined)
|
|
784
|
+
step.executor = j.executor;
|
|
785
785
|
if (j.command !== undefined)
|
|
786
786
|
step.command = j.command;
|
|
787
787
|
if (j.spec !== undefined)
|
|
@@ -879,8 +879,8 @@ function buildStep(rl, i, baseDir) {
|
|
|
879
879
|
step.workdir = asString(rl.workdir, `step '${name}'.workdir`);
|
|
880
880
|
if (rl.model !== undefined)
|
|
881
881
|
step.model = asString(rl.model, `step '${name}'.model`);
|
|
882
|
-
if (rl.
|
|
883
|
-
step.
|
|
882
|
+
if (rl.executor !== undefined)
|
|
883
|
+
step.executor = asString(rl.executor, `step '${name}'.executor`);
|
|
884
884
|
if (rl.command !== undefined)
|
|
885
885
|
step.command = asString(rl.command, `step '${name}'.command`);
|
|
886
886
|
if (rl.spec !== undefined)
|
|
@@ -929,12 +929,12 @@ function buildStep(rl, i, baseDir) {
|
|
|
929
929
|
const reapTtlStr = asString(rl.reapTtl, `step '${name}'.reapTtl`);
|
|
930
930
|
step.reapTtlMs = parseDurationMs(reapTtlStr);
|
|
931
931
|
}
|
|
932
|
-
// A2: opaque routing
|
|
932
|
+
// A2: opaque routing capabilities. Empty list normalizes to absent (claimable by
|
|
933
933
|
// any caller), mirroring the groups.length > 0 pattern below.
|
|
934
|
-
if (rl.
|
|
935
|
-
const ls = asStringArray(rl.
|
|
934
|
+
if (rl.capabilities !== undefined) {
|
|
935
|
+
const ls = asStringArray(rl.capabilities, `step '${name}'.capabilities`);
|
|
936
936
|
if (ls.length > 0)
|
|
937
|
-
step.
|
|
937
|
+
step.capabilities = ls;
|
|
938
938
|
}
|
|
939
939
|
// A3: per-step max total lease lifetime (duration string, same as reapTtl).
|
|
940
940
|
if (rl.maxLease !== undefined) {
|
|
@@ -1006,6 +1006,18 @@ export function validateDef(def) {
|
|
|
1006
1006
|
errors.push(`step '${l.name}' produces a per-element output but has no map (\$i) consume to bind it`);
|
|
1007
1007
|
}
|
|
1008
1008
|
}
|
|
1009
|
+
// a reduce-mode step whose only produces are collections can never fire: eligibleFirings'
|
|
1010
|
+
// reduce branch (src/model.ts) derives the discharge set from singletonProduces(step) only,
|
|
1011
|
+
// so zero singleton produces means outs.length === 0 and no firing is ever pushed — the step
|
|
1012
|
+
// is silently dead (collection debt owed forever, absent from eligible/pending/blocked).
|
|
1013
|
+
for (const l of def.steps) {
|
|
1014
|
+
const isReduce = l.consumes.some((c) => c.mode === 'reduce');
|
|
1015
|
+
const hasCollectionProduce = l.produces.some((p) => p.kind === 'collection');
|
|
1016
|
+
const hasSingletonProduce = l.produces.some((p) => p.kind === 'singleton');
|
|
1017
|
+
if (isReduce && hasCollectionProduce && !hasSingletonProduce) {
|
|
1018
|
+
errors.push(`step ${l.name} is reduce-mode but produces only collections; reduce steps can only discharge singleton produces`);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1009
1021
|
// same stem in both produces: and generates: on the same step is a hard error
|
|
1010
1022
|
for (const l of def.steps) {
|
|
1011
1023
|
if (!l.generates || l.generates.length === 0)
|
|
@@ -1086,40 +1098,40 @@ export function validateDef(def) {
|
|
|
1086
1098
|
}
|
|
1087
1099
|
}
|
|
1088
1100
|
}
|
|
1089
|
-
// W1-VALIDATE:
|
|
1090
|
-
// Only two hard requirements; any other
|
|
1101
|
+
// W1-VALIDATE: executor:/command: shape rules (declarative executor dispatch).
|
|
1102
|
+
// Only two hard requirements; any other executor value is fully opaque.
|
|
1091
1103
|
for (const l of def.steps) {
|
|
1092
|
-
const
|
|
1093
|
-
// Deliberately `l.
|
|
1094
|
-
// `(l.
|
|
1104
|
+
const executor = l.executor ?? 'agent';
|
|
1105
|
+
// Deliberately `l.executor === 'agent'` (explicit opt-in), NOT
|
|
1106
|
+
// `(l.executor ?? 'agent') === 'agent'` — that stricter form would also
|
|
1095
1107
|
// catch every default-agent step that already gets away with an empty
|
|
1096
1108
|
// body today (e.g. calls:-adjacent or generator-only fixtures), breaking
|
|
1097
|
-
// existing defs that never write `
|
|
1098
|
-
// an EXPLICIT `
|
|
1099
|
-
// unaffected while still catching "someone opted into the agent
|
|
1109
|
+
// existing defs that never write `executor:` at all. Scoping the check to
|
|
1110
|
+
// an EXPLICIT `executor: agent` keeps every pre-existing def byte-for-byte
|
|
1111
|
+
// unaffected while still catching "someone opted into the agent executor
|
|
1100
1112
|
// type and forgot a body".
|
|
1101
|
-
if (l.
|
|
1102
|
-
errors.push(`step '${l.name}' has
|
|
1113
|
+
if (l.executor === 'agent' && l.body.trim() === '') {
|
|
1114
|
+
errors.push(`step '${l.name}' has executor 'agent' but no body: (an agent step needs a prompt)`);
|
|
1103
1115
|
}
|
|
1104
|
-
else if (
|
|
1116
|
+
else if (executor === 'command') {
|
|
1105
1117
|
if (l.command === undefined) {
|
|
1106
|
-
errors.push(`step '${l.name}' has
|
|
1118
|
+
errors.push(`step '${l.name}' has executor 'command' but no command:`);
|
|
1107
1119
|
}
|
|
1108
1120
|
}
|
|
1109
|
-
// any other
|
|
1121
|
+
// any other executor value: opaque, no body/command requirement
|
|
1110
1122
|
}
|
|
1111
|
-
// W1-VALIDATE:
|
|
1112
|
-
// per-step `
|
|
1123
|
+
// W1-VALIDATE: executors: def-level allow-list typo guard. Applied AFTER the
|
|
1124
|
+
// per-step `executor` default (?? 'agent') — a def declaring `executors:
|
|
1113
1125
|
// [command]` (deliberately excluding 'agent') still fails a step that omits
|
|
1114
|
-
// `
|
|
1126
|
+
// `executor:` entirely, since its effective executor is 'agent'. This is
|
|
1115
1127
|
// intended (the list is exhaustive once declared), documented in
|
|
1116
1128
|
// docs/authoring.md.
|
|
1117
|
-
if (def.
|
|
1118
|
-
const allowed = new Set(def.
|
|
1129
|
+
if (def.executors && def.executors.length > 0) {
|
|
1130
|
+
const allowed = new Set(def.executors);
|
|
1119
1131
|
for (const l of def.steps) {
|
|
1120
|
-
const
|
|
1121
|
-
if (!allowed.has(
|
|
1122
|
-
errors.push(`step '${l.name}' has
|
|
1132
|
+
const executor = l.executor ?? 'agent';
|
|
1133
|
+
if (!allowed.has(executor)) {
|
|
1134
|
+
errors.push(`step '${l.name}' has executor '${executor}' but workflow '${def.name}'.executors does not list it`);
|
|
1123
1135
|
}
|
|
1124
1136
|
}
|
|
1125
1137
|
}
|
|
@@ -1147,6 +1159,17 @@ export function validateDef(def) {
|
|
|
1147
1159
|
errors.push(`step '${l.name}': idleAfter is set but 'idle' is not in on:; idleAfter is only meaningful with the idle trigger`);
|
|
1148
1160
|
}
|
|
1149
1161
|
}
|
|
1162
|
+
// an allGreen/idle evaluator step that declares consumes can never commit: both firings
|
|
1163
|
+
// (src/model.ts) are built with inputs: [], so the claim fingerprint is empty, but commit-time
|
|
1164
|
+
// casCheck (src/engine.ts) derives required inputs from consumes and finds no fingerprint
|
|
1165
|
+
// entry for them — every firing is born-rejected forever. Evaluators must declare their
|
|
1166
|
+
// output under generates: with no consumes: (see examples/workflows/sla-watchdog.yaml, monitor).
|
|
1167
|
+
for (const l of def.steps) {
|
|
1168
|
+
const triggers = l.on ?? ['inputsGreen'];
|
|
1169
|
+
if (triggers.some((t) => t === 'allGreen' || t === 'idle') && l.consumes.length > 0) {
|
|
1170
|
+
errors.push(`evaluator step ${l.name} (on: allGreen/idle) must not declare consumes; its firings carry no input fingerprint`);
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1150
1173
|
// M2-VALIDATE: calls: step per-def rules.
|
|
1151
1174
|
// Note: cross-def checks (target-def existence, child input-key validity) cannot be done here
|
|
1152
1175
|
// because validateDef is a pure per-def function with no resolver. Those checks live in loadDefs
|
|
@@ -45,11 +45,11 @@ export declare class SchemaRefusalError extends Error {
|
|
|
45
45
|
* step's daily run allowance is exhausted (binding over parallel); `'parallel-cap'`
|
|
46
46
|
* — the step's concurrency cap is the binding constraint. Always emitted by
|
|
47
47
|
* `applySchedule` or `tick`; never alters which firings are selected or claimed.
|
|
48
|
-
* `'
|
|
49
|
-
* intersect the step's declared
|
|
50
|
-
*
|
|
48
|
+
* `'capability-mismatch'` (A2) — the tick caller passed a capability filter that does not
|
|
49
|
+
* intersect the step's declared capabilities, so a peer orchestrator serving other
|
|
50
|
+
* capabilities leaves it for the matching caller.
|
|
51
51
|
*/
|
|
52
|
-
export type DeferredReason = 'in-flight' | 'cadence' | 'daily-budget' | 'parallel-cap' | '
|
|
52
|
+
export type DeferredReason = 'in-flight' | 'cadence' | 'daily-budget' | 'parallel-cap' | 'capability-mismatch';
|
|
53
53
|
export interface DeferredFiring {
|
|
54
54
|
step: string;
|
|
55
55
|
key: string;
|
|
@@ -428,7 +428,7 @@ export declare class Engine {
|
|
|
428
428
|
tick(workflow: string, opts?: {
|
|
429
429
|
now?: number;
|
|
430
430
|
deep?: boolean;
|
|
431
|
-
|
|
431
|
+
capabilities?: string[];
|
|
432
432
|
}): TickResult;
|
|
433
433
|
/**
|
|
434
434
|
* The recursive tick worker. Runs this instance's own maintain → reap →
|
|
@@ -501,9 +501,9 @@ export declare class Engine {
|
|
|
501
501
|
private callsDescendTargets;
|
|
502
502
|
/**
|
|
503
503
|
* Per-step cadence + daily budget + parallel cap over the eligible firings.
|
|
504
|
-
* A2: `
|
|
505
|
-
* step whose own `
|
|
506
|
-
* intersect; a disjoint step's firings are deferred as `'
|
|
504
|
+
* A2: `capabilities` is the tick caller's optional claim filter — when non-empty, a
|
|
505
|
+
* step whose own `capabilities` are also non-empty is only schedulable when the two
|
|
506
|
+
* intersect; a disjoint step's firings are deferred as `'capability-mismatch'`.
|
|
507
507
|
* Filtering here (before cadence/budget) means a mismatched firing never
|
|
508
508
|
* consumes the caller's slots and never perturbs cadence math.
|
|
509
509
|
*/
|
|
@@ -806,7 +806,7 @@ export class Engine {
|
|
|
806
806
|
* only this instance's own orders. See `TickResult` for the fold semantics.
|
|
807
807
|
*/
|
|
808
808
|
tick(workflow, opts = {}) {
|
|
809
|
-
return this.tickInternal(workflow, opts.now ?? nowMs(), opts.deep ?? true, opts.
|
|
809
|
+
return this.tickInternal(workflow, opts.now ?? nowMs(), opts.deep ?? true, opts.capabilities ?? [], new Set(), 0);
|
|
810
810
|
}
|
|
811
811
|
/**
|
|
812
812
|
* The recursive tick worker. Runs this instance's own maintain → reap →
|
|
@@ -847,7 +847,7 @@ export class Engine {
|
|
|
847
847
|
* edge it hangs from. The guard is silent (no debt/reasons/events), mirroring
|
|
848
848
|
* the abort discipline of `publishCallsGreen`/`provisionCallsChild`.
|
|
849
849
|
*/
|
|
850
|
-
tickInternal(workflow, now, deep,
|
|
850
|
+
tickInternal(workflow, now, deep, capabilities, visited, depth, parentEdge) {
|
|
851
851
|
if (depth > this.maxCallDepth) {
|
|
852
852
|
throw new Error(`calls depth limit exceeded (maxCallDepth=${this.maxCallDepth}) ticking '${workflow}': `
|
|
853
853
|
+ `a calls: composition is deeper than the bound, which usually means a calls: cycle `
|
|
@@ -893,7 +893,7 @@ export class Engine {
|
|
|
893
893
|
// Compute time facts for idle eligibility (clock-read boundary).
|
|
894
894
|
const timeFacts = this.computeTimeFacts(def, workflow, arts, now);
|
|
895
895
|
const firings = eligibleFirings(def, arts, timeFacts);
|
|
896
|
-
const { selected, deferred } = this.applySchedule(workflow, def, firings, now,
|
|
896
|
+
const { selected, deferred } = this.applySchedule(workflow, def, firings, now, capabilities);
|
|
897
897
|
// Clear alarm_at for any idle firing that was selected (consume the alarm).
|
|
898
898
|
for (const f of selected) {
|
|
899
899
|
if (f.cause === 'idle') {
|
|
@@ -927,7 +927,7 @@ export class Engine {
|
|
|
927
927
|
// subtree — do not tick grandchildren off a frame that issued nothing.
|
|
928
928
|
if (deep && !staleEdge) {
|
|
929
929
|
for (const { step, child } of this.callsDescendTargets(workflow, def)) {
|
|
930
|
-
const cr = this.tickInternal(child.id, now, deep,
|
|
930
|
+
const cr = this.tickInternal(child.id, now, deep, capabilities, visited, depth + 1, {
|
|
931
931
|
parentWf: workflow,
|
|
932
932
|
step,
|
|
933
933
|
callsStem: step.produces[0].stem,
|
|
@@ -1001,13 +1001,13 @@ export class Engine {
|
|
|
1001
1001
|
}
|
|
1002
1002
|
/**
|
|
1003
1003
|
* Per-step cadence + daily budget + parallel cap over the eligible firings.
|
|
1004
|
-
* A2: `
|
|
1005
|
-
* step whose own `
|
|
1006
|
-
* intersect; a disjoint step's firings are deferred as `'
|
|
1004
|
+
* A2: `capabilities` is the tick caller's optional claim filter — when non-empty, a
|
|
1005
|
+
* step whose own `capabilities` are also non-empty is only schedulable when the two
|
|
1006
|
+
* intersect; a disjoint step's firings are deferred as `'capability-mismatch'`.
|
|
1007
1007
|
* Filtering here (before cadence/budget) means a mismatched firing never
|
|
1008
1008
|
* consumes the caller's slots and never perturbs cadence math.
|
|
1009
1009
|
*/
|
|
1010
|
-
applySchedule(workflow, def, firings, now,
|
|
1010
|
+
applySchedule(workflow, def, firings, now, capabilities) {
|
|
1011
1011
|
const midnight = localMidnightMs(now);
|
|
1012
1012
|
const selected = [];
|
|
1013
1013
|
const deferred = [];
|
|
@@ -1021,13 +1021,13 @@ export class Engine {
|
|
|
1021
1021
|
const stepFirings = firings.filter((f) => f.step === step.name);
|
|
1022
1022
|
if (stepFirings.length === 0)
|
|
1023
1023
|
continue;
|
|
1024
|
-
// A2: caller
|
|
1024
|
+
// A2: caller capability filter vs. step capabilities. Both non-empty and disjoint →
|
|
1025
1025
|
// this caller must not claim the step; defer every firing and skip it
|
|
1026
1026
|
// before it touches cadence/budget/slot math.
|
|
1027
|
-
if (
|
|
1028
|
-
!step.
|
|
1027
|
+
if (capabilities.length > 0 && step.capabilities && step.capabilities.length > 0 &&
|
|
1028
|
+
!step.capabilities.some((l) => capabilities.includes(l))) {
|
|
1029
1029
|
for (const f of stepFirings)
|
|
1030
|
-
defer(f, '
|
|
1030
|
+
defer(f, 'capability-mismatch');
|
|
1031
1031
|
continue;
|
|
1032
1032
|
}
|
|
1033
1033
|
const latest = this.store.latestRun(workflow, step.name);
|
|
@@ -1187,8 +1187,8 @@ export class Engine {
|
|
|
1187
1187
|
order.workdir = step.workdir;
|
|
1188
1188
|
if (step.model !== undefined)
|
|
1189
1189
|
order.model = step.model;
|
|
1190
|
-
if (step.
|
|
1191
|
-
order.
|
|
1190
|
+
if (step.executor !== undefined)
|
|
1191
|
+
order.executor = step.executor;
|
|
1192
1192
|
if (step.command !== undefined)
|
|
1193
1193
|
order.command = step.command;
|
|
1194
1194
|
if (step.spec !== undefined)
|
|
@@ -1337,7 +1337,7 @@ export class Engine {
|
|
|
1337
1337
|
const req = requiredInputs(def, arts, art);
|
|
1338
1338
|
const cas = this.casCheck(arts, req, r.fingerprint ?? {});
|
|
1339
1339
|
if (cas.moved) {
|
|
1340
|
-
this.bornReject(art, cas.moved);
|
|
1340
|
+
this.bornReject(art, cas.moved, cas.reason);
|
|
1341
1341
|
this.releaseLeaseOnBornReject(workflow, run);
|
|
1342
1342
|
this.settle(workflow, def);
|
|
1343
1343
|
return { path, outcome: 'born-rejected', reason: cas.reason };
|
|
@@ -1419,7 +1419,7 @@ export class Engine {
|
|
|
1419
1419
|
if (cas.moved) {
|
|
1420
1420
|
const seal = arts.get(sealPath(stem));
|
|
1421
1421
|
if (seal)
|
|
1422
|
-
this.bornReject(seal, cas.moved);
|
|
1422
|
+
this.bornReject(seal, cas.moved, cas.reason);
|
|
1423
1423
|
this.releaseLeaseOnBornReject(workflow, run);
|
|
1424
1424
|
this.settle(workflow, def);
|
|
1425
1425
|
return { outcome: 'born-rejected', created: [], reason: cas.reason };
|
|
@@ -1512,7 +1512,7 @@ export class Engine {
|
|
|
1512
1512
|
const req = plainConsumes(step).map((c) => c.stem);
|
|
1513
1513
|
const cas = this.casCheck(arts, req, r.fingerprint ?? {});
|
|
1514
1514
|
if (cas.moved) {
|
|
1515
|
-
this.bornReject(sealArt, cas.moved);
|
|
1515
|
+
this.bornReject(sealArt, cas.moved, cas.reason);
|
|
1516
1516
|
this.releaseLeaseOnBornReject(workflow, run);
|
|
1517
1517
|
this.settle(workflow, def);
|
|
1518
1518
|
return { path: sealP, outcome: 'born-rejected', reason: cas.reason };
|
|
@@ -2297,13 +2297,13 @@ export class Engine {
|
|
|
2297
2297
|
});
|
|
2298
2298
|
}
|
|
2299
2299
|
}
|
|
2300
|
-
bornReject(art, movedPath) {
|
|
2300
|
+
bornReject(art, movedPath, reasonText) {
|
|
2301
2301
|
this.store.putArtifact({
|
|
2302
2302
|
...art,
|
|
2303
2303
|
acceptance: 'rejected',
|
|
2304
2304
|
reasons: [
|
|
2305
2305
|
...art.reasons,
|
|
2306
|
-
reason('born-rejected', 'structural', 'engine', `born-rejected: ${movedPath} moved during this run`, art.version),
|
|
2306
|
+
reason('born-rejected', 'structural', 'engine', `born-rejected: ${reasonText ?? `${movedPath} moved during this run`}`, art.version),
|
|
2307
2307
|
],
|
|
2308
2308
|
});
|
|
2309
2309
|
}
|
|
@@ -2315,7 +2315,16 @@ export class Engine {
|
|
|
2315
2315
|
}
|
|
2316
2316
|
if (!fingerprintMatches(arts, req, fp)) {
|
|
2317
2317
|
const moved = req.find((p) => (arts.get(p)?.version ?? -1) !== fp[p]) ?? req[0] ?? 'inputs';
|
|
2318
|
-
|
|
2318
|
+
// Two structurally different causes share this branch: (a) ABSENT — the path
|
|
2319
|
+
// was never in the claim fingerprint at all (e.g. an allGreen/idle firing whose
|
|
2320
|
+
// inputs: [] yields fp={}, but the step still declares consumes:), so there is
|
|
2321
|
+
// no claimed version to have "moved" from; (b) CHANGED — the path WAS
|
|
2322
|
+
// fingerprinted but a concurrent commit moved it since claim. Keep the wording
|
|
2323
|
+
// distinct so the diagnostic doesn't lie about case (a).
|
|
2324
|
+
if (fp[moved] === undefined) {
|
|
2325
|
+
return { moved, reason: `${moved} was not in the claim fingerprint (this firing carried no input version for it)` };
|
|
2326
|
+
}
|
|
2327
|
+
return { moved, reason: `${moved} moved version during this run (claimed v${fp[moved]}, now v${arts.get(moved)?.version ?? -1})` };
|
|
2319
2328
|
}
|
|
2320
2329
|
return {};
|
|
2321
2330
|
}
|