owenloop 0.5.7 → 0.5.8
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 +16 -0
- package/README.md +3 -6
- 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 +39 -25
- package/dist/packages/work/src/agent/loop.js +102 -50
- package/dist/packages/work/src/bundle/types.d.ts +3 -3
- package/dist/packages/work/src/exec/loop.js +37 -15
- package/dist/packages/work/src/harness/child-env.js +4 -5
- 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/types.d.ts +3 -3
- package/dist/packages/work/src/roles/agent-run.js +48 -42
- 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 +1 -1
- package/dist/packages/work/src/settings/roster.d.ts +21 -0
- package/dist/packages/work/src/settings/roster.js +80 -0
- package/dist/packages/work/src/settings/settings.d.ts +12 -24
- package/dist/packages/work/src/settings/settings.js +17 -35
- package/dist/packages/work/src/shift/runtime.js +2 -10
- package/dist/packages/work/src/shift/spawn.d.ts +6 -53
- package/dist/packages/work/src/shift/spawn.js +28 -66
- package/dist/packages/work/src/usage.d.ts +1 -1
- package/dist/packages/work/src/usage.js +3 -4
- package/dist/src/capabilities.d.ts +44 -0
- package/dist/src/capabilities.js +38 -0
- package/dist/src/cli.d.ts +1 -0
- package/dist/src/cli.js +460 -5
- package/dist/src/config-dir.d.ts +13 -18
- package/dist/src/config-dir.js +15 -23
- package/dist/src/credentials.d.ts +1 -1
- package/dist/src/credentials.js +1 -1
- package/dist/src/crypto/records.d.ts +1 -0
- package/dist/src/crypto/records.js +6 -0
- package/dist/src/crypto/trust-roots.d.ts +2 -2
- package/dist/src/crypto/trust-roots.js +2 -2
- package/dist/src/engine.d.ts +14 -0
- package/dist/src/engine.js +21 -13
- 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 +2 -2
- package/dist/src/index.js +1 -1
- package/dist/src/schemas/index.d.ts +8 -0
- package/dist/src/schemas/order.v1.schema.json +6 -1
- package/dist/src/store/pre-commit-verifier.js +1 -1
- package/dist/src/types.d.ts +24 -4
- 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/bundles.md +3 -1
- package/docs/cli.md +295 -101
- package/docs/crypto.md +14 -14
- package/docs/routing.md +607 -0
- package/docs/shift-logs.md +22 -6
- 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/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,22 @@ All notable changes to this project are documented here. The format is based on
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
|
|
5
5
|
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.5.8](https://github.com/typicalday/owenloop/compare/v0.5.7...v0.5.8) (2026-08-17)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* add layered crew roster routing ([#186](https://github.com/typicalday/owenloop/issues/186)) ([9fc1a55](https://github.com/typicalday/owenloop/commit/9fc1a55447bc48806d5b8775a9bdd5340f9258b8))
|
|
13
|
+
* add owenloop routing command group for alerts and reroute rules ([#182](https://github.com/typicalday/owenloop/issues/182)) ([012a16a](https://github.com/typicalday/owenloop/commit/012a16a97f01b2c98691403a2a8a9eba201ef889))
|
|
14
|
+
* let the offer caller reroute a composed capability ([#181](https://github.com/typicalday/owenloop/issues/181)) ([7240e61](https://github.com/typicalday/owenloop/commit/7240e61ee4263290d9eb1adfea96c3659a657ca9))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* key session resume on the engine task, not on the per-firing run id ([#177](https://github.com/typicalday/owenloop/issues/177)) ([f1d4fbb](https://github.com/typicalday/owenloop/commit/f1d4fbbccab3048558a5319293e87bb3bcff22e8))
|
|
20
|
+
* relay a command step's output to the worker log on success too ([#185](https://github.com/typicalday/owenloop/issues/185)) ([618a3e0](https://github.com/typicalday/owenloop/commit/618a3e0309d79bb680f521c19fc183934f6f7bf8))
|
|
21
|
+
* surface a hub instance's terminal status in `instance show` ([#187](https://github.com/typicalday/owenloop/issues/187)) ([42e53bd](https://github.com/typicalday/owenloop/commit/42e53bd809bfe8e93a27ffa2941b8a89b0161bcc))
|
|
22
|
+
|
|
7
23
|
## [0.5.7](https://github.com/typicalday/owenloop/compare/v0.5.6...v0.5.7) (2026-08-16)
|
|
8
24
|
|
|
9
25
|
|
package/README.md
CHANGED
|
@@ -487,12 +487,9 @@ hub's own def hashes. `owenloop agent new
|
|
|
487
487
|
Setting up a machine from scratch? `owenloop setup` may sign you in as a human
|
|
488
488
|
and, when needed, mint or rekey and store a Scoped Identity. Setup writes only
|
|
489
489
|
`hubOrigin` into the execution settings file, preserving the other keys. The
|
|
490
|
-
file is `$
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
`$HOME/.config/owenloop/settings.json`. Prefer `OWENLOOP_CONFIG_DIR` when
|
|
494
|
-
running several shifts on one machine — `XDG_CONFIG_HOME` also relocates `gh`,
|
|
495
|
-
`git`, and `gcloud` for every command step the shift dispatches. For
|
|
490
|
+
file is `$HOME/.owenloop/settings.json` by default (`OWENLOOP_CONFIG_DIR` can
|
|
491
|
+
provide an absolute isolated directory; `XDG_CONFIG_HOME` is not consulted).
|
|
492
|
+
For
|
|
496
493
|
a non-default account,
|
|
497
494
|
setup only prints the `OWENLOOP_ACCOUNT=<name>` instruction. Setup probes and,
|
|
498
495
|
when needed, converges the bundled `owenloop` plugins for Claude Code and Codex.
|
|
@@ -1,58 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resolve an order's COMPOSED CAPABILITY to the
|
|
3
|
-
*
|
|
2
|
+
* Resolve an order's COMPOSED CAPABILITY to the local crew roster that serves
|
|
3
|
+
* it. The hub decides what grade of work an order is; the machine decides
|
|
4
|
+
* which locally available harness, model, and effort serve that grade.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* definition has no business asserting.
|
|
10
|
-
*
|
|
11
|
-
* So the settings file carries a flat map from capability to `{model, effort}`:
|
|
6
|
+
* A crew roster is a capability-to-candidate-list table. It is deliberately
|
|
7
|
+
* local: accounts, quotas, and operator preference do not belong in a shared
|
|
8
|
+
* workflow definition. The candidates are ordered so an operator can express
|
|
9
|
+
* a preferred harness with a deterministic fallback:
|
|
12
10
|
*
|
|
13
11
|
* ```json
|
|
14
12
|
* {
|
|
15
|
-
* "
|
|
16
|
-
* "wise:deep":
|
|
17
|
-
*
|
|
18
|
-
*
|
|
13
|
+
* "roster": {
|
|
14
|
+
* "wise:deep": [
|
|
15
|
+
* { "harness": "<harness-id>", "model": "<model-id>", "effort": "xhigh" }
|
|
16
|
+
* ]
|
|
19
17
|
* }
|
|
20
18
|
* }
|
|
21
19
|
* ```
|
|
22
20
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* and `docs/` carry worked examples with real ids.
|
|
27
|
-
*
|
|
28
|
-
* THIS REPLACES `tierMap`/`tierProfiles` OUTRIGHT. A tier was an abstract rung
|
|
29
|
-
* (`fast`/`standard`/`strong`/`strongest`) that a machine then mapped to a
|
|
30
|
-
* model, and the tier ladder could not express the thing the operator actually
|
|
31
|
-
* wanted: "Luna at low effort" and "Fable at max effort" are different routes,
|
|
32
|
-
* but the ladder welded model choice and depth into one ordered axis, so one
|
|
33
|
-
* could not vary without the other. A capability is just a name. What serves it
|
|
34
|
-
* is a local lookup, and depth rides on the capability's modifier suffix rather
|
|
35
|
-
* than on a rung.
|
|
36
|
-
*
|
|
37
|
-
* The one behavior worth carrying out of the tier code is EFFORT VALIDITY
|
|
38
|
-
* CHECKING, which now happens at settings load rather than at resolution time.
|
|
39
|
-
* It checks the effort against `EFFORT_LADDER` — the neutral start contract's
|
|
40
|
-
* own five rungs — and nothing else.
|
|
21
|
+
* The one behavior worth carrying out of the retired tier code is EFFORT
|
|
22
|
+
* VALIDITY CHECKING. It happens at settings load and checks only the neutral
|
|
23
|
+
* start contract's five rungs.
|
|
41
24
|
*
|
|
42
|
-
* IT DELIBERATELY DOES NOT CHECK EFFORT AGAINST THE MODEL.
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* table here would be either a restatement of `EFFORT_LADDER` under
|
|
50
|
-
* model-shaped keys, or an invention that blocks a valid operator config. The
|
|
51
|
-
* real per-harness check belongs on the adapter contract; see the follow-up
|
|
52
|
-
* noted in `validateCapabilityModels`.
|
|
53
|
-
*
|
|
54
|
-
* The old snap-up/ceiling-refusal logic in `resolveEffort` is gone with the
|
|
55
|
-
* ladder it resolved through: there is no abstract rung left to snap.
|
|
25
|
+
* IT DELIBERATELY DOES NOT CHECK EFFORT AGAINST THE MODEL. That would require a
|
|
26
|
+
* table of model identifiers which this repository has no ground truth for.
|
|
27
|
+
* Harnesses may validate effort as a harness-wide property or pass it through;
|
|
28
|
+
* neither case establishes a per-model constraint. A table here would either
|
|
29
|
+
* restate `EFFORT_LADDER` under model-shaped keys or invent a restriction that
|
|
30
|
+
* rejects a valid operator config. A future per-harness check belongs on the
|
|
31
|
+
* adapter contract, not in this neutral shape module.
|
|
56
32
|
*/
|
|
57
33
|
/** Reasoning rungs the neutral start contract accepts, weakest to strongest. */
|
|
58
34
|
export declare const EFFORT_LADDER: readonly ["low", "medium", "high", "xhigh", "max"];
|
|
@@ -66,58 +42,64 @@ export type Effort = (typeof EFFORT_LADDER)[number];
|
|
|
66
42
|
export declare const MODIFIER_SEPARATOR = ":";
|
|
67
43
|
/** The bare capability name inside a composed capability. `wise:deep` → `wise`. */
|
|
68
44
|
export declare function capabilityNamePart(capability: string): string;
|
|
69
|
-
/** One
|
|
70
|
-
export interface
|
|
45
|
+
/** One ordered candidate in a crew roster row. */
|
|
46
|
+
export interface RosterCandidate {
|
|
47
|
+
harness: string;
|
|
71
48
|
model: string;
|
|
72
49
|
effort: string;
|
|
73
50
|
}
|
|
74
|
-
/**
|
|
75
|
-
export type
|
|
76
|
-
/** Thrown when the
|
|
77
|
-
export declare class
|
|
51
|
+
/** A crew roster keyed by composed capability (`wise:deep`) or bare name (`wise`). */
|
|
52
|
+
export type Roster = Readonly<Record<string, readonly RosterCandidate[]>>;
|
|
53
|
+
/** Thrown when the crew roster is unusable. Never silently repaired. */
|
|
54
|
+
export declare class RosterError extends Error {
|
|
78
55
|
}
|
|
79
56
|
/**
|
|
80
|
-
* Validate
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* a missing or empty `model`, and an `effort` that is not one of
|
|
85
|
-
* `EFFORT_LADDER`. Each is wrong under every harness and every model, and a
|
|
86
|
-
* shift that started anyway would refuse or misroute its first matching order
|
|
87
|
-
* hours later, far from the typo.
|
|
57
|
+
* Validate a crew roster, throwing on the first unusable row. Every fault this
|
|
58
|
+
* function catches is certainly wrong: an empty capability, an old object row,
|
|
59
|
+
* an empty candidate list, or a candidate missing any required part would make
|
|
60
|
+
* routing ambiguous hours after the configuration mistake.
|
|
88
61
|
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* header). FOLLOW-UP: `HarnessAdapter` is the right owner for the first one —
|
|
92
|
-
* an adapter that validates effort against a closed union could declare that
|
|
93
|
-
* union, and a composition root could check every row against every registered
|
|
94
|
-
* adapter at shift start. Until then those faults surface at the vendor API on
|
|
95
|
-
* the first order that lands on the bad row.
|
|
62
|
+
* It intentionally does not judge whether a model id exists or whether a
|
|
63
|
+
* particular model accepts an effort; see this module's header.
|
|
96
64
|
*/
|
|
97
|
-
export declare function
|
|
98
|
-
/** Which row served the order: its exact compound, or the bare name fallback. */
|
|
65
|
+
export declare function validateRoster(roster: Readonly<Record<string, unknown>>, ctx?: string): void;
|
|
66
|
+
/** Which roster row served the order: its exact compound, or the bare name fallback. */
|
|
99
67
|
export type CapabilityMatch = 'exact' | 'bare';
|
|
100
|
-
export interface
|
|
68
|
+
export interface CapabilityCandidates {
|
|
101
69
|
/** The capability the winning row was keyed by (`wise:deep` or `wise`). */
|
|
102
70
|
capability: string;
|
|
103
71
|
match: CapabilityMatch;
|
|
104
|
-
|
|
105
|
-
effort: string;
|
|
72
|
+
candidates: readonly RosterCandidate[];
|
|
106
73
|
}
|
|
107
74
|
/**
|
|
108
|
-
* Resolve an order's capabilities against the
|
|
109
|
-
* then the bare name-part row, else `undefined` (the caller
|
|
110
|
-
* never a default model).
|
|
75
|
+
* Resolve an order's capabilities against the merged roster: exact compound
|
|
76
|
+
* row first, then the bare name-part row, else `undefined` (the caller
|
|
77
|
+
* refuses the order — never a default model).
|
|
111
78
|
*
|
|
112
79
|
* TWO PASSES ACROSS ALL CAPABILITIES, NOT ONE PASS PER CAPABILITY. A step may
|
|
113
80
|
* author several capabilities, and the hub's claim gate is itself exact-first
|
|
114
|
-
* across the set
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* bare `builder` grade purely because of authoring order.
|
|
81
|
+
* across the set. Resolving capability by capability instead would let a bare
|
|
82
|
+
* row on the first capability beat an exact row on the second — the shift
|
|
83
|
+
* would run a deep order at the bare grade purely because of authoring order.
|
|
118
84
|
*
|
|
119
|
-
* The bare row is what makes a
|
|
120
|
-
* hub
|
|
121
|
-
* then claims, and that shift has no `wise:deep` row by
|
|
85
|
+
* The bare row is what makes a name-match fallback order resolvable at all:
|
|
86
|
+
* the hub can stamp `wise:deep` on an order that a crew bound only to
|
|
87
|
+
* `wise:standard` then claims, and that shift has no `wise:deep` row by
|
|
88
|
+
* construction.
|
|
89
|
+
*/
|
|
90
|
+
export declare function resolveCapabilityCandidates(roster: Roster, capabilities: readonly string[]): CapabilityCandidates | undefined;
|
|
91
|
+
export type SelectionOutcome = {
|
|
92
|
+
kind: 'selected';
|
|
93
|
+
candidate: RosterCandidate;
|
|
94
|
+
} | {
|
|
95
|
+
kind: 'harness-policy';
|
|
96
|
+
offered: readonly string[];
|
|
97
|
+
} | {
|
|
98
|
+
kind: 'none-available';
|
|
99
|
+
offered: readonly string[];
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Select the first usable candidate in roster order. A non-empty step harness
|
|
103
|
+
* is a policy constraint; it narrows candidates before availability is tested.
|
|
122
104
|
*/
|
|
123
|
-
export declare function
|
|
105
|
+
export declare function selectCandidate(candidates: readonly RosterCandidate[], stepHarness: string | undefined, isAvailable: (harnessId: string) => boolean): SelectionOutcome;
|
|
@@ -1,58 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resolve an order's COMPOSED CAPABILITY to the
|
|
3
|
-
*
|
|
2
|
+
* Resolve an order's COMPOSED CAPABILITY to the local crew roster that serves
|
|
3
|
+
* it. The hub decides what grade of work an order is; the machine decides
|
|
4
|
+
* which locally available harness, model, and effort serve that grade.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* definition has no business asserting.
|
|
10
|
-
*
|
|
11
|
-
* So the settings file carries a flat map from capability to `{model, effort}`:
|
|
6
|
+
* A crew roster is a capability-to-candidate-list table. It is deliberately
|
|
7
|
+
* local: accounts, quotas, and operator preference do not belong in a shared
|
|
8
|
+
* workflow definition. The candidates are ordered so an operator can express
|
|
9
|
+
* a preferred harness with a deterministic fallback:
|
|
12
10
|
*
|
|
13
11
|
* ```json
|
|
14
12
|
* {
|
|
15
|
-
* "
|
|
16
|
-
* "wise:deep":
|
|
17
|
-
*
|
|
18
|
-
*
|
|
13
|
+
* "roster": {
|
|
14
|
+
* "wise:deep": [
|
|
15
|
+
* { "harness": "<harness-id>", "model": "<model-id>", "effort": "xhigh" }
|
|
16
|
+
* ]
|
|
19
17
|
* }
|
|
20
18
|
* }
|
|
21
19
|
* ```
|
|
22
20
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* and `docs/` carry worked examples with real ids.
|
|
27
|
-
*
|
|
28
|
-
* THIS REPLACES `tierMap`/`tierProfiles` OUTRIGHT. A tier was an abstract rung
|
|
29
|
-
* (`fast`/`standard`/`strong`/`strongest`) that a machine then mapped to a
|
|
30
|
-
* model, and the tier ladder could not express the thing the operator actually
|
|
31
|
-
* wanted: "Luna at low effort" and "Fable at max effort" are different routes,
|
|
32
|
-
* but the ladder welded model choice and depth into one ordered axis, so one
|
|
33
|
-
* could not vary without the other. A capability is just a name. What serves it
|
|
34
|
-
* is a local lookup, and depth rides on the capability's modifier suffix rather
|
|
35
|
-
* than on a rung.
|
|
36
|
-
*
|
|
37
|
-
* The one behavior worth carrying out of the tier code is EFFORT VALIDITY
|
|
38
|
-
* CHECKING, which now happens at settings load rather than at resolution time.
|
|
39
|
-
* It checks the effort against `EFFORT_LADDER` — the neutral start contract's
|
|
40
|
-
* own five rungs — and nothing else.
|
|
21
|
+
* The one behavior worth carrying out of the retired tier code is EFFORT
|
|
22
|
+
* VALIDITY CHECKING. It happens at settings load and checks only the neutral
|
|
23
|
+
* start contract's five rungs.
|
|
41
24
|
*
|
|
42
|
-
* IT DELIBERATELY DOES NOT CHECK EFFORT AGAINST THE MODEL.
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* table here would be either a restatement of `EFFORT_LADDER` under
|
|
50
|
-
* model-shaped keys, or an invention that blocks a valid operator config. The
|
|
51
|
-
* real per-harness check belongs on the adapter contract; see the follow-up
|
|
52
|
-
* noted in `validateCapabilityModels`.
|
|
53
|
-
*
|
|
54
|
-
* The old snap-up/ceiling-refusal logic in `resolveEffort` is gone with the
|
|
55
|
-
* ladder it resolved through: there is no abstract rung left to snap.
|
|
25
|
+
* IT DELIBERATELY DOES NOT CHECK EFFORT AGAINST THE MODEL. That would require a
|
|
26
|
+
* table of model identifiers which this repository has no ground truth for.
|
|
27
|
+
* Harnesses may validate effort as a harness-wide property or pass it through;
|
|
28
|
+
* neither case establishes a per-model constraint. A table here would either
|
|
29
|
+
* restate `EFFORT_LADDER` under model-shaped keys or invent a restriction that
|
|
30
|
+
* rejects a valid operator config. A future per-harness check belongs on the
|
|
31
|
+
* adapter contract, not in this neutral shape module.
|
|
56
32
|
*/
|
|
57
33
|
/** Reasoning rungs the neutral start contract accepts, weakest to strongest. */
|
|
58
34
|
export const EFFORT_LADDER = ['low', 'medium', 'high', 'xhigh', 'max'];
|
|
@@ -68,70 +44,80 @@ export function capabilityNamePart(capability) {
|
|
|
68
44
|
const at = capability.indexOf(MODIFIER_SEPARATOR);
|
|
69
45
|
return at === -1 ? capability : capability.slice(0, at);
|
|
70
46
|
}
|
|
71
|
-
/** Thrown when the
|
|
72
|
-
export class
|
|
47
|
+
/** Thrown when the crew roster is unusable. Never silently repaired. */
|
|
48
|
+
export class RosterError extends Error {
|
|
73
49
|
}
|
|
74
50
|
function isEffort(value) {
|
|
75
51
|
return EFFORT_LADDER.includes(value);
|
|
76
52
|
}
|
|
77
53
|
/**
|
|
78
|
-
* Validate
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* a missing or empty `model`, and an `effort` that is not one of
|
|
83
|
-
* `EFFORT_LADDER`. Each is wrong under every harness and every model, and a
|
|
84
|
-
* shift that started anyway would refuse or misroute its first matching order
|
|
85
|
-
* hours later, far from the typo.
|
|
54
|
+
* Validate a crew roster, throwing on the first unusable row. Every fault this
|
|
55
|
+
* function catches is certainly wrong: an empty capability, an old object row,
|
|
56
|
+
* an empty candidate list, or a candidate missing any required part would make
|
|
57
|
+
* routing ambiguous hours after the configuration mistake.
|
|
86
58
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* header). FOLLOW-UP: `HarnessAdapter` is the right owner for the first one —
|
|
90
|
-
* an adapter that validates effort against a closed union could declare that
|
|
91
|
-
* union, and a composition root could check every row against every registered
|
|
92
|
-
* adapter at shift start. Until then those faults surface at the vendor API on
|
|
93
|
-
* the first order that lands on the bad row.
|
|
59
|
+
* It intentionally does not judge whether a model id exists or whether a
|
|
60
|
+
* particular model accepts an effort; see this module's header.
|
|
94
61
|
*/
|
|
95
|
-
export function
|
|
96
|
-
for (const [capability,
|
|
62
|
+
export function validateRoster(roster, ctx = 'roster') {
|
|
63
|
+
for (const [capability, rawCandidates] of Object.entries(roster)) {
|
|
97
64
|
if (capability.trim() === '') {
|
|
98
|
-
throw new
|
|
65
|
+
throw new RosterError(`${ctx}: a capability key may not be empty`);
|
|
99
66
|
}
|
|
100
|
-
if (
|
|
101
|
-
throw new
|
|
67
|
+
if (!Array.isArray(rawCandidates)) {
|
|
68
|
+
throw new RosterError(`${ctx}['${capability}'] must be a non-empty array of { harness: "<harness-id>", model: "<model-id>", effort: "high" }, got ${JSON.stringify(rawCandidates)}`);
|
|
102
69
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (typeof model !== 'string' || model.trim() === '') {
|
|
106
|
-
throw new CapabilityModelError(`${ctx}['${capability}'].model must be a non-empty string`);
|
|
70
|
+
if (rawCandidates.length === 0) {
|
|
71
|
+
throw new RosterError(`${ctx}['${capability}'] must be a non-empty array of candidates`);
|
|
107
72
|
}
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
73
|
+
for (const [index, rawCandidate] of rawCandidates.entries()) {
|
|
74
|
+
const entryCtx = `${ctx}['${capability}'][${index}]`;
|
|
75
|
+
if (typeof rawCandidate !== 'object' || rawCandidate === null || Array.isArray(rawCandidate)) {
|
|
76
|
+
throw new RosterError(`${entryCtx} must be an object with exactly 'harness', 'model', and 'effort', got ${JSON.stringify(rawCandidate)}`);
|
|
77
|
+
}
|
|
78
|
+
const candidate = rawCandidate;
|
|
79
|
+
const keys = Object.keys(candidate);
|
|
80
|
+
const unknown = keys.filter((key) => !['harness', 'model', 'effort'].includes(key));
|
|
81
|
+
if (unknown.length > 0) {
|
|
82
|
+
throw new RosterError(`${entryCtx} has unknown key(s): ${unknown.join(', ')}`);
|
|
83
|
+
}
|
|
84
|
+
for (const key of ['harness', 'model']) {
|
|
85
|
+
if (typeof candidate[key] !== 'string' || candidate[key].trim() === '') {
|
|
86
|
+
throw new RosterError(`${entryCtx}.${key} must be a non-empty string`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const effort = candidate['effort'];
|
|
90
|
+
if (typeof effort !== 'string' || !isEffort(effort)) {
|
|
91
|
+
throw new RosterError(`${entryCtx}.effort must be one of ${EFFORT_LADDER.join(', ')}, got ${JSON.stringify(effort)}`);
|
|
92
|
+
}
|
|
111
93
|
}
|
|
112
94
|
}
|
|
113
95
|
}
|
|
96
|
+
/** Read only a declared roster row; inherited Object.prototype names are never capabilities. */
|
|
97
|
+
function ownCandidates(roster, capability) {
|
|
98
|
+
return Object.prototype.hasOwnProperty.call(roster, capability) ? roster[capability] : undefined;
|
|
99
|
+
}
|
|
114
100
|
/**
|
|
115
|
-
* Resolve an order's capabilities against the
|
|
116
|
-
* then the bare name-part row, else `undefined` (the caller
|
|
117
|
-
* never a default model).
|
|
101
|
+
* Resolve an order's capabilities against the merged roster: exact compound
|
|
102
|
+
* row first, then the bare name-part row, else `undefined` (the caller
|
|
103
|
+
* refuses the order — never a default model).
|
|
118
104
|
*
|
|
119
105
|
* TWO PASSES ACROSS ALL CAPABILITIES, NOT ONE PASS PER CAPABILITY. A step may
|
|
120
106
|
* author several capabilities, and the hub's claim gate is itself exact-first
|
|
121
|
-
* across the set
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* bare `builder` grade purely because of authoring order.
|
|
107
|
+
* across the set. Resolving capability by capability instead would let a bare
|
|
108
|
+
* row on the first capability beat an exact row on the second — the shift
|
|
109
|
+
* would run a deep order at the bare grade purely because of authoring order.
|
|
125
110
|
*
|
|
126
|
-
* The bare row is what makes a
|
|
127
|
-
* hub
|
|
128
|
-
* then claims, and that shift has no `wise:deep` row by
|
|
111
|
+
* The bare row is what makes a name-match fallback order resolvable at all:
|
|
112
|
+
* the hub can stamp `wise:deep` on an order that a crew bound only to
|
|
113
|
+
* `wise:standard` then claims, and that shift has no `wise:deep` row by
|
|
114
|
+
* construction.
|
|
129
115
|
*/
|
|
130
|
-
export function
|
|
116
|
+
export function resolveCapabilityCandidates(roster, capabilities) {
|
|
131
117
|
for (const capability of capabilities) {
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
134
|
-
return { capability, match: 'exact',
|
|
118
|
+
const candidates = ownCandidates(roster, capability);
|
|
119
|
+
if (candidates !== undefined)
|
|
120
|
+
return { capability, match: 'exact', candidates };
|
|
135
121
|
}
|
|
136
122
|
for (const capability of capabilities) {
|
|
137
123
|
const name = capabilityNamePart(capability);
|
|
@@ -140,9 +126,26 @@ export function resolveCapabilityModel(map, capabilities) {
|
|
|
140
126
|
// exact hit as a fallback in the resolution record.
|
|
141
127
|
if (name === capability)
|
|
142
128
|
continue;
|
|
143
|
-
const
|
|
144
|
-
if (
|
|
145
|
-
return { capability: name, match: 'bare',
|
|
129
|
+
const candidates = ownCandidates(roster, name);
|
|
130
|
+
if (candidates !== undefined)
|
|
131
|
+
return { capability: name, match: 'bare', candidates };
|
|
146
132
|
}
|
|
147
133
|
return undefined;
|
|
148
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Select the first usable candidate in roster order. A non-empty step harness
|
|
137
|
+
* is a policy constraint; it narrows candidates before availability is tested.
|
|
138
|
+
*/
|
|
139
|
+
export function selectCandidate(candidates, stepHarness, isAvailable) {
|
|
140
|
+
const survivors = stepHarness !== undefined && stepHarness !== ''
|
|
141
|
+
? candidates.filter((candidate) => candidate.harness === stepHarness)
|
|
142
|
+
: candidates;
|
|
143
|
+
if (survivors.length === 0) {
|
|
144
|
+
return { kind: 'harness-policy', offered: candidates.map((candidate) => candidate.harness) };
|
|
145
|
+
}
|
|
146
|
+
for (const candidate of survivors) {
|
|
147
|
+
if (isAvailable(candidate.harness))
|
|
148
|
+
return { kind: 'selected', candidate };
|
|
149
|
+
}
|
|
150
|
+
return { kind: 'none-available', offered: survivors.map((candidate) => candidate.harness) };
|
|
151
|
+
}
|
|
@@ -3,8 +3,9 @@ import type { ContactHolder, OrderPacket } from '../hub/types.ts';
|
|
|
3
3
|
import type { ConsumedVerifier } from '../consumed-verifier.ts';
|
|
4
4
|
import type { NormalizedStepSpec } from '../bundle/types.ts';
|
|
5
5
|
import type { HarnessAdapter } from '../harness/contract.ts';
|
|
6
|
-
import { type SessionRecord } from '../harness/session-store.ts';
|
|
7
|
-
import { type
|
|
6
|
+
import { type SessionRecord, type SessionTaskRef } from '../harness/session-store.ts';
|
|
7
|
+
import { type CapabilityMatch } from './capability-model.ts';
|
|
8
|
+
import type { MergedRoster } from '../settings/roster.ts';
|
|
8
9
|
/** Discriminated result of one worker life; the role maps these to exit codes. */
|
|
9
10
|
export type AgentRunOutcome = 'submitted' | 'completed' | 'misroute' | 'workdir-denied' | 'no-template' | 'no-harness' | 'incompatible-harness-policy' | 'unresolvable-capability' | 'unverified-consumed' | 'session-store-failed' | 'no-submit' | 'killed' | 'lease-lost' | 'ownership-error' | 'hub-unreachable' | 'stopped';
|
|
10
11
|
/**
|
|
@@ -22,9 +23,10 @@ export type StepLoader = (order: OrderPacket) => Promise<NormalizedStepSpec | nu
|
|
|
22
23
|
* The outcome of resolving which adapter hosts this step agent.
|
|
23
24
|
*
|
|
24
25
|
* The loop never reads a registry and never names a harness: the role
|
|
25
|
-
* (`src/roles/agent-run.ts`, the composition root) owns the precedence
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* (`src/roles/agent-run.ts`, the composition root) owns the precedence:
|
|
27
|
+
* selected roster candidate > `--harness` > step harness > registered
|
|
28
|
+
* default. The selected harness is supplied separately because routing decides
|
|
29
|
+
* it before adapter resolution.
|
|
28
30
|
* `registered` is only ever used to make the failure message actionable.
|
|
29
31
|
*/
|
|
30
32
|
export interface AdapterResolution {
|
|
@@ -32,8 +34,8 @@ export interface AdapterResolution {
|
|
|
32
34
|
adapter?: HarnessAdapter;
|
|
33
35
|
registered: string[];
|
|
34
36
|
}
|
|
35
|
-
/**
|
|
36
|
-
export type AdapterResolver = (stepHarness: string | undefined) => AdapterResolution;
|
|
37
|
+
/** The two harness inputs are rank 1 (roster) and rank 3 (step definition). */
|
|
38
|
+
export type AdapterResolver = (chosenHarness: string | undefined, stepHarness: string | undefined) => AdapterResolution;
|
|
37
39
|
/** Default confirm-phase cadence: one `get_order` per second. */
|
|
38
40
|
export declare const DEFAULT_CONFIRM_INTERVAL_MS = 1000;
|
|
39
41
|
/** Default confirm-phase bound: give the hub 15s to show the submit's outcome. */
|
|
@@ -68,27 +70,32 @@ export interface AgentRunLoopOptions {
|
|
|
68
70
|
loadStep: StepLoader;
|
|
69
71
|
resolveAdapter: AdapterResolver;
|
|
70
72
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*
|
|
79
|
-
*
|
|
73
|
+
* Merged crew rosters, in shift-start crew order. A hand-run worker and a
|
|
74
|
+
* shift started with `--all` receive exactly one machine-global roster.
|
|
75
|
+
* The Phase 1 crew selection is interim: Phase 2 replaces it with crews
|
|
76
|
+
* stamped by the hub on the order.
|
|
77
|
+
*/
|
|
78
|
+
rosters?: readonly MergedRoster[];
|
|
79
|
+
/**
|
|
80
|
+
* Phase-1 availability is adapter-registry membership at the composition
|
|
81
|
+
* root. A real binary/credential probe needs new adapter-contract surface.
|
|
80
82
|
*/
|
|
81
|
-
|
|
83
|
+
harnessAvailable: (harnessId: string) => boolean;
|
|
82
84
|
/** Gate dynamic values and rejection reasons before any prompt rendering. */
|
|
83
85
|
consumedVerifier?: ConsumedVerifier;
|
|
84
86
|
/** Append one session record. Wired to `appendSession` by the role. */
|
|
85
87
|
appendSession: (rec: SessionRecord) => void;
|
|
86
|
-
/** The attempt number for this `(workflow, run, step)`. Wired to `latestFor`. */
|
|
87
|
-
nextAttempt: (workflow: string, run: string, step: string) => number;
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* the
|
|
89
|
+
* The attempt number for this engine TASK — `(workflow, step, key)`, not
|
|
90
|
+
* `(workflow, run, step)`. Wired to `latestForTask`. Keyed on the task because
|
|
91
|
+
* the hub re-mints `run` on every firing: keyed on the run this could only ever
|
|
92
|
+
* return 1, and it did, for every firing this machine has ever executed.
|
|
93
|
+
*/
|
|
94
|
+
nextAttempt: (task: SessionTaskRef) => number;
|
|
95
|
+
/**
|
|
96
|
+
* PHASE 4 — the last session record for this engine TASK, or `null` when the
|
|
97
|
+
* task has never run here. Wired to `latestForTask(sessionsFile, ...)` by the
|
|
98
|
+
* role, the same reader `nextAttempt` already uses.
|
|
92
99
|
*
|
|
93
100
|
* It is what makes a resume possible at all: the prior `token` to resume, the
|
|
94
101
|
* `harness` that minted it, the `cwd` it is scoped to, and the
|
|
@@ -96,7 +103,7 @@ export interface AgentRunLoopOptions {
|
|
|
96
103
|
* heard. Absent (or returning `null`) ⇒ every firing is a cold start, which is
|
|
97
104
|
* exactly the pre-Phase-4 behaviour.
|
|
98
105
|
*/
|
|
99
|
-
latestSession?: (
|
|
106
|
+
latestSession?: (task: SessionTaskRef) => SessionRecord | null;
|
|
100
107
|
/**
|
|
101
108
|
* Does this directory still exist? Injected for the same reason every other
|
|
102
109
|
* side effect here is: a unit test drives the "the work dir was reaped, so the
|
|
@@ -159,10 +166,17 @@ export interface ConfirmOptions {
|
|
|
159
166
|
*/
|
|
160
167
|
export type OrderRouting = {
|
|
161
168
|
kind: 'resolved';
|
|
162
|
-
|
|
169
|
+
capability: string;
|
|
170
|
+
match: CapabilityMatch;
|
|
171
|
+
harness: string;
|
|
172
|
+
model: string;
|
|
173
|
+
effort: string;
|
|
163
174
|
} | {
|
|
164
175
|
kind: 'refused';
|
|
165
176
|
capabilities: readonly string[];
|
|
177
|
+
reason: 'harness-policy' | 'unresolvable-capability';
|
|
178
|
+
offered?: readonly string[];
|
|
179
|
+
stepHarness?: string;
|
|
166
180
|
} | {
|
|
167
181
|
kind: 'unrouted';
|
|
168
182
|
};
|
|
@@ -174,7 +188,7 @@ export type OrderRouting = {
|
|
|
174
188
|
* abstract rung with no meaning left, and reading it as a model id would put a
|
|
175
189
|
* literal `strong` on the wire to a vendor.
|
|
176
190
|
*/
|
|
177
|
-
export declare function resolveOrderRouting(packet: OrderPacket,
|
|
191
|
+
export declare function resolveOrderRouting(packet: OrderPacket, rosters: readonly MergedRoster[] | undefined, stepHarness: string | undefined, isAvailable: (harnessId: string) => boolean): OrderRouting;
|
|
178
192
|
/**
|
|
179
193
|
* Poll `get_order` at `intervalMs` for at most `graceMs`, answering ONE
|
|
180
194
|
* question: did the hub see the agent's `submit`?
|