@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
@@ -25,7 +25,7 @@ import type { TaskAnalysisResult, TaskRef } from '../results.js';
25
25
  /**
26
26
  * Common task types (API contract — matches CLI src/types/task.ts)
27
27
  */
28
- import type { TaskStatus } from '../status-registry.js';
28
+ import type { CancellationKind, TaskStatus } from '../status-registry.js';
29
29
  import type { TaskClaim, TaskKind, TaskPriority, TaskSeverity, TaskType } from '../task.js';
30
30
  import type {
31
31
  MinimalTaskRecord,
@@ -52,7 +52,7 @@ import type {
52
52
  TaskPlanResult,
53
53
  TaskTreeNode,
54
54
  TaskView,
55
- } from '../tasks.js';
55
+ } from '../tasks/index.js';
56
56
  import type { DocsType } from './docs.js';
57
57
  import type { JsonSchema, OperationInputContract } from './input-contract.js';
58
58
 
@@ -236,13 +236,11 @@ export interface TasksCurrentResult {
236
236
  sessionId?: string;
237
237
  }
238
238
 
239
- // tasks.show (with optional history/ivtrHistory/relations flags)
239
+ // tasks.show (with optional history/relations flags)
240
240
  export interface TasksShowParams {
241
241
  taskId: string;
242
242
  /** When true, include task change history. */
243
243
  history?: boolean;
244
- /** When true, include IVTR phase history. */
245
- ivtrHistory?: boolean;
246
244
  /** When true, include expanded relation/doc ID lists alongside compact counts. */
247
245
  relations?: boolean;
248
246
  }
@@ -1042,6 +1040,13 @@ export interface TasksSyncLinksRemoveResult {
1042
1040
  }
1043
1041
 
1044
1042
  // tasks.cancel
1043
+ /**
1044
+ * Child handling mode for `tasks.cancel`: `block` refuses while unsettled
1045
+ * children remain, `cascade` cancels the subtree, `reparent` moves the
1046
+ * children under `reparentTo` (T11811 · moved from core in T14273).
1047
+ */
1048
+ export type ChildStrategy = 'block' | 'cascade' | 'reparent';
1049
+
1045
1050
  export interface TasksCancelParams {
1046
1051
  taskId: string;
1047
1052
  reason?: string;
@@ -1051,7 +1056,7 @@ export interface TasksCancelParams {
1051
1056
  * legacy `orphan`/detach mode was removed by T11811 (it manufactured the
1052
1057
  * exact orphan the containment guard rejects).
1053
1058
  */
1054
- children?: 'block' | 'cascade' | 'reparent';
1059
+ children?: ChildStrategy;
1055
1060
  /**
1056
1061
  * Target parent ID for the `reparent` strategy (T11811). REQUIRED when
1057
1062
  * `children='reparent'`.
@@ -1063,6 +1068,10 @@ export interface TasksCancelParams {
1063
1068
  cascadeThreshold?: number;
1064
1069
  /** Config-level cascade permission. Defaults to true. */
1065
1070
  allowCascade?: boolean;
1071
+ /** Why the task is cancelled (T14267): abandoned, superseded, duplicate or obsolete. */
1072
+ kind?: CancellationKind;
1073
+ /** The task that replaced this one; only with kind `superseded` or `duplicate` (T14267). */
1074
+ replacedBy?: string;
1066
1075
  }
1067
1076
  /**
1068
1077
  * Result of `tasks.cancel` — cancellation confirmation.
@@ -1087,8 +1096,12 @@ export interface TasksCancelResult {
1087
1096
  * @defaultValue undefined
1088
1097
  */
1089
1098
  alreadyCancelled?: boolean;
1099
+ /** The recorded cancel kind (T14267). @defaultValue undefined */
1100
+ kind?: CancellationKind;
1101
+ /** The recorded replacement (T14267). @defaultValue undefined */
1102
+ replacedBy?: string;
1090
1103
  /** Explicit child handling mode applied by the operation. */
1091
- childStrategy?: 'block' | 'cascade' | 'reparent';
1104
+ childStrategy?: ChildStrategy;
1092
1105
  /** Child or descendant tasks affected by cascade/reparent handling. */
1093
1106
  affectedTasks?: string[];
1094
1107
  /** Count of affected child/descendant tasks. */
@@ -238,6 +238,12 @@ export interface ValidateGateParams {
238
238
  * with these REQ-IDs (comma-separated); the others are not run.
239
239
  */
240
240
  req?: string;
241
+ /**
242
+ * `cleo verify --criterion` (T14199): record a per-criterion receipt from
243
+ * `evidence` (one `satisfies:` plus a `decision:` or stored-document
244
+ * `files:` atom) instead of a gate. Exclusive with `gate`, `all` and `reset`.
245
+ */
246
+ criterion?: boolean;
241
247
  }
242
248
  export interface ValidateGateResult {
243
249
  taskId: string;
@@ -483,7 +483,10 @@ export interface DestroyWorktreeOptions {
483
483
  */
484
484
  forceDeleteUnmergedBranch?: boolean;
485
485
  /**
486
- * When true, force destruction even if the worktree has uncommitted changes.
486
+ * When true, a worktree whose content or commits are not proven preserved
487
+ * is archived first (an archive ref plus a patch, with a receipt) and then
488
+ * removed; without it such a worktree is kept (T13924). Nothing that still
489
+ * links into the worktree, or evidence found only there, is overridden.
487
490
  *
488
491
  * @default false
489
492
  */
@@ -564,6 +567,127 @@ export interface DestroyWorktreeResult {
564
567
  hookResults?: WorktreeHookResult[];
565
568
  /** Set when the worktree was kept because something still needs its files (T13696). */
566
569
  kept?: WorktreeDisposalBlockers;
570
+ /** The archive a forced destroy wrote before removing unpreserved work (T13924). */
571
+ archive?: WorktreeArchiveReceipt;
572
+ }
573
+
574
+ /**
575
+ * What `createWorktree` attaches to the error it rethrows.
576
+ *
577
+ * @task T12506
578
+ * @task T14407
579
+ */
580
+ export interface CreateWorktreeFailure {
581
+ /** True when the failing call itself created the worktree directory. */
582
+ freshWorktreeCreated: boolean;
583
+ /**
584
+ * The removal of that fresh worktree, run while the per-task lock was still
585
+ * held. Absent when the call created none. Callers must not clean up again:
586
+ * the lock is released by then, so a concurrent re-spawn may own the path.
587
+ */
588
+ cleanup?: DestroyWorktreeResult;
589
+ }
590
+
591
+ /**
592
+ * Receipt of a worktree archived before removal (T13924): every commit and
593
+ * every uncommitted change it held, as a ref in the repository and a patch on
594
+ * disk. Written beside the patch as `<name>.json`.
595
+ *
596
+ * @task T13924
597
+ */
598
+ export interface WorktreeArchiveReceipt {
599
+ /** The worktree that was archived. */
600
+ worktreePath: string;
601
+ /** Owning task, when known. */
602
+ taskId: string | null;
603
+ /** The disposal that archived it. */
604
+ reason: string;
605
+ /** Branch checked out in the worktree, or `null` when detached. */
606
+ branch: string | null;
607
+ /** The worktree's HEAD commit, or `null` for an unborn branch. */
608
+ head: string | null;
609
+ /** Ref holding the archive commit, under `refs/cleo/archive/`. */
610
+ archiveRef: string;
611
+ /** Archive commit: HEAD as parent, the tracked, untracked and ignored content (bar `node_modules` and build output) as its tree. */
612
+ archiveSha: string;
613
+ /** Patch from HEAD to the archive commit (`git diff --binary`). */
614
+ patchPath: string;
615
+ /** Path of this receipt. */
616
+ receiptPath: string;
617
+ /** ISO-8601 time the archive was written. */
618
+ createdAt: string;
619
+ /** Command that restores the archive into a new worktree. */
620
+ restore: string;
621
+ }
622
+
623
+ /**
624
+ * Options for the one worktree disposal engine (T13924, `disposeWorktree`).
625
+ *
626
+ * @task T13924
627
+ */
628
+ export interface DisposeWorktreeOptions {
629
+ /** Worktree directory to dispose. */
630
+ worktreePath: string;
631
+ /** Repository root the worktree belongs to; read from the worktree when omitted. */
632
+ gitRoot?: string;
633
+ /** Main checkout untracked and ignored content is compared against, and the archive's home; the repository's main worktree when omitted. */
634
+ projectRoot?: string;
635
+ /** Owning task, when known. */
636
+ taskId: string | null;
637
+ /** Why the worktree is disposed (audit and archive receipt). */
638
+ reason: string;
639
+ /** The task's recorded evidence atoms (T13696). */
640
+ evidence?: readonly EvidenceAtom[];
641
+ /**
642
+ * The project's default branch (core `getDefaultBranch`, which honours
643
+ * `git.defaultBranch`). When omitted: `origin/HEAD`, then `main`, `master`,
644
+ * `develop`, `trunk`.
645
+ */
646
+ defaultBranch?: string;
647
+ /** Ignored build output counts as redundant: only for a checkout whose commits are merged. */
648
+ exemptRegenerable?: boolean;
649
+ /**
650
+ * Archive unpreserved work, then remove (`destroy --force` only). The
651
+ * dependents and evidence guard still keeps the worktree.
652
+ */
653
+ force?: boolean;
654
+ /** Report what would happen; never write, archive or remove. */
655
+ dryRun?: boolean;
656
+ /**
657
+ * Decide only: run the proof and record a keep marker when the guard keeps
658
+ * it (as a real disposal does), but never archive or remove. Callers that
659
+ * act between deciding and removing (hooks, a re-check) use it.
660
+ */
661
+ probe?: boolean;
662
+ /**
663
+ * Whether something still uses the worktree (a live task lock or claim):
664
+ * a reason when it does, `null` when not. A probe that throws counts as in use.
665
+ */
666
+ inUse?: () => string | null;
667
+ }
668
+
669
+ /**
670
+ * Outcome of {@link DisposeWorktreeOptions | disposeWorktree}.
671
+ *
672
+ * @task T13924
673
+ */
674
+ export interface DisposeWorktreeResult {
675
+ /** The worktree considered. */
676
+ worktreePath: string;
677
+ /** Whether the directory is gone (a dry run reports `false`). */
678
+ removed: boolean;
679
+ /** Why it was kept, when it was; absent when removed or removable. */
680
+ keptReason?: string;
681
+ /** Set when the dependents and evidence guard kept it (T13696). */
682
+ kept?: WorktreeDisposalBlockers;
683
+ /** The preservation clause that failed, when one did (dirty, untracked, ignored content, unpreserved commits, a failed probe). */
684
+ unpreserved?: string;
685
+ /** The archive written before a forced removal. */
686
+ archive?: WorktreeArchiveReceipt;
687
+ /** Set when the removal (or the archive before it) was attempted and failed: an error, not a proof result. */
688
+ failed?: string;
689
+ /** True when a probe could not answer (a git or read error), so the worktree was kept unproven (T14274). */
690
+ indeterminate?: boolean;
567
691
  }
568
692
 
569
693
  // ---------------------------------------------------------------------------
@@ -649,9 +773,9 @@ export interface PruneWorktreesResult {
649
773
  removed: number;
650
774
  /** Absolute paths that were removed. */
651
775
  removedPaths: string[];
652
- /** Number of worktrees quarantined (dirty/unpushed — preserved, not deleted). */
776
+ /** Number of worktrees kept because their content or commits are not proven preserved (T13924). */
653
777
  quarantined: number;
654
- /** Absolute paths of quarantined worktrees. */
778
+ /** Absolute paths of those kept worktrees, left on disk untouched. */
655
779
  quarantinedPaths: string[];
656
780
  /** Entries that failed to remove (with reasons). */
657
781
  errors: Array<{ path: string; reason: string }>;
@@ -670,25 +794,26 @@ export interface PruneWorktreesResult {
670
794
  // ---------------------------------------------------------------------------
671
795
 
672
796
  /**
673
- * Mutually-exclusive worktree status category assigned by orphan-detection
674
- * heuristics in {@link WorktreeInfo}.
797
+ * Mutually-exclusive worktree status category: what the one disposal proof
798
+ * (`disposeWorktree`, T13924) says about the worktree (T14274).
675
799
  *
676
- * Resolution precedence (first match wins):
677
- * 1. `active` — primary worktree guard: the canonical project checkout
678
- * (the directory containing `.git/`, not a `git worktree add` derivative)
679
- * is ALWAYS active, regardless of merge state. Without this guard the
680
- * `main` branch would classify as `merged` (it is trivially its own
681
- * ancestor) and `cleo worktree prune --orphaned` would offer to delete
682
- * the project root. (T9686-D)
683
- * 2. `locked` — git porcelain reports the worktree is locked.
684
- * 3. `orphan` — owning task is cancelled OR the branch has been deleted.
685
- * 4. `merged` — the branch is reachable from `main` (already integrated).
686
- * 5. `stale` — no commits in N days AND (task=done OR no live owner).
687
- * 6. `active` — everything else (default).
800
+ * - `active` — in use: the primary checkout (T9686-D), a worktree whose task
801
+ * is open, or one with no (stored) task that was active within the stale
802
+ * window. Never pruned.
803
+ * - `redundant` — its task is done or cancelled (or it has no task and has
804
+ * been idle past the stale window) and the proof holds: nothing in it would
805
+ * be lost. `cleo worktree prune --orphaned` acts only on these.
806
+ * - `keep` — same candidacy, but the proof fails; {@link WorktreeInfo.keepReason}
807
+ * names the failing clause (uncommitted changes, unpreserved commits,
808
+ * something linking into it, a task lock held, …).
809
+ * - `unknown` — a probe could not answer (a git or read error); never redundant.
810
+ *
811
+ * Staleness is an annotation ({@link WorktreeInfo.isStale}), not a category.
688
812
  *
689
813
  * @task T9546
814
+ * @task T14274
690
815
  */
691
- export type WorktreeStatusCategory = 'active' | 'stale' | 'merged' | 'orphan' | 'locked';
816
+ export type WorktreeStatusCategory = 'active' | 'redundant' | 'keep' | 'unknown';
692
817
 
693
818
  /**
694
819
  * Source classifier for a worktree entry.
@@ -759,7 +884,7 @@ export interface WorktreeInfo {
759
884
  * @task T9546
760
885
  */
761
886
  lockState: 'locked' | 'unlocked';
762
- /** Whether the worktree is stale: no activity > N days AND (task done/cancelled OR branch merged). */
887
+ /** Annotation: no activity for more than the stale window AND (task done/cancelled OR branch merged). */
763
888
  isStale: boolean;
764
889
  /** Whether the branch is reachable from `main` (already integrated). */
765
890
  isMerged: boolean;
@@ -767,6 +892,8 @@ export interface WorktreeInfo {
767
892
  owningTaskStatus: string | null;
768
893
  /** Mutually-exclusive status category — see {@link WorktreeStatusCategory}. */
769
894
  statusCategory: WorktreeStatusCategory;
895
+ /** For `keep` and `unknown`: the proof clause that failed, or the probe that could not answer (T14274). */
896
+ keepReason?: string;
770
897
  /**
771
898
  * Origin of this worktree entry.
772
899
  *
@@ -793,6 +920,8 @@ export interface WorktreeInfo {
793
920
  * @task T9546
794
921
  */
795
922
  export interface ListWorktreesOpts {
923
+ /** Limit enrichment and disposal proofs to this task (terminal lifecycle cleanup). */
924
+ taskId?: string;
796
925
  /**
797
926
  * Absolute path to the project root (used to compute the project hash
798
927
  * and resolve the canonical worktrees directory).
@@ -811,6 +940,8 @@ export interface ListWorktreesOpts {
811
940
  * @default 7
812
941
  */
813
942
  staleDays?: number;
943
+ /** Whether merged ignored build output may be regenerated (default: true for legacy listing). */
944
+ exemptRegenerable?: boolean;
814
945
  }
815
946
 
816
947
  /**
@@ -1098,3 +1229,69 @@ export interface AdoptWorktreeResult {
1098
1229
  */
1099
1230
  projectInfo: 'seeded' | 'present' | 'skipped';
1100
1231
  }
1232
+
1233
+ /**
1234
+ * Options for `cleanupMergedWork` (T14142): remove what merged work left
1235
+ * behind, after proving each item redundant.
1236
+ *
1237
+ * @task T14142
1238
+ */
1239
+ export interface MergedCleanupOpts {
1240
+ /** Project root (the main checkout; its hash names the canonical worktree root). */
1241
+ projectRoot: string;
1242
+ /**
1243
+ * Tasks whose work merged (the sweep's merged PR, or a release's tasks).
1244
+ * Either way a task is in scope only while stored `done` or `cancelled`:
1245
+ * an open task (more PRs to come) keeps its worktree and branches.
1246
+ */
1247
+ taskIds?: readonly string[];
1248
+ /** List everything without deleting. Default `true`: deleting is opt-in. */
1249
+ dryRun?: boolean;
1250
+ /** Also delete merged task branches on `origin`. Default `true`. */
1251
+ remote?: boolean;
1252
+ }
1253
+
1254
+ /**
1255
+ * One item the cleanup considered: removed (or, on a dry run, removable), or
1256
+ * kept with the reason.
1257
+ *
1258
+ * @task T14142
1259
+ */
1260
+ export interface MergedCleanupItem {
1261
+ /** Worktree or nested-copy path, or branch name. */
1262
+ target: string;
1263
+ /** Owning task, when the target names one. */
1264
+ taskId: string | null;
1265
+ /** Branch tip (branches only): what a restore pushes back. */
1266
+ sha?: string;
1267
+ /** True when removed (dry run: when it would be removed). */
1268
+ removed: boolean;
1269
+ /** Why it was kept, or what proved it redundant. */
1270
+ reason: string;
1271
+ /** Bytes on disk (worktrees and nested copies; 0 for branches). */
1272
+ bytes: number;
1273
+ }
1274
+
1275
+ /**
1276
+ * Result of `cleanupMergedWork` (T14142).
1277
+ *
1278
+ * @task T14142
1279
+ */
1280
+ export interface MergedCleanupResult {
1281
+ /** Whether nothing was deleted. */
1282
+ dryRun: boolean;
1283
+ /** The default branch merges were proven against (`origin/<name>`). */
1284
+ base: string;
1285
+ /** Canonical task worktrees. */
1286
+ worktrees: MergedCleanupItem[];
1287
+ /** Local `task/*` branches. */
1288
+ localBranches: MergedCleanupItem[];
1289
+ /** `origin` `task/*` branches. */
1290
+ remoteBranches: MergedCleanupItem[];
1291
+ /** Repository copies nested inside worktrees. */
1292
+ nestedCopies: MergedCleanupItem[];
1293
+ /** Bytes removed (dry run: that would be removed). */
1294
+ bytesReclaimed: number;
1295
+ /** Why nothing was considered (the fetch failed, no base branch); absent when it ran. */
1296
+ skippedReason?: string;
1297
+ }