@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,5 +1,5 @@
1
1
  import type { DecideInput, OfferDecision } from "../decide.js";
2
- import type { ActorId, ContractId } from "../facts/types.js";
2
+ import { type ActorId, type ContractId } from "../facts/types.js";
3
3
  export type AbandonInput = Readonly<{
4
4
  contractId: ContractId;
5
5
  actor?: ActorId;
@@ -10,4 +10,5 @@ export type AbandonRefusal = Readonly<{
10
10
  kind: "contract-missing" | "terminal";
11
11
  contractId: ContractId;
12
12
  }>;
13
+ export declare function decodeAbandonRefusal(value: unknown): AbandonRefusal;
13
14
  export declare function decideAbandon({ input, attempt, observation, }: DecideInput<AbandonInput>): OfferDecision<AbandonRefusal>;
@@ -1,4 +1,20 @@
1
1
  import { activeContract } from "../facts/observation.js";
2
+ import { contractId } from "../facts/types.js";
3
+ export function decodeAbandonRefusal(value) {
4
+ if (value === null || typeof value !== "object" || Array.isArray(value))
5
+ throw new Error("malformed abandon refusal");
6
+ const object = value;
7
+ if (object.kind !== "contract-missing" && object.kind !== "terminal")
8
+ throw new Error("malformed abandon refusal");
9
+ if (Object.keys(object).some((key) => key !== "kind" && key !== "contractId"))
10
+ throw new Error("malformed abandon refusal");
11
+ try {
12
+ return { kind: object.kind, contractId: contractId(String(object.contractId)) };
13
+ }
14
+ catch {
15
+ throw new Error("malformed abandon refusal");
16
+ }
17
+ }
2
18
  export function decideAbandon({ input, attempt, observation, }) {
3
19
  const id = input.contractId;
4
20
  const current = activeContract(observation, id);
@@ -1,5 +1,5 @@
1
1
  import type { DecideInput, OfferDecision, Preparation } from "../decide.js";
2
- import type { ActorId, AmendData, ContractId, ContractTerms } from "../facts/types.js";
2
+ import { type ActorId, type AmendData, type ContractId, type ContractTerms } from "../facts/types.js";
3
3
  export type AmendInput<Failure = never> = Readonly<{
4
4
  contractId: ContractId;
5
5
  actor?: ActorId;
@@ -11,4 +11,5 @@ export type AmendRefusal = Readonly<{
11
11
  kind: "contract-missing" | "terminal" | "terms-moved" | "unknown-prerequisite" | "cyclic-prerequisite";
12
12
  contractId: ContractId;
13
13
  }>;
14
+ export declare function decodeAmendRefusal(value: unknown): AmendRefusal;
14
15
  export declare function decideAmend<Failure>({ input, attempt, observation, }: DecideInput<AmendInput<Failure>>): OfferDecision<AmendRefusal | Failure>;
@@ -1,5 +1,25 @@
1
1
  import { prerequisitesReach, samePrerequisites } from "../facts/eligibility.js";
2
2
  import { activeContract, prerequisiteStatus } from "../facts/observation.js";
3
+ import { contractId, } from "../facts/types.js";
4
+ export function decodeAmendRefusal(value) {
5
+ if (value === null || typeof value !== "object" || Array.isArray(value))
6
+ throw new Error("malformed amend refusal");
7
+ const object = value;
8
+ if (object.kind !== "contract-missing" &&
9
+ object.kind !== "terminal" &&
10
+ object.kind !== "terms-moved" &&
11
+ object.kind !== "unknown-prerequisite" &&
12
+ object.kind !== "cyclic-prerequisite")
13
+ throw new Error("malformed amend refusal");
14
+ if (Object.keys(object).some((key) => key !== "kind" && key !== "contractId"))
15
+ throw new Error("malformed amend refusal");
16
+ try {
17
+ return { kind: object.kind, contractId: contractId(String(object.contractId)) };
18
+ }
19
+ catch {
20
+ throw new Error("malformed amend refusal");
21
+ }
22
+ }
3
23
  export function decideAmend({ input, attempt, observation, }) {
4
24
  const id = input.contractId;
5
25
  const current = activeContract(observation, id);
@@ -1,5 +1,5 @@
1
1
  import type { DecideInput, OfferDecision } from "../decide.js";
2
- import type { ActorId, ArcData, ContractId } from "../facts/types.js";
2
+ import { type ActorId, type ArcData, type ContractId } from "../facts/types.js";
3
3
  export type ArcInput = Readonly<{
4
4
  contractId: ContractId;
5
5
  actor?: ActorId;
@@ -10,4 +10,5 @@ export type ArcRefusal = Readonly<{
10
10
  kind: "contract-missing" | "terminal";
11
11
  contractId: ContractId;
12
12
  }>;
13
+ export declare function decodeArcRefusal(value: unknown): ArcRefusal;
13
14
  export declare function decideArc({ input, attempt, observation }: DecideInput<ArcInput>): OfferDecision<ArcRefusal>;
@@ -1,4 +1,20 @@
1
1
  import { activeContract } from "../facts/observation.js";
2
+ import { contractId } from "../facts/types.js";
3
+ export function decodeArcRefusal(value) {
4
+ if (value === null || typeof value !== "object" || Array.isArray(value))
5
+ throw new Error("malformed arc refusal");
6
+ const object = value;
7
+ if (object.kind !== "contract-missing" && object.kind !== "terminal")
8
+ throw new Error("malformed arc refusal");
9
+ if (Object.keys(object).some((key) => key !== "kind" && key !== "contractId"))
10
+ throw new Error("malformed arc refusal");
11
+ try {
12
+ return { kind: object.kind, contractId: contractId(String(object.contractId)) };
13
+ }
14
+ catch {
15
+ throw new Error("malformed arc refusal");
16
+ }
17
+ }
2
18
  export function decideArc({ input, attempt, observation }) {
3
19
  const id = input.contractId;
4
20
  const current = activeContract(observation, id);
@@ -1,5 +1,5 @@
1
1
  import type { DecideInput, OfferDecision, Preparation } from "../decide.js";
2
- import type { ActorId, AttestationData, ContractId } from "../facts/types.js";
2
+ import { type ActorId, type AttestationData, type ContractId } from "../facts/types.js";
3
3
  export type AttestationInput<Failure = never> = Readonly<{
4
4
  contractId: ContractId;
5
5
  actor?: ActorId;
@@ -10,4 +10,5 @@ export type AttestationRefusal = Readonly<{
10
10
  kind: "contract-missing" | "terminal";
11
11
  contractId: ContractId;
12
12
  }>;
13
+ export declare function decodeAttestationRefusal(value: unknown): AttestationRefusal;
13
14
  export declare function decideAttestation<Failure>({ input, attempt, observation, }: DecideInput<AttestationInput<Failure>>): OfferDecision<AttestationRefusal | Failure>;
@@ -1,4 +1,20 @@
1
1
  import { activeContract } from "../facts/observation.js";
2
+ import { contractId } from "../facts/types.js";
3
+ export function decodeAttestationRefusal(value) {
4
+ if (value === null || typeof value !== "object" || Array.isArray(value))
5
+ throw new Error("malformed attestation refusal");
6
+ const object = value;
7
+ if (object.kind !== "contract-missing" && object.kind !== "terminal")
8
+ throw new Error("malformed attestation refusal");
9
+ if (Object.keys(object).some((key) => key !== "kind" && key !== "contractId"))
10
+ throw new Error("malformed attestation refusal");
11
+ try {
12
+ return { kind: object.kind, contractId: contractId(String(object.contractId)) };
13
+ }
14
+ catch {
15
+ throw new Error("malformed attestation refusal");
16
+ }
17
+ }
2
18
  export function decideAttestation({ input, attempt, observation, }) {
3
19
  const state = activeContract(observation, input.contractId);
4
20
  if ("kind" in state)
@@ -1,5 +1,5 @@
1
1
  import type { DecideInput, OfferDecision, Preparation } from "../decide.js";
2
- import type { ActorId, BindData, ContractId } from "../facts/types.js";
2
+ import { type ActorId, type BindData, type ContractId } from "../facts/types.js";
3
3
  export type BindInput<Failure = never> = Readonly<{
4
4
  contractId: ContractId;
5
5
  actor?: ActorId;
@@ -10,4 +10,5 @@ export type BindRefusal = Readonly<{
10
10
  kind: "contract-exists" | "invalid-after" | "unknown-prerequisite";
11
11
  contractId: ContractId;
12
12
  }>;
13
+ export declare function decodeBindRefusal(value: unknown): BindRefusal;
13
14
  export declare function decideBind<Failure>({ input, attempt, observation, }: DecideInput<BindInput<Failure>>): OfferDecision<BindRefusal | Failure>;
@@ -1,4 +1,20 @@
1
1
  import { contractState, prerequisiteStatus } from "../facts/observation.js";
2
+ import { contractId } from "../facts/types.js";
3
+ export function decodeBindRefusal(value) {
4
+ if (value === null || typeof value !== "object" || Array.isArray(value))
5
+ throw new Error("malformed bind refusal");
6
+ const object = value;
7
+ if (object.kind !== "contract-exists" && object.kind !== "invalid-after" && object.kind !== "unknown-prerequisite")
8
+ throw new Error("malformed bind refusal");
9
+ if (Object.keys(object).some((key) => key !== "kind" && key !== "contractId"))
10
+ throw new Error("malformed bind refusal");
11
+ try {
12
+ return { kind: object.kind, contractId: contractId(String(object.contractId)) };
13
+ }
14
+ catch {
15
+ throw new Error("malformed bind refusal");
16
+ }
17
+ }
2
18
  export function decideBind({ input, attempt, observation, }) {
3
19
  const id = input.contractId;
4
20
  const current = contractState(observation, id);
@@ -1,5 +1,5 @@
1
1
  import type { DecideInput, OfferDecision, StampedPreparation } from "../decide.js";
2
- import type { ActorId, ContractId, DeliverData } from "../facts/types.js";
2
+ import { type ActorId, type ContractId, type DeliverData } from "../facts/types.js";
3
3
  export type DeliverInput<Failure = never> = Readonly<{
4
4
  contractId: ContractId;
5
5
  actor?: ActorId;
@@ -10,4 +10,5 @@ export type DeliverRefusal = Readonly<{
10
10
  kind: "contract-missing" | "terminal" | "document-moved";
11
11
  contractId: ContractId;
12
12
  }>;
13
+ export declare function decodeDeliverRefusal(value: unknown): DeliverRefusal;
13
14
  export declare function decideDeliver<Failure>({ input, attempt, observation, }: DecideInput<DeliverInput<Failure>>): OfferDecision<DeliverRefusal | Failure>;
@@ -1,4 +1,20 @@
1
1
  import { activeContract, documentIsCurrent } from "../facts/observation.js";
2
+ import { contractId } from "../facts/types.js";
3
+ export function decodeDeliverRefusal(value) {
4
+ if (value === null || typeof value !== "object" || Array.isArray(value))
5
+ throw new Error("malformed deliver refusal");
6
+ const object = value;
7
+ if (object.kind !== "contract-missing" && object.kind !== "terminal" && object.kind !== "document-moved")
8
+ throw new Error("malformed deliver refusal");
9
+ if (Object.keys(object).some((key) => key !== "kind" && key !== "contractId"))
10
+ throw new Error("malformed deliver refusal");
11
+ try {
12
+ return { kind: object.kind, contractId: contractId(String(object.contractId)) };
13
+ }
14
+ catch {
15
+ throw new Error("malformed deliver refusal");
16
+ }
17
+ }
2
18
  export function decideDeliver({ input, attempt, observation, }) {
3
19
  const state = activeContract(observation, input.contractId);
4
20
  if ("kind" in state)
@@ -1,5 +1,5 @@
1
1
  import { type GateReport } from "../facts/gate.js";
2
- import type { ActorId, ContractId } from "../facts/types.js";
2
+ import { type ActorId, type ContractId } from "../facts/types.js";
3
3
  import type { DecideInput, OfferDecision } from "../decide.js";
4
4
  type PlacementInput = Readonly<{
5
5
  contractId: ContractId;
@@ -22,5 +22,6 @@ export type PlacementRefusal = Readonly<{
22
22
  contractId: ContractId;
23
23
  unmet: readonly UnmetPrerequisite[];
24
24
  }>;
25
+ export declare function decodePlacementRefusal(value: unknown): PlacementRefusal;
25
26
  export declare function decidePlacement({ input, attempt, observation, }: DecideInput<PlacementInput>): OfferDecision<PlacementRefusal>;
26
27
  export {};
@@ -1,5 +1,62 @@
1
- import { gateReports } from "../facts/gate.js";
1
+ import { decodeGateReport, gateReports } from "../facts/gate.js";
2
2
  import { activeContract, contractState } from "../facts/observation.js";
3
+ import { contractId } from "../facts/types.js";
4
+ export function decodePlacementRefusal(value) {
5
+ if (value === null || typeof value !== "object" || Array.isArray(value))
6
+ throw new Error("malformed placement refusal");
7
+ const object = value;
8
+ if (object.kind === "contract-missing" || object.kind === "delivery-missing" || object.kind === "terminal") {
9
+ if (Object.keys(object).some((key) => key !== "kind" && key !== "contractId"))
10
+ throw new Error("malformed placement refusal");
11
+ try {
12
+ return { kind: object.kind, contractId: contractId(String(object.contractId)) };
13
+ }
14
+ catch {
15
+ throw new Error("malformed placement refusal");
16
+ }
17
+ }
18
+ if (object.kind === "gates-unsatisfied") {
19
+ if (Object.keys(object).some((key) => key !== "kind" && key !== "contractId" && key !== "unmet"))
20
+ throw new Error("malformed placement refusal");
21
+ if (!Array.isArray(object.unmet))
22
+ throw new Error("malformed placement refusal");
23
+ try {
24
+ return {
25
+ kind: "gates-unsatisfied",
26
+ contractId: contractId(String(object.contractId)),
27
+ unmet: object.unmet.map(decodeGateReport),
28
+ };
29
+ }
30
+ catch {
31
+ throw new Error("malformed placement refusal");
32
+ }
33
+ }
34
+ if (object.kind !== "prerequisites-unsatisfied")
35
+ throw new Error("malformed placement refusal");
36
+ if (Object.keys(object).some((key) => key !== "kind" && key !== "contractId" && key !== "unmet"))
37
+ throw new Error("malformed placement refusal");
38
+ if (!Array.isArray(object.unmet))
39
+ throw new Error("malformed placement refusal");
40
+ try {
41
+ return {
42
+ kind: "prerequisites-unsatisfied",
43
+ contractId: contractId(String(object.contractId)),
44
+ unmet: object.unmet.map((item) => {
45
+ if (item === null || typeof item !== "object" || Array.isArray(item))
46
+ throw new Error("malformed placement refusal");
47
+ const unmet = item;
48
+ if (Object.keys(unmet).some((key) => key !== "contractId" && key !== "state"))
49
+ throw new Error("malformed placement refusal");
50
+ if (unmet.state !== "missing" && unmet.state !== "active" && unmet.state !== "abandoned")
51
+ throw new Error("malformed placement refusal");
52
+ return { contractId: contractId(String(unmet.contractId)), state: unmet.state };
53
+ }),
54
+ };
55
+ }
56
+ catch {
57
+ throw new Error("malformed placement refusal");
58
+ }
59
+ }
3
60
  function unmetPrerequisites(prerequisites, observation) {
4
61
  const unmet = [];
5
62
  for (const contractId of prerequisites) {
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ export declare const dispatchAssociationSchema: z.ZodUnion<readonly [z.ZodObject<{
3
+ kind: z.ZodLiteral<"none">;
4
+ }, z.core.$strict>, z.ZodObject<{
5
+ kind: z.ZodLiteral<"associated">;
6
+ contractId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").ContractId, string>>;
7
+ }, z.core.$strict>, z.ZodObject<{
8
+ kind: z.ZodLiteral<"failed">;
9
+ diagnostic: z.ZodString;
10
+ }, z.core.$strict>]>;
11
+ export type DispatchAssociation = z.infer<typeof dispatchAssociationSchema>;
12
+ export declare const NO_DISPATCH_ASSOCIATION: DispatchAssociation;
13
+ export declare function parseDispatchAssociation(value: unknown): DispatchAssociation;
@@ -0,0 +1,20 @@
1
+ import { contractId } from "../core/facts/types.js";
2
+ import { z } from "zod";
3
+ const contractIdSchema = z.string().transform((value, context) => {
4
+ try {
5
+ return contractId(value);
6
+ }
7
+ catch {
8
+ context.addIssue({ code: "custom", message: "expected ContractId" });
9
+ return z.NEVER;
10
+ }
11
+ });
12
+ export const dispatchAssociationSchema = z.union([
13
+ z.object({ kind: z.literal("none") }).strict(),
14
+ z.object({ kind: z.literal("associated"), contractId: contractIdSchema }).strict(),
15
+ z.object({ kind: z.literal("failed"), diagnostic: z.string() }).strict(),
16
+ ]);
17
+ export const NO_DISPATCH_ASSOCIATION = { kind: "none" };
18
+ export function parseDispatchAssociation(value) {
19
+ return dispatchAssociationSchema.parse(value);
20
+ }
@@ -1,7 +1,9 @@
1
1
  import { type ContractId } from "../core/facts/types.js";
2
2
  import { type AkuId } from "../akuma/identity.js";
3
+ import { type PrivateStateSeatCloseLag } from "../git/private-state-seat.js";
3
4
  import type { GitRepository } from "../git/process.js";
4
5
  import { type GitReadObservation } from "../git/read-observation.js";
6
+ import { type DispatchAssociation } from "./association.js";
5
7
  export type Dispatch = Readonly<{
6
8
  akuId: AkuId;
7
9
  contractId: ContractId;
@@ -17,6 +19,7 @@ export type DispatchFailure = Readonly<{
17
19
  export type DispatchPublication = Readonly<{
18
20
  kind: "dispatched";
19
21
  dispatch: Dispatch;
22
+ seatClose?: readonly PrivateStateSeatCloseLag[];
20
23
  }> | Readonly<{
21
24
  kind: "failed";
22
25
  failure: DispatchFailure;
@@ -29,3 +32,6 @@ export declare function publishDispatch(input: Readonly<{
29
32
  akuId: AkuId;
30
33
  contractId: ContractId;
31
34
  }>): Promise<DispatchPublication>;
35
+ export { dispatchAssociationSchema, NO_DISPATCH_ASSOCIATION, parseDispatchAssociation, type DispatchAssociation, } from "./association.js";
36
+ /** Read-only Dispatch association projection for one Akuma identity. */
37
+ export declare function observeDispatchAssociation(repository: GitRepository | undefined, akuId: AkuId): Promise<DispatchAssociation>;
@@ -2,9 +2,10 @@ import { createHash } from "node:crypto";
2
2
  import { AuthorityCorruptionError } from "../core/facts/errors.js";
3
3
  import { contractId } from "../core/facts/types.js";
4
4
  import { parseAkuId } from "../akuma/identity.js";
5
- import { confirmPrivateStatePublication, withPrivateStatePublicationSeat } from "../git/private-state-seat.js";
5
+ import { appendPrivateStateSeatClose, confirmPrivateStatePublication, mergePrivateStateSeatClose, withPrivateStatePublicationSeat, } from "../git/private-state-seat.js";
6
6
  import { GIT_FORMAT_BYTES, GIT_FORMAT_PATH, GIT_REF, readBlob, readGitPaths, updateGitTree, updateRefsAtomically, writeBlob, writeStateCommit, } from "../git/repository.js";
7
7
  import { withGitDecodeChannel, withGitReadObservation } from "../git/read-observation.js";
8
+ import { NO_DISPATCH_ASSOCIATION } from "./association.js";
8
9
  const DISPATCH_ROOT = "dispatch";
9
10
  const DISPATCH_PREFIX = `${DISPATCH_ROOT}/`;
10
11
  const DISPATCH_SUFFIX = ".json";
@@ -118,12 +119,19 @@ async function observedPublication(repository, akuId, owner) {
118
119
  function diagnostic(error) {
119
120
  return error instanceof Error ? error.message : String(error);
120
121
  }
122
+ function dispatchPublicationWithSeatClose(outcome) {
123
+ return mergePrivateStateSeatClose(outcome, (value, closeLag) => {
124
+ if (value.kind !== "dispatched")
125
+ throw new Error(closeLag.diagnostic);
126
+ return { ...value, seatClose: appendPrivateStateSeatClose(value.seatClose, closeLag) };
127
+ });
128
+ }
121
129
  export async function publishDispatch(input) {
122
130
  const akuId = parseAkuId(input.akuId).id;
123
131
  const owner = contractId(input.contractId);
124
132
  const intended = { akuId, contractId: owner, dispatchedAt: new Date().toISOString() };
125
133
  const path = pathFor(akuId);
126
- return await withPrivateStatePublicationSeat(input.repository, async (seat) => {
134
+ return dispatchPublicationWithSeatClose(await withPrivateStatePublicationSeat(input.repository, async (seat) => {
127
135
  const snapshot = await readGitPaths(input.repository, [path]);
128
136
  const current = await dispatchFromSnapshot(input.repository, snapshot, akuId);
129
137
  if (current !== null) {
@@ -176,5 +184,21 @@ export async function publishDispatch(input) {
176
184
  kind: "failed",
177
185
  failure: { kind: "publication-failed", diagnostic: "Dispatch publication outcome is unknown" },
178
186
  };
179
- });
187
+ }));
188
+ }
189
+ export { dispatchAssociationSchema, NO_DISPATCH_ASSOCIATION, parseDispatchAssociation, } from "./association.js";
190
+ function associationDiagnostic(error) {
191
+ return error instanceof Error ? error.message : String(error);
192
+ }
193
+ /** Read-only Dispatch association projection for one Akuma identity. */
194
+ export async function observeDispatchAssociation(repository, akuId) {
195
+ if (repository === undefined)
196
+ return NO_DISPATCH_ASSOCIATION;
197
+ try {
198
+ const dispatch = await readDispatch(repository, akuId);
199
+ return dispatch === null ? NO_DISPATCH_ASSOCIATION : { kind: "associated", contractId: dispatch.contractId };
200
+ }
201
+ catch (error) {
202
+ return { kind: "failed", diagnostic: associationDiagnostic(error) };
203
+ }
180
204
  }
@@ -1,3 +1,4 @@
1
+ import { type Settings } from "../settings.js";
1
2
  export type HookCommand = Readonly<{
2
3
  name: string;
3
4
  argv: readonly string[];
@@ -30,6 +31,13 @@ export type WorktreeHookLag = Readonly<{
30
31
  failure: HookFailure;
31
32
  }>;
32
33
  export type HookPhase = "create" | "destroy";
34
+ export type WorktreeHooksFromInput = Readonly<{
35
+ settings: Settings;
36
+ }>;
37
+ export declare function worktreeHooksFrom(input: WorktreeHooksFromInput): WorktreeHooks;
38
+ export declare function normalizedWorktreeHooks(value: unknown): WorktreeHooks;
39
+ export declare const EMPTY_WORKTREE_HOOKS: WorktreeHooks;
40
+ export declare function worktreeHooksOption(value: unknown): WorktreeHooks;
33
41
  export type HookCommandRun = Readonly<{
34
42
  kind: "ok";
35
43
  }> | Readonly<{
@@ -40,7 +48,7 @@ export type HookCommandRun = Readonly<{
40
48
  failure: HookFailure;
41
49
  }>;
42
50
  /** Execute an ordered command list without lifecycle state. Scratch owns this policy. */
43
- export declare function runHookCommands(worktree: string, commands: readonly HookCommand[], signal?: AbortSignal): Promise<HookCommandRun>;
51
+ export declare function runHookCommands(worktree: string, commands: readonly HookCommand[], signal?: AbortSignal, environment?: NodeJS.ProcessEnv): Promise<HookCommandRun>;
44
52
  export type HookPhaseRun = Readonly<{
45
53
  lag: WorktreeHookLag | null;
46
54
  runs: readonly string[];
@@ -1,4 +1,81 @@
1
1
  import { runProcess } from "../runtime/proc/run.js";
2
+ import { SettingsError } from "../settings.js";
3
+ function record(value) {
4
+ return value !== null && typeof value === "object" && !Array.isArray(value);
5
+ }
6
+ function namespaceFailure(view) {
7
+ if (view.kind !== "failed")
8
+ throw new Error("settings namespace failure expected");
9
+ throw new SettingsError(view.failures.map((failure) => `${failure.scope}: ${failure.diagnostic}`).join("; "));
10
+ }
11
+ function command(value, coordinate, ErrorType) {
12
+ if (!record(value))
13
+ throw new ErrorType(`${coordinate} must be an object`);
14
+ for (const key of Object.keys(value)) {
15
+ if (key !== "name" && key !== "argv" && key !== "timeoutMs")
16
+ throw new ErrorType(`${coordinate} has unknown field: ${key}`);
17
+ }
18
+ if (typeof value.name !== "string" || value.name.trim().length === 0)
19
+ throw new ErrorType(`${coordinate}.name must be nonblank`);
20
+ if (!Array.isArray(value.argv) || value.argv.length === 0 || !value.argv.every((item) => typeof item === "string")) {
21
+ throw new ErrorType(`${coordinate}.argv must be a nonempty string array`);
22
+ }
23
+ if (value.argv[0].trim().length === 0)
24
+ throw new ErrorType(`${coordinate}.argv[0] must be nonblank`);
25
+ if (!Number.isSafeInteger(value.timeoutMs) ||
26
+ value.timeoutMs < 1 ||
27
+ value.timeoutMs > 2_147_483_647) {
28
+ throw new ErrorType(`${coordinate}.timeoutMs must be an integer from 1 through 2147483647`);
29
+ }
30
+ return Object.freeze({
31
+ name: value.name.trim(),
32
+ argv: Object.freeze([...value.argv]),
33
+ timeoutMs: value.timeoutMs,
34
+ });
35
+ }
36
+ function commands(value, coordinate, ErrorType) {
37
+ if (!Array.isArray(value))
38
+ throw new ErrorType(`${coordinate} must be an array`);
39
+ return Object.freeze(value.map((item, index) => command(item, `${coordinate}[${index}]`, ErrorType)));
40
+ }
41
+ export function worktreeHooksFrom(input) {
42
+ if (!record(input))
43
+ throw new TypeError("worktreeHooksFrom input must be an object");
44
+ const view = input.settings.namespace("worktree");
45
+ if (view.kind === "failed")
46
+ namespaceFailure(view);
47
+ for (const entry of view.entries) {
48
+ if (entry.name !== "create" && entry.name !== "destroy") {
49
+ throw new SettingsError(`worktree has unknown entry: ${entry.name}`);
50
+ }
51
+ }
52
+ const selected = (phase) => {
53
+ const entry = view.entries.find((item) => item.name === phase);
54
+ if (entry === undefined)
55
+ return Object.freeze([]);
56
+ return commands(entry.value, `worktree.${phase}`, SettingsError);
57
+ };
58
+ return Object.freeze({ create: selected("create"), destroy: selected("destroy") });
59
+ }
60
+ export function normalizedWorktreeHooks(value) {
61
+ if (!record(value))
62
+ throw new TypeError("hooks must be an object");
63
+ for (const key of Object.keys(value)) {
64
+ if (key !== "create" && key !== "destroy")
65
+ throw new TypeError(`hooks has unknown field: ${key}`);
66
+ }
67
+ return Object.freeze({
68
+ create: commands(value.create, "hooks.create", TypeError),
69
+ destroy: commands(value.destroy, "hooks.destroy", TypeError),
70
+ });
71
+ }
72
+ export const EMPTY_WORKTREE_HOOKS = Object.freeze({
73
+ create: Object.freeze([]),
74
+ destroy: Object.freeze([]),
75
+ });
76
+ export function worktreeHooksOption(value) {
77
+ return value === undefined ? EMPTY_WORKTREE_HOOKS : normalizedWorktreeHooks(value);
78
+ }
2
79
  function failedOutcome(outcome) {
3
80
  if (outcome.kind === "terminal") {
4
81
  return outcome.code === 0
@@ -14,13 +91,14 @@ function failedOutcome(outcome) {
14
91
  return outcome;
15
92
  }
16
93
  /** Execute an ordered command list without lifecycle state. Scratch owns this policy. */
17
- export async function runHookCommands(worktree, commands, signal) {
94
+ export async function runHookCommands(worktree, commands, signal, environment) {
18
95
  for (const [command, value] of commands.entries()) {
19
96
  const outcome = await runProcess({
20
97
  argv: value.argv,
21
98
  timeoutMs: value.timeoutMs,
22
99
  cwd: worktree,
23
100
  ...(signal === undefined ? {} : { signal }),
101
+ ...(environment === undefined ? {} : { env: environment }),
24
102
  });
25
103
  if (outcome.kind === "cancelled")
26
104
  return outcome;
@@ -1,3 +1,4 @@
1
1
  import type { WorldRoot } from "../world.js";
2
2
  import { type GitRepository } from "./process.js";
3
- export declare function nukeGit(world: WorldRoot, gitPath?: string, options?: Readonly<Pick<GitRepository, "onPrivateStateSeatContention">>): Promise<void>;
3
+ import { type PrivateStateSeatOutcome } from "./private-state-seat.js";
4
+ export declare function nukeGit(world: WorldRoot, gitPath?: string, options?: Readonly<Pick<GitRepository, "onPrivateStateSeatContention" | "onPrivateStateSeatClose">>): Promise<PrivateStateSeatOutcome<void>>;
@@ -2,8 +2,8 @@ import { access, lstat, realpath, rm } from "node:fs/promises";
2
2
  import { isAbsolute, relative, sep } from "node:path";
3
3
  import { nukeEmptyPlaceAuthority, readPlaceRegister, releaseManagedWorktrees, withPlaceAuthorityFence, } from "../workspace-place.js";
4
4
  import { GitPlumbingError, runGit } from "./process.js";
5
- import { confirmPrivateStatePublication, withPrivateStatePublicationSeat } from "./private-state-seat.js";
6
- import { CANDIDATE_PIN_REF_NAMESPACE, DELIVERY_REF_NAMESPACE, GIT_REF, LEGACY_CANDIDATE_PIN_REF_NAMESPACE, LEGACY_DELIVERY_REF_NAMESPACE, NoGitWorldError, readRef, registeredWorktrees, repositoryAt, worktreeGitDirectory, } from "./repository.js";
5
+ import { confirmPrivateStatePublication, withPrivateStatePublicationSeat, } from "./private-state-seat.js";
6
+ import { CANDIDATE_PIN_REF_NAMESPACE, DELIVERY_REF_NAMESPACE, GIT_REF, NoGitWorldError, readRef, registeredWorktrees, repositoryAt, worktreeGitDirectory, } from "./repository.js";
7
7
  import { worktreePath } from "./workspace.js";
8
8
  async function managedCustody(repository) {
9
9
  const register = await readPlaceRegister(repository);
@@ -117,12 +117,7 @@ async function deleteObservedStateRef(repository, expectedOid, seat) {
117
117
  throw new Error("state-ref deletion outcome is unknown");
118
118
  }
119
119
  async function removeOwnedRefs(repository) {
120
- const roots = [
121
- DELIVERY_REF_NAMESPACE,
122
- CANDIDATE_PIN_REF_NAMESPACE,
123
- LEGACY_DELIVERY_REF_NAMESPACE,
124
- LEGACY_CANDIDATE_PIN_REF_NAMESPACE,
125
- ];
120
+ const roots = [DELIVERY_REF_NAMESPACE, CANDIDATE_PIN_REF_NAMESPACE];
126
121
  for (const root of roots) {
127
122
  const refs = (await runGit(repository, ["for-each-ref", "--format=%(refname)", root]))
128
123
  .toString("utf8")
@@ -142,12 +137,12 @@ export async function nukeGit(world, gitPath = "git", options) {
142
137
  }
143
138
  catch (error) {
144
139
  if (error instanceof NoGitWorldError)
145
- return;
140
+ return { value: undefined };
146
141
  throw error;
147
142
  }
148
- await withPlaceAuthorityFence(repository, async (placeFence) => {
143
+ return await withPlaceAuthorityFence(repository, async (placeFence) => {
149
144
  const custody = await managedCustody(repository);
150
- await withPrivateStatePublicationSeat(repository, async (seat) => {
145
+ return await withPrivateStatePublicationSeat(repository, async (seat) => {
151
146
  const state = await readRef(repository, GIT_REF);
152
147
  if (state !== null)
153
148
  await deleteObservedStateRef(repository, state, seat);
@@ -1,12 +1,37 @@
1
1
  import type { GitRepository } from "./process.js";
2
2
  declare const privateStateSeat: unique symbol;
3
+ /** Timed-out wait for the private-state publication seat. The holder and lock are unchanged. */
4
+ export declare class GitPrivateStateSeatContentionError extends Error {
5
+ readonly reason: "timeout";
6
+ constructor(message: string, options?: ErrorOptions);
7
+ }
3
8
  /** Proves an admission's private-root observation was made while the shared seat was held. */
4
9
  export type PrivateStatePublicationSeat = Readonly<{
5
10
  readonly [privateStateSeat]: true;
6
11
  }>;
12
+ /** Post-confirmation failure to release the private-state publication seat. */
13
+ export type PrivateStateSeatCloseLag = Readonly<{
14
+ kind: "private-state-seat-close-failed";
15
+ diagnostic: string;
16
+ }>;
17
+ /** Action result plus any confirmed-publication seat-close lag. */
18
+ export type PrivateStateSeatOutcome<T> = Readonly<{
19
+ value: T;
20
+ closeLag?: PrivateStateSeatCloseLag;
21
+ }>;
7
22
  /** Record a known or exact-read-back-proven private-root publication. */
8
23
  export declare function confirmPrivateStatePublication(seat: PrivateStatePublicationSeat): void;
9
24
  export declare function privateStatePublicationSeatPath(repository: GitRepository): string;
25
+ export declare function privateStateSeatCloseLag(error: unknown): PrivateStateSeatCloseLag;
26
+ export declare function concatenatePrivateStateSeatClose(current: readonly PrivateStateSeatCloseLag[] | undefined, next: readonly PrivateStateSeatCloseLag[] | undefined): readonly PrivateStateSeatCloseLag[] | undefined;
27
+ export declare function appendPrivateStateSeatClose(current: readonly PrivateStateSeatCloseLag[] | undefined, closeLag: PrivateStateSeatCloseLag): readonly PrivateStateSeatCloseLag[];
28
+ /** Unwrap a seat outcome that has no typed lag surface; confirmed close lag throws. */
29
+ export declare function requireClosedPrivateStateSeat<T>(outcome: PrivateStateSeatOutcome<T>): T;
30
+ /** Unwrap a seat outcome through an owner-typed merge of confirmed close lag. */
31
+ export declare function mergePrivateStateSeatClose<T>(outcome: PrivateStateSeatOutcome<T>, merge: (value: T, closeLag: PrivateStateSeatCloseLag) => T): T;
32
+ export declare function isPrivateStateSeatContention(error: unknown): error is GitPrivateStateSeatContentionError;
10
33
  /** Serialize cooperating writers of the one private Git state root. */
11
- export declare function withPrivateStatePublicationSeat<T>(repository: GitRepository, action: (seat: PrivateStatePublicationSeat) => T | Promise<T>): Promise<T>;
34
+ export declare function withPrivateStatePublicationSeat<T>(repository: GitRepository, action: (seat: PrivateStatePublicationSeat) => T | Promise<T>, options?: Readonly<{
35
+ timeoutMs?: number;
36
+ }>): Promise<PrivateStateSeatOutcome<T>>;
12
37
  export {};