@astrosheep/keiyaku 4.5.11 → 4.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +135 -377
  2. package/build/integrations/pi/keiyaku.ts +11 -116
  3. package/build/src/akuma/akuma-errors.d.ts +1 -0
  4. package/build/src/akuma/akuma-errors.js +1 -0
  5. package/build/src/akuma/akuma-handle.d.ts +1 -0
  6. package/build/src/akuma/akuma-handle.js +6 -7
  7. package/build/src/akuma/akuma-product.d.ts +6 -8
  8. package/build/src/akuma/akuma-product.js +141 -57
  9. package/build/src/akuma/akuma.d.ts +5 -7
  10. package/build/src/akuma/akuma.js +1 -22
  11. package/build/src/akuma/archetype.d.ts +6 -5
  12. package/build/src/akuma/archetype.js +137 -38
  13. package/build/src/akuma/body.d.ts +5 -5
  14. package/build/src/akuma/body.js +223 -63
  15. package/build/src/akuma/call-input.d.ts +4 -0
  16. package/build/src/akuma/call-input.js +21 -0
  17. package/build/src/akuma/call-request.d.ts +5 -8
  18. package/build/src/akuma/call-request.js +28 -73
  19. package/build/src/akuma/fleet-execution.d.ts +26 -0
  20. package/build/src/akuma/fleet-execution.js +109 -0
  21. package/build/src/{library/fleet-result.d.ts → akuma/fleet-observation.d.ts} +13 -57
  22. package/build/src/{library/fleet-result.js → akuma/fleet-observation.js} +4 -25
  23. package/build/src/akuma/fleet-request.d.ts +122 -0
  24. package/build/src/akuma/fleet-request.js +168 -0
  25. package/build/src/akuma/heart/facts.d.ts +23 -0
  26. package/build/src/akuma/heart/facts.js +7 -0
  27. package/build/src/akuma/heart/index.d.ts +43 -4
  28. package/build/src/akuma/heart/index.js +107 -7
  29. package/build/src/akuma/heart/request-authority.d.ts +2 -0
  30. package/build/src/akuma/heart/request-authority.js +28 -3
  31. package/build/src/akuma/heart/request-rows.d.ts +2 -0
  32. package/build/src/akuma/heart/request-rows.js +24 -5
  33. package/build/src/akuma/heart/rows.d.ts +4 -1
  34. package/build/src/akuma/heart/rows.js +46 -19
  35. package/build/src/akuma/heart/schema.d.ts +1 -1
  36. package/build/src/akuma/heart/schema.js +28 -6
  37. package/build/src/akuma/heart/storage.d.ts +1 -1
  38. package/build/src/akuma/heart/tells.d.ts +29 -0
  39. package/build/src/akuma/heart/tells.js +136 -5
  40. package/build/src/akuma/heart/timeline.js +9 -3
  41. package/build/src/akuma/projection-read.js +36 -3
  42. package/build/src/akuma/projection.js +3 -4
  43. package/build/src/akuma/provider.d.ts +4 -0
  44. package/build/src/akuma/provider.js +56 -3
  45. package/build/src/akuma/providers/claude/index.js +3 -0
  46. package/build/src/akuma/providers/codex-app-server/index.js +14 -12
  47. package/build/src/akuma/providers/pi/index.js +7 -1
  48. package/build/src/akuma/publication.js +65 -49
  49. package/build/src/akuma/request-lifecycle.d.ts +5 -4
  50. package/build/src/akuma/request-lifecycle.js +29 -16
  51. package/build/src/akuma/request-rendezvous.d.ts +15 -12
  52. package/build/src/akuma/request-rendezvous.js +80 -51
  53. package/build/src/akuma/request-serve.d.ts +1 -2
  54. package/build/src/akuma/request-serve.js +94 -39
  55. package/build/src/akuma/request-wire.d.ts +57 -26
  56. package/build/src/akuma/request-wire.js +64 -25
  57. package/build/src/akuma/turn-drive.d.ts +5 -4
  58. package/build/src/akuma/turn-drive.js +27 -11
  59. package/build/src/akuma-body.d.ts +4 -6
  60. package/build/src/akuma-body.js +19 -17
  61. package/build/src/bounded-list.d.ts +8 -0
  62. package/build/src/bounded-list.js +14 -0
  63. package/build/src/cli/accepted.d.ts +1 -1
  64. package/build/src/cli/accepted.js +1 -0
  65. package/build/src/cli/commands/akuma-invoke.js +1 -25
  66. package/build/src/cli/commands/contract-help.d.ts +5 -2
  67. package/build/src/cli/commands/contract-help.js +62 -12
  68. package/build/src/cli/commands/contract-invoke.d.ts +5 -0
  69. package/build/src/cli/commands/contract-invoke.js +26 -1
  70. package/build/src/cli/commands/contract.js +50 -18
  71. package/build/src/cli/commands/task-invoke.js +10 -2
  72. package/build/src/cli/commands/task-query.js +3 -4
  73. package/build/src/cli/coordinates.d.ts +13 -0
  74. package/build/src/cli/coordinates.js +38 -24
  75. package/build/src/cli/draft.d.ts +1 -1
  76. package/build/src/cli/invoke.js +14 -1
  77. package/build/src/cli/render/akuma-activity.d.ts +0 -1
  78. package/build/src/cli/render/akuma-activity.js +5 -38
  79. package/build/src/cli/render/akuma.js +4 -1
  80. package/build/src/cli/render/audit.js +4 -1
  81. package/build/src/cli/render/catalog.js +13 -39
  82. package/build/src/cli/render/contract.js +4 -14
  83. package/build/src/cli/render/kanshi-akuma.js +3 -8
  84. package/build/src/cli/render/kanshi.js +8 -34
  85. package/build/src/cli/render/nuke.js +7 -3
  86. package/build/src/cli/render/receipt.d.ts +1 -0
  87. package/build/src/cli/render/receipt.js +8 -0
  88. package/build/src/cli/render/refusal.js +4 -3
  89. package/build/src/cli/render/task.js +4 -37
  90. package/build/src/cli/render/terminal.d.ts +2 -6
  91. package/build/src/cli/render/terminal.js +4 -9
  92. package/build/src/cli/result.d.ts +2 -1
  93. package/build/src/contract-guidance.js +13 -3
  94. package/build/src/contract-worktree.d.ts +1 -0
  95. package/build/src/contract-worktree.js +26 -2
  96. package/build/src/core/facts/codec.d.ts +2 -1
  97. package/build/src/core/facts/codec.js +3 -0
  98. package/build/src/core/facts/gate.d.ts +2 -1
  99. package/build/src/core/facts/gate.js +63 -0
  100. package/build/src/core/verbs/abandon.d.ts +2 -1
  101. package/build/src/core/verbs/abandon.js +16 -0
  102. package/build/src/core/verbs/amend.d.ts +2 -1
  103. package/build/src/core/verbs/amend.js +20 -0
  104. package/build/src/core/verbs/arc.d.ts +2 -1
  105. package/build/src/core/verbs/arc.js +16 -0
  106. package/build/src/core/verbs/attestation.d.ts +2 -1
  107. package/build/src/core/verbs/attestation.js +16 -0
  108. package/build/src/core/verbs/bind.d.ts +2 -1
  109. package/build/src/core/verbs/bind.js +16 -0
  110. package/build/src/core/verbs/deliver.d.ts +2 -1
  111. package/build/src/core/verbs/deliver.js +16 -0
  112. package/build/src/core/verbs/placement.d.ts +2 -1
  113. package/build/src/core/verbs/placement.js +58 -1
  114. package/build/src/dispatch/association.d.ts +13 -0
  115. package/build/src/dispatch/association.js +20 -0
  116. package/build/src/dispatch/index.d.ts +6 -0
  117. package/build/src/dispatch/index.js +27 -3
  118. package/build/src/git/hooks.d.ts +9 -1
  119. package/build/src/git/hooks.js +79 -1
  120. package/build/src/git/nuke.d.ts +2 -1
  121. package/build/src/git/nuke.js +6 -11
  122. package/build/src/git/private-state-seat.d.ts +26 -1
  123. package/build/src/git/private-state-seat.js +78 -13
  124. package/build/src/git/process.d.ts +2 -0
  125. package/build/src/git/reconcile.d.ts +1 -2
  126. package/build/src/git/reconcile.js +0 -6
  127. package/build/src/git/repository.d.ts +0 -2
  128. package/build/src/git/repository.js +27 -25
  129. package/build/src/git/result-codec.d.ts +29 -0
  130. package/build/src/git/result-codec.js +306 -0
  131. package/build/src/git/target-placement.js +2 -8
  132. package/build/src/git/workspace.d.ts +2 -0
  133. package/build/src/git/workspace.js +4 -0
  134. package/build/src/index.d.ts +1 -0
  135. package/build/src/kanshi/fleet.js +1 -1
  136. package/build/src/kanshi/read.js +55 -28
  137. package/build/src/kanshi/report.d.ts +4 -3
  138. package/build/src/kanshi/select.js +14 -1
  139. package/build/src/library/address.d.ts +1 -0
  140. package/build/src/library/address.js +4 -7
  141. package/build/src/library/akuma-creation.d.ts +5 -3
  142. package/build/src/library/akuma-creation.js +90 -33
  143. package/build/src/library/audit.js +2 -1
  144. package/build/src/library/catalog.d.ts +10 -2
  145. package/build/src/library/catalog.js +65 -25
  146. package/build/src/library/composition.d.ts +1 -0
  147. package/build/src/library/composition.js +1 -0
  148. package/build/src/library/configuration.d.ts +4 -21
  149. package/build/src/library/configuration.js +2 -158
  150. package/build/src/library/continuation.d.ts +20 -1
  151. package/build/src/library/continuation.js +36 -0
  152. package/build/src/library/contract-bind.d.ts +1 -0
  153. package/build/src/library/contract-bind.js +16 -5
  154. package/build/src/library/contract-forwarding.d.ts +2 -2
  155. package/build/src/library/contract-forwarding.js +18 -4
  156. package/build/src/library/contract-handle.js +4 -3
  157. package/build/src/library/contract-operations.d.ts +5 -9
  158. package/build/src/library/contract-operations.js +34 -47
  159. package/build/src/library/contract.d.ts +11 -2
  160. package/build/src/library/contract.js +21 -1
  161. package/build/src/library/delivery.d.ts +4 -1
  162. package/build/src/library/delivery.js +47 -0
  163. package/build/src/library/fleet.d.ts +4 -136
  164. package/build/src/library/fleet.js +31 -315
  165. package/build/src/library/keiyaku.d.ts +7 -3
  166. package/build/src/library/keiyaku.js +1 -0
  167. package/build/src/library/mutation.d.ts +431 -3
  168. package/build/src/library/mutation.js +192 -19
  169. package/build/src/library/nuke.d.ts +7 -1
  170. package/build/src/library/nuke.js +18 -4
  171. package/build/src/library/reconcile.d.ts +14 -0
  172. package/build/src/library/reconcile.js +22 -8
  173. package/build/src/library/refusal.d.ts +9 -1
  174. package/build/src/library/refusal.js +76 -0
  175. package/build/src/library/region.d.ts +0 -8
  176. package/build/src/library/region.js +1 -29
  177. package/build/src/library/result-codec.d.ts +2 -0
  178. package/build/src/library/result-codec.js +12 -0
  179. package/build/src/markdown/lex.js +9 -2
  180. package/build/src/markdown/types.d.ts +2 -1
  181. package/build/src/markdown/types.js +3 -1
  182. package/build/src/plugin/akuma-signals.d.ts +12 -0
  183. package/build/src/plugin/akuma-signals.js +14 -0
  184. package/build/src/plugin/public.d.ts +51 -0
  185. package/build/src/plugin/public.js +1 -0
  186. package/build/src/plugin/runtime.d.ts +14 -0
  187. package/build/src/plugin/runtime.js +357 -0
  188. package/build/src/protocol/amend.js +3 -3
  189. package/build/src/protocol/attempt.d.ts +2 -1
  190. package/build/src/protocol/attempt.js +1 -1
  191. package/build/src/protocol/audit.d.ts +1 -1
  192. package/build/src/protocol/audit.js +1 -1
  193. package/build/src/protocol/bind.d.ts +3 -1
  194. package/build/src/protocol/bind.js +26 -0
  195. package/build/src/protocol/completion.js +0 -1
  196. package/build/src/protocol/deliver.d.ts +1 -1
  197. package/build/src/protocol/deliver.js +136 -57
  198. package/build/src/protocol/intent.d.ts +0 -1
  199. package/build/src/protocol/intent.js +0 -1
  200. package/build/src/protocol/operations.d.ts +9 -2
  201. package/build/src/protocol/operations.js +16 -1
  202. package/build/src/protocol/outcome.d.ts +3 -0
  203. package/build/src/protocol/outcome.js +17 -1
  204. package/build/src/protocol/placement.js +10 -3
  205. package/build/src/protocol/read/status.d.ts +8 -0
  206. package/build/src/protocol/read/status.js +49 -0
  207. package/build/src/protocol/reintegrate.js +10 -3
  208. package/build/src/protocol/result-codec.d.ts +22 -0
  209. package/build/src/protocol/result-codec.js +442 -0
  210. package/build/src/protocol/review.d.ts +1 -1
  211. package/build/src/protocol/review.js +81 -46
  212. package/build/src/protocol/run.d.ts +22 -2
  213. package/build/src/protocol/run.js +119 -29
  214. package/build/src/runtime/proc/lifecycle.js +1 -1
  215. package/build/src/runtime/proc/line-rpc.d.ts +7 -1
  216. package/build/src/runtime/proc/line-rpc.js +49 -9
  217. package/build/src/runtime/proc/run.d.ts +0 -1
  218. package/build/src/runtime/proc/run.js +1 -11
  219. package/build/src/runtime/proc/termination.d.ts +1 -0
  220. package/build/src/runtime/proc/termination.js +63 -18
  221. package/build/src/runtime/proc/windows-launch.exe +0 -0
  222. package/build/src/settings.d.ts +10 -0
  223. package/build/src/settings.js +88 -2
  224. package/build/src/settlement/result-codec.d.ts +2 -0
  225. package/build/src/settlement/result-codec.js +56 -0
  226. package/build/src/settlement/settle.d.ts +5 -12
  227. package/build/src/settlement/settle.js +60 -55
  228. package/build/src/task/board.d.ts +3 -0
  229. package/build/src/task/board.js +22 -4
  230. package/build/src/task/catalog.d.ts +13 -2
  231. package/build/src/task/catalog.js +59 -5
  232. package/build/src/task/compose.d.ts +4 -2
  233. package/build/src/task/compose.js +56 -30
  234. package/build/src/task/created-observation.d.ts +39 -0
  235. package/build/src/task/created-observation.js +26 -0
  236. package/build/src/task/identity.d.ts +6 -0
  237. package/build/src/task/identity.js +48 -7
  238. package/build/src/task/index.d.ts +4 -3
  239. package/build/src/task/index.js +19 -16
  240. package/build/src/task/input.d.ts +3 -1
  241. package/build/src/task/input.js +7 -4
  242. package/build/src/task/lifecycle-operations.d.ts +6 -0
  243. package/build/src/task/lifecycle-operations.js +116 -0
  244. package/build/src/task/mutation-result.d.ts +762 -20
  245. package/build/src/task/mutation-result.js +34 -9
  246. package/build/src/task/mutation.d.ts +4 -9
  247. package/build/src/task/mutation.js +17 -52
  248. package/build/src/task/operation-types.d.ts +114 -0
  249. package/build/src/task/operation-types.js +1 -0
  250. package/build/src/task/operations.d.ts +6 -113
  251. package/build/src/task/operations.js +75 -117
  252. package/build/src/task/query.d.ts +8 -11
  253. package/build/src/task/query.js +7 -14
  254. package/build/src/task/store.d.ts +11 -1
  255. package/build/src/task/store.js +169 -55
  256. package/build/src/task/view.d.ts +4 -0
  257. package/build/src/task/view.js +7 -0
  258. package/build/src/verification/declaration.d.ts +1 -0
  259. package/build/src/verification/declaration.js +18 -1
  260. package/build/src/verification/execution.d.ts +0 -1
  261. package/build/src/verification/execution.js +5 -5
  262. package/build/src/world.d.ts +0 -2
  263. package/build/src/world.js +3 -7
  264. package/package.json +17 -5
  265. package/build/src/cli/square-edge.d.ts +0 -7
  266. package/build/src/cli/square-edge.js +0 -159
  267. package/build/src/git/ref-migration.d.ts +0 -22
  268. package/build/src/git/ref-migration.js +0 -55
  269. package/build/src/library/contract-forwarding-reconciliation-result.d.ts +0 -102
  270. package/build/src/library/contract-forwarding-reconciliation-result.js +0 -92
  271. package/build/src/library/contract-forwarding-result.d.ts +0 -4270
  272. package/build/src/library/contract-forwarding-result.js +0 -521
@@ -1,159 +0,0 @@
1
- import { bindCurrentParticipant, createHostLedgerPort, Square, squareAssignedParticipantName, } from "@astrosheep/square";
2
- import { homedir } from "node:os";
3
- import { dirname, join } from "node:path";
4
- import { keiyakuSquarePath } from "../world.js";
5
- async function openKeiyakuSquare(path, environment, hostLedger) {
6
- try {
7
- return await Square.at({ path, env: environment, hostLedger });
8
- }
9
- catch (error) {
10
- if (error.code !== "ENOENT" && error.code !== "unavailable")
11
- throw error;
12
- try {
13
- return await Square.build({ path, markdown: "", env: environment, hostLedger });
14
- }
15
- catch (buildError) {
16
- try {
17
- return await Square.at({ path, env: environment, hostLedger });
18
- }
19
- catch {
20
- throw buildError;
21
- }
22
- }
23
- }
24
- }
25
- function squareInvocationEnvironment(environment, path) {
26
- const ledgerRoot = environment.SQUARE_REGISTRY === undefined ? undefined : dirname(environment.SQUARE_REGISTRY);
27
- return {
28
- ...environment,
29
- SQUARE_HOST_LEDGER_USER: environment.SQUARE_HOST_LEDGER_USER ?? ledgerRoot ?? join(homedir(), ".square", "host-ledger"),
30
- SQUARE_HOST_LEDGER_LOCAL: environment.SQUARE_HOST_LEDGER_LOCAL ??
31
- ledgerRoot ??
32
- join(environment.PWD ?? dirname(path), ".square", "host-ledger"),
33
- };
34
- }
35
- function invocationHostLedger(environment) {
36
- return createHostLedgerPort({
37
- userPath: environment.SQUARE_HOST_LEDGER_USER,
38
- localPath: environment.SQUARE_HOST_LEDGER_LOCAL,
39
- });
40
- }
41
- async function participantBindings(hostLedger, path, name) {
42
- return await hostLedger.listPresence({ location: path, participant: name });
43
- }
44
- function presenceKey({ location, participant, session, channel }) {
45
- return JSON.stringify([location, participant, session, channel]);
46
- }
47
- function exactPresenceKey({ location, participant, session, channel }) {
48
- return { location, participant, session, channel };
49
- }
50
- async function bestEffort(operation) {
51
- try {
52
- await operation();
53
- }
54
- catch { }
55
- }
56
- async function rollbackSquareEdge(input) {
57
- const { path, environment, hostLedger, name, allocated, joined, listening, createdBindings } = input;
58
- if (listening || joined) {
59
- let square;
60
- await bestEffort(async () => {
61
- square = await Square.at({ path, env: environment, hostLedger });
62
- });
63
- let participant;
64
- if (square !== undefined)
65
- await bestEffort(async () => {
66
- participant = await square.join(name);
67
- });
68
- if (participant !== undefined && listening)
69
- await bestEffort(async () => participant.ignore(allocated.id));
70
- if (participant !== undefined && joined)
71
- await bestEffort(async () => participant.done());
72
- if (square !== undefined)
73
- await bestEffort(async () => square.close());
74
- }
75
- for (const binding of createdBindings)
76
- await bestEffort(async () => hostLedger.removePresence(binding));
77
- }
78
- export async function recognizeAndListen(worldRoot, environment, allocated) {
79
- const path = keiyakuSquarePath(worldRoot);
80
- const squareEnvironment = squareInvocationEnvironment(environment, path);
81
- let name;
82
- try {
83
- const assigned = squareAssignedParticipantName(squareEnvironment);
84
- if (assigned === undefined)
85
- return;
86
- name = assigned;
87
- }
88
- catch {
89
- return;
90
- }
91
- const hostLedger = invocationHostLedger(squareEnvironment);
92
- let joined = false;
93
- let listening = false;
94
- let bindingsBeforeCall = [];
95
- let hasBindingSnapshot = false;
96
- let createdBindings = [];
97
- const rememberCreatedBindings = async () => {
98
- const beforeKeys = new Set(bindingsBeforeCall.map(presenceKey));
99
- createdBindings = (await participantBindings(hostLedger, path, name))
100
- .filter((binding) => !beforeKeys.has(presenceKey(binding)))
101
- .map(exactPresenceKey);
102
- };
103
- const refreshCreatedBindings = async () => {
104
- try {
105
- await rememberCreatedBindings();
106
- }
107
- catch { }
108
- };
109
- const rollback = async () => await rollbackSquareEdge({
110
- path,
111
- environment: squareEnvironment,
112
- hostLedger,
113
- name,
114
- allocated,
115
- joined,
116
- listening,
117
- createdBindings,
118
- });
119
- let square;
120
- try {
121
- bindingsBeforeCall = await participantBindings(hostLedger, path, name);
122
- hasBindingSnapshot = true;
123
- square = await openKeiyakuSquare(path, squareEnvironment, hostLedger);
124
- const joinedResult = await square.joinWithActivity(name);
125
- joined = joinedResult.activity !== null;
126
- const participant = joinedResult.participant;
127
- await bindCurrentParticipant(path, name, squareEnvironment);
128
- await rememberCreatedBindings();
129
- const listener = participant;
130
- let change;
131
- try {
132
- change = await listener.listen(allocated.id);
133
- }
134
- catch {
135
- // Keep birth independent from an older or drifting Square name grammar.
136
- await refreshCreatedBindings();
137
- await rollback();
138
- return;
139
- }
140
- listening = change.activity !== null;
141
- await square.close();
142
- square = undefined;
143
- return {
144
- committed: true,
145
- participantName: name,
146
- rollback,
147
- };
148
- }
149
- catch {
150
- if (hasBindingSnapshot)
151
- await refreshCreatedBindings();
152
- await rollback();
153
- return;
154
- }
155
- finally {
156
- if (square !== undefined)
157
- await square.close().catch(() => undefined);
158
- }
159
- }
@@ -1,22 +0,0 @@
1
- import type { ContractId } from "../core/facts/types.js";
2
- import { type GitRepository } from "./process.js";
3
- import { type GitOid } from "./repository.js";
4
- export type RefMigrationEffect = Readonly<{
5
- kind: "ref";
6
- name: string;
7
- before: GitOid | null;
8
- after: GitOid | null;
9
- action: "created" | "removed";
10
- }>;
11
- export type RefMigrationConflict = Readonly<{
12
- kind: "ref-migration-conflict";
13
- legacyRef: string;
14
- legacyOid: GitOid;
15
- currentRef: string;
16
- currentOid: GitOid;
17
- }>;
18
- export type RefMigrationResult = Readonly<{
19
- effects: readonly RefMigrationEffect[];
20
- lag: readonly RefMigrationConflict[];
21
- }>;
22
- export declare function migrateContractCustodyRefs(repository: GitRepository, contract: ContractId): Promise<RefMigrationResult>;
@@ -1,55 +0,0 @@
1
- import { contractPhysicalName } from "./identity.js";
2
- import { runGit } from "./process.js";
3
- import { CANDIDATE_PIN_REF_NAMESPACE, DELIVERY_REF_NAMESPACE, LEGACY_CANDIDATE_PIN_REF_NAMESPACE, LEGACY_DELIVERY_REF_NAMESPACE, readRef, } from "./repository.js";
4
- export async function migrateContractCustodyRefs(repository, contract) {
5
- const leaf = contractPhysicalName(contract);
6
- const pairs = [
7
- {
8
- legacy: `${LEGACY_DELIVERY_REF_NAMESPACE}/${leaf}`,
9
- current: `${DELIVERY_REF_NAMESPACE}/${leaf}`,
10
- },
11
- {
12
- legacy: `${LEGACY_CANDIDATE_PIN_REF_NAMESPACE}/${leaf}`,
13
- current: `${CANDIDATE_PIN_REF_NAMESPACE}/${leaf}`,
14
- },
15
- ];
16
- const observed = await Promise.all(pairs.map(async (pair) => {
17
- const [legacyOid, currentOid] = await Promise.all([
18
- readRef(repository, pair.legacy),
19
- readRef(repository, pair.current),
20
- ]);
21
- return { ...pair, legacyOid, currentOid };
22
- }));
23
- const lag = observed.flatMap((pair) => pair.legacyOid !== null && pair.currentOid !== null && pair.currentOid !== pair.legacyOid
24
- ? [
25
- {
26
- kind: "ref-migration-conflict",
27
- legacyRef: pair.legacy,
28
- legacyOid: pair.legacyOid,
29
- currentRef: pair.current,
30
- currentOid: pair.currentOid,
31
- },
32
- ]
33
- : []);
34
- if (lag.length > 0)
35
- return { effects: [], lag };
36
- const migrating = observed.filter((pair) => pair.legacyOid !== null);
37
- if (migrating.length === 0)
38
- return { effects: [], lag: [] };
39
- const lines = ["start"];
40
- const effects = [];
41
- for (const pair of migrating) {
42
- if (pair.currentOid === null) {
43
- lines.push(`create ${pair.current} ${pair.legacyOid}`);
44
- effects.push({ kind: "ref", name: pair.current, before: null, after: pair.legacyOid, action: "created" });
45
- }
46
- else {
47
- lines.push(`verify ${pair.current} ${pair.currentOid}`);
48
- }
49
- lines.push(`delete ${pair.legacy} ${pair.legacyOid}`);
50
- effects.push({ kind: "ref", name: pair.legacy, before: pair.legacyOid, after: null, action: "removed" });
51
- }
52
- lines.push("prepare", "commit", "");
53
- await runGit(repository, ["update-ref", "--stdin", "--no-deref"], lines.join("\n"));
54
- return { effects, lag: [] };
55
- }
@@ -1,102 +0,0 @@
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("./contract.js").SnapshotId, string>>;
9
- head: z.ZodPipe<z.ZodString, z.ZodTransform<import("./contract.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("./contract.js").SnapshotId;
21
- head: import("./contract.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("./contract.js").SnapshotId;
28
- head: import("./contract.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("./contract.js").SnapshotId;
34
- head: import("./contract.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("./contract.js").SnapshotId, string>>>;
42
- }, z.core.$strict>, z.ZodTransform<{
43
- kind: "unsealed-bytes";
44
- path: string;
45
- paths: string[];
46
- } | {
47
- head: import("./contract.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("./contract.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<"ref-migration-conflict">;
70
- legacyRef: z.ZodString;
71
- legacyOid: z.ZodPipe<z.ZodString, z.ZodTransform<import("./contract.js").SnapshotId, string>>;
72
- currentRef: z.ZodString;
73
- currentOid: z.ZodPipe<z.ZodString, z.ZodTransform<import("./contract.js").SnapshotId, string>>;
74
- }, z.core.$strict>, z.ZodObject<{
75
- kind: z.ZodLiteral<"worktree-hook-failed">;
76
- phase: z.ZodEnum<{
77
- destroy: "destroy";
78
- create: "create";
79
- }>;
80
- path: z.ZodString;
81
- command: z.ZodNumber;
82
- name: z.ZodString;
83
- failure: z.ZodUnion<readonly [z.ZodObject<{
84
- kind: z.ZodLiteral<"exit">;
85
- code: z.ZodNumber;
86
- stdout: z.ZodString;
87
- stderr: z.ZodString;
88
- truncated: z.ZodBoolean;
89
- }, z.core.$strict>, z.ZodObject<{
90
- kind: z.ZodLiteral<"timeout">;
91
- }, z.core.$strict>, z.ZodObject<{
92
- kind: z.ZodLiteral<"spawn-error">;
93
- diagnostic: z.ZodString;
94
- }, z.core.$strict>, z.ZodObject<{
95
- kind: z.ZodLiteral<"unknown-exit">;
96
- }, z.core.$strict>]>;
97
- }, z.core.$strict>, z.ZodObject<{
98
- kind: z.ZodLiteral<"contract-file-failed">;
99
- worktree: z.ZodString;
100
- path: z.ZodString;
101
- diagnostic: z.ZodString;
102
- }, z.core.$strict>]>;
@@ -1,92 +0,0 @@
1
- import { mintSnapshotId } from "../git/identity.js";
2
- import { z } from "zod";
3
- function canonicalSnapshot(value, context) {
4
- try {
5
- return mintSnapshotId(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("ref-migration-conflict"),
68
- legacyRef: nonblankStringSchema,
69
- legacyOid: snapshotIdSchema,
70
- currentRef: nonblankStringSchema,
71
- currentOid: snapshotIdSchema,
72
- })
73
- .strict(),
74
- z
75
- .object({
76
- kind: z.literal("worktree-hook-failed"),
77
- phase: z.enum(["create", "destroy"]),
78
- path: nonblankStringSchema,
79
- command: z.number().int().nonnegative(),
80
- name: nonblankStringSchema,
81
- failure: hookFailureSchema,
82
- })
83
- .strict(),
84
- z
85
- .object({
86
- kind: z.literal("contract-file-failed"),
87
- worktree: nonblankStringSchema,
88
- path: nonblankStringSchema,
89
- diagnostic: nonblankStringSchema,
90
- })
91
- .strict(),
92
- ]);