@astrosheep/keiyaku 4.5.28 → 4.6.1

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 (425) hide show
  1. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +0 -13
  2. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +47 -78
  3. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/references/automation.md +54 -41
  4. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-babysit/SKILL.md +10 -0
  5. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +27 -9
  6. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +68 -71
  7. package/build/src/akuma/akuma-call.d.ts +53 -0
  8. package/build/src/akuma/akuma-call.js +113 -0
  9. package/build/src/akuma/akuma-instance.d.ts +20 -19
  10. package/build/src/akuma/akuma-instance.js +65 -177
  11. package/build/src/akuma/akuma-observe.d.ts +3 -21
  12. package/build/src/akuma/akuma-observe.js +7 -25
  13. package/build/src/akuma/{akuma-handle.d.ts → akuma-owner.d.ts} +60 -25
  14. package/build/src/akuma/{akuma-handle.js → akuma-owner.js} +43 -29
  15. package/build/src/akuma/akuma-selection-execution.d.ts +51 -0
  16. package/build/src/akuma/akuma-selection-execution.js +134 -0
  17. package/build/src/akuma/{fleet-execution.d.ts → akuma-wait.d.ts} +24 -32
  18. package/build/src/akuma/akuma-wait.js +113 -0
  19. package/build/src/akuma/akuma.d.ts +35 -97
  20. package/build/src/akuma/akuma.js +148 -35
  21. package/build/src/akuma/archetype.d.ts +18 -6
  22. package/build/src/akuma/archetype.js +52 -34
  23. package/build/src/akuma/body.d.ts +79 -61
  24. package/build/src/akuma/body.js +101 -50
  25. package/build/src/akuma/call-initial-tell.d.ts +164 -0
  26. package/build/src/akuma/call-initial-tell.js +62 -0
  27. package/build/src/akuma/call-input.d.ts +0 -3
  28. package/build/src/akuma/call-input.js +0 -7
  29. package/build/src/akuma/call-request.d.ts +247 -38
  30. package/build/src/akuma/call-request.js +77 -92
  31. package/build/src/akuma/coordinate.d.ts +15 -5
  32. package/build/src/akuma/coordinate.js +12 -22
  33. package/build/src/akuma/dispatch-association.d.ts +1 -1
  34. package/build/src/akuma/dispatch-association.js +1 -10
  35. package/build/src/akuma/heart/activity-schema.d.ts +325 -0
  36. package/build/src/akuma/heart/activity-schema.js +53 -0
  37. package/build/src/akuma/heart/facts.d.ts +3 -9
  38. package/build/src/akuma/heart/index.d.ts +3 -1
  39. package/build/src/akuma/heart/index.js +4 -1
  40. package/build/src/akuma/heart/rows.d.ts +49 -2
  41. package/build/src/akuma/heart/rows.js +16 -2
  42. package/build/src/akuma/heart/soul.d.ts +1 -0
  43. package/build/src/akuma/heart/soul.js +7 -10
  44. package/build/src/akuma/heart/tells.d.ts +1 -0
  45. package/build/src/akuma/heart/tells.js +18 -0
  46. package/build/src/akuma/identity.d.ts +10 -7
  47. package/build/src/akuma/identity.js +23 -0
  48. package/build/src/akuma/index.d.ts +10 -8
  49. package/build/src/akuma/index.js +2 -2
  50. package/build/src/akuma/nuke.d.ts +3 -0
  51. package/build/src/akuma/nuke.js +13 -7
  52. package/build/src/akuma/projection-read.js +1 -2
  53. package/build/src/akuma/projection.d.ts +0 -5
  54. package/build/src/akuma/projection.js +22 -43
  55. package/build/src/akuma/provider-recipe.d.ts +58 -23
  56. package/build/src/akuma/provider-recipe.js +62 -103
  57. package/build/src/akuma/provider.d.ts +7 -78
  58. package/build/src/akuma/provider.js +11 -219
  59. package/build/src/akuma/providers/acp/config.d.ts +2 -0
  60. package/build/src/akuma/providers/acp/config.js +26 -1
  61. package/build/src/akuma/providers/acp/core.d.ts +7 -0
  62. package/build/src/akuma/providers/acp/core.js +49 -18
  63. package/build/src/akuma/providers/acp/index.js +14 -17
  64. package/build/src/akuma/providers/claude/index.js +2 -14
  65. package/build/src/akuma/providers/codex-app-server/index.js +0 -22
  66. package/build/src/akuma/providers/grok-build/index.js +44 -24
  67. package/build/src/akuma/providers/index.d.ts +3 -3
  68. package/build/src/akuma/providers/index.js +2 -13
  69. package/build/src/akuma/providers/opencode-sdk/event-stream.d.ts +28 -0
  70. package/build/src/akuma/providers/opencode-sdk/event-stream.js +92 -0
  71. package/build/src/akuma/providers/opencode-sdk/events.d.ts +0 -1
  72. package/build/src/akuma/providers/opencode-sdk/index.js +200 -74
  73. package/build/src/akuma/providers/opencode-sdk/session.d.ts +41 -1
  74. package/build/src/akuma/providers/opencode-sdk/session.js +69 -2
  75. package/build/src/akuma/providers/pi/events.js +5 -2
  76. package/build/src/akuma/providers/pi/index.js +70 -24
  77. package/build/src/akuma/publication.d.ts +84 -3
  78. package/build/src/akuma/publication.js +145 -2
  79. package/build/src/akuma/read-pool.d.ts +2 -0
  80. package/build/src/akuma/read-pool.js +15 -0
  81. package/build/src/akuma/request-rendezvous.js +10 -0
  82. package/build/src/akuma/request-serve.js +7 -0
  83. package/build/src/akuma/request-wire.d.ts +14 -26
  84. package/build/src/akuma/request-wire.js +4 -0
  85. package/build/src/akuma/requests.d.ts +0 -3
  86. package/build/src/akuma/requests.js +0 -24
  87. package/build/src/akuma/{fleet-observation.d.ts → selection-observation.d.ts} +61 -52
  88. package/build/src/akuma/selection-observation.js +65 -0
  89. package/build/src/akuma/{fleet-owner-port.d.ts → selection-owner-port.d.ts} +3 -3
  90. package/build/src/akuma/{fleet-owner-port.js → selection-owner-port.js} +11 -17
  91. package/build/src/akuma/{fleet-request.d.ts → selection-request.d.ts} +42 -82
  92. package/build/src/akuma/{fleet-request.js → selection-request.js} +92 -136
  93. package/build/src/akuma/turn-drive.d.ts +3 -0
  94. package/build/src/akuma/turn-drive.js +75 -16
  95. package/build/src/akuma-body.js +91 -56
  96. package/build/src/body/amend.d.ts +5 -0
  97. package/build/src/body/amend.js +26 -50
  98. package/build/src/body/arc.d.ts +4 -2
  99. package/build/src/body/arc.js +19 -26
  100. package/build/src/body/criteria.d.ts +6 -0
  101. package/build/src/body/criteria.js +37 -0
  102. package/build/src/body/decode.js +5 -42
  103. package/build/src/body/region.d.ts +5 -0
  104. package/build/src/body/region.js +45 -2
  105. package/build/src/body/render.js +2 -4
  106. package/build/src/cli/activity.d.ts +26 -0
  107. package/build/src/cli/activity.js +75 -0
  108. package/build/src/cli/actor.d.ts +3 -1
  109. package/build/src/cli/actor.js +15 -2
  110. package/build/src/cli/commands/akuma-grammar.d.ts +75 -0
  111. package/build/src/cli/commands/akuma-grammar.js +414 -0
  112. package/build/src/cli/commands/akuma.d.ts +5 -69
  113. package/build/src/cli/commands/akuma.js +352 -312
  114. package/build/src/cli/commands/amend.d.ts +4 -5
  115. package/build/src/cli/commands/amend.js +1 -2
  116. package/build/src/cli/commands/bind.d.ts +4 -5
  117. package/build/src/cli/commands/bind.js +5 -9
  118. package/build/src/cli/commands/contract-grammar.d.ts +112 -0
  119. package/build/src/cli/commands/contract-grammar.js +282 -0
  120. package/build/src/cli/commands/contract-help.d.ts +28 -30
  121. package/build/src/cli/commands/contract-help.js +69 -96
  122. package/build/src/cli/commands/contract.d.ts +18 -97
  123. package/build/src/cli/commands/contract.js +620 -237
  124. package/build/src/cli/commands/install.d.ts +1 -1
  125. package/build/src/cli/commands/install.js +2 -2
  126. package/build/src/cli/commands/task-grammar.d.ts +19 -0
  127. package/build/src/cli/commands/task-grammar.js +438 -0
  128. package/build/src/cli/commands/task-query.js +23 -104
  129. package/build/src/cli/commands/task.d.ts +5 -20
  130. package/build/src/cli/commands/task.js +415 -333
  131. package/build/src/cli/coordinates.d.ts +10 -0
  132. package/build/src/cli/coordinates.js +20 -0
  133. package/build/src/cli/draft.d.ts +7 -1
  134. package/build/src/cli/main.js +10 -1
  135. package/build/src/cli/parse.d.ts +8 -9
  136. package/build/src/cli/parse.js +63 -61
  137. package/build/src/cli/render/akuma-activity.d.ts +88 -39
  138. package/build/src/cli/render/akuma-activity.js +465 -263
  139. package/build/src/cli/render/akuma-tool.d.ts +15 -5
  140. package/build/src/cli/render/akuma-tool.js +40 -27
  141. package/build/src/cli/render/akuma.d.ts +40 -24
  142. package/build/src/cli/render/akuma.js +108 -205
  143. package/build/src/cli/render/audit.d.ts +6 -2
  144. package/build/src/cli/render/audit.js +61 -30
  145. package/build/src/cli/render/catalog.d.ts +11 -2
  146. package/build/src/cli/render/catalog.js +75 -94
  147. package/build/src/cli/render/contract-history.d.ts +3 -1
  148. package/build/src/cli/render/contract-history.js +215 -22
  149. package/build/src/cli/render/contract-observation.d.ts +10 -5
  150. package/build/src/cli/render/contract-observation.js +29 -46
  151. package/build/src/cli/render/contract.d.ts +10 -3
  152. package/build/src/cli/render/contract.js +255 -106
  153. package/build/src/cli/render/effects.d.ts +26 -0
  154. package/build/src/cli/render/effects.js +41 -0
  155. package/build/src/cli/render/execution-progress.d.ts +18 -6
  156. package/build/src/cli/render/execution-progress.js +34 -31
  157. package/build/src/cli/render/kanshi-akuma.d.ts +1 -2
  158. package/build/src/cli/render/kanshi-akuma.js +5 -26
  159. package/build/src/cli/render/kanshi.js +108 -129
  160. package/build/src/cli/render/marks.d.ts +13 -0
  161. package/build/src/cli/render/marks.js +74 -0
  162. package/build/src/cli/render/nuke.js +18 -7
  163. package/build/src/cli/render/receipt.d.ts +10 -4
  164. package/build/src/cli/render/receipt.js +126 -46
  165. package/build/src/cli/render/reconcile.d.ts +5 -0
  166. package/build/src/cli/render/reconcile.js +152 -0
  167. package/build/src/cli/render/refusal.d.ts +21 -4
  168. package/build/src/cli/render/refusal.js +61 -34
  169. package/build/src/cli/render/region.js +3 -2
  170. package/build/src/cli/render/settings.js +4 -14
  171. package/build/src/cli/render/task.d.ts +37 -6
  172. package/build/src/cli/render/task.js +162 -158
  173. package/build/src/cli/render/terminal.d.ts +25 -1
  174. package/build/src/cli/render/terminal.js +105 -18
  175. package/build/src/cli/runtime.d.ts +32 -8
  176. package/build/src/cli/runtime.js +161 -163
  177. package/build/src/cli/selectors.d.ts +5 -2
  178. package/build/src/cli/selectors.js +11 -3
  179. package/build/src/cli/streams.d.ts +11 -0
  180. package/build/src/cli/streams.js +32 -0
  181. package/build/src/cli/usage.d.ts +2 -0
  182. package/build/src/cli/usage.js +12 -8
  183. package/build/src/contract-guidance.js +3 -7
  184. package/build/src/contract-worktree.d.ts +20 -28
  185. package/build/src/contract-worktree.js +18 -70
  186. package/build/src/coordination/durable-file.d.ts +2 -2
  187. package/build/src/coordination/durable-file.js +0 -27
  188. package/build/src/core/facts/codec.d.ts +1 -2
  189. package/build/src/core/facts/codec.js +6 -7
  190. package/build/src/core/facts/gate.d.ts +0 -1
  191. package/build/src/core/facts/gate.js +0 -82
  192. package/build/src/core/facts/types.d.ts +1 -2
  193. package/build/src/core/verbs/abandon.d.ts +2 -6
  194. package/build/src/core/verbs/abandon.js +0 -16
  195. package/build/src/core/verbs/amend.d.ts +0 -1
  196. package/build/src/core/verbs/amend.js +0 -20
  197. package/build/src/core/verbs/arc.d.ts +7 -8
  198. package/build/src/core/verbs/arc.js +2 -19
  199. package/build/src/core/verbs/attestation.d.ts +2 -6
  200. package/build/src/core/verbs/attestation.js +0 -16
  201. package/build/src/core/verbs/bind.d.ts +0 -1
  202. package/build/src/core/verbs/bind.js +0 -16
  203. package/build/src/core/verbs/deliver.d.ts +0 -1
  204. package/build/src/core/verbs/deliver.js +0 -16
  205. package/build/src/core/verbs/placement.d.ts +2 -1
  206. package/build/src/core/verbs/placement.js +10 -59
  207. package/build/src/git/admission.d.ts +6 -4
  208. package/build/src/git/admission.js +4 -0
  209. package/build/src/git/hooks.d.ts +55 -30
  210. package/build/src/git/hooks.js +30 -3
  211. package/build/src/git/identity.d.ts +6 -0
  212. package/build/src/git/identity.js +47 -0
  213. package/build/src/git/integration.d.ts +31 -13
  214. package/build/src/git/integration.js +32 -1
  215. package/build/src/git/nuke.d.ts +10 -1
  216. package/build/src/git/nuke.js +31 -11
  217. package/build/src/git/observe.js +2 -15
  218. package/build/src/git/private-state-seat.d.ts +6 -7
  219. package/build/src/git/private-state-seat.js +8 -6
  220. package/build/src/git/read-observation.d.ts +6 -1
  221. package/build/src/git/read-observation.js +81 -46
  222. package/build/src/git/reconcile.d.ts +117 -40
  223. package/build/src/git/reconcile.js +169 -40
  224. package/build/src/git/scratch.d.ts +7 -4
  225. package/build/src/git/scratch.js +28 -6
  226. package/build/src/git/target-placement.d.ts +53 -38
  227. package/build/src/git/target-placement.js +69 -54
  228. package/build/src/git/tender.d.ts +37 -28
  229. package/build/src/git/tender.js +39 -0
  230. package/build/src/git/terminal-reconcile.js +21 -23
  231. package/build/src/git/terminal-seal.d.ts +8 -6
  232. package/build/src/git/terminal-seal.js +10 -0
  233. package/build/src/git/workspace.d.ts +29 -15
  234. package/build/src/git/workspace.js +28 -2
  235. package/build/src/identity/normalize.js +19 -6
  236. package/build/src/index.d.ts +78 -6
  237. package/build/src/index.js +52 -3
  238. package/build/src/kanshi/read.d.ts +3 -3
  239. package/build/src/kanshi/read.js +21 -21
  240. package/build/src/kanshi/report.d.ts +9 -8
  241. package/build/src/kanshi/roster.d.ts +2 -0
  242. package/build/src/kanshi/roster.js +2 -0
  243. package/build/src/kanshi/select.js +7 -3
  244. package/build/src/library/address.d.ts +3 -7
  245. package/build/src/library/address.js +7 -7
  246. package/build/src/library/akuma-creation.d.ts +35 -33
  247. package/build/src/library/akuma-creation.js +184 -167
  248. package/build/src/library/akumas.d.ts +40 -0
  249. package/build/src/library/akumas.js +84 -0
  250. package/build/src/library/bind.d.ts +107 -13
  251. package/build/src/library/bind.js +29 -23
  252. package/build/src/library/continuation.d.ts +556 -28
  253. package/build/src/library/continuation.js +29 -54
  254. package/build/src/library/contract-composition.d.ts +40 -0
  255. package/build/src/library/contract-composition.js +105 -0
  256. package/build/src/library/contract-creation.d.ts +7 -0
  257. package/build/src/library/contract-creation.js +192 -0
  258. package/build/src/library/contract-execution.d.ts +29 -40
  259. package/build/src/library/contract-execution.js +503 -128
  260. package/build/src/library/contract-operations.d.ts +275 -134
  261. package/build/src/library/contract-operations.js +83 -92
  262. package/build/src/library/contract-outcomes.d.ts +71 -0
  263. package/build/src/library/contract-outcomes.js +32 -0
  264. package/build/src/library/contract-settings.d.ts +25 -0
  265. package/build/src/library/contract-settings.js +135 -0
  266. package/build/src/library/contract-types.d.ts +24 -38
  267. package/build/src/library/delivery.d.ts +530 -10
  268. package/build/src/library/delivery.js +20 -45
  269. package/build/src/library/input.d.ts +3 -1
  270. package/build/src/library/input.js +11 -16
  271. package/build/src/library/invocation.d.ts +87 -0
  272. package/build/src/library/invocation.js +290 -0
  273. package/build/src/library/keiyaku.d.ts +44 -437
  274. package/build/src/library/keiyaku.js +132 -20
  275. package/build/src/library/nuke.d.ts +2 -11
  276. package/build/src/library/nuke.js +70 -57
  277. package/build/src/library/outcome.d.ts +13196 -0
  278. package/build/src/library/outcome.js +487 -0
  279. package/build/src/library/reconcile.d.ts +96 -24
  280. package/build/src/library/reconcile.js +102 -42
  281. package/build/src/library/refusal.d.ts +470 -42
  282. package/build/src/library/refusal.js +55 -143
  283. package/build/src/library/region.d.ts +15 -7
  284. package/build/src/library/region.js +23 -3
  285. package/build/src/library/repo.d.ts +2 -12
  286. package/build/src/library/repo.js +1 -22
  287. package/build/src/library/selection.d.ts +121 -0
  288. package/build/src/library/{fleet.js → selection.js} +177 -160
  289. package/build/src/plugin/public.d.ts +2 -0
  290. package/build/src/protocol/abandon.d.ts +2 -2
  291. package/build/src/protocol/abandon.js +1 -0
  292. package/build/src/protocol/amend.js +1 -0
  293. package/build/src/protocol/arc.d.ts +6 -4
  294. package/build/src/protocol/attempt.d.ts +4 -2
  295. package/build/src/protocol/attempt.js +10 -0
  296. package/build/src/protocol/audit.d.ts +255 -52
  297. package/build/src/protocol/audit.js +63 -5
  298. package/build/src/protocol/bind.d.ts +18 -17
  299. package/build/src/protocol/bind.js +9 -28
  300. package/build/src/protocol/completion.d.ts +256 -22
  301. package/build/src/protocol/completion.js +100 -12
  302. package/build/src/protocol/deliver.d.ts +34 -23
  303. package/build/src/protocol/deliver.js +39 -25
  304. package/build/src/protocol/execution-observation.d.ts +36 -37
  305. package/build/src/protocol/execution-observation.js +7 -9
  306. package/build/src/protocol/intent.d.ts +101 -30
  307. package/build/src/protocol/intent.js +74 -1
  308. package/build/src/protocol/operations.d.ts +570 -64
  309. package/build/src/protocol/operations.js +189 -9
  310. package/build/src/protocol/outcome.d.ts +2 -1
  311. package/build/src/protocol/placement.d.ts +2 -2
  312. package/build/src/protocol/placement.js +3 -1
  313. package/build/src/protocol/progress.d.ts +108 -65
  314. package/build/src/protocol/progress.js +82 -132
  315. package/build/src/protocol/read/status.d.ts +4 -3
  316. package/build/src/protocol/read/status.js +6 -5
  317. package/build/src/protocol/reconcile.d.ts +3 -3
  318. package/build/src/protocol/reconcile.js +4 -0
  319. package/build/src/protocol/reintegrate.d.ts +2 -2
  320. package/build/src/protocol/review.d.ts +30 -12
  321. package/build/src/protocol/review.js +15 -24
  322. package/build/src/protocol/run.d.ts +34 -5
  323. package/build/src/protocol/run.js +24 -12
  324. package/build/src/runtime/proc/windows-launch.exe +0 -0
  325. package/build/src/settings.d.ts +0 -10
  326. package/build/src/settings.js +0 -76
  327. package/build/src/settlement/holder.d.ts +1 -1
  328. package/build/src/settlement/settle.d.ts +25 -16
  329. package/build/src/settlement/settle.js +80 -20
  330. package/build/src/task/board.d.ts +3 -1
  331. package/build/src/task/board.js +13 -17
  332. package/build/src/task/catalog.d.ts +0 -4
  333. package/build/src/task/catalog.js +0 -15
  334. package/build/src/task/compose-language.d.ts +19 -9
  335. package/build/src/task/compose-language.js +30 -20
  336. package/build/src/task/compose.d.ts +7 -37
  337. package/build/src/task/compose.js +20 -2
  338. package/build/src/task/created-observation.d.ts +0 -1
  339. package/build/src/task/created-observation.js +1 -4
  340. package/build/src/task/document.d.ts +12 -2
  341. package/build/src/task/document.js +4 -0
  342. package/build/src/task/identity.d.ts +4 -1
  343. package/build/src/task/identity.js +21 -17
  344. package/build/src/task/index.d.ts +36 -16
  345. package/build/src/task/index.js +103 -96
  346. package/build/src/task/lifecycle-operations.d.ts +1 -1
  347. package/build/src/task/mutation-result.d.ts +647 -586
  348. package/build/src/task/mutation-result.js +79 -46
  349. package/build/src/task/mutation.d.ts +298 -270
  350. package/build/src/task/mutation.js +93 -110
  351. package/build/src/task/operation-types.d.ts +6 -49
  352. package/build/src/task/operations.d.ts +2 -1
  353. package/build/src/task/operations.js +35 -12
  354. package/build/src/task/query.d.ts +9 -3
  355. package/build/src/task/query.js +42 -16
  356. package/build/src/task/store.d.ts +2 -1
  357. package/build/src/task/store.js +10 -14
  358. package/build/src/verification/declaration.d.ts +0 -1
  359. package/build/src/verification/declaration.js +1 -18
  360. package/build/src/verification/execution.d.ts +6 -2
  361. package/build/src/verification/observation.d.ts +1 -1
  362. package/package.json +2 -14
  363. package/build/src/akuma/akuma-product-symbols.d.ts +0 -1
  364. package/build/src/akuma/akuma-product-symbols.js +0 -1
  365. package/build/src/akuma/akuma-product.d.ts +0 -62
  366. package/build/src/akuma/akuma-product.js +0 -293
  367. package/build/src/akuma/fleet-execution.js +0 -181
  368. package/build/src/akuma/fleet-observation.js +0 -91
  369. package/build/src/cli/accepted.d.ts +0 -24
  370. package/build/src/cli/accepted.js +0 -167
  371. package/build/src/cli/commands/akuma-invoke.d.ts +0 -114
  372. package/build/src/cli/commands/akuma-invoke.js +0 -402
  373. package/build/src/cli/commands/contract-invoke.d.ts +0 -34
  374. package/build/src/cli/commands/contract-invoke.js +0 -259
  375. package/build/src/cli/commands/nuke.d.ts +0 -10
  376. package/build/src/cli/commands/nuke.js +0 -20
  377. package/build/src/cli/commands/status-set.d.ts +0 -4
  378. package/build/src/cli/commands/status-set.js +0 -52
  379. package/build/src/cli/commands/task-invoke.d.ts +0 -49
  380. package/build/src/cli/commands/task-invoke.js +0 -306
  381. package/build/src/cli/invoke.d.ts +0 -27
  382. package/build/src/cli/invoke.js +0 -484
  383. package/build/src/cli/render/board.d.ts +0 -3
  384. package/build/src/cli/render/board.js +0 -25
  385. package/build/src/cli/render/status-set.d.ts +0 -5
  386. package/build/src/cli/render/status-set.js +0 -19
  387. package/build/src/cli/render/text.d.ts +0 -3
  388. package/build/src/cli/render/text.js +0 -33
  389. package/build/src/cli/result.d.ts +0 -240
  390. package/build/src/cli/result.js +0 -1
  391. package/build/src/git/result-codec.d.ts +0 -29
  392. package/build/src/git/result-codec.js +0 -309
  393. package/build/src/kanshi/fleet.d.ts +0 -6
  394. package/build/src/kanshi/fleet.js +0 -27
  395. package/build/src/library/audit.d.ts +0 -29
  396. package/build/src/library/audit.js +0 -41
  397. package/build/src/library/catalog.d.ts +0 -68
  398. package/build/src/library/catalog.js +0 -130
  399. package/build/src/library/composition.d.ts +0 -403
  400. package/build/src/library/composition.js +0 -29
  401. package/build/src/library/configuration.d.ts +0 -4
  402. package/build/src/library/configuration.js +0 -2
  403. package/build/src/library/contract-bind.d.ts +0 -31
  404. package/build/src/library/contract-bind.js +0 -140
  405. package/build/src/library/contract-forwarding.d.ts +0 -55
  406. package/build/src/library/contract-forwarding.js +0 -67
  407. package/build/src/library/contract-handle.d.ts +0 -45
  408. package/build/src/library/contract-handle.js +0 -373
  409. package/build/src/library/contract.d.ts +0 -53
  410. package/build/src/library/contract.js +0 -91
  411. package/build/src/library/execution-result.d.ts +0 -243
  412. package/build/src/library/execution-result.js +0 -101
  413. package/build/src/library/execution.d.ts +0 -8
  414. package/build/src/library/execution.js +0 -102
  415. package/build/src/library/fleet.d.ts +0 -83
  416. package/build/src/library/mutation.d.ts +0 -501
  417. package/build/src/library/mutation.js +0 -248
  418. package/build/src/library/result-codec.d.ts +0 -2
  419. package/build/src/library/result-codec.js +0 -12
  420. package/build/src/protocol/result-codec.d.ts +0 -23
  421. package/build/src/protocol/result-codec.js +0 -488
  422. package/build/src/settlement/result-codec.d.ts +0 -2
  423. package/build/src/settlement/result-codec.js +0 -56
  424. package/build/src/task/public.d.ts +0 -2
  425. package/build/src/task/public.js +0 -1
@@ -0,0 +1,487 @@
1
+ /** @architectureCompositionRoot */
2
+ import { z } from "zod";
3
+ import { contractFileEffectSchema } from "../contract-worktree.js";
4
+ import { decodeJournalEntry } from "../core/facts/codec.js";
5
+ import { AuthorityCorruptionError } from "../core/facts/errors.js";
6
+ import { contractHeadSchema } from "../git/identity.js";
7
+ import { reconcileEffectSchema } from "../git/reconcile.js";
8
+ import { worktreeWorkspaceSchema } from "../git/workspace.js";
9
+ import { auditReportSchema } from "../protocol/audit.js";
10
+ import { completionEvidenceSchema } from "../protocol/completion.js";
11
+ import { materializedConflictSchema } from "../protocol/deliver.js";
12
+ import { contractIdSchema, deliverDataSchema, gateSchema } from "../protocol/operations.js";
13
+ import { executionCleanupSchema, executionStageSchema } from "../protocol/progress.js";
14
+ import { reviewAdmissionValueSchema } from "../protocol/review.js";
15
+ import { settlementActionSchema, settlementLagSchema } from "../settlement/settle.js";
16
+ import { continuationReportSchema } from "./continuation.js";
17
+ import { deliveryValueSchema } from "./delivery.js";
18
+ import { reconcileLagScope, reconciliationLagSchema } from "./reconcile.js";
19
+ import { nukeConfirmationRefusalSchema, nukeConfirmationRequiredRefusalSchema, operationRefusalSchemas, operationRetrySchemas, } from "./refusal.js";
20
+ import { regionOverlapSchema } from "./region.js";
21
+ // ---------------------------------------------------------------------------
22
+ // One invocation-wide tagged Effect carrier
23
+ // ---------------------------------------------------------------------------
24
+ const reconciliationEffectSchema = z.union([reconcileEffectSchema, contractFileEffectSchema]);
25
+ const resetOwnerSchema = z.enum(["akuma", "git", "task", "world"]);
26
+ const resetEffectFields = { world: z.string().min(1), owner: resetOwnerSchema, diagnostic: z.string().min(1) };
27
+ const resetEffectSchema = z.union([
28
+ z.object({ kind: z.literal("reset-owner-stopped"), ...resetEffectFields }).strict(),
29
+ z.object({ kind: z.literal("reset-residue"), ...resetEffectFields }).strict(),
30
+ ]);
31
+ const contractEffectSchema = z.union([
32
+ z
33
+ .object({
34
+ kind: z.literal("reconciliation-effect"),
35
+ contract: contractIdSchema,
36
+ effect: reconciliationEffectSchema,
37
+ })
38
+ .strict(),
39
+ z
40
+ .object({
41
+ kind: z.literal("reconciliation-lag"),
42
+ contract: contractIdSchema,
43
+ affects: z.enum(["none", "reconciliation", "placement", "continuation"]),
44
+ lag: reconciliationLagSchema,
45
+ })
46
+ .strict()
47
+ .refine((value) => value.affects === reconcileLagScope(value.lag), "invalid reconciliation requiredness"),
48
+ z
49
+ .object({
50
+ kind: z.literal("checkout-retained"),
51
+ contract: contractIdSchema,
52
+ path: z.string().min(1),
53
+ target: z.string().min(1),
54
+ diagnostic: z.string().min(1),
55
+ })
56
+ .strict(),
57
+ z
58
+ .object({ kind: z.literal("settlement-action"), contract: contractIdSchema, action: settlementActionSchema })
59
+ .strict(),
60
+ z.object({ kind: z.literal("settlement-lag"), contract: contractIdSchema, lag: settlementLagSchema }).strict(),
61
+ z
62
+ .object({ kind: z.literal("cleanup"), contract: contractIdSchema, issue: executionCleanupSchema })
63
+ .strict()
64
+ .refine((value) => value.contract === value.issue.contractId, "invalid cleanup owner"),
65
+ z
66
+ .object({
67
+ kind: z.literal("execution-stopped"),
68
+ contract: contractIdSchema,
69
+ stage: executionStageSchema,
70
+ reason: z.enum(["cancelled", "failed"]),
71
+ diagnostic: z.string().refine((value) => value.trim() !== ""),
72
+ })
73
+ .strict(),
74
+ z.object({ kind: z.literal("worktree-retired"), contract: contractIdSchema, name: z.string().min(1) }).strict(),
75
+ z.object({ kind: z.literal("worktree-retained"), contract: contractIdSchema, path: z.string().min(1) }).strict(),
76
+ ]);
77
+ const invocationEffectSchema = z.union([contractEffectSchema, resetEffectSchema]);
78
+ const pendingActionSchema = z.enum([
79
+ "reset",
80
+ "verification",
81
+ "placement",
82
+ "continuation",
83
+ "reconciliation",
84
+ "settlement",
85
+ "cleanup",
86
+ "execution",
87
+ ]);
88
+ const pendingSurfaceSchema = z.object({ surface: pendingActionSchema, required: z.boolean() }).strict();
89
+ function surface(surface, required) {
90
+ return { surface, required };
91
+ }
92
+ function phasePending(operation, value) {
93
+ if (operation === "audit") {
94
+ const report = value;
95
+ return report?.verification?.kind === "stopped" ? [surface("verification", true)] : [];
96
+ }
97
+ if (operation !== "review" && operation !== "deliver")
98
+ return [];
99
+ const concluded = value;
100
+ if (concluded === undefined)
101
+ return [];
102
+ const pending = [];
103
+ if (concluded.verification !== undefined)
104
+ pending.push(surface("verification", true));
105
+ if (concluded.placement !== undefined)
106
+ pending.push(surface("placement", true));
107
+ if (concluded.continuation !== undefined && concluded.continuation.stopped.length > 0)
108
+ pending.push(surface("continuation", true));
109
+ return pending;
110
+ }
111
+ function stopSurface(stage) {
112
+ return stage === "admission" ? "execution" : stage === "reintegration" ? "placement" : stage;
113
+ }
114
+ function effectPending(effects) {
115
+ const pending = [];
116
+ for (const effect of effects) {
117
+ if (effect.kind === "reconciliation-lag") {
118
+ if (effect.affects !== "none")
119
+ pending.push(surface(effect.affects, true));
120
+ }
121
+ else if (effect.kind === "checkout-retained")
122
+ pending.push(surface("placement", true));
123
+ else if (effect.kind === "settlement-lag")
124
+ pending.push(surface("settlement", true));
125
+ else if (effect.kind === "cleanup")
126
+ pending.push(surface("cleanup", false));
127
+ else if (effect.kind === "execution-stopped")
128
+ pending.push(surface(stopSurface(effect.stage), true));
129
+ else if (effect.kind === "reset-owner-stopped")
130
+ pending.push(surface("reset", true));
131
+ else if (effect.kind === "reset-residue")
132
+ pending.push(surface("reset", false));
133
+ }
134
+ return pending;
135
+ }
136
+ /**
137
+ * Pending is computed here and nowhere else, from the operation's conclusions and the invocation's
138
+ * effects. It is never taken from a transported summary.
139
+ */
140
+ function projectPending(operation, value, effects) {
141
+ const merged = new Map();
142
+ for (const entry of [...phasePending(operation, value), ...effectPending(effects)])
143
+ merged.set(entry.surface, entry.required || merged.get(entry.surface) === true);
144
+ return [...merged].map(([name, required]) => ({ surface: name, required }));
145
+ }
146
+ function envelopeOf(operation, snapshot, contract, value) {
147
+ return {
148
+ fields: {
149
+ ...(contract === undefined ? {} : { contract }),
150
+ facts: snapshot.facts,
151
+ effects: snapshot.effects.filter((effect) => effect.kind !== "reset-owner-stopped" && effect.kind !== "reset-residue"),
152
+ },
153
+ pending: projectPending(operation, value, snapshot.effects),
154
+ };
155
+ }
156
+ export function project(operation, snapshot, projection) {
157
+ if ("world" in projection) {
158
+ if (operation !== "nuke")
159
+ throw new Error("reset projection requires nuke");
160
+ const effects = snapshot.effects.filter((effect) => effect.kind === "reset-owner-stopped" || effect.kind === "reset-residue");
161
+ const value = { removed: snapshot.reset?.removed ?? { refs: 0, worktrees: 0, tasks: 0 } };
162
+ const base = { operation, world: projection.world, effects, pending: projectPending(operation, value, effects) };
163
+ if (projection.kind === "failed")
164
+ return {
165
+ kind: "failed",
166
+ error: withOutcomeReceipt(projection.error, { ...base, value }),
167
+ };
168
+ return {
169
+ kind: "returned",
170
+ outcome: projection.kind === "refused"
171
+ ? { ...base, kind: "refused", refusal: projection.refusal }
172
+ : { ...base, kind: "accepted", value },
173
+ };
174
+ }
175
+ if (operation === "nuke")
176
+ throw new Error("nuke requires a World projection");
177
+ const contract = projection.contract;
178
+ const value = projection.kind === "accepted" || projection.kind === "handoff"
179
+ ? projection.value
180
+ : contract === undefined
181
+ ? undefined
182
+ : snapshot.conclusions.get(contract);
183
+ const { fields, pending } = envelopeOf(operation, snapshot, contract, value);
184
+ const base = { operation, ...fields, pending };
185
+ switch (projection.kind) {
186
+ case "accepted":
187
+ return {
188
+ kind: "returned",
189
+ outcome: {
190
+ ...base,
191
+ kind: "accepted",
192
+ contract: projection.contract,
193
+ head: projection.head,
194
+ value: projection.value,
195
+ },
196
+ };
197
+ case "handoff":
198
+ return {
199
+ kind: "returned",
200
+ outcome: {
201
+ ...base,
202
+ kind: "handoff",
203
+ contract: projection.contract,
204
+ value: projection.value,
205
+ },
206
+ };
207
+ case "refused":
208
+ return { kind: "returned", outcome: { ...base, kind: "refused", refusal: projection.refusal } };
209
+ case "retry":
210
+ return { kind: "returned", outcome: { ...base, kind: "retry", reason: projection.reason } };
211
+ case "failed": {
212
+ const head = contract === undefined ? undefined : snapshot.heads.get(contract);
213
+ // This is trusted owner evidence, not wire input. A decoder must never mask the original failure.
214
+ const partial = {
215
+ operation,
216
+ ...fields,
217
+ pending,
218
+ ...(head === undefined ? {} : { head }),
219
+ ...(value === undefined ? {} : { value }),
220
+ };
221
+ return { kind: "failed", error: withOutcomeReceipt(projection.error, partial) };
222
+ }
223
+ }
224
+ }
225
+ /** The one exceptional failure: a category, the native original cause, and an optional same-envelope receipt. */
226
+ export class KeiyakuError extends Error {
227
+ category;
228
+ outcome;
229
+ constructor(category, message, options = {}) {
230
+ super(message);
231
+ this.name = "KeiyakuError";
232
+ this.category = category;
233
+ if (options.cause !== undefined)
234
+ this.cause = options.cause;
235
+ if (options.outcome !== undefined)
236
+ this.outcome = options.outcome;
237
+ }
238
+ }
239
+ /** One explicit caller-validation phase; its failures are invalid input with a native TypeError cause. */
240
+ export function validated(phase) {
241
+ try {
242
+ return phase();
243
+ }
244
+ catch (error) {
245
+ if (error instanceof KeiyakuError)
246
+ throw error;
247
+ const message = error instanceof Error ? error.message : String(error);
248
+ throw new KeiyakuError("invalid-input", message, {
249
+ cause: error instanceof TypeError ? error : new TypeError(message),
250
+ });
251
+ }
252
+ }
253
+ export function errorCategory(error) {
254
+ if (error instanceof AuthorityCorruptionError)
255
+ return "authority-corruption";
256
+ if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError"))
257
+ return "aborted";
258
+ return "internal";
259
+ }
260
+ function errorDiagnostic(error) {
261
+ return error instanceof Error ? error.message : String(error);
262
+ }
263
+ /** Attach this invocation's partial envelope without changing the error's own identity or category. */
264
+ export function withOutcomeReceipt(error, outcome) {
265
+ if (error instanceof KeiyakuError) {
266
+ const current = new KeiyakuError(error.category, error.message, { cause: error.cause, outcome });
267
+ for (const key of ["requestId", "action", "requestOutcome"]) {
268
+ const descriptor = Object.getOwnPropertyDescriptor(error, key);
269
+ if (descriptor !== undefined)
270
+ Object.defineProperty(current, key, { ...descriptor, enumerable: false });
271
+ }
272
+ return current;
273
+ }
274
+ return new KeiyakuError(errorCategory(error), errorDiagnostic(error), { cause: error, outcome });
275
+ }
276
+ // Public value composition: owned nested declarations, no local re-decoding.
277
+ export const reviewSchema = completionEvidenceSchema
278
+ .extend({
279
+ ...reviewAdmissionValueSchema.shape,
280
+ continuation: continuationReportSchema.optional(),
281
+ })
282
+ .strict();
283
+ const bindEvidenceSchema = z
284
+ .object({
285
+ keiyaku: z.object({ contract: contractIdSchema }).strict().optional(),
286
+ workspace: worktreeWorkspaceSchema.optional(),
287
+ warnings: z.array(z.string()).readonly().optional(),
288
+ overlaps: z.array(regionOverlapSchema).readonly().optional(),
289
+ overlapFailure: z.string().optional(),
290
+ })
291
+ .strict()
292
+ .refine((value) => value.overlaps === undefined || value.overlapFailure === undefined);
293
+ const amendEvidenceSchema = z
294
+ .object({
295
+ documentDiff: z.string().optional(),
296
+ changes: z
297
+ .object({
298
+ gates: z.array(gateSchema).readonly().optional(),
299
+ after: z.array(contractIdSchema).readonly().optional(),
300
+ })
301
+ .strict()
302
+ .optional(),
303
+ overlaps: z.array(regionOverlapSchema).readonly().optional(),
304
+ overlapFailure: z.string().optional(),
305
+ })
306
+ .strict()
307
+ .refine((value) => value.overlaps === undefined || value.overlapFailure === undefined);
308
+ const partialDeliverySchema = deliveryValueSchema.partial().superRefine((value, context) => {
309
+ const fields = deliverDataSchema.keyof().options;
310
+ const present = fields.filter((field) => value[field] !== undefined);
311
+ if (present.length !== 0 && present.length !== fields.length)
312
+ context.addIssue({ code: "custom", message: "delivery identity must be complete when present" });
313
+ });
314
+ const partialValueSchemas = {
315
+ bind: bindEvidenceSchema,
316
+ amend: amendEvidenceSchema,
317
+ deliver: partialDeliverySchema,
318
+ review: reviewSchema,
319
+ audit: auditReportSchema.partial(),
320
+ arc: z.object({}).strict(),
321
+ abandon: z.object({}).strict(),
322
+ };
323
+ const journalEntrySchema = z.unknown().transform((value, context) => {
324
+ try {
325
+ return decodeJournalEntry(value);
326
+ }
327
+ catch {
328
+ context.addIssue({ code: "custom", message: "invalid journal fact" });
329
+ return z.NEVER;
330
+ }
331
+ });
332
+ const envelopeFieldsSchema = z
333
+ .object({
334
+ operation: z.enum(["bind", "amend", "deliver", "review", "audit", "arc", "abandon"]),
335
+ contract: contractIdSchema.optional(),
336
+ facts: z.array(journalEntrySchema).readonly(),
337
+ effects: z.array(contractEffectSchema).readonly(),
338
+ pending: z.array(pendingSurfaceSchema).readonly(),
339
+ })
340
+ .strict();
341
+ function definedContract(value) {
342
+ const { contract, ...fields } = value;
343
+ return { ...fields, ...(contract === undefined ? {} : { contract }) };
344
+ }
345
+ function acceptedOutcomeSchema(operation, value) {
346
+ return envelopeFieldsSchema
347
+ .extend({
348
+ operation: z.literal(operation),
349
+ kind: z.literal("accepted"),
350
+ contract: contractIdSchema,
351
+ head: contractHeadSchema,
352
+ value,
353
+ })
354
+ .strict();
355
+ }
356
+ function refusedOutcomeSchema(operation, refusal) {
357
+ return envelopeFieldsSchema
358
+ .extend({ operation: z.literal(operation), kind: z.literal("refused"), refusal })
359
+ .strict()
360
+ .transform(definedContract);
361
+ }
362
+ function retryOutcomeSchema(operation) {
363
+ return envelopeFieldsSchema
364
+ .extend({
365
+ operation: z.literal(operation),
366
+ kind: z.literal("retry"),
367
+ reason: operationRetrySchemas[operation],
368
+ })
369
+ .strict()
370
+ .transform(definedContract);
371
+ }
372
+ const handoffOutcomeSchema = envelopeFieldsSchema
373
+ .extend({
374
+ operation: z.literal("deliver"),
375
+ kind: z.literal("handoff"),
376
+ contract: contractIdSchema,
377
+ value: materializedConflictSchema,
378
+ })
379
+ .strict();
380
+ /** Complete and exceptional modes use the same envelope and nested owner declarations. */
381
+ export function outcomeSchema(operation, value, handoff) {
382
+ const accepted = acceptedOutcomeSchema(operation, value);
383
+ const refused = refusedOutcomeSchema(operation, operationRefusalSchemas[operation]);
384
+ const retry = retryOutcomeSchema(operation);
385
+ const ordinary = z.union([accepted, refused, retry]);
386
+ return (handoff === undefined ? ordinary : z.union([ordinary, handoffOutcomeSchema.extend({ value: handoff }).strict()]));
387
+ }
388
+ function partialContractSchema(operation, value) {
389
+ return envelopeFieldsSchema
390
+ .extend({ operation: z.literal(operation), head: contractHeadSchema.optional(), value: value.optional() })
391
+ .strict();
392
+ }
393
+ const resetCountsSchema = z
394
+ .object({
395
+ refs: z.number().int().nonnegative(),
396
+ worktrees: z.number().int().nonnegative(),
397
+ tasks: z.number().int().nonnegative(),
398
+ })
399
+ .strict();
400
+ const resetValueSchema = z.object({ removed: resetCountsSchema }).strict();
401
+ const resetBaseSchema = z
402
+ .object({
403
+ operation: z.literal("nuke"),
404
+ world: z.string().min(1),
405
+ effects: z.array(resetEffectSchema).readonly(),
406
+ pending: z.array(pendingSurfaceSchema).readonly(),
407
+ })
408
+ .strict();
409
+ const resetOutcomeSchema = z.union([
410
+ resetBaseSchema.extend({ kind: z.literal("accepted"), value: resetValueSchema }).strict(),
411
+ resetBaseSchema
412
+ .extend({
413
+ kind: z.literal("refused"),
414
+ refusal: z.union([nukeConfirmationRefusalSchema, nukeConfirmationRequiredRefusalSchema]),
415
+ })
416
+ .strict(),
417
+ ]);
418
+ const partialContractEnvelopeSchema = z.union([
419
+ partialContractSchema("bind", partialValueSchemas.bind),
420
+ partialContractSchema("amend", partialValueSchemas.amend),
421
+ partialContractSchema("deliver", partialValueSchemas.deliver),
422
+ partialContractSchema("review", partialValueSchemas.review),
423
+ partialContractSchema("audit", partialValueSchemas.audit),
424
+ partialContractSchema("arc", partialValueSchemas.arc),
425
+ partialContractSchema("abandon", partialValueSchemas.abandon),
426
+ ]);
427
+ const partialOutcomeEnvelopeSchema = z.union([
428
+ partialContractEnvelopeSchema,
429
+ resetBaseSchema.extend({ value: resetValueSchema.optional() }).strict(),
430
+ ]);
431
+ // ---------------------------------------------------------------------------
432
+ // Wire failure: category, diagnostic, and the same-envelope receipt
433
+ // ---------------------------------------------------------------------------
434
+ const errorCategorySchema = z.enum(["invalid-input", "authority-corruption", "unknown-outcome", "aborted", "internal"]);
435
+ const failureWireSchema = z
436
+ .object({
437
+ kind: z.literal("failed"),
438
+ category: errorCategorySchema,
439
+ diagnostic: z.string(),
440
+ causeClass: z.string().optional(),
441
+ causeDiagnostic: z.string().optional(),
442
+ outcome: partialOutcomeEnvelopeSchema.optional(),
443
+ })
444
+ .strict()
445
+ .refine((value) => (value.causeClass === undefined) === (value.causeDiagnostic === undefined), "native cause requires class and diagnostic");
446
+ const NATIVE_CAUSES = {
447
+ Error,
448
+ TypeError,
449
+ RangeError,
450
+ ReferenceError,
451
+ SyntaxError,
452
+ URIError,
453
+ EvalError,
454
+ AuthorityCorruptionError,
455
+ };
456
+ function causeWire(cause) {
457
+ return cause instanceof Error ? { causeClass: cause.name, causeDiagnostic: cause.message } : {};
458
+ }
459
+ export function encodeFailureWire(error) {
460
+ return error instanceof KeiyakuError
461
+ ? {
462
+ kind: "failed",
463
+ category: error.category,
464
+ diagnostic: error.message,
465
+ ...causeWire(error.cause),
466
+ ...(error.outcome === undefined ? {} : { outcome: error.outcome }),
467
+ }
468
+ : { kind: "failed", category: errorCategory(error), diagnostic: errorDiagnostic(error), ...causeWire(error) };
469
+ }
470
+ export function decodeFailureWire(value) {
471
+ const parsed = failureWireSchema.safeParse(value);
472
+ if (!parsed.success)
473
+ return null;
474
+ const wire = parsed.data;
475
+ let cause;
476
+ if (wire.causeClass !== undefined && wire.causeDiagnostic !== undefined) {
477
+ const constructor = Object.hasOwn(NATIVE_CAUSES, wire.causeClass)
478
+ ? NATIVE_CAUSES[wire.causeClass]
479
+ : Error;
480
+ cause = new constructor(wire.causeDiagnostic);
481
+ cause.name = wire.causeClass;
482
+ }
483
+ return new KeiyakuError(wire.category, wire.diagnostic, {
484
+ ...(cause === undefined ? {} : { cause }),
485
+ ...(wire.outcome === undefined ? {} : { outcome: wire.outcome }),
486
+ });
487
+ }
@@ -1,40 +1,102 @@
1
1
  /** @architectureCompositionRoot */
2
+ import { z } from "zod";
3
+ import { type ContractFileEffect, type ContractFileLag } from "../contract-worktree.js";
2
4
  import type { ContractId } from "../core/facts/types.js";
5
+ import type { WorktreeHooks } from "../git/hooks.js";
3
6
  import type { GitDecodeChannel } from "../git/read-observation.js";
4
- import { type ReconcileReport } from "../protocol/reconcile.js";
7
+ import type { ReconcileResult } from "../git/reconcile.js";
5
8
  import { type RepositoryScope } from "../protocol/operations.js";
9
+ import { type ProtocolProgress } from "../protocol/progress.js";
6
10
  import { type SettlementReport } from "../settlement/settle.js";
7
- import type { WorktreeHooks } from "./configuration.js";
8
- import { type ContractFileEffect, type ContractFileLag } from "../contract-worktree.js";
9
- import { z } from "zod";
10
- export type ReconcileCompletion = Readonly<{
11
- effects: readonly (ReconcileReport["effects"][number] | ContractFileEffect)[];
12
- lag: readonly (ReconcileReport["lag"][number] | ContractFileLag)[];
11
+ export type ReconcileReport = Readonly<{
12
+ effects: readonly (ReconcileResult["effects"][number] | ContractFileEffect)[];
13
+ lag: readonly (ReconcileResult["lag"][number] | ContractFileLag)[];
13
14
  settlement: SettlementReport;
15
+ }>;
16
+ export type TopologyEffect = ReconcileReport["effects"][number];
17
+ export type ReconcileCompletion = ReconcileReport & Readonly<{
14
18
  hookRuns?: readonly {
15
19
  phase: "create" | "destroy";
16
20
  name: string;
17
21
  }[];
22
+ /** The appointed worktree's short name when this invocation physically removed it. */
23
+ retiredWorktree?: string;
24
+ /** The appointed worktree's path when this invocation's own removal of it was retained. */
25
+ retainedWorktree?: string;
18
26
  }>;
19
- /**
20
- * Identifies the next independently retryable action for a reconciliation lag.
21
- * Retained terminal bytes are observable residue, not a blocker for another
22
- * action.
23
- */
24
27
  export type ReconcileLagScope = "none" | "reconciliation" | "placement" | "continuation";
28
+ /** Identifies the next independently retryable action for a reconciliation lag. */
25
29
  export declare function reconcileLagScope(lag: ReconcileCompletion["lag"][number]): ReconcileLagScope;
26
- export declare function decodeReconciliationLag(value: unknown): ReconcileCompletion["lag"][number];
27
- export declare const reconciliationLagSchema: z.ZodType<import("../git/reconcile.js").ReconcileLag | Readonly<{
28
- kind: "contract-file-failed";
29
- worktree: string;
30
- path: string;
31
- diagnostic: string;
32
- }>, unknown, z.core.$ZodTypeInternals<import("../git/reconcile.js").ReconcileLag | Readonly<{
33
- kind: "contract-file-failed";
34
- worktree: string;
35
- path: string;
36
- diagnostic: string;
37
- }>, unknown>>;
30
+ /** True only when a reconciliation lag means physical repair is incomplete. */
31
+ export declare function reconcileLagIsFailure(lag: ReconcileCompletion["lag"][number]): boolean;
32
+ export declare const reconciliationLagSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
33
+ kind: z.ZodLiteral<"worktree-retained">;
34
+ path: z.ZodString;
35
+ diagnostic: z.ZodOptional<z.ZodString>;
36
+ }, z.core.$strict>, z.ZodObject<{
37
+ kind: z.ZodLiteral<"worktree-follow-retained">;
38
+ path: z.ZodString;
39
+ tender: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
40
+ head: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
41
+ reason: z.ZodEnum<{
42
+ "head-moved": "head-moved";
43
+ "head-attached": "head-attached";
44
+ "operation-in-progress": "operation-in-progress";
45
+ "unsupported-parent-shape": "unsupported-parent-shape";
46
+ }>;
47
+ paths: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
48
+ }, z.core.$strict>, z.ZodObject<{
49
+ kind: z.ZodLiteral<"unsealed-bytes">;
50
+ path: z.ZodString;
51
+ paths: z.ZodReadonly<z.ZodArray<z.ZodString>>;
52
+ head: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>>;
53
+ }, z.core.$strict>, z.ZodObject<{
54
+ kind: z.ZodLiteral<"target-checkout-retained">;
55
+ path: z.ZodString;
56
+ target: z.ZodString;
57
+ diagnostic: z.ZodString;
58
+ }, z.core.$strict>, z.ZodObject<{
59
+ kind: z.ZodLiteral<"worktree-hook-failed">;
60
+ phase: z.ZodEnum<{
61
+ destroy: "destroy";
62
+ create: "create";
63
+ }>;
64
+ path: z.ZodString;
65
+ command: z.ZodNumber;
66
+ name: z.ZodString;
67
+ failure: z.ZodUnion<readonly [z.ZodObject<{
68
+ kind: z.ZodLiteral<"exit">;
69
+ code: z.ZodNumber;
70
+ stdout: z.ZodString;
71
+ stderr: z.ZodString;
72
+ truncated: z.ZodBoolean;
73
+ }, z.core.$strict>, z.ZodObject<{
74
+ stdout: z.ZodOptional<z.ZodString>;
75
+ stderr: z.ZodOptional<z.ZodString>;
76
+ truncated: z.ZodOptional<z.ZodBoolean>;
77
+ kind: z.ZodLiteral<"timeout">;
78
+ }, z.core.$strict>, z.ZodObject<{
79
+ stdout: z.ZodOptional<z.ZodString>;
80
+ stderr: z.ZodOptional<z.ZodString>;
81
+ truncated: z.ZodOptional<z.ZodBoolean>;
82
+ kind: z.ZodLiteral<"unknown-exit">;
83
+ }, z.core.$strict>, z.ZodObject<{
84
+ kind: z.ZodLiteral<"spawn-error">;
85
+ diagnostic: z.ZodString;
86
+ }, z.core.$strict>]>;
87
+ }, z.core.$strict>, z.ZodObject<{
88
+ kind: z.ZodLiteral<"reconcile-failed">;
89
+ stage: z.ZodEnum<{
90
+ observation: "observation";
91
+ effect: "effect";
92
+ }>;
93
+ diagnostic: z.ZodString;
94
+ }, z.core.$strict>]>, z.ZodObject<{
95
+ kind: z.ZodLiteral<"contract-file-failed">;
96
+ worktree: z.ZodString;
97
+ path: z.ZodString;
98
+ diagnostic: z.ZodString;
99
+ }, z.core.$strict>]>;
38
100
  export type RepoContractReconcileReport = ReconcileCompletion;
39
101
  type RepoReconcileContracts = readonly Readonly<{
40
102
  contractId: ContractId;
@@ -47,11 +109,21 @@ export type RepoReconcileReport = Readonly<{
47
109
  kind: "world-observation-failed";
48
110
  diagnostic: string;
49
111
  }>;
112
+ type ReconcileProgress = ProtocolProgress & Readonly<{
113
+ recordSettlement(contractId: ContractId, report: SettlementReport): void;
114
+ recordReconciliation(contractId: ContractId, report: Readonly<{
115
+ effects?: readonly (ReconcileResult["effects"][number] | ContractFileEffect)[];
116
+ lag?: readonly (ReconcileResult["lag"][number] | ContractFileLag)[];
117
+ retiredWorktree?: string;
118
+ retainedWorktree?: string;
119
+ }>): void;
120
+ }>;
50
121
  type ReconcileOptions = Readonly<{
51
122
  scope: RepositoryScope;
52
123
  channel: GitDecodeChannel;
53
124
  hooks: WorktreeHooks;
54
125
  retryHooks: boolean;
126
+ progress?: ReconcileProgress;
55
127
  }>;
56
128
  export declare function completeReconcile(input: ReconcileOptions & Readonly<{
57
129
  contractId: ContractId;