@cleocode/contracts 2026.10.27 → 2026.11.1-canary.10

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 (289) hide show
  1. package/README.md +2 -1
  2. package/dist/.source-stamp.json +4 -0
  3. package/dist/__tests__/acceptance-gate.test.js +15 -3
  4. package/dist/__tests__/acceptance-gate.test.js.map +1 -1
  5. package/dist/__tests__/completion-operation-contracts.test.js +1 -1
  6. package/dist/__tests__/completion-operation-contracts.test.js.map +1 -1
  7. package/dist/__tests__/evidence-atom-schema.test.js +3 -1
  8. package/dist/__tests__/evidence-atom-schema.test.js.map +1 -1
  9. package/dist/__tests__/gateway-contract.test.js +1 -1
  10. package/dist/__tests__/gateway-contract.test.js.map +1 -1
  11. package/dist/__tests__/memory-wire-shapes.test.js.map +1 -1
  12. package/dist/__tests__/operation-def.test.js +4 -3
  13. package/dist/__tests__/operation-def.test.js.map +1 -1
  14. package/dist/acceptance-gate-schema.d.ts +25 -0
  15. package/dist/acceptance-gate-schema.d.ts.map +1 -1
  16. package/dist/acceptance-gate-schema.js +5 -0
  17. package/dist/acceptance-gate-schema.js.map +1 -1
  18. package/dist/acceptance-gate.d.ts +8 -0
  19. package/dist/acceptance-gate.d.ts.map +1 -1
  20. package/dist/brain-graph.d.ts +1 -1
  21. package/dist/brain-graph.js +1 -1
  22. package/dist/caamp-markers.d.ts +11 -0
  23. package/dist/caamp-markers.d.ts.map +1 -1
  24. package/dist/config/manifest.d.ts.map +1 -1
  25. package/dist/config/manifest.js +13 -0
  26. package/dist/config/manifest.js.map +1 -1
  27. package/dist/{config.d.ts → config/types.d.ts} +130 -6
  28. package/dist/config/types.d.ts.map +1 -0
  29. package/dist/{config.js → config/types.js} +1 -1
  30. package/dist/config/types.js.map +1 -0
  31. package/dist/config/worker-policy.d.ts +42 -0
  32. package/dist/config/worker-policy.d.ts.map +1 -0
  33. package/dist/config/worker-policy.js +35 -0
  34. package/dist/config/worker-policy.js.map +1 -0
  35. package/dist/data-accessor.d.ts +15 -0
  36. package/dist/data-accessor.d.ts.map +1 -1
  37. package/dist/data-accessor.js.map +1 -1
  38. package/dist/dependency.d.ts +2 -0
  39. package/dist/dependency.d.ts.map +1 -1
  40. package/dist/dispatch/__tests__/operation-envelope-snapshots.test.js +0 -6
  41. package/dist/dispatch/__tests__/operation-envelope-snapshots.test.js.map +1 -1
  42. package/dist/dispatch/identity.d.ts +3 -8
  43. package/dist/dispatch/identity.d.ts.map +1 -1
  44. package/dist/dispatch/identity.js +2 -8
  45. package/dist/dispatch/identity.js.map +1 -1
  46. package/dist/dispatch/operations-registry.d.ts.map +1 -1
  47. package/dist/dispatch/operations-registry.js +360 -513
  48. package/dist/dispatch/operations-registry.js.map +1 -1
  49. package/dist/docs/modernize.d.ts +468 -0
  50. package/dist/docs/modernize.d.ts.map +1 -0
  51. package/dist/docs/modernize.js +145 -0
  52. package/dist/docs/modernize.js.map +1 -0
  53. package/dist/docs/provenance.d.ts +6 -6
  54. package/dist/docs-taxonomy.d.ts +6 -0
  55. package/dist/docs-taxonomy.d.ts.map +1 -1
  56. package/dist/docs-taxonomy.js +38 -1
  57. package/dist/docs-taxonomy.js.map +1 -1
  58. package/dist/done-plan.d.ts +34 -3
  59. package/dist/done-plan.d.ts.map +1 -1
  60. package/dist/evidence-atom-schema.d.ts +78 -4
  61. package/dist/evidence-atom-schema.d.ts.map +1 -1
  62. package/dist/evidence-atom-schema.js +136 -11
  63. package/dist/evidence-atom-schema.js.map +1 -1
  64. package/dist/evidence-record-schema.d.ts +2 -2
  65. package/dist/exit-codes.d.ts +93 -0
  66. package/dist/exit-codes.d.ts.map +1 -1
  67. package/dist/exit-codes.js +93 -0
  68. package/dist/exit-codes.js.map +1 -1
  69. package/dist/{gateway.d.ts → gateway/index.d.ts} +4 -4
  70. package/dist/gateway/index.d.ts.map +1 -0
  71. package/dist/{gateway.js → gateway/index.js} +2 -2
  72. package/dist/gateway/index.js.map +1 -0
  73. package/dist/gateway/rpc/messages.d.ts +4 -4
  74. package/dist/gateway/rpc/messages.js +1 -1
  75. package/dist/gateway/rpc/messages.js.map +1 -1
  76. package/dist/git-hooks.d.ts +29 -3
  77. package/dist/git-hooks.d.ts.map +1 -1
  78. package/dist/git-hooks.js +34 -3
  79. package/dist/git-hooks.js.map +1 -1
  80. package/dist/heavy-command-hook.d.ts +5 -0
  81. package/dist/heavy-command-hook.d.ts.map +1 -1
  82. package/dist/index.d.ts +23 -19
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +10 -6
  85. package/dist/index.js.map +1 -1
  86. package/dist/invariants/sync-write-invariants.d.ts.map +1 -1
  87. package/dist/invariants/sync-write-invariants.js +29 -1
  88. package/dist/invariants/sync-write-invariants.js.map +1 -1
  89. package/dist/jobs.d.ts +5 -0
  90. package/dist/jobs.d.ts.map +1 -1
  91. package/dist/lease-ipc/messages.d.ts +5 -5
  92. package/dist/llm/onboarding.d.ts +1 -1
  93. package/dist/llm/system-of-use.d.ts +1 -1
  94. package/dist/llm/system-of-use.d.ts.map +1 -1
  95. package/dist/llm/system-resolver.d.ts +1 -1
  96. package/dist/llm/system-resolver.d.ts.map +1 -1
  97. package/dist/{memory.d.ts → memory/index.d.ts} +1 -1
  98. package/dist/memory/index.d.ts.map +1 -0
  99. package/dist/{memory.js → memory/index.js} +1 -1
  100. package/dist/memory/index.js.map +1 -0
  101. package/dist/memory/search.d.ts +20 -2
  102. package/dist/memory/search.d.ts.map +1 -1
  103. package/dist/merge-close.d.ts +277 -0
  104. package/dist/merge-close.d.ts.map +1 -0
  105. package/dist/merge-close.js +16 -0
  106. package/dist/merge-close.js.map +1 -0
  107. package/dist/nexus-cloud.d.ts +1 -1
  108. package/dist/operations/admin.d.ts +6 -0
  109. package/dist/operations/admin.d.ts.map +1 -1
  110. package/dist/operations/docs.d.ts +233 -9
  111. package/dist/operations/docs.d.ts.map +1 -1
  112. package/dist/operations/docs.js.map +1 -1
  113. package/dist/operations/index.d.ts +0 -1
  114. package/dist/operations/index.d.ts.map +1 -1
  115. package/dist/operations/index.js +0 -1
  116. package/dist/operations/index.js.map +1 -1
  117. package/dist/operations/memory.d.ts +7 -4
  118. package/dist/operations/memory.d.ts.map +1 -1
  119. package/dist/operations/nexus-scope-map.d.ts +0 -8
  120. package/dist/operations/nexus-scope-map.d.ts.map +1 -1
  121. package/dist/operations/nexus-scope-map.js +0 -8
  122. package/dist/operations/nexus-scope-map.js.map +1 -1
  123. package/dist/operations/nexus.d.ts +2 -10
  124. package/dist/operations/nexus.d.ts.map +1 -1
  125. package/dist/operations/nexus.js.map +1 -1
  126. package/dist/operations/orchestrate.d.ts +219 -6
  127. package/dist/operations/orchestrate.d.ts.map +1 -1
  128. package/dist/operations/orchestrate.js +329 -1
  129. package/dist/operations/orchestrate.js.map +1 -1
  130. package/dist/operations/output-contracts-data.js +1 -1
  131. package/dist/operations/output-contracts-data.js.map +1 -1
  132. package/dist/operations/release.d.ts +0 -79
  133. package/dist/operations/release.d.ts.map +1 -1
  134. package/dist/operations/session.d.ts +1 -1
  135. package/dist/operations/session.d.ts.map +1 -1
  136. package/dist/operations/tasks.d.ts +18 -6
  137. package/dist/operations/tasks.d.ts.map +1 -1
  138. package/dist/operations/tasks.js.map +1 -1
  139. package/dist/operations/validate.d.ts +6 -0
  140. package/dist/operations/validate.d.ts.map +1 -1
  141. package/dist/operations/worktree.d.ts +209 -19
  142. package/dist/operations/worktree.d.ts.map +1 -1
  143. package/dist/orca-execution.d.ts +489 -0
  144. package/dist/orca-execution.d.ts.map +1 -0
  145. package/dist/orca-execution.js +362 -0
  146. package/dist/orca-execution.js.map +1 -0
  147. package/dist/project-context.d.ts +31 -0
  148. package/dist/project-context.d.ts.map +1 -1
  149. package/dist/project-hooks.d.ts +8 -8
  150. package/dist/release/authorization.d.ts +46 -0
  151. package/dist/release/authorization.d.ts.map +1 -0
  152. package/dist/release/authorization.js +10 -0
  153. package/dist/release/authorization.js.map +1 -0
  154. package/dist/release/hook-pilot.d.ts +1 -1
  155. package/dist/resource-governor.d.ts +44 -0
  156. package/dist/resource-governor.d.ts.map +1 -1
  157. package/dist/resource-governor.js +10 -0
  158. package/dist/resource-governor.js.map +1 -1
  159. package/dist/review-verdict.d.ts +253 -0
  160. package/dist/review-verdict.d.ts.map +1 -0
  161. package/dist/review-verdict.js +20 -0
  162. package/dist/review-verdict.js.map +1 -0
  163. package/dist/row-identity.d.ts +11 -0
  164. package/dist/row-identity.d.ts.map +1 -1
  165. package/dist/session-journal.d.ts.map +1 -1
  166. package/dist/session-journal.js +7 -1
  167. package/dist/session-journal.js.map +1 -1
  168. package/dist/session.d.ts +11 -0
  169. package/dist/session.d.ts.map +1 -1
  170. package/dist/session.js.map +1 -1
  171. package/dist/skills/migrate.d.ts +1 -1
  172. package/dist/skills/migrate.js +1 -1
  173. package/dist/skills/stats.d.ts +1 -1
  174. package/dist/skills/stats.js +1 -1
  175. package/dist/spawn-types.d.ts +57 -0
  176. package/dist/spawn-types.d.ts.map +1 -1
  177. package/dist/spawn.d.ts +43 -0
  178. package/dist/spawn.d.ts.map +1 -1
  179. package/dist/spawn.js +1 -0
  180. package/dist/spawn.js.map +1 -1
  181. package/dist/status-registry.d.ts +27 -0
  182. package/dist/status-registry.d.ts.map +1 -1
  183. package/dist/status-registry.js +28 -0
  184. package/dist/status-registry.js.map +1 -1
  185. package/dist/table-classification.d.ts +22 -0
  186. package/dist/table-classification.d.ts.map +1 -1
  187. package/dist/task-id.d.ts +8 -10
  188. package/dist/task-id.d.ts.map +1 -1
  189. package/dist/task-id.js +9 -48
  190. package/dist/task-id.js.map +1 -1
  191. package/dist/task-record.d.ts +10 -1
  192. package/dist/task-record.d.ts.map +1 -1
  193. package/dist/task.d.ts +177 -4
  194. package/dist/task.d.ts.map +1 -1
  195. package/dist/task.js.map +1 -1
  196. package/dist/{tasks.d.ts → tasks/index.d.ts} +3 -3
  197. package/dist/tasks/index.d.ts.map +1 -0
  198. package/dist/{tasks.js → tasks/index.js} +2 -2
  199. package/dist/tasks/index.js.map +1 -0
  200. package/dist/templates/manifest.d.ts +1 -1
  201. package/dist/tools/build-task-tree.d.ts +1 -1
  202. package/dist/tools/build-task-tree.d.ts.map +1 -1
  203. package/dist/workgraph.d.ts +56 -56
  204. package/package.json +22 -6
  205. package/schemas/acceptance-gate.schema.json +24 -0
  206. package/schemas/task.schema.json +24 -0
  207. package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
  208. package/src/__tests__/acceptance-gate.test.ts +16 -3
  209. package/src/__tests__/completion-operation-contracts.test.ts +1 -1
  210. package/src/__tests__/evidence-atom-schema.test.ts +3 -1
  211. package/src/__tests__/gateway-contract.test.ts +1 -1
  212. package/src/__tests__/llm-config-schema.test.ts +1 -1
  213. package/src/__tests__/memory-wire-shapes.test.ts +4 -1
  214. package/src/__tests__/operation-def.test.ts +4 -3
  215. package/src/acceptance-gate-schema.ts +5 -0
  216. package/src/acceptance-gate.ts +9 -0
  217. package/src/brain-graph.ts +1 -1
  218. package/src/caamp-markers.ts +11 -0
  219. package/src/config/manifest.ts +13 -0
  220. package/src/{config.ts → config/types.ts} +134 -5
  221. package/src/config/worker-policy.ts +55 -0
  222. package/src/data-accessor.ts +16 -0
  223. package/src/dependency.ts +2 -0
  224. package/src/dispatch/__tests__/operation-envelope-snapshots.test.ts +0 -6
  225. package/src/dispatch/identity.ts +2 -8
  226. package/src/dispatch/operations-registry.ts +377 -525
  227. package/src/docs/modernize.ts +442 -0
  228. package/src/docs-taxonomy.ts +44 -1
  229. package/src/done-plan.ts +33 -2
  230. package/src/evidence-atom-schema.ts +167 -14
  231. package/src/exit-codes.ts +95 -0
  232. package/src/{gateway.ts → gateway/index.ts} +3 -3
  233. package/src/gateway/rpc/messages.ts +1 -1
  234. package/src/git-hooks.ts +43 -3
  235. package/src/heavy-command-hook.ts +5 -0
  236. package/src/index.ts +132 -48
  237. package/src/invariants/sync-write-invariants.ts +30 -0
  238. package/src/jobs.ts +5 -0
  239. package/src/llm/onboarding.ts +1 -1
  240. package/src/llm/system-of-use.ts +1 -1
  241. package/src/llm/system-resolver.ts +1 -1
  242. package/src/memory/search.ts +17 -2
  243. package/src/merge-close.ts +291 -0
  244. package/src/operations/admin.ts +6 -0
  245. package/src/operations/docs.ts +242 -10
  246. package/src/operations/index.ts +0 -1
  247. package/src/operations/memory.ts +7 -4
  248. package/src/operations/nexus-scope-map.ts +0 -8
  249. package/src/operations/nexus.ts +2 -11
  250. package/src/operations/orchestrate.ts +490 -6
  251. package/src/operations/output-contracts-data.ts +1 -1
  252. package/src/operations/release.ts +0 -87
  253. package/src/operations/session.ts +1 -1
  254. package/src/operations/tasks.ts +20 -7
  255. package/src/operations/validate.ts +6 -0
  256. package/src/operations/worktree.ts +216 -19
  257. package/src/orca-execution.ts +493 -0
  258. package/src/project-context.ts +33 -0
  259. package/src/release/authorization.ts +48 -0
  260. package/src/resource-governor.ts +47 -0
  261. package/src/review-verdict.ts +265 -0
  262. package/src/row-identity.ts +11 -0
  263. package/src/session-journal.ts +7 -1
  264. package/src/session.ts +11 -0
  265. package/src/skills/migrate.ts +1 -1
  266. package/src/skills/stats.ts +1 -1
  267. package/src/spawn-types.ts +75 -0
  268. package/src/spawn.ts +48 -0
  269. package/src/status-registry.ts +37 -0
  270. package/src/table-classification.ts +23 -0
  271. package/src/task-id.ts +9 -47
  272. package/src/task-record.ts +10 -1
  273. package/src/task.ts +171 -4
  274. package/src/{tasks.ts → tasks/index.ts} +3 -3
  275. package/src/tools/build-task-tree.ts +1 -1
  276. package/dist/config.d.ts.map +0 -1
  277. package/dist/config.js.map +0 -1
  278. package/dist/gateway.d.ts.map +0 -1
  279. package/dist/gateway.js.map +0 -1
  280. package/dist/memory.d.ts.map +0 -1
  281. package/dist/memory.js.map +0 -1
  282. package/dist/operations/conduit.d.ts +0 -285
  283. package/dist/operations/conduit.d.ts.map +0 -1
  284. package/dist/operations/conduit.js +0 -39
  285. package/dist/operations/conduit.js.map +0 -1
  286. package/dist/tasks.d.ts.map +0 -1
  287. package/dist/tasks.js.map +0 -1
  288. package/src/operations/conduit.ts +0 -348
  289. /package/src/{memory.ts → memory/index.ts} +0 -0
@@ -64,6 +64,8 @@ export const EVIDENCE_ATOM_KINDS = [
64
64
  'decision',
65
65
  'pr',
66
66
  'ci',
67
+ 'ci-run',
68
+ 'deploy',
67
69
  'loc-drop',
68
70
  'callsite-coverage',
69
71
  'satisfies',
@@ -81,6 +83,12 @@ const PARSER_PREFIXES = [...EVIDENCE_ATOM_KINDS, 'state'] as const;
81
83
  */
82
84
  const KIND_BOUNDARY_REGEX = new RegExp(`;(?=\\s*(?:${PARSER_PREFIXES.join('|')})\\s*:)`, 'g');
83
85
 
86
+ /** A `deploy:` provider name (T14083): lowercase, e.g. `railway`, `fly`, `cloudflare-pages`. */
87
+ const DEPLOY_PROVIDER_REGEX = /^[a-z0-9][a-z0-9._-]*$/;
88
+
89
+ /** A `deploy:` deployment id (T14083): no whitespace, `@` or `|`. */
90
+ const DEPLOY_ID_REGEX = /^[^\s@|]+$/;
91
+
84
92
  // ---------------------------------------------------------------------------
85
93
  // Per-atom Zod schemas
86
94
  // ---------------------------------------------------------------------------
@@ -262,6 +270,47 @@ export const ciAtomSchema = z.object({
262
270
  .optional(),
263
271
  });
264
272
 
273
+ /**
274
+ * `ci-run:<runId>` atom (T14149): a run of the `repeat-run.yml` workflow
275
+ * (dispatched on the default branch) that ran one test file N times, all green.
276
+ * Validated from GitHub's record of the run and its uploaded report, never from
277
+ * a file the agent supplies. It links an acceptance criterion that needs a heavy
278
+ * or repeated run; it does not satisfy `testsPassed` on its own.
279
+ *
280
+ * Format: `ci-run:<positive integer run id>` (e.g. `ci-run:40812345678`).
281
+ *
282
+ * @task T14149
283
+ */
284
+ export const ciRunAtomSchema = z.object({
285
+ kind: z.literal('ci-run'),
286
+ runId: z.number().int().positive('ci-run atom requires a positive integer run id'),
287
+ });
288
+
289
+ /**
290
+ * `deploy:<provider>/<deploymentId>@<sha>|<probe-url>` atom (T14083): a
291
+ * deployment of commit `<sha>`, proven at verify time by a bounded GET of
292
+ * `<probe-url>` that returns 2xx and names `<sha>` in its body or in an
293
+ * `X-Commit` / `X-Version` header. Satisfies only the gates the project lists
294
+ * in `evidence.deploySatisfies` (no default).
295
+ *
296
+ * Format: `deploy:railway/9f3c2a@1a2b3c4d|https://api.example.com/health`.
297
+ * The provider and deployment id are recorded as given; the probe, not the
298
+ * provider, is the proof.
299
+ *
300
+ * @task T14083
301
+ */
302
+ export const deployAtomSchema = z.object({
303
+ kind: z.literal('deploy'),
304
+ provider: z
305
+ .string()
306
+ .regex(DEPLOY_PROVIDER_REGEX, 'deploy atom provider must be a lowercase name'),
307
+ deploymentId: z.string().regex(DEPLOY_ID_REGEX, 'deploy atom requires a deployment id'),
308
+ sha: z.string().regex(/^[0-9a-f]{7,40}$/, 'deploy atom sha must be 7-40 lowercase hex chars'),
309
+ probeUrl: z
310
+ .string()
311
+ .regex(/^https?:\/\/\S+$/, 'deploy atom probe url must start with http:// or https://'),
312
+ });
313
+
265
314
  /**
266
315
  * `loc-drop:<fromLines>:<toLines>` atom — proves that a migrated engine shed
267
316
  * lines. Required for the `implemented` gate when the task carries the
@@ -428,6 +477,8 @@ export const satisfiesAtomSchema = z.object({
428
477
  * - `note` — free-form note (T832)
429
478
  * - `decision` — brain_decisions row reference (T1875)
430
479
  * - `pr` — merged-PR retroactive proof (T9764 / T9838)
480
+ * - `ci-run` — a green repeat-run.yml run of one test file (T14149)
481
+ * - `deploy` — probed deployment of a commit (T14083)
431
482
  * - `loc-drop` — engine-migration LOC reduction (T1604)
432
483
  * - `callsite-coverage` — exported-symbol production callsite (T1605)
433
484
  * - `satisfies` — cross-task AC binding (T10506 / ADR-079-r2;
@@ -447,6 +498,8 @@ export const EvidenceAtomSchema = z.discriminatedUnion('kind', [
447
498
  decisionAtomSchema,
448
499
  prAtomSchema,
449
500
  ciAtomSchema,
501
+ ciRunAtomSchema,
502
+ deployAtomSchema,
450
503
  locDropAtomSchema,
451
504
  callsiteCoverageAtomSchema,
452
505
  satisfiesAtomSchema,
@@ -546,10 +599,59 @@ export const GATE_EVIDENCE_REQUIREMENTS: Readonly<
546
599
  nexusImpact: { oneOf: [['tool'], ['note']] },
547
600
  });
548
601
 
602
+ /**
603
+ * The gate profiles a task with no code change may declare as a
604
+ * `profile:<name>` label (T13474): operations work, a decision, a census or
605
+ * an audit. The closed set lives here so the gate requirements below and the
606
+ * label rules in core read one list.
607
+ *
608
+ * @task T13474
609
+ * @task T14187
610
+ */
611
+ export const GATE_PROFILE_NAMES = ['ops', 'decision', 'census', 'audit'] as const;
612
+
613
+ /** One of {@link GATE_PROFILE_NAMES}. */
614
+ export type GateProfileName = (typeof GATE_PROFILE_NAMES)[number];
615
+
616
+ /**
617
+ * Atom combinations a gate accepts IN ADDITION to
618
+ * {@link GATE_EVIDENCE_REQUIREMENTS} for a task that declares a gate profile
619
+ * and whose change touches no code (T14187). An operations, census or audit
620
+ * task (a live-data repair, a measurement) has no commit, PR or decision to
621
+ * cite: its proof is the stored document recording what was done or found,
622
+ * so `implemented` also accepts `files` (that document) with a `note`. A
623
+ * decision task still proves itself with its decision. Core applies this
624
+ * only when every `files:` path is a document, so a code change still owes a
625
+ * commit or PR. `cleo done --plan` and the gates read this one table.
626
+ *
627
+ * @task T14187
628
+ */
629
+ export const PROFILE_GATE_EVIDENCE: Readonly<
630
+ Record<
631
+ GateProfileName,
632
+ Partial<Record<VerificationGate, ReadonlyArray<ReadonlyArray<EvidenceAtomKind>>>>
633
+ >
634
+ > = Object.freeze({
635
+ ops: { implemented: [['files', 'note']] },
636
+ decision: {},
637
+ census: { implemented: [['files', 'note']] },
638
+ audit: { implemented: [['files', 'note']] },
639
+ });
640
+
549
641
  // ---------------------------------------------------------------------------
550
642
  // Helpers
551
643
  // ---------------------------------------------------------------------------
552
644
 
645
+ /** The combinations `gate` accepts, with a gate profile's additions. */
646
+ function gateCombinations(
647
+ gate: VerificationGate,
648
+ profile?: GateProfileName | null,
649
+ ): ReadonlyArray<ReadonlyArray<EvidenceAtomKind>> {
650
+ const base = GATE_EVIDENCE_REQUIREMENTS[gate]?.oneOf ?? [];
651
+ const extra = profile ? (PROFILE_GATE_EVIDENCE[profile][gate] ?? []) : [];
652
+ return [...base, ...extra];
653
+ }
654
+
553
655
  /**
554
656
  * Result of {@link validateEvidenceForGate}.
555
657
  *
@@ -582,9 +684,13 @@ export type EvidenceValidationResult = { readonly ok: true } | EvidenceValidatio
582
684
  *
583
685
  * @task T10337
584
686
  */
585
- export function formatGateRequirement(gate: VerificationGate): string {
586
- const requirement = GATE_EVIDENCE_REQUIREMENTS[gate];
587
- return requirement.oneOf.map((set) => `[${set.join(' AND ')}]`).join(' OR ');
687
+ export function formatGateRequirement(
688
+ gate: VerificationGate,
689
+ profile?: GateProfileName | null,
690
+ ): string {
691
+ return gateCombinations(gate, profile)
692
+ .map((set) => `[${set.join(' AND ')}]`)
693
+ .join(' OR ');
588
694
  }
589
695
 
590
696
  /**
@@ -605,6 +711,8 @@ const ATOM_EXAMPLES: Readonly<Record<EvidenceAtomKind, string>> = Object.freeze(
605
711
  decision: 'decision:D-arch-001',
606
712
  pr: 'pr:357',
607
713
  ci: 'ci:357',
714
+ 'ci-run': 'ci-run:<runId>',
715
+ deploy: 'deploy:<provider>/<deploymentId>@<sha>|https://<host>/health',
608
716
  'loc-drop': 'loc-drop:<fromLines>:<toLines>',
609
717
  'callsite-coverage': 'callsite-coverage:<symbolName>:<relativeSourcePath>',
610
718
  satisfies: 'satisfies:T1234#AC2',
@@ -654,16 +762,20 @@ function renderCombinationAsEvidence(combination: ReadonlyArray<EvidenceAtomKind
654
762
  * @task T9949
655
763
  * @adr ADR-051 §2.3
656
764
  */
657
- export function formatGateRequirementHint(gate: VerificationGate): string {
765
+ export function formatGateRequirementHint(
766
+ gate: VerificationGate,
767
+ profile?: GateProfileName | null,
768
+ ): string {
658
769
  const requirement = GATE_EVIDENCE_REQUIREMENTS[gate];
659
770
  if (!requirement) {
660
771
  // Unknown gate — match validateEvidenceForGate's defensive default.
661
772
  return `Gate '${gate}' has no documented evidence requirements.`;
662
773
  }
774
+ const oneOf = gateCombinations(gate, profile);
663
775
 
664
776
  const lines: string[] = [
665
777
  `Gate '${gate}' requires programmatic evidence. Use ONE of:`,
666
- ...requirement.oneOf.map(
778
+ ...oneOf.map(
667
779
  (combo) =>
668
780
  ` - cleo verify T#### --gate ${gate} --evidence '${renderCombinationAsEvidence(combo)}'`,
669
781
  ),
@@ -671,16 +783,12 @@ export function formatGateRequirementHint(gate: VerificationGate): string {
671
783
 
672
784
  // Note-specific clarification — T9949's headline pain point.
673
785
  // The gate accepts note: alone IFF some single-element combination is ['note'].
674
- const noteAloneAccepted = requirement.oneOf.some(
675
- (combo) => combo.length === 1 && combo[0] === 'note',
676
- );
786
+ const noteAloneAccepted = oneOf.some((combo) => combo.length === 1 && combo[0] === 'note');
677
787
  if (noteAloneAccepted) {
678
788
  lines.push(`Note: 'note:' alone IS accepted for this gate (waiver-style evidence).`);
679
789
  } else {
680
790
  // Surface every alternative pairing involving note for at-a-glance routing.
681
- const notePairings = requirement.oneOf.filter(
682
- (combo) => combo.length > 1 && combo.includes('note'),
683
- );
791
+ const notePairings = oneOf.filter((combo) => combo.length > 1 && combo.includes('note'));
684
792
  if (notePairings.length > 0) {
685
793
  const partners = Array.from(
686
794
  new Set(notePairings.flatMap((combo) => combo.filter((k) => k !== 'note'))),
@@ -715,6 +823,8 @@ export function formatGateRequirementHint(gate: VerificationGate): string {
715
823
  *
716
824
  * @param gate - Verification gate being checked.
717
825
  * @param atoms - Already-parsed evidence atoms.
826
+ * @param profile - The task's gate profile when its change touches no code
827
+ * ({@link PROFILE_GATE_EVIDENCE}, T14187); omit otherwise.
718
828
  * @returns Pass / fail with a human-readable failure message.
719
829
  *
720
830
  * @example
@@ -731,6 +841,7 @@ export function formatGateRequirementHint(gate: VerificationGate): string {
731
841
  export function validateEvidenceForGate(
732
842
  gate: VerificationGate,
733
843
  atoms: ReadonlyArray<{ kind: EvidenceAtomKind }>,
844
+ profile?: GateProfileName | null,
734
845
  ): EvidenceValidationResult {
735
846
  const requirement = GATE_EVIDENCE_REQUIREMENTS[gate];
736
847
  if (!requirement) {
@@ -738,18 +849,18 @@ export function validateEvidenceForGate(
738
849
  // behavior from checkGateEvidenceMinimum when the gate had no entry).
739
850
  return { ok: true };
740
851
  }
741
- for (const combination of requirement.oneOf) {
852
+ for (const combination of gateCombinations(gate, profile)) {
742
853
  const satisfied = combination.every((kind) => atoms.some((a) => a.kind === kind));
743
854
  if (satisfied) return { ok: true };
744
855
  }
745
856
  return {
746
857
  ok: false,
747
- message: `Gate '${gate}' requires evidence: ${formatGateRequirement(gate)}`,
858
+ message: `Gate '${gate}' requires evidence: ${formatGateRequirement(gate, profile)}`,
748
859
  // T9949: rich, example-bearing remediation hint suitable for CLI `fix:`.
749
860
  // Always populated alongside `message` so consumers can choose between
750
861
  // the legacy single-line surface and the multi-line hint without re-
751
862
  // computing the spec.
752
- hint: formatGateRequirementHint(gate),
863
+ hint: formatGateRequirementHint(gate, profile),
753
864
  };
754
865
  }
755
866
 
@@ -835,6 +946,35 @@ function parsePrReference(
835
946
  : { prNumber: second, componentPrNumber: first, ...repo };
836
947
  }
837
948
 
949
+ /**
950
+ * Parse a `deploy:` payload, `<provider>/<deploymentId>@<sha>|<probe-url>`
951
+ * (T14083). The provider is lowercased, the SHA lowercased hex.
952
+ */
953
+ function parseDeployPayload(payload: string, chunk: string): z.infer<typeof deployAtomSchema> {
954
+ const fix =
955
+ 'Use format: deploy:<provider>/<deploymentId>@<sha>|<probe-url> e.g. ' +
956
+ 'deploy:railway/9f3c2a@1a2b3c4d|https://api.example.com/health';
957
+ const bar = payload.indexOf('|');
958
+ const match = /^([^/]+)\/(.+)@([0-9A-Fa-f]{7,40})$/.exec(
959
+ bar < 0 ? '' : payload.slice(0, bar).trim(),
960
+ );
961
+ const probeUrl = bar < 0 ? '' : payload.slice(bar + 1).trim();
962
+ const parsed = deployAtomSchema.safeParse({
963
+ kind: 'deploy',
964
+ provider: match?.[1]?.toLowerCase() ?? '',
965
+ deploymentId: match?.[2] ?? '',
966
+ sha: match?.[3]?.toLowerCase() ?? '',
967
+ probeUrl,
968
+ });
969
+ if (!match || !parsed.success) {
970
+ throw new EvidenceParseError(
971
+ `Malformed deploy atom: "${chunk}" (${!match || parsed.success ? 'expected <provider>/<deploymentId>@<sha>|<probe-url>' : parsed.error.issues[0]?.message})`,
972
+ fix,
973
+ );
974
+ }
975
+ return parsed.data;
976
+ }
977
+
838
978
  export function parseEvidenceString(raw: string): EvidenceAtom[] {
839
979
  if (!raw || typeof raw !== 'string') {
840
980
  throw new EvidenceParseError(
@@ -919,6 +1059,19 @@ export function parseEvidenceString(raw: string): EvidenceAtom[] {
919
1059
  atoms.push(kind === 'pr' ? { kind: 'pr', ...ref } : { kind: 'ci', ...ref });
920
1060
  break;
921
1061
  }
1062
+ case 'ci-run': {
1063
+ if (!/^[1-9][0-9]*$/.test(payload)) {
1064
+ throw new EvidenceParseError(
1065
+ `ci-run atom requires a positive integer run id, got "${payload}" in "${chunk}"`,
1066
+ 'Use format: ci-run:<runId> e.g. ci-run:40812345678 (a repeat-run.yml run on main)',
1067
+ );
1068
+ }
1069
+ atoms.push({ kind: 'ci-run', runId: Number(payload) });
1070
+ break;
1071
+ }
1072
+ case 'deploy':
1073
+ atoms.push(parseDeployPayload(payload, chunk));
1074
+ break;
922
1075
  case 'loc-drop': {
923
1076
  const firstColon = payload.indexOf(':');
924
1077
  if (firstColon < 1 || firstColon === payload.length - 1) {
package/src/exit-codes.ts CHANGED
@@ -77,6 +77,15 @@ export enum ExitCode {
77
77
  * (`details.expected`). @task T12800
78
78
  */
79
79
  TASK_RENAMED = 26,
80
+ /**
81
+ * A MUTATION came from an unqualified caller (no `CLEO_AGENT_ID`, no
82
+ * `CLEO_SESSION_ID`) inside a harness session whose provider key has no
83
+ * binding of its own while two or more agents of that harness hold live
84
+ * sessions: which agent is calling cannot be told, so the operation refuses
85
+ * rather than act as one of them. LAFS code `E_SESSION_AMBIGUOUS`; the
86
+ * details name the live agents. @task T14269
87
+ */
88
+ SESSION_AMBIGUOUS = 27,
80
89
 
81
90
  // === SESSION ERRORS (30-39) ===
82
91
  SESSION_EXISTS = 30,
@@ -392,6 +401,66 @@ export const E_EVIDENCE_INSUFFICIENT = 'E_EVIDENCE_INSUFFICIENT' as const;
392
401
  export const E_PLAN_NOT_FOUND = 'E_PLAN_NOT_FOUND' as const;
393
402
  /** Generic release-plan validation failure (e.g. schema). Exit code 6. */
394
403
  export const E_RELEASE_PLAN_INVALID = 'E_RELEASE_PLAN_INVALID' as const;
404
+ /**
405
+ * `cleo release cut` found no recent default-branch commit whose required `CI`
406
+ * check run concluded `success` (or the pinned `--sha` is not green). Exit code 6.
407
+ * `error.details.candidates[]` lists each commit checked and its CI state.
408
+ *
409
+ * @task T14102
410
+ */
411
+ export const E_RELEASE_NO_GREEN_COMMIT = 'E_RELEASE_NO_GREEN_COMMIT' as const;
412
+ /**
413
+ * `cleo release cut` found a changeset in range that no merged pull request
414
+ * brought in (pushed straight to the default branch). Exit code 6.
415
+ * `error.details.changesets[]` lists each file and the commit that added it.
416
+ *
417
+ * @task T14102
418
+ */
419
+ export const E_RELEASE_UNMERGED_CHANGESET = 'E_RELEASE_UNMERGED_CHANGESET' as const;
420
+ /**
421
+ * `cleo release cut` could not create the tag (the tag object or its ref POST
422
+ * failed). Exit code 1. `error.details.tagObject` names a created but
423
+ * unreferenced tag object, which is harmless. The attempt is audited.
424
+ *
425
+ * @task T14102
426
+ */
427
+ export const E_RELEASE_TAG_FAILED = 'E_RELEASE_TAG_FAILED' as const;
428
+ /**
429
+ * `cleo release cut --yes` from a non-interactive caller (an agent) without a
430
+ * standing release authorization (owner decision D11212; T14141 stores it).
431
+ * Exit code 6. A human at a terminal confirms with `--yes` directly.
432
+ *
433
+ * @task T14102
434
+ */
435
+ export const E_RELEASE_NOT_AUTHORIZED = 'E_RELEASE_NOT_AUTHORIZED' as const;
436
+ /**
437
+ * `cleo release cut --yes` found a `release.yml` run still in progress for a
438
+ * lower release tag: its GitHub Release may not exist yet, so the new release
439
+ * would base its notes on an older tag and repeat that release's entries.
440
+ * Exit code 6. `--allow-in-flight` cuts anyway; `error.details.inFlight`
441
+ * names the runs.
442
+ *
443
+ * @task T14184
444
+ */
445
+ export const E_RELEASE_IN_FLIGHT = 'E_RELEASE_IN_FLIGHT' as const;
446
+ /**
447
+ * `cleo release cut` found docs rot (stale, duplicate or orphaned docs, per
448
+ * `cleo docs rot`) and refused to tag. Exit code 6. `error.details.docsRot`
449
+ * carries the scan.
450
+ *
451
+ * @task T14102
452
+ * @task T14111
453
+ */
454
+ export const E_DOCS_ROT = 'E_DOCS_ROT' as const;
455
+ /**
456
+ * A stable `cleo release cut` found no passing release smoke for the commit it
457
+ * would tag: `scripts/release-mac-smoke.mjs` writes
458
+ * `.cleo/release-smoke/<sha12>/results.json`, and a missing, failing or
459
+ * other-commit receipt refuses the cut (prereleases are not gated).
460
+ *
461
+ * @task T14250
462
+ */
463
+ export const E_RELEASE_SMOKE_MISSING = 'E_RELEASE_SMOKE_MISSING' as const;
395
464
  /**
396
465
  * `cleo release plan` (or the lint script) encountered a `.changeset/*.md`
397
466
  * file whose YAML frontmatter cannot be parsed. Exit code 6 (VALIDATION_ERROR).
@@ -527,6 +596,32 @@ export const E_AC_COVERAGE_INCOMPLETE = 'E_AC_COVERAGE_INCOMPLETE' as const;
527
596
  */
528
597
  export const E_CWD_WALKUP_FORBIDDEN = 'E_CWD_WALKUP_FORBIDDEN' as const;
529
598
 
599
+ /**
600
+ * E_LEAD_TOOLS_UNSTRIPPED — a lead spawn under the lead/worker split
601
+ * (`orchestrate.leadWorker.v1`) was refused because the provider cannot strip
602
+ * the lead's denied tools (`LeadToolPolicy.stripSupport` is `'unsupported'`).
603
+ * A lead that keeps `Bash`, `Edit` or `Write` could do the work itself.
604
+ *
605
+ * Maps to {@link ExitCode.SPAWN_VALIDATION_FAILED} (63) at the CLI boundary.
606
+ *
607
+ * @task T14356
608
+ * @epic T14351
609
+ */
610
+ export const E_LEAD_TOOLS_UNSTRIPPED = 'E_LEAD_TOOLS_UNSTRIPPED' as const;
611
+
612
+ /**
613
+ * E_WORKER_REPORT_PROOF — a worker's `WorkerReport` was rejected because its
614
+ * proof does not back its conclusion (no proof entry, or an entry with no
615
+ * command, exit code or artifact).
616
+ *
617
+ * Maps to {@link ExitCode.INVALID_RETURN_MESSAGE} (61) at the CLI boundary.
618
+ *
619
+ * @task T14356
620
+ * @task T14361
621
+ * @epic T14351
622
+ */
623
+ export const E_WORKER_REPORT_PROOF = 'E_WORKER_REPORT_PROOF' as const;
624
+
530
625
  /** Check if an exit code represents an error (1-99). */
531
626
  export function isErrorCode(code: ExitCode): boolean {
532
627
  return code >= 1 && code < 100;
@@ -26,10 +26,10 @@
26
26
  import type { LAFSPage, MVILevel } from '@cleocode/lafs';
27
27
  import { isMVILevel } from '@cleocode/lafs';
28
28
  import { z } from 'zod';
29
- import type { CanonicalDomain, Gateway, Tier } from './dispatch/identity.js';
30
- import type { ProblemDetails } from './engine-result.js';
29
+ import type { CanonicalDomain, Gateway, Tier } from '../dispatch/identity.js';
30
+ import type { ProblemDetails } from '../engine-result.js';
31
31
 
32
- export { CANONICAL_DOMAINS } from './dispatch/identity.js';
32
+ export { CANONICAL_DOMAINS } from '../dispatch/identity.js';
33
33
  export type { CanonicalDomain, Gateway, Tier };
34
34
 
35
35
  /**
@@ -39,7 +39,7 @@
39
39
  */
40
40
 
41
41
  import { z } from 'zod';
42
- import { dispatchRequestSchema, dispatchResponseSchema } from '../../gateway.js';
42
+ import { dispatchRequestSchema, dispatchResponseSchema } from '../index.js';
43
43
  import { GATEWAY_RPC_PROTOCOL_VERSION } from './version.js';
44
44
 
45
45
  // ─── Protocol-level error payload ──────────────────────────────────────────────
package/src/git-hooks.ts CHANGED
@@ -2,10 +2,44 @@
2
2
  import { z } from 'zod';
3
3
 
4
4
  /**
5
- * Canonical names of the shipped Git hooks: three checks, and `post-merge`,
6
- * which starts an opt-in background NEXUS reindex (T14010).
5
+ * Canonical names of the shipped Git hooks: three checks, and four `post-*`
6
+ * hooks that start a detached incremental NEXUS refresh (T14010, T12349).
7
7
  */
8
- export const CLEO_GIT_HOOK_NAMES = ['commit-msg', 'pre-commit', 'pre-push', 'post-merge'] as const;
8
+ export const CLEO_GIT_HOOK_NAMES = [
9
+ 'commit-msg',
10
+ 'pre-commit',
11
+ 'pre-push',
12
+ 'post-merge',
13
+ 'post-commit',
14
+ 'post-checkout',
15
+ 'post-rewrite',
16
+ ] as const;
17
+
18
+ /** Name of a shipped Git hook. */
19
+ export type CleoGitHookName = (typeof CLEO_GIT_HOOK_NAMES)[number];
20
+
21
+ /**
22
+ * Hooks whose exit status Git ignores. A foreign hook found at one of these
23
+ * names is chained, not skipped: it moves to `<name>.cleo-chained`, and the
24
+ * CLEO hook runs it last with the same arguments and stdin (T12349).
25
+ */
26
+ export const CHAINED_GIT_HOOK_NAMES: readonly CleoGitHookName[] = [
27
+ 'post-merge',
28
+ 'post-commit',
29
+ 'post-checkout',
30
+ 'post-rewrite',
31
+ ];
32
+
33
+ /**
34
+ * Hooks that exist only to keep the NEXUS index current (T12349): installed
35
+ * unless `cleo.nexusAutoReindex` is `false`, and removed by
36
+ * `cleo nexus hooks uninstall`.
37
+ */
38
+ export const NEXUS_GIT_HOOK_NAMES: readonly CleoGitHookName[] = [
39
+ 'post-commit',
40
+ 'post-checkout',
41
+ 'post-rewrite',
42
+ ];
9
43
 
10
44
  /** One recoverable managed Git hook change. */
11
45
  export const GitHookChangeSchema = z.object({
@@ -13,6 +47,8 @@ export const GitHookChangeSchema = z.object({
13
47
  before: z.string().nullable(),
14
48
  beforeMode: z.number().int().min(0).max(0o777).nullable(),
15
49
  afterHash: z.string().regex(/^[a-f0-9]{64}$/),
50
+ /** The `before` hook was moved to `<name>.cleo-chained`, not overwritten. */
51
+ chained: z.boolean().optional(),
16
52
  });
17
53
  /** A receipt scoped to the effective Git hook directory. */
18
54
  export const GitHookInstallReceiptSchema = z.object({
@@ -43,4 +79,8 @@ export interface GitHookInstallOptions {
43
79
  rollbackReceipt?: GitHookInstallReceipt;
44
80
  /** Explicitly permit writes into an effective hooksPath inside the working tree. */
45
81
  allowTrackedHooksPath?: boolean;
82
+ /** Hooks to manage (default: every shipped hook, less the NEXUS hooks when disabled). */
83
+ names?: readonly CleoGitHookName[];
84
+ /** Restore the recorded pre-CLEO image of `names` (exact bytes and mode). */
85
+ uninstall?: boolean;
46
86
  }
@@ -106,6 +106,11 @@ export interface PreToolUseHookInput {
106
106
  readonly cwd?: string;
107
107
  /** Claude Code and Codex: `default`, `plan`, `acceptEdits`, `auto`, `dontAsk`, `bypassPermissions`. */
108
108
  readonly permission_mode?: string;
109
+ /**
110
+ * Claude Code: the subagent or in-process teammate the call comes from;
111
+ * absent on the main thread (T14341).
112
+ */
113
+ readonly agent_id?: string;
109
114
  }
110
115
 
111
116
  /** The answer `cleo hook heavy-command --provider opencode` prints for CLEO's opencode plugin. */