@intentius/chant 0.124.109 → 0.124.110

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 (338) hide show
  1. package/dist/__golden__/wave-loop/fan-out-applied.json +12 -6
  2. package/dist/__golden__/wave-loop/fan-out-apply-fails.json +8 -4
  3. package/dist/__golden__/wave-loop/fan-out-gated.json +4 -2
  4. package/dist/__golden__/wave-loop/fan-out-no-members.json +16 -8
  5. package/dist/__golden__/wave-loop/fan-out-plan-fails.json +8 -4
  6. package/dist/__golden__/wave-loop/fan-out-same-root.json +4 -2
  7. package/dist/agent-facts.d.ts +130 -0
  8. package/dist/agent-facts.js +196 -0
  9. package/dist/change-risk.d.ts +216 -0
  10. package/dist/change-risk.js +304 -0
  11. package/dist/change-set.d.ts +8 -0
  12. package/dist/ci-agent-alert.d.ts +139 -0
  13. package/dist/ci-agent-alert.js +342 -0
  14. package/dist/ci-agent-triggers.d.ts +152 -0
  15. package/dist/ci-agent-triggers.js +232 -0
  16. package/dist/ci-agent-verify-failed.d.ts +149 -0
  17. package/dist/ci-agent-verify-failed.js +191 -0
  18. package/dist/ci-agent.d.ts +136 -8
  19. package/dist/ci-agent.js +353 -26
  20. package/dist/ci-comment-commands.d.ts +8 -0
  21. package/dist/ci-comment-commands.js +17 -1
  22. package/dist/ci-comment-reject.d.ts +70 -0
  23. package/dist/ci-comment-reject.js +135 -0
  24. package/dist/ci-comment-replies.d.ts +3 -1
  25. package/dist/ci-comment-replies.js +6 -0
  26. package/dist/ci-estate/delivery.d.ts +25 -3
  27. package/dist/ci-estate/delivery.js +28 -9
  28. package/dist/ci-estate/page.d.ts +7 -3
  29. package/dist/ci-estate/page.js +19 -4
  30. package/dist/ci-estate/rows.d.ts +14 -2
  31. package/dist/ci-estate/rows.js +9 -1
  32. package/dist/ci-estate.d.ts +5 -2
  33. package/dist/ci-estate.js +3 -2
  34. package/dist/ci-handover.d.ts +2 -7
  35. package/dist/ci-handover.js +3 -20
  36. package/dist/ci-jobs.d.ts +6 -0
  37. package/dist/ci-jobs.js +17 -0
  38. package/dist/ci-note-commands.d.ts +2 -0
  39. package/dist/ci-note-commands.js +12 -1
  40. package/dist/ci-product-words.d.ts +151 -1
  41. package/dist/ci-product-words.js +1390 -3
  42. package/dist/ci-product.d.ts +100 -4
  43. package/dist/ci-product.js +99 -3
  44. package/dist/ci-respond-run.d.ts +9 -0
  45. package/dist/ci-respond-run.js +35 -4
  46. package/dist/ci-respond-summary-env.d.ts +56 -0
  47. package/dist/ci-respond-summary-env.js +81 -0
  48. package/dist/ci-respond-summary.d.ts +103 -0
  49. package/dist/ci-respond-summary.js +243 -0
  50. package/dist/ci-respond.d.ts +4 -2
  51. package/dist/ci-respond.js +4 -2
  52. package/dist/cli/command-group.js +1 -1
  53. package/dist/cli/commands/lint.js +21 -3
  54. package/dist/cli/handlers/agent.js +49 -4
  55. package/dist/cli/handlers/approve.js +3 -1
  56. package/dist/cli/handlers/build.d.ts +97 -1
  57. package/dist/cli/handlers/build.js +251 -3
  58. package/dist/cli/handlers/fan-out.js +55 -0
  59. package/dist/cli/handlers/graph.d.ts +14 -0
  60. package/dist/cli/handlers/graph.js +58 -3
  61. package/dist/cli/handlers/lifecycle-health.d.ts +7 -0
  62. package/dist/cli/handlers/lifecycle-health.js +47 -9
  63. package/dist/cli/handlers/lifecycle.js +4 -1
  64. package/dist/cli/handlers/notify-relay.d.ts +2 -2
  65. package/dist/cli/handlers/notify-relay.js +67 -7
  66. package/dist/cli/handlers/pipeline-agent.d.ts +30 -0
  67. package/dist/cli/handlers/pipeline-agent.js +255 -0
  68. package/dist/cli/handlers/pipeline-artifacts.d.ts +39 -0
  69. package/dist/cli/handlers/pipeline-artifacts.js +203 -0
  70. package/dist/cli/handlers/pipeline.d.ts +16 -0
  71. package/dist/cli/handlers/pipeline.js +112 -0
  72. package/dist/cli/handlers/pr-comment.js +4 -0
  73. package/dist/cli/handlers/pr-notes.js +4 -1
  74. package/dist/cli/handlers/pr.d.ts +20 -0
  75. package/dist/cli/handlers/pr.js +114 -11
  76. package/dist/cli/handlers/promote.js +792 -47
  77. package/dist/cli/handlers/reject.d.ts +84 -0
  78. package/dist/cli/handlers/reject.js +216 -0
  79. package/dist/cli/handlers/replan.d.ts +54 -0
  80. package/dist/cli/handlers/replan.js +177 -0
  81. package/dist/cli/handlers/run-generate.d.ts +5 -0
  82. package/dist/cli/handlers/run-generate.js +31 -4
  83. package/dist/cli/handlers/run-wave.js +15 -2
  84. package/dist/cli/handlers/run.js +4 -2
  85. package/dist/cli/handlers/stage.d.ts +35 -0
  86. package/dist/cli/handlers/stage.js +90 -0
  87. package/dist/cli/lsp/server.js +4 -0
  88. package/dist/cli/main.js +88 -8
  89. package/dist/cli/parse-args.js +35 -2
  90. package/dist/cli/registry.d.ts +12 -0
  91. package/dist/components/auto-release.d.ts +2 -0
  92. package/dist/components/auto-release.js +1 -0
  93. package/dist/components/capability.d.ts +40 -0
  94. package/dist/components/cli-support.d.ts +21 -1
  95. package/dist/components/cli-support.js +28 -6
  96. package/dist/components/component.d.ts +23 -4
  97. package/dist/components/component.schema.json +28 -0
  98. package/dist/components/declared-reads.d.ts +44 -4
  99. package/dist/components/declared-reads.js +80 -3
  100. package/dist/components/discover.d.ts +8 -0
  101. package/dist/components/discover.js +1 -1
  102. package/dist/components/driver.d.ts +13 -0
  103. package/dist/components/driver.js +23 -2
  104. package/dist/components/environment-sets.d.ts +229 -0
  105. package/dist/components/environment-sets.js +338 -0
  106. package/dist/components/fan-out-canary.d.ts +47 -0
  107. package/dist/components/fan-out-canary.js +58 -0
  108. package/dist/components/fan-out-run.d.ts +17 -0
  109. package/dist/components/fan-out-run.js +14 -1
  110. package/dist/components/fan-out-support.d.ts +7 -0
  111. package/dist/components/fan-out-support.js +1 -1
  112. package/dist/components/groups.d.ts +8 -1
  113. package/dist/components/groups.js +19 -1
  114. package/dist/components/index.d.ts +5 -2
  115. package/dist/components/index.js +4 -1
  116. package/dist/components/pr-cost.d.ts +28 -0
  117. package/dist/components/pr-cost.js +53 -0
  118. package/dist/components/pr-pipeline.d.ts +33 -0
  119. package/dist/components/pr-pipeline.js +32 -5
  120. package/dist/components/pr-policy.d.ts +33 -2
  121. package/dist/components/pr-policy.js +5 -2
  122. package/dist/components/pr-risk.d.ts +42 -0
  123. package/dist/components/pr-risk.js +74 -0
  124. package/dist/components/product-pipeline.d.ts +43 -0
  125. package/dist/components/product-pipeline.js +67 -1
  126. package/dist/components/promote.d.ts +6 -0
  127. package/dist/components/promote.js +13 -0
  128. package/dist/components/release-compile.js +3 -1
  129. package/dist/components/release-gate.d.ts +6 -1
  130. package/dist/components/release-gate.js +10 -2
  131. package/dist/components/step-environments.d.ts +236 -0
  132. package/dist/components/step-environments.js +392 -0
  133. package/dist/components/upstream-replan.d.ts +201 -0
  134. package/dist/components/upstream-replan.js +249 -0
  135. package/dist/components/verify-step.d.ts +30 -0
  136. package/dist/components/verify-step.js +27 -0
  137. package/dist/components/wave-plan.js +6 -2
  138. package/dist/config-environments.d.ts +4 -2
  139. package/dist/control/dispatch.d.ts +15 -0
  140. package/dist/control/dispatch.js +28 -4
  141. package/dist/cost-estimate.d.ts +188 -0
  142. package/dist/cost-estimate.js +363 -0
  143. package/dist/drift-record.d.ts +36 -0
  144. package/dist/drift-record.js +44 -0
  145. package/dist/engine-facts.d.ts +105 -0
  146. package/dist/engine-facts.js +111 -0
  147. package/dist/exit-codes.d.ts +4 -3
  148. package/dist/exit-codes.js +4 -3
  149. package/dist/flag-params.d.ts +2 -2
  150. package/dist/flag-params.js +9 -4
  151. package/dist/floor-table.data.js +53 -0
  152. package/dist/forge-token-vars.d.ts +12 -0
  153. package/dist/forge-token-vars.js +25 -0
  154. package/dist/gate-decision.d.ts +3 -1
  155. package/dist/gate-decision.js +3 -1
  156. package/dist/gated-waves.d.ts +2 -0
  157. package/dist/gated-waves.js +1 -0
  158. package/dist/graph-ir.d.ts +30 -0
  159. package/dist/graph-ir.js +33 -1
  160. package/dist/graph-refs.d.ts +26 -0
  161. package/dist/graph-refs.js +34 -3
  162. package/dist/graph-schema/graph.schema.json +136 -0
  163. package/dist/health.d.ts +65 -0
  164. package/dist/health.js +62 -0
  165. package/dist/lexicon.d.ts +188 -1
  166. package/dist/lifecycle/disruption.d.ts +14 -1
  167. package/dist/lifecycle/disruption.js +5 -1
  168. package/dist/lifecycle/gate-change-set.d.ts +8 -0
  169. package/dist/lifecycle/gate-change-set.js +2 -1
  170. package/dist/lifecycle/gate-ledger.d.ts +26 -0
  171. package/dist/lifecycle/gate-rejection.d.ts +82 -0
  172. package/dist/lifecycle/gate-rejection.js +93 -0
  173. package/dist/lifecycle/gate-seal.d.ts +3 -3
  174. package/dist/lifecycle/gate-seal.js +5 -5
  175. package/dist/lifecycle/observe.d.ts +17 -0
  176. package/dist/lifecycle/observe.js +10 -1
  177. package/dist/lifecycle/release-cut.js +4 -0
  178. package/dist/lifecycle/release-ledger.d.ts +8 -0
  179. package/dist/lifecycle/release-risk.d.ts +137 -0
  180. package/dist/lifecycle/release-risk.js +214 -0
  181. package/dist/lifecycle/release-store.d.ts +9 -0
  182. package/dist/lifecycle/release-store.js +4 -0
  183. package/dist/lifecycle/stage-log.d.ts +85 -0
  184. package/dist/lifecycle/stage-log.js +141 -0
  185. package/dist/lint/canary-checks.d.ts +31 -0
  186. package/dist/lint/canary-checks.js +45 -0
  187. package/dist/lint/rule.d.ts +1 -0
  188. package/dist/lint/rules/evl012-pipeline-fold.d.ts +14 -0
  189. package/dist/lint/rules/evl012-pipeline-fold.js +30 -0
  190. package/dist/lint/rules/index.d.ts +1 -0
  191. package/dist/lint/rules/index.js +3 -0
  192. package/dist/notify-relay-repo.d.ts +54 -0
  193. package/dist/notify-relay-repo.js +84 -0
  194. package/dist/notify-relay.d.ts +53 -3
  195. package/dist/notify-relay.js +96 -3
  196. package/dist/notify.d.ts +57 -1
  197. package/dist/notify.js +7 -1
  198. package/dist/notify.schema.json +61 -3
  199. package/dist/observation.d.ts +34 -0
  200. package/dist/observation.js +14 -1
  201. package/dist/op/activities/review-agent.d.ts +39 -2
  202. package/dist/op/activities/review-agent.js +88 -5
  203. package/dist/op/agent-permit.d.ts +88 -0
  204. package/dist/op/agent-permit.js +97 -0
  205. package/dist/op/gate-approval-base.d.ts +8 -0
  206. package/dist/op/gate-approval-base.js +9 -0
  207. package/dist/op/gate-approval.d.ts +30 -1
  208. package/dist/op/gate-approval.js +23 -2
  209. package/dist/op/gate-quorum.d.ts +114 -8
  210. package/dist/op/gate-quorum.js +198 -21
  211. package/dist/op/gate-reject.d.ts +79 -0
  212. package/dist/op/gate-reject.js +96 -0
  213. package/dist/op/gate-summary.js +1 -1
  214. package/dist/op/gate.d.ts +28 -3
  215. package/dist/op/gate.js +55 -13
  216. package/dist/op/generate-pipeline.d.ts +15 -1
  217. package/dist/op/generate-pipeline.js +32 -5
  218. package/dist/op/index.d.ts +11 -6
  219. package/dist/op/index.js +10 -5
  220. package/dist/op/local-executor.d.ts +2 -0
  221. package/dist/op/local-executor.js +23 -4
  222. package/dist/op/op-waves-after-plan.d.ts +23 -0
  223. package/dist/op/op-waves-after-plan.js +12 -1
  224. package/dist/op/op-waves-capability-spec.d.ts +14 -0
  225. package/dist/op/op-waves-capability-spec.js +46 -6
  226. package/dist/op/op-waves-capability.d.ts +21 -13
  227. package/dist/op/op-waves-capability.js +22 -59
  228. package/dist/op/op-waves-environment-sets.d.ts +41 -0
  229. package/dist/op/op-waves-environment-sets.js +82 -0
  230. package/dist/op/op-waves-quorum-warnings.d.ts +53 -0
  231. package/dist/op/op-waves-quorum-warnings.js +90 -0
  232. package/dist/op/op-waves-release-port.d.ts +7 -0
  233. package/dist/op/op-waves-release-port.js +15 -3
  234. package/dist/op/op-waves-release.d.ts +15 -0
  235. package/dist/op/op-waves-release.js +15 -0
  236. package/dist/op/op-waves-run.d.ts +37 -3
  237. package/dist/op/op-waves-run.js +141 -18
  238. package/dist/op/op-waves-soak.d.ts +57 -0
  239. package/dist/op/op-waves-soak.js +111 -0
  240. package/dist/op/op-waves-split.d.ts +4 -0
  241. package/dist/op/op-waves-split.js +4 -0
  242. package/dist/op/op-waves.d.ts +67 -4
  243. package/dist/op/op-waves.js +71 -3
  244. package/dist/pipeline/agent-ajv.d.ts +4 -0
  245. package/dist/pipeline/agent-ajv.js +14 -0
  246. package/dist/pipeline/agent-steps.d.ts +329 -0
  247. package/dist/pipeline/agent-steps.js +602 -0
  248. package/dist/pipeline/artifacts.d.ts +264 -0
  249. package/dist/pipeline/artifacts.js +425 -0
  250. package/dist/pipeline/diff.d.ts +45 -0
  251. package/dist/pipeline/diff.js +177 -0
  252. package/dist/pipeline/fold.d.ts +43 -0
  253. package/dist/pipeline/fold.js +140 -0
  254. package/dist/pipeline/generate.d.ts +52 -0
  255. package/dist/pipeline/generate.js +120 -0
  256. package/dist/pipeline/product.d.ts +225 -0
  257. package/dist/pipeline/product.js +257 -0
  258. package/dist/pipeline/promote.d.ts +404 -0
  259. package/dist/pipeline/promote.js +694 -0
  260. package/dist/pipeline/read.d.ts +37 -0
  261. package/dist/pipeline/read.js +58 -0
  262. package/dist/pipeline/rendered.d.ts +25 -0
  263. package/dist/pipeline/rendered.js +53 -0
  264. package/dist/pipeline/soak-checks.d.ts +80 -0
  265. package/dist/pipeline/soak-checks.js +254 -0
  266. package/dist/pipeline/soak-gate.d.ts +97 -0
  267. package/dist/pipeline/soak-gate.js +176 -0
  268. package/dist/pipeline/soak-sources.d.ts +17 -0
  269. package/dist/pipeline/soak-sources.js +42 -0
  270. package/dist/pipeline/soak.d.ts +260 -0
  271. package/dist/pipeline/soak.js +378 -0
  272. package/dist/pipeline/spec.d.ts +724 -0
  273. package/dist/pipeline/spec.js +567 -0
  274. package/dist/pipeline/stage-ledger.d.ts +187 -0
  275. package/dist/pipeline/stage-ledger.js +185 -0
  276. package/dist/pipeline/stage-waves.d.ts +114 -0
  277. package/dist/pipeline/stage-waves.js +161 -0
  278. package/dist/pipeline/stages.d.ts +64 -0
  279. package/dist/pipeline/stages.js +174 -0
  280. package/dist/pipeline/verify-rollback.d.ts +277 -0
  281. package/dist/pipeline/verify-rollback.js +393 -0
  282. package/dist/pipeline.d.ts +142 -0
  283. package/dist/pipeline.js +143 -0
  284. package/dist/pr-loop.d.ts +22 -0
  285. package/dist/pr-loop.js +8 -0
  286. package/dist/pr-plan-note.d.ts +15 -1
  287. package/dist/pr-plan-note.js +8 -0
  288. package/dist/pr-post.d.ts +31 -0
  289. package/dist/pr-post.js +89 -0
  290. package/dist/release-floors.d.ts +1 -1
  291. package/dist/release-floors.js +1 -1
  292. package/dist/report-store/audit.schema.json +50 -0
  293. package/dist/report-store/dora.schema.json +331 -0
  294. package/dist/report-store/estate.schema.json +96 -0
  295. package/dist/report-store/run.schema.json +14 -0
  296. package/dist/report-store.d.ts +151 -0
  297. package/dist/report-store.js +344 -0
  298. package/dist/run-event.d.ts +7 -2
  299. package/dist/wave-runtime.mjs +458 -404
  300. package/dist/workspace/catalog-edges.js +3 -3
  301. package/dist/workspace/change-set.schema.json +4 -0
  302. package/dist/workspace/ci-cloud-identity.d.ts +4 -0
  303. package/dist/workspace/ci-cloud-identity.js +30 -0
  304. package/dist/workspace/ci-run.js +17 -2
  305. package/dist/workspace/ci-secrets.d.ts +3 -1
  306. package/dist/workspace/ci-secrets.js +7 -1
  307. package/dist/workspace/compose-graph.d.ts +1 -1
  308. package/dist/workspace/compose-graph.js +3 -1
  309. package/dist/workspace/declaration.d.ts +27 -0
  310. package/dist/workspace/declaration.js +35 -0
  311. package/dist/workspace/declaration.schema.json +56 -0
  312. package/dist/workspace/graph-cli.js +26 -0
  313. package/dist/workspace/graph.schema.json +5 -1
  314. package/dist/workspace/identity-gate-rule.d.ts +4 -0
  315. package/dist/workspace/identity-gate-rule.js +2 -2
  316. package/dist/workspace/identity-reject-rule.d.ts +14 -0
  317. package/dist/workspace/identity-reject-rule.js +24 -0
  318. package/dist/workspace/identity.d.ts +3 -0
  319. package/dist/workspace/identity.js +2 -1
  320. package/dist/workspace/nested-graph.js +2 -0
  321. package/dist/workspace/pr-report.schema.json +65 -0
  322. package/dist/workspace/promotion-order.d.ts +19 -4
  323. package/dist/workspace/promotion-order.js +26 -4
  324. package/dist/workspace/release-train.d.ts +14 -0
  325. package/dist/workspace/release-train.js +32 -0
  326. package/dist/workspace/run-event.schema.json +2 -2
  327. package/dist/workspace/stack-read-edges.d.ts +19 -0
  328. package/dist/workspace/stack-read-edges.js +54 -0
  329. package/dist/workspace/status-gates.d.ts +51 -1
  330. package/dist/workspace/status-gates.js +60 -0
  331. package/dist/workspace/status-stages.d.ts +223 -0
  332. package/dist/workspace/status-stages.js +279 -0
  333. package/dist/workspace/status.d.ts +45 -1
  334. package/dist/workspace/status.js +109 -5
  335. package/dist/workspace/status.schema.json +283 -2
  336. package/dist/workspace/trust/seal.d.ts +7 -0
  337. package/dist/workspace/trust/seal.js +9 -0
  338. package/package.json +5 -1
@@ -2,7 +2,7 @@ import { isAbsolute, relative, resolve } from "node:path";
2
2
  import { discoverOps } from "../../op/discover.js";
3
3
  import { discover } from "../../discovery/index.js";
4
4
  import { partitionByLexicon, computeStackGraph, build } from "../../build.js";
5
- import { applyLexiconOutputs, buildGraphIr, buildLiveGraphIr, collectUnobserved, overlayGraphs, sourceOverlayGraphs, withInstanceNodes, GRAPH_IR_VERSION } from "../../graph-ir.js";
5
+ import { applyLexiconOutputs, buildGraphIr, buildLiveGraphIr, carryEngineFacts, collectUnobserved, overlayGraphs, sourceOverlayGraphs, withInstanceNodes, GRAPH_IR_VERSION } from "../../graph-ir.js";
6
6
  import { behaviourOverlay } from "../../behaviour-overlay.js";
7
7
  import { applyBehaviourOverlay, behaviourRequestFromIr } from "../../behaviour-graph.js";
8
8
  import { buildDeclaredPerStack } from "../../graph-declared.js";
@@ -274,6 +274,10 @@ async function runGraphLive(ctx, format) {
274
274
  let observations;
275
275
  // Facts about absent entities (#4372), carried onto the overlay's nodes.
276
276
  let annotations;
277
+ // An engine's facts about what the read did not return as present (#5333).
278
+ let engineFacts;
279
+ // Live objects no declared entity names (#5429): live nodes, never in the diff.
280
+ let undeclared;
277
281
  // Which read answered each root (#4452), carried onto the IR as written.
278
282
  let rootReads;
279
283
  // A replay is a graph of what was recorded, so it must not reach the provider
@@ -306,6 +310,8 @@ async function runGraphLive(ctx, format) {
306
310
  });
307
311
  observations = observeResult.observations;
308
312
  annotations = observeResult.annotations;
313
+ engineFacts = observeResult.engineFacts;
314
+ undeclared = observeResult.undeclared;
309
315
  rootReads = observeResult.rootReads;
310
316
  const { errors, warnings, notes = [] } = observeResult;
311
317
  for (const e of errors)
@@ -329,7 +335,10 @@ async function runGraphLive(ctx, format) {
329
335
  }
330
336
  // Both paths land here: a replay rejoins the live pipeline at exactly this
331
337
  // point, which is what makes every fold and overlay below shared.
332
- ir = buildLiveGraphIr(observations);
338
+ // An object the read found live that nothing declares (#5429) is a live
339
+ // node like any other, so the overlay paints it as provisioned and
340
+ // undeclared. It joins here only: `observations` stays what the diff reads.
341
+ ir = buildLiveGraphIr(undeclared ? [...observations, ...undeclared] : observations);
333
342
  // The estate was asked for and nothing came back. Say that once, and say
334
343
  // that a recording exists — the per-entity warnings above describe the same
335
344
  // failure N times without ever naming the thing that would answer. Agents
@@ -433,6 +442,10 @@ async function runGraphLive(ctx, format) {
433
442
  // declared node beside the overlay's `_status`. A planned create keeps its
434
443
  // pending paint and carries the plan's attributes.
435
444
  ir = { ...ir, nodes: carryAnnotations(ir.nodes, annotations) };
445
+ // What an ownership engine said about a declared entity it found absent,
446
+ // or that --owned filtered out (#5333): choudoufu's `pending`, `unowned`
447
+ // and `foreign`, on the declared node beside its paint.
448
+ ir = { ...ir, nodes: carryEngineFacts(ir.nodes, engineFacts) };
436
449
  }
437
450
  // Behaviour overlay (#2377, epic #2355): carry a prediction on the graph.
438
451
  // After the drift overlay so it lands on the final node set beside `_status`,
@@ -628,7 +641,9 @@ async function runComponentGraphView(ctx, format) {
628
641
  refuseLintGate(lint, projectPath);
629
642
  return 1;
630
643
  }
631
- const graph = await computeComponentGraph(projectPath, ctx.args.sandbox, componentParams);
644
+ const graph = await computeComponentGraph(projectPath, ctx.args.sandbox, componentParams, {
645
+ reads: ctx.args.env ? { env: ctx.args.env } : {},
646
+ });
632
647
  if (!graph.success) {
633
648
  console.error(formatError({ message: graph.error ?? "Failed to compute component graph" }));
634
649
  return 1;
@@ -671,6 +686,7 @@ async function runComponentGraphView(ctx, format) {
671
686
  byWave: Object.fromEntries(graph.waves.map((wave, i) => [`wave-${i + 1}`, [...wave]])),
672
687
  },
673
688
  };
689
+ ir = withStackReads(ir, graph.reads ?? []);
674
690
  if (ctx.args.projection) {
675
691
  const pipeline = await buildPipelineProjection(projectPath, ctx.args.projection, ctx.args.sandbox);
676
692
  if (!pipeline.success) {
@@ -681,6 +697,45 @@ async function runComponentGraphView(ctx, format) {
681
697
  }
682
698
  return emitIr(ir, ctx, format);
683
699
  }
700
+ /** The id of the node a stack outside the project is drawn as (#5331). */
701
+ export function externalStackNodeId(name) {
702
+ return `external:${name}`;
703
+ }
704
+ /**
705
+ * The reads a capability finds in its steps' files (#5331, a Pulumi
706
+ * program's `StackReference`s) as edges of the component graph: from the
707
+ * reader to the component that deploys the stack it reads, `viaAttr` naming
708
+ * the output where the program shows it. A stack no component deploys is a
709
+ * node of kind `ExternalStack` with `attrs.external: true`, and the edge goes
710
+ * to it. The edges carry `origin: "declared"` beside the `dependsOn` edges
711
+ * they may repeat, since they differ in `viaAttr`. Pure.
712
+ */
713
+ export function withStackReads(ir, reads) {
714
+ if (reads.length === 0)
715
+ return ir;
716
+ const nodes = [...ir.nodes];
717
+ const edges = [...ir.edges];
718
+ const have = new Set(nodes.map((n) => n.id));
719
+ const seen = new Set(edges.map((e) => `${e.from}|${e.to}|${e.viaAttr ?? ""}`));
720
+ for (const r of reads) {
721
+ let to = r.upstream;
722
+ if (to === undefined) {
723
+ if (r.external === undefined)
724
+ continue;
725
+ to = externalStackNodeId(r.external);
726
+ if (!have.has(to)) {
727
+ have.add(to);
728
+ nodes.push({ id: to, kind: "ExternalStack", lexicon: r.kind === "pulumi-up" ? "pulumi" : "chant", attrs: { external: true, stack: r.external } });
729
+ }
730
+ }
731
+ const key = `${r.reader}|${to}|${r.output ?? ""}`;
732
+ if (seen.has(key))
733
+ continue;
734
+ seen.add(key);
735
+ edges.push({ from: r.reader, to, kind: "ref", ...(r.output !== undefined ? { viaAttr: r.output } : {}), origin: "declared" });
736
+ }
737
+ return { ...ir, nodes, edges };
738
+ }
684
739
  /**
685
740
  * Reshape `generateComponentsPipeline`'s result (../../components/cli-support.ts
686
741
  * — the exact function `chant build --components --generate <lexicon>` calls)
@@ -7,6 +7,13 @@
7
7
  * entities whose types it names. An environment's declared endpoint is applied
8
8
  * for the read, as on the other live reads (#1166).
9
9
  *
10
+ * A terraform root or a pulumi stack is read through the provider lexicons
11
+ * (#5338): the engine lexicon's `healthTargets` maps each resource of a
12
+ * covered type to its provider's health type and the id from the root's
13
+ * state or the stack's export, and the provider's `observeHealth` reads it.
14
+ * A provider lexicon the project does not configure is loaded when it is
15
+ * installed.
16
+ *
10
17
  * The JSON is the {@link HEALTH_SCHEMA} shape. A single-stack project prints
11
18
  * `lexicons` at the top level; a multi-stack one nests them under `stacks`,
12
19
  * the same split `lifecycle diff --live --json` makes.
@@ -7,6 +7,13 @@
7
7
  * entities whose types it names. An environment's declared endpoint is applied
8
8
  * for the read, as on the other live reads (#1166).
9
9
  *
10
+ * A terraform root or a pulumi stack is read through the provider lexicons
11
+ * (#5338): the engine lexicon's `healthTargets` maps each resource of a
12
+ * covered type to its provider's health type and the id from the root's
13
+ * state or the stack's export, and the provider's `observeHealth` reads it.
14
+ * A provider lexicon the project does not configure is loaded when it is
15
+ * installed.
16
+ *
10
17
  * The JSON is the {@link HEALTH_SCHEMA} shape. A single-stack project prints
11
18
  * `lexicons` at the top level; a multi-stack one nests them under `stacks`,
12
19
  * the same split `lifecycle diff --live --json` makes.
@@ -15,7 +22,7 @@ import { resolve } from "node:path";
15
22
  import { build } from "../../build.js";
16
23
  import { loadChantConfig } from "../../config.js";
17
24
  import { isObservableDeclarable } from "../../declarable.js";
18
- import { HEALTH_SCHEMA, healthApplicable, observeHealthFor, summarizeHealth } from "../../health.js";
25
+ import { HEALTH_SCHEMA, healthApplicable, observeEngineHealth, observeHealthFor, summarizeHealth, } from "../../health.js";
19
26
  import { applyLiveEndpoint } from "../../live-endpoint.js";
20
27
  import { CHANT_VERSION } from "../version.js";
21
28
  import { commandBuildParams } from "../build-params-cli.js";
@@ -30,15 +37,17 @@ export async function runLifecycleHealth(ctx) {
30
37
  console.error(formatError({ message: "Environment is required: chant lifecycle health <environment> [lexicon]" }));
31
38
  return 1;
32
39
  }
33
- const readers = plugins.filter((p) => p.observeHealth && (p.healthTypes?.length ?? 0) > 0 && (!lexiconFilter || p.name === lexiconFilter));
40
+ const readers = plugins.filter((p) => ((p.observeHealth && (p.healthTypes?.length ?? 0) > 0) || p.healthTargets) &&
41
+ (!lexiconFilter || p.name === lexiconFilter));
34
42
  if (readers.length === 0) {
35
43
  console.error(formatWarning({
36
44
  message: lexiconFilter
37
45
  ? `${lexiconFilter}: no health read in this lexicon`
38
- : "No configured lexicon has a health read (aws, azure and gcp do)",
46
+ : "No configured lexicon has a health read (aws, azure and gcp do, and terraform and pulumi through them)",
39
47
  }));
40
48
  return 1;
41
49
  }
50
+ const provider = providerLookup(plugins);
42
51
  const projectRoot = resolve(".");
43
52
  const { config } = await loadChantConfig(projectRoot);
44
53
  const declaredParams = await commandBuildParams(config.buildParams, args);
@@ -81,18 +90,29 @@ export async function runLifecycleHealth(ctx) {
81
90
  });
82
91
  }
83
92
  }
84
- const entities = healthApplicable(plugin, declared);
85
- if (entities.size === 0)
86
- continue;
87
93
  const raw = buildResult.outputs.get(plugin.name);
88
94
  const buildOutput = raw === undefined ? "" : typeof raw === "string" ? raw : raw.primary;
89
- byLexicon[plugin.name] = await observeHealthFor(plugin, {
95
+ const scope = {
90
96
  environment,
91
97
  buildOutput,
92
- entities,
93
98
  ...(target.stack ? { stack: target.stack } : {}),
94
99
  ...(target.region ? { region: target.region } : {}),
95
- });
100
+ };
101
+ if (plugin.healthTargets) {
102
+ if (declared.size === 0)
103
+ continue;
104
+ const { result, error } = await observeEngineHealth(plugin, { ...scope, entities: declared }, provider);
105
+ if (error)
106
+ console.error(formatWarning({ message: `${plugin.name}: the health targets could not be read: ${error}` }));
107
+ if (Object.keys(result.entities).length + Object.keys(result.unobserved).length + result.absent.length > 0) {
108
+ byLexicon[plugin.name] = result;
109
+ }
110
+ continue;
111
+ }
112
+ const entities = healthApplicable(plugin, declared);
113
+ if (entities.size === 0)
114
+ continue;
115
+ byLexicon[plugin.name] = await observeHealthFor(plugin, { ...scope, entities });
96
116
  }
97
117
  if (target.stack)
98
118
  perStack[target.stack] = byLexicon;
@@ -135,6 +155,24 @@ export async function runLifecycleHealth(ctx) {
135
155
  }
136
156
  return anyBuildError ? 1 : 0;
137
157
  }
158
+ /**
159
+ * The provider lexicon an engine's target names: a configured one, else the
160
+ * installed package, loaded once. Undefined when it is not installed.
161
+ */
162
+ function providerLookup(plugins) {
163
+ const loaded = new Map();
164
+ return (lexicon) => {
165
+ const configured = plugins.find((p) => p.name === lexicon);
166
+ if (configured)
167
+ return Promise.resolve(configured);
168
+ let pending = loaded.get(lexicon);
169
+ if (!pending) {
170
+ pending = import("../plugins.js").then(({ loadPlugin }) => loadPlugin(lexicon)).catch(() => undefined);
171
+ loaded.set(lexicon, pending);
172
+ }
173
+ return pending;
174
+ };
175
+ }
138
176
  function renderHealth(byLexicon) {
139
177
  for (const [lexicon, result] of Object.entries(byLexicon)) {
140
178
  console.log(formatBold(lexicon));
@@ -1408,7 +1408,10 @@ export async function runLifecyclePlan(ctx) {
1408
1408
  // deltas are paths into its own observation shape, and the replacement
1409
1409
  // rules are in the spec it compiled. A lexicon that answers nothing
1410
1410
  // leaves every update `unknown` — never `in-place`.
1411
- const classified = await annotateDisruption(cs, environment, plugin.classifyDisruption ? (o) => plugin.classifyDisruption(o) : undefined);
1411
+ const classified = await annotateDisruption(cs, environment, plugin.classifyDisruption ? (o) => plugin.classifyDisruption(o) : undefined,
1412
+ // Each query carries the entry's observed attributes (#5338), so a
1413
+ // read that holds the engine's plan can be answered from it.
1414
+ observed.resources);
1412
1415
  merged.entries.push(...classified.entries);
1413
1416
  checked++;
1414
1417
  }
@@ -15,8 +15,8 @@ export declare function relaySettingsFromEnv(env: NodeJS.ProcessEnv): {
15
15
  * stale tip could still count one removed since.
16
16
  */
17
17
  export declare function fetchDefaultBranch(cwd: string): Promise<void>;
18
- /** The relay's reads and writes against the checkout at `cwd`. */
19
- export declare function checkoutRelayDeps(cwd: string, principal: string): RelayDeps;
18
+ /** The relay's reads and writes against the checkout at `cwd`. `dispatch` starts the alert agent's workflow (#5329). */
19
+ export declare function checkoutRelayDeps(cwd: string, principal: string, dispatch?: RelayDeps["dispatch"]): RelayDeps;
20
20
  /** The flags and variables that make the relay clone the repo itself (#4759). */
21
21
  export interface RelayRepoOptions {
22
22
  repo?: string;
@@ -31,13 +31,21 @@
31
31
  * and gitlab.com, and `--host` and `--port` override `CHANT_RELAY_HOST` and
32
32
  * `CHANT_RELAY_PORT`. `CHANT_RELAY_REPO` and `CHANT_RELAY_FORGE` stand in for
33
33
  * the flags.
34
+ *
35
+ * Alerts (#5329) are on when `CHANT_ALERT_SECRET` or a source's own
36
+ * `CHANT_ALERT_SECRET_<SOURCE>` is set. Each delivery's facts are written
37
+ * and pushed one at a time with the clicks. With `--repo` and
38
+ * `CHANT_ALERT_DISPATCH_TOKEN`, the relay starts the alert agent's workflow
39
+ * (`CHANT_ALERT_WORKFLOW` on GitHub and Forgejo) after each new fact, and
40
+ * refuses to start when that token can do more than start a workflow.
34
41
  */
35
42
  import { execFile } from "node:child_process";
36
43
  import { promisify } from "node:util";
37
44
  import { activeProductWords } from "../../ci-product-words.js";
38
45
  import { CHANT_EXIT } from "../../exit-codes.js";
39
46
  import { DEFAULT_RELAY_MAX_AGE_SECONDS } from "../../notify.js";
40
- import { DEFAULT_RELAY_HOST, DEFAULT_RELAY_PORT, RELAY_ENV, RELAY_REPO_ENV, startRelayServer } from "../../notify-relay.js";
47
+ import { alertSecretEnv, DEFAULT_RELAY_HOST, DEFAULT_RELAY_PORT, RELAY_ENV, RELAY_REPO_ENV, startRelayServer } from "../../notify-relay.js";
48
+ import { ALERT_SOURCES } from "../../ci-agent-alert.js";
41
49
  import { formatError, formatInfo } from "../format.js";
42
50
  /** The relay's settings, read from `env`, or the first problem with them. */
43
51
  export function relaySettingsFromEnv(env) {
@@ -46,8 +54,19 @@ export function relaySettingsFromEnv(env) {
46
54
  return { error: `${RELAY_ENV.key} is not set; it holds the key notify signs the buttons with (notify.relay on the sending side)` };
47
55
  const slackSecret = env[RELAY_ENV.slackSecret] || undefined;
48
56
  const teamsSecret = env[RELAY_ENV.teamsSecret] || undefined;
49
- if (!slackSecret && !teamsSecret)
50
- return { error: `set ${RELAY_ENV.slackSecret}, ${RELAY_ENV.teamsSecret} or both, so the relay can verify a click` };
57
+ const alertSecrets = {};
58
+ for (const source of ALERT_SOURCES) {
59
+ const secret = env[alertSecretEnv(source)] || env[RELAY_ENV.alertSecret] || undefined;
60
+ if (secret)
61
+ alertSecrets[source] = secret;
62
+ }
63
+ const alerts = Object.keys(alertSecrets).length > 0;
64
+ if (!slackSecret && !teamsSecret && !alerts)
65
+ return { error: `set ${RELAY_ENV.slackSecret}, ${RELAY_ENV.teamsSecret} or both, so the relay can verify a click, or ${RELAY_ENV.alertSecret} for alerts` };
66
+ const alertAgeText = env[RELAY_ENV.alertMaxAge];
67
+ const alertMaxAge = alertAgeText === undefined || alertAgeText === "" ? undefined : Number(alertAgeText);
68
+ if (alertMaxAge !== undefined && (!Number.isInteger(alertMaxAge) || alertMaxAge <= 0))
69
+ return { error: `${RELAY_ENV.alertMaxAge} is a whole number of seconds (got ${JSON.stringify(alertAgeText)})` };
51
70
  const maxAgeText = env[RELAY_ENV.maxAge];
52
71
  const maxAge = maxAgeText === undefined || maxAgeText === "" ? DEFAULT_RELAY_MAX_AGE_SECONDS : Number(maxAgeText);
53
72
  if (!Number.isInteger(maxAge) || maxAge <= 0)
@@ -58,7 +77,15 @@ export function relaySettingsFromEnv(env) {
58
77
  return { error: `${RELAY_ENV.port} is a port number (got ${JSON.stringify(portText)})` };
59
78
  const slackResponse = env[RELAY_ENV.slackResponse]?.split(",").map((s) => s.trim()).filter(Boolean);
60
79
  return {
61
- settings: { key, ...(slackSecret ? { slackSecret } : {}), ...(teamsSecret ? { teamsSecret } : {}), maxAgeSeconds: maxAge, ...(slackResponse?.length ? { slackResponse } : {}) },
80
+ settings: {
81
+ key,
82
+ ...(slackSecret ? { slackSecret } : {}),
83
+ ...(teamsSecret ? { teamsSecret } : {}),
84
+ maxAgeSeconds: maxAge,
85
+ ...(slackResponse?.length ? { slackResponse } : {}),
86
+ ...(alerts ? { alertSecrets } : {}),
87
+ ...(alertMaxAge !== undefined ? { alertMaxAgeSeconds: alertMaxAge } : {}),
88
+ },
62
89
  host: env[RELAY_ENV.host] || DEFAULT_RELAY_HOST,
63
90
  port,
64
91
  };
@@ -98,13 +125,24 @@ export async function fetchDefaultBranch(cwd) {
98
125
  throw new Error(`cannot fetch ${branch} to read the signers at its tip: ${(err.stderr ?? "").trim() || err.message}`);
99
126
  }
100
127
  }
101
- /** The relay's reads and writes against the checkout at `cwd`. */
102
- export function checkoutRelayDeps(cwd, principal) {
128
+ /** The relay's reads and writes against the checkout at `cwd`. `dispatch` starts the alert agent's workflow (#5329). */
129
+ export function checkoutRelayDeps(cwd, principal, dispatch) {
103
130
  const words = activeProductWords();
104
131
  const one = serial();
105
132
  return {
106
133
  principal,
107
134
  words,
135
+ ...(dispatch ? { dispatch } : {}),
136
+ recordAlerts: (facts) => one(async () => {
137
+ const { fetchLifecycle, pushLifecycleRebasing } = await import("../../lifecycle/git.js");
138
+ const { recordAgentFacts } = await import("../../agent-facts.js");
139
+ await fetchLifecycle({ cwd });
140
+ const out = await recordAgentFacts(facts, { cwd });
141
+ // The fact must be on the remote before the workflow that reads it starts.
142
+ if (out.recorded.length > 0)
143
+ await pushLifecycleRebasing({ cwd, requireLanded: true });
144
+ return out;
145
+ }),
108
146
  signers: () => one(async () => {
109
147
  await fetchDefaultBranch(cwd);
110
148
  const { scopeSource } = await import("../../workspace/write-scope.js");
@@ -218,9 +256,31 @@ export async function serveNotifyRelay(o, env = process.env) {
218
256
  else if (o.tokenEnv || o.forge) {
219
257
  return fail("--token-env and --forge go with --repo <url>");
220
258
  }
221
- const deps = checkoutRelayDeps(cwd, principal);
259
+ // #5329: the relay starts the alert agent's workflow with a token that can do that and nothing else.
260
+ let dispatch;
261
+ const dispatchToken = env[RELAY_ENV.alertDispatchToken]?.trim();
262
+ if (read.settings.alertSecrets && dispatchToken) {
263
+ if (!repoUrl)
264
+ return fail(`${RELAY_ENV.alertDispatchToken} goes with --repo <url>, the repository whose workflow it starts`);
265
+ const { checkDispatchToken, dispatchAgentWorkflow, relayRepo, WORKFLOW_FILE } = await import("../../notify-relay-repo.js");
266
+ const repo = relayRepo(repoUrl, o.forge ?? (env[RELAY_REPO_ENV.forge] || undefined));
267
+ if ("error" in repo)
268
+ return fail(repo.error);
269
+ const workflow = env[RELAY_ENV.alertWorkflow]?.trim();
270
+ if (repo.forge !== "gitlab" && !(workflow && WORKFLOW_FILE.test(workflow)))
271
+ return fail(`${RELAY_ENV.alertWorkflow} names the alert agent's workflow file, such as ${words.product}-alert-agent.yml`);
272
+ const checked = await checkDispatchToken(repo, dispatchToken);
273
+ if ("error" in checked)
274
+ return fail(`${RELAY_ENV.alertDispatchToken} may only start a workflow, and this one can do more: ${checked.error}`);
275
+ const branch = (await run("git", ["rev-parse", "--abbrev-ref", "HEAD"], { cwd })).stdout.trim();
276
+ dispatch = () => dispatchAgentWorkflow({ repo, token: dispatchToken, branch, ...(workflow ? { workflow } : {}) });
277
+ }
278
+ const deps = checkoutRelayDeps(cwd, principal, dispatch);
222
279
  const { url } = await startRelayServer(read.settings, deps, { host: read.host, port: read.port, log: (line) => console.error(formatInfo(line)) });
280
+ const alertSources = Object.keys(read.settings.alertSecrets ?? {});
223
281
  console.error(formatInfo(`${words.product} notify relay listens at ${url} (POST /slack, POST /teams, GET /healthz), recording approvals relayed by ${principal}`));
282
+ if (alertSources.length > 0)
283
+ console.error(formatInfo(`alerts from ${alertSources.join(", ")} at POST /alert/<source>; ${dispatch ? "each new alert starts the agent's workflow" : `no ${RELAY_ENV.alertDispatchToken}, so the agent's schedule picks alerts up`}`));
224
284
  await new Promise(() => { });
225
285
  return 0;
226
286
  }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * `chant pipeline agent` (#5358): a stage's agent steps. See
3
+ * ../../pipeline/agent-steps.ts.
4
+ *
5
+ * pipeline agent run --stage <stage> --release <label|digest> [--output <dir>]
6
+ * run the stage's agent steps for the release, in order, and write each
7
+ * step's record to <dir>/<step>.json (default .chant/agent-steps/<stage>).
8
+ * Reads the ledger and writes nothing to it: the job it runs in holds a
9
+ * read token only. Exits 1 when a step failed, naming why.
10
+ * pipeline agent record --stage <stage> --release <label|digest> [--from <dir>]
11
+ * check each record against the pipeline at base, record it on
12
+ * <stage>/agent-answers.jsonl with a run record per model run, and push.
13
+ * Exits 1 when a step failed or a record is refused.
14
+ * pipeline agent answer --stage <stage> --release <label|digest> [--name <step>] [--json]
15
+ * print the stage's answers for the release, or one step's answer.
16
+ */
17
+ import type { CommandContext } from "../registry.js";
18
+ import type { PipelineSpec } from "../../pipeline/spec.js";
19
+ import type { AgentPolicyVerdict } from "../../pipeline/promote.js";
20
+ import type { PolicyAgentAnswer } from "../../pipeline/agent-steps.js";
21
+ /** Where `run` writes a stage's records and `record` reads them, unless named. */
22
+ export declare const AGENT_STEPS_DIR = ".chant/agent-steps";
23
+ export declare function runPipelineAgent(ctx: CommandContext): Promise<number>;
24
+ /**
25
+ * The stage gate's policy over agent answers, for the promote (#5358): the
26
+ * workspace's `ci.policy` at base, with the answers as `input.agent` and no
27
+ * change set, since a promote is gated before it plans. Undefined when no
28
+ * policy is named at base.
29
+ */
30
+ export declare function stageAgentPolicy(cwd: string, spec: PipelineSpec, stage: string, agent: Record<string, PolicyAgentAnswer>): Promise<AgentPolicyVerdict>;