@intentius/chant 0.124.108 → 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 (342) 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/release.js +4 -2
  80. package/dist/cli/handlers/replan.d.ts +54 -0
  81. package/dist/cli/handlers/replan.js +177 -0
  82. package/dist/cli/handlers/run-generate.d.ts +5 -0
  83. package/dist/cli/handlers/run-generate.js +31 -4
  84. package/dist/cli/handlers/run-wave.js +15 -2
  85. package/dist/cli/handlers/run.js +4 -2
  86. package/dist/cli/handlers/stage.d.ts +35 -0
  87. package/dist/cli/handlers/stage.js +90 -0
  88. package/dist/cli/lsp/server.js +4 -0
  89. package/dist/cli/main.js +88 -8
  90. package/dist/cli/parse-args.js +35 -2
  91. package/dist/cli/registry.d.ts +12 -0
  92. package/dist/components/auto-release.d.ts +2 -0
  93. package/dist/components/auto-release.js +1 -0
  94. package/dist/components/capability.d.ts +40 -0
  95. package/dist/components/cli-support.d.ts +21 -1
  96. package/dist/components/cli-support.js +28 -6
  97. package/dist/components/component.d.ts +23 -4
  98. package/dist/components/component.schema.json +28 -0
  99. package/dist/components/declared-reads.d.ts +44 -4
  100. package/dist/components/declared-reads.js +80 -3
  101. package/dist/components/discover.d.ts +8 -0
  102. package/dist/components/discover.js +1 -1
  103. package/dist/components/driver.d.ts +13 -0
  104. package/dist/components/driver.js +23 -2
  105. package/dist/components/environment-sets.d.ts +229 -0
  106. package/dist/components/environment-sets.js +338 -0
  107. package/dist/components/fan-out-canary.d.ts +47 -0
  108. package/dist/components/fan-out-canary.js +58 -0
  109. package/dist/components/fan-out-run.d.ts +17 -0
  110. package/dist/components/fan-out-run.js +14 -1
  111. package/dist/components/fan-out-support.d.ts +7 -0
  112. package/dist/components/fan-out-support.js +1 -1
  113. package/dist/components/groups.d.ts +8 -1
  114. package/dist/components/groups.js +19 -1
  115. package/dist/components/index.d.ts +5 -2
  116. package/dist/components/index.js +4 -1
  117. package/dist/components/pr-cost.d.ts +28 -0
  118. package/dist/components/pr-cost.js +53 -0
  119. package/dist/components/pr-pipeline.d.ts +33 -0
  120. package/dist/components/pr-pipeline.js +32 -5
  121. package/dist/components/pr-policy.d.ts +33 -2
  122. package/dist/components/pr-policy.js +5 -2
  123. package/dist/components/pr-risk.d.ts +42 -0
  124. package/dist/components/pr-risk.js +74 -0
  125. package/dist/components/product-pipeline.d.ts +43 -0
  126. package/dist/components/product-pipeline.js +67 -1
  127. package/dist/components/promote.d.ts +6 -0
  128. package/dist/components/promote.js +13 -0
  129. package/dist/components/release-compile.js +3 -1
  130. package/dist/components/release-gate.d.ts +6 -1
  131. package/dist/components/release-gate.js +10 -2
  132. package/dist/components/step-environments.d.ts +236 -0
  133. package/dist/components/step-environments.js +392 -0
  134. package/dist/components/upstream-replan.d.ts +201 -0
  135. package/dist/components/upstream-replan.js +249 -0
  136. package/dist/components/verify-step.d.ts +30 -0
  137. package/dist/components/verify-step.js +27 -0
  138. package/dist/components/wave-plan.js +6 -2
  139. package/dist/config-environments.d.ts +4 -2
  140. package/dist/control/dispatch.d.ts +15 -0
  141. package/dist/control/dispatch.js +28 -4
  142. package/dist/cost-estimate.d.ts +188 -0
  143. package/dist/cost-estimate.js +363 -0
  144. package/dist/drift-record.d.ts +36 -0
  145. package/dist/drift-record.js +44 -0
  146. package/dist/engine-facts.d.ts +105 -0
  147. package/dist/engine-facts.js +111 -0
  148. package/dist/exit-codes.d.ts +4 -3
  149. package/dist/exit-codes.js +4 -3
  150. package/dist/flag-params.d.ts +2 -2
  151. package/dist/flag-params.js +9 -4
  152. package/dist/floor-table.data.js +53 -0
  153. package/dist/forge-token-vars.d.ts +12 -0
  154. package/dist/forge-token-vars.js +25 -0
  155. package/dist/gate-decision.d.ts +3 -1
  156. package/dist/gate-decision.js +3 -1
  157. package/dist/gated-waves.d.ts +2 -0
  158. package/dist/gated-waves.js +1 -0
  159. package/dist/graph-ir.d.ts +30 -0
  160. package/dist/graph-ir.js +33 -1
  161. package/dist/graph-refs.d.ts +26 -0
  162. package/dist/graph-refs.js +34 -3
  163. package/dist/graph-schema/graph.schema.json +136 -0
  164. package/dist/health.d.ts +65 -0
  165. package/dist/health.js +62 -0
  166. package/dist/lexicon.d.ts +188 -1
  167. package/dist/lifecycle/disruption.d.ts +14 -1
  168. package/dist/lifecycle/disruption.js +5 -1
  169. package/dist/lifecycle/gate-change-set.d.ts +8 -0
  170. package/dist/lifecycle/gate-change-set.js +2 -1
  171. package/dist/lifecycle/gate-ledger.d.ts +26 -0
  172. package/dist/lifecycle/gate-rejection.d.ts +82 -0
  173. package/dist/lifecycle/gate-rejection.js +93 -0
  174. package/dist/lifecycle/gate-seal.d.ts +3 -3
  175. package/dist/lifecycle/gate-seal.js +5 -5
  176. package/dist/lifecycle/observe.d.ts +17 -0
  177. package/dist/lifecycle/observe.js +10 -1
  178. package/dist/lifecycle/release-cut.js +4 -0
  179. package/dist/lifecycle/release-ledger.d.ts +8 -0
  180. package/dist/lifecycle/release-risk.d.ts +137 -0
  181. package/dist/lifecycle/release-risk.js +214 -0
  182. package/dist/lifecycle/release-store.d.ts +9 -0
  183. package/dist/lifecycle/release-store.js +4 -0
  184. package/dist/lifecycle/stage-log.d.ts +85 -0
  185. package/dist/lifecycle/stage-log.js +141 -0
  186. package/dist/lint/canary-checks.d.ts +31 -0
  187. package/dist/lint/canary-checks.js +45 -0
  188. package/dist/lint/rule.d.ts +1 -0
  189. package/dist/lint/rules/evl012-pipeline-fold.d.ts +14 -0
  190. package/dist/lint/rules/evl012-pipeline-fold.js +30 -0
  191. package/dist/lint/rules/index.d.ts +1 -0
  192. package/dist/lint/rules/index.js +3 -0
  193. package/dist/notify-relay-repo.d.ts +54 -0
  194. package/dist/notify-relay-repo.js +84 -0
  195. package/dist/notify-relay.d.ts +53 -3
  196. package/dist/notify-relay.js +96 -3
  197. package/dist/notify.d.ts +57 -1
  198. package/dist/notify.js +7 -1
  199. package/dist/notify.schema.json +61 -3
  200. package/dist/observation.d.ts +34 -0
  201. package/dist/observation.js +14 -1
  202. package/dist/op/activities/review-agent.d.ts +39 -2
  203. package/dist/op/activities/review-agent.js +88 -5
  204. package/dist/op/agent-permit.d.ts +88 -0
  205. package/dist/op/agent-permit.js +97 -0
  206. package/dist/op/gate-approval-base.d.ts +8 -0
  207. package/dist/op/gate-approval-base.js +9 -0
  208. package/dist/op/gate-approval.d.ts +30 -1
  209. package/dist/op/gate-approval.js +23 -2
  210. package/dist/op/gate-quorum.d.ts +114 -8
  211. package/dist/op/gate-quorum.js +198 -21
  212. package/dist/op/gate-reject.d.ts +79 -0
  213. package/dist/op/gate-reject.js +96 -0
  214. package/dist/op/gate-summary.js +1 -1
  215. package/dist/op/gate.d.ts +28 -3
  216. package/dist/op/gate.js +55 -13
  217. package/dist/op/generate-pipeline.d.ts +15 -1
  218. package/dist/op/generate-pipeline.js +32 -5
  219. package/dist/op/index.d.ts +11 -6
  220. package/dist/op/index.js +10 -5
  221. package/dist/op/local-executor.d.ts +2 -0
  222. package/dist/op/local-executor.js +23 -4
  223. package/dist/op/op-waves-after-plan.d.ts +23 -0
  224. package/dist/op/op-waves-after-plan.js +12 -1
  225. package/dist/op/op-waves-capability-spec.d.ts +14 -0
  226. package/dist/op/op-waves-capability-spec.js +46 -6
  227. package/dist/op/op-waves-capability.d.ts +21 -13
  228. package/dist/op/op-waves-capability.js +22 -59
  229. package/dist/op/op-waves-environment-sets.d.ts +41 -0
  230. package/dist/op/op-waves-environment-sets.js +82 -0
  231. package/dist/op/op-waves-quorum-warnings.d.ts +53 -0
  232. package/dist/op/op-waves-quorum-warnings.js +90 -0
  233. package/dist/op/op-waves-release-port.d.ts +7 -0
  234. package/dist/op/op-waves-release-port.js +15 -3
  235. package/dist/op/op-waves-release.d.ts +15 -0
  236. package/dist/op/op-waves-release.js +15 -0
  237. package/dist/op/op-waves-run.d.ts +37 -3
  238. package/dist/op/op-waves-run.js +141 -18
  239. package/dist/op/op-waves-soak.d.ts +57 -0
  240. package/dist/op/op-waves-soak.js +111 -0
  241. package/dist/op/op-waves-split.d.ts +4 -0
  242. package/dist/op/op-waves-split.js +4 -0
  243. package/dist/op/op-waves.d.ts +67 -4
  244. package/dist/op/op-waves.js +71 -3
  245. package/dist/pipeline/agent-ajv.d.ts +4 -0
  246. package/dist/pipeline/agent-ajv.js +14 -0
  247. package/dist/pipeline/agent-steps.d.ts +329 -0
  248. package/dist/pipeline/agent-steps.js +602 -0
  249. package/dist/pipeline/artifacts.d.ts +264 -0
  250. package/dist/pipeline/artifacts.js +425 -0
  251. package/dist/pipeline/diff.d.ts +45 -0
  252. package/dist/pipeline/diff.js +177 -0
  253. package/dist/pipeline/fold.d.ts +43 -0
  254. package/dist/pipeline/fold.js +140 -0
  255. package/dist/pipeline/generate.d.ts +52 -0
  256. package/dist/pipeline/generate.js +120 -0
  257. package/dist/pipeline/product.d.ts +225 -0
  258. package/dist/pipeline/product.js +257 -0
  259. package/dist/pipeline/promote.d.ts +404 -0
  260. package/dist/pipeline/promote.js +694 -0
  261. package/dist/pipeline/read.d.ts +37 -0
  262. package/dist/pipeline/read.js +58 -0
  263. package/dist/pipeline/rendered.d.ts +25 -0
  264. package/dist/pipeline/rendered.js +53 -0
  265. package/dist/pipeline/soak-checks.d.ts +80 -0
  266. package/dist/pipeline/soak-checks.js +254 -0
  267. package/dist/pipeline/soak-gate.d.ts +97 -0
  268. package/dist/pipeline/soak-gate.js +176 -0
  269. package/dist/pipeline/soak-sources.d.ts +17 -0
  270. package/dist/pipeline/soak-sources.js +42 -0
  271. package/dist/pipeline/soak.d.ts +260 -0
  272. package/dist/pipeline/soak.js +378 -0
  273. package/dist/pipeline/spec.d.ts +724 -0
  274. package/dist/pipeline/spec.js +567 -0
  275. package/dist/pipeline/stage-ledger.d.ts +187 -0
  276. package/dist/pipeline/stage-ledger.js +185 -0
  277. package/dist/pipeline/stage-waves.d.ts +114 -0
  278. package/dist/pipeline/stage-waves.js +161 -0
  279. package/dist/pipeline/stages.d.ts +64 -0
  280. package/dist/pipeline/stages.js +174 -0
  281. package/dist/pipeline/verify-rollback.d.ts +277 -0
  282. package/dist/pipeline/verify-rollback.js +393 -0
  283. package/dist/pipeline.d.ts +142 -0
  284. package/dist/pipeline.js +143 -0
  285. package/dist/pr-loop.d.ts +22 -0
  286. package/dist/pr-loop.js +8 -0
  287. package/dist/pr-plan-note.d.ts +15 -1
  288. package/dist/pr-plan-note.js +8 -0
  289. package/dist/pr-post.d.ts +31 -0
  290. package/dist/pr-post.js +89 -0
  291. package/dist/release-floors.d.ts +1 -1
  292. package/dist/release-floors.js +1 -1
  293. package/dist/report-store/audit.schema.json +50 -0
  294. package/dist/report-store/dora.schema.json +331 -0
  295. package/dist/report-store/estate.schema.json +96 -0
  296. package/dist/report-store/run.schema.json +14 -0
  297. package/dist/report-store.d.ts +151 -0
  298. package/dist/report-store.js +344 -0
  299. package/dist/run-event.d.ts +7 -2
  300. package/dist/wave-runtime.mjs +458 -404
  301. package/dist/workspace/catalog-edges.js +3 -3
  302. package/dist/workspace/change-set.schema.json +4 -0
  303. package/dist/workspace/ci-cloud-identity.d.ts +4 -0
  304. package/dist/workspace/ci-cloud-identity.js +30 -0
  305. package/dist/workspace/ci-run.js +17 -2
  306. package/dist/workspace/ci-secrets.d.ts +3 -1
  307. package/dist/workspace/ci-secrets.js +7 -1
  308. package/dist/workspace/compose-graph.d.ts +1 -1
  309. package/dist/workspace/compose-graph.js +3 -1
  310. package/dist/workspace/declaration.d.ts +27 -0
  311. package/dist/workspace/declaration.js +35 -0
  312. package/dist/workspace/declaration.schema.json +56 -0
  313. package/dist/workspace/graph-cli.js +26 -0
  314. package/dist/workspace/graph.schema.json +5 -1
  315. package/dist/workspace/identity-gate-rule.d.ts +4 -0
  316. package/dist/workspace/identity-gate-rule.js +2 -2
  317. package/dist/workspace/identity-reject-rule.d.ts +14 -0
  318. package/dist/workspace/identity-reject-rule.js +24 -0
  319. package/dist/workspace/identity.d.ts +3 -0
  320. package/dist/workspace/identity.js +2 -1
  321. package/dist/workspace/nested-graph.js +2 -0
  322. package/dist/workspace/pr-report.schema.json +65 -0
  323. package/dist/workspace/promotion-order.d.ts +19 -4
  324. package/dist/workspace/promotion-order.js +26 -4
  325. package/dist/workspace/release-train.d.ts +14 -0
  326. package/dist/workspace/release-train.js +32 -0
  327. package/dist/workspace/run-event.schema.json +2 -2
  328. package/dist/workspace/stack-read-edges.d.ts +19 -0
  329. package/dist/workspace/stack-read-edges.js +54 -0
  330. package/dist/workspace/status-gates.d.ts +51 -1
  331. package/dist/workspace/status-gates.js +60 -0
  332. package/dist/workspace/status-stages.d.ts +223 -0
  333. package/dist/workspace/status-stages.js +279 -0
  334. package/dist/workspace/status.d.ts +45 -1
  335. package/dist/workspace/status.js +109 -5
  336. package/dist/workspace/status.schema.json +283 -2
  337. package/dist/workspace/train-cut.js +5 -2
  338. package/dist/workspace/train-shell.d.ts +18 -0
  339. package/dist/workspace/train-shell.js +43 -0
  340. package/dist/workspace/trust/seal.d.ts +7 -0
  341. package/dist/workspace/trust/seal.js +9 -0
  342. package/package.json +5 -1
@@ -0,0 +1,84 @@
1
+ /**
2
+ * `chant reject <op> <gate> --reason <text>` (#5354): turn down the digest a
3
+ * gate waits on. At a pipeline stage's gate (`chant reject <pipeline>
4
+ * <stage>`) that digest is a release's, so the release does not enter the
5
+ * stage, and `components promote` says who rejected it and why.
6
+ *
7
+ * It records the rejection the way `chant approve` records an approval: the
8
+ * digest from the gate's standing pending fact (or `--plan`), its
9
+ * environment and release from the same fact, the actor from `--actor`, the
10
+ * CI or the shell, a seal with `--sign` or a signature made elsewhere with
11
+ * `--signature` and `--at` over the statement `--statement` prints, and the
12
+ * workspace's `identity.gates` rule for the gate judged before anything is
13
+ * written. A rejection is final for the digest it names: nothing withdraws
14
+ * it, and more approvals do not clear it. A new release goes through again.
15
+ */
16
+ import { type GateOrigin } from "../../lifecycle/gate-origin.js";
17
+ import { checkGateSignature } from "../../lifecycle/gate-seal.js";
18
+ import { type GateRejectionRecord, type SealedGateRejection } from "../../lifecycle/gate-rejection.js";
19
+ import { type GateLedgerPort } from "../../op/gate.js";
20
+ import type { IdentitySource } from "../../workspace/identity.js";
21
+ import type { GateAdmission } from "../../workspace/identity.js";
22
+ import type { CommandContext } from "../registry.js";
23
+ /** What `chant reject` takes. */
24
+ export interface GateRejectionOptions {
25
+ /** `--reason`: why, on one line. Required. */
26
+ reason?: string;
27
+ /** `--actor` / `--approver`; falls back to the CI or shell identity. */
28
+ actor?: string;
29
+ /** `--plan <digest>`: the digest rejected. Default: the gate's standing pending fact's. */
30
+ plan?: string;
31
+ /** `--env <env>`: which environment's pending fact, on a gate whose facts name one. */
32
+ environment?: string;
33
+ /** `--release <digest>`: the release rejected, when no pending fact names it. */
34
+ release?: string;
35
+ /** `--url`: where the rejection was made. */
36
+ url?: string;
37
+ /** `--sign [<key file>]`: seal it with an ssh key. */
38
+ sign?: string | true;
39
+ /** `--signature <file>`: a signature made elsewhere over the statement; `-` reads stdin. */
40
+ signature?: string;
41
+ /** `--at <timestamp>`: the statement's time. */
42
+ at?: string;
43
+ /** `--agent`: an agent's rejection, recorded and counted for nothing. */
44
+ agent?: boolean;
45
+ /** The channel it arrived on. Default: the process's. */
46
+ origin?: GateOrigin;
47
+ /** The repository. Default: the process's directory. */
48
+ cwd?: string;
49
+ /** The gate ledger. Default: `chant/lifecycle` in `cwd`. */
50
+ port?: GateLedgerPort;
51
+ /** The declaration, trust policy and `identity.gates` rule at base. Default: read at the base of `cwd`. */
52
+ scope?: IdentitySource & {
53
+ rule: GateAdmission | null;
54
+ signers: Parameters<typeof checkGateSignature>[0];
55
+ };
56
+ }
57
+ /** The bytes a rejection signed elsewhere signs, as `--statement` prints them. */
58
+ export interface GateRejectionStatement {
59
+ namespace: string;
60
+ text: string;
61
+ statement: string;
62
+ challenge: string;
63
+ rejection: SealedGateRejection;
64
+ }
65
+ export type GateRejectionOutcome = {
66
+ ok: true;
67
+ record: GateRejectionRecord;
68
+ pushed: boolean;
69
+ pushWarning?: string;
70
+ } | {
71
+ ok: false;
72
+ message: string;
73
+ hint?: string;
74
+ };
75
+ export declare function scopeAt(cwd: string, gate: string): Promise<NonNullable<GateRejectionOptions["scope"]>>;
76
+ /**
77
+ * Record a rejection, or return the statement to sign with
78
+ * `statementOnly`. Writes nothing when it refuses; the outcome says why.
79
+ */
80
+ export declare function recordGateRejection(op: string, gate: string, opts: GateRejectionOptions, statementOnly?: boolean): Promise<GateRejectionOutcome | {
81
+ statement: GateRejectionStatement;
82
+ }>;
83
+ /** `chant reject <op> <gate> --reason <text>`. */
84
+ export declare function runReject(ctx: CommandContext): Promise<number>;
@@ -0,0 +1,216 @@
1
+ /**
2
+ * `chant reject <op> <gate> --reason <text>` (#5354): turn down the digest a
3
+ * gate waits on. At a pipeline stage's gate (`chant reject <pipeline>
4
+ * <stage>`) that digest is a release's, so the release does not enter the
5
+ * stage, and `components promote` says who rejected it and why.
6
+ *
7
+ * It records the rejection the way `chant approve` records an approval: the
8
+ * digest from the gate's standing pending fact (or `--plan`), its
9
+ * environment and release from the same fact, the actor from `--actor`, the
10
+ * CI or the shell, a seal with `--sign` or a signature made elsewhere with
11
+ * `--signature` and `--at` over the statement `--statement` prints, and the
12
+ * workspace's `identity.gates` rule for the gate judged before anything is
13
+ * written. A rejection is final for the digest it names: nothing withdraws
14
+ * it, and more approvals do not clear it. A new release goes through again.
15
+ */
16
+ import { readFileSync } from "node:fs";
17
+ import { resolve as resolvePath } from "node:path";
18
+ import { latestPendingGate } from "../../lifecycle/gate-ledger.js";
19
+ import { currentGateOrigin, isModelAuthored, UNATTESTED_APPROVER } from "../../lifecycle/gate-origin.js";
20
+ import { isPlanDigest, samePlanDigest } from "../../lifecycle/plan-digest.js";
21
+ import { checkGateSignature, WEBAUTHN_SEAL_KIND } from "../../lifecycle/gate-seal.js";
22
+ import { webAuthnChallenge } from "../../lifecycle/gate-webauthn.js";
23
+ import { readExternalSignature } from "../../lifecycle/gate-statement.js";
24
+ import { GATE_REJECTION_NAMESPACE, gateRejectionPayload, rejectionReasonProblem } from "../../lifecycle/gate-rejection.js";
25
+ import { ledgerRecordingOff, NO_RECORD_ENV } from "../../lifecycle/no-record.js";
26
+ import { gitGateLedgerPort } from "../../op/gate.js";
27
+ import { actorFromEnv } from "../../actor.js";
28
+ import { formatError, formatInfo, formatSuccess } from "../format.js";
29
+ /** How far in the future `--at` may be, for a clock a little ahead of this one. */
30
+ const AT_SKEW_MS = 5 * 60 * 1000;
31
+ export async function scopeAt(cwd, gate) {
32
+ const { scopeSource } = await import("../../workspace/write-scope.js");
33
+ const { gateAdmissionFrom } = await import("../../workspace/identity.js");
34
+ const scope = scopeSource(cwd);
35
+ return { declaration: scope.declaration, policy: scope.policy, rule: gateAdmissionFrom(scope, gate), signers: scope.policy };
36
+ }
37
+ /**
38
+ * Record a rejection, or return the statement to sign with
39
+ * `statementOnly`. Writes nothing when it refuses; the outcome says why.
40
+ */
41
+ export async function recordGateRejection(op, gate, opts, statementOnly = false) {
42
+ const refuse = (message, hint) => ({ ok: false, message: `Gate "${gate}" on "${op}" was not rejected: ${message}`, ...(hint ? { hint } : {}) });
43
+ const reasonProblem = rejectionReasonProblem(opts.reason);
44
+ if (reasonProblem)
45
+ return refuse(reasonProblem);
46
+ const reason = opts.reason.trim();
47
+ if (!statementOnly && ledgerRecordingOff())
48
+ return refuse(`${NO_RECORD_ENV} is set, so nothing is written to chant/lifecycle`, `Unset ${NO_RECORD_ENV} to reject the release.`);
49
+ const cwd = opts.cwd ?? process.cwd();
50
+ const port = opts.port ?? gitGateLedgerPort(opts.cwd !== undefined ? { cwd: opts.cwd } : undefined);
51
+ if (!port.appendRejection)
52
+ return refuse("this gate ledger keeps no rejections");
53
+ let ledger;
54
+ try {
55
+ ledger = await port.read(op);
56
+ }
57
+ catch (err) {
58
+ return refuse(err instanceof Error ? err.message : String(err), "The pending fact this answers lives on chant/lifecycle; fetch it and run again.");
59
+ }
60
+ const pending = opts.environment !== undefined ? ledger.pending.filter((p) => p.environment === opts.environment) : ledger.pending;
61
+ const standing = latestPendingGate(pending, gate);
62
+ let planDigest;
63
+ if (opts.plan !== undefined) {
64
+ if (!isPlanDigest(opts.plan))
65
+ return refuse(`--plan must be a plan digest ("jcs1-sha256:" or "sha256:", then 64 hex characters), got "${opts.plan}"`);
66
+ planDigest = opts.plan;
67
+ }
68
+ else {
69
+ if (!standing?.planDigest) {
70
+ return refuse(`the gate has no pending fact${opts.environment !== undefined ? ` in environment "${opts.environment}"` : ""}, so there is no release to reject`, `Name the release's digest: chant reject ${op} ${gate} --plan <digest> --reason <text>.`);
71
+ }
72
+ planDigest = standing.planDigest;
73
+ }
74
+ const answers = standing !== undefined && samePlanDigest(standing.planDigest, planDigest);
75
+ const environment = opts.environment ?? (answers ? standing.environment : undefined);
76
+ if (opts.release !== undefined && !isPlanDigest(opts.release))
77
+ return refuse(`--release must be a release digest, got "${opts.release}"`);
78
+ const releaseDigest = opts.release ?? (answers ? standing.releaseDigest : undefined);
79
+ const origin = opts.origin ?? currentGateOrigin();
80
+ const rejectedBy = opts.actor ?? (isModelAuthored(origin) ? UNATTESTED_APPROVER : actorFromEnv());
81
+ const kind = opts.agent || isModelAuthored(origin) ? "agent" : "human";
82
+ const scope = opts.scope ?? (await scopeAt(cwd, gate));
83
+ const identity = await import("../../workspace/identity.js");
84
+ try {
85
+ identity.refuseUnidentified(scope, [rejectedBy], opts.actor !== undefined ? "--actor" : "the rejecter");
86
+ }
87
+ catch (err) {
88
+ if (!(err instanceof identity.IdentityError))
89
+ throw err;
90
+ return refuse(err.message, "Pass --actor <forge identity or signer>, for example --actor github:<login>.");
91
+ }
92
+ if (opts.signature !== undefined && opts.sign !== undefined)
93
+ return refuse("--sign signs here and --signature brings a signature made elsewhere; pass one of them");
94
+ if (opts.at !== undefined && !statementOnly && opts.signature === undefined)
95
+ return refuse("--at sets the time of a statement signed elsewhere, so it goes with --statement or --signature");
96
+ if (opts.signature !== undefined && opts.at === undefined)
97
+ return refuse("--signature needs --at <timestamp>, the statement's time, since the signature covers it");
98
+ let timestamp = new Date().toISOString();
99
+ if (opts.at !== undefined) {
100
+ const at = Date.parse(opts.at);
101
+ if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(opts.at) || Number.isNaN(at) || new Date(at).toISOString() !== opts.at)
102
+ return refuse(`--at takes a UTC time as chant writes one, such as ${timestamp}`);
103
+ if (at > Date.now() + AT_SKEW_MS)
104
+ return refuse(`--at ${opts.at} is in the future`);
105
+ timestamp = opts.at;
106
+ }
107
+ const sealed = {
108
+ op,
109
+ gate,
110
+ ...(environment !== undefined ? { environment } : {}),
111
+ planDigest,
112
+ ...(releaseDigest !== undefined ? { releaseDigest } : {}),
113
+ rejectedBy,
114
+ timestamp,
115
+ reason,
116
+ };
117
+ if (statementOnly) {
118
+ const bytes = gateRejectionPayload(sealed);
119
+ return { statement: { namespace: GATE_REJECTION_NAMESPACE, text: bytes.toString("utf-8"), statement: bytes.toString("base64"), challenge: webAuthnChallenge(bytes), rejection: sealed } };
120
+ }
121
+ // #3163: a gate the workspace's identity.gates names counts only a signed rejection, as it counts only a signed approval.
122
+ if (scope.rule && opts.sign === undefined && opts.signature === undefined) {
123
+ return refuse(`chant.workspace.json at base names gate "${gate}" in identity.gates, so only a signed rejection counts there, and this one is not signed`, `chant reject ${op} ${gate} --actor <principal> --sign [<key file>] --reason <text>, with a key ${scope.policy.signersPath} at base lists for that principal.`);
124
+ }
125
+ let seal;
126
+ if (opts.signature !== undefined) {
127
+ let text;
128
+ try {
129
+ text = opts.signature === "-" ? readFileSync(0, "utf-8") : readFileSync(resolvePath(cwd, opts.signature), "utf-8");
130
+ }
131
+ catch (err) {
132
+ return refuse(`--signature ${opts.signature} can't be read: ${err instanceof Error ? err.message : String(err)}`);
133
+ }
134
+ const sig = readExternalSignature(text);
135
+ if ("problem" in sig)
136
+ return refuse(`--signature ${opts.signature}: ${sig.problem}`);
137
+ const candidate = sig.kind === "ssh"
138
+ ? { signer: rejectedBy, key: "", signature: sig.signature }
139
+ : { kind: WEBAUTHN_SEAL_KIND, signer: rejectedBy, key: sig.assertion.id, signature: sig.assertion.signature, clientDataJSON: sig.assertion.clientDataJSON, authenticatorData: sig.assertion.authenticatorData };
140
+ const r = checkGateSignature(scope.signers, rejectedBy, candidate, gateRejectionPayload(sealed), GATE_REJECTION_NAMESPACE);
141
+ if (!r.ok)
142
+ return refuse(r.unlisted ? `${rejectedBy} has no key or passkey listed at base, so a signature made elsewhere can't be checked` : `the signature does not verify for ${rejectedBy} over this rejection's statement: ${r.reason}`);
143
+ seal = { ...candidate, key: r.key };
144
+ }
145
+ if (opts.sign !== undefined) {
146
+ const { resolveSigningKey, sealGateRejection, SealError } = await import("../../workspace/trust/seal.js");
147
+ try {
148
+ const key = resolveSigningKey(opts.sign, cwd);
149
+ try {
150
+ seal = sealGateRejection(key.file, sealed);
151
+ }
152
+ finally {
153
+ key.cleanup();
154
+ }
155
+ }
156
+ catch (err) {
157
+ if (!(err instanceof SealError))
158
+ throw err;
159
+ return refuse(err.message);
160
+ }
161
+ }
162
+ const record = {
163
+ version: 1,
164
+ kind: "rejection",
165
+ ...sealed,
166
+ ...(opts.url !== undefined ? { url: opts.url } : {}),
167
+ approver: { kind },
168
+ origin,
169
+ ...(answers && standing.gitSha ? { gitSha: standing.gitSha } : {}),
170
+ ...(seal ? { seal } : {}),
171
+ };
172
+ if (scope.rule) {
173
+ const why = scope.rule.refusesRejection(record);
174
+ if (why !== null)
175
+ return refuse(why);
176
+ }
177
+ const push = await port.appendRejection(record);
178
+ return { ok: true, record, pushed: push.pushed, ...(push.pushWarning ? { pushWarning: push.pushWarning } : {}) };
179
+ }
180
+ /** `chant reject <op> <gate> --reason <text>`. */
181
+ export async function runReject(ctx) {
182
+ const op = ctx.args.path;
183
+ const gate = ctx.args.extraPositional;
184
+ if (!op || op === "." || !gate) {
185
+ console.error(formatError({ message: "Usage: chant reject <op> <gate> --reason <text> [--plan <digest>] [--env <env>] [--release <digest>] [--actor <name>] [--sign [<key file>]]" }));
186
+ return 1;
187
+ }
188
+ const opts = {
189
+ ...(ctx.args.reason !== undefined ? { reason: ctx.args.reason } : {}),
190
+ ...((ctx.args.approver ?? ctx.args.actor) !== undefined ? { actor: ctx.args.approver ?? ctx.args.actor } : {}),
191
+ ...(ctx.args.plan !== undefined ? { plan: ctx.args.plan } : {}),
192
+ ...(ctx.args.env !== undefined ? { environment: ctx.args.env } : {}),
193
+ ...(ctx.args.release !== undefined ? { release: ctx.args.release } : {}),
194
+ ...(ctx.args.url !== undefined ? { url: ctx.args.url } : {}),
195
+ ...(ctx.args.sign !== undefined ? { sign: ctx.args.sign } : {}),
196
+ ...(ctx.args.signature !== undefined ? { signature: ctx.args.signature } : {}),
197
+ ...(ctx.args.at !== undefined ? { at: ctx.args.at } : {}),
198
+ ...(ctx.args.agent ? { agent: true } : {}),
199
+ };
200
+ const out = await recordGateRejection(op, gate, opts, ctx.args.statement === true);
201
+ if ("statement" in out) {
202
+ console.log(JSON.stringify(out.statement, null, 2));
203
+ console.error(formatInfo(`Have ${out.statement.rejection.rejectedBy} sign these bytes (an ssh key in the ${out.statement.namespace} namespace, or a passkey with challenge ${out.statement.challenge}), ` +
204
+ `then record it with --signature <file> --at ${out.statement.rejection.timestamp} and the same --actor, --plan and --reason.`));
205
+ return 0;
206
+ }
207
+ if (!out.ok) {
208
+ console.error(formatError({ message: out.message, ...(out.hint ? { hint: out.hint } : {}) }));
209
+ return 1;
210
+ }
211
+ const r = out.record;
212
+ const where = r.releaseDigest !== undefined ? `release ${r.releaseDigest}` : `plan ${r.planDigest}`;
213
+ console.error(formatSuccess(`${where} rejected at ${op} ${gate}${r.environment !== undefined ? ` (${r.environment})` : ""} by ${r.rejectedBy} at ${r.timestamp}${r.seal ? ", signed" : ""}${out.pushed ? "" : " (local only: the push did not land)"}`));
214
+ console.error(formatInfo("It does not go through this gate, and more approvals do not clear the rejection. A new release goes through the gate again."));
215
+ return 0;
216
+ }
@@ -737,7 +737,7 @@ export async function runReleaseCut(ctx) {
737
737
  const checkLines = await releaseChecksOf(cutCwd);
738
738
  const check = checkLines.length > 0
739
739
  ? async (at) => {
740
- const { runToStderr } = await import("../../workspace/train-shell.js");
740
+ const { runToStderrCaptured, failedOutputBlock } = await import("../../workspace/train-shell.js");
741
741
  const env = { ...process.env, CHANT_RELEASE_COMMIT: at };
742
742
  delete env[RELEASE_LABEL_ENV];
743
743
  if (label !== null)
@@ -746,8 +746,10 @@ export async function runReleaseCut(ctx) {
746
746
  env.CHANT_RELEASE_DIGESTS = digestsFile;
747
747
  for (const line of checkLines) {
748
748
  console.error(`check: ${line}`);
749
- const code = await runToStderr(line, { cwd: cutCwd, env });
749
+ const { code, stdout, stderr } = await runToStderrCaptured(line, { cwd: cutCwd, env });
750
750
  if (code !== 0) {
751
+ // The refusal's message is one line, and a train shows only the end of it: print what the check said first.
752
+ console.error(failedOutputBlock("release.check", line, { stdout, stderr }));
751
753
  throw new ReleaseCutError("release-check-failed", `no release was cut: release.check failed (exit ${code}): ${line}`, "Nothing was recorded or tagged. Fix what the check reports, or cut another label, and run the cut again.");
752
754
  }
753
755
  }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * `chant components replan --env <env> --component <a,b>` (#5345): after
3
+ * those components applied in `<env>`, compare their outputs with the ones
4
+ * their last apply recorded, list the dependents that read a changed output,
5
+ * and plan the dependents of the members `replanDependents` names. The plan
6
+ * waits at `<gate>-replan` under `--op` (default `replan-<env>`); nothing
7
+ * applies here. See ../../components/upstream-replan.ts.
8
+ *
9
+ * `replanDependents` is read from the pipeline (`.chant/pipeline.ts`) as it
10
+ * stands on the default branch, the stage named `--env`, else the
11
+ * pipeline's `defaults`. A wave job runs the same step in its own process
12
+ * once a wave applied, with the op-waves spec's `replanDependents` at base
13
+ * ({@link replanStep}, `../../op/op-waves-run.ts`). Absent, the dependents
14
+ * are listed and nothing is planned.
15
+ */
16
+ import type { CommandContext } from "../registry.js";
17
+ import type { BuildParamProvenance } from "../../provenance.js";
18
+ import { type ReplanResult } from "../../components/upstream-replan.js";
19
+ /** What {@link runReplan} is asked. */
20
+ export interface ReplanRequest {
21
+ cwd: string;
22
+ env: string;
23
+ /** The components that applied. */
24
+ components: string[];
25
+ /** The members whose dependents are planned. Default: the pipeline's, on the default branch. */
26
+ replanDependents?: string[];
27
+ gate?: string;
28
+ op?: string;
29
+ dryRun?: boolean;
30
+ buildParams?: BuildParamProvenance[];
31
+ sandbox?: boolean;
32
+ /** A name that is no component: refuse (the command), or leave it out with a warning (a wave's runs). */
33
+ unknown?: "refuse" | "skip";
34
+ }
35
+ /** Run the replan for `request`; a string is a refusal. */
36
+ export declare function runReplan(request: ReplanRequest): Promise<{
37
+ result: ReplanResult;
38
+ op: string;
39
+ } | string>;
40
+ /** The one line a run's outcome reads as in a wave job's log. */
41
+ export declare function replanLine(result: ReplanResult): string;
42
+ /**
43
+ * The replan step a wave job runs once a wave applied (#5345), in its own
44
+ * process: the wave's spec read at base named the members, and `components`
45
+ * are the runs it applied. Answers the log line. A run that names no
46
+ * component is left out.
47
+ */
48
+ export declare function replanStep(input: {
49
+ cwd: string;
50
+ env: string;
51
+ components: string[];
52
+ replanDependents?: string[];
53
+ }): Promise<string>;
54
+ export declare function runComponentsReplan(ctx: CommandContext): Promise<number>;
@@ -0,0 +1,177 @@
1
+ /**
2
+ * `chant components replan --env <env> --component <a,b>` (#5345): after
3
+ * those components applied in `<env>`, compare their outputs with the ones
4
+ * their last apply recorded, list the dependents that read a changed output,
5
+ * and plan the dependents of the members `replanDependents` names. The plan
6
+ * waits at `<gate>-replan` under `--op` (default `replan-<env>`); nothing
7
+ * applies here. See ../../components/upstream-replan.ts.
8
+ *
9
+ * `replanDependents` is read from the pipeline (`.chant/pipeline.ts`) as it
10
+ * stands on the default branch, the stage named `--env`, else the
11
+ * pipeline's `defaults`. A wave job runs the same step in its own process
12
+ * once a wave applied, with the op-waves spec's `replanDependents` at base
13
+ * ({@link replanStep}, `../../op/op-waves-run.ts`). Absent, the dependents
14
+ * are listed and nothing is planned.
15
+ */
16
+ import { resolve } from "node:path";
17
+ import { formatError, formatWarning } from "../format.js";
18
+ import { ENV_VAR } from "../../env.js";
19
+ import { loadChantConfig } from "../../config.js";
20
+ import { resolveCliBuildParams, parseParamFlags } from "../build-params-cli.js";
21
+ import { resolveComponentTargets } from "../../components/cli-support.js";
22
+ import { fanOutRegistry } from "../../components/fan-out-support.js";
23
+ import { withDeclaredReads } from "../../components/declared-reads.js";
24
+ import { gitOutputRecordPort, readMarkedOutputs, replanAfterApply, replanNote } from "../../components/upstream-replan.js";
25
+ import { PR_APPLY_GATE } from "../../pr-loop.js";
26
+ const USAGE = "chant components replan --env <env> --component <name>[,<name>...] [--gate <gate>] [--op <op>] [--dry-run] [--json]";
27
+ /** The members `replanDependents` names for stage `env`, from the pipeline on the default branch. */
28
+ async function replanDependentsAt(cwd, env) {
29
+ const { promoteBase, readPipelineAt } = await import("../../pipeline/read.js");
30
+ const { stageReplanDependents } = await import("../../pipeline/spec.js");
31
+ const base = promoteBase(cwd);
32
+ if (!base)
33
+ return [];
34
+ const read = readPipelineAt(base, cwd);
35
+ if (read.status === "refused")
36
+ console.error(formatWarning({ message: `${read.line}; no dependents are planned` }));
37
+ return read.status === "folded" ? stageReplanDependents(read.spec, env) : [];
38
+ }
39
+ /** Run the replan for `request`; a string is a refusal. */
40
+ export async function runReplan(request) {
41
+ const { cwd, env } = request;
42
+ const before = process.env[ENV_VAR];
43
+ process.env[ENV_VAR] = env;
44
+ try {
45
+ const { config } = await loadChantConfig(cwd).catch(() => ({ config: {} }));
46
+ const targets = await resolveComponentTargets(cwd, "all", request.sandbox, request.buildParams);
47
+ if (!targets.success)
48
+ return targets.error ?? "Could not discover components";
49
+ const registry = await fanOutRegistry(cwd, config);
50
+ const components = await withDeclaredReads(targets.targets, registry, cwd);
51
+ const byName = new Map(components.map((c) => [c.name, c]));
52
+ const unknown = request.components.filter((n) => !byName.has(n));
53
+ if (unknown.length > 0 && request.unknown !== "skip")
54
+ return `no component named ${unknown.join(", ")}`;
55
+ if (unknown.length > 0)
56
+ console.error(formatWarning({ message: `${unknown.join(", ")}: no component of that name, so no outputs to compare` }));
57
+ const { fetchLifecycle, getHeadCommit } = await import("../../lifecycle/git.js");
58
+ await fetchLifecycle({ cwd }).catch(() => false);
59
+ const applied = {};
60
+ const sensitive = {};
61
+ for (const name of request.components.filter((n) => byName.has(n))) {
62
+ const found = await readMarkedOutputs(byName.get(name), registry, { env, component: name });
63
+ if (!found) {
64
+ console.error(formatWarning({ message: `${name}: its steps say no outputs, so there is nothing to compare` }));
65
+ continue;
66
+ }
67
+ applied[name] = found.outputs;
68
+ if (found.sensitive.length > 0)
69
+ sensitive[name] = found.sensitive;
70
+ }
71
+ const gitSha = await getHeadCommit({ cwd }).catch(() => undefined);
72
+ const op = request.op ?? `replan-${env}`;
73
+ const { gitGateLedgerPort } = await import("../../op/gate.js");
74
+ const { decidePrGate, approvalOf } = await import("../../components/pr-run.js");
75
+ const result = await replanAfterApply({
76
+ components,
77
+ registry,
78
+ root: cwd,
79
+ env,
80
+ applied,
81
+ sensitive,
82
+ replanDependents: request.replanDependents ?? (await replanDependentsAt(cwd, env)),
83
+ records: gitOutputRecordPort({ cwd }),
84
+ gate: request.gate ?? PR_APPLY_GATE,
85
+ ...(gitSha ? { gitSha } : {}),
86
+ ...(request.dryRun ? { dryRun: true } : {}),
87
+ decide: async ({ gate, set, description }) => {
88
+ const { storeGateChangeSet } = await import("../../lifecycle/gate-change-set.js");
89
+ try {
90
+ const stored = await storeGateChangeSet({ doc: set.doc, cwd, ...(gitSha ? { at: gitSha } : {}) });
91
+ if (stored.warning)
92
+ console.error(formatWarning({ message: stored.warning }));
93
+ }
94
+ catch (err) {
95
+ console.error(formatWarning({ message: `could not store the change set ${set.doc.digest}: ${err instanceof Error ? err.message : String(err)}` }));
96
+ }
97
+ return approvalOf(await decidePrGate(gitGateLedgerPort({ cwd }), { op, gate, digest: set.doc.digest, description }));
98
+ },
99
+ });
100
+ if (!request.dryRun) {
101
+ const { pushLifecycleRebasing } = await import("../../lifecycle/git.js");
102
+ const pushed = await pushLifecycleRebasing({ cwd }).catch((err) => ({ pushed: false, pushWarning: err instanceof Error ? err.message : String(err) }));
103
+ if (!pushed.pushed && pushed.pushWarning)
104
+ console.error(formatWarning({ message: pushed.pushWarning }));
105
+ }
106
+ return { result, op };
107
+ }
108
+ finally {
109
+ if (before === undefined)
110
+ delete process.env[ENV_VAR];
111
+ else
112
+ process.env[ENV_VAR] = before;
113
+ }
114
+ }
115
+ /** The one line a run's outcome reads as in a wave job's log. */
116
+ export function replanLine(result) {
117
+ const moved = result.changes.filter((c) => c.dependents.length > 0);
118
+ if (moved.length === 0)
119
+ return "replan: no applied member changed an output another member reads";
120
+ const listed = moved.map((c) => `${c.member} (${c.changed.join(", ")}) read by ${c.dependents.map((d) => d.member).join(", ")}`).join("; ");
121
+ const p = result.planned;
122
+ return p ? `replan: ${listed}; plan ${p.digest} ${p.failed ? "failed to plan" : `waits at ${p.gate} (${p.approval.status})`}` : `replan: ${listed}; listed, none planned`;
123
+ }
124
+ /**
125
+ * The replan step a wave job runs once a wave applied (#5345), in its own
126
+ * process: the wave's spec read at base named the members, and `components`
127
+ * are the runs it applied. Answers the log line. A run that names no
128
+ * component is left out.
129
+ */
130
+ export async function replanStep(input) {
131
+ const ran = await runReplan({ ...input, unknown: "skip" });
132
+ if (typeof ran === "string")
133
+ return `replan: ${ran}`;
134
+ return replanLine(ran.result);
135
+ }
136
+ export async function runComponentsReplan(ctx) {
137
+ const { args } = ctx;
138
+ const env = args.env;
139
+ const named = (args.component ?? "").split(",").map((s) => s.trim()).filter((s) => s !== "");
140
+ if (!env || named.length === 0) {
141
+ console.error(formatError({ message: "--env and --component are required", hint: USAGE }));
142
+ return 1;
143
+ }
144
+ const root = resolve(".");
145
+ const { config } = await loadChantConfig(root).catch(() => ({ config: {} }));
146
+ const params = resolveCliBuildParams(config.buildParams, { cli: parseParamFlags(args.param), paramsFile: args.paramsFile, verbose: args.verbose });
147
+ if (!params.success) {
148
+ for (const message of params.errors)
149
+ console.error(message);
150
+ return 1;
151
+ }
152
+ let ran;
153
+ try {
154
+ ran = await runReplan({
155
+ cwd: root,
156
+ env,
157
+ components: named,
158
+ buildParams: params.provenance,
159
+ ...(args.sandbox ? { sandbox: true } : {}),
160
+ ...(args.gate ? { gate: args.gate } : {}),
161
+ ...(args.op ? { op: args.op } : {}),
162
+ ...(args.dryRun ? { dryRun: true } : {}),
163
+ });
164
+ }
165
+ catch (err) {
166
+ ran = err instanceof Error ? err.message : String(err);
167
+ }
168
+ if (typeof ran === "string") {
169
+ console.error(formatError({ message: ran, hint: USAGE }));
170
+ return 1;
171
+ }
172
+ if (args.json)
173
+ console.log(JSON.stringify({ ...ran.result, op: ran.op }, null, 2));
174
+ else
175
+ process.stdout.write(replanNote(ran.result, ran.op));
176
+ return ran.result.planned?.failed ? 1 : 0;
177
+ }
@@ -27,6 +27,11 @@ import type { CommandContext } from "../registry.js";
27
27
  /** Where each forge reads its pipeline files from, relative to the repository root. `--output` overrides it. */
28
28
  export declare const DEFAULT_OP_PIPELINE_DIRS: Record<string, string>;
29
29
  /** The first line of every file this command writes. */
30
+ /** The repository's `.gitlab-ci.yml`, from the git root above `dir`, or its path alone when it cannot be read. */
31
+ export declare function readProjectGitlabCi(dir: string): {
32
+ path: string;
33
+ text?: string;
34
+ };
30
35
  export declare function opPipelineHeader(provider: string, specFile?: string): string;
31
36
  interface SpecFile {
32
37
  ops: ScheduledOpSpec[];
@@ -22,6 +22,7 @@
22
22
  * finding mode, setup steps, or generator options. The file is passed to
23
23
  * the generator unchanged.
24
24
  */
25
+ import { execFileSync } from "node:child_process";
25
26
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
26
27
  import { dirname, join, resolve } from "node:path";
27
28
  import { discoverOps } from "../../op/discover.js";
@@ -29,7 +30,7 @@ import { generateOpsPipeline, generateOpWavesPipeline } from "../../op/generate-
29
30
  import { parseOpWavesSpec } from "../../op/op-waves-run.js";
30
31
  import { GENERATED_MARKER } from "../../discovery/files.js";
31
32
  import { findWorkspaceRoot } from "../../project-root.js";
32
- import { formatBold, formatError, formatSuccess } from "../format.js";
33
+ import { formatBold, formatError, formatSuccess, formatWarning } from "../format.js";
33
34
  /** Where each forge reads its pipeline files from, relative to the repository root. `--output` overrides it. */
34
35
  export const DEFAULT_OP_PIPELINE_DIRS = {
35
36
  github: ".github/workflows",
@@ -39,6 +40,23 @@ export const DEFAULT_OP_PIPELINE_DIRS = {
39
40
  prow: "prow",
40
41
  };
41
42
  /** The first line of every file this command writes. */
43
+ /** The repository's `.gitlab-ci.yml`, from the git root above `dir`, or its path alone when it cannot be read. */
44
+ export function readProjectGitlabCi(dir) {
45
+ let top = dir;
46
+ try {
47
+ top = execFileSync("git", ["rev-parse", "--show-toplevel"], { cwd: dir, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim() || dir;
48
+ }
49
+ catch {
50
+ // Not a git checkout: the directory itself.
51
+ }
52
+ const path = join(top, ".gitlab-ci.yml");
53
+ try {
54
+ return { path: ".gitlab-ci.yml", text: readFileSync(path, "utf8") };
55
+ }
56
+ catch {
57
+ return { path: ".gitlab-ci.yml" };
58
+ }
59
+ }
42
60
  export function opPipelineHeader(provider, specFile) {
43
61
  const command = `chant run --generate ${provider}${specFile ? ` --spec ${specFile}` : ""}`;
44
62
  return `# ${GENERATED_MARKER}. Regenerate with: ${command}\n`;
@@ -98,11 +116,14 @@ async function runOpWavesGenerate(ctx, provider, specPath) {
98
116
  console.error(formatError({ message: result.error ?? "Failed to generate the Op waves pipeline" }));
99
117
  return 1;
100
118
  }
119
+ // #5349: a count plain approval lines can meet is allowed, and said.
120
+ for (const w of result.warnings ?? [])
121
+ console.error(formatWarning({ file: specPath, message: w }));
101
122
  const header = opPipelineHeader(provider, specPath);
102
123
  const outDir = args.output ?? DEFAULT_OP_PIPELINE_DIRS[provider] ?? ".";
103
124
  const files = (result.files ?? []).map((f) => ({ name: f.name, path: join(outDir, f.name), content: header + f.yaml }));
104
125
  if (args.format === "json") {
105
- console.log(JSON.stringify({ files, jobs: result.jobs ?? [] }, null, 2));
126
+ console.log(JSON.stringify({ files, jobs: result.jobs ?? [], ...(result.warnings ? { warnings: result.warnings } : {}) }, null, 2));
106
127
  return 0;
107
128
  }
108
129
  for (const file of files) {
@@ -176,11 +197,17 @@ export async function runOpGenerate(ctx) {
176
197
  }
177
198
  options = { ...options, forgeRepo: resolved.repo };
178
199
  }
200
+ // #5329: an alert agent's pipeline on GitLab starts the project's own jobs too, so the generator reads .gitlab-ci.yml to name the unguarded ones.
201
+ if (provider === "gitlab" && ops.some((s) => s.agent?.on === "alert") && !options?.projectCi) {
202
+ options = { ...options, projectCi: readProjectGitlabCi(process.cwd()) };
203
+ }
179
204
  const result = await generateOpsPipeline(ops, provider, plan ? { ...options, member: plan.member } : options);
180
205
  if (!result.success) {
181
206
  console.error(formatError({ message: result.error ?? "Failed to generate Op pipelines" }));
182
207
  return 1;
183
208
  }
209
+ for (const w of result.warnings ?? [])
210
+ console.error(formatWarning({ message: w }));
184
211
  if (plan && memberPipeline) {
185
212
  const header = memberPipeline.generatedHeader(plan.command);
186
213
  if (args.format === "json") {
@@ -189,7 +216,7 @@ export async function runOpGenerate(ctx) {
189
216
  path: memberPipeline.repoRelative(plan.ctx, join(plan.outDir, f.name)),
190
217
  content: header + f.yaml,
191
218
  }));
192
- console.log(JSON.stringify({ member: plan.member.name, files, jobs: result.jobs ?? [] }, null, 2));
219
+ console.log(JSON.stringify({ member: plan.member.name, files, jobs: result.jobs ?? [], ...(result.warnings ? { warnings: result.warnings } : {}) }, null, 2));
193
220
  return 0;
194
221
  }
195
222
  for (const path of memberPipeline.writeMemberOpPipelines(plan, result.files ?? [])) {
@@ -205,7 +232,7 @@ export async function runOpGenerate(ctx) {
205
232
  content: header + f.yaml,
206
233
  }));
207
234
  if (args.format === "json") {
208
- console.log(JSON.stringify({ files, jobs: result.jobs ?? [] }, null, 2));
235
+ console.log(JSON.stringify({ files, jobs: result.jobs ?? [], ...(result.warnings ? { warnings: result.warnings } : {}) }, null, 2));
209
236
  return 0;
210
237
  }
211
238
  for (const file of files) {