@astrosheep/keiyaku 4.5.11 → 4.5.13

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 (272) hide show
  1. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +135 -377
  2. package/build/integrations/pi/keiyaku.ts +11 -116
  3. package/build/src/akuma/akuma-errors.d.ts +1 -0
  4. package/build/src/akuma/akuma-errors.js +1 -0
  5. package/build/src/akuma/akuma-handle.d.ts +1 -0
  6. package/build/src/akuma/akuma-handle.js +6 -7
  7. package/build/src/akuma/akuma-product.d.ts +6 -8
  8. package/build/src/akuma/akuma-product.js +141 -57
  9. package/build/src/akuma/akuma.d.ts +5 -7
  10. package/build/src/akuma/akuma.js +1 -22
  11. package/build/src/akuma/archetype.d.ts +6 -5
  12. package/build/src/akuma/archetype.js +137 -38
  13. package/build/src/akuma/body.d.ts +5 -5
  14. package/build/src/akuma/body.js +223 -63
  15. package/build/src/akuma/call-input.d.ts +4 -0
  16. package/build/src/akuma/call-input.js +21 -0
  17. package/build/src/akuma/call-request.d.ts +5 -8
  18. package/build/src/akuma/call-request.js +28 -73
  19. package/build/src/akuma/fleet-execution.d.ts +26 -0
  20. package/build/src/akuma/fleet-execution.js +109 -0
  21. package/build/src/{library/fleet-result.d.ts → akuma/fleet-observation.d.ts} +13 -57
  22. package/build/src/{library/fleet-result.js → akuma/fleet-observation.js} +4 -25
  23. package/build/src/akuma/fleet-request.d.ts +122 -0
  24. package/build/src/akuma/fleet-request.js +168 -0
  25. package/build/src/akuma/heart/facts.d.ts +23 -0
  26. package/build/src/akuma/heart/facts.js +7 -0
  27. package/build/src/akuma/heart/index.d.ts +43 -4
  28. package/build/src/akuma/heart/index.js +107 -7
  29. package/build/src/akuma/heart/request-authority.d.ts +2 -0
  30. package/build/src/akuma/heart/request-authority.js +28 -3
  31. package/build/src/akuma/heart/request-rows.d.ts +2 -0
  32. package/build/src/akuma/heart/request-rows.js +24 -5
  33. package/build/src/akuma/heart/rows.d.ts +4 -1
  34. package/build/src/akuma/heart/rows.js +46 -19
  35. package/build/src/akuma/heart/schema.d.ts +1 -1
  36. package/build/src/akuma/heart/schema.js +28 -6
  37. package/build/src/akuma/heart/storage.d.ts +1 -1
  38. package/build/src/akuma/heart/tells.d.ts +29 -0
  39. package/build/src/akuma/heart/tells.js +136 -5
  40. package/build/src/akuma/heart/timeline.js +9 -3
  41. package/build/src/akuma/projection-read.js +36 -3
  42. package/build/src/akuma/projection.js +3 -4
  43. package/build/src/akuma/provider.d.ts +4 -0
  44. package/build/src/akuma/provider.js +56 -3
  45. package/build/src/akuma/providers/claude/index.js +3 -0
  46. package/build/src/akuma/providers/codex-app-server/index.js +14 -12
  47. package/build/src/akuma/providers/pi/index.js +7 -1
  48. package/build/src/akuma/publication.js +65 -49
  49. package/build/src/akuma/request-lifecycle.d.ts +5 -4
  50. package/build/src/akuma/request-lifecycle.js +29 -16
  51. package/build/src/akuma/request-rendezvous.d.ts +15 -12
  52. package/build/src/akuma/request-rendezvous.js +80 -51
  53. package/build/src/akuma/request-serve.d.ts +1 -2
  54. package/build/src/akuma/request-serve.js +94 -39
  55. package/build/src/akuma/request-wire.d.ts +57 -26
  56. package/build/src/akuma/request-wire.js +64 -25
  57. package/build/src/akuma/turn-drive.d.ts +5 -4
  58. package/build/src/akuma/turn-drive.js +27 -11
  59. package/build/src/akuma-body.d.ts +4 -6
  60. package/build/src/akuma-body.js +19 -17
  61. package/build/src/bounded-list.d.ts +8 -0
  62. package/build/src/bounded-list.js +14 -0
  63. package/build/src/cli/accepted.d.ts +1 -1
  64. package/build/src/cli/accepted.js +1 -0
  65. package/build/src/cli/commands/akuma-invoke.js +1 -25
  66. package/build/src/cli/commands/contract-help.d.ts +5 -2
  67. package/build/src/cli/commands/contract-help.js +62 -12
  68. package/build/src/cli/commands/contract-invoke.d.ts +5 -0
  69. package/build/src/cli/commands/contract-invoke.js +26 -1
  70. package/build/src/cli/commands/contract.js +50 -18
  71. package/build/src/cli/commands/task-invoke.js +10 -2
  72. package/build/src/cli/commands/task-query.js +3 -4
  73. package/build/src/cli/coordinates.d.ts +13 -0
  74. package/build/src/cli/coordinates.js +38 -24
  75. package/build/src/cli/draft.d.ts +1 -1
  76. package/build/src/cli/invoke.js +14 -1
  77. package/build/src/cli/render/akuma-activity.d.ts +0 -1
  78. package/build/src/cli/render/akuma-activity.js +5 -38
  79. package/build/src/cli/render/akuma.js +4 -1
  80. package/build/src/cli/render/audit.js +4 -1
  81. package/build/src/cli/render/catalog.js +13 -39
  82. package/build/src/cli/render/contract.js +4 -14
  83. package/build/src/cli/render/kanshi-akuma.js +3 -8
  84. package/build/src/cli/render/kanshi.js +8 -34
  85. package/build/src/cli/render/nuke.js +7 -3
  86. package/build/src/cli/render/receipt.d.ts +1 -0
  87. package/build/src/cli/render/receipt.js +8 -0
  88. package/build/src/cli/render/refusal.js +4 -3
  89. package/build/src/cli/render/task.js +4 -37
  90. package/build/src/cli/render/terminal.d.ts +2 -6
  91. package/build/src/cli/render/terminal.js +4 -9
  92. package/build/src/cli/result.d.ts +2 -1
  93. package/build/src/contract-guidance.js +13 -3
  94. package/build/src/contract-worktree.d.ts +1 -0
  95. package/build/src/contract-worktree.js +26 -2
  96. package/build/src/core/facts/codec.d.ts +2 -1
  97. package/build/src/core/facts/codec.js +3 -0
  98. package/build/src/core/facts/gate.d.ts +2 -1
  99. package/build/src/core/facts/gate.js +63 -0
  100. package/build/src/core/verbs/abandon.d.ts +2 -1
  101. package/build/src/core/verbs/abandon.js +16 -0
  102. package/build/src/core/verbs/amend.d.ts +2 -1
  103. package/build/src/core/verbs/amend.js +20 -0
  104. package/build/src/core/verbs/arc.d.ts +2 -1
  105. package/build/src/core/verbs/arc.js +16 -0
  106. package/build/src/core/verbs/attestation.d.ts +2 -1
  107. package/build/src/core/verbs/attestation.js +16 -0
  108. package/build/src/core/verbs/bind.d.ts +2 -1
  109. package/build/src/core/verbs/bind.js +16 -0
  110. package/build/src/core/verbs/deliver.d.ts +2 -1
  111. package/build/src/core/verbs/deliver.js +16 -0
  112. package/build/src/core/verbs/placement.d.ts +2 -1
  113. package/build/src/core/verbs/placement.js +58 -1
  114. package/build/src/dispatch/association.d.ts +13 -0
  115. package/build/src/dispatch/association.js +20 -0
  116. package/build/src/dispatch/index.d.ts +6 -0
  117. package/build/src/dispatch/index.js +27 -3
  118. package/build/src/git/hooks.d.ts +9 -1
  119. package/build/src/git/hooks.js +79 -1
  120. package/build/src/git/nuke.d.ts +2 -1
  121. package/build/src/git/nuke.js +6 -11
  122. package/build/src/git/private-state-seat.d.ts +26 -1
  123. package/build/src/git/private-state-seat.js +78 -13
  124. package/build/src/git/process.d.ts +2 -0
  125. package/build/src/git/reconcile.d.ts +1 -2
  126. package/build/src/git/reconcile.js +0 -6
  127. package/build/src/git/repository.d.ts +0 -2
  128. package/build/src/git/repository.js +27 -25
  129. package/build/src/git/result-codec.d.ts +29 -0
  130. package/build/src/git/result-codec.js +306 -0
  131. package/build/src/git/target-placement.js +2 -8
  132. package/build/src/git/workspace.d.ts +2 -0
  133. package/build/src/git/workspace.js +4 -0
  134. package/build/src/index.d.ts +1 -0
  135. package/build/src/kanshi/fleet.js +1 -1
  136. package/build/src/kanshi/read.js +55 -28
  137. package/build/src/kanshi/report.d.ts +4 -3
  138. package/build/src/kanshi/select.js +14 -1
  139. package/build/src/library/address.d.ts +1 -0
  140. package/build/src/library/address.js +4 -7
  141. package/build/src/library/akuma-creation.d.ts +5 -3
  142. package/build/src/library/akuma-creation.js +90 -33
  143. package/build/src/library/audit.js +2 -1
  144. package/build/src/library/catalog.d.ts +10 -2
  145. package/build/src/library/catalog.js +65 -25
  146. package/build/src/library/composition.d.ts +1 -0
  147. package/build/src/library/composition.js +1 -0
  148. package/build/src/library/configuration.d.ts +4 -21
  149. package/build/src/library/configuration.js +2 -158
  150. package/build/src/library/continuation.d.ts +20 -1
  151. package/build/src/library/continuation.js +36 -0
  152. package/build/src/library/contract-bind.d.ts +1 -0
  153. package/build/src/library/contract-bind.js +16 -5
  154. package/build/src/library/contract-forwarding.d.ts +2 -2
  155. package/build/src/library/contract-forwarding.js +18 -4
  156. package/build/src/library/contract-handle.js +4 -3
  157. package/build/src/library/contract-operations.d.ts +5 -9
  158. package/build/src/library/contract-operations.js +34 -47
  159. package/build/src/library/contract.d.ts +11 -2
  160. package/build/src/library/contract.js +21 -1
  161. package/build/src/library/delivery.d.ts +4 -1
  162. package/build/src/library/delivery.js +47 -0
  163. package/build/src/library/fleet.d.ts +4 -136
  164. package/build/src/library/fleet.js +31 -315
  165. package/build/src/library/keiyaku.d.ts +7 -3
  166. package/build/src/library/keiyaku.js +1 -0
  167. package/build/src/library/mutation.d.ts +431 -3
  168. package/build/src/library/mutation.js +192 -19
  169. package/build/src/library/nuke.d.ts +7 -1
  170. package/build/src/library/nuke.js +18 -4
  171. package/build/src/library/reconcile.d.ts +14 -0
  172. package/build/src/library/reconcile.js +22 -8
  173. package/build/src/library/refusal.d.ts +9 -1
  174. package/build/src/library/refusal.js +76 -0
  175. package/build/src/library/region.d.ts +0 -8
  176. package/build/src/library/region.js +1 -29
  177. package/build/src/library/result-codec.d.ts +2 -0
  178. package/build/src/library/result-codec.js +12 -0
  179. package/build/src/markdown/lex.js +9 -2
  180. package/build/src/markdown/types.d.ts +2 -1
  181. package/build/src/markdown/types.js +3 -1
  182. package/build/src/plugin/akuma-signals.d.ts +12 -0
  183. package/build/src/plugin/akuma-signals.js +14 -0
  184. package/build/src/plugin/public.d.ts +51 -0
  185. package/build/src/plugin/public.js +1 -0
  186. package/build/src/plugin/runtime.d.ts +14 -0
  187. package/build/src/plugin/runtime.js +357 -0
  188. package/build/src/protocol/amend.js +3 -3
  189. package/build/src/protocol/attempt.d.ts +2 -1
  190. package/build/src/protocol/attempt.js +1 -1
  191. package/build/src/protocol/audit.d.ts +1 -1
  192. package/build/src/protocol/audit.js +1 -1
  193. package/build/src/protocol/bind.d.ts +3 -1
  194. package/build/src/protocol/bind.js +26 -0
  195. package/build/src/protocol/completion.js +0 -1
  196. package/build/src/protocol/deliver.d.ts +1 -1
  197. package/build/src/protocol/deliver.js +136 -57
  198. package/build/src/protocol/intent.d.ts +0 -1
  199. package/build/src/protocol/intent.js +0 -1
  200. package/build/src/protocol/operations.d.ts +9 -2
  201. package/build/src/protocol/operations.js +16 -1
  202. package/build/src/protocol/outcome.d.ts +3 -0
  203. package/build/src/protocol/outcome.js +17 -1
  204. package/build/src/protocol/placement.js +10 -3
  205. package/build/src/protocol/read/status.d.ts +8 -0
  206. package/build/src/protocol/read/status.js +49 -0
  207. package/build/src/protocol/reintegrate.js +10 -3
  208. package/build/src/protocol/result-codec.d.ts +22 -0
  209. package/build/src/protocol/result-codec.js +442 -0
  210. package/build/src/protocol/review.d.ts +1 -1
  211. package/build/src/protocol/review.js +81 -46
  212. package/build/src/protocol/run.d.ts +22 -2
  213. package/build/src/protocol/run.js +119 -29
  214. package/build/src/runtime/proc/lifecycle.js +1 -1
  215. package/build/src/runtime/proc/line-rpc.d.ts +7 -1
  216. package/build/src/runtime/proc/line-rpc.js +49 -9
  217. package/build/src/runtime/proc/run.d.ts +0 -1
  218. package/build/src/runtime/proc/run.js +1 -11
  219. package/build/src/runtime/proc/termination.d.ts +1 -0
  220. package/build/src/runtime/proc/termination.js +63 -18
  221. package/build/src/runtime/proc/windows-launch.exe +0 -0
  222. package/build/src/settings.d.ts +10 -0
  223. package/build/src/settings.js +88 -2
  224. package/build/src/settlement/result-codec.d.ts +2 -0
  225. package/build/src/settlement/result-codec.js +56 -0
  226. package/build/src/settlement/settle.d.ts +5 -12
  227. package/build/src/settlement/settle.js +60 -55
  228. package/build/src/task/board.d.ts +3 -0
  229. package/build/src/task/board.js +22 -4
  230. package/build/src/task/catalog.d.ts +13 -2
  231. package/build/src/task/catalog.js +59 -5
  232. package/build/src/task/compose.d.ts +4 -2
  233. package/build/src/task/compose.js +56 -30
  234. package/build/src/task/created-observation.d.ts +39 -0
  235. package/build/src/task/created-observation.js +26 -0
  236. package/build/src/task/identity.d.ts +6 -0
  237. package/build/src/task/identity.js +48 -7
  238. package/build/src/task/index.d.ts +4 -3
  239. package/build/src/task/index.js +19 -16
  240. package/build/src/task/input.d.ts +3 -1
  241. package/build/src/task/input.js +7 -4
  242. package/build/src/task/lifecycle-operations.d.ts +6 -0
  243. package/build/src/task/lifecycle-operations.js +116 -0
  244. package/build/src/task/mutation-result.d.ts +762 -20
  245. package/build/src/task/mutation-result.js +34 -9
  246. package/build/src/task/mutation.d.ts +4 -9
  247. package/build/src/task/mutation.js +17 -52
  248. package/build/src/task/operation-types.d.ts +114 -0
  249. package/build/src/task/operation-types.js +1 -0
  250. package/build/src/task/operations.d.ts +6 -113
  251. package/build/src/task/operations.js +75 -117
  252. package/build/src/task/query.d.ts +8 -11
  253. package/build/src/task/query.js +7 -14
  254. package/build/src/task/store.d.ts +11 -1
  255. package/build/src/task/store.js +169 -55
  256. package/build/src/task/view.d.ts +4 -0
  257. package/build/src/task/view.js +7 -0
  258. package/build/src/verification/declaration.d.ts +1 -0
  259. package/build/src/verification/declaration.js +18 -1
  260. package/build/src/verification/execution.d.ts +0 -1
  261. package/build/src/verification/execution.js +5 -5
  262. package/build/src/world.d.ts +0 -2
  263. package/build/src/world.js +3 -7
  264. package/package.json +17 -5
  265. package/build/src/cli/square-edge.d.ts +0 -7
  266. package/build/src/cli/square-edge.js +0 -159
  267. package/build/src/git/ref-migration.d.ts +0 -22
  268. package/build/src/git/ref-migration.js +0 -55
  269. package/build/src/library/contract-forwarding-reconciliation-result.d.ts +0 -102
  270. package/build/src/library/contract-forwarding-reconciliation-result.js +0 -92
  271. package/build/src/library/contract-forwarding-result.d.ts +0 -4270
  272. package/build/src/library/contract-forwarding-result.js +0 -521
@@ -1,20 +1,21 @@
1
1
  import { materializeIntegrationSnapshot, materializeJudgedConflict, planIntegration, worktreeChangeId, } from "../git/integration.js";
2
2
  import { captureTender, dirtyTenderRefusal, materializeTenderSnapshot, prepareDeliveryCommitMetadata, } from "../git/tender.js";
3
- import { recordConflictHandoff, retireConflictHandoff, workspaceMergeStatePresent, worktreePath, } from "../git/workspace.js";
3
+ import { checkoutDetachedSnapshot, recordConflictHandoff, retireConflictHandoff, workspaceMergeStatePresent, worktreePath, } from "../git/workspace.js";
4
4
  import { observeContractsForAdmissionAt } from "../git/observe.js";
5
- import { withPrivateStatePublicationSeat } from "../git/private-state-seat.js";
5
+ import { matchingPrivateRootObservation, privateStateSeatAttempt, sameSpeculativeWorktreeInput, } from "./run.js";
6
6
  import { contractState } from "../core/facts/observation.js";
7
7
  import { decideDeliver } from "../core/verbs/deliver.js";
8
8
  import { admitDecidedOffer, mintAttempts } from "./attempt.js";
9
9
  import { admitted } from "./outcome.js";
10
10
  import { completeCandidate } from "./completion.js";
11
11
  import { appointmentFor, readPlaceRegister } from "../workspace-place.js";
12
- import { timestamp } from "./operations.js";
12
+ import { attemptDecisionWithSeatClose, timestamp } from "./operations.js";
13
+ export { decodeMaterializedConflict } from "./result-codec.js";
13
14
  const DELIVER_CONFLICT_RECOVERY = Object.freeze({
14
- materialize: "deliver --materialize-conflict",
15
+ materialize: "deliver --materialize-conflict --include-dirty",
15
16
  continue: "deliver --include-dirty",
16
17
  });
17
- export async function prepareDelivery(repository, stage, input) {
18
+ async function captureAuthorizedDeliveryTender(repository, stage, includeDirty) {
18
19
  const { contractId, coordinates } = stage;
19
20
  const appointed = coordinates.workspace === "worktree"
20
21
  ? stage.appointment === undefined
@@ -29,10 +30,17 @@ export async function prepareDelivery(repository, stage, input) {
29
30
  });
30
31
  if (tender.kind === "refused")
31
32
  return tender;
32
- if (((tender.data.dirty || tender.data.mergeHead !== undefined) && input.includeDirty !== true) ||
33
+ if (((tender.data.dirty || tender.data.mergeHead !== undefined) && includeDirty !== true) ||
33
34
  tender.data.changes.submodules.length > 0) {
34
35
  return { kind: "refused", refusal: await dirtyTenderRefusal(repository, contractId, tender.data) };
35
36
  }
37
+ return { kind: "prepared", data: tender.data };
38
+ }
39
+ async function prepareDeliveryWithWorktree(repository, stage, input) {
40
+ const { contractId, coordinates } = stage;
41
+ const tender = await captureAuthorizedDeliveryTender(repository, stage, input.includeDirty);
42
+ if (tender.kind === "refused")
43
+ return tender;
36
44
  const commit = await prepareDeliveryCommitMetadata(repository, {
37
45
  contractId,
38
46
  title: input.title,
@@ -46,6 +54,7 @@ export async function prepareDelivery(repository, stage, input) {
46
54
  const integration = await planIntegration(repository, { contractId, coordinates }, { ...tender.data, head: tenderSnapshot }, requireBranchesToBeUpToDate);
47
55
  if (integration.kind === "refused")
48
56
  return integration;
57
+ const changeId = await worktreeChangeId(repository, { contractId, coordinates }, tender.data);
49
58
  const integrationSnapshot = coordinates.target === undefined
50
59
  ? tenderSnapshot
51
60
  : await materializeIntegrationSnapshot(repository, integration.data.tree, integration.data.predecessor, commit);
@@ -56,53 +65,96 @@ export async function prepareDelivery(repository, stage, input) {
56
65
  integration: {
57
66
  predecessor: integration.data.predecessor,
58
67
  snapshot: integrationSnapshot,
59
- changeId: await worktreeChangeId(repository, { contractId, coordinates }, tender.data),
68
+ changeId,
60
69
  },
61
70
  method: "squash",
62
71
  policy: { requireBranchesToBeUpToDate },
63
72
  },
73
+ worktree: {
74
+ tree: tender.data.tree,
75
+ head: tender.data.head,
76
+ ...(tender.data.mergeHead === undefined ? {} : { mergeHead: tender.data.mergeHead }),
77
+ dirty: tender.data.dirty,
78
+ changeId,
79
+ },
64
80
  };
65
81
  }
66
- async function deliverAttempt(input, attempt) {
67
- return await withPrivateStatePublicationSeat(input.scope, async (seat) => await deliverAttemptInPrivateStateSeat(input, attempt, seat));
82
+ export async function prepareDelivery(repository, stage, input) {
83
+ const prepared = await prepareDeliveryWithWorktree(repository, stage, input);
84
+ return prepared.kind === "refused" ? prepared : { kind: "prepared", data: prepared.data };
85
+ }
86
+ function deliveryPreparationInput(input, derivation) {
87
+ return {
88
+ title: derivation.title,
89
+ document: derivation.bytes,
90
+ ...(input.actor === undefined ? {} : { actor: input.actor }),
91
+ ...(input.message === undefined ? {} : { message: input.message }),
92
+ requireBranchesToBeUpToDate: input.requireBranchesToBeUpToDate,
93
+ includeDirty: input.includeDirty,
94
+ };
95
+ }
96
+ async function recaptureDeliveryWorktree(input, state) {
97
+ const tender = await captureAuthorizedDeliveryTender(input.scope, { contractId: state.id, coordinates: state.coordinates }, input.includeDirty);
98
+ if (tender.kind === "refused")
99
+ return undefined;
100
+ return {
101
+ tree: tender.data.tree,
102
+ head: tender.data.head,
103
+ ...(tender.data.mergeHead === undefined ? {} : { mergeHead: tender.data.mergeHead }),
104
+ dirty: tender.data.dirty,
105
+ changeId: await worktreeChangeId(input.scope, { contractId: state.id, coordinates: state.coordinates }, tender.data),
106
+ };
107
+ }
108
+ async function mechanicalDeliveryPreparation(input, state, derivation) {
109
+ const prepared = await prepareDeliveryWithWorktree(input.scope, { contractId: state.id, coordinates: state.coordinates }, deliveryPreparationInput(input, derivation));
110
+ if (prepared.kind === "refused") {
111
+ return { kind: "refused", document: derivation.document, refusal: prepared.refusal };
112
+ }
113
+ return {
114
+ kind: "prepared",
115
+ document: derivation.document,
116
+ data: prepared.data,
117
+ worktree: prepared.worktree,
118
+ };
68
119
  }
69
- async function deliverAttemptInPrivateStateSeat(input, attempt, seat) {
70
- const decisionObservation = await observeContractsForAdmissionAt(input.scope, input.channel, [input.contractId]);
71
- const state = contractState(decisionObservation.decision, input.contractId);
120
+ async function speculateDelivery(input) {
121
+ const observation = await observeContractsForAdmissionAt(input.scope, input.channel, [input.contractId]);
122
+ const state = contractState(observation.decision, input.contractId);
72
123
  const derivation = state === null ? undefined : input.deriveDocument(state);
73
- let preparation;
74
124
  if (state === null || derivation === undefined) {
75
- preparation = { kind: "unavailable" };
125
+ return { observation, state, preparation: { kind: "unavailable" } };
76
126
  }
77
- else if (derivation.verification.kind === "refused") {
78
- preparation = { kind: "refused", document: derivation.document, refusal: derivation.verification.refusal };
127
+ if (derivation.verification.kind === "refused") {
128
+ return {
129
+ observation,
130
+ state,
131
+ derivation,
132
+ preparation: { kind: "refused", document: derivation.document, refusal: derivation.verification.refusal },
133
+ };
79
134
  }
80
- else {
81
- const materialization = input.materializeConflict === true && state.terminal === null
82
- ? await materializationMergeStateRefusal(input)
83
- : undefined;
84
- const prepared = materialization === undefined
85
- ? await prepareDelivery(input.scope, {
86
- contractId: state.id,
87
- coordinates: state.coordinates,
88
- }, {
89
- title: derivation.title,
90
- document: derivation.bytes,
91
- ...(input.actor === undefined ? {} : { actor: input.actor }),
92
- ...(input.message === undefined ? {} : { message: input.message }),
93
- requireBranchesToBeUpToDate: input.requireBranchesToBeUpToDate,
94
- includeDirty: input.includeDirty,
95
- })
96
- : { kind: "refused", refusal: materialization };
97
- preparation =
98
- prepared.kind === "refused"
99
- ? { kind: "refused", document: derivation.document, refusal: prepared.refusal }
100
- : {
101
- kind: "prepared",
102
- document: derivation.document,
103
- data: prepared.data,
104
- };
135
+ if (input.materializeConflict === true && state.terminal === null)
136
+ return { observation, state, derivation };
137
+ const prepared = await mechanicalDeliveryPreparation(input, state, derivation);
138
+ return prepared.kind === "prepared"
139
+ ? { observation, state, derivation, preparation: prepared, worktree: prepared.worktree }
140
+ : { observation, state, derivation, preparation: prepared };
141
+ }
142
+ async function resolveDeliveryPreparation(input, speculated) {
143
+ if (speculated.preparation !== undefined)
144
+ return speculated.preparation;
145
+ if (speculated.state === null || speculated.derivation === undefined)
146
+ return { kind: "unavailable" };
147
+ const materialization = await materializationMergeStateRefusal(input);
148
+ if (materialization !== undefined) {
149
+ return { kind: "refused", document: speculated.derivation.document, refusal: materialization };
105
150
  }
151
+ const prepared = await mechanicalDeliveryPreparation(input, speculated.state, speculated.derivation);
152
+ return prepared.kind === "prepared"
153
+ ? { kind: "prepared", document: prepared.document, data: prepared.data }
154
+ : prepared;
155
+ }
156
+ async function decideAndAdmitDelivery(input, attempt, seat, observation, speculated) {
157
+ const preparation = await resolveDeliveryPreparation(input, speculated);
106
158
  const decision = decideDeliver({
107
159
  input: {
108
160
  contractId: input.contractId,
@@ -111,7 +163,7 @@ async function deliverAttemptInPrivateStateSeat(input, attempt, seat) {
111
163
  preparation,
112
164
  },
113
165
  attempt,
114
- observation: decisionObservation.decision,
166
+ observation: observation.decision,
115
167
  });
116
168
  if (decision.kind === "refused")
117
169
  return { kind: "refused", refusal: decision.refusal };
@@ -121,23 +173,36 @@ async function deliverAttemptInPrivateStateSeat(input, attempt, seat) {
121
173
  channel: input.channel,
122
174
  repository: input.scope,
123
175
  seat,
124
- decisionObservation,
176
+ decisionObservation: observation,
125
177
  attempt,
126
178
  offer: decision.offer,
127
179
  primaryContract: input.contractId,
128
180
  });
129
- if (admission.kind === "accepted") {
130
- if (derivation === undefined)
131
- throw new Error("accepted delivery is missing its document derivation");
132
- return {
133
- ...admission,
134
- value: {
135
- delivery: preparation.data,
136
- derivation,
137
- },
138
- };
139
- }
140
- return admission;
181
+ if (admission.kind !== "accepted")
182
+ return admission;
183
+ if (speculated.derivation === undefined)
184
+ throw new Error("accepted delivery is missing its document derivation");
185
+ return {
186
+ ...admission,
187
+ value: { delivery: preparation.data, derivation: speculated.derivation },
188
+ };
189
+ }
190
+ async function deliverAttemptInPrivateStateSeat(input, attempt, seat, speculated) {
191
+ const observation = await matchingPrivateRootObservation(input.scope, input.channel, input.contractId, speculated.observation, async (fresh) => {
192
+ if (speculated.worktree === undefined)
193
+ return true;
194
+ const state = contractState(fresh.decision, input.contractId);
195
+ if (state === null)
196
+ return false;
197
+ return sameSpeculativeWorktreeInput(speculated.worktree, await recaptureDeliveryWorktree(input, state));
198
+ });
199
+ return "kind" in observation
200
+ ? observation
201
+ : await decideAndAdmitDelivery(input, attempt, seat, observation, speculated);
202
+ }
203
+ async function deliverAttempt(input, attempt) {
204
+ const speculated = await speculateDelivery(input);
205
+ return await privateStateSeatAttempt(input.scope, async (seat) => await deliverAttemptInPrivateStateSeat(input, attempt, seat, speculated), attemptDecisionWithSeatClose);
141
206
  }
142
207
  async function completeDelivery(input, first) {
143
208
  const derivation = first.value.derivation;
@@ -246,14 +311,28 @@ async function materializeDeliverConflict(input, refusal) {
246
311
  });
247
312
  if (tender.kind === "refused")
248
313
  return tender;
249
- if (tender.data.dirty || tender.data.changes.submodules.length > 0) {
314
+ if (tender.data.changes.submodules.length > 0 || (tender.data.dirty && input.includeDirty !== true)) {
250
315
  return { kind: "refused", refusal: await dirtyTenderRefusal(input.scope, input.contractId, tender.data) };
251
316
  }
317
+ let handoffHead = tender.data.head;
318
+ if (tender.data.dirty) {
319
+ const derivation = input.deriveDocument(appointed.state);
320
+ const commit = await prepareDeliveryCommitMetadata(input.scope, {
321
+ contractId: input.contractId,
322
+ title: derivation.title,
323
+ document: derivation.bytes,
324
+ at: tender.data.at,
325
+ ...(input.actor === undefined ? {} : { actor: input.actor }),
326
+ ...(input.message === undefined ? {} : { message: input.message }),
327
+ });
328
+ handoffHead = await materializeTenderSnapshot(input.scope, tender.data, commit);
329
+ await checkoutDetachedSnapshot(input.scope, workspace.path, handoffHead);
330
+ }
252
331
  await recordConflictHandoff(input.scope, {
253
332
  contractId: input.contractId,
254
333
  place: appointment.place,
255
334
  workspace: workspace.path,
256
- head: tender.data.head,
335
+ head: handoffHead,
257
336
  mergeHead: refusal.targetHead,
258
337
  });
259
338
  await materializeJudgedConflict(input.scope, workspace.path, refusal.targetHead);
@@ -45,7 +45,6 @@ type VerifyDeliveryInput = Readonly<{
45
45
  at: string;
46
46
  state: ContractState;
47
47
  snapshot?: SnapshotId;
48
- environment: NodeJS.ProcessEnv;
49
48
  signal?: AbortSignal;
50
49
  verification?: VerificationDefinition;
51
50
  }>;
@@ -69,7 +69,6 @@ export async function verifyDelivery(input) {
69
69
  repository: input.repository,
70
70
  candidate: snapshot,
71
71
  declarations: input.verification.declarations,
72
- environment: input.environment,
73
72
  materializeScratchCandidate,
74
73
  projectSettings,
75
74
  ...(input.signal === undefined ? {} : { signal: input.signal }),
@@ -14,12 +14,13 @@ import type { IntegrationPreparationRefusal } from "../git/integration.js";
14
14
  import type { TargetPlacementRefusal } from "../git/target-placement.js";
15
15
  import type { VerificationCleanupFailure, VerificationRuntimeStop, VerificationResult } from "./intent.js";
16
16
  import type { VerificationDeclarationPreparation, VerificationDeclarationRefusal } from "../verification/declaration.js";
17
+ import { type PrivateStateSeatOutcome } from "../git/private-state-seat.js";
17
18
  import type { PlacementProtocolResult } from "./placement.js";
18
19
  import type { AcceptedAdmission, DecidedOfferResult } from "./attempt.js";
19
20
  import type { AcceptedProtocolStep, IntentOutcome as ProtocolIntentOutcome } from "./outcome.js";
20
21
  import type { ProtocolResult, ProtocolTerminal } from "./run.js";
21
22
  import { type ContractDocumentProjection } from "./read/documents.js";
22
- import { type ContractBoard, type ContractObservation } from "./read/status.js";
23
+ import { type ContractBoard, type ContractCatalogue, type ContractObservation } from "./read/status.js";
23
24
  export type MergeStatePresentRefusal = Readonly<{
24
25
  kind: "merge-state-present";
25
26
  contractId: ContractId;
@@ -40,7 +41,7 @@ export type DeliverConflictRefusal = Readonly<{
40
41
  targetHead: SnapshotId;
41
42
  conflictPaths: readonly string[];
42
43
  recovery: Readonly<{
43
- materialize: "deliver --materialize-conflict";
44
+ materialize: "deliver --materialize-conflict --include-dirty";
44
45
  continue: "deliver --include-dirty";
45
46
  }>;
46
47
  }>;
@@ -108,6 +109,7 @@ export type AttemptDecision<Value, Refusal = IntentRefusal> = (AcceptedAdmission
108
109
  kind: "publication-failed";
109
110
  }>;
110
111
  export declare function timestamp(): string;
112
+ export declare function attemptDecisionWithSeatClose<Value, Refusal = IntentRefusal>(outcome: PrivateStateSeatOutcome<AttemptDecision<Value, Refusal>>): AttemptDecision<Value, Refusal>;
111
113
  export declare function mergeAdmissions(current: AcceptedProtocolStep, next: AcceptedProtocolStep): AcceptedProtocolStep;
112
114
  export declare function stepStop<Refusal>(result: ProtocolResult<Refusal>): StepStop<Refusal> | undefined;
113
115
  export declare function unpackVerificationOutcome(verification: VerificationResult): Readonly<{
@@ -131,6 +133,11 @@ export declare function contractsOperation(input: Readonly<{
131
133
  scope: RepositoryScope;
132
134
  channel: GitDecodeChannel;
133
135
  }>): Promise<ContractBoard>;
136
+ export declare function contractCatalogueOperation(input: Readonly<{
137
+ scope: RepositoryScope;
138
+ channel: GitDecodeChannel;
139
+ limit?: number;
140
+ }>): Promise<ContractCatalogue>;
134
141
  export declare function contractObservationOperation(input: Readonly<{
135
142
  scope: RepositoryScope;
136
143
  channel: GitDecodeChannel;
@@ -2,18 +2,29 @@ import { readDeliveryDiff } from "../git/integration.js";
2
2
  import { currentBranch, observeContractAt } from "../git/observe.js";
3
3
  import { repositoryAt } from "../git/repository.js";
4
4
  import { withGitReadObservation } from "../git/read-observation.js";
5
+ import { appendPrivateStateSeatClose, concatenatePrivateStateSeatClose, mergePrivateStateSeatClose, } from "../git/private-state-seat.js";
5
6
  import { readDocuments } from "./read/documents.js";
6
- import { readContractBoard, readContractObservationAt, } from "./read/status.js";
7
+ import { readContractBoard, readContractCatalogue, readContractObservationAt, } from "./read/status.js";
8
+ import { boundedListLimit } from "../bounded-list.js";
7
9
  export function timestamp() {
8
10
  return new Date().toISOString();
9
11
  }
12
+ export function attemptDecisionWithSeatClose(outcome) {
13
+ return mergePrivateStateSeatClose(outcome, (value, closeLag) => {
14
+ if (value.kind !== "accepted")
15
+ throw new Error(closeLag.diagnostic);
16
+ return { ...value, seatClose: appendPrivateStateSeatClose(value.seatClose, closeLag) };
17
+ });
18
+ }
10
19
  export function mergeAdmissions(current, next) {
11
20
  const effects = [...(current.physical?.effects ?? []), ...(next.physical?.effects ?? [])];
12
21
  const lag = [...(current.physical?.lag ?? []), ...(next.physical?.lag ?? [])];
22
+ const seatClose = concatenatePrivateStateSeatClose(current.seatClose, next.seatClose);
13
23
  return {
14
24
  ...next,
15
25
  facts: [...current.facts, ...next.facts],
16
26
  ...(effects.length === 0 && lag.length === 0 ? {} : { physical: { effects, lag } }),
27
+ ...(seatClose === undefined ? {} : { seatClose }),
17
28
  };
18
29
  }
19
30
  export function stepStop(result) {
@@ -56,6 +67,10 @@ export async function currentBranchOperation(input) {
56
67
  export async function contractsOperation(input) {
57
68
  return withGitReadObservation(input.scope, input.channel, (observation) => readContractBoard(observation));
58
69
  }
70
+ export async function contractCatalogueOperation(input) {
71
+ const limit = boundedListLimit(input.limit);
72
+ return withGitReadObservation(input.scope, input.channel, (observation) => readContractCatalogue(observation, limit));
73
+ }
59
74
  export async function contractObservationOperation(input) {
60
75
  return await readContractObservationAt(input.scope, input.channel, input.contractId);
61
76
  }
@@ -1,6 +1,7 @@
1
1
  import type { ContractHead, ContractState, JournalEntry } from "../core/facts/types.js";
2
2
  import type { WorktreeLeak } from "../git/scratch.js";
3
3
  import type { ReconcileResult } from "../git/reconcile.js";
4
+ import { type PrivateStateSeatCloseLag, type PrivateStateSeatOutcome } from "../git/private-state-seat.js";
4
5
  import type { AcceptedAdmission } from "./attempt.js";
5
6
  import type { VerificationCleanupFailure } from "./intent.js";
6
7
  import type { ProtocolResult, ProtocolTerminal } from "./run.js";
@@ -10,6 +11,7 @@ export type AcceptedProtocolStep = AcceptedAdmission & Readonly<{
10
11
  export type AcceptedObligations = Readonly<{
11
12
  cleanup?: VerificationCleanupFailure;
12
13
  leak?: WorktreeLeak;
14
+ seatClose?: readonly PrivateStateSeatCloseLag[];
13
15
  }>;
14
16
  export type IntentOutcome<Value, Refusal = never> = Readonly<{
15
17
  kind: "accepted";
@@ -27,3 +29,4 @@ export type IntentOutcome<Value, Refusal = never> = Readonly<{
27
29
  export declare function accepted<Value, Refusal = never>(state: ContractState, facts: readonly JournalEntry[], value: Value, physical?: ReconcileResult, obligations?: AcceptedObligations): IntentOutcome<Value, Refusal>;
28
30
  export declare function admitted<Value, Refusal = never>(admission: AcceptedProtocolStep, value: Value): IntentOutcome<Value, Refusal>;
29
31
  export declare function complete<Value, Refusal>(result: ProtocolResult<Refusal>, value: Value): IntentOutcome<Value, Refusal>;
32
+ export declare function intentOutcomeWithSeatClose<Value, Refusal>(outcome: PrivateStateSeatOutcome<IntentOutcome<Value, Refusal>>): IntentOutcome<Value, Refusal>;
@@ -1,3 +1,4 @@
1
+ import { appendPrivateStateSeatClose, mergePrivateStateSeatClose, } from "../git/private-state-seat.js";
1
2
  export function accepted(state, facts, value, physical, obligations) {
2
3
  if (state.head === null)
3
4
  throw new Error("accepted contract is missing its journal head");
@@ -9,10 +10,18 @@ export function accepted(state, facts, value, physical, obligations) {
9
10
  ...(physical === undefined ? {} : { physical }),
10
11
  ...(obligations?.cleanup === undefined ? {} : { cleanup: obligations.cleanup }),
11
12
  ...(obligations?.leak === undefined ? {} : { leak: obligations.leak }),
13
+ ...seatCloseObligations(obligations?.seatClose),
12
14
  };
13
15
  }
16
+ function seatCloseObligations(seatClose) {
17
+ return seatClose === undefined || seatClose.length === 0 ? {} : { seatClose };
18
+ }
19
+ function admissionObligations(admission) {
20
+ const seatClose = admission.seatClose;
21
+ return seatClose === undefined || seatClose.length === 0 ? undefined : { seatClose };
22
+ }
14
23
  export function admitted(admission, value) {
15
- return accepted(admission.state, admission.facts, value, admission.physical);
24
+ return accepted(admission.state, admission.facts, value, admission.physical, admissionObligations(admission));
16
25
  }
17
26
  export function complete(result, value) {
18
27
  if (result.kind === "refused")
@@ -21,3 +30,10 @@ export function complete(result, value) {
21
30
  return { kind: "retry", reason: result };
22
31
  return admitted(result, value);
23
32
  }
33
+ export function intentOutcomeWithSeatClose(outcome) {
34
+ return mergePrivateStateSeatClose(outcome, (value, closeLag) => {
35
+ if (value.kind !== "accepted")
36
+ throw new Error(closeLag.diagnostic);
37
+ return { ...value, seatClose: appendPrivateStateSeatClose(value.seatClose, closeLag) };
38
+ });
39
+ }
@@ -3,7 +3,7 @@ import { AuthorityCorruptionError } from "../core/facts/errors.js";
3
3
  import { contractState } from "../core/facts/observation.js";
4
4
  import { decidePlacement } from "../core/verbs/placement.js";
5
5
  import { observeGitForAdmissionAt } from "../git/observe.js";
6
- import { withPrivateStatePublicationSeat } from "../git/private-state-seat.js";
6
+ import { appendPrivateStateSeatClose, mergePrivateStateSeatClose, withPrivateStatePublicationSeat, } from "../git/private-state-seat.js";
7
7
  import { reconcileEffectFailure } from "../git/reconcile.js";
8
8
  import { GitPlumbingError } from "../git/process.js";
9
9
  import { acquireTargetPlacementFence, followTargetPlacement, prepareTargetPlacement, observeTargetHead, observedTreeEqualsCandidate, } from "../git/target-placement.js";
@@ -21,9 +21,16 @@ function expectedOperationalDiagnostic(error) {
21
21
  function expectedPlacementFailure(error) {
22
22
  return { kind: "placement-failed", diagnostic: expectedOperationalDiagnostic(error) };
23
23
  }
24
+ function placementResultWithSeatClose(outcome) {
25
+ return mergePrivateStateSeatClose(outcome, (value, closeLag) => {
26
+ if (value.kind !== "accepted")
27
+ throw new Error(closeLag.diagnostic);
28
+ return { ...value, seatClose: appendPrivateStateSeatClose(value.seatClose, closeLag) };
29
+ });
30
+ }
24
31
  async function runFencedPlacement(repository, input, protocol) {
25
32
  let preparedPhysical;
26
- const result = await withPrivateStatePublicationSeat(repository, async (seat) => {
33
+ const result = placementResultWithSeatClose(await withPrivateStatePublicationSeat(repository, async (seat) => {
27
34
  for (let index = 0; index < protocol.attempts.length; index += 1) {
28
35
  const prepared = await prepareProtocolAttempt(protocol, protocol.attempts[index]);
29
36
  if (prepared.kind === "refused")
@@ -67,7 +74,7 @@ async function runFencedPlacement(repository, input, protocol) {
67
74
  return result;
68
75
  }
69
76
  return { kind: "exhausted" };
70
- });
77
+ }));
71
78
  if (result.kind !== "accepted")
72
79
  return result;
73
80
  if (preparedPhysical === undefined) {
@@ -3,6 +3,7 @@ import type { GitRepository } from "../../git/process.js";
3
3
  import type { GitDecodeChannel, GitReadObservation } from "../../git/read-observation.js";
4
4
  import { type GateCurrent } from "../../core/facts/gate.js";
5
5
  import type { ContractId, ContractState, DeliverData, JournalEntry, SnapshotId } from "../../core/facts/types.js";
6
+ import { type BoundedList } from "../../bounded-list.js";
6
7
  export type ContractPhase = "waiting" | "bound" | "tendered" | "claimed" | "abandoned";
7
8
  export type ContractDisposition = "active" | "terminal";
8
9
  export type ContractGateCurrent = GateCurrent;
@@ -59,6 +60,11 @@ export type ContractBoard = Readonly<{
59
60
  observedAt: string;
60
61
  rows: readonly ContractRow[];
61
62
  }>;
63
+ export type ContractCatalogue = Readonly<{
64
+ root: string;
65
+ state: SnapshotId | null;
66
+ observedAt: string;
67
+ }> & BoundedList<ContractRow>;
62
68
  export type ContractObservation = Readonly<{
63
69
  kind: "missing";
64
70
  id: ContractId;
@@ -70,6 +76,8 @@ export declare function phaseAtFor(state: Pick<ContractState, "terminal" | "deli
70
76
  export declare function lastJournalAtFor(entries: readonly Pick<JournalEntry, "at">[]): string;
71
77
  /** Build the Contract board from one immutable git observation. */
72
78
  export declare function readContractBoard(observation: GitReadObservation, include?: ContractId): Promise<ContractBoard>;
79
+ /** Observe a bounded recent active Contract catalogue from one immutable git observation. */
80
+ export declare function readContractCatalogue(observation: GitReadObservation, limit: number): Promise<ContractCatalogue>;
73
81
  /** Observe one Contract and its target from one fresh ref epoch. */
74
82
  export declare function readContractObservation(observation: GitReadObservation, id: ContractId): Promise<ContractObservation>;
75
83
  /** Observe one Contract and its target from one fresh ref epoch. */
@@ -3,6 +3,7 @@ import { decodeContractDocument } from "../../body/decode.js";
3
3
  import { observeTargetLag, observeWorkspace, worktreePath } from "../../git/workspace.js";
4
4
  import { appointmentFor, readPlaceRegister } from "../../workspace-place.js";
5
5
  import { gateReports } from "../../core/facts/gate.js";
6
+ import { projectBoundedList } from "../../bounded-list.js";
6
7
  function titleFor(state) {
7
8
  try {
8
9
  return decodeContractDocument(state.terms.document.bytes).title;
@@ -149,6 +150,54 @@ export async function readContractBoard(observation, include) {
149
150
  rows,
150
151
  };
151
152
  }
153
+ function compareRecentContracts(left, right) {
154
+ return (right.lastJournalAt.localeCompare(left.lastJournalAt) ||
155
+ Buffer.compare(Buffer.from(left.state.id), Buffer.from(right.state.id)));
156
+ }
157
+ function activeContractStates(contracts) {
158
+ return [...contracts.values()].flatMap((record) => record.state === null || record.state.terminal !== null
159
+ ? []
160
+ : [
161
+ {
162
+ state: record.state,
163
+ bindAt: record.entries[0].at,
164
+ lastJournalAt: lastJournalAtFor(record.entries),
165
+ },
166
+ ]);
167
+ }
168
+ function reverseDependentsFromStates(id, states) {
169
+ return states
170
+ .filter(({ state }) => state.terms.after.includes(id))
171
+ .map(({ state }) => ({ contractId: state.id, phase: phaseFor(state) }))
172
+ .sort((left, right) => left.contractId.localeCompare(right.contractId));
173
+ }
174
+ /** Observe a bounded recent active Contract catalogue from one immutable git observation. */
175
+ export async function readContractCatalogue(observation, limit) {
176
+ const observedAt = new Date().toISOString();
177
+ const observed = await observeActiveContractWorld(observation);
178
+ const active = activeContractStates(observed.contracts);
179
+ const selected = projectBoundedList([...active].sort(compareRecentContracts), limit);
180
+ const afterIds = selected.rows.flatMap(({ state }) => state.terms.after);
181
+ const endpoints = await afterEndpointMap(observation, new Map(observed.eligibility), afterIds);
182
+ const register = await readPlaceRegister(observation.repository);
183
+ const rows = await Promise.all(selected.rows.map(async ({ state, bindAt, lastJournalAt }) => await rowFor({
184
+ repository: observation.repository,
185
+ state,
186
+ bindAt,
187
+ lastJournalAt,
188
+ targetObservation: await observeDeliveryTargetAt(observation, state),
189
+ register,
190
+ after: afterEdges(state, endpoints),
191
+ dependents: reverseDependentsFromStates(state.id, active),
192
+ })));
193
+ return {
194
+ root: observation.repository.primaryWorktree,
195
+ state: observed.snapshot,
196
+ observedAt,
197
+ rows,
198
+ hasMore: selected.hasMore,
199
+ };
200
+ }
152
201
  /** Observe one Contract and its target from one fresh ref epoch. */
153
202
  export async function readContractObservation(observation, id) {
154
203
  const observed = await observeContractsForAdmissionInObservationAt(observation, [id]);
@@ -2,12 +2,19 @@ import { contractState } from "../core/facts/observation.js";
2
2
  import { decideReintegrate } from "../core/verbs/reintegrate.js";
3
3
  import { materializeReintegrationSnapshot, persistedTender, planIntegration, } from "../git/integration.js";
4
4
  import { observeContractsForAdmissionAt } from "../git/observe.js";
5
- import { withPrivateStatePublicationSeat } from "../git/private-state-seat.js";
5
+ import { appendPrivateStateSeatClose, mergePrivateStateSeatClose, withPrivateStatePublicationSeat, } from "../git/private-state-seat.js";
6
6
  import { admitDecidedOffer, mintAttempts } from "./attempt.js";
7
7
  import { timestamp } from "./operations.js";
8
8
  import { runUnderTargetPlacementFence } from "./placement.js";
9
+ function reintegrationResultWithSeatClose(outcome) {
10
+ return mergePrivateStateSeatClose(outcome, (value, closeLag) => {
11
+ if (value.kind !== "accepted")
12
+ throw new Error(closeLag.diagnostic);
13
+ return { ...value, seatClose: appendPrivateStateSeatClose(value.seatClose, closeLag) };
14
+ });
15
+ }
9
16
  async function runReintegration(input) {
10
- return await withPrivateStatePublicationSeat(input.repository, async (seat) => {
17
+ return reintegrationResultWithSeatClose(await withPrivateStatePublicationSeat(input.repository, async (seat) => {
11
18
  const attempts = mintAttempts({ entryCount: 1 });
12
19
  for (let index = 0; index < attempts.length; index += 1) {
13
20
  const attempt = attempts[index];
@@ -71,7 +78,7 @@ async function runReintegration(input) {
71
78
  return { kind: "retry", reason: result };
72
79
  }
73
80
  return { kind: "retry", reason: { kind: "exhausted" } };
74
- });
81
+ }));
75
82
  }
76
83
  export async function reintegrateOperation(input) {
77
84
  return await runUnderTargetPlacementFence(input.repository, input.target, async () => await runReintegration(input));
@@ -0,0 +1,22 @@
1
+ import type { AuditReport } from "./audit.js";
2
+ import type { CandidateCompletion, CompletionEvidence } from "./completion.js";
3
+ import type { IntegrationConflictMaterialized } from "./deliver.js";
4
+ import type { CurrentVerifiedAttestation, VerificationCleanupFailure, VerificationRuntimeStop } from "./intent.js";
5
+ import type { DeliverConflictRefusal, DeliveryPreparationRefusal, IntentRefusal, MergeStatePresentRefusal, PlacementStop, VerificationStop } from "./operations.js";
6
+ import type { ReviewValue } from "./review.js";
7
+ import type { ProtocolTerminal } from "./run.js";
8
+ export declare function decodeProtocolTerminal(value: unknown): ProtocolTerminal;
9
+ export declare function decodeMergeStatePresentRefusal(value: unknown): MergeStatePresentRefusal;
10
+ export declare function decodeDeliverConflictRefusal(value: unknown): DeliverConflictRefusal;
11
+ export declare function decodeDeliveryPreparationRefusal(value: unknown): DeliveryPreparationRefusal;
12
+ export declare function decodeIntentRefusal(value: unknown): IntentRefusal;
13
+ export declare function decodeVerificationRuntimeStop(value: unknown): VerificationRuntimeStop;
14
+ export declare function decodeVerificationStop(value: unknown): VerificationStop;
15
+ export declare function decodeVerificationReuse(value: unknown): CurrentVerifiedAttestation;
16
+ export declare function decodePlacementStop(value: unknown): PlacementStop;
17
+ export declare function decodeVerificationCleanupFailure(value: unknown): VerificationCleanupFailure;
18
+ export declare function decodeCandidateCompletion(value: unknown): CandidateCompletion;
19
+ export declare function decodeCompletionEvidence(value: unknown): CompletionEvidence;
20
+ export declare function decodeMaterializedConflict(value: unknown): IntegrationConflictMaterialized;
21
+ export declare function decodeAuditReport(value: unknown): AuditReport;
22
+ export declare function decodeReviewValue(value: unknown): ReviewValue;