@intentius/chant 0.124.97 → 0.124.98

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 (223) hide show
  1. package/dist/audit/core.d.ts +29 -0
  2. package/dist/audit/core.d.ts.map +1 -1
  3. package/dist/audit/core.js +48 -11
  4. package/dist/audit/identity.d.ts +27 -0
  5. package/dist/audit/identity.d.ts.map +1 -0
  6. package/dist/audit/identity.js +36 -0
  7. package/dist/audit/report-html.d.ts +3 -1
  8. package/dist/audit/report-html.d.ts.map +1 -1
  9. package/dist/audit/report-html.js +1 -1
  10. package/dist/audit/report-model.d.ts +16 -0
  11. package/dist/audit/report-model.d.ts.map +1 -1
  12. package/dist/audit/report-model.js +5 -1
  13. package/dist/ci-agent.d.ts +17 -0
  14. package/dist/ci-agent.d.ts.map +1 -1
  15. package/dist/ci-agent.js +32 -0
  16. package/dist/ci-comment-allow.d.ts +88 -0
  17. package/dist/ci-comment-allow.d.ts.map +1 -0
  18. package/dist/ci-comment-allow.js +178 -0
  19. package/dist/ci-comment-commands.d.ts +12 -0
  20. package/dist/ci-comment-commands.d.ts.map +1 -1
  21. package/dist/ci-comment-commands.js +22 -0
  22. package/dist/ci-control.d.ts +6 -1
  23. package/dist/ci-control.d.ts.map +1 -1
  24. package/dist/ci-control.js +6 -1
  25. package/dist/ci-product.d.ts +3 -0
  26. package/dist/ci-product.d.ts.map +1 -1
  27. package/dist/ci-product.js +3 -0
  28. package/dist/cli/commands/audit.d.ts +3 -1
  29. package/dist/cli/commands/audit.d.ts.map +1 -1
  30. package/dist/cli/commands/audit.js +23 -6
  31. package/dist/cli/commands/import.d.ts +8 -1
  32. package/dist/cli/commands/import.d.ts.map +1 -1
  33. package/dist/cli/commands/import.js +31 -6
  34. package/dist/cli/handlers/agent.d.ts.map +1 -1
  35. package/dist/cli/handlers/agent.js +12 -2
  36. package/dist/cli/handlers/pr-comment.d.ts +6 -0
  37. package/dist/cli/handlers/pr-comment.d.ts.map +1 -1
  38. package/dist/cli/handlers/pr-comment.js +12 -0
  39. package/dist/cli/handlers/promote.d.ts.map +1 -1
  40. package/dist/cli/handlers/promote.js +53 -6
  41. package/dist/cli/main.d.ts.map +1 -1
  42. package/dist/cli/main.js +29 -6
  43. package/dist/cli/parse-args.d.ts.map +1 -1
  44. package/dist/cli/parse-args.js +23 -0
  45. package/dist/cli/registry.d.ts +8 -0
  46. package/dist/cli/registry.d.ts.map +1 -1
  47. package/dist/cloud-lister/mask.d.ts +30 -1
  48. package/dist/cloud-lister/mask.d.ts.map +1 -1
  49. package/dist/cloud-lister/mask.js +66 -3
  50. package/dist/components/driver.d.ts +8 -1
  51. package/dist/components/driver.d.ts.map +1 -1
  52. package/dist/components/driver.js +1 -0
  53. package/dist/components/product-pipeline.d.ts +23 -1
  54. package/dist/components/product-pipeline.d.ts.map +1 -1
  55. package/dist/components/product-pipeline.js +40 -7
  56. package/dist/components/product-plan.d.ts +20 -0
  57. package/dist/components/product-plan.d.ts.map +1 -1
  58. package/dist/components/product-plan.js +11 -1
  59. package/dist/control/applied.d.ts +8 -1
  60. package/dist/control/applied.d.ts.map +1 -1
  61. package/dist/control/applied.js +18 -2
  62. package/dist/control/dispatch.d.ts +52 -0
  63. package/dist/control/dispatch.d.ts.map +1 -1
  64. package/dist/control/dispatch.js +140 -4
  65. package/dist/control/train.d.ts +198 -0
  66. package/dist/control/train.d.ts.map +1 -0
  67. package/dist/control/train.js +294 -0
  68. package/dist/deep-observation.js +2 -2
  69. package/dist/floor-table.data.d.ts.map +1 -1
  70. package/dist/floor-table.data.js +11 -0
  71. package/dist/graph-detail.d.ts +9 -0
  72. package/dist/graph-detail.d.ts.map +1 -1
  73. package/dist/graph-detail.js +38 -13
  74. package/dist/graph-refs.d.ts +233 -3
  75. package/dist/graph-refs.d.ts.map +1 -1
  76. package/dist/graph-refs.js +106 -15
  77. package/dist/lint/post-synth.d.ts +22 -0
  78. package/dist/lint/post-synth.d.ts.map +1 -1
  79. package/dist/lint/rules/declarable-naming-convention.d.ts +12 -0
  80. package/dist/lint/rules/declarable-naming-convention.d.ts.map +1 -1
  81. package/dist/lint/rules/declarable-naming-convention.js +38 -8
  82. package/dist/lint/rules/imported-source.d.ts +20 -0
  83. package/dist/lint/rules/imported-source.d.ts.map +1 -0
  84. package/dist/lint/rules/imported-source.js +27 -0
  85. package/dist/lint/rules/no-unused-declarable.d.ts.map +1 -1
  86. package/dist/lint/rules/no-unused-declarable.js +3 -0
  87. package/dist/op/gate.d.ts +2 -0
  88. package/dist/op/gate.d.ts.map +1 -1
  89. package/dist/op/gate.js +8 -1
  90. package/dist/pr-forge-reads.d.ts +17 -0
  91. package/dist/pr-forge-reads.d.ts.map +1 -1
  92. package/dist/pr-forge-reads.js +55 -0
  93. package/dist/release-floors.d.ts +9 -1
  94. package/dist/release-floors.d.ts.map +1 -1
  95. package/dist/release-floors.js +9 -1
  96. package/dist/repo-path.d.ts +29 -0
  97. package/dist/repo-path.d.ts.map +1 -0
  98. package/dist/repo-path.js +81 -0
  99. package/dist/sensitive-key.d.ts +23 -0
  100. package/dist/sensitive-key.d.ts.map +1 -1
  101. package/dist/sensitive-key.js +37 -0
  102. package/dist/terraform/hcl2json.d.ts +7 -0
  103. package/dist/terraform/hcl2json.d.ts.map +1 -1
  104. package/dist/terraform/hcl2json.js +7 -0
  105. package/dist/wave-runtime.mjs +352 -345
  106. package/dist/workspace/catalog-edges.d.ts +147 -0
  107. package/dist/workspace/catalog-edges.d.ts.map +1 -0
  108. package/dist/workspace/catalog-edges.js +461 -0
  109. package/dist/workspace/compose-graph.d.ts +73 -3
  110. package/dist/workspace/compose-graph.d.ts.map +1 -1
  111. package/dist/workspace/declaration.d.ts +2 -0
  112. package/dist/workspace/declaration.d.ts.map +1 -1
  113. package/dist/workspace/declaration.js +1 -0
  114. package/dist/workspace/declaration.schema.json +6 -0
  115. package/dist/workspace/discover.d.ts +134 -0
  116. package/dist/workspace/discover.d.ts.map +1 -0
  117. package/dist/workspace/discover.js +372 -0
  118. package/dist/workspace/graph-cli.d.ts +20 -0
  119. package/dist/workspace/graph-cli.d.ts.map +1 -1
  120. package/dist/workspace/graph-cli.js +178 -20
  121. package/dist/workspace/graph.schema.json +195 -2
  122. package/dist/workspace/release-train.d.ts +214 -3
  123. package/dist/workspace/release-train.d.ts.map +1 -1
  124. package/dist/workspace/release-train.js +552 -16
  125. package/dist/workspace/repo-ref.d.ts +14 -0
  126. package/dist/workspace/repo-ref.d.ts.map +1 -1
  127. package/dist/workspace/repo-ref.js +26 -1
  128. package/dist/workspace/workspace-gates.d.ts +24 -0
  129. package/dist/workspace/workspace-gates.d.ts.map +1 -1
  130. package/dist/workspace/workspace-gates.js +29 -5
  131. package/dist/workspace/workspace-ledger.d.ts +31 -5
  132. package/dist/workspace/workspace-ledger.d.ts.map +1 -1
  133. package/dist/workspace/workspace-ledger.js +2 -1
  134. package/dist/workspace/workspace-run.d.ts +14 -0
  135. package/dist/workspace/workspace-run.d.ts.map +1 -1
  136. package/dist/workspace/workspace-run.js +2 -2
  137. package/dist/yaml.d.ts.map +1 -1
  138. package/dist/yaml.js +33 -8
  139. package/package.json +1 -1
  140. package/src/audit/core.test.ts +64 -1
  141. package/src/audit/core.ts +75 -10
  142. package/src/audit/identity.test.ts +31 -0
  143. package/src/audit/identity.ts +43 -0
  144. package/src/audit/report-html.ts +4 -2
  145. package/src/audit/report-model.ts +21 -1
  146. package/src/ci-agent.test.ts +32 -0
  147. package/src/ci-agent.ts +42 -0
  148. package/src/ci-comment-allow.test.ts +380 -0
  149. package/src/ci-comment-allow.ts +184 -0
  150. package/src/ci-comment-commands.ts +25 -0
  151. package/src/ci-control.ts +42 -0
  152. package/src/ci-product.ts +3 -0
  153. package/src/cli/commands/audit-parser-notice.test.ts +74 -0
  154. package/src/cli/commands/audit.test.ts +12 -0
  155. package/src/cli/commands/audit.ts +25 -7
  156. package/src/cli/commands/import-layout.test.ts +2 -1
  157. package/src/cli/commands/import.ts +29 -6
  158. package/src/cli/handlers/agent.ts +13 -2
  159. package/src/cli/handlers/pr-comment.ts +12 -0
  160. package/src/cli/handlers/promote.test.ts +68 -0
  161. package/src/cli/handlers/promote.ts +52 -6
  162. package/src/cli/main.test.ts +5 -0
  163. package/src/cli/main.ts +29 -6
  164. package/src/cli/parse-args.ts +18 -0
  165. package/src/cli/registry.ts +8 -0
  166. package/src/cloud-lister/kubernetes.k3d.e2e.test.ts +104 -0
  167. package/src/cloud-lister/mask-references.test.ts +132 -0
  168. package/src/cloud-lister/mask.ts +68 -3
  169. package/src/components/driver.ts +9 -1
  170. package/src/components/product-pipeline.ts +57 -7
  171. package/src/components/product-plan.ts +27 -2
  172. package/src/control/applied.ts +33 -3
  173. package/src/control/dispatch.ts +156 -5
  174. package/src/control/train.test.ts +215 -0
  175. package/src/control/train.ts +413 -0
  176. package/src/deep-observation.ts +2 -2
  177. package/src/floor-table.data.ts +6 -0
  178. package/src/graph-detail.ts +37 -12
  179. package/src/graph-refs.test.ts +45 -1
  180. package/src/graph-refs.ts +321 -14
  181. package/src/lint/post-synth.ts +20 -0
  182. package/src/lint/rules/declarable-naming-convention.test.ts +35 -1
  183. package/src/lint/rules/declarable-naming-convention.ts +35 -8
  184. package/src/lint/rules/imported-source.test.ts +22 -0
  185. package/src/lint/rules/imported-source.ts +31 -0
  186. package/src/lint/rules/no-unused-declarable.test.ts +16 -0
  187. package/src/lint/rules/no-unused-declarable.ts +7 -0
  188. package/src/op/gate.ts +10 -2
  189. package/src/pr-forge-reads.ts +62 -0
  190. package/src/release-floors.ts +13 -1
  191. package/src/repo-path.test.ts +72 -0
  192. package/src/repo-path.ts +103 -0
  193. package/src/sensitive-key.ts +38 -0
  194. package/src/terraform/hcl2json.ts +8 -0
  195. package/src/workspace/application-set.e2e.test.ts +405 -0
  196. package/src/workspace/catalog-edges.ts +507 -0
  197. package/src/workspace/ci-green-workflow.test.ts +2 -2
  198. package/src/workspace/cluster-join.e2e.test.ts +150 -0
  199. package/src/workspace/compose-graph.ts +74 -5
  200. package/src/workspace/declaration.schema.json +6 -0
  201. package/src/workspace/declaration.ts +3 -0
  202. package/src/workspace/discover.e2e.test.ts +122 -0
  203. package/src/workspace/discover.test.ts +225 -0
  204. package/src/workspace/discover.ts +406 -0
  205. package/src/workspace/external-secret-catalog.e2e.test.ts +98 -0
  206. package/src/workspace/external-secret-catalog.test.ts +142 -0
  207. package/src/workspace/graph-cli.ts +207 -21
  208. package/src/workspace/graph-contract.test.ts +92 -0
  209. package/src/workspace/graph.schema.json +195 -2
  210. package/src/workspace/helm-references.e2e.test.ts +135 -0
  211. package/src/workspace/identity-annotation-catalog.e2e.test.ts +91 -0
  212. package/src/workspace/identity-annotation-catalog.test.ts +139 -0
  213. package/src/workspace/release-train-repos.test.ts +304 -0
  214. package/src/workspace/release-train.test.ts +296 -0
  215. package/src/workspace/release-train.ts +631 -16
  216. package/src/workspace/repo-ref.ts +26 -1
  217. package/src/workspace/runs-on.test.ts +45 -0
  218. package/src/workspace/workspace-gates.ts +48 -5
  219. package/src/workspace/workspace-ledger.ts +28 -5
  220. package/src/workspace/workspace-run.test.ts +1 -1
  221. package/src/workspace/workspace-run.ts +2 -2
  222. package/src/yaml.test.ts +96 -8
  223. package/src/yaml.ts +36 -8
package/src/ci-control.ts CHANGED
@@ -11,6 +11,10 @@
11
11
  * - The control repo's projects and defaults as `control-entry` records on
12
12
  * its workspace ledger (./control/records.ts).
13
13
  * - Reconcile over the product's generator (./control/reconcile.ts).
14
+ * - A release train across repositories (./control/train.ts, #5119): the
15
+ * control repo's dispatch into each member repository, the member's train
16
+ * job that runs the release and answers with its applied dispatch, and the
17
+ * control repo's job that starts the promote.
14
18
  * - Each project's `consumers.json` joined into one consumer list per
15
19
  * release version, for the release catalog (./control/consumers.ts, #4600).
16
20
  * - The apply outcome an op waves pipeline's dispatch carries, and the
@@ -58,6 +62,15 @@ export {
58
62
  CONTROL_TOKEN_ENV,
59
63
  CONTROL_TOKEN_SECRET,
60
64
  CONTROL_TOKEN_VARS,
65
+ CONTROL_TRAIN_VAR,
66
+ CONTROL_RUN_VAR,
67
+ CONTROL_ENV_VAR,
68
+ CONTROL_RELEASE_VAR,
69
+ CONTROL_TRAIN_ID,
70
+ CONTROL_RUN_ID,
71
+ CONTROL_RELEASE_DIGEST,
72
+ controlTrainProblems,
73
+ type ControlTrainAnswer,
61
74
  ControlConfigError,
62
75
  ControlDispatchError,
63
76
  controlDependentsScript,
@@ -172,3 +185,32 @@ export {
172
185
  type CrossStackEdge,
173
186
  type CrossStackRead,
174
187
  } from "./control/edges";
188
+ export {
189
+ CONTROL_TRAIN_FLOOR,
190
+ TRAIN_COMMIT_VAR,
191
+ TRAIN_ENV_VAR,
192
+ TRAIN_ID_VAR,
193
+ TRAIN_PRODUCT_VAR,
194
+ TRAIN_RELEASE_VAR,
195
+ TRAIN_RUN_VAR,
196
+ dispatchTrainMember,
197
+ trainControlJobSpec,
198
+ trainDispatchEvent,
199
+ trainDispatchProblems,
200
+ trainDispatchRequest,
201
+ trainMemberJobSpec,
202
+ trainMemberTarget,
203
+ trainPipelineFileName,
204
+ trainPipelinePath,
205
+ trainProductOf,
206
+ trainTokenEnv,
207
+ trainTokenEnvOf,
208
+ type DispatchTrainOptions,
209
+ type TrainControlJobSpec,
210
+ type TrainDispatch,
211
+ type TrainDispatchRequest,
212
+ type TrainForge,
213
+ type TrainMemberJobOptions,
214
+ type TrainMemberJobSpec,
215
+ type TrainMemberTarget,
216
+ } from "./control/train";
package/src/ci-product.ts CHANGED
@@ -163,6 +163,9 @@ export const PRODUCT_PLAN_REACH_LOCKS_FLOOR = "0.124.89";
163
163
  export { LOCK_REACH_ENV, reachedTargets, reachOpen, type Reached, type ReachInput } from "./lifecycle/reach-locks";
164
164
  export { productPlanReachLock, type ProductPlanReachLock } from "./components/product-plan";
165
165
  export { planFlagsReply } from "./ci-comment-commands";
166
+ /** INTENTIUS/terragucci#1461: comment commands limited to logins and teams on GitHub and Forgejo. */
167
+ export { COMMENT_ALLOW_COMMANDS, COMMENT_ALLOW_ENV, COMMENT_ALLOW_TOKEN_ENV, TeamReadError, commentAllowProblems, decideCommentAllow, type CommentAllow, type CommentAllowCommand, type CommentAllowDecision, type CommentAllowReads } from "./ci-comment-allow";
168
+ export { COMMENT_ALLOW_FLOOR } from "./release-floors";
166
169
 
167
170
  /**
168
171
  * The first chant whose comment job stops a merged pull request's re-run at a wave (#4979): `/<product> apply wave-<n>` writes a stop for the merge commit on `chant/lifecycle` (`_waves/<op>.stops.json`, `@intentius/chant/op/wave-stop`) before GitHub's re-run or Forgejo's dispatch, and `chant run wave` leaves each wave after n waiting (exit 3).
@@ -0,0 +1,74 @@
1
+ import { describe, test, expect, vi, beforeAll } from "vitest";
2
+ import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from "fs";
3
+ import { tmpdir } from "os";
4
+ import { join } from "path";
5
+
6
+ // The optional HCL parser is absent. Every load of it fails the way an
7
+ // uninstalled package does, so `loadHcl2json` raises `Hcl2JsonNotInstalled`
8
+ // once per audited input, not only on the first.
9
+ vi.mock("../../terraform/hcl2json", async (importOriginal) => {
10
+ const real = await importOriginal<typeof import("../../terraform/hcl2json")>();
11
+ return {
12
+ ...real,
13
+ loadHcl2json: async () => {
14
+ throw new real.Hcl2JsonNotInstalled(new Error("Cannot find package '@cdktn/hcl2json'"));
15
+ },
16
+ };
17
+ });
18
+
19
+ import { auditCommand, printAuditResult } from "./audit";
20
+ import { loadAuditPlugins } from "../../audit/discover";
21
+
22
+ beforeAll(async () => {
23
+ await loadAuditPlugins();
24
+ }, 60_000);
25
+
26
+ function repoWithTerraform(): string {
27
+ const root = mkdtempSync(join(tmpdir(), "chant-audit-parser-"));
28
+ for (const dir of ["envs/prod", "envs/dev"]) {
29
+ mkdirSync(join(root, dir), { recursive: true });
30
+ writeFileSync(join(root, dir, "main.tf"), `resource "aws_s3_bucket" "b" {\n bucket = "${dir.replace("/", "-")}"\n}\n`);
31
+ }
32
+ return root;
33
+ }
34
+
35
+ describe("chant audit with the HCL parser not installed (#5083)", () => {
36
+ test("the JSON report lists the skipped directories and the package", async () => {
37
+ const root = repoWithTerraform();
38
+ try {
39
+ const result = await auditCommand({ path: root, format: "json" });
40
+ expect(result.success).toBe(true);
41
+ const report = JSON.parse(result.output);
42
+ expect(report.skipped).toHaveLength(1);
43
+ expect(report.skipped[0]).toMatchObject({
44
+ lexicon: "terraform",
45
+ reason: "parser-not-installed",
46
+ package: "@cdktn/hcl2json",
47
+ install: "npm install -D @cdktn/hcl2json",
48
+ });
49
+ expect(report.skipped[0].paths.sort()).toEqual(["envs/dev", "envs/prod"]);
50
+ expect(result.skipped).toEqual(report.skipped);
51
+ expect(result.warnings?.[0]?.message).toContain("npm install -D @cdktn/hcl2json");
52
+ } finally {
53
+ rmSync(root, { recursive: true, force: true });
54
+ }
55
+ });
56
+
57
+ test("the text report and the log both say so", async () => {
58
+ const root = repoWithTerraform();
59
+ const errors: string[] = [];
60
+ const spy = vi.spyOn(console, "error").mockImplementation((m) => void errors.push(String(m)));
61
+ try {
62
+ const result = await auditCommand({ path: root });
63
+ expect(result.output).toContain("not installed");
64
+ expect(result.output).toContain("npm install -D @cdktn/hcl2json");
65
+ const out = join(root, "report.txt");
66
+ const written = await auditCommand({ path: root, format: "markdown", output: out });
67
+ printAuditResult(written);
68
+ expect(errors.join("\n")).toContain("npm install -D @cdktn/hcl2json");
69
+ } finally {
70
+ spy.mockRestore();
71
+ rmSync(root, { recursive: true, force: true });
72
+ }
73
+ });
74
+ });
@@ -166,6 +166,18 @@ describe("auditCommand", () => {
166
166
  expect(md.output).toContain("FTN014");
167
167
  });
168
168
 
169
+ test("json and sarif give each finding the same identity (#5106)", async () => {
170
+ const repo = fileURLToPath(new URL("./__fixtures__/audit-fountain", import.meta.url));
171
+ const json = JSON.parse((await auditCommand({ path: repo, format: "json" })).output) as { findings: Array<{ identity: string }> };
172
+ const sarif = JSON.parse((await auditCommand({ path: repo, format: "sarif" })).output) as {
173
+ runs: Array<{ results: Array<{ partialFingerprints: Record<string, string> }> }>;
174
+ };
175
+ const fromSarif = sarif.runs[0].results.map((r) => r.partialFingerprints["chantFindingIdentity/v1"]);
176
+ expect(json.findings.length).toBeGreaterThan(0);
177
+ expect(json.findings.every((f) => /^[0-9a-f]{32}$/.test(f.identity))).toBe(true);
178
+ expect([...fromSarif].sort()).toEqual(json.findings.map((f) => f.identity).sort());
179
+ });
180
+
169
181
  test("a clean fountain manifest set audits quiet", async () => {
170
182
  const repo = fileURLToPath(new URL("./__fixtures__/audit-fountain-clean", import.meta.url));
171
183
  const result = await auditCommand({ path: repo, format: "stylish" });
@@ -7,9 +7,10 @@
7
7
 
8
8
  import { existsSync, readFileSync, statSync, writeFileSync } from "fs";
9
9
  import { dirname, join, resolve } from "path";
10
- import { auditFiles, type AuditInput, type AuditFinding, type ChecksProvider, type SuppressionStats } from "../../audit/core";
10
+ import { auditFiles, describeSkip, type AuditSkip, type AuditInput, type AuditFinding, type ChecksProvider, type SuppressionStats } from "../../audit/core";
11
11
  import { AUDIT_LEXICONS, classifyFiles, loadAuditPlugins, unclaimedFiles, walkCandidates, type CandidateWalk, type DetectPlugin, type RepoFile, type UnclaimedFile } from "../../audit/discover";
12
12
  import { RULE_CATALOG, resolveAuditCatalog, type RuleMeta } from "../../audit/catalog";
13
+ import { findingIdentities, IDENTITY_FINGERPRINT_KEY } from "../../audit/identity";
13
14
  import { scanForSecrets, parseSecretsConfig, type SecretsScanOptions } from "../../audit/secrets";
14
15
  import { auditWranglerConfigs } from "../../audit/wrangler";
15
16
  import { auditNginxConfigs } from "../../audit/nginx";
@@ -119,6 +120,8 @@ export interface AuditCommandResult {
119
120
  * summary line.
120
121
  */
121
122
  suppressedCount?: number;
123
+ /** Lexicons found but not read for want of an optional parser (#5083); also in the JSON report as `skipped`. */
124
+ skipped?: AuditSkip[];
122
125
  /** Run diagnostics for stderr: a truncated scan in a format that cannot carry it (#2528). */
123
126
  warnings?: AuditWarning[];
124
127
  }
@@ -398,13 +401,15 @@ function renderSarif(findings: AuditFinding[], catalog: Record<string, RuleMeta>
398
401
  : {}),
399
402
  };
400
403
  });
401
- const results = findings.map((f) => {
404
+ const identities = findingIdentities(findings);
405
+ const results = findings.map((f, i) => {
402
406
  const tier = catalog[f.checkId]?.tier;
403
407
  const properties = { ...(tier ? { tier } : {}), ...(f.missing ? { missing: f.missing } : {}) };
404
408
  return {
405
409
  ruleId: f.checkId,
406
410
  level: sarifLevel(f.severity),
407
411
  message: { text: f.message },
412
+ partialFingerprints: { [IDENTITY_FINGERPRINT_KEY]: identities[i] },
408
413
  locations: [
409
414
  {
410
415
  physicalLocation: {
@@ -532,7 +537,7 @@ export async function auditCommand(options: AuditCommandOptions): Promise<AuditC
532
537
  truncated && format === "sarif" ? [{ message: truncationNote(truncated, options.path) }] : [];
533
538
  if (pathLexicons.notice !== undefined) warnings.push({ message: pathLexicons.notice });
534
539
  const withWarnings = warnings.length > 0 ? { warnings } : {};
535
- // A local target hands its directory to the classifier, so an input whose
540
+ // A local target hands its directory to the classifier, so an input whose
536
541
  // path names a directory carries the directory itself (#2217): terraform's
537
542
  // parse-to-graph follows a root module's local `module` calls from there. A
538
543
  // URL target has no local tree, and never fetches `.tf` in the first place.
@@ -582,11 +587,14 @@ export async function auditCommand(options: AuditCommandOptions): Promise<AuditC
582
587
  // ignore*`) suppressed count reaches the summary without changing
583
588
  // `auditFiles`'s `AuditFinding[]` return type; see `SuppressionStats`'s doc.
584
589
  const suppressionStats: SuppressionStats = { count: 0 };
590
+ const skips: AuditSkip[] = [];
585
591
  if (inputs.length > 0) {
586
592
  try {
587
593
  findings = await auditFiles(inputs, {
588
594
  checksProvider: options.checksProvider,
589
595
  suppressionStats,
596
+ skips,
597
+ ...(isUrl ? {} : { root: options.path }),
590
598
  ...(isUrl ? {} : { enabledRules: readEnabledRules(options.path) }),
591
599
  });
592
600
  } catch (err) {
@@ -606,6 +614,16 @@ export async function auditCommand(options: AuditCommandOptions): Promise<AuditC
606
614
  const notes = coverageNotes(inputs);
607
615
  if (truncated) notes.unshift(truncationNote(truncated, options.path));
608
616
  if (missingLexiconNote) notes.push(missingLexiconNote);
617
+ // A skipped lexicon is stated in the report when the report is read as text
618
+ // (the stylish, markdown and html renderers print notes) and always in the
619
+ // log, so a pipe or a file never hides it (#5083). The JSON report carries
620
+ // it as `skipped`, which SARIF has no slot for.
621
+ const textReport = (format === "stylish" || format === "markdown" || format === "html") && !options.output;
622
+ for (const skip of skips) {
623
+ notes.push(describeSkip(skip));
624
+ if (!textReport) warnings.push({ message: describeSkip(skip) });
625
+ }
626
+ const finalWarnings = warnings.length > 0 ? { warnings } : {};
609
627
  if (suppressionStats.count > 0) {
610
628
  notes.push(
611
629
  `${suppressionStats.count} finding${suppressionStats.count === 1 ? "" : "s"} suppressed via inline chant-ignore comments.`,
@@ -653,7 +671,7 @@ export async function auditCommand(options: AuditCommandOptions): Promise<AuditC
653
671
  switch (format) {
654
672
  case "json": {
655
673
  const snapshot = await buildSnapshot(options, scanned, isUrl);
656
- output = JSON.stringify(buildReportJson(findings, { snapshot, toolVersion: options.toolVersion, catalog, unclaimed, truncated }), null, 2);
674
+ output = JSON.stringify(buildReportJson(findings, { snapshot, toolVersion: options.toolVersion, catalog, unclaimed, truncated, skipped: skips }), null, 2);
657
675
  break;
658
676
  }
659
677
  case "sarif":
@@ -664,7 +682,7 @@ export async function auditCommand(options: AuditCommandOptions): Promise<AuditC
664
682
  break;
665
683
  case "html": {
666
684
  const snapshot = await buildSnapshot(options, scanned, isUrl);
667
- output = renderHtml(findings, { files, resolveSha, resolveDigest, notes, snapshot, theme: options.theme, template: options.template, catalog, truncated });
685
+ output = renderHtml(findings, { files, resolveSha, resolveDigest, notes, snapshot, theme: options.theme, template: options.template, catalog, truncated, skipped: skips });
668
686
  break;
669
687
  }
670
688
  default:
@@ -678,10 +696,10 @@ export async function auditCommand(options: AuditCommandOptions): Promise<AuditC
678
696
  } catch (err) {
679
697
  return { success: false, output, findings, scanned, exitCode: 1, error: `Failed to write ${options.output}: ${err instanceof Error ? err.message : String(err)}` };
680
698
  }
681
- return { success: true, status: "ok", output, findings, scanned, unclaimed, exitCode, wroteTo: options.output, suppressedCount: suppressionStats.count, ...withWarnings };
699
+ return { success: true, status: "ok", output, findings, scanned, unclaimed, exitCode, wroteTo: options.output, suppressedCount: suppressionStats.count, ...(skips.length > 0 ? { skipped: skips } : {}), ...finalWarnings };
682
700
  }
683
701
 
684
- return { success: true, status: "ok", output, findings, scanned, unclaimed, exitCode, suppressedCount: suppressionStats.count, ...withWarnings };
702
+ return { success: true, status: "ok", output, findings, scanned, unclaimed, exitCode, suppressedCount: suppressionStats.count, ...(skips.length > 0 ? { skipped: skips } : {}), ...finalWarnings };
685
703
  }
686
704
 
687
705
  /** Print an audit result to stdout, and its warnings to stderr. */
@@ -6,6 +6,7 @@ import { tmpdir } from "node:os";
6
6
  import type { LexiconPlugin } from "../../lexicon";
7
7
  import type { GeneratedFile, TypeScriptGenerator } from "../../import/generator";
8
8
  import type { TemplateIR } from "../../import/parser";
9
+ import { IMPORTED_SOURCE_HEADER } from "../../lint/rules/imported-source";
9
10
  import { generateOrganizedFiles, importCommand } from "./import";
10
11
 
11
12
  // A generator that writes one module per resource plus a barrel, the shape
@@ -127,7 +128,7 @@ describe("chant import writes a placing generator's files (#2964)", () => {
127
128
  expect(result.success).toBe(true);
128
129
  expect(result.warnings).toEqual([]);
129
130
  expect(result.generatedFiles).toEqual(perResourceFiles(fiveIR).map((f) => f.path));
130
- expect(await readFile(join(outputDir, "pipeline.ts"), "utf-8")).toBe("export const pipeline = {};\n");
131
+ expect(await readFile(join(outputDir, "pipeline.ts"), "utf-8")).toBe(IMPORTED_SOURCE_HEADER + "export const pipeline = {};\n");
131
132
  expect(existsSync(join(outputDir, "other.ts"))).toBe(false);
132
133
  });
133
134
 
@@ -1,4 +1,6 @@
1
- import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync } from "fs";
1
+ import { getProvenance } from "../../provenance";
2
+ import { markImportedSource } from "../../lint/rules/imported-source";
3
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync, realpathSync } from "fs";
2
4
  import { join, resolve, basename, dirname } from "path";
3
5
  import { formatSuccess, formatWarning, formatError } from "../format";
4
6
  import type { TemplateIR, ResourceIR, ParameterIR, ParseContext, ImportDiagnostic } from "../../import/parser";
@@ -540,8 +542,15 @@ async function parseWithEmbedded(
540
542
  * named. When the source does not build here (the lexicon is not installed
541
543
  * beside it, or embedded content needs another lexicon's serializer), nothing
542
544
  * is said: import reports what build would refuse, not why it cannot run.
545
+ *
546
+ * The whole directory is built, so a second import into the same directory
547
+ * would otherwise repeat the findings about files an earlier import wrote
548
+ * (#5084). With `written` (the paths this import wrote, relative to
549
+ * `outputDir`), a finding whose entity was declared in some other file is
550
+ * left out; one with no entity, or an entity that does not resolve to a
551
+ * source file, is kept, since nothing says it is about an earlier import.
543
552
  */
544
- export async function buildErrorWarnings(plugin: LexiconPlugin, outputDir: string): Promise<string[]> {
553
+ export async function buildErrorWarnings(plugin: LexiconPlugin, outputDir: string, written?: readonly string[]): Promise<string[]> {
545
554
  try {
546
555
  const checks = plugin.postSynthChecks?.() ?? [];
547
556
  if (checks.length === 0) return [];
@@ -557,8 +566,22 @@ export async function buildErrorWarnings(plugin: LexiconPlugin, outputDir: strin
557
566
  const diagnostics = runPostSynthChecks(checks, { ...result, outputs });
558
567
  const presetIds = resolvePresetIds(plugin.lintPresets?.(), config.lint?.presets?.[plugin.name] ?? "recommended");
559
568
  const afterPreset = applyConfiguredPreset(diagnostics, presetIds, rules).diagnostics;
569
+ const real = (path: string): string => {
570
+ try {
571
+ return realpathSync(path);
572
+ } catch {
573
+ return resolve(path);
574
+ }
575
+ };
576
+ const writtenHere = written ? new Set(written.map((file) => real(join(outputDir, file)))) : undefined;
577
+ const fromThisImport = (entity: string | undefined): boolean => {
578
+ if (!writtenHere || !entity) return true;
579
+ const declared = result.entities.get(entity);
580
+ const file = declared && getProvenance(declared)?.sourceFile;
581
+ return !file || writtenHere.has(real(file));
582
+ };
560
583
  return applyConfiguredSeverity(afterPreset, rules)
561
- .diagnostics.filter((diag) => diag.severity === "error")
584
+ .diagnostics.filter((diag) => diag.severity === "error" && fromThisImport(diag.entity))
562
585
  .map(
563
586
  (diag) =>
564
587
  `${diag.checkId}: ${diag.message.replace(/\.$/, "")}. chant build stops on this error; ` +
@@ -673,12 +696,12 @@ async function parseAndWrite(
673
696
  continue;
674
697
  }
675
698
 
676
- writeFileSync(filePath, file.content);
699
+ writeFileSync(filePath, markImportedSource(file.path, file.content));
677
700
  generatedFiles.push(file.path);
678
701
  }
679
702
 
680
703
  // What `chant build` will refuse, said now rather than at the first build (#3605).
681
- warnings.push(...(await buildErrorWarnings(plugin, outputDir)));
704
+ warnings.push(...(await buildErrorWarnings(plugin, outputDir, generatedFiles)));
682
705
 
683
706
  return {
684
707
  success: true,
@@ -890,7 +913,7 @@ export async function liveImportFromPlugins(
890
913
  warnings.push(`File ${file.path} already exists, skipping`);
891
914
  continue;
892
915
  }
893
- writeFileSync(filePath, file.content);
916
+ writeFileSync(filePath, markImportedSource(file.path, file.content));
894
917
  generatedFiles.push(file.path);
895
918
  }
896
919
 
@@ -32,7 +32,8 @@ import { CHANT_EXIT } from "../../exit-codes";
32
32
  import { appendRunRecord, readRunLedger } from "../../lifecycle/run-ledger";
33
33
  import { pushLifecycle } from "../../lifecycle/git";
34
34
  import { resolveCiRun } from "../../lifecycle/release-ledger";
35
- import { FORGE_KINDS, forgeFromEnv, type ForgeKind, type PrForge } from "../../pr-forge";
35
+ import { COMMENT_ALLOW_TOKEN_ENV, type CommentAllowReads } from "../../ci-comment-allow";
36
+ import { FORGE_KINDS, forgeFromEnv, forgeTargetFromEnv, type ForgeKind, type PrForge } from "../../pr-forge";
36
37
  import { formatError, formatInfo } from "../format";
37
38
  import type { CommandContext } from "../registry";
38
39
 
@@ -64,6 +65,14 @@ function eventOf(): unknown {
64
65
  }
65
66
  }
66
67
 
68
+ /** The reads that answer team membership for `comment_allow`: the pipeline's team token when it has one, else the job's own. */
69
+ async function teamReadsFor(kind: "github" | "forgejo"): Promise<CommentAllowReads> {
70
+ const { forgeReadsFor } = await import("../../pr-forge-reads");
71
+ const target = forgeTargetFromEnv(process.env, { kind });
72
+ const token = process.env[COMMENT_ALLOW_TOKEN_ENV];
73
+ return forgeReadsFor(token ? { ...target, token } : target);
74
+ }
75
+
67
76
  function workDir(name: string): string {
68
77
  return join(process.env.RUNNER_TEMP || process.env.TMPDIR || tmpdir(), name);
69
78
  }
@@ -86,7 +95,9 @@ export async function runAgentCommandLine(ctx: CommandContext): Promise<number>
86
95
 
87
96
  try {
88
97
  if (action === "prepare") {
89
- const d = await prepareAgentRun({ settings, words, dir, env: process.env, event: eventOf(), forge: settings.on === "comment" && kind !== "gitlab" ? forge() : undefined, readRuns, git, now: new Date() });
98
+ // INTENTIUS/terragucci#1461: team membership is read with the pipeline's team token when it has one, else the job's.
99
+ const teams = settings.commentAllow && settings.on === "comment" && kind !== "gitlab" ? await teamReadsFor(kind as "github" | "forgejo") : undefined;
100
+ const d = await prepareAgentRun({ settings, words, dir, env: process.env, event: eventOf(), forge: settings.on === "comment" && kind !== "gitlab" ? forge() : undefined, ...(teams ? { teams } : {}), readRuns, git, now: new Date() });
90
101
  console.error(formatInfo(d.go ? `${words.product} agent: runs on ${d.sha?.slice(0, 12)}${d.pr ? ` for #${d.pr}` : ""}` : `${words.product} agent: does not run: ${d.reason}`));
91
102
  return CHANT_EXIT.done;
92
103
  }
@@ -9,6 +9,12 @@
9
9
  * or the re-run of a merged pull request's apply. The words are the
10
10
  * product's, as its bin set them.
11
11
  *
12
+ * With `CHANT_COMMENT_ALLOW` (JSON, written by the generator, see
13
+ * `../../ci-comment-allow.ts`) it also limits `plan`, `apply`, `lock`,
14
+ * `unlock` and `agent` to the logins and teams it names. Teams are read with
15
+ * `CHANT_COMMENT_ALLOW_TOKEN` when the pipeline names a secret for it, else
16
+ * the job's token.
17
+ *
12
18
  * It runs at the target branch's commit with the job's token
13
19
  * (`GITHUB_TOKEN`), so none of the change's code runs here, and it loads no
14
20
  * plugins.
@@ -16,6 +22,7 @@
16
22
 
17
23
  import { readFileSync } from "node:fs";
18
24
  import { activeProductWords } from "../../ci-product-words";
25
+ import { COMMENT_ALLOW_ENV, COMMENT_ALLOW_TOKEN_ENV, commentAllowFromEnv, type CommentAllow } from "../../ci-comment-allow";
19
26
  import { answerProductComment, COMMENT_JOBS_ENV, commentRuns, type CommentBeforeMerge, type CommentJobs } from "../../ci-comment-commands";
20
27
  import type { WavesBeforeMergeJobs } from "../../op/before-merge-decide";
21
28
  import { PR_APPLY_REQUIRES } from "../../pr-requires";
@@ -161,8 +168,10 @@ export async function runComponentsPrComment(ctx: CommandContext): Promise<numbe
161
168
  let event: unknown;
162
169
  let jobs: CommentJobs;
163
170
  let poster: PrForge;
171
+ let allow: CommentAllow | undefined;
164
172
  let target: ReturnType<typeof forgeTargetFromEnv>;
165
173
  try {
174
+ allow = commentAllowFromEnv(env[COMMENT_ALLOW_ENV]);
166
175
  event = JSON.parse(readFileSync(eventPath, "utf8"));
167
176
  jobs = commentJobsFromEnv(env[COMMENT_JOBS_ENV]);
168
177
  poster = forgeFromEnv(kind, env);
@@ -173,11 +182,14 @@ export async function runComponentsPrComment(ctx: CommandContext): Promise<numbe
173
182
  const repository = (event as { repository?: { default_branch?: unknown } } | null)?.repository;
174
183
  const base = args.branch ?? (typeof repository?.default_branch === "string" ? repository.default_branch : undefined);
175
184
  if (!base) return fail("pr-comment needs the default branch: --branch <name>, or repository.default_branch in the event");
185
+ // INTENTIUS/terragucci#1461: teams are read with the pipeline's team token when it has one.
186
+ const teamToken = env[COMMENT_ALLOW_TOKEN_ENV];
176
187
  const outcome = await answerProductComment({
177
188
  forge: kind,
178
189
  event,
179
190
  repo: target.repo,
180
191
  reads: forgeReadsFor(target),
192
+ ...(allow ? { allow, ...(teamToken ? { teams: forgeReadsFor({ ...target, token: teamToken }) } : {}) } : {}),
181
193
  poster,
182
194
  runs: commentRuns({ apiBase: target.apiBase, repo: target.repo, token: target.token }),
183
195
  words: activeProductWords(),
@@ -175,6 +175,16 @@ let verification: { status: "verified" | "unsigned" | "unverified"; digestMatche
175
175
  vi.mock("../../workspace/security", async (original) => ({ ...(await original<typeof import("../../workspace/security")>()), securityGroupsAt: () => new Set(groups) }));
176
176
  vi.mock("../../lifecycle/release-verify", async (original) => ({ ...(await original<typeof import("../../lifecycle/release-verify")>()), verifyRelease: async () => verification }));
177
177
 
178
+ // #4037: the workspace gate a train's promote runs under answers from a list, not the workspace ledger.
179
+ const standInAsked: Array<{ cwd: string; gate: string; q: Record<string, unknown> }> = [];
180
+ let standInAnswers: (q: Record<string, unknown>) => boolean = () => false;
181
+ vi.mock("../../workspace/workspace-gates", () => ({
182
+ memberGateStandIn: async (cwd: string, gate: string, q: Record<string, unknown>) => {
183
+ standInAsked.push({ cwd, gate, q });
184
+ return standInAnswers(q) ? { gate, digest: "sha256:" + "7".repeat(64), approvedBy: "carol", timestamp: "2026-01-04T00:00:00.000Z" } : null;
185
+ },
186
+ }));
187
+
178
188
  // The run handler pulls in every runtime; the promote needs only its exit code.
179
189
  vi.mock("./run", () => ({ GATED_EXIT_CODE: 3 }));
180
190
 
@@ -701,6 +711,64 @@ describe("chant components promote --release binds its gate (#4045)", () => {
701
711
  expect(appendReleaseRecordMock).not.toHaveBeenCalled();
702
712
  });
703
713
 
714
+ test("--plan-only plans and stores the change set, prints it, and deploys and records nothing (#4037)", async () => {
715
+ expect(await runComponentsPromote(ctx({ release: "v1.0.0", planOnly: true, json: true }))).toBe(0);
716
+ const [doc] = onlyStored();
717
+ expect(JSON.parse(logs.join("\n"))).toEqual({
718
+ env: "prod",
719
+ releaseDigest: r1.releaseDigest,
720
+ label: "v1.0.0",
721
+ op: "release",
722
+ gates: ["prod-release"],
723
+ changeSet: doc!.digest,
724
+ empty: false,
725
+ components: ["api"],
726
+ });
727
+ expect(ran).toEqual([]);
728
+ expect(releaseGatePort!.appended).toEqual([]);
729
+ expect(releaseGatePort!.resolved).toEqual([]);
730
+ expect(appendReleaseRecordMock).not.toHaveBeenCalled();
731
+ expect(removedTemplates).toHaveLength(1);
732
+ // The promote that follows binds the same change set.
733
+ expect(await runComponentsPromote(ctx({ release: "v1.0.0" }))).toBe(3);
734
+ expect(releaseGatePort!.appended[0]).toMatchObject({ planDigest: doc!.digest, releaseDigest: r1.releaseDigest });
735
+ });
736
+
737
+ test("--plan-only of an empty change set writes no empty pass, and --plan-only needs --release (#4037)", async () => {
738
+ ledgers.prod = [{ ...staging, env: "prod", releaseDigest: r1.releaseDigest, timestamp: "2026-01-03T00:00:00.000Z" }];
739
+ expect(await runComponentsPromote(ctx({ release: "v1.0.0", planOnly: true, json: true }))).toBe(0);
740
+ expect(JSON.parse(logs.join("\n"))).toMatchObject({ empty: true, gates: ["prod-release"] });
741
+ expect(releaseGatePort!.resolved).toEqual([]);
742
+ errors.length = 0;
743
+ expect(await runComponentsPromote(ctx({ planOnly: true }))).toBe(1);
744
+ expect(errors.join("\n")).toMatch(/--plan-only plans a release's change set: it needs --release/);
745
+ });
746
+
747
+ test("under a train's workspace gate, the release gate takes the workspace approval only for its release, environment and change set (#4037)", async () => {
748
+ const saved = { run: process.env.CHANT_WORKSPACE_RUN, gate: process.env.CHANT_WORKSPACE_GATE };
749
+ process.env.CHANT_WORKSPACE_RUN = "ws-1";
750
+ process.env.CHANT_WORKSPACE_GATE = "train-prod";
751
+ standInAsked.length = 0;
752
+ try {
753
+ standInAnswers = (q) => q.releaseDigest === r2.releaseDigest;
754
+ expect(await runComponentsPromote(ctx({ release: "v1.0.0" }))).toBe(3);
755
+ const [doc] = onlyStored();
756
+ expect(standInAsked.at(-1)).toMatchObject({ gate: "train-prod", q: { op: "release", gate: "prod-release", planDigest: doc!.digest, environment: "prod", releaseDigest: r1.releaseDigest } });
757
+ expect(ran).not.toContain("prod:apply");
758
+
759
+ standInAnswers = (q) => q.releaseDigest === r1.releaseDigest && q.planDigest === doc!.digest && q.environment === "prod";
760
+ expect(await runComponentsPromote(ctx({ release: "v1.0.0" }))).toBe(0);
761
+ expect(ran).toContain("prod:apply");
762
+ expect(appendReleaseRecordMock.mock.calls[0][0]).toMatchObject({ releaseDigest: r1.releaseDigest, approver: "carol" });
763
+ } finally {
764
+ for (const [k, v] of [["CHANT_WORKSPACE_RUN", saved.run], ["CHANT_WORKSPACE_GATE", saved.gate]] as const) {
765
+ if (v === undefined) delete process.env[k];
766
+ else process.env[k] = v;
767
+ }
768
+ standInAnswers = () => false;
769
+ }
770
+ });
771
+
704
772
  test("an approval for one environment can't be used for another", async () => {
705
773
  expect(await runComponentsPromote(ctx({ release: "v1.0.0" }))).toBe(3);
706
774
  const pending = releaseGatePort!.appended[0];