@cleocode/contracts 2026.10.27 → 2026.11.1-canary.11

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 +533 -0
  144. package/dist/orca-execution.d.ts.map +1 -0
  145. package/dist/orca-execution.js +385 -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 +528 -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
@@ -427,14 +427,6 @@ export const NEXUS_SCOPE_MAP = {
427
427
  stores: ['nexus-graph', 'tasks'],
428
428
  requiresProject: true,
429
429
  },
430
- 'conduit-scan': {
431
- op: 'conduit-scan',
432
- description: 'Scan Conduit messaging patterns into the graph.',
433
- scope: 'project',
434
- effect: 'write',
435
- stores: ['nexus-graph'],
436
- requiresProject: true,
437
- },
438
430
 
439
431
  // ── Analytics ops ─────────────────────────────────────────────────────────
440
432
 
@@ -856,6 +856,8 @@ export interface NexusImpactParams {
856
856
  depth?: number;
857
857
  /** `--no-refresh` (T13523): answer from the index as it stands. */
858
858
  noRefresh?: boolean;
859
+ /** `--coverage-detail` (T14365): return every coverage reason instead of a bounded sample. */
860
+ coverageDetail?: boolean;
859
861
  }
860
862
  /** Affected symbol in impact result. */
861
863
  export interface NexusImpactAffectedNode {
@@ -1095,16 +1097,6 @@ export interface NexusSigilSyncResult {
1095
1097
  warnings: string[];
1096
1098
  }
1097
1099
 
1098
- /** Parameters for `nexus.conduit-scan`. */
1099
- export type NexusConduitScanParams = Record<string, never>;
1100
- /** Result of `nexus.conduit-scan`. */
1101
- export interface NexusConduitScanResult {
1102
- /** Count of conduit messages scanned. */
1103
- scanned: number;
1104
- /** Count of conduit_mentions_symbol edges written. */
1105
- linked: number;
1106
- }
1107
-
1108
1100
  /** Parameters for `nexus.contracts-sync`. */
1109
1101
  export interface NexusContractsSyncParams {
1110
1102
  /** Repository path (optional). */
@@ -2407,7 +2399,6 @@ export type NexusOps = {
2407
2399
  NexusContractsLinkTasksParams,
2408
2400
  NexusContractsLinkTasksResult,
2409
2401
  ];
2410
- readonly 'conduit-scan': readonly [NexusConduitScanParams, NexusConduitScanResult];
2411
2402
  // T1510 — Phase 2 dispatch ops
2412
2403
  readonly clusters: readonly [NexusClustersParams, NexusClustersResult];
2413
2404
  readonly flows: readonly [NexusFlowsParams, NexusFlowsResult];
@@ -12,9 +12,7 @@
12
12
  * @task T890 — orchestrate.plan deterministic wave+worker plan
13
13
  */
14
14
 
15
- /**
16
- * Common orchestration types
17
- */
15
+ import type { SpawnProtocolResolution, SpawnWorkerSession } from '../spawn-types.js';
18
16
 
19
17
  /**
20
18
  * A single execution wave grouping tasks by dependency depth.
@@ -554,6 +552,10 @@ export interface OrchestrateSpawnParams {
554
552
  export interface OrchestrateSpawnResult {
555
553
  /** Task ID the spawn is about (mirrors `task.id`). @task T963 */
556
554
  taskId: string;
555
+ /** Allocated worker identity, preserved for Orca and other execution backends. */
556
+ workerSession?: SpawnWorkerSession;
557
+ /** Coordinator session for correlation only, never a worker binding. */
558
+ coordinatorSessionId?: string | null;
557
559
  /**
558
560
  * Fully-resolved spawn prompt, copy-pastable into any LLM runtime
559
561
  * (Claude, GPT-4, Gemini, open-source). Primary payload every caller
@@ -577,7 +579,7 @@ export interface OrchestrateSpawnResult {
577
579
  * @task T13494
578
580
  */
579
581
  persona: string;
580
- /** Role the agent will execute as (`orchestrator` | `lead` | `worker`). @task T963 */
582
+ /** Coordination role for guidance; execution privileges come from workerSession.role. @task T963 */
581
583
  role: string;
582
584
  /** Tier of the rendered prompt (0/1/2). @task T963 */
583
585
  tier: 0 | 1 | 2;
@@ -613,6 +615,8 @@ export interface OrchestrateSpawnResult {
613
615
  promptChars: number;
614
616
  /** Protocol phase the prompt was rendered for. @task T963 */
615
617
  protocol: string;
618
+ /** Protocol authority and conflicting task signals. */
619
+ protocolResolution?: SpawnProtocolResolution;
616
620
  /** ISO 8601 timestamp when the payload was generated. @task T963 */
617
621
  generatedAt: string;
618
622
  /** Pinned composer contract version. @task T963 */
@@ -625,8 +629,7 @@ export interface OrchestrateSpawnResult {
625
629
  */
626
630
  protocolType: string;
627
631
  /**
628
- * Active session id threaded into the prompt, or `null` when the
629
- * orchestrator had no active session at spawn time.
632
+ * Allocated worker session id, retained for legacy consumers.
630
633
  * @task T963
631
634
  */
632
635
  sessionId: string | null;
@@ -839,3 +842,484 @@ export interface OrchestrateReportResult {
839
842
  totalEntries: number;
840
843
  };
841
844
  }
845
+
846
+ // ---------------------------------------------------------------------------
847
+ // Lead/worker split (epic T14351)
848
+ //
849
+ // A lead plans and delegates; workers do the work and report back. The lead's
850
+ // write and network tools are stripped so it cannot do the work itself, and a
851
+ // worker's report must carry proof the lead can check. Gated by the config key
852
+ // `orchestrate.leadWorker.v1` (default off).
853
+ // ---------------------------------------------------------------------------
854
+
855
+ /**
856
+ * Tools a lead is denied under the lead/worker split: every tool that writes
857
+ * files, runs commands or reaches the network. A lead only reads, plans and
858
+ * delegates.
859
+ *
860
+ * @task T14356
861
+ * @epic T14351
862
+ */
863
+ export const LEAD_DENIED_TOOLS = [
864
+ 'Bash',
865
+ 'Edit',
866
+ 'Write',
867
+ 'MultiEdit',
868
+ 'NotebookEdit',
869
+ 'WebFetch',
870
+ 'WebSearch',
871
+ ] as const;
872
+
873
+ /**
874
+ * One tool name a lead is denied. Member of {@link LEAD_DENIED_TOOLS}.
875
+ *
876
+ * @task T14356
877
+ */
878
+ export type LeadDeniedTool = (typeof LEAD_DENIED_TOOLS)[number];
879
+
880
+ /**
881
+ * Whether a provider can remove tools from a spawned lead.
882
+ *
883
+ * - `'enforced'` — the provider strips the denied tools; the lead cannot call them.
884
+ * - `'unsupported'` — the provider cannot strip them. Spawning a lead there with
885
+ * the split on is refused with `E_LEAD_TOOLS_UNSTRIPPED`.
886
+ *
887
+ * @task T14356
888
+ */
889
+ export type LeadToolStripSupport = 'enforced' | 'unsupported';
890
+
891
+ /**
892
+ * How a lead runs (T14363, owner decision):
893
+ *
894
+ * - `interactive` (default): a Claude session in the caller's terminal
895
+ * (stdio inherited, not detached). The owner types to it; it asks
896
+ * decisions with `AskUserQuestion`.
897
+ * - `detached`: a background run. Owner decisions go to the owner's AgentMBX
898
+ * mailbox as a structured `hitl.request`, and the lead waits there.
899
+ *
900
+ * @task T14363
901
+ */
902
+ export type LeadMode = 'interactive' | 'detached';
903
+
904
+ /**
905
+ * Built-in tool an interactive lead may use to ask the owner (T14363).
906
+ *
907
+ * @task T14363
908
+ */
909
+ export const LEAD_ASK_TOOL = 'AskUserQuestion';
910
+
911
+ /**
912
+ * A detached lead has no owner channel: the mbx MCP server is not configured
913
+ * or was refused, so it could never ask the owner and is refused (T14363).
914
+ *
915
+ * @task T14363
916
+ */
917
+ export const E_LEAD_NO_OWNER_CHANNEL = 'E_LEAD_NO_OWNER_CHANNEL';
918
+
919
+ /**
920
+ * AgentMBX recipient for owner decisions of a detached lead (T14363).
921
+ *
922
+ * @task T14363
923
+ */
924
+ export const LEAD_OWNER_MAILBOX = 'owner';
925
+
926
+ /**
927
+ * AgentMBX MCP server name a lead may load beside the runner (T14423).
928
+ *
929
+ * @task T14423
930
+ */
931
+ export const LEAD_MAILBOX_MCP_SERVER = 'mbx';
932
+
933
+ /**
934
+ * The MCP servers a lead spawn loaded (T14423). A lead loads ONLY the runner
935
+ * ({@link LEAD_RUNNER_MCP_SERVER}) and, when the user configured it, the
936
+ * AgentMBX server ({@link LEAD_MAILBOX_MCP_SERVER}); every other user MCP
937
+ * server is shut out, since one with shell or file tools would hand back
938
+ * what the tool strip removed.
939
+ *
940
+ * @task T14423
941
+ * @epic T14351
942
+ */
943
+ export interface LeadMcpReport {
944
+ /** Server names the lead loads, the runner first. */
945
+ readonly servers: readonly string[];
946
+ /**
947
+ * `loaded` when the user-level mbx server was found, validated and passed;
948
+ * `not-configured` when there is none; `refused` when an entry failed the
949
+ * checks (not the agentmbx binary, a path inside the project, ...).
950
+ */
951
+ readonly mailbox: 'loaded' | 'not-configured' | 'refused';
952
+ /** Why the mbx entry was refused (with `mailbox: 'refused'`). */
953
+ readonly warning?: string;
954
+ }
955
+
956
+ /**
957
+ * Tool policy applied to a lead spawn under the lead/worker split.
958
+ *
959
+ * @task T14356
960
+ * @epic T14351
961
+ */
962
+ export interface LeadToolPolicy {
963
+ /** Tools removed from the lead. Normally {@link LEAD_DENIED_TOOLS}. */
964
+ deniedTools: readonly LeadDeniedTool[];
965
+ /** Whether the spawning provider can enforce {@link LeadToolPolicy.deniedTools}. */
966
+ stripSupport: LeadToolStripSupport;
967
+ }
968
+
969
+ /**
970
+ * MCP server name of the lead command runner. The lead reaches it as
971
+ * {@link LEAD_RUNNER_TOOL}.
972
+ *
973
+ * @task T14374
974
+ */
975
+ export const LEAD_RUNNER_MCP_SERVER = 'cleo-lead';
976
+
977
+ /**
978
+ * Tool name the lead command runner serves.
979
+ *
980
+ * @task T14374
981
+ */
982
+ export const LEAD_RUNNER_TOOL_NAME = 'cleo_run';
983
+
984
+ /**
985
+ * Provider-qualified name of the lead command runner tool: the one way a lead
986
+ * without Bash runs a command. It takes an argv array, never a shell string.
987
+ *
988
+ * @task T14374
989
+ * @epic T14351
990
+ */
991
+ export const LEAD_RUNNER_TOOL = `mcp__${LEAD_RUNNER_MCP_SERVER}__${LEAD_RUNNER_TOOL_NAME}` as const;
992
+
993
+ /**
994
+ * Binary the lead command runner may execute.
995
+ *
996
+ * @task T14374
997
+ */
998
+ export type LeadCommandBinary = 'cleo' | 'gh';
999
+
1000
+ /**
1001
+ * How a lead-runner flag is parsed: `boolean` takes no value; `value` takes
1002
+ * the next argv word (which must not start with `-`) or an inline
1003
+ * `--flag=value`.
1004
+ *
1005
+ * @task T14374
1006
+ */
1007
+ export type LeadFlagArity = 'boolean' | 'value';
1008
+
1009
+ /**
1010
+ * One allowed command, allow-only at every level: the full command path, the
1011
+ * flags it accepts with their arity, how many positional words it takes, and
1012
+ * the flags that must be set. Anything not listed is refused.
1013
+ *
1014
+ * @task T14374
1015
+ */
1016
+ export interface LeadCommandRule {
1017
+ /** Full command path after the binary, down to a leaf, e.g. `['review', 'verdict']`. */
1018
+ readonly verb: readonly string[];
1019
+ /** Flags the command accepts, keyed by their full token (`--json`), with arity. */
1020
+ readonly flags?: Readonly<Record<string, LeadFlagArity>>;
1021
+ /** Most positional words allowed after the path. @defaultValue 0 */
1022
+ readonly positionals?: number;
1023
+ /**
1024
+ * Positional words must be plain numbers (a PR number or run id), so a URL
1025
+ * cannot point the command at another repository.
1026
+ */
1027
+ readonly numericPositionals?: boolean;
1028
+ /** Flags the parse must show set (a boolean set true, a value flag given a value). */
1029
+ readonly requireFlags?: readonly string[];
1030
+ }
1031
+
1032
+ /**
1033
+ * Global `cleo` output flags (parsed by the CLI entry for every command) that
1034
+ * a lead may add after any allowed `cleo` command.
1035
+ *
1036
+ * @task T14374
1037
+ */
1038
+ export const LEAD_CLEO_GLOBAL_FLAGS: Readonly<Record<string, LeadFlagArity>> = {
1039
+ '--json': 'boolean',
1040
+ '--human': 'boolean',
1041
+ '--quiet': 'boolean',
1042
+ '--full': 'boolean',
1043
+ '--verbose': 'boolean',
1044
+ '--summary': 'boolean',
1045
+ '--describe': 'boolean',
1046
+ '--field': 'value',
1047
+ '--fields': 'value',
1048
+ '--output': 'value',
1049
+ '--mvi': 'value',
1050
+ };
1051
+
1052
+ /**
1053
+ * Commands a lead may run through {@link LEAD_RUNNER_TOOL}: read, plan,
1054
+ * dispatch and review verbs only, plus `merge train` (T14371), which merges only
1055
+ * PRs green on their exact head and reviewed per AC. Nothing here edits files,
1056
+ * pushes or answers an owner gate; anything not listed is refused.
1057
+ *
1058
+ * Each rule names a leaf command with no subcommands (checked against the
1059
+ * CLI command manifest), so neither a flag nor a flag value can select a
1060
+ * different subcommand; `briefing` is absent because it has one (`inject`).
1061
+ * `gh` positionals must be numbers, so a URL cannot reach another repo. `orchestrate` lists only its
1062
+ * read/plan/dispatch sub-verbs: never `worktree-complete` (merges),
1063
+ * `approve`/`reject` (owner gate), `lead-runner`, `prune`, `ivtr`,
1064
+ * `bootstrap` or `conduit-*`. `gh` takes no `--repo`, `--web`, `--watch`,
1065
+ * `--body-file`, `--edit-last` or `--delete-last`; a comment is `--body` text.
1066
+ *
1067
+ * @task T14374
1068
+ * @epic T14351
1069
+ */
1070
+ export const LEAD_COMMAND_ALLOWLIST: Readonly<
1071
+ Record<LeadCommandBinary, readonly LeadCommandRule[]>
1072
+ > = {
1073
+ cleo: [
1074
+ { verb: ['orchestrate', 'start'], positionals: 1 },
1075
+ { verb: ['orchestrate', 'status'], flags: { '--epic': 'value', '--merge-queue': 'boolean' } },
1076
+ { verb: ['orchestrate', 'dashboard'], flags: { '--window': 'value' } },
1077
+ { verb: ['orchestrate', 'roll-up'], positionals: 1, flags: { '--wave': 'value' } },
1078
+ {
1079
+ verb: ['orchestrate', 'analyze'],
1080
+ positionals: 1,
1081
+ flags: { '--mode': 'value', '--tasks': 'value' },
1082
+ },
1083
+ {
1084
+ verb: ['orchestrate', 'ready'],
1085
+ positionals: 1,
1086
+ flags: { '--ignore-deps-validate': 'boolean', '--via': 'value' },
1087
+ },
1088
+ {
1089
+ verb: ['orchestrate', 'report'],
1090
+ positionals: 1,
1091
+ flags: { '--page': 'value', '--page-size': 'value' },
1092
+ },
1093
+ { verb: ['orchestrate', 'next'], positionals: 1 },
1094
+ {
1095
+ verb: ['orchestrate', 'waves'],
1096
+ positionals: 1,
1097
+ flags: { '--via': 'value', '--hide-completed': 'boolean' },
1098
+ },
1099
+ { verb: ['orchestrate', 'plan'], positionals: 1, flags: { '--tier': 'value' } },
1100
+ {
1101
+ verb: ['orchestrate', 'spawn'],
1102
+ positionals: 1,
1103
+ flags: {
1104
+ '--protocol': 'value',
1105
+ '--tier': 'value',
1106
+ '--scope': 'value',
1107
+ '--orchestrator-defer': 'boolean',
1108
+ '--lead-mbx': 'value',
1109
+ '--base': 'value',
1110
+ '--include-deps': 'boolean',
1111
+ '--resume': 'boolean',
1112
+ },
1113
+ },
1114
+ {
1115
+ verb: ['orchestrate', 'validate'],
1116
+ positionals: 1,
1117
+ flags: { '--file': 'value', '--manifest': 'boolean' },
1118
+ },
1119
+ { verb: ['orchestrate', 'context'], positionals: 1 },
1120
+ { verb: ['orchestrate', 'parallel'], positionals: 2, flags: { '--wave': 'value' } },
1121
+ { verb: ['orchestrate', 'unblock'] },
1122
+ { verb: ['orchestrate', 'classify'], positionals: 1 },
1123
+ { verb: ['orchestrate', 'fanout-status'], flags: { '--manifest-entry-id': 'value' } },
1124
+ { verb: ['orchestrate', 'handoff'], positionals: 1, flags: { '--protocol': 'value' } },
1125
+ {
1126
+ verb: ['orchestrate', 'spawn-execute'],
1127
+ positionals: 1,
1128
+ flags: { '--base': 'value', '--adapter': 'value' },
1129
+ },
1130
+ { verb: ['orchestrate', 'fanout'], positionals: 1, flags: { '--tasks': 'value' } },
1131
+ { verb: ['orchestrate', 'pending'] },
1132
+ {
1133
+ verb: ['show'],
1134
+ positionals: 50,
1135
+ flags: { '--history': 'boolean', '--relations': 'boolean' },
1136
+ },
1137
+ {
1138
+ verb: ['find'],
1139
+ positionals: 1,
1140
+ flags: {
1141
+ '--id': 'value',
1142
+ '--exact': 'boolean',
1143
+ '--fuzzy': 'boolean',
1144
+ '--status': 'value',
1145
+ '--in': 'value',
1146
+ '--include-archive': 'boolean',
1147
+ '--limit': 'value',
1148
+ '--all': 'boolean',
1149
+ '--offset': 'value',
1150
+ '--kind': 'value',
1151
+ '--urgent': 'boolean',
1152
+ '--label': 'value',
1153
+ '--parent': 'value',
1154
+ },
1155
+ },
1156
+ {
1157
+ verb: ['list'],
1158
+ flags: {
1159
+ '--include-archive': 'boolean',
1160
+ '--parent': 'value',
1161
+ '--status': 'value',
1162
+ '--priority': 'value',
1163
+ '--type': 'value',
1164
+ '--severity': 'value',
1165
+ '--kind': 'value',
1166
+ '--phase': 'value',
1167
+ '--label': 'value',
1168
+ '--limit': 'value',
1169
+ '--offset': 'value',
1170
+ '--all': 'boolean',
1171
+ },
1172
+ },
1173
+ { verb: ['review', 'packet'], positionals: 1, flags: { '--task': 'value' } },
1174
+ { verb: ['review', 'check'], positionals: 1, flags: { '--task': 'value', '--ac': 'value' } },
1175
+ {
1176
+ verb: ['review', 'verdict'],
1177
+ positionals: 1,
1178
+ flags: {
1179
+ '--task': 'value',
1180
+ '--ac': 'value',
1181
+ '--met': 'boolean',
1182
+ '--unmet': 'boolean',
1183
+ '--reason': 'value',
1184
+ '--packet': 'value',
1185
+ '--answers': 'value',
1186
+ },
1187
+ },
1188
+ {
1189
+ verb: ['done'],
1190
+ flags: { '--from-merge': 'value', '--dry-run': 'boolean' },
1191
+ requireFlags: ['--from-merge', '--dry-run'],
1192
+ },
1193
+ {
1194
+ verb: ['memory', 'find'],
1195
+ positionals: 1,
1196
+ flags: {
1197
+ '--type': 'value',
1198
+ '--docs': 'boolean',
1199
+ '--history': 'boolean',
1200
+ '--pattern-type': 'value',
1201
+ '--min-confidence': 'value',
1202
+ '--actionable': 'boolean',
1203
+ '--limit': 'value',
1204
+ '--agent': 'value',
1205
+ },
1206
+ },
1207
+ { verb: ['memory', 'fetch'], positionals: 50 },
1208
+ { verb: ['session', 'status'] },
1209
+ {
1210
+ verb: ['decide', 'ask'],
1211
+ flags: {
1212
+ '--state': 'value',
1213
+ '--question': 'value',
1214
+ '--noul': 'value',
1215
+ '--timeout-ms': 'value',
1216
+ '--profile': 'value',
1217
+ },
1218
+ },
1219
+ { verb: ['merge', 'train'], flags: { '--dry-run': 'boolean', '--execute': 'boolean' } },
1220
+ ],
1221
+ gh: [
1222
+ {
1223
+ verb: ['pr', 'view'],
1224
+ positionals: 1,
1225
+ numericPositionals: true,
1226
+ flags: { '--json': 'value', '--jq': 'value', '--template': 'value', '--comments': 'boolean' },
1227
+ },
1228
+ {
1229
+ verb: ['pr', 'list'],
1230
+ flags: {
1231
+ '--state': 'value',
1232
+ '--limit': 'value',
1233
+ '--search': 'value',
1234
+ '--label': 'value',
1235
+ '--author': 'value',
1236
+ '--base': 'value',
1237
+ '--head': 'value',
1238
+ '--draft': 'boolean',
1239
+ '--json': 'value',
1240
+ '--jq': 'value',
1241
+ },
1242
+ },
1243
+ {
1244
+ verb: ['pr', 'checks'],
1245
+ positionals: 1,
1246
+ numericPositionals: true,
1247
+ flags: { '--json': 'value', '--jq': 'value', '--required': 'boolean' },
1248
+ },
1249
+ {
1250
+ verb: ['pr', 'diff'],
1251
+ positionals: 1,
1252
+ numericPositionals: true,
1253
+ flags: { '--name-only': 'boolean', '--patch': 'boolean', '--color': 'value' },
1254
+ },
1255
+ {
1256
+ verb: ['pr', 'comment'],
1257
+ positionals: 1,
1258
+ numericPositionals: true,
1259
+ flags: { '--body': 'value' },
1260
+ requireFlags: ['--body'],
1261
+ },
1262
+ {
1263
+ verb: ['run', 'list'],
1264
+ flags: {
1265
+ '--branch': 'value',
1266
+ '--workflow': 'value',
1267
+ '--limit': 'value',
1268
+ '--status': 'value',
1269
+ '--commit': 'value',
1270
+ '--event': 'value',
1271
+ '--user': 'value',
1272
+ '--json': 'value',
1273
+ '--jq': 'value',
1274
+ },
1275
+ },
1276
+ {
1277
+ verb: ['run', 'view'],
1278
+ positionals: 1,
1279
+ numericPositionals: true,
1280
+ flags: {
1281
+ '--log': 'boolean',
1282
+ '--log-failed': 'boolean',
1283
+ '--job': 'value',
1284
+ '--attempt': 'value',
1285
+ '--verbose': 'boolean',
1286
+ '--exit-status': 'boolean',
1287
+ '--json': 'value',
1288
+ '--jq': 'value',
1289
+ },
1290
+ },
1291
+ ],
1292
+ };
1293
+
1294
+ /**
1295
+ * One piece of proof backing a worker's conclusion: a command it ran with its
1296
+ * exit code, an artifact it produced (a PR url, a file path, a commit sha), or
1297
+ * both. A proof entry with no field set proves nothing and is rejected with
1298
+ * `E_WORKER_REPORT_PROOF`.
1299
+ *
1300
+ * @task T14356
1301
+ */
1302
+ export interface WorkerProof {
1303
+ /** Command the worker ran, verbatim. */
1304
+ command?: string;
1305
+ /** Exit code of {@link WorkerProof.command}. */
1306
+ exitCode?: number;
1307
+ /** Artifact the worker produced: a PR url, file path or commit sha. */
1308
+ artifact?: string;
1309
+ }
1310
+
1311
+ /**
1312
+ * The report a worker returns to its lead: one conclusion, the blocker (or
1313
+ * `null`), and the proof behind the conclusion.
1314
+ *
1315
+ * @task T14356
1316
+ * @epic T14351
1317
+ */
1318
+ export interface WorkerReport {
1319
+ /** One-line result of the worker's task. */
1320
+ conclusion: string;
1321
+ /** What stopped the worker, or `null` when nothing did. */
1322
+ blocker: string | null;
1323
+ /** Proof for {@link WorkerReport.conclusion}. Checked by the lead (T14361). */
1324
+ proof: WorkerProof[];
1325
+ }
@@ -325,7 +325,7 @@ const tasksFindOutputContract: OperationOutputContract = {
325
325
 
326
326
  // ---------------------------------------------------------------------------
327
327
  // Mutation envelope shape (T9931 / T10608) — shared by add / add-batch /
328
- // update / complete / delete.
328
+ // update / complete / delete / cancel / restore (T14220).
329
329
  //
330
330
  // DEFAULT (minimal) shape — what `--field` resolves against — is
331
331
  // `MinimalMutateEnvelope` from `mutate-projection.ts`:
@@ -351,90 +351,3 @@ export interface ReleaseRollbackResult {
351
351
  /** Rollback reason. @task T963 */
352
352
  reason: string;
353
353
  }
354
-
355
- // ── RELEASE-03: IVTR gate check ──────────────────────────────────────────────
356
-
357
- /**
358
- * Parameters for `release.gate` — checks all IVTR loops in a release epic
359
- * have reached the `released` phase before allowing `release.ship`.
360
- *
361
- * @task T820 RELEASE-03
362
- * @task T1416
363
- */
364
- export interface ReleaseGateCheckParams {
365
- /** Epic ID whose child tasks should be inspected. */
366
- epicId: string;
367
- /**
368
- * Bypass the IVTR gate — requires explicit owner confirmation.
369
- * When true, the gate check is skipped and a loud warning is emitted.
370
- */
371
- force?: boolean;
372
- }
373
-
374
- /** A single task's IVTR phase status as reported by `release.gate`. */
375
- export interface IvtrTaskStatus {
376
- /** Task ID. */
377
- taskId: string;
378
- /**
379
- * Current IVTR phase, or `null` when no IVTR loop has been started for
380
- * this task (task is "unchecked").
381
- */
382
- currentPhase: 'implement' | 'validate' | 'test' | 'released' | null;
383
- /** Whether the task blocks release (`true` = blocking). */
384
- blocking: boolean;
385
- }
386
-
387
- /**
388
- * Result of `release.gate`.
389
- *
390
- * @task T820 RELEASE-03
391
- * @task T1416
392
- */
393
- export interface ReleaseGateCheckResult {
394
- /** Epic ID that was inspected. */
395
- epicId: string;
396
- /** Whether the gate passed — all tasks are released or unchecked. */
397
- passed: boolean;
398
- /** Whether the gate was bypassed via `--force`. */
399
- forcedBypass: boolean;
400
- /** Task IDs whose IVTR state is not `released` (blocking). */
401
- blocked: string[];
402
- /**
403
- * Task IDs with no IVTR state (non-blocking; docs / chore tasks often
404
- * have no IVTR loop).
405
- */
406
- unchecked: string[];
407
- /** Full per-task status breakdown. */
408
- tasks: IvtrTaskStatus[];
409
- /**
410
- * Human-readable summary suitable for CLI output and operator review.
411
- * Present on both pass and fail.
412
- */
413
- summary: string;
414
- }
415
-
416
- // ── RELEASE-07: IVTR → release auto-suggest ──────────────────────────────────
417
-
418
- /**
419
- * Result emitted by `release.ivtr-suggest` — the hint produced when an IVTR
420
- * loop transitions to `released` and all tasks in the parent epic are now
421
- * in the `released` phase.
422
- *
423
- * @task T820 RELEASE-07
424
- * @task T1416
425
- */
426
- export interface IvtrAutoSuggestResult {
427
- /** Task ID that just reached the `released` phase. */
428
- taskId: string;
429
- /** Parent epic ID, if the task belongs to one. */
430
- epicId: string | null;
431
- /** Whether every task in the epic has reached `released`. */
432
- epicFullyReleased: boolean;
433
- /**
434
- * Suggested next CLI command. Non-null only when `epicFullyReleased` is
435
- * true. Points the operator toward `cleo release ship`.
436
- */
437
- suggestedCommand: string | null;
438
- /** Human-readable message for operator guidance. */
439
- message: string;
440
- }
@@ -615,7 +615,7 @@ export interface SessionEndParams {
615
615
  * When provided, CLEO persists key learnings, decisions, patterns, and next actions.
616
616
  * @task T140 @epic T134
617
617
  */
618
- sessionSummary?: import('../config.js').SessionSummaryInput;
618
+ sessionSummary?: import('../config/types.js').SessionSummaryInput;
619
619
  /**
620
620
  * Explicit session id to end (T11346 · Epic T11284).
621
621
  *