@intentius/chant 0.124.48 → 0.124.49

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 (167) hide show
  1. package/dist/cli/handlers/approve.d.ts.map +1 -1
  2. package/dist/cli/handlers/approve.js +20 -12
  3. package/dist/cli/handlers/graph-reader.d.ts +26 -0
  4. package/dist/cli/handlers/graph-reader.d.ts.map +1 -0
  5. package/dist/cli/handlers/graph-reader.js +41 -0
  6. package/dist/cli/handlers/graph.d.ts.map +1 -1
  7. package/dist/cli/handlers/graph.js +14 -0
  8. package/dist/cli/handlers/pr.d.ts.map +1 -1
  9. package/dist/cli/handlers/pr.js +40 -1
  10. package/dist/cli/main.d.ts.map +1 -1
  11. package/dist/cli/main.js +22 -0
  12. package/dist/cli/parse-args.d.ts.map +1 -1
  13. package/dist/cli/parse-args.js +11 -0
  14. package/dist/cli/registry.d.ts +8 -0
  15. package/dist/cli/registry.d.ts.map +1 -1
  16. package/dist/components/pr-run.d.ts +3 -0
  17. package/dist/components/pr-run.d.ts.map +1 -1
  18. package/dist/components/pr-run.js +1 -0
  19. package/dist/config.d.ts +16 -0
  20. package/dist/config.d.ts.map +1 -1
  21. package/dist/config.js +4 -0
  22. package/dist/gate-decision.d.ts +9 -0
  23. package/dist/gate-decision.d.ts.map +1 -1
  24. package/dist/gate-decision.js +22 -7
  25. package/dist/lexicon.d.ts +23 -0
  26. package/dist/lexicon.d.ts.map +1 -1
  27. package/dist/op/activities/activity-contracts.d.ts +4 -4
  28. package/dist/op/gate-approval-base.d.ts +25 -0
  29. package/dist/op/gate-approval-base.d.ts.map +1 -0
  30. package/dist/op/gate-approval-base.js +71 -0
  31. package/dist/op/gate-approval.d.ts +7 -4
  32. package/dist/op/gate-approval.d.ts.map +1 -1
  33. package/dist/op/gate-approval.js +2 -25
  34. package/dist/op/gate-name.d.ts +13 -0
  35. package/dist/op/gate-name.d.ts.map +1 -1
  36. package/dist/op/gate-name.js +14 -1
  37. package/dist/op/gate.d.ts +4 -3
  38. package/dist/op/gate.d.ts.map +1 -1
  39. package/dist/op/local-executor.d.ts +9 -2
  40. package/dist/op/local-executor.d.ts.map +1 -1
  41. package/dist/op/local-executor.js +24 -5
  42. package/dist/pr-loop.d.ts +10 -0
  43. package/dist/pr-loop.d.ts.map +1 -1
  44. package/dist/pr-loop.js +4 -0
  45. package/dist/pr-migrations.d.ts +62 -0
  46. package/dist/pr-migrations.d.ts.map +1 -0
  47. package/dist/pr-migrations.js +50 -0
  48. package/dist/pr-post.js +1 -1
  49. package/dist/wave-runtime.mjs +219 -218
  50. package/dist/workspace/check.schema.json +4 -2
  51. package/dist/workspace/checks/gate-approval.d.ts +58 -0
  52. package/dist/workspace/checks/gate-approval.d.ts.map +1 -0
  53. package/dist/workspace/checks/gate-approval.js +103 -0
  54. package/dist/workspace/checks.d.ts +1 -0
  55. package/dist/workspace/checks.d.ts.map +1 -1
  56. package/dist/workspace/checks.js +4 -0
  57. package/dist/workspace/declaration.d.ts +7 -0
  58. package/dist/workspace/declaration.d.ts.map +1 -1
  59. package/dist/workspace/declaration.js +13 -1
  60. package/dist/workspace/declaration.schema.json +33 -0
  61. package/dist/workspace/exit-cli.d.ts +44 -0
  62. package/dist/workspace/exit-cli.d.ts.map +1 -0
  63. package/dist/workspace/exit-cli.js +198 -0
  64. package/dist/workspace/exit.d.ts +159 -0
  65. package/dist/workspace/exit.d.ts.map +1 -0
  66. package/dist/workspace/exit.js +480 -0
  67. package/dist/workspace/exit.schema.json +257 -0
  68. package/dist/workspace/graph-cache.d.ts +3 -1
  69. package/dist/workspace/graph-cache.d.ts.map +1 -1
  70. package/dist/workspace/graph-cache.js +12 -1
  71. package/dist/workspace/import-fetch.d.ts +38 -0
  72. package/dist/workspace/import-fetch.d.ts.map +1 -0
  73. package/dist/workspace/import-fetch.js +99 -0
  74. package/dist/workspace/import-init.d.ts +26 -0
  75. package/dist/workspace/import-init.d.ts.map +1 -0
  76. package/dist/workspace/import-init.js +130 -0
  77. package/dist/workspace/import-source.d.ts +147 -0
  78. package/dist/workspace/import-source.d.ts.map +1 -0
  79. package/dist/workspace/import-source.js +370 -0
  80. package/dist/workspace/init.d.ts +4 -0
  81. package/dist/workspace/init.d.ts.map +1 -1
  82. package/dist/workspace/init.js +70 -3
  83. package/dist/workspace/kind-readers.d.ts +6 -0
  84. package/dist/workspace/kind-readers.d.ts.map +1 -1
  85. package/dist/workspace/kind-readers.js +18 -0
  86. package/dist/workspace/kinds.d.ts +24 -1
  87. package/dist/workspace/kinds.d.ts.map +1 -1
  88. package/dist/workspace/kinds.js +64 -4
  89. package/dist/workspace/lineage-upgrade.d.ts.map +1 -1
  90. package/dist/workspace/lineage-upgrade.js +13 -4
  91. package/dist/workspace/new-migrations.d.ts +47 -0
  92. package/dist/workspace/new-migrations.d.ts.map +1 -0
  93. package/dist/workspace/new-migrations.js +91 -0
  94. package/dist/workspace/pr-report.schema.json +46 -0
  95. package/dist/workspace/promote.d.ts +96 -0
  96. package/dist/workspace/promote.d.ts.map +1 -0
  97. package/dist/workspace/promote.js +263 -0
  98. package/dist/workspace/reason-codes.d.ts +13 -0
  99. package/dist/workspace/reason-codes.d.ts.map +1 -1
  100. package/dist/workspace/reason-codes.js +14 -0
  101. package/dist/workspace/search-contract.d.ts +1 -1
  102. package/dist/workspace/search-contract.d.ts.map +1 -1
  103. package/dist/workspace/workspace-kinds.schema.json +50 -7
  104. package/package.json +1 -1
  105. package/src/cli/handlers/approve.ts +10 -2
  106. package/src/cli/handlers/graph-reader.test.ts +31 -0
  107. package/src/cli/handlers/graph-reader.ts +51 -0
  108. package/src/cli/handlers/graph.ts +14 -0
  109. package/src/cli/handlers/pr.ts +38 -1
  110. package/src/cli/main.test.ts +2 -0
  111. package/src/cli/main.ts +22 -0
  112. package/src/cli/parse-args.ts +8 -0
  113. package/src/cli/registry.ts +8 -0
  114. package/src/components/pr-env-run-bundle.test.ts +1 -0
  115. package/src/components/pr-run.ts +4 -0
  116. package/src/config.ts +16 -0
  117. package/src/gate-decision-bundle.test.ts +4 -2
  118. package/src/gate-decision-identity.test.ts +11 -0
  119. package/src/gate-decision.ts +26 -6
  120. package/src/lexicon.ts +24 -0
  121. package/src/op/gate-approval-at-base.test.ts +97 -0
  122. package/src/op/gate-approval-base.ts +72 -0
  123. package/src/op/gate-approval.ts +10 -21
  124. package/src/op/gate-name.ts +16 -1
  125. package/src/op/gate.ts +4 -3
  126. package/src/op/local-executor.ts +25 -5
  127. package/src/pr-loop-bundle.test.ts +3 -2
  128. package/src/pr-loop.test.ts +52 -0
  129. package/src/pr-loop.ts +12 -0
  130. package/src/pr-migrations.ts +97 -0
  131. package/src/pr-post.ts +1 -1
  132. package/src/workspace/__fixtures__/import/spacelift.json +9 -0
  133. package/src/workspace/__fixtures__/import/tfc.json +13 -0
  134. package/src/workspace/behold-kinds.test.ts +1 -0
  135. package/src/workspace/check-contract.test.ts +3 -2
  136. package/src/workspace/check.schema.json +4 -2
  137. package/src/workspace/checks/gate-approval.test.ts +77 -0
  138. package/src/workspace/checks/gate-approval.ts +121 -0
  139. package/src/workspace/checks.ts +4 -0
  140. package/src/workspace/declaration.schema.json +33 -0
  141. package/src/workspace/declaration.ts +19 -2
  142. package/src/workspace/exit-cli.ts +219 -0
  143. package/src/workspace/exit.schema.json +257 -0
  144. package/src/workspace/exit.test.ts +185 -0
  145. package/src/workspace/exit.ts +560 -0
  146. package/src/workspace/graph-cache.ts +12 -2
  147. package/src/workspace/identity.test.ts +18 -3
  148. package/src/workspace/import-fetch.ts +151 -0
  149. package/src/workspace/import-init.ts +147 -0
  150. package/src/workspace/import-source.test.ts +183 -0
  151. package/src/workspace/import-source.ts +462 -0
  152. package/src/workspace/init.test.ts +55 -1
  153. package/src/workspace/init.ts +66 -4
  154. package/src/workspace/kind-readers.test.ts +36 -0
  155. package/src/workspace/kind-readers.ts +18 -1
  156. package/src/workspace/kinds.test.ts +23 -0
  157. package/src/workspace/kinds.ts +81 -5
  158. package/src/workspace/lineage-upgrade.test.ts +20 -0
  159. package/src/workspace/lineage-upgrade.ts +16 -7
  160. package/src/workspace/new-migrations.test.ts +98 -0
  161. package/src/workspace/new-migrations.ts +109 -0
  162. package/src/workspace/pr-report.schema.json +46 -0
  163. package/src/workspace/promote.test.ts +114 -0
  164. package/src/workspace/promote.ts +302 -0
  165. package/src/workspace/reason-codes.test.ts +4 -0
  166. package/src/workspace/reason-codes.ts +14 -0
  167. package/src/workspace/workspace-kinds.schema.json +50 -7
@@ -20,6 +20,12 @@
20
20
  * package, found from the workspace root as the kind's pin was. The lexicon
21
21
  * chant loads is then the one the declaration pins.
22
22
  *
23
+ * A kind whose `graph` names a `reader` module instead (#4413) gets a
24
+ * project with `lexicons: []` and `graph.reader` set to the module, which the
25
+ * supplying package ships, so any package can supply one. The member's own
26
+ * `chant graph` loads it there, under the member's toolchain, and prints the
27
+ * IR it returns. There is no lexicon to link.
28
+ *
23
29
  * Nothing is written under the workspace, and the projects are removed when
24
30
  * the read ends. A lexicon that can't be found where its pin says fails the
25
31
  * member with `command-failed` and says what to install; the other members
@@ -1 +1 @@
1
- {"version":3,"file":"kind-readers.d.ts","sourceRoot":"","sources":["../../src/workspace/kind-readers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAW,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE3E,MAAM,WAAW,eAAe;IAC9B,4FAA4F;IAC5F,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,gEAAgE;IAChE,OAAO,IAAI,IAAI,CAAC;CACjB;AAmCD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CAoClF"}
1
+ {"version":3,"file":"kind-readers.d.ts","sourceRoot":"","sources":["../../src/workspace/kind-readers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAW,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE3E,MAAM,WAAW,eAAe;IAC9B,4FAA4F;IAC5F,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,gEAAgE;IAChE,OAAO,IAAI,IAAI,CAAC;CACjB;AAoCD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CA8ClF"}
@@ -20,6 +20,12 @@
20
20
  * package, found from the workspace root as the kind's pin was. The lexicon
21
21
  * chant loads is then the one the declaration pins.
22
22
  *
23
+ * A kind whose `graph` names a `reader` module instead (#4413) gets a
24
+ * project with `lexicons: []` and `graph.reader` set to the module, which the
25
+ * supplying package ships, so any package can supply one. The member's own
26
+ * `chant graph` loads it there, under the member's toolchain, and prints the
27
+ * IR it returns. There is no lexicon to link.
28
+ *
23
29
  * Nothing is written under the workspace, and the projects are removed when
24
30
  * the read ends. A lexicon that can't be found where its pin says fails the
25
31
  * member with `command-failed` and says what to install; the other members
@@ -47,6 +53,8 @@ function real(path) {
47
53
  /** Why a unit's lexicon can't be loaded from `root`, or the `node_modules` to link. */
48
54
  function lexiconModules(unit, root) {
49
55
  const reader = unit.reader;
56
+ if (!reader.lexicon)
57
+ return { message: `kind ${unit.kind} names no lexicon` };
50
58
  const name = lexiconPackageName(reader.lexicon);
51
59
  const installed = findInstalledPackage(name, root);
52
60
  if (!installed) {
@@ -80,6 +88,16 @@ export function prepareKindReaders(plan, root) {
80
88
  group.units = group.units.filter((unit) => {
81
89
  if (!unit.reader)
82
90
  return true;
91
+ if (unit.reader.readerFile) {
92
+ // A graph reader module (#4413): no lexicon and no node_modules link. The module sits in the pinned package and resolves its own imports from there.
93
+ scratch ?? (scratch = mkdtempSync(join(tmpdir(), "chant-ws-reader-")));
94
+ const project = join(scratch, unit.id);
95
+ mkdirSync(project, { recursive: true });
96
+ const config = substituteGraphConfig(unit.reader.config, { member: unit.member, dir: unit.abs, workspace: root });
97
+ writeFileSync(join(project, "chant.config.json"), `${JSON.stringify({ lexicons: [], graph: { lint: "report", reader: { module: unit.reader.readerFile, config } } }, null, 2)}\n`);
98
+ unit.abs = project;
99
+ return true;
100
+ }
83
101
  const found = lexiconModules(unit, root);
84
102
  if ("message" in found) {
85
103
  failed.push({ name: unit.member, dir: unit.dir, kind: unit.kind, reason: { code: "command-failed", message: found.message } });
@@ -61,6 +61,21 @@ export interface FileProbe {
61
61
  in: string[];
62
62
  starts: string[];
63
63
  };
64
+ /**
65
+ * A file directly in the directory whose name matches one of `in` parses
66
+ * as YAML or JSON (every document of a multi-document file is read), and
67
+ * one document satisfies one of the `match` entries. An entry maps JSON
68
+ * Pointers to the values allowed there, and a document satisfies it when
69
+ * every pointer holds a value that matches one of its patterns. A `*` in
70
+ * a pattern matches any run of characters, so `["*"]` means "has a
71
+ * value". This is how an Argo Application, a Flux Kustomization and a
72
+ * CloudFormation template are found by what they say, not by their file
73
+ * names (#3179). A file that doesn't parse is no evidence either way.
74
+ */
75
+ anyDocument?: {
76
+ in: string[];
77
+ match: Record<string, string[]>[];
78
+ };
64
79
  }
65
80
  /** A string, integer or boolean field a kind declares for its members (#3151). */
66
81
  export interface ScalarKindField {
@@ -118,7 +133,15 @@ export type KindOutputs =
118
133
  * chant writes itself. See {@link substituteGraphConfig} for the placeholders.
119
134
  */
120
135
  export interface KindGraph {
121
- lexicon: string;
136
+ /** The lexicon that reads the member; unset when `reader` is. */
137
+ lexicon?: string;
138
+ /**
139
+ * A graph reader module (#4413), as the kinds file names it: a path inside
140
+ * the supplying package, which may be any package. Unset when `lexicon` is.
141
+ */
142
+ reader?: string;
143
+ /** The reader module, absolute; set once the package directory is known. */
144
+ readerFile?: string;
122
145
  config: Record<string, unknown>;
123
146
  }
124
147
  export interface MemberKind {
@@ -1 +1 @@
1
- {"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../../src/workspace/kinds.ts"],"names":[],"mappings":"AAAA;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B,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,YAAY,CAsCrH"}
@@ -16,7 +16,7 @@
16
16
  * kinds claim one directory, the highest precedence decides, and a tie
17
17
  * fails ({@link resolveKind}).
18
18
  */
19
- import { readFileSync } from "node:fs";
19
+ import { existsSync, readFileSync } from "node:fs";
20
20
  import { isAbsolute, join, relative, resolve } from "node:path";
21
21
  import schema from "./workspace-kinds.schema.json" with { type: "json" };
22
22
  import { joinPath, skippedDir } from "./tree.js";
@@ -122,7 +122,7 @@ export function probeKind(kind, tree, dir) {
122
122
  return holdsChantProject(tree, dir);
123
123
  if ("repo" in kind.probe)
124
124
  return true;
125
- const { anyFile, anyBlock, anyJsonKey, anyLine } = kind.probe;
125
+ const { anyFile, anyBlock, anyJsonKey, anyLine, anyDocument } = kind.probe;
126
126
  if (anyFile && filesMatching(tree, dir, anyFile).length > 0)
127
127
  return true;
128
128
  if (anyJsonKey) {
@@ -149,6 +149,17 @@ export function probeKind(kind, tree, dir) {
149
149
  }
150
150
  }
151
151
  }
152
+ if (anyDocument) {
153
+ for (const file of filesMatching(tree, dir, anyDocument.in)) {
154
+ try {
155
+ if (documentsOf(tree.read(file)).some((doc) => anyDocument.match.some((m) => documentMatches(doc, m))))
156
+ return true;
157
+ }
158
+ catch {
159
+ // An unreadable file is no evidence either way.
160
+ }
161
+ }
162
+ }
152
163
  if (anyBlock) {
153
164
  const opener = new RegExp(`^\\s*(?:${anyBlock.blocks.map(escapeRegExp).join("|")})\\s*\\{`, "m");
154
165
  for (const file of filesMatching(tree, dir, anyBlock.in)) {
@@ -188,6 +199,36 @@ function filesMatching(tree, dir, names) {
188
199
  }
189
200
  return out.sort();
190
201
  }
202
+ /**
203
+ * The documents in `text`, read as YAML (which holds JSON). A CloudFormation
204
+ * short-form tag such as `!Ref` or `!Sub` is not YAML js-yaml knows, so a
205
+ * file that fails to parse is read again with those tags dropped. Text that
206
+ * still doesn't parse has no documents.
207
+ */
208
+ function documentsOf(text) {
209
+ try {
210
+ return yaml.loadAll(text);
211
+ }
212
+ catch {
213
+ try {
214
+ return yaml.loadAll(text.replace(/(^|[\s:\-[,{])!(?:[A-Za-z][\w]*:?)+/gm, "$1"));
215
+ }
216
+ catch {
217
+ return [];
218
+ }
219
+ }
220
+ }
221
+ /** Whether every pointer in `match` holds a value matching one of its patterns. */
222
+ function documentMatches(doc, match) {
223
+ const pointers = Object.entries(match);
224
+ return (pointers.length > 0 &&
225
+ pointers.every(([pointer, patterns]) => {
226
+ const value = atPointer(doc, pointer);
227
+ if (value === undefined)
228
+ return false;
229
+ return patterns.some((pattern) => new RegExp(`^${pattern.split("*").map(escapeRegExp).join(".*")}$`).test(String(value)));
230
+ }));
231
+ }
191
232
  /** The value at JSON Pointer `pointer` in `json`, or undefined when there is none. */
192
233
  function atPointer(json, pointer) {
193
234
  let at = json;
@@ -301,12 +342,15 @@ export function parseKindData(text, source) {
301
342
  ...(k.probe.anyBlock ? { anyBlock: { in: [...k.probe.anyBlock.in], blocks: [...k.probe.anyBlock.blocks] } } : {}),
302
343
  ...(k.probe.anyJsonKey ? { anyJsonKey: { in: [...k.probe.anyJsonKey.in], pointers: [...k.probe.anyJsonKey.pointers] } } : {}),
303
344
  ...(k.probe.anyLine ? { anyLine: { in: [...k.probe.anyLine.in], starts: [...k.probe.anyLine.starts] } } : {}),
345
+ ...(k.probe.anyDocument ? { anyDocument: { in: [...k.probe.anyDocument.in], match: k.probe.anyDocument.match.map((m) => structuredClone(m)) } } : {}),
304
346
  },
305
347
  precedence: k.precedence,
306
348
  shape: "member",
307
349
  outputs: { from: "declared", names: [...(k.outputs ?? [])] },
308
350
  source,
309
- ...(k.graph ? { graph: { lexicon: k.graph.lexicon, config: structuredClone(k.graph.config) } } : {}),
351
+ ...(k.graph
352
+ ? { graph: { ...(k.graph.lexicon ? { lexicon: k.graph.lexicon } : {}), ...(k.graph.reader ? { reader: k.graph.reader } : {}), config: structuredClone(k.graph.config ?? {}) } }
353
+ : {}),
310
354
  ...(k.fields ? { fields: structuredClone(k.fields) } : {}),
311
355
  ...(k.reader && KIND_LINK_READERS.includes(k.reader) ? { reader: k.reader } : {}),
312
356
  ...(k.memberFile ? { memberFile: { path: k.memberFile.path, schema: k.memberFile.schema } } : {}),
@@ -365,7 +409,23 @@ export function readPackageKinds(packageDir, source) {
365
409
  if (problem)
366
410
  data.problems.push(`${name}: kind ${k.name} ${problem}; members of the kind fail WSP012 until it is fixed`);
367
411
  }
368
- if (k.graph && packageName !== lexiconPackageName(k.graph.lexicon)) {
412
+ if (k.graph?.reader) {
413
+ // A reader module is any package's own file (#4413): it must sit inside the package and exist. Nothing is imported here.
414
+ const file = resolve(packageDir, ...k.graph.reader.split("/"));
415
+ const inside = relative(packageDir, file);
416
+ if (inside.startsWith("..") || isAbsolute(inside)) {
417
+ data.problems.push(`${name}: kind ${k.name} names graph reader ${k.graph.reader}, which is outside the package; the kind is kept, and workspace graph lists its members with kind-not-run`);
418
+ delete k.graph;
419
+ }
420
+ else if (!existsSync(file)) {
421
+ data.problems.push(`${name}: kind ${k.name} names graph reader ${k.graph.reader}, which does not exist in the package; the kind is kept, and workspace graph lists its members with kind-not-run`);
422
+ delete k.graph;
423
+ }
424
+ else {
425
+ k.graph.readerFile = file;
426
+ }
427
+ }
428
+ else if (k.graph?.lexicon && packageName !== lexiconPackageName(k.graph.lexicon)) {
369
429
  data.problems.push(`${name}: kind ${k.name} reads its members with lexicon ${k.graph.lexicon}, which is ${lexiconPackageName(k.graph.lexicon)}, ` +
370
430
  `and this package is ${packageName ?? "unnamed"}; the kind is kept, and workspace graph lists its members with kind-not-run`);
371
431
  delete k.graph;
@@ -1 +1 @@
1
- {"version":3,"file":"lineage-upgrade.d.ts","sourceRoot":"","sources":["../../src/workspace/lineage-upgrade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA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;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,+CAA+C;IAC/C,OAAO,IAAI,IAAI,CAAC;CACjB;AA+OD,mGAAmG;AACnG,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD;AA+FD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAyBjI;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CA0QlF;AAyBD,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAa9D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAiBlG;AAED,sEAAsE;AACtE,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,EAAE,CAmC9D"}
@@ -401,16 +401,25 @@ export function isGovernancePath(path) {
401
401
  * one. The Op files are read from the project's tree, which the upgrade
402
402
  * requires to match HEAD for every path the patch touches.
403
403
  *
404
+ * Both come from HEAD, never from the patch: the Op files are read from the
405
+ * clean project tree, and the declaration through `identityGatesAt(repo,
406
+ * head)` (`git show`). A change the upgrade itself makes to an Op or to
407
+ * `chant.workspace.json` cannot lower the approvals it asks for (#4404). A
408
+ * gate whose `identity.gates.<gate>.quorum` at HEAD sets one is asked for that
409
+ * quorum, as a run of the gate is (#4324), not the Op's own.
410
+ *
404
411
  * Discovery runs from each changed Op file's own directory, so it finds the
405
412
  * file under the project that owns it. Run from a workspace root, it would
406
413
  * skip every member's Op files (#2892).
407
414
  */
408
- async function rulesAtHead(repo, paths) {
415
+ async function rulesAtHead(repo, paths, head) {
409
416
  const opFiles = new Set(paths.filter((p) => GOVERNANCE[0].test(p)));
410
417
  let count = 1;
411
418
  let roles;
412
419
  if (opFiles.size > 0) {
413
420
  const { discoverOps } = await import("../op/discover.js");
421
+ const { identityGatesAt } = await import("../gate-decision.js");
422
+ const atBase = new Map(identityGatesAt(repo, head).map((g) => [g.gate, g.quorum]));
414
423
  const dirs = new Set([...opFiles].map((p) => dirname(join(repo, p))));
415
424
  for (const dir of dirs) {
416
425
  if (!existsSync(dir))
@@ -422,7 +431,7 @@ async function rulesAtHead(repo, paths) {
422
431
  continue;
423
432
  // #4290: a quorum may be a list of rules; the strictest count is asked for.
424
433
  for (const approval of gateApprovals(config)) {
425
- for (const rule of quorumRules(approval.quorum)) {
434
+ for (const rule of quorumRules(atBase.get(approval.gate) ?? approval.quorum)) {
426
435
  if (rule.count > count) {
427
436
  count = rule.count;
428
437
  roles = rule.roles;
@@ -438,7 +447,7 @@ function gateApprovals(config) {
438
447
  const out = [];
439
448
  const visit = (step) => {
440
449
  if (step.kind === "gate")
441
- out.push(step.approval ?? {});
450
+ out.push({ gate: step.gate ?? step.signalName ?? "", ...(step.approval?.quorum !== undefined ? { quorum: step.approval.quorum } : {}) });
442
451
  if (step.kind === "effect")
443
452
  (step.steps ?? []).forEach(visit);
444
453
  };
@@ -693,7 +702,7 @@ export async function stageUpgrade(options) {
693
702
  if (touched.length > 0) {
694
703
  throw new UpgradeError(`the upgrade changes governance files that have uncommitted edits (${touched.map((l) => l.slice(3)).join(", ")}). Commit them first: their gates are read at HEAD.`);
695
704
  }
696
- governance = { paths: governed, approval: await rulesAtHead(repo, governed), rules: head };
705
+ governance = { paths: governed, approval: await rulesAtHead(repo, governed, head), rules: head };
697
706
  }
698
707
  // 5. Checks.
699
708
  const checks = [];
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The migration files a pull request adds to a migration-directory workspace
3
+ * member (#4407), for the plan note. Reads the member's migrations at the
4
+ * pull request's head with the kind's own reader (`./kind-link-readers.ts`),
5
+ * keeps the files the base commit lacks, and asks a lexicon to classify
6
+ * them (`LexiconPlugin.classifyMigrations`). It reads git objects and files
7
+ * only: nothing is applied, no server is contacted, and no tool runs.
8
+ */
9
+ import type { LexiconPlugin } from "../lexicon.js";
10
+ import type { PrMigrationFile } from "../pr-migrations.js";
11
+ import { type KindLinkRead, type KindReadMigration } from "./kind-link-readers.js";
12
+ import type { WorkspaceTree } from "./tree.js";
13
+ /** One member's new migrations. */
14
+ export interface NewMigrationGroup {
15
+ member: string;
16
+ /** The member's directory, tree-relative; "" for the workspace root. */
17
+ dir: string;
18
+ reader: string;
19
+ dialect: string;
20
+ /** The new files, in the order the tool applies them. */
21
+ migrations: KindReadMigration[];
22
+ }
23
+ /**
24
+ * Per member, the migrations whose file is not in `base`. An `undo` file is
25
+ * not an up migration and is left out. With no `base` tree (the workspace did
26
+ * not exist there) every migration is new. `only` limits the answer to one
27
+ * member, for a member's own pipeline.
28
+ */
29
+ export declare function newMigrationGroups(members: readonly {
30
+ name: string;
31
+ dir: string;
32
+ }[], read: ReadonlyMap<string, KindLinkRead>, base: WorkspaceTree | undefined, only?: string): NewMigrationGroup[];
33
+ /**
34
+ * Classify the new files with the first lexicon that answers each. A file no
35
+ * lexicon answers for comes back with an `error` that says which dialect, so
36
+ * the note shows it instead of leaving it out.
37
+ */
38
+ export declare function classifyNewMigrations(groups: readonly NewMigrationGroup[], head: WorkspaceTree, plugins: readonly Pick<LexiconPlugin, "name" | "classifyMigrations">[]): Promise<PrMigrationFile[]>;
39
+ /**
40
+ * The new migration files of the workspace holding `cwd`, between `base` and
41
+ * `head`. Empty outside a workspace or when the declaration cannot be read.
42
+ */
43
+ export declare function newMigrationFilesBetween(cwd: string, base: string, head: string, options: {
44
+ member?: string;
45
+ plugins: () => Promise<readonly Pick<LexiconPlugin, "name" | "classifyMigrations">[]>;
46
+ }): Promise<PrMigrationFile[]>;
47
+ //# sourceMappingURL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,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,OAAO,CAAC,SAAS,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,oBAAoB,CAAC,EAAE,CAAC,CAAA;CAAE,GAClH,OAAO,CAAC,eAAe,EAAE,CAAC,CAoB5B"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The migration files a pull request adds to a migration-directory workspace
3
+ * member (#4407), for the plan note. Reads the member's migrations at the
4
+ * pull request's head with the kind's own reader (`./kind-link-readers.ts`),
5
+ * keeps the files the base commit lacks, and asks a lexicon to classify
6
+ * them (`LexiconPlugin.classifyMigrations`). It reads git objects and files
7
+ * only: nothing is applied, no server is contacted, and no tool runs.
8
+ */
9
+ import { readDeclaration } from "./declaration.js";
10
+ import { readKindLinks } from "./kind-link-readers.js";
11
+ import { loadKindRegistry } from "./kinds.js";
12
+ import { locateWorkspace } from "./which-chant.js";
13
+ /**
14
+ * Per member, the migrations whose file is not in `base`. An `undo` file is
15
+ * not an up migration and is left out. With no `base` tree (the workspace did
16
+ * not exist there) every migration is new. `only` limits the answer to one
17
+ * member, for a member's own pipeline.
18
+ */
19
+ export function newMigrationGroups(members, read, base, only) {
20
+ const out = [];
21
+ for (const m of members) {
22
+ if (only !== undefined && m.name !== only)
23
+ continue;
24
+ const r = read.get(m.name);
25
+ if (!r?.migrations)
26
+ continue;
27
+ const added = r.migrations.filter((mig) => mig.type !== "undo" && base?.stat(mig.file) !== "file");
28
+ if (added.length === 0)
29
+ continue;
30
+ out.push({ member: m.name, dir: m.dir === "." ? "" : m.dir, reader: r.reader, dialect: added[0].dialect, migrations: added });
31
+ }
32
+ return out;
33
+ }
34
+ /**
35
+ * Classify the new files with the first lexicon that answers each. A file no
36
+ * lexicon answers for comes back with an `error` that says which dialect, so
37
+ * the note shows it instead of leaving it out.
38
+ */
39
+ export async function classifyNewMigrations(groups, head, plugins) {
40
+ const out = [];
41
+ for (const g of groups) {
42
+ const files = g.migrations.map((m) => m.file);
43
+ const answers = new Map();
44
+ for (const p of plugins) {
45
+ if (!p.classifyMigrations || answers.size === files.length)
46
+ continue;
47
+ const left = files.filter((f) => !answers.has(f));
48
+ try {
49
+ for (const a of await p.classifyMigrations({ reader: g.reader, dialect: g.dialect, tree: head, dir: g.dir, files: left }))
50
+ answers.set(a.file, a);
51
+ }
52
+ catch (err) {
53
+ for (const f of left)
54
+ answers.set(f, { file: f, statements: [], error: `the ${p.name} lexicon could not classify it: ${err instanceof Error ? err.message : String(err)}` });
55
+ }
56
+ }
57
+ for (const m of g.migrations) {
58
+ const a = answers.get(m.file) ?? { file: m.file, statements: [], error: `no installed lexicon classifies ${g.dialect} migrations` };
59
+ out.push({ member: g.member, reader: g.reader, version: m.version, name: m.name, type: m.type, dialect: m.dialect, ...a });
60
+ }
61
+ }
62
+ return out;
63
+ }
64
+ /**
65
+ * The new migration files of the workspace holding `cwd`, between `base` and
66
+ * `head`. Empty outside a workspace or when the declaration cannot be read.
67
+ */
68
+ export async function newMigrationFilesBetween(cwd, base, head, options) {
69
+ let located;
70
+ let declaration;
71
+ try {
72
+ located = locateWorkspace(cwd, head);
73
+ declaration = readDeclaration(located.tree, "", { rootChant: true });
74
+ }
75
+ catch {
76
+ return [];
77
+ }
78
+ const { registry } = loadKindRegistry(declaration.pins, located.rootOnDisk);
79
+ const read = readKindLinks(declaration, located.tree, registry);
80
+ let baseTree;
81
+ try {
82
+ baseTree = locateWorkspace(cwd, base).tree;
83
+ }
84
+ catch {
85
+ baseTree = undefined;
86
+ }
87
+ const groups = newMigrationGroups(declaration.members, read, baseTree, options.member);
88
+ if (groups.length === 0)
89
+ return [];
90
+ return classifyNewMigrations(groups, located.tree, await options.plugins());
91
+ }
@@ -92,6 +92,39 @@
92
92
  }
93
93
  }
94
94
  },
95
+ "migrations": {
96
+ "type": "array",
97
+ "description": "Added within contract version 1 by #4407, written by chant 0.124.49 and newer. Plan stage: the migration files the pull request adds in a migration-directory workspace member (goose, golang-migrate, clickhouse-migrations, Flyway), each statement with the class the lexicon's classifier gives it, read offline. Absent when the pull request adds none.",
98
+ "items": {
99
+ "type": "object",
100
+ "required": ["member", "reader", "file", "version", "name", "type", "dialect", "statements"],
101
+ "properties": {
102
+ "member": { "type": "string" },
103
+ "reader": { "type": "string" },
104
+ "file": { "type": "string", "description": "Relative to the workspace root." },
105
+ "version": { "type": "string" },
106
+ "name": { "type": "string" },
107
+ "type": { "enum": ["versioned", "repeatable", "baseline", "undo"] },
108
+ "dialect": { "type": "string" },
109
+ "error": { "type": "string", "description": "Why the file could not be read; its statements are then empty." },
110
+ "statements": {
111
+ "type": "array",
112
+ "items": {
113
+ "type": "object",
114
+ "required": ["index", "sql", "outcome", "changes"],
115
+ "properties": {
116
+ "index": { "type": "integer", "minimum": 1 },
117
+ "sql": { "type": "string" },
118
+ "outcome": { "enum": ["classified", "undecided", "unclassified", "data"] },
119
+ "changes": { "type": "array", "items": { "$ref": "#/$defs/migrationChange" } },
120
+ "candidates": { "type": "array", "items": { "$ref": "#/$defs/migrationChange" }, "description": "With undecided: the rules that could apply." },
121
+ "note": { "type": "string" }
122
+ }
123
+ }
124
+ }
125
+ }
126
+ }
127
+ },
95
128
  "plannedOutputs": {
96
129
  "type": "object",
97
130
  "description": "Added within contract version 1 by #3999, written by chant 0.124.32 and newer. Per dependency in the change that a member was planned against, the names of the outputs its plan knows, sorted. An output a member reads that is not listed is known only after apply, and the member lists it under unknownInputs. Absent when no member read one.",
@@ -258,6 +291,19 @@
258
291
  }
259
292
  },
260
293
  "$defs": {
294
+ "migrationChange": {
295
+ "type": "object",
296
+ "required": ["rule", "class", "label", "title"],
297
+ "properties": {
298
+ "rule": { "type": "string" },
299
+ "class": { "type": "string" },
300
+ "label": { "type": "string" },
301
+ "title": { "type": "string" },
302
+ "lock": { "type": "string" },
303
+ "destructive": { "type": "boolean" },
304
+ "note": { "type": "string" }
305
+ }
306
+ },
261
307
  "policyFinding": {
262
308
  "type": "object",
263
309
  "required": ["rule", "message"],
@@ -0,0 +1,96 @@
1
+ /**
2
+ * `chant workspace promote <member>` (#3178): move one member one rung up the
3
+ * kind ladder, `other` or `terraform`, then `choudoufu`, then `chant`.
4
+ *
5
+ * The change is staged the way `workspace upgrade` stages one (#2550): in a
6
+ * git worktree at HEAD, so the tree is never touched until the gate passes.
7
+ * The gate is `workspace-promote/<member>` on the gate ledger and binds the
8
+ * digest of the patch the staging produced. The first run records a pending
9
+ * fact and exits 3. After `chant approve workspace-promote <member>`, the same
10
+ * command stages again, finds the approval for the same digest, applies the
11
+ * patch, and runs the rung's follow-up (for `choudoufu`, stamping the
12
+ * ownership markers with `live-import -approve`).
13
+ *
14
+ * Rungs:
15
+ *
16
+ * - `terraform` to `choudoufu`: `choudoufu live-check` in the member's
17
+ * directory must pass, then `choudoufu live-import -state=<--state>
18
+ * -estate=<member>` prints its ratification report (read-only: it stamps
19
+ * nothing without `-approve`). The patch changes the member's kind.
20
+ * - `choudoufu` or `other` to `chant`: `chant import` writes TypeScript into
21
+ * the member's directory. The patch holds those files and the kind change.
22
+ *
23
+ * Commands run through an injectable runner, so a test never starts a binary.
24
+ */
25
+ import type { CommandContext } from "../cli/registry.js";
26
+ import { type GateLedgerPort } from "../op/gate.js";
27
+ export declare const PROMOTE_PLAN_KIND = "workspace-promote";
28
+ export declare const PROMOTE_GATED_EXIT = 3;
29
+ export declare class PromoteError extends Error {
30
+ }
31
+ /** The ladder, lowest rung first. `other` and `terraform` share the bottom rung. */
32
+ export declare const LADDER: readonly ["terraform", "choudoufu", "chant"];
33
+ export interface Rung {
34
+ from: string;
35
+ to: "choudoufu" | "chant";
36
+ }
37
+ /** The next rung for a member of `kind`, or undefined at the top or off the ladder. */
38
+ export declare function nextRung(kind: string): Rung | undefined;
39
+ export interface CommandRun {
40
+ label: string;
41
+ argv: string[];
42
+ /** Directory relative to the project root. */
43
+ cwd: string;
44
+ }
45
+ export type PromoteRunner = (argv: string[], cwd: string) => Promise<{
46
+ exitCode: number;
47
+ output: string;
48
+ }>;
49
+ export declare const spawnRunner: PromoteRunner;
50
+ /** The commands the rung runs in the staging worktree. */
51
+ export declare function stagingRuns(rung: Rung, member: {
52
+ name: string;
53
+ dir: string;
54
+ }, opts: {
55
+ state?: string;
56
+ lexicon?: string;
57
+ }): CommandRun[];
58
+ /** After the approved patch is applied: stamping ownership markers on the live resources. */
59
+ export declare function followUpRuns(rung: Rung, member: {
60
+ name: string;
61
+ dir: string;
62
+ }, opts: {
63
+ state?: string;
64
+ }): CommandRun[];
65
+ export interface PromoteOptions {
66
+ root: string;
67
+ member: string;
68
+ state?: string;
69
+ lexicon?: string;
70
+ dryRun?: boolean;
71
+ output?: string;
72
+ json?: boolean;
73
+ /** For tests. */
74
+ runner?: PromoteRunner;
75
+ ledger?: GateLedgerPort;
76
+ now?: string;
77
+ }
78
+ export type PromoteOutcome = "top-of-ladder" | "checks-failed" | "dry-run" | "gated" | "applied";
79
+ export interface PromoteResult {
80
+ outcome: PromoteOutcome;
81
+ exitCode: number;
82
+ member: string;
83
+ from?: string;
84
+ to?: string;
85
+ digest?: string;
86
+ patch?: string;
87
+ ran?: {
88
+ label: string;
89
+ exitCode: number;
90
+ }[];
91
+ }
92
+ /** Rewrite the member's `kind` in the declaration text. */
93
+ export declare function setMemberKind(text: string, file: string, member: string, kind: string): string;
94
+ export declare function promoteCommand(opts: PromoteOptions): Promise<PromoteResult>;
95
+ export declare function runWorkspacePromote(ctx: CommandContext): Promise<number>;
96
+ //# sourceMappingURL=promote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promote.d.ts","sourceRoot":"","sources":["../../src/workspace/promote.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAOH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EAAuF,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAMtI,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AACrD,eAAO,MAAM,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