@astrosheep/keiyaku 4.6.32 → 4.6.34

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 (244) hide show
  1. package/README.md +18 -7
  2. package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +18 -11
  3. package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +8 -6
  4. package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +2 -1
  5. package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +2 -1
  6. package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +18 -11
  7. package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +8 -6
  8. package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +2 -1
  9. package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +2 -1
  10. package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +18 -11
  11. package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +8 -6
  12. package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +2 -1
  13. package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +2 -1
  14. package/build/plugins/pi/README.md +55 -97
  15. package/build/plugins/pi/keiyaku.ts +1 -142
  16. package/build/skills/keiyaku-akuma/SKILL.md +18 -11
  17. package/build/skills/keiyaku-babysit/SKILL.md +8 -6
  18. package/build/skills/keiyaku-debt/SKILL.md +2 -1
  19. package/build/skills/keiyaku-workflow/SKILL.md +2 -1
  20. package/build/src/akuma/akuma-instance.d.ts +11 -0
  21. package/build/src/akuma/akuma-instance.js +1 -2
  22. package/build/src/akuma/akuma-observe.d.ts +8 -0
  23. package/build/src/akuma/akuma-observe.js +81 -14
  24. package/build/src/akuma/akuma-owner.d.ts +1 -0
  25. package/build/src/akuma/akuma-owner.js +3 -5
  26. package/build/src/akuma/akuma-selection-execution.d.ts +82 -7
  27. package/build/src/akuma/akuma-selection-execution.js +26 -27
  28. package/build/src/akuma/akuma-wait.d.ts +155 -1
  29. package/build/src/akuma/akuma-wait.js +94 -34
  30. package/build/src/akuma/akuma.d.ts +17 -1
  31. package/build/src/akuma/akuma.js +37 -18
  32. package/build/src/akuma/body.js +13 -18
  33. package/build/src/akuma/call-initial-tell.d.ts +0 -1
  34. package/build/src/akuma/call-initial-tell.js +0 -1
  35. package/build/src/akuma/heart/activity-schema.d.ts +16 -0
  36. package/build/src/akuma/heart/activity-schema.js +7 -0
  37. package/build/src/akuma/heart/facts.d.ts +1 -0
  38. package/build/src/akuma/heart/facts.js +14 -0
  39. package/build/src/akuma/heart/index.d.ts +7 -1
  40. package/build/src/akuma/heart/index.js +35 -9
  41. package/build/src/akuma/heart/rows.d.ts +1 -0
  42. package/build/src/akuma/heart/rows.js +4 -0
  43. package/build/src/akuma/heart/timeline.js +4 -4
  44. package/build/src/akuma/lineage-cache.d.ts +7 -2
  45. package/build/src/akuma/lineage-cache.js +48 -24
  46. package/build/src/akuma/projection-read.d.ts +4 -2
  47. package/build/src/akuma/projection-read.js +25 -23
  48. package/build/src/akuma/projection.d.ts +94 -2
  49. package/build/src/akuma/projection.js +47 -47
  50. package/build/src/akuma/provider.d.ts +2 -2
  51. package/build/src/akuma/provider.js +27 -20
  52. package/build/src/akuma/providers/acp/core.js +2 -5
  53. package/build/src/akuma/providers/opencode-sdk/events.d.ts +2 -1
  54. package/build/src/akuma/providers/opencode-sdk/events.js +31 -1
  55. package/build/src/akuma/publication.js +3 -2
  56. package/build/src/akuma/selection-observation.d.ts +645 -0
  57. package/build/src/akuma/selection-observation.js +22 -7
  58. package/build/src/akuma/status-projection.d.ts +14 -1
  59. package/build/src/akuma/status-projection.js +40 -2
  60. package/build/src/akuma/turn-drive.js +21 -15
  61. package/build/src/body/amend.js +5 -17
  62. package/build/src/body/decode.js +11 -1
  63. package/build/src/body/envelope.d.ts +5 -1
  64. package/build/src/body/envelope.js +4 -2
  65. package/build/src/body/render.js +4 -6
  66. package/build/src/bounded-list.d.ts +8 -0
  67. package/build/src/bounded-list.js +10 -0
  68. package/build/src/cli/commands/akuma-grammar.d.ts +5 -8
  69. package/build/src/cli/commands/akuma-grammar.js +52 -77
  70. package/build/src/cli/commands/akuma.d.ts +1 -2
  71. package/build/src/cli/commands/akuma.js +12 -61
  72. package/build/src/cli/commands/contract-grammar.d.ts +1 -0
  73. package/build/src/cli/commands/contract-grammar.js +39 -42
  74. package/build/src/cli/commands/contract-help.d.ts +6 -5
  75. package/build/src/cli/commands/contract-help.js +21 -13
  76. package/build/src/cli/commands/contract.d.ts +3 -3
  77. package/build/src/cli/commands/contract.js +13 -9
  78. package/build/src/cli/commands/debt-grammar.js +2 -4
  79. package/build/src/cli/parse.d.ts +4 -10
  80. package/build/src/cli/parse.js +2 -5
  81. package/build/src/cli/render/akuma-activity.d.ts +12 -34
  82. package/build/src/cli/render/akuma-activity.js +99 -180
  83. package/build/src/cli/render/akuma.d.ts +5 -11
  84. package/build/src/cli/render/akuma.js +22 -30
  85. package/build/src/cli/render/catalog.js +4 -6
  86. package/build/src/cli/render/contract-history.d.ts +1 -3
  87. package/build/src/cli/render/contract-history.js +70 -49
  88. package/build/src/cli/render/contract-observation.d.ts +2 -1
  89. package/build/src/cli/render/contract-observation.js +25 -1
  90. package/build/src/cli/render/contract-wait.d.ts +2 -2
  91. package/build/src/cli/render/contract-wait.js +21 -17
  92. package/build/src/cli/render/contract.js +12 -9
  93. package/build/src/cli/render/debt.js +1 -2
  94. package/build/src/cli/render/execution-progress.js +1 -3
  95. package/build/src/cli/render/kanshi-akuma.d.ts +4 -3
  96. package/build/src/cli/render/kanshi-akuma.js +27 -23
  97. package/build/src/cli/render/kanshi.js +45 -60
  98. package/build/src/cli/render/receipt.d.ts +1 -1
  99. package/build/src/cli/render/receipt.js +33 -28
  100. package/build/src/cli/render/reconcile.js +2 -5
  101. package/build/src/cli/render/refusal.js +3 -6
  102. package/build/src/cli/render/terminal.d.ts +2 -4
  103. package/build/src/cli/render/terminal.js +10 -17
  104. package/build/src/cli/render/verbs.d.ts +1 -0
  105. package/build/src/cli/render/verbs.js +39 -34
  106. package/build/src/cli/runtime.js +12 -32
  107. package/build/src/core/facts/codec.js +7 -2
  108. package/build/src/core/facts/eligibility.d.ts +4 -4
  109. package/build/src/core/facts/eligibility.js +11 -0
  110. package/build/src/core/facts/fold.js +9 -5
  111. package/build/src/core/facts/gate.d.ts +5 -1
  112. package/build/src/core/facts/gate.js +14 -10
  113. package/build/src/core/facts/types.d.ts +5 -1
  114. package/build/src/core/facts/types.js +7 -0
  115. package/build/src/core/subject.d.ts +4 -1
  116. package/build/src/core/subject.js +10 -2
  117. package/build/src/core/verbs/amend.d.ts +15 -4
  118. package/build/src/core/verbs/amend.js +19 -9
  119. package/build/src/debt/board.d.ts +2 -1
  120. package/build/src/debt/board.js +3 -3
  121. package/build/src/debt/catalog.js +2 -1
  122. package/build/src/debt/document.d.ts +1 -0
  123. package/build/src/debt/document.js +3 -0
  124. package/build/src/debt/index.d.ts +2 -2
  125. package/build/src/debt/index.js +9 -14
  126. package/build/src/debt/input.d.ts +2 -1
  127. package/build/src/debt/input.js +6 -4
  128. package/build/src/debt/operations.d.ts +2 -1
  129. package/build/src/dispatch/index.d.ts +0 -17
  130. package/build/src/dispatch/index.js +1 -10
  131. package/build/src/git/identity.js +16 -45
  132. package/build/src/git/nuke.js +13 -23
  133. package/build/src/git/observe.d.ts +7 -3
  134. package/build/src/git/observe.js +29 -26
  135. package/build/src/git/process.js +11 -18
  136. package/build/src/git/read-observation.d.ts +5 -4
  137. package/build/src/git/repository.d.ts +2 -0
  138. package/build/src/git/repository.js +13 -1
  139. package/build/src/git/scratch.js +2 -14
  140. package/build/src/git/terminal-reconcile.js +1 -13
  141. package/build/src/history.d.ts +26 -0
  142. package/build/src/history.js +43 -0
  143. package/build/src/index.d.ts +6 -3
  144. package/build/src/kanshi/counts.d.ts +15 -1
  145. package/build/src/kanshi/counts.js +14 -3
  146. package/build/src/kanshi/index.d.ts +3 -4
  147. package/build/src/kanshi/index.js +2 -3
  148. package/build/src/kanshi/read.d.ts +21 -0
  149. package/build/src/kanshi/read.js +7 -3
  150. package/build/src/kanshi/report.d.ts +94 -0
  151. package/build/src/library/address.d.ts +12 -5
  152. package/build/src/library/address.js +18 -32
  153. package/build/src/library/akuma-creation.d.ts +39 -0
  154. package/build/src/library/akuma-creation.js +3 -9
  155. package/build/src/library/akumas.d.ts +5 -1
  156. package/build/src/library/akumas.js +11 -5
  157. package/build/src/library/continuation.d.ts +10 -0
  158. package/build/src/library/contract-composition.js +10 -10
  159. package/build/src/library/contract-creation.js +12 -13
  160. package/build/src/library/contract-outcomes.d.ts +72 -1
  161. package/build/src/library/contract-outcomes.js +1 -0
  162. package/build/src/library/contract-types.d.ts +233 -25
  163. package/build/src/library/contract-types.js +32 -12
  164. package/build/src/library/contract-wait.d.ts +212 -0
  165. package/build/src/library/contract-wait.js +65 -49
  166. package/build/src/library/delivery.d.ts +25 -0
  167. package/build/src/library/input.d.ts +8 -26
  168. package/build/src/library/input.js +17 -12
  169. package/build/src/library/kei.js +167 -90
  170. package/build/src/library/keiyaku-attribution.d.ts +1 -1
  171. package/build/src/library/keiyaku-attribution.js +3 -1
  172. package/build/src/library/keiyaku-classify.js +8 -4
  173. package/build/src/library/keiyaku-debt.d.ts +8 -7
  174. package/build/src/library/keiyaku-debt.js +1 -2
  175. package/build/src/library/keiyaku-identity.d.ts +4 -3
  176. package/build/src/library/keiyaku-identity.js +35 -7
  177. package/build/src/library/keiyaku-verbs.d.ts +974 -1409
  178. package/build/src/library/keiyaku-verbs.js +154 -161
  179. package/build/src/library/keiyaku-wait.d.ts +753 -0
  180. package/build/src/library/keiyaku-wait.js +230 -0
  181. package/build/src/library/keiyaku.d.ts +3110 -29
  182. package/build/src/library/keiyaku.js +342 -438
  183. package/build/src/library/model-tools.d.ts +754 -0
  184. package/build/src/library/model-tools.js +362 -0
  185. package/build/src/library/outcome.js +5 -6
  186. package/build/src/library/refusal.d.ts +25 -1
  187. package/build/src/library/refusal.js +4 -5
  188. package/build/src/library/selection.d.ts +18 -5
  189. package/build/src/library/selection.js +11 -5
  190. package/build/src/mcp/adapter.d.ts +0 -6
  191. package/build/src/mcp/adapter.js +11 -160
  192. package/build/src/mcp/description.d.ts +2 -0
  193. package/build/src/mcp/description.js +2 -0
  194. package/build/src/mcp/help.d.ts +1 -1
  195. package/build/src/mcp/help.js +10 -7
  196. package/build/src/pi/index.d.ts +5 -0
  197. package/build/src/pi/index.js +99 -0
  198. package/build/src/pi/status.d.ts +12 -0
  199. package/build/src/pi/status.js +140 -0
  200. package/build/src/protocol/amend.d.ts +14 -3
  201. package/build/src/protocol/amend.js +113 -46
  202. package/build/src/protocol/bind.d.ts +1 -1
  203. package/build/src/protocol/bind.js +5 -16
  204. package/build/src/protocol/completion.d.ts +30 -0
  205. package/build/src/protocol/completion.js +8 -5
  206. package/build/src/protocol/deliver.js +7 -20
  207. package/build/src/protocol/delivery-preview.d.ts +5 -0
  208. package/build/src/protocol/execution-observation.d.ts +8 -0
  209. package/build/src/protocol/intent.d.ts +1 -0
  210. package/build/src/protocol/intent.js +4 -1
  211. package/build/src/protocol/operations.d.ts +56 -16
  212. package/build/src/protocol/operations.js +18 -32
  213. package/build/src/protocol/placement.js +7 -1
  214. package/build/src/protocol/progress.js +0 -6
  215. package/build/src/protocol/read/status.d.ts +52 -4
  216. package/build/src/protocol/read/status.js +26 -22
  217. package/build/src/protocol/reintegrate.js +2 -2
  218. package/build/src/protocol/result-leaves.d.ts +56 -8
  219. package/build/src/protocol/result-leaves.js +11 -2
  220. package/build/src/protocol/run.js +1 -4
  221. package/build/src/protocol/verify.d.ts +10 -0
  222. package/build/src/protocol/verify.js +1 -0
  223. package/build/src/runtime/proc/windows-launch.exe +0 -0
  224. package/build/src/settlement/settle.js +19 -68
  225. package/package.json +7 -3
  226. package/plugins/paseo/plugin/index.server.ts +6 -2
  227. package/plugins/paseo/plugin/server/attach.ts +68 -48
  228. package/plugins/paseo/plugin/server/directory.ts +259 -0
  229. package/plugins/paseo/plugin/server/mirror-identity.ts +3 -32
  230. package/plugins/paseo/plugin/server/reopen.ts +52 -38
  231. package/plugins/pi/README.md +55 -97
  232. package/plugins/pi/keiyaku.ts +1 -142
  233. package/skills/keiyaku-akuma/SKILL.md +18 -11
  234. package/skills/keiyaku-babysit/SKILL.md +8 -6
  235. package/skills/keiyaku-debt/SKILL.md +2 -1
  236. package/skills/keiyaku-workflow/SKILL.md +2 -1
  237. package/build/plugins/pi/akuma-tools.ts +0 -283
  238. package/build/src/body/keys.d.ts +0 -4
  239. package/build/src/body/keys.js +0 -11
  240. package/build/src/kanshi/roster.d.ts +0 -2
  241. package/build/src/kanshi/roster.js +0 -2
  242. package/build/src/mcp/output.d.ts +0 -385
  243. package/build/src/mcp/output.js +0 -193
  244. package/plugins/pi/akuma-tools.ts +0 -283
@@ -2,10 +2,10 @@ import { resolve } from "node:path";
2
2
  import { AkumaNotBornError, AkumaObservationError } from "../akuma/akuma-errors.js";
3
3
  import { AkumaNameError, Keiyaku } from "../index.js";
4
4
  import { errorCategory } from "../errors.js";
5
- import { AkumaAddressError, AkumaWorldScopeError, observeNamedAddress, resolveNamedAddress, } from "../library/address.js";
5
+ import { AkumaAddressError, AkumaWorldScopeError } from "../library/address.js";
6
6
  import { projectFailure, KeiyakuError } from "../library/outcome.js";
7
7
  import { classifyVerb } from "../library/keiyaku-verbs.js";
8
- import { acquireAkumaRequest, runSpawn, runAsk, runAkumaHistory } from "./commands/akuma.js";
8
+ import { acquireAkumaRequest, runAsk, runAkumaHistory } from "./commands/akuma.js";
9
9
  import { acquireContractRequest, admitBindMarkdown, runContractRequest } from "./commands/contract.js";
10
10
  import { installOutcome, installHarnesses, renderInstallText } from "./commands/install.js";
11
11
  import { runDebtCommand } from "./commands/debt.js";
@@ -30,10 +30,6 @@ function memoized(reader) {
30
30
  let value;
31
31
  return () => (value ??= reader());
32
32
  }
33
- function homeFromEnvironment(environment) {
34
- const mapped = environment.KEIYAKU_HOME?.trim();
35
- return mapped === undefined || mapped.length === 0 ? undefined : mapped;
36
- }
37
33
  /** Builds the one live progress observer for an invocation; the leaf owns when it finishes. */
38
34
  export async function writeExecutionProgress(stream = process.stderr) {
39
35
  const terminal = stream;
@@ -155,14 +151,14 @@ function invocationCoordinates(invocation, input, environment) {
155
151
  async function runCommand(invocation, input) {
156
152
  const command = invocation.command;
157
153
  const environment = { ...(input.environment ?? process.env) };
158
- const home = homeFromEnvironment(environment);
154
+ const home = environment.KEIYAKU_HOME?.trim() || undefined;
159
155
  const cancellation = cliCancellation(input.signal);
160
156
  let progress;
161
157
  try {
162
158
  assertExplicitRepoUse(command, invocation.repo);
163
159
  const runtime = {
164
160
  environment,
165
- facet: Keiyaku.at({
161
+ facet: Keiyaku.for({
166
162
  cwd: resolve(input.cwd ?? process.cwd(), invocation.cwd ?? "."),
167
163
  environment,
168
164
  ...(home === undefined ? {} : { home }),
@@ -186,37 +182,21 @@ async function runCommand(invocation, input) {
186
182
  }
187
183
  if (command.name === "bind" && "acquire" in command) {
188
184
  await admitBindMarkdown({
189
- markdown: await runtime.readStdin(),
185
+ terms: await runtime.readStdin(),
190
186
  processCwd: input.cwd ?? process.cwd(),
191
187
  ...(invocation.cwd === undefined ? {} : { cwd: invocation.cwd }),
192
188
  });
193
189
  }
194
- let request;
195
- let selectedAlias;
196
- if ("acquire" in command && command.name === "status") {
197
- const { world, repo } = await invocationCoordinates(invocation, input, environment);
198
- const selector = command.acquire.selector;
199
- const authority = await observeNamedAddress({ world, repo: repo ?? null, selectors: [selector] });
200
- const address = resolveNamedAddress({ selector, ...authority });
201
- if (address.kind === "akuma")
202
- selectedAlias = selector;
203
- request = { name: "status", input: { id: address.id }, output: command.output };
204
- }
205
- else {
206
- request =
207
- "acquire" in command
208
- ? command.name === "spawn" || command.name === "tell" || command.name === "ask"
209
- ? await acquireAkumaRequest(command, invocation.workdir, runtime)
210
- : await acquireContractRequest(command, runtime)
211
- : command;
212
- }
213
- if (request.name === "spawn")
214
- return await runSpawn(request, runtime);
215
- if (request.name === "ask" || (request.name === "tell" && request.input.wait !== undefined))
190
+ const request = "acquire" in command
191
+ ? command.name === "spawn" || command.name === "tell" || command.name === "ask"
192
+ ? await acquireAkumaRequest(command, invocation.workdir, runtime)
193
+ : await acquireContractRequest(command, runtime)
194
+ : command;
195
+ if (request.name === "ask")
216
196
  return await runAsk(request, runtime);
217
197
  if (request.name === "history" && !request.input.selector.startsWith("kei/"))
218
198
  return await runAkumaHistory(request, runtime);
219
- return await runContractRequest(request, runtime, selectedAlias);
199
+ return await runContractRequest(request, runtime);
220
200
  }
221
201
  catch (error) {
222
202
  return writeFailure(error, command);
@@ -183,8 +183,13 @@ function validateData(kind, value) {
183
183
  terms: termsValue(object.terms, `${path}.terms`),
184
184
  };
185
185
  }
186
- case "amend":
187
- return termsValue(value, path);
186
+ case "amend": {
187
+ const object = requireRecord(value, path);
188
+ return {
189
+ ...termsValue(object, path),
190
+ ...(object.target === undefined ? {} : { target: targetValue(object.target, `${path}.target`) }),
191
+ };
192
+ }
188
193
  case "deliver": {
189
194
  const object = requireRecord(value, path);
190
195
  requireKeys(object, ["tenderSnapshot", "integration", "method", "policy"], path);
@@ -1,7 +1,7 @@
1
1
  import { type ContractsObservation } from "./observation.js";
2
- import type { ContractId } from "./types.js";
3
- type EligibilityObservation = ContractsObservation;
2
+ import type { ContractId, ContractTarget } from "./types.js";
3
+ /** Decide whether a destination chain would cycle through the amended Contract. */
4
+ export declare function targetCycles(contract: ContractId, target: ContractTarget | undefined, observation: ContractsObservation): boolean;
4
5
  /** Decide whether resulting prerequisites reach the amended contract. */
5
- export declare function prerequisitesReach(contract: ContractId, prerequisites: readonly ContractId[], observation: EligibilityObservation): boolean;
6
+ export declare function prerequisitesReach(contract: ContractId, prerequisites: readonly ContractId[], observation: ContractsObservation): boolean;
6
7
  export declare function samePrerequisites(left: readonly ContractId[], right: readonly ContractId[]): boolean;
7
- export {};
@@ -1,4 +1,15 @@
1
1
  import { contractState } from "./observation.js";
2
+ /** Decide whether a destination chain would cycle through the amended Contract. */
3
+ export function targetCycles(contract, target, observation) {
4
+ const visited = new Set([contract]);
5
+ while (target !== undefined && typeof target !== "string") {
6
+ if (visited.has(target.contractId))
7
+ return true;
8
+ visited.add(target.contractId);
9
+ target = contractState(observation, target.contractId)?.coordinates.target;
10
+ }
11
+ return false;
12
+ }
2
13
  /** Decide whether resulting prerequisites reach the amended contract. */
3
14
  export function prerequisitesReach(contract, prerequisites, observation) {
4
15
  const pending = [...prerequisites];
@@ -1,4 +1,5 @@
1
1
  import { gatesSatisfied } from "./gate.js";
2
+ import { sameTarget } from "./types.js";
2
3
  import { AuthorityCorruptionError } from "./errors.js";
3
4
  function foldError(message) {
4
5
  throw new AuthorityCorruptionError(`invalid journal fold: ${message}`);
@@ -12,16 +13,13 @@ function cloneTerms(terms) {
12
13
  after: [...terms.after],
13
14
  };
14
15
  }
15
- function cloneCoordinates(coordinates) {
16
- return { ...coordinates };
17
- }
18
16
  function stateFromBind(id, head, bind, attestations) {
19
17
  if (bind.contract !== id)
20
18
  foldError(`entry belongs to ${bind.contract}, not ${id}`);
21
19
  return {
22
20
  id,
23
21
  head,
24
- coordinates: cloneCoordinates(bind.data.coordinates),
22
+ coordinates: { ...bind.data.coordinates },
25
23
  terms: cloneTerms(bind.data.terms),
26
24
  delivery: null,
27
25
  currentIntegration: null,
@@ -48,7 +46,13 @@ function foldEntry(state, entry, attestations) {
48
46
  case "bind":
49
47
  foldError("bind may appear only once");
50
48
  case "amend":
51
- return { ...state, terms: cloneTerms(entry.data) };
49
+ return {
50
+ ...state,
51
+ terms: cloneTerms(entry.data),
52
+ ...(entry.data.target === undefined || sameTarget(state.coordinates.target, entry.data.target)
53
+ ? {}
54
+ : { coordinates: { ...state.coordinates, target: entry.data.target }, targetRevision: entry.entry }),
55
+ };
52
56
  case "deliver":
53
57
  return { ...state, delivery: entry, currentIntegration: { ...entry.data.integration } };
54
58
  case "reintegrated":
@@ -1,9 +1,13 @@
1
- import { type AttestationEntry, type ChangeId, type ContractState, type Gate, type RequirementId } from "./types.js";
1
+ import { type AttestationEntry, type ChangeId, type ContractState, type Gate, type RequirementId, type SnapshotId } from "./types.js";
2
2
  export type GateStaleReason = Readonly<{
3
3
  kind: "candidate-content-changed";
4
4
  target?: string;
5
5
  previousChange: ChangeId;
6
6
  currentChange: ChangeId;
7
+ }> | Readonly<{
8
+ kind: "snapshot-changed";
9
+ previousSnapshot: SnapshotId;
10
+ currentSnapshot: SnapshotId;
7
11
  }>;
8
12
  export type GateCurrent = Readonly<{
9
13
  kind: "attested";
@@ -2,18 +2,22 @@ import { dependencyKeys, currentSubjectPredicate } from "../subject.js";
2
2
  import { targetName, } from "./types.js";
3
3
  function staleReason(state, previous) {
4
4
  const target = state.coordinates.target;
5
- const currentChange = state.currentIntegration?.changeId ?? state.delivery?.data.integration.changeId;
6
- if (currentChange === undefined)
5
+ const integration = state.currentIntegration ?? state.delivery?.data.integration;
6
+ if (integration === undefined)
7
7
  return undefined;
8
- const previousChange = dependencyKeys(previous.data.subject).find((key) => key.kind === "change")?.value;
9
- if (previousChange === undefined || previousChange === currentChange)
8
+ const keys = dependencyKeys(previous.data.subject);
9
+ const previousChange = keys.find((key) => key.kind === "change")?.value;
10
+ if (previousChange !== undefined && previousChange !== integration.changeId)
11
+ return {
12
+ kind: "candidate-content-changed",
13
+ ...(target === undefined ? {} : { target: targetName(target) }),
14
+ previousChange,
15
+ currentChange: integration.changeId,
16
+ };
17
+ const previousSnapshot = keys.find((key) => key.kind === "snapshot")?.value;
18
+ if (previousSnapshot === undefined || previousSnapshot === integration.snapshot)
10
19
  return undefined;
11
- return {
12
- kind: "candidate-content-changed",
13
- ...(target === undefined ? {} : { target: targetName(target) }),
14
- previousChange,
15
- currentChange,
16
- };
20
+ return { kind: "snapshot-changed", previousSnapshot, currentSnapshot: integration.snapshot };
17
21
  }
18
22
  /** Resolve latest current testimony independently for each gate and requirement. */
19
23
  export function latestCurrentAttestations(state, requested) {
@@ -58,6 +58,7 @@ export type ContractTarget = string | Readonly<{
58
58
  }>;
59
59
  }>;
60
60
  export declare function targetName(target: ContractTarget): string;
61
+ export declare function sameTarget(left: ContractTarget | undefined, right: ContractTarget | undefined): boolean;
61
62
  export type ContractCoordinates = Readonly<{
62
63
  start: SnapshotId;
63
64
  target?: ContractTarget;
@@ -77,7 +78,9 @@ export type BindData = Readonly<{
77
78
  coordinates: ContractCoordinates;
78
79
  terms: ContractTerms;
79
80
  }>;
80
- export type AmendData = ContractTerms;
81
+ export type AmendData = ContractTerms & Readonly<{
82
+ target?: ContractTarget;
83
+ }>;
81
84
  export type DeliverData = Readonly<{
82
85
  note?: string;
83
86
  tenderSnapshot: SnapshotId;
@@ -149,6 +152,7 @@ export type ContractState = Readonly<{
149
152
  id: ContractId;
150
153
  head: ContractHead | null;
151
154
  coordinates: ContractCoordinates;
155
+ targetRevision?: EntryUlid;
152
156
  terms: ContractTerms;
153
157
  delivery: DeliverEntry | null;
154
158
  currentIntegration: CurrentIntegration | null;
@@ -66,6 +66,13 @@ export function gate(value) {
66
66
  export function targetName(target) {
67
67
  return typeof target === "string" ? target : target.contractId;
68
68
  }
69
+ export function sameTarget(left, right) {
70
+ if (typeof left !== "object" || typeof right !== "object")
71
+ return left === right;
72
+ return (left.contractId === right.contractId &&
73
+ left.worktree.id === right.worktree.id &&
74
+ left.worktree.identity === right.worktree.identity);
75
+ }
69
76
  /**
70
77
  * The one journal-envelope constructor for every verb offering a single fact: entry identity, the
71
78
  * invoking decision input's Contract and timestamp, and the verb's own payload.
@@ -1,4 +1,4 @@
1
- import { type ChangeId, type ContractState, type DependencyKeySet, type DocumentKey, type DocumentSegmentKey, type SnapshotId } from "./facts/types.js";
1
+ import { type EntryUlid, type ChangeId, type ContractState, type DependencyKeySet, type DocumentKey, type DocumentSegmentKey, type SnapshotId } from "./facts/types.js";
2
2
  export type DependencyKey = Readonly<{
3
3
  readonly kind: "document";
4
4
  readonly value: DocumentKey;
@@ -11,6 +11,9 @@ export type DependencyKey = Readonly<{
11
11
  } | {
12
12
  readonly kind: "change";
13
13
  readonly value: ChangeId;
14
+ } | {
15
+ readonly kind: "target";
16
+ readonly value: EntryUlid;
14
17
  }>;
15
18
  /** Mint the opaque persisted representation of an ordered producer-selected key set. */
16
19
  export declare function dependencyKeySet(keys: readonly DependencyKey[]): DependencyKeySet;
@@ -1,4 +1,4 @@
1
- import { changeId, documentKey, documentSegmentKey, snapshotId, } from "./facts/types.js";
1
+ import { changeId, entryUlid, documentKey, documentSegmentKey, snapshotId, } from "./facts/types.js";
2
2
  import { AuthorityCorruptionError } from "./facts/errors.js";
3
3
  function keyTuple(key) {
4
4
  return [key.kind, key.value];
@@ -20,6 +20,8 @@ function parseKey(value, index) {
20
20
  return { kind: "snapshot", value: snapshotId(value[1]) };
21
21
  case "change":
22
22
  return { kind: "change", value: changeId(value[1]) };
23
+ case "target":
24
+ return { kind: "target", value: entryUlid(value[1]) };
23
25
  default:
24
26
  throw new AuthorityCorruptionError(`unknown dependency key kind '${value[0]}'`);
25
27
  }
@@ -78,6 +80,7 @@ function currentKeys(state) {
78
80
  return new Set([
79
81
  encodeKey({ kind: "document", value: state.terms.document.key }),
80
82
  ...state.terms.segments.map((value) => encodeKey({ kind: "segment", value })),
83
+ ...(state.targetRevision === undefined ? [] : [encodeKey({ kind: "target", value: state.targetRevision })]),
81
84
  ...(integration === undefined
82
85
  ? []
83
86
  : [
@@ -94,7 +97,12 @@ export function currentSubjectPredicate(state) {
94
97
  const known = current.get(subject);
95
98
  if (known !== undefined)
96
99
  return known;
97
- const value = decodeDependencyKeySet(subject).encodedKeys.every((key) => available.has(key));
100
+ const decoded = decodeDependencyKeySet(subject);
101
+ // Snapshot-only testimony cannot cross a target change, even when the new target has the same head.
102
+ const snapshotTargetCurrent = state.targetRevision === undefined ||
103
+ !decoded.keys.some((key) => key.kind === "snapshot") ||
104
+ decoded.keys.some((key) => key.kind === "target" && key.value === state.targetRevision);
105
+ const value = snapshotTargetCurrent && decoded.encodedKeys.every((key) => available.has(key));
98
106
  current.set(subject, value);
99
107
  return value;
100
108
  };
@@ -1,12 +1,23 @@
1
1
  import type { DecideInput, OfferDecision, Preparation } from "../decide.js";
2
+ import { type TargetContractRefusal } from "../facts/observation.js";
2
3
  import { type AmendData, type ContractId, type ContractTerms } from "../facts/types.js";
4
+ /** What one amendment replaces: the source terms it stamps and the terms it asks for. */
5
+ export type AmendEdit<Failure = never> = Readonly<{
6
+ source: ContractTerms;
7
+ targetContract?: ContractId;
8
+ preparation: Preparation<AmendData, Failure>;
9
+ }>;
3
10
  export type AmendInput<Failure = never> = Readonly<{
4
11
  contractId: ContractId;
5
12
  at: string;
6
- source?: ContractTerms;
7
- preparation?: Preparation<AmendData, Failure>;
13
+ /** Absent when the amendment requests no change: an ordinary no-op, not an empty edit. */
14
+ edit?: AmendEdit<Failure>;
8
15
  }>;
9
16
  export type AmendRefusal = Readonly<{
10
- kind: "contract-missing" | "terminal" | "terms-moved" | "unknown-prerequisite" | "cyclic-prerequisite";
17
+ kind: "contract-missing" | "terminal" | "terms-moved" | "unknown-prerequisite" | "cyclic-prerequisite" | "cyclic-target";
18
+ }> | TargetContractRefusal;
19
+ /** The owner's answer for a well-formed amendment request, including one that asks for nothing. */
20
+ export type AmendDecision<Failure> = OfferDecision<AmendRefusal | Failure> | Readonly<{
21
+ kind: "unchanged";
11
22
  }>;
12
- export declare function decideAmend<Failure>({ input, attempt, observation, }: DecideInput<AmendInput<Failure>>): OfferDecision<AmendRefusal | Failure>;
23
+ export declare function decideAmend<Failure>({ input, attempt, observation, }: DecideInput<AmendInput<Failure>>): AmendDecision<Failure>;
@@ -1,15 +1,15 @@
1
- import { prerequisitesReach, samePrerequisites } from "../facts/eligibility.js";
2
- import { activeContract, prerequisiteStatus } from "../facts/observation.js";
1
+ import { prerequisitesReach, samePrerequisites, targetCycles } from "../facts/eligibility.js";
2
+ import { activeContract, prerequisiteStatus, targetContractRefusal, targetContractIdRefusal, } from "../facts/observation.js";
3
3
  import { journalEntry } from "../facts/types.js";
4
4
  export function decideAmend({ input, attempt, observation, }) {
5
5
  const id = input.contractId;
6
6
  const current = activeContract(observation, id);
7
7
  if ("kind" in current)
8
8
  return { kind: "refused", refusal: current };
9
- if (input.preparation === undefined || input.source === undefined) {
10
- throw new Error("existing contract requires an amend preparation and source terms");
11
- }
12
- const source = input.source;
9
+ const edit = input.edit;
10
+ if (edit === undefined)
11
+ return { kind: "unchanged" };
12
+ const source = edit.source;
13
13
  const termsCurrent = source.document.key === current.terms.document.key &&
14
14
  source.segments.length === current.terms.segments.length &&
15
15
  source.segments.every((value, index) => value === current.terms.segments[index]) &&
@@ -27,9 +27,19 @@ export function decideAmend({ input, attempt, observation, }) {
27
27
  if (!termsCurrent) {
28
28
  return { kind: "refused", refusal: { kind: "terms-moved" } };
29
29
  }
30
- if (input.preparation.kind === "refused")
31
- return { kind: "refused", refusal: input.preparation.refusal };
32
- const { data } = input.preparation;
30
+ if (edit.targetContract !== undefined) {
31
+ const refusal = targetContractIdRefusal(observation, edit.targetContract);
32
+ if (refusal !== undefined)
33
+ return { kind: "refused", refusal };
34
+ }
35
+ if (edit.preparation.kind === "refused")
36
+ return { kind: "refused", refusal: edit.preparation.refusal };
37
+ const { data } = edit.preparation;
38
+ const targetRefusal = targetContractRefusal(observation, data.target);
39
+ if (targetRefusal !== undefined)
40
+ return { kind: "refused", refusal: targetRefusal };
41
+ if (targetCycles(id, data.target, observation))
42
+ return { kind: "refused", refusal: { kind: "cyclic-target" } };
33
43
  const prerequisites = prerequisiteStatus(data.after, observation);
34
44
  if (prerequisites === "unknown") {
35
45
  return { kind: "refused", refusal: { kind: "unknown-prerequisite" } };
@@ -1,6 +1,7 @@
1
1
  import { type DebtDocument } from "./document.js";
2
2
  import { type DebtId } from "./identity.js";
3
3
  import { z } from "zod";
4
+ import type { LifecycleSelection } from "../bounded-list.js";
4
5
  export declare const debtRefSchema: z.ZodReadonly<z.ZodObject<{
5
6
  id: z.ZodPipe<z.ZodString, z.ZodTransform<`debt/${string}`, string>>;
6
7
  state: z.ZodUnion<readonly [z.ZodEnum<{
@@ -90,7 +91,7 @@ export declare function debtDisposition(board: DebtBoard, debt: DebtDocument): D
90
91
  export declare function debtBlocked(board: DebtBoard, debt: DebtDocument): boolean;
91
92
  export declare function projectDebtDetail(board: DebtBoard, id: DebtId): DebtDetail | null;
92
93
  export declare function projectDebtSummary(board: DebtBoard, debt: DebtDocument): DebtSummary;
93
- export declare function projectRows(board: DebtBoard, selection: "active" | "closed" | "all"): readonly DebtSummary[];
94
+ export declare function projectRows(board: DebtBoard, selection: LifecycleSelection): readonly DebtSummary[];
94
95
  export declare function projectBlocked(board: DebtBoard): readonly BlockedDebtRow[];
95
96
  export declare function relationProblem(board: DebtBoard, before: DebtDocument | null, after: DebtDocument): string | null;
96
97
  export declare function diagnoseBoard(board: DebtBoard): readonly DebtDoctorIssue[];
@@ -1,4 +1,4 @@
1
- import { debtNonblankTextSchema, debtStateSchema, debtPrioritySchema, } from "./document.js";
1
+ import { debtNonblankTextSchema, debtStateSchema, debtLifecycle, debtPrioritySchema, } from "./document.js";
2
2
  import { debtIdSchema } from "./identity.js";
3
3
  import { nonEmptyDebtValues, nonEmptyDebtArraySchema } from "./operation-types.js";
4
4
  import { z } from "zod";
@@ -64,7 +64,7 @@ export const debtDoctorIssueSchema = z.union([
64
64
  })
65
65
  .readonly(),
66
66
  ]);
67
- const terminal = (state) => state === "done" || state === "drop";
67
+ const terminal = (state) => debtLifecycle(state) === "settled";
68
68
  const sorted = (values) => [...values].sort((a, b) => Buffer.compare(Buffer.from(a.id), Buffer.from(b.id)));
69
69
  export function debtRef(board, id) {
70
70
  const debt = board.debts.get(id);
@@ -110,7 +110,7 @@ export function projectDebtSummary(board, debt) {
110
110
  }
111
111
  export function projectRows(board, selection) {
112
112
  return [...board.debts.values()]
113
- .filter((debt) => selection === "all" || (selection === "closed") === terminal(debt.state))
113
+ .filter((debt) => selection === "all" || debtLifecycle(debt.state) === selection)
114
114
  .map((debt) => projectDebtSummary(board, debt))
115
115
  .sort(compareDebtRows);
116
116
  }
@@ -1,6 +1,7 @@
1
+ import { debtLifecycle } from "./document.js";
1
2
  import { readRecentDebtDocuments, readDebtDocument } from "./store.js";
2
3
  function terminal(debt) {
3
- return debt?.state === "done" || debt?.state === "drop";
4
+ return debt !== undefined && debtLifecycle(debt.state) === "settled";
4
5
  }
5
6
  async function catalogRow(world, debt, documents) {
6
7
  const needs = await Promise.all(debt.needs.map(async (id) => documents.get(id) ?? (await readDebtDocument(world, id))));
@@ -10,6 +10,7 @@ export declare const debtStateSchema: z.ZodEnum<{
10
10
  export type DebtPriority = 0 | 1 | 2 | 3;
11
11
  export declare const debtPrioritySchema: z.ZodType<DebtPriority, DebtPriority>;
12
12
  export type DebtState = z.infer<typeof debtStateSchema>;
13
+ export declare function debtLifecycle(state: DebtState): "active" | "settled";
13
14
  export declare const debtDocumentSchema: z.ZodReadonly<z.ZodObject<{
14
15
  id: z.ZodPipe<z.ZodString, z.ZodTransform<`debt/${string}`, string>>;
15
16
  title: z.ZodString;
@@ -6,6 +6,9 @@ export const debtNonblankTextSchema = z.string().refine((value) => value.trim()
6
6
  export const debtStateSchema = z.enum(["open", "done", "drop"]);
7
7
  // Integer bounds prove the finite priority type without a four-branch wire union.
8
8
  export const debtPrioritySchema = z.number().int().min(0).max(3);
9
+ export function debtLifecycle(state) {
10
+ return state === "open" ? "active" : "settled";
11
+ }
9
12
  export const debtDocumentSchema = z
10
13
  .strictObject({
11
14
  id: debtIdSchema,
@@ -1,8 +1,8 @@
1
+ import { type LifecycleSelection } from "../bounded-list.js";
1
2
  import { z } from "zod";
2
3
  import { debtRefSchema, blockedDebtRowSchema, readyDebtRowSchema, debtDoctorIssueSchema, debtSummarySchema, debtDispositionSchema, debtDetailSchema, type BlockedDebtRow, type DebtDetail, type DebtDoctorIssue, type DebtRef, type DebtSummary, type ReadyDebtRow } from "./board.js";
3
4
  import { debtWarningSchema, debtRefusalSchema, debtRetrySchema, debtReadPageSchema, debtMutationResultSchema, debtMutationNormalResultSchema, debtUpdateResultSchema, debtChangeSchema, type DebtWarning, type DebtRefusal, type DebtRetry, type DebtReadPage, type DebtMutationResult, type DebtUpdateResult, type DebtChange } from "./operation-types.js";
4
5
  import type { WorldRoot } from "../world.js";
5
- export type { WorldRoot } from "../world.js";
6
6
  import { DebtAuthorityCorruptionError, type DebtPriority, type DebtState } from "./document.js";
7
7
  import { type DebtId } from "./identity.js";
8
8
  import { type AddDebtDocumentInput, type AddDebtInput, type UpdateDebtInput } from "./operations.js";
@@ -254,7 +254,7 @@ declare class DebtsHandle {
254
254
  add(input: AddDebtInput): Promise<DebtMutationResult>;
255
255
  addDocument(input: AddDebtDocumentInput): Promise<DebtMutationResult>;
256
256
  list(input?: Readonly<{
257
- selection?: "active" | "closed" | "all";
257
+ selection?: LifecycleSelection;
258
258
  limit?: number;
259
259
  }>): Promise<DebtList>;
260
260
  ready(input?: Readonly<{
@@ -1,4 +1,5 @@
1
1
  import { KeiyakuError } from "../errors.js";
2
+ import { lifecycleSelection } from "../bounded-list.js";
2
3
  import { z } from "zod";
3
4
  import { debtRefSchema, blockedDebtRowSchema, readyDebtRowSchema, debtDoctorIssueSchema, debtSummarySchema, debtDispositionSchema, debtDetailSchema, diagnoseBoard, projectDebtDetail, } from "./board.js";
4
5
  import { debtWarningSchema, debtRefusalSchema, debtRetrySchema, debtReadPageSchema, nonEmptyDebtValues, nonEmptyDebtArraySchema, debtMutationResultSchema, debtMutationNormalResultSchema, debtUpdateResultSchema, debtChangeSchema, } from "./operation-types.js";
@@ -7,7 +8,7 @@ import { debtIdSchema } from "./identity.js";
7
8
  import { addDebt, addDebtDocument, blockedDebts, listDebts, readDebtDetail, readyDebts, updateDebt, } from "./operations.js";
8
9
  import { boundedListLimit } from "../bounded-list.js";
9
10
  import { readBoard } from "./store.js";
10
- import { addDocumentInput, addInput, closed, record, debtId as id, updateInput } from "./input.js";
11
+ import { addDocumentInput, addInput, fields, debtId as id, updateInput } from "./input.js";
11
12
  export const debtAbsentSchema = z.strictObject({ kind: z.literal("absent") }).readonly();
12
13
  export const debtReadResultSchema = z.union([
13
14
  z.strictObject({ kind: z.literal("present"), ...debtDetailSchema.unwrap().shape }).readonly(),
@@ -77,8 +78,7 @@ class DebtsHandle {
77
78
  this.root = world;
78
79
  }
79
80
  debt(input) {
80
- const v = record(input, "debt input");
81
- closed(v, ["id"], "debt input");
81
+ const v = fields(input, ["id"], "debt input");
82
82
  return new DebtHandle(id(v.id), this.world);
83
83
  }
84
84
  add(input) {
@@ -88,28 +88,23 @@ class DebtsHandle {
88
88
  return addDebtDocument(this.world, addDocumentInput(input));
89
89
  }
90
90
  async list(input = {}) {
91
- const v = record(input, "list input");
92
- closed(v, ["selection", "limit"], "list input");
93
- if (v.selection !== undefined && v.selection !== "active" && v.selection !== "closed" && v.selection !== "all")
94
- throw new KeiyakuError("invalid-input", "selection must be active, closed, or all");
91
+ const v = fields(input, ["selection", "limit"], "list input");
92
+ const selection = lifecycleSelection(v.selection);
95
93
  return {
96
- ...(await listDebts(this.world, v.selection ?? "active", boundedListLimit(v.limit))),
94
+ ...(await listDebts(this.world, selection, boundedListLimit(v.limit))),
97
95
  kind: "debt-catalogue",
98
96
  };
99
97
  }
100
98
  async ready(input = {}) {
101
- const v = record(input, "ready input");
102
- closed(v, ["limit"], "ready input");
99
+ const v = fields(input, ["limit"], "ready input");
103
100
  return readyDebts(this.world, boundedListLimit(v.limit));
104
101
  }
105
102
  async blocked(input = {}) {
106
- const v = record(input, "blocked input");
107
- closed(v, ["limit"], "blocked input");
103
+ const v = fields(input, ["limit"], "blocked input");
108
104
  return blockedDebts(this.world, boundedListLimit(v.limit));
109
105
  }
110
106
  async read(input) {
111
- const v = record(input, "read input");
112
- closed(v, ["ids"], "read input");
107
+ const v = fields(input, ["ids"], "read input");
113
108
  if (!Array.isArray(v.ids) || v.ids.length === 0)
114
109
  throw new KeiyakuError("invalid-input", "ids requires at least one DebtId");
115
110
  const ids = v.ids.map(id);
@@ -2,7 +2,8 @@ import { z } from "zod";
2
2
  import { type DebtId } from "./identity.js";
3
3
  import type { AddDebtDocumentInput, AddDebtInput, UpdateDebtInput } from "./operations.js";
4
4
  export declare function record(value: unknown, label: string): Record<string, unknown>;
5
- export declare function closed(value: Record<string, unknown>, allowed: readonly string[], label: string): void;
5
+ /** One closed caller object: an object with only the fields its surface names. */
6
+ export declare function fields(value: unknown, allowed: readonly string[], label: string): Record<string, unknown>;
6
7
  export declare function debtId(value: unknown): DebtId;
7
8
  export declare function signal(value: unknown): AbortSignal | undefined;
8
9
  export declare function text(value: unknown, label: string): string | undefined;
@@ -8,11 +8,14 @@ export function record(value, label) {
8
8
  }
9
9
  return value;
10
10
  }
11
- export function closed(value, allowed, label) {
12
- for (const key of Object.keys(value)) {
11
+ /** One closed caller object: an object with only the fields its surface names. */
12
+ export function fields(value, allowed, label) {
13
+ const recordValue = record(value, label);
14
+ for (const key of Object.keys(recordValue)) {
13
15
  if (!allowed.includes(key))
14
16
  throw new KeiyakuError("invalid-input", `${label} has unknown field: ${key}`);
15
17
  }
18
+ return recordValue;
16
19
  }
17
20
  export function debtId(value) {
18
21
  if (typeof value !== "string")
@@ -74,8 +77,7 @@ export function addInput(input) {
74
77
  return parseDebtInput(addDebtInputSchema.extend({ signal: signalSchema }), input);
75
78
  }
76
79
  export function addDocumentInput(input) {
77
- const v = record(input, "addDocument input");
78
- closed(v, ["markdown", "signal"], "addDocument input");
80
+ const v = fields(input, ["markdown", "signal"], "addDocument input");
79
81
  const markdown = text(v.markdown, "markdown");
80
82
  if (markdown === undefined)
81
83
  throw new KeiyakuError("invalid-input", "markdown is required");
@@ -1,6 +1,7 @@
1
1
  import { type BlockedDebtRow, type DebtDetail, type DebtSummary, type ReadyDebtRow } from "./board.js";
2
2
  import { type DebtId } from "./identity.js";
3
3
  import type { WorldRoot } from "../world.js";
4
+ import { type LifecycleSelection } from "../bounded-list.js";
4
5
  export type { AddDebtDocumentInput, AddDebtInput, DebtMutationResult, DebtReadPage, DebtRefusal, DebtRetry, DebtUpdateResult, SettledDebtResult, UpdateDebtInput, } from "./operation-types.js";
5
6
  import type { AddDebtDocumentInput, AddDebtInput, DebtMutationResult, DebtReadPage, DebtUpdateResult, UpdateDebtInput } from "./operation-types.js";
6
7
  export declare function nukeDebt(world: WorldRoot, options?: Readonly<{
@@ -11,7 +12,7 @@ export declare function addDebt(world: WorldRoot, input: AddDebtInput): Promise<
11
12
  export declare function addDebtDocument(world: WorldRoot, input: AddDebtDocumentInput): Promise<DebtMutationResult>;
12
13
  export declare function updateDebt(world: WorldRoot, id: DebtId, input: UpdateDebtInput): Promise<DebtUpdateResult>;
13
14
  export { settleDebt } from "./lifecycle-operations.js";
14
- export declare function listDebts(world: WorldRoot, selection: "active" | "closed" | "all", limit?: number): Promise<Extract<DebtReadPage<DebtSummary>, {
15
+ export declare function listDebts(world: WorldRoot, selection: LifecycleSelection, limit?: number): Promise<Extract<DebtReadPage<DebtSummary>, {
15
16
  kind: "present";
16
17
  }>>;
17
18
  export declare function readDebtDetail(world: WorldRoot, id: DebtId): Promise<DebtDetail | null>;
@@ -1,26 +1,9 @@
1
- import { z } from "zod";
2
1
  import { type ContractId } from "../core/facts/types.js";
3
2
  import { type AkumaId } from "../akuma/identity.js";
4
3
  import { type PrivateStateSeatCloseLag } from "../git/private-state-seat.js";
5
4
  import type { GitRepository } from "../git/process.js";
6
5
  import { type GitReadObservation } from "../git/read-observation.js";
7
6
  import { type DispatchAssociation } from "../akuma/dispatch-association.js";
8
- export declare const dispatchSchema: z.ZodReadonly<z.ZodObject<{
9
- akumaId: z.ZodPipe<z.ZodString, z.ZodTransform<AkumaId, string>>;
10
- contractId: z.ZodPipe<z.ZodString, z.ZodTransform<ContractId, string>>;
11
- dispatchedAt: z.ZodString;
12
- }, z.core.$strict>>;
13
- export declare const dispatchFailureSchema: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
14
- kind: z.ZodLiteral<"conflict">;
15
- current: z.ZodReadonly<z.ZodObject<{
16
- akumaId: z.ZodPipe<z.ZodString, z.ZodTransform<AkumaId, string>>;
17
- contractId: z.ZodPipe<z.ZodString, z.ZodTransform<ContractId, string>>;
18
- dispatchedAt: z.ZodString;
19
- }, z.core.$strict>>;
20
- }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
21
- kind: z.ZodLiteral<"publication-failed">;
22
- diagnostic: z.ZodString;
23
- }, z.core.$strict>>]>;
24
7
  export type Dispatch = Readonly<{
25
8
  akumaId: AkumaId;
26
9
  contractId: ContractId;