looply-cli 0.0.0-stage → 0.2.0

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 (785) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +137 -3
  3. package/dist/.src-hash +1 -0
  4. package/dist/acceptance-observe.d.ts +108 -0
  5. package/dist/acceptance-observe.d.ts.map +1 -0
  6. package/dist/acceptance-observe.js +152 -0
  7. package/dist/acceptance-observe.js.map +1 -0
  8. package/dist/agent-cmd.d.ts +131 -0
  9. package/dist/agent-cmd.d.ts.map +1 -0
  10. package/dist/agent-cmd.js +154 -0
  11. package/dist/agent-cmd.js.map +1 -0
  12. package/dist/agent-contained.d.ts +114 -0
  13. package/dist/agent-contained.d.ts.map +1 -0
  14. package/dist/agent-contained.js +292 -0
  15. package/dist/agent-contained.js.map +1 -0
  16. package/dist/agent-driver.d.ts +130 -0
  17. package/dist/agent-driver.d.ts.map +1 -0
  18. package/dist/agent-driver.js +170 -0
  19. package/dist/agent-driver.js.map +1 -0
  20. package/dist/agent-envelope.d.ts +94 -0
  21. package/dist/agent-envelope.d.ts.map +1 -0
  22. package/dist/agent-envelope.js +214 -0
  23. package/dist/agent-envelope.js.map +1 -0
  24. package/dist/agent-exec.d.ts +182 -0
  25. package/dist/agent-exec.d.ts.map +1 -0
  26. package/dist/agent-exec.js +125 -0
  27. package/dist/agent-exec.js.map +1 -0
  28. package/dist/agent-runtime.d.ts +23 -0
  29. package/dist/agent-runtime.d.ts.map +1 -0
  30. package/dist/agent-runtime.js +143 -0
  31. package/dist/agent-runtime.js.map +1 -0
  32. package/dist/approval-gate-read.d.ts +66 -0
  33. package/dist/approval-gate-read.d.ts.map +1 -0
  34. package/dist/approval-gate-read.js +138 -0
  35. package/dist/approval-gate-read.js.map +1 -0
  36. package/dist/approval-resolution.d.ts +87 -0
  37. package/dist/approval-resolution.d.ts.map +1 -0
  38. package/dist/approval-resolution.js +100 -0
  39. package/dist/approval-resolution.js.map +1 -0
  40. package/dist/approval-resumes.d.ts +102 -0
  41. package/dist/approval-resumes.d.ts.map +1 -0
  42. package/dist/approval-resumes.js +167 -0
  43. package/dist/approval-resumes.js.map +1 -0
  44. package/dist/ask-brain.d.ts +167 -0
  45. package/dist/ask-brain.d.ts.map +1 -0
  46. package/dist/ask-brain.js +355 -0
  47. package/dist/ask-brain.js.map +1 -0
  48. package/dist/autonomy-authority.d.ts +80 -0
  49. package/dist/autonomy-authority.d.ts.map +1 -0
  50. package/dist/autonomy-authority.js +82 -0
  51. package/dist/autonomy-authority.js.map +1 -0
  52. package/dist/autonomy-controller.d.ts +321 -0
  53. package/dist/autonomy-controller.d.ts.map +1 -0
  54. package/dist/autonomy-controller.js +517 -0
  55. package/dist/autonomy-controller.js.map +1 -0
  56. package/dist/autonomy-store.d.ts +327 -0
  57. package/dist/autonomy-store.d.ts.map +1 -0
  58. package/dist/autonomy-store.js +581 -0
  59. package/dist/autonomy-store.js.map +1 -0
  60. package/dist/autonomy-tick.d.ts +257 -0
  61. package/dist/autonomy-tick.d.ts.map +1 -0
  62. package/dist/autonomy-tick.js +616 -0
  63. package/dist/autonomy-tick.js.map +1 -0
  64. package/dist/bin.d.ts +3 -0
  65. package/dist/bin.d.ts.map +1 -0
  66. package/dist/bin.js +2719 -0
  67. package/dist/bin.js.map +1 -0
  68. package/dist/brain-advice.d.ts +21 -0
  69. package/dist/brain-advice.d.ts.map +1 -0
  70. package/dist/brain-advice.js +51 -0
  71. package/dist/brain-advice.js.map +1 -0
  72. package/dist/candidate-replay-runtime.d.ts +125 -0
  73. package/dist/candidate-replay-runtime.d.ts.map +1 -0
  74. package/dist/candidate-replay-runtime.js +188 -0
  75. package/dist/candidate-replay-runtime.js.map +1 -0
  76. package/dist/checkout-carry.d.ts +76 -0
  77. package/dist/checkout-carry.d.ts.map +1 -0
  78. package/dist/checkout-carry.js +125 -0
  79. package/dist/checkout-carry.js.map +1 -0
  80. package/dist/citation-readers.d.ts +26 -0
  81. package/dist/citation-readers.d.ts.map +1 -0
  82. package/dist/citation-readers.js +102 -0
  83. package/dist/citation-readers.js.map +1 -0
  84. package/dist/command-receipts.d.ts +79 -0
  85. package/dist/command-receipts.d.ts.map +1 -0
  86. package/dist/command-receipts.js +143 -0
  87. package/dist/command-receipts.js.map +1 -0
  88. package/dist/command-runner.d.ts +32 -0
  89. package/dist/command-runner.d.ts.map +1 -0
  90. package/dist/command-runner.js +108 -0
  91. package/dist/command-runner.js.map +1 -0
  92. package/dist/compatible-sets.d.ts +67 -0
  93. package/dist/compatible-sets.d.ts.map +1 -0
  94. package/dist/compatible-sets.js +81 -0
  95. package/dist/compatible-sets.js.map +1 -0
  96. package/dist/compile-check.d.ts +31 -0
  97. package/dist/compile-check.d.ts.map +1 -0
  98. package/dist/compile-check.js +34 -0
  99. package/dist/compile-check.js.map +1 -0
  100. package/dist/compile-store.d.ts +16 -0
  101. package/dist/compile-store.d.ts.map +1 -0
  102. package/dist/compile-store.js +21 -0
  103. package/dist/compile-store.js.map +1 -0
  104. package/dist/completion.d.ts +106 -0
  105. package/dist/completion.d.ts.map +1 -0
  106. package/dist/completion.js +131 -0
  107. package/dist/completion.js.map +1 -0
  108. package/dist/config.d.ts +549 -0
  109. package/dist/config.d.ts.map +1 -0
  110. package/dist/config.js +763 -0
  111. package/dist/config.js.map +1 -0
  112. package/dist/control-file.d.ts +142 -0
  113. package/dist/control-file.d.ts.map +1 -0
  114. package/dist/control-file.js +144 -0
  115. package/dist/control-file.js.map +1 -0
  116. package/dist/coordinator-state.d.ts +131 -0
  117. package/dist/coordinator-state.d.ts.map +1 -0
  118. package/dist/coordinator-state.js +380 -0
  119. package/dist/coordinator-state.js.map +1 -0
  120. package/dist/coordinator.d.ts +95 -0
  121. package/dist/coordinator.d.ts.map +1 -0
  122. package/dist/coordinator.js +97 -0
  123. package/dist/coordinator.js.map +1 -0
  124. package/dist/cursor-store.d.ts +53 -0
  125. package/dist/cursor-store.d.ts.map +1 -0
  126. package/dist/cursor-store.js +98 -0
  127. package/dist/cursor-store.js.map +1 -0
  128. package/dist/daemon-cmd.d.ts +239 -0
  129. package/dist/daemon-cmd.d.ts.map +1 -0
  130. package/dist/daemon-cmd.js +1751 -0
  131. package/dist/daemon-cmd.js.map +1 -0
  132. package/dist/daemon-lock.d.ts +140 -0
  133. package/dist/daemon-lock.d.ts.map +1 -0
  134. package/dist/daemon-lock.js +352 -0
  135. package/dist/daemon-lock.js.map +1 -0
  136. package/dist/daemon-recovery.d.ts +78 -0
  137. package/dist/daemon-recovery.d.ts.map +1 -0
  138. package/dist/daemon-recovery.js +161 -0
  139. package/dist/daemon-recovery.js.map +1 -0
  140. package/dist/daemon.d.ts +368 -0
  141. package/dist/daemon.d.ts.map +1 -0
  142. package/dist/daemon.js +601 -0
  143. package/dist/daemon.js.map +1 -0
  144. package/dist/declared-response-shape.d.ts +93 -0
  145. package/dist/declared-response-shape.d.ts.map +1 -0
  146. package/dist/declared-response-shape.js +200 -0
  147. package/dist/declared-response-shape.js.map +1 -0
  148. package/dist/declared-surfaces.d.ts +16 -0
  149. package/dist/declared-surfaces.d.ts.map +1 -0
  150. package/dist/declared-surfaces.js +19 -0
  151. package/dist/declared-surfaces.js.map +1 -0
  152. package/dist/depends-review.d.ts +113 -0
  153. package/dist/depends-review.d.ts.map +1 -0
  154. package/dist/depends-review.js +110 -0
  155. package/dist/depends-review.js.map +1 -0
  156. package/dist/doctor.d.ts +91 -0
  157. package/dist/doctor.d.ts.map +1 -0
  158. package/dist/doctor.js +71 -0
  159. package/dist/doctor.js.map +1 -0
  160. package/dist/edge-approval.d.ts +105 -0
  161. package/dist/edge-approval.d.ts.map +1 -0
  162. package/dist/edge-approval.js +100 -0
  163. package/dist/edge-approval.js.map +1 -0
  164. package/dist/evidence-cache.d.ts +45 -0
  165. package/dist/evidence-cache.d.ts.map +1 -0
  166. package/dist/evidence-cache.js +90 -0
  167. package/dist/evidence-cache.js.map +1 -0
  168. package/dist/evidence-cmd.d.ts +133 -0
  169. package/dist/evidence-cmd.d.ts.map +1 -0
  170. package/dist/evidence-cmd.js +347 -0
  171. package/dist/evidence-cmd.js.map +1 -0
  172. package/dist/evidence-facts.d.ts +40 -0
  173. package/dist/evidence-facts.d.ts.map +1 -0
  174. package/dist/evidence-facts.js +114 -0
  175. package/dist/evidence-facts.js.map +1 -0
  176. package/dist/exclusive-lock.d.ts +52 -0
  177. package/dist/exclusive-lock.d.ts.map +1 -0
  178. package/dist/exclusive-lock.js +150 -0
  179. package/dist/exclusive-lock.js.map +1 -0
  180. package/dist/exec-domains.d.ts +140 -0
  181. package/dist/exec-domains.d.ts.map +1 -0
  182. package/dist/exec-domains.js +287 -0
  183. package/dist/exec-domains.js.map +1 -0
  184. package/dist/exemption-store.d.ts +197 -0
  185. package/dist/exemption-store.d.ts.map +1 -0
  186. package/dist/exemption-store.js +266 -0
  187. package/dist/exemption-store.js.map +1 -0
  188. package/dist/explicit-start-gate.d.ts +96 -0
  189. package/dist/explicit-start-gate.d.ts.map +1 -0
  190. package/dist/explicit-start-gate.js +103 -0
  191. package/dist/explicit-start-gate.js.map +1 -0
  192. package/dist/fs-trouble.d.ts +70 -0
  193. package/dist/fs-trouble.d.ts.map +1 -0
  194. package/dist/fs-trouble.js +98 -0
  195. package/dist/fs-trouble.js.map +1 -0
  196. package/dist/gate.d.ts +278 -0
  197. package/dist/gate.d.ts.map +1 -0
  198. package/dist/gate.js +278 -0
  199. package/dist/gate.js.map +1 -0
  200. package/dist/git-driver.d.ts +519 -0
  201. package/dist/git-driver.d.ts.map +1 -0
  202. package/dist/git-driver.js +900 -0
  203. package/dist/git-driver.js.map +1 -0
  204. package/dist/git-push-executor.d.ts +41 -0
  205. package/dist/git-push-executor.d.ts.map +1 -0
  206. package/dist/git-push-executor.js +142 -0
  207. package/dist/git-push-executor.js.map +1 -0
  208. package/dist/glob.d.ts +26 -0
  209. package/dist/glob.d.ts.map +1 -0
  210. package/dist/glob.js +93 -0
  211. package/dist/glob.js.map +1 -0
  212. package/dist/goal-adaptive.d.ts +295 -0
  213. package/dist/goal-adaptive.d.ts.map +1 -0
  214. package/dist/goal-adaptive.js +393 -0
  215. package/dist/goal-adaptive.js.map +1 -0
  216. package/dist/goal-compile.d.ts +342 -0
  217. package/dist/goal-compile.d.ts.map +1 -0
  218. package/dist/goal-compile.js +444 -0
  219. package/dist/goal-compile.js.map +1 -0
  220. package/dist/goal-depends-executor.d.ts +55 -0
  221. package/dist/goal-depends-executor.d.ts.map +1 -0
  222. package/dist/goal-depends-executor.js +202 -0
  223. package/dist/goal-depends-executor.js.map +1 -0
  224. package/dist/goal-execution-evidence.d.ts +135 -0
  225. package/dist/goal-execution-evidence.d.ts.map +1 -0
  226. package/dist/goal-execution-evidence.js +159 -0
  227. package/dist/goal-execution-evidence.js.map +1 -0
  228. package/dist/goal-gap.d.ts +140 -0
  229. package/dist/goal-gap.d.ts.map +1 -0
  230. package/dist/goal-gap.js +197 -0
  231. package/dist/goal-gap.js.map +1 -0
  232. package/dist/goal-met-target.d.ts +98 -0
  233. package/dist/goal-met-target.d.ts.map +1 -0
  234. package/dist/goal-met-target.js +92 -0
  235. package/dist/goal-met-target.js.map +1 -0
  236. package/dist/goal-ownership.d.ts +416 -0
  237. package/dist/goal-ownership.d.ts.map +1 -0
  238. package/dist/goal-ownership.js +576 -0
  239. package/dist/goal-ownership.js.map +1 -0
  240. package/dist/goal-runs.d.ts +82 -0
  241. package/dist/goal-runs.d.ts.map +1 -0
  242. package/dist/goal-runs.js +120 -0
  243. package/dist/goal-runs.js.map +1 -0
  244. package/dist/goal-store.d.ts +146 -0
  245. package/dist/goal-store.d.ts.map +1 -0
  246. package/dist/goal-store.js +294 -0
  247. package/dist/goal-store.js.map +1 -0
  248. package/dist/goal-view.d.ts +156 -0
  249. package/dist/goal-view.d.ts.map +1 -0
  250. package/dist/goal-view.js +499 -0
  251. package/dist/goal-view.js.map +1 -0
  252. package/dist/governed-approvals.d.ts +152 -0
  253. package/dist/governed-approvals.d.ts.map +1 -0
  254. package/dist/governed-approvals.js +246 -0
  255. package/dist/governed-approvals.js.map +1 -0
  256. package/dist/governed-broker.d.ts +169 -0
  257. package/dist/governed-broker.d.ts.map +1 -0
  258. package/dist/governed-broker.js +196 -0
  259. package/dist/governed-broker.js.map +1 -0
  260. package/dist/governed-run.d.ts +220 -0
  261. package/dist/governed-run.d.ts.map +1 -0
  262. package/dist/governed-run.js +406 -0
  263. package/dist/governed-run.js.map +1 -0
  264. package/dist/grant-reconcile.d.ts +63 -0
  265. package/dist/grant-reconcile.d.ts.map +1 -0
  266. package/dist/grant-reconcile.js +121 -0
  267. package/dist/grant-reconcile.js.map +1 -0
  268. package/dist/index-for-head.d.ts +56 -0
  269. package/dist/index-for-head.d.ts.map +1 -0
  270. package/dist/index-for-head.js +103 -0
  271. package/dist/index-for-head.js.map +1 -0
  272. package/dist/index.d.ts +39 -0
  273. package/dist/index.d.ts.map +1 -0
  274. package/dist/index.js +55 -0
  275. package/dist/index.js.map +1 -0
  276. package/dist/init-detect.d.ts +39 -0
  277. package/dist/init-detect.d.ts.map +1 -0
  278. package/dist/init-detect.js +188 -0
  279. package/dist/init-detect.js.map +1 -0
  280. package/dist/integration-deps.d.ts +62 -0
  281. package/dist/integration-deps.d.ts.map +1 -0
  282. package/dist/integration-deps.js +251 -0
  283. package/dist/integration-deps.js.map +1 -0
  284. package/dist/integration-runtime.d.ts +458 -0
  285. package/dist/integration-runtime.d.ts.map +1 -0
  286. package/dist/integration-runtime.js +681 -0
  287. package/dist/integration-runtime.js.map +1 -0
  288. package/dist/integration.d.ts +45 -0
  289. package/dist/integration.d.ts.map +1 -0
  290. package/dist/integration.js +87 -0
  291. package/dist/integration.js.map +1 -0
  292. package/dist/integrator.d.ts +84 -0
  293. package/dist/integrator.d.ts.map +1 -0
  294. package/dist/integrator.js +193 -0
  295. package/dist/integrator.js.map +1 -0
  296. package/dist/lane-claims.d.ts +174 -0
  297. package/dist/lane-claims.d.ts.map +1 -0
  298. package/dist/lane-claims.js +218 -0
  299. package/dist/lane-claims.js.map +1 -0
  300. package/dist/lane-coverage.d.ts +87 -0
  301. package/dist/lane-coverage.d.ts.map +1 -0
  302. package/dist/lane-coverage.js +129 -0
  303. package/dist/lane-coverage.js.map +1 -0
  304. package/dist/ledger-replay.d.ts +115 -0
  305. package/dist/ledger-replay.d.ts.map +1 -0
  306. package/dist/ledger-replay.js +155 -0
  307. package/dist/ledger-replay.js.map +1 -0
  308. package/dist/ledger-store.d.ts +68 -0
  309. package/dist/ledger-store.d.ts.map +1 -0
  310. package/dist/ledger-store.js +111 -0
  311. package/dist/ledger-store.js.map +1 -0
  312. package/dist/loop-safety-observer.d.ts +132 -0
  313. package/dist/loop-safety-observer.d.ts.map +1 -0
  314. package/dist/loop-safety-observer.js +76 -0
  315. package/dist/loop-safety-observer.js.map +1 -0
  316. package/dist/loop-safety-store.d.ts +339 -0
  317. package/dist/loop-safety-store.d.ts.map +1 -0
  318. package/dist/loop-safety-store.js +800 -0
  319. package/dist/loop-safety-store.js.map +1 -0
  320. package/dist/machine-store.d.ts +54 -0
  321. package/dist/machine-store.d.ts.map +1 -0
  322. package/dist/machine-store.js +149 -0
  323. package/dist/machine-store.js.map +1 -0
  324. package/dist/mcp-main.d.ts +2 -0
  325. package/dist/mcp-main.d.ts.map +1 -0
  326. package/dist/mcp-main.js +116 -0
  327. package/dist/mcp-main.js.map +1 -0
  328. package/dist/mcp-server.d.ts +72 -0
  329. package/dist/mcp-server.d.ts.map +1 -0
  330. package/dist/mcp-server.js +259 -0
  331. package/dist/mcp-server.js.map +1 -0
  332. package/dist/model-routing.d.ts +75 -0
  333. package/dist/model-routing.d.ts.map +1 -0
  334. package/dist/model-routing.js +108 -0
  335. package/dist/model-routing.js.map +1 -0
  336. package/dist/model-transport.d.ts +188 -0
  337. package/dist/model-transport.d.ts.map +1 -0
  338. package/dist/model-transport.js +625 -0
  339. package/dist/model-transport.js.map +1 -0
  340. package/dist/notify-cadence.d.ts +55 -0
  341. package/dist/notify-cadence.d.ts.map +1 -0
  342. package/dist/notify-cadence.js +68 -0
  343. package/dist/notify-cadence.js.map +1 -0
  344. package/dist/notify-channel.d.ts +69 -0
  345. package/dist/notify-channel.d.ts.map +1 -0
  346. package/dist/notify-channel.js +151 -0
  347. package/dist/notify-channel.js.map +1 -0
  348. package/dist/notify.d.ts +71 -0
  349. package/dist/notify.d.ts.map +1 -0
  350. package/dist/notify.js +125 -0
  351. package/dist/notify.js.map +1 -0
  352. package/dist/observation-inventory.d.ts +65 -0
  353. package/dist/observation-inventory.d.ts.map +1 -0
  354. package/dist/observation-inventory.js +139 -0
  355. package/dist/observation-inventory.js.map +1 -0
  356. package/dist/owned-children.d.ts +45 -0
  357. package/dist/owned-children.d.ts.map +1 -0
  358. package/dist/owned-children.js +64 -0
  359. package/dist/owned-children.js.map +1 -0
  360. package/dist/packet-for-goal.d.ts +19 -0
  361. package/dist/packet-for-goal.d.ts.map +1 -0
  362. package/dist/packet-for-goal.js +32 -0
  363. package/dist/packet-for-goal.js.map +1 -0
  364. package/dist/pair-cmd.d.ts +85 -0
  365. package/dist/pair-cmd.d.ts.map +1 -0
  366. package/dist/pair-cmd.js +205 -0
  367. package/dist/pair-cmd.js.map +1 -0
  368. package/dist/partial-asker.d.ts +96 -0
  369. package/dist/partial-asker.d.ts.map +1 -0
  370. package/dist/partial-asker.js +117 -0
  371. package/dist/partial-asker.js.map +1 -0
  372. package/dist/pdf-text-lines.d.ts +17 -0
  373. package/dist/pdf-text-lines.d.ts.map +1 -0
  374. package/dist/pdf-text-lines.js +70 -0
  375. package/dist/pdf-text-lines.js.map +1 -0
  376. package/dist/pdf-text-worker.d.ts +2 -0
  377. package/dist/pdf-text-worker.d.ts.map +1 -0
  378. package/dist/pdf-text-worker.js +81 -0
  379. package/dist/pdf-text-worker.js.map +1 -0
  380. package/dist/pdf-text.d.ts +56 -0
  381. package/dist/pdf-text.d.ts.map +1 -0
  382. package/dist/pdf-text.js +64 -0
  383. package/dist/pdf-text.js.map +1 -0
  384. package/dist/pending-action.d.ts +154 -0
  385. package/dist/pending-action.d.ts.map +1 -0
  386. package/dist/pending-action.js +148 -0
  387. package/dist/pending-action.js.map +1 -0
  388. package/dist/preemptor.d.ts +40 -0
  389. package/dist/preemptor.d.ts.map +1 -0
  390. package/dist/preemptor.js +49 -0
  391. package/dist/preemptor.js.map +1 -0
  392. package/dist/programme-mode.d.ts +29 -0
  393. package/dist/programme-mode.d.ts.map +1 -0
  394. package/dist/programme-mode.js +50 -0
  395. package/dist/programme-mode.js.map +1 -0
  396. package/dist/progress-view.d.ts +14 -0
  397. package/dist/progress-view.d.ts.map +1 -0
  398. package/dist/progress-view.js +114 -0
  399. package/dist/progress-view.js.map +1 -0
  400. package/dist/project-graph-builder.d.ts +81 -0
  401. package/dist/project-graph-builder.d.ts.map +1 -0
  402. package/dist/project-graph-builder.js +246 -0
  403. package/dist/project-graph-builder.js.map +1 -0
  404. package/dist/project-graph-runtime.d.ts +86 -0
  405. package/dist/project-graph-runtime.d.ts.map +1 -0
  406. package/dist/project-graph-runtime.js +112 -0
  407. package/dist/project-graph-runtime.js.map +1 -0
  408. package/dist/project-index-builder.d.ts +96 -0
  409. package/dist/project-index-builder.d.ts.map +1 -0
  410. package/dist/project-index-builder.js +298 -0
  411. package/dist/project-index-builder.js.map +1 -0
  412. package/dist/project-index-facts.d.ts +51 -0
  413. package/dist/project-index-facts.d.ts.map +1 -0
  414. package/dist/project-index-facts.js +117 -0
  415. package/dist/project-index-facts.js.map +1 -0
  416. package/dist/project-index-store.d.ts +97 -0
  417. package/dist/project-index-store.d.ts.map +1 -0
  418. package/dist/project-index-store.js +140 -0
  419. package/dist/project-index-store.js.map +1 -0
  420. package/dist/project-memory-store.d.ts +127 -0
  421. package/dist/project-memory-store.d.ts.map +1 -0
  422. package/dist/project-memory-store.js +302 -0
  423. package/dist/project-memory-store.js.map +1 -0
  424. package/dist/proposal-store.d.ts +14 -0
  425. package/dist/proposal-store.d.ts.map +1 -0
  426. package/dist/proposal-store.js +19 -0
  427. package/dist/proposal-store.js.map +1 -0
  428. package/dist/prover.d.ts +80 -0
  429. package/dist/prover.d.ts.map +1 -0
  430. package/dist/prover.js +137 -0
  431. package/dist/prover.js.map +1 -0
  432. package/dist/provider-identity-store.d.ts +34 -0
  433. package/dist/provider-identity-store.d.ts.map +1 -0
  434. package/dist/provider-identity-store.js +72 -0
  435. package/dist/provider-identity-store.js.map +1 -0
  436. package/dist/provider-identity.d.ts +104 -0
  437. package/dist/provider-identity.d.ts.map +1 -0
  438. package/dist/provider-identity.js +167 -0
  439. package/dist/provider-identity.js.map +1 -0
  440. package/dist/provider-limit.d.ts +79 -0
  441. package/dist/provider-limit.d.ts.map +1 -0
  442. package/dist/provider-limit.js +148 -0
  443. package/dist/provider-limit.js.map +1 -0
  444. package/dist/provider-preflight.d.ts +171 -0
  445. package/dist/provider-preflight.d.ts.map +1 -0
  446. package/dist/provider-preflight.js +395 -0
  447. package/dist/provider-preflight.js.map +1 -0
  448. package/dist/provider-state.d.ts +120 -0
  449. package/dist/provider-state.d.ts.map +1 -0
  450. package/dist/provider-state.js +182 -0
  451. package/dist/provider-state.js.map +1 -0
  452. package/dist/providers.d.ts +132 -0
  453. package/dist/providers.d.ts.map +1 -0
  454. package/dist/providers.js +161 -0
  455. package/dist/providers.js.map +1 -0
  456. package/dist/publication-recorder.d.ts +117 -0
  457. package/dist/publication-recorder.d.ts.map +1 -0
  458. package/dist/publication-recorder.js +124 -0
  459. package/dist/publication-recorder.js.map +1 -0
  460. package/dist/pursuit-delivery.d.ts +24 -0
  461. package/dist/pursuit-delivery.d.ts.map +1 -0
  462. package/dist/pursuit-delivery.js +38 -0
  463. package/dist/pursuit-delivery.js.map +1 -0
  464. package/dist/queue-store.d.ts +132 -0
  465. package/dist/queue-store.d.ts.map +1 -0
  466. package/dist/queue-store.js +185 -0
  467. package/dist/queue-store.js.map +1 -0
  468. package/dist/queue-summary.d.ts +14 -0
  469. package/dist/queue-summary.d.ts.map +1 -0
  470. package/dist/queue-summary.js +82 -0
  471. package/dist/queue-summary.js.map +1 -0
  472. package/dist/queue-view.d.ts +20 -0
  473. package/dist/queue-view.d.ts.map +1 -0
  474. package/dist/queue-view.js +163 -0
  475. package/dist/queue-view.js.map +1 -0
  476. package/dist/queue-write-lease.d.ts +106 -0
  477. package/dist/queue-write-lease.d.ts.map +1 -0
  478. package/dist/queue-write-lease.js +282 -0
  479. package/dist/queue-write-lease.js.map +1 -0
  480. package/dist/rails-home.d.ts +162 -0
  481. package/dist/rails-home.d.ts.map +1 -0
  482. package/dist/rails-home.js +452 -0
  483. package/dist/rails-home.js.map +1 -0
  484. package/dist/rails-migrations.d.ts +75 -0
  485. package/dist/rails-migrations.d.ts.map +1 -0
  486. package/dist/rails-migrations.js +199 -0
  487. package/dist/rails-migrations.js.map +1 -0
  488. package/dist/rails-stores.d.ts +49 -0
  489. package/dist/rails-stores.d.ts.map +1 -0
  490. package/dist/rails-stores.js +100 -0
  491. package/dist/rails-stores.js.map +1 -0
  492. package/dist/reaper.d.ts +69 -0
  493. package/dist/reaper.d.ts.map +1 -0
  494. package/dist/reaper.js +152 -0
  495. package/dist/reaper.js.map +1 -0
  496. package/dist/record-store.d.ts +36 -0
  497. package/dist/record-store.d.ts.map +1 -0
  498. package/dist/record-store.js +78 -0
  499. package/dist/record-store.js.map +1 -0
  500. package/dist/recovery-io.d.ts +50 -0
  501. package/dist/recovery-io.d.ts.map +1 -0
  502. package/dist/recovery-io.js +122 -0
  503. package/dist/recovery-io.js.map +1 -0
  504. package/dist/recovery.d.ts +146 -0
  505. package/dist/recovery.d.ts.map +1 -0
  506. package/dist/recovery.js +110 -0
  507. package/dist/recovery.js.map +1 -0
  508. package/dist/redraw.d.ts +34 -0
  509. package/dist/redraw.d.ts.map +1 -0
  510. package/dist/redraw.js +62 -0
  511. package/dist/redraw.js.map +1 -0
  512. package/dist/rejected-evidence.d.ts +255 -0
  513. package/dist/rejected-evidence.d.ts.map +1 -0
  514. package/dist/rejected-evidence.js +324 -0
  515. package/dist/rejected-evidence.js.map +1 -0
  516. package/dist/report-cmd.d.ts +32 -0
  517. package/dist/report-cmd.d.ts.map +1 -0
  518. package/dist/report-cmd.js +201 -0
  519. package/dist/report-cmd.js.map +1 -0
  520. package/dist/repos-cmd.d.ts +80 -0
  521. package/dist/repos-cmd.d.ts.map +1 -0
  522. package/dist/repos-cmd.js +240 -0
  523. package/dist/repos-cmd.js.map +1 -0
  524. package/dist/request-body-shape.d.ts +93 -0
  525. package/dist/request-body-shape.d.ts.map +1 -0
  526. package/dist/request-body-shape.js +407 -0
  527. package/dist/request-body-shape.js.map +1 -0
  528. package/dist/requirement-claims.d.ts +89 -0
  529. package/dist/requirement-claims.d.ts.map +1 -0
  530. package/dist/requirement-claims.js +92 -0
  531. package/dist/requirement-claims.js.map +1 -0
  532. package/dist/retention-apply-runtime.d.ts +105 -0
  533. package/dist/retention-apply-runtime.d.ts.map +1 -0
  534. package/dist/retention-apply-runtime.js +269 -0
  535. package/dist/retention-apply-runtime.js.map +1 -0
  536. package/dist/reverify.d.ts +41 -0
  537. package/dist/reverify.d.ts.map +1 -0
  538. package/dist/reverify.js +69 -0
  539. package/dist/reverify.js.map +1 -0
  540. package/dist/round-records.d.ts +65 -0
  541. package/dist/round-records.d.ts.map +1 -0
  542. package/dist/round-records.js +61 -0
  543. package/dist/round-records.js.map +1 -0
  544. package/dist/round-runner.d.ts +924 -0
  545. package/dist/round-runner.d.ts.map +1 -0
  546. package/dist/round-runner.js +1693 -0
  547. package/dist/round-runner.js.map +1 -0
  548. package/dist/run-approval.d.ts +180 -0
  549. package/dist/run-approval.d.ts.map +1 -0
  550. package/dist/run-approval.js +199 -0
  551. package/dist/run-approval.js.map +1 -0
  552. package/dist/run-cmd.d.ts +359 -0
  553. package/dist/run-cmd.d.ts.map +1 -0
  554. package/dist/run-cmd.js +4418 -0
  555. package/dist/run-cmd.js.map +1 -0
  556. package/dist/run-delivery.d.ts +71 -0
  557. package/dist/run-delivery.d.ts.map +1 -0
  558. package/dist/run-delivery.js +104 -0
  559. package/dist/run-delivery.js.map +1 -0
  560. package/dist/run-ended.d.ts +75 -0
  561. package/dist/run-ended.d.ts.map +1 -0
  562. package/dist/run-ended.js +27 -0
  563. package/dist/run-ended.js.map +1 -0
  564. package/dist/run-ending-locator.d.ts +125 -0
  565. package/dist/run-ending-locator.d.ts.map +1 -0
  566. package/dist/run-ending-locator.js +133 -0
  567. package/dist/run-ending-locator.js.map +1 -0
  568. package/dist/run-launcher.d.ts +459 -0
  569. package/dist/run-launcher.d.ts.map +1 -0
  570. package/dist/run-launcher.js +652 -0
  571. package/dist/run-launcher.js.map +1 -0
  572. package/dist/run-lease.d.ts +208 -0
  573. package/dist/run-lease.d.ts.map +1 -0
  574. package/dist/run-lease.js +301 -0
  575. package/dist/run-lease.js.map +1 -0
  576. package/dist/run-refusal-marks.d.ts +189 -0
  577. package/dist/run-refusal-marks.d.ts.map +1 -0
  578. package/dist/run-refusal-marks.js +249 -0
  579. package/dist/run-refusal-marks.js.map +1 -0
  580. package/dist/run-start-marks.d.ts +153 -0
  581. package/dist/run-start-marks.d.ts.map +1 -0
  582. package/dist/run-start-marks.js +269 -0
  583. package/dist/run-start-marks.js.map +1 -0
  584. package/dist/scan-cmd.d.ts +14 -0
  585. package/dist/scan-cmd.d.ts.map +1 -0
  586. package/dist/scan-cmd.js +270 -0
  587. package/dist/scan-cmd.js.map +1 -0
  588. package/dist/scan-events.d.ts +50 -0
  589. package/dist/scan-events.d.ts.map +1 -0
  590. package/dist/scan-events.js +91 -0
  591. package/dist/scan-events.js.map +1 -0
  592. package/dist/scan.d.ts +191 -0
  593. package/dist/scan.d.ts.map +1 -0
  594. package/dist/scan.js +417 -0
  595. package/dist/scan.js.map +1 -0
  596. package/dist/scope-rule.d.ts +148 -0
  597. package/dist/scope-rule.d.ts.map +1 -0
  598. package/dist/scope-rule.js +121 -0
  599. package/dist/scope-rule.js.map +1 -0
  600. package/dist/self-repo-id.d.ts +18 -0
  601. package/dist/self-repo-id.d.ts.map +1 -0
  602. package/dist/self-repo-id.js +70 -0
  603. package/dist/self-repo-id.js.map +1 -0
  604. package/dist/server-client.d.ts +766 -0
  605. package/dist/server-client.d.ts.map +1 -0
  606. package/dist/server-client.js +475 -0
  607. package/dist/server-client.js.map +1 -0
  608. package/dist/session-adapter-runtime.d.ts +195 -0
  609. package/dist/session-adapter-runtime.d.ts.map +1 -0
  610. package/dist/session-adapter-runtime.js +373 -0
  611. package/dist/session-adapter-runtime.js.map +1 -0
  612. package/dist/session-checkpoint-runtime.d.ts +62 -0
  613. package/dist/session-checkpoint-runtime.d.ts.map +1 -0
  614. package/dist/session-checkpoint-runtime.js +268 -0
  615. package/dist/session-checkpoint-runtime.js.map +1 -0
  616. package/dist/session-control-transport.d.ts +106 -0
  617. package/dist/session-control-transport.d.ts.map +1 -0
  618. package/dist/session-control-transport.js +232 -0
  619. package/dist/session-control-transport.js.map +1 -0
  620. package/dist/session-observation-store.d.ts +98 -0
  621. package/dist/session-observation-store.d.ts.map +1 -0
  622. package/dist/session-observation-store.js +155 -0
  623. package/dist/session-observation-store.js.map +1 -0
  624. package/dist/session-observe-runtime.d.ts +123 -0
  625. package/dist/session-observe-runtime.d.ts.map +1 -0
  626. package/dist/session-observe-runtime.js +317 -0
  627. package/dist/session-observe-runtime.js.map +1 -0
  628. package/dist/session-store.d.ts +98 -0
  629. package/dist/session-store.d.ts.map +1 -0
  630. package/dist/session-store.js +116 -0
  631. package/dist/session-store.js.map +1 -0
  632. package/dist/sessions-cmd.d.ts +202 -0
  633. package/dist/sessions-cmd.d.ts.map +1 -0
  634. package/dist/sessions-cmd.js +609 -0
  635. package/dist/sessions-cmd.js.map +1 -0
  636. package/dist/settings-overlay.d.ts +53 -0
  637. package/dist/settings-overlay.d.ts.map +1 -0
  638. package/dist/settings-overlay.js +175 -0
  639. package/dist/settings-overlay.js.map +1 -0
  640. package/dist/setup-prompt.d.ts +34 -0
  641. package/dist/setup-prompt.d.ts.map +1 -0
  642. package/dist/setup-prompt.js +92 -0
  643. package/dist/setup-prompt.js.map +1 -0
  644. package/dist/setup.d.ts +103 -0
  645. package/dist/setup.d.ts.map +1 -0
  646. package/dist/setup.js +283 -0
  647. package/dist/setup.js.map +1 -0
  648. package/dist/shared-grants.d.ts +164 -0
  649. package/dist/shared-grants.d.ts.map +1 -0
  650. package/dist/shared-grants.js +242 -0
  651. package/dist/shared-grants.js.map +1 -0
  652. package/dist/signals.d.ts +55 -0
  653. package/dist/signals.d.ts.map +1 -0
  654. package/dist/signals.js +85 -0
  655. package/dist/signals.js.map +1 -0
  656. package/dist/source-cmd.d.ts +201 -0
  657. package/dist/source-cmd.d.ts.map +1 -0
  658. package/dist/source-cmd.js +684 -0
  659. package/dist/source-cmd.js.map +1 -0
  660. package/dist/source-verdict.d.ts +99 -0
  661. package/dist/source-verdict.d.ts.map +1 -0
  662. package/dist/source-verdict.js +182 -0
  663. package/dist/source-verdict.js.map +1 -0
  664. package/dist/spend-ledger.d.ts +350 -0
  665. package/dist/spend-ledger.d.ts.map +1 -0
  666. package/dist/spend-ledger.js +546 -0
  667. package/dist/spend-ledger.js.map +1 -0
  668. package/dist/stale-run-sweep.d.ts +79 -0
  669. package/dist/stale-run-sweep.d.ts.map +1 -0
  670. package/dist/stale-run-sweep.js +116 -0
  671. package/dist/stale-run-sweep.js.map +1 -0
  672. package/dist/start-attempts.d.ts +385 -0
  673. package/dist/start-attempts.d.ts.map +1 -0
  674. package/dist/start-attempts.js +613 -0
  675. package/dist/start-attempts.js.map +1 -0
  676. package/dist/status-cmd.d.ts +28 -0
  677. package/dist/status-cmd.d.ts.map +1 -0
  678. package/dist/status-cmd.js +116 -0
  679. package/dist/status-cmd.js.map +1 -0
  680. package/dist/stop-follow-up.d.ts +107 -0
  681. package/dist/stop-follow-up.d.ts.map +1 -0
  682. package/dist/stop-follow-up.js +172 -0
  683. package/dist/stop-follow-up.js.map +1 -0
  684. package/dist/surface-lease.d.ts +118 -0
  685. package/dist/surface-lease.d.ts.map +1 -0
  686. package/dist/surface-lease.js +485 -0
  687. package/dist/surface-lease.js.map +1 -0
  688. package/dist/sync.d.ts +54 -0
  689. package/dist/sync.d.ts.map +1 -0
  690. package/dist/sync.js +93 -0
  691. package/dist/sync.js.map +1 -0
  692. package/dist/syncing-ledger.d.ts +45 -0
  693. package/dist/syncing-ledger.d.ts.map +1 -0
  694. package/dist/syncing-ledger.js +53 -0
  695. package/dist/syncing-ledger.js.map +1 -0
  696. package/dist/temp-fixtures.d.ts +68 -0
  697. package/dist/temp-fixtures.d.ts.map +1 -0
  698. package/dist/temp-fixtures.js +38 -0
  699. package/dist/temp-fixtures.js.map +1 -0
  700. package/dist/token-window.d.ts +84 -0
  701. package/dist/token-window.d.ts.map +1 -0
  702. package/dist/token-window.js +143 -0
  703. package/dist/token-window.js.map +1 -0
  704. package/dist/tool-bridge.d.ts +177 -0
  705. package/dist/tool-bridge.d.ts.map +1 -0
  706. package/dist/tool-bridge.js +329 -0
  707. package/dist/tool-bridge.js.map +1 -0
  708. package/dist/tool-call-record.d.ts +197 -0
  709. package/dist/tool-call-record.d.ts.map +1 -0
  710. package/dist/tool-call-record.js +276 -0
  711. package/dist/tool-call-record.js.map +1 -0
  712. package/dist/tool-protocol.d.ts +135 -0
  713. package/dist/tool-protocol.d.ts.map +1 -0
  714. package/dist/tool-protocol.js +104 -0
  715. package/dist/tool-protocol.js.map +1 -0
  716. package/dist/tool-worker.d.ts +3 -0
  717. package/dist/tool-worker.d.ts.map +1 -0
  718. package/dist/tool-worker.js +478 -0
  719. package/dist/tool-worker.js.map +1 -0
  720. package/dist/toolchain-mirror.d.ts +86 -0
  721. package/dist/toolchain-mirror.d.ts.map +1 -0
  722. package/dist/toolchain-mirror.js +307 -0
  723. package/dist/toolchain-mirror.js.map +1 -0
  724. package/dist/trusted-git.d.ts +243 -0
  725. package/dist/trusted-git.d.ts.map +1 -0
  726. package/dist/trusted-git.js +920 -0
  727. package/dist/trusted-git.js.map +1 -0
  728. package/dist/ui.d.ts +76 -0
  729. package/dist/ui.d.ts.map +1 -0
  730. package/dist/ui.js +118 -0
  731. package/dist/ui.js.map +1 -0
  732. package/dist/untrusted-exec.d.ts +275 -0
  733. package/dist/untrusted-exec.d.ts.map +1 -0
  734. package/dist/untrusted-exec.js +479 -0
  735. package/dist/untrusted-exec.js.map +1 -0
  736. package/dist/untrusted-gate.d.ts +73 -0
  737. package/dist/untrusted-gate.d.ts.map +1 -0
  738. package/dist/untrusted-gate.js +226 -0
  739. package/dist/untrusted-gate.js.map +1 -0
  740. package/dist/uploader.d.ts +153 -0
  741. package/dist/uploader.d.ts.map +1 -0
  742. package/dist/uploader.js +204 -0
  743. package/dist/uploader.js.map +1 -0
  744. package/dist/verifier.d.ts +66 -0
  745. package/dist/verifier.d.ts.map +1 -0
  746. package/dist/verifier.js +170 -0
  747. package/dist/verifier.js.map +1 -0
  748. package/dist/verify-apply.d.ts +26 -0
  749. package/dist/verify-apply.d.ts.map +1 -0
  750. package/dist/verify-apply.js +36 -0
  751. package/dist/verify-apply.js.map +1 -0
  752. package/dist/verify-cmd.d.ts +44 -0
  753. package/dist/verify-cmd.d.ts.map +1 -0
  754. package/dist/verify-cmd.js +125 -0
  755. package/dist/verify-cmd.js.map +1 -0
  756. package/dist/verify-pass.d.ts +73 -0
  757. package/dist/verify-pass.d.ts.map +1 -0
  758. package/dist/verify-pass.js +103 -0
  759. package/dist/verify-pass.js.map +1 -0
  760. package/dist/welcome.d.ts +43 -0
  761. package/dist/welcome.d.ts.map +1 -0
  762. package/dist/welcome.js +116 -0
  763. package/dist/welcome.js.map +1 -0
  764. package/dist/workspace-provisioner.d.ts +65 -0
  765. package/dist/workspace-provisioner.d.ts.map +1 -0
  766. package/dist/workspace-provisioner.js +66 -0
  767. package/dist/workspace-provisioner.js.map +1 -0
  768. package/dist/workspace-quarantine.d.ts +64 -0
  769. package/dist/workspace-quarantine.d.ts.map +1 -0
  770. package/dist/workspace-quarantine.js +156 -0
  771. package/dist/workspace-quarantine.js.map +1 -0
  772. package/dist/workspace-residue-sweep.d.ts +113 -0
  773. package/dist/workspace-residue-sweep.d.ts.map +1 -0
  774. package/dist/workspace-residue-sweep.js +158 -0
  775. package/dist/workspace-residue-sweep.js.map +1 -0
  776. package/dist/workspace.d.ts +639 -0
  777. package/dist/workspace.d.ts.map +1 -0
  778. package/dist/workspace.js +2026 -0
  779. package/dist/workspace.js.map +1 -0
  780. package/package.json +54 -6
  781. package/win/CredProbe.cs +64 -0
  782. package/win/FakeClaude.cs +56 -0
  783. package/win/HandleProbe.cs +116 -0
  784. package/win/TokenProbe.cs +53 -0
  785. package/win/appcontainer.ps1 +500 -0
@@ -0,0 +1,406 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EVIDENCE_MAX_CHARS = exports.EVIDENCE_MAX_LINES = void 0;
4
+ exports.governedServerOf = governedServerOf;
5
+ exports.runGovernedAction = runGovernedAction;
6
+ exports.evidenceLines = evidenceLines;
7
+ exports.describeGovernedResult = describeGovernedResult;
8
+ const governed_approvals_1 = require("./governed-approvals");
9
+ const governed_broker_1 = require("./governed-broker");
10
+ const core_1 = require("@looply/core");
11
+ const config_1 = require("./config");
12
+ /**
13
+ * The governed surface, narrowed out of the full client.
14
+ *
15
+ * BUILT HERE RATHER THAN AT THE CALL SITE, and that is not tidiness. The
16
+ * composition root is on a list of files asserted to contain no claim
17
+ * vocabulary at all, and writing these six lines there would put the words back
18
+ * into exactly the file the guard exists to keep clean. It also keeps the
19
+ * narrowing discipline `openGoalServer` already follows: the client itself
20
+ * never leaves the function that made it.
21
+ */
22
+ function governedServerOf(client) {
23
+ return {
24
+ projectApproval: (p, id) => client.projectApproval(p, id),
25
+ claimApproval: (p, id, input) => client.claimApproval(p, id, input),
26
+ beginExecution: (p, id, input) => client.beginExecution(p, id, input),
27
+ settleExecution: (p, id, input) => client.settleExecution(p, id, input),
28
+ assignExecutionResult: (p, id, runId) => client.assignExecutionResult(p, id, runId),
29
+ acknowledgeExecutionResult: (p, id, runId) => client.acknowledgeExecutionResult(p, id, runId),
30
+ };
31
+ }
32
+ async function runGovernedAction(deps, input) {
33
+ const say = deps.log ?? (() => { });
34
+ const refused = (because) => ({ kind: 'refused', because });
35
+ // ── the durable chain, before anything is read from the server ────────────
36
+ if (input.commandId === undefined || input.commandId.length === 0) {
37
+ // No Start spawned this. A direct `looply run` lands here and stops, which
38
+ // is the whole of C5 in one branch.
39
+ return refused('a governed action needs the Start that authorised it');
40
+ }
41
+ let reservation;
42
+ try {
43
+ reservation = await deps.reservations.reservationOf(input.approvalId);
44
+ }
45
+ catch (e) {
46
+ return refused(`the reservation for that action could not be read (${e.message})`);
47
+ }
48
+ if (reservation === null) {
49
+ return refused('no Start has reserved that action on this machine');
50
+ }
51
+ if (reservation.requestId !== input.commandId) {
52
+ return refused('that action was reserved by a different Start');
53
+ }
54
+ // ── the approval, as the server holds it NOW ──────────────────────────────
55
+ let row;
56
+ try {
57
+ // Reading ONE approval settles a window that has closed, so a claim can
58
+ // never be taken a moment after the authority ran out.
59
+ row = await deps.server.projectApproval(input.projectId, input.approvalId);
60
+ }
61
+ catch (e) {
62
+ // NO CONSEQUENTIAL EFFECT WITHOUT AN AUTHORITATIVE READ.
63
+ return refused(`the approval could not be read (${e.message})`);
64
+ }
65
+ if (row === null || typeof row !== 'object' || row.id !== input.approvalId) {
66
+ return refused('the server answered with something that is not that approval');
67
+ }
68
+ if (row.projectId !== input.projectId)
69
+ return refused('that approval belongs to another project');
70
+ if (row.goalId !== input.goalId || row.goalVersion !== input.goalVersion) {
71
+ return refused('that approval was raised for a different pursuit');
72
+ }
73
+ if (typeof row.actionFingerprint !== 'string' || row.actionFingerprint.length === 0) {
74
+ return refused('the server returned an approval this build cannot read');
75
+ }
76
+ // ── may this project publish at all? ─────────────────────────────────────
77
+ //
78
+ // ASKED HERE, BEFORE THE CLAIM, and never again afterwards. The action type
79
+ // comes from the row rather than from anything local, and `actionPublishes`
80
+ // fails closed for a type this build does not know.
81
+ if (row.state !== 'claimed' &&
82
+ (0, core_1.actionPublishes)(row.actionType) &&
83
+ !(0, config_1.mayPublish)(input.publishPolicy ?? 'never')) {
84
+ return refused(`${String(row.actionType)} would leave this machine, and this project's publish policy is ${input.publishPolicy ?? 'never'}`);
85
+ }
86
+ // ── the claim ─────────────────────────────────────────────────────────────
87
+ const claimRef = (0, governed_approvals_1.claimRefFor)(reservation);
88
+ let claimId;
89
+ if (row.state === 'claimed') {
90
+ // ALREADY OURS, or nobody's business. A machine that claimed and died
91
+ // leaves exactly this, and the reservation is what lets a later process
92
+ // present the identical key rather than ask for a second authority.
93
+ if (typeof row.claimId !== 'string' || row.claimId.length === 0) {
94
+ return refused('that approval is claimed and the server did not say by what');
95
+ }
96
+ claimId = row.claimId;
97
+ }
98
+ else if (row.state === 'approved') {
99
+ if (typeof row.version !== 'number') {
100
+ return refused('the server returned an approval with no version to claim against');
101
+ }
102
+ let taken;
103
+ try {
104
+ taken = await deps.server.claimApproval(input.projectId, input.approvalId, {
105
+ claimRef,
106
+ expectedFingerprint: row.actionFingerprint,
107
+ expectedVersion: row.version,
108
+ });
109
+ }
110
+ catch (e) {
111
+ // Denied, revoked, expired or context-stale between the read and the
112
+ // write, or another machine got there first. Nothing was attempted.
113
+ return refused(`that action could not be claimed (${e.message})`);
114
+ }
115
+ if (typeof taken.claimId !== 'string' || taken.claimId.length === 0) {
116
+ return refused('the claim was accepted and the server named no claim');
117
+ }
118
+ claimId = taken.claimId;
119
+ }
120
+ else {
121
+ // requested, denied, revoked, expired. A person has not answered, or has
122
+ // answered no — either way this is not a governed execution, and the
123
+ // ordinary resume path is what carries a refusal to a model.
124
+ return refused(`that approval is ${String(row.state)}, which is not something to carry out`);
125
+ }
126
+ // ── one execution identity, from the server ───────────────────────────────
127
+ let envelope;
128
+ try {
129
+ envelope = await deps.server.beginExecution(input.projectId, input.approvalId, {
130
+ claimId,
131
+ expectedFingerprint: row.actionFingerprint,
132
+ });
133
+ }
134
+ catch (e) {
135
+ return refused(`the attempt could not be recorded (${e.message})`);
136
+ }
137
+ const brokerEnvelope = brokerEnvelopeOf(envelope);
138
+ if (typeof brokerEnvelope === 'string')
139
+ return refused(brokerEnvelope);
140
+ /**
141
+ * IS THIS ATTEMPT STILL OURS TO MAKE?
142
+ *
143
+ * `begin` is idempotent, so an execution that already SETTLED comes back here
144
+ * looking exactly like one that has just been created. Without this the run
145
+ * went straight from the envelope to `reconcile`, and from
146
+ * `observed-not-executed` to EXECUTE — against an attempt that was already
147
+ * over.
148
+ *
149
+ * The daemon's Start gate refuses a Start while an attempt is ambiguous, so
150
+ * in ordinary running this was unreachable. But that is ONE guard, in another
151
+ * process, and "terminal for automation" has to be true in the module that
152
+ * ACTS, not only in the one that admits Starts. `takeClaim` carries four
153
+ * independent predicates for the same reason.
154
+ *
155
+ * The classification is `classifyGovernedRecovery`'s, so the rule about what
156
+ * may be done with an unfinished attempt is written once, purely, and not
157
+ * restated here where it could drift.
158
+ */
159
+ const recovery = (0, core_1.classifyGovernedRecovery)({
160
+ executionId: envelope.executionId,
161
+ approvalId: envelope.approvalId,
162
+ state: envelope.executionState,
163
+ // Neither field bears on whether this run may ACT, and the envelope does
164
+ // not carry them. Delivery is decided by the server when it is asked for,
165
+ // and asking here would be a second opinion about somebody else's row.
166
+ resultAssignedRunId: null,
167
+ acknowledged: false,
168
+ });
169
+ if (recovery.kind === 'blocked') {
170
+ return { kind: 'stop', because: recovery.because };
171
+ }
172
+ if (recovery.kind === 'deliver') {
173
+ // Settled, and the answer belongs to whoever the server gives it to. This
174
+ // run may ask for it, but it may not attempt the action again.
175
+ say('that action already finished — picking the answer up rather than repeating it');
176
+ }
177
+ // ── LOOK BEFORE ACTING, ALWAYS ────────────────────────────────────────────
178
+ //
179
+ // Not "after a crash": a process cannot know whether it is the one that
180
+ // crashed. The only observation that permits acting is the one that says
181
+ // nothing happened, and everything else is settled from what was seen.
182
+ let outcome;
183
+ let evidence = {};
184
+ let reason;
185
+ if (recovery.kind === 'deliver') {
186
+ /**
187
+ * ALREADY SETTLED. The attempt is over and nobody has been told, so this
188
+ * run may ask for the answer and may NOT make the attempt again.
189
+ *
190
+ * It falls through to the ordinary tail rather than taking a path of its
191
+ * own: settling with the outcome the row already holds is idempotent by
192
+ * design — the server hands the row back, writes nothing and emits no
193
+ * second event — so the assign-and-acknowledge that follows is reached with
194
+ * no duplicated logic and no second place for delivery to be decided.
195
+ */
196
+ outcome = envelope.executionState === 'succeeded' ? 'success' : 'failure';
197
+ }
198
+ else {
199
+ const looked = await deps.broker.reconcile(brokerEnvelope);
200
+ const decided = (0, core_1.decideFromObservation)((0, governed_broker_1.observationOf)(looked));
201
+ if (decided.kind === 'settle') {
202
+ outcome = decided.outcome;
203
+ if (looked.kind === 'observed-success')
204
+ evidence = looked.evidence;
205
+ if (looked.kind === 'observed-failure' || looked.kind === 'ambiguous')
206
+ reason = looked.safeReason;
207
+ say(`already done — recording what was found rather than doing it again`);
208
+ }
209
+ else {
210
+ const result = await deps.broker.execute(brokerEnvelope);
211
+ outcome = (0, governed_broker_1.outcomeOf)(result);
212
+ evidence = result.evidence;
213
+ if (result.kind !== 'success')
214
+ reason = result.safeReason;
215
+ }
216
+ }
217
+ // ── record it ─────────────────────────────────────────────────────────────
218
+ let settled;
219
+ try {
220
+ settled = await deps.server.settleExecution(input.projectId, envelope.executionId, {
221
+ claimId,
222
+ expectedVersion: envelope.executionVersion,
223
+ expectedFingerprint: envelope.actionFingerprint,
224
+ outcome,
225
+ ...(reason === undefined ? {} : { reason }),
226
+ evidence,
227
+ });
228
+ }
229
+ catch (e) {
230
+ // The effect may be in the world and the record may not be. NOT a refusal
231
+ // that lets the run carry on: the next Start reconciles this same execution
232
+ // and finds out, which is the only safe way to learn.
233
+ return {
234
+ kind: 'stop',
235
+ because: `that action was attempted and the result could not be recorded (${e.message})`,
236
+ };
237
+ }
238
+ if (settled.state === 'ambiguous') {
239
+ // TERMINAL FOR AUTOMATION. No retry, no new claim, no new execution, and
240
+ // nothing to tell a model — the plan it would produce from "it may or may
241
+ // not have happened" is to try again.
242
+ return {
243
+ kind: 'stop',
244
+ because: 'nobody can tell whether that action happened — this one needs you',
245
+ };
246
+ }
247
+ if (settled.state !== 'succeeded' && settled.state !== 'failed') {
248
+ return { kind: 'stop', because: `that attempt is ${String(settled.state)}` };
249
+ }
250
+ // ── one run owns the answer ───────────────────────────────────────────────
251
+ try {
252
+ await deps.server.assignExecutionResult(input.projectId, envelope.executionId, input.runId);
253
+ }
254
+ catch (e) {
255
+ // Another run already took it, and it is never reassigned. Telling a model
256
+ // twice that a consequential act succeeded reads as permission to build on
257
+ // work already done.
258
+ return { kind: 'stop', because: `that answer belongs to another run (${e.message})` };
259
+ }
260
+ const result = {
261
+ approvalId: input.approvalId,
262
+ executionId: envelope.executionId,
263
+ actionType: envelope.actionType,
264
+ actionFingerprint: envelope.actionFingerprint,
265
+ outcome: settled.state,
266
+ display: envelope.display,
267
+ safeEvidence: evidence,
268
+ };
269
+ try {
270
+ await deps.server.acknowledgeExecutionResult(input.projectId, envelope.executionId, input.runId);
271
+ }
272
+ catch (e) {
273
+ // The answer is in hand but nothing durably says so. Stopping is the safe
274
+ // direction: carrying on would leave a pursuit that can never be told the
275
+ // result again, because the assignment is never given to a second run.
276
+ return { kind: 'stop', because: `that answer could not be taken up (${e.message})` };
277
+ }
278
+ say(`${result.outcome === 'succeeded' ? 'done' : 'not done'} — ${result.display}`);
279
+ return { kind: 'done', result };
280
+ }
281
+ /**
282
+ * The server's envelope, checked into the shape the broker will only accept.
283
+ *
284
+ * The action is REBUILT through 7B1's parser rather than cast. A 200 is not an
285
+ * answer, and this is the last point at which what a broker is about to act on
286
+ * can still be told apart from what somebody sent.
287
+ */
288
+ function brokerEnvelopeOf(env) {
289
+ if (env === null || typeof env !== 'object')
290
+ return 'the server answered with no execution';
291
+ if (typeof env.executionId !== 'string' || env.executionId.length === 0) {
292
+ return 'the server returned an execution with no id';
293
+ }
294
+ const parsed = (0, core_1.parseActionRequest)(env.actionRequest);
295
+ if (!parsed.ok)
296
+ return `the server returned an action this build cannot read — ${parsed.because}`;
297
+ if (parsed.request.fingerprint !== env.actionFingerprint) {
298
+ return 'the action the server returned is not the one this execution is for';
299
+ }
300
+ return {
301
+ executionId: env.executionId,
302
+ approvalId: env.approvalId,
303
+ claimId: env.claimId,
304
+ projectId: env.projectId,
305
+ machineId: env.machineId,
306
+ actionFingerprint: env.actionFingerprint,
307
+ actionRequest: parsed.request,
308
+ actionType: parsed.request.type,
309
+ display: env.display,
310
+ executionVersion: env.executionVersion,
311
+ executionState: env.executionState,
312
+ };
313
+ }
314
+ /**
315
+ * What a resumed model is told, as plain lines.
316
+ *
317
+ * PROSE, AND DELIBERATELY NOT JSON, for the reason `describeResolution` gives:
318
+ * the implementer's transcript is scanned for a structured declaration and the
319
+ * scan takes the FIRST one it finds, so a prompt containing something shaped
320
+ * like a request is a decoy an echoing model files for real.
321
+ */
322
+ /**
323
+ * WHAT A GUARANTEE RESTS ON, SAID BESIDE THE GUARANTEE (the audit’s H-06).
324
+ *
325
+ * 🔴 THE TWO ARMS OF THIS SENTENCE DISAGREED ABOUT SCOPE. The failure arm says
326
+ * "nothing was changed outside this machine" and scopes itself; the success arm
327
+ * said "it happened exactly once" and named nothing — and the success arm is the
328
+ * one a model acts on, because it ends "do not ask for it a second time".
329
+ *
330
+ * ⚠️ AND WHAT MAKES IT TRUE IS NOT THIS MACHINE. The audit reads the fixture
331
+ * executor's `createExclusive` and calls exactly-once local, which invites the
332
+ * conclusion that two machines could each do it once. They cannot: a claim by a
333
+ * second machine is refused by the server with `already_claimed`, behind a
334
+ * unique index, and its idempotent arm is reached only by the same machine under
335
+ * its own key. Two fences at two layers — the server stops a second MACHINE, the
336
+ * executor's own record stops the same machine doing it twice.
337
+ *
338
+ * ⚠️ IT CLAIMS NO MORE THAN THAT. It does not say the effect was verified against
339
+ * a remote — only `git.push` can say that, and it says it in its own evidence —
340
+ * and it promises nothing about a machine that never claimed.
341
+ */
342
+ exports.EVIDENCE_MAX_LINES = 6;
343
+ /** Bound on one value, for the reason every free field on a prompt has one. */
344
+ exports.EVIDENCE_MAX_CHARS = 120;
345
+ /**
346
+ * The broker's own evidence, as lines in the shape this block already uses.
347
+ *
348
+ * 🔴 CARRIED HERE SINCE IT WAS WRITTEN AND READ BY NOTHING. `safeEvidence` is
349
+ * declared on the context, populated where the result is taken up, and shown by
350
+ * nobody — while for `git.push` it holds `remote`, `ref`, `sha` and the
351
+ * `observedSha` the executor actually read back: the observation that makes
352
+ * "exactly once" checkable rather than believable. Its own type calls it
353
+ * "bounded, deterministic where possible, and never secret".
354
+ *
355
+ * ⚠️ LINES, NEVER JSON. The block's own rule: the transcript is scanned for a
356
+ * structured declaration and the scan takes the first one it finds, so anything
357
+ * here shaped like a request is a decoy an echoing model files for real. This
358
+ * uses the same ` key : value` shape as the two lines above it and no other.
359
+ */
360
+ function evidenceLines(e) {
361
+ const keys = Object.keys(e).sort();
362
+ const shown = keys.slice(0, exports.EVIDENCE_MAX_LINES);
363
+ const width = Math.max(0, ...shown.map((k) => k.length));
364
+ const lines = shown.map((k) => {
365
+ const raw = String(e[k]).replace(/\s+/g, ' ').trim();
366
+ const value = raw.length <= exports.EVIDENCE_MAX_CHARS
367
+ ? raw
368
+ : `${raw.slice(0, Math.max(0, exports.EVIDENCE_MAX_CHARS - 1)).trimEnd()}…`;
369
+ return ` ${k.padEnd(width)} : ${value}`;
370
+ });
371
+ // A cut list says so, for the same reason a cut sentence does.
372
+ if (keys.length > shown.length)
373
+ lines.push(` … and ${keys.length - shown.length} more`);
374
+ return lines;
375
+ }
376
+ function describeGovernedResult(r) {
377
+ const head = r.outcome === 'succeeded'
378
+ ? 'A PERSON APPROVED SOMETHING AND IT HAS NOW BEEN DONE.'
379
+ : 'A PERSON APPROVED SOMETHING AND IT DID NOT HAPPEN.';
380
+ const tail = r.outcome === 'succeeded'
381
+ ? [
382
+ 'It happened exactly once, and it will not happen again on its own.',
383
+ 'That rests on the server rather than on this run: one claim was issued for',
384
+ 'this approval and a second is refused. What the executor observed is above,',
385
+ 'so you can check it rather than take it on trust.',
386
+ 'Carry on from there. Do not ask for it a second time.',
387
+ ]
388
+ : [
389
+ 'Nothing was changed outside this machine, and the authority for it is spent.',
390
+ 'Plan around it. Asking for the same thing again needs a new approval, so',
391
+ 'only do that if it is genuinely the way forward.',
392
+ ];
393
+ const seen = evidenceLines(r.safeEvidence);
394
+ return [
395
+ head,
396
+ '',
397
+ ` what was approved : ${r.display}`,
398
+ ` what happened : ${r.outcome}`,
399
+ // Nothing at all when the executor recorded nothing — an empty heading would
400
+ // be an invitation to wonder what was withheld.
401
+ ...(seen.length === 0 ? [] : ['', 'what the executor saw:', ...seen]),
402
+ '',
403
+ ...tail,
404
+ ].join('\n');
405
+ }
406
+ //# sourceMappingURL=governed-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"governed-run.js","sourceRoot":"","sources":["../src/governed-run.ts"],"names":[],"mappings":";;;AAsJA,4CAgBC;AAoCD,8CA6PC;AAiFD,sCAeC;AAED,wDA+BC;AAnkBD,6DAI8B;AAC9B,uDAM2B;AAC3B,uCAMsB;AACtB,qCAA0D;AAoH1D;;;;;;;;;GASG;AACH,SAAgB,gBAAgB,CAAC,MAOhC;IACC,OAAO;QACL,eAAe,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,EAAE,CAAC;QACzD,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC;QACnE,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC;QACrE,eAAe,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,EAAE,EA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C,CAAC;YACE,8EAA8E;YAC9E,0EAA0E;YAC1E,kDAAkD;SACnD,CAAC;IACR,MAAM,IAAI,GAAG,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IAC3C,OAAO;QACL,IAAI;QACJ,EAAE;QACF,yBAAyB,CAAC,CAAC,OAAO,EAAE;QACpC,yBAAyB,CAAC,CAAC,OAAO,EAAE;QACpC,6EAA6E;QAC7E,gDAAgD;QAChD,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,wBAAwB,EAAE,GAAG,IAAI,CAAC,CAAC;QACrE,EAAE;QACF,GAAG,IAAI;KACR,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,63 @@
1
+ import type { GoalAutonomyState, GoalState, MachineSettlableState } from '@looply/core';
2
+ import type { Reconciliation } from './autonomy-controller';
3
+ import type { AutonomyProgress } from './autonomy-store';
4
+ import type { ServerAutonomy } from './server-client';
5
+ /**
6
+ * WHETHER THE SERVER STILL AUTHORIZES THIS GRANT.
7
+ *
8
+ * Pure, and shared by production and every test — there is one answer to "may
9
+ * this machine spend another of a person's Starts", and a second derivation
10
+ * living somewhere else is how two halves of a system come to disagree about
11
+ * somebody's permission.
12
+ *
13
+ * ─────────────────────────────────────────────────────────────────────────────
14
+ * IDENTITY BEFORE STATE
15
+ *
16
+ * It is not enough that the server says `authorized`. Every immutable field of
17
+ * a grant is stamped at authorization and never moves again, so a response
18
+ * whose goal, version, generation, ceiling or expiry differs from the one this
19
+ * machine adopted is not a newer answer about the same grant — it is a
20
+ * different grant, or a build that disagrees about what a grant is. Either way
21
+ * the two records contradict each other, and this is not the place to pick a
22
+ * side.
23
+ *
24
+ * ─────────────────────────────────────────────────────────────────────────────
25
+ * A NETWORK FAILURE IS NOT AN ENDING
26
+ *
27
+ * `unreachable` never becomes `cancelled`, `expired` or anything else terminal.
28
+ * Not reaching the server means this machine does not currently know whether it
29
+ * may spend — which is a reason to wait, and never a statement about a person's
30
+ * goal.
31
+ */
32
+ /**
33
+ * The goal as the server holds it right now.
34
+ *
35
+ * Not optional. A machine cannot decide whether to spend another of a person's
36
+ * Starts without knowing whether the wording it was authorized for is still the
37
+ * wording — and an absent answer must not read as "unchanged".
38
+ */
39
+ export interface CurrentGoal {
40
+ version: number;
41
+ state: GoalState;
42
+ }
43
+ /** What the machine holds locally, narrowed to what reconciliation compares. */
44
+ export type LocalGrant = Pick<AutonomyProgress, 'controllerId' | 'goalId' | 'goalVersion' | 'maxStarts' | 'expiresAt'>;
45
+ /** The immutable fields, named once so the comparison and its test agree. */
46
+ export declare const IMMUTABLE_GRANT_FIELDS: readonly ["controllerId", "goalId", "goalVersion", "maxStarts", "expiresAt"];
47
+ /**
48
+ * Compare what the server says with what this machine adopted.
49
+ *
50
+ * `remote` is null when the server could be reached but has no such grant —
51
+ * which is a contradiction rather than an absence, since the machine only holds
52
+ * grants the server minted.
53
+ */
54
+ export declare function reconcileGrant(local: LocalGrant, remote: ServerAutonomy | null, goal: CurrentGoal | null, now: number): Reconciliation;
55
+ /**
56
+ * The states a machine may report about itself, as the controller's vocabulary.
57
+ *
58
+ * The controller can conclude things the machine may not SAY — `cancelled` is
59
+ * the one that matters, because a person owns it. Mapping happens here so the
60
+ * refusal that produced it is not quietly rewritten somewhere further out.
61
+ */
62
+ export declare function settlableState(state: GoalAutonomyState): MachineSettlableState | null;
63
+ //# sourceMappingURL=grant-reconcile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grant-reconcile.d.ts","sourceRoot":"","sources":["../src/grant-reconcile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,gFAAgF;AAChF,MAAM,MAAM,UAAU,GAAG,IAAI,CAC3B,gBAAgB,EAChB,cAAc,GAAG,QAAQ,GAAG,aAAa,GAAG,WAAW,GAAG,WAAW,CACtE,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,sBAAsB,8EAMzB,CAAC;AAEX;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,cAAc,GAAG,IAAI,EAC7B,IAAI,EAAE,WAAW,GAAG,IAAI,EACxB,GAAG,EAAE,MAAM,GACV,cAAc,CAgEhB;AAcD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,iBAAiB,GAAG,qBAAqB,GAAG,IAAI,CAoBrF"}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IMMUTABLE_GRANT_FIELDS = void 0;
4
+ exports.reconcileGrant = reconcileGrant;
5
+ exports.settlableState = settlableState;
6
+ /** The immutable fields, named once so the comparison and its test agree. */
7
+ exports.IMMUTABLE_GRANT_FIELDS = [
8
+ 'controllerId',
9
+ 'goalId',
10
+ 'goalVersion',
11
+ 'maxStarts',
12
+ 'expiresAt',
13
+ ];
14
+ /**
15
+ * Compare what the server says with what this machine adopted.
16
+ *
17
+ * `remote` is null when the server could be reached but has no such grant —
18
+ * which is a contradiction rather than an absence, since the machine only holds
19
+ * grants the server minted.
20
+ */
21
+ function reconcileGrant(local, remote, goal, now) {
22
+ if (remote === null) {
23
+ return {
24
+ kind: 'mismatch',
25
+ because: `the server has no record of grant ${local.controllerId}`,
26
+ };
27
+ }
28
+ if (goal === null) {
29
+ // A grant for a goal the server does not have. Not an ending — a
30
+ // contradiction, and not something to pick a side of.
31
+ return { kind: 'mismatch', because: `the server has no goal ${local.goalId}` };
32
+ }
33
+ // IDENTITY FIRST. A grant that disagrees about what it is for cannot be
34
+ // reasoned about, whatever state it claims.
35
+ const differs = describeDrift(local, remote);
36
+ if (differs !== null)
37
+ return { kind: 'mismatch', because: differs };
38
+ // THE GOAL AS IT STANDS NOW, and this is REQUIRED rather than optional.
39
+ //
40
+ // It was optional and production supplied nothing, which meant "assume the
41
+ // wording has not changed" — a default that is wrong exactly when it matters.
42
+ // Nothing on the server writes `superseded`, so a grant for G@8 goes on
43
+ // reading `authorized` after somebody edits the goal to G@9, and the machine
44
+ // would spend a whole Start of their budget discovering, inside the bounded
45
+ // run, something the server already knew.
46
+ //
47
+ // Checked BEFORE the grant's own state: a grant that is live for wording that
48
+ // no longer exists is superseded whatever its row says.
49
+ if (goal.state === 'abandoned') {
50
+ return { kind: 'ended', state: 'abandoned', because: 'the goal was given up on' };
51
+ }
52
+ if (goal.version !== remote.goalVersion) {
53
+ return {
54
+ kind: 'ended',
55
+ state: 'superseded',
56
+ because: `the goal has moved to version ${goal.version}`,
57
+ };
58
+ }
59
+ if (remote.state !== 'authorized') {
60
+ return {
61
+ kind: 'ended',
62
+ state: remote.state,
63
+ because: remote.reason ?? `the pursuit is ${remote.state}`,
64
+ };
65
+ }
66
+ // The clock, checked against the SERVER's copy. A machine whose clock ran
67
+ // fast must not be able to extend an authorization, and one whose clock ran
68
+ // slow must not keep spending past the end.
69
+ const expires = Date.parse(remote.expiresAt);
70
+ if (Number.isNaN(expires)) {
71
+ return { kind: 'mismatch', because: 'the expiry on this grant cannot be read' };
72
+ }
73
+ if (expires <= now) {
74
+ return {
75
+ kind: 'ended',
76
+ state: 'budget_exhausted',
77
+ because: 'the time this grant was given has run out',
78
+ };
79
+ }
80
+ return { kind: 'active', maxStarts: remote.maxStarts };
81
+ }
82
+ /** The first immutable field the two records disagree about, in words. */
83
+ function describeDrift(local, remote) {
84
+ for (const field of exports.IMMUTABLE_GRANT_FIELDS) {
85
+ const mine = local[field];
86
+ const theirs = remote[field];
87
+ if (mine !== theirs) {
88
+ return `this grant's ${field} is ${String(mine)} here and ${String(theirs)} on the server`;
89
+ }
90
+ }
91
+ return null;
92
+ }
93
+ /**
94
+ * The states a machine may report about itself, as the controller's vocabulary.
95
+ *
96
+ * The controller can conclude things the machine may not SAY — `cancelled` is
97
+ * the one that matters, because a person owns it. Mapping happens here so the
98
+ * refusal that produced it is not quietly rewritten somewhere further out.
99
+ */
100
+ function settlableState(state) {
101
+ switch (state) {
102
+ case 'satisfied':
103
+ case 'human_required':
104
+ case 'budget_exhausted':
105
+ case 'superseded':
106
+ case 'abandoned':
107
+ return state;
108
+ case 'cancelled':
109
+ // A person's word. The machine may observe it and stop; it may not write
110
+ // it, so there is nothing to project.
111
+ return null;
112
+ case 'authorized':
113
+ // Not an ending at all.
114
+ return null;
115
+ default: {
116
+ const never = state;
117
+ throw new Error(`no settlable mapping for ${String(never)}`);
118
+ }
119
+ }
120
+ }
121
+ //# sourceMappingURL=grant-reconcile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grant-reconcile.js","sourceRoot":"","sources":["../src/grant-reconcile.ts"],"names":[],"mappings":";;;AAmEA,wCAqEC;AAqBD,wCAoBC;AA9HD,6EAA6E;AAChE,QAAA,sBAAsB,GAAG;IACpC,cAAc;IACd,QAAQ;IACR,aAAa;IACb,WAAW;IACX,WAAW;CACH,CAAC;AAEX;;;;;;GAMG;AACH,SAAgB,cAAc,CAC5B,KAAiB,EACjB,MAA6B,EAC7B,IAAwB,EACxB,GAAW;IAEX,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,qCAAqC,KAAK,CAAC,YAAY,EAAE;SACnE,CAAC;IACJ,CAAC;IACD,IAAI,IAA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