@astrosheep/keiyaku 4.5.7 → 4.5.8

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 (234) hide show
  1. package/README.md +10 -0
  2. package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +1 -1
  3. package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +1 -1
  4. package/build/integrations/marketplace/plugins/keiyaku/opencode.js +3 -2
  5. package/build/integrations/marketplace/plugins/keiyaku/package.json +1 -1
  6. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +10 -9
  7. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +22 -1
  8. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-babysit/SKILL.md +35 -96
  9. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +28 -49
  10. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +21 -15
  11. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +148 -89
  12. package/build/src/akuma/abort.d.ts +2 -1
  13. package/build/src/akuma/abort.js +6 -23
  14. package/build/src/akuma/akuma-handle.js +4 -2
  15. package/build/src/akuma/akuma-observe.d.ts +2 -0
  16. package/build/src/akuma/akuma-observe.js +1 -0
  17. package/build/src/akuma/akuma-product.js +9 -7
  18. package/build/src/akuma/akuma.d.ts +372 -9
  19. package/build/src/akuma/akuma.js +31 -1
  20. package/build/src/akuma/allowed.d.ts +1 -1
  21. package/build/src/akuma/allowed.js +1 -0
  22. package/build/src/akuma/body.d.ts +6 -4
  23. package/build/src/akuma/body.js +5 -3
  24. package/build/src/akuma/call-request.d.ts +80 -0
  25. package/build/src/akuma/call-request.js +211 -0
  26. package/build/src/akuma/heart/facts.d.ts +6 -78
  27. package/build/src/akuma/heart/index.d.ts +1 -1
  28. package/build/src/akuma/heart/request-authority.d.ts +5 -4
  29. package/build/src/akuma/heart/request-authority.js +20 -34
  30. package/build/src/akuma/heart/request-rows.js +12 -23
  31. package/build/src/akuma/heart/schema.d.ts +1 -1
  32. package/build/src/akuma/heart/schema.js +5 -13
  33. package/build/src/akuma/index.d.ts +1 -1
  34. package/build/src/akuma/index.js +1 -1
  35. package/build/src/akuma/projection-read.d.ts +1 -0
  36. package/build/src/akuma/projection-read.js +8 -1
  37. package/build/src/akuma/projection.d.ts +856 -137
  38. package/build/src/akuma/projection.js +190 -0
  39. package/build/src/akuma/provider.d.ts +30 -3
  40. package/build/src/akuma/provider.js +104 -0
  41. package/build/src/akuma/providers/acp/core.d.ts +2 -2
  42. package/build/src/akuma/providers/acp/core.js +13 -6
  43. package/build/src/akuma/providers/acp/index.js +5 -4
  44. package/build/src/akuma/providers/claude/index.d.ts +3 -3
  45. package/build/src/akuma/providers/claude/index.js +16 -5
  46. package/build/src/akuma/providers/codex-app-server/events.js +1 -1
  47. package/build/src/akuma/providers/codex-app-server/index.js +18 -6
  48. package/build/src/akuma/providers/grok-build/index.js +5 -4
  49. package/build/src/akuma/providers/opencode-sdk/index.js +66 -25
  50. package/build/src/akuma/providers/opencode-sdk/session.d.ts +3 -2
  51. package/build/src/akuma/providers/opencode-sdk/session.js +28 -11
  52. package/build/src/akuma/providers/pi/index.js +42 -14
  53. package/build/src/akuma/request-lifecycle.d.ts +3 -9
  54. package/build/src/akuma/request-lifecycle.js +4 -4
  55. package/build/src/akuma/request-rendezvous.d.ts +26 -0
  56. package/build/src/akuma/request-rendezvous.js +100 -0
  57. package/build/src/akuma/request-serve.d.ts +5 -65
  58. package/build/src/akuma/request-serve.js +81 -208
  59. package/build/src/akuma/request-wire.d.ts +109 -115
  60. package/build/src/akuma/request-wire.js +63 -318
  61. package/build/src/akuma/requests.d.ts +19 -47
  62. package/build/src/akuma/requests.js +51 -107
  63. package/build/src/akuma/turn-drive.d.ts +5 -3
  64. package/build/src/akuma/turn-drive.js +32 -10
  65. package/build/src/akuma-body.d.ts +7 -2
  66. package/build/src/akuma-body.js +68 -46
  67. package/build/src/cli/accepted.d.ts +1 -1
  68. package/build/src/cli/accepted.js +2 -2
  69. package/build/src/cli/commands/akuma-invoke.d.ts +2 -0
  70. package/build/src/cli/commands/akuma-invoke.js +17 -9
  71. package/build/src/cli/commands/akuma.js +7 -7
  72. package/build/src/cli/commands/contract-invoke.d.ts +3 -2
  73. package/build/src/cli/commands/contract-invoke.js +26 -19
  74. package/build/src/cli/commands/contract.d.ts +13 -13
  75. package/build/src/cli/commands/contract.js +32 -17
  76. package/build/src/cli/commands/install.d.ts +1 -1
  77. package/build/src/cli/commands/install.js +1 -1
  78. package/build/src/cli/commands/task-invoke.d.ts +3 -0
  79. package/build/src/cli/commands/task-invoke.js +23 -140
  80. package/build/src/cli/commands/task.js +54 -20
  81. package/build/src/cli/invoke.js +39 -25
  82. package/build/src/cli/main.js +2 -1
  83. package/build/src/cli/parse.d.ts +2 -2
  84. package/build/src/cli/parse.js +37 -22
  85. package/build/src/cli/render/akuma-activity.d.ts +4 -1
  86. package/build/src/cli/render/akuma-activity.js +45 -30
  87. package/build/src/cli/render/akuma-tool.d.ts +5 -1
  88. package/build/src/cli/render/akuma.js +5 -9
  89. package/build/src/cli/render/audit.js +1 -1
  90. package/build/src/cli/render/catalog.js +80 -21
  91. package/build/src/cli/render/contract-observation.d.ts +2 -0
  92. package/build/src/cli/render/contract-observation.js +11 -0
  93. package/build/src/cli/render/contract.js +25 -65
  94. package/build/src/cli/render/kanshi-akuma.d.ts +8 -0
  95. package/build/src/cli/render/kanshi-akuma.js +111 -0
  96. package/build/src/cli/render/kanshi.js +108 -213
  97. package/build/src/cli/render/receipt.d.ts +1 -2
  98. package/build/src/cli/render/receipt.js +76 -26
  99. package/build/src/cli/render/refusal.js +2 -10
  100. package/build/src/cli/render/region.js +5 -2
  101. package/build/src/cli/render/settings.d.ts +1 -1
  102. package/build/src/cli/render/settings.js +27 -8
  103. package/build/src/cli/render/task.js +22 -5
  104. package/build/src/cli/render/terminal.d.ts +28 -0
  105. package/build/src/cli/render/terminal.js +65 -0
  106. package/build/src/cli/result.d.ts +3 -3
  107. package/build/src/cli/runtime.js +3 -1
  108. package/build/src/cli/selectors.d.ts +2 -1
  109. package/build/src/cli/selectors.js +4 -3
  110. package/build/src/cli/square-edge.js +120 -36
  111. package/build/src/cli/usage.js +2 -1
  112. package/build/src/contract-guidance.d.ts +5 -0
  113. package/build/src/contract-guidance.js +121 -0
  114. package/build/src/contract-worktree.d.ts +0 -1
  115. package/build/src/contract-worktree.js +32 -83
  116. package/build/src/coordination/sqlite-transaction-lock.d.ts +1 -0
  117. package/build/src/coordination/sqlite-transaction-lock.js +5 -0
  118. package/build/src/core/facts/codec.d.ts +2 -0
  119. package/build/src/core/facts/codec.js +4 -0
  120. package/build/src/core/verbs/placement.d.ts +6 -1
  121. package/build/src/core/verbs/placement.js +5 -3
  122. package/build/src/dispatch/index.d.ts +0 -2
  123. package/build/src/dispatch/index.js +54 -55
  124. package/build/src/git/admission.js +2 -2
  125. package/build/src/git/hooks.d.ts +9 -15
  126. package/build/src/git/hooks.js +23 -317
  127. package/build/src/git/nuke.d.ts +2 -1
  128. package/build/src/git/nuke.js +36 -18
  129. package/build/src/git/private-state-seat.d.ts +12 -0
  130. package/build/src/git/private-state-seat.js +39 -0
  131. package/build/src/git/process.d.ts +6 -0
  132. package/build/src/git/process.js +19 -7
  133. package/build/src/git/read-observation.js +29 -20
  134. package/build/src/git/reconcile.d.ts +11 -0
  135. package/build/src/git/reconcile.js +64 -11
  136. package/build/src/git/repository.d.ts +6 -2
  137. package/build/src/git/repository.js +8 -0
  138. package/build/src/git/target-placement.d.ts +1 -0
  139. package/build/src/git/target-placement.js +5 -0
  140. package/build/src/git/tender.d.ts +1 -0
  141. package/build/src/git/terminal-reconcile.d.ts +1 -1
  142. package/build/src/git/terminal-reconcile.js +22 -20
  143. package/build/src/git/workspace.d.ts +14 -0
  144. package/build/src/git/workspace.js +44 -0
  145. package/build/src/kanshi/index.d.ts +1 -1
  146. package/build/src/kanshi/read.js +16 -16
  147. package/build/src/kanshi/report.d.ts +2 -2
  148. package/build/src/library/address.d.ts +9 -3
  149. package/build/src/library/address.js +3 -2
  150. package/build/src/library/akuma-creation.d.ts +4 -3
  151. package/build/src/library/akuma-creation.js +19 -13
  152. package/build/src/library/audit.d.ts +1 -1
  153. package/build/src/library/audit.js +5 -3
  154. package/build/src/library/catalog.d.ts +3 -1
  155. package/build/src/library/catalog.js +20 -6
  156. package/build/src/library/composition.d.ts +371 -0
  157. package/build/src/library/composition.js +28 -0
  158. package/build/src/library/configuration.js +8 -2
  159. package/build/src/library/continuation.js +66 -30
  160. package/build/src/library/contract-bind.js +10 -2
  161. package/build/src/library/contract-forwarding-reconciliation-result.d.ts +96 -0
  162. package/build/src/library/contract-forwarding-reconciliation-result.js +83 -0
  163. package/build/src/library/contract-forwarding-result.d.ts +6723 -0
  164. package/build/src/library/contract-forwarding-result.js +521 -0
  165. package/build/src/library/contract-forwarding.d.ts +72 -0
  166. package/build/src/library/contract-forwarding.js +125 -0
  167. package/build/src/library/contract-handle.d.ts +36 -0
  168. package/build/src/library/contract-handle.js +313 -0
  169. package/build/src/library/contract-operations.d.ts +1044 -67
  170. package/build/src/library/contract-operations.js +190 -118
  171. package/build/src/library/contract.d.ts +11 -32
  172. package/build/src/library/contract.js +16 -289
  173. package/build/src/library/fleet-result.d.ts +1454 -0
  174. package/build/src/library/fleet-result.js +96 -0
  175. package/build/src/library/fleet.d.ts +112 -54
  176. package/build/src/library/fleet.js +211 -71
  177. package/build/src/library/input.d.ts +2 -0
  178. package/build/src/library/input.js +4 -0
  179. package/build/src/library/keiyaku.d.ts +371 -20
  180. package/build/src/library/keiyaku.js +8 -21
  181. package/build/src/library/mutation.d.ts +3 -3
  182. package/build/src/library/mutation.js +5 -9
  183. package/build/src/library/nuke.d.ts +1 -1
  184. package/build/src/library/nuke.js +4 -3
  185. package/build/src/library/reconcile.d.ts +4 -0
  186. package/build/src/library/reconcile.js +2 -0
  187. package/build/src/library/refusal.d.ts +0 -9
  188. package/build/src/library/refusal.js +0 -7
  189. package/build/src/protocol/amend.js +56 -50
  190. package/build/src/protocol/attempt.d.ts +2 -0
  191. package/build/src/protocol/attempt.js +8 -1
  192. package/build/src/protocol/completion.js +7 -0
  193. package/build/src/protocol/deliver.js +6 -2
  194. package/build/src/protocol/operations.d.ts +4 -1
  195. package/build/src/protocol/operations.js +5 -2
  196. package/build/src/protocol/placement.d.ts +1 -0
  197. package/build/src/protocol/placement.js +52 -38
  198. package/build/src/protocol/read/observation.d.ts +1 -4
  199. package/build/src/protocol/read/observation.js +2 -15
  200. package/build/src/protocol/reintegrate.js +62 -58
  201. package/build/src/protocol/review.js +5 -0
  202. package/build/src/protocol/run.js +17 -13
  203. package/build/src/runtime/proc/run.d.ts +8 -0
  204. package/build/src/runtime/proc/run.js +27 -0
  205. package/build/src/runtime/proc/termination.js +26 -22
  206. package/build/src/runtime/proc/windows-launch.exe +0 -0
  207. package/build/src/settlement/holder.d.ts +2 -1
  208. package/build/src/settlement/holder.js +15 -4
  209. package/build/src/settlement/settle.js +99 -33
  210. package/build/src/task/board.d.ts +68 -27
  211. package/build/src/task/board.js +31 -1
  212. package/build/src/task/catalog.d.ts +4 -0
  213. package/build/src/task/catalog.js +23 -0
  214. package/build/src/task/compose-language.js +33 -7
  215. package/build/src/task/compose-parser.d.ts +1 -1
  216. package/build/src/task/compose-parser.js +1 -1
  217. package/build/src/task/compose.js +2 -0
  218. package/build/src/task/index.d.ts +12 -4
  219. package/build/src/task/index.js +97 -16
  220. package/build/src/task/mutation-result.d.ts +923 -0
  221. package/build/src/task/mutation-result.js +140 -0
  222. package/build/src/task/mutation.d.ts +552 -28
  223. package/build/src/task/mutation.js +304 -97
  224. package/build/src/task/operations.d.ts +1 -4
  225. package/build/src/task/operations.js +0 -6
  226. package/build/src/task/public.d.ts +2 -0
  227. package/build/src/task/public.js +1 -0
  228. package/build/src/workspace-place.d.ts +7 -2
  229. package/build/src/workspace-place.js +34 -24
  230. package/build/src/world.d.ts +1 -0
  231. package/build/src/world.js +11 -0
  232. package/package.json +8 -6
  233. package/build/src/akuma/request-execution.d.ts +0 -8
  234. package/build/src/akuma/request-execution.js +0 -98
@@ -73,9 +73,11 @@ function command(value, coordinate, ErrorType) {
73
73
  if (!record(value))
74
74
  throw new ErrorType(`${coordinate} must be an object`);
75
75
  for (const key of Object.keys(value)) {
76
- if (key !== "argv" && key !== "timeoutMs")
76
+ if (key !== "name" && key !== "argv" && key !== "timeoutMs")
77
77
  throw new ErrorType(`${coordinate} has unknown field: ${key}`);
78
78
  }
79
+ if (typeof value.name !== "string" || value.name.trim().length === 0)
80
+ throw new ErrorType(`${coordinate}.name must be nonblank`);
79
81
  if (!Array.isArray(value.argv) || value.argv.length === 0 || !value.argv.every((item) => typeof item === "string")) {
80
82
  throw new ErrorType(`${coordinate}.argv must be a nonempty string array`);
81
83
  }
@@ -86,7 +88,11 @@ function command(value, coordinate, ErrorType) {
86
88
  value.timeoutMs > 2_147_483_647) {
87
89
  throw new ErrorType(`${coordinate}.timeoutMs must be an integer from 1 through 2147483647`);
88
90
  }
89
- return Object.freeze({ argv: Object.freeze([...value.argv]), timeoutMs: value.timeoutMs });
91
+ return Object.freeze({
92
+ name: value.name.trim(),
93
+ argv: Object.freeze([...value.argv]),
94
+ timeoutMs: value.timeoutMs,
95
+ });
90
96
  }
91
97
  function commands(value, coordinate, ErrorType) {
92
98
  if (!Array.isArray(value))
@@ -1,6 +1,9 @@
1
1
  import { observeActiveContractWorld } from "../git/observe.js";
2
2
  import { withGitReadObservation } from "../git/read-observation.js";
3
+ import { reconcileDependentWorktree } from "../git/reconcile.js";
4
+ import { worktreePath } from "../git/workspace.js";
3
5
  import { continueDeliveryOperation } from "../protocol/deliver.js";
6
+ import { appointmentFor, readPlaceRegister } from "../workspace-place.js";
4
7
  function reverseDependents(world) {
5
8
  const index = new Map();
6
9
  for (const record of world.contracts.values()) {
@@ -27,48 +30,81 @@ function appendAccepted(primary, child) {
27
30
  ...(effects.length === 0 && lag.length === 0 ? {} : { physical: { effects, lag } }),
28
31
  };
29
32
  }
33
+ function appendPhysical(primary, physical) {
34
+ const effects = [...(primary.physical?.effects ?? []), ...physical.effects];
35
+ const lag = [...(primary.physical?.lag ?? []), ...physical.lag];
36
+ return {
37
+ ...primary,
38
+ ...(effects.length === 0 && lag.length === 0 ? {} : { physical: { effects, lag } }),
39
+ };
40
+ }
41
+ // The bounded dependency walk keeps selection, physical follow, and child admission together.
42
+ // eslint-disable-next-line max-lines-per-function
30
43
  export async function continueDeliveredDependents(input) {
31
44
  const world = await withGitReadObservation(input.scope, input.channel, async (observation) => await observeActiveContractWorld(observation));
32
45
  const dependents = reverseDependents(world);
33
- const pending = [input.contractId];
46
+ const places = await readPlaceRegister(input.scope);
47
+ const initialTarget = typeof input.accepted.value === "object" && input.accepted.value !== null && "completion" in input.accepted.value
48
+ ? (input.accepted.value
49
+ .completion?.integration ?? undefined)
50
+ : undefined;
51
+ const pending = [{ contractId: input.contractId, target: initialTarget }];
34
52
  const attempted = new Set();
35
- const newlyClaimed = new Set(pending);
53
+ const newlyClaimed = new Set([input.contractId]);
36
54
  const claimed = [];
37
55
  const stopped = [];
38
56
  let accepted = input.accepted;
57
+ const process = async (candidate, predecessorTarget) => {
58
+ const contractId = candidate.state.id;
59
+ if (!candidate.state.terms.after.every((dependency) => newlyClaimed.has(dependency) || world.eligibility.get(dependency)?.terminal?.kind === "claimed")) {
60
+ return { accepted, outcome: "skip" };
61
+ }
62
+ attempted.add(contractId);
63
+ if (predecessorTarget !== undefined && candidate.state.coordinates.workspace === "worktree") {
64
+ const appointment = appointmentFor(places, contractId);
65
+ if (appointment !== undefined) {
66
+ const reconciled = await reconcileDependentWorktree(input.scope, contractId, worktreePath(input.scope, appointment.place), predecessorTarget);
67
+ accepted = appendPhysical(accepted, reconciled);
68
+ if (reconciled.lag.length > 0)
69
+ return { accepted, outcome: "stopped" };
70
+ }
71
+ }
72
+ const child = await continueDeliveryOperation({
73
+ scope: input.scope,
74
+ channel: input.channel,
75
+ state: candidate.state,
76
+ journal: candidate.journal,
77
+ deriveDocument: input.deriveDocument,
78
+ ...(input.actor === undefined ? {} : { actor: input.actor }),
79
+ ...(input.signal === undefined ? {} : { signal: input.signal }),
80
+ });
81
+ accepted = appendAccepted(accepted, child.admission);
82
+ if (child.evidence.completion !== undefined) {
83
+ newlyClaimed.add(contractId);
84
+ pending.push({ contractId, target: child.evidence.completion.integration });
85
+ return { accepted, outcome: "claimed" };
86
+ }
87
+ const stop = child.evidence.placement;
88
+ if (stop === undefined)
89
+ throw new Error("incomplete continuation is missing its placement stop");
90
+ return {
91
+ accepted,
92
+ outcome: "stopped",
93
+ stop: "refusal" in stop && stop.refusal.kind === "terminal" ? { kind: "already-terminal" } : stop,
94
+ };
95
+ };
39
96
  while (pending.length > 0) {
40
97
  const parent = pending.shift();
41
- for (const candidate of dependents.get(parent) ?? []) {
98
+ for (const candidate of dependents.get(parent.contractId) ?? []) {
42
99
  const contractId = candidate.state.id;
43
- if (attempted.has(contractId) ||
44
- !candidate.state.terms.after.every((dependency) => newlyClaimed.has(dependency) || world.eligibility.get(dependency)?.terminal?.kind === "claimed"))
100
+ if (attempted.has(contractId))
45
101
  continue;
46
- attempted.add(contractId);
47
- const child = await continueDeliveryOperation({
48
- scope: input.scope,
49
- channel: input.channel,
50
- state: candidate.state,
51
- journal: candidate.journal,
52
- deriveDocument: input.deriveDocument,
53
- ...(input.actor === undefined ? {} : { actor: input.actor }),
54
- ...(input.signal === undefined ? {} : { signal: input.signal }),
55
- });
56
- accepted = appendAccepted(accepted, child.admission);
57
- if (child.evidence.completion !== undefined) {
102
+ const result = await process(candidate, parent.target);
103
+ accepted = result.accepted;
104
+ if (result.outcome === "claimed")
58
105
  claimed.push(contractId);
59
- newlyClaimed.add(contractId);
60
- pending.push(contractId);
61
- continue;
62
- }
63
- const stop = child.evidence.placement;
64
- if (stop === undefined)
65
- throw new Error("incomplete continuation is missing its placement stop");
66
- if ("refusal" in stop && stop.refusal.kind === "terminal") {
67
- stopped.push({ contractId, stop: { kind: "already-terminal" } });
68
- }
69
- else {
70
- stopped.push({ contractId, stop });
71
- }
106
+ if (result.outcome === "stopped" && result.stop !== undefined)
107
+ stopped.push({ contractId, stop: result.stop });
72
108
  }
73
109
  }
74
110
  return {
@@ -9,8 +9,16 @@ import { observeRegion } from "./region.js";
9
9
  import { scopeForRepo } from "./repo.js";
10
10
  import { worktreeHooksOption } from "./configuration.js";
11
11
  function acceptedBindResult(result, region) {
12
- const { facts, head, effects, lags, settlement } = result;
13
- return { facts, head, keiyaku: result.value, effects, lags, settlement, ...region };
12
+ const { facts, head, lags, settlementLags, recoverySnapshot } = result;
13
+ return {
14
+ facts,
15
+ head,
16
+ keiyaku: result.value,
17
+ lags,
18
+ settlementLags,
19
+ ...(recoverySnapshot === undefined ? {} : { recoverySnapshot }),
20
+ ...region,
21
+ };
14
22
  }
15
23
  export async function bindKeiyaku(input, createHandle) {
16
24
  const values = requireInput(input, "Keiyaku.bind input");
@@ -0,0 +1,96 @@
1
+ import { z } from "zod";
2
+ export declare const reconciliationLagSchema: z.ZodUnion<readonly [z.ZodObject<{
3
+ kind: z.ZodLiteral<"worktree-retained">;
4
+ path: z.ZodString;
5
+ }, z.core.$strict>, z.ZodPipe<z.ZodObject<{
6
+ kind: z.ZodLiteral<"worktree-follow-retained">;
7
+ path: z.ZodString;
8
+ tender: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
9
+ head: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
10
+ reason: z.ZodEnum<{
11
+ "head-moved": "head-moved";
12
+ "head-attached": "head-attached";
13
+ "operation-in-progress": "operation-in-progress";
14
+ "unsupported-parent-shape": "unsupported-parent-shape";
15
+ }>;
16
+ paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
17
+ }, z.core.$strict>, z.ZodTransform<{
18
+ kind: "worktree-follow-retained";
19
+ path: string;
20
+ tender: import("../core/facts/types.js").SnapshotId;
21
+ head: import("../core/facts/types.js").SnapshotId;
22
+ reason: "head-moved" | "head-attached" | "operation-in-progress" | "unsupported-parent-shape";
23
+ } | {
24
+ paths: string[];
25
+ kind: "worktree-follow-retained";
26
+ path: string;
27
+ tender: import("../core/facts/types.js").SnapshotId;
28
+ head: import("../core/facts/types.js").SnapshotId;
29
+ reason: "head-moved" | "head-attached" | "operation-in-progress" | "unsupported-parent-shape";
30
+ }, {
31
+ kind: "worktree-follow-retained";
32
+ path: string;
33
+ tender: import("../core/facts/types.js").SnapshotId;
34
+ head: import("../core/facts/types.js").SnapshotId;
35
+ reason: "head-moved" | "head-attached" | "operation-in-progress" | "unsupported-parent-shape";
36
+ paths?: string[] | undefined;
37
+ }>>, z.ZodPipe<z.ZodObject<{
38
+ kind: z.ZodLiteral<"unsealed-bytes">;
39
+ path: z.ZodString;
40
+ paths: z.ZodArray<z.ZodString>;
41
+ head: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>>;
42
+ }, z.core.$strict>, z.ZodTransform<{
43
+ kind: "unsealed-bytes";
44
+ path: string;
45
+ paths: string[];
46
+ } | {
47
+ head: import("../core/facts/types.js").SnapshotId;
48
+ kind: "unsealed-bytes";
49
+ path: string;
50
+ paths: string[];
51
+ }, {
52
+ kind: "unsealed-bytes";
53
+ path: string;
54
+ paths: string[];
55
+ head?: import("../core/facts/types.js").SnapshotId | undefined;
56
+ }>>, z.ZodObject<{
57
+ kind: z.ZodLiteral<"target-checkout-retained">;
58
+ path: z.ZodString;
59
+ target: z.ZodString;
60
+ diagnostic: z.ZodString;
61
+ }, z.core.$strict>, z.ZodObject<{
62
+ kind: z.ZodLiteral<"reconcile-failed">;
63
+ stage: z.ZodEnum<{
64
+ observation: "observation";
65
+ effect: "effect";
66
+ }>;
67
+ diagnostic: z.ZodString;
68
+ }, z.core.$strict>, z.ZodObject<{
69
+ kind: z.ZodLiteral<"worktree-hook-failed">;
70
+ phase: z.ZodEnum<{
71
+ destroy: "destroy";
72
+ create: "create";
73
+ }>;
74
+ path: z.ZodString;
75
+ command: z.ZodNumber;
76
+ name: z.ZodString;
77
+ failure: z.ZodUnion<readonly [z.ZodObject<{
78
+ kind: z.ZodLiteral<"exit">;
79
+ code: z.ZodNumber;
80
+ stdout: z.ZodString;
81
+ stderr: z.ZodString;
82
+ truncated: z.ZodBoolean;
83
+ }, z.core.$strict>, z.ZodObject<{
84
+ kind: z.ZodLiteral<"timeout">;
85
+ }, z.core.$strict>, z.ZodObject<{
86
+ kind: z.ZodLiteral<"spawn-error">;
87
+ diagnostic: z.ZodString;
88
+ }, z.core.$strict>, z.ZodObject<{
89
+ kind: z.ZodLiteral<"unknown-exit">;
90
+ }, z.core.$strict>]>;
91
+ }, z.core.$strict>, z.ZodObject<{
92
+ kind: z.ZodLiteral<"contract-file-failed">;
93
+ worktree: z.ZodString;
94
+ path: z.ZodString;
95
+ diagnostic: z.ZodString;
96
+ }, z.core.$strict>]>;
@@ -0,0 +1,83 @@
1
+ import { snapshotId } from "../core/facts/types.js";
2
+ import { z } from "zod";
3
+ function canonicalSnapshot(value, context) {
4
+ try {
5
+ return snapshotId(value);
6
+ }
7
+ catch {
8
+ context.addIssue({ code: "custom", message: "expected SnapshotId" });
9
+ return z.NEVER;
10
+ }
11
+ }
12
+ const nonblankStringSchema = z.string().refine((value) => value.trim() !== "");
13
+ const snapshotIdSchema = z.string().transform(canonicalSnapshot);
14
+ const hookFailureSchema = z.union([
15
+ z
16
+ .object({
17
+ kind: z.literal("exit"),
18
+ code: z.number().int(),
19
+ stdout: z.string(),
20
+ stderr: z.string(),
21
+ truncated: z.boolean(),
22
+ })
23
+ .strict(),
24
+ z.object({ kind: z.literal("timeout") }).strict(),
25
+ z.object({ kind: z.literal("spawn-error"), diagnostic: z.string() }).strict(),
26
+ z.object({ kind: z.literal("unknown-exit") }).strict(),
27
+ ]);
28
+ export const reconciliationLagSchema = z.union([
29
+ z.object({ kind: z.literal("worktree-retained"), path: nonblankStringSchema }).strict(),
30
+ z
31
+ .object({
32
+ kind: z.literal("worktree-follow-retained"),
33
+ path: nonblankStringSchema,
34
+ tender: snapshotIdSchema,
35
+ head: snapshotIdSchema,
36
+ reason: z.enum(["head-moved", "head-attached", "operation-in-progress", "unsupported-parent-shape"]),
37
+ paths: z.array(nonblankStringSchema).optional(),
38
+ })
39
+ .strict()
40
+ .transform(({ paths, ...lag }) => (paths === undefined ? lag : { ...lag, paths })),
41
+ z
42
+ .object({
43
+ kind: z.literal("unsealed-bytes"),
44
+ path: nonblankStringSchema,
45
+ paths: z.array(nonblankStringSchema),
46
+ head: snapshotIdSchema.optional(),
47
+ })
48
+ .strict()
49
+ .transform(({ head, ...lag }) => (head === undefined ? lag : { ...lag, head })),
50
+ z
51
+ .object({
52
+ kind: z.literal("target-checkout-retained"),
53
+ path: nonblankStringSchema,
54
+ target: nonblankStringSchema,
55
+ diagnostic: nonblankStringSchema,
56
+ })
57
+ .strict(),
58
+ z
59
+ .object({
60
+ kind: z.literal("reconcile-failed"),
61
+ stage: z.enum(["observation", "effect"]),
62
+ diagnostic: nonblankStringSchema,
63
+ })
64
+ .strict(),
65
+ z
66
+ .object({
67
+ kind: z.literal("worktree-hook-failed"),
68
+ phase: z.enum(["create", "destroy"]),
69
+ path: nonblankStringSchema,
70
+ command: z.number().int().nonnegative(),
71
+ name: nonblankStringSchema,
72
+ failure: hookFailureSchema,
73
+ })
74
+ .strict(),
75
+ z
76
+ .object({
77
+ kind: z.literal("contract-file-failed"),
78
+ worktree: nonblankStringSchema,
79
+ path: nonblankStringSchema,
80
+ diagnostic: nonblankStringSchema,
81
+ })
82
+ .strict(),
83
+ ]);