@intentius/chant 0.124.108 → 0.124.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (342) hide show
  1. package/dist/__golden__/wave-loop/fan-out-applied.json +12 -6
  2. package/dist/__golden__/wave-loop/fan-out-apply-fails.json +8 -4
  3. package/dist/__golden__/wave-loop/fan-out-gated.json +4 -2
  4. package/dist/__golden__/wave-loop/fan-out-no-members.json +16 -8
  5. package/dist/__golden__/wave-loop/fan-out-plan-fails.json +8 -4
  6. package/dist/__golden__/wave-loop/fan-out-same-root.json +4 -2
  7. package/dist/agent-facts.d.ts +130 -0
  8. package/dist/agent-facts.js +196 -0
  9. package/dist/change-risk.d.ts +216 -0
  10. package/dist/change-risk.js +304 -0
  11. package/dist/change-set.d.ts +8 -0
  12. package/dist/ci-agent-alert.d.ts +139 -0
  13. package/dist/ci-agent-alert.js +342 -0
  14. package/dist/ci-agent-triggers.d.ts +152 -0
  15. package/dist/ci-agent-triggers.js +232 -0
  16. package/dist/ci-agent-verify-failed.d.ts +149 -0
  17. package/dist/ci-agent-verify-failed.js +191 -0
  18. package/dist/ci-agent.d.ts +136 -8
  19. package/dist/ci-agent.js +353 -26
  20. package/dist/ci-comment-commands.d.ts +8 -0
  21. package/dist/ci-comment-commands.js +17 -1
  22. package/dist/ci-comment-reject.d.ts +70 -0
  23. package/dist/ci-comment-reject.js +135 -0
  24. package/dist/ci-comment-replies.d.ts +3 -1
  25. package/dist/ci-comment-replies.js +6 -0
  26. package/dist/ci-estate/delivery.d.ts +25 -3
  27. package/dist/ci-estate/delivery.js +28 -9
  28. package/dist/ci-estate/page.d.ts +7 -3
  29. package/dist/ci-estate/page.js +19 -4
  30. package/dist/ci-estate/rows.d.ts +14 -2
  31. package/dist/ci-estate/rows.js +9 -1
  32. package/dist/ci-estate.d.ts +5 -2
  33. package/dist/ci-estate.js +3 -2
  34. package/dist/ci-handover.d.ts +2 -7
  35. package/dist/ci-handover.js +3 -20
  36. package/dist/ci-jobs.d.ts +6 -0
  37. package/dist/ci-jobs.js +17 -0
  38. package/dist/ci-note-commands.d.ts +2 -0
  39. package/dist/ci-note-commands.js +12 -1
  40. package/dist/ci-product-words.d.ts +151 -1
  41. package/dist/ci-product-words.js +1390 -3
  42. package/dist/ci-product.d.ts +100 -4
  43. package/dist/ci-product.js +99 -3
  44. package/dist/ci-respond-run.d.ts +9 -0
  45. package/dist/ci-respond-run.js +35 -4
  46. package/dist/ci-respond-summary-env.d.ts +56 -0
  47. package/dist/ci-respond-summary-env.js +81 -0
  48. package/dist/ci-respond-summary.d.ts +103 -0
  49. package/dist/ci-respond-summary.js +243 -0
  50. package/dist/ci-respond.d.ts +4 -2
  51. package/dist/ci-respond.js +4 -2
  52. package/dist/cli/command-group.js +1 -1
  53. package/dist/cli/commands/lint.js +21 -3
  54. package/dist/cli/handlers/agent.js +49 -4
  55. package/dist/cli/handlers/approve.js +3 -1
  56. package/dist/cli/handlers/build.d.ts +97 -1
  57. package/dist/cli/handlers/build.js +251 -3
  58. package/dist/cli/handlers/fan-out.js +55 -0
  59. package/dist/cli/handlers/graph.d.ts +14 -0
  60. package/dist/cli/handlers/graph.js +58 -3
  61. package/dist/cli/handlers/lifecycle-health.d.ts +7 -0
  62. package/dist/cli/handlers/lifecycle-health.js +47 -9
  63. package/dist/cli/handlers/lifecycle.js +4 -1
  64. package/dist/cli/handlers/notify-relay.d.ts +2 -2
  65. package/dist/cli/handlers/notify-relay.js +67 -7
  66. package/dist/cli/handlers/pipeline-agent.d.ts +30 -0
  67. package/dist/cli/handlers/pipeline-agent.js +255 -0
  68. package/dist/cli/handlers/pipeline-artifacts.d.ts +39 -0
  69. package/dist/cli/handlers/pipeline-artifacts.js +203 -0
  70. package/dist/cli/handlers/pipeline.d.ts +16 -0
  71. package/dist/cli/handlers/pipeline.js +112 -0
  72. package/dist/cli/handlers/pr-comment.js +4 -0
  73. package/dist/cli/handlers/pr-notes.js +4 -1
  74. package/dist/cli/handlers/pr.d.ts +20 -0
  75. package/dist/cli/handlers/pr.js +114 -11
  76. package/dist/cli/handlers/promote.js +792 -47
  77. package/dist/cli/handlers/reject.d.ts +84 -0
  78. package/dist/cli/handlers/reject.js +216 -0
  79. package/dist/cli/handlers/release.js +4 -2
  80. package/dist/cli/handlers/replan.d.ts +54 -0
  81. package/dist/cli/handlers/replan.js +177 -0
  82. package/dist/cli/handlers/run-generate.d.ts +5 -0
  83. package/dist/cli/handlers/run-generate.js +31 -4
  84. package/dist/cli/handlers/run-wave.js +15 -2
  85. package/dist/cli/handlers/run.js +4 -2
  86. package/dist/cli/handlers/stage.d.ts +35 -0
  87. package/dist/cli/handlers/stage.js +90 -0
  88. package/dist/cli/lsp/server.js +4 -0
  89. package/dist/cli/main.js +88 -8
  90. package/dist/cli/parse-args.js +35 -2
  91. package/dist/cli/registry.d.ts +12 -0
  92. package/dist/components/auto-release.d.ts +2 -0
  93. package/dist/components/auto-release.js +1 -0
  94. package/dist/components/capability.d.ts +40 -0
  95. package/dist/components/cli-support.d.ts +21 -1
  96. package/dist/components/cli-support.js +28 -6
  97. package/dist/components/component.d.ts +23 -4
  98. package/dist/components/component.schema.json +28 -0
  99. package/dist/components/declared-reads.d.ts +44 -4
  100. package/dist/components/declared-reads.js +80 -3
  101. package/dist/components/discover.d.ts +8 -0
  102. package/dist/components/discover.js +1 -1
  103. package/dist/components/driver.d.ts +13 -0
  104. package/dist/components/driver.js +23 -2
  105. package/dist/components/environment-sets.d.ts +229 -0
  106. package/dist/components/environment-sets.js +338 -0
  107. package/dist/components/fan-out-canary.d.ts +47 -0
  108. package/dist/components/fan-out-canary.js +58 -0
  109. package/dist/components/fan-out-run.d.ts +17 -0
  110. package/dist/components/fan-out-run.js +14 -1
  111. package/dist/components/fan-out-support.d.ts +7 -0
  112. package/dist/components/fan-out-support.js +1 -1
  113. package/dist/components/groups.d.ts +8 -1
  114. package/dist/components/groups.js +19 -1
  115. package/dist/components/index.d.ts +5 -2
  116. package/dist/components/index.js +4 -1
  117. package/dist/components/pr-cost.d.ts +28 -0
  118. package/dist/components/pr-cost.js +53 -0
  119. package/dist/components/pr-pipeline.d.ts +33 -0
  120. package/dist/components/pr-pipeline.js +32 -5
  121. package/dist/components/pr-policy.d.ts +33 -2
  122. package/dist/components/pr-policy.js +5 -2
  123. package/dist/components/pr-risk.d.ts +42 -0
  124. package/dist/components/pr-risk.js +74 -0
  125. package/dist/components/product-pipeline.d.ts +43 -0
  126. package/dist/components/product-pipeline.js +67 -1
  127. package/dist/components/promote.d.ts +6 -0
  128. package/dist/components/promote.js +13 -0
  129. package/dist/components/release-compile.js +3 -1
  130. package/dist/components/release-gate.d.ts +6 -1
  131. package/dist/components/release-gate.js +10 -2
  132. package/dist/components/step-environments.d.ts +236 -0
  133. package/dist/components/step-environments.js +392 -0
  134. package/dist/components/upstream-replan.d.ts +201 -0
  135. package/dist/components/upstream-replan.js +249 -0
  136. package/dist/components/verify-step.d.ts +30 -0
  137. package/dist/components/verify-step.js +27 -0
  138. package/dist/components/wave-plan.js +6 -2
  139. package/dist/config-environments.d.ts +4 -2
  140. package/dist/control/dispatch.d.ts +15 -0
  141. package/dist/control/dispatch.js +28 -4
  142. package/dist/cost-estimate.d.ts +188 -0
  143. package/dist/cost-estimate.js +363 -0
  144. package/dist/drift-record.d.ts +36 -0
  145. package/dist/drift-record.js +44 -0
  146. package/dist/engine-facts.d.ts +105 -0
  147. package/dist/engine-facts.js +111 -0
  148. package/dist/exit-codes.d.ts +4 -3
  149. package/dist/exit-codes.js +4 -3
  150. package/dist/flag-params.d.ts +2 -2
  151. package/dist/flag-params.js +9 -4
  152. package/dist/floor-table.data.js +53 -0
  153. package/dist/forge-token-vars.d.ts +12 -0
  154. package/dist/forge-token-vars.js +25 -0
  155. package/dist/gate-decision.d.ts +3 -1
  156. package/dist/gate-decision.js +3 -1
  157. package/dist/gated-waves.d.ts +2 -0
  158. package/dist/gated-waves.js +1 -0
  159. package/dist/graph-ir.d.ts +30 -0
  160. package/dist/graph-ir.js +33 -1
  161. package/dist/graph-refs.d.ts +26 -0
  162. package/dist/graph-refs.js +34 -3
  163. package/dist/graph-schema/graph.schema.json +136 -0
  164. package/dist/health.d.ts +65 -0
  165. package/dist/health.js +62 -0
  166. package/dist/lexicon.d.ts +188 -1
  167. package/dist/lifecycle/disruption.d.ts +14 -1
  168. package/dist/lifecycle/disruption.js +5 -1
  169. package/dist/lifecycle/gate-change-set.d.ts +8 -0
  170. package/dist/lifecycle/gate-change-set.js +2 -1
  171. package/dist/lifecycle/gate-ledger.d.ts +26 -0
  172. package/dist/lifecycle/gate-rejection.d.ts +82 -0
  173. package/dist/lifecycle/gate-rejection.js +93 -0
  174. package/dist/lifecycle/gate-seal.d.ts +3 -3
  175. package/dist/lifecycle/gate-seal.js +5 -5
  176. package/dist/lifecycle/observe.d.ts +17 -0
  177. package/dist/lifecycle/observe.js +10 -1
  178. package/dist/lifecycle/release-cut.js +4 -0
  179. package/dist/lifecycle/release-ledger.d.ts +8 -0
  180. package/dist/lifecycle/release-risk.d.ts +137 -0
  181. package/dist/lifecycle/release-risk.js +214 -0
  182. package/dist/lifecycle/release-store.d.ts +9 -0
  183. package/dist/lifecycle/release-store.js +4 -0
  184. package/dist/lifecycle/stage-log.d.ts +85 -0
  185. package/dist/lifecycle/stage-log.js +141 -0
  186. package/dist/lint/canary-checks.d.ts +31 -0
  187. package/dist/lint/canary-checks.js +45 -0
  188. package/dist/lint/rule.d.ts +1 -0
  189. package/dist/lint/rules/evl012-pipeline-fold.d.ts +14 -0
  190. package/dist/lint/rules/evl012-pipeline-fold.js +30 -0
  191. package/dist/lint/rules/index.d.ts +1 -0
  192. package/dist/lint/rules/index.js +3 -0
  193. package/dist/notify-relay-repo.d.ts +54 -0
  194. package/dist/notify-relay-repo.js +84 -0
  195. package/dist/notify-relay.d.ts +53 -3
  196. package/dist/notify-relay.js +96 -3
  197. package/dist/notify.d.ts +57 -1
  198. package/dist/notify.js +7 -1
  199. package/dist/notify.schema.json +61 -3
  200. package/dist/observation.d.ts +34 -0
  201. package/dist/observation.js +14 -1
  202. package/dist/op/activities/review-agent.d.ts +39 -2
  203. package/dist/op/activities/review-agent.js +88 -5
  204. package/dist/op/agent-permit.d.ts +88 -0
  205. package/dist/op/agent-permit.js +97 -0
  206. package/dist/op/gate-approval-base.d.ts +8 -0
  207. package/dist/op/gate-approval-base.js +9 -0
  208. package/dist/op/gate-approval.d.ts +30 -1
  209. package/dist/op/gate-approval.js +23 -2
  210. package/dist/op/gate-quorum.d.ts +114 -8
  211. package/dist/op/gate-quorum.js +198 -21
  212. package/dist/op/gate-reject.d.ts +79 -0
  213. package/dist/op/gate-reject.js +96 -0
  214. package/dist/op/gate-summary.js +1 -1
  215. package/dist/op/gate.d.ts +28 -3
  216. package/dist/op/gate.js +55 -13
  217. package/dist/op/generate-pipeline.d.ts +15 -1
  218. package/dist/op/generate-pipeline.js +32 -5
  219. package/dist/op/index.d.ts +11 -6
  220. package/dist/op/index.js +10 -5
  221. package/dist/op/local-executor.d.ts +2 -0
  222. package/dist/op/local-executor.js +23 -4
  223. package/dist/op/op-waves-after-plan.d.ts +23 -0
  224. package/dist/op/op-waves-after-plan.js +12 -1
  225. package/dist/op/op-waves-capability-spec.d.ts +14 -0
  226. package/dist/op/op-waves-capability-spec.js +46 -6
  227. package/dist/op/op-waves-capability.d.ts +21 -13
  228. package/dist/op/op-waves-capability.js +22 -59
  229. package/dist/op/op-waves-environment-sets.d.ts +41 -0
  230. package/dist/op/op-waves-environment-sets.js +82 -0
  231. package/dist/op/op-waves-quorum-warnings.d.ts +53 -0
  232. package/dist/op/op-waves-quorum-warnings.js +90 -0
  233. package/dist/op/op-waves-release-port.d.ts +7 -0
  234. package/dist/op/op-waves-release-port.js +15 -3
  235. package/dist/op/op-waves-release.d.ts +15 -0
  236. package/dist/op/op-waves-release.js +15 -0
  237. package/dist/op/op-waves-run.d.ts +37 -3
  238. package/dist/op/op-waves-run.js +141 -18
  239. package/dist/op/op-waves-soak.d.ts +57 -0
  240. package/dist/op/op-waves-soak.js +111 -0
  241. package/dist/op/op-waves-split.d.ts +4 -0
  242. package/dist/op/op-waves-split.js +4 -0
  243. package/dist/op/op-waves.d.ts +67 -4
  244. package/dist/op/op-waves.js +71 -3
  245. package/dist/pipeline/agent-ajv.d.ts +4 -0
  246. package/dist/pipeline/agent-ajv.js +14 -0
  247. package/dist/pipeline/agent-steps.d.ts +329 -0
  248. package/dist/pipeline/agent-steps.js +602 -0
  249. package/dist/pipeline/artifacts.d.ts +264 -0
  250. package/dist/pipeline/artifacts.js +425 -0
  251. package/dist/pipeline/diff.d.ts +45 -0
  252. package/dist/pipeline/diff.js +177 -0
  253. package/dist/pipeline/fold.d.ts +43 -0
  254. package/dist/pipeline/fold.js +140 -0
  255. package/dist/pipeline/generate.d.ts +52 -0
  256. package/dist/pipeline/generate.js +120 -0
  257. package/dist/pipeline/product.d.ts +225 -0
  258. package/dist/pipeline/product.js +257 -0
  259. package/dist/pipeline/promote.d.ts +404 -0
  260. package/dist/pipeline/promote.js +694 -0
  261. package/dist/pipeline/read.d.ts +37 -0
  262. package/dist/pipeline/read.js +58 -0
  263. package/dist/pipeline/rendered.d.ts +25 -0
  264. package/dist/pipeline/rendered.js +53 -0
  265. package/dist/pipeline/soak-checks.d.ts +80 -0
  266. package/dist/pipeline/soak-checks.js +254 -0
  267. package/dist/pipeline/soak-gate.d.ts +97 -0
  268. package/dist/pipeline/soak-gate.js +176 -0
  269. package/dist/pipeline/soak-sources.d.ts +17 -0
  270. package/dist/pipeline/soak-sources.js +42 -0
  271. package/dist/pipeline/soak.d.ts +260 -0
  272. package/dist/pipeline/soak.js +378 -0
  273. package/dist/pipeline/spec.d.ts +724 -0
  274. package/dist/pipeline/spec.js +567 -0
  275. package/dist/pipeline/stage-ledger.d.ts +187 -0
  276. package/dist/pipeline/stage-ledger.js +185 -0
  277. package/dist/pipeline/stage-waves.d.ts +114 -0
  278. package/dist/pipeline/stage-waves.js +161 -0
  279. package/dist/pipeline/stages.d.ts +64 -0
  280. package/dist/pipeline/stages.js +174 -0
  281. package/dist/pipeline/verify-rollback.d.ts +277 -0
  282. package/dist/pipeline/verify-rollback.js +393 -0
  283. package/dist/pipeline.d.ts +142 -0
  284. package/dist/pipeline.js +143 -0
  285. package/dist/pr-loop.d.ts +22 -0
  286. package/dist/pr-loop.js +8 -0
  287. package/dist/pr-plan-note.d.ts +15 -1
  288. package/dist/pr-plan-note.js +8 -0
  289. package/dist/pr-post.d.ts +31 -0
  290. package/dist/pr-post.js +89 -0
  291. package/dist/release-floors.d.ts +1 -1
  292. package/dist/release-floors.js +1 -1
  293. package/dist/report-store/audit.schema.json +50 -0
  294. package/dist/report-store/dora.schema.json +331 -0
  295. package/dist/report-store/estate.schema.json +96 -0
  296. package/dist/report-store/run.schema.json +14 -0
  297. package/dist/report-store.d.ts +151 -0
  298. package/dist/report-store.js +344 -0
  299. package/dist/run-event.d.ts +7 -2
  300. package/dist/wave-runtime.mjs +458 -404
  301. package/dist/workspace/catalog-edges.js +3 -3
  302. package/dist/workspace/change-set.schema.json +4 -0
  303. package/dist/workspace/ci-cloud-identity.d.ts +4 -0
  304. package/dist/workspace/ci-cloud-identity.js +30 -0
  305. package/dist/workspace/ci-run.js +17 -2
  306. package/dist/workspace/ci-secrets.d.ts +3 -1
  307. package/dist/workspace/ci-secrets.js +7 -1
  308. package/dist/workspace/compose-graph.d.ts +1 -1
  309. package/dist/workspace/compose-graph.js +3 -1
  310. package/dist/workspace/declaration.d.ts +27 -0
  311. package/dist/workspace/declaration.js +35 -0
  312. package/dist/workspace/declaration.schema.json +56 -0
  313. package/dist/workspace/graph-cli.js +26 -0
  314. package/dist/workspace/graph.schema.json +5 -1
  315. package/dist/workspace/identity-gate-rule.d.ts +4 -0
  316. package/dist/workspace/identity-gate-rule.js +2 -2
  317. package/dist/workspace/identity-reject-rule.d.ts +14 -0
  318. package/dist/workspace/identity-reject-rule.js +24 -0
  319. package/dist/workspace/identity.d.ts +3 -0
  320. package/dist/workspace/identity.js +2 -1
  321. package/dist/workspace/nested-graph.js +2 -0
  322. package/dist/workspace/pr-report.schema.json +65 -0
  323. package/dist/workspace/promotion-order.d.ts +19 -4
  324. package/dist/workspace/promotion-order.js +26 -4
  325. package/dist/workspace/release-train.d.ts +14 -0
  326. package/dist/workspace/release-train.js +32 -0
  327. package/dist/workspace/run-event.schema.json +2 -2
  328. package/dist/workspace/stack-read-edges.d.ts +19 -0
  329. package/dist/workspace/stack-read-edges.js +54 -0
  330. package/dist/workspace/status-gates.d.ts +51 -1
  331. package/dist/workspace/status-gates.js +60 -0
  332. package/dist/workspace/status-stages.d.ts +223 -0
  333. package/dist/workspace/status-stages.js +279 -0
  334. package/dist/workspace/status.d.ts +45 -1
  335. package/dist/workspace/status.js +109 -5
  336. package/dist/workspace/status.schema.json +283 -2
  337. package/dist/workspace/train-cut.js +5 -2
  338. package/dist/workspace/train-shell.d.ts +18 -0
  339. package/dist/workspace/train-shell.js +43 -0
  340. package/dist/workspace/trust/seal.d.ts +7 -0
  341. package/dist/workspace/trust/seal.js +9 -0
  342. package/package.json +5 -1
@@ -0,0 +1,344 @@
1
+ /**
2
+ * `@intentius/chant/report-store` (#5336): the schema ids of what the CI
3
+ * products put in their report store, and one audit line for all of them.
4
+ *
5
+ * ## Schema ids
6
+ *
7
+ * Each document names its schema in `schema`. The product-neutral ids are
8
+ * {@link REPORT_SCHEMAS}, `chant.<kind>/v1`, and a document under one names
9
+ * its product in `product`. The ids the products wrote before,
10
+ * `<product>.estate/v1`, `<product>.dora/v1`, `<product>.report/v1`,
11
+ * `<product>.run/v1` and `<product>.audit/v1`, stay readable:
12
+ * {@link readReportSchema} gives the kind and the product of either.
13
+ * `ci-estate` writes the neutral ids when a product passes
14
+ * `schemas: "neutral"`, and the product-named ids otherwise.
15
+ *
16
+ * The JSON Schemas are `@intentius/chant/report-store/<kind>.schema.json`
17
+ * ({@link REPORT_SCHEMA_FILES}), so a reader such as behold validates every
18
+ * product's files with chant installed and no product. The estate and DORA
19
+ * schemas take a product-named id too; the audit schema is the neutral line,
20
+ * and {@link readAuditLine} maps a product's line onto it.
21
+ *
22
+ * ## The audit line
23
+ *
24
+ * `chant.audit/v1` ({@link AuditLine}) is terragucci's `audit.jsonl` line
25
+ * with the product and, for sql-yodeler's lines, the environment added. Its
26
+ * `kind` is one of {@link AUDIT_KINDS}, the vocabulary's
27
+ * `PRODUCT_AUDIT_KINDS` (`approved`, `applied`, ...), and a line read from a
28
+ * product that spelled the kind another way keeps that word in
29
+ * `product_kind`. Fields a product's line carries that the schema does not
30
+ * name are kept in `product_fields`, so {@link toProductAuditLine} gives the
31
+ * product's line back unchanged.
32
+ *
33
+ * {@link auditLinesFromLedger} builds the lines from the gate ledger
34
+ * (`deriveGateAudit`, ./lifecycle/gate-audit.ts) for any product, and
35
+ * {@link writeAuditRecord} appends them to `audit.jsonl` in the report store,
36
+ * keeping every line the record holds, in whatever format it was written.
37
+ */
38
+ import { PRODUCT_AUDIT_KINDS } from "./ci-product-words.js";
39
+ /** The first chant with `@intentius/chant/report-store`: the product-neutral schema ids, the `chant.audit/v1` line and its readers, the published schemas, and `ci-estate`'s `schemas: "neutral"` and promote and rollback counts (#5336). */
40
+ export const REPORT_STORE_FLOOR = "0.124.110";
41
+ /** The product-neutral schema ids. */
42
+ export const REPORT_SCHEMAS = /* @__PURE__ */ Object.freeze({
43
+ estate: "chant.estate/v1",
44
+ dora: "chant.dora/v1",
45
+ run: "chant.run/v1",
46
+ audit: "chant.audit/v1",
47
+ });
48
+ /** The published JSON Schema of each kind, as a package path. */
49
+ export const REPORT_SCHEMA_FILES = /* @__PURE__ */ Object.freeze({
50
+ estate: "@intentius/chant/report-store/estate.schema.json",
51
+ dora: "@intentius/chant/report-store/dora.schema.json",
52
+ run: "@intentius/chant/report-store/run.schema.json",
53
+ audit: "@intentius/chant/report-store/audit.schema.json",
54
+ });
55
+ /** The prefix of the neutral ids. */
56
+ const NEUTRAL = "chant";
57
+ /** The word after the product in a product-named id, by kind: terragucci's stage report is `report`, its run view `run`. */
58
+ const ID_WORDS = { estate: "estate", dora: "dora", report: "run", run: "run", audit: "audit" };
59
+ const ID_RE = /^([a-z][a-z0-9-]*)\.([a-z][a-z0-9-]*)\/v1$/;
60
+ /** The kind of a schema id, neutral or product-named, or undefined for an id the report store does not hold. */
61
+ export function readReportSchema(id) {
62
+ if (typeof id !== "string")
63
+ return undefined;
64
+ const m = ID_RE.exec(id);
65
+ if (!m)
66
+ return undefined;
67
+ const kind = ID_WORDS[m[2]];
68
+ if (!kind)
69
+ return undefined;
70
+ if (m[1] === NEUTRAL)
71
+ return { kind, neutral: true };
72
+ return { kind, product: m[1], neutral: false };
73
+ }
74
+ /** The product a document came from: its `product`, else the product its schema id names. */
75
+ export function reportProduct(doc) {
76
+ if (typeof doc.product === "string" && doc.product !== "")
77
+ return doc.product;
78
+ const s = readReportSchema(doc.schema);
79
+ if (!s)
80
+ return undefined;
81
+ return s.product ?? NEUTRAL;
82
+ }
83
+ /** `doc` under the neutral id of `kind`, with `product` after `schema`. */
84
+ export function neutralReport(doc, kind, product) {
85
+ const { schema: _schema, product: _product, ...rest } = doc;
86
+ return { schema: REPORT_SCHEMAS[kind], product, ...rest };
87
+ }
88
+ // ── the audit line ───────────────────────────────────────────────────────
89
+ export const AUDIT_KINDS = [
90
+ "approval-requested",
91
+ "approved",
92
+ "revoked",
93
+ "override-requested",
94
+ "override-recorded",
95
+ "override-spent",
96
+ "applied",
97
+ "refused",
98
+ "hook",
99
+ "recorded",
100
+ ];
101
+ const isRow = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
102
+ const str = (v) => (typeof v === "string" ? v : undefined);
103
+ const KIND_OF = new Map(Object.entries(PRODUCT_AUDIT_KINDS).flatMap(([kind, aliases]) => [[kind, kind], ...aliases.map((a) => [a, kind])]));
104
+ /** The audit kind a product's word names: the kind itself, an alias of one, or `recorded`. */
105
+ export function auditKindOf(word) {
106
+ return KIND_OF.get(word) ?? "recorded";
107
+ }
108
+ const TERRAGUCCI_FIELDS = new Set(["schema", "id", "kind", "project", "at", "who", "what", "digest", "result", "evidence", "detail"]);
109
+ const YODELER_FIELDS = new Set(["id", "at", "environment", "kind", "by", "migration", "digest", "detail", "wave", "source"]);
110
+ const rest = (row, known) => {
111
+ const out = Object.fromEntries(Object.entries(row).filter(([k]) => !known.has(k)));
112
+ return Object.keys(out).length ? out : undefined;
113
+ };
114
+ function fromTerragucci(row, product) {
115
+ const id = str(row.id);
116
+ const word = str(row.kind);
117
+ if (!id || !word || !isRow(row.evidence))
118
+ return undefined;
119
+ const kind = auditKindOf(word);
120
+ const extra = rest(row, TERRAGUCCI_FIELDS);
121
+ return {
122
+ schema: REPORT_SCHEMAS.audit,
123
+ product,
124
+ id,
125
+ kind,
126
+ ...(kind !== word ? { product_kind: word } : {}),
127
+ project: str(row.project) ?? "",
128
+ at: str(row.at) ?? "",
129
+ who: str(row.who) ?? null,
130
+ what: str(row.what) ?? "",
131
+ digest: str(row.digest) ?? null,
132
+ result: str(row.result) ?? "",
133
+ evidence: row.evidence,
134
+ ...(isRow(row.detail) ? { detail: row.detail } : {}),
135
+ ...(extra ? { product_fields: extra } : {}),
136
+ };
137
+ }
138
+ /** sql-yodeler's `result` for each of its kinds: a wait, or the kind's own word. */
139
+ const yodelerResult = (word) => (word === "approval-requested" ? "waiting" : word);
140
+ function fromYodeler(row, product, project) {
141
+ const id = str(row.id);
142
+ const word = str(row.kind);
143
+ const environment = str(row.environment);
144
+ const source = row.source;
145
+ if (!id || !word || environment === undefined || !isRow(source))
146
+ return undefined;
147
+ // A failed migration row is an apply that failed.
148
+ const kind = word === "failed" ? "applied" : auditKindOf(word);
149
+ const evidence = typeof source.history === "string"
150
+ ? { source: "history", table: source.history, ...(typeof source.seq === "number" ? { seq: source.seq } : {}), ...(typeof source.run === "string" ? { run: source.run } : {}) }
151
+ : { source: "ledger", ...(typeof source.ledger === "string" ? { path: source.ledger } : {}), ...(typeof source.op === "string" ? { op: source.op } : {}), ...(typeof source.gate === "string" ? { gate: source.gate } : {}) };
152
+ const migration = str(row.migration);
153
+ const detail = {
154
+ ...(migration !== undefined ? { migration } : {}),
155
+ ...(row.detail !== undefined ? { text: row.detail } : {}),
156
+ ...(row.wave !== undefined ? { wave: row.wave } : {}),
157
+ };
158
+ const extra = rest(row, YODELER_FIELDS);
159
+ return {
160
+ schema: REPORT_SCHEMAS.audit,
161
+ product,
162
+ id,
163
+ kind,
164
+ ...(kind !== word ? { product_kind: word } : {}),
165
+ project,
166
+ environment,
167
+ at: str(row.at) ?? "",
168
+ who: str(row.by) ?? null,
169
+ what: migration ?? str(source.gate) ?? environment,
170
+ digest: str(row.digest) ?? null,
171
+ result: yodelerResult(word),
172
+ evidence,
173
+ ...(Object.keys(detail).length ? { detail } : {}),
174
+ ...(extra ? { product_fields: extra } : {}),
175
+ };
176
+ }
177
+ /**
178
+ * One audit line as `chant.audit/v1`: a neutral line as it is, a
179
+ * terragucci-format line (`<product>.audit/v1`) or a sql-yodeler line
180
+ * mapped onto it. Undefined for anything else.
181
+ */
182
+ export function readAuditLine(raw, options = {}) {
183
+ if (!isRow(raw))
184
+ return undefined;
185
+ const schema = readReportSchema(raw.schema);
186
+ if (schema?.kind === "audit" && schema.neutral) {
187
+ return typeof raw.id === "string" && typeof raw.product === "string" && AUDIT_KINDS.includes(raw.kind) ? raw : undefined;
188
+ }
189
+ if (schema?.kind === "audit")
190
+ return fromTerragucci(raw, schema.product);
191
+ if (raw.schema === undefined)
192
+ return fromYodeler(raw, options.product ?? "sql-yodeler", options.project ?? "default");
193
+ return undefined;
194
+ }
195
+ /** Every line of an `audit.jsonl` as `chant.audit/v1`, and the 1-based numbers of the lines that are not audit lines. */
196
+ export function readAuditRecord(text, options = {}) {
197
+ const lines = [];
198
+ const unreadable = [];
199
+ text.split("\n").forEach((t, i) => {
200
+ if (t.trim() === "")
201
+ return;
202
+ let v;
203
+ try {
204
+ v = JSON.parse(t);
205
+ }
206
+ catch {
207
+ unreadable.push(i + 1);
208
+ return;
209
+ }
210
+ const line = readAuditLine(v, options);
211
+ if (line)
212
+ lines.push(line);
213
+ else
214
+ unreadable.push(i + 1);
215
+ });
216
+ return { lines, unreadable };
217
+ }
218
+ /**
219
+ * A line in a product's own format again, for a product that keeps writing
220
+ * it: a line read from that format comes back as it was read.
221
+ */
222
+ export function toProductAuditLine(line, format) {
223
+ const kind = line.product_kind ?? line.kind;
224
+ if (format === "terragucci") {
225
+ return {
226
+ schema: `${line.product}.audit/v1`,
227
+ id: line.id,
228
+ kind,
229
+ project: line.project,
230
+ at: line.at,
231
+ who: line.who,
232
+ what: line.what,
233
+ digest: line.digest,
234
+ result: line.result,
235
+ evidence: line.evidence,
236
+ ...(line.detail ? { detail: line.detail } : {}),
237
+ ...line.product_fields,
238
+ };
239
+ }
240
+ const d = line.detail ?? {};
241
+ const e = line.evidence;
242
+ const source = e.source === "history"
243
+ ? { history: e.table, ...(e.seq !== undefined ? { seq: e.seq } : {}), ...(e.run !== undefined ? { run: e.run } : {}) }
244
+ : { ...(e.path !== undefined ? { ledger: e.path } : {}), ...(e.op !== undefined ? { op: e.op } : {}), ...(e.gate !== undefined ? { gate: e.gate } : {}) };
245
+ return {
246
+ id: line.id,
247
+ at: line.at,
248
+ environment: line.environment ?? "",
249
+ kind,
250
+ ...(line.who !== null ? { by: line.who } : {}),
251
+ ...(typeof d.migration === "string" ? { migration: d.migration } : {}),
252
+ ...(line.digest !== null ? { digest: line.digest } : {}),
253
+ ...(d.text !== undefined ? { detail: d.text } : {}),
254
+ ...(d.wave !== undefined ? { wave: d.wave } : {}),
255
+ source,
256
+ ...line.product_fields,
257
+ };
258
+ }
259
+ // ── from the ledger ──────────────────────────────────────────────────────
260
+ /** How a gate entry came out, as the line's `result`. */
261
+ function resultOf(e) {
262
+ switch (e.kind) {
263
+ case "approval-requested":
264
+ return "waiting";
265
+ case "override-requested":
266
+ return "denied";
267
+ case "approved":
268
+ case "override-recorded":
269
+ return e.seal ?? "unsigned";
270
+ case "revoked":
271
+ return "revoked";
272
+ case "applied":
273
+ return typeof e.detail.result === "string" ? e.detail.result : "applied";
274
+ case "override-spent":
275
+ return "spent";
276
+ case "hook":
277
+ return e.hook?.outcome ?? "ran";
278
+ }
279
+ }
280
+ const ENTRY_FIELDS = new Set(["id", "kind", "at", "gate", "digest", "by", "detail", "source"]);
281
+ /** The audit lines of the gate ledger's entries (`deriveGateAudit`), for any product. */
282
+ export function auditLinesFromLedger(entries, options) {
283
+ return entries.map((e) => {
284
+ const s = e.source;
285
+ const ledger = s.change === "added" || s.change === "removed";
286
+ const evidence = ledger
287
+ ? { source: "ledger", branch: options.branch ?? "chant/lifecycle", path: s.path, ...(s.op ? { op: s.op } : {}), gate: e.gate, ...(s.line !== undefined ? { line: s.line } : {}), ...(s.commit ? { commit: s.commit } : {}) }
288
+ : { source: s.change === "decision" ? "run" : "report", key: s.path, gate: e.gate, ...(s.commit ? { commit: s.commit } : {}) };
289
+ const typed = Object.fromEntries(Object.entries(e).filter(([k, v]) => !ENTRY_FIELDS.has(k) && v !== undefined));
290
+ const detail = { ...e.detail, ...typed };
291
+ return {
292
+ schema: REPORT_SCHEMAS.audit,
293
+ product: options.product,
294
+ id: e.id,
295
+ kind: e.kind,
296
+ project: options.project,
297
+ ...(options.environment ? { environment: options.environment } : {}),
298
+ at: e.at,
299
+ who: e.by ?? null,
300
+ what: e.gate,
301
+ digest: e.digest ?? null,
302
+ result: resultOf(e),
303
+ evidence,
304
+ ...(Object.keys(detail).length ? { detail } : {}),
305
+ };
306
+ });
307
+ }
308
+ // ── the record in the store ──────────────────────────────────────────────
309
+ /** The record's name at the top of a reports prefix. */
310
+ export const AUDIT_RECORD_FILE = "audit.jsonl";
311
+ /**
312
+ * Append the lines whose id the record lacks to `audit.jsonl` in the report
313
+ * store. Every line already there is kept as it is, whatever its format;
314
+ * nothing is written when nothing is new.
315
+ */
316
+ export async function writeAuditRecord(lines, options) {
317
+ const key = options.key ?? AUDIT_RECORD_FILE;
318
+ const before = (await options.get(key)) ?? "";
319
+ const have = new Set();
320
+ for (const t of before.split("\n")) {
321
+ if (t.trim() === "")
322
+ continue;
323
+ try {
324
+ const v = JSON.parse(t);
325
+ if (isRow(v) && typeof v.id === "string")
326
+ have.add(v.id);
327
+ }
328
+ catch {
329
+ // A line that is not JSON stays in the record and holds no id.
330
+ }
331
+ }
332
+ const fresh = [];
333
+ for (const l of lines) {
334
+ if (have.has(l.id))
335
+ continue;
336
+ have.add(l.id);
337
+ fresh.push(l);
338
+ }
339
+ if (fresh.length === 0)
340
+ return { key, added: 0 };
341
+ const head = before === "" || before.endsWith("\n") ? before : `${before}\n`;
342
+ await options.put(key, head + fresh.map((l) => `${JSON.stringify(l)}\n`).join(""), "application/x-ndjson");
343
+ return { key, added: fresh.length };
344
+ }
@@ -44,8 +44,13 @@ export type RunEventSettleStatus = "ok" | "failed" | "gated" | "waiting";
44
44
  * `cached` is for a cache hit standing in for the step (#4015).
45
45
  */
46
46
  export type RunEventStepStatus = "ok" | "failed" | "skipped" | "cached" | "gated" | "waiting";
47
- /** Why a step was skipped. */
48
- export type RunEventSkipReason = "receipt" | "resumed" | "refused" | "not-run";
47
+ /**
48
+ * Why a step was skipped. `environment` (#5401) is a gate step whose
49
+ * `environments` names other environments than the run's; chant
50
+ * `GATE_ENVIRONMENTS_FLOOR` (./components/step-environments.ts) and newer
51
+ * write it.
52
+ */
53
+ export type RunEventSkipReason = "receipt" | "resumed" | "refused" | "not-run" | "environment";
49
54
  /** How a gate's approval passed, when it was more than one person's approval of that gate. */
50
55
  export type RunEventGateVia = "quorum" | "policy" | "point" | "alias" | "empty" | "workspace";
51
56
  /** The run every event of a stream names: the same on every line. */