@astrosheep/keiyaku 4.6.27 → 4.6.29

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 (293) hide show
  1. package/README.md +76 -35
  2. package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
  3. package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +41 -4
  4. package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +4 -7
  5. package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +1 -1
  6. package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +39 -15
  7. package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +42 -22
  8. package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
  9. package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +41 -4
  10. package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +4 -7
  11. package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +1 -1
  12. package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +39 -15
  13. package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +42 -22
  14. package/build/plugins/opencode/package.json +1 -1
  15. package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +41 -4
  16. package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +4 -7
  17. package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +1 -1
  18. package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +39 -15
  19. package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +42 -22
  20. package/build/plugins/pi/README.md +17 -12
  21. package/build/plugins/pi/akuma-tools.ts +5 -20
  22. package/build/plugins/pi/keiyaku.ts +73 -1
  23. package/build/skills/keiyaku-akuma/SKILL.md +41 -4
  24. package/build/skills/keiyaku-akuma/references/automation.md +4 -7
  25. package/build/skills/keiyaku-babysit/SKILL.md +1 -1
  26. package/build/skills/keiyaku-bind/SKILL.md +39 -15
  27. package/build/skills/keiyaku-workflow/SKILL.md +42 -22
  28. package/build/src/akuma/akuma-call.d.ts +15 -18
  29. package/build/src/akuma/akuma-call.js +55 -112
  30. package/build/src/akuma/akuma-errors.d.ts +0 -5
  31. package/build/src/akuma/akuma-errors.js +0 -9
  32. package/build/src/akuma/akuma-instance.d.ts +0 -2
  33. package/build/src/akuma/akuma-instance.js +18 -14
  34. package/build/src/akuma/akuma-observe.js +0 -1
  35. package/build/src/akuma/akuma-owner.js +5 -5
  36. package/build/src/akuma/akuma.d.ts +12 -26
  37. package/build/src/akuma/akuma.js +17 -7
  38. package/build/src/akuma/archetype.d.ts +0 -2
  39. package/build/src/akuma/archetype.js +3 -9
  40. package/build/src/akuma/body-launch.d.ts +12 -4
  41. package/build/src/akuma/body.d.ts +2 -5
  42. package/build/src/akuma/body.js +5 -49
  43. package/build/src/akuma/call-initial-tell.d.ts +39 -147
  44. package/build/src/akuma/call-initial-tell.js +0 -48
  45. package/build/src/akuma/caller.d.ts +0 -4
  46. package/build/src/akuma/custody.js +1 -57
  47. package/build/src/akuma/heart/facts.d.ts +0 -39
  48. package/build/src/akuma/heart/facts.js +0 -1
  49. package/build/src/akuma/heart/index.d.ts +1 -2
  50. package/build/src/akuma/heart/index.js +0 -1
  51. package/build/src/akuma/heart/schema.js +0 -26
  52. package/build/src/akuma/heart/soul.d.ts +2 -2
  53. package/build/src/akuma/heart/soul.js +2 -4
  54. package/build/src/akuma/identity.d.ts +4 -1
  55. package/build/src/akuma/identity.js +7 -2
  56. package/build/src/akuma/in-process-body.d.ts +1 -1
  57. package/build/src/akuma/index.d.ts +0 -2
  58. package/build/src/akuma/index.js +0 -1
  59. package/build/src/akuma/projection.d.ts +30 -24
  60. package/build/src/akuma/projection.js +6 -1
  61. package/build/src/akuma/provider.d.ts +0 -5
  62. package/build/src/akuma/provider.js +0 -1
  63. package/build/src/akuma/providers/acp/core.js +1 -1
  64. package/build/src/akuma/providers/claude/index.js +1 -2
  65. package/build/src/akuma/providers/codex-app-server/index.js +1 -1
  66. package/build/src/akuma/providers/execution-environment.d.ts +1 -3
  67. package/build/src/akuma/providers/execution-environment.js +1 -7
  68. package/build/src/akuma/providers/opencode-sdk/index.js +0 -1
  69. package/build/src/akuma/providers/opencode-sdk/session.d.ts +0 -1
  70. package/build/src/akuma/providers/opencode-sdk/session.js +4 -4
  71. package/build/src/akuma/providers/paseo/index.js +2 -9
  72. package/build/src/akuma/providers/pi/index.js +8 -14
  73. package/build/src/akuma/publication.d.ts +24 -59
  74. package/build/src/akuma/publication.js +29 -64
  75. package/build/src/akuma/selection-observation.d.ts +47 -2036
  76. package/build/src/akuma/selection-observation.js +1 -59
  77. package/build/src/akuma/turn-drive.d.ts +0 -8
  78. package/build/src/akuma/turn-drive.js +19 -103
  79. package/build/src/akuma-body.js +3 -6
  80. package/build/src/body-host.d.ts +8 -2
  81. package/build/src/body-host.js +30 -4
  82. package/build/src/cli/commands/akuma-grammar.d.ts +0 -2
  83. package/build/src/cli/commands/akuma-grammar.js +14 -37
  84. package/build/src/cli/commands/akuma.js +31 -49
  85. package/build/src/cli/commands/contract-grammar.d.ts +7 -1
  86. package/build/src/cli/commands/contract-grammar.js +15 -0
  87. package/build/src/cli/commands/contract-help.d.ts +13 -1
  88. package/build/src/cli/commands/contract-help.js +47 -16
  89. package/build/src/cli/commands/contract.js +27 -26
  90. package/build/src/cli/commands/debt.js +3 -3
  91. package/build/src/cli/commands/whoami.d.ts +0 -2
  92. package/build/src/cli/commands/whoami.js +0 -5
  93. package/build/src/cli/coordinates.js +15 -0
  94. package/build/src/cli/delivery-identity.d.ts +3 -0
  95. package/build/src/cli/delivery-identity.js +23 -0
  96. package/build/src/cli/parse.js +1 -0
  97. package/build/src/cli/render/akuma-activity.d.ts +0 -1
  98. package/build/src/cli/render/akuma-activity.js +8 -12
  99. package/build/src/cli/render/akuma.js +1 -1
  100. package/build/src/cli/render/catalog.js +7 -1
  101. package/build/src/cli/render/contract-history.js +16 -38
  102. package/build/src/cli/render/contract-observation.d.ts +23 -10
  103. package/build/src/cli/render/contract-observation.js +9 -6
  104. package/build/src/cli/render/contract-wait.d.ts +2 -0
  105. package/build/src/cli/render/contract-wait.js +18 -0
  106. package/build/src/cli/render/contract.d.ts +2 -2
  107. package/build/src/cli/render/contract.js +57 -39
  108. package/build/src/cli/render/delivery-preview.js +13 -26
  109. package/build/src/cli/render/execution-progress.js +9 -9
  110. package/build/src/cli/render/kanshi.js +4 -11
  111. package/build/src/cli/render/receipt.d.ts +18 -0
  112. package/build/src/cli/render/receipt.js +34 -10
  113. package/build/src/cli/render/reconcile.js +3 -0
  114. package/build/src/cli/render/refusal.js +28 -6
  115. package/build/src/cli/render/whoami.js +1 -4
  116. package/build/src/cli/runtime.d.ts +0 -2
  117. package/build/src/cli/runtime.js +3 -7
  118. package/build/src/cli/selectors.d.ts +1 -2
  119. package/build/src/cli/selectors.js +2 -5
  120. package/build/src/contract-guidance.js +4 -2
  121. package/build/src/contract-worktree.d.ts +3 -3
  122. package/build/src/core/facts/codec.js +38 -5
  123. package/build/src/core/facts/fold.js +1 -0
  124. package/build/src/core/facts/gate.d.ts +10 -4
  125. package/build/src/core/facts/gate.js +56 -39
  126. package/build/src/core/facts/observation.d.ts +7 -1
  127. package/build/src/core/facts/observation.js +15 -0
  128. package/build/src/core/facts/offer.d.ts +2 -2
  129. package/build/src/core/facts/types.d.ts +17 -1
  130. package/build/src/core/facts/types.js +6 -0
  131. package/build/src/core/verbs/amend.js +8 -0
  132. package/build/src/core/verbs/bind.d.ts +3 -1
  133. package/build/src/core/verbs/bind.js +9 -1
  134. package/build/src/core/verbs/deliver.d.ts +2 -1
  135. package/build/src/core/verbs/deliver.js +4 -1
  136. package/build/src/core/verbs/placement.d.ts +2 -1
  137. package/build/src/core/verbs/placement.js +7 -4
  138. package/build/src/core/verbs/reintegrate.d.ts +2 -1
  139. package/build/src/core/verbs/reintegrate.js +4 -1
  140. package/build/src/debt/board.d.ts +10 -10
  141. package/build/src/debt/created-observation.d.ts +3 -3
  142. package/build/src/debt/document.d.ts +1 -1
  143. package/build/src/debt/index.d.ts +2 -24
  144. package/build/src/debt/index.js +11 -71
  145. package/build/src/debt/operation-types.d.ts +44 -3
  146. package/build/src/git/admission.js +18 -6
  147. package/build/src/git/integration.d.ts +4 -4
  148. package/build/src/git/integration.js +7 -1
  149. package/build/src/git/observe.d.ts +6 -4
  150. package/build/src/git/observe.js +18 -17
  151. package/build/src/git/reconcile.d.ts +20 -8
  152. package/build/src/git/reconcile.js +94 -45
  153. package/build/src/git/repository.d.ts +3 -1
  154. package/build/src/git/repository.js +26 -4
  155. package/build/src/git/scratch.d.ts +1 -1
  156. package/build/src/git/scratch.js +19 -18
  157. package/build/src/git/target-placement.d.ts +33 -7
  158. package/build/src/git/target-placement.js +67 -18
  159. package/build/src/git/target.d.ts +32 -0
  160. package/build/src/git/target.js +84 -0
  161. package/build/src/git/terminal-reconcile.d.ts +1 -1
  162. package/build/src/git/terminal-reconcile.js +34 -6
  163. package/build/src/index.d.ts +11 -8
  164. package/build/src/index.js +2 -2
  165. package/build/src/kanshi/counts.d.ts +15 -0
  166. package/build/src/kanshi/counts.js +66 -0
  167. package/build/src/kanshi/index.d.ts +2 -0
  168. package/build/src/kanshi/index.js +1 -0
  169. package/build/src/library/address.d.ts +1 -20
  170. package/build/src/library/address.js +3 -24
  171. package/build/src/library/akuma-creation.d.ts +2 -5
  172. package/build/src/library/akuma-creation.js +60 -44
  173. package/build/src/library/akumas.d.ts +3 -9
  174. package/build/src/library/akumas.js +12 -25
  175. package/build/src/library/bind.d.ts +21 -9
  176. package/build/src/library/bind.js +5 -1
  177. package/build/src/library/continuation.d.ts +130 -155
  178. package/build/src/library/continuation.js +1 -4
  179. package/build/src/library/contract-composition.d.ts +4 -9
  180. package/build/src/library/contract-composition.js +8 -12
  181. package/build/src/library/contract-creation.d.ts +1 -3
  182. package/build/src/library/contract-creation.js +2 -3
  183. package/build/src/library/contract-execution.d.ts +3 -5
  184. package/build/src/library/contract-execution.js +55 -96
  185. package/build/src/library/contract-outcomes.d.ts +2 -1
  186. package/build/src/library/contract-types.d.ts +5 -0
  187. package/build/src/library/contract-wait.d.ts +35 -0
  188. package/build/src/library/contract-wait.js +141 -0
  189. package/build/src/library/delivery.d.ts +13 -525
  190. package/build/src/library/delivery.js +1 -12
  191. package/build/src/library/input.js +2 -1
  192. package/build/src/library/invocation.d.ts +5 -1
  193. package/build/src/library/invocation.js +9 -2
  194. package/build/src/library/keiyaku.d.ts +7 -6
  195. package/build/src/library/keiyaku.js +12 -7
  196. package/build/src/library/outcome.d.ts +461 -12586
  197. package/build/src/library/outcome.js +15 -234
  198. package/build/src/library/reconcile.d.ts +12 -0
  199. package/build/src/library/reconcile.js +1 -0
  200. package/build/src/library/refusal.d.ts +251 -34
  201. package/build/src/library/refusal.js +10 -5
  202. package/build/src/library/selection.d.ts +15 -36
  203. package/build/src/library/selection.js +64 -132
  204. package/build/src/plugin/akuma-signals.d.ts +2 -2
  205. package/build/src/plugin/akuma-signals.js +2 -2
  206. package/build/src/plugin/public.d.ts +0 -7
  207. package/build/src/plugin/runtime.d.ts +2 -2
  208. package/build/src/plugin/runtime.js +4 -3
  209. package/build/src/protocol/attempt.js +7 -3
  210. package/build/src/protocol/bind.d.ts +18 -4
  211. package/build/src/protocol/bind.js +102 -35
  212. package/build/src/protocol/completion.d.ts +18 -331
  213. package/build/src/protocol/completion.js +17 -130
  214. package/build/src/protocol/deliver.d.ts +3 -3
  215. package/build/src/protocol/deliver.js +64 -74
  216. package/build/src/protocol/delivery-preview.d.ts +85 -28
  217. package/build/src/protocol/delivery-preview.js +34 -22
  218. package/build/src/protocol/execution-observation.d.ts +12 -9
  219. package/build/src/protocol/execution-observation.js +0 -1
  220. package/build/src/protocol/intent.d.ts +20 -50
  221. package/build/src/protocol/intent.js +37 -44
  222. package/build/src/protocol/operations.d.ts +299 -19
  223. package/build/src/protocol/operations.js +68 -27
  224. package/build/src/protocol/outcome.d.ts +1 -1
  225. package/build/src/protocol/placement.d.ts +2 -2
  226. package/build/src/protocol/placement.js +4 -3
  227. package/build/src/protocol/progress.d.ts +35 -2
  228. package/build/src/protocol/progress.js +12 -1
  229. package/build/src/protocol/read/observation.js +15 -4
  230. package/build/src/protocol/read/status.d.ts +9 -14
  231. package/build/src/protocol/read/status.js +15 -22
  232. package/build/src/protocol/reintegrate.d.ts +4 -3
  233. package/build/src/protocol/reintegrate.js +21 -5
  234. package/build/src/protocol/review.d.ts +9 -15
  235. package/build/src/protocol/review.js +2 -6
  236. package/build/src/protocol/run.d.ts +1 -1
  237. package/build/src/protocol/verify.d.ts +51 -0
  238. package/build/src/protocol/verify.js +128 -0
  239. package/build/src/verification/declaration.d.ts +5 -1
  240. package/build/src/verification/declaration.js +19 -2
  241. package/build/src/verification/execution.d.ts +5 -2
  242. package/build/src/verification/execution.js +48 -53
  243. package/build/src/verification/observation.d.ts +10 -6
  244. package/build/src/verification/observation.js +5 -2
  245. package/package.json +3 -3
  246. package/plugins/paseo/plugin/index.server.ts +3 -0
  247. package/plugins/paseo/plugin/server/attach.ts +42 -0
  248. package/plugins/paseo/plugin/server/mirror-identity.ts +51 -0
  249. package/plugins/paseo/plugin/server/model.ts +26 -0
  250. package/plugins/paseo/plugin/server/provider.ts +4 -6
  251. package/plugins/paseo/plugin/server/reopen.ts +4 -39
  252. package/plugins/pi/README.md +17 -12
  253. package/plugins/pi/akuma-tools.ts +5 -20
  254. package/plugins/pi/keiyaku.ts +73 -1
  255. package/skills/keiyaku-akuma/SKILL.md +41 -4
  256. package/skills/keiyaku-akuma/references/automation.md +4 -7
  257. package/skills/keiyaku-babysit/SKILL.md +1 -1
  258. package/skills/keiyaku-bind/SKILL.md +39 -15
  259. package/skills/keiyaku-workflow/SKILL.md +42 -22
  260. package/build/src/akuma/allowed.d.ts +0 -23
  261. package/build/src/akuma/allowed.js +0 -63
  262. package/build/src/akuma/call-request.d.ts +0 -308
  263. package/build/src/akuma/call-request.js +0 -175
  264. package/build/src/akuma/heart/request-authority.d.ts +0 -16
  265. package/build/src/akuma/heart/request-authority.js +0 -140
  266. package/build/src/akuma/heart/request-rows.d.ts +0 -18
  267. package/build/src/akuma/heart/request-rows.js +0 -107
  268. package/build/src/akuma/request-lifecycle.d.ts +0 -42
  269. package/build/src/akuma/request-lifecycle.js +0 -197
  270. package/build/src/akuma/request-observation.d.ts +0 -45
  271. package/build/src/akuma/request-observation.js +0 -162
  272. package/build/src/akuma/request-rendezvous.d.ts +0 -32
  273. package/build/src/akuma/request-rendezvous.js +0 -189
  274. package/build/src/akuma/request-serve.d.ts +0 -16
  275. package/build/src/akuma/request-serve.js +0 -188
  276. package/build/src/akuma/request-wire.d.ts +0 -143
  277. package/build/src/akuma/request-wire.js +0 -146
  278. package/build/src/akuma/requests.d.ts +0 -20
  279. package/build/src/akuma/requests.js +0 -72
  280. package/build/src/akuma/selection-owner-port.d.ts +0 -14
  281. package/build/src/akuma/selection-owner-port.js +0 -54
  282. package/build/src/akuma/selection-request.d.ts +0 -305
  283. package/build/src/akuma/selection-request.js +0 -307
  284. package/build/src/body-requests.d.ts +0 -13
  285. package/build/src/body-requests.js +0 -131
  286. package/build/src/cli/square-identity.d.ts +0 -10
  287. package/build/src/cli/square-identity.js +0 -130
  288. package/build/src/debt/mutation-result.d.ts +0 -981
  289. package/build/src/debt/mutation-result.js +0 -109
  290. package/build/src/debt/mutation.d.ts +0 -424
  291. package/build/src/debt/mutation.js +0 -223
  292. package/build/src/library/contract-operations.d.ts +0 -382
  293. package/build/src/library/contract-operations.js +0 -300
@@ -1,12 +1,13 @@
1
1
  import { z } from "zod";
2
2
  import { boundedListLimit } from "../bounded-list.js";
3
- import { gate } from "../core/facts/types.js";
3
+ import { gate, requirementId } from "../core/facts/types.js";
4
4
  import { changeIdSchema, contractIdSchema, snapshotIdSchema } from "../git/identity.js";
5
5
  import { integrationPreparationRefusalSchema, readDeliveryDiff } from "../git/integration.js";
6
- import { currentBranch, observeContractAt } from "../git/observe.js";
6
+ import { observeContractAt } from "../git/observe.js";
7
7
  import { withGitReadObservation } from "../git/read-observation.js";
8
- import { repositoryAt } from "../git/repository.js";
8
+ import { currentBranch, repositoryAt } from "../git/repository.js";
9
9
  import { checkoutNotFollowableRefusalSchema } from "../git/target-placement.js";
10
+ import { targetWorkspaceRefusalSchema } from "../git/target.js";
10
11
  import { dirtyWorkspaceRefusalSchema, unmergedPathsRefusalSchema, worktreeMissingRefusalSchema, } from "../git/tender.js";
11
12
  import { conflictRecoverySchema, worktreeWorkspaceSchema } from "../git/workspace.js";
12
13
  import { forkSourceMovedRefusalSchema, targetInputRefusalSchema } from "./bind.js";
@@ -41,21 +42,22 @@ export const deliverDataSchema = z
41
42
  policy: z.object({ requireBranchesToBeUpToDate: z.boolean() }).strict(),
42
43
  })
43
44
  .strict();
44
- export function recordedIntegrationSnapshots(journal) {
45
- return journal
46
- .flatMap((entry) => entry.kind === "deliver"
47
- ? [entry.data.integration.snapshot]
48
- : entry.kind === "reintegrated"
49
- ? [entry.data.snapshot]
50
- : [])
51
- .reverse();
52
- }
53
45
  export const verdictSchema = z.enum(["satisfied", "unsatisfied"]);
54
46
  export const activeContractRefusalSchema = z
55
47
  .object({ kind: z.enum(["contract-missing", "terminal"]), contractId: contractIdSchema })
56
48
  .strict();
57
49
  export const bindRefusalSchema = z
58
- .object({ kind: z.enum(["contract-exists", "invalid-after", "unknown-prerequisite"]), contractId: contractIdSchema })
50
+ .object({
51
+ kind: z.enum([
52
+ "contract-exists",
53
+ "invalid-after",
54
+ "unknown-prerequisite",
55
+ "target-contract-missing",
56
+ "target-contract-terminal",
57
+ "target-contract-self",
58
+ ]),
59
+ contractId: contractIdSchema,
60
+ })
59
61
  .strict();
60
62
  export const amendRefusalSchema = z
61
63
  .object({
@@ -64,7 +66,17 @@ export const amendRefusalSchema = z
64
66
  })
65
67
  .strict();
66
68
  export const deliverRefusalSchema = z
67
- .object({ kind: z.enum(["contract-missing", "terminal", "document-moved"]), contractId: contractIdSchema })
69
+ .object({
70
+ kind: z.enum([
71
+ "contract-missing",
72
+ "terminal",
73
+ "document-moved",
74
+ "target-contract-missing",
75
+ "target-contract-terminal",
76
+ "target-contract-self",
77
+ ]),
78
+ contractId: contractIdSchema,
79
+ })
68
80
  .strict();
69
81
  export const verificationDeclarationRefusalSchema = z
70
82
  .object({ kind: z.literal("verification-declaration-invalid"), contractId: contractIdSchema.optional() })
@@ -77,25 +89,52 @@ export const candidateContentChangeSchema = z
77
89
  currentChange: changeIdSchema,
78
90
  })
79
91
  .strict();
92
+ export const gateCurrentSchema = z.union([
93
+ z.object({ kind: z.literal("missing") }).strict(),
94
+ z
95
+ .object({ kind: z.literal("attested"), verdict: verdictSchema, at: z.string(), summary: z.string().optional() })
96
+ .strict(),
97
+ z
98
+ .object({ kind: z.literal("stale"), priorVerdict: verdictSchema, reason: candidateContentChangeSchema.optional() })
99
+ .strict(),
100
+ ]);
101
+ export const requirementIdSchema = z
102
+ .string()
103
+ .min(1)
104
+ .transform((value) => requirementId(value));
105
+ export const requirementReportSchema = z
106
+ .object({
107
+ requirement: requirementIdSchema,
108
+ current: gateCurrentSchema,
109
+ })
110
+ .strict();
80
111
  export const gateReportSchema = z
81
112
  .object({
82
113
  gate: gateSchema,
83
- current: z.union([
84
- z.object({ kind: z.literal("missing") }).strict(),
85
- z
86
- .object({ kind: z.literal("attested"), verdict: verdictSchema, at: z.string(), summary: z.string().optional() })
87
- .strict(),
88
- z
89
- .object({
90
- kind: z.literal("stale"),
91
- priorVerdict: verdictSchema,
92
- reason: candidateContentChangeSchema.optional(),
93
- })
94
- .strict(),
95
- ]),
114
+ requirements: z.array(requirementReportSchema).readonly(),
115
+ satisfied: z.boolean(),
116
+ current: gateCurrentSchema,
96
117
  })
97
118
  .strict();
119
+ export const verifyRefusalSchema = z.union([
120
+ z.object({ kind: z.literal("verification-not-selected"), contractId: contractIdSchema }).strict(),
121
+ z
122
+ .object({
123
+ kind: z.literal("verification-index-out-of-range"),
124
+ contractId: contractIdSchema,
125
+ index: z.number().int().positive(),
126
+ total: z.number().int().nonnegative(),
127
+ })
128
+ .strict(),
129
+ ]);
98
130
  export const placementRefusalSchema = z.union([
131
+ z
132
+ .object({
133
+ kind: z.enum(["target-contract-missing", "target-contract-terminal", "target-contract-self"]),
134
+ contractId: contractIdSchema,
135
+ })
136
+ .strict(),
137
+ targetWorkspaceRefusalSchema,
99
138
  z
100
139
  .object({ kind: z.enum(["contract-missing", "delivery-missing", "terminal"]), contractId: contractIdSchema })
101
140
  .strict(),
@@ -134,6 +173,7 @@ const targetMissingRefusalSchema = z
134
173
  .object({ kind: z.literal("target-missing"), contractId: contractIdSchema })
135
174
  .strict();
136
175
  export const deliveryPreparationRefusalSchema = z.union([
176
+ targetWorkspaceRefusalSchema,
137
177
  targetMissingRefusalSchema,
138
178
  worktreeMissingRefusalSchema,
139
179
  dirtyWorkspaceRefusalSchema,
@@ -153,6 +193,7 @@ export const intentRefusalSchema = z.union([
153
193
  placementRefusalSchema,
154
194
  targetInputRefusalSchema,
155
195
  verificationDeclarationRefusalSchema,
196
+ verifyRefusalSchema,
156
197
  ]);
157
198
  /**
158
199
  * Observe, decide, and atomically admit one intent over the invoking actor and time, then complete it
@@ -3,7 +3,7 @@ import type { WorktreeLeak } from "../git/scratch.js";
3
3
  import type { ReconcileResult } from "../git/reconcile.js";
4
4
  import type { PrivateStateSeatCloseLag } from "../git/private-state-seat.js";
5
5
  import type { AcceptedAdmission } from "./attempt.js";
6
- import type { VerificationCleanupFailure } from "./intent.js";
6
+ import type { VerificationCleanupFailure } from "./progress.js";
7
7
  import type { ProtocolResult, ProtocolTerminal } from "./run.js";
8
8
  export type AcceptedProtocolStep = AcceptedAdmission & Readonly<{
9
9
  physical?: ReconcileResult;
@@ -1,5 +1,5 @@
1
1
  import type { ProtocolProgress } from "./progress.js";
2
- import type { ActorId, ContractId, SnapshotId } from "../core/facts/types.js";
2
+ import { type ActorId, type ContractId, type ContractTarget, type SnapshotId } from "../core/facts/types.js";
3
3
  import { type PlacementRefusal } from "../core/verbs/placement.js";
4
4
  import type { GitDecodeChannel } from "../git/read-observation.js";
5
5
  import { type ReconcileResult } from "../git/reconcile.js";
@@ -32,7 +32,7 @@ type PlacementProtocolInput = Readonly<{
32
32
  type PlacementAdmissionInput<ExtraRefusal> = Readonly<{
33
33
  channel: GitDecodeChannel;
34
34
  repository: GitRepository;
35
- target: string | undefined;
35
+ target: ContractTarget | undefined;
36
36
  placement: PlacementProtocolInput;
37
37
  onDeliveryMissing?: () => Promise<PlacementProtocolResult<ExtraRefusal> | undefined>;
38
38
  progress?: ProtocolProgress;
@@ -1,6 +1,7 @@
1
1
  import { SqliteTransactionLockError } from "../coordination/sqlite-transaction-lock.js";
2
2
  import { AuthorityCorruptionError } from "../core/facts/errors.js";
3
3
  import { contractState } from "../core/facts/observation.js";
4
+ import { targetName, } from "../core/facts/types.js";
4
5
  import { decidePlacement } from "../core/verbs/placement.js";
5
6
  import { observeContractsForAdmissionAt, observeGitForAdmissionAt } from "../git/observe.js";
6
7
  import { withPrivateStatePublicationSeat } from "../git/private-state-seat.js";
@@ -21,7 +22,7 @@ export async function observeIntegrationTargetMovement(repository, state) {
21
22
  return {
22
23
  kind: "target-moved",
23
24
  contractId: state.id,
24
- target,
25
+ target: targetName(target),
25
26
  expected: integration.predecessor,
26
27
  observed,
27
28
  observedTreeEqualsCandidate: await observedTreeEqualsCandidate(repository, observed, integration.snapshot),
@@ -72,7 +73,7 @@ async function runFencedPlacement(repository, input, protocol) {
72
73
  return {
73
74
  kind: "target-moved",
74
75
  contractId: input.contractId,
75
- target: target.target,
76
+ target: targetName(target.target),
76
77
  expected: target.expectedOid,
77
78
  observed,
78
79
  observedTreeEqualsCandidate: await observedTreeEqualsCandidate(repository, observed, target.newOid),
@@ -192,7 +193,7 @@ export async function admitPlacement(admission) {
192
193
  };
193
194
  if (target === undefined)
194
195
  return await runProtocol(protocol);
195
- return await runUnderTargetPlacementFence(repository, target, async () => {
196
+ return await runUnderTargetPlacementFence(repository, targetName(target), async () => {
196
197
  const result = await runFencedPlacement(repository, input, protocol);
197
198
  if (onDeliveryMissing === undefined || !isDeliveryMissing(result))
198
199
  return result;
@@ -3,9 +3,9 @@ import type { ContractHead, ContractId, ContractState, JournalEntry, SnapshotId
3
3
  import type { ReconcileResult } from "../git/reconcile.js";
4
4
  import type { WorktreeLeak } from "../git/scratch.js";
5
5
  import { type PrivateStateSeatCloseLag } from "../git/private-state-seat.js";
6
- import type { VerificationCleanupFailure } from "./intent.js";
7
6
  import type { AcceptedProtocolStep } from "./outcome.js";
8
7
  import type { ExecutionObservation } from "./execution-observation.js";
8
+ import type { VerificationCheck } from "./verify.js";
9
9
  import type { CandidateCompletion, CompletionEvidence } from "./completion.js";
10
10
  /** A captured interpretation is not an invocation's admission receipt. */
11
11
  export type ContractCheckpoint = Readonly<{
@@ -13,6 +13,31 @@ export type ContractCheckpoint = Readonly<{
13
13
  journal: readonly JournalEntry[];
14
14
  }>;
15
15
  export declare function contractCheckpoint(input: ContractCheckpoint): ContractCheckpoint;
16
+ export declare const verificationCleanupFailureSchema: z.ZodObject<{
17
+ phase: z.ZodLiteral<"destroy">;
18
+ name: z.ZodString;
19
+ detail: z.ZodUnion<readonly [z.ZodObject<{
20
+ kind: z.ZodLiteral<"exit">;
21
+ code: z.ZodNumber;
22
+ stdout: z.ZodString;
23
+ stderr: z.ZodString;
24
+ truncated: z.ZodBoolean;
25
+ }, z.core.$strict>, z.ZodObject<{
26
+ stdout: z.ZodOptional<z.ZodString>;
27
+ stderr: z.ZodOptional<z.ZodString>;
28
+ truncated: z.ZodOptional<z.ZodBoolean>;
29
+ kind: z.ZodLiteral<"timeout">;
30
+ }, z.core.$strict>, z.ZodObject<{
31
+ stdout: z.ZodOptional<z.ZodString>;
32
+ stderr: z.ZodOptional<z.ZodString>;
33
+ truncated: z.ZodOptional<z.ZodBoolean>;
34
+ kind: z.ZodLiteral<"unknown-exit">;
35
+ }, z.core.$strict>, z.ZodObject<{
36
+ kind: z.ZodLiteral<"spawn-error">;
37
+ diagnostic: z.ZodString;
38
+ }, z.core.$strict>]>;
39
+ }, z.core.$strict>;
40
+ export type VerificationCleanupFailure = z.infer<typeof verificationCleanupFailureSchema>;
16
41
  export declare const executionCleanupSchema: z.ZodUnion<readonly [z.ZodObject<{
17
42
  kind: z.ZodLiteral<"decode-channel-retirement">;
18
43
  contractId: z.ZodPipe<z.ZodString, z.ZodTransform<ContractId, string>>;
@@ -21,6 +46,8 @@ export declare const executionCleanupSchema: z.ZodUnion<readonly [z.ZodObject<{
21
46
  kind: z.ZodLiteral<"verification-cleanup">;
22
47
  contractId: z.ZodPipe<z.ZodString, z.ZodTransform<ContractId, string>>;
23
48
  snapshot: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<SnapshotId, string>>>;
49
+ requirement: z.ZodOptional<z.ZodString>;
50
+ index: z.ZodOptional<z.ZodNumber>;
24
51
  failure: z.ZodObject<{
25
52
  phase: z.ZodLiteral<"destroy">;
26
53
  name: z.ZodString;
@@ -49,6 +76,8 @@ export declare const executionCleanupSchema: z.ZodUnion<readonly [z.ZodObject<{
49
76
  kind: z.ZodLiteral<"worktree-leak">;
50
77
  contractId: z.ZodPipe<z.ZodString, z.ZodTransform<ContractId, string>>;
51
78
  snapshot: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<SnapshotId, string>>>;
79
+ requirement: z.ZodOptional<z.ZodString>;
80
+ index: z.ZodOptional<z.ZodNumber>;
52
81
  leak: z.ZodObject<{
53
82
  path: z.ZodOptional<z.ZodString>;
54
83
  diagnostic: z.ZodString;
@@ -116,7 +145,11 @@ export interface ProtocolProgress {
116
145
  recordPhysical(contractId: ContractId, report: ReconcileResult): void;
117
146
  /** Physical follow owned by this invocation's target movement, distinct from retained topology. */
118
147
  recordPlacementPhysical(contractId: ContractId, report: ReconcileResult): void;
119
- recordVerification(contractId: ContractId, snapshot: SnapshotId | undefined, result: VerificationResidue): void;
148
+ recordVerification(contractId: ContractId, snapshot: SnapshotId | undefined, result: VerificationResidue, coordinate?: Readonly<{
149
+ requirement: string;
150
+ index: number;
151
+ }>): void;
152
+ recordVerificationCheck(contractId: ContractId, check: VerificationCheck): void;
120
153
  recordStop(stop: ExecutionStop): void;
121
154
  recordDeliveryPreview(contractId: ContractId, report: Partial<import("./delivery-preview.js").DeliveryPreviewReport>): void;
122
155
  /** Current candidate conclusions, retained before the next await can fail. */
@@ -2,7 +2,7 @@ import { contractIdSchema, snapshotIdSchema } from "../git/identity.js";
2
2
  import { z } from "zod";
3
3
  import { worktreeLeakSchema } from "../git/scratch.js";
4
4
  import { privateStateSeatCloseLagSchema } from "../git/private-state-seat.js";
5
- import { verificationCleanupFailureSchema } from "./intent.js";
5
+ import { hookFailureSchema } from "../git/hooks.js";
6
6
  import { AuthorityCorruptionError } from "../core/facts/errors.js";
7
7
  import { GitPlumbingError } from "../git/process.js";
8
8
  import { SqliteTransactionLockError } from "../coordination/sqlite-transaction-lock.js";
@@ -10,6 +10,13 @@ import { GitPrivateStateSeatContentionError } from "../git/private-state-seat.js
10
10
  export function contractCheckpoint(input) {
11
11
  return { state: input.state, journal: input.journal };
12
12
  }
13
+ export const verificationCleanupFailureSchema = z
14
+ .object({
15
+ phase: z.literal("destroy"),
16
+ name: z.string().refine((value) => value.trim() !== ""),
17
+ detail: hookFailureSchema,
18
+ })
19
+ .strict();
13
20
  export const executionCleanupSchema = z.union([
14
21
  z
15
22
  .object({
@@ -23,6 +30,8 @@ export const executionCleanupSchema = z.union([
23
30
  kind: z.literal("verification-cleanup"),
24
31
  contractId: contractIdSchema,
25
32
  snapshot: snapshotIdSchema.optional(),
33
+ requirement: z.string().min(1).optional(),
34
+ index: z.number().int().positive().optional(),
26
35
  failure: verificationCleanupFailureSchema,
27
36
  })
28
37
  .strict(),
@@ -31,6 +40,8 @@ export const executionCleanupSchema = z.union([
31
40
  kind: z.literal("worktree-leak"),
32
41
  contractId: contractIdSchema,
33
42
  snapshot: snapshotIdSchema.optional(),
43
+ requirement: z.string().min(1).optional(),
44
+ index: z.number().int().positive().optional(),
34
45
  leak: worktreeLeakSchema,
35
46
  })
36
47
  .strict(),
@@ -1,3 +1,5 @@
1
+ import { targetName } from "../../core/facts/types.js";
2
+ import { resolveContractTarget } from "../../git/target.js";
1
3
  import { registeredWorktrees } from "../../git/repository.js";
2
4
  import { observeTargetCheckoutShape } from "../../git/target-placement.js";
3
5
  /** Selected-only pure projection of retained target checkout state. */
@@ -8,9 +10,18 @@ export async function observeCurrentPhysicalIssue(repository, row) {
8
10
  return undefined;
9
11
  if (row.targetObservation?.head !== delivery.integration.snapshot)
10
12
  return undefined;
11
- const worktrees = (await registeredWorktrees(repository))
12
- .filter((worktree) => worktree.branch === target)
13
- .sort((left, right) => left.path.localeCompare(right.path));
13
+ let worktrees;
14
+ if (typeof target === "string") {
15
+ worktrees = (await registeredWorktrees(repository))
16
+ .filter((worktree) => worktree.branch === target)
17
+ .sort((left, right) => left.path.localeCompare(right.path));
18
+ }
19
+ else {
20
+ const resolved = await resolveContractTarget(repository, target.contractId, target);
21
+ if (resolved.kind === "refused")
22
+ return { kind: "target-checkout-retained", target: targetName(target) };
23
+ worktrees = [{ path: resolved.path }];
24
+ }
14
25
  for (const worktree of worktrees) {
15
26
  const shape = await observeTargetCheckoutShape(repository, {
16
27
  path: worktree.path,
@@ -18,7 +29,7 @@ export async function observeCurrentPhysicalIssue(repository, row) {
18
29
  candidate: delivery.integration.snapshot,
19
30
  });
20
31
  if (shape === "retained")
21
- return { kind: "target-checkout-retained", target };
32
+ return { kind: "target-checkout-retained", target: targetName(target) };
22
33
  }
23
34
  return undefined;
24
35
  }
@@ -2,24 +2,20 @@ import type { ContractTargetLag as GitContractTargetLag, ContractWorkspaceObserv
2
2
  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
- import { type ContractId, type ContractState, type DeliverData, type JournalEntry, type SnapshotId } from "../../core/facts/types.js";
5
+ import { type ContractId, type ContractState, type ContractTarget, type DeliverData, type JournalEntry, type SnapshotId } from "../../core/facts/types.js";
6
6
  import { type BoundedList } from "../../bounded-list.js";
7
7
  export type ContractPhase = "bound" | "claimed" | "abandoned";
8
8
  export type ContractDisposition = "active" | "terminal";
9
9
  export type ContractGateCurrent = GateCurrent;
10
10
  export type ContractGateReport = Readonly<{
11
11
  gate: string;
12
- current: ContractGateCurrent;
13
- }>;
14
- export type ContractVerificationStatus = Readonly<{
15
- kind: "undeclared";
16
- }> | Readonly<{
17
- kind: "unrecorded";
18
- }> | Readonly<{
19
- kind: "recorded";
20
- verdict: "satisfied" | "unsatisfied";
21
- at: string;
22
- snapshot?: SnapshotId;
12
+ current: GateCurrent;
13
+ satisfied: boolean;
14
+ requirements: readonly Readonly<{
15
+ requirement: string;
16
+ current: GateCurrent;
17
+ index?: number;
18
+ }>[];
23
19
  }>;
24
20
  export type ContractTargetLag = GitContractTargetLag | Readonly<{
25
21
  kind: "counted";
@@ -64,7 +60,7 @@ export type ContractRow = Readonly<{
64
60
  workspace: "worktree";
65
61
  worktreePath: string | null;
66
62
  workspaceObservation: ContractWorkspaceObservation;
67
- target: string | null;
63
+ target: ContractTarget | null;
68
64
  targetLag: ContractTargetLag;
69
65
  delivery: DeliverData | null;
70
66
  abandonNote?: string;
@@ -72,7 +68,6 @@ export type ContractRow = Readonly<{
72
68
  head: SnapshotId | null;
73
69
  drift: boolean;
74
70
  }> | null;
75
- verification?: ContractVerificationStatus;
76
71
  gates: Readonly<{
77
72
  reports: readonly ContractGateReport[];
78
73
  satisfied: boolean;
@@ -1,10 +1,9 @@
1
1
  import { observeActiveContractWorld, observeContractsForAdmissionInObservationAt, observeDeliveryTargetAt, withContractReadObservationAt, } from "../../git/observe.js";
2
2
  import { decodeContractDocument } from "../../body/decode.js";
3
- import { dependencyKeys } from "../../core/subject.js";
4
3
  import { observeTargetLag, observeWorkspace, readConflictHandoffs, conflictRecovery, worktreePath, } from "../../git/workspace.js";
5
4
  import { appointmentFor, readPlaceRegister } from "../../workspace-place.js";
6
- import { gateReports, latestCurrentAttestations } from "../../core/facts/gate.js";
7
- import { gate, } from "../../core/facts/types.js";
5
+ import { gateReports } from "../../core/facts/gate.js";
6
+ import { verificationRequirement } from "../../verification/declaration.js";
8
7
  import { projectBoundedList } from "../../bounded-list.js";
9
8
  function documentFor(state) {
10
9
  try {
@@ -26,22 +25,6 @@ function phaseFor(state) {
26
25
  return "abandoned";
27
26
  return "bound";
28
27
  }
29
- function verificationFor(state) {
30
- const verifiedGate = gate("verified");
31
- if (!state.terms.gates.includes(verifiedGate))
32
- return { kind: "undeclared" };
33
- const current = latestCurrentAttestations(state, new Set([verifiedGate])).get(verifiedGate);
34
- if (current !== undefined) {
35
- const snapshot = dependencyKeys(current.data.subject).find((key) => key.kind === "snapshot")?.value;
36
- return {
37
- kind: "recorded",
38
- verdict: current.data.verdict,
39
- at: current.at,
40
- ...(snapshot === undefined ? {} : { snapshot: snapshot }),
41
- };
42
- }
43
- return state.delivery === null ? undefined : { kind: "unrecorded" };
44
- }
45
28
  export function phaseAtFor(state, bindAt) {
46
29
  return state.terminal?.at ?? state.delivery?.at ?? bindAt;
47
30
  }
@@ -108,7 +91,12 @@ async function rowFor(input) {
108
91
  const { repository, state, bindAt, lastJournalAt, targetObservation, workspace, handoff, after, dependents } = input;
109
92
  const gates = gateReports(state);
110
93
  const document = documentFor(state);
111
- const verification = verificationFor(state);
94
+ const indexes = new Map();
95
+ document?.verification.forEach((declaration, index) => {
96
+ const requirement = verificationRequirement(declaration);
97
+ if (!indexes.has(requirement))
98
+ indexes.set(requirement, index + 1);
99
+ });
112
100
  const facts = await managedWorkspaceFacts(repository, state, workspace, targetObservation, handoff);
113
101
  return {
114
102
  id: state.id,
@@ -129,9 +117,14 @@ async function rowFor(input) {
129
117
  ? { abandonNote: state.terminal.data.note }
130
118
  : {}),
131
119
  targetObservation,
132
- ...(verification === undefined ? {} : { verification }),
133
120
  gates: {
134
- reports: gates.reports.map((report) => ({ gate: report.gate, current: report.current })),
121
+ reports: gates.reports.map((report) => ({
122
+ ...report,
123
+ requirements: report.requirements.map((requirement) => {
124
+ const index = report.gate === "verified" ? indexes.get(requirement.requirement) : undefined;
125
+ return { ...requirement, ...(index === undefined ? {} : { index }) };
126
+ }),
127
+ })),
135
128
  satisfied: gates.satisfied,
136
129
  },
137
130
  after,
@@ -1,5 +1,6 @@
1
1
  import type { ProtocolProgress } from "./progress.js";
2
- import type { ActorId, ContractId, ReintegratedData } from "../core/facts/types.js";
2
+ import { type ActorId, type ContractId, type ContractTarget, type ReintegratedData } from "../core/facts/types.js";
3
+ import { type TargetWorkspaceRefusal } from "../git/target.js";
3
4
  import { type ReintegrateRefusal } from "../core/verbs/reintegrate.js";
4
5
  import { type IntegrationPreparationRefusal } from "../git/integration.js";
5
6
  import type { GitRepository } from "../git/process.js";
@@ -11,7 +12,7 @@ type TargetMissing = Readonly<{
11
12
  kind: "target-missing";
12
13
  contractId: ContractId;
13
14
  }>;
14
- type ReintegrationRefusal = ReintegrateRefusal | TargetMissing | IntegrationPreparationRefusal;
15
+ type ReintegrationRefusal = ReintegrateRefusal | TargetMissing | IntegrationPreparationRefusal | TargetWorkspaceRefusal;
15
16
  export type ReintegrationResult = (AcceptedAdmission & Readonly<{
16
17
  value: ReintegratedData;
17
18
  }>) | Readonly<{
@@ -25,7 +26,7 @@ type ReintegrationInput = Readonly<{
25
26
  channel: GitDecodeChannel;
26
27
  repository: GitRepository;
27
28
  contractId: ContractId;
28
- target: string;
29
+ target: ContractTarget;
29
30
  actor?: ActorId;
30
31
  progress?: ProtocolProgress;
31
32
  }>;
@@ -1,15 +1,18 @@
1
- import { contractState } from "../core/facts/observation.js";
1
+ import { contractState, targetContractRefusal } from "../core/facts/observation.js";
2
+ import { targetName, } from "../core/facts/types.js";
3
+ import { resolveContractTarget, targetRef } from "../git/target.js";
2
4
  import { decideReintegrate } from "../core/verbs/reintegrate.js";
3
5
  import { materializeReintegrationSnapshot, persistedTender, planIntegration, reusableIntegrationSnapshot, } from "../git/integration.js";
4
6
  import { observeContractsForAdmissionAt } from "../git/observe.js";
5
7
  import { withPrivateStatePublicationSeat } from "../git/private-state-seat.js";
6
8
  import { admitDecidedOffer, mintAttempts } from "./attempt.js";
7
- import { recordedIntegrationSnapshots, timestamp } from "./operations.js";
9
+ import { timestamp } from "./operations.js";
10
+ import { deliveryIntegrationSnapshots } from "./deliver.js";
8
11
  import { externalPreparation, protocolSeatClose, STALE_PRIVATE_STATE_PREPARATION, } from "./run.js";
9
12
  import { runUnderTargetPlacementFence } from "./placement.js";
10
13
  /** Plan and materialize the target-specific reintegration artifacts outside the publication seat. */
11
14
  async function prepareExternalReintegration(input) {
12
- return await externalPreparation({ ...input, scope: input.repository }, (observation, state) => planReintegrationArtifacts(input, state, recordedIntegrationSnapshots(observation.journals.get(state.id)?.entries ?? [])));
15
+ return await externalPreparation({ ...input, scope: input.repository }, (observation, state) => planReintegrationArtifacts(input, state, deliveryIntegrationSnapshots(observation.journals.get(state.id)?.entries ?? [])));
13
16
  }
14
17
  async function planReintegrationArtifacts(input, state, recordedIntegrations) {
15
18
  if (state.delivery === null || state.currentIntegration === null)
@@ -22,7 +25,7 @@ async function planReintegrationArtifacts(input, state, recordedIntegrations) {
22
25
  return {
23
26
  kind: "prepared",
24
27
  data: { predecessor: planned.data.predecessor, snapshot },
25
- assertion: { ref: input.target, oid: planned.data.predecessor },
28
+ assertion: { ref: targetRef(input.target), oid: planned.data.predecessor },
26
29
  };
27
30
  }
28
31
  /** Assemble the decision input from the fresh Contract; spent artifacts restart the whole cycle. */
@@ -52,6 +55,19 @@ async function runReintegration(input) {
52
55
  const assembled = assembleReintegrationAttempt(input, observation, external);
53
56
  if (assembled.kind === "stale")
54
57
  return assembled;
58
+ const state = contractState(observation.decision, input.contractId);
59
+ if (state !== null) {
60
+ const refusal = targetContractRefusal(observation.decision, state.id, state.coordinates.target);
61
+ if (refusal !== undefined)
62
+ return { kind: "refused", refusal };
63
+ }
64
+ if (typeof input.target !== "string") {
65
+ const resolved = await resolveContractTarget(input.repository, input.target.contractId, input.target);
66
+ if (resolved.kind === "refused")
67
+ return resolved;
68
+ if (assembled.kind === "prepared" && resolved.head !== assembled.data.predecessor)
69
+ return STALE_PRIVATE_STATE_PREPARATION;
70
+ }
55
71
  const preparation = assembled.kind === "unavailable" ? { kind: "refused", refusal: assembled.refusal } : assembled;
56
72
  const decision = decideReintegrate({
57
73
  input: {
@@ -93,5 +109,5 @@ async function runReintegration(input) {
93
109
  return { kind: "retry", reason: { kind: "exhausted" } };
94
110
  }
95
111
  export async function reintegrateOperation(input) {
96
- return await runUnderTargetPlacementFence(input.repository, input.target, async () => await runReintegration(input));
112
+ return await runUnderTargetPlacementFence(input.repository, targetName(input.target), async () => await runReintegration(input));
97
113
  }
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import { dirtyTenderDelta } from "../git/tender.js";
2
2
  import { type ActiveContractRefusal } from "../core/facts/observation.js";
3
3
  import type { AttestationData } from "../core/facts/types.js";
4
4
  import type { LeadingOutcome } from "./outcome.js";
@@ -12,19 +12,13 @@ type ReviewOperationInput = MutationOperationInput & Readonly<{
12
12
  verdict: AttestationData["verdict"];
13
13
  summary?: string;
14
14
  }>;
15
- export declare const reviewAdmissionValueSchema: z.ZodObject<{
16
- workspace: z.ZodOptional<z.ZodObject<{
17
- staged: z.ZodReadonly<z.ZodArray<z.ZodString>>;
18
- unstaged: z.ZodReadonly<z.ZodArray<z.ZodString>>;
19
- untracked: z.ZodReadonly<z.ZodArray<z.ZodString>>;
20
- shortStat: z.ZodObject<{
21
- filesChanged: z.ZodNumber;
22
- insertions: z.ZodNumber;
23
- deletions: z.ZodNumber;
24
- }, z.core.$strict>;
25
- unmergedPaths: z.ZodReadonly<z.ZodArray<z.ZodString>>;
26
- }, z.core.$strict>>;
27
- }, z.core.$strict>;
28
- type ReviewAdmissionValue = z.infer<typeof reviewAdmissionValueSchema>;
15
+ type ReviewWorkspaceDelta = NonNullable<Awaited<ReturnType<typeof dirtyTenderDelta>>>;
16
+ type ReviewWorkspaceEvidence = Readonly<Omit<ReviewWorkspaceDelta, "shortStat"> & {
17
+ shortStat: Readonly<ReviewWorkspaceDelta["shortStat"]>;
18
+ unmergedPaths: readonly string[];
19
+ }>;
20
+ export type ReviewAdmissionValue = Readonly<{
21
+ workspace?: ReviewWorkspaceEvidence;
22
+ }>;
29
23
  export declare function admitReviewOperation(input: ReviewOperationInput): Promise<LeadingOutcome<ReviewAdmissionValue, ReviewRefusal>>;
30
24
  export {};
@@ -1,5 +1,3 @@
1
- import { z } from "zod";
2
- import { workspaceDirtyDeltaSchema } from "../git/tender.js";
3
1
  import { worktreeChangeId } from "../git/integration.js";
4
2
  import { captureTender, dirtyTenderDelta, dirtyTenderRefusal } from "../git/tender.js";
5
3
  import { observeContractsForAdmissionAt } from "../git/observe.js";
@@ -8,15 +6,12 @@ import { externalPreparation, privateStateSeatAttempt, protocolSeatClose, runBou
8
6
  import { dependencyKeySet } from "../core/subject.js";
9
7
  import { contractState } from "../core/facts/observation.js";
10
8
  import { gate } from "../core/facts/types.js";
9
+ import { singletonRequirement } from "../verification/declaration.js";
11
10
  import { decideAttestation } from "../core/verbs/attestation.js";
12
11
  import { admitDecidedOffer, mintAttempts } from "./attempt.js";
13
12
  import { appointmentFor, readPlaceRegister } from "../workspace-place.js";
14
13
  import { timestamp } from "./operations.js";
15
14
  const REVIEWED = gate("reviewed");
16
- const reviewWorkspaceEvidenceSchema = workspaceDirtyDeltaSchema
17
- .extend({ unmergedPaths: z.array(z.string().refine((value) => value.trim() !== "")).readonly() })
18
- .strict();
19
- export const reviewAdmissionValueSchema = z.object({ workspace: reviewWorkspaceEvidenceSchema.optional() }).strict();
20
15
  async function captureReviewableWorktree(repository, stage) {
21
16
  const appointed = stage.coordinates.workspace === "worktree"
22
17
  ? appointmentFor(await readPlaceRegister(repository), stage.contractId)
@@ -56,6 +51,7 @@ function preparedReviewCapture(input, state, changeId) {
56
51
  kind: "prepared",
57
52
  data: {
58
53
  gate: REVIEWED,
54
+ requirement: singletonRequirement(REVIEWED),
59
55
  subject: dependencyKeySet([
60
56
  { kind: "document", value: state.terms.document.key },
61
57
  { kind: "change", value: changeId },
@@ -15,8 +15,8 @@ export declare const STALE_PRIVATE_STATE_PREPARATION: {
15
15
  };
16
16
  export declare const protocolTerminalSchema: z.ZodUnion<readonly [z.ZodObject<{
17
17
  kind: z.ZodEnum<{
18
- exhausted: "exhausted";
19
18
  collision: "collision";
19
+ exhausted: "exhausted";
20
20
  }>;
21
21
  }, z.core.$strict>, z.ZodObject<{
22
22
  kind: z.ZodLiteral<"publication-failed">;