@intentius/chant 0.90.0 → 0.93.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 (402) hide show
  1. package/dist/cli/commands/build.d.ts.map +1 -1
  2. package/dist/cli/commands/lint.d.ts.map +1 -1
  3. package/dist/cli/handlers/components.d.ts +8 -0
  4. package/dist/cli/handlers/components.d.ts.map +1 -1
  5. package/dist/cli/handlers/graph.d.ts.map +1 -1
  6. package/dist/cli/handlers/operator.d.ts +20 -0
  7. package/dist/cli/handlers/operator.d.ts.map +1 -1
  8. package/dist/cli/handlers/run.d.ts.map +1 -1
  9. package/dist/cli/main.d.ts.map +1 -1
  10. package/dist/cli/mcp/workspace-tools.d.ts +7 -4
  11. package/dist/cli/mcp/workspace-tools.d.ts.map +1 -1
  12. package/dist/cli/plugins.d.ts.map +1 -1
  13. package/dist/cli/registry.d.ts +42 -1
  14. package/dist/cli/registry.d.ts.map +1 -1
  15. package/dist/codegen/pinned-upgrade.d.ts.map +1 -1
  16. package/dist/components/verbs/vuln-scan.d.ts +72 -0
  17. package/dist/components/verbs/vuln-scan.d.ts.map +1 -1
  18. package/dist/config.d.ts +22 -0
  19. package/dist/config.d.ts.map +1 -1
  20. package/dist/lexicon-module.d.ts +22 -0
  21. package/dist/lexicon-module.d.ts.map +1 -1
  22. package/dist/lifecycle/converge-ledger.d.ts +19 -0
  23. package/dist/lifecycle/converge-ledger.d.ts.map +1 -1
  24. package/dist/lifecycle/git.d.ts +40 -5
  25. package/dist/lifecycle/git.d.ts.map +1 -1
  26. package/dist/lifecycle/lease.d.ts +72 -16
  27. package/dist/lifecycle/lease.d.ts.map +1 -1
  28. package/dist/lifecycle/member-ledger.d.ts +3 -2
  29. package/dist/lifecycle/member-ledger.d.ts.map +1 -1
  30. package/dist/lifecycle/plan-ledger.d.ts +114 -0
  31. package/dist/lifecycle/plan-ledger.d.ts.map +1 -0
  32. package/dist/lifecycle/run-ledger.d.ts +2 -0
  33. package/dist/lifecycle/run-ledger.d.ts.map +1 -1
  34. package/dist/lifecycle/symptoms.d.ts +51 -0
  35. package/dist/lifecycle/symptoms.d.ts.map +1 -1
  36. package/dist/lifecycle/work-lease.d.ts +140 -0
  37. package/dist/lifecycle/work-lease.d.ts.map +1 -0
  38. package/dist/lint/rules/index.d.ts +4 -2
  39. package/dist/lint/rules/index.d.ts.map +1 -1
  40. package/dist/lint/rules/op/index.d.ts +14 -3
  41. package/dist/lint/rules/op/index.d.ts.map +1 -1
  42. package/dist/lint/rules/op/ops014-converge-rule-refusals.d.ts.map +1 -1
  43. package/dist/lint/rules/op/sys010-key-over-plain-http.d.ts +29 -0
  44. package/dist/lint/rules/op/sys010-key-over-plain-http.d.ts.map +1 -0
  45. package/dist/lint/rules/sys001-no-literal-key.d.ts +3 -0
  46. package/dist/lint/rules/sys001-no-literal-key.d.ts.map +1 -0
  47. package/dist/op/__fixtures__/decide-stub-backend.d.ts +53 -0
  48. package/dist/op/__fixtures__/decide-stub-backend.d.ts.map +1 -0
  49. package/dist/op/activities/activity-contracts.d.ts +203 -2
  50. package/dist/op/activities/activity-contracts.d.ts.map +1 -1
  51. package/dist/op/activities/apply.d.ts.map +1 -1
  52. package/dist/op/activities/change-coverage.d.ts +44 -0
  53. package/dist/op/activities/change-coverage.d.ts.map +1 -0
  54. package/dist/op/activities/converge.d.ts +24 -1
  55. package/dist/op/activities/converge.d.ts.map +1 -1
  56. package/dist/op/activities/decide.d.ts +107 -0
  57. package/dist/op/activities/decide.d.ts.map +1 -0
  58. package/dist/op/activities/index.d.ts +10 -0
  59. package/dist/op/activities/index.d.ts.map +1 -1
  60. package/dist/op/activities/shell.d.ts +32 -0
  61. package/dist/op/activities/shell.d.ts.map +1 -1
  62. package/dist/op/activities/source-release.d.ts +86 -0
  63. package/dist/op/activities/source-release.d.ts.map +1 -0
  64. package/dist/op/activities/source-rollback.d.ts +100 -0
  65. package/dist/op/activities/source-rollback.d.ts.map +1 -0
  66. package/dist/op/activities/work-evidence.d.ts +42 -0
  67. package/dist/op/activities/work-evidence.d.ts.map +1 -0
  68. package/dist/op/activity-contract.d.ts +1 -0
  69. package/dist/op/activity-contract.d.ts.map +1 -1
  70. package/dist/op/activity-profiles.d.ts +16 -0
  71. package/dist/op/activity-profiles.d.ts.map +1 -1
  72. package/dist/op/builders.d.ts +84 -2
  73. package/dist/op/builders.d.ts.map +1 -1
  74. package/dist/op/composites/converge-op.d.ts +31 -4
  75. package/dist/op/composites/converge-op.d.ts.map +1 -1
  76. package/dist/op/decide-backend.d.ts +116 -0
  77. package/dist/op/decide-backend.d.ts.map +1 -0
  78. package/dist/op/decide-config.d.ts +120 -0
  79. package/dist/op/decide-config.d.ts.map +1 -0
  80. package/dist/op/decide-read-inputs.d.ts +40 -0
  81. package/dist/op/decide-read-inputs.d.ts.map +1 -0
  82. package/dist/op/discover.d.ts +25 -0
  83. package/dist/op/discover.d.ts.map +1 -1
  84. package/dist/op/gate-wait.d.ts +43 -0
  85. package/dist/op/gate-wait.d.ts.map +1 -0
  86. package/dist/op/gate.d.ts +5 -2
  87. package/dist/op/gate.d.ts.map +1 -1
  88. package/dist/op/index.d.ts +18 -5
  89. package/dist/op/index.d.ts.map +1 -1
  90. package/dist/op/lifecycle-receipt-store.d.ts +34 -0
  91. package/dist/op/lifecycle-receipt-store.d.ts.map +1 -0
  92. package/dist/op/local-executor.d.ts +48 -4
  93. package/dist/op/local-executor.d.ts.map +1 -1
  94. package/dist/op/local-output.d.ts +2 -0
  95. package/dist/op/local-output.d.ts.map +1 -1
  96. package/dist/op/op-ir.d.ts +12 -1
  97. package/dist/op/op-ir.d.ts.map +1 -1
  98. package/dist/op/op-verb-class.d.ts.map +1 -1
  99. package/dist/op/operator.d.ts +126 -1
  100. package/dist/op/operator.d.ts.map +1 -1
  101. package/dist/op/runtime.d.ts +46 -5
  102. package/dist/op/runtime.d.ts.map +1 -1
  103. package/dist/op/runtimes/local.d.ts.map +1 -1
  104. package/dist/op/source-archive.d.ts +63 -0
  105. package/dist/op/source-archive.d.ts.map +1 -0
  106. package/dist/op/step-output-ref.d.ts +2 -2
  107. package/dist/op/step-output-ref.d.ts.map +1 -1
  108. package/dist/op/steward-points.d.ts +136 -0
  109. package/dist/op/steward-points.d.ts.map +1 -0
  110. package/dist/op/steward-turn.d.ts +53 -0
  111. package/dist/op/steward-turn.d.ts.map +1 -0
  112. package/dist/op/steward.d.ts +161 -0
  113. package/dist/op/steward.d.ts.map +1 -0
  114. package/dist/op/types.d.ts +58 -0
  115. package/dist/op/types.d.ts.map +1 -1
  116. package/dist/op/work-lease-decl.d.ts +18 -0
  117. package/dist/op/work-lease-decl.d.ts.map +1 -0
  118. package/dist/op/work-lease-run.d.ts +173 -0
  119. package/dist/op/work-lease-run.d.ts.map +1 -0
  120. package/dist/workspace/__fixtures__/decide-workspace.d.ts +100 -0
  121. package/dist/workspace/__fixtures__/decide-workspace.d.ts.map +1 -0
  122. package/dist/workspace/answers-ledger.d.ts +76 -0
  123. package/dist/workspace/answers-ledger.d.ts.map +1 -0
  124. package/dist/workspace/box-isolation.d.ts +99 -0
  125. package/dist/workspace/box-isolation.d.ts.map +1 -0
  126. package/dist/workspace/changes-cli.d.ts +16 -0
  127. package/dist/workspace/changes-cli.d.ts.map +1 -0
  128. package/dist/workspace/changes.d.ts +200 -0
  129. package/dist/workspace/changes.d.ts.map +1 -0
  130. package/dist/workspace/chant-migrations/chud-lexicon-exit-fly-site.d.ts +59 -0
  131. package/dist/workspace/chant-migrations/chud-lexicon-exit-fly-site.d.ts.map +1 -0
  132. package/dist/workspace/chant-migrations/chud-lexicon-exit-live-names.d.ts +51 -0
  133. package/dist/workspace/chant-migrations/chud-lexicon-exit-live-names.d.ts.map +1 -0
  134. package/dist/workspace/chant-migrations/chud-lexicon-exit-rollback.d.ts +26 -0
  135. package/dist/workspace/chant-migrations/chud-lexicon-exit-rollback.d.ts.map +1 -0
  136. package/dist/workspace/chant-migrations/chud-lexicon-exit-ship-inputs.d.ts +59 -0
  137. package/dist/workspace/chant-migrations/chud-lexicon-exit-ship-inputs.d.ts.map +1 -0
  138. package/dist/workspace/chant-migrations/chud-lexicon-exit-ship-policy.d.ts +22 -0
  139. package/dist/workspace/chant-migrations/chud-lexicon-exit-ship-policy.d.ts.map +1 -0
  140. package/dist/workspace/chant-migrations/chud-lexicon-exit.d.ts +71 -0
  141. package/dist/workspace/chant-migrations/chud-lexicon-exit.d.ts.map +1 -0
  142. package/dist/workspace/chant-migrations.d.ts +99 -0
  143. package/dist/workspace/chant-migrations.d.ts.map +1 -0
  144. package/dist/workspace/checks/box-isolation.d.ts +18 -0
  145. package/dist/workspace/checks/box-isolation.d.ts.map +1 -0
  146. package/dist/workspace/checks/boxes.d.ts +104 -0
  147. package/dist/workspace/checks/boxes.d.ts.map +1 -0
  148. package/dist/workspace/checks/diagrams.d.ts +31 -0
  149. package/dist/workspace/checks/diagrams.d.ts.map +1 -0
  150. package/dist/workspace/checks/records.d.ts +8 -0
  151. package/dist/workspace/checks/records.d.ts.map +1 -1
  152. package/dist/workspace/checks.d.ts +13 -1
  153. package/dist/workspace/checks.d.ts.map +1 -1
  154. package/dist/workspace/compose-graph.d.ts +2 -0
  155. package/dist/workspace/compose-graph.d.ts.map +1 -1
  156. package/dist/workspace/conformance/index.d.ts.map +1 -1
  157. package/dist/workspace/decide.d.ts +229 -0
  158. package/dist/workspace/decide.d.ts.map +1 -0
  159. package/dist/workspace/decision-points.schema.json +137 -0
  160. package/dist/workspace/declaration.d.ts +103 -0
  161. package/dist/workspace/declaration.d.ts.map +1 -1
  162. package/dist/workspace/declaration.schema.json +285 -0
  163. package/dist/workspace/declared-kinds.d.ts +32 -0
  164. package/dist/workspace/declared-kinds.d.ts.map +1 -1
  165. package/dist/workspace/generated-files.d.ts +7 -0
  166. package/dist/workspace/generated-files.d.ts.map +1 -1
  167. package/dist/workspace/intent.d.ts.map +1 -1
  168. package/dist/workspace/lineage-check.d.ts +3 -0
  169. package/dist/workspace/lineage-check.d.ts.map +1 -1
  170. package/dist/workspace/lineage-upgrade.d.ts +6 -1
  171. package/dist/workspace/lineage-upgrade.d.ts.map +1 -1
  172. package/dist/workspace/ls.d.ts +39 -1
  173. package/dist/workspace/ls.d.ts.map +1 -1
  174. package/dist/workspace/point-answer.schema.json +95 -0
  175. package/dist/workspace/points-cli.d.ts +113 -0
  176. package/dist/workspace/points-cli.d.ts.map +1 -0
  177. package/dist/workspace/points.d.ts +320 -0
  178. package/dist/workspace/points.d.ts.map +1 -0
  179. package/dist/workspace/reason-codes.d.ts +38 -0
  180. package/dist/workspace/reason-codes.d.ts.map +1 -1
  181. package/dist/workspace/record-assets.d.ts.map +1 -1
  182. package/dist/workspace/records-cli.d.ts +23 -1
  183. package/dist/workspace/records-cli.d.ts.map +1 -1
  184. package/dist/workspace/records-close.d.ts +1 -1
  185. package/dist/workspace/records-close.d.ts.map +1 -1
  186. package/dist/workspace/records-write.d.ts +11 -5
  187. package/dist/workspace/records-write.d.ts.map +1 -1
  188. package/dist/workspace/records.d.ts +42 -6
  189. package/dist/workspace/records.d.ts.map +1 -1
  190. package/dist/workspace/status-gates.d.ts +7 -2
  191. package/dist/workspace/status-gates.d.ts.map +1 -1
  192. package/dist/workspace/status-stewards.d.ts +179 -0
  193. package/dist/workspace/status-stewards.d.ts.map +1 -0
  194. package/dist/workspace/status.d.ts +68 -1
  195. package/dist/workspace/status.d.ts.map +1 -1
  196. package/dist/workspace/work-cli.d.ts +189 -0
  197. package/dist/workspace/work-cli.d.ts.map +1 -0
  198. package/dist/workspace/work-evidence.d.ts +74 -0
  199. package/dist/workspace/work-evidence.d.ts.map +1 -0
  200. package/dist/workspace/work.d.ts +43 -1
  201. package/dist/workspace/work.d.ts.map +1 -1
  202. package/package.json +1 -1
  203. package/src/cli/commands/audit.test.ts +9 -1
  204. package/src/cli/commands/build.ts +3 -2
  205. package/src/cli/commands/lint.ts +7 -1
  206. package/src/cli/handlers/components.test.ts +93 -0
  207. package/src/cli/handlers/components.ts +44 -3
  208. package/src/cli/handlers/graph.test.ts +20 -0
  209. package/src/cli/handlers/graph.ts +16 -2
  210. package/src/cli/handlers/operator.ts +141 -4
  211. package/src/cli/handlers/run.test.ts +173 -2
  212. package/src/cli/handlers/run.ts +174 -3
  213. package/src/cli/main.test.ts +50 -0
  214. package/src/cli/main.ts +97 -2
  215. package/src/cli/mcp/workspace-tools.test.ts +48 -19
  216. package/src/cli/mcp/workspace-tools.ts +110 -8
  217. package/src/cli/plugins.ts +11 -3
  218. package/src/cli/registry.ts +42 -1
  219. package/src/codegen/pinned-upgrade.ts +2 -1
  220. package/src/codegen/release-wiring.test.ts +49 -2
  221. package/src/components/capability-plugin-loader.ts +3 -3
  222. package/src/components/cli-support.ts +2 -2
  223. package/src/components/verbs/vuln-scan.test.ts +124 -1
  224. package/src/components/verbs/vuln-scan.ts +142 -1
  225. package/src/config.ts +11 -0
  226. package/src/lexicon-module.ts +56 -1
  227. package/src/lexicon-package.test.ts +96 -0
  228. package/src/lifecycle/converge-ledger.ts +20 -0
  229. package/src/lifecycle/git.ts +65 -15
  230. package/src/lifecycle/lease.test.ts +22 -0
  231. package/src/lifecycle/lease.ts +133 -29
  232. package/src/lifecycle/member-ledger.ts +3 -2
  233. package/src/lifecycle/plan-ledger.test.ts +148 -0
  234. package/src/lifecycle/plan-ledger.ts +158 -0
  235. package/src/lifecycle/run-ledger.ts +6 -0
  236. package/src/lifecycle/symptoms.ts +95 -0
  237. package/src/lifecycle/work-lease.test.ts +236 -0
  238. package/src/lifecycle/work-lease.ts +426 -0
  239. package/src/lint/rules/index.ts +6 -2
  240. package/src/lint/rules/op/index.ts +17 -4
  241. package/src/lint/rules/op/ops014-converge-rule-refusals.test.ts +23 -1
  242. package/src/lint/rules/op/ops014-converge-rule-refusals.ts +10 -6
  243. package/src/lint/rules/op/sys010-key-over-plain-http.test.ts +52 -0
  244. package/src/lint/rules/op/sys010-key-over-plain-http.ts +100 -0
  245. package/src/lint/rules/sys001-no-literal-key.test.ts +31 -0
  246. package/src/lint/rules/sys001-no-literal-key.ts +67 -0
  247. package/src/op/__fixtures__/decide-stub-backend.ts +143 -0
  248. package/src/op/activities/activity-contracts.ts +190 -1
  249. package/src/op/activities/apply.ts +7 -6
  250. package/src/op/activities/change-coverage.ts +60 -0
  251. package/src/op/activities/converge.test.ts +55 -1
  252. package/src/op/activities/converge.ts +208 -29
  253. package/src/op/activities/decide.live.test.ts +78 -0
  254. package/src/op/activities/decide.test.ts +300 -0
  255. package/src/op/activities/decide.ts +267 -0
  256. package/src/op/activities/index.ts +21 -0
  257. package/src/op/activities/shell.test.ts +91 -1
  258. package/src/op/activities/shell.ts +91 -2
  259. package/src/op/activities/source-release.test.ts +118 -0
  260. package/src/op/activities/source-release.ts +168 -0
  261. package/src/op/activities/source-rollback.test.ts +131 -0
  262. package/src/op/activities/source-rollback.ts +239 -0
  263. package/src/op/activities/work-evidence.ts +62 -0
  264. package/src/op/activity-contract-registry.test.ts +2 -0
  265. package/src/op/activity-contract-registry.ts +2 -2
  266. package/src/op/activity-contract.test.ts +12 -0
  267. package/src/op/activity-contract.ts +6 -1
  268. package/src/op/activity-profiles.ts +29 -0
  269. package/src/op/activity-registry.test.ts +1 -1
  270. package/src/op/activity-registry.ts +2 -2
  271. package/src/op/builders.ts +124 -5
  272. package/src/op/command-gate.test.ts +192 -0
  273. package/src/op/composites/converge-op.test.ts +27 -1
  274. package/src/op/composites/converge-op.ts +69 -15
  275. package/src/op/decide-backend.test.ts +44 -0
  276. package/src/op/decide-backend.ts +212 -0
  277. package/src/op/decide-config.test.ts +52 -0
  278. package/src/op/decide-config.ts +80 -0
  279. package/src/op/decide-read-inputs.ts +117 -0
  280. package/src/op/discover.ts +71 -0
  281. package/src/op/gate-approval.ts +2 -2
  282. package/src/op/gate-wait.ts +57 -0
  283. package/src/op/gate.ts +8 -3
  284. package/src/op/generate-pipeline.ts +2 -2
  285. package/src/op/index.ts +34 -6
  286. package/src/op/lifecycle-receipt-store.test.ts +60 -0
  287. package/src/op/lifecycle-receipt-store.ts +61 -0
  288. package/src/op/local-executor.ts +367 -33
  289. package/src/op/local-output.test.ts +33 -0
  290. package/src/op/local-output.ts +33 -2
  291. package/src/op/op-ir.test.ts +10 -0
  292. package/src/op/op-ir.ts +18 -0
  293. package/src/op/op-verb-class.ts +1 -0
  294. package/src/op/operator.ts +360 -10
  295. package/src/op/runtime.ts +37 -8
  296. package/src/op/runtimes/local.ts +6 -1
  297. package/src/op/source-archive.ts +161 -0
  298. package/src/op/step-output-ref.ts +6 -2
  299. package/src/op/steward-points.test.ts +313 -0
  300. package/src/op/steward-points.ts +194 -0
  301. package/src/op/steward-turn.ts +79 -0
  302. package/src/op/steward.test.ts +296 -0
  303. package/src/op/steward.ts +277 -0
  304. package/src/op/types.ts +60 -0
  305. package/src/op/work-lease-decl.ts +80 -0
  306. package/src/op/work-lease-run.test.ts +345 -0
  307. package/src/op/work-lease-run.ts +395 -0
  308. package/src/workspace/__fixtures__/decide-workspace.ts +129 -0
  309. package/src/workspace/__fixtures__/studio-template-84c8b21.json +67 -0
  310. package/src/workspace/answers-ledger.ts +118 -0
  311. package/src/workspace/box-isolation.test.ts +261 -0
  312. package/src/workspace/box-isolation.ts +205 -0
  313. package/src/workspace/changes-cli.ts +56 -0
  314. package/src/workspace/changes.schema.json +472 -0
  315. package/src/workspace/changes.test.ts +315 -0
  316. package/src/workspace/changes.ts +512 -0
  317. package/src/workspace/chant-migrations/chud-lexicon-exit-fly-site.ts +234 -0
  318. package/src/workspace/chant-migrations/chud-lexicon-exit-live-names.ts +164 -0
  319. package/src/workspace/chant-migrations/chud-lexicon-exit-rollback.ts +223 -0
  320. package/src/workspace/chant-migrations/chud-lexicon-exit-ship-inputs.ts +195 -0
  321. package/src/workspace/chant-migrations/chud-lexicon-exit-ship-policy.ts +108 -0
  322. package/src/workspace/chant-migrations/chud-lexicon-exit.ts +882 -0
  323. package/src/workspace/chant-migrations.e2e.test.ts +1089 -0
  324. package/src/workspace/chant-migrations.ts +164 -0
  325. package/src/workspace/check-contract.test.ts +5 -1
  326. package/src/workspace/check.schema.json +25 -7
  327. package/src/workspace/checks/box-isolation.ts +68 -0
  328. package/src/workspace/checks/boxes.test.ts +276 -0
  329. package/src/workspace/checks/boxes.ts +442 -0
  330. package/src/workspace/checks/diagrams.test.ts +134 -0
  331. package/src/workspace/checks/diagrams.ts +108 -0
  332. package/src/workspace/checks/records.ts +72 -0
  333. package/src/workspace/checks.test.ts +7 -0
  334. package/src/workspace/checks.ts +27 -3
  335. package/src/workspace/compose-graph.ts +2 -0
  336. package/src/workspace/conformance/__fixture__/decisions/decision.kind.mjs +10 -0
  337. package/src/workspace/conformance/__fixture__/decisions/decision.schema.json +26 -0
  338. package/src/workspace/conformance/index.ts +5 -0
  339. package/src/workspace/decide.test.ts +224 -0
  340. package/src/workspace/decide.ts +709 -0
  341. package/src/workspace/decision-points.schema.json +137 -0
  342. package/src/workspace/declaration.schema.json +285 -0
  343. package/src/workspace/declaration.test.ts +58 -0
  344. package/src/workspace/declaration.ts +241 -0
  345. package/src/workspace/declared-kinds.test.ts +5 -5
  346. package/src/workspace/declared-kinds.ts +71 -3
  347. package/src/workspace/generated-files.ts +14 -0
  348. package/src/workspace/graph-cli.ts +1 -1
  349. package/src/workspace/graph.schema.json +9 -1
  350. package/src/workspace/intent.schema.json +12 -3
  351. package/src/workspace/intent.ts +3 -10
  352. package/src/workspace/lineage-check.ts +16 -1
  353. package/src/workspace/lineage-upgrade-cli.ts +1 -1
  354. package/src/workspace/lineage-upgrade.test.ts +70 -0
  355. package/src/workspace/lineage-upgrade.ts +81 -10
  356. package/src/workspace/ls-contract.test.ts +57 -0
  357. package/src/workspace/ls.schema.json +46 -1
  358. package/src/workspace/ls.ts +62 -3
  359. package/src/workspace/point-answer.schema.json +95 -0
  360. package/src/workspace/points-cli.ts +284 -0
  361. package/src/workspace/points-write.schema.json +499 -0
  362. package/src/workspace/points.schema.json +743 -0
  363. package/src/workspace/points.test.ts +264 -0
  364. package/src/workspace/points.ts +564 -0
  365. package/src/workspace/read-contract.test.ts +18 -1
  366. package/src/workspace/reason-codes.test.ts +24 -1
  367. package/src/workspace/reason-codes.ts +49 -0
  368. package/src/workspace/record-assets.test.ts +3 -2
  369. package/src/workspace/record-assets.ts +4 -1
  370. package/src/workspace/records-amend.schema.json +2 -0
  371. package/src/workspace/records-cli.ts +28 -5
  372. package/src/workspace/records-close.schema.json +2 -0
  373. package/src/workspace/records-contract.test.ts +3 -2
  374. package/src/workspace/records-new.schema.json +2 -0
  375. package/src/workspace/records-review.schema.json +2 -0
  376. package/src/workspace/records-sessions-write.e2e.test.ts +77 -0
  377. package/src/workspace/records-sessions-write.test.ts +2 -34
  378. package/src/workspace/records-write.e2e.test.ts +108 -0
  379. package/src/workspace/records-write.test.ts +32 -41
  380. package/src/workspace/records-write.ts +33 -15
  381. package/src/workspace/records.schema.json +53 -2
  382. package/src/workspace/records.test.ts +48 -3
  383. package/src/workspace/records.ts +142 -6
  384. package/src/workspace/status-contract.test.ts +189 -6
  385. package/src/workspace/status-gates.ts +9 -4
  386. package/src/workspace/status-stewards.ts +329 -0
  387. package/src/workspace/status.schema.json +335 -5
  388. package/src/workspace/status.ts +142 -6
  389. package/src/workspace/work-acceptance.test.ts +274 -0
  390. package/src/workspace/work-cli.e2e.test.ts +180 -0
  391. package/src/workspace/work-cli.ts +429 -0
  392. package/src/workspace/work-evidence.schema.json +212 -0
  393. package/src/workspace/work-evidence.ts +169 -0
  394. package/src/workspace/work-history.schema.json +349 -0
  395. package/src/workspace/work-history.test.ts +156 -0
  396. package/src/workspace/work-lease.schema.json +233 -0
  397. package/src/workspace/work-readiness-chud.test.ts +145 -0
  398. package/src/workspace/work.test.ts +3 -2
  399. package/src/workspace/work.ts +100 -1
  400. /package/src/cli/{discovery-skip.test.ts → discovery-skip.e2e.test.ts} +0 -0
  401. /package/src/workspace/conformance/{conformance.test.ts → conformance.e2e.test.ts} +0 -0
  402. /package/src/workspace/{which-chant.test.ts → which-chant.e2e.test.ts} +0 -0
@@ -0,0 +1,136 @@
1
+ /**
2
+ * A decision point asked inside an Op run (#2749), and in a steward's turn in
3
+ * particular.
4
+ *
5
+ * An Op that needs a decision (the factory's builder tier, whether to ship)
6
+ * calls {@link askPointInRun} from one of its activities, such as the decide
7
+ * activity (#2740). It asks the point through `askPoint` (ws-058,
8
+ * `../workspace/decide.ts`), which records the question and its answer as a
9
+ * record, and then:
10
+ *
11
+ * - an `answered` question returns its answer, and the Op goes on;
12
+ * - an `escalated` or `proposed` question is open, so the activity throws
13
+ * {@link PointWait}. The executor ends the run there with status `waiting`,
14
+ * as a gate ends it with `gated`: no later step runs, no `onFailure` phase
15
+ * runs, and the run ledger records the question the run is waiting on.
16
+ *
17
+ * The question stays open in the workspace, where `chant workspace points
18
+ * --open`, MCP's `workspace-points` and hud read it, and a person answers it
19
+ * with `points answer`. Nothing waits in the meantime: the next run asks the
20
+ * same point with the same inputs, finds the answer record, and goes on. A
21
+ * local steward re-runs a waiting Op on the first round after its question is
22
+ * answered (`./operator.ts`).
23
+ *
24
+ * ## In a steward's turn
25
+ *
26
+ * A steward runs unattended, so two more rules hold when the process is a
27
+ * steward's turn (`./steward-turn.ts`):
28
+ *
29
+ * - The model call goes through the broker. The caller supplies the call as a
30
+ * {@link BrokeredModelAsk}, which is handed the box capability to reach the
31
+ * model through, and only a capability the steward declares
32
+ * (`declareSteward({ capabilities })`, #2726). A steward that names none,
33
+ * or holds a vault, makes no model call: the model decider is recorded as
34
+ * not reached and the question goes to people.
35
+ * - The question is written on the `chant/lifecycle` branch, not in the
36
+ * checkout (#2786): the working tree is the coding agent's, and an Op's
37
+ * leased worktree goes when the run ends. `points` reads it from there
38
+ * (`../workspace/answers-ledger.ts`), and a person's answer goes there too.
39
+ * - The question names the steward and its run in its source block, and
40
+ * neither the steward's turn nor the steward's name can answer it: `points
41
+ * answer` refuses inside a steward's turn (`answer-in-steward-turn`) and
42
+ * leaves the asking steward out of the quorum.
43
+ *
44
+ * The question never goes to the steward's own thread: on Fountain that thread
45
+ * is the steward's, and nobody reads it for questions.
46
+ */
47
+ import type { ModelAsk, ModelRequest, WireAnswer } from "../workspace/points.js";
48
+ import type { QuestionView } from "../workspace/decide.js";
49
+ import { type StewardTurn } from "./steward-turn.js";
50
+ /** The box capability a model call goes through when the caller names none. */
51
+ export declare const DEFAULT_INFERENCE_CAPABILITY = "inference";
52
+ /** The open question a run stopped on, as the run ledger records it. */
53
+ export interface WaitingPoint {
54
+ /** The answer record's id: what `points answer` and hud name. */
55
+ id: string;
56
+ /** The point asked. */
57
+ point: string;
58
+ /** Its state when the run stopped: `escalated` to people, or `proposed` by a model and waiting for a person to confirm it. */
59
+ state: "escalated" | "proposed";
60
+ /** The answer record, from the repository root. */
61
+ path: string;
62
+ /** What the question is about, or null. */
63
+ subject: string | null;
64
+ /** The steward whose turn asked it, or null. */
65
+ steward: string | null;
66
+ }
67
+ /** The marker {@link PointWait} carries, so a copy of core linked twice still recognises it. */
68
+ declare const POINT_WAIT: unique symbol;
69
+ /**
70
+ * Thrown by an activity whose decision point is open. Not a failure: the
71
+ * executor ends the run with status `waiting` (see the module doc).
72
+ */
73
+ export declare class PointWait extends Error {
74
+ readonly question: WaitingPoint;
75
+ readonly [POINT_WAIT] = true;
76
+ constructor(question: WaitingPoint);
77
+ }
78
+ /** Is this a {@link PointWait}? Duck-typed on the shared symbol. */
79
+ export declare function isPointWait(err: unknown): err is PointWait;
80
+ /**
81
+ * The model call, supplied by the caller (the decide activity, #2740, or a
82
+ * test's stub), made through a box capability. `via.capability` is the
83
+ * capability to reach the model through and `via.broker` the broker the
84
+ * member's box block names for it, when that is known. The function holds no
85
+ * credential: the broker does.
86
+ */
87
+ export type BrokeredModelAsk = (request: ModelRequest, via: {
88
+ capability: string;
89
+ broker: string | null;
90
+ }) => Promise<{
91
+ model: string;
92
+ answer: WireAnswer;
93
+ }>;
94
+ export interface AskPointInRunOptions {
95
+ /** Where the workspace and the answer kind are found. */
96
+ cwd: string;
97
+ point: string;
98
+ inputs: unknown;
99
+ subject?: string;
100
+ /** The answer kind file, or a declared kind's name. */
101
+ kind?: string;
102
+ /** The model call. Without it, a model decider is not asked. */
103
+ ask?: BrokeredModelAsk;
104
+ /** The box capability the model call goes through. Default `inference`. */
105
+ capability?: string;
106
+ /** The broker the member's box block names for the capability, when the caller has read it. */
107
+ broker?: string | null;
108
+ /** The date written as asked_on, YYYY-MM-DD. */
109
+ on?: string;
110
+ /** The steward turn, when the caller has it. Default: this process's (`currentStewardTurn`). */
111
+ turn?: StewardTurn | null;
112
+ }
113
+ /**
114
+ * The {@link ModelAsk} a point is asked with. In a steward's turn the call is
115
+ * made only through a capability the steward declares; otherwise it throws,
116
+ * which the chain records as the model not being reached.
117
+ */
118
+ export declare function brokeredModelAsk(ask: BrokeredModelAsk, opts: {
119
+ capability?: string;
120
+ broker?: string | null;
121
+ turn?: StewardTurn | null;
122
+ cwd: string;
123
+ }): Promise<ModelAsk>;
124
+ /**
125
+ * Ask a decision point from inside an Op run. Resolves with the answer when
126
+ * the question is answered, and throws {@link PointWait} when it is open.
127
+ * Any other problem (the points can't be read, the inputs are wrong, a model
128
+ * declared `unreachable: "fail"` could not answer) throws an ordinary error,
129
+ * which fails the step.
130
+ */
131
+ export declare function askPointInRun(opts: AskPointInRunOptions): Promise<{
132
+ answer: string | boolean;
133
+ question: QuestionView;
134
+ }>;
135
+ export {};
136
+ //# sourceMappingURL=steward-points.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"steward-points.d.ts","sourceRoot":"","sources":["../../src/op/steward-points.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEtE,+EAA+E;A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,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+FAA+F;IAC/F,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,gDAAgD;IAChD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,gGAAgG;IAChG,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC3B;AAUD;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC5F,OAAO,CAAC,QAAQ,CAAC,CAkBnB;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAA;CAAE,CAAC,CAyB7H"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Whether this process is a steward's turn, and whose (#2749).
3
+ *
4
+ * A steward runs unattended. In the local form, `chant operator --steward`
5
+ * is the steward for as long as it runs; on Fountain, the Agent's `chant acp
6
+ * --steward <name>` session is. Two things read this: a decision point asked
7
+ * during the turn (`./steward-points.ts`), which records the steward on the
8
+ * question and makes its model call through the steward's brokered
9
+ * capability, and `points answer`, which refuses to record an answer from a
10
+ * steward's own turn, as the gate ledger's origin rule refuses a gate
11
+ * resolved on the channel that reached it.
12
+ *
13
+ * Like the gate origin (`../lifecycle/gate-origin.ts`) this is a property of
14
+ * the process, set once at its entry point, not a parameter threaded through
15
+ * every executor and activity. It is also exported to child processes as
16
+ * `CHANT_STEWARD`, so a `chant workspace points answer` an Op shells out to
17
+ * is refused the same way.
18
+ */
19
+ /** The environment variable a steward's turn carries into child processes. */
20
+ export declare const STEWARD_ENV = "CHANT_STEWARD";
21
+ /** A steward's turn, as the process knows it. */
22
+ export interface StewardTurn {
23
+ /** The steward's name. */
24
+ steward: string;
25
+ /**
26
+ * The box capabilities the steward reaches through the broker (#2726), or
27
+ * undefined when the process was told only the steward's name (a child
28
+ * process, or `chant acp --steward <name>`): the declaration is then read
29
+ * from the project's `*.op.ts` files when a model call needs it.
30
+ */
31
+ capabilities?: readonly string[];
32
+ /** The vault the steward holds, by name, when it is not behind a broker. */
33
+ vault?: string | null;
34
+ /** The run the steward is in, when an Op is running. */
35
+ run?: string;
36
+ }
37
+ /**
38
+ * Declare that this process is a steward's turn. Called once by `chant
39
+ * operator --steward` and `chant acp --steward`; also exports
40
+ * {@link STEWARD_ENV} so a child process knows it too.
41
+ */
42
+ export declare function setStewardTurn(turn: StewardTurn): void;
43
+ /**
44
+ * Be a steward's turn until the returned function is called, which puts back
45
+ * whatever was there before. `chant operator --steward` enters one per Op run,
46
+ * naming the run, so a question asked during it names the run too.
47
+ */
48
+ export declare function enterStewardTurn(turn: StewardTurn): () => void;
49
+ /** The steward whose turn this process is, or undefined. */
50
+ export declare function currentStewardTurn(): StewardTurn | undefined;
51
+ /** Forget the turn. For tests, which must not leak a steward into each other. */
52
+ export declare function resetStewardTurn(): void;
53
+ //# sourceMappingURL=steward-turn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"steward-turn.d.ts","sourceRoot":"","sources":["../../src/op/steward-turn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,8EAA8E;AAC9E,eAAO,MAAM,WAAW,kBAAkB,CAAC;AAE3C,iDAAiD;AACjD,MAAM,WAAW,WAAW;IAC1B,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAID;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAGtD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,IAAI,CAS9D;AAED,4DAA4D;AAC5D,wBAAgB,kBAAkB,IAAI,WAAW,GAAG,SAAS,CAI5D;AAED,iFAAiF;AACjF,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC"}
@@ -0,0 +1,161 @@
1
+ /**
2
+ * A steward's declaration (#2731): the one writer for an environment, as data
3
+ * core can read without any lexicon loaded.
4
+ *
5
+ * A steward runs a fixed list of Ops, each on its own `schedule` when it has
6
+ * one, one Op at a time. Where it runs is its form:
7
+ *
8
+ * - `fountain`: the fountain lexicon's `Steward` composite, an `acp` Agent on
9
+ * a persistent sandbox bound to a Teammate, with a Fountain `Schedule` per
10
+ * scheduled Op. A turn is one `chant run <op>` on the teammate's thread.
11
+ * - `local`: `chant operator --steward <name>` in the box itself, for a box
12
+ * with no Fountain behind it (a docker compose box, a Sprites box). The same
13
+ * Ops on the same crons, each run under its operator lease, and the steward
14
+ * itself under a lease of its own so a second local operator is refused.
15
+ *
16
+ * One declaration covers both. `form` is either one of the two, or a default
17
+ * with per-environment exceptions, so a box whose `minimal` environment has no
18
+ * Fountain and whose `fountain-k3d` one does still has exactly one steward:
19
+ *
20
+ * ```ts
21
+ * // ops/steward.op.ts
22
+ * export const steward = declareSteward({
23
+ * name: "box-steward",
24
+ * ops: [converge, dispatch, release, upgrade],
25
+ * form: { default: "local", environments: { "fountain-k3d": "fountain" } },
26
+ * });
27
+ * ```
28
+ *
29
+ * The fountain composite builds this same declaration from its own options and
30
+ * returns it as `declaration`, so a project that declares its steward there
31
+ * exports that object from an `*.op.ts` file instead of calling this function.
32
+ *
33
+ * ## Discovery
34
+ *
35
+ * A steward is discovered from the same `*.op.ts` files Ops are
36
+ * (`./discover.ts`), because it is chant's own run-time declaration and sits
37
+ * beside the Ops it runs. It is plain data with a `kind` marker, not a
38
+ * Declarable, so `chant build` never serializes it and a copy of core linked
39
+ * twice still recognises it.
40
+ *
41
+ * ## What a steward writes
42
+ *
43
+ * A steward's writes are chant writes: run, converge and gate records on the
44
+ * `chant/lifecycle` branch, the answer records of the decision points its
45
+ * Ops ask (`_answers/`, #2786), and lease refs under `refs/chant/lease/`, all made
46
+ * with git plumbing (`../lifecycle/git.ts`: `hash-object`, `mktree`,
47
+ * `commit-tree`, `update-ref`). None of them reads or writes the checkout's
48
+ * index or working tree, so a coding agent editing the app in the same
49
+ * checkout, and holding git's index lock while it commits, never collides with
50
+ * a steward turn. The app's files are the coding agent's; the steward does not
51
+ * edit them.
52
+ *
53
+ * An Op that has to change the checkout (applying a build, a workspace
54
+ * upgrade) says so with `changesCheckout` and runs under a work item's lease
55
+ * (`workLease`, #2748): its leased steps get a worktree of their own on
56
+ * `chant/work/<item>`. `declareSteward` refuses such an Op without the lease,
57
+ * and a scheduled Op whose lease leaves the item to the run.
58
+ */
59
+ import type { OpConfig } from "./types.js";
60
+ /** The entity marker a steward declaration carries. */
61
+ export declare const STEWARD_KIND = "Chant::Steward";
62
+ /** Where a steward runs. */
63
+ export declare const STEWARD_FORMS: readonly ["local", "fountain"];
64
+ export type StewardForm = (typeof STEWARD_FORMS)[number];
65
+ /** The form a declaration asks for, as given: one form, or a default with per-environment exceptions. */
66
+ export type StewardFormSpec = StewardForm | {
67
+ default: StewardForm;
68
+ environments?: Record<string, StewardForm>;
69
+ };
70
+ /** The environment a form is chosen for when none is named: the same default a run ledger uses. */
71
+ export declare const DEFAULT_STEWARD_ENV = "local";
72
+ /** Names a steward's lease ref and a ledger path can hold. */
73
+ export declare const STEWARD_NAME_PATTERN: RegExp;
74
+ /**
75
+ * An Op a steward runs, however the project holds it: the `Op()` declaration
76
+ * (config behind `.props`), or the bare config.
77
+ */
78
+ export type StewardOpInput = OpConfig | {
79
+ props: unknown;
80
+ };
81
+ export interface StewardDeclarationConfig {
82
+ /** The steward's name. On Fountain, the Agent's and the Teammate's. */
83
+ name: string;
84
+ /** The Ops it runs. A scheduled one runs on its cron; any other runs when asked. */
85
+ ops: StewardOpInput[];
86
+ /** Where it runs. Default `local`. */
87
+ form?: StewardFormSpec;
88
+ /**
89
+ * The box capabilities its Ops reach through the box's broker (#2726), by
90
+ * the names the member's `box` block in the workspace declaration gives
91
+ * them, such as `fountain` or `inference`. A steward that names any holds no
92
+ * credential of its own, so it takes no `vault`.
93
+ */
94
+ capabilities?: string[];
95
+ /** The vault the steward holds on Fountain, by name, for a steward that isn't behind a broker. */
96
+ vault?: string;
97
+ }
98
+ /** A steward's declaration, normalised. Plain data: see the module doc. */
99
+ export interface StewardDeclaration {
100
+ readonly kind: typeof STEWARD_KIND;
101
+ readonly name: string;
102
+ readonly ops: readonly OpConfig[];
103
+ readonly form: {
104
+ readonly default: StewardForm;
105
+ readonly environments: Readonly<Record<string, StewardForm>>;
106
+ };
107
+ /** Brokered box capabilities its Ops use (#2726). Empty when it names none. */
108
+ readonly capabilities: readonly string[];
109
+ /** The vault it holds, by name, or null. Never set together with `capabilities`. */
110
+ readonly vault: string | null;
111
+ }
112
+ /** The config inside an op, whether it arrived as a declaration or as itself. */
113
+ export declare function stewardOpConfig(op: StewardOpInput): OpConfig;
114
+ /** Normalise a form spec, refusing an unknown form or an environment name no ledger could hold. */
115
+ export declare function normaliseStewardForm(steward: string, spec: StewardFormSpec | undefined): StewardDeclaration["form"];
116
+ /**
117
+ * Declare a steward. Refuses what would make it more than one writer or a
118
+ * promise it can't keep: an Op listed twice, a schedule whose overlap isn't
119
+ * `skip` (a fire while a turn runs is dropped in both forms), a cron that
120
+ * doesn't parse, and a name a lease ref can't hold.
121
+ */
122
+ export declare function declareSteward(config: StewardDeclarationConfig): StewardDeclaration;
123
+ /** Is this value a steward declaration? Duck-typed, like `isOpEntity`. */
124
+ export declare function isStewardDeclaration(value: unknown): value is StewardDeclaration;
125
+ /** The form a steward takes in `env` (`local` when none is named). */
126
+ export declare function stewardFormFor(steward: StewardDeclaration, env?: string): StewardForm;
127
+ /**
128
+ * The lease a local steward holds for as long as it runs, so a second
129
+ * `chant operator --steward` for the same steward is refused. It sits under
130
+ * `refs/chant/lease/_stewards/`, beside the per-Op leases, which a leading
131
+ * `_` keeps out of any Op's name.
132
+ */
133
+ export declare function stewardLeaseName(steward: string): string;
134
+ /**
135
+ * The lease a local steward holds for as long as one of its Ops is actually
136
+ * running: one turn (#2750). Distinct from {@link stewardLeaseName}, which one
137
+ * `chant operator --steward` process holds for its whole life (renewed
138
+ * between ticks, released only when the process stops) — this one is taken
139
+ * right before a run starts and released right after it ends, whether the
140
+ * run is a round's scheduled tick or `chant run <op>` typed by hand. That is
141
+ * what makes an on-request run wait its turn behind a turn already in
142
+ * progress, and succeed again the moment that turn ends, rather than only
143
+ * once the whole steward process stops.
144
+ *
145
+ * `_turns/<name>`, not `_stewards/<name>/turn`: a git ref name is a path
146
+ * component in the loose-refs tree, and `refs/chant/lease/_stewards/<name>`
147
+ * (the lease {@link stewardLeaseName} names) already exists as a *leaf* —
148
+ * git refuses to also create anything *under* it (`fatal: ... exists;
149
+ * cannot create ...`), so nesting the turn lease inside the steward lease's
150
+ * own name is unusable the moment both are live at once. A sibling
151
+ * top-level segment sidesteps that entirely.
152
+ */
153
+ export declare function stewardTurnLeaseName(steward: string): string;
154
+ /**
155
+ * Pick the steward `--steward [<name>]` names, or the project's only one.
156
+ * Returns the steward, or the message to refuse with.
157
+ */
158
+ export declare function pickSteward(stewards: Map<string, {
159
+ declaration: StewardDeclaration;
160
+ }>, name: string): StewardDeclaration | string;
161
+ //# sourceMappingURL=steward.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"steward.d.ts","sourceRoot":"","sources":["../../src/op/steward.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAA;KAAE,CAAC;IAC/G,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,oFAAoF;IACpF,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,EAAE,EAAE,cAAc,GAAG,QAAQ,CAG5D;AASD,mGAAmG;AACnG,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,SAAS,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAWnH;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,wBAAwB,GAAG,kBAAkB,CAyDnF;AAED,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAWhF;AAED,sEAAsE;AACtE,wBAAgB,cAAc,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,GAAE,MAA4B,GAAG,WAAW,CAE1G;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,WAAW,EAAE,kBAAkB,CAAA;CAAE,CAAC,EAC1D,IAAI,EAAE,MAAM,GACX,kBAAkB,GAAG,MAAM,CAU7B"}
@@ -40,6 +40,57 @@ export interface OpConfig {
40
40
  * local one-shot executor ignores it.
41
41
  */
42
42
  schedule?: OpSchedule;
43
+ /**
44
+ * The work item this Op runs under (#2748, ws-055). The executor claims the
45
+ * item's work lease (`../lifecycle/work-lease.ts`) before the steps that run
46
+ * under it, renews it as a heartbeat while they run, stops the run when the
47
+ * lease is lost, and gives it back when the run ends. See
48
+ * {@link OpWorkLease} and `./work-lease-run.ts`.
49
+ */
50
+ workLease?: OpWorkLease;
51
+ /**
52
+ * The Op changes the checkout: it applies a build, or upgrades the
53
+ * workspace (#2748). Such an Op must declare {@link OpConfig.workLease}: the
54
+ * executor refuses to run it otherwise, and `declareSteward` refuses to list
55
+ * it. Its leased steps get a git worktree of their own, on the branch
56
+ * `chant/work/<item>`, so the change never lands in the working tree a
57
+ * coding agent is editing.
58
+ */
59
+ changesCheckout?: boolean;
60
+ }
61
+ /**
62
+ * The id under which a run's work lease is published to its steps (#2748):
63
+ * `stepOutput(WORK_LEASE_STEP_ID, "token")`, or `workLeaseOutput("token")`
64
+ * from `./work-lease-run.ts`. No step of an Op with a `workLease` may use it.
65
+ */
66
+ export declare const WORK_LEASE_STEP_ID = "workLease";
67
+ /**
68
+ * Which work item an Op runs under, and how (#2748).
69
+ *
70
+ * `item` is an id, a list of candidate ids (the first one nobody holds is
71
+ * claimed, as chud's dispatcher took the first ready contract nobody held), a
72
+ * reference to an earlier step's output that resolves to either, or omitted,
73
+ * in which case the run names it (`chant run <op> --work <id>`). A literal or
74
+ * run-time item is claimed before the first step; a referenced one right
75
+ * after the step that produces it. A run that finds nothing to claim (the
76
+ * reference resolved to nothing, or every candidate is held) ends `ok` with
77
+ * the rest of its steps skipped, and the claim's record says why.
78
+ */
79
+ export interface OpWorkLease {
80
+ item?: string | string[] | StepOutputRef;
81
+ /**
82
+ * The work kind file whose member owns the lease (#2524 D7), relative to
83
+ * the project directory. Omitted, the lease is in the project's own ledger.
84
+ */
85
+ kind?: string;
86
+ /** How long a claim lasts unless renewed, as a duration ("10m"). Renewed every third of it. Default 10m. */
87
+ ttl?: string;
88
+ /**
89
+ * How the release records a run that ended `ok`: a reference to a step
90
+ * output holding a short string (`done`, `not_done`, ...). Default `done`;
91
+ * a failed run releases `not_done` and a gated one `gated`.
92
+ */
93
+ outcome?: StepOutputRef;
43
94
  }
44
95
  /**
45
96
  * An Op's cadence (#2120). The cron is validated at `Op()` construction by
@@ -94,6 +145,13 @@ export interface ActivityStep {
94
145
  * Default: "fastIdempotent"
95
146
  */
96
147
  profile?: ActivityProfileName;
148
+ /**
149
+ * How long one attempt may run, such as `"45m"`, in place of the
150
+ * profile's timeout (#2787). The profile's retry policy is kept, so a
151
+ * `shell` step stays one attempt. At most `MAX_STEP_TIMEOUT` (six hours); a longer
152
+ * wait is a gate, not a step.
153
+ */
154
+ timeout?: string;
97
155
  /**
98
156
  * Surface this activity's return value as a named run outcome.
99
157
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/op/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,WAAW,QAAQ;IACvB,2JAA2J;IAC3J,IAAI,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,eAAe,EAAE,CAAC;IAC9B;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;I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AM,CAAC;CACrB,GACD;IACE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,0FAA0F;IAC1F,UAAU,EAAE,MAAM,CAAC;CACpB,CACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The rules an Op's `workLease` and `changesCheckout` declaration keeps
3
+ * (#2748), with no imports beyond the Op model, so `Op()` and
4
+ * `declareSteward` can check them without loading the lease machinery in
5
+ * `./work-lease-run.ts`.
6
+ */
7
+ import { type OpConfig } from "./types.js";
8
+ /** A work item id a lease can be keyed by: the same pattern as `WORK_ITEM_ID_PATTERN` in `../lifecycle/work-lease.ts`. */
9
+ export declare const WORK_LEASE_ITEM_PATTERN: RegExp;
10
+ /**
11
+ * What is wrong with an Op's `workLease` and `changesCheckout`, or an empty
12
+ * list. The executor refuses to start a run with any of these, and
13
+ * `declareSteward` refuses to list the Op.
14
+ */
15
+ export declare function workLeaseProblems(config: Pick<OpConfig, "name" | "phases" | "workLease" | "changesCheckout">): string[];
16
+ /** Whether a run of this Op has to be told its work item (`--work <id>`). */
17
+ export declare function workLeaseNeedsRunItem(config: Pick<OpConfig, "workLease">): boolean;
18
+ //# sourceMappingURL=work-lease-decl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"work-lease-decl.d.ts","sourceRoot":"","sources":["../../src/op/work-lease-decl.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAsB,KAAK,QAAQ,EAAwB,MAAM,SAAS,CAAC;AAElF,0HAA0H;AAC1H,eAAO,MAAM,uBAAuB,QAAsC,CAAC;AAW3E;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,iBAAiB,CAAC,GAAG,MAAM,EAAE,CA6CvH;AAED,6EAA6E;AAC7E,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,OAAO,CAElF"}
@@ -0,0 +1,173 @@
1
+ /**
2
+ * An Op run under a work item's lease (#2748, the Steward's gap 4 in #2731).
3
+ *
4
+ * An Op that declares `workLease` (`./types.ts`) runs its steps under the work
5
+ * lease of one work item (`../lifecycle/work-lease.ts`, ws-055). The local
6
+ * executor (`./local-executor.ts`) drives the {@link RunWorkLease} here:
7
+ *
8
+ * - Claim. Before the first step when the item is a literal or named by the
9
+ * run (`chant run <op> --work <id>`); right after the producing step when
10
+ * the item is a reference to a step's output. A list of candidates is tried
11
+ * in order and the first one nobody holds is taken. When nothing can be
12
+ * claimed the run ends `ok` with its remaining steps skipped, and the claim's
13
+ * record carries the refusal, which names who holds the item.
14
+ * - Heartbeat. While the steps run, the lease is renewed every third of its
15
+ * time to live, keeping its fencing token. A renewal the lease refuses (it
16
+ * ran out and someone else claimed it, or it was released) means the lease
17
+ * is lost: the in-flight step's abort signal fires, no further step starts,
18
+ * and the run fails with `lease-lost`. A renewal that fails for any other
19
+ * reason (the remote didn't answer) is retried at the next beat; if that
20
+ * goes on past the expiry, the next renewal is refused and the lease is lost
21
+ * then. These are the semantics of chud's dispatcher
22
+ * (packages/runtime/src/dispatch.mjs), which this replaces.
23
+ * - Fence. Before the run's record is written, one last renewal checks that
24
+ * the lease is still this run's, with the same token. Refused, the run is
25
+ * recorded as failed with `lease-lost`, never as done.
26
+ * - Release. When the run ends, the lease is given back with the run's
27
+ * outcome (`done`, `not_done`, `gated`, or the Op's own `outcome`), which
28
+ * lands on `_leases/<id>.jsonl`. A lost lease is not released: it isn't
29
+ * this run's to give back.
30
+ *
31
+ * Steps read the lease through {@link workLeaseOutput}: its item, holder,
32
+ * token and expiry, and for an Op that changes the checkout, the worktree and
33
+ * branch it works in. An activity that writes somewhere a token can fence
34
+ * (another ledger, a remote) passes the token along.
35
+ *
36
+ * ## Changing the checkout
37
+ *
38
+ * An Op with `changesCheckout` (applying a build, `chant workspace upgrade`)
39
+ * must declare `workLease`, and its leased steps get a git worktree of their
40
+ * own: `chant/work/<item>` checked out under the repository's git directory,
41
+ * from the checkout's HEAD, or from the branch as an earlier run left it. The
42
+ * worktree is removed when the run ends and the branch keeps whatever the
43
+ * steps committed, for the runner to deliver. The checkout a coding agent is
44
+ * editing, its index and its uncommitted files, are never touched.
45
+ */
46
+ import { type StepOutputRef } from "./step-output-ref.js";
47
+ import { type OpConfig } from "./types.js";
48
+ export { WORK_LEASE_STEP_ID } from "./types.js";
49
+ export { workLeaseProblems, workLeaseNeedsRunItem } from "./work-lease-decl.js";
50
+ /** Why a run under a work lease failed when the lease was lost: chud's reason, kept. */
51
+ export declare const LEASE_LOST = "lease-lost";
52
+ /** The branch prefix an Op that changes the checkout works on. */
53
+ export declare const WORK_BRANCH_PREFIX = "chant/work/";
54
+ /** What a run's steps read about its work lease, via {@link workLeaseOutput}. */
55
+ export interface WorkLeaseOutput {
56
+ item: string;
57
+ holder: string;
58
+ /** The fencing token: the same for the whole run unless the lease is lost. */
59
+ token: string;
60
+ acquiredAt: string;
61
+ expiresAt: string;
62
+ /** The lease ref. */
63
+ ref: string;
64
+ /** For an Op that changes the checkout: the worktree its steps work in. Otherwise null. */
65
+ worktree: string | null;
66
+ /** For an Op that changes the checkout: the worktree's branch. Otherwise null. */
67
+ branch: string | null;
68
+ }
69
+ /** How a run's work lease ended, on `OpRunResult.workLease`. */
70
+ export interface WorkLeaseRunResult {
71
+ /** The item claimed, or null when the run claimed nothing. */
72
+ item: string | null;
73
+ holder: string;
74
+ token: string | null;
75
+ /** The branch an Op that changes the checkout worked on, or null. */
76
+ branch: string | null;
77
+ /** Whether the lease was given back. False when it was lost, or never claimed. */
78
+ released: boolean;
79
+ /** The outcome the release recorded, or null when there was no release. */
80
+ outcome: string | null;
81
+ /** Why the lease was lost, or null when it wasn't. */
82
+ lost: string | null;
83
+ /** Why nothing was claimed, or null when something was. */
84
+ refusal: string | null;
85
+ }
86
+ /**
87
+ * A reference to the run's work lease, for a step's args:
88
+ * `workLeaseOutput("token")`, `workLeaseOutput("worktree")`, or the whole
89
+ * {@link WorkLeaseOutput} with no path.
90
+ */
91
+ export declare function workLeaseOutput(path?: keyof WorkLeaseOutput): StepOutputRef;
92
+ /**
93
+ * The holder a steward's turn claims work leases as:
94
+ * `<steward>/<op>@<process>`. `chant workspace status --json` reads it back
95
+ * to show the lease a steward's current turn holds beside its Ops.
96
+ */
97
+ export declare function stewardWorkHolder(steward: string, op: string, process?: string): string;
98
+ /** What a claim attempt came to, for the executor to record. */
99
+ export type WorkClaimOutcome = {
100
+ kind: "claimed";
101
+ lease: WorkLeaseOutput;
102
+ tried: string[];
103
+ }
104
+ /** Nothing to claim, or every candidate is held. `refusal` says which. */
105
+ | {
106
+ kind: "unclaimed";
107
+ refusal: string;
108
+ tried: string[];
109
+ };
110
+ export interface RunWorkLeaseOptions {
111
+ /** The project directory: where the run's ledger is, and what `workLease.kind` is relative to. */
112
+ cwd: string;
113
+ holder?: string;
114
+ /** The item the run names (`--work`), which takes the place of the Op's own. */
115
+ item?: string;
116
+ /** Called with a renewal's error that didn't lose the lease, which the next beat retries. */
117
+ onRenewError?: (message: string) => void;
118
+ }
119
+ /** One run's hold on one work item's lease. Created by the executor for an Op with `workLease`. */
120
+ export declare class RunWorkLease {
121
+ private readonly config;
122
+ private readonly opts;
123
+ readonly holder: string;
124
+ readonly ttlMs: number;
125
+ /** Aborts when the lease is lost, so the step in flight stops. */
126
+ readonly lostSignal: AbortSignal;
127
+ /** Set once the claim was made or given up on. */
128
+ attempted: boolean;
129
+ lease: WorkLeaseOutput | undefined;
130
+ refusal: string | undefined;
131
+ lost: string | undefined;
132
+ private readonly spec;
133
+ private readonly abort;
134
+ private timer;
135
+ private beat;
136
+ constructor(config: Pick<OpConfig, "name" | "workLease" | "changesCheckout">, opts: RunWorkLeaseOptions);
137
+ /** The directory whose ledger holds the lease: the kind file's, or the project's. */
138
+ private get ledgerCwd();
139
+ /** Whether the claim is due at a step boundary, given the results so far. */
140
+ due(resultsById: ReadonlyMap<string, unknown>): boolean;
141
+ /** The candidate ids, in order. Empty when the reference resolved to nothing. */
142
+ private candidates;
143
+ /**
144
+ * Claim the first candidate nobody holds. On a claim, the heartbeat starts,
145
+ * and for an Op that changes the checkout its worktree is made. Throws when
146
+ * the claim could not be made for a reason other than someone holding it
147
+ * (git failed): the run fails, as for any failing step.
148
+ */
149
+ claim(resultsById: ReadonlyMap<string, unknown>): Promise<WorkClaimOutcome>;
150
+ /**
151
+ * A worktree for `id` on `chant/work/[<member>/]<id>`, under the git
152
+ * directory so the checkout's own `git status` never lists it. Starts from
153
+ * the branch when an earlier run left it, from HEAD otherwise.
154
+ */
155
+ private makeWorktree;
156
+ private lose;
157
+ /** One renewal. Refused, the lease is lost; failed otherwise, the next beat retries. */
158
+ private renew;
159
+ private startHeartbeat;
160
+ private stopHeartbeat;
161
+ /**
162
+ * The last renewal before the run's record is written, after the heartbeat
163
+ * stops. Returns whether the lease is still this run's.
164
+ */
165
+ fence(): Promise<boolean>;
166
+ /**
167
+ * End the run's hold: stop the heartbeat, remove the worktree (the branch
168
+ * keeps what was committed), and give the lease back with the outcome
169
+ * unless it was lost.
170
+ */
171
+ finish(status: "ok" | "fail" | "gated" | "waiting", resultsById: ReadonlyMap<string, unknown>): Promise<WorkLeaseRunResult>;
172
+ }
173
+ //# sourceMappingURL=work-lease-run.d.ts.map