@astrosheep/keiyaku 4.6.4 → 4.6.6

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 (191) hide show
  1. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +43 -8
  2. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +7 -8
  3. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +3 -3
  4. package/build/src/akuma/akuma-observe.d.ts +18 -15
  5. package/build/src/akuma/akuma-observe.js +75 -16
  6. package/build/src/akuma/akuma-wait.d.ts +4 -3
  7. package/build/src/akuma/akuma-wait.js +75 -53
  8. package/build/src/akuma/akuma.d.ts +6 -4
  9. package/build/src/akuma/akuma.js +4 -0
  10. package/build/src/akuma/call-initial-tell.d.ts +2 -2
  11. package/build/src/akuma/call-initial-tell.js +1 -1
  12. package/build/src/akuma/call-request.d.ts +2 -2
  13. package/build/src/akuma/heart/index.d.ts +7 -2
  14. package/build/src/akuma/heart/index.js +50 -5
  15. package/build/src/akuma/heart/tells.d.ts +33 -2
  16. package/build/src/akuma/heart/tells.js +24 -18
  17. package/build/src/akuma/heart/timeline.d.ts +23 -1
  18. package/build/src/akuma/heart/timeline.js +28 -21
  19. package/build/src/akuma/projection.d.ts +10 -10
  20. package/build/src/akuma/providers/pi/index.js +72 -39
  21. package/build/src/akuma/selection-observation.d.ts +20 -20
  22. package/build/src/akuma-body.js +1 -0
  23. package/build/src/alias/index.d.ts +0 -1
  24. package/build/src/alias/index.js +0 -4
  25. package/build/src/body/amend.d.ts +0 -4
  26. package/build/src/body/amend.js +0 -3
  27. package/build/src/body/region.d.ts +0 -1
  28. package/build/src/body/region.js +0 -3
  29. package/build/src/body/verification.d.ts +0 -1
  30. package/build/src/cli/commands/akuma-grammar.js +23 -66
  31. package/build/src/cli/commands/akuma.js +17 -30
  32. package/build/src/cli/commands/contract-grammar.d.ts +14 -1
  33. package/build/src/cli/commands/contract-grammar.js +54 -21
  34. package/build/src/cli/commands/contract-help.d.ts +9 -8
  35. package/build/src/cli/commands/contract-help.js +14 -7
  36. package/build/src/cli/commands/contract.js +57 -117
  37. package/build/src/cli/commands/install.d.ts +5 -5
  38. package/build/src/cli/commands/install.js +1 -4
  39. package/build/src/cli/commands/task-grammar.js +10 -66
  40. package/build/src/cli/commands/task.d.ts +0 -1
  41. package/build/src/cli/commands/task.js +34 -53
  42. package/build/src/cli/coordinates.d.ts +1 -2
  43. package/build/src/cli/coordinates.js +1 -4
  44. package/build/src/cli/parse.d.ts +2 -3
  45. package/build/src/cli/parse.js +24 -66
  46. package/build/src/cli/render/akuma.d.ts +3 -16
  47. package/build/src/cli/render/akuma.js +1 -13
  48. package/build/src/cli/render/audit.js +1 -1
  49. package/build/src/cli/render/contract.js +34 -32
  50. package/build/src/cli/render/kanshi-akuma.d.ts +8 -2
  51. package/build/src/cli/render/kanshi-akuma.js +14 -7
  52. package/build/src/cli/render/kanshi.d.ts +3 -1
  53. package/build/src/cli/render/kanshi.js +44 -32
  54. package/build/src/cli/render/receipt.js +6 -1
  55. package/build/src/cli/render/task.d.ts +1 -1
  56. package/build/src/cli/render/task.js +3 -27
  57. package/build/src/cli/render/terminal.d.ts +6 -2
  58. package/build/src/cli/render/terminal.js +8 -2
  59. package/build/src/cli/runtime.js +3 -16
  60. package/build/src/cli/scan.d.ts +26 -0
  61. package/build/src/cli/scan.js +82 -0
  62. package/build/src/cli/streams.d.ts +5 -0
  63. package/build/src/cli/streams.js +11 -0
  64. package/build/src/contract-worktree.js +38 -21
  65. package/build/src/core/facts/codec.d.ts +1 -2
  66. package/build/src/core/facts/codec.js +5 -11
  67. package/build/src/core/facts/types.d.ts +16 -2
  68. package/build/src/core/facts/types.js +15 -0
  69. package/build/src/core/verbs/abandon.js +3 -9
  70. package/build/src/core/verbs/amend.js +2 -9
  71. package/build/src/core/verbs/arc.js +6 -13
  72. package/build/src/core/verbs/attestation.js +2 -9
  73. package/build/src/core/verbs/bind.js +2 -9
  74. package/build/src/core/verbs/deliver.js +2 -9
  75. package/build/src/core/verbs/placement.d.ts +1 -1
  76. package/build/src/core/verbs/placement.js +2 -9
  77. package/build/src/core/verbs/reintegrate.d.ts +1 -1
  78. package/build/src/core/verbs/reintegrate.js +2 -9
  79. package/build/src/dispatch/index.d.ts +2 -2
  80. package/build/src/dispatch/index.js +33 -11
  81. package/build/src/git/hooks.d.ts +2 -4
  82. package/build/src/git/hooks.js +0 -12
  83. package/build/src/git/integration.d.ts +5 -3
  84. package/build/src/git/integration.js +36 -25
  85. package/build/src/git/nuke.js +4 -4
  86. package/build/src/git/observe.d.ts +4 -4
  87. package/build/src/git/observe.js +5 -5
  88. package/build/src/git/process.d.ts +1 -4
  89. package/build/src/git/process.js +1 -11
  90. package/build/src/git/read-observation.js +1 -1
  91. package/build/src/git/reconcile.d.ts +1 -1
  92. package/build/src/git/reconcile.js +15 -13
  93. package/build/src/git/repository.d.ts +2 -6
  94. package/build/src/git/repository.js +18 -31
  95. package/build/src/git/scratch.d.ts +6 -6
  96. package/build/src/git/scratch.js +110 -46
  97. package/build/src/git/target-placement.d.ts +5 -5
  98. package/build/src/git/target-placement.js +18 -33
  99. package/build/src/git/tender.d.ts +6 -2
  100. package/build/src/git/tender.js +19 -12
  101. package/build/src/git/terminal-reconcile.js +24 -13
  102. package/build/src/git/terminal-seal.d.ts +2 -5
  103. package/build/src/git/terminal-seal.js +5 -3
  104. package/build/src/git/workspace.d.ts +17 -13
  105. package/build/src/git/workspace.js +58 -41
  106. package/build/src/kanshi/index.d.ts +2 -2
  107. package/build/src/kanshi/index.js +1 -1
  108. package/build/src/kanshi/read.d.ts +8 -1
  109. package/build/src/kanshi/read.js +72 -7
  110. package/build/src/kanshi/report.d.ts +12 -0
  111. package/build/src/library/akuma-creation.d.ts +4 -4
  112. package/build/src/library/bind.d.ts +1 -63
  113. package/build/src/library/bind.js +3 -9
  114. package/build/src/library/contract-creation.js +2 -30
  115. package/build/src/library/contract-execution.d.ts +0 -1
  116. package/build/src/library/contract-execution.js +9 -34
  117. package/build/src/library/contract-operations.d.ts +5 -1
  118. package/build/src/library/contract-operations.js +7 -3
  119. package/build/src/library/contract-types.d.ts +1 -1
  120. package/build/src/library/delivery.d.ts +91 -93
  121. package/build/src/library/delivery.js +2 -1
  122. package/build/src/library/input.d.ts +0 -2
  123. package/build/src/library/input.js +0 -4
  124. package/build/src/library/invocation.d.ts +0 -1
  125. package/build/src/library/invocation.js +3 -25
  126. package/build/src/library/outcome.d.ts +651 -602
  127. package/build/src/library/outcome.js +4 -4
  128. package/build/src/library/reconcile.d.ts +6 -0
  129. package/build/src/library/reconcile.js +31 -1
  130. package/build/src/library/repo.d.ts +0 -1
  131. package/build/src/library/selection.d.ts +1 -10
  132. package/build/src/library/selection.js +14 -15
  133. package/build/src/protocol/abandon.d.ts +1 -1
  134. package/build/src/protocol/abandon.js +3 -10
  135. package/build/src/protocol/amend.js +2 -5
  136. package/build/src/protocol/arc.d.ts +1 -1
  137. package/build/src/protocol/arc.js +2 -9
  138. package/build/src/protocol/attempt.d.ts +3 -20
  139. package/build/src/protocol/attempt.js +6 -5
  140. package/build/src/protocol/audit.d.ts +1 -0
  141. package/build/src/protocol/audit.js +10 -11
  142. package/build/src/protocol/completion.d.ts +129 -55
  143. package/build/src/protocol/completion.js +62 -73
  144. package/build/src/protocol/deliver.d.ts +7 -5
  145. package/build/src/protocol/deliver.js +74 -44
  146. package/build/src/protocol/execution-observation.d.ts +2 -4
  147. package/build/src/protocol/execution-observation.js +3 -7
  148. package/build/src/protocol/intent.d.ts +1 -1
  149. package/build/src/protocol/intent.js +1 -0
  150. package/build/src/protocol/operations.d.ts +24 -12
  151. package/build/src/protocol/operations.js +36 -15
  152. package/build/src/protocol/placement.d.ts +2 -1
  153. package/build/src/protocol/placement.js +21 -5
  154. package/build/src/protocol/progress.d.ts +1 -1
  155. package/build/src/protocol/read/status.js +58 -41
  156. package/build/src/protocol/reintegrate.d.ts +1 -1
  157. package/build/src/protocol/reintegrate.js +10 -19
  158. package/build/src/protocol/review.d.ts +3 -28
  159. package/build/src/protocol/review.js +10 -37
  160. package/build/src/protocol/run.d.ts +19 -7
  161. package/build/src/protocol/run.js +19 -9
  162. package/build/src/runtime/proc/windows-launch.exe +0 -0
  163. package/build/src/settlement/holder.d.ts +2 -4
  164. package/build/src/settlement/holder.js +3 -6
  165. package/build/src/task/board.d.ts +6 -0
  166. package/build/src/task/board.js +30 -1
  167. package/build/src/task/catalog.js +1 -4
  168. package/build/src/task/compose.d.ts +0 -1
  169. package/build/src/task/compose.js +0 -1
  170. package/build/src/task/context.d.ts +0 -1
  171. package/build/src/task/context.js +0 -3
  172. package/build/src/task/created-observation.d.ts +5 -1
  173. package/build/src/task/created-observation.js +12 -5
  174. package/build/src/task/index.d.ts +1 -1
  175. package/build/src/task/index.js +7 -6
  176. package/build/src/task/input.d.ts +0 -6
  177. package/build/src/task/input.js +2 -14
  178. package/build/src/task/mutation.d.ts +3 -4
  179. package/build/src/task/mutation.js +11 -39
  180. package/build/src/task/operations.d.ts +2 -7
  181. package/build/src/task/operations.js +37 -49
  182. package/build/src/task/query.d.ts +0 -1
  183. package/build/src/task/query.js +1 -4
  184. package/build/src/task/store.d.ts +0 -2
  185. package/build/src/task/store.js +27 -11
  186. package/build/src/verification/declaration.js +3 -2
  187. package/build/src/verification/execution.d.ts +3 -2
  188. package/build/src/verification/execution.js +10 -6
  189. package/build/src/workspace-place.d.ts +0 -1
  190. package/build/src/workspace-place.js +0 -11
  191. package/package.json +7 -3
@@ -4,49 +4,27 @@ import type { GitRepository } from "../git/process.js";
4
4
  import type { GitDecodeChannel } from "../git/read-observation.js";
5
5
  import { type ContractCheckpoint, type ProtocolProgress, type ExecutionStop } from "./progress.js";
6
6
  import type { DocumentDerivation, PlacementStop, VerificationStop } from "./operations.js";
7
- declare const candidateCompletionSchema: z.ZodObject<{
8
- integration: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
9
- predecessor: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>>;
10
- target: z.ZodOptional<z.ZodString>;
11
- scope: z.ZodOptional<z.ZodObject<{
12
- deletions: z.ZodNumber;
13
- filesChanged: z.ZodNumber;
14
- insertions: z.ZodNumber;
15
- }, z.core.$strict>>;
16
- verification: z.ZodOptional<z.ZodObject<{
17
- mode: z.ZodEnum<{
18
- reused: "reused";
19
- ran: "ran";
20
- }>;
21
- verdict: z.ZodEnum<{
22
- satisfied: "satisfied";
23
- unsatisfied: "unsatisfied";
24
- }>;
25
- }, z.core.$strict>>;
26
- }, z.core.$strict>;
27
- export type CandidateCompletion = z.infer<typeof candidateCompletionSchema>;
28
- export declare const completionEvidenceSchema: z.ZodObject<{
29
- completion: z.ZodOptional<z.ZodObject<{
30
- integration: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
31
- predecessor: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>>;
32
- target: z.ZodOptional<z.ZodString>;
33
- scope: z.ZodOptional<z.ZodObject<{
34
- deletions: z.ZodNumber;
35
- filesChanged: z.ZodNumber;
36
- insertions: z.ZodNumber;
37
- }, z.core.$strict>>;
38
- verification: z.ZodOptional<z.ZodObject<{
39
- mode: z.ZodEnum<{
40
- reused: "reused";
41
- ran: "ran";
42
- }>;
43
- verdict: z.ZodEnum<{
44
- satisfied: "satisfied";
45
- unsatisfied: "unsatisfied";
46
- }>;
47
- }, z.core.$strict>>;
48
- }, z.core.$strict>>;
49
- verification: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
7
+ declare const verificationEvidenceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
8
+ snapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
9
+ verdict: z.ZodEnum<{
10
+ satisfied: "satisfied";
11
+ unsatisfied: "unsatisfied";
12
+ }>;
13
+ summary: z.ZodOptional<z.ZodString>;
14
+ kind: z.ZodLiteral<"ran">;
15
+ entry: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<EntryUlid, string>>>;
16
+ }, z.core.$strict>, z.ZodObject<{
17
+ snapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
18
+ verdict: z.ZodEnum<{
19
+ satisfied: "satisfied";
20
+ unsatisfied: "unsatisfied";
21
+ }>;
22
+ entry: z.ZodPipe<z.ZodString, z.ZodTransform<EntryUlid, string>>;
23
+ summary: z.ZodOptional<z.ZodString>;
24
+ kind: z.ZodLiteral<"reused">;
25
+ }, z.core.$strict>, z.ZodObject<{
26
+ kind: z.ZodLiteral<"stopped">;
27
+ stop: z.ZodUnion<readonly [z.ZodObject<{
50
28
  refusal: z.ZodUnion<readonly [z.ZodObject<{
51
29
  kind: z.ZodEnum<{
52
30
  terminal: "terminal";
@@ -116,27 +94,123 @@ export declare const completionEvidenceSchema: z.ZodObject<{
116
94
  kind: z.ZodLiteral<"spawn-error">;
117
95
  diagnostic: z.ZodString;
118
96
  }, z.core.$strict>]>;
119
- }, z.core.$strict>]>]>>;
120
- verificationReuse: z.ZodOptional<z.ZodObject<{
121
- entry: z.ZodPipe<z.ZodString, z.ZodTransform<EntryUlid, string>>;
97
+ }, z.core.$strict>]>]>;
98
+ }, z.core.$strict>], "kind">;
99
+ export type VerificationEvidence = z.infer<typeof verificationEvidenceSchema>;
100
+ declare const candidateCompletionSchema: z.ZodObject<{
101
+ integration: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
102
+ predecessor: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>>;
103
+ target: z.ZodOptional<z.ZodString>;
104
+ scope: z.ZodOptional<z.ZodObject<{
105
+ deletions: z.ZodNumber;
106
+ filesChanged: z.ZodNumber;
107
+ insertions: z.ZodNumber;
108
+ }, z.core.$strict>>;
109
+ }, z.core.$strict>;
110
+ export type CandidateCompletion = z.infer<typeof candidateCompletionSchema>;
111
+ export declare const completionEvidenceSchema: z.ZodObject<{
112
+ completion: z.ZodOptional<z.ZodObject<{
113
+ integration: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
114
+ predecessor: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>>;
115
+ target: z.ZodOptional<z.ZodString>;
116
+ scope: z.ZodOptional<z.ZodObject<{
117
+ deletions: z.ZodNumber;
118
+ filesChanged: z.ZodNumber;
119
+ insertions: z.ZodNumber;
120
+ }, z.core.$strict>>;
121
+ }, z.core.$strict>>;
122
+ verification: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
123
+ snapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
122
124
  verdict: z.ZodEnum<{
123
125
  satisfied: "satisfied";
124
126
  unsatisfied: "unsatisfied";
125
127
  }>;
126
128
  summary: z.ZodOptional<z.ZodString>;
127
- }, z.core.$strict>>;
128
- verificationSubject: z.ZodOptional<z.ZodObject<{
129
- mode: z.ZodEnum<{
130
- reused: "reused";
131
- ran: "ran";
132
- }>;
129
+ kind: z.ZodLiteral<"ran">;
130
+ entry: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<EntryUlid, string>>>;
131
+ }, z.core.$strict>, z.ZodObject<{
132
+ snapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
133
133
  verdict: z.ZodEnum<{
134
134
  satisfied: "satisfied";
135
135
  unsatisfied: "unsatisfied";
136
136
  }>;
137
- snapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
138
- }, z.core.$strict>>;
139
- verificationSummary: z.ZodOptional<z.ZodString>;
137
+ entry: z.ZodPipe<z.ZodString, z.ZodTransform<EntryUlid, string>>;
138
+ summary: z.ZodOptional<z.ZodString>;
139
+ kind: z.ZodLiteral<"reused">;
140
+ }, z.core.$strict>, z.ZodObject<{
141
+ kind: z.ZodLiteral<"stopped">;
142
+ stop: z.ZodUnion<readonly [z.ZodObject<{
143
+ refusal: z.ZodUnion<readonly [z.ZodObject<{
144
+ kind: z.ZodEnum<{
145
+ terminal: "terminal";
146
+ "contract-missing": "contract-missing";
147
+ }>;
148
+ contractId: z.ZodPipe<z.ZodString, z.ZodTransform<ContractId, string>>;
149
+ }, z.core.$strict>, z.ZodObject<{
150
+ kind: z.ZodLiteral<"verification-declaration-invalid">;
151
+ contractId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<ContractId, string>>>;
152
+ }, z.core.$strict>]>;
153
+ }, z.core.$strict>, z.ZodObject<{
154
+ retry: z.ZodUnion<readonly [z.ZodObject<{
155
+ kind: z.ZodEnum<{
156
+ exhausted: "exhausted";
157
+ collision: "collision";
158
+ }>;
159
+ }, z.core.$strict>, z.ZodObject<{
160
+ kind: z.ZodLiteral<"publication-failed">;
161
+ diagnostic: z.ZodString;
162
+ }, z.core.$strict>]>;
163
+ }, z.core.$strict>, z.ZodUnion<readonly [z.ZodObject<{
164
+ stdout: z.ZodOptional<z.ZodString>;
165
+ stderr: z.ZodOptional<z.ZodString>;
166
+ truncated: z.ZodOptional<z.ZodLiteral<true>>;
167
+ failure: z.ZodEnum<{
168
+ cancelled: "cancelled";
169
+ "unknown-exit": "unknown-exit";
170
+ }>;
171
+ }, z.core.$strict>, z.ZodObject<{
172
+ stdout: z.ZodOptional<z.ZodString>;
173
+ stderr: z.ZodOptional<z.ZodString>;
174
+ truncated: z.ZodOptional<z.ZodLiteral<true>>;
175
+ failure: z.ZodEnum<{
176
+ "spawn-error": "spawn-error";
177
+ "candidate-unavailable": "candidate-unavailable";
178
+ }>;
179
+ diagnostic: z.ZodString;
180
+ }, z.core.$strict>, z.ZodObject<{
181
+ stdout: z.ZodOptional<z.ZodString>;
182
+ stderr: z.ZodOptional<z.ZodString>;
183
+ truncated: z.ZodOptional<z.ZodLiteral<true>>;
184
+ failure: z.ZodLiteral<"environment-failure">;
185
+ diagnostic: z.ZodString;
186
+ }, z.core.$strict>, z.ZodObject<{
187
+ stdout: z.ZodOptional<z.ZodString>;
188
+ stderr: z.ZodOptional<z.ZodString>;
189
+ truncated: z.ZodOptional<z.ZodLiteral<true>>;
190
+ failure: z.ZodLiteral<"environment-failure">;
191
+ name: z.ZodString;
192
+ detail: z.ZodUnion<readonly [z.ZodObject<{
193
+ kind: z.ZodLiteral<"exit">;
194
+ code: z.ZodNumber;
195
+ stdout: z.ZodString;
196
+ stderr: z.ZodString;
197
+ truncated: z.ZodBoolean;
198
+ }, z.core.$strict>, z.ZodObject<{
199
+ stdout: z.ZodOptional<z.ZodString>;
200
+ stderr: z.ZodOptional<z.ZodString>;
201
+ truncated: z.ZodOptional<z.ZodBoolean>;
202
+ kind: z.ZodLiteral<"timeout">;
203
+ }, z.core.$strict>, z.ZodObject<{
204
+ stdout: z.ZodOptional<z.ZodString>;
205
+ stderr: z.ZodOptional<z.ZodString>;
206
+ truncated: z.ZodOptional<z.ZodBoolean>;
207
+ kind: z.ZodLiteral<"unknown-exit">;
208
+ }, z.core.$strict>, z.ZodObject<{
209
+ kind: z.ZodLiteral<"spawn-error">;
210
+ diagnostic: z.ZodString;
211
+ }, z.core.$strict>]>;
212
+ }, z.core.$strict>]>]>;
213
+ }, z.core.$strict>], "kind">>;
140
214
  placement: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
141
215
  refusal: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
142
216
  kind: z.ZodEnum<{
@@ -1,15 +1,23 @@
1
1
  import { z } from "zod";
2
- import { snapshotIdSchema, verdictSchema, verificationStopSchema, placementStopSchema } from "./operations.js";
3
- import { verificationReuseSchema } from "./intent.js";
2
+ import { snapshotIdSchema, verdictSchema, verificationStopSchema, placementStopSchema, entryUlidSchema, } from "./operations.js";
4
3
  import { deliveryDiffScopeSchema, readDeliveryScope } from "../git/integration.js";
5
4
  import { currentVerifiedAttestation, verifyDelivery } from "./intent.js";
6
- import { admitPlacement, observeTargetPlacement } from "./placement.js";
5
+ import { admitPlacement, observeTargetPlacement, observeIntegrationTargetMovement } from "./placement.js";
7
6
  import { reintegrateOperation } from "./reintegrate.js";
8
7
  import { contractCheckpoint, executionStop, isOperationalFailure, isOperationalStop, } from "./progress.js";
9
8
  import { placementStop, timestamp, unpackVerificationOutcome } from "./operations.js";
10
- import { VERIFIED } from "../verification/declaration.js";
11
9
  const MAX_REINTEGRATION_CYCLES = 3;
12
- const verdictProvenanceSchema = z.object({ mode: z.enum(["ran", "reused"]), verdict: verdictSchema }).strict();
10
+ const verificationVerdictSchema = z.object({
11
+ snapshot: snapshotIdSchema,
12
+ verdict: verdictSchema,
13
+ entry: entryUlidSchema,
14
+ summary: z.string().optional(),
15
+ });
16
+ const verificationEvidenceSchema = z.discriminatedUnion("kind", [
17
+ verificationVerdictSchema.extend({ kind: z.literal("ran"), entry: entryUlidSchema.optional() }).strict(),
18
+ verificationVerdictSchema.extend({ kind: z.literal("reused") }).strict(),
19
+ z.object({ kind: z.literal("stopped"), stop: verificationStopSchema }).strict(),
20
+ ]);
13
21
  const candidateCompletionSchema = z
14
22
  .object({
15
23
  integration: snapshotIdSchema,
@@ -19,20 +27,12 @@ const candidateCompletionSchema = z
19
27
  .refine((value) => value.trim() !== "")
20
28
  .optional(),
21
29
  scope: deliveryDiffScopeSchema.omit({ paths: true }).optional(),
22
- verification: verdictProvenanceSchema.optional(),
23
30
  })
24
31
  .strict();
25
- const verificationSubjectSchema = verdictProvenanceSchema.extend({ snapshot: snapshotIdSchema }).strict();
26
32
  export const completionEvidenceSchema = z
27
33
  .object({
28
34
  completion: candidateCompletionSchema.optional(),
29
- verification: verificationStopSchema.optional(),
30
- verificationReuse: verificationReuseSchema.optional(),
31
- verificationSubject: verificationSubjectSchema.optional(),
32
- verificationSummary: z
33
- .string()
34
- .refine((value) => value.trim() !== "")
35
- .optional(),
35
+ verification: verificationEvidenceSchema.optional(),
36
36
  placement: placementStopSchema.optional(),
37
37
  })
38
38
  .strict();
@@ -53,18 +53,19 @@ async function verifyCurrentCandidate(input, cursor) {
53
53
  cursor.evidence = {};
54
54
  cursor.ran = undefined;
55
55
  input.progress.recordCandidate(state.id, cursor.evidence);
56
- const current = currentVerifiedAttestation(state);
57
- if (current !== undefined) {
58
- cursor.evidence = {
59
- verificationReuse: current,
60
- verificationSubject: { snapshot, mode: "reused", verdict: current.verdict },
61
- };
56
+ const declaration = input.deriveDocument(state).verification;
57
+ if (declaration.kind === "refused") {
58
+ cursor.evidence = { verification: { kind: "stopped", stop: { refusal: declaration.refusal } } };
62
59
  input.progress.recordCandidate(state.id, cursor.evidence);
63
60
  return;
64
61
  }
65
- const declaration = input.deriveDocument(state).verification;
66
- if (declaration.kind === "refused") {
67
- cursor.evidence = { verification: { refusal: declaration.refusal } };
62
+ if (declaration.data === null)
63
+ return;
64
+ const current = currentVerifiedAttestation(state);
65
+ if (current?.verdict === "satisfied") {
66
+ cursor.evidence = {
67
+ verification: { kind: "reused", snapshot, ...current },
68
+ };
68
69
  input.progress.recordCandidate(state.id, cursor.evidence);
69
70
  return;
70
71
  }
@@ -78,7 +79,7 @@ async function verifyCurrentCandidate(input, cursor) {
78
79
  snapshot,
79
80
  ...(input.signal === undefined ? {} : { signal: input.signal }),
80
81
  progress: input.progress,
81
- ...(declaration.data === null ? {} : { verification: declaration.data }),
82
+ verification: declaration.data,
82
83
  });
83
84
  if (result === null)
84
85
  return;
@@ -88,19 +89,22 @@ async function verifyCurrentCandidate(input, cursor) {
88
89
  input.progress.recordResidue(state.id, verified.admission);
89
90
  cursor.ran = verified.admission.facts.find((fact) => fact.kind === "attestation" && fact.data.gate === "verified")?.entry;
90
91
  }
91
- const subject = verified.reuse !== undefined
92
- ? { snapshot, mode: "reused", verdict: verified.reuse.verdict }
93
- : verified.counts === undefined
94
- ? undefined
95
- : { snapshot, mode: "ran", verdict: verified.counts.verdict };
96
- cursor.evidence = {
97
- ...(verified.reuse === undefined ? {} : { verificationReuse: verified.reuse }),
98
- ...(subject === undefined ? {} : { verificationSubject: subject }),
99
- ...(verified.stop === undefined ? {} : { verification: verified.stop }),
100
- ...(verified.counts?.verdict !== "unsatisfied" || verified.counts.summary === undefined
101
- ? {}
102
- : { verificationSummary: verified.counts.summary }),
103
- };
92
+ if (verified.reuse !== undefined)
93
+ cursor.ran = verified.reuse.entry;
94
+ const verification = verified.stop !== undefined
95
+ ? { kind: "stopped", stop: verified.stop }
96
+ : verified.reuse !== undefined
97
+ ? { kind: "reused", snapshot, ...verified.reuse }
98
+ : verified.counts === undefined
99
+ ? undefined
100
+ : {
101
+ kind: "ran",
102
+ snapshot,
103
+ verdict: verified.counts.verdict,
104
+ ...(cursor.ran === undefined ? {} : { entry: cursor.ran }),
105
+ ...(verified.counts.verdict === "unsatisfied" ? { summary: verified.counts.summary } : {}),
106
+ };
107
+ cursor.evidence = verification === undefined ? {} : { verification };
104
108
  input.progress.recordCandidate(state.id, cursor.evidence);
105
109
  }
106
110
  async function observeCandidateTarget(input, cursor) {
@@ -139,39 +143,27 @@ async function completedResult(input, cursor) {
139
143
  ...(predecessor === undefined || target === undefined ? {} : { predecessor, target }),
140
144
  };
141
145
  input.progress.recordCompletion(state.id, cursor.completion);
142
- // Never attach a superseded run's verdict to the final integration.
143
- const current = currentVerifiedAttestation(state);
146
+ const declaration = input.deriveDocument(state).verification;
147
+ const current = declaration.data == null ? undefined : currentVerifiedAttestation(state);
144
148
  const verification = current === undefined
145
149
  ? undefined
146
- : {
147
- mode: cursor.ran === current.entry ? "ran" : "reused",
148
- verdict: current.verdict,
149
- };
150
- cursor.completion = { ...cursor.completion, ...(verification === undefined ? {} : { verification }) };
151
- input.progress.recordCompletion(state.id, cursor.completion);
150
+ : { kind: cursor.ran === current.entry ? "ran" : "reused", snapshot: integration, ...current };
151
+ cursor.evidence = verification === undefined ? {} : { verification };
152
+ input.progress.recordCandidate(state.id, { ...cursor.evidence, completion: cursor.completion });
152
153
  const scope = predecessor === undefined ? undefined : await readDeliveryScope(input.repository, predecessor, integration, false);
153
- const { verificationSummary: _oldSummary, verificationReuse: _oldReuse, verificationSubject: _oldSubject, ...evidence } = cursor.evidence;
154
154
  const completion = {
155
155
  integration,
156
156
  ...(predecessor === undefined || target === undefined ? {} : { predecessor, target }),
157
157
  ...(scope === undefined
158
158
  ? {}
159
159
  : { scope: { filesChanged: scope.filesChanged, insertions: scope.insertions, deletions: scope.deletions } }),
160
- ...(verification === undefined ? {} : { verification }),
161
160
  };
162
161
  cursor.completion = completion;
163
162
  input.progress.recordCompletion(state.id, completion);
164
163
  return {
165
164
  kind: "completed",
166
165
  checkpoint: cursor.checkpoint,
167
- evidence: {
168
- ...evidence,
169
- completion,
170
- ...(current === undefined || verification?.mode !== "reused" ? {} : { verificationReuse: current }),
171
- ...(current?.verdict !== "unsatisfied" || current.summary === undefined
172
- ? {}
173
- : { verificationSummary: current.summary }),
174
- },
166
+ evidence: { ...cursor.evidence, completion },
175
167
  };
176
168
  }
177
169
  function stoppedResult(cursor, stop) {
@@ -226,34 +218,34 @@ async function placeCurrentCandidate(input, cursor) {
226
218
  }
227
219
  return result;
228
220
  }
229
- /** Verification blocks completion only when the Contract selected the verified gate; placement owns gate eligibility. */
230
- function verificationBlocks(state) {
231
- return state.terms.gates.includes(VERIFIED);
232
- }
233
221
  async function verifyCandidateReadiness(input, cursor) {
234
222
  const observedPlacement = await observeCandidateTarget(input, cursor);
235
223
  await verifyCurrentCandidate(input, cursor);
236
- const verification = cursor.evidence.verification;
237
- const blocking = verification !== undefined && verificationBlocks(cursor.checkpoint.state);
238
- if (blocking || observedPlacement !== undefined) {
224
+ const stop = cursor.evidence.verification?.kind === "stopped" ? cursor.evidence.verification.stop : observedPlacement;
225
+ if (stop !== undefined) {
239
226
  return {
240
227
  kind: "stopped",
241
228
  checkpoint: cursor.checkpoint,
242
229
  evidence: { ...cursor.evidence, ...(observedPlacement === undefined ? {} : { placement: observedPlacement }) },
243
- stop: blocking ? verification : observedPlacement,
230
+ stop,
244
231
  };
245
232
  }
246
233
  return undefined;
247
234
  }
248
235
  async function advanceCandidate(input, cursor) {
249
- if (input.start === "verification") {
250
- const stopped = await verifyCandidateReadiness(input, cursor);
251
- if (stopped !== undefined)
252
- return stopped;
253
- }
254
236
  const target = cursor.checkpoint.state.coordinates.target;
255
- let placement = await placeCurrentCandidate(input, cursor);
237
+ let needsVerification = input.start === "verification";
256
238
  for (let cycles = 0;; cycles += 1) {
239
+ input.signal?.throwIfAborted();
240
+ let placement = await observeIntegrationTargetMovement(input.repository, cursor.checkpoint.state);
241
+ if (placement === undefined) {
242
+ if (needsVerification) {
243
+ const stopped = await verifyCandidateReadiness(input, cursor);
244
+ if (stopped !== undefined)
245
+ return stopped;
246
+ }
247
+ placement = await placeCurrentCandidate(input, cursor);
248
+ }
257
249
  if (placement.kind === "accepted")
258
250
  return await completedResult(input, cursor);
259
251
  if (placement.kind !== "target-moved" || target === undefined || placement.observedTreeEqualsCandidate) {
@@ -287,10 +279,7 @@ async function advanceCandidate(input, cursor) {
287
279
  return stoppedResult(cursor, reintegrationStop(reintegrated));
288
280
  cursor.checkpoint = contractCheckpoint(reintegrated);
289
281
  input.progress.recordResidue(reintegrated.state.id, reintegrated);
290
- const stopped = await verifyCandidateReadiness(input, cursor);
291
- if (stopped !== undefined)
292
- return stopped;
293
- placement = await placeCurrentCandidate(input, cursor);
282
+ needsVerification = true;
294
283
  }
295
284
  }
296
285
  /** Advance one contract. The trigger owns the leading act; this node owns no other contract. */
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
- import { worktreeWorkspaceSchema } from "../git/workspace.js";
3
- import type { ActorId, ContractId, ContractState, DeliverData } from "../core/facts/types.js";
2
+ import { candidateContentChangeSchema } from "./operations.js";
3
+ import type { ActorId, ContractId, ContractState, DeliverData, SnapshotId } from "../core/facts/types.js";
4
4
  import { type CurrentVerifiedAttestation } from "./intent.js";
5
5
  import type { LeadingOutcome } from "./outcome.js";
6
6
  import type { CompletionEvidence } from "./completion.js";
@@ -14,21 +14,22 @@ export declare const deliverLeadingSchema: z.ZodObject<{
14
14
  "already-admitted": "already-admitted";
15
15
  }>;
16
16
  fact: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").EntryUlid, string>>;
17
+ reusedIntegration: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<SnapshotId, string>>>;
17
18
  }, z.core.$strict>;
18
19
  type DeliverLeading = z.infer<typeof deliverLeadingSchema>;
19
20
  type DeliverValue = DeliveryIdentity & CompletionEvidence & Readonly<{
20
21
  leading: DeliverLeading;
22
+ contentChange?: z.infer<typeof candidateContentChangeSchema>;
21
23
  }>;
22
- export type AppointedWorkspace = z.infer<typeof worktreeWorkspaceSchema>;
23
24
  export declare const materializedConflictSchema: z.ZodObject<{
24
25
  kind: z.ZodLiteral<"integration-conflict-materialized">;
25
- targetHead: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
26
+ targetHead: z.ZodPipe<z.ZodString, z.ZodTransform<SnapshotId, string>>;
26
27
  conflictPaths: z.ZodReadonly<z.ZodArray<z.ZodString>>;
27
28
  workspace: z.ZodObject<{
28
29
  kind: z.ZodLiteral<"worktree">;
29
30
  path: z.ZodString;
30
31
  }, z.core.$strict>;
31
- handoffBase: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
32
+ handoffBase: z.ZodPipe<z.ZodString, z.ZodTransform<SnapshotId, string>>;
32
33
  recovery: z.ZodObject<{
33
34
  materialize: z.ZodLiteral<"deliver --materialize-conflict --include-dirty">;
34
35
  deliver: z.ZodLiteral<"deliver --include-dirty">;
@@ -49,6 +50,7 @@ type DeliverOperationRefusal = import("../core/verbs/deliver.js").DeliverRefusal
49
50
  export declare function prepareDelivery(repository: import("../git/process.js").GitRepository, stage: Readonly<{
50
51
  contractId: ContractId;
51
52
  coordinates: ContractState["coordinates"];
53
+ recordedIntegrations?: readonly SnapshotId[];
52
54
  appointment?: Extract<ManagedWorktreeAppointment, {
53
55
  kind: "appointed";
54
56
  }>;