@astrosheep/keiyaku 4.1.0 → 4.1.2

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 (278) hide show
  1. package/README.md +1 -1
  2. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +3 -0
  3. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +3 -0
  4. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +3 -6
  5. package/build/src/akuma/akuma-errors.d.ts +6 -0
  6. package/build/src/akuma/akuma-errors.js +9 -0
  7. package/build/src/akuma/akuma-handle.d.ts +39 -0
  8. package/build/src/akuma/akuma-handle.js +263 -0
  9. package/build/src/akuma/akuma-observe.d.ts +19 -0
  10. package/build/src/akuma/akuma-observe.js +74 -0
  11. package/build/src/akuma/akuma-product-symbols.d.ts +1 -0
  12. package/build/src/akuma/akuma-product-symbols.js +1 -0
  13. package/build/src/akuma/akuma-product.d.ts +18 -0
  14. package/build/src/akuma/akuma-product.js +154 -0
  15. package/build/src/akuma/akuma.d.ts +37 -81
  16. package/build/src/akuma/akuma.js +39 -447
  17. package/build/src/akuma/allowed.d.ts +1 -0
  18. package/build/src/akuma/allowed.js +6 -0
  19. package/build/src/akuma/archetype.js +8 -5
  20. package/build/src/akuma/body-supervisor.d.ts +26 -0
  21. package/build/src/akuma/body-supervisor.js +89 -0
  22. package/build/src/akuma/body.d.ts +45 -4
  23. package/build/src/akuma/body.js +145 -35
  24. package/build/src/akuma/coordinate.js +17 -7
  25. package/build/src/akuma/heart/facts.js +1 -1
  26. package/build/src/akuma/heart/index.d.ts +1 -1
  27. package/build/src/akuma/heart/index.js +2 -4
  28. package/build/src/akuma/heart/request-authority.js +4 -4
  29. package/build/src/akuma/heart/request-rows.js +27 -16
  30. package/build/src/akuma/heart/rows.js +79 -41
  31. package/build/src/akuma/heart/soul.js +1 -1
  32. package/build/src/akuma/heart/storage.d.ts +1 -0
  33. package/build/src/akuma/heart/storage.js +76 -11
  34. package/build/src/akuma/heart/tells.js +35 -18
  35. package/build/src/akuma/heart/timeline.js +19 -11
  36. package/build/src/akuma/identity.d.ts +1 -0
  37. package/build/src/akuma/identity.js +1 -0
  38. package/build/src/akuma/index.d.ts +3 -3
  39. package/build/src/akuma/index.js +1 -1
  40. package/build/src/akuma/nuke.js +106 -14
  41. package/build/src/akuma/projection-read.d.ts +17 -0
  42. package/build/src/akuma/projection-read.js +135 -0
  43. package/build/src/akuma/projection.d.ts +1 -16
  44. package/build/src/akuma/projection.js +77 -154
  45. package/build/src/akuma/provider-recipe.js +11 -5
  46. package/build/src/akuma/provider.js +105 -62
  47. package/build/src/akuma/providers/acp/config.js +5 -6
  48. package/build/src/akuma/providers/acp/core.js +17 -10
  49. package/build/src/akuma/providers/acp/events.js +38 -29
  50. package/build/src/akuma/providers/acp/index.js +13 -9
  51. package/build/src/akuma/providers/claude/events.js +8 -12
  52. package/build/src/akuma/providers/claude/index.d.ts +1 -0
  53. package/build/src/akuma/providers/claude/index.js +55 -26
  54. package/build/src/akuma/providers/claude/input.js +6 -2
  55. package/build/src/akuma/providers/codex-app-server/events.js +61 -36
  56. package/build/src/akuma/providers/codex-app-server/index.js +25 -13
  57. package/build/src/akuma/providers/grok-build/index.js +22 -25
  58. package/build/src/akuma/providers/index.js +2 -18
  59. package/build/src/akuma/providers/opencode-sdk/events.js +32 -18
  60. package/build/src/akuma/providers/opencode-sdk/index.js +26 -17
  61. package/build/src/akuma/providers/opencode-sdk/session.js +21 -5
  62. package/build/src/akuma/providers/pi/events.js +26 -19
  63. package/build/src/akuma/providers/pi/index.js +58 -40
  64. package/build/src/akuma/publication.js +9 -9
  65. package/build/src/akuma/request-execution.d.ts +6 -0
  66. package/build/src/akuma/request-execution.js +86 -0
  67. package/build/src/akuma/request-serve.d.ts +12 -1
  68. package/build/src/akuma/request-serve.js +19 -122
  69. package/build/src/akuma/request-wire.d.ts +2 -2
  70. package/build/src/akuma/request-wire.js +75 -102
  71. package/build/src/akuma/requests.js +2 -2
  72. package/build/src/akuma/{body-turn.d.ts → turn-drive.d.ts} +2 -25
  73. package/build/src/akuma/{body-turn.js → turn-drive.js} +20 -103
  74. package/build/src/akuma-body.js +6 -5
  75. package/build/src/body/amend.d.ts +4 -1
  76. package/build/src/body/amend.js +14 -6
  77. package/build/src/body/decode.js +2 -4
  78. package/build/src/body/envelope.js +2 -4
  79. package/build/src/body/region.d.ts +1 -2
  80. package/build/src/body/region.js +2 -70
  81. package/build/src/body/render.js +17 -12
  82. package/build/src/body/shape.js +1 -7
  83. package/build/src/cli/accepted.d.ts +1 -1
  84. package/build/src/cli/accepted.js +8 -1
  85. package/build/src/cli/commands/akuma-invoke.js +18 -6
  86. package/build/src/cli/commands/akuma.d.ts +0 -6
  87. package/build/src/cli/commands/akuma.js +11 -24
  88. package/build/src/cli/commands/amend.d.ts +2 -2
  89. package/build/src/cli/commands/amend.js +2 -4
  90. package/build/src/cli/commands/bind.d.ts +4 -4
  91. package/build/src/cli/commands/bind.js +16 -6
  92. package/build/src/cli/commands/contract-invoke.d.ts +25 -0
  93. package/build/src/cli/commands/contract-invoke.js +193 -0
  94. package/build/src/cli/commands/contract.d.ts +109 -10
  95. package/build/src/cli/commands/contract.js +339 -16
  96. package/build/src/cli/commands/install.d.ts +1 -1
  97. package/build/src/cli/commands/install.js +23 -15
  98. package/build/src/cli/commands/task-invoke.js +187 -67
  99. package/build/src/cli/commands/task-query.js +48 -24
  100. package/build/src/cli/commands/task.js +150 -38
  101. package/build/src/cli/coordinates.js +2 -4
  102. package/build/src/cli/invoke.js +92 -208
  103. package/build/src/cli/main.js +4 -2
  104. package/build/src/cli/parse.d.ts +3 -90
  105. package/build/src/cli/parse.js +27 -233
  106. package/build/src/cli/render/akuma-activity.d.ts +38 -0
  107. package/build/src/cli/render/akuma-activity.js +362 -0
  108. package/build/src/cli/render/akuma-tool-command.js +6 -7
  109. package/build/src/cli/render/akuma-tool.js +10 -8
  110. package/build/src/cli/render/akuma.d.ts +1 -1
  111. package/build/src/cli/render/akuma.js +61 -353
  112. package/build/src/cli/render/audit.js +5 -15
  113. package/build/src/cli/render/board.d.ts +1 -0
  114. package/build/src/cli/render/board.js +17 -0
  115. package/build/src/cli/render/catalog.js +81 -8
  116. package/build/src/cli/render/contract-history.d.ts +2 -0
  117. package/build/src/cli/render/contract-history.js +83 -0
  118. package/build/src/cli/render/contract-observation.d.ts +10 -0
  119. package/build/src/cli/render/contract-observation.js +58 -0
  120. package/build/src/cli/render/contract.d.ts +1 -2
  121. package/build/src/cli/render/contract.js +41 -142
  122. package/build/src/cli/render/kanshi.js +239 -215
  123. package/build/src/cli/render/receipt.js +2 -9
  124. package/build/src/cli/render/refusal.js +10 -15
  125. package/build/src/cli/render/region.js +22 -6
  126. package/build/src/cli/render/settings.js +4 -4
  127. package/build/src/cli/render/task.js +34 -14
  128. package/build/src/cli/render/terminal.js +16 -5
  129. package/build/src/cli/result.d.ts +3 -3
  130. package/build/src/cli/runtime.d.ts +6 -1
  131. package/build/src/cli/runtime.js +84 -63
  132. package/build/src/cli/selectors.js +2 -4
  133. package/build/src/cli/usage.js +6 -5
  134. package/build/src/contract-worktree.d.ts +1 -23
  135. package/build/src/contract-worktree.js +79 -155
  136. package/build/src/coordination/durable-file.js +7 -3
  137. package/build/src/coordination/sqlite-transaction-lock.js +29 -12
  138. package/build/src/core/facts/codec.js +7 -3
  139. package/build/src/core/facts/types.d.ts +1 -1
  140. package/build/src/core/subject.js +16 -9
  141. package/build/src/core/verbs/abandon.d.ts +1 -1
  142. package/build/src/core/verbs/abandon.js +1 -1
  143. package/build/src/core/verbs/amend.d.ts +1 -1
  144. package/build/src/core/verbs/amend.js +7 -7
  145. package/build/src/core/verbs/attestation.js +4 -1
  146. package/build/src/core/verbs/bind.d.ts +1 -1
  147. package/build/src/core/verbs/bind.js +1 -1
  148. package/build/src/core/verbs/placement.d.ts +1 -1
  149. package/build/src/core/verbs/placement.js +10 -8
  150. package/build/src/dispatch/index.js +8 -6
  151. package/build/src/duration.js +5 -1
  152. package/build/src/git/admission.js +5 -3
  153. package/build/src/git/hooks.d.ts +8 -0
  154. package/build/src/git/hooks.js +63 -14
  155. package/build/src/git/identity.js +1 -4
  156. package/build/src/git/integration.d.ts +2 -3
  157. package/build/src/git/integration.js +32 -39
  158. package/build/src/git/nuke.d.ts +1 -1
  159. package/build/src/git/nuke.js +110 -57
  160. package/build/src/git/observe.d.ts +13 -1
  161. package/build/src/git/observe.js +51 -44
  162. package/build/src/git/process.js +4 -2
  163. package/build/src/git/read-observation.js +10 -8
  164. package/build/src/git/reconcile.d.ts +22 -2
  165. package/build/src/git/reconcile.js +38 -274
  166. package/build/src/git/repository.d.ts +2 -0
  167. package/build/src/git/repository.js +13 -22
  168. package/build/src/git/scratch.d.ts +8 -5
  169. package/build/src/git/scratch.js +29 -2
  170. package/build/src/git/target-placement.d.ts +9 -10
  171. package/build/src/git/target-placement.js +59 -62
  172. package/build/src/git/tender.js +13 -46
  173. package/build/src/git/terminal-reconcile.d.ts +21 -0
  174. package/build/src/git/terminal-reconcile.js +278 -0
  175. package/build/src/git/terminal-seal.js +15 -12
  176. package/build/src/git/tree.js +5 -2
  177. package/build/src/git/workspace.d.ts +24 -2
  178. package/build/src/git/workspace.js +120 -16
  179. package/build/src/identity/coordinates.js +3 -1
  180. package/build/src/identity/selector.js +6 -3
  181. package/build/src/kanshi/fleet.d.ts +6 -0
  182. package/build/src/kanshi/fleet.js +27 -0
  183. package/build/src/kanshi/index.d.ts +1 -1
  184. package/build/src/kanshi/read.js +60 -48
  185. package/build/src/kanshi/report.d.ts +11 -23
  186. package/build/src/kanshi/select.js +25 -24
  187. package/build/src/library/address.d.ts +2 -1
  188. package/build/src/library/address.js +7 -8
  189. package/build/src/library/akuma-creation.js +20 -12
  190. package/build/src/library/audit.d.ts +0 -1
  191. package/build/src/library/audit.js +1 -2
  192. package/build/src/library/bind.d.ts +53 -5
  193. package/build/src/library/bind.js +98 -22
  194. package/build/src/library/catalog.d.ts +1 -0
  195. package/build/src/library/catalog.js +6 -3
  196. package/build/src/library/configuration.js +3 -1
  197. package/build/src/library/continuation.d.ts +15 -4
  198. package/build/src/library/continuation.js +24 -16
  199. package/build/src/library/contract-bind.d.ts +26 -0
  200. package/build/src/library/contract-bind.js +106 -0
  201. package/build/src/library/contract-operations.d.ts +77 -0
  202. package/build/src/library/contract-operations.js +130 -0
  203. package/build/src/library/contract-types.d.ts +95 -0
  204. package/build/src/library/contract-types.js +1 -0
  205. package/build/src/library/contract.d.ts +19 -154
  206. package/build/src/library/contract.js +46 -261
  207. package/build/src/library/fleet.d.ts +1 -1
  208. package/build/src/library/fleet.js +19 -11
  209. package/build/src/library/input.d.ts +2 -0
  210. package/build/src/library/input.js +14 -0
  211. package/build/src/library/keiyaku.d.ts +8 -7
  212. package/build/src/library/keiyaku.js +3 -3
  213. package/build/src/library/nuke.js +14 -5
  214. package/build/src/library/reconcile.d.ts +9 -4
  215. package/build/src/library/reconcile.js +30 -24
  216. package/build/src/library/refusal.d.ts +13 -5
  217. package/build/src/library/refusal.js +7 -0
  218. package/build/src/library/region.d.ts +8 -7
  219. package/build/src/library/region.js +31 -11
  220. package/build/src/library/repo.js +2 -2
  221. package/build/src/markdown/lex.js +9 -2
  222. package/build/src/markdown/parse.js +11 -7
  223. package/build/src/markdown/query.js +4 -2
  224. package/build/src/protocol/amend.js +3 -1
  225. package/build/src/protocol/attempt.d.ts +7 -3
  226. package/build/src/protocol/attempt.js +9 -5
  227. package/build/src/protocol/audit.d.ts +1 -1
  228. package/build/src/protocol/audit.js +4 -14
  229. package/build/src/protocol/bind.d.ts +19 -6
  230. package/build/src/protocol/bind.js +28 -13
  231. package/build/src/protocol/completion.d.ts +0 -1
  232. package/build/src/protocol/completion.js +1 -3
  233. package/build/src/protocol/deliver.d.ts +1 -3
  234. package/build/src/protocol/deliver.js +15 -39
  235. package/build/src/protocol/intent.d.ts +1 -0
  236. package/build/src/protocol/intent.js +9 -7
  237. package/build/src/protocol/operations.d.ts +3 -7
  238. package/build/src/protocol/operations.js +5 -3
  239. package/build/src/protocol/placement.d.ts +0 -1
  240. package/build/src/protocol/placement.js +6 -6
  241. package/build/src/protocol/read/observation.d.ts +11 -0
  242. package/build/src/protocol/read/observation.js +37 -0
  243. package/build/src/protocol/read/status.d.ts +23 -12
  244. package/build/src/protocol/read/status.js +90 -72
  245. package/build/src/protocol/reconcile.d.ts +1 -0
  246. package/build/src/protocol/reconcile.js +2 -3
  247. package/build/src/protocol/reintegrate.js +1 -1
  248. package/build/src/protocol/review.d.ts +0 -1
  249. package/build/src/protocol/review.js +15 -22
  250. package/build/src/protocol/run.d.ts +1 -0
  251. package/build/src/protocol/run.js +4 -5
  252. package/build/src/runtime/proc/launch.d.ts +33 -0
  253. package/build/src/runtime/proc/launch.js +98 -0
  254. package/build/src/runtime/proc/line-rpc.js +9 -3
  255. package/build/src/runtime/proc/run.d.ts +12 -6
  256. package/build/src/runtime/proc/run.js +78 -21
  257. package/build/src/runtime/proc/stdio.js +7 -10
  258. package/build/src/settings.js +6 -2
  259. package/build/src/settlement/holder.js +13 -10
  260. package/build/src/settlement/settle.js +39 -6
  261. package/build/src/task/board.js +12 -6
  262. package/build/src/task/compose.js +85 -22
  263. package/build/src/task/context.js +21 -8
  264. package/build/src/task/document.js +46 -10
  265. package/build/src/task/identity.js +5 -2
  266. package/build/src/task/index.d.ts +0 -1
  267. package/build/src/task/index.js +119 -34
  268. package/build/src/task/input.js +29 -7
  269. package/build/src/task/mutation.js +61 -19
  270. package/build/src/task/operations.d.ts +6 -1
  271. package/build/src/task/operations.js +83 -29
  272. package/build/src/task/query.js +55 -26
  273. package/build/src/task/store.d.ts +3 -1
  274. package/build/src/task/store.js +81 -17
  275. package/build/src/verification/execution.js +14 -11
  276. package/build/src/workspace-place.js +19 -7
  277. package/build/src/world.js +16 -6
  278. package/package.json +8 -3
@@ -1,4 +1,4 @@
1
- import { currentVerifiedAttestation, verifyDelivery } from "./intent.js";
1
+ import { currentVerifiedAttestation, verifyDelivery, } from "./intent.js";
2
2
  import { admitPlacement } from "./placement.js";
3
3
  import { reintegrateOperation } from "./reintegrate.js";
4
4
  import { mergeAdmissions, placementStop, timestamp, unpackVerificationOutcome } from "./operations.js";
@@ -112,7 +112,6 @@ async function admitCurrentPlacement(input) {
112
112
  ...(input.actor === undefined ? {} : { actor: input.actor }),
113
113
  at: timestamp(),
114
114
  },
115
- ...(input.hereWorkspacePath === undefined ? {} : { hereWorkspacePath: input.hereWorkspacePath }),
116
115
  });
117
116
  }
118
117
  export async function completeCandidate(input) {
@@ -144,7 +143,6 @@ export async function completeCandidate(input) {
144
143
  contractId: input.contractId,
145
144
  target: input.target,
146
145
  ...(input.actor === undefined ? {} : { actor: input.actor }),
147
- ...(input.hereWorkspacePath === undefined ? {} : { hereWorkspacePath: input.hereWorkspacePath }),
148
146
  });
149
147
  if (reintegrated.kind !== "accepted") {
150
148
  return { admission, evidence: mergeEvidence(evidence, { placement: reintegrationStop(reintegrated) }) };
@@ -7,7 +7,7 @@ type DeliveryIdentity = DeliverData;
7
7
  export type VerificationReuse = CurrentVerifiedAttestation;
8
8
  export type DeliverValue = DeliveryIdentity & CompletionEvidence;
9
9
  export type AppointedWorkspace = Readonly<{
10
- kind: "here" | "worktree";
10
+ kind: "worktree";
11
11
  path: string;
12
12
  }>;
13
13
  export type IntegrationConflictMaterialized = Readonly<{
@@ -30,7 +30,6 @@ export declare function prepareDelivery(repository: import("../git/process.js").
30
30
  appointment?: Extract<ManagedWorktreeAppointment, {
31
31
  kind: "appointed";
32
32
  }>;
33
- workspacePath?: string;
34
33
  }>, input: Readonly<{
35
34
  title: string;
36
35
  document: string;
@@ -51,7 +50,6 @@ export declare function continueDeliveryOperation(input: Readonly<{
51
50
  state: ContractState;
52
51
  journal: readonly JournalEntry[];
53
52
  deriveDocument: (state: ContractState) => DocumentDerivation;
54
- resolveHereWorkspace?: MutationOperationInput["resolveHereWorkspace"];
55
53
  actor?: ActorId;
56
54
  signal?: AbortSignal;
57
55
  }>): Promise<CompletionResult>;
@@ -1,7 +1,7 @@
1
1
  import { materializeIntegrationSnapshot, materializeJudgedConflict, planIntegration, workspaceMergeStatePresent, worktreeChangeId, } from "../git/integration.js";
2
2
  import { captureTender, dirtyTenderRefusal, materializeTenderSnapshot, prepareDeliveryCommitMetadata, } from "../git/tender.js";
3
3
  import { worktreePath } from "../git/workspace.js";
4
- import { currentBranch, observeContractsForAdmissionAt } from "../git/observe.js";
4
+ import { observeContractsForAdmissionAt } from "../git/observe.js";
5
5
  import { contractState } from "../core/facts/observation.js";
6
6
  import { decideDeliver } from "../core/verbs/deliver.js";
7
7
  import { admitDecidedOffer, mintAttempts } from "./attempt.js";
@@ -15,15 +15,6 @@ const DELIVER_CONFLICT_RECOVERY = Object.freeze({
15
15
  });
16
16
  export async function prepareDelivery(repository, stage, input) {
17
17
  const { contractId, coordinates } = stage;
18
- if (coordinates.workspace === "here" && coordinates.target !== undefined) {
19
- const branch = await currentBranch(repository, stage.workspacePath);
20
- if (branch !== coordinates.target) {
21
- return {
22
- kind: "refused",
23
- refusal: { kind: "workspace-not-on-target", contractId, target: coordinates.target, branch },
24
- };
25
- }
26
- }
27
18
  const appointed = coordinates.workspace === "worktree"
28
19
  ? stage.appointment === undefined
29
20
  ? appointmentFor(await readPlaceRegister(repository), contractId)
@@ -33,13 +24,13 @@ export async function prepareDelivery(repository, stage, input) {
33
24
  contractId,
34
25
  coordinates,
35
26
  ...(appointed === undefined ? {} : { place: appointed.place }),
36
- ...(stage.workspacePath === undefined ? {} : { workspacePath: stage.workspacePath }),
37
27
  captureMergeState: true,
38
28
  rejectUnmerged: true,
39
29
  });
40
30
  if (tender.kind === "refused")
41
31
  return tender;
42
- if (((tender.data.dirty || tender.data.mergeHead !== undefined) && input.includeDirty !== true) || tender.data.changes.submodules.length > 0) {
32
+ if (((tender.data.dirty || tender.data.mergeHead !== undefined) && input.includeDirty !== true) ||
33
+ tender.data.changes.submodules.length > 0) {
43
34
  return { kind: "refused", refusal: await dirtyTenderRefusal(repository, contractId, tender.data) };
44
35
  }
45
36
  const commit = await prepareDeliveryCommitMetadata(repository, {
@@ -77,7 +68,6 @@ async function deliverAttempt(input, attempt) {
77
68
  const state = contractState(decisionObservation.decision, input.contractId);
78
69
  const derivation = state === null ? undefined : input.deriveDocument(state);
79
70
  let preparation;
80
- let workspacePath;
81
71
  if (state === null || derivation === undefined) {
82
72
  preparation = { kind: "unavailable" };
83
73
  }
@@ -85,9 +75,6 @@ async function deliverAttempt(input, attempt) {
85
75
  preparation = { kind: "refused", document: derivation.document, refusal: derivation.verification.refusal };
86
76
  }
87
77
  else {
88
- workspacePath = state.terminal === null && state.coordinates.workspace === "here"
89
- ? await input.resolveHereWorkspace?.(state.id)
90
- : undefined;
91
78
  const materialization = input.materializeConflict === true && state.terminal === null
92
79
  ? await materializationMergeStateRefusal(input)
93
80
  : undefined;
@@ -95,7 +82,6 @@ async function deliverAttempt(input, attempt) {
95
82
  ? await prepareDelivery(input.scope, {
96
83
  contractId: state.id,
97
84
  coordinates: state.coordinates,
98
- ...(workspacePath === undefined ? {} : { workspacePath }),
99
85
  }, {
100
86
  title: derivation.title,
101
87
  document: derivation.bytes,
@@ -105,14 +91,14 @@ async function deliverAttempt(input, attempt) {
105
91
  includeDirty: input.includeDirty,
106
92
  })
107
93
  : { kind: "refused", refusal: materialization };
108
- preparation = prepared.kind === "refused"
109
- ? { kind: "refused", document: derivation.document, refusal: prepared.refusal }
110
- : {
111
- kind: "prepared",
112
- document: derivation.document,
113
- data: prepared.data,
114
- ...(workspacePath === undefined ? {} : { workspacePath }),
115
- };
94
+ preparation =
95
+ prepared.kind === "refused"
96
+ ? { kind: "refused", document: derivation.document, refusal: prepared.refusal }
97
+ : {
98
+ kind: "prepared",
99
+ document: derivation.document,
100
+ data: prepared.data,
101
+ };
116
102
  }
117
103
  const decision = decideDeliver({
118
104
  input: {
@@ -144,7 +130,6 @@ async function deliverAttempt(input, attempt) {
144
130
  value: {
145
131
  delivery: preparation.data,
146
132
  derivation,
147
- ...(workspacePath === undefined ? {} : { workspacePath }),
148
133
  },
149
134
  };
150
135
  }
@@ -161,7 +146,6 @@ async function completeDelivery(input, first) {
161
146
  contractId: input.contractId,
162
147
  ...(input.actor === undefined ? {} : { actor: input.actor }),
163
148
  ...(input.signal === undefined ? {} : { signal: input.signal }),
164
- ...(first.value.workspacePath === undefined ? {} : { hereWorkspacePath: first.value.workspacePath }),
165
149
  ...(first.state.coordinates.target === undefined ? {} : { target: first.state.coordinates.target }),
166
150
  verification: derivation.verification,
167
151
  initial: first,
@@ -174,9 +158,6 @@ async function completeDelivery(input, first) {
174
158
  }
175
159
  export async function continueDeliveryOperation(input) {
176
160
  const contractId = input.state.id;
177
- const hereWorkspacePath = input.state.coordinates.workspace === "here"
178
- ? await input.resolveHereWorkspace?.(contractId)
179
- : undefined;
180
161
  return await completeCandidate({
181
162
  channel: input.channel,
182
163
  repository: input.scope,
@@ -187,7 +168,6 @@ export async function continueDeliveryOperation(input) {
187
168
  verification: input.deriveDocument(input.state).verification,
188
169
  initial: { kind: "accepted", state: input.state, journal: input.journal, facts: [] },
189
170
  verifyInitial: true,
190
- ...(hereWorkspacePath === undefined ? {} : { hereWorkspacePath }),
191
171
  });
192
172
  }
193
173
  function isIntegrationConflict(refusal) {
@@ -210,13 +190,6 @@ async function appointedDeliverWorkspace(input) {
210
190
  const state = contractState(observation.decision, input.contractId);
211
191
  if (state === null)
212
192
  return { kind: "refused", refusal: { kind: "worktree-missing", contractId: input.contractId } };
213
- if (state.coordinates.workspace === "here") {
214
- const path = await input.resolveHereWorkspace?.(state.id);
215
- if (path === undefined) {
216
- return { kind: "refused", refusal: { kind: "worktree-missing", contractId: input.contractId } };
217
- }
218
- return { workspace: { kind: "here", path }, coordinates: state.coordinates };
219
- }
220
193
  const appointment = appointmentFor(await readPlaceRegister(input.scope), input.contractId);
221
194
  if (appointment === undefined) {
222
195
  return { kind: "refused", refusal: { kind: "worktree-missing", contractId: input.contractId } };
@@ -244,13 +217,16 @@ async function materializeDeliverConflict(input, refusal) {
244
217
  if ("kind" in appointed)
245
218
  return appointed;
246
219
  const { workspace, coordinates } = appointed;
220
+ const appointment = appointmentFor(await readPlaceRegister(input.scope), input.contractId);
221
+ if (appointment === undefined)
222
+ return { kind: "refused", refusal: { kind: "worktree-missing", contractId: input.contractId } };
247
223
  const mergeState = await mergeStatePresentRefusal(input, workspace);
248
224
  if (mergeState !== undefined)
249
225
  return { kind: "refused", refusal: mergeState };
250
226
  const tender = await captureTender(input.scope, {
251
227
  contractId: input.contractId,
252
228
  coordinates,
253
- workspacePath: workspace.path,
229
+ place: appointment.place,
254
230
  });
255
231
  if (tender.kind === "refused")
256
232
  return tender;
@@ -13,6 +13,7 @@ type IntentAdmissionOptions<Input, Refusal, Seed> = Readonly<{
13
13
  observedContracts?: readonly ContractId[];
14
14
  observe?: (repository: GitRepository, channel: GitDecodeChannel, contracts: readonly ContractId[]) => Promise<GitDecisionObservation>;
15
15
  decorateOffer?: CompanionDecorator;
16
+ validateAdmission?: (observation: GitDecisionObservation) => Refusal | undefined | Promise<Refusal | undefined>;
16
17
  observationSelection?: GitTreeSelection;
17
18
  prepareInput?: (observation: GitDecisionObservation, input: Seed) => Readonly<{
18
19
  kind: "prepared";
@@ -3,7 +3,7 @@ import { projectSettings } from "../settings.js";
3
3
  import { dependencyKeySet } from "../core/subject.js";
4
4
  import { latestCurrentAttestations } from "../core/facts/gate.js";
5
5
  import { decideAttestation } from "../core/verbs/attestation.js";
6
- import { executeVerification } from "../verification/execution.js";
6
+ import { executeVerification, } from "../verification/execution.js";
7
7
  import { VERIFIED } from "../verification/declaration.js";
8
8
  import { runProtocol } from "./run.js";
9
9
  import { mintAttempts } from "./attempt.js";
@@ -19,6 +19,7 @@ export function admitIntent(channel, repository, input, decide, options = {}) {
19
19
  decide,
20
20
  ...(options.observe === undefined ? {} : { observe: options.observe }),
21
21
  ...(options.decorateOffer === undefined ? {} : { decorateOffer: options.decorateOffer }),
22
+ ...(options.validateAdmission === undefined ? {} : { validateAdmission: options.validateAdmission }),
22
23
  ...(options.observationSelection === undefined ? {} : { observationSelection: options.observationSelection }),
23
24
  ...(options.prepareInput === undefined ? {} : { prepareInput: options.prepareInput }),
24
25
  });
@@ -81,13 +82,14 @@ export async function verifyDelivery(input) {
81
82
  step = { failure: "candidate-unavailable", diagnostic: execution.outcome.diagnostic };
82
83
  }
83
84
  else if (execution.outcome.kind === "environment-failure") {
84
- step = "diagnostic" in execution.outcome
85
- ? { failure: "environment-failure", diagnostic: execution.outcome.diagnostic }
86
- : { failure: "environment-failure", command: execution.outcome.command, detail: execution.outcome.detail };
85
+ step =
86
+ "diagnostic" in execution.outcome
87
+ ? { failure: "environment-failure", diagnostic: execution.outcome.diagnostic }
88
+ : { failure: "environment-failure", command: execution.outcome.command, detail: execution.outcome.detail };
87
89
  }
88
- else if (execution.outcome.kind === "unknown-exit"
89
- || execution.outcome.kind === "cancelled"
90
- || execution.outcome.kind === "spawn-error") {
90
+ else if (execution.outcome.kind === "unknown-exit" ||
91
+ execution.outcome.kind === "cancelled" ||
92
+ execution.outcome.kind === "spawn-error") {
91
93
  step = runtimeStop(execution.outcome);
92
94
  }
93
95
  else {
@@ -9,7 +9,7 @@ import type { DeliverRefusal } from "../core/verbs/deliver.js";
9
9
  import type { PlacementRefusal } from "../core/verbs/placement.js";
10
10
  import type { AttestationRefusal } from "../core/verbs/attestation.js";
11
11
  import type { ContractId, ContractState, DeliverData, DocumentKey, SnapshotId } from "../core/facts/types.js";
12
- import type { BindRefusal, TargetInputRefusal } from "./bind.js";
12
+ import type { BindRefusal, ForkSourceMovedRefusal, TargetInputRefusal } from "./bind.js";
13
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";
@@ -24,7 +24,7 @@ export type MergeStatePresentRefusal = Readonly<{
24
24
  kind: "merge-state-present";
25
25
  contractId: ContractId;
26
26
  workspace: Readonly<{
27
- kind: "here" | "worktree";
27
+ kind: "worktree" | "worktree";
28
28
  path: string;
29
29
  }>;
30
30
  }>;
@@ -48,7 +48,7 @@ export type DeliveryPreparationRefusal = Readonly<{
48
48
  kind: "target-missing" | "worktree-missing";
49
49
  contractId: ContractId;
50
50
  }> | DirtyWorkspaceRefusal | UnmergedPathsRefusal | IntegrationPreparationRefusal | MergeStatePresentRefusal | TargetPlacementRefusal;
51
- export type IntentRefusal = AbandonRefusal | AmendRefusal | ArcRefusal | BindRefusal | DeliverRefusal | DeliveryPreparationRefusal | DeliverConflictRefusal | PlacementRefusal | AttestationRefusal | TargetInputRefusal | VerificationDeclarationRefusal;
51
+ export type IntentRefusal = AbandonRefusal | AmendRefusal | ArcRefusal | BindRefusal | ForkSourceMovedRefusal | DeliverRefusal | DeliveryPreparationRefusal | DeliverConflictRefusal | PlacementRefusal | AttestationRefusal | TargetInputRefusal | VerificationDeclarationRefusal;
52
52
  export type IntentRetry = ProtocolTerminal;
53
53
  export type IntentOutcome<Value, Refusal = IntentRefusal> = ProtocolIntentOutcome<Value, Refusal>;
54
54
  type OperationInput = Readonly<{
@@ -56,10 +56,8 @@ type OperationInput = Readonly<{
56
56
  contractId: ContractId;
57
57
  actor?: import("../core/facts/types.js").ActorId;
58
58
  }>;
59
- export type HereWorkspaceResolver = (contractId: ContractId) => Promise<string | undefined>;
60
59
  export type MutationOperationInput = OperationInput & Readonly<{
61
60
  channel: GitDecodeChannel;
62
- resolveHereWorkspace?: HereWorkspaceResolver;
63
61
  }>;
64
62
  export type DocumentDerivation = Readonly<{
65
63
  document: DocumentKey;
@@ -129,13 +127,11 @@ export declare function currentBranchOperation(input: Readonly<{
129
127
  export declare function contractsOperation(input: Readonly<{
130
128
  scope: RepositoryScope;
131
129
  channel: GitDecodeChannel;
132
- hereWorkspace?: import("./read/status.js").HereWorkspaceObservationResolver;
133
130
  }>): Promise<ContractBoard>;
134
131
  export declare function contractObservationOperation(input: Readonly<{
135
132
  scope: RepositoryScope;
136
133
  channel: GitDecodeChannel;
137
134
  contractId: ContractId;
138
- hereWorkspace?: import("./read/status.js").HereWorkspaceObservationResolver;
139
135
  }>): Promise<ContractObservation>;
140
136
  export declare function documentsOperationAt(scope: RepositoryScope, channel: GitDecodeChannel): Promise<readonly ContractDocumentProjection[]>;
141
137
  export declare function stateOperation(input: MutationOperationInput): Promise<ContractState>;
@@ -4,7 +4,9 @@ import { repositoryAt } from "../git/repository.js";
4
4
  import { withGitReadObservation } from "../git/read-observation.js";
5
5
  import { readDocuments } from "./read/documents.js";
6
6
  import { readContractBoard, readContractObservationAt, } from "./read/status.js";
7
- export function timestamp() { return new Date().toISOString(); }
7
+ export function timestamp() {
8
+ return new Date().toISOString();
9
+ }
8
10
  export function mergeAdmissions(current, next) {
9
11
  const effects = [...(current.physical?.effects ?? []), ...(next.physical?.effects ?? [])];
10
12
  const lag = [...(current.physical?.lag ?? []), ...(next.physical?.lag ?? [])];
@@ -49,10 +51,10 @@ export async function currentBranchOperation(input) {
49
51
  return await currentBranch(input.scope);
50
52
  }
51
53
  export async function contractsOperation(input) {
52
- return withGitReadObservation(input.scope, input.channel, (observation) => readContractBoard(observation, undefined, input.hereWorkspace));
54
+ return withGitReadObservation(input.scope, input.channel, (observation) => readContractBoard(observation));
53
55
  }
54
56
  export async function contractObservationOperation(input) {
55
- return await readContractObservationAt(input.scope, input.channel, input.contractId, input.hereWorkspace);
57
+ return await readContractObservationAt(input.scope, input.channel, input.contractId);
56
58
  }
57
59
  export async function documentsOperationAt(scope, channel) {
58
60
  return withGitReadObservation(scope, channel, readDocuments);
@@ -30,7 +30,6 @@ type PlacementAdmissionInput<ExtraRefusal> = Readonly<{
30
30
  repository: GitRepository;
31
31
  target: string | undefined;
32
32
  placement: PlacementProtocolInput;
33
- hereWorkspacePath?: string;
34
33
  onDeliveryMissing?: () => Promise<PlacementProtocolResult<ExtraRefusal> | undefined>;
35
34
  }>;
36
35
  /** Hold the existing target-placement fence for one owner callback. */
@@ -7,7 +7,7 @@ import { reconcileEffectFailure } from "../git/reconcile.js";
7
7
  import { GitPlumbingError } from "../git/process.js";
8
8
  import { acquireTargetPlacementFence, followTargetPlacement, prepareTargetPlacement, observeTargetHead, } from "../git/target-placement.js";
9
9
  import { admitDecidedOffer, mintAttempts } from "./attempt.js";
10
- import { prepareProtocolAttempt, runProtocol, } from "./run.js";
10
+ import { prepareProtocolAttempt, runProtocol } from "./run.js";
11
11
  function placementFailure(error) {
12
12
  return { kind: "placement-failed", diagnostic: error instanceof Error ? error.message : String(error) };
13
13
  }
@@ -20,7 +20,7 @@ function expectedOperationalDiagnostic(error) {
20
20
  function expectedPlacementFailure(error) {
21
21
  return { kind: "placement-failed", diagnostic: expectedOperationalDiagnostic(error) };
22
22
  }
23
- async function runFencedPlacement(repository, input, protocol, hereWorkspacePath) {
23
+ async function runFencedPlacement(repository, input, protocol) {
24
24
  for (let index = 0; index < protocol.attempts.length; index += 1) {
25
25
  const prepared = await prepareProtocolAttempt(protocol, protocol.attempts[index]);
26
26
  if (prepared.kind === "refused")
@@ -40,7 +40,7 @@ async function runFencedPlacement(repository, input, protocol, hereWorkspacePath
40
40
  observed,
41
41
  };
42
42
  }
43
- const physical = await prepareTargetPlacement(repository, state, prepared.offer.target, hereWorkspacePath);
43
+ const physical = await prepareTargetPlacement(repository, state, prepared.offer.target);
44
44
  if (physical.kind === "refused")
45
45
  return physical;
46
46
  const result = await admitDecidedOffer({
@@ -112,7 +112,7 @@ function isDeliveryMissing(result) {
112
112
  }
113
113
  /** Run the sole placement adjudicator inside the target's physical fence. */
114
114
  export async function admitPlacement(admission) {
115
- const { channel, repository, target, placement: input, hereWorkspacePath, onDeliveryMissing } = admission;
115
+ const { channel, repository, target, placement: input, onDeliveryMissing } = admission;
116
116
  const attempts = mintAttempts({ entryCount: 1 });
117
117
  const protocol = {
118
118
  input,
@@ -126,10 +126,10 @@ export async function admitPlacement(admission) {
126
126
  if (target === undefined)
127
127
  return await runProtocol(protocol);
128
128
  return await runUnderTargetPlacementFence(repository, target, async () => {
129
- const result = await runFencedPlacement(repository, input, protocol, hereWorkspacePath);
129
+ const result = await runFencedPlacement(repository, input, protocol);
130
130
  if (onDeliveryMissing === undefined || !isDeliveryMissing(result))
131
131
  return result;
132
- return await onDeliveryMissing() ?? result;
132
+ return (await onDeliveryMissing()) ?? result;
133
133
  }, (result, error) => result.kind === "accepted"
134
134
  ? { ...result, physical: reconcileEffectFailure(error, result.physical) }
135
135
  : placementFailure(error));
@@ -0,0 +1,11 @@
1
+ import type { GitRepository } from "../../git/process.js";
2
+ import type { ContractRow } from "./status.js";
3
+ export type CurrentPhysicalIssue = Readonly<{
4
+ kind: "hook-failure";
5
+ diagnostic: string;
6
+ }> | Readonly<{
7
+ kind: "target-checkout-retained";
8
+ target: string;
9
+ }>;
10
+ /** Selected-only pure projection of durable hook failure or retained target checkout. */
11
+ export declare function observeCurrentPhysicalIssue(repository: GitRepository, row: ContractRow): Promise<CurrentPhysicalIssue | undefined>;
@@ -0,0 +1,37 @@
1
+ import { observeWorktreeHookMarker } from "../../git/hooks.js";
2
+ import { registeredWorktrees, worktreeGitDirectory } from "../../git/repository.js";
3
+ import { observeTargetCheckoutShape } from "../../git/target-placement.js";
4
+ function appointedWorkspacePath(row) {
5
+ const observation = row.workspaceObservation;
6
+ if (observation.kind !== "clean" && observation.kind !== "dirty")
7
+ return null;
8
+ return observation.location.kind === "worktree" ? observation.location.path : null;
9
+ }
10
+ /** Selected-only pure projection of durable hook failure or retained target checkout. */
11
+ export async function observeCurrentPhysicalIssue(repository, row) {
12
+ const workspacePath = appointedWorkspacePath(row);
13
+ if (workspacePath !== null) {
14
+ const marker = await observeWorktreeHookMarker(await worktreeGitDirectory(repository, workspacePath));
15
+ if (marker.kind === "failed")
16
+ return { kind: "hook-failure", diagnostic: marker.diagnostic };
17
+ }
18
+ const target = row.target;
19
+ const delivery = row.delivery;
20
+ if (row.phase !== "claimed" || target === null || delivery === null)
21
+ return undefined;
22
+ if (row.targetObservation?.head !== delivery.integration.snapshot)
23
+ return undefined;
24
+ const worktrees = (await registeredWorktrees(repository))
25
+ .filter((worktree) => worktree.branch === target)
26
+ .sort((left, right) => left.path.localeCompare(right.path));
27
+ for (const worktree of worktrees) {
28
+ const shape = await observeTargetCheckoutShape(repository, {
29
+ path: worktree.path,
30
+ predecessor: delivery.integration.predecessor,
31
+ candidate: delivery.integration.snapshot,
32
+ });
33
+ if (shape === "retained")
34
+ return { kind: "target-checkout-retained", target };
35
+ }
36
+ return undefined;
37
+ }
@@ -3,7 +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
- export type ContractPhase = "waiting" | "bound" | "pending-delivery" | "claimed" | "abandoned";
6
+ export type ContractPhase = "waiting" | "bound" | "tendered" | "claimed" | "abandoned";
7
7
  export type ContractDisposition = "active" | "terminal";
8
8
  export type ContractGateCurrent = GateCurrent;
9
9
  export type ContractGateReport = Readonly<{
@@ -11,16 +11,24 @@ export type ContractGateReport = Readonly<{
11
11
  current: ContractGateCurrent;
12
12
  }>;
13
13
  export type { ContractTargetLag, ContractWorkspaceObservation };
14
- export type HereWorkspaceObservationResolution = Readonly<{
15
- kind: "appointed";
16
- path: string;
14
+ export type AfterEndpointObservation = Readonly<{
15
+ kind: "claimed";
17
16
  }> | Readonly<{
18
- kind: "unappointed";
17
+ kind: "active";
18
+ phase: ContractPhase;
19
+ }> | Readonly<{
20
+ kind: "abandoned";
19
21
  }> | Readonly<{
20
- kind: "failed";
21
- diagnostic: string;
22
+ kind: "missing";
23
+ }>;
24
+ export type ContractAfterEdge = Readonly<{
25
+ contractId: ContractId;
26
+ endpoint: AfterEndpointObservation;
27
+ }>;
28
+ export type ContractDependent = Readonly<{
29
+ contractId: ContractId;
30
+ phase: ContractPhase;
22
31
  }>;
23
- export type HereWorkspaceObservationResolver = (contractId: ContractId) => Promise<HereWorkspaceObservationResolution>;
24
32
  export type ContractRow = Readonly<{
25
33
  id: ContractId;
26
34
  title: string | null;
@@ -28,7 +36,7 @@ export type ContractRow = Readonly<{
28
36
  phaseAt: string;
29
37
  lastJournalAt: string;
30
38
  disposition: ContractDisposition;
31
- workspace: "worktree" | "here";
39
+ workspace: "worktree";
32
40
  worktreePath: string | null;
33
41
  workspaceObservation: ContractWorkspaceObservation;
34
42
  target: string | null;
@@ -42,10 +50,13 @@ export type ContractRow = Readonly<{
42
50
  reports: readonly ContractGateReport[];
43
51
  satisfied: boolean;
44
52
  }>;
53
+ after: readonly ContractAfterEdge[];
54
+ dependents: readonly ContractDependent[];
45
55
  }>;
46
56
  export type ContractBoard = Readonly<{
47
57
  root: string;
48
58
  state: SnapshotId | null;
59
+ observedAt: string;
49
60
  rows: readonly ContractRow[];
50
61
  }>;
51
62
  export type ContractObservation = Readonly<{
@@ -58,8 +69,8 @@ export type ContractObservation = Readonly<{
58
69
  export declare function phaseAtFor(state: Pick<ContractState, "terminal" | "delivery" | "bound">, bindAt: string): string;
59
70
  export declare function lastJournalAtFor(entries: readonly Pick<JournalEntry, "at">[]): string;
60
71
  /** Build the Contract board from one immutable git observation. */
61
- export declare function readContractBoard(observation: GitReadObservation, selected?: ContractId, resolveHereWorkspace?: HereWorkspaceObservationResolver): Promise<ContractBoard>;
72
+ export declare function readContractBoard(observation: GitReadObservation, include?: ContractId): Promise<ContractBoard>;
62
73
  /** Observe one Contract and its target from one fresh ref epoch. */
63
- export declare function readContractObservation(observation: GitReadObservation, id: ContractId, resolveHereWorkspace?: HereWorkspaceObservationResolver): Promise<ContractObservation>;
74
+ export declare function readContractObservation(observation: GitReadObservation, id: ContractId): Promise<ContractObservation>;
64
75
  /** Observe one Contract and its target from one fresh ref epoch. */
65
- export declare function readContractObservationAt(repository: GitRepository, channel: GitDecodeChannel, id: ContractId, resolveHereWorkspace?: HereWorkspaceObservationResolver): Promise<ContractObservation>;
76
+ export declare function readContractObservationAt(repository: GitRepository, channel: GitDecodeChannel, id: ContractId): Promise<ContractObservation>;