owenloop 0.5.0 → 0.5.2

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 (229) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +144 -35
  3. package/bin/owenloop.mjs +49 -1
  4. package/dist/packages/work/src/agent/brief.d.ts +29 -4
  5. package/dist/packages/work/src/agent/brief.js +49 -4
  6. package/dist/packages/work/src/agent/capability-model.d.ts +123 -0
  7. package/dist/packages/work/src/agent/capability-model.js +148 -0
  8. package/dist/packages/work/src/agent/loop.d.ts +56 -7
  9. package/dist/packages/work/src/agent/loop.js +166 -9
  10. package/dist/packages/work/src/bundle/cache.d.ts +7 -5
  11. package/dist/packages/work/src/bundle/cache.js +20 -6
  12. package/dist/packages/work/src/bundle/fetch.d.ts +7 -5
  13. package/dist/packages/work/src/bundle/fetch.js +27 -7
  14. package/dist/packages/work/src/bundle/types.d.ts +8 -4
  15. package/dist/packages/work/src/consumed-verifier.d.ts +45 -0
  16. package/dist/packages/work/src/consumed-verifier.js +205 -0
  17. package/dist/packages/work/src/exec/instructions.d.ts +99 -0
  18. package/dist/packages/work/src/exec/instructions.js +323 -0
  19. package/dist/packages/work/src/exec/loop.d.ts +29 -1
  20. package/dist/packages/work/src/exec/loop.js +313 -35
  21. package/dist/packages/work/src/exec/payload.d.ts +29 -0
  22. package/dist/packages/work/src/exec/payload.js +54 -0
  23. package/dist/packages/work/src/exec/receipt.d.ts +9 -6
  24. package/dist/packages/work/src/exec/receipt.js +12 -1
  25. package/dist/packages/work/src/exec/runner.d.ts +7 -1
  26. package/dist/packages/work/src/exec/runner.js +84 -3
  27. package/dist/packages/work/src/harness/child-env.js +7 -0
  28. package/dist/packages/work/src/harness/claude.d.ts +20 -8
  29. package/dist/packages/work/src/harness/claude.js +260 -58
  30. package/dist/packages/work/src/harness/codex.d.ts +5 -4
  31. package/dist/packages/work/src/harness/codex.js +169 -41
  32. package/dist/packages/work/src/harness/contract.d.ts +36 -11
  33. package/dist/packages/work/src/harness/fake.js +1 -0
  34. package/dist/packages/work/src/harness/jsonrpc-stdio.js +7 -0
  35. package/dist/packages/work/src/harness/permissions.d.ts +16 -3
  36. package/dist/packages/work/src/harness/permissions.js +102 -13
  37. package/dist/packages/work/src/harness/session-store.d.ts +30 -10
  38. package/dist/packages/work/src/harness/session-store.js +317 -89
  39. package/dist/packages/work/src/hold/mcp.d.ts +25 -5
  40. package/dist/packages/work/src/hold/mcp.js +134 -12
  41. package/dist/packages/work/src/hub/client.d.ts +8 -1
  42. package/dist/packages/work/src/hub/client.js +15 -1
  43. package/dist/packages/work/src/hub/types.d.ts +137 -33
  44. package/dist/packages/work/src/hub/types.js +8 -10
  45. package/dist/packages/work/src/mcp/server.js +1 -1
  46. package/dist/packages/work/src/owenloop-bin.d.ts +1 -0
  47. package/dist/packages/work/src/owenloop-bin.js +18 -0
  48. package/dist/packages/work/src/roles/agent-run.d.ts +12 -6
  49. package/dist/packages/work/src/roles/agent-run.js +115 -34
  50. package/dist/packages/work/src/roles/exec.d.ts +8 -0
  51. package/dist/packages/work/src/roles/exec.js +27 -2
  52. package/dist/packages/work/src/roles/hold.d.ts +6 -0
  53. package/dist/packages/work/src/roles/hold.js +83 -13
  54. package/dist/packages/work/src/roles/lint.d.ts +3 -4
  55. package/dist/packages/work/src/roles/lint.js +41 -7
  56. package/dist/packages/work/src/roles/settings.js +19 -2
  57. package/dist/packages/work/src/roles/shift.d.ts +1 -0
  58. package/dist/packages/work/src/roles/shift.js +36 -2
  59. package/dist/packages/work/src/settings/settings.d.ts +70 -1
  60. package/dist/packages/work/src/settings/settings.js +90 -4
  61. package/dist/packages/work/src/shift/logretention.d.ts +253 -0
  62. package/dist/packages/work/src/shift/logretention.js +407 -0
  63. package/dist/packages/work/src/shift/logsink.d.ts +14 -0
  64. package/dist/packages/work/src/shift/logsink.js +98 -0
  65. package/dist/packages/work/src/shift/loop.d.ts +32 -4
  66. package/dist/packages/work/src/shift/loop.js +687 -166
  67. package/dist/packages/work/src/shift/protocol.d.ts +128 -1
  68. package/dist/packages/work/src/shift/protocol.js +14 -0
  69. package/dist/packages/work/src/shift/runtime.d.ts +16 -0
  70. package/dist/packages/work/src/shift/runtime.js +291 -5
  71. package/dist/packages/work/src/shift/server.d.ts +13 -0
  72. package/dist/packages/work/src/shift/server.js +61 -36
  73. package/dist/packages/work/src/shift/spawn.d.ts +115 -19
  74. package/dist/packages/work/src/shift/spawn.js +234 -30
  75. package/dist/packages/work/src/shift/state.d.ts +76 -49
  76. package/dist/packages/work/src/shift/state.js +350 -103
  77. package/dist/packages/work/src/shift/truncate.d.ts +35 -0
  78. package/dist/packages/work/src/shift/truncate.js +73 -0
  79. package/dist/packages/work/src/submit-proof.d.ts +61 -0
  80. package/dist/packages/work/src/submit-proof.js +119 -0
  81. package/dist/packages/work/src/submit-value.d.ts +48 -0
  82. package/dist/packages/work/src/submit-value.js +118 -0
  83. package/dist/packages/work/src/usage.d.ts +1 -1
  84. package/dist/packages/work/src/usage.js +11 -0
  85. package/dist/src/add.d.ts +64 -259
  86. package/dist/src/add.js +81 -615
  87. package/dist/src/archive.d.ts +97 -0
  88. package/dist/src/archive.js +591 -0
  89. package/dist/src/bundle/index.d.ts +64 -0
  90. package/dist/src/bundle/index.js +508 -0
  91. package/dist/src/bundle/manifest.d.ts +50 -0
  92. package/dist/src/bundle/manifest.js +435 -0
  93. package/dist/src/bundle/runtime.d.ts +26 -0
  94. package/dist/src/bundle/runtime.js +64 -0
  95. package/dist/src/bundle/tar.d.ts +62 -0
  96. package/dist/src/bundle/tar.js +238 -0
  97. package/dist/src/bundle/types.d.ts +105 -0
  98. package/dist/src/bundle/types.js +21 -0
  99. package/dist/src/capabilities.d.ts +93 -0
  100. package/dist/src/capabilities.js +101 -0
  101. package/dist/src/cli.d.ts +90 -20
  102. package/dist/src/cli.js +2421 -374
  103. package/dist/src/credentials.d.ts +4 -3
  104. package/dist/src/credentials.js +21 -19
  105. package/dist/src/crypto/allowed-signers.d.ts +68 -0
  106. package/dist/src/crypto/allowed-signers.js +307 -0
  107. package/dist/src/crypto/canonical.d.ts +8 -0
  108. package/dist/src/crypto/canonical.js +92 -0
  109. package/dist/src/crypto/chain.d.ts +65 -0
  110. package/dist/src/crypto/chain.js +377 -0
  111. package/dist/src/crypto/dsse.d.ts +209 -0
  112. package/dist/src/crypto/dsse.js +282 -0
  113. package/dist/src/crypto/enrollment.d.ts +78 -0
  114. package/dist/src/crypto/enrollment.js +186 -0
  115. package/dist/src/crypto/index.d.ts +48 -0
  116. package/dist/src/crypto/index.js +44 -0
  117. package/dist/src/crypto/keys.d.ts +258 -0
  118. package/dist/src/crypto/keys.js +908 -0
  119. package/dist/src/crypto/org-root.d.ts +33 -0
  120. package/dist/src/crypto/org-root.js +78 -0
  121. package/dist/src/crypto/origin-rules.d.ts +56 -0
  122. package/dist/src/crypto/origin-rules.js +143 -0
  123. package/dist/src/crypto/policy-floor.d.ts +98 -0
  124. package/dist/src/crypto/policy-floor.js +353 -0
  125. package/dist/src/crypto/records.d.ts +319 -0
  126. package/dist/src/crypto/records.js +168 -0
  127. package/dist/src/crypto/scope.d.ts +49 -0
  128. package/dist/src/crypto/scope.js +83 -0
  129. package/dist/src/crypto/ssh.d.ts +171 -0
  130. package/dist/src/crypto/ssh.js +396 -0
  131. package/dist/src/crypto/submission.d.ts +33 -0
  132. package/dist/src/crypto/submission.js +47 -0
  133. package/dist/src/crypto/trust-roots.d.ts +29 -0
  134. package/dist/src/crypto/trust-roots.js +39 -0
  135. package/dist/src/crypto/verify-consumed.d.ts +67 -0
  136. package/dist/src/crypto/verify-consumed.js +259 -0
  137. package/dist/src/crypto/verify-origin.d.ts +50 -0
  138. package/dist/src/crypto/verify-origin.js +151 -0
  139. package/dist/src/crypto/verify-publication.d.ts +60 -0
  140. package/dist/src/crypto/verify-publication.js +150 -0
  141. package/dist/src/defs.d.ts +24 -1
  142. package/dist/src/defs.js +335 -27
  143. package/dist/src/engine.d.ts +211 -6
  144. package/dist/src/engine.js +459 -59
  145. package/dist/src/factory.d.ts +16 -0
  146. package/dist/src/factory.js +16 -4
  147. package/dist/src/global-config.d.ts +59 -0
  148. package/dist/src/global-config.js +84 -0
  149. package/dist/src/hub.d.ts +102 -32
  150. package/dist/src/hub.js +147 -58
  151. package/dist/src/index.d.ts +19 -2
  152. package/dist/src/index.js +23 -2
  153. package/dist/src/install.d.ts +538 -0
  154. package/dist/src/install.js +1981 -0
  155. package/dist/src/lock.d.ts +15 -57
  156. package/dist/src/lock.js +251 -143
  157. package/dist/src/mcp/serve.d.ts +46 -22
  158. package/dist/src/mcp/serve.js +174 -44
  159. package/dist/src/mcp/server.js +12 -1
  160. package/dist/src/model.d.ts +51 -0
  161. package/dist/src/model.js +157 -1
  162. package/dist/src/order-resolver.d.ts +184 -0
  163. package/dist/src/order-resolver.js +252 -0
  164. package/dist/src/package-version.d.ts +10 -0
  165. package/dist/src/package-version.js +42 -0
  166. package/dist/src/paths.d.ts +14 -1
  167. package/dist/src/paths.js +18 -0
  168. package/dist/src/schemas/enrollment-grant.v1.schema.json +90 -0
  169. package/dist/src/schemas/index.d.ts +1433 -0
  170. package/dist/src/schemas/index.js +31 -0
  171. package/dist/src/schemas/order.v1.schema.json +120 -0
  172. package/dist/src/schemas/origin.v1.schema.json +68 -0
  173. package/dist/src/schemas/policy-floor.v1.schema.json +29 -0
  174. package/dist/src/schemas/publication.v1.schema.json +31 -0
  175. package/dist/src/schemas/revocation.v1.schema.json +39 -0
  176. package/dist/src/schemas/submission.v1.schema.json +61 -0
  177. package/dist/src/store/def-source.d.ts +52 -0
  178. package/dist/src/store/def-source.js +335 -0
  179. package/dist/src/store/index-file.d.ts +69 -0
  180. package/dist/src/store/index-file.js +151 -0
  181. package/dist/src/store/index.d.ts +27 -0
  182. package/dist/src/store/index.js +22 -0
  183. package/dist/src/store/ingestor.d.ts +43 -0
  184. package/dist/src/store/ingestor.js +211 -0
  185. package/dist/src/store/install.d.ts +228 -0
  186. package/dist/src/store/install.js +555 -0
  187. package/dist/src/store/instruction-source.d.ts +49 -0
  188. package/dist/src/store/instruction-source.js +298 -0
  189. package/dist/src/store/origin-evidence.d.ts +21 -0
  190. package/dist/src/store/origin-evidence.js +66 -0
  191. package/dist/src/store/pre-commit-verifier.d.ts +68 -0
  192. package/dist/src/store/pre-commit-verifier.js +418 -0
  193. package/dist/src/store/resolve.d.ts +138 -0
  194. package/dist/src/store/resolve.js +363 -0
  195. package/dist/src/store/types.d.ts +288 -0
  196. package/dist/src/store/types.js +356 -0
  197. package/dist/src/store.d.ts +33 -1
  198. package/dist/src/store.js +57 -4
  199. package/dist/src/types.d.ts +146 -12
  200. package/dist/src/untar.d.ts +8 -23
  201. package/dist/src/untar.js +10 -136
  202. package/docs/agent-runner.md +86 -0
  203. package/docs/authoring.md +64 -6
  204. package/docs/bundles.md +350 -0
  205. package/docs/cli.md +1298 -106
  206. package/docs/crypto.md +832 -0
  207. package/docs/design.md +342 -20
  208. package/docs/embedding.md +132 -25
  209. package/docs/shift-logs.md +642 -0
  210. package/docs/wire-contracts.md +395 -0
  211. package/package.json +6 -1
  212. package/plugins/claude-code/.claude-plugin/marketplace.json +14 -0
  213. package/plugins/claude-code/plugin/.claude-plugin/plugin.json +8 -0
  214. package/plugins/claude-code/plugin/.mcp.json +14 -0
  215. package/plugins/claude-code/plugin/hooks/hooks.json +26 -0
  216. package/plugins/claude-code/plugin/hooks/session-end.sh +40 -0
  217. package/plugins/claude-code/plugin/hooks/session-start.sh +52 -0
  218. package/plugins/claude-code/plugin/skills/author/SKILL.md +181 -0
  219. package/plugins/claude-code/plugin/skills/conduct/SKILL.md +106 -0
  220. package/plugins/claude-code/plugin/skills/shift/SKILL.md +105 -0
  221. package/plugins/codex/.agents/plugins/marketplace.json +21 -0
  222. package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +7 -0
  223. package/plugins/codex/plugins/owenloop/.mcp.json +20 -0
  224. package/plugins/codex/plugins/owenloop/hooks/hooks.json +26 -0
  225. package/plugins/codex/plugins/owenloop/hooks/session-end.sh +40 -0
  226. package/plugins/codex/plugins/owenloop/hooks/session-start.sh +52 -0
  227. package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +181 -0
  228. package/plugins/codex/plugins/owenloop/skills/conduct/SKILL.md +106 -0
  229. package/plugins/codex/plugins/owenloop/skills/shift/SKILL.md +105 -0
@@ -35,6 +35,7 @@ import "../harnesses.js";
35
35
  import { existsSync, readFileSync } from 'node:fs';
36
36
  import { parse as parseYaml } from 'yaml';
37
37
  import { adapterFor, defaultHarnessId } from "../harness/registry.js";
38
+ import { normalizeStepPermissions, preflightStepPermissions, validateHarnessOptions, } from "../harness/permissions.js";
38
39
  import { parseHarnessCarrier } from "../bundle/fetch.js";
39
40
  import { readLatestBundle, resolveCacheDir } from "../bundle/cache.js";
40
41
  import { loadSettings } from "../settings/settings.js";
@@ -86,10 +87,9 @@ export async function run(args) {
86
87
  * Findings for ONE step: resolve which adapter would run it, then hand that
87
88
  * adapter the step's option bag.
88
89
  *
89
- * A step with no `x.harness` bag at all is silent — an empty bag is a completely
90
- * normal step, and lint has nothing to say about it. That is why the empty-bag
91
- * check comes BEFORE the unregistered-harness check: a def that names no harness
92
- * and carries no options is clean even in a build with an empty registry.
90
+ * A step that omits both the harness id and the `x.harness` bag is silent — lint
91
+ * has no explicit selection or options to judge. An explicit id is checked even
92
+ * when no option bag exists, because dispatch would still try to resolve that id.
93
93
  *
94
94
  * ONE finding is raised HERE rather than by the adapter: the bag-`model` /
95
95
  * first-class-`model` conflict. The harness contract's `lintStep(bag, step)`
@@ -105,9 +105,20 @@ export async function run(args) {
105
105
  */
106
106
  export function lintOneStep(step) {
107
107
  const bag = step.harnessOptions;
108
+ const id = step.harness ?? defaultHarnessId();
109
+ // An explicit id is independently lintable: naming an adapter this build does
110
+ // not have is an error even when the step carries no adapter option fields.
111
+ // Omission with no bag remains clean because there is nothing to validate.
112
+ if (step.harness !== undefined && adapterFor(step.harness) === undefined) {
113
+ return [{
114
+ severity: 'error',
115
+ step: step.name,
116
+ message: `unknown harness '${step.harness}' — this build cannot run it`,
117
+ field: 'id',
118
+ }];
119
+ }
108
120
  if (bag === undefined)
109
121
  return [];
110
- const id = step.harness ?? defaultHarnessId();
111
122
  if (id === undefined) {
112
123
  return [{
113
124
  severity: 'error',
@@ -124,7 +135,23 @@ export function lintOneStep(step) {
124
135
  field: 'id',
125
136
  }];
126
137
  }
127
- const findings = [...(adapter.lintStep?.(bag, step.name) ?? [])];
138
+ const permissions = normalizeStepPermissions(bag, step);
139
+ const findings = [
140
+ ...validateHarnessOptions(bag, step.name),
141
+ ...preflightStepPermissions(permissions).map((issue) => ({
142
+ severity: 'error',
143
+ step: step.name,
144
+ message: issue.message,
145
+ ...(issue.field !== undefined ? { field: issue.field } : {}),
146
+ })),
147
+ ...adapter.preflight(permissions).map((issue) => ({
148
+ severity: 'error',
149
+ step: step.name,
150
+ message: issue.message,
151
+ ...(issue.field !== undefined ? { field: issue.field } : {}),
152
+ })),
153
+ ...(adapter.lintStep?.(bag, step.name) ?? []),
154
+ ];
128
155
  if (step.model !== undefined && 'model' in bag) {
129
156
  findings.push({
130
157
  severity: 'warning',
@@ -133,7 +160,14 @@ export function lintOneStep(step) {
133
160
  message: `bag sets model but the step's first-class model wins (step model: '${step.model}')`,
134
161
  });
135
162
  }
136
- return findings;
163
+ const seen = new Set();
164
+ return findings.filter((finding) => {
165
+ const key = `${finding.severity}\0${finding.step}\0${finding.field ?? ''}\0${finding.message}`;
166
+ if (seen.has(key))
167
+ return false;
168
+ seen.add(key);
169
+ return true;
170
+ });
137
171
  }
138
172
  /** Load the steps to lint from a yaml def, a json bundle, or a bare name. */
139
173
  function loadSteps(target) {
@@ -13,10 +13,18 @@
13
13
  * args (there are no options in v1).
14
14
  */
15
15
  import { inspectSettings, KNOWN_SETTINGS_KEYS } from "../settings/settings.js";
16
- /** Built-in defaults shown for knobs absent from the file (else `unset`). */
16
+ /**
17
+ * Built-in defaults shown for knobs absent from the file (else `unset`).
18
+ *
19
+ * `capabilityModels` is deliberately absent: it HAS no built-in default. A shift
20
+ * with no row for an order's capability refuses that order rather than falling
21
+ * back to some default model, so printing a default here would describe
22
+ * behaviour that does not exist.
23
+ */
17
24
  const DEFAULT_NOTE = {
18
25
  dispatchCap: '3',
19
26
  commandRouting: 'shift',
27
+ defPolicy: 'warn',
20
28
  };
21
29
  function errMsg(err) {
22
30
  return err instanceof Error ? err.message : String(err);
@@ -38,7 +46,7 @@ export async function run(args, deps = {}) {
38
46
  err(`owenloop work settings: ${errMsg(e)}`);
39
47
  return 1;
40
48
  }
41
- const { path, exists, settings, unrecognized } = inspection;
49
+ const { path, exists, settings, unrecognized, warnings } = inspection;
42
50
  out(`settings file: ${path}`);
43
51
  out(`exists: ${exists ? 'yes' : 'no'}`);
44
52
  out('');
@@ -58,6 +66,15 @@ export async function run(args, deps = {}) {
58
66
  out('');
59
67
  out(`unrecognized keys (ignored — likely typos): ${unrecognized.join(', ')}`);
60
68
  }
69
+ // Warnings are keys owenloop still recognizes but no longer acts on. They do
70
+ // not fail the load and so do not change the exit code; a shift that starts on
71
+ // this file starts fine. They print because the alternative is the operator
72
+ // continuing to believe a dead knob does something.
73
+ if (warnings.length > 0) {
74
+ out('');
75
+ for (const warning of warnings)
76
+ out(`warning: ${warning}`);
77
+ }
61
78
  return 0;
62
79
  }
63
80
  /** Render a settings value for display: strings bare, everything else JSON. */
@@ -8,5 +8,6 @@ declare function resolveSocketPath(flag: string | undefined): {
8
8
  path?: string;
9
9
  error?: string;
10
10
  };
11
+ export declare function shiftDaemonClientPlatformError(command: 'next' | 'status' | 'end', platform?: NodeJS.Platform): string | undefined;
11
12
  export declare function run(args: string[]): Promise<number>;
12
13
  export { parseStartArgs, resolveSocketPath };
@@ -7,13 +7,14 @@
7
7
  */
8
8
  import { loadSettings } from "../settings/settings.js";
9
9
  import { resolveStateDir } from "../shift/state.js";
10
- import { resolveStateDirOverride, runShiftRuntime } from "../shift/runtime.js";
10
+ import { assertShiftDaemonPlatform, resolveStateDirOverride, runShiftRuntime, } from "../shift/runtime.js";
11
11
  import { noDaemonMessage, parseNextArgs, parseStateDirArgs, requestShift, ShiftClientError, shiftSocketPath, } from "../shift/client.js";
12
12
  import { isShiftError } from "../shift/protocol.js";
13
13
  function usage() {
14
14
  process.stderr.write('usage: owenloop shift start <crew...> [--all] [--origin <url>] [--as <account>] [--name <n>]\n' +
15
15
  ' [--cap <n>] [--max-agents <n>] [--poll-interval <ms>] [--once]\n' +
16
16
  ' [--cache-dir <p>] [--state-dir <p>]\n' +
17
+ ' [--log-dir <p>] [--log-max-age <ms>]\n' +
17
18
  ' owenloop shift next [--wait <seconds>] [--state-dir <p>]\n' +
18
19
  ' owenloop shift status [--state-dir <p>]\n' +
19
20
  ' owenloop shift end [--state-dir <p>]\n');
@@ -27,7 +28,10 @@ function intValue(raw, flag) {
27
28
  }
28
29
  function parseStartArgs(args) {
29
30
  const parsed = { crews: [] };
30
- const valueFlags = new Set(['--origin', '--as', '--name', '--cap', '--max-agents', '--poll-interval', '--cache-dir', '--state-dir']);
31
+ const valueFlags = new Set([
32
+ '--origin', '--as', '--name', '--cap', '--max-agents', '--poll-interval',
33
+ '--cache-dir', '--state-dir', '--log-dir', '--log-max-age',
34
+ ]);
31
35
  for (let i = 0; i < args.length; i++) {
32
36
  const raw = args[i];
33
37
  const name = raw.startsWith('--') && raw.includes('=') ? raw.slice(0, raw.indexOf('=')) : raw;
@@ -57,6 +61,14 @@ function parseStartArgs(args) {
57
61
  parsed.cacheDir = value;
58
62
  else if (name === '--state-dir')
59
63
  parsed.stateDir = value;
64
+ else if (name === '--log-dir')
65
+ parsed.logDir = value;
66
+ else if (name === '--log-max-age') {
67
+ const n = intValue(value, '--log-max-age');
68
+ if (typeof n !== 'number')
69
+ return { crews: parsed.crews, error: n };
70
+ parsed.logMaxAgeMs = n;
71
+ }
60
72
  else if (name === '--cap') {
61
73
  const n = intValue(value, '--cap');
62
74
  if (typeof n !== 'number')
@@ -114,6 +126,22 @@ function resolveSocketPath(flag) {
114
126
  function printJson(value) {
115
127
  process.stdout.write(`${JSON.stringify(value)}\n`);
116
128
  }
129
+ export function shiftDaemonClientPlatformError(command, platform = process.platform) {
130
+ try {
131
+ assertShiftDaemonPlatform(platform);
132
+ return undefined;
133
+ }
134
+ catch (error) {
135
+ return `owenloop shift ${command}: ${error instanceof Error ? error.message : String(error)}`;
136
+ }
137
+ }
138
+ function rejectUnsupportedDaemonClient(command) {
139
+ const error = shiftDaemonClientPlatformError(command);
140
+ if (error === undefined)
141
+ return false;
142
+ process.stderr.write(`${error}\n`);
143
+ return true;
144
+ }
117
145
  async function runNext(args) {
118
146
  const parsed = parseNextArgs(args);
119
147
  if (parsed.error !== undefined) {
@@ -121,6 +149,8 @@ async function runNext(args) {
121
149
  usage();
122
150
  return 2;
123
151
  }
152
+ if (rejectUnsupportedDaemonClient('next'))
153
+ return 1;
124
154
  const socket = resolveSocketPath(parsed.stateDir);
125
155
  if (socket.error !== undefined || socket.path === undefined) {
126
156
  process.stderr.write(`owenloop shift next: ${socket.error ?? 'cannot resolve state directory'}\n`);
@@ -147,6 +177,8 @@ async function runStatus(args) {
147
177
  usage();
148
178
  return 2;
149
179
  }
180
+ if (rejectUnsupportedDaemonClient('status'))
181
+ return 1;
150
182
  const socket = resolveSocketPath(parsed.stateDir);
151
183
  if (socket.error !== undefined || socket.path === undefined) {
152
184
  process.stderr.write(`owenloop shift status: ${socket.error ?? 'cannot resolve state directory'}\n`);
@@ -177,6 +209,8 @@ async function runEnd(args) {
177
209
  usage();
178
210
  return 2;
179
211
  }
212
+ if (rejectUnsupportedDaemonClient('end'))
213
+ return 1;
180
214
  const socket = resolveSocketPath(parsed.stateDir);
181
215
  if (socket.error !== undefined || socket.path === undefined) {
182
216
  process.stderr.write(`owenloop shift end: ${socket.error ?? 'cannot resolve state directory'}\n`);
@@ -1,3 +1,4 @@
1
+ import { type CapabilityModelRow } from '../agent/capability-model.ts';
1
2
  /**
2
3
  * The settings surface — every knob optional, a missing file loading as `{}`.
3
4
  * Each field is the lowest-precedence fallback for a role option (a CLI flag
@@ -10,7 +11,12 @@
10
11
  * (below `OWENLOOP_STATE_DIR`).
11
12
  * - `dispatchCap` — shift max in-flight exec children; below `--cap`,
12
13
  * above the built-in default of 3. A positive integer.
14
+ * - `shiftLogDir` — where `shift.log` and `<run>.log` are written; below
15
+ * `--log-dir` and `OWENLOOP_SHIFT_LOG_DIR`, above the state dir.
16
+ * - `shiftLogMaxAgeMs` — worker-log retention in ms; below `--log-max-age`
17
+ * and `OWENLOOP_SHIFT_LOG_MAX_AGE_MS`, above the 14-day default.
13
18
  * - `commandRouting` — who runs `executor: 'command'` steps this machine sees.
19
+ * - `defPolicy` — local publication trust policy (`warn` by default).
14
20
  */
15
21
  export interface Settings {
16
22
  /** Default hub origin when `--origin` is omitted. */
@@ -21,6 +27,24 @@ export interface Settings {
21
27
  stateDir?: string;
22
28
  /** Shift dispatch cap (positive integer); fallback below `--cap`, default 3. */
23
29
  dispatchCap?: number;
30
+ /**
31
+ * Directory holding the shift's own `shift.log` and each worker's `<run>.log`.
32
+ * Fallback below `--log-dir` and `OWENLOOP_SHIFT_LOG_DIR`; defaults to the
33
+ * resolved `stateDir`, which puts `<run>.log` beside its `<run>.json`.
34
+ */
35
+ shiftLogDir?: string;
36
+ /**
37
+ * How long a worker's `<run>.log` is kept, in milliseconds. Fallback below
38
+ * `--log-max-age` and `OWENLOOP_SHIFT_LOG_MAX_AGE_MS`; defaults to 14 days.
39
+ *
40
+ * A NON-NEGATIVE integer, unlike `dispatchCap`, which must be positive: `0`
41
+ * is meaningful here and means "reap every worker log whose run has
42
+ * completed, at the next shift startup".
43
+ *
44
+ * Applies ONLY to per-worker `<run>.log` files. `shift.log` is never reaped
45
+ * and never rotated — see `docs/shift-logs.md`.
46
+ */
47
+ shiftLogMaxAgeMs?: number;
24
48
  /**
25
49
  * Who runs `executor: 'command'` steps this machine sees: `'shift'` (default)
26
50
  * lets the shift auto-dispatch them; `'manual'` leaves them for a human/
@@ -29,6 +53,15 @@ export interface Settings {
29
53
  * most restrictive wins (see src/shift/routing.ts).
30
54
  */
31
55
  commandRouting?: 'shift' | 'manual';
56
+ /**
57
+ * Publication trust policy for installed workflow definitions. `warn` is the
58
+ * built-in default; `enforce` refuses unsigned/unverifiable definitions and
59
+ * `off` suppresses those warnings for agent orders only. Command workers
60
+ * always require a verified definition regardless of this value.
61
+ */
62
+ defPolicy?: 'enforce' | 'warn' | 'off';
63
+ /** Policy for signed consumed artifact values; defaults to `warn`. */
64
+ artifactPolicy?: 'enforce' | 'warn' | 'off';
32
65
  /**
33
66
  * Max in-flight `agent-run` children (positive integer, default 4 —
34
67
  * `DEFAULT_MAX_AGENTS` in `src/roles/shift.ts`). A SEPARATE
@@ -66,9 +99,31 @@ export interface Settings {
66
99
  * of the MACHINE running the shift, not of the workflow.
67
100
  */
68
101
  workRepo?: string;
102
+ /**
103
+ * How THIS machine serves each capability: a flat map from capability to
104
+ * `{model, effort}`, keyed by the composed capability (`wise:deep`) or by the
105
+ * bare name (`wise`). See `src/agent/capability-model.ts` for the lookup rule
106
+ * and for why this replaced `tierMap`/`tierProfiles` outright.
107
+ *
108
+ * Carry a bare row per capability the shift's crews serve. The bare row is
109
+ * what makes a hub name-match fallback order resolvable — the hub can stamp
110
+ * `wise:deep` on an order claimed by a crew bound only to `wise:standard`,
111
+ * and that shift has no `wise:deep` row by construction.
112
+ */
113
+ capabilityModels?: Record<string, CapabilityModelRow>;
69
114
  }
70
115
  /** The known settings keys, in the order `owenloop work settings` prints them. */
71
- export declare const KNOWN_SETTINGS_KEYS: readonly ["hubOrigin", "cacheDir", "stateDir", "dispatchCap", "commandRouting", "maxConcurrentAgents", "workRoot", "workRepo"];
116
+ export declare const KNOWN_SETTINGS_KEYS: readonly ["hubOrigin", "cacheDir", "stateDir", "dispatchCap", "shiftLogDir", "shiftLogMaxAgeMs", "commandRouting", "defPolicy", "artifactPolicy", "maxConcurrentAgents", "workRoot", "workRepo", "capabilityModels"];
117
+ /**
118
+ * Keys owenloop still RECOGNIZES but no longer acts on. Each one produces a
119
+ * warning naming what replaced it, and is excluded from `unrecognized` so the
120
+ * same key is not also reported as a likely typo.
121
+ *
122
+ * Distinct from `tierMap`/`tierProfiles`, which are a hard error: ignoring
123
+ * those would leave the shift with no capability map and refuse every order,
124
+ * whereas ignoring these changes nothing about how a shift runs.
125
+ */
126
+ export declare const RETIRED_IGNORED_KEYS: readonly ["escalateAt", "escalationExtensionKey"];
72
127
  /**
73
128
  * A validated load: the typed `settings` (unknown keys retained for forward
74
129
  * compatibility — consumers ignore them), plus the list of keys that are NOT
@@ -78,6 +133,20 @@ export interface ValidatedSettings {
78
133
  settings: Settings;
79
134
  /** Keys present in the file that owenloop does not recognize. */
80
135
  unrecognized: string[];
136
+ /**
137
+ * Non-fatal findings from validation, in the order they were noticed.
138
+ *
139
+ * A SEPARATE CHANNEL FROM `unrecognized` because it answers a different
140
+ * question. `unrecognized` says "owenloop does not know this key at all,
141
+ * probably a typo"; a warning says "the key is known, but something about it
142
+ * is worth your attention" — today, only `RETIRED_IGNORED_KEYS`: a key
143
+ * owenloop still recognizes and no longer acts on.
144
+ *
145
+ * Callers decide what to do with these. `owenloop work settings` prints them;
146
+ * the shift prints them once at startup. Nothing here ever blocks a load —
147
+ * anything that should block throws instead.
148
+ */
149
+ warnings: string[];
81
150
  }
82
151
  /** The result of inspecting the settings file: where it is, whether it exists, and its validated contents. */
83
152
  export interface SettingsInspection extends ValidatedSettings {
@@ -14,17 +14,33 @@
14
14
  */
15
15
  import { existsSync, readFileSync } from 'node:fs';
16
16
  import { join } from 'node:path';
17
+ import { validateCapabilityModels } from "../agent/capability-model.js";
17
18
  /** The known settings keys, in the order `owenloop work settings` prints them. */
18
19
  export const KNOWN_SETTINGS_KEYS = [
19
20
  'hubOrigin',
20
21
  'cacheDir',
21
22
  'stateDir',
22
23
  'dispatchCap',
24
+ 'shiftLogDir',
25
+ 'shiftLogMaxAgeMs',
23
26
  'commandRouting',
27
+ 'defPolicy',
28
+ 'artifactPolicy',
24
29
  'maxConcurrentAgents',
25
30
  'workRoot',
26
31
  'workRepo',
32
+ 'capabilityModels',
27
33
  ];
34
+ /**
35
+ * Keys owenloop still RECOGNIZES but no longer acts on. Each one produces a
36
+ * warning naming what replaced it, and is excluded from `unrecognized` so the
37
+ * same key is not also reported as a likely typo.
38
+ *
39
+ * Distinct from `tierMap`/`tierProfiles`, which are a hard error: ignoring
40
+ * those would leave the shift with no capability map and refuse every order,
41
+ * whereas ignoring these changes nothing about how a shift runs.
42
+ */
43
+ export const RETIRED_IGNORED_KEYS = ['escalateAt', 'escalationExtensionKey'];
28
44
  /**
29
45
  * Resolve the settings file path from the caller's env:
30
46
  * `$XDG_CONFIG_HOME/owenloop/settings.json` when `XDG_CONFIG_HOME` is set and
@@ -56,11 +72,20 @@ export function validateSettings(raw, path) {
56
72
  throw new Error(`invalid settings file at ${path}: expected a JSON object, got ${got}`);
57
73
  }
58
74
  const obj = raw;
75
+ const warnings = [];
59
76
  const bad = (key, expected, value) => new Error(`invalid settings file at ${path}: '${key}' must be ${expected}, got ${JSON.stringify(value)}`);
60
- for (const key of ['hubOrigin', 'cacheDir', 'stateDir', 'workRoot', 'workRepo']) {
77
+ for (const key of ['hubOrigin', 'cacheDir', 'stateDir', 'shiftLogDir', 'workRoot', 'workRepo']) {
61
78
  if (key in obj && typeof obj[key] !== 'string')
62
79
  throw bad(key, 'a string', obj[key]);
63
80
  }
81
+ if ('shiftLogMaxAgeMs' in obj) {
82
+ // NON-NEGATIVE, not positive: 0 means "reap every completed run's log at the
83
+ // next startup", which is a legitimate setting on a disk-constrained host.
84
+ const v = obj['shiftLogMaxAgeMs'];
85
+ if (typeof v !== 'number' || !Number.isInteger(v) || v < 0) {
86
+ throw bad('shiftLogMaxAgeMs', 'a non-negative integer', v);
87
+ }
88
+ }
64
89
  if ('dispatchCap' in obj) {
65
90
  const v = obj['dispatchCap'];
66
91
  if (typeof v !== 'number' || !Number.isInteger(v) || v <= 0) {
@@ -73,14 +98,75 @@ export function validateSettings(raw, path) {
73
98
  throw bad('maxConcurrentAgents', 'a positive integer', v);
74
99
  }
75
100
  }
101
+ // RETIRED KEYS ARE A HARD ERROR, NOT AN IGNORED ONE. A file still naming
102
+ // `tierMap` or `tierProfiles` describes a routing scheme that no longer
103
+ // exists; passing it over as an unrecognized key would start the shift with
104
+ // NO capability map at all, and every agent order would then be refused at
105
+ // dispatch with a message about capabilities the operator never wrote.
106
+ for (const retired of ['tierMap', 'tierProfiles']) {
107
+ if (retired in obj) {
108
+ throw new Error(`invalid settings file at ${path}: '${retired}' was removed — tiers are replaced by ` +
109
+ `'capabilityModels', a flat map from capability to { model, effort } ` +
110
+ `(e.g. {"capabilityModels": {"wise:deep": {"model": "<model-id>", "effort": "xhigh"}}}). ` +
111
+ `Depth now rides on the capability's modifier suffix, not on a tier rung.`);
112
+ }
113
+ }
114
+ if ('capabilityModels' in obj) {
115
+ const v = obj['capabilityModels'];
116
+ if (typeof v !== 'object' || v === null || Array.isArray(v)) {
117
+ throw bad('capabilityModels', 'an object of { model, effort } per capability', v);
118
+ }
119
+ // Row shape and effort validity are checked at LOAD, not at resolution: a
120
+ // shift whose map is wrong should fail when it starts, not on the first
121
+ // order that happens to land on the broken row, hours later.
122
+ try {
123
+ validateCapabilityModels(v);
124
+ }
125
+ catch (e) {
126
+ throw new Error(`invalid settings file at ${path}: ${e instanceof Error ? e.message : String(e)}`);
127
+ }
128
+ }
129
+ // RETIRED, BUT ONLY A WARNING — a different case from `tierMap` above, and the
130
+ // difference is what happens if the key is silently ignored.
131
+ //
132
+ // These two configured the WORKER-LOCAL escalation that bumped an order's
133
+ // model after N judgment rejections. Escalation is now entirely the engine's:
134
+ // it re-offers the step composed with the def's `escalation.modifier`, and the
135
+ // shift resolves that new compound like any other. So a file still carrying
136
+ // these describes a mechanism that no longer runs — but escalation itself
137
+ // still happens, correctly, without them. Ignoring them changes no behavior;
138
+ // it only leaves the operator believing a knob does something. A warning says
139
+ // exactly that, and does not stop a shift from starting.
140
+ for (const retired of RETIRED_IGNORED_KEYS) {
141
+ if (retired in obj) {
142
+ warnings.push(`'${retired}' no longer does anything and is ignored — retry escalation moved into the engine, ` +
143
+ `which re-offers a rejected step at the def's 'escalation.modifier'. Remove the key.`);
144
+ }
145
+ }
76
146
  if ('commandRouting' in obj) {
77
147
  const v = obj['commandRouting'];
78
148
  if (v !== 'shift' && v !== 'manual')
79
149
  throw bad('commandRouting', "'shift' or 'manual'", v);
80
150
  }
81
- const known = new Set(KNOWN_SETTINGS_KEYS);
151
+ if ('defPolicy' in obj) {
152
+ const v = obj['defPolicy'];
153
+ if (v !== 'enforce' && v !== 'warn' && v !== 'off') {
154
+ throw bad('defPolicy', "'enforce', 'warn', or 'off'", v);
155
+ }
156
+ }
157
+ if ('artifactPolicy' in obj) {
158
+ const v = obj['artifactPolicy'];
159
+ if (v !== 'enforce' && v !== 'warn' && v !== 'off') {
160
+ throw bad('artifactPolicy', "'enforce', 'warn', or 'off'", v);
161
+ }
162
+ }
163
+ // The retired-but-warned keys count as KNOWN for this purpose. They are not
164
+ // typos — owenloop recognizes them perfectly well and has already said, in a
165
+ // warning, that they no longer take effect. Listing them again under
166
+ // "unrecognized keys (ignored — likely typos)" would contradict that.
167
+ const known = new Set([...KNOWN_SETTINGS_KEYS, ...RETIRED_IGNORED_KEYS]);
82
168
  const unrecognized = Object.keys(obj).filter((k) => !known.has(k));
83
- return { settings: obj, unrecognized };
169
+ return { settings: obj, unrecognized, warnings };
84
170
  }
85
171
  /**
86
172
  * Inspect the settings file: resolve its path, whether it exists, and its
@@ -92,7 +178,7 @@ export function validateSettings(raw, path) {
92
178
  export function inspectSettings(env) {
93
179
  const path = settingsPath(env);
94
180
  if (!existsSync(path))
95
- return { path, exists: false, settings: {}, unrecognized: [] };
181
+ return { path, exists: false, settings: {}, unrecognized: [], warnings: [] };
96
182
  const raw = readFileSync(path, 'utf8');
97
183
  let parsed;
98
184
  try {