@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
@@ -6,9 +6,10 @@
6
6
  */
7
7
  import { existsSync, readFileSync, writeFileSync } from "fs";
8
8
  import { dirname, join, resolve } from "path";
9
- import { auditFiles } from "../../audit/core.js";
9
+ import { auditFiles, describeSkip } from "../../audit/core.js";
10
10
  import { AUDIT_LEXICONS, classifyFiles, loadAuditPlugins, unclaimedFiles, walkCandidates } from "../../audit/discover.js";
11
11
  import { RULE_CATALOG, resolveAuditCatalog } from "../../audit/catalog.js";
12
+ import { findingIdentities, IDENTITY_FINGERPRINT_KEY } from "../../audit/identity.js";
12
13
  import { scanForSecrets, parseSecretsConfig } from "../../audit/secrets.js";
13
14
  import { auditWranglerConfigs } from "../../audit/wrangler.js";
14
15
  import { auditNginxConfigs } from "../../audit/nginx.js";
@@ -288,13 +289,15 @@ function renderSarif(findings, catalog = RULE_CATALOG) {
288
289
  : {}),
289
290
  };
290
291
  });
291
- const results = findings.map((f) => {
292
+ const identities = findingIdentities(findings);
293
+ const results = findings.map((f, i) => {
292
294
  const tier = catalog[f.checkId]?.tier;
293
295
  const properties = { ...(tier ? { tier } : {}), ...(f.missing ? { missing: f.missing } : {}) };
294
296
  return {
295
297
  ruleId: f.checkId,
296
298
  level: sarifLevel(f.severity),
297
299
  message: { text: f.message },
300
+ partialFingerprints: { [IDENTITY_FINGERPRINT_KEY]: identities[i] },
298
301
  locations: [
299
302
  {
300
303
  physicalLocation: {
@@ -452,11 +455,14 @@ export async function auditCommand(options) {
452
455
  // ignore*`) suppressed count reaches the summary without changing
453
456
  // `auditFiles`'s `AuditFinding[]` return type; see `SuppressionStats`'s doc.
454
457
  const suppressionStats = { count: 0 };
458
+ const skips = [];
455
459
  if (inputs.length > 0) {
456
460
  try {
457
461
  findings = await auditFiles(inputs, {
458
462
  checksProvider: options.checksProvider,
459
463
  suppressionStats,
464
+ skips,
465
+ ...(isUrl ? {} : { root: options.path }),
460
466
  ...(isUrl ? {} : { enabledRules: readEnabledRules(options.path) }),
461
467
  });
462
468
  }
@@ -479,6 +485,17 @@ export async function auditCommand(options) {
479
485
  notes.unshift(truncationNote(truncated, options.path));
480
486
  if (missingLexiconNote)
481
487
  notes.push(missingLexiconNote);
488
+ // A skipped lexicon is stated in the report when the report is read as text
489
+ // (the stylish, markdown and html renderers print notes) and always in the
490
+ // log, so a pipe or a file never hides it (#5083). The JSON report carries
491
+ // it as `skipped`, which SARIF has no slot for.
492
+ const textReport = (format === "stylish" || format === "markdown" || format === "html") && !options.output;
493
+ for (const skip of skips) {
494
+ notes.push(describeSkip(skip));
495
+ if (!textReport)
496
+ warnings.push({ message: describeSkip(skip) });
497
+ }
498
+ const finalWarnings = warnings.length > 0 ? { warnings } : {};
482
499
  if (suppressionStats.count > 0) {
483
500
  notes.push(`${suppressionStats.count} finding${suppressionStats.count === 1 ? "" : "s"} suppressed via inline chant-ignore comments.`);
484
501
  }
@@ -526,7 +543,7 @@ export async function auditCommand(options) {
526
543
  switch (format) {
527
544
  case "json": {
528
545
  const snapshot = await buildSnapshot(options, scanned, isUrl);
529
- output = JSON.stringify(buildReportJson(findings, { snapshot, toolVersion: options.toolVersion, catalog, unclaimed, truncated }), null, 2);
546
+ output = JSON.stringify(buildReportJson(findings, { snapshot, toolVersion: options.toolVersion, catalog, unclaimed, truncated, skipped: skips }), null, 2);
530
547
  break;
531
548
  }
532
549
  case "sarif":
@@ -537,7 +554,7 @@ export async function auditCommand(options) {
537
554
  break;
538
555
  case "html": {
539
556
  const snapshot = await buildSnapshot(options, scanned, isUrl);
540
- output = renderHtml(findings, { files, resolveSha, resolveDigest, notes, snapshot, theme: options.theme, template: options.template, catalog, truncated });
557
+ output = renderHtml(findings, { files, resolveSha, resolveDigest, notes, snapshot, theme: options.theme, template: options.template, catalog, truncated, skipped: skips });
541
558
  break;
542
559
  }
543
560
  default:
@@ -551,9 +568,9 @@ export async function auditCommand(options) {
551
568
  catch (err) {
552
569
  return { success: false, output, findings, scanned, exitCode: 1, error: `Failed to write ${options.output}: ${err instanceof Error ? err.message : String(err)}` };
553
570
  }
554
- return { success: true, status: "ok", output, findings, scanned, unclaimed, exitCode, wroteTo: options.output, suppressedCount: suppressionStats.count, ...withWarnings };
571
+ return { success: true, status: "ok", output, findings, scanned, unclaimed, exitCode, wroteTo: options.output, suppressedCount: suppressionStats.count, ...(skips.length > 0 ? { skipped: skips } : {}), ...finalWarnings };
555
572
  }
556
- return { success: true, status: "ok", output, findings, scanned, unclaimed, exitCode, suppressedCount: suppressionStats.count, ...withWarnings };
573
+ return { success: true, status: "ok", output, findings, scanned, unclaimed, exitCode, suppressedCount: suppressionStats.count, ...(skips.length > 0 ? { skipped: skips } : {}), ...finalWarnings };
557
574
  }
558
575
  /** Print an audit result to stdout, and its warnings to stderr. */
559
576
  export function printAuditResult(result) {
@@ -134,8 +134,15 @@ export declare function importFromContent(options: ContentImportOptions): Promis
134
134
  * named. When the source does not build here (the lexicon is not installed
135
135
  * beside it, or embedded content needs another lexicon's serializer), nothing
136
136
  * is said: import reports what build would refuse, not why it cannot run.
137
+ *
138
+ * The whole directory is built, so a second import into the same directory
139
+ * would otherwise repeat the findings about files an earlier import wrote
140
+ * (#5084). With `written` (the paths this import wrote, relative to
141
+ * `outputDir`), a finding whose entity was declared in some other file is
142
+ * left out; one with no entity, or an entity that does not resolve to a
143
+ * source file, is kept, since nothing says it is about an earlier import.
137
144
  */
138
- export declare function buildErrorWarnings(plugin: LexiconPlugin, outputDir: string): Promise<string[]>;
145
+ export declare function buildErrorWarnings(plugin: LexiconPlugin, outputDir: string, written?: readonly string[]): Promise<string[]>;
139
146
  /**
140
147
  * Live import options — read from a running cloud/cluster instead of a file.
141
148
  */
@@ -1 +1 @@
1
- {"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/import.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAyC,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC/G,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAEjF,OAAO,KAAK,EAAoB,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAOvF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,4BAA4B;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,gGAAgG;IAChG,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,+BAA+B;IAC/B,OAAO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E,CAAC,CAAC,CAezD;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,aAAa,EAAE,EACxB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,YAAY,CAAC,CAgHvB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CA0B5D"}
@@ -1,4 +1,6 @@
1
- import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync } from "fs";
1
+ import { getProvenance } from "../../provenance.js";
2
+ import { markImportedSource } from "../../lint/rules/imported-source.js";
3
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync, realpathSync } from "fs";
2
4
  import { join, resolve, dirname } from "path";
3
5
  import { formatSuccess, formatWarning, formatError } from "../format.js";
4
6
  import { listInstalledLexicons, loadPlugin, loadPlugins, resolveProjectLexicons } from "../plugins.js";
@@ -405,8 +407,15 @@ async function parseWithEmbedded(parses, loaded, projectDir) {
405
407
  * named. When the source does not build here (the lexicon is not installed
406
408
  * beside it, or embedded content needs another lexicon's serializer), nothing
407
409
  * is said: import reports what build would refuse, not why it cannot run.
410
+ *
411
+ * The whole directory is built, so a second import into the same directory
412
+ * would otherwise repeat the findings about files an earlier import wrote
413
+ * (#5084). With `written` (the paths this import wrote, relative to
414
+ * `outputDir`), a finding whose entity was declared in some other file is
415
+ * left out; one with no entity, or an entity that does not resolve to a
416
+ * source file, is kept, since nothing says it is about an earlier import.
408
417
  */
409
- export async function buildErrorWarnings(plugin, outputDir) {
418
+ export async function buildErrorWarnings(plugin, outputDir, written) {
410
419
  try {
411
420
  const checks = plugin.postSynthChecks?.() ?? [];
412
421
  if (checks.length === 0)
@@ -423,8 +432,24 @@ export async function buildErrorWarnings(plugin, outputDir) {
423
432
  const diagnostics = runPostSynthChecks(checks, { ...result, outputs });
424
433
  const presetIds = resolvePresetIds(plugin.lintPresets?.(), config.lint?.presets?.[plugin.name] ?? "recommended");
425
434
  const afterPreset = applyConfiguredPreset(diagnostics, presetIds, rules).diagnostics;
435
+ const real = (path) => {
436
+ try {
437
+ return realpathSync(path);
438
+ }
439
+ catch {
440
+ return resolve(path);
441
+ }
442
+ };
443
+ const writtenHere = written ? new Set(written.map((file) => real(join(outputDir, file)))) : undefined;
444
+ const fromThisImport = (entity) => {
445
+ if (!writtenHere || !entity)
446
+ return true;
447
+ const declared = result.entities.get(entity);
448
+ const file = declared && getProvenance(declared)?.sourceFile;
449
+ return !file || writtenHere.has(real(file));
450
+ };
426
451
  return applyConfiguredSeverity(afterPreset, rules)
427
- .diagnostics.filter((diag) => diag.severity === "error")
452
+ .diagnostics.filter((diag) => diag.severity === "error" && fromThisImport(diag.entity))
428
453
  .map((diag) => `${diag.checkId}: ${diag.message.replace(/\.$/, "")}. chant build stops on this error; ` +
429
454
  `change the generated source, or set lint.rules.${diag.checkId} to "off" in chant.config.ts.`);
430
455
  }
@@ -517,11 +542,11 @@ async function parseAndWrite(plugin, content, outputDir, force, warnings, genera
517
542
  warnings.push(`File ${file.path} already exists, skipping`);
518
543
  continue;
519
544
  }
520
- writeFileSync(filePath, file.content);
545
+ writeFileSync(filePath, markImportedSource(file.path, file.content));
521
546
  generatedFiles.push(file.path);
522
547
  }
523
548
  // What `chant build` will refuse, said now rather than at the first build (#3605).
524
- warnings.push(...(await buildErrorWarnings(plugin, outputDir)));
549
+ warnings.push(...(await buildErrorWarnings(plugin, outputDir, generatedFiles)));
525
550
  return {
526
551
  success: true,
527
552
  generatedFiles,
@@ -690,7 +715,7 @@ export async function liveImportFromPlugins(plugins, options) {
690
715
  warnings.push(`File ${file.path} already exists, skipping`);
691
716
  continue;
692
717
  }
693
- writeFileSync(filePath, file.content);
718
+ writeFileSync(filePath, markImportedSource(file.path, file.content));
694
719
  generatedFiles.push(file.path);
695
720
  }
696
721
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAuBH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAkClD,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAuD9E"}
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAwBH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA0ClD,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAyD9E"}
@@ -22,7 +22,8 @@ import { CHANT_EXIT } from "../../exit-codes.js";
22
22
  import { appendRunRecord, readRunLedger } from "../../lifecycle/run-ledger.js";
23
23
  import { pushLifecycle } from "../../lifecycle/git.js";
24
24
  import { resolveCiRun } from "../../lifecycle/release-ledger.js";
25
- import { FORGE_KINDS, forgeFromEnv } from "../../pr-forge.js";
25
+ import { COMMENT_ALLOW_TOKEN_ENV } from "../../ci-comment-allow.js";
26
+ import { FORGE_KINDS, forgeFromEnv, forgeTargetFromEnv } from "../../pr-forge.js";
26
27
  import { formatError, formatInfo } from "../format.js";
27
28
  const USAGE = "chant agent prepare|run|land --forge github|gitlab|forgejo [--output <dir>]";
28
29
  function fail(message) {
@@ -49,6 +50,13 @@ function eventOf() {
49
50
  return undefined;
50
51
  }
51
52
  }
53
+ /** The reads that answer team membership for `comment_allow`: the pipeline's team token when it has one, else the job's own. */
54
+ async function teamReadsFor(kind) {
55
+ const { forgeReadsFor } = await import("../../pr-forge-reads.js");
56
+ const target = forgeTargetFromEnv(process.env, { kind });
57
+ const token = process.env[COMMENT_ALLOW_TOKEN_ENV];
58
+ return forgeReadsFor(token ? { ...target, token } : target);
59
+ }
52
60
  function workDir(name) {
53
61
  return join(process.env.RUNNER_TEMP || process.env.TMPDIR || tmpdir(), name);
54
62
  }
@@ -72,7 +80,9 @@ export async function runAgentCommandLine(ctx) {
72
80
  const forge = () => forgeFromEnv(kind);
73
81
  try {
74
82
  if (action === "prepare") {
75
- 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() });
83
+ // INTENTIUS/terragucci#1461: team membership is read with the pipeline's team token when it has one, else the job's.
84
+ const teams = settings.commentAllow && settings.on === "comment" && kind !== "gitlab" ? await teamReadsFor(kind) : undefined;
85
+ 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() });
76
86
  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}`));
77
87
  return CHANT_EXIT.done;
78
88
  }
@@ -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.
@@ -1 +1 @@
1
- {"version":3,"file":"pr-comment.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/pr-comment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAuD,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC3I,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAAoC,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C,CAkD1I;AAED,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAsDjF"}
@@ -9,12 +9,19 @@
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.
15
21
  */
16
22
  import { readFileSync } from "node:fs";
17
23
  import { activeProductWords } from "../../ci-product-words.js";
24
+ import { COMMENT_ALLOW_ENV, COMMENT_ALLOW_TOKEN_ENV, commentAllowFromEnv } from "../../ci-comment-allow.js";
18
25
  import { answerProductComment, COMMENT_JOBS_ENV, commentRuns } from "../../ci-comment-commands.js";
19
26
  import { PR_APPLY_REQUIRES } from "../../pr-requires.js";
20
27
  import { forgeFromEnv, forgeTargetFromEnv } from "../../pr-forge.js";
@@ -176,8 +183,10 @@ export async function runComponentsPrComment(ctx) {
176
183
  let event;
177
184
  let jobs;
178
185
  let poster;
186
+ let allow;
179
187
  let target;
180
188
  try {
189
+ allow = commentAllowFromEnv(env[COMMENT_ALLOW_ENV]);
181
190
  event = JSON.parse(readFileSync(eventPath, "utf8"));
182
191
  jobs = commentJobsFromEnv(env[COMMENT_JOBS_ENV]);
183
192
  poster = forgeFromEnv(kind, env);
@@ -190,11 +199,14 @@ export async function runComponentsPrComment(ctx) {
190
199
  const base = args.branch ?? (typeof repository?.default_branch === "string" ? repository.default_branch : undefined);
191
200
  if (!base)
192
201
  return fail("pr-comment needs the default branch: --branch <name>, or repository.default_branch in the event");
202
+ // INTENTIUS/terragucci#1461: teams are read with the pipeline's team token when it has one.
203
+ const teamToken = env[COMMENT_ALLOW_TOKEN_ENV];
193
204
  const outcome = await answerProductComment({
194
205
  forge: kind,
195
206
  event,
196
207
  repo: target.repo,
197
208
  reads: forgeReadsFor(target),
209
+ ...(allow ? { allow, ...(teamToken ? { teams: forgeReadsFor({ ...target, token: teamToken }) } : {}) } : {}),
198
210
  poster,
199
211
  runs: commentRuns({ apiBase: target.apiBase, repo: target.repo, token: target.token }),
200
212
  words: activeProductWords(),
@@ -1 +1 @@
1
- {"version":3,"file":"promote.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/promote.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAkDH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA24BlD,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAmF/E;AAED,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAiDhF;AAsCD,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA6BhF"}
1
+ {"version":3,"file":"promote.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/promote.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAkDH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAq7BlD,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAuF/E;AAED,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAiDhF;AAsCD,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA6BhF"}
@@ -46,7 +46,7 @@ import { GATED_EXIT_CODE } from "./run.js";
46
46
  import { withComponentEndpoint } from "../component-endpoint.js";
47
47
  import { redeployLine, releaseRollbackLine, rollbackTarget, unsettledComponents } from "../../lifecycle/mixed-environment.js";
48
48
  import { actorFromEnv } from "../../actor.js";
49
- const PROMOTE_USAGE = "chant components promote --to <env> [--from <env>] [--allow-skip] [--release <label|digest>] [--component <name> [--digest <sha256:...>] | --digest <component>=<sha256:...> ...] [--wave-gate <gate>] [--resume <file>] [--dry-run] [--json]";
49
+ const PROMOTE_USAGE = "chant components promote --to <env> [--from <env>] [--allow-skip] [--release <label|digest> [--plan-only]] [--component <name> [--digest <sha256:...>] | --digest <component>=<sha256:...> ...] [--wave-gate <gate>] [--resume <file>] [--dry-run] [--json]";
50
50
  const ROLLBACK_USAGE = "chant components rollback <env> (--component <name> [--digest <sha256:...>] | --release <label|digest>) [--dry-run] [--json]";
51
51
  const REDEPLOY_USAGE = "chant components redeploy <env> --component <name> [--digest <sha256:...>] [--dry-run] [--json]";
52
52
  function renderPlan(verb, plan, removed) {
@@ -187,6 +187,10 @@ async function bindReleaseGate(input) {
187
187
  const { readStoredChangeSet } = await import("../../lifecycle/change-set-store.js");
188
188
  const { isEmptyChangeSet } = await import("../../change-set.js");
189
189
  const verifyEmpty = gate.emptyVerifier((digest) => readStoredChangeSet(digest, { cwd: input.projectPath }), { releaseDigest, environment: env });
190
+ // #4037: a promote a train started under a workspace gate may take that gate's approval in place of its own.
191
+ const { resolveWorkspaceRun } = await import("../../op/workspace-run-env.js");
192
+ const underWorkspace = resolveWorkspaceRun();
193
+ const workspace = underWorkspace?.gate ? { workspace: releaseWorkspaceGate(input.projectPath, underWorkspace.gate) } : {};
190
194
  /** Refuse, store, and pass the gates of an empty plan; the binding, or the exit code of a refusal already printed. */
191
195
  const bindDoc = async (doc, names, what) => {
192
196
  const provisional = gate.provisionalMembers(doc);
@@ -218,7 +222,7 @@ async function bindReleaseGate(input) {
218
222
  console.error(formatInfo(`release gate: ${what} ${doc.digest} for "${env}"` +
219
223
  (empty ? ", empty: its gates pass without an approval" : `, ${doc.summary.entries} entr${doc.summary.entries === 1 ? "y" : "ies"}, ${doc.summary.holes} hole(s)`) +
220
224
  ` (chant change-set show ${doc.digest})`));
221
- if (empty) {
225
+ if (empty && !input.planOnly) {
222
226
  if (!port.appendResolution)
223
227
  throw new Error("the gate ledger can't record a resolution, so an empty change set can't pass its gates");
224
228
  const { resolutions } = await port.read(gate.RELEASE_GATE_OP);
@@ -231,7 +235,7 @@ async function bindReleaseGate(input) {
231
235
  await port.appendResolution(gate.emptyResolution({ gate: name, doc, actor: input.actor, timestamp, ...(input.head ? { gitSha: input.head } : {}) }));
232
236
  }
233
237
  }
234
- return { binding: { op: gate.RELEASE_GATE_OP, planDigest: doc.digest, releaseDigest, verifyEmpty }, empty };
238
+ return { binding: { op: gate.RELEASE_GATE_OP, planDigest: doc.digest, releaseDigest, verifyEmpty, ...workspace }, empty };
235
239
  };
236
240
  const later = {
237
241
  replan: async (only, outputs) => (await planSet(only, outputs)).doc,
@@ -256,7 +260,7 @@ async function bindReleaseGate(input) {
256
260
  return {
257
261
  doc: stored.document,
258
262
  empty: isEmptyChangeSet(stored.document),
259
- binding: { op: gate.RELEASE_GATE_OP, planDigest: stored.document.digest, releaseDigest, verifyEmpty },
263
+ binding: { op: gate.RELEASE_GATE_OP, planDigest: stored.document.digest, releaseDigest, verifyEmpty, ...workspace },
260
264
  reads: fresh.reads,
261
265
  resumedFrom: stored.document.digest,
262
266
  ...groupsOf(fresh),
@@ -282,6 +286,19 @@ async function bindReleaseGate(input) {
282
286
  }
283
287
  return { doc: first.doc, ...bound, reads: first.reads, ...groupsOf(first), ...(first.plannedOutputs ? { plannedOutputs: first.plannedOutputs } : {}), ...(first.unknownInputs ? { unknownInputs: first.unknownInputs } : {}), ...later };
284
288
  }
289
+ /**
290
+ * The workspace gate stand-in for a release gate (#4037, ws-039), loading the
291
+ * workspace code only when a gate is asked about it. The approval must cover
292
+ * this member's gate, change set, environment and release.
293
+ */
294
+ function releaseWorkspaceGate(cwd, gate) {
295
+ return {
296
+ async standIn(q) {
297
+ const { memberGateStandIn } = await import("../../workspace/workspace-gates.js");
298
+ return memberGateStandIn(cwd, gate, q);
299
+ },
300
+ };
301
+ }
285
302
  /** A later round's or wave's plan was refused (provisional or failed members); the refusal is already printed. */
286
303
  class PromoteStageRefused extends Error {
287
304
  constructor() {
@@ -511,15 +528,19 @@ async function deployPlanIn(ctx, verb, plan, project, actor, record, under) {
511
528
  actor: actor,
512
529
  projectPath: project.projectPath,
513
530
  head,
514
- ...(resume ? { resume } : {}),
531
+ ...(resume && !args.planOnly ? { resume } : {}),
515
532
  ...(grouped ? { grouped } : {}),
516
533
  groupRuns,
534
+ ...(args.planOnly ? { planOnly: true } : {}),
517
535
  });
518
536
  if (typeof result === "number") {
519
537
  tidy();
520
538
  return result;
521
539
  }
522
- if (result) {
540
+ if (result && args.planOnly) {
541
+ bound = result;
542
+ }
543
+ else if (result) {
523
544
  bound = result;
524
545
  releaseGate = result.binding;
525
546
  changeSetJson = { changeSet: result.doc.digest, empty: result.empty };
@@ -538,6 +559,28 @@ async function deployPlanIn(ctx, verb, plan, project, actor, record, under) {
538
559
  throw err;
539
560
  }
540
561
  }
562
+ // #4037: --plan-only stops here, with the change set planned and stored, and nothing deployed.
563
+ if (args.planOnly && under) {
564
+ tidy();
565
+ const { gateNamesOf, RELEASE_GATE_OP: op } = await import("../../components/release-gate.js");
566
+ const planned = {
567
+ env: plan.to,
568
+ releaseDigest: under.release.releaseDigest,
569
+ label: under.label,
570
+ op,
571
+ gates: bound ? gateNamesOf(prepared) : [],
572
+ changeSet: bound?.doc.digest ?? null,
573
+ empty: bound?.empty ?? null,
574
+ components: plan.items.map((i) => i.component),
575
+ };
576
+ if (args.json)
577
+ console.log(JSON.stringify(planned, null, 2));
578
+ else if (!bound)
579
+ console.error(formatInfo(`release ${under.label ?? under.release.releaseDigest} for "${plan.to}": no promoted composition declares a gate, so there is no change set to approve; nothing was deployed`));
580
+ else
581
+ console.error(formatInfo(`release ${under.label ?? under.release.releaseDigest} for "${plan.to}": change set ${planned.changeSet}${planned.empty ? ", empty" : ""}, gates ${planned.gates.join(", ")}; nothing was deployed`));
582
+ return 0;
583
+ }
541
584
  if (args.waveGate && !bound) {
542
585
  console.error(formatError({ message: "--wave-gate needs a promote under --release whose compositions declare a gate", hint: PROMOTE_USAGE }));
543
586
  tidy();
@@ -902,6 +945,10 @@ export async function runComponentsPromote(ctx) {
902
945
  return 1;
903
946
  }
904
947
  }
948
+ if (args.planOnly && !args.release) {
949
+ console.error(formatError({ message: "--plan-only plans a release's change set: it needs --release <label|digest>", hint: PROMOTE_USAGE }));
950
+ return 1;
951
+ }
905
952
  const who = actorOrRefuse(ctx);
906
953
  if (typeof who === "number")
907
954
  return who;
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAEA,OAAO,EAAoB,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAItG,OAAO,EAAkB,KAAK,UAAU,EAAmB,MAAM,YAAY,CAAC;AAa9E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAgB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG3D,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;AAm0DzC;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,mBAAmB,GAAG,cAAc,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,qBAAqB,EAAE,cAAc,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,2BAA2B,EAAE,eAAe,CAAA;CAAO,GAC7K,OAAO,CAAC,MAAM,CAAC,CAuCjB;AAID;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,UAAU,EA0RvC,CAAC"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAEA,OAAO,EAAoB,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAItG,OAAO,EAAkB,KAAK,UAAU,EAAmB,MAAM,YAAY,CAAC;AAa9E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAgB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG3D,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;AA01DzC;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,mBAAmB,GAAG,cAAc,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,qBAAqB,EAAE,cAAc,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,2BAA2B,EAAE,eAAe,CAAA;CAAO,GAC7K,OAAO,CAAC,MAAM,CAAC,CAuCjB;AAID;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,UAAU,EA0RvC,CAAC"}
package/dist/cli/main.js CHANGED
@@ -1208,6 +1208,14 @@ Workspace (level 1, #2524):
1208
1208
  --no-cache reads every member
1209
1209
  --capability-view: each member's chant adds its
1210
1210
  capability view, mapped by its own lexicons
1211
+ workspace graph <dir> --discover [--runs-on <member>=<member>/<address>]... [--at <rev>] [--member <name>] [--detail 0..3] [--no-cache] [-o <file>]
1212
+ The same document for a directory with no
1213
+ declaration: the kinds' probes find the members, a
1214
+ discovered list says what each claimed directory
1215
+ became, and nothing is written inside <dir>.
1216
+ --runs-on names the cluster resource a member runs
1217
+ on, drawing a declared edge from its Argo CD cluster
1218
+ Secrets to it
1211
1219
  workspace drift --member <name> [--read <state|plan|refresh|live-read|ownership>] [--resource <addr>] [--env <name>] [--stream] [-o <file>]
1212
1220
  One member's drift, read by its own engine: a chant
1213
1221
  member through lifecycle diff --live (needs --env), a
@@ -1259,11 +1267,24 @@ Workspace (level 1, #2524):
1259
1267
  plan and the member sets acceptWorkspaceGates at base
1260
1268
  workspace train <env> [--pin <member>=<label|digest>]... [--dry-run] [--json]
1261
1269
  Record a release train: one cut release of every
1262
- chant member (the newest, unless --pin picks one),
1263
- under _members/_workspace/<env>/trains.jsonl. Refuses
1264
- when a member has no release
1270
+ chant and repo member (the newest, unless --pin picks
1271
+ one), under _members/_workspace/<env>/trains.jsonl. A
1272
+ repo member's releases are read at its pinned rev with
1273
+ its own chant release list (#5119). Refuses when a
1274
+ member has no release
1265
1275
  workspace train list <env> [--json]
1266
- The release trains recorded for <env>, oldest first
1276
+ The release trains recorded for <env>, oldest first,
1277
+ each with its digest and the runs that promoted it
1278
+ workspace train promote <env> [<train id|digest>] [--gate <name>] [--continue] [--dry-run] [--json]
1279
+ Promote a train (the newest for <env> unless named):
1280
+ each member's components promote --release, producers
1281
+ first. --gate plans every member first and records one
1282
+ workspace gate fact over their release gates; nothing
1283
+ deploys until run approve approves it (#4037). A train
1284
+ of repo members dispatches the first member repository
1285
+ instead; --continue moves on from the member's answer
1286
+ in _control/applied.jsonl, after applied or unchanged
1287
+ (#5119)
1267
1288
 
1268
1289
  Lifecycle (alias: lc):
1269
1290
  lifecycle snapshot <env> Query API, save metadata to orphan branch
@@ -1462,7 +1483,7 @@ Component release ledger + status:
1462
1483
  components promote Deploy the digests one environment's release
1463
1484
  ledger records to another, without a build
1464
1485
  (--to <env> [--from <env>] [--allow-skip]
1465
- [--release <label|digest>]
1486
+ [--release <label|digest> [--plan-only]]
1466
1487
  [--component <name> [--digest <sha256:...>]];
1467
1488
  --from defaults to the environment before --to
1468
1489
  in the config's environments; --dry-run prints
@@ -1470,7 +1491,9 @@ Component release ledger + status:
1470
1491
  --release a dependent plans against its
1471
1492
  upstream's planned outputs and plans again once
1472
1493
  it applies; --wave-gate <gate> checks each wave
1473
- at <gate>-wave-<k>; a stop writes --resume <file>)
1494
+ at <gate>-wave-<k>; a stop writes --resume <file>;
1495
+ --plan-only plans and stores the release's change
1496
+ set and deploys nothing, #4037)
1474
1497
  components rollback <env> Redeploy an earlier release of an environment
1475
1498
  from its recorded digest (--component <name>
1476
1499
  [--digest <sha256:...>]; defaults to the release
@@ -1 +1 @@
1
- {"version":3,"file":"parse-args.d.ts","sourceRoot":"","sources":["../../src/cli/parse-args.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAkH7C;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CA0zCpD"}
1
+ {"version":3,"file":"parse-args.d.ts","sourceRoot":"","sources":["../../src/cli/parse-args.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAqH7C;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAy0CpD"}
@@ -64,10 +64,13 @@ const BOOLEAN_FLAGS = new Set([
64
64
  "--bump",
65
65
  "--no-release-record",
66
66
  "--deploy-unchanged",
67
+ "--plan-only",
68
+ "--continue",
67
69
  "--no-record",
68
70
  "--fold",
69
71
  "--no-fold",
70
72
  "--no-cache",
73
+ "--discover",
71
74
  "--no-build",
72
75
  "--sandbox",
73
76
  "--yes",
@@ -1497,6 +1500,14 @@ export function parseArgs(args) {
1497
1500
  // `chant run --components --release --deploy-unchanged` (#4695): deploy a component whose inputs did not change.
1498
1501
  result.deployUnchanged = true;
1499
1502
  }
1503
+ else if (arg === "--continue") {
1504
+ // `chant workspace train promote --continue` (#5119): advance a train's promote across repositories from the answers recorded.
1505
+ result.continueTrain = true;
1506
+ }
1507
+ else if (arg === "--plan-only") {
1508
+ // `chant components promote --release --plan-only` (#4037): plan and store the release's change set, deploy nothing.
1509
+ result.planOnly = true;
1510
+ }
1500
1511
  else if (arg === "--artifacts") {
1501
1512
  // `chant release compile --artifacts` (#4026, internal)
1502
1513
  result.artifacts = true;
@@ -1563,6 +1574,10 @@ export function parseArgs(args) {
1563
1574
  // `chant workspace graph --no-cache` (#2876): read every member.
1564
1575
  result.noCache = true;
1565
1576
  }
1577
+ else if (arg === "--discover") {
1578
+ // `chant workspace graph <dir> --discover` (#5095): find the members by probe, with no declaration.
1579
+ result.discover = true;
1580
+ }
1566
1581
  else if (arg === "--no-fold") {
1567
1582
  // chant #1134 — fold is the default build path; this is the explicit
1568
1583
  // opt-out, and like --fold it beats chant.config.ts's build.fold.
@@ -1800,6 +1815,14 @@ export function parseArgs(args) {
1800
1815
  // generator and compares its output with the file in the tree.
1801
1816
  result.generated = true;
1802
1817
  }
1818
+ else if (arg === "--runs-on") {
1819
+ // `chant workspace graph --discover --runs-on <member>=<member>/<address>` (#5101): the cluster resource a discovered member runs on. Repeatable.
1820
+ const value = args[++i];
1821
+ const at = value?.indexOf("=") ?? -1;
1822
+ if (!value || at < 1 || at === value.length - 1)
1823
+ throw new Error("--runs-on needs a member and the cluster resource it runs on: --runs-on <member>=<member>/<address>");
1824
+ result.runsOn = { ...(result.runsOn ?? {}), [value.slice(0, at)]: value.slice(at + 1) };
1825
+ }
1803
1826
  else if (arg === "--member") {
1804
1827
  // #2537 — `chant workspace build|lint|audit|graph --member <name>`.
1805
1828
  // Repeatable, and a comma list works too.
@@ -650,6 +650,10 @@ export interface ParsedArgs {
650
650
  resource?: string;
651
651
  /** `chant workspace graph --no-cache` (#2876): read every member, bypassing the per-member cache. */
652
652
  noCache?: boolean;
653
+ /** `chant workspace graph <dir> --discover` (#5095): find the members by the kinds' probes, with no declaration and no writes inside <dir>. */
654
+ discover?: boolean;
655
+ /** `chant workspace graph --discover --runs-on <member>=<member>/<address>` (#5101): the cluster resource a discovered member runs on, by member name. */
656
+ runsOn?: Record<string, string>;
653
657
  /** `chant release images --no-build` (#4657): check the archives already on disk instead of building them. */
654
658
  noBuild?: boolean;
655
659
  /** `chant workspace graph --composites` (#2662): print each composite instance with the components that can deploy it. */
@@ -890,6 +894,10 @@ export interface ParsedArgs {
890
894
  release?: string;
891
895
  /** `chant run --components --release --deploy-unchanged` (#4695): deploy every component, also one whose declared inputs are the same as in the release the environment runs it from. */
892
896
  deployUnchanged?: boolean;
897
+ /** `chant components promote --release <label|digest> --plan-only` (#4037): plan the release's change set for `--to`, store it and print it, and deploy nothing. `chant workspace train promote --gate` asks each member for it before any member deploys. */
898
+ planOnly?: boolean;
899
+ /** `chant workspace train promote <env> <train> --continue` (#5119): advance the promote in flight of a train of repo members from the answers the control repo recorded, and start nothing new. */
900
+ continueTrain?: boolean;
893
901
  /** `chant release cut --build <command>` (#4026): the shell command run in the member's directory before each environment's templates are read, with `CHANT_ENV` set to the environment. */
894
902
  buildCommand?: string;
895
903
  /** `chant release compile --artifacts` (#4026, internal): build the artifacts of `--component` instead of compiling the environment. */