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.
Files changed (65) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +3 -6
  3. package/dist/packages/work/src/agent/capability-model.d.ts +64 -82
  4. package/dist/packages/work/src/agent/capability-model.js +94 -91
  5. package/dist/packages/work/src/agent/loop.d.ts +39 -25
  6. package/dist/packages/work/src/agent/loop.js +102 -50
  7. package/dist/packages/work/src/bundle/types.d.ts +3 -3
  8. package/dist/packages/work/src/exec/loop.js +37 -15
  9. package/dist/packages/work/src/harness/child-env.js +4 -5
  10. package/dist/packages/work/src/harness/codex.js +3 -4
  11. package/dist/packages/work/src/harness/session-store.d.ts +63 -3
  12. package/dist/packages/work/src/harness/session-store.js +104 -9
  13. package/dist/packages/work/src/hub/types.d.ts +3 -3
  14. package/dist/packages/work/src/roles/agent-run.js +48 -42
  15. package/dist/packages/work/src/roles/sessions.d.ts +3 -2
  16. package/dist/packages/work/src/roles/sessions.js +9 -2
  17. package/dist/packages/work/src/roles/settings.js +1 -1
  18. package/dist/packages/work/src/settings/roster.d.ts +21 -0
  19. package/dist/packages/work/src/settings/roster.js +80 -0
  20. package/dist/packages/work/src/settings/settings.d.ts +12 -24
  21. package/dist/packages/work/src/settings/settings.js +17 -35
  22. package/dist/packages/work/src/shift/runtime.js +2 -10
  23. package/dist/packages/work/src/shift/spawn.d.ts +6 -53
  24. package/dist/packages/work/src/shift/spawn.js +28 -66
  25. package/dist/packages/work/src/usage.d.ts +1 -1
  26. package/dist/packages/work/src/usage.js +3 -4
  27. package/dist/src/capabilities.d.ts +44 -0
  28. package/dist/src/capabilities.js +38 -0
  29. package/dist/src/cli.d.ts +1 -0
  30. package/dist/src/cli.js +460 -5
  31. package/dist/src/config-dir.d.ts +13 -18
  32. package/dist/src/config-dir.js +15 -23
  33. package/dist/src/credentials.d.ts +1 -1
  34. package/dist/src/credentials.js +1 -1
  35. package/dist/src/crypto/records.d.ts +1 -0
  36. package/dist/src/crypto/records.js +6 -0
  37. package/dist/src/crypto/trust-roots.d.ts +2 -2
  38. package/dist/src/crypto/trust-roots.js +2 -2
  39. package/dist/src/engine.d.ts +14 -0
  40. package/dist/src/engine.js +21 -13
  41. package/dist/src/global-config.d.ts +4 -7
  42. package/dist/src/global-config.js +4 -7
  43. package/dist/src/hub.d.ts +207 -5
  44. package/dist/src/hub.js +263 -3
  45. package/dist/src/index.d.ts +2 -2
  46. package/dist/src/index.js +1 -1
  47. package/dist/src/schemas/index.d.ts +8 -0
  48. package/dist/src/schemas/order.v1.schema.json +6 -1
  49. package/dist/src/store/pre-commit-verifier.js +1 -1
  50. package/dist/src/types.d.ts +24 -4
  51. package/dist/src/work-settings.d.ts +2 -4
  52. package/dist/src/work-settings.js +2 -4
  53. package/docs/agent-runner.md +2 -2
  54. package/docs/bundles.md +3 -1
  55. package/docs/cli.md +295 -101
  56. package/docs/crypto.md +14 -14
  57. package/docs/routing.md +607 -0
  58. package/docs/shift-logs.md +22 -6
  59. package/package.json +1 -1
  60. package/plugins/claude-code/plugin/.claude-plugin/plugin.json +1 -1
  61. package/plugins/claude-code/plugin/.mcp.json +1 -1
  62. package/plugins/claude-code/plugin/skills/author/SKILL.md +1 -2
  63. package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +1 -1
  64. package/plugins/codex/plugins/owenloop/.mcp.json +1 -1
  65. package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +1 -2
@@ -92,10 +92,11 @@ import { createConsumedVerifier } from "../consumed-verifier.js";
92
92
  import { createHubClient } from "../hub/client.js";
93
93
  import { resolveBearer } from "../credentials/resolve.js";
94
94
  import { loadSettings } from "../settings/settings.js";
95
+ import { machineRosterLayers, mergeRosterLayers } from "../settings/roster.js";
95
96
  import { adapterFor, defaultHarnessId, registeredHarnessIds } from "../harness/registry.js";
96
97
  import { parseHarnessCarrier } from "../bundle/fetch.js";
97
98
  import { normalizeStepPermissions, validateHarnessOptions } from "../harness/permissions.js";
98
- import { appendSession, latestFor, sessionsPath } from "../harness/session-store.js";
99
+ import { appendSession, latestForTask, sessionsPath, } from "../harness/session-store.js";
99
100
  import { ensureWorkDir, resolveAllowedWorkdirRoots, resolveWorkRepo, resolveWorkRoot, } from "../agent/workdir.js";
100
101
  import { resolveShiftId, resolveTarget } from "./hold.js";
101
102
  import { installSignalHandlers } from "./signals.js";
@@ -154,8 +155,6 @@ export function parseArgs(args) {
154
155
  else if (name === '--shift')
155
156
  parsed.shift = r.value;
156
157
  else if (name === '--harness') {
157
- if (r.value.trim() === '')
158
- return { error: '--harness must be a non-empty harness id' };
159
158
  parsed.harness = r.value;
160
159
  }
161
160
  else {
@@ -220,8 +219,8 @@ export function exitCodeFor(outcome) {
220
219
  * adapter at all. What it still buys is the ability for a drill to register a
221
220
  * FAKE adapter inside a real spawned child without the child reaching for a
222
221
  * real CLI. Production leaves the variable unset and this is a no-op. Drills
223
- * that use it also pin `OWENLOOP_HARNESS=fake`, because the statically
224
- * imported real adapters now occupy the front of the registry and would
222
+ * that use it select a fake adapter through a roster candidate, because the
223
+ * statically imported real adapters occupy the front of the registry and would
225
224
  * otherwise win the `defaultHarnessId()` tie-break. A failed import is
226
225
  * reported and then ignored — resolution proceeds and fails honestly with
227
226
  * `'no-harness'` if nothing ended up registered.
@@ -265,12 +264,25 @@ export async function run(args, deps = {}) {
265
264
  err(`owenloop work agent-run: ${errMsg(e)}`);
266
265
  return 1;
267
266
  }
268
- // Passed through verbatim. `loadSettings` already validated every row (shape,
269
- // effort on the ladder, effort accepted by a known model), so there is nothing
270
- // left to normalize here — and nothing to default: an absent map means the
271
- // loop refuses capability-bearing orders, which is the intended answer for a
272
- // shift that never declared what serves what.
273
- const capabilityModels = settings.capabilityModels;
267
+ // Phase 1 interim rule: choose crew rosters in the order the shift was
268
+ // started with. Phase 2 replaces this handoff with crews stamped by the hub
269
+ // on each offer. A hand-run worker and a shift started with --all see only
270
+ // the machine-global settings layer.
271
+ const servedCrews = (env['OWENLOOP_SERVE_CREWS'] ?? '')
272
+ .split(',')
273
+ .map((crew) => crew.trim())
274
+ .filter((crew) => crew !== '');
275
+ let rosters;
276
+ try {
277
+ rosters =
278
+ servedCrews.length > 0
279
+ ? servedCrews.map((crew) => mergeRosterLayers(machineRosterLayers(env, crew)))
280
+ : [mergeRosterLayers(machineRosterLayers(env, undefined))];
281
+ }
282
+ catch (e) {
283
+ err(`owenloop work agent-run: ${errMsg(e)}`);
284
+ return 1;
285
+ }
274
286
  const origin = parsed.origin ?? settings.hubOrigin;
275
287
  if (origin === undefined || origin.trim() === '') {
276
288
  err('owenloop work agent-run: no hub origin — pass --origin <url> or set hubOrigin in settings');
@@ -346,36 +358,22 @@ export async function run(args, deps = {}) {
346
358
  ...(shiftId !== undefined ? { shiftId } : {}),
347
359
  };
348
360
  /**
349
- * Adapter id precedence: `--harness` > `OWENLOOP_HARNESS` > the step def's
350
- * `harness` field > the first registered adapter. Every rank is a plain
351
- * string comparison — nothing here knows what any id MEANS.
361
+ * The winning roster candidate is deliberately above the debug --harness
362
+ * flag: it extends the existing rule that resolved routing wins over a
363
+ * step's authored model and effort. Every rank is a plain string comparison.
352
364
  */
353
- const envHarness = env['OWENLOOP_HARNESS'];
354
- const resolveAdapter = (stepHarness) => {
355
- let id;
356
- if (parsed.harness !== undefined) {
357
- id = parsed.harness;
358
- }
359
- else if (envHarness !== undefined) {
360
- // Definition and default selection are lower precedence. An explicit empty
361
- // environment override is invalid; it must not silently fall through.
362
- if (envHarness.trim() === '') {
363
- return {
364
- id: '<empty OWENLOOP_HARNESS>',
365
- registered: registeredHarnessIds(),
366
- };
367
- }
368
- id = envHarness;
369
- }
370
- else {
371
- id =
372
- (stepHarness !== undefined && stepHarness !== '' ? stepHarness : undefined) ??
373
- defaultHarnessId() ??
374
- '';
375
- }
365
+ const resolveAdapter = (chosenHarness, stepHarness) => {
366
+ const id = chosenHarness ??
367
+ parsed.harness ??
368
+ (stepHarness !== undefined && stepHarness !== '' ? stepHarness : undefined) ??
369
+ defaultHarnessId() ??
370
+ '';
376
371
  const adapter = id !== '' ? adapterFor(id) : undefined;
377
372
  return {
378
- id: id !== '' ? id : '<none>',
373
+ // Keep an explicit blank `--harness` visible to the refusal instead of
374
+ // silently treating it as an absent override and selecting the default.
375
+ // A roster candidate still outranks it at the line above.
376
+ id: id !== '' || parsed.harness !== undefined ? id : '<none>',
379
377
  ...(adapter !== undefined ? { adapter } : {}),
380
378
  registered: registeredHarnessIds(),
381
379
  };
@@ -509,16 +507,24 @@ export async function run(args, deps = {}) {
509
507
  allowedWorkdirRoots: resolveAllowedWorkdirRoots(env, settings.allowedWorkdirRoots, process.cwd()),
510
508
  loadStep,
511
509
  resolveAdapter,
512
- ...(capabilityModels !== undefined ? { capabilityModels } : {}),
510
+ rosters,
511
+ // Phase-1 availability means registry membership. A real binary or
512
+ // credential probe requires new HarnessAdapter contract surface.
513
+ harnessAvailable: (id) => adapterFor(id) !== undefined,
513
514
  consumedVerifier,
514
515
  appendSession: writeSession,
515
- nextAttempt: (workflow, run, step) => {
516
- const prev = latestFor(sessionsFile, workflow, run, step);
516
+ // Both readers key on the engine TASK — `(workflow, step, key)` — and not on
517
+ // `(workflow, run, step)`. The hub mints a fresh run id every time it claims
518
+ // a step, so a run-keyed lookup can only ever see records written by the
519
+ // firing that is asking: `nextAttempt` returned 1 forever and `latestSession`
520
+ // returned null forever, which made the whole resume path unreachable.
521
+ nextAttempt: (task) => {
522
+ const prev = latestForTask(sessionsFile, task);
517
523
  return prev === null ? 1 : prev.attempt + 1;
518
524
  },
519
525
  // PHASE 4: the same reader `nextAttempt` uses, handed to the loop whole so
520
526
  // it can decide resume vs cold replay. Reads only; the loop is what writes.
521
- latestSession: (workflow, run, step) => latestFor(sessionsFile, workflow, run, step),
527
+ latestSession: (task) => latestForTask(sessionsFile, task),
522
528
  sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
523
529
  now: () => Date.now(),
524
530
  out,
@@ -47,8 +47,9 @@ export declare function formatAge(ms: number): string;
47
47
  /**
48
48
  * The resume command for one record, or `undefined` when there is none.
49
49
  *
50
- * Three separate reasons there may be none, all rendered the same way in the
51
- * table because the operator's next move is identical in each: the record names
50
+ * Four separate reasons there may be none, all rendered the same way in the
51
+ * table because the operator's next move is identical in each: the record
52
+ * carries no session token, so there is nothing to resume INTO; the record names
52
53
  * a harness this build does not register (an old row after an adapter was
53
54
  * removed); the adapter registers but implements no interactive resume; or the
54
55
  * adapter threw. The throw is caught rather than propagated because this is a
@@ -98,14 +98,21 @@ function shellQuote(s) {
98
98
  /**
99
99
  * The resume command for one record, or `undefined` when there is none.
100
100
  *
101
- * Three separate reasons there may be none, all rendered the same way in the
102
- * table because the operator's next move is identical in each: the record names
101
+ * Four separate reasons there may be none, all rendered the same way in the
102
+ * table because the operator's next move is identical in each: the record
103
+ * carries no session token, so there is nothing to resume INTO; the record names
103
104
  * a harness this build does not register (an old row after an adapter was
104
105
  * removed); the adapter registers but implements no interactive resume; or the
105
106
  * adapter threw. The throw is caught rather than propagated because this is a
106
107
  * LISTING — one bad row must not take down the other rows with it.
107
108
  */
108
109
  export function resumeCommandFor(rec) {
110
+ // An empty token is a real, readable record: the worker writes one before the
111
+ // harness emits `started`, so a launch that died still leaves proof it existed.
112
+ // Handing that empty string to `resumeCommand` would print a command that
113
+ // cannot work, which is worse than printing nothing.
114
+ if (rec.token === '')
115
+ return undefined;
109
116
  const adapter = adapterFor(rec.harness);
110
117
  if (adapter?.resumeCommand === undefined)
111
118
  return undefined;
@@ -16,7 +16,7 @@ import { inspectSettings, KNOWN_SETTINGS_KEYS } from "../settings/settings.js";
16
16
  /**
17
17
  * Built-in defaults shown for knobs absent from the file (else `unset`).
18
18
  *
19
- * `capabilityModels` is deliberately absent: it HAS no built-in default. A shift
19
+ * `roster` is deliberately absent: it HAS no built-in default. A shift
20
20
  * with no row for an order's capability refuses that order rather than falling
21
21
  * back to some default model, so printing a default here would describe
22
22
  * behaviour that does not exist.
@@ -0,0 +1,21 @@
1
+ import { type Roster, type RosterCandidate } from '../agent/capability-model.ts';
2
+ export interface RosterLayer {
3
+ /** Provenance printed verbatim by `owenloop roster show`. */
4
+ source: string;
5
+ /** Inspected even if absent, so diagnostics can state where they looked. */
6
+ path?: string;
7
+ /** Absent when the layer does not exist on this machine. */
8
+ roster?: Roster;
9
+ }
10
+ export interface MergedRosterEntry {
11
+ candidates: readonly RosterCandidate[];
12
+ source: string;
13
+ }
14
+ export type MergedRoster = Readonly<Record<string, MergedRosterEntry>>;
15
+ /** Merge key-by-key. `layers` is ordered STRONGEST FIRST. */
16
+ export declare function mergeRosterLayers(layers: readonly RosterLayer[]): MergedRoster;
17
+ /**
18
+ * The machine's layers for one crew, strongest first. When no crew is known,
19
+ * only the machine-global `settings.json` roster participates.
20
+ */
21
+ export declare function machineRosterLayers(env: Record<string, string | undefined>, crew: string | undefined): RosterLayer[];
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Crew-roster disk layout and layered merge.
3
+ *
4
+ * This module owns where machine roster layers come from and their
5
+ * strongest-first cascade. Shape validation and capability lookup remain in
6
+ * `agent/capability-model.ts`.
7
+ */
8
+ import { existsSync, readFileSync } from 'node:fs';
9
+ import { join } from 'node:path';
10
+ import { validateRoster, } from "../agent/capability-model.js";
11
+ import { owenloopConfigDir } from "../../../../src/config-dir.js";
12
+ import { loadSettings } from "./settings.js";
13
+ /** Merge key-by-key. `layers` is ordered STRONGEST FIRST. */
14
+ export function mergeRosterLayers(layers) {
15
+ // Capability names are arbitrary strings, including Object.prototype names.
16
+ // A null prototype keeps every own key routable and makes `__proto__` data,
17
+ // rather than a request to mutate the result's prototype.
18
+ const merged = Object.create(null);
19
+ for (const layer of layers) {
20
+ if (layer.roster === undefined)
21
+ continue;
22
+ for (const [capability, candidates] of Object.entries(layer.roster)) {
23
+ if (!Object.prototype.hasOwnProperty.call(merged, capability)) {
24
+ // Candidate arrays are atomic: a winning layer replaces every weaker
25
+ // candidate, never concatenating or element-merging with it.
26
+ merged[capability] = { candidates, source: layer.source };
27
+ }
28
+ }
29
+ }
30
+ return merged;
31
+ }
32
+ function readCrewRoster(path) {
33
+ let parsed;
34
+ try {
35
+ parsed = JSON.parse(readFileSync(path, 'utf8'));
36
+ }
37
+ catch (error) {
38
+ const message = error instanceof Error ? error.message : String(error);
39
+ throw new Error(`invalid crew roster at ${path}: ${message}`);
40
+ }
41
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
42
+ throw new Error(`invalid crew roster at ${path}: expected an object with a 'roster' key`);
43
+ }
44
+ const roster = parsed['roster'];
45
+ if (typeof roster !== 'object' || roster === null || Array.isArray(roster)) {
46
+ throw new Error(`invalid crew roster at ${path}: 'roster' must be a JSON object`);
47
+ }
48
+ try {
49
+ validateRoster(roster, 'roster');
50
+ }
51
+ catch (error) {
52
+ const message = error instanceof Error ? error.message : String(error);
53
+ throw new Error(`invalid crew roster at ${path}: ${message}`);
54
+ }
55
+ return roster;
56
+ }
57
+ /**
58
+ * The machine's layers for one crew, strongest first. When no crew is known,
59
+ * only the machine-global `settings.json` roster participates.
60
+ */
61
+ export function machineRosterLayers(env, crew) {
62
+ const configDir = owenloopConfigDir(env);
63
+ const layers = [];
64
+ if (crew !== undefined) {
65
+ const path = join(configDir, 'crews', `${crew}.json`);
66
+ layers.push({
67
+ source: `machine crews/${crew}.json`,
68
+ path,
69
+ ...(existsSync(path) ? { roster: readCrewRoster(path) } : {}),
70
+ });
71
+ }
72
+ const path = join(configDir, 'settings.json');
73
+ const settings = loadSettings(env);
74
+ layers.push({
75
+ source: 'machine settings.json',
76
+ path,
77
+ ...(settings.roster !== undefined ? { roster: settings.roster } : {}),
78
+ });
79
+ return layers;
80
+ }
@@ -1,4 +1,4 @@
1
- import { type CapabilityModelRow } from '../agent/capability-model.ts';
1
+ import { type Roster } from '../agent/capability-model.ts';
2
2
  /**
3
3
  * The settings surface — every knob optional, a missing file loading as `{}`.
4
4
  * Each field is the lowest-precedence fallback for a role option (a CLI flag
@@ -119,28 +119,22 @@ export interface Settings {
119
119
  */
120
120
  allowedWorkdirRoots?: string[];
121
121
  /**
122
- * How THIS machine serves each capability: a flat map from capability to
123
- * `{model, effort}`, keyed by the composed capability (`wise:deep`) or by the
124
- * bare name (`wise`). See `src/agent/capability-model.ts` for the lookup rule
125
- * and for why this replaced `tierMap`/`tierProfiles` outright.
126
- *
127
- * Carry a bare row per capability the shift's crews serve. The bare row is
128
- * what makes a hub name-match fallback order resolvable — the hub can stamp
129
- * `wise:deep` on an order claimed by a crew bound only to `wise:standard`,
130
- * and that shift has no `wise:deep` row by construction.
122
+ * Machine-global crew roster: each capability maps to an ordered list of
123
+ * `{harness, model, effort}` candidates. A crew-specific roster file can
124
+ * replace individual capability rows above this layer.
131
125
  */
132
- capabilityModels?: Record<string, CapabilityModelRow>;
126
+ roster?: Roster;
133
127
  }
134
128
  /** The known settings keys, in the order `owenloop work settings` prints them. */
135
- export declare const KNOWN_SETTINGS_KEYS: readonly ["hubOrigin", "cacheDir", "stateDir", "dispatchCap", "shiftLogDir", "shiftLogMaxAgeMs", "commandRouting", "defPolicy", "artifactPolicy", "maxConcurrentAgents", "workRoot", "workRepo", "allowedWorkdirRoots", "capabilityModels"];
129
+ export declare const KNOWN_SETTINGS_KEYS: readonly ["hubOrigin", "cacheDir", "stateDir", "dispatchCap", "shiftLogDir", "shiftLogMaxAgeMs", "commandRouting", "defPolicy", "artifactPolicy", "maxConcurrentAgents", "workRoot", "workRepo", "allowedWorkdirRoots", "roster"];
136
130
  /**
137
131
  * Keys owenloop still RECOGNIZES but no longer acts on. Each one produces a
138
132
  * warning naming what replaced it, and is excluded from `unrecognized` so the
139
133
  * same key is not also reported as a likely typo.
140
134
  *
141
- * Distinct from `tierMap`/`tierProfiles`, which are a hard error: ignoring
142
- * those would leave the shift with no capability map and refuse every order,
143
- * whereas ignoring these changes nothing about how a shift runs.
135
+ * Distinct from unrecognized keys, which are surfaced as likely typos. These
136
+ * are recognized legacy settings whose removal leaves current shift behavior
137
+ * unchanged, so they remain a warning rather than a load failure.
144
138
  */
145
139
  export declare const RETIRED_IGNORED_KEYS: readonly ["escalateAt", "escalationExtensionKey"];
146
140
  /**
@@ -176,15 +170,9 @@ export interface SettingsInspection extends ValidatedSettings {
176
170
  * Resolve the settings file path from the caller's env, through the one shared
177
171
  * ladder in `src/config-dir.ts`: `$OWENLOOP_CONFIG_DIR/settings.json` when
178
172
  * `OWENLOOP_CONFIG_DIR` is set and non-blank (it must be absolute), else
179
- * `$XDG_CONFIG_HOME/owenloop/settings.json`, else
180
- * `$HOME/.config/owenloop/settings.json`. Throws when no rung yields a value
181
- * rather than guessing a home directory.
182
- *
183
- * `OWENLOOP_CONFIG_DIR` is the variable an operator running SEVERAL shifts on
184
- * one machine should reach for. Setting `XDG_CONFIG_HOME` per shift also works,
185
- * but a shift spreads its whole environment into every worker and every command
186
- * step's child, so relocating `XDG_CONFIG_HOME` relocates the config of `gh`,
187
- * `git`, `gcloud`, and everything else those steps shell out to.
173
+ * `$HOME/.owenloop/settings.json`. Throws when no rung yields a value rather
174
+ * than guessing a home directory. `OWENLOOP_CONFIG_DIR` remains for tests and
175
+ * throwaway isolation, not normal operator configuration.
188
176
  */
189
177
  export declare function settingsPath(env: Record<string, string | undefined>): string;
190
178
  /**
@@ -15,7 +15,7 @@
15
15
  import { existsSync, readFileSync } from 'node:fs';
16
16
  import { isAbsolute, join } from 'node:path';
17
17
  import { owenloopConfigDir } from "../../../../src/config-dir.js";
18
- import { validateCapabilityModels } from "../agent/capability-model.js";
18
+ import { validateRoster } from "../agent/capability-model.js";
19
19
  /** The known settings keys, in the order `owenloop work settings` prints them. */
20
20
  export const KNOWN_SETTINGS_KEYS = [
21
21
  'hubOrigin',
@@ -31,31 +31,25 @@ export const KNOWN_SETTINGS_KEYS = [
31
31
  'workRoot',
32
32
  'workRepo',
33
33
  'allowedWorkdirRoots',
34
- 'capabilityModels',
34
+ 'roster',
35
35
  ];
36
36
  /**
37
37
  * Keys owenloop still RECOGNIZES but no longer acts on. Each one produces a
38
38
  * warning naming what replaced it, and is excluded from `unrecognized` so the
39
39
  * same key is not also reported as a likely typo.
40
40
  *
41
- * Distinct from `tierMap`/`tierProfiles`, which are a hard error: ignoring
42
- * those would leave the shift with no capability map and refuse every order,
43
- * whereas ignoring these changes nothing about how a shift runs.
41
+ * Distinct from unrecognized keys, which are surfaced as likely typos. These
42
+ * are recognized legacy settings whose removal leaves current shift behavior
43
+ * unchanged, so they remain a warning rather than a load failure.
44
44
  */
45
45
  export const RETIRED_IGNORED_KEYS = ['escalateAt', 'escalationExtensionKey'];
46
46
  /**
47
47
  * Resolve the settings file path from the caller's env, through the one shared
48
48
  * ladder in `src/config-dir.ts`: `$OWENLOOP_CONFIG_DIR/settings.json` when
49
49
  * `OWENLOOP_CONFIG_DIR` is set and non-blank (it must be absolute), else
50
- * `$XDG_CONFIG_HOME/owenloop/settings.json`, else
51
- * `$HOME/.config/owenloop/settings.json`. Throws when no rung yields a value
52
- * rather than guessing a home directory.
53
- *
54
- * `OWENLOOP_CONFIG_DIR` is the variable an operator running SEVERAL shifts on
55
- * one machine should reach for. Setting `XDG_CONFIG_HOME` per shift also works,
56
- * but a shift spreads its whole environment into every worker and every command
57
- * step's child, so relocating `XDG_CONFIG_HOME` relocates the config of `gh`,
58
- * `git`, `gcloud`, and everything else those steps shell out to.
50
+ * `$HOME/.owenloop/settings.json`. Throws when no rung yields a value rather
51
+ * than guessing a home directory. `OWENLOOP_CONFIG_DIR` remains for tests and
52
+ * throwaway isolation, not normal operator configuration.
59
53
  */
60
54
  export function settingsPath(env) {
61
55
  return join(owenloopConfigDir(env), 'settings.json');
@@ -102,19 +96,6 @@ export function validateSettings(raw, path) {
102
96
  throw bad('maxConcurrentAgents', 'a positive integer', v);
103
97
  }
104
98
  }
105
- // RETIRED KEYS ARE A HARD ERROR, NOT AN IGNORED ONE. A file still naming
106
- // `tierMap` or `tierProfiles` describes a routing scheme that no longer
107
- // exists; passing it over as an unrecognized key would start the shift with
108
- // NO capability map at all, and every agent order would then be refused at
109
- // dispatch with a message about capabilities the operator never wrote.
110
- for (const retired of ['tierMap', 'tierProfiles']) {
111
- if (retired in obj) {
112
- throw new Error(`invalid settings file at ${path}: '${retired}' was removed — tiers are replaced by ` +
113
- `'capabilityModels', a flat map from capability to { model, effort } ` +
114
- `(e.g. {"capabilityModels": {"wise:deep": {"model": "<model-id>", "effort": "xhigh"}}}). ` +
115
- `Depth now rides on the capability's modifier suffix, not on a tier rung.`);
116
- }
117
- }
118
99
  if ('allowedWorkdirRoots' in obj) {
119
100
  // ABSOLUTE PATHS ONLY, and that is the one rule worth a hard error rather
120
101
  // than a warning. A relative entry would resolve against whatever directory
@@ -137,22 +118,23 @@ export function validateSettings(raw, path) {
137
118
  }
138
119
  }
139
120
  if ('capabilityModels' in obj) {
140
- const v = obj['capabilityModels'];
121
+ throw new Error(`invalid settings file at ${path}: 'capabilityModels' was replaced by 'roster'. ` +
122
+ `Use {"roster":{"wise":[{"harness":"<harness-id>","model":"<model-id>","effort":"high"}]}}.`);
123
+ }
124
+ if ('roster' in obj) {
125
+ const v = obj['roster'];
141
126
  if (typeof v !== 'object' || v === null || Array.isArray(v)) {
142
- throw bad('capabilityModels', 'an object of { model, effort } per capability', v);
127
+ throw bad('roster', 'a JSON object mapping capabilities to candidate arrays', v);
143
128
  }
144
- // Row shape and effort validity are checked at LOAD, not at resolution: a
145
- // shift whose map is wrong should fail when it starts, not on the first
146
- // order that happens to land on the broken row, hours later.
147
129
  try {
148
- validateCapabilityModels(v);
130
+ validateRoster(v, 'roster');
149
131
  }
150
132
  catch (e) {
151
133
  throw new Error(`invalid settings file at ${path}: ${e instanceof Error ? e.message : String(e)}`);
152
134
  }
153
135
  }
154
- // RETIRED, BUT ONLY A WARNING — a different case from `tierMap` above, and the
155
- // difference is what happens if the key is silently ignored.
136
+ // RETIRED, BUT ONLY A WARNING. The difference is what happens if the key is
137
+ // silently ignored.
156
138
  //
157
139
  // These two configured the WORKER-LOCAL escalation that bumped an order's
158
140
  // model after N judgment rejections. Escalation is now entirely the engine's:
@@ -308,14 +308,7 @@ export async function runShiftRuntime(parsed, options = {}) {
308
308
  // not this run-id set, because every Shift on the machine shares the store.
309
309
  reconcileInFlight(stateDir);
310
310
  try {
311
- const configuredHarness = env['OWENLOOP_HARNESS'];
312
- const retired = reconcileActiveSessions(sessionsPath(cacheDir), {
313
- shiftName: name,
314
- shiftOwner,
315
- ...(configuredHarness !== undefined && configuredHarness.trim() !== ''
316
- ? { harness: configuredHarness }
317
- : {}),
318
- }, Date.now());
311
+ const retired = reconcileActiveSessions(sessionsPath(cacheDir), { shiftName: name, shiftOwner }, Date.now());
319
312
  for (const rec of retired) {
320
313
  process.stderr.write(`${roleLabel}: retired orphaned session ${rec.workflow}/${rec.run} step '${rec.step}' ` +
321
314
  `(harness '${rec.harness}', attempt ${String(rec.attempt ?? 1)}, ` +
@@ -466,7 +459,6 @@ export async function runShiftRuntime(parsed, options = {}) {
466
459
  run: failure.run,
467
460
  step: failure.step ?? '(unknown)',
468
461
  kind: failure.kind,
469
- ...(failure.harness !== undefined ? { harness: failure.harness } : {}),
470
462
  executable: failure.executable,
471
463
  exitStatus: failure.exitStatus,
472
464
  signal: failure.signal,
@@ -485,7 +477,7 @@ export async function runShiftRuntime(parsed, options = {}) {
485
477
  // output discarded exactly as it did before this change.
486
478
  logDirReady
487
479
  ? { dir: logDir, err: (line) => process.stderr.write(`${line}\n`) }
488
- : undefined, allowedWorkdirRoots);
480
+ : undefined, allowedWorkdirRoots, parsed.serveCrews);
489
481
  const pollIntervalMs = parsed.pollIntervalMs ?? DEFAULT_POLL_MS;
490
482
  const loop = createShiftLoop({
491
483
  hub,
@@ -20,16 +20,6 @@ export interface SpawnSpec {
20
20
  * hosts the step agent itself. This is the ONLY agent path.
21
21
  */
22
22
  kind?: 'exec' | 'agent-run';
23
- /**
24
- * Optional safe lifecycle-reporting label for an `agent-run` child. This field
25
- * never becomes `--harness`; the child resolves the authoritative harness from
26
- * CLI/environment/verified runtime definition precedence.
27
- *
28
- * It is ONE INPUT to the reported label, not the label itself, and it is the
29
- * LOWER-ranked one: `reportedHarnessId` puts the child's `OWENLOOP_HARNESS`
30
- * above it, because the child does.
31
- */
32
- harness?: string;
33
23
  /** Closed start gate created by the durable Shift reservation. */
34
24
  startGate?: string;
35
25
  /** Stable shift name in force when this worker was dispatched. */
@@ -72,48 +62,12 @@ export interface WorkerFailure {
72
62
  run: string;
73
63
  step?: string;
74
64
  kind: 'exec' | 'agent-run';
75
- harness?: string;
76
65
  executable: string;
77
66
  exitStatus: number | null;
78
67
  signal: NodeJS.Signals | null;
79
68
  message: string;
80
69
  }
81
70
  export type WorkerFailureReporter = (failure: WorkerFailure) => void;
82
- /**
83
- * The harness id to REPORT on an agent-run worker failure — a best-effort
84
- * mirror of the id the CHILD resolved, never an independent decision.
85
- *
86
- * It mirrors `resolveAdapter` in `roles/agent-run.ts`, minus the `--harness`
87
- * rank the Shift never emits:
88
- *
89
- * 1. `OWENLOOP_HARNESS` when the variable is SET. Set-but-blank is not a
90
- * fall-through: the child refuses that config outright and names it
91
- * `<empty OWENLOOP_HARNESS>`, so the failure event says the same thing.
92
- * 2. `spec.harness` — the prepared-cache step's `harness` field — when it is
93
- * a non-empty string. An empty string counts as absent, matching the
94
- * child.
95
- * 3. Otherwise the child took the first REGISTERED adapter. This process
96
- * cannot name it: the Shift is a neutral dispatcher and never imports the
97
- * adapter composition root, so its own registry is empty and asking it
98
- * would answer `undefined`. Report the placeholder instead.
99
- *
100
- * WHY THE ORDER MATTERS. It used to read `spec.harness ?? OWENLOOP_HARNESS`,
101
- * which is the child's precedence INVERTED. An operator who pinned
102
- * `OWENLOOP_HARNESS` on a shift whose cached step also named a harness got a
103
- * failure event naming the harness that did NOT run — the single most
104
- * misleading field in the record, since the harness is the first thing an
105
- * operator reaches for when a worker dies.
106
- *
107
- * BEST-EFFORT IS DELIBERATE at rank 2. A modern agent order carries no
108
- * `spec.harness` at all (the child reads the verified, order-pinned step), so
109
- * rank 2 only ever fires on the legacy cache path. The alternative — the Shift
110
- * verifying the order digest itself purely to label a failure — would duplicate
111
- * the child's whole resolution for a diagnostic string.
112
- *
113
- * `env` is the environment the CHILD is spawned with (`plan.options.env`), not
114
- * this process's — they differ, and the child's is the one that decided.
115
- */
116
- export declare function reportedHarnessId(spec: Pick<SpawnSpec, 'harness'>, env: NodeJS.ProcessEnv): string;
117
71
  /**
118
72
  * The stdio topology of a detached worker.
119
73
  *
@@ -162,11 +116,10 @@ export interface SpawnPlan {
162
116
  * — is identical for both kinds, so an agent-run child is detached,
163
117
  * stdio-ignored, and account-scoped exactly like an exec child.
164
118
  *
165
- * The Shift never emits `--harness`. A prepared-cache step is dispatch metadata,
166
- * not an operator override; the `agent-run` child resolves its authoritative
167
- * inputs in precedence order (`--harness`, `OWENLOOP_HARNESS`, verified runtime
168
- * step, registered default). The Shift command has no operator-facing harness
169
- * flag, so there is no legitimate CLI override for this seam to carry.
119
+ * The Shift never emits `--harness`. A prepared-cache step is dispatch
120
+ * metadata, not an operator override; the `agent-run` child resolves the
121
+ * selected crew-roster harness before its debug flag, verified runtime step,
122
+ * and registered default.
170
123
  *
171
124
  * `allowedWorkdirRoots` (trailing, for the same reason) rides the child's spawn
172
125
  * env as `OWENLOOP_ALLOWED_WORKDIR_ROOTS`, a `:`-separated list — the same
@@ -184,7 +137,7 @@ export interface SpawnPlan {
184
137
  * is pure, and `createDefaultSpawner` substitutes the descriptors. Omitted ⇒ no
185
138
  * `logFile` key at all, and the plan is byte-identical to the pre-logging shape.
186
139
  */
187
- export declare function buildSpawnPlan(spec: SpawnSpec, origin: string, account: string, binPath: string, execPath?: string, shiftId?: string, logDir?: string, allowedWorkdirRoots?: string[]): SpawnPlan;
140
+ export declare function buildSpawnPlan(spec: SpawnSpec, origin: string, account: string, binPath: string, execPath?: string, shiftId?: string, logDir?: string, allowedWorkdirRoots?: string[], serveCrews?: string[]): SpawnPlan;
188
141
  /**
189
142
  * The default detached spawner. Captures the resolved hub `origin`, the
190
143
  * resolved `account`, the packaged bin path, and the dispatching Shift's
@@ -193,4 +146,4 @@ export declare function buildSpawnPlan(spec: SpawnSpec, origin: string, account:
193
146
  * relying on `buildSpawnPlan`'s default) so `shiftId` — trailing after it
194
147
  * — can be supplied positionally.
195
148
  */
196
- export declare function createDefaultSpawner(origin: string, account: string, binPath?: string, shiftId?: string, onFailure?: WorkerFailureReporter, logging?: WorkerLogOptions, allowedWorkdirRoots?: string[]): Spawner;
149
+ export declare function createDefaultSpawner(origin: string, account: string, binPath?: string, shiftId?: string, onFailure?: WorkerFailureReporter, logging?: WorkerLogOptions, allowedWorkdirRoots?: string[], serveCrews?: string[]): Spawner;