@astrosheep/keiyaku 4.0.3 → 4.0.5

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 (238) hide show
  1. package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +1 -1
  2. package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +1 -1
  3. package/build/integrations/marketplace/plugins/keiyaku/package.json +1 -1
  4. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +4 -4
  5. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +1 -1
  6. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +15 -1
  7. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +3 -1
  8. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +34 -13
  9. package/build/src/akuma/akuma.d.ts +34 -12
  10. package/build/src/akuma/akuma.js +118 -63
  11. package/build/src/akuma/allowed.d.ts +7 -0
  12. package/build/src/akuma/allowed.js +33 -0
  13. package/build/src/akuma/archetype.d.ts +7 -4
  14. package/build/src/akuma/archetype.js +15 -16
  15. package/build/src/akuma/body.d.ts +6 -1
  16. package/build/src/akuma/body.js +36 -27
  17. package/build/src/akuma/heart/facts.d.ts +82 -14
  18. package/build/src/akuma/heart/index.d.ts +5 -18
  19. package/build/src/akuma/heart/index.js +14 -84
  20. package/build/src/akuma/heart/request-authority.d.ts +12 -0
  21. package/build/src/akuma/heart/request-authority.js +119 -0
  22. package/build/src/akuma/heart/request-rows.d.ts +16 -0
  23. package/build/src/akuma/heart/request-rows.js +88 -0
  24. package/build/src/akuma/heart/rows.d.ts +1 -26
  25. package/build/src/akuma/heart/rows.js +0 -50
  26. package/build/src/akuma/heart/schema.d.ts +1 -1
  27. package/build/src/akuma/heart/schema.js +22 -10
  28. package/build/src/akuma/heart/soul.js +2 -36
  29. package/build/src/akuma/heart/storage.d.ts +1 -0
  30. package/build/src/akuma/heart/storage.js +15 -0
  31. package/build/src/akuma/heart/timeline.d.ts +1 -5
  32. package/build/src/akuma/heart/timeline.js +8 -17
  33. package/build/src/akuma/index.d.ts +5 -2
  34. package/build/src/akuma/index.js +1 -0
  35. package/build/src/akuma/projection.d.ts +17 -3
  36. package/build/src/akuma/projection.js +40 -3
  37. package/build/src/akuma/provider-recipe.js +1 -11
  38. package/build/src/akuma/provider.d.ts +2 -7
  39. package/build/src/akuma/provider.js +2 -1
  40. package/build/src/akuma/providers/acp/core.d.ts +3 -1
  41. package/build/src/akuma/providers/acp/core.js +10 -6
  42. package/build/src/akuma/providers/acp/events.d.ts +11 -3
  43. package/build/src/akuma/providers/acp/events.js +78 -4
  44. package/build/src/akuma/providers/acp/index.js +0 -1
  45. package/build/src/akuma/providers/claude/events.js +62 -3
  46. package/build/src/akuma/providers/claude/index.d.ts +0 -4
  47. package/build/src/akuma/providers/claude/index.js +7 -3
  48. package/build/src/akuma/providers/codex-app-server/events.js +1 -13
  49. package/build/src/akuma/providers/codex-app-server/index.d.ts +2 -27
  50. package/build/src/akuma/providers/codex-app-server/index.js +0 -2
  51. package/build/src/akuma/providers/grok-build/index.d.ts +2 -1
  52. package/build/src/akuma/providers/grok-build/index.js +72 -3
  53. package/build/src/akuma/providers/opencode-sdk/events.js +71 -6
  54. package/build/src/akuma/providers/opencode-sdk/index.d.ts +2 -28
  55. package/build/src/akuma/providers/opencode-sdk/index.js +8 -4
  56. package/build/src/akuma/providers/opencode-sdk/session.d.ts +1 -1
  57. package/build/src/akuma/providers/opencode-sdk/session.js +1 -1
  58. package/build/src/akuma/providers/pi/events.js +17 -3
  59. package/build/src/akuma/providers/pi/index.js +11 -4
  60. package/build/src/akuma/providers/unified-patch.d.ts +4 -0
  61. package/build/src/akuma/providers/unified-patch.js +14 -0
  62. package/build/src/akuma/publication.d.ts +1 -1
  63. package/build/src/akuma/publication.js +1 -1
  64. package/build/src/akuma/request-serve.d.ts +87 -0
  65. package/build/src/akuma/request-serve.js +484 -0
  66. package/build/src/akuma/request-wire.d.ts +124 -0
  67. package/build/src/akuma/request-wire.js +380 -0
  68. package/build/src/akuma/requests.d.ts +41 -41
  69. package/build/src/akuma/requests.js +75 -374
  70. package/build/src/akuma-body.d.ts +8 -0
  71. package/build/src/akuma-body.js +84 -0
  72. package/build/src/body/arc.js +4 -29
  73. package/build/src/body/decode.js +5 -39
  74. package/build/src/body/envelope.d.ts +7 -0
  75. package/build/src/body/envelope.js +37 -0
  76. package/build/src/cli/accepted.d.ts +4 -1
  77. package/build/src/cli/accepted.js +39 -9
  78. package/build/src/cli/commands/akuma-invoke.d.ts +8 -7
  79. package/build/src/cli/commands/akuma-invoke.js +18 -10
  80. package/build/src/cli/commands/akuma.d.ts +11 -2
  81. package/build/src/cli/commands/akuma.js +67 -28
  82. package/build/src/cli/commands/amend.d.ts +1 -1
  83. package/build/src/cli/commands/amend.js +1 -1
  84. package/build/src/cli/commands/contract.d.ts +8 -8
  85. package/build/src/cli/commands/contract.js +3 -3
  86. package/build/src/cli/commands/install.js +2 -2
  87. package/build/src/cli/commands/task-invoke.js +98 -9
  88. package/build/src/cli/commands/task-query.d.ts +1 -1
  89. package/build/src/cli/commands/task-query.js +11 -5
  90. package/build/src/cli/coordinates.d.ts +2 -0
  91. package/build/src/cli/coordinates.js +12 -5
  92. package/build/src/cli/invoke.d.ts +1 -0
  93. package/build/src/cli/invoke.js +116 -75
  94. package/build/src/cli/main.d.ts +2 -0
  95. package/build/src/cli/main.js +29 -4
  96. package/build/src/cli/parse.d.ts +3 -2
  97. package/build/src/cli/parse.js +25 -8
  98. package/build/src/cli/render/akuma.d.ts +2 -2
  99. package/build/src/cli/render/akuma.js +138 -24
  100. package/build/src/cli/render/audit.js +18 -8
  101. package/build/src/cli/render/contract.d.ts +2 -0
  102. package/build/src/cli/render/contract.js +243 -36
  103. package/build/src/cli/render/kanshi.js +64 -29
  104. package/build/src/cli/render/receipt.d.ts +2 -1
  105. package/build/src/cli/render/receipt.js +37 -2
  106. package/build/src/cli/render/terminal.d.ts +0 -2
  107. package/build/src/cli/render/terminal.js +0 -29
  108. package/build/src/cli/render/text.js +3 -1
  109. package/build/src/cli/result.d.ts +52 -9
  110. package/build/src/cli/selectors.d.ts +1 -0
  111. package/build/src/cli/selectors.js +9 -6
  112. package/build/src/contract-worktree.d.ts +1 -2
  113. package/build/src/contract-worktree.js +7 -9
  114. package/build/src/core/facts/codec.js +9 -0
  115. package/build/src/core/facts/fold.js +13 -1
  116. package/build/src/core/facts/types.d.ts +8 -1
  117. package/build/src/core/subject.js +4 -3
  118. package/build/src/core/verbs/placement.d.ts +9 -1
  119. package/build/src/core/verbs/placement.js +24 -6
  120. package/build/src/core/verbs/reintegrate.d.ts +13 -0
  121. package/build/src/core/verbs/reintegrate.js +24 -0
  122. package/build/src/dispatch/index.d.ts +1 -1
  123. package/build/src/dispatch/index.js +50 -39
  124. package/build/src/git/admission.d.ts +2 -1
  125. package/build/src/git/hooks.d.ts +0 -4
  126. package/build/src/git/hooks.js +0 -36
  127. package/build/src/git/integration.d.ts +7 -8
  128. package/build/src/git/integration.js +62 -9
  129. package/build/src/git/observe.d.ts +2 -1
  130. package/build/src/git/observe.js +6 -5
  131. package/build/src/git/process.d.ts +26 -0
  132. package/build/src/git/process.js +94 -0
  133. package/build/src/git/read-observation.d.ts +2 -1
  134. package/build/src/git/read-observation.js +3 -2
  135. package/build/src/git/reconcile.d.ts +8 -2
  136. package/build/src/git/reconcile.js +63 -14
  137. package/build/src/git/repository.d.ts +2 -29
  138. package/build/src/git/repository.js +4 -118
  139. package/build/src/git/scratch.d.ts +1 -1
  140. package/build/src/git/scratch.js +1 -1
  141. package/build/src/git/target-placement.d.ts +1 -1
  142. package/build/src/git/target-placement.js +9 -7
  143. package/build/src/git/tender.d.ts +20 -5
  144. package/build/src/git/tender.js +45 -13
  145. package/build/src/git/terminal-seal.d.ts +16 -2
  146. package/build/src/git/terminal-seal.js +15 -5
  147. package/build/src/git/workspace.d.ts +2 -1
  148. package/build/src/git/workspace.js +13 -5
  149. package/build/src/index.d.ts +1 -2
  150. package/build/src/index.js +1 -1
  151. package/build/src/kanshi/index.d.ts +1 -1
  152. package/build/src/kanshi/index.js +1 -1
  153. package/build/src/kanshi/read.d.ts +9 -1
  154. package/build/src/kanshi/read.js +91 -37
  155. package/build/src/kanshi/report.d.ts +1 -0
  156. package/build/src/library/address.d.ts +5 -14
  157. package/build/src/library/address.js +27 -23
  158. package/build/src/library/akuma-creation.d.ts +4 -2
  159. package/build/src/library/akuma-creation.js +43 -26
  160. package/build/src/library/audit.d.ts +2 -1
  161. package/build/src/library/audit.js +1 -1
  162. package/build/src/library/bind.d.ts +2 -1
  163. package/build/src/library/bind.js +4 -4
  164. package/build/src/library/catalog.d.ts +1 -2
  165. package/build/src/library/catalog.js +11 -6
  166. package/build/src/library/configuration.d.ts +5 -1
  167. package/build/src/library/configuration.js +71 -18
  168. package/build/src/library/contract.d.ts +70 -3
  169. package/build/src/library/contract.js +213 -27
  170. package/build/src/library/delivery.d.ts +1 -1
  171. package/build/src/library/fleet.d.ts +70 -12
  172. package/build/src/library/fleet.js +236 -56
  173. package/build/src/library/input.d.ts +0 -1
  174. package/build/src/library/input.js +1 -5
  175. package/build/src/library/keiyaku.d.ts +4 -4
  176. package/build/src/library/keiyaku.js +1 -2
  177. package/build/src/library/mutation.d.ts +2 -1
  178. package/build/src/library/reconcile.d.ts +2 -1
  179. package/build/src/library/reconcile.js +3 -1
  180. package/build/src/library/region.d.ts +1 -1
  181. package/build/src/library/repo.d.ts +3 -1
  182. package/build/src/library/repo.js +8 -4
  183. package/build/src/protocol/abandon.d.ts +9 -0
  184. package/build/src/protocol/abandon.js +15 -0
  185. package/build/src/protocol/amend.d.ts +16 -0
  186. package/build/src/protocol/amend.js +77 -0
  187. package/build/src/protocol/arc.d.ts +6 -0
  188. package/build/src/protocol/arc.js +12 -0
  189. package/build/src/protocol/attempt.d.ts +2 -1
  190. package/build/src/protocol/audit.d.ts +53 -0
  191. package/build/src/protocol/audit.js +140 -0
  192. package/build/src/protocol/bind.d.ts +2 -3
  193. package/build/src/protocol/bind.js +2 -16
  194. package/build/src/protocol/completion.d.ts +32 -0
  195. package/build/src/protocol/completion.js +130 -0
  196. package/build/src/protocol/deliver.d.ts +37 -0
  197. package/build/src/protocol/deliver.js +160 -0
  198. package/build/src/protocol/intent.d.ts +1 -1
  199. package/build/src/protocol/intent.js +1 -1
  200. package/build/src/protocol/operations.d.ts +65 -198
  201. package/build/src/protocol/operations.js +21 -634
  202. package/build/src/protocol/placement.d.ts +4 -13
  203. package/build/src/protocol/placement.js +3 -15
  204. package/build/src/protocol/read/status.d.ts +4 -2
  205. package/build/src/protocol/read/status.js +27 -15
  206. package/build/src/protocol/reconcile.d.ts +35 -0
  207. package/build/src/protocol/reconcile.js +41 -0
  208. package/build/src/protocol/reintegrate.d.ts +31 -0
  209. package/build/src/protocol/reintegrate.js +74 -0
  210. package/build/src/protocol/review.d.ts +33 -0
  211. package/build/src/protocol/review.js +148 -0
  212. package/build/src/protocol/run.d.ts +1 -1
  213. package/build/src/runtime/proc/run.d.ts +1 -0
  214. package/build/src/runtime/proc/run.js +9 -2
  215. package/build/src/settlement/fence.d.ts +1 -1
  216. package/build/src/settlement/holder.d.ts +1 -1
  217. package/build/src/settlement/settle.d.ts +2 -1
  218. package/build/src/settlement/settle.js +4 -1
  219. package/build/src/task/board.d.ts +18 -4
  220. package/build/src/task/board.js +73 -29
  221. package/build/src/task/compose.d.ts +1 -1
  222. package/build/src/task/compose.js +11 -4
  223. package/build/src/task/index.d.ts +4 -4
  224. package/build/src/task/index.js +8 -131
  225. package/build/src/task/input.d.ts +18 -0
  226. package/build/src/task/input.js +189 -0
  227. package/build/src/task/mutation.d.ts +39 -0
  228. package/build/src/task/mutation.js +85 -0
  229. package/build/src/task/operations.d.ts +4 -19
  230. package/build/src/task/operations.js +64 -18
  231. package/build/src/task/query.d.ts +9 -2
  232. package/build/src/task/query.js +32 -64
  233. package/build/src/task/store.js +0 -2
  234. package/build/src/verification/execution.d.ts +1 -1
  235. package/build/src/verification/execution.js +2 -1
  236. package/build/src/workspace-place.d.ts +1 -4
  237. package/build/src/workspace-place.js +0 -15
  238. package/package.json +5 -3
@@ -0,0 +1,160 @@
1
+ import { materializeIntegrationSnapshot, planIntegration, worktreeChangeId, } from "../git/integration.js";
2
+ import { captureTender, dirtyTenderRefusal, materializeTenderSnapshot, prepareDeliveryCommitMetadata, } from "../git/tender.js";
3
+ import { currentBranch, observeContractsForAdmissionAt } from "../git/observe.js";
4
+ import { contractState } from "../core/facts/observation.js";
5
+ import { decideDeliver } from "../core/verbs/deliver.js";
6
+ import { admitDecidedOffer, mintAttempts } from "./attempt.js";
7
+ import { admitted } from "./outcome.js";
8
+ import { completeCandidate } from "./completion.js";
9
+ import { appointmentFor, readPlaceRegister } from "../workspace-place.js";
10
+ import { timestamp } from "./operations.js";
11
+ export async function prepareDelivery(repository, stage, input) {
12
+ const { contractId, coordinates } = stage;
13
+ if (coordinates.workspace === "here" && coordinates.target !== undefined) {
14
+ const branch = await currentBranch(repository);
15
+ if (branch !== coordinates.target) {
16
+ return {
17
+ kind: "refused",
18
+ refusal: { kind: "workspace-not-on-target", contractId, target: coordinates.target, branch },
19
+ };
20
+ }
21
+ }
22
+ const appointed = coordinates.workspace === "worktree"
23
+ ? stage.appointment === undefined
24
+ ? appointmentFor(await readPlaceRegister(repository), contractId)
25
+ : { contract: contractId, place: stage.appointment.place }
26
+ : undefined;
27
+ const tender = await captureTender(repository, {
28
+ contractId,
29
+ coordinates,
30
+ ...(appointed === undefined ? {} : { place: appointed.place }),
31
+ });
32
+ if (tender.kind === "refused")
33
+ return tender;
34
+ if ((tender.data.dirty && input.includeDirty !== true) || tender.data.changes.submodules.length > 0) {
35
+ return { kind: "refused", refusal: await dirtyTenderRefusal(repository, contractId, tender.data) };
36
+ }
37
+ const commit = await prepareDeliveryCommitMetadata(repository, {
38
+ contractId,
39
+ title: input.title,
40
+ document: input.document,
41
+ at: tender.data.at,
42
+ ...(input.actor === undefined ? {} : { actor: input.actor }),
43
+ ...(input.message === undefined ? {} : { message: input.message }),
44
+ });
45
+ const tenderSnapshot = await materializeTenderSnapshot(repository, tender.data, commit);
46
+ const requireBranchesToBeUpToDate = input.requireBranchesToBeUpToDate ?? false;
47
+ const integration = await planIntegration(repository, { contractId, coordinates }, { ...tender.data, head: tenderSnapshot }, requireBranchesToBeUpToDate);
48
+ if (integration.kind === "refused")
49
+ return integration;
50
+ const integrationSnapshot = coordinates.target === undefined
51
+ ? tenderSnapshot
52
+ : await materializeIntegrationSnapshot(repository, integration.data.tree, integration.data.predecessor, commit);
53
+ return {
54
+ kind: "prepared",
55
+ data: {
56
+ tenderSnapshot,
57
+ integration: {
58
+ predecessor: integration.data.predecessor,
59
+ snapshot: integrationSnapshot,
60
+ changeId: await worktreeChangeId(repository, { contractId, coordinates }, tender.data),
61
+ },
62
+ method: "squash",
63
+ policy: { requireBranchesToBeUpToDate },
64
+ },
65
+ };
66
+ }
67
+ async function deliverAttempt(input, attempt) {
68
+ const decisionObservation = await observeContractsForAdmissionAt(input.scope, input.channel, [input.contractId]);
69
+ const state = contractState(decisionObservation.decision, input.contractId);
70
+ const derivation = state === null ? undefined : input.deriveDocument(state);
71
+ let preparation;
72
+ if (state === null || derivation === undefined) {
73
+ preparation = { kind: "unavailable" };
74
+ }
75
+ else if (derivation.verification.kind === "refused") {
76
+ preparation = { kind: "refused", document: derivation.document, refusal: derivation.verification.refusal };
77
+ }
78
+ else {
79
+ const prepared = await prepareDelivery(input.scope, { contractId: state.id, coordinates: state.coordinates }, {
80
+ title: derivation.title,
81
+ document: derivation.bytes,
82
+ ...(input.actor === undefined ? {} : { actor: input.actor }),
83
+ ...(input.message === undefined ? {} : { message: input.message }),
84
+ requireBranchesToBeUpToDate: input.requireBranchesToBeUpToDate,
85
+ includeDirty: input.includeDirty,
86
+ });
87
+ preparation = prepared.kind === "refused"
88
+ ? { kind: "refused", document: derivation.document, refusal: prepared.refusal }
89
+ : { kind: "prepared", document: derivation.document, data: prepared.data };
90
+ }
91
+ const decision = decideDeliver({
92
+ input: {
93
+ contractId: input.contractId,
94
+ ...(input.actor === undefined ? {} : { actor: input.actor }),
95
+ at: timestamp(),
96
+ preparation,
97
+ },
98
+ attempt,
99
+ observation: decisionObservation.decision,
100
+ });
101
+ if (decision.kind === "refused")
102
+ return { kind: "refused", refusal: decision.refusal };
103
+ if (preparation.kind !== "prepared")
104
+ throw new Error("offered delivery is missing its mechanical preparation");
105
+ const admission = await admitDecidedOffer({
106
+ channel: input.channel,
107
+ repository: input.scope,
108
+ decisionObservation,
109
+ attempt,
110
+ offer: decision.offer,
111
+ primaryContract: input.contractId,
112
+ });
113
+ if (admission.kind === "accepted") {
114
+ if (derivation === undefined)
115
+ throw new Error("accepted delivery is missing its document derivation");
116
+ return { ...admission, value: { delivery: preparation.data, derivation } };
117
+ }
118
+ return admission;
119
+ }
120
+ async function completeDelivery(input, first) {
121
+ const derivation = first.value.derivation;
122
+ if (derivation.verification.kind !== "prepared") {
123
+ throw new Error("accepted delivery is missing its Verification preparation");
124
+ }
125
+ const completed = await completeCandidate({
126
+ channel: input.channel,
127
+ repository: input.scope,
128
+ contractId: input.contractId,
129
+ ...(input.actor === undefined ? {} : { actor: input.actor }),
130
+ ...(input.signal === undefined ? {} : { signal: input.signal }),
131
+ ...(first.state.coordinates.target === undefined ? {} : { target: first.state.coordinates.target }),
132
+ verification: derivation.verification,
133
+ initial: first,
134
+ verifyInitial: true,
135
+ });
136
+ return admitted(completed.admission, {
137
+ ...first.value.delivery,
138
+ ...completed.evidence,
139
+ });
140
+ }
141
+ export async function deliverOperation(input) {
142
+ const attempts = mintAttempts({ entryCount: 2 });
143
+ let first = null;
144
+ for (let index = 0; index < attempts.length; index += 1) {
145
+ const result = await deliverAttempt(input, attempts[index]);
146
+ if (result.kind === "accepted") {
147
+ first = result;
148
+ break;
149
+ }
150
+ if (result.kind === "refused")
151
+ return result;
152
+ if (result.kind === "publication-failed")
153
+ return { kind: "retry", reason: result };
154
+ if (result.kind === "collision" && index + 1 === attempts.length)
155
+ return { kind: "retry", reason: result };
156
+ }
157
+ if (first === null)
158
+ return { kind: "retry", reason: { kind: "exhausted" } };
159
+ return await completeDelivery(input, first);
160
+ }
@@ -1,6 +1,6 @@
1
1
  import type { GitDecisionObservation } from "../git/observe.js";
2
2
  import type { GitDecodeChannel, GitTreeSelection } from "../git/read-observation.js";
3
- import type { GitRepository } from "../git/repository.js";
3
+ import type { GitRepository } from "../git/process.js";
4
4
  import type { GitRefAssertion } from "../git/repository.js";
5
5
  import { type WorktreeLeak } from "../git/scratch.js";
6
6
  import type { HookFailure } from "../git/hooks.js";
@@ -51,7 +51,7 @@ export function currentVerifiedAttestation(state) {
51
51
  }
52
52
  /** Run Verification against an explicit or admitted integration snapshot. */
53
53
  export async function verifyDelivery(input) {
54
- const snapshot = input.snapshot ?? input.state.delivery?.data.integration.snapshot;
54
+ const snapshot = input.snapshot ?? input.state.currentIntegration?.snapshot;
55
55
  if (snapshot === undefined || input.verification === undefined)
56
56
  return null;
57
57
  const subject = dependencyKeySet([
@@ -1,122 +1,102 @@
1
- import { type DeliveryDiffScope, type IntegrationPreparationRefusal } from "../git/integration.js";
2
- import { type DirtyWorkspaceRefusal, type WorkspaceDirtyDelta } from "../git/tender.js";
3
- import { type ReconcileResult } from "../git/reconcile.js";
4
- import type { WorktreeHooks } from "../git/hooks.js";
5
- import { NoGitWorldError, type GitRepository } from "../git/repository.js";
6
- import { type GitDecodeChannel, type GitTreeSelection } from "../git/read-observation.js";
1
+ import { type DirtyWorkspaceRefusal } from "../git/tender.js";
2
+ import type { GitRepository } from "../git/process.js";
3
+ import { type GitDecodeChannel } from "../git/read-observation.js";
7
4
  import type { WorktreeLeak } from "../git/scratch.js";
8
- import type { ActorId, AmendData, ArcData, AttestationData, ChangeId, ContractId, ContractState, ContractTerms, DeliverData, DocumentKey, SnapshotId } from "../core/facts/types.js";
9
- import { type AbandonRefusal } from "../core/verbs/abandon.js";
10
- import { type AmendRefusal } from "../core/verbs/amend.js";
11
- import { type ArcRefusal } from "../core/verbs/arc.js";
12
- import { type DeliverRefusal } from "../core/verbs/deliver.js";
5
+ import type { AbandonRefusal } from "../core/verbs/abandon.js";
6
+ import type { AmendRefusal } from "../core/verbs/amend.js";
7
+ import type { ArcRefusal } from "../core/verbs/arc.js";
8
+ import type { DeliverRefusal } from "../core/verbs/deliver.js";
13
9
  import type { PlacementRefusal } from "../core/verbs/placement.js";
14
- import { type AttestationRefusal } from "../core/verbs/attestation.js";
10
+ import type { AttestationRefusal } from "../core/verbs/attestation.js";
11
+ import type { ContractId, ContractState, DeliverData, DocumentKey, SnapshotId } from "../core/facts/types.js";
12
+ import type { BindRefusal, TargetInputRefusal } from "./bind.js";
13
+ import type { IntegrationPreparationRefusal } from "../git/integration.js";
14
+ import type { TargetPlacementRefusal } from "../git/target-placement.js";
15
+ import type { VerificationCleanupFailure, VerificationRuntimeStop, VerificationResult } from "./intent.js";
15
16
  import type { VerificationDeclarationPreparation, VerificationDeclarationRefusal } from "../verification/declaration.js";
16
- import { type CurrentVerifiedAttestation, type VerificationRuntimeStop, type VerificationCleanupFailure } from "./intent.js";
17
- import { type AuditTargetAnswer, type TargetPlacementRefusal } from "../git/target-placement.js";
17
+ import type { PlacementProtocolResult } from "./placement.js";
18
+ import type { AcceptedAdmission, DecidedOfferResult } from "./attempt.js";
19
+ import type { AcceptedProtocolStep, IntentOutcome as ProtocolIntentOutcome } from "./outcome.js";
20
+ import type { ProtocolResult, ProtocolTerminal } from "./run.js";
18
21
  import { type ContractDocumentProjection } from "./read/documents.js";
19
- import { type ContractBoard, type ContractDisposition, type ContractGateCurrent, type ContractGateReport, type ContractObservation, type ContractPhase, type ContractRow } from "./read/status.js";
20
- import { type ManagedWorktreeAppointment } from "../workspace-place.js";
21
- export { bindOperation } from "./bind.js";
22
- export { reconcileObservationFailure } from "../git/reconcile.js";
23
- import type { BindRefusal, TargetInputRefusal } from "./bind.js";
24
- import { type IntentOutcome as ProtocolIntentOutcome } from "./outcome.js";
25
- import type { ProtocolTerminal } from "./run.js";
26
- import type { CompanionDecorator } from "./run.js";
27
- export type { FactKind } from "../core/facts/types.js";
28
- export type { ContractDocumentProjection } from "./read/documents.js";
22
+ import { type ContractBoard, type ContractObservation } from "./read/status.js";
29
23
  export type DeliveryPreparationRefusal = Readonly<{
30
24
  kind: "target-missing" | "worktree-missing";
31
25
  contractId: ContractId;
32
26
  }> | DirtyWorkspaceRefusal | IntegrationPreparationRefusal | TargetPlacementRefusal;
33
- type ReviewPreparationRefusal = Readonly<{
34
- kind: "worktree-missing";
35
- contractId: ContractId;
36
- }> | DirtyWorkspaceRefusal;
37
- type ReviewRefusal = AttestationRefusal | ReviewPreparationRefusal;
38
- export type IntentRefusal = AbandonRefusal | AmendRefusal | ArcRefusal | BindRefusal | DeliverRefusal | DeliveryPreparationRefusal | PlacementRefusal | ReviewRefusal | TargetInputRefusal | VerificationDeclarationRefusal;
39
- export type { TargetInputRefusal } from "./bind.js";
27
+ export type IntentRefusal = AbandonRefusal | AmendRefusal | ArcRefusal | BindRefusal | DeliverRefusal | DeliveryPreparationRefusal | PlacementRefusal | AttestationRefusal | TargetInputRefusal | VerificationDeclarationRefusal;
40
28
  export type IntentRetry = ProtocolTerminal;
41
29
  export type IntentOutcome<Value, Refusal = IntentRefusal> = ProtocolIntentOutcome<Value, Refusal>;
42
30
  type OperationInput = Readonly<{
43
31
  scope: RepositoryScope;
44
32
  contractId: ContractId;
45
- actor?: ActorId;
33
+ actor?: import("../core/facts/types.js").ActorId;
46
34
  }>;
47
- type MutationOperationInput = OperationInput & Readonly<{
35
+ export type MutationOperationInput = OperationInput & Readonly<{
48
36
  channel: GitDecodeChannel;
49
37
  }>;
50
- export type AuditWorkspace = Readonly<{
51
- kind: "worktree" | "here";
52
- path: string;
53
- }>;
54
- export type DiffScope = DeliveryDiffScope;
55
- export type AuditReport = Readonly<{
56
- candidate: Readonly<{
57
- kind: "blocked";
58
- refusal: DeliveryPreparationRefusal;
59
- }> | Readonly<{
60
- kind: "ready";
61
- workspace: AuditWorkspace;
62
- identity: DeliveryIdentity;
63
- scope: DiffScope;
64
- diff?: string;
65
- }>;
66
- verification: Readonly<{
67
- kind: "not-run";
68
- }> | Readonly<{
69
- kind: "satisfied";
70
- passed: number;
71
- total: number;
72
- summary?: string;
73
- }> | Readonly<{
74
- kind: "unsatisfied";
75
- passed: number;
76
- total: number;
77
- summary?: string;
78
- }> | Readonly<{
79
- kind: "stopped";
80
- stop: VerificationStop;
81
- }>;
82
- target: Readonly<{
83
- kind: "not-observed";
84
- }> | AuditTargetAnswer;
85
- delivery?: Readonly<{
86
- changeId: ChangeId;
87
- relation: "identical" | "differs";
88
- }>;
89
- }>;
90
- export type VerificationReuse = CurrentVerifiedAttestation;
91
38
  export type DocumentDerivation = Readonly<{
92
39
  document: DocumentKey;
40
+ bytes: string;
93
41
  title: string;
94
42
  verification: VerificationDeclarationPreparation;
95
43
  }>;
96
- export type StepStop<R> = Readonly<{
44
+ type StepStop<R> = Readonly<{
97
45
  refusal: R;
98
46
  retry?: never;
99
47
  } | {
100
48
  retry: IntentRetry;
101
49
  refusal?: never;
102
50
  }>;
103
- export type VerificationStop = StepStop<AttestationRefusal> | VerificationRuntimeStop;
104
- export type PlacementStop = StepStop<PlacementRefusal | TargetPlacementRefusal | IntegrationPreparationRefusal> | Readonly<{
51
+ export type VerificationStop = StepStop<AttestationRefusal | VerificationDeclarationRefusal> | VerificationRuntimeStop;
52
+ export type PlacementStop = StepStop<PlacementRefusal | TargetPlacementRefusal | IntegrationPreparationRefusal | Readonly<{
53
+ kind: "target-missing";
54
+ contractId: ContractId;
55
+ }>> | Readonly<{
105
56
  failure: "target-moved";
106
57
  contractId: ContractId;
107
58
  target: string;
108
59
  expected: SnapshotId;
109
60
  observed: SnapshotId | null;
61
+ }> | Readonly<{
62
+ failure: "target-moved";
63
+ contractId: ContractId;
64
+ target: string;
65
+ integratedAt: SnapshotId;
66
+ observed: SnapshotId | null;
67
+ attempts: number;
110
68
  }> | Readonly<{
111
69
  failure: "target-placement-failed";
112
70
  diagnostic: string;
113
71
  }>;
114
- type ScopeOperationInput = Readonly<{
115
- coordinate: string;
72
+ export type AttemptDecision<Value, Refusal = IntentRefusal> = (AcceptedAdmission & Readonly<{
73
+ value: Value;
74
+ }>) | Readonly<{
75
+ kind: "refused";
76
+ refusal: Refusal;
77
+ }> | Readonly<{
78
+ kind: "redecide";
79
+ }> | Readonly<{
80
+ kind: "collision";
81
+ }> | Extract<DecidedOfferResult, {
82
+ kind: "publication-failed";
83
+ }>;
84
+ export declare function timestamp(): string;
85
+ export declare function mergeAdmissions(current: AcceptedProtocolStep, next: AcceptedProtocolStep): AcceptedProtocolStep;
86
+ export declare function stepStop<Refusal>(result: ProtocolResult<Refusal>): StepStop<Refusal> | undefined;
87
+ export declare function unpackVerificationOutcome(verification: VerificationResult): Readonly<{
88
+ cleanup?: VerificationCleanupFailure;
89
+ leak?: WorktreeLeak;
90
+ stop?: VerificationStop;
91
+ admission?: AcceptedProtocolStep;
92
+ counts?: NonNullable<VerificationResult["counts"]>;
116
93
  }>;
94
+ export declare function placementStop(result: PlacementProtocolResult<IntegrationPreparationRefusal>): PlacementStop | undefined;
117
95
  export type RepositoryScope = GitRepository;
118
- export { NoGitWorldError };
119
- export declare function scopeOperation(input: ScopeOperationInput): Promise<RepositoryScope>;
96
+ export declare function scopeOperation(input: Readonly<{
97
+ coordinate: string;
98
+ gitPath?: string;
99
+ }>): Promise<RepositoryScope>;
120
100
  export declare function currentBranchOperation(input: Readonly<{
121
101
  scope: RepositoryScope;
122
102
  }>): Promise<string | null>;
@@ -125,125 +105,12 @@ export declare function contractsOperation(input: Readonly<{
125
105
  channel: GitDecodeChannel;
126
106
  }>): Promise<ContractBoard>;
127
107
  export declare function contractObservationOperation(input: MutationOperationInput): Promise<ContractObservation>;
128
- export type { ContractBoard, ContractDisposition, ContractGateCurrent, ContractGateReport, ContractObservation, ContractPhase, ContractRow };
129
108
  export declare function documentsOperationAt(scope: RepositoryScope, channel: GitDecodeChannel): Promise<readonly ContractDocumentProjection[]>;
130
109
  export declare function stateOperation(input: MutationOperationInput): Promise<ContractState>;
131
- type DeliveryIdentity = DeliverData;
132
- export declare function deliveryOperation(input: MutationOperationInput): Promise<DeliveryIdentity | null>;
133
- type DeliveryDiffOperationInput = Readonly<{
110
+ export declare function deliveryOperation(input: MutationOperationInput): Promise<DeliverData | null>;
111
+ export declare function deliveryDiffOperation(input: Readonly<{
134
112
  scope: RepositoryScope;
135
113
  integrationPredecessor: SnapshotId;
136
114
  integrationSnapshot: SnapshotId;
137
- }>;
138
- export declare function deliveryDiffOperation(input: DeliveryDiffOperationInput): Promise<string | null>;
139
- type AmendOperationInput = MutationOperationInput & Readonly<{
140
- source?: ContractTerms;
141
- deriveAmendment?: (source: ContractTerms) => Readonly<{
142
- terms: AmendData;
143
- verification: VerificationDeclarationPreparation;
144
- }>;
145
- }>;
146
- type Amendment = Readonly<{
147
- source: ContractTerms;
148
- }> & ReturnType<NonNullable<AmendOperationInput["deriveAmendment"]>>;
149
- export declare function amendOperation(input: AmendOperationInput): Promise<IntentOutcome<Amendment, AmendRefusal | VerificationDeclarationRefusal>>;
150
- export type DeliverValue = DeliveryIdentity & Readonly<{
151
- verification?: VerificationStop;
152
- verificationReuse?: VerificationReuse;
153
- placement?: PlacementStop;
154
- cleanup?: VerificationCleanupFailure;
155
- leak?: WorktreeLeak;
156
- }>;
157
- type DeliverOperationInput = MutationOperationInput & Readonly<{
158
- deriveDocument?: (state: ContractState) => DocumentDerivation;
159
- message?: string;
160
- requireBranchesToBeUpToDate: boolean;
161
- includeDirty: boolean;
162
- signal?: AbortSignal;
163
- }>;
164
- export declare function prepareDelivery(repository: GitRepository, stage: Readonly<{
165
- contractId: ContractId;
166
- coordinates: ContractState["coordinates"];
167
- appointment?: Extract<ManagedWorktreeAppointment, {
168
- kind: "appointed";
169
- }>;
170
- }>, input: Readonly<{
171
- title: string;
172
- message?: string;
173
- requireBranchesToBeUpToDate?: boolean;
174
- includeDirty?: boolean;
175
- }>): Promise<{
176
- kind: "prepared";
177
- data: DeliverData;
178
- } | {
179
- kind: "refused";
180
- refusal: DeliveryPreparationRefusal;
181
- }>;
182
- export declare function prepareReview(repository: GitRepository, stage: Readonly<{
183
- contractId: ContractId;
184
- coordinates: ContractState["coordinates"];
185
- }>): Promise<{
186
- kind: "prepared";
187
- data: Readonly<{
188
- changeId: DeliverData["integration"]["changeId"];
189
- workspace?: WorkspaceDirtyDelta;
190
- }>;
191
- } | {
192
- kind: "refused";
193
- refusal: ReviewPreparationRefusal;
194
- }>;
195
- export declare function deliverOperation(input: DeliverOperationInput): Promise<IntentOutcome<DeliverValue>>;
196
- export declare function abandonOperation(input: MutationOperationInput & Readonly<{
197
- note?: string;
198
- decorateOffer?: CompanionDecorator;
199
- observationSelection?: GitTreeSelection;
200
- }>): Promise<IntentOutcome<void, AbandonRefusal>>;
201
- export declare function arcOperation(input: MutationOperationInput & Readonly<{
202
- chapter: Omit<ArcData, "seq">;
203
- }>): Promise<IntentOutcome<void, ArcRefusal>>;
204
- type ReviewOperationInput = MutationOperationInput & Readonly<{
205
- verdict: AttestationData["verdict"];
206
- summary?: string;
207
- }>;
208
- export type ReviewValue = Readonly<{
209
- placement?: PlacementStop;
210
- workspace?: WorkspaceDirtyDelta;
211
- }>;
212
- export declare function reviewOperation(input: ReviewOperationInput): Promise<IntentOutcome<ReviewValue, ReviewRefusal>>;
213
- type AuditOperationInput = MutationOperationInput & Readonly<{
214
- deriveDocument?: (state: ContractState) => DocumentDerivation;
215
- requireBranchesToBeUpToDate?: boolean;
216
- includeDirty?: boolean;
217
- showDiff?: boolean;
218
- signal?: AbortSignal;
219
- }>;
220
- export declare function auditOperation(input: AuditOperationInput): Promise<IntentOutcome<AuditReport>>;
221
- export type ReconcileReport = ReconcileResult;
222
- export type ReconcileObservation = Readonly<{
223
- state: ContractState | null;
224
- report: ReconcileReport;
225
- }>;
226
- type ReconcileOptions = Readonly<{
227
- hooks: WorktreeHooks;
228
- retryHooks: boolean;
229
- retainTerminalWorktree?: boolean;
230
- place?: string;
231
- places?: ReadonlyMap<ContractId, string>;
232
- }>;
233
- export declare function reconcileOperation(input: MutationOperationInput & ReconcileOptions): Promise<ReconcileObservation>;
234
- type RepoReconcileItem = Readonly<{
235
- contractId: ContractId;
236
- state: ContractState | null;
237
- report: ReconcileReport;
238
- }>;
239
- export type RepoReconcileReport = Readonly<{
240
- contracts: readonly RepoReconcileItem[];
241
- }>;
242
- export declare function worldContractStates(input: Readonly<{
243
- scope: RepositoryScope;
244
- channel: GitDecodeChannel;
245
- }>): Promise<readonly ContractState[]>;
246
- export declare function reconcileAllOperation(input: Readonly<{
247
- scope: RepositoryScope;
248
- channel: GitDecodeChannel;
249
- }> & ReconcileOptions): Promise<RepoReconcileReport>;
115
+ }>): Promise<string | null>;
116
+ export {};