@intentius/chant 0.124.40 → 0.124.42

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 (346) hide show
  1. package/dist/__fixtures__/oidc-emulator.d.ts +49 -0
  2. package/dist/__fixtures__/oidc-emulator.d.ts.map +1 -0
  3. package/dist/__fixtures__/oidc-emulator.js +89 -0
  4. package/dist/ci-handover.d.ts +117 -0
  5. package/dist/ci-handover.d.ts.map +1 -0
  6. package/dist/ci-handover.js +217 -0
  7. package/dist/ci-identity.d.ts +190 -0
  8. package/dist/ci-identity.d.ts.map +1 -0
  9. package/dist/ci-identity.js +219 -0
  10. package/dist/cli/handlers/approve.d.ts +2 -1
  11. package/dist/cli/handlers/approve.d.ts.map +1 -1
  12. package/dist/cli/handlers/approve.js +20 -6
  13. package/dist/cli/handlers/build.d.ts.map +1 -1
  14. package/dist/cli/handlers/build.js +18 -1
  15. package/dist/cli/handlers/fan-out.d.ts.map +1 -1
  16. package/dist/cli/handlers/fan-out.js +42 -5
  17. package/dist/cli/handlers/gate-resume.d.ts +3 -0
  18. package/dist/cli/handlers/gate-resume.d.ts.map +1 -1
  19. package/dist/cli/handlers/gate-resume.js +15 -2
  20. package/dist/cli/handlers/lock.d.ts +8 -0
  21. package/dist/cli/handlers/lock.d.ts.map +1 -0
  22. package/dist/cli/handlers/lock.js +197 -0
  23. package/dist/cli/handlers/pr-env.d.ts +34 -0
  24. package/dist/cli/handlers/pr-env.d.ts.map +1 -0
  25. package/dist/cli/handlers/pr-env.js +436 -0
  26. package/dist/cli/handlers/pr.d.ts +76 -0
  27. package/dist/cli/handlers/pr.d.ts.map +1 -1
  28. package/dist/cli/handlers/pr.js +615 -55
  29. package/dist/cli/handlers/promote.d.ts.map +1 -1
  30. package/dist/cli/handlers/promote.js +9 -0
  31. package/dist/cli/handlers/query.d.ts +6 -0
  32. package/dist/cli/handlers/query.d.ts.map +1 -0
  33. package/dist/cli/handlers/query.js +80 -0
  34. package/dist/cli/handlers/run.d.ts.map +1 -1
  35. package/dist/cli/handlers/run.js +11 -0
  36. package/dist/cli/main.d.ts.map +1 -1
  37. package/dist/cli/main.js +49 -4
  38. package/dist/cli/parse-args.d.ts.map +1 -1
  39. package/dist/cli/parse-args.js +46 -2
  40. package/dist/cli/registry.d.ts +31 -2
  41. package/dist/cli/registry.d.ts.map +1 -1
  42. package/dist/components/capability.d.ts +47 -0
  43. package/dist/components/capability.d.ts.map +1 -1
  44. package/dist/components/capability.js +44 -0
  45. package/dist/components/cli-support.d.ts +6 -0
  46. package/dist/components/cli-support.d.ts.map +1 -1
  47. package/dist/components/cli-support.js +8 -1
  48. package/dist/components/driver.d.ts +10 -0
  49. package/dist/components/driver.d.ts.map +1 -1
  50. package/dist/components/driver.js +52 -2
  51. package/dist/components/fan-out-run.d.ts +37 -0
  52. package/dist/components/fan-out-run.d.ts.map +1 -1
  53. package/dist/components/fan-out-run.js +44 -4
  54. package/dist/components/gate-plan.d.ts +2 -0
  55. package/dist/components/gate-plan.d.ts.map +1 -1
  56. package/dist/components/gate-plan.js +1 -0
  57. package/dist/components/pr-environment.d.ts +298 -0
  58. package/dist/components/pr-environment.d.ts.map +1 -0
  59. package/dist/components/pr-environment.js +406 -0
  60. package/dist/components/pr-hooks.d.ts +66 -0
  61. package/dist/components/pr-hooks.d.ts.map +1 -0
  62. package/dist/components/pr-hooks.js +119 -0
  63. package/dist/components/pr-pipeline.d.ts +92 -2
  64. package/dist/components/pr-pipeline.d.ts.map +1 -1
  65. package/dist/components/pr-pipeline.js +150 -21
  66. package/dist/components/pr-policy.d.ts +109 -0
  67. package/dist/components/pr-policy.d.ts.map +1 -0
  68. package/dist/components/pr-policy.js +150 -0
  69. package/dist/components/pr-run.d.ts +6 -0
  70. package/dist/components/pr-run.d.ts.map +1 -1
  71. package/dist/components/pr-run.js +8 -3
  72. package/dist/components/wave-plan.d.ts +14 -1
  73. package/dist/components/wave-plan.d.ts.map +1 -1
  74. package/dist/components/wave-plan.js +34 -2
  75. package/dist/gate-decision.d.ts +15 -2
  76. package/dist/gate-decision.d.ts.map +1 -1
  77. package/dist/gate-decision.js +17 -2
  78. package/dist/gate-policy.d.ts +140 -0
  79. package/dist/gate-policy.d.ts.map +1 -0
  80. package/dist/gate-policy.js +242 -0
  81. package/dist/lifecycle/gate-checkpoint.d.ts +1 -1
  82. package/dist/lifecycle/gate-checkpoint.js +1 -1
  83. package/dist/{workspace/trust → lifecycle}/gate-seal.d.ts +1 -1
  84. package/dist/lifecycle/gate-seal.d.ts.map +1 -0
  85. package/dist/lifecycle/query.d.ts +68 -0
  86. package/dist/lifecycle/query.d.ts.map +1 -0
  87. package/dist/lifecycle/query.js +246 -0
  88. package/dist/lifecycle/run-ledger.d.ts +13 -0
  89. package/dist/lifecycle/run-ledger.d.ts.map +1 -1
  90. package/dist/lifecycle/run-ledger.js +16 -0
  91. package/dist/lifecycle/target-lock.d.ts +97 -0
  92. package/dist/lifecycle/target-lock.d.ts.map +1 -0
  93. package/dist/lifecycle/target-lock.js +286 -0
  94. package/dist/op/activities/activity-contracts.d.ts +30 -0
  95. package/dist/op/activities/activity-contracts.d.ts.map +1 -1
  96. package/dist/op/activities/activity-contracts.js +26 -0
  97. package/dist/op/activities/index.d.ts +2 -0
  98. package/dist/op/activities/index.d.ts.map +1 -1
  99. package/dist/op/activities/index.js +4 -0
  100. package/dist/op/activities/pr-refs.d.ts +10 -0
  101. package/dist/op/activities/pr-refs.d.ts.map +1 -0
  102. package/dist/op/activities/pr-refs.js +26 -0
  103. package/dist/op/activities/predict-behaviour.d.ts +2 -4
  104. package/dist/op/activities/predict-behaviour.d.ts.map +1 -1
  105. package/dist/op/activities/predict-behaviour.js +2 -21
  106. package/dist/op/activities/review-agent.d.ts +137 -0
  107. package/dist/op/activities/review-agent.d.ts.map +1 -0
  108. package/dist/op/activities/review-agent.js +266 -0
  109. package/dist/op/builders.d.ts +9 -0
  110. package/dist/op/builders.d.ts.map +1 -1
  111. package/dist/op/builders.js +11 -0
  112. package/dist/op/cron.d.ts +8 -0
  113. package/dist/op/cron.d.ts.map +1 -1
  114. package/dist/op/cron.js +51 -0
  115. package/dist/op/gate-approval.d.ts +20 -13
  116. package/dist/op/gate-approval.d.ts.map +1 -1
  117. package/dist/op/gate-approval.js +13 -18
  118. package/dist/op/gate-quorum.d.ts +131 -0
  119. package/dist/op/gate-quorum.d.ts.map +1 -0
  120. package/dist/op/gate-quorum.js +183 -0
  121. package/dist/op/gate-resume.d.ts +4 -2
  122. package/dist/op/gate-resume.d.ts.map +1 -1
  123. package/dist/op/gate-resume.js +5 -4
  124. package/dist/op/gate-review.js +1 -1
  125. package/dist/op/gate.d.ts +32 -4
  126. package/dist/op/gate.d.ts.map +1 -1
  127. package/dist/op/gate.js +40 -24
  128. package/dist/op/index.d.ts +6 -4
  129. package/dist/op/index.d.ts.map +1 -1
  130. package/dist/op/index.js +4 -3
  131. package/dist/op/local-executor.d.ts.map +1 -1
  132. package/dist/op/local-executor.js +9 -3
  133. package/dist/op/op-waves-run.d.ts +28 -43
  134. package/dist/op/op-waves-run.d.ts.map +1 -1
  135. package/dist/op/op-waves-run.js +170 -120
  136. package/dist/op/op-waves.d.ts +55 -3
  137. package/dist/op/op-waves.d.ts.map +1 -1
  138. package/dist/op/op-waves.js +63 -8
  139. package/dist/op/schedule-overdue.d.ts +57 -0
  140. package/dist/op/schedule-overdue.d.ts.map +1 -0
  141. package/dist/op/schedule-overdue.js +138 -0
  142. package/dist/op/stage-hooks.d.ts +132 -0
  143. package/dist/op/stage-hooks.d.ts.map +1 -0
  144. package/dist/op/stage-hooks.js +142 -0
  145. package/dist/override-gate.d.ts +2 -2
  146. package/dist/override-gate.d.ts.map +1 -1
  147. package/dist/override-gate.js +1 -1
  148. package/dist/pr-forge.d.ts +64 -0
  149. package/dist/pr-forge.d.ts.map +1 -1
  150. package/dist/pr-forge.js +331 -44
  151. package/dist/pr-loop.d.ts +107 -1
  152. package/dist/pr-loop.d.ts.map +1 -1
  153. package/dist/pr-loop.js +84 -3
  154. package/dist/pr-post.d.ts +72 -0
  155. package/dist/pr-post.d.ts.map +1 -0
  156. package/dist/pr-post.js +134 -0
  157. package/dist/pr-requires.d.ts +38 -0
  158. package/dist/pr-requires.d.ts.map +1 -0
  159. package/dist/pr-requires.js +48 -0
  160. package/dist/wave-blocked.d.ts +79 -0
  161. package/dist/wave-blocked.d.ts.map +1 -0
  162. package/dist/wave-blocked.js +245 -0
  163. package/dist/wave-engine.d.ts +6 -0
  164. package/dist/wave-engine.d.ts.map +1 -1
  165. package/dist/wave-engine.js +2 -0
  166. package/dist/wave-runtime.mjs +243 -243
  167. package/dist/workspace/__fixtures__/two-member-workspace.d.ts +1 -0
  168. package/dist/workspace/__fixtures__/two-member-workspace.d.ts.map +1 -1
  169. package/dist/workspace/__fixtures__/two-member-workspace.js +1 -1
  170. package/dist/workspace/checks/ci-workflow.d.ts.map +1 -1
  171. package/dist/workspace/checks/ci-workflow.js +19 -4
  172. package/dist/workspace/ci-branches.d.ts +51 -0
  173. package/dist/workspace/ci-branches.d.ts.map +1 -0
  174. package/dist/workspace/ci-branches.js +69 -0
  175. package/dist/workspace/ci-cloud-identity.d.ts +11 -0
  176. package/dist/workspace/ci-cloud-identity.d.ts.map +1 -0
  177. package/dist/workspace/ci-cloud-identity.js +24 -0
  178. package/dist/workspace/ci-init.d.ts.map +1 -1
  179. package/dist/workspace/ci-init.js +5 -4
  180. package/dist/workspace/ci-locks.d.ts +12 -0
  181. package/dist/workspace/ci-locks.d.ts.map +1 -0
  182. package/dist/workspace/ci-locks.js +6 -0
  183. package/dist/workspace/ci-run.d.ts +17 -1
  184. package/dist/workspace/ci-run.d.ts.map +1 -1
  185. package/dist/workspace/ci-run.js +66 -4
  186. package/dist/workspace/ci-workflow-at.d.ts +14 -0
  187. package/dist/workspace/ci-workflow-at.d.ts.map +1 -0
  188. package/dist/workspace/ci-workflow-at.js +17 -0
  189. package/dist/workspace/ci-workflow.d.ts +11 -3
  190. package/dist/workspace/ci-workflow.d.ts.map +1 -1
  191. package/dist/workspace/ci-workflow.js +10 -2
  192. package/dist/workspace/declaration.d.ts +69 -3
  193. package/dist/workspace/declaration.d.ts.map +1 -1
  194. package/dist/workspace/declaration.js +72 -1
  195. package/dist/workspace/declaration.schema.json +149 -2
  196. package/dist/workspace/identity-gate-rule.d.ts +1 -1
  197. package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
  198. package/dist/workspace/identity-gate-rule.js +1 -1
  199. package/dist/workspace/identity.d.ts +1 -1
  200. package/dist/workspace/identity.d.ts.map +1 -1
  201. package/dist/workspace/lineage-upgrade.d.ts.map +1 -1
  202. package/dist/workspace/lineage-upgrade.js +8 -5
  203. package/dist/workspace/member-pipeline.d.ts +6 -0
  204. package/dist/workspace/member-pipeline.d.ts.map +1 -1
  205. package/dist/workspace/member-pipeline.js +23 -0
  206. package/dist/workspace/pr-report.schema.json +94 -3
  207. package/dist/workspace/reason-codes.d.ts +1 -1
  208. package/dist/workspace/reason-codes.d.ts.map +1 -1
  209. package/dist/workspace/reason-codes.js +1 -1
  210. package/dist/workspace/security.d.ts.map +1 -1
  211. package/dist/workspace/security.js +4 -0
  212. package/dist/workspace/status-gates.d.ts +3 -2
  213. package/dist/workspace/status-gates.d.ts.map +1 -1
  214. package/dist/workspace/status-gates.js +8 -7
  215. package/dist/workspace/status.d.ts.map +1 -1
  216. package/dist/workspace/status.js +4 -1
  217. package/dist/workspace/trust/seal.d.ts +2 -2
  218. package/dist/workspace/trust/seal.d.ts.map +1 -1
  219. package/dist/workspace/trust/seal.js +2 -2
  220. package/package.json +1 -1
  221. package/src/__fixtures__/oidc-emulator.ts +118 -0
  222. package/src/ci-handover.test.ts +209 -0
  223. package/src/ci-handover.ts +237 -0
  224. package/src/ci-identity.test.ts +201 -0
  225. package/src/ci-identity.ts +310 -0
  226. package/src/cli/handlers/approve.ts +18 -5
  227. package/src/cli/handlers/build.ts +18 -1
  228. package/src/cli/handlers/fan-out.ts +43 -6
  229. package/src/cli/handlers/gate-resume.ts +16 -2
  230. package/src/cli/handlers/lock.test.ts +98 -0
  231. package/src/cli/handlers/lock.ts +202 -0
  232. package/src/cli/handlers/operator.test.ts +3 -1
  233. package/src/cli/handlers/pr-before-merge.test.ts +276 -0
  234. package/src/cli/handlers/pr-env.ts +462 -0
  235. package/src/cli/handlers/pr-waves-blocked.test.ts +247 -0
  236. package/src/cli/handlers/pr.test.ts +184 -0
  237. package/src/cli/handlers/pr.ts +605 -61
  238. package/src/cli/handlers/promote.ts +9 -0
  239. package/src/cli/handlers/query.ts +78 -0
  240. package/src/cli/handlers/run.ts +10 -0
  241. package/src/cli/main.ts +49 -4
  242. package/src/cli/parse-args.ts +34 -2
  243. package/src/cli/registry.ts +31 -2
  244. package/src/components/capability-targets.test.ts +162 -0
  245. package/src/components/capability.ts +71 -0
  246. package/src/components/cli-support.ts +14 -1
  247. package/src/components/driver.ts +54 -3
  248. package/src/components/fan-out-run.ts +58 -3
  249. package/src/components/fan-out-waves.test.ts +45 -1
  250. package/src/components/gate-plan.ts +3 -0
  251. package/src/components/pr-environment.test.ts +249 -0
  252. package/src/components/pr-environment.ts +538 -0
  253. package/src/components/pr-hooks.test.ts +118 -0
  254. package/src/components/pr-hooks.ts +157 -0
  255. package/src/components/pr-pipeline.ts +194 -21
  256. package/src/components/pr-policy.test.ts +145 -0
  257. package/src/components/pr-policy.ts +211 -0
  258. package/src/components/pr-run.ts +14 -2
  259. package/src/components/wave-plan.ts +38 -3
  260. package/src/gate-decision-bundle.test.ts +4 -3
  261. package/src/gate-decision.ts +39 -2
  262. package/src/gate-policy-bundle.test.ts +28 -0
  263. package/src/gate-policy.test.ts +162 -0
  264. package/src/gate-policy.ts +298 -0
  265. package/src/lifecycle/gate-checkpoint.ts +1 -1
  266. package/src/{workspace/trust → lifecycle}/gate-seal.ts +1 -1
  267. package/src/lifecycle/query.test.ts +91 -0
  268. package/src/lifecycle/query.ts +315 -0
  269. package/src/lifecycle/run-ledger.ts +18 -0
  270. package/src/lifecycle/target-lock.test.ts +195 -0
  271. package/src/lifecycle/target-lock.ts +347 -0
  272. package/src/op/activities/activity-contracts.ts +31 -0
  273. package/src/op/activities/index.ts +6 -0
  274. package/src/op/activities/pr-refs.ts +28 -0
  275. package/src/op/activities/predict-behaviour.ts +3 -23
  276. package/src/op/activities/review-agent.test.ts +240 -0
  277. package/src/op/activities/review-agent.ts +355 -0
  278. package/src/op/builders.ts +13 -0
  279. package/src/op/cron.ts +44 -0
  280. package/src/op/gate-alias.test.ts +2 -2
  281. package/src/op/gate-approval.test.ts +30 -9
  282. package/src/op/gate-approval.ts +23 -26
  283. package/src/op/gate-quorum.test.ts +139 -0
  284. package/src/op/gate-quorum.ts +248 -0
  285. package/src/op/gate-resume.ts +6 -3
  286. package/src/op/gate-review.ts +1 -1
  287. package/src/op/gate.ts +64 -23
  288. package/src/op/index.ts +13 -1
  289. package/src/op/local-executor.ts +9 -2
  290. package/src/op/op-waves-hook-targets.test.ts +126 -0
  291. package/src/op/op-waves-policy-hold.test.ts +66 -0
  292. package/src/op/op-waves-quorum.test.ts +101 -0
  293. package/src/op/op-waves-run.ts +197 -183
  294. package/src/op/op-waves.ts +83 -10
  295. package/src/op/schedule-overdue.test.ts +220 -0
  296. package/src/op/schedule-overdue.ts +161 -0
  297. package/src/op/stage-hooks.ts +251 -0
  298. package/src/override-gate-bundle.test.ts +1 -1
  299. package/src/override-gate.ts +2 -2
  300. package/src/pr-forge-bundle.test.ts +2 -2
  301. package/src/pr-forge.test.ts +33 -0
  302. package/src/pr-forge.ts +347 -35
  303. package/src/pr-loop-bundle.test.ts +2 -2
  304. package/src/pr-loop.test.ts +58 -0
  305. package/src/pr-loop.ts +170 -4
  306. package/src/pr-post.test.ts +141 -0
  307. package/src/pr-post.ts +159 -0
  308. package/src/pr-requires.test.ts +184 -0
  309. package/src/pr-requires.ts +79 -0
  310. package/src/review-agent-bundle.test.ts +35 -0
  311. package/src/stage-hooks-bundle.test.ts +38 -0
  312. package/src/wave-blocked-bundle.test.ts +25 -0
  313. package/src/wave-blocked.test.ts +146 -0
  314. package/src/wave-blocked.ts +271 -0
  315. package/src/wave-engine.ts +8 -0
  316. package/src/workspace/__fixtures__/two-member-workspace.ts +2 -2
  317. package/src/workspace/checks/ci-workflow.test.ts +9 -0
  318. package/src/workspace/checks/ci-workflow.ts +18 -4
  319. package/src/workspace/ci-branches.test.ts +62 -0
  320. package/src/workspace/ci-branches.ts +79 -0
  321. package/src/workspace/ci-cloud-identity.test.ts +53 -0
  322. package/src/workspace/ci-cloud-identity.ts +23 -0
  323. package/src/workspace/ci-init.ts +5 -4
  324. package/src/workspace/ci-locks.ts +16 -0
  325. package/src/workspace/ci-run-index.test.ts +2 -1
  326. package/src/workspace/ci-run.test.ts +107 -8
  327. package/src/workspace/ci-run.ts +74 -5
  328. package/src/workspace/ci-workflow-at.ts +23 -0
  329. package/src/workspace/ci-workflow.ts +13 -2
  330. package/src/workspace/declaration.schema.json +149 -2
  331. package/src/workspace/declaration.test.ts +76 -0
  332. package/src/workspace/declaration.ts +140 -5
  333. package/src/workspace/identity-gate-rule.ts +1 -1
  334. package/src/workspace/identity.ts +1 -1
  335. package/src/workspace/lineage-upgrade.ts +11 -8
  336. package/src/workspace/member-pipeline.test.ts +29 -0
  337. package/src/workspace/member-pipeline.ts +30 -0
  338. package/src/workspace/pr-report.schema.json +94 -3
  339. package/src/workspace/reason-codes.ts +1 -1
  340. package/src/workspace/security.ts +4 -0
  341. package/src/workspace/status-gates.ts +9 -6
  342. package/src/workspace/status.ts +4 -1
  343. package/src/workspace/trust/gate-seal.test.ts +1 -1
  344. package/src/workspace/trust/seal.ts +2 -2
  345. package/dist/workspace/trust/gate-seal.d.ts.map +0 -1
  346. /package/dist/{workspace/trust → lifecycle}/gate-seal.js +0 -0
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Gate-time policy on the pull-request path (#4294): `ci.policy` in the
3
+ * workspace declaration, run by `chant components pr-plan` and `pr-apply`
4
+ * over the change-set document the gate binds (`CapabilityPlan.changeSet`,
5
+ * composed by `planPrSet`).
6
+ *
7
+ * The settings and the policy directory are both read at the base the job
8
+ * measures the change from, so a pull request cannot loosen, edit or delete
9
+ * the policy that judges it. The engine and its result shapes are
10
+ * `../gate-policy.ts`.
11
+ *
12
+ * - deny: pr-apply applies nothing unless an override counts
13
+ * (`../override-gate.ts`, subject the gate's op, such as `pr-12`). The
14
+ * first refusal records the denial on `_gates/policy-override.jsonl`, so
15
+ * `chant approve policy-override <op> --rule <id> --reason <text>` can
16
+ * answer it. The gate's own approval is still needed. The override is
17
+ * spent just before anything applies.
18
+ * - hold: the plan needs a person's approval of its own digest. pr-apply
19
+ * always asks for one, so a hold changes one path: a green commit's plan
20
+ * no longer applies under the approvals of the merges it carries.
21
+ * - error: the policy did not run or gave no readable answer. pr-apply
22
+ * applies nothing.
23
+ */
24
+ import { readDeclaration, WorkspaceReadError } from "../workspace/declaration.js";
25
+ import { locateWorkspace } from "../workspace/which-chant.js";
26
+ import { checkGatePolicy, DEFAULT_POLICY_PATH, exportGatePolicy, } from "../gate-policy.js";
27
+ /** Whether the working tree's declaration names a `ci.policy`. */
28
+ function checkoutNamesPolicy(cwd) {
29
+ try {
30
+ return readDeclaration(locateWorkspace(cwd).tree).ci?.policy !== undefined;
31
+ }
32
+ catch {
33
+ return false;
34
+ }
35
+ }
36
+ /**
37
+ * The policy a pull-request job in `cwd` runs, from the declaration at
38
+ * `base`. Throws when the declaration at base cannot be read and the
39
+ * working tree's names a policy: running none would let the change waive it.
40
+ */
41
+ export function prLoopPolicyAt(cwd, base) {
42
+ try {
43
+ const located = locateWorkspace(cwd, base);
44
+ const settings = readDeclaration(located.tree).ci?.policy;
45
+ return { base, ...(settings ? { settings, tree: located.tree } : {}) };
46
+ }
47
+ catch (err) {
48
+ const missing = err instanceof WorkspaceReadError && (err.code === "declaration-missing" || err.code === "not-a-git-repository");
49
+ const why = err instanceof Error ? err.message : String(err);
50
+ if (checkoutNamesPolicy(cwd)) {
51
+ if (missing)
52
+ return { base, note: `ci.policy: the base ${base.slice(0, 12)} has no workspace declaration, so the policy this change declares runs once it merges` };
53
+ throw new Error(`ci.policy is read from the workspace declaration at ${base.slice(0, 12)}, and it could not be read (${why}), so the policy cannot be run`);
54
+ }
55
+ return missing ? { base } : { base, note: `ci.policy: the declaration at ${base.slice(0, 12)} could not be read (${why}); this checkout names no policy, so none runs` };
56
+ }
57
+ }
58
+ /** Run the policy over `input`. Undefined when the base sets no policy. */
59
+ export function runPrPolicy(read, input, exec) {
60
+ if (!read.settings || !read.tree)
61
+ return undefined;
62
+ const engine = read.settings.engine ?? "conftest";
63
+ const path = read.settings.path ?? DEFAULT_POLICY_PATH;
64
+ const exported = exportGatePolicy(read.tree, path);
65
+ if ("error" in exported)
66
+ return { result: "error", engine, denials: [], rules: [], holds: [], warnings: [], error: exported.error };
67
+ try {
68
+ return checkGatePolicy({ settings: read.settings, input, policyDir: exported.dir, cwd: process.cwd(), ...(exec ? { exec } : {}) });
69
+ }
70
+ finally {
71
+ exported.cleanup();
72
+ }
73
+ }
74
+ /** The verdict as the report keeps it. */
75
+ export function prPolicyReport(verdict, base) {
76
+ return {
77
+ result: verdict.result,
78
+ engine: verdict.engine,
79
+ base,
80
+ denials: verdict.denials,
81
+ ...(verdict.rules.length > 0 ? { rules: verdict.rules } : {}),
82
+ holds: verdict.holds,
83
+ warnings: verdict.warnings,
84
+ ...(verdict.error !== undefined ? { error: verdict.error } : {}),
85
+ };
86
+ }
87
+ /**
88
+ * Decide a denied plan against the override ledger, as an Op waves job
89
+ * decides a denied run (`settleDenials` in `../op/op-waves-run.ts`).
90
+ */
91
+ export async function decidePrPolicyOverride(input) {
92
+ const og = await import("../override-gate.js");
93
+ const overriders = og.overridersAt(input.cwd, input.base).principals;
94
+ const signers = input.sealed ? (await import("../gate-decision.js")).gateSignersAt(input.cwd, input.base) : undefined;
95
+ const ledger = await input.port.read(og.OVERRIDE_OP);
96
+ const applied = ((await input.port.readApplied?.(og.OVERRIDE_OP)) ?? []);
97
+ const now = input.now ?? new Date().toISOString();
98
+ const verdict = og.decideOverride({
99
+ ledger,
100
+ applied,
101
+ subject: input.subject,
102
+ planDigest: input.digest,
103
+ rules: input.rules,
104
+ overriders,
105
+ mode: input.sealed ? "sealed" : "ledger",
106
+ ...(signers ? { signers } : {}),
107
+ now,
108
+ });
109
+ if (verdict.status === "overridden") {
110
+ const o = verdict.override;
111
+ return { status: "overridden", override: { by: o.by, at: o.at, reason: o.reason, digest: o.digest } };
112
+ }
113
+ let recorded = false;
114
+ if (input.record && !verdict.standing) {
115
+ const { version: _v, kind: _k, ...fact } = og.overridePending({
116
+ subject: input.subject,
117
+ planDigest: input.digest,
118
+ rules: input.rules,
119
+ timestamp: now,
120
+ expiresAt: new Date(new Date(now).getTime() + 48 * 3600 * 1000).toISOString(),
121
+ ...(input.description ? { description: input.description } : {}),
122
+ });
123
+ await input.port.appendPending(fact);
124
+ recorded = true;
125
+ }
126
+ return {
127
+ status: "none",
128
+ refusals: verdict.refusals,
129
+ command: og.overrideCommand(input.subject, input.rules, input.sealed),
130
+ overriders,
131
+ recorded,
132
+ ...(verdict.status === "moved" ? { moved: { by: verdict.by } } : {}),
133
+ };
134
+ }
135
+ /**
136
+ * Spend the override the apply runs under: append its applied record before
137
+ * anything applies. Throws when it could not be written or did not reach the
138
+ * remote, and the caller applies nothing.
139
+ */
140
+ export async function spendPrPolicyOverride(port, subject, override, at = {}) {
141
+ const og = await import("../override-gate.js");
142
+ if (!port.appendApplied)
143
+ throw new Error("this gate ledger cannot record an applied override");
144
+ const record = og.appliedOverride({ subject, digest: override.digest, at: override.at, by: override.by }, { timestamp: at.now ?? new Date().toISOString(), ...(at.commit ? { commit: at.commit } : {}) });
145
+ const pushed = await port.appendApplied(record);
146
+ const { isLifecycleLocalNote } = await import("../lifecycle/local-note.js");
147
+ if (!pushed.pushed && !isLifecycleLocalNote(pushed.pushWarning)) {
148
+ throw new Error(`the applied record did not reach the remote the next run reads: ${pushed.pushWarning ?? "the push did not land"}`);
149
+ }
150
+ }
@@ -87,6 +87,8 @@ export interface PrPlanSetOptions {
87
87
  vars?: Record<string, unknown>;
88
88
  /** Outputs supplied by the caller (`--seed-outputs`). They win over outputs read here. */
89
89
  seededOutputs?: Record<string, Record<string, unknown>>;
90
+ /** The addresses each component narrows to (#4300), by component: its steps' `DeployContext.targets`. */
91
+ targets?: Readonly<Record<string, readonly string[]>>;
90
92
  /**
91
93
  * Where the planning's events go (#4041): a `plan` phase with no
92
94
  * component, and in it one `plan` step per component, started as its wave
@@ -174,6 +176,8 @@ export interface PrApplyOptions {
174
176
  vars?: Record<string, unknown>;
175
177
  /** The set {@link planPrSet} planned and the gate approved, or {@link resumePrSet}'s set. */
176
178
  set: PrPlanSet;
179
+ /** The addresses each component narrows to (#4300), by component: its steps' `DeployContext.targets`. */
180
+ targets?: Readonly<Record<string, readonly string[]>>;
177
181
  onProgress?: (event: RunProgressEvent) => void;
178
182
  /** Where the apply's events go (#4041): the fan-out's run events. */
179
183
  onRunEvent?: RunEventSink;
@@ -255,6 +259,8 @@ export interface PrResumeOptions {
255
259
  env: string;
256
260
  vars?: Record<string, unknown>;
257
261
  seededOutputs?: Record<string, Record<string, unknown>>;
262
+ /** The addresses each component narrows to (#4300), by component: its steps' `DeployContext.targets`. */
263
+ targets?: Readonly<Record<string, readonly string[]>>;
258
264
  /** The approved set, from the attempt record. */
259
265
  record: PrApplyRecord;
260
266
  /** Components an earlier attempt applied. */
@@ -1 +1 @@
1
- {"version":3,"file":"pr-run.d.ts","sourceRoot":"","sources":["../../src/components/pr-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AAEH,OAAO,EAA2C,KAAK,iBAAiB,EAA2C,MAAM,eAAe,CAAC;AACzI,OAAO,EAAgB,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EAML,KAAK,UAAU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,CAAC,KAAK,EAAE,aAAa,GAAG,QAAQ,CAkCvD"}
@@ -329,6 +329,7 @@ export async function applyPrSet(options) {
329
329
  env: options.env,
330
330
  ...(options.vars ? { vars: options.vars } : {}),
331
331
  plans,
332
+ ...(options.targets ? { targets: options.targets } : {}),
332
333
  componentOutputs: outputs,
333
334
  hold: (name, now) => heldReason(byName.get(name), read, now, inChange),
334
335
  ...(options.onProgress ? { onProgress: options.onProgress } : {}),
@@ -352,6 +353,7 @@ export async function applyPrSet(options) {
352
353
  env: options.env,
353
354
  ...(options.vars ? { vars: options.vars } : {}),
354
355
  seededOutputs: run.componentOutputs,
356
+ ...(options.targets ? { targets: options.targets } : {}),
355
357
  });
356
358
  for (const name of plan.order)
357
359
  roundOf.set(name, { round, set });
@@ -375,7 +377,7 @@ export async function applyPrSet(options) {
375
377
  }
376
378
  const completed = new Set(run.completed);
377
379
  const held = new Map((run.held ?? []).map((h) => [h.component, h]));
378
- const blocked = new Set(run.blocked.map((b) => b.component));
380
+ const blocked = new Map(run.blocked.map((b) => [b.component, b.blockedBy]));
379
381
  const errorOf = (component) => {
380
382
  const result = [...run.results].reverse().find((r) => r.component === component);
381
383
  if (result?.status === "gated")
@@ -395,8 +397,10 @@ export async function applyPrSet(options) {
395
397
  return { ...asPlanned, status: "waiting", held: h.heldBy ? `${h.heldBy} is held: ${h.reason}` : h.reason };
396
398
  if (fresh?.status === "plan-failed")
397
399
  return { ...asPlanned, status: "plan-failed", ...(fresh.error ? { error: fresh.error } : {}) };
398
- if (blocked.has(m.component))
399
- return { ...asPlanned, status: "blocked" };
400
+ if (blocked.has(m.component)) {
401
+ const by = blocked.get(m.component);
402
+ return { ...asPlanned, status: "blocked", ...(by ? { blockedBy: by } : {}) };
403
+ }
400
404
  const error = errorOf(m.component);
401
405
  return { ...asPlanned, status: "failed", ...(error ? { error } : {}) };
402
406
  });
@@ -516,6 +520,7 @@ export async function resumePrSet(options) {
516
520
  env: options.env,
517
521
  ...(options.vars ? { vars: options.vars } : {}),
518
522
  seededOutputs: { ...(options.seededOutputs ?? {}), ...options.record.planOutputs },
523
+ ...(options.targets ? { targets: options.targets } : {}),
519
524
  });
520
525
  const reasons = fresh.doc.members
521
526
  .map((m) => planCoveredBy(options.record.changeSet, fresh.doc, m.member))
@@ -27,7 +27,7 @@
27
27
  * `@<component>.publish.*`) resolves.
28
28
  */
29
29
  import { type DriverComponent, type DriverPhase, type DriverStep } from "./driver.js";
30
- import type { CapabilityRegistry, DeployContext, PlannedOutputs } from "./capability.js";
30
+ import type { CapabilityPlan, CapabilityRegistry, DeployContext, PlannedOutputs } from "./capability.js";
31
31
  import type { WaveMember } from "../gated-waves.js";
32
32
  import type { ChangeSetPart } from "../change-set.js";
33
33
  /**
@@ -59,6 +59,19 @@ export declare function capabilitySteps(phases: readonly DriverPhase[]): DriverS
59
59
  export declare function planContext(ctx: DeployContext, stepInput: Record<string, unknown>, componentOutputs: Record<string, Record<string, unknown>>): DeployContext;
60
60
  /** Plan one component against the outputs earlier waves produced. Never throws: a failure comes back as `error`. */
61
61
  export declare function planWaveComponent(component: DriverComponent, registry: CapabilityRegistry, ctx: DeployContext, componentOutputs: Record<string, Record<string, unknown>>): Promise<WaveComponentPlan>;
62
+ /**
63
+ * A member's digest with its targets in it (#4300), the way terragucci's
64
+ * cone plan digest binds a cone: the digest over the plan's own digest and
65
+ * the sorted targets, so an approval of one narrowing covers no other.
66
+ */
67
+ export declare function targetedPlanDigest(planDigest: string, targets: readonly string[]): string;
68
+ /**
69
+ * A step's plan made with `ctx.targets` (#4300), its digest bound to them.
70
+ * The plan must give back the targets it was asked for, which says it planned
71
+ * those alone; one that gives back others, or none, refuses. Without
72
+ * `ctx.targets`, the plan as it came.
73
+ */
74
+ export declare function bindTargets(kind: string, ctx: DeployContext, planned: CapabilityPlan): CapabilityPlan;
62
75
  /**
63
76
  * The outputs `component` exposes now, read from each step whose capability
64
77
  * has `outputs` (#3183), merged the way the driver merges a run's outputs.
@@ -1 +1 @@
1
- {"version":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,EAAE,eAAe,EAC1B,QAAQ,EAAE,kBAAkB,EAC5B,GAAG,EAAE,aAAa,EAClB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxD,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAU9C;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,EAChD,QAAQ,EAAE,kBAAkB,EAC5B,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,aAAa,EAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC/C,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAYnC"}
@@ -26,7 +26,7 @@
26
26
  * plans as `undefined`. Cross-component wiring (`stackOutput()`,
27
27
  * `@<component>.publish.*`) resolves.
28
28
  */
29
- import { resolveStepInput, unresolvedWiringSources } from "./driver.js";
29
+ import { assertTargetsAccepted, resolveStepInput, unresolvedWiringSources } from "./driver.js";
30
30
  import { componentPlanDigest } from "./gate-plan.js";
31
31
  import { componentDeployInputs } from "./deploy-inputs.js";
32
32
  import { computePlanDigest } from "../lifecycle/plan-digest.js";
@@ -73,13 +73,14 @@ export async function planWaveComponent(component, registry, ctx, componentOutpu
73
73
  const plans = {};
74
74
  const parts = [];
75
75
  let outputs;
76
+ assertTargetsAccepted(component, registry, ctx);
76
77
  for (const step of capabilitySteps(component.deploy)) {
77
78
  const capability = registry.resolve(step.kind);
78
79
  if (!capability.plan)
79
80
  continue;
80
81
  const { kind: _kind, ...rest } = step;
81
82
  const input = resolveStepInput(rest, {}, componentOutputs);
82
- const planned = await capability.plan(planContext(ctx, rest, componentOutputs), input);
83
+ const planned = bindTargets(step.kind, ctx, await capability.plan(planContext(ctx, rest, componentOutputs), input));
83
84
  const member = { member: planned.member, planDigest: planned.planDigest };
84
85
  members.push(member);
85
86
  parts.push(planned.changeSet ?? emptyPart(member));
@@ -99,6 +100,7 @@ export async function planWaveComponent(component, registry, ctx, componentOutpu
99
100
  component,
100
101
  ...(ctx.vars ? { vars: ctx.vars } : {}),
101
102
  inputs: read.inputs,
103
+ ...(ctx.targets ? { targets: ctx.targets } : {}),
102
104
  }),
103
105
  };
104
106
  members.push(member);
@@ -121,6 +123,36 @@ export async function planWaveComponent(component, registry, ctx, componentOutpu
121
123
  return { component: component.name, error: err instanceof Error ? err.message : String(err) };
122
124
  }
123
125
  }
126
+ /**
127
+ * A member's digest with its targets in it (#4300), the way terragucci's
128
+ * cone plan digest binds a cone: the digest over the plan's own digest and
129
+ * the sorted targets, so an approval of one narrowing covers no other.
130
+ */
131
+ export function targetedPlanDigest(planDigest, targets) {
132
+ return computePlanDigest("capability-targets", { plan: planDigest, targets: [...new Set(targets)].sort() });
133
+ }
134
+ /**
135
+ * A step's plan made with `ctx.targets` (#4300), its digest bound to them.
136
+ * The plan must give back the targets it was asked for, which says it planned
137
+ * those alone; one that gives back others, or none, refuses. Without
138
+ * `ctx.targets`, the plan as it came.
139
+ */
140
+ export function bindTargets(kind, ctx, planned) {
141
+ const asked = ctx.targets;
142
+ if (!asked || asked.length === 0)
143
+ return planned;
144
+ const want = [...new Set(asked)].sort();
145
+ const got = [...new Set(planned.targets ?? [])].sort();
146
+ if (got.length !== want.length || got.some((t, i) => t !== want[i])) {
147
+ throw new Error(`component "${ctx.component}": ${kind} was asked to plan ${want.join(", ")} but its plan of ${planned.member} ` +
148
+ (got.length === 0 ? "names no targets" : `names ${got.join(", ")}`));
149
+ }
150
+ const planDigest = targetedPlanDigest(planned.planDigest, want);
151
+ const changeSet = planned.changeSet
152
+ ? { ...planned.changeSet, member: { ...planned.changeSet.member, planDigest } }
153
+ : undefined;
154
+ return { ...planned, planDigest, targets: want, ...(changeSet ? { changeSet } : {}) };
155
+ }
124
156
  /** `next` over `prior`, as a later step's outputs win over an earlier one's in a run. */
125
157
  function mergePlannedOutputs(prior, next) {
126
158
  const known = { ...(prior?.known ?? {}), ...next.known };
@@ -27,6 +27,11 @@
27
27
  * counts for nothing, as terragucci's wave gate has it: the caller hands in
28
28
  * the lines of `_gates/<op>/applied.jsonl` ({@link parseAppliedGateLines}).
29
29
  *
30
+ * Approval rules (#4290), a quorum as a list of `{ targets, count, roles,
31
+ * notAuthor }`, are judged with `./op/gate-quorum.ts`, re-exported here:
32
+ * {@link trustRolesAt} and {@link gateSignersAt} read what
33
+ * `trustQuorumJudge` judges by, at base.
34
+ *
30
35
  * The module reads the ledger lines and the review it is handed; reading
31
36
  * them is the caller's. It imports no TypeScript, esbuild, zod, ajv, lint,
32
37
  * fold or codegen module, no package's code, and none of chant's git ledger
@@ -36,19 +41,20 @@
36
41
  * `gate-decision.test.ts` decides the same ledgers both ways.
37
42
  */
38
43
  import { type AppliedGateRecord } from "./lifecycle/gate-applied.js";
39
- import { type GateSigners, type SealedGateApproval } from "./workspace/trust/gate-seal.js";
44
+ import { type GateSigners, type SealedGateApproval } from "./lifecycle/gate-seal.js";
40
45
  import { type ClassGrant } from "./workspace/identity-gate-rule.js";
41
46
  import type { GateResolutionRecord, PendingGateRecord } from "./lifecycle/gate-ledger.js";
42
47
  import type { MergedReview } from "./op/gate-review.js";
43
48
  import type { GateApprovalSource } from "./op/op-waves.js";
44
49
  export { GATE_APPROVAL_SOURCES, type GateApprovalSource } from "./op/op-waves.js";
45
50
  export { isPendingGateExpired, latestPendingGate, latestResolutionForPlan, latestResolutionSince, type PlanBoundResolution, } from "./lifecycle/gate-ledger-select.js";
46
- export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealRefusal, gateSealVersion, sealedFieldsOf, sshKeyFingerprint, verifySshSignatureWith, type GateSigners, type SealedGateApproval, type SshSignatureCheck, } from "./workspace/trust/gate-seal.js";
51
+ export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealRefusal, gateSealVersion, sealedFieldsOf, sshKeyFingerprint, verifySshSignatureWith, type GateSigners, type SealedGateApproval, type SshSignatureCheck, } from "./lifecycle/gate-seal.js";
47
52
  export { DEFAULT_SIGNERS_PATH, TRUST_CONFIG_PATH, parseAllowedSigners, trustConfigProblems, type Signer, type SignerSet, } from "./workspace/trust/trust-files.js";
48
53
  export type { GateResolutionRecord, PendingGateRecord } from "./lifecycle/gate-ledger.js";
49
54
  export { CORE_CLASSES, admitApprover, grantedClasses, type ClassGrant, type GateAdmissionRule, type PrincipalClass, } from "./workspace/identity-gate-rule.js";
50
55
  export { appliedGateApplies, appliedGatePath, isApprovalSpent, parseAppliedGateLines, type AppliedGateRecord, } from "./lifecycle/gate-applied.js";
51
56
  export type { MergedReview } from "./op/gate-review.js";
57
+ export { quorumNeed, quorumProblems, quorumRuleLine, quorumRuleProgress, quorumRules, quorumRulesFor, quorumWaiting, rolesOf, ruleNeedsProof, samePrincipal, targetGlobMatch, trustQuorumJudge, UNPROVEN_JUDGE, type GateQuorumJudge, type GateQuorumRule, type GateQuorumRuleProgress, type GateQuorumSpec, type QuorumApprover, type QuorumJudgement, type TrustQuorumInput, } from "./op/gate-quorum.js";
52
58
  /**
53
59
  * The commit a gate's rule is read at when the default branch applies its
54
60
  * own commit: the first parent of HEAD, the branch as it stood before the
@@ -65,6 +71,13 @@ export declare function baseCommit(repo: string): string;
65
71
  * commit the repository holds, such as {@link baseCommit}'s answer.
66
72
  */
67
73
  export declare function gateSignersAt(repo: string, base: string): GateSigners;
74
+ /**
75
+ * The role grants of `.chant/trust.json` at `base` (#4290): role name to the
76
+ * principals that hold it, as chant reads them. A missing file gives none,
77
+ * and so does one that is not valid, which turns chant's trust off.
78
+ * {@link trustQuorumJudge} takes them with {@link gateSignersAt}'s signers.
79
+ */
80
+ export declare function trustRolesAt(repo: string, base: string): Record<string, string[]>;
68
81
  /** A gate the declaration at base names under `identity.gates`, and the principal class its signer must be in, if any. */
69
82
  export interface IdentityGate {
70
83
  gate: string;
@@ -1 +1 @@
1
- {"version":3,"file":"gate-decision.d.ts","sourceRoot":"","sources":["../src/gate-decision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAWH,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAmB,KAAK,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAQzG,OAAO,EAA+B,KAAK,UAAU,EAA+C,MAAM,gCAAgC,CAAC;AAE3I,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,KAAK,mBAAmB,GACzB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,MAAM,EACX,KAAK,SAAS,GACf,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EACL,YAAY,EACZ,aAAa,EACb,cAAc,EACd,KAAK,UAAU,EACf,KAAK,iBAAiB,EACt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BAAiB,EAAE,CAAC;IAC/B,yDAAyD;IACzD,MAAM,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IAClC,wHAAwH;IACxH,KAAK,CAAC,EAAE,oBAAoB,CAAC;CAC9B,CAAC;AAIN;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,oBAAoB,CA6CjF"}
@@ -27,6 +27,11 @@
27
27
  * counts for nothing, as terragucci's wave gate has it: the caller hands in
28
28
  * the lines of `_gates/<op>/applied.jsonl` ({@link parseAppliedGateLines}).
29
29
  *
30
+ * Approval rules (#4290), a quorum as a list of `{ targets, count, roles,
31
+ * notAuthor }`, are judged with `./op/gate-quorum.ts`, re-exported here:
32
+ * {@link trustRolesAt} and {@link gateSignersAt} read what
33
+ * `trustQuorumJudge` judges by, at base.
34
+ *
30
35
  * The module reads the ledger lines and the review it is handed; reading
31
36
  * them is the caller's. It imports no TypeScript, esbuild, zod, ajv, lint,
32
37
  * fold or codegen module, no package's code, and none of chant's git ledger
@@ -41,17 +46,18 @@ import { join, posix } from "node:path";
41
46
  import { isPendingGateExpired, latestPendingGate, latestResolutionForPlan, } from "./lifecycle/gate-ledger-select.js";
42
47
  import { samePlanDigest } from "./lifecycle/plan-digest.js";
43
48
  import { isApprovalSpent } from "./lifecycle/gate-applied.js";
44
- import { gateSealRefusal } from "./workspace/trust/gate-seal.js";
49
+ import { gateSealRefusal } from "./lifecycle/gate-seal.js";
45
50
  import { DEFAULT_SIGNERS_PATH, TRUST_CONFIG_PATH, parseAllowedSigners, trustConfigProblems, } from "./workspace/trust/trust-files.js";
46
51
  import { parseJsonText } from "./workspace/jsonc.js";
47
52
  import { CORE_CLASSES, admitApprover } from "./workspace/identity-gate-rule.js";
48
53
  import { diskFiles, findInstalledPackage, mergePinClasses, parseClassDataByHand, readClassFiles } from "./workspace/class-data.js";
49
54
  export { GATE_APPROVAL_SOURCES } from "./op/op-waves.js";
50
55
  export { isPendingGateExpired, latestPendingGate, latestResolutionForPlan, latestResolutionSince, } from "./lifecycle/gate-ledger-select.js";
51
- export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealRefusal, gateSealVersion, sealedFieldsOf, sshKeyFingerprint, verifySshSignatureWith, } from "./workspace/trust/gate-seal.js";
56
+ export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealRefusal, gateSealVersion, sealedFieldsOf, sshKeyFingerprint, verifySshSignatureWith, } from "./lifecycle/gate-seal.js";
52
57
  export { DEFAULT_SIGNERS_PATH, TRUST_CONFIG_PATH, parseAllowedSigners, trustConfigProblems, } from "./workspace/trust/trust-files.js";
53
58
  export { CORE_CLASSES, admitApprover, grantedClasses, } from "./workspace/identity-gate-rule.js";
54
59
  export { appliedGateApplies, appliedGatePath, isApprovalSpent, parseAppliedGateLines, } from "./lifecycle/gate-applied.js";
60
+ export { quorumNeed, quorumProblems, quorumRuleLine, quorumRuleProgress, quorumRules, quorumRulesFor, quorumWaiting, rolesOf, ruleNeedsProof, samePrincipal, targetGlobMatch, trustQuorumJudge, UNPROVEN_JUDGE, } from "./op/gate-quorum.js";
55
61
  // ── reading at base ──────────────────────────────────────────────────────
56
62
  function git(repo, args) {
57
63
  return spawnSync("git", args, { cwd: repo, encoding: "utf-8" });
@@ -118,6 +124,15 @@ function trustAt(repo, base) {
118
124
  export function gateSignersAt(repo, base) {
119
125
  return trustAt(repo, base).signers;
120
126
  }
127
+ /**
128
+ * The role grants of `.chant/trust.json` at `base` (#4290): role name to the
129
+ * principals that hold it, as chant reads them. A missing file gives none,
130
+ * and so does one that is not valid, which turns chant's trust off.
131
+ * {@link trustQuorumJudge} takes them with {@link gateSignersAt}'s signers.
132
+ */
133
+ export function trustRolesAt(repo, base) {
134
+ return trustAt(repo, base).roles;
135
+ }
121
136
  /** The declaration at `base`, parsed, or null when there is none. Throws when it cannot be parsed. */
122
137
  function declarationAt(repo, base) {
123
138
  for (const file of ["chant.workspace.json", "chant.workspace.jsonc"]) {
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Gate-time policy (#4294): a policy engine run over a plan's change set,
3
+ * with the policy read at base, whose rules deny a plan or hold it for a
4
+ * person.
5
+ *
6
+ * The engine is any command that prints conftest's JSON result
7
+ * (`conftest test --output json`) or OPA's (`opa eval --format json`). The
8
+ * rules are counted as conftest counts them:
9
+ *
10
+ * - `deny`, `violation`, `deny_<name>` and `violation_<name>` deny the plan.
11
+ * A denied plan applies only under an override that counts
12
+ * (`./override-gate.ts`), on top of the gate's own approval.
13
+ * - `hold` and `hold_<name>` hold the plan: it waits for a person's approval
14
+ * of its digest, even where the gate would let it through without one.
15
+ * conftest runs only deny and warn rules, so a hold needs the opa shape.
16
+ * - `warn` and `warn_<name>` are advice. They fail nothing.
17
+ *
18
+ * There is no outcome that lets a plan apply with nobody approving it: a
19
+ * non-empty change set always waits for a person (ws-104, ws-080). A rule
20
+ * named `allow_unattended` is read as no rule at all.
21
+ *
22
+ * A policy that cannot run, or gives no answer this module can read, is an
23
+ * error, and the caller stops the apply: no path waives a policy.
24
+ *
25
+ * Like `./override-gate.ts` this module reads what it is handed and imports
26
+ * only node built-ins, so a product can bundle it into one file
27
+ * (`gate-policy-bundle.test.ts`). The pull-request jobs' use of it is in
28
+ * `./components/pr-policy.ts`.
29
+ */
30
+ /** The result shapes chant reads: conftest's and OPA's. */
31
+ export declare const GATE_POLICY_ENGINES: readonly ["conftest", "opa"];
32
+ export type GatePolicyEngine = (typeof GATE_POLICY_ENGINES)[number];
33
+ /** Where the policy is read when the settings name no `path`. */
34
+ export declare const DEFAULT_POLICY_PATH = "policy";
35
+ /** The settings of one policy step, read at base. */
36
+ export interface GatePolicySettings {
37
+ /** The result shape, and the default command. Default `conftest`. */
38
+ engine?: GatePolicyEngine;
39
+ /** The policy directory, relative to the declaration at base. Default {@link DEFAULT_POLICY_PATH}. */
40
+ path?: string;
41
+ /** The package to read. conftest default: every namespace. opa default: `main`. */
42
+ namespace?: string;
43
+ /**
44
+ * The command to run instead of the engine's own, as argv. `{policy}` is
45
+ * the policy directory exported from base and `{input}` the input file. It
46
+ * prints the result shape `engine` names.
47
+ */
48
+ command?: string[];
49
+ }
50
+ /** A rule that matched, and what it said. */
51
+ export interface GatePolicyFinding {
52
+ /** `<package>.<rule>`, such as `main.deny_public_bucket`. */
53
+ rule: string;
54
+ message: string;
55
+ }
56
+ /** What an engine's answer holds. */
57
+ export interface GatePolicyFindings {
58
+ denials: GatePolicyFinding[];
59
+ holds: GatePolicyFinding[];
60
+ warnings: string[];
61
+ }
62
+ /**
63
+ * One policy check's outcome. `denied` wins over `held`. `error`: the
64
+ * policy did not run or gave no readable answer, and the apply stops.
65
+ */
66
+ export interface GatePolicyVerdict {
67
+ result: "passed" | "denied" | "held" | "error";
68
+ engine: GatePolicyEngine;
69
+ denials: GatePolicyFinding[];
70
+ /** The ids of the rules that denied, sorted, each once: what an override names. */
71
+ rules: string[];
72
+ holds: GatePolicyFinding[];
73
+ warnings: string[];
74
+ error?: string;
75
+ }
76
+ export declare const DENY_RULE: RegExp;
77
+ export declare const WARN_RULE: RegExp;
78
+ export declare const HOLD_RULE: RegExp;
79
+ /** The findings in `conftest test --output json`. Undefined when it is not that shape. */
80
+ export declare function conftestFindings(stdout: string): GatePolicyFindings | undefined;
81
+ /**
82
+ * The findings in `opa eval --format json data.<namespace>`. The query's
83
+ * value is the package: its rules are read by name. An array value is a
84
+ * deny set named after the query. A query that is undefined has no rule
85
+ * that matched. Undefined when the output is not that shape.
86
+ */
87
+ export declare function opaFindings(stdout: string, namespace?: string): GatePolicyFindings | undefined;
88
+ /** A verdict from what the engine found. */
89
+ export declare function gatePolicyVerdict(engine: GatePolicyEngine, found: GatePolicyFindings): GatePolicyVerdict;
90
+ /** The argv one check runs: the settings' `command` with its placeholders filled, or the engine's own. */
91
+ export declare function gatePolicyArgv(settings: GatePolicySettings, at: {
92
+ policy: string;
93
+ input: string;
94
+ }): string[];
95
+ /** What one run of the engine printed and how it exited. `status` is null when it did not start. */
96
+ export interface GatePolicyRun {
97
+ status: number | null;
98
+ stdout: string;
99
+ stderr: string;
100
+ }
101
+ export type GatePolicyExec = (argv: string[], cwd: string) => GatePolicyRun;
102
+ /** Runs the engine with the job's environment. */
103
+ export declare const defaultGatePolicyExec: GatePolicyExec;
104
+ export interface CheckGatePolicyOptions {
105
+ settings: GatePolicySettings;
106
+ /** The input document, or its JSON text. */
107
+ input: unknown;
108
+ /** The policy directory, already exported from base. */
109
+ policyDir: string;
110
+ /** Where the engine runs. Default the policy directory. */
111
+ cwd?: string;
112
+ exec?: GatePolicyExec;
113
+ }
114
+ /** Run the engine once over `input` and read its answer. */
115
+ export declare function checkGatePolicy(options: CheckGatePolicyOptions): GatePolicyVerdict;
116
+ /** The part of a tree a policy is exported from: a workspace tree at base fits. */
117
+ export interface GatePolicyTree {
118
+ stat(path: string): "file" | "dir" | undefined;
119
+ list(path: string): Array<{
120
+ name: string;
121
+ type: "file" | "dir";
122
+ }> | undefined;
123
+ read(path: string): string;
124
+ bytes?(path: string): Uint8Array;
125
+ }
126
+ /**
127
+ * Copy the policy directory `path` out of `tree` (the tree at base) into a
128
+ * new temporary directory, so the engine reads the policy as the base has
129
+ * it and never the change's copy. Returns the directory and how to remove
130
+ * it, or the reason there is no policy to read.
131
+ */
132
+ export declare function exportGatePolicy(tree: GatePolicyTree, path: string): {
133
+ dir: string;
134
+ cleanup: () => void;
135
+ } | {
136
+ error: string;
137
+ };
138
+ /** The settings, checked. Throws with what is wrong. `where` names them, such as `ci.policy`. */
139
+ export declare function assertGatePolicySettings(where: string, raw: unknown): asserts raw is GatePolicySettings;
140
+ //# sourceMappingURL=gate-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gate-policy.d.ts","sourceRoot":"","sources":["../src/gate-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAOH,2DAA2D;AAC3D,eAAO,MAAM,mBAAmB,YAAI,UAAU,EAAE,KAAK,CAAU,CAAC;AAChE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