@intentius/chant 0.80.0 → 0.81.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 (414) hide show
  1. package/dist/audit/discover.d.ts +8 -16
  2. package/dist/audit/discover.d.ts.map +1 -1
  3. package/dist/audit/report-html.d.ts +5 -0
  4. package/dist/audit/report-html.d.ts.map +1 -1
  5. package/dist/audit/report-model.d.ts +13 -0
  6. package/dist/audit/report-model.d.ts.map +1 -1
  7. package/dist/audit/terraform-state.d.ts +4 -5
  8. package/dist/audit/terraform-state.d.ts.map +1 -1
  9. package/dist/cli/commands/audit.d.ts +25 -9
  10. package/dist/cli/commands/audit.d.ts.map +1 -1
  11. package/dist/cli/commands/check-lexicon.d.ts +8 -0
  12. package/dist/cli/commands/check-lexicon.d.ts.map +1 -1
  13. package/dist/cli/commands/doctor.d.ts.map +1 -1
  14. package/dist/cli/commands/import-agents.d.ts.map +1 -1
  15. package/dist/cli/commands/init.d.ts.map +1 -1
  16. package/dist/cli/commands/lint.d.ts.map +1 -1
  17. package/dist/cli/commands/update.d.ts +6 -0
  18. package/dist/cli/commands/update.d.ts.map +1 -1
  19. package/dist/cli/commands/vendor.d.ts +5 -0
  20. package/dist/cli/commands/vendor.d.ts.map +1 -1
  21. package/dist/cli/handlers/build.d.ts.map +1 -1
  22. package/dist/cli/handlers/components.d.ts.map +1 -1
  23. package/dist/cli/handlers/dev.d.ts.map +1 -1
  24. package/dist/cli/handlers/fan-out.d.ts.map +1 -1
  25. package/dist/cli/handlers/init.d.ts.map +1 -1
  26. package/dist/cli/handlers/operator.d.ts +7 -0
  27. package/dist/cli/handlers/operator.d.ts.map +1 -1
  28. package/dist/cli/handlers/promote.d.ts +7 -4
  29. package/dist/cli/handlers/promote.d.ts.map +1 -1
  30. package/dist/cli/handlers/run-generate.d.ts.map +1 -1
  31. package/dist/cli/handlers/run.d.ts +4 -1
  32. package/dist/cli/handlers/run.d.ts.map +1 -1
  33. package/dist/cli/handlers/vendor.d.ts +8 -3
  34. package/dist/cli/handlers/vendor.d.ts.map +1 -1
  35. package/dist/cli/main.d.ts +12 -0
  36. package/dist/cli/main.d.ts.map +1 -1
  37. package/dist/cli/plugins.d.ts +12 -7
  38. package/dist/cli/plugins.d.ts.map +1 -1
  39. package/dist/cli/registry.d.ts +32 -0
  40. package/dist/cli/registry.d.ts.map +1 -1
  41. package/dist/codegen/fetch.d.ts +10 -0
  42. package/dist/codegen/fetch.d.ts.map +1 -1
  43. package/dist/components/cli-support.d.ts +3 -1
  44. package/dist/components/cli-support.d.ts.map +1 -1
  45. package/dist/components/discover.d.ts.map +1 -1
  46. package/dist/components/driver.d.ts +16 -2
  47. package/dist/components/driver.d.ts.map +1 -1
  48. package/dist/components/gate-plan.d.ts +40 -0
  49. package/dist/components/gate-plan.d.ts.map +1 -0
  50. package/dist/components/promote.d.ts +60 -7
  51. package/dist/components/promote.d.ts.map +1 -1
  52. package/dist/components/sandbox/driver.d.ts.map +1 -1
  53. package/dist/components/sandbox/run.d.ts.map +1 -1
  54. package/dist/components/verbs/build-archive.d.ts +22 -11
  55. package/dist/components/verbs/build-archive.d.ts.map +1 -1
  56. package/dist/components/verbs/run-agent.d.ts.map +1 -1
  57. package/dist/config-static.d.ts +59 -0
  58. package/dist/config-static.d.ts.map +1 -0
  59. package/dist/config.d.ts +32 -10
  60. package/dist/config.d.ts.map +1 -1
  61. package/dist/content-digest.d.ts +17 -0
  62. package/dist/content-digest.d.ts.map +1 -0
  63. package/dist/discovery/files.d.ts +10 -5
  64. package/dist/discovery/files.d.ts.map +1 -1
  65. package/dist/discovery/fold-import.d.ts +20 -4
  66. package/dist/discovery/fold-import.d.ts.map +1 -1
  67. package/dist/discovery/index.d.ts.map +1 -1
  68. package/dist/discovery/sandbox/driver.d.ts +20 -0
  69. package/dist/discovery/sandbox/driver.d.ts.map +1 -1
  70. package/dist/discovery/sandbox/fork.d.ts +20 -0
  71. package/dist/discovery/sandbox/fork.d.ts.map +1 -1
  72. package/dist/discovery/walk.d.ts +119 -0
  73. package/dist/discovery/walk.d.ts.map +1 -0
  74. package/dist/graph-ir.d.ts +4 -1
  75. package/dist/graph-ir.d.ts.map +1 -1
  76. package/dist/join-key.d.ts +31 -0
  77. package/dist/join-key.d.ts.map +1 -0
  78. package/dist/lexicon-module.d.ts +51 -6
  79. package/dist/lexicon-module.d.ts.map +1 -1
  80. package/dist/lexicon.d.ts +58 -1
  81. package/dist/lexicon.d.ts.map +1 -1
  82. package/dist/lifecycle/build-ledger-store.d.ts.map +1 -1
  83. package/dist/lifecycle/digest.d.ts +5 -1
  84. package/dist/lifecycle/digest.d.ts.map +1 -1
  85. package/dist/lifecycle/gate-ledger.d.ts +20 -5
  86. package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
  87. package/dist/lifecycle/git.d.ts +64 -0
  88. package/dist/lifecycle/git.d.ts.map +1 -1
  89. package/dist/lifecycle/lease.d.ts +8 -1
  90. package/dist/lifecycle/lease.d.ts.map +1 -1
  91. package/dist/lifecycle/legacy-digest.d.ts +41 -8
  92. package/dist/lifecycle/legacy-digest.d.ts.map +1 -1
  93. package/dist/lifecycle/member-ledger.d.ts +67 -0
  94. package/dist/lifecycle/member-ledger.d.ts.map +1 -0
  95. package/dist/lifecycle/plan-digest.d.ts +4 -3
  96. package/dist/lifecycle/plan-digest.d.ts.map +1 -1
  97. package/dist/lifecycle/release-ledger.d.ts +18 -2
  98. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  99. package/dist/lifecycle/status.d.ts +90 -5
  100. package/dist/lifecycle/status.d.ts.map +1 -1
  101. package/dist/op/activities/activity-contracts.d.ts +32 -0
  102. package/dist/op/activities/activity-contracts.d.ts.map +1 -1
  103. package/dist/op/activities/index.d.ts +2 -0
  104. package/dist/op/activities/index.d.ts.map +1 -1
  105. package/dist/op/activities/propose-upgrade.d.ts +75 -0
  106. package/dist/op/activities/propose-upgrade.d.ts.map +1 -0
  107. package/dist/op/discover.d.ts.map +1 -1
  108. package/dist/op/gate-name.d.ts +7 -0
  109. package/dist/op/gate-name.d.ts.map +1 -1
  110. package/dist/op/gate-summary.d.ts +16 -0
  111. package/dist/op/gate-summary.d.ts.map +1 -1
  112. package/dist/op/gate.d.ts +16 -2
  113. package/dist/op/gate.d.ts.map +1 -1
  114. package/dist/project-root.d.ts +26 -0
  115. package/dist/project-root.d.ts.map +1 -1
  116. package/dist/workspace/__fixtures__/contract-repo.d.ts +37 -0
  117. package/dist/workspace/__fixtures__/contract-repo.d.ts.map +1 -0
  118. package/dist/workspace/__fixtures__/two-member-workspace.d.ts +11 -0
  119. package/dist/workspace/__fixtures__/two-member-workspace.d.ts.map +1 -0
  120. package/dist/workspace/checks/generated.d.ts +156 -0
  121. package/dist/workspace/checks/generated.d.ts.map +1 -0
  122. package/dist/workspace/checks/ledgers.d.ts +78 -0
  123. package/dist/workspace/checks/ledgers.d.ts.map +1 -0
  124. package/dist/workspace/checks/links.d.ts +25 -0
  125. package/dist/workspace/checks/links.d.ts.map +1 -0
  126. package/dist/workspace/checks/pipelines.d.ts +76 -0
  127. package/dist/workspace/checks/pipelines.d.ts.map +1 -0
  128. package/dist/workspace/checks.d.ts +161 -0
  129. package/dist/workspace/checks.d.ts.map +1 -0
  130. package/dist/workspace/compose-graph.d.ts +115 -0
  131. package/dist/workspace/compose-graph.d.ts.map +1 -0
  132. package/dist/workspace/compose-reports.d.ts +68 -0
  133. package/dist/workspace/compose-reports.d.ts.map +1 -0
  134. package/dist/workspace/declaration.d.ts +220 -0
  135. package/dist/workspace/declaration.d.ts.map +1 -0
  136. package/dist/workspace/declaration.schema.json +434 -0
  137. package/dist/workspace/generated-files.d.ts +65 -0
  138. package/dist/workspace/generated-files.d.ts.map +1 -0
  139. package/dist/workspace/glob.d.ts +13 -0
  140. package/dist/workspace/glob.d.ts.map +1 -0
  141. package/dist/workspace/graph-cli.d.ts +75 -0
  142. package/dist/workspace/graph-cli.d.ts.map +1 -0
  143. package/dist/workspace/init.d.ts +96 -0
  144. package/dist/workspace/init.d.ts.map +1 -0
  145. package/dist/workspace/jsonc.d.ts +38 -0
  146. package/dist/workspace/jsonc.d.ts.map +1 -0
  147. package/dist/workspace/kinds.d.ts +192 -0
  148. package/dist/workspace/kinds.d.ts.map +1 -0
  149. package/dist/workspace/lineage-check.d.ts +84 -0
  150. package/dist/workspace/lineage-check.d.ts.map +1 -0
  151. package/dist/workspace/lineage-cli.d.ts +31 -0
  152. package/dist/workspace/lineage-cli.d.ts.map +1 -0
  153. package/dist/workspace/lineage-init.d.ts +101 -0
  154. package/dist/workspace/lineage-init.d.ts.map +1 -0
  155. package/dist/workspace/lineage-lock.d.ts +258 -0
  156. package/dist/workspace/lineage-lock.d.ts.map +1 -0
  157. package/dist/workspace/lineage-merge.d.ts +14 -0
  158. package/dist/workspace/lineage-merge.d.ts.map +1 -0
  159. package/dist/workspace/lineage-migrations.d.ts +178 -0
  160. package/dist/workspace/lineage-migrations.d.ts.map +1 -0
  161. package/dist/workspace/lineage-update.d.ts +59 -0
  162. package/dist/workspace/lineage-update.d.ts.map +1 -0
  163. package/dist/workspace/lineage-upgrade-cli.d.ts +40 -0
  164. package/dist/workspace/lineage-upgrade-cli.d.ts.map +1 -0
  165. package/dist/workspace/lineage-upgrade.d.ts +146 -0
  166. package/dist/workspace/lineage-upgrade.d.ts.map +1 -0
  167. package/dist/workspace/lineage-vendor.d.ts +63 -0
  168. package/dist/workspace/lineage-vendor.d.ts.map +1 -0
  169. package/dist/workspace/lineage-version.d.ts +32 -0
  170. package/dist/workspace/lineage-version.d.ts.map +1 -0
  171. package/dist/workspace/links.d.ts +150 -0
  172. package/dist/workspace/links.d.ts.map +1 -0
  173. package/dist/workspace/ls.d.ts +99 -0
  174. package/dist/workspace/ls.d.ts.map +1 -0
  175. package/dist/workspace/member-commands.d.ts +139 -0
  176. package/dist/workspace/member-commands.d.ts.map +1 -0
  177. package/dist/workspace/member-handles.d.ts +54 -0
  178. package/dist/workspace/member-handles.d.ts.map +1 -0
  179. package/dist/workspace/member-pipeline.d.ts +143 -0
  180. package/dist/workspace/member-pipeline.d.ts.map +1 -0
  181. package/dist/workspace/member-run.d.ts +67 -0
  182. package/dist/workspace/member-run.d.ts.map +1 -0
  183. package/dist/workspace/reason-codes.d.ts +65 -0
  184. package/dist/workspace/reason-codes.d.ts.map +1 -0
  185. package/dist/workspace/records-cli.d.ts +28 -4
  186. package/dist/workspace/records-cli.d.ts.map +1 -1
  187. package/dist/workspace/records.d.ts.map +1 -1
  188. package/dist/workspace/root-refusal.d.ts +53 -0
  189. package/dist/workspace/root-refusal.d.ts.map +1 -0
  190. package/dist/workspace/status.d.ts +150 -0
  191. package/dist/workspace/status.d.ts.map +1 -0
  192. package/dist/workspace/template-manifest.d.ts +90 -0
  193. package/dist/workspace/template-manifest.d.ts.map +1 -0
  194. package/dist/workspace/tree.d.ts +36 -0
  195. package/dist/workspace/tree.d.ts.map +1 -0
  196. package/dist/workspace/trust/attestor.d.ts +67 -0
  197. package/dist/workspace/trust/attestor.d.ts.map +1 -0
  198. package/dist/workspace/trust/policy.d.ts +111 -0
  199. package/dist/workspace/trust/policy.d.ts.map +1 -0
  200. package/dist/workspace/trust/provenance.d.ts +67 -0
  201. package/dist/workspace/trust/provenance.d.ts.map +1 -0
  202. package/dist/workspace/trust/ssh-commit.d.ts +43 -0
  203. package/dist/workspace/trust/ssh-commit.d.ts.map +1 -0
  204. package/dist/workspace/trust/test-repo.d.ts +42 -0
  205. package/dist/workspace/trust/test-repo.d.ts.map +1 -0
  206. package/dist/workspace/trust/verify-cli.d.ts +9 -0
  207. package/dist/workspace/trust/verify-cli.d.ts.map +1 -0
  208. package/dist/workspace/trust/verify.d.ts +66 -0
  209. package/dist/workspace/trust/verify.d.ts.map +1 -0
  210. package/dist/workspace/which-chant.d.ts +58 -0
  211. package/dist/workspace/which-chant.d.ts.map +1 -0
  212. package/dist/workspace/workspace-kinds.schema.json +133 -0
  213. package/package.json +2 -1
  214. package/src/audit/discover.ts +66 -78
  215. package/src/audit/report-html.ts +3 -1
  216. package/src/audit/report-model.ts +14 -1
  217. package/src/audit/terraform-state.test.ts +4 -9
  218. package/src/audit/terraform-state.ts +4 -5
  219. package/src/cli/commands/audit-truncation.test.ts +167 -0
  220. package/src/cli/commands/audit.ts +89 -60
  221. package/src/cli/commands/check-lexicon.ts +24 -0
  222. package/src/cli/commands/doctor.test.ts +30 -0
  223. package/src/cli/commands/doctor.ts +18 -0
  224. package/src/cli/commands/import-agents.ts +6 -2
  225. package/src/cli/commands/init.ts +22 -3
  226. package/src/cli/commands/lint.test.ts +17 -23
  227. package/src/cli/commands/lint.ts +24 -84
  228. package/src/cli/commands/update.ts +13 -4
  229. package/src/cli/commands/vendor.ts +11 -6
  230. package/src/cli/handlers/__snapshots__/build-member.test.ts.snap +38 -0
  231. package/src/cli/handlers/build-member.test.ts +127 -0
  232. package/src/cli/handlers/build.ts +35 -1
  233. package/src/cli/handlers/components.test.ts +127 -0
  234. package/src/cli/handlers/components.ts +70 -8
  235. package/src/cli/handlers/dev.ts +5 -3
  236. package/src/cli/handlers/fan-out.ts +9 -2
  237. package/src/cli/handlers/init.ts +54 -1
  238. package/src/cli/handlers/operator.test.ts +68 -0
  239. package/src/cli/handlers/operator.ts +37 -9
  240. package/src/cli/handlers/promote.test.ts +118 -2
  241. package/src/cli/handlers/promote.ts +82 -16
  242. package/src/cli/handlers/run-generate-member.test.ts +83 -0
  243. package/src/cli/handlers/run-generate.test.ts +6 -8
  244. package/src/cli/handlers/run-generate.ts +36 -1
  245. package/src/cli/handlers/run.test.ts +47 -0
  246. package/src/cli/handlers/run.ts +28 -5
  247. package/src/cli/handlers/vendor.ts +147 -43
  248. package/src/cli/main.test.ts +105 -1
  249. package/src/cli/main.ts +230 -17
  250. package/src/cli/plugins.ts +17 -17
  251. package/src/cli/registry.ts +32 -0
  252. package/src/cli/static-config-read.test.ts +208 -0
  253. package/src/codegen/fetch.test.ts +63 -1
  254. package/src/codegen/fetch.ts +30 -1
  255. package/src/components/cli-support.ts +6 -1
  256. package/src/components/discover.test.ts +27 -57
  257. package/src/components/discover.ts +13 -68
  258. package/src/components/driver.test.ts +78 -1
  259. package/src/components/driver.ts +43 -7
  260. package/src/components/gate-plan.ts +53 -0
  261. package/src/components/promote.test.ts +276 -2
  262. package/src/components/promote.ts +119 -15
  263. package/src/components/sandbox/driver.ts +8 -8
  264. package/src/components/sandbox/run.ts +4 -1
  265. package/src/components/verbs/build-archive.ts +27 -21
  266. package/src/components/verbs/run-agent.ts +3 -5
  267. package/src/config-static.test.ts +136 -0
  268. package/src/config-static.ts +232 -0
  269. package/src/config.test.ts +2 -2
  270. package/src/config.ts +48 -15
  271. package/src/content-digest.test.ts +120 -0
  272. package/src/content-digest.ts +21 -0
  273. package/src/discovery/files.test.ts +10 -10
  274. package/src/discovery/files.ts +25 -81
  275. package/src/discovery/fold-import.ts +49 -5
  276. package/src/discovery/index.ts +1 -0
  277. package/src/discovery/sandbox/driver.ts +73 -35
  278. package/src/discovery/sandbox/fork-diagnostic.test.ts +136 -13
  279. package/src/discovery/sandbox/fork.ts +83 -43
  280. package/src/discovery/sandbox/path-lexicon-multifile.test.ts +285 -0
  281. package/src/discovery/walk.test.ts +263 -0
  282. package/src/discovery/walk.ts +334 -0
  283. package/src/effect-receipt.ts +2 -2
  284. package/src/graph-ir.ts +4 -1
  285. package/src/join-key.test.ts +25 -0
  286. package/src/join-key.ts +39 -0
  287. package/src/lexicon-module.ts +108 -10
  288. package/src/lexicon.ts +79 -1
  289. package/src/lifecycle/build-ledger-store.ts +11 -10
  290. package/src/lifecycle/digest.ts +9 -5
  291. package/src/lifecycle/gate-ledger.test.ts +20 -0
  292. package/src/lifecycle/gate-ledger.ts +28 -6
  293. package/src/lifecycle/git.test.ts +13 -1
  294. package/src/lifecycle/git.ts +221 -176
  295. package/src/lifecycle/lease.ts +25 -10
  296. package/src/lifecycle/legacy-digest.test.ts +115 -23
  297. package/src/lifecycle/legacy-digest.ts +60 -19
  298. package/src/lifecycle/member-ledger.test.ts +319 -0
  299. package/src/lifecycle/member-ledger.ts +145 -0
  300. package/src/lifecycle/plan-digest.ts +7 -7
  301. package/src/lifecycle/release-ledger.test.ts +20 -0
  302. package/src/lifecycle/release-ledger.ts +23 -7
  303. package/src/lifecycle/status.test.ts +151 -1
  304. package/src/lifecycle/status.ts +228 -7
  305. package/src/op/activities/activity-contracts.ts +37 -0
  306. package/src/op/activities/index.ts +10 -0
  307. package/src/op/activities/propose-upgrade.ts +206 -0
  308. package/src/op/discover.test.ts +14 -4
  309. package/src/op/discover.ts +19 -27
  310. package/src/op/gate-name.ts +8 -0
  311. package/src/op/gate-summary.test.ts +14 -0
  312. package/src/op/gate-summary.ts +25 -2
  313. package/src/op/gate.ts +36 -7
  314. package/src/op/generate-pipeline.test.ts +14 -5
  315. package/src/project-root.test.ts +66 -1
  316. package/src/project-root.ts +48 -0
  317. package/src/workspace/__fixtures__/contract-repo.ts +100 -0
  318. package/src/workspace/__fixtures__/two-member-workspace.ts +35 -0
  319. package/src/workspace/behold-kinds.test.ts +162 -0
  320. package/src/workspace/check-contract.test.ts +127 -0
  321. package/src/workspace/check.schema.json +347 -0
  322. package/src/workspace/checks/generated.test.ts +287 -0
  323. package/src/workspace/checks/generated.ts +475 -0
  324. package/src/workspace/checks/ledgers.test.ts +139 -0
  325. package/src/workspace/checks/ledgers.ts +246 -0
  326. package/src/workspace/checks/links.ts +183 -0
  327. package/src/workspace/checks/pipelines.test.ts +133 -0
  328. package/src/workspace/checks/pipelines.ts +225 -0
  329. package/src/workspace/checks-repo.test.ts +71 -0
  330. package/src/workspace/checks.test.ts +450 -0
  331. package/src/workspace/checks.ts +461 -0
  332. package/src/workspace/compose-graph.test.ts +146 -0
  333. package/src/workspace/compose-graph.ts +228 -0
  334. package/src/workspace/compose-reports.test.ts +109 -0
  335. package/src/workspace/compose-reports.ts +186 -0
  336. package/src/workspace/declaration.schema.json +434 -0
  337. package/src/workspace/declaration.test.ts +347 -0
  338. package/src/workspace/declaration.ts +623 -0
  339. package/src/workspace/generated-files.test.ts +114 -0
  340. package/src/workspace/generated-files.ts +94 -0
  341. package/src/workspace/glob.ts +49 -0
  342. package/src/workspace/graph-cli.ts +220 -0
  343. package/src/workspace/graph-contract.test.ts +204 -0
  344. package/src/workspace/graph.schema.json +662 -0
  345. package/src/workspace/init.test.ts +223 -0
  346. package/src/workspace/init.ts +585 -0
  347. package/src/workspace/jsonc.test.ts +65 -0
  348. package/src/workspace/jsonc.ts +231 -0
  349. package/src/workspace/kinds.test.ts +288 -0
  350. package/src/workspace/kinds.ts +506 -0
  351. package/src/workspace/lineage-check.ts +264 -0
  352. package/src/workspace/lineage-cli.ts +114 -0
  353. package/src/workspace/lineage-init.test.ts +231 -0
  354. package/src/workspace/lineage-init.ts +365 -0
  355. package/src/workspace/lineage-lock.test.ts +224 -0
  356. package/src/workspace/lineage-lock.ts +357 -0
  357. package/src/workspace/lineage-merge.ts +44 -0
  358. package/src/workspace/lineage-migrations.test.ts +178 -0
  359. package/src/workspace/lineage-migrations.ts +343 -0
  360. package/src/workspace/lineage-update.ts +160 -0
  361. package/src/workspace/lineage-upgrade-cli.ts +151 -0
  362. package/src/workspace/lineage-upgrade.test.ts +474 -0
  363. package/src/workspace/lineage-upgrade.ts +624 -0
  364. package/src/workspace/lineage-vendor.test.ts +126 -0
  365. package/src/workspace/lineage-vendor.ts +215 -0
  366. package/src/workspace/lineage-version.ts +127 -0
  367. package/src/workspace/links.test.ts +344 -0
  368. package/src/workspace/links.ts +331 -0
  369. package/src/workspace/ls-contract.test.ts +200 -0
  370. package/src/workspace/ls.schema.json +190 -0
  371. package/src/workspace/ls.ts +254 -0
  372. package/src/workspace/member-commands.e2e.test.ts +244 -0
  373. package/src/workspace/member-commands.test.ts +217 -0
  374. package/src/workspace/member-commands.ts +540 -0
  375. package/src/workspace/member-handles.test.ts +76 -0
  376. package/src/workspace/member-handles.ts +228 -0
  377. package/src/workspace/member-pipeline.test.ts +135 -0
  378. package/src/workspace/member-pipeline.ts +317 -0
  379. package/src/workspace/member-run.ts +146 -0
  380. package/src/workspace/read-contract.test.ts +129 -0
  381. package/src/workspace/reason-codes.test.ts +113 -0
  382. package/src/workspace/reason-codes.ts +81 -0
  383. package/src/workspace/records-cli.ts +86 -14
  384. package/src/workspace/records-contract.test.ts +5 -0
  385. package/src/workspace/records.schema.json +32 -2
  386. package/src/workspace/records.ts +3 -2
  387. package/src/workspace/root-refusal.ts +97 -0
  388. package/src/workspace/status-contract.test.ts +308 -0
  389. package/src/workspace/status.schema.json +210 -0
  390. package/src/workspace/status.ts +412 -0
  391. package/src/workspace/template-manifest.test.ts +79 -0
  392. package/src/workspace/template-manifest.ts +221 -0
  393. package/src/workspace/tree.ts +132 -0
  394. package/src/workspace/trust/attestor.ts +93 -0
  395. package/src/workspace/trust/policy.ts +306 -0
  396. package/src/workspace/trust/provenance.ts +181 -0
  397. package/src/workspace/trust/ssh-commit.ts +138 -0
  398. package/src/workspace/trust/test-repo.ts +138 -0
  399. package/src/workspace/trust/trust.test.ts +397 -0
  400. package/src/workspace/trust/verify-cli.ts +56 -0
  401. package/src/workspace/trust/verify.ts +194 -0
  402. package/src/workspace/which-chant.test.ts +117 -0
  403. package/src/workspace/which-chant.ts +151 -0
  404. package/src/workspace/workspace-kinds.schema.json +133 -0
  405. package/dist/components/unbound-gate-approval.d.ts +0 -24
  406. package/dist/components/unbound-gate-approval.d.ts.map +0 -1
  407. package/dist/discovery/convergence.d.ts +0 -97
  408. package/dist/discovery/convergence.d.ts.map +0 -1
  409. package/src/cli/commands/audit-walk-warnings.test.ts +0 -156
  410. package/src/components/unbound-gate-approval.test.ts +0 -82
  411. package/src/components/unbound-gate-approval.ts +0 -51
  412. package/src/discovery/convergence.test.ts +0 -231
  413. package/src/discovery/convergence.ts +0 -399
  414. package/src/op/discover-convergence.test.ts +0 -70
@@ -0,0 +1,258 @@
1
+ /**
2
+ * The lineage lock, `.chant/workspace.lock.json` (#2524 D9, #2540).
3
+ *
4
+ * The lock records where a project's files came from. It holds one lineage per
5
+ * scope, keyed by the scope's directory relative to the lock's root:
6
+ *
7
+ * - a project made by `chant init --from <repo>@<ref>` or
8
+ * `chant init --template <name>` has one scope, `"."`;
9
+ * - each `chant vendor` target is a scope of kind `vendor` (copied, no
10
+ * parameters), which replaces its entry in `vendor.json` (ws-038).
11
+ *
12
+ * A lineage names its template, the content address the files came from, the
13
+ * parameter values used, the migrations applied so far and, per file, a class
14
+ * (`owned`, `generated` or `seed`) and the hash the file had when chant wrote
15
+ * it. That hash is the merge base: a file whose content still has it was not
16
+ * edited, and an update may replace it. A file that differs is the project's
17
+ * own, and an update that also changed it becomes a manual step instead of an
18
+ * overwrite. `chant workspace upgrade` (#2550) builds on exactly this.
19
+ *
20
+ * Lineage works for a plain project (#2525 rule 4, ws-013): the lock sits at
21
+ * the project root and needs no `chant.workspace.json`. Like everything under
22
+ * `workspace/`, this module loads only when a lock exists or a command that
23
+ * writes one runs, never on a level-0 path (#2525 rule 5).
24
+ */
25
+ import { z } from "zod";
26
+ import { type DeclaredFiles } from "./generated-files.js";
27
+ /** Where the lock lives, relative to the project (or workspace) root. */
28
+ export declare const LOCK_FILE = ".chant/workspace.lock.json";
29
+ /** The format this chant reads and writes. A reader refuses a newer one. */
30
+ export declare const LOCK_VERSION = 1;
31
+ /**
32
+ * How an update treats a file (D9, D14).
33
+ *
34
+ * - `owned`: from the template; replaced by an update when it still has its
35
+ * recorded hash, merged or turned into a manual step when it does not.
36
+ * - `generated`: rebuilt by `command` rather than merged.
37
+ * - `seed`: written once at init and never touched again.
38
+ */
39
+ export declare const FILE_CLASSES: readonly ["owned", "generated", "seed"];
40
+ export type FileClass = (typeof FILE_CLASSES)[number];
41
+ /** Where a template's files are fetched from. */
42
+ declare const SourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
43
+ type: z.ZodLiteral<"git">;
44
+ repo: z.ZodString;
45
+ url: z.ZodString;
46
+ path: z.ZodOptional<z.ZodString>;
47
+ }, z.core.$strict>, z.ZodObject<{
48
+ type: z.ZodLiteral<"lexicon">;
49
+ lexicon: z.ZodString;
50
+ template: z.ZodString;
51
+ }, z.core.$strict>, z.ZodObject<{
52
+ type: z.ZodLiteral<"local">;
53
+ path: z.ZodString;
54
+ }, z.core.$strict>, z.ZodObject<{
55
+ type: z.ZodLiteral<"archive">;
56
+ url: z.ZodString;
57
+ subpath: z.ZodOptional<z.ZodString>;
58
+ }, z.core.$strict>], "type">;
59
+ export type LineageSource = z.infer<typeof SourceSchema>;
60
+ /**
61
+ * Why an update left a file alone. Closed: a reader may switch on it.
62
+ *
63
+ * - `changed-locally`: both the project and the source changed the file.
64
+ * - `deleted-locally`: the project deleted a file the source changed.
65
+ * - `exists-locally`: the source added a file the project already has.
66
+ * - `removed-upstream`: the source removed a file the project changed.
67
+ */
68
+ export declare const MANUAL_STEP_REASONS: readonly ["changed-locally", "deleted-locally", "exists-locally", "removed-upstream"];
69
+ export type ManualStepReason = (typeof MANUAL_STEP_REASONS)[number];
70
+ declare const ManualStepSchema: z.ZodObject<{
71
+ path: z.ZodString;
72
+ reason: z.ZodEnum<{
73
+ "changed-locally": "changed-locally";
74
+ "deleted-locally": "deleted-locally";
75
+ "exists-locally": "exists-locally";
76
+ "removed-upstream": "removed-upstream";
77
+ }>;
78
+ upstream: z.ZodNullable<z.ZodString>;
79
+ }, z.core.$strict>;
80
+ export type ManualStep = z.infer<typeof ManualStepSchema>;
81
+ declare const LineageSchema: z.ZodObject<{
82
+ kind: z.ZodEnum<{
83
+ template: "template";
84
+ vendor: "vendor";
85
+ }>;
86
+ name: z.ZodOptional<z.ZodString>;
87
+ template: z.ZodString;
88
+ source: z.ZodDiscriminatedUnion<[z.ZodObject<{
89
+ type: z.ZodLiteral<"git">;
90
+ repo: z.ZodString;
91
+ url: z.ZodString;
92
+ path: z.ZodOptional<z.ZodString>;
93
+ }, z.core.$strict>, z.ZodObject<{
94
+ type: z.ZodLiteral<"lexicon">;
95
+ lexicon: z.ZodString;
96
+ template: z.ZodString;
97
+ }, z.core.$strict>, z.ZodObject<{
98
+ type: z.ZodLiteral<"local">;
99
+ path: z.ZodString;
100
+ }, z.core.$strict>, z.ZodObject<{
101
+ type: z.ZodLiteral<"archive">;
102
+ url: z.ZodString;
103
+ subpath: z.ZodOptional<z.ZodString>;
104
+ }, z.core.$strict>], "type">;
105
+ ref: z.ZodOptional<z.ZodString>;
106
+ address: z.ZodNullable<z.ZodObject<{
107
+ digest: z.ZodString;
108
+ commit: z.ZodOptional<z.ZodString>;
109
+ tree: z.ZodOptional<z.ZodString>;
110
+ package: z.ZodOptional<z.ZodString>;
111
+ version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
112
+ chant: z.ZodOptional<z.ZodString>;
113
+ }, z.core.$strict>>;
114
+ parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
115
+ migrations: z.ZodArray<z.ZodString>;
116
+ files: z.ZodRecord<z.ZodString, z.ZodObject<{
117
+ class: z.ZodEnum<{
118
+ owned: "owned";
119
+ generated: "generated";
120
+ seed: "seed";
121
+ }>;
122
+ sha256: z.ZodString;
123
+ command: z.ZodOptional<z.ZodString>;
124
+ }, z.core.$strict>>;
125
+ manualSteps: z.ZodArray<z.ZodObject<{
126
+ path: z.ZodString;
127
+ reason: z.ZodEnum<{
128
+ "changed-locally": "changed-locally";
129
+ "deleted-locally": "deleted-locally";
130
+ "exists-locally": "exists-locally";
131
+ "removed-upstream": "removed-upstream";
132
+ }>;
133
+ upstream: z.ZodNullable<z.ZodString>;
134
+ }, z.core.$strict>>;
135
+ }, z.core.$strict>;
136
+ export type Lineage = z.infer<typeof LineageSchema>;
137
+ declare const LockSchema: z.ZodObject<{
138
+ lockVersion: z.ZodLiteral<1>;
139
+ scopes: z.ZodRecord<z.ZodString, z.ZodObject<{
140
+ kind: z.ZodEnum<{
141
+ template: "template";
142
+ vendor: "vendor";
143
+ }>;
144
+ name: z.ZodOptional<z.ZodString>;
145
+ template: z.ZodString;
146
+ source: z.ZodDiscriminatedUnion<[z.ZodObject<{
147
+ type: z.ZodLiteral<"git">;
148
+ repo: z.ZodString;
149
+ url: z.ZodString;
150
+ path: z.ZodOptional<z.ZodString>;
151
+ }, z.core.$strict>, z.ZodObject<{
152
+ type: z.ZodLiteral<"lexicon">;
153
+ lexicon: z.ZodString;
154
+ template: z.ZodString;
155
+ }, z.core.$strict>, z.ZodObject<{
156
+ type: z.ZodLiteral<"local">;
157
+ path: z.ZodString;
158
+ }, z.core.$strict>, z.ZodObject<{
159
+ type: z.ZodLiteral<"archive">;
160
+ url: z.ZodString;
161
+ subpath: z.ZodOptional<z.ZodString>;
162
+ }, z.core.$strict>], "type">;
163
+ ref: z.ZodOptional<z.ZodString>;
164
+ address: z.ZodNullable<z.ZodObject<{
165
+ digest: z.ZodString;
166
+ commit: z.ZodOptional<z.ZodString>;
167
+ tree: z.ZodOptional<z.ZodString>;
168
+ package: z.ZodOptional<z.ZodString>;
169
+ version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
170
+ chant: z.ZodOptional<z.ZodString>;
171
+ }, z.core.$strict>>;
172
+ parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
173
+ migrations: z.ZodArray<z.ZodString>;
174
+ files: z.ZodRecord<z.ZodString, z.ZodObject<{
175
+ class: z.ZodEnum<{
176
+ owned: "owned";
177
+ generated: "generated";
178
+ seed: "seed";
179
+ }>;
180
+ sha256: z.ZodString;
181
+ command: z.ZodOptional<z.ZodString>;
182
+ }, z.core.$strict>>;
183
+ manualSteps: z.ZodArray<z.ZodObject<{
184
+ path: z.ZodString;
185
+ reason: z.ZodEnum<{
186
+ "changed-locally": "changed-locally";
187
+ "deleted-locally": "deleted-locally";
188
+ "exists-locally": "exists-locally";
189
+ "removed-upstream": "removed-upstream";
190
+ }>;
191
+ upstream: z.ZodNullable<z.ZodString>;
192
+ }, z.core.$strict>>;
193
+ }, z.core.$strict>>;
194
+ }, z.core.$strict>;
195
+ export type LineageLock = z.infer<typeof LockSchema>;
196
+ /** `sha256:<hex>` of one file's bytes. */
197
+ export declare function fileHash(data: Buffer | string): string;
198
+ /**
199
+ * The content hash of a file set, independent of order: sha256 over each
200
+ * `path\0content\0` in sorted-path order. Identical to `vendor.json`'s
201
+ * `checksum`, so a migrated entry keeps its digest.
202
+ */
203
+ export declare function contentDigest(files: Map<string, Buffer>): string;
204
+ /** Normalise a scope directory to the lock's key form: posix, relative, `.` for the root. */
205
+ export declare function scopeKey(dir: string): string;
206
+ export declare class LockError extends Error {
207
+ name: string;
208
+ }
209
+ export declare function lockPath(root: string): string;
210
+ export declare function lockExists(root: string): boolean;
211
+ export declare function emptyLock(): LineageLock;
212
+ /** Read and validate the lock at `root`, or return null when there is none. */
213
+ export declare function readLock(root: string): LineageLock | null;
214
+ /** Validate a lock's text, such as one read from a revision (`chant workspace check --at`, #2536). */
215
+ export declare function parseLock(text: string): LineageLock;
216
+ /** Serialise the lock deterministically. */
217
+ export declare function renderLock(lock: LineageLock): string;
218
+ export declare function writeLock(root: string, lock: LineageLock): void;
219
+ /**
220
+ * The class a file gets (D14), from the same list the drift check reads
221
+ * (`generated-files.ts`): a member's declared generated files, passed as
222
+ * `declared`, then the implicit rules. Skills that `chant update` rewrites
223
+ * are generated, `.mcp.json` is a seed, a hand-written entry and the rest are
224
+ * owned. `.chant/types/` is ignored, and {@link fileEntries} leaves it out.
225
+ */
226
+ export declare function defaultFileClass(path: string, declared?: DeclaredFiles): {
227
+ class: FileClass;
228
+ command?: string;
229
+ };
230
+ /**
231
+ * The declared generated files for the scope directory `absDir`, from the
232
+ * workspace declaration above it, if any (#2541). A declaration that can't
233
+ * be read is a {@link LockError}, never an empty list.
234
+ */
235
+ export declare function declaredFilesAt(absDir: string): DeclaredFiles;
236
+ /** Per-file entries for a file set, each with its default class. Ignored paths (`.chant/types/`) are left out. */
237
+ export declare function fileEntries(files: Map<string, Buffer>, declared?: DeclaredFiles): Lineage["files"];
238
+ export interface ScopeStatus {
239
+ scope: string;
240
+ lineage: Lineage;
241
+ /** Files whose content no longer has the recorded hash (generated files excluded). */
242
+ customised: string[];
243
+ /** Files recorded in the lock and missing from the tree. */
244
+ missing: string[];
245
+ }
246
+ /** Compare each recorded file of a scope with the tree under `root`. */
247
+ export declare function scopeStatus(root: string, scope: string, lineage: Lineage): ScopeStatus;
248
+ /**
249
+ * Close a manual step: the file as it stands is the project's resolution, and
250
+ * the source's version becomes its new merge base. For a file the source
251
+ * removed, the file leaves the lineage and stays in the tree as the project's.
252
+ */
253
+ export declare function resolveManualStep(lock: LineageLock, filePath: string): {
254
+ scope: string;
255
+ step: ManualStep;
256
+ } | null;
257
+ export {};
258
+ //# sourceMappingURL=lineage-lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineage-lock.d.ts","sourceRoot":"","sources":["../../src/workspace/lineage-lock.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The three-way merge of one file (#2550, ws-005).
3
+ *
4
+ * ws-005 merges per file: a customised file takes the template's changes only
5
+ * when every hunk merges cleanly. Otherwise the file stays as it was and the
6
+ * upgrade records one manual step for it. So this answers with the merged
7
+ * bytes or with null, never with conflict markers.
8
+ *
9
+ * The merge is `git merge-file`, run on three scratch files. It reads no
10
+ * repository and reaches no network. A binary file never merges.
11
+ */
12
+ /** Merge `theirs` into `ours` against `base`. Null when any hunk conflicts, or the file is binary. */
13
+ export declare function mergeFile(base: Buffer, ours: Buffer, theirs: Buffer): Buffer | null;
14
+ //# sourceMappingURL=lineage-merge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineage-merge.d.ts","sourceRoot":"","sources":["../../src/workspace/lineage-merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,sGAAsG;AACtG,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoBnF"}
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Template migrations (#2550, D9).
3
+ *
4
+ * A template ships its migrations beside its files, under
5
+ * `.chant/migrations/`, one JSON file each. The metadata is data: an id, the
6
+ * template versions it applies `from` (a template id and a version range), the
7
+ * version it brings the scope `to`, a body, and a post-condition. The body is
8
+ * either a closed list of declarative steps or a module, marked
9
+ * `"type": "code"`, which runs only when the caller allows code.
10
+ *
11
+ * `chant workspace upgrade` plans a chain from the scope's version to the
12
+ * target: every migration whose `to` lies in between, ordered by `to`. Each
13
+ * must accept the version the scope has reached when its turn comes. When one
14
+ * does not, a migration is missing from the chain, and the upgrade is refused
15
+ * rather than applied in part.
16
+ *
17
+ * Migrations run inside the upgrade's staging worktree, before the per-file
18
+ * merge. A `move` or `delete` updates the lineage too, so the merge that
19
+ * follows compares the right merge base with the new version.
20
+ */
21
+ import { z } from "zod";
22
+ import { LockError, type Lineage } from "./lineage-lock.js";
23
+ import { type Version } from "./lineage-version.js";
24
+ /** Where a template keeps its migrations, relative to the template's directory. */
25
+ export declare const MIGRATIONS_DIR = ".chant/migrations";
26
+ /** The declarative steps. Closed: a step chant does not know is refused. */
27
+ declare const StepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
28
+ op: z.ZodLiteral<"move">;
29
+ from: z.ZodString;
30
+ to: z.ZodString;
31
+ }, z.core.$strict>, z.ZodObject<{
32
+ op: z.ZodLiteral<"delete">;
33
+ path: z.ZodString;
34
+ }, z.core.$strict>, z.ZodObject<{
35
+ op: z.ZodLiteral<"replace">;
36
+ path: z.ZodString;
37
+ find: z.ZodString;
38
+ with: z.ZodString;
39
+ }, z.core.$strict>, z.ZodObject<{
40
+ op: z.ZodLiteral<"json-set">;
41
+ path: z.ZodString;
42
+ pointer: z.ZodString;
43
+ value: z.ZodUnknown;
44
+ }, z.core.$strict>, z.ZodObject<{
45
+ op: z.ZodLiteral<"json-delete">;
46
+ path: z.ZodString;
47
+ pointer: z.ZodString;
48
+ }, z.core.$strict>], "op">;
49
+ export type MigrationStep = z.infer<typeof StepSchema>;
50
+ /** What must hold after a migration ran. Every check must pass. */
51
+ declare const PostSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
52
+ check: z.ZodLiteral<"exists">;
53
+ path: z.ZodString;
54
+ }, z.core.$strict>, z.ZodObject<{
55
+ check: z.ZodLiteral<"absent">;
56
+ path: z.ZodString;
57
+ }, z.core.$strict>, z.ZodObject<{
58
+ check: z.ZodLiteral<"contains">;
59
+ path: z.ZodString;
60
+ text: z.ZodString;
61
+ }, z.core.$strict>, z.ZodObject<{
62
+ check: z.ZodLiteral<"not-contains">;
63
+ path: z.ZodString;
64
+ text: z.ZodString;
65
+ }, z.core.$strict>], "check">;
66
+ export type MigrationCheck = z.infer<typeof PostSchema>;
67
+ declare const MigrationSchema: z.ZodObject<{
68
+ $schema: z.ZodOptional<z.ZodString>;
69
+ /** Unique within the template. Recorded in the lock once applied. */
70
+ id: z.ZodString;
71
+ description: z.ZodOptional<z.ZodString>;
72
+ from: z.ZodObject<{
73
+ /** The template id the migration applies to. Omitted, it applies to the template it ships in. */
74
+ template: z.ZodOptional<z.ZodString>;
75
+ /** The versions it can be applied to. */
76
+ versions: z.ZodString;
77
+ }, z.core.$strict>;
78
+ /** The version the scope is at once the migration ran. */
79
+ to: z.ZodString;
80
+ body: z.ZodDiscriminatedUnion<[z.ZodObject<{
81
+ type: z.ZodLiteral<"declarative">;
82
+ steps: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
83
+ op: z.ZodLiteral<"move">;
84
+ from: z.ZodString;
85
+ to: z.ZodString;
86
+ }, z.core.$strict>, z.ZodObject<{
87
+ op: z.ZodLiteral<"delete">;
88
+ path: z.ZodString;
89
+ }, z.core.$strict>, z.ZodObject<{
90
+ op: z.ZodLiteral<"replace">;
91
+ path: z.ZodString;
92
+ find: z.ZodString;
93
+ with: z.ZodString;
94
+ }, z.core.$strict>, z.ZodObject<{
95
+ op: z.ZodLiteral<"json-set">;
96
+ path: z.ZodString;
97
+ pointer: z.ZodString;
98
+ value: z.ZodUnknown;
99
+ }, z.core.$strict>, z.ZodObject<{
100
+ op: z.ZodLiteral<"json-delete">;
101
+ path: z.ZodString;
102
+ pointer: z.ZodString;
103
+ }, z.core.$strict>], "op">>;
104
+ }, z.core.$strict>, z.ZodObject<{
105
+ type: z.ZodLiteral<"code">;
106
+ module: z.ZodString;
107
+ }, z.core.$strict>], "type">;
108
+ post: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
109
+ check: z.ZodLiteral<"exists">;
110
+ path: z.ZodString;
111
+ }, z.core.$strict>, z.ZodObject<{
112
+ check: z.ZodLiteral<"absent">;
113
+ path: z.ZodString;
114
+ }, z.core.$strict>, z.ZodObject<{
115
+ check: z.ZodLiteral<"contains">;
116
+ path: z.ZodString;
117
+ text: z.ZodString;
118
+ }, z.core.$strict>, z.ZodObject<{
119
+ check: z.ZodLiteral<"not-contains">;
120
+ path: z.ZodString;
121
+ text: z.ZodString;
122
+ }, z.core.$strict>], "check">>>;
123
+ }, z.core.$strict>;
124
+ export type Migration = z.infer<typeof MigrationSchema>;
125
+ export declare class MigrationError extends LockError {
126
+ name: string;
127
+ }
128
+ export interface LoadedMigration {
129
+ migration: Migration;
130
+ /** The file it was read from, relative to the template directory. */
131
+ file: string;
132
+ }
133
+ /**
134
+ * Read the migrations out of a template's files (relative path to bytes).
135
+ * Returns them and the files that remain once `.chant/migrations/` is taken
136
+ * out: migrations are the template's, never copied into a project.
137
+ */
138
+ export declare function splitMigrations(files: Map<string, Buffer>): {
139
+ migrations: LoadedMigration[];
140
+ modules: Map<string, Buffer>;
141
+ files: Map<string, Buffer>;
142
+ };
143
+ export interface MigrationPlan {
144
+ /** In the order they run. */
145
+ chain: LoadedMigration[];
146
+ from: Version | null;
147
+ to: Version | null;
148
+ }
149
+ /**
150
+ * The migrations that take `lineage` from its version to `targetRef`, in order.
151
+ *
152
+ * Refused, with a {@link MigrationError}:
153
+ * - a target below the scope's version;
154
+ * - a pending migration when either end of the upgrade is not a version, so
155
+ * no chain can be computed;
156
+ * - a gap: a migration in range whose `from` does not accept the version the
157
+ * scope has reached by then.
158
+ */
159
+ export declare function planMigrations(lineage: Lineage, targetRef: string | undefined, available: LoadedMigration[]): MigrationPlan;
160
+ export interface RunMigrationOptions {
161
+ /** The scope directory in the staging worktree. */
162
+ dir: string;
163
+ lineage: Lineage;
164
+ /** Code modules from the template, relative to its migrations directory. */
165
+ modules: Map<string, Buffer>;
166
+ /** Run `"type": "code"` bodies. Without it, a chain holding one is refused. */
167
+ allowCode: boolean;
168
+ /** Where a code module is written before it is imported. */
169
+ scratch: string;
170
+ /** Told of each file a declarative step moves, so a caller keyed by path (the merge base) can follow. */
171
+ onMove?: (from: string, to: string) => void;
172
+ }
173
+ /** Refuse a chain holding code when code is not allowed, before anything runs. */
174
+ export declare function assertCodeAllowed(chain: LoadedMigration[], allowCode: boolean): void;
175
+ /** Run one migration in the worktree, then its post-condition. Updates `lineage`. */
176
+ export declare function runMigration(m: LoadedMigration, opts: RunMigrationOptions): Promise<void>;
177
+ export {};
178
+ //# sourceMappingURL=lineage-migrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineage-migrations.d.ts","sourceRoot":"","sources":["../../src/workspace/lineage-migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAA6F,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5I,mFAAmF;AACnF,eAAO,MAAM,cAAc,sBAAsB,CAAC;AAUlD,4EAA4E;AAC5E,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;0BAWd,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEvD,mEAAmE;AACnE,QAAA,MAAM,UAAU;;;;;;;;;;;;;;6BAKd,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAUxD,QAAA,MAAM,eAAe;;IAEnB,qEAAqE;;;;QAInE,iGAAiG;;QAEjG,yCAAyC;;;IAG3C,0DAA0D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAW1D,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,qBAAa,cAAe,SAAQ,SAAS;IAClC,IAAI,SAAoB;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,SAAS,CAAC;IACrB,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;IAAE,UAAU,EAAE,eAAe,EAAE,CAAC;IAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAsCvJ;AAID,MAAM,WAAW,aAAa;IAC5B,6BAA6B;IAC7B,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACrB,EAAE,EAAE,OAAO,GAAG,IAAI,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,aAAa,CA0C3H;AAID,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,4EAA4E;IAC5E,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,+EAA+E;IAC/E,SAAS,EAAE,OAAO,CAAC;IACnB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,yGAAyG;IACzG,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C;AAED,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI,CAOpF;AAED,qFAAqF;AACrF,wBAAsB,YAAY,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4B/F"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Bring one lineage scope to a new version of its source, file by file,
3
+ * without deleting the project's edits (#2540, ws-038).
4
+ *
5
+ * For each path, three hashes decide what happens: the merge base recorded in
6
+ * the lock, the source's new version, and the file in the tree.
7
+ *
8
+ * | tree | source | result |
9
+ * |-----------------|--------------------------|-----------------------------------------|
10
+ * | equals base | anything | replaced (or removed) by the source |
11
+ * | equals source | anything | kept; base moves to the source |
12
+ * | edited | unchanged from base | kept; base stays |
13
+ * | edited | changed, merges cleanly | merged; base moves to the source (*) |
14
+ * | edited | changed or removed | kept; a manual step |
15
+ * | deleted | unchanged from base | stays deleted |
16
+ * | deleted | changed | stays deleted; a manual step |
17
+ * | untracked file | adds the same path | kept; a manual step |
18
+ *
19
+ * The table is for `owned` files. A `seed` file is never touched again, and a
20
+ * `generated` file is left for its command to rebuild (D9, D14). Files in the
21
+ * scope directory that the lineage does not list are never touched. This is
22
+ * the per-file rule of ws-005.
23
+ *
24
+ * (*) Only when the caller passes {@link MergeOptions}: the merge base's
25
+ * content, rebuilt by `chant workspace upgrade` (#2550), and a merge function.
26
+ * A file merges only when every hunk is clean; otherwise it is kept as it was
27
+ * and becomes one manual step. `chant vendor pull` passes no base, since a
28
+ * vendor source keeps no history to rebuild it from, so every conflicting
29
+ * path there is a manual step.
30
+ */
31
+ import { type Lineage, type ManualStep } from "./lineage-lock.js";
32
+ export interface UpdateResult {
33
+ written: string[];
34
+ /** Edited files that took the source's changes through a clean three-way merge. */
35
+ merged: string[];
36
+ /** `seed` files, which an update never touches, and `generated` files, which their command rebuilds. */
37
+ skipped: Array<{
38
+ path: string;
39
+ class: "seed" | "generated";
40
+ command?: string;
41
+ }>;
42
+ removed: string[];
43
+ kept: string[];
44
+ manualSteps: ManualStep[];
45
+ }
46
+ /** The three-way merge, for `chant workspace upgrade`. */
47
+ export interface MergeOptions {
48
+ /** The merge base's content, by path. A path missing here cannot be merged. */
49
+ base: Map<string, Buffer>;
50
+ /** Merged bytes, or null when a hunk conflicts. */
51
+ merge: (base: Buffer, ours: Buffer, theirs: Buffer) => Buffer | null;
52
+ }
53
+ /**
54
+ * Apply `upstream` (relative path to bytes) to the scope directory `dir`,
55
+ * updating `lineage` in place: its files, digest and manual steps. Open manual
56
+ * steps for paths this update touches again are replaced, others are kept.
57
+ */
58
+ export declare function applyUpstream(dir: string, lineage: Lineage, upstream: Map<string, Buffer>, merging?: MergeOptions): UpdateResult;
59
+ //# sourceMappingURL=lineage-update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineage-update.d.ts","sourceRoot":"","sources":["../../src/workspace/lineage-update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,OAAO,EAA8D,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE3H,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,mFAAmF;IACnF,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,wGAAwG;IACxG,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChF,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,0DAA0D;AAC1D,MAAM,WAAW,YAAY;IAC3B,+EAA+E;IAC/E,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,mDAAmD;IACnD,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;CACtE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,YAAY,CA+FhI"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * `chant workspace upgrade [<scope>] [--to <ref>] [--allow-code] [--dry-run]
3
+ * [--output <file>] [--json]` (#2550).
4
+ *
5
+ * Stages the upgrade in a worktree (see ./lineage-upgrade.ts), then decides
6
+ * its gate. The gate is `workspace-upgrade/<scope>` on the gate ledger, and it
7
+ * binds the digest of the patch the staging produced. The first run records
8
+ * the pending fact and exits 3, the code `chant run` gives a gated run. After
9
+ * `chant approve workspace-upgrade <scope>`, the same command stages the same
10
+ * patch, finds the approval for its digest, and applies the patch to the tree.
11
+ * A patch that differs from the approved one needs a new approval.
12
+ */
13
+ import type { CommandContext } from "../cli/registry.js";
14
+ import { type GateLedgerPort } from "../op/gate.js";
15
+ import { type ChantRunner, type StagedUpgrade } from "./lineage-upgrade.js";
16
+ /** The exit code of a gated upgrade: the same as `chant run`'s gated run. */
17
+ export declare const UPGRADE_GATED_EXIT = 3;
18
+ export interface UpgradeCommandOptions {
19
+ root: string;
20
+ scope?: string;
21
+ to?: string;
22
+ allowCode?: boolean;
23
+ dryRun?: boolean;
24
+ output?: string;
25
+ json?: boolean;
26
+ /** For tests. */
27
+ runChant?: ChantRunner;
28
+ ledger?: GateLedgerPort;
29
+ now?: string;
30
+ }
31
+ export type UpgradeOutcome = "up-to-date" | "checks-failed" | "dry-run" | "gated" | "applied";
32
+ export interface UpgradeCommandResult {
33
+ outcome: UpgradeOutcome;
34
+ exitCode: number;
35
+ staged?: Omit<StagedUpgrade, "dispose" | "patch" | "worktree" | "worktreeProject" | "lock">;
36
+ }
37
+ /** The command, with its output. Returns the exit code and what happened. */
38
+ export declare function upgradeCommand(opts: UpgradeCommandOptions): Promise<UpgradeCommandResult>;
39
+ export declare function runWorkspaceUpgrade(ctx: CommandContext): Promise<number>;
40
+ //# sourceMappingURL=lineage-upgrade-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineage-upgrade-cli.d.ts","sourceRoot":"","sources":["../../src/workspace/lineage-upgrade-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAyE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAGxH,OAAO,EAAoD,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAI3H,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iBAAiB;IACjB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,eAAe,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAE9F,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,iBAAiB,GAAG,MAAM,CAAC,CAAC;CAC7F;AAED,6EAA6E;AAC7E,wBAAsB,cAAc,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA4E/F;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAsB9E"}