@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
@@ -85,10 +85,26 @@ const SHA = /^[0-9a-f]{40,64}$/;
85
85
  * read and the risk it named. A gate policy reads it back with
86
86
  * {@link parseReviewResult}, and counts it only for the head it is applying.
87
87
  */
88
- export function reviewResultMarker(head, risk) {
89
- return `${RESULT_PREFIX}${JSON.stringify({ head, risk })} -->`;
88
+ export function reviewResultMarker(head, risk, answers) {
89
+ return `${RESULT_PREFIX}${JSON.stringify({ head, risk, ...(answers && Object.keys(answers).length > 0 ? { answers } : {}) })} -->`;
90
90
  }
91
- /** The head and risk a review note's first result line holds, or undefined when it has none. */
91
+ const ANSWER_ID = /^[a-z0-9][a-z0-9_-]{0,63}$/;
92
+ /** Answers read back as untrusted data: each id and value checked, anything else dropped. */
93
+ export function readReviewAnswers(value) {
94
+ if (value === null || typeof value !== "object" || Array.isArray(value))
95
+ return undefined;
96
+ const out = {};
97
+ for (const [id, v] of Object.entries(value)) {
98
+ if (!ANSWER_ID.test(id))
99
+ continue;
100
+ if (v === "unknown")
101
+ out[id] = "unknown";
102
+ else if (typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 1)
103
+ out[id] = v;
104
+ }
105
+ return Object.keys(out).length > 0 ? out : undefined;
106
+ }
107
+ /** The head, risk and answers a review note's first result line holds, or undefined when it has none. */
92
108
  export function parseReviewResult(body) {
93
109
  const m = /^<!-- chant-review-result (\{[^\n]*?\}) -->$/m.exec(body);
94
110
  if (!m)
@@ -98,12 +114,41 @@ export function parseReviewResult(body) {
98
114
  if (typeof v.head !== "string" || !SHA.test(v.head))
99
115
  return undefined;
100
116
  const risk = REVIEW_RISKS.includes(v.risk) ? v.risk : "unknown";
101
- return { head: v.head, risk };
117
+ const answers = readReviewAnswers(v.answers);
118
+ return { head: v.head, risk, ...(answers ? { answers } : {}) };
102
119
  }
103
120
  catch {
104
121
  return undefined;
105
122
  }
106
123
  }
124
+ /** Why every answer is `unknown` when the change set did not fit the prompt. */
125
+ export const REVIEW_TOO_LARGE = "the plan is larger than the review's prompt carries";
126
+ /** Whether a change set is cut in the prompt: too large for the model's context, so no answer about it stands. */
127
+ export function changeSetTooLarge(doc) {
128
+ return changeSetText(doc).length > MAX_CHANGES;
129
+ }
130
+ /**
131
+ * The review's answers to `questions`: each `answer <id>: <0 to 1>` line the
132
+ * review ends with, the last one for an id winning. A question with no such
133
+ * line is `unknown`, and with `tooLarge` every one is.
134
+ */
135
+ export function answersOf(review, questions, tooLarge = false) {
136
+ const out = {};
137
+ for (const q of questions)
138
+ out[q.id] = "unknown";
139
+ if (tooLarge)
140
+ return out;
141
+ const ids = new Set(questions.map((q) => q.id));
142
+ for (const line of review.split(/\r?\n/)) {
143
+ const m = /^[\s>*_`-]*answer\s+([a-z0-9][a-z0-9_-]{0,63})\s*:\s*[*_`]*\s*([01](?:\.\d+)?)\b/i.exec(line);
144
+ if (!m || !ids.has(m[1].toLowerCase()))
145
+ continue;
146
+ const n = Number(m[2]);
147
+ if (Number.isFinite(n) && n >= 0 && n <= 1)
148
+ out[m[1].toLowerCase()] = n;
149
+ }
150
+ return out;
151
+ }
107
152
  /** The prefix every Op's review note starts with, for a reader that does not know the Op. */
108
153
  export const REVIEW_MARKER_PREFIX = "<!-- chant-review:";
109
154
  /**
@@ -180,6 +225,14 @@ export function reviewPrompt(p) {
180
225
  "",
181
226
  `<change_set digest="${p.changeSet.digest}">\n${quoted(cut(changeSetText(p.changeSet), MAX_CHANGES, "change set"))}\n</change_set>`,
182
227
  "",
228
+ ...(p.questions && p.questions.length > 0
229
+ ? [
230
+ "After the risk line, answer each question below on a line of its own, exactly `answer <id>: <number>`, where the number runs from 0 (the change set gives no reason for concern) to 1 (it gives every reason). The questions come from the base branch.",
231
+ "",
232
+ ...p.questions.map((q) => `- ${q.id}: ${quoted(q.text.replace(/\s+/g, " ").trim())}`),
233
+ "",
234
+ ]
235
+ : []),
183
236
  ].join("\n");
184
237
  }
185
238
  /** The risk the review's last `risk:` line names, or unknown. */
@@ -198,16 +251,21 @@ const shortDigest = (d) => d.replace(/^(jcs1-)?sha256:/, "").slice(0, 12);
198
251
  export function reviewNoteBody(o) {
199
252
  const ok = o.exitCode === 0;
200
253
  const risk = ok ? riskOf(o.review) : "unknown";
254
+ // #5325: a failed command answers nothing.
255
+ const answers = o.answers && !ok ? Object.fromEntries(Object.keys(o.answers).map((id) => [id, "unknown"])) : o.answers;
201
256
  const text = cut(o.review.replace(/<!--/g, "&lt;!--").trim(), MAX_REVIEW, "review");
202
257
  const lines = [
203
258
  // Ours, and first: the review's own `<!--` is escaped below, so no later marker of this kind is the model's.
204
- ...(o.head !== undefined ? [reviewResultMarker(o.head, risk), ""] : []),
259
+ ...(o.head !== undefined ? [reviewResultMarker(o.head, risk, answers), ""] : []),
205
260
  `### Review of change set \`${shortDigest(o.digest)}\``,
206
261
  "",
207
262
  `Risk: **${risk}**. A model compared the title and description with the change set. This note approves nothing and gates nothing.`,
208
263
  ];
209
264
  if (o.instructions === "none")
210
265
  lines.push("", "> The base branch has no review instructions, so the model had only chant's.");
266
+ if (answers && Object.keys(answers).length > 0) {
267
+ lines.push("", `Answers: ${Object.entries(answers).map(([id, a]) => `${id} ${a}`).join(", ")}.`);
268
+ }
211
269
  lines.push("");
212
270
  if (!ok)
213
271
  lines.push(`The review command stopped with ${o.exitCode === null ? "no exit code" : `exit code ${o.exitCode}`}; the job's log has its output.`, "");
@@ -294,6 +352,23 @@ export const gitDiffIn = (cwd) => async (base, signal) => {
294
352
  };
295
353
  /** {@link gitDiffIn} the process's working directory. */
296
354
  export const gitDiffAtBase = gitDiffIn();
355
+ /** `ci.risk.questions` of the declaration a `show` reads at `base`, or none (#5325). */
356
+ async function questionsAtBase(show, base, signal) {
357
+ const text = await show(base, "chant.workspace.json", signal);
358
+ if (text === undefined)
359
+ return [];
360
+ try {
361
+ const raw = JSON.parse(text).ci?.risk?.questions;
362
+ if (!Array.isArray(raw))
363
+ return [];
364
+ return raw
365
+ .filter((q) => q !== null && typeof q === "object" && typeof q.id === "string" && ANSWER_ID.test(q.id) && typeof q.text === "string")
366
+ .map((q) => ({ id: q.id, text: q.text }));
367
+ }
368
+ catch {
369
+ return [];
370
+ }
371
+ }
297
372
  /** The event payload `GITHUB_EVENT_PATH` names, or undefined when there is none or it does not parse. */
298
373
  function eventFrom(env, read) {
299
374
  return async () => {
@@ -348,17 +423,22 @@ export function createReviewAgent(deps = {}) {
348
423
  const diff = await readDiff(base, signal);
349
424
  const title = args.title ?? fromEvent?.title ?? "";
350
425
  const description = args.description ?? fromEvent?.description ?? "";
426
+ const questions = args.questions ?? (await questionsAtBase(show, base, signal));
351
427
  const prompt = reviewPrompt({
352
428
  title,
353
429
  description,
354
430
  changeSet: doc,
431
+ ...(questions.length > 0 ? { questions } : {}),
355
432
  ...(diff !== undefined ? { diff } : {}),
356
433
  ...(instructions !== undefined ? { instructions } : {}),
357
434
  instructionsPath: path,
358
435
  base,
359
436
  });
360
437
  const outcome = await run(args.command ?? REVIEW_COMMAND, prompt, reviewCommandEnv(env, args.keyEnv ?? REVIEW_KEY_ENV), (args.timeout ?? 10) * 60000, signal);
438
+ // #5325: a plan the prompt cut answers every question unknown.
439
+ const answers = questions.length > 0 ? answersOf(outcome.exitCode === 0 ? outcome.stdout : "", questions, changeSetTooLarge(doc)) : undefined;
361
440
  const summary = reviewNoteBody({
441
+ ...(answers ? { answers } : {}),
362
442
  review: outcome.stdout,
363
443
  exitCode: outcome.exitCode,
364
444
  digest: doc.digest ?? "",
@@ -370,6 +450,7 @@ export function createReviewAgent(deps = {}) {
370
450
  risk: outcome.exitCode === 0 ? riskOf(outcome.stdout) : "unknown",
371
451
  exitCode: outcome.exitCode,
372
452
  summary,
453
+ ...(answers ? { answers } : {}),
373
454
  };
374
455
  if (mode === "report")
375
456
  return result;
@@ -383,6 +464,7 @@ export function createReviewAgent(deps = {}) {
383
464
  exitCode: outcome.exitCode,
384
465
  digest: doc.digest ?? "",
385
466
  instructions: instructions !== undefined ? "base" : "none",
467
+ ...(answers ? { answers } : {}),
386
468
  };
387
469
  await write(recordFile, `${JSON.stringify(record)}\n`);
388
470
  return { ...result, recordFile };
@@ -422,6 +504,7 @@ export function readReviewRecord(text) {
422
504
  exitCode,
423
505
  digest,
424
506
  instructions: r.instructions === "base" ? "base" : "none",
507
+ ...(readReviewAnswers(r.answers) ? { answers: readReviewAnswers(r.answers) } : {}),
425
508
  };
426
509
  }
427
510
  /**
@@ -0,0 +1,88 @@
1
+ /**
2
+ * An agent's Cedar permit on an `enforce` gate (#5388).
3
+ *
4
+ * An agent's permit passes an Op gate with no person approving only when the
5
+ * gate's `identity.gates.<gate>` entry at base sets `agentPassesAlone: true`.
6
+ * Without it, the permit passes the gate beside a person's approval of the
7
+ * same plan ({@link tallyGateApprovals} in `./gate.ts`). A pipeline stage
8
+ * passes through its own gates, `<stage>`, `<stage>-skip`, `<stage>-urgent`,
9
+ * `<stage>-rollback` and `<stage>-soak`, and `chant build` refuses the key on
10
+ * an entry naming one of them, so a stage never passes on an agent alone.
11
+ *
12
+ * `chant build` reads the declaration and the member's built Ops through
13
+ * {@link agentPermitBuildFindings}: a warning for each entry that sets the
14
+ * key, a warning naming the key for each enforced gate whose policy permits an
15
+ * agent and whose entry does not set it, and a refusal for a stage gate's
16
+ * entry that sets it.
17
+ */
18
+ /**
19
+ * The first chant whose agent permit passes an `enforce` Op gate alone only
20
+ * under `identity.gates.<gate>.agentPassesAlone` (#5388), and otherwise only
21
+ * beside a person's approval of the same plan; `chant build` warns while the
22
+ * key is set, names it for each enforced gate whose policy permits an agent,
23
+ * and refuses it on a pipeline stage's promote, skip, urgent, rollback or
24
+ * soak gate.
25
+ */
26
+ export declare const AGENT_PASSES_ALONE_FLOOR = "0.124.110";
27
+ /** The gates a stage passes through, by name, each with the kind of gate it is. */
28
+ export declare function stageGateNames(stages: readonly {
29
+ name: string;
30
+ }[]): Map<string, string>;
31
+ /** An `identity.gates` entry, as far as this module reads it. */
32
+ export interface AgentPermitGateEntry {
33
+ policy?: {
34
+ text?: unknown;
35
+ } | null;
36
+ mode?: unknown;
37
+ agentPassesAlone?: boolean | null;
38
+ }
39
+ /** A gate of a built Op (`dist/ops/<name>/op.json`), as far as this module reads it. */
40
+ export interface AgentPermitOpGate {
41
+ op: string;
42
+ gate: string;
43
+ approval: {
44
+ policy?: {
45
+ text?: unknown;
46
+ } | null;
47
+ mode?: unknown;
48
+ risk?: unknown;
49
+ context?: Record<string, unknown> | null;
50
+ };
51
+ }
52
+ interface StepJson {
53
+ kind?: string;
54
+ gate?: string;
55
+ signalName?: string;
56
+ approval?: AgentPermitOpGate["approval"];
57
+ steps?: StepJson[];
58
+ }
59
+ /** The gates with an `approval` block in a built Op. */
60
+ export declare function opGatesWithApproval(op: {
61
+ name?: string;
62
+ phases?: {
63
+ steps?: StepJson[];
64
+ }[];
65
+ onFailure?: {
66
+ steps?: StepJson[];
67
+ }[];
68
+ }, fallbackName?: string): AgentPermitOpGate[];
69
+ /** What {@link agentPermitBuildFindings} found: warnings to print, and refusals that fail the build. */
70
+ export interface AgentPermitFindings {
71
+ warnings: string[];
72
+ refusals: string[];
73
+ }
74
+ /**
75
+ * The build's findings for `agentPassesAlone` (#5388). `gates` is the
76
+ * declaration's `identity.gates`, `ops` the member's built Op gates, and
77
+ * `stages` the member's pipeline stages, empty without a pipeline. With
78
+ * `ops`, an entry that sets the key is warned about when one of those Ops
79
+ * uses its gate; without, every such entry is.
80
+ */
81
+ export declare function agentPermitBuildFindings(input: {
82
+ gates: Readonly<Record<string, AgentPermitGateEntry>>;
83
+ ops?: readonly AgentPermitOpGate[];
84
+ stages?: readonly {
85
+ name: string;
86
+ }[];
87
+ }): AgentPermitFindings;
88
+ export {};
@@ -0,0 +1,97 @@
1
+ /**
2
+ * An agent's Cedar permit on an `enforce` gate (#5388).
3
+ *
4
+ * An agent's permit passes an Op gate with no person approving only when the
5
+ * gate's `identity.gates.<gate>` entry at base sets `agentPassesAlone: true`.
6
+ * Without it, the permit passes the gate beside a person's approval of the
7
+ * same plan ({@link tallyGateApprovals} in `./gate.ts`). A pipeline stage
8
+ * passes through its own gates, `<stage>`, `<stage>-skip`, `<stage>-urgent`,
9
+ * `<stage>-rollback` and `<stage>-soak`, and `chant build` refuses the key on
10
+ * an entry naming one of them, so a stage never passes on an agent alone.
11
+ *
12
+ * `chant build` reads the declaration and the member's built Ops through
13
+ * {@link agentPermitBuildFindings}: a warning for each entry that sets the
14
+ * key, a warning naming the key for each enforced gate whose policy permits an
15
+ * agent and whose entry does not set it, and a refusal for a stage gate's
16
+ * entry that sets it.
17
+ */
18
+ import { AGENT_PASSES_ALONE_KEY } from "./gate-approval-base.js";
19
+ import { CHANGE_RISK_CONTEXT_KEY } from "../change-risk.js";
20
+ /**
21
+ * The first chant whose agent permit passes an `enforce` Op gate alone only
22
+ * under `identity.gates.<gate>.agentPassesAlone` (#5388), and otherwise only
23
+ * beside a person's approval of the same plan; `chant build` warns while the
24
+ * key is set, names it for each enforced gate whose policy permits an agent,
25
+ * and refuses it on a pipeline stage's promote, skip, urgent, rollback or
26
+ * soak gate.
27
+ */
28
+ export const AGENT_PASSES_ALONE_FLOOR = "0.124.110";
29
+ /** The Cedar entity type of an agent principal, as the cedar lexicon's `GATE_AGENT_TYPE` spells it. */
30
+ const AGENT_PRINCIPAL = "Chant::Agent";
31
+ /** The gates a stage passes through, by name, each with the kind of gate it is. */
32
+ export function stageGateNames(stages) {
33
+ const out = new Map();
34
+ for (const { name } of stages) {
35
+ out.set(name, `stage ${name}'s promote gate`);
36
+ out.set(`${name}-skip`, `stage ${name}'s skip gate`);
37
+ out.set(`${name}-urgent`, `stage ${name}'s urgent gate`);
38
+ out.set(`${name}-rollback`, `stage ${name}'s rollback gate`);
39
+ out.set(`${name}-soak`, `stage ${name}'s soak gate`);
40
+ }
41
+ return out;
42
+ }
43
+ /** The gates with an `approval` block in a built Op. */
44
+ export function opGatesWithApproval(op, fallbackName = "") {
45
+ const out = [];
46
+ const visit = (step) => {
47
+ if (step.kind === "gate" && step.approval && typeof step.approval === "object") {
48
+ out.push({ op: op.name ?? fallbackName, gate: step.gate ?? step.signalName ?? "", approval: step.approval });
49
+ }
50
+ if (step.kind === "effect")
51
+ (step.steps ?? []).forEach(visit);
52
+ };
53
+ for (const p of [...(op.phases ?? []), ...(op.onFailure ?? [])])
54
+ (p.steps ?? []).forEach(visit);
55
+ return out;
56
+ }
57
+ /**
58
+ * The build's findings for `agentPassesAlone` (#5388). `gates` is the
59
+ * declaration's `identity.gates`, `ops` the member's built Op gates, and
60
+ * `stages` the member's pipeline stages, empty without a pipeline. With
61
+ * `ops`, an entry that sets the key is warned about when one of those Ops
62
+ * uses its gate; without, every such entry is.
63
+ */
64
+ export function agentPermitBuildFindings(input) {
65
+ const warnings = [];
66
+ const refusals = [];
67
+ const stageGates = stageGateNames(input.stages ?? []);
68
+ // With the member's Ops given, warn for the gates they use; without, for every entry.
69
+ const used = input.ops ? new Set(input.ops.map((o) => o.gate)) : undefined;
70
+ for (const [gate, entry] of Object.entries(input.gates)) {
71
+ if (entry.agentPassesAlone !== true)
72
+ continue;
73
+ const stage = stageGates.get(gate);
74
+ if (stage) {
75
+ refusals.push(`identity.gates.${gate}.${AGENT_PASSES_ALONE_KEY} is set, and ${gate} is ${stage}: a stage gate passes on a person's approval, so remove the key from this entry`);
76
+ }
77
+ else if (!used || used.has(gate)) {
78
+ warnings.push(`identity.gates.${gate}.${AGENT_PASSES_ALONE_KEY} is true: an agent's policy permit passes gate ${gate} in enforce mode with no person approving`);
79
+ }
80
+ }
81
+ for (const use of input.ops ?? []) {
82
+ const entry = input.gates[use.gate];
83
+ if (entry?.agentPassesAlone === true || stageGates.has(use.gate))
84
+ continue;
85
+ const mode = entry?.mode ?? use.approval.mode;
86
+ const policy = entry?.policy ?? use.approval.policy;
87
+ const text = typeof policy?.text === "string" ? policy.text : "";
88
+ if (mode !== "enforce" || !text.includes(AGENT_PRINCIPAL))
89
+ continue;
90
+ // #5325: a permit that reads the change risk never counts from an agent, key or not.
91
+ if (use.approval.risk !== undefined || text.includes(CHANGE_RISK_CONTEXT_KEY) || (use.approval.context && CHANGE_RISK_CONTEXT_KEY in use.approval.context))
92
+ continue;
93
+ warnings.push(`gate ${use.gate} in Op ${use.op} enforces a policy that permits ${AGENT_PRINCIPAL}, and an agent's permit now passes it only beside a person's approval; ` +
94
+ `to let the agent pass it alone, set "${AGENT_PASSES_ALONE_KEY}": true in identity.gates.${use.gate} in chant.workspace.json`);
95
+ }
96
+ return { warnings, refusals };
97
+ }
@@ -7,6 +7,13 @@
7
7
  */
8
8
  import type { GateApprovalMode, GatePolicyRef } from "./gate-approval.js";
9
9
  export declare const GATE_APPROVAL_MODES: readonly GateApprovalMode[];
10
+ /**
11
+ * The `identity.gates.<gate>` key (#5388) that lets an agent's Cedar permit
12
+ * pass the gate in `enforce` with no person approving. Without it, an agent's
13
+ * permit passes a gate only beside a person's approval. A pipeline stage gate
14
+ * refuses it at build.
15
+ */
16
+ export declare const AGENT_PASSES_ALONE_KEY = "agentPassesAlone";
10
17
  /** The version of a gate policy: `sha256:` and the hex digest of its text. A lexicon's helper stamps it, and OPS015 checks it still matches. */
11
18
  export declare function gatePolicyVersion(text: string): string;
12
19
  export declare function isGatePolicyRef(value: unknown): value is GatePolicyRef;
@@ -20,5 +27,6 @@ export declare function gateBaseApprovalProblems(entry: {
20
27
  policy?: unknown;
21
28
  mode?: unknown;
22
29
  context?: unknown;
30
+ agentPassesAlone?: unknown;
23
31
  }, at: string): string[];
24
32
  export declare function isContextValue(value: unknown): boolean;
@@ -8,6 +8,13 @@
8
8
  import { createHash } from "node:crypto";
9
9
  import { GATE_PLAN_CONTEXT_KEY } from "./gate-plan-context.js";
10
10
  export const GATE_APPROVAL_MODES = ["log-only", "enforce"];
11
+ /**
12
+ * The `identity.gates.<gate>` key (#5388) that lets an agent's Cedar permit
13
+ * pass the gate in `enforce` with no person approving. Without it, an agent's
14
+ * permit passes a gate only beside a person's approval. A pipeline stage gate
15
+ * refuses it at build.
16
+ */
17
+ export const AGENT_PASSES_ALONE_KEY = "agentPassesAlone";
11
18
  // The brand `stepOutput()` stamps (`step-output-ref.ts`), as a global symbol so
12
19
  // this module need not import that file and its zod schemas; the same copy
13
20
  // `activity-contract.ts` keeps for the same reason.
@@ -37,6 +44,8 @@ export function isGatePolicyRef(value) {
37
44
  */
38
45
  export function gateBaseApprovalProblems(entry, at) {
39
46
  const problems = [];
47
+ if (entry.agentPassesAlone !== undefined && typeof entry.agentPassesAlone !== "boolean")
48
+ problems.push(`\`${at}.${AGENT_PASSES_ALONE_KEY}\` must be true or false`);
40
49
  if (entry.policy !== undefined) {
41
50
  if (!isGatePolicyRef(entry.policy))
42
51
  problems.push(`\`${at}.policy\` does not resolve to a gate policy set: it needs kind "gate-policy", lexicon, name, version and text`);
@@ -39,8 +39,9 @@
39
39
  * policy's request carries those same roles, never the claimed ones.
40
40
  */
41
41
  import { type StepOutputRef } from "./step-output-ref.js";
42
- export { GATE_APPROVAL_MODES, gateBaseApprovalProblems, gatePolicyVersion, isGatePolicyRef } from "./gate-approval-base.js";
42
+ export { AGENT_PASSES_ALONE_KEY, GATE_APPROVAL_MODES, gateBaseApprovalProblems, gatePolicyVersion, isGatePolicyRef } from "./gate-approval-base.js";
43
43
  import { type GateQuorumRule, type GateQuorumSpec } from "./gate-quorum.js";
44
+ import { type ChangeRiskSettings } from "../change-risk.js";
44
45
  export type { GateQuorumRule, GateQuorumSpec } from "./gate-quorum.js";
45
46
  /** What a policy's decision does to the gate. */
46
47
  export type GateApprovalMode = "log-only" | "enforce";
@@ -83,6 +84,15 @@ export interface GateApproval {
83
84
  * puts that change set's `GatePlanSummary` there on its own.
84
85
  */
85
86
  context?: Record<string, GateContextValue>;
87
+ /**
88
+ * The change risk (#5325): when the gate's `plan` names the step that
89
+ * planned it, the run scores that change set (`../change-risk.ts`) and puts
90
+ * the record under `context.changeRisk` for the policy. A gate that sets
91
+ * it counts a policy's permit only from a human whose approval
92
+ * `.chant/trust.json` at base proves; an agent's permit counts for nothing.
93
+ * Over `approveAbove`, the gate takes `quorum`'s rules on top of its own.
94
+ */
95
+ risk?: Omit<ChangeRiskSettings, "questions">;
86
96
  }
87
97
  /**
88
98
  * {@link GateApproval} as a run resolved it: context references replaced with
@@ -96,7 +106,24 @@ export interface ResolvedGateApproval {
96
106
  policy?: GatePolicyRef;
97
107
  mode: GateApprovalMode;
98
108
  context?: Record<string, unknown>;
109
+ /** `approval.risk` (#5325): a permit then counts only from a proven human. */
110
+ risk?: Omit<ChangeRiskSettings, "questions">;
111
+ /**
112
+ * `identity.gates.<gate>.agentPassesAlone` at base (#5388): an agent's
113
+ * permit passes the gate in `enforce` with no person approving. Absent, an
114
+ * agent's permit passes it only beside a person's approval. Only the entry
115
+ * at base sets it; the Op's own `approval` block cannot.
116
+ */
117
+ agentPassesAlone?: true;
99
118
  }
119
+ /**
120
+ * Whether a gate's permit reads the change risk (#5325): the gate declares
121
+ * `approval.risk`, its resolved context carries `changeRisk`, or its policy
122
+ * names `changeRisk`. Such a permit passes the gate only from a human
123
+ * principal `.chant/trust.json` at base proves, never from an agent, so a
124
+ * score never lets a plan through with no person approving it.
125
+ */
126
+ export declare function gatePermitReadsRisk(approval: Pick<ResolvedGateApproval, "risk" | "context" | "policy">): boolean;
100
127
  /** Who recorded an approval. Absent on every resolution written before #2508, which reads as a human with no roles. */
101
128
  export interface GateApprover {
102
129
  kind: "human" | "agent";
@@ -165,6 +192,8 @@ export interface GateBaseApproval {
165
192
  policy?: GatePolicyRef | null;
166
193
  mode?: GateApprovalMode | null;
167
194
  context?: Record<string, string | number | boolean | string[]> | null;
195
+ /** `identity.gates.<gate>.agentPassesAlone` (#5388): an agent's permit passes the gate in `enforce` with no person approving. */
196
+ agentPassesAlone?: boolean | null;
168
197
  }
169
198
  /** Import `lexicon`'s evaluator. Throws a message that names the package when it is not installed or exports none. */
170
199
  export declare function loadGatePolicyEvaluator(lexicon: string): Promise<GatePolicyEvaluator>;
@@ -41,9 +41,20 @@
41
41
  import { createHash } from "node:crypto";
42
42
  import { lexiconModulePath, importLexiconPackage } from "../lexicon-module.js";
43
43
  import { GATE_PLAN_CONTEXT_KEY } from "./gate-plan-context.js";
44
- import { GATE_APPROVAL_MODES, gatePolicyVersion, isContextValue, isGatePolicyRef } from "./gate-approval-base.js";
45
- export { GATE_APPROVAL_MODES, gateBaseApprovalProblems, gatePolicyVersion, isGatePolicyRef } from "./gate-approval-base.js";
44
+ import { AGENT_PASSES_ALONE_KEY, GATE_APPROVAL_MODES, gatePolicyVersion, isContextValue, isGatePolicyRef } from "./gate-approval-base.js";
45
+ export { AGENT_PASSES_ALONE_KEY, GATE_APPROVAL_MODES, gateBaseApprovalProblems, gatePolicyVersion, isGatePolicyRef } from "./gate-approval-base.js";
46
46
  import { quorumProblems } from "./gate-quorum.js";
47
+ import { CHANGE_RISK_CONTEXT_KEY, changeRiskProblems } from "../change-risk.js";
48
+ /**
49
+ * Whether a gate's permit reads the change risk (#5325): the gate declares
50
+ * `approval.risk`, its resolved context carries `changeRisk`, or its policy
51
+ * names `changeRisk`. Such a permit passes the gate only from a human
52
+ * principal `.chant/trust.json` at base proves, never from an agent, so a
53
+ * score never lets a plan through with no person approving it.
54
+ */
55
+ export function gatePermitReadsRisk(approval) {
56
+ return approval.risk !== undefined || approval.context?.[CHANGE_RISK_CONTEXT_KEY] !== undefined || (approval.policy?.text.includes(CHANGE_RISK_CONTEXT_KEY) ?? false);
57
+ }
47
58
  /**
48
59
  * The digest of a gate's resolved approval context (#3774): `sha256:` and the
49
60
  * hex digest of its JSON with keys sorted at every level. No context and an
@@ -91,6 +102,12 @@ export function gateApprovalProblems(approval) {
91
102
  if (a.mode === "enforce" && a.policy === undefined) {
92
103
  problems.push("`approval.mode: \"enforce\"` needs an `approval.policy` to enforce");
93
104
  }
105
+ if (a[AGENT_PASSES_ALONE_KEY] !== undefined) {
106
+ problems.push(`\`approval.${AGENT_PASSES_ALONE_KEY}\` is read only at base: set \`identity.gates.<gate>.${AGENT_PASSES_ALONE_KEY}\` in chant.workspace.json (#5388)`);
107
+ }
108
+ if (a.risk !== undefined) {
109
+ problems.push(...changeRiskProblems("approval.risk", a.risk, { quorum: true, questions: false }, (rules, at) => quorumProblems(rules, at, { notAuthor: false })));
110
+ }
94
111
  if (a.context !== undefined) {
95
112
  if (typeof a.context !== "object" || a.context === null || Array.isArray(a.context)) {
96
113
  problems.push("`approval.context` must be an object of plan attributes");
@@ -100,6 +117,10 @@ export function gateApprovalProblems(approval) {
100
117
  }
101
118
  else {
102
119
  for (const [key, value] of Object.entries(a.context)) {
120
+ if (key === CHANGE_RISK_CONTEXT_KEY) {
121
+ problems.push(`\`approval.context.${key}\` is reserved: the run fills it with the change risk (#5325) when the gate sets \`approval.risk\``);
122
+ continue;
123
+ }
103
124
  if (key === GATE_PLAN_CONTEXT_KEY) {
104
125
  problems.push(`\`approval.context.${key}\` is reserved: the run fills it with the plan's change-set summary (#3182) ` +
105
126
  "when the gate's `plan` names the step that planned it");