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/mcp/serve.d.ts
CHANGED
|
@@ -44,9 +44,20 @@ import type { LineStream } from './server.ts';
|
|
|
44
44
|
* command falls back to `process.stdin`).
|
|
45
45
|
*/
|
|
46
46
|
export interface McpIo extends CredentialIO {
|
|
47
|
+
/** The session's working directory — the repo the MCP host was launched in. */
|
|
48
|
+
cwd: string;
|
|
47
49
|
out: (line: string) => void;
|
|
48
50
|
err: (line: string) => void;
|
|
49
51
|
stdinStream?: LineStream;
|
|
52
|
+
/**
|
|
53
|
+
* Local command runner, used only to read the git `origin` remote for the
|
|
54
|
+
* `start_run` scope default. Without it the default cannot be resolved.
|
|
55
|
+
*/
|
|
56
|
+
runCommand?: (cmd: string, args: string[]) => {
|
|
57
|
+
status: number | null;
|
|
58
|
+
stdout: string;
|
|
59
|
+
stderr: string;
|
|
60
|
+
};
|
|
50
61
|
principalKeys?: Pick<PrincipalKeyManager, 'inspect' | 'resolveRef' | 'withSigningKey'>;
|
|
51
62
|
/** Injectable ssh-keygen seam for hermetic submit-proof tests. */
|
|
52
63
|
sshProcess?: SshProcessAdapter;
|
|
@@ -95,6 +106,17 @@ export interface McpIo extends CredentialIO {
|
|
|
95
106
|
* tool error instead of a dead server.
|
|
96
107
|
*/
|
|
97
108
|
export declare function resolveMcpOrigin(io: McpIo, hubFlag: string | undefined): string;
|
|
109
|
+
/**
|
|
110
|
+
* The default `scope` for a run started from inside a repo session: the repo
|
|
111
|
+
* name, taken from the `origin` remote's URL (last path segment, trailing
|
|
112
|
+
* `.git` removed). Worktree-stable by construction — every checkout of one repo
|
|
113
|
+
* reports the same remote, whereas the directory name differs per worktree.
|
|
114
|
+
*
|
|
115
|
+
* Returns `undefined` — meaning "send no scope at all" — for every failure:
|
|
116
|
+
* no runner seam, not a git repo, no `origin` remote, empty or unparseable URL,
|
|
117
|
+
* or a segment outside the legal charset. Never guesses a label.
|
|
118
|
+
*/
|
|
119
|
+
export declare function resolveRepoScope(io: McpIo): string | undefined;
|
|
98
120
|
/**
|
|
99
121
|
* Run the `owenloop mcp` command: resolve the origin, decide the enrollment
|
|
100
122
|
* gate, build the tool list, construct the JSON-RPC server, and pump stdin until
|
package/dist/src/mcp/serve.js
CHANGED
|
@@ -109,6 +109,30 @@ export function resolveMcpOrigin(io, hubFlag) {
|
|
|
109
109
|
}
|
|
110
110
|
return DEFAULT_HUB;
|
|
111
111
|
}
|
|
112
|
+
/** Repo-name charset — kept local so this module does not depend on the installer. */
|
|
113
|
+
const REPO_SEGMENT_RE = /^[A-Za-z0-9._-]+$/;
|
|
114
|
+
/**
|
|
115
|
+
* The default `scope` for a run started from inside a repo session: the repo
|
|
116
|
+
* name, taken from the `origin` remote's URL (last path segment, trailing
|
|
117
|
+
* `.git` removed). Worktree-stable by construction — every checkout of one repo
|
|
118
|
+
* reports the same remote, whereas the directory name differs per worktree.
|
|
119
|
+
*
|
|
120
|
+
* Returns `undefined` — meaning "send no scope at all" — for every failure:
|
|
121
|
+
* no runner seam, not a git repo, no `origin` remote, empty or unparseable URL,
|
|
122
|
+
* or a segment outside the legal charset. Never guesses a label.
|
|
123
|
+
*/
|
|
124
|
+
export function resolveRepoScope(io) {
|
|
125
|
+
if (io.runCommand === undefined)
|
|
126
|
+
return undefined;
|
|
127
|
+
const r = io.runCommand('git', ['-C', io.cwd, 'remote', 'get-url', 'origin']);
|
|
128
|
+
if (r.status !== 0)
|
|
129
|
+
return undefined;
|
|
130
|
+
const url = r.stdout.trim().replace(/\/+$/, '');
|
|
131
|
+
if (url === '')
|
|
132
|
+
return undefined;
|
|
133
|
+
const segment = (url.split(/[/:]/).pop() ?? '').replace(/\.git$/, '');
|
|
134
|
+
return REPO_SEGMENT_RE.test(segment) ? segment : undefined;
|
|
135
|
+
}
|
|
112
136
|
// ---- the authenticated hub client -------------------------------------------
|
|
113
137
|
/** The non-interactive "you are not authenticated" instruction (Decision 8). */
|
|
114
138
|
function loginHint(origin) {
|
|
@@ -322,13 +346,13 @@ function warnMcpUnsigned(deps, reason) {
|
|
|
322
346
|
deps.io.err(`owenloop mcp: ${reason}`);
|
|
323
347
|
}
|
|
324
348
|
/**
|
|
325
|
-
* The
|
|
349
|
+
* The 20 baseline tools — names, descriptions, and schemas mirror the hub's own
|
|
326
350
|
* HTTP-MCP toolset (owenloop-service `apps/hub-edge/src/mcp/tools.ts`); each maps
|
|
327
351
|
* to an H3 `/api/*` REST mirror. Descriptions say "Scoped Identity" for the identity
|
|
328
352
|
* (wire names keep `agent`), never "tool" (model-doc §0/§10).
|
|
329
353
|
*
|
|
330
354
|
* This is not the server's whole tool list. `runMcpCommand` assembles the full
|
|
331
|
-
* set: these
|
|
355
|
+
* set: these 20, plus `createAgentTool`, plus the four crew tools from
|
|
332
356
|
* `buildCrewTools` (below — deliberately NOT folded in here, since they do not
|
|
333
357
|
* mirror the hub's own MCP toolset), plus the conditionally-registered
|
|
334
358
|
* `stageEnrollmentTool`.
|
|
@@ -340,7 +364,16 @@ function buildBaselineTools(deps) {
|
|
|
340
364
|
description: 'THE verb. With workflow: ticks it and returns the next work order(s), or a status summary if none. Without workflow: the inbox of started instances. Serves only YOUR OWN runs by default. Pass serve_crews to partition your own runs further (intersects with each step\'s capabilities; absent or [] = no capability filter). serve_crews is ignored in inbox mode (no workflow).',
|
|
341
365
|
inputSchema: {
|
|
342
366
|
type: 'object',
|
|
343
|
-
properties: {
|
|
367
|
+
properties: {
|
|
368
|
+
workflow: { type: 'string' },
|
|
369
|
+
serve_crews: { type: 'array', items: { type: 'string' } },
|
|
370
|
+
serve_capabilities: {
|
|
371
|
+
type: 'array',
|
|
372
|
+
items: { type: 'string' },
|
|
373
|
+
description: 'Capability keys this caller serves, raw (bare names and exact compounds). ' +
|
|
374
|
+
'Shifts compute this from their effective rosters; other callers normally omit it.',
|
|
375
|
+
},
|
|
376
|
+
},
|
|
344
377
|
additionalProperties: false,
|
|
345
378
|
},
|
|
346
379
|
handler: passthrough(deps, (a) => ({ method: 'POST', path: '/api/whats_next', body: a })),
|
|
@@ -389,6 +422,19 @@ function buildBaselineTools(deps) {
|
|
|
389
422
|
},
|
|
390
423
|
handler: passthrough(deps, (a) => ({ method: 'POST', path: '/api/reject_artifact', body: a })),
|
|
391
424
|
},
|
|
425
|
+
{
|
|
426
|
+
name: 'retry_artifact',
|
|
427
|
+
description: "The human stall-clearing lever: re-arm a stalled or rejected artifact to 'owed', resetting its " +
|
|
428
|
+
'reject counters. This is also the answer path for a worker that escalated with `ask` — `text` ' +
|
|
429
|
+
"rides to the next producer on the artifact's reason thread. Omit `text` for a bare stall-clear.",
|
|
430
|
+
inputSchema: {
|
|
431
|
+
type: 'object',
|
|
432
|
+
properties: { workflow: { type: 'string' }, path: { type: 'string' }, text: { type: 'string' } },
|
|
433
|
+
required: ['workflow', 'path'],
|
|
434
|
+
additionalProperties: false,
|
|
435
|
+
},
|
|
436
|
+
handler: passthrough(deps, (a) => ({ method: 'POST', path: '/api/retry_artifact', body: a })),
|
|
437
|
+
},
|
|
392
438
|
{
|
|
393
439
|
name: 'provide_input',
|
|
394
440
|
description: 'The human-gate answer path: provide a value for a seeded/owed input.',
|
|
@@ -406,14 +452,30 @@ function buildBaselineTools(deps) {
|
|
|
406
452
|
},
|
|
407
453
|
{
|
|
408
454
|
name: 'start_run',
|
|
409
|
-
description: 'Create a new workflow instance from a definition name, optionally seeding provided inputs.'
|
|
455
|
+
description: 'Create a new workflow instance from a definition name, optionally seeding provided inputs. ' +
|
|
456
|
+
'`scope` is a free routing label recorded on the run; when omitted it defaults to this ' +
|
|
457
|
+
"session's repository name (the `origin` remote's last path segment) when one can be " +
|
|
458
|
+
'determined, and is sent as nothing otherwise. `priority` is the rate-limit band; omit it ' +
|
|
459
|
+
'and the hub applies `normal`.',
|
|
410
460
|
inputSchema: {
|
|
411
461
|
type: 'object',
|
|
412
|
-
properties: {
|
|
462
|
+
properties: {
|
|
463
|
+
workflow_name: { type: 'string' },
|
|
464
|
+
provide: { type: 'object', additionalProperties: true },
|
|
465
|
+
scope: { type: 'string' },
|
|
466
|
+
// Unlike crew `kind`/`principalKind`, this is a fixed local wire
|
|
467
|
+
// contract, so the MCP schema rejects an out-of-set value too.
|
|
468
|
+
priority: { type: 'string', enum: ['low', 'normal', 'high'] },
|
|
469
|
+
},
|
|
413
470
|
required: ['workflow_name'],
|
|
414
471
|
additionalProperties: false,
|
|
415
472
|
},
|
|
416
|
-
handler: passthrough(deps, (a) => ({
|
|
473
|
+
handler: passthrough(deps, (a) => ({
|
|
474
|
+
method: 'POST',
|
|
475
|
+
path: '/api/start_run',
|
|
476
|
+
// A default, never an override: explicit `scope`, including '', wins.
|
|
477
|
+
body: deps.repoScope !== undefined && !('scope' in a) ? { ...a, scope: deps.repoScope } : a,
|
|
478
|
+
})),
|
|
417
479
|
},
|
|
418
480
|
{
|
|
419
481
|
name: 'create_workflow',
|
|
@@ -532,6 +594,12 @@ function buildBaselineTools(deps) {
|
|
|
532
594
|
properties: {
|
|
533
595
|
name: { type: 'string' },
|
|
534
596
|
serve_crews: { type: 'array', items: { type: 'string' } },
|
|
597
|
+
serve_capabilities: {
|
|
598
|
+
type: 'array',
|
|
599
|
+
items: { type: 'string' },
|
|
600
|
+
description: 'Capability keys this caller serves, raw (bare names and exact compounds). ' +
|
|
601
|
+
'Shifts compute this from their effective rosters; other callers normally omit it.',
|
|
602
|
+
},
|
|
535
603
|
shift_id: { type: 'string' },
|
|
536
604
|
started_at: { type: 'number' },
|
|
537
605
|
},
|
|
@@ -546,6 +614,18 @@ function buildBaselineTools(deps) {
|
|
|
546
614
|
inputSchema: { type: 'object', properties: {}, additionalProperties: false },
|
|
547
615
|
handler: passthrough(deps, () => ({ method: 'GET', path: '/api/shifts' })),
|
|
548
616
|
},
|
|
617
|
+
{
|
|
618
|
+
name: 'get_rosters',
|
|
619
|
+
description: "The org's roster cascade: one org-global capability table plus optional per-crew tables. These rows select harness/model/effort after the hub has already routed work to a crew.",
|
|
620
|
+
inputSchema: { type: 'object', properties: {}, additionalProperties: false },
|
|
621
|
+
handler: passthrough(deps, () => ({ method: 'GET', path: '/api/rosters' })),
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
name: 'list_harness_models',
|
|
625
|
+
description: "The hub's known harnesses and model snapshots, including each model's supported effort values. Read-only; roster writes stay in the terminal CLI.",
|
|
626
|
+
inputSchema: { type: 'object', properties: {}, additionalProperties: false },
|
|
627
|
+
handler: passthrough(deps, () => ({ method: 'GET', path: '/api/harness_models' })),
|
|
628
|
+
},
|
|
549
629
|
{
|
|
550
630
|
name: 'wake',
|
|
551
631
|
description: 'A cheap "has anything relevant to you changed since cursor X" pre-check for a polling loop — returns { cursor, changed }. Keep the returned cursor and pass it next time; call whats_next ONLY when changed is true. Omit cursor to bootstrap. NOT a substitute for whats_next — it never returns work orders, only whether to ask.',
|
|
@@ -636,7 +716,7 @@ function createAgentTool(deps) {
|
|
|
636
716
|
},
|
|
637
717
|
};
|
|
638
718
|
}
|
|
639
|
-
/** Tool
|
|
719
|
+
/** Tool 20 (gated) — `stage_enrollment`: a plain passthrough (join codes are transcript-legal per model-doc §6). */
|
|
640
720
|
function stageEnrollmentTool(deps) {
|
|
641
721
|
return {
|
|
642
722
|
name: 'stage_enrollment',
|
|
@@ -814,7 +894,7 @@ async function shouldRegisterEnrollment(deps) {
|
|
|
814
894
|
*/
|
|
815
895
|
export async function runMcpCommand(io, opts) {
|
|
816
896
|
const origin = resolveMcpOrigin(io, opts.hubFlag);
|
|
817
|
-
const deps = { io, origin };
|
|
897
|
+
const deps = { io, origin, repoScope: resolveRepoScope(io) };
|
|
818
898
|
const tools = [...buildBaselineTools(deps), createAgentTool(deps), ...buildCrewTools(deps)];
|
|
819
899
|
if (await shouldRegisterEnrollment(deps))
|
|
820
900
|
tools.push(stageEnrollmentTool(deps));
|
package/dist/src/model.d.ts
CHANGED
|
@@ -79,6 +79,8 @@ export declare function stepMode(step: StepDef): StepMode;
|
|
|
79
79
|
*/
|
|
80
80
|
export declare function judgeNameOf(step: StepDef): string;
|
|
81
81
|
export declare function mapProduce(step: StepDef): ProducePattern | undefined;
|
|
82
|
+
/** All per-element outputs a map step owns for each input index. */
|
|
83
|
+
export declare function mapProduces(step: StepDef): ProducePattern[];
|
|
82
84
|
/**
|
|
83
85
|
* The concrete input artifact a map element binds on for index `i`. Normally the
|
|
84
86
|
* bare collection member `stem[i]`. But when the map consume carries a suffix
|
package/dist/src/model.js
CHANGED
|
@@ -43,6 +43,10 @@ export function judgeNameOf(step) {
|
|
|
43
43
|
export function mapProduce(step) {
|
|
44
44
|
return step.produces.find((p) => p.kind === 'map');
|
|
45
45
|
}
|
|
46
|
+
/** All per-element outputs a map step owns for each input index. */
|
|
47
|
+
export function mapProduces(step) {
|
|
48
|
+
return step.produces.filter((p) => p.kind === 'map');
|
|
49
|
+
}
|
|
46
50
|
/**
|
|
47
51
|
* The concrete input artifact a map element binds on for index `i`. Normally the
|
|
48
52
|
* bare collection member `stem[i]`. But when the map consume carries a suffix
|
|
@@ -451,8 +455,8 @@ export function pendingOwed(def, arts) {
|
|
|
451
455
|
const mode = stepMode(step);
|
|
452
456
|
if (mode === 'map') {
|
|
453
457
|
const mc = mapConsume(step);
|
|
454
|
-
const
|
|
455
|
-
if (!mc ||
|
|
458
|
+
const mps = mapProduces(step);
|
|
459
|
+
if (!mc || mps.length === 0)
|
|
456
460
|
continue;
|
|
457
461
|
// the bare members fix the index space; a child is owed only once that
|
|
458
462
|
// index's actual consumed input (bare member, or its suffixed child) greens
|
|
@@ -462,7 +466,8 @@ export function pendingOwed(def, arts) {
|
|
|
462
466
|
continue;
|
|
463
467
|
if (!isGreen(arts.get(mapInputPath(mc, el.index))))
|
|
464
468
|
continue;
|
|
465
|
-
|
|
469
|
+
for (const mp of mps)
|
|
470
|
+
ensure(bindProduce(mp, el.index), step.name);
|
|
466
471
|
}
|
|
467
472
|
}
|
|
468
473
|
else {
|
|
@@ -627,8 +632,8 @@ export function eligibleFirings(def, arts, time, opts) {
|
|
|
627
632
|
else if (mode === 'map') {
|
|
628
633
|
if (plainSatisfied) {
|
|
629
634
|
const mc = mapConsume(step);
|
|
630
|
-
const
|
|
631
|
-
if (mc &&
|
|
635
|
+
const mps = mapProduces(step);
|
|
636
|
+
if (mc && mps.length > 0) {
|
|
632
637
|
for (const m of members(arts, mc.stem)) {
|
|
633
638
|
const el = parseElement(m.path);
|
|
634
639
|
if (!el)
|
|
@@ -638,22 +643,25 @@ export function eligibleFirings(def, arts, time, opts) {
|
|
|
638
643
|
const inPath = mapInputPath(mc, el.index);
|
|
639
644
|
if (!isGreen(arts.get(inPath)))
|
|
640
645
|
continue;
|
|
641
|
-
const
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
646
|
+
const outputs = mps
|
|
647
|
+
.map((mp) => bindProduce(mp, el.index))
|
|
648
|
+
.filter((outPath) => {
|
|
649
|
+
const outArt = arts.get(outPath);
|
|
650
|
+
// Group membership is singleton-only (§26.3), so a map-produce
|
|
651
|
+
// path cannot be a group member today. Keep the defensive check
|
|
652
|
+
// so a future relaxation cannot reopen the eligibility/commit gap.
|
|
653
|
+
return isDebt(outArt)
|
|
654
|
+
&& (opts?.ignoreFreeze || !frozen(outArt, step))
|
|
655
|
+
&& groupBlockingWinner(def, arts, outPath) === undefined;
|
|
656
|
+
});
|
|
657
|
+
if (outputs.length === 0)
|
|
650
658
|
continue;
|
|
651
659
|
firings.push({
|
|
652
660
|
step: step.name,
|
|
653
661
|
key: m.path,
|
|
654
662
|
index: el.index,
|
|
655
663
|
inputs: [inPath, ...plainPaths],
|
|
656
|
-
outputs
|
|
664
|
+
outputs,
|
|
657
665
|
});
|
|
658
666
|
}
|
|
659
667
|
}
|
|
@@ -808,7 +816,7 @@ export function canEverFire(step, def, reachable) {
|
|
|
808
816
|
case 'reduce':
|
|
809
817
|
return singletonProduces(step).length > 0;
|
|
810
818
|
case 'map':
|
|
811
|
-
return
|
|
819
|
+
return mapProduces(step).length > 0 && !!mapConsume(step);
|
|
812
820
|
case 'plain':
|
|
813
821
|
return plainOutputs(step).length > 0;
|
|
814
822
|
default:
|
|
@@ -1116,12 +1124,12 @@ function stepOwesSomething(def, step, arts) {
|
|
|
1116
1124
|
const mode = stepMode(step);
|
|
1117
1125
|
if (mode === 'map') {
|
|
1118
1126
|
const mc = mapConsume(step);
|
|
1119
|
-
const
|
|
1120
|
-
if (!mc ||
|
|
1127
|
+
const mps = mapProduces(step);
|
|
1128
|
+
if (!mc || mps.length === 0)
|
|
1121
1129
|
return false;
|
|
1122
1130
|
return members(arts, mc.stem).some((m) => {
|
|
1123
1131
|
const el = parseElement(m.path);
|
|
1124
|
-
return el
|
|
1132
|
+
return el !== null && mps.some((mp) => isDebt(arts.get(bindProduce(mp, el.index))));
|
|
1125
1133
|
});
|
|
1126
1134
|
}
|
|
1127
1135
|
return plainOutputs(step).some((p) => isDebt(arts.get(p)));
|
|
@@ -1151,13 +1159,13 @@ function blockingInputs(def, step, arts) {
|
|
|
1151
1159
|
// a map child that owes but can't fire is blocked on its per-element input
|
|
1152
1160
|
// (its bare member, or — for a chained map — the suffixed child upstream owes)
|
|
1153
1161
|
const mc = mapConsume(step);
|
|
1154
|
-
const
|
|
1155
|
-
if (mc &&
|
|
1162
|
+
const mps = mapProduces(step);
|
|
1163
|
+
if (mc && mps.length > 0) {
|
|
1156
1164
|
for (const m of members(arts, mc.stem)) {
|
|
1157
1165
|
const el = parseElement(m.path);
|
|
1158
1166
|
if (!el)
|
|
1159
1167
|
continue;
|
|
1160
|
-
if (!isDebt(arts.get(bindProduce(mp, el.index))))
|
|
1168
|
+
if (!mps.some((mp) => isDebt(arts.get(bindProduce(mp, el.index)))))
|
|
1161
1169
|
continue;
|
|
1162
1170
|
const inPath = mapInputPath(mc, el.index);
|
|
1163
1171
|
if (!isGreen(arts.get(inPath)))
|
|
@@ -1218,9 +1226,8 @@ export function buildTrace(def, artifacts, runs) {
|
|
|
1218
1226
|
stems.push(p.stem);
|
|
1219
1227
|
for (const p of collectionProduces(step))
|
|
1220
1228
|
stems.push(p.stem);
|
|
1221
|
-
const mp
|
|
1222
|
-
|
|
1223
|
-
stems.push(mp.raw); // use the raw pattern (e.g. "gather.source[$i].check")
|
|
1229
|
+
for (const mp of mapProduces(step))
|
|
1230
|
+
stems.push(mp.raw); // use raw patterns (e.g. "gather.source[$i].check")
|
|
1224
1231
|
stepProducedStems.set(step.name, stems);
|
|
1225
1232
|
}
|
|
1226
1233
|
// --- step 3: build the timeline ---
|
|
@@ -194,6 +194,7 @@ export function substituteOrderVars(body, runtime, opts = {}) {
|
|
|
194
194
|
case 'STEP': return opts.step ?? m;
|
|
195
195
|
case 'KEY': return runtime.key;
|
|
196
196
|
case 'INDEX': return runtime.index === undefined ? '' : String(runtime.index);
|
|
197
|
+
case 'MODIFIER': return runtime.modifier ?? m;
|
|
197
198
|
// Intentionally step-generic: a single firing can discharge multiple
|
|
198
199
|
// outputs (order.outputs) at once, so there is no single produce to
|
|
199
200
|
// resolve a per-produce maxAttempts override against here. This
|
|
@@ -246,7 +247,13 @@ export class OrderResolver {
|
|
|
246
247
|
return instructions;
|
|
247
248
|
return {
|
|
248
249
|
...instructions,
|
|
249
|
-
prompt: substituteOrderVars(resolved.prompt, {
|
|
250
|
+
prompt: substituteOrderVars(resolved.prompt, {
|
|
251
|
+
workflow: order.workflow,
|
|
252
|
+
run: order.run,
|
|
253
|
+
key: order.key,
|
|
254
|
+
...(order.index !== undefined ? { index: order.index } : {}),
|
|
255
|
+
...(order.modifier !== undefined ? { modifier: order.modifier } : {}),
|
|
256
|
+
}, { step: order.step, maxAttempts }),
|
|
250
257
|
};
|
|
251
258
|
}
|
|
252
259
|
}
|
|
@@ -555,6 +555,9 @@ export declare const WIRE_SCHEMAS: {
|
|
|
555
555
|
type: string;
|
|
556
556
|
minimum: number;
|
|
557
557
|
};
|
|
558
|
+
requested: {
|
|
559
|
+
type: string;
|
|
560
|
+
};
|
|
558
561
|
};
|
|
559
562
|
};
|
|
560
563
|
};
|
|
@@ -590,6 +593,22 @@ export declare const WIRE_SCHEMAS: {
|
|
|
590
593
|
minLength: number;
|
|
591
594
|
};
|
|
592
595
|
};
|
|
596
|
+
crews: {
|
|
597
|
+
type: string;
|
|
598
|
+
description: string;
|
|
599
|
+
items: {
|
|
600
|
+
type: string;
|
|
601
|
+
minLength: number;
|
|
602
|
+
};
|
|
603
|
+
};
|
|
604
|
+
reroutedFrom: {
|
|
605
|
+
type: string;
|
|
606
|
+
description: string;
|
|
607
|
+
items: {
|
|
608
|
+
type: string;
|
|
609
|
+
minLength: number;
|
|
610
|
+
};
|
|
611
|
+
};
|
|
593
612
|
modifier: {
|
|
594
613
|
type: string;
|
|
595
614
|
minLength: number;
|
|
@@ -92,7 +92,8 @@
|
|
|
92
92
|
},
|
|
93
93
|
"by": { "type": "string" },
|
|
94
94
|
"text": { "type": "string" },
|
|
95
|
-
"fromVersion": { "type": "integer", "minimum": 0 }
|
|
95
|
+
"fromVersion": { "type": "integer", "minimum": 0 },
|
|
96
|
+
"requested": { "type": "string" }
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
},
|
|
@@ -113,7 +114,17 @@
|
|
|
113
114
|
"cause": { "type": "string", "enum": ["inputsGreen", "allGreen", "idle"] },
|
|
114
115
|
"capabilities": {
|
|
115
116
|
"type": "array",
|
|
116
|
-
"description": "The composed routing capabilities this order was offered under: each authored step capability, suffixed ':<modifier>' where a modifier applied. A snapshot of the offer — a claimed order is never recomposed.",
|
|
117
|
+
"description": "The composed routing capabilities this order was offered under: each authored step capability, suffixed ':<modifier>' where a modifier applied. A snapshot of the offer — a claimed order is never recomposed. When 'reroutedFrom' is present this holds the reroute target instead, because this is the capability actually being served.",
|
|
118
|
+
"items": { "type": "string", "minLength": 1 }
|
|
119
|
+
},
|
|
120
|
+
"crews": {
|
|
121
|
+
"type": "array",
|
|
122
|
+
"description": "The ordered crews the offering side matched for this capability-bearing order. Hub → worker; unlike worker → hub serve_crews, this snapshot decides which local roster resolves the order.",
|
|
123
|
+
"items": { "type": "string", "minLength": 1 }
|
|
124
|
+
},
|
|
125
|
+
"reroutedFrom": {
|
|
126
|
+
"type": "array",
|
|
127
|
+
"description": "The composed capabilities this order WOULD have been offered under, present only when a reroute rule substituted something else into 'capabilities'. Absent on every ordinary offer, so its presence is itself the signal that the order is not running on the capability its definition asked for.",
|
|
117
128
|
"items": { "type": "string", "minLength": 1 }
|
|
118
129
|
},
|
|
119
130
|
"modifier": {
|
|
@@ -30,7 +30,7 @@ function resolvePolicyValue(env, explicit, envKey, settingsKey, label) {
|
|
|
30
30
|
}
|
|
31
31
|
return envValue;
|
|
32
32
|
}
|
|
33
|
-
// A missing HOME
|
|
33
|
+
// A missing HOME means there is no settings file to read;
|
|
34
34
|
// the built-in default remains usable. Any other settings read/parse error is
|
|
35
35
|
// surfaced rather than weakened into the least restrictive policy.
|
|
36
36
|
let path;
|
package/dist/src/store.d.ts
CHANGED
|
@@ -87,6 +87,11 @@ export declare class Store {
|
|
|
87
87
|
* decide what "drift" means, it just persists what the engine computed.
|
|
88
88
|
*/
|
|
89
89
|
repinWorkflowDef(id: string, snapshot: WorkflowDef, hash: string): void;
|
|
90
|
+
/** Apply an engine-authored routing patch without rewriting authored params. */
|
|
91
|
+
setWorkflowRouting(id: string, patch: {
|
|
92
|
+
modifier?: string;
|
|
93
|
+
meta?: Record<string, unknown>;
|
|
94
|
+
}): void;
|
|
90
95
|
getWorkflow(id: string): WorkflowRow | undefined;
|
|
91
96
|
listWorkflows(): WorkflowRow[];
|
|
92
97
|
/** Deletes only this workflow's own rows (artifact/task/run/workflow). Does NOT
|
package/dist/src/store.js
CHANGED
|
@@ -29,6 +29,7 @@ CREATE TABLE IF NOT EXISTS workflow (
|
|
|
29
29
|
title TEXT,
|
|
30
30
|
params TEXT NOT NULL DEFAULT '{}',
|
|
31
31
|
modifier TEXT,
|
|
32
|
+
meta TEXT,
|
|
32
33
|
created_at INTEGER NOT NULL
|
|
33
34
|
);
|
|
34
35
|
|
|
@@ -150,8 +151,11 @@ CREATE TABLE IF NOT EXISTS meta (
|
|
|
150
151
|
* nullable `modifier` column (see `migrate()`). Additive and un-backfilled —
|
|
151
152
|
* NULL on every existing row means "unmodified run", which is the correct
|
|
152
153
|
* reading of an instance created before modifiers existed.
|
|
154
|
+
*
|
|
155
|
+
* Bumped to '11' for bound artifacts: the `workflow` table gains nullable
|
|
156
|
+
* JSON `meta` for non-routing `meta.<key>` artifact binds.
|
|
153
157
|
*/
|
|
154
|
-
const SCHEMA_VERSION = '
|
|
158
|
+
const SCHEMA_VERSION = '11';
|
|
155
159
|
/** Thrown by the `Store` constructor when the on-disk `schema_version` is
|
|
156
160
|
* newer than this binary's `SCHEMA_VERSION` — the operator needs to
|
|
157
161
|
* upgrade their owenloop install to open this database. */
|
|
@@ -369,6 +373,13 @@ function mapWorkflow(r) {
|
|
|
369
373
|
// become the same thing downstream, where '' would compose 'build:'.
|
|
370
374
|
if (r.modifier !== null)
|
|
371
375
|
out.modifier = r.modifier;
|
|
376
|
+
const meta = fromJson(r.meta, undefined, {
|
|
377
|
+
table: 'workflow',
|
|
378
|
+
id: r.id,
|
|
379
|
+
column: 'meta',
|
|
380
|
+
});
|
|
381
|
+
if (meta !== undefined)
|
|
382
|
+
out.meta = meta;
|
|
372
383
|
return out;
|
|
373
384
|
}
|
|
374
385
|
// ---- the store ---------------------------------------------------------------
|
|
@@ -517,14 +528,18 @@ export class Store {
|
|
|
517
528
|
if (!wfCols.some((c) => c.name === 'def_hash')) {
|
|
518
529
|
this.db.exec(`ALTER TABLE workflow ADD COLUMN def_hash TEXT`);
|
|
519
530
|
}
|
|
520
|
-
// Routing modifier: the ONE modifier this instance carries
|
|
521
|
-
//
|
|
522
|
-
//
|
|
523
|
-
//
|
|
531
|
+
// Routing modifier: the ONE modifier this instance carries. The starter
|
|
532
|
+
// supplies its initial value; a def-declared artifact bind may later update
|
|
533
|
+
// it through the engine's routing writer. NULL on every pre-existing row,
|
|
534
|
+
// which is exactly right — an instance created before modifiers existed is
|
|
535
|
+
// an unmodified run and every step is offered on bare capabilities. No
|
|
524
536
|
// backfill: there is no value to invent.
|
|
525
537
|
if (!wfCols.some((c) => c.name === 'modifier')) {
|
|
526
538
|
this.db.exec(`ALTER TABLE workflow ADD COLUMN modifier TEXT`);
|
|
527
539
|
}
|
|
540
|
+
if (!wfCols.some((c) => c.name === 'meta')) {
|
|
541
|
+
this.db.exec(`ALTER TABLE workflow ADD COLUMN meta TEXT`);
|
|
542
|
+
}
|
|
528
543
|
// Only a genuine pre-v8 -> v8 upgrade may backfill the current projection's
|
|
529
544
|
// reason thread. Re-opening an already-v8 database must not manufacture a
|
|
530
545
|
// second copy of its lifecycle events (even though the legacy keys differ
|
|
@@ -581,9 +596,9 @@ export class Store {
|
|
|
581
596
|
const at = nowMs();
|
|
582
597
|
this.db
|
|
583
598
|
.prepare(`INSERT INTO workflow
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
.run(id, data.def, data.title ?? null, JSON.stringify(data.params ?? {}), producedBy?.parentWf ?? null, producedBy?.parentPath ?? null, toJson(data.defSnapshot), data.defHash ?? null, data.modifier ?? null, at);
|
|
599
|
+
(id, def, title, params, produced_by_wf, produced_by_path, def_snapshot, def_hash, modifier, meta, created_at)
|
|
600
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
601
|
+
.run(id, data.def, data.title ?? null, JSON.stringify(data.params ?? {}), producedBy?.parentWf ?? null, producedBy?.parentPath ?? null, toJson(data.defSnapshot), data.defHash ?? null, data.modifier ?? null, toJson(data.meta), at);
|
|
587
602
|
return this.getWorkflow(id);
|
|
588
603
|
}
|
|
589
604
|
/**
|
|
@@ -596,6 +611,26 @@ export class Store {
|
|
|
596
611
|
.prepare('UPDATE workflow SET def_snapshot = ?, def_hash = ? WHERE id = ?')
|
|
597
612
|
.run(JSON.stringify(snapshot), hash, id);
|
|
598
613
|
}
|
|
614
|
+
/** Apply an engine-authored routing patch without rewriting authored params. */
|
|
615
|
+
setWorkflowRouting(id, patch) {
|
|
616
|
+
const assignments = [];
|
|
617
|
+
const values = [];
|
|
618
|
+
if (patch.modifier !== undefined) {
|
|
619
|
+
assignments.push('modifier = ?');
|
|
620
|
+
values.push(patch.modifier);
|
|
621
|
+
}
|
|
622
|
+
if (patch.meta !== undefined) {
|
|
623
|
+
const current = this.getWorkflow(id);
|
|
624
|
+
if (current === undefined)
|
|
625
|
+
throw new Error(`cannot update routing for unknown workflow '${id}'`);
|
|
626
|
+
assignments.push('meta = ?');
|
|
627
|
+
values.push(JSON.stringify({ ...(current.meta ?? {}), ...patch.meta }));
|
|
628
|
+
}
|
|
629
|
+
if (assignments.length === 0)
|
|
630
|
+
return;
|
|
631
|
+
values.push(id);
|
|
632
|
+
this.db.prepare(`UPDATE workflow SET ${assignments.join(', ')} WHERE id = ?`).run(...values);
|
|
633
|
+
}
|
|
599
634
|
getWorkflow(id) {
|
|
600
635
|
const r = this.db.prepare('SELECT * FROM workflow WHERE id = ?').get(id);
|
|
601
636
|
return r ? mapWorkflow(r) : undefined;
|