@intentius/chant 0.124.84 → 0.124.86

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 (254) hide show
  1. package/dist/bundle-check.d.ts +102 -0
  2. package/dist/bundle-check.d.ts.map +1 -0
  3. package/dist/bundle-check.js +310 -0
  4. package/dist/chant-install.d.ts +100 -0
  5. package/dist/chant-install.d.ts.map +1 -0
  6. package/dist/chant-install.js +158 -0
  7. package/dist/ci-commit.d.ts +19 -6
  8. package/dist/ci-commit.d.ts.map +1 -1
  9. package/dist/ci-commit.js +23 -4
  10. package/dist/ci-evidence-jobs.d.ts +54 -0
  11. package/dist/ci-evidence-jobs.d.ts.map +1 -0
  12. package/dist/ci-evidence-jobs.js +55 -0
  13. package/dist/ci-image.d.ts +274 -0
  14. package/dist/ci-image.d.ts.map +1 -0
  15. package/dist/ci-image.js +635 -0
  16. package/dist/ci-login.d.ts +150 -0
  17. package/dist/ci-login.d.ts.map +1 -0
  18. package/dist/ci-login.js +240 -0
  19. package/dist/ci-product.d.ts +16 -0
  20. package/dist/ci-product.d.ts.map +1 -1
  21. package/dist/ci-product.js +17 -0
  22. package/dist/cli/commands/import-index.js +2 -2
  23. package/dist/cli/handlers/build.d.ts +8 -0
  24. package/dist/cli/handlers/build.d.ts.map +1 -1
  25. package/dist/cli/handlers/build.js +22 -4
  26. package/dist/cli/handlers/ci-check.d.ts.map +1 -1
  27. package/dist/cli/handlers/ci-check.js +57 -2
  28. package/dist/cli/handlers/ci-evidence.d.ts +3 -0
  29. package/dist/cli/handlers/ci-evidence.d.ts.map +1 -0
  30. package/dist/cli/handlers/ci-evidence.js +171 -0
  31. package/dist/cli/handlers/components.js +3 -3
  32. package/dist/cli/handlers/dead-guards.d.ts +3 -0
  33. package/dist/cli/handlers/dead-guards.d.ts.map +1 -0
  34. package/dist/cli/handlers/dead-guards.js +35 -0
  35. package/dist/cli/handlers/graph.js +4 -4
  36. package/dist/cli/handlers/lifecycle.d.ts +2 -1
  37. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  38. package/dist/cli/handlers/lifecycle.js +5 -4
  39. package/dist/cli/handlers/local-chant.d.ts +16 -0
  40. package/dist/cli/handlers/local-chant.d.ts.map +1 -0
  41. package/dist/cli/handlers/local-chant.js +109 -0
  42. package/dist/cli/handlers/operator.js +2 -2
  43. package/dist/cli/handlers/search.js +5 -5
  44. package/dist/cli/main.d.ts.map +1 -1
  45. package/dist/cli/main.js +38 -0
  46. package/dist/cli/parse-args.d.ts.map +1 -1
  47. package/dist/cli/parse-args.js +28 -0
  48. package/dist/cli/registry.d.ts +16 -0
  49. package/dist/cli/registry.d.ts.map +1 -1
  50. package/dist/components/check-hooks.d.ts +49 -0
  51. package/dist/components/check-hooks.d.ts.map +1 -1
  52. package/dist/components/check-hooks.js +64 -4
  53. package/dist/components/check-steps.d.ts +17 -0
  54. package/dist/components/check-steps.d.ts.map +1 -1
  55. package/dist/components/check-steps.js +37 -5
  56. package/dist/components/product-pipeline.d.ts +23 -0
  57. package/dist/components/product-pipeline.d.ts.map +1 -1
  58. package/dist/components/product-pipeline.js +6 -2
  59. package/dist/components/product-plan.d.ts +137 -0
  60. package/dist/components/product-plan.d.ts.map +1 -0
  61. package/dist/components/product-plan.js +143 -0
  62. package/dist/components/release-compile.d.ts.map +1 -1
  63. package/dist/components/release-compile.js +2 -2
  64. package/dist/config.d.ts +39 -1
  65. package/dist/config.d.ts.map +1 -1
  66. package/dist/config.js +35 -3
  67. package/dist/dead-guards.d.ts +82 -0
  68. package/dist/dead-guards.d.ts.map +1 -0
  69. package/dist/dead-guards.js +436 -0
  70. package/dist/discovery/files.d.ts +3 -1
  71. package/dist/discovery/files.d.ts.map +1 -1
  72. package/dist/discovery/files.js +5 -3
  73. package/dist/drift-issue.d.ts +152 -0
  74. package/dist/drift-issue.d.ts.map +1 -0
  75. package/dist/drift-issue.js +167 -0
  76. package/dist/floor-table.d.ts +30 -0
  77. package/dist/floor-table.d.ts.map +1 -0
  78. package/dist/floor-table.data.d.ts +3 -0
  79. package/dist/floor-table.data.d.ts.map +1 -0
  80. package/dist/floor-table.data.js +178 -0
  81. package/dist/floor-table.js +56 -0
  82. package/dist/forge-flags.d.ts +90 -0
  83. package/dist/forge-flags.d.ts.map +1 -0
  84. package/dist/forge-flags.js +184 -0
  85. package/dist/lexicon.d.ts +69 -0
  86. package/dist/lexicon.d.ts.map +1 -1
  87. package/dist/lifecycle/gated-op.d.ts +7 -1
  88. package/dist/lifecycle/gated-op.d.ts.map +1 -1
  89. package/dist/lifecycle/gated-op.js +7 -4
  90. package/dist/local-chant.d.ts +98 -0
  91. package/dist/local-chant.d.ts.map +1 -0
  92. package/dist/local-chant.js +307 -0
  93. package/dist/op/activities/predict-behaviour.js +2 -2
  94. package/dist/op/op-waves-evidence-spec.d.ts +13 -0
  95. package/dist/op/op-waves-evidence-spec.d.ts.map +1 -0
  96. package/dist/op/op-waves-evidence-spec.js +21 -0
  97. package/dist/op/op-waves-evidence.d.ts +38 -0
  98. package/dist/op/op-waves-evidence.d.ts.map +1 -0
  99. package/dist/op/op-waves-evidence.js +57 -0
  100. package/dist/op/op-waves-run.d.ts +4 -0
  101. package/dist/op/op-waves-run.d.ts.map +1 -1
  102. package/dist/op/op-waves-run.js +24 -1
  103. package/dist/op/op-waves.d.ts +17 -1
  104. package/dist/op/op-waves.d.ts.map +1 -1
  105. package/dist/op/op-waves.js +23 -0
  106. package/dist/op/schedule-overdue.d.ts +41 -9
  107. package/dist/op/schedule-overdue.d.ts.map +1 -1
  108. package/dist/op/schedule-overdue.js +154 -25
  109. package/dist/plan-summary.d.ts +25 -0
  110. package/dist/plan-summary.d.ts.map +1 -1
  111. package/dist/plan-summary.js +31 -0
  112. package/dist/pr-plan-note.d.ts +35 -0
  113. package/dist/pr-plan-note.d.ts.map +1 -1
  114. package/dist/pr-plan-note.js +10 -0
  115. package/dist/pr-post.d.ts +23 -0
  116. package/dist/pr-post.d.ts.map +1 -1
  117. package/dist/pr-post.js +125 -3
  118. package/dist/release-floors.d.ts +31 -1
  119. package/dist/release-floors.d.ts.map +1 -1
  120. package/dist/release-floors.js +31 -1
  121. package/dist/state-migration.d.ts +24 -0
  122. package/dist/state-migration.d.ts.map +1 -1
  123. package/dist/state-migration.js +100 -5
  124. package/dist/wave-runtime.mjs +305 -298
  125. package/dist/workspace/lexicon-outputs.d.ts.map +1 -1
  126. package/dist/workspace/lexicon-outputs.js +21 -7
  127. package/dist/workspace/reason-codes.d.ts +3 -0
  128. package/dist/workspace/reason-codes.d.ts.map +1 -1
  129. package/dist/workspace/reason-codes.js +4 -0
  130. package/dist/workspace/ref-gate.schema.json +85 -0
  131. package/dist/workspace/search-contract.d.ts +1 -1
  132. package/dist/workspace/search-contract.d.ts.map +1 -1
  133. package/dist/workspace/trust/check-evidence-report.d.ts +51 -0
  134. package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -0
  135. package/dist/workspace/trust/check-evidence-report.js +102 -0
  136. package/dist/workspace/trust/check-evidence.d.ts +126 -0
  137. package/dist/workspace/trust/check-evidence.d.ts.map +1 -0
  138. package/dist/workspace/trust/check-evidence.js +237 -0
  139. package/dist/workspace/trust/local-evidence.d.ts +120 -0
  140. package/dist/workspace/trust/local-evidence.d.ts.map +1 -0
  141. package/dist/workspace/trust/local-evidence.js +259 -0
  142. package/dist/workspace/trust/policy.d.ts +84 -0
  143. package/dist/workspace/trust/policy.d.ts.map +1 -1
  144. package/dist/workspace/trust/policy.js +94 -1
  145. package/dist/workspace/trust/ref-gate-cli.d.ts +33 -0
  146. package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -0
  147. package/dist/workspace/trust/ref-gate-cli.js +234 -0
  148. package/dist/workspace/trust/ref-gate-fixture.d.ts +38 -0
  149. package/dist/workspace/trust/ref-gate-fixture.d.ts.map +1 -0
  150. package/dist/workspace/trust/ref-gate-fixture.js +97 -0
  151. package/dist/workspace/trust/ref-gate.d.ts +187 -0
  152. package/dist/workspace/trust/ref-gate.d.ts.map +1 -0
  153. package/dist/workspace/trust/ref-gate.js +430 -0
  154. package/dist/workspace/trust/trust-files.d.ts.map +1 -1
  155. package/dist/workspace/trust/trust-files.js +18 -1
  156. package/package.json +1 -1
  157. package/src/bundle-check.test.ts +140 -0
  158. package/src/bundle-check.ts +352 -0
  159. package/src/chant-install.test.ts +112 -0
  160. package/src/chant-install.ts +179 -0
  161. package/src/ci-commit.test.ts +45 -0
  162. package/src/ci-commit.ts +38 -4
  163. package/src/ci-evidence-jobs.ts +67 -0
  164. package/src/ci-image.test.ts +506 -0
  165. package/src/ci-image.ts +822 -0
  166. package/src/ci-login.test.ts +235 -0
  167. package/src/ci-login.ts +307 -0
  168. package/src/ci-product.ts +18 -0
  169. package/src/cli/commands/__fixtures__/source-dir-include/chant.config.json +1 -0
  170. package/src/cli/commands/__fixtures__/source-dir-include/infra.ts +1 -0
  171. package/src/cli/commands/__fixtures__/source-dir-include/scripts/run-on-load.ts +3 -0
  172. package/src/cli/commands/__fixtures__/source-dir-root/chant.config.json +1 -0
  173. package/src/cli/commands/__fixtures__/source-dir-root/infra.test.ts +1 -0
  174. package/src/cli/commands/__fixtures__/source-dir-root/infra.ts +1 -0
  175. package/src/cli/commands/__fixtures__/source-dir-root/scripts/run-on-load.ts +3 -0
  176. package/src/cli/commands/__fixtures__/source-dir-scoped/app.ts +3 -0
  177. package/src/cli/commands/__fixtures__/source-dir-scoped/chant.config.json +1 -0
  178. package/src/cli/commands/__fixtures__/source-dir-scoped/infra/net.ts +1 -0
  179. package/src/cli/commands/__fixtures__/source-dir-scoped/scripts/run-on-load.ts +3 -0
  180. package/src/cli/commands/import-index.ts +2 -2
  181. package/src/cli/handlers/build-source-dir.test.ts +64 -0
  182. package/src/cli/handlers/build.ts +21 -4
  183. package/src/cli/handlers/ci-check.ts +56 -3
  184. package/src/cli/handlers/ci-evidence.ts +162 -0
  185. package/src/cli/handlers/components.ts +3 -3
  186. package/src/cli/handlers/dead-guards.ts +37 -0
  187. package/src/cli/handlers/graph.ts +4 -4
  188. package/src/cli/handlers/lifecycle.ts +5 -4
  189. package/src/cli/handlers/local-chant.ts +106 -0
  190. package/src/cli/handlers/operator.ts +2 -2
  191. package/src/cli/handlers/search.ts +5 -5
  192. package/src/cli/main.test.ts +7 -0
  193. package/src/cli/main.ts +38 -0
  194. package/src/cli/parse-args.ts +21 -0
  195. package/src/cli/registry.ts +16 -0
  196. package/src/components/check-evidence-stage.test.ts +80 -0
  197. package/src/components/check-hooks.ts +84 -4
  198. package/src/components/check-local-evidence-stage.test.ts +141 -0
  199. package/src/components/check-steps.ts +56 -6
  200. package/src/components/product-pipeline.ts +28 -3
  201. package/src/components/product-plan.test.ts +87 -0
  202. package/src/components/product-plan.ts +226 -0
  203. package/src/components/release-compile.ts +2 -2
  204. package/src/config.ts +44 -3
  205. package/src/dead-guards.test.ts +206 -0
  206. package/src/dead-guards.ts +446 -0
  207. package/src/discovery/files.ts +5 -3
  208. package/src/drift-issue-bundle.test.ts +31 -0
  209. package/src/drift-issue.test.ts +206 -0
  210. package/src/drift-issue.ts +274 -0
  211. package/src/fit-note.test.ts +44 -0
  212. package/src/floor-table.data.ts +180 -0
  213. package/src/floor-table.ts +77 -0
  214. package/src/forge-flags.test.ts +110 -0
  215. package/src/forge-flags.ts +208 -0
  216. package/src/gate-decision-bundle.test.ts +1 -0
  217. package/src/lexicon.ts +68 -0
  218. package/src/lifecycle/gated-op.ts +10 -5
  219. package/src/local-chant.e2e.test.ts +94 -0
  220. package/src/local-chant.test.ts +162 -0
  221. package/src/local-chant.ts +341 -0
  222. package/src/op/activities/predict-behaviour.ts +2 -2
  223. package/src/op/op-waves-evidence-spec.ts +24 -0
  224. package/src/op/op-waves-evidence.test.ts +130 -0
  225. package/src/op/op-waves-evidence.ts +57 -0
  226. package/src/op/op-waves-run.ts +25 -1
  227. package/src/op/op-waves.ts +31 -1
  228. package/src/op/schedule-overdue.test.ts +85 -0
  229. package/src/op/schedule-overdue.ts +162 -26
  230. package/src/plan-summary.ts +40 -0
  231. package/src/pr-plan-note.ts +34 -0
  232. package/src/pr-post-plan-note.test.ts +146 -0
  233. package/src/pr-post.ts +127 -3
  234. package/src/release-floors.ts +44 -1
  235. package/src/stage-hooks-bundle.test.ts +1 -0
  236. package/src/state-migration.test.ts +52 -1
  237. package/src/state-migration.ts +107 -5
  238. package/src/workspace/lexicon-outputs.ts +23 -6
  239. package/src/workspace/reason-codes.test.ts +3 -0
  240. package/src/workspace/reason-codes.ts +4 -0
  241. package/src/workspace/ref-gate.schema.json +85 -0
  242. package/src/workspace/trust/check-evidence-report.ts +106 -0
  243. package/src/workspace/trust/check-evidence.test.ts +133 -0
  244. package/src/workspace/trust/check-evidence.ts +257 -0
  245. package/src/workspace/trust/local-evidence.test.ts +127 -0
  246. package/src/workspace/trust/local-evidence.ts +266 -0
  247. package/src/workspace/trust/policy.ts +134 -1
  248. package/src/workspace/trust/ref-gate-cli.ts +244 -0
  249. package/src/workspace/trust/ref-gate-fixture.ts +125 -0
  250. package/src/workspace/trust/ref-gate.e2e.test.ts +76 -0
  251. package/src/workspace/trust/ref-gate.test.ts +247 -0
  252. package/src/workspace/trust/ref-gate.ts +538 -0
  253. package/src/workspace/trust/trust-files.test.ts +16 -0
  254. package/src/workspace/trust/trust-files.ts +41 -1
@@ -0,0 +1,436 @@
1
+ /**
2
+ * `@intentius/chant/dead-guards` (#4792): find each feature-detect in a
3
+ * product's source whose chant floor the product's pin already meets.
4
+ *
5
+ * A product that runs on several chant releases checks for a part before it
6
+ * calls it, and keeps a fallback for a chant without it. Once the product
7
+ * pins a chant that has the part, the check always passes and the fallback is
8
+ * dead code that still gets tested and kept. `chant dev dead-guards` reads
9
+ * the pin from the product's package.json files, scans the product's source
10
+ * and fails naming every such check, so the product deletes it.
11
+ *
12
+ * What counts as a feature-detect on a floor, from the table in
13
+ * ./floor-table.ts:
14
+ *
15
+ * - `floor`: a floor's name read off a module the product did not import
16
+ * statically (`m.CI_CHECK_HOOK_FLOOR`, `typeof m.X_FLOOR === "string"`), in
17
+ * a string (`exportsAll(spec, ["OP_WAVE_STAND_DOWN_FLOOR"])`), as a member
18
+ * of a type the product writes out for a lazily loaded chant module
19
+ * (`CI_CONTROL_FLOOR: string;`), or destructured from a dynamic import. A
20
+ * floor the file imports statically is the product using the part, so it
21
+ * is not a check.
22
+ * - `module`: a chant subpath loaded with `import()` where a `catch` is near
23
+ * (`try { await import(specifier) } catch { return undefined }`, or
24
+ * `.catch(`), the shape of a chant-next.ts loader. Its floor is the lowest
25
+ * floor the subpath serves: a chant with that floor has the subpath.
26
+ * - `product-floor`: a product's own constant for the chant it needs,
27
+ * `const CHANT_CI_FLOOR = "0.124.67"`, whose checks the pin meets.
28
+ *
29
+ * A line holding `chant-dead-guards: keep`, or below a comment line that
30
+ * does, is left out: a check kept on purpose, such as one for a chant a user
31
+ * installs beside the product.
32
+ *
33
+ * This module imports only Node's own modules and the floor table.
34
+ */
35
+ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
36
+ import { dirname, join, relative, sep } from "node:path";
37
+ import { compareChantVersions, FLOOR_TABLE } from "./floor-table.js";
38
+ const SKIP_DIRS = new Set(["node_modules", "dist", "build", "out", "coverage", "test", "tests", "__tests__", "__fixtures__", "fixtures"]);
39
+ const SOURCE = /\.(?:[cm]?[jt]s|tsx)$/;
40
+ const NOT_SOURCE = /\.d\.[cm]?ts$|\.(?:test|spec|e2e\.test)\.[cm]?[jt]sx?$/;
41
+ const CHANT_DEPS = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
42
+ const KEEP = "chant-dead-guards: keep";
43
+ /** The lowest version a chant range admits: `^0.124.78` is 0.124.78. Undefined for `workspace:`, `file:` and the like. */
44
+ export function pinOf(range) {
45
+ const r = range.trim();
46
+ if (/^(?:workspace|file|link|git|github|https?):/.test(r))
47
+ return undefined;
48
+ return /(\d+\.\d+\.\d+)/.exec(r)?.[1];
49
+ }
50
+ /** The `@intentius/chant` range a package.json names, if any. */
51
+ function chantRange(file) {
52
+ try {
53
+ const pkg = JSON.parse(readFileSync(file, "utf8"));
54
+ for (const k of CHANT_DEPS) {
55
+ const v = pkg[k]?.["@intentius/chant"];
56
+ if (typeof v === "string")
57
+ return v;
58
+ }
59
+ }
60
+ catch {
61
+ // not JSON; no pin
62
+ }
63
+ return undefined;
64
+ }
65
+ /** The product's source files, relative, skipping dependencies, builds, tests and hidden directories. */
66
+ export function productSources(productDir) {
67
+ const out = [];
68
+ const walk = (dir) => {
69
+ let names;
70
+ try {
71
+ names = readdirSync(dir).sort();
72
+ }
73
+ catch {
74
+ return;
75
+ }
76
+ for (const name of names) {
77
+ if (name.startsWith("."))
78
+ continue;
79
+ const at = join(dir, name);
80
+ let st;
81
+ try {
82
+ st = statSync(at);
83
+ }
84
+ catch {
85
+ continue;
86
+ }
87
+ if (st.isDirectory()) {
88
+ if (!SKIP_DIRS.has(name))
89
+ walk(at);
90
+ }
91
+ else if (SOURCE.test(name) && !NOT_SOURCE.test(name)) {
92
+ out.push(relative(productDir, at).split(sep).join("/"));
93
+ }
94
+ }
95
+ };
96
+ walk(productDir);
97
+ return out;
98
+ }
99
+ /**
100
+ * `src` with every comment blanked to spaces (line breaks kept), and a mask
101
+ * of which characters sit inside a string or template literal's text.
102
+ */
103
+ export function scanSource(src) {
104
+ const out = src.split("");
105
+ const inString = new Uint8Array(src.length);
106
+ // Each open template literal's brace depth at its `${`.
107
+ const templates = [];
108
+ let depth = 0;
109
+ let prev = ""; // the last significant character outside strings and comments
110
+ let i = 0;
111
+ const blank = (from, to) => {
112
+ for (let k = from; k < to; k++)
113
+ if (out[k] !== "\n")
114
+ out[k] = " ";
115
+ };
116
+ const quoted = (q) => {
117
+ const start = i++;
118
+ while (i < src.length && src[i] !== q && src[i] !== "\n") {
119
+ if (src[i] === "\\")
120
+ i++;
121
+ i++;
122
+ }
123
+ for (let k = start + 1; k < i && k < src.length; k++)
124
+ inString[k] = 1;
125
+ i++;
126
+ };
127
+ // Template text from i (just past "`" or "}") to the closing "`" or a "${".
128
+ const templateText = () => {
129
+ const start = i;
130
+ while (i < src.length) {
131
+ if (src[i] === "\\") {
132
+ i += 2;
133
+ continue;
134
+ }
135
+ if (src[i] === "`") {
136
+ for (let k = start; k < i; k++)
137
+ inString[k] = 1;
138
+ i++;
139
+ return;
140
+ }
141
+ if (src[i] === "$" && src[i + 1] === "{") {
142
+ for (let k = start; k < i; k++)
143
+ inString[k] = 1;
144
+ i += 2;
145
+ templates.push(depth);
146
+ depth++;
147
+ return;
148
+ }
149
+ i++;
150
+ }
151
+ for (let k = start; k < src.length; k++)
152
+ inString[k] = 1;
153
+ };
154
+ while (i < src.length) {
155
+ const c = src[i];
156
+ const n = src[i + 1];
157
+ if (c === "/" && n === "/") {
158
+ const end = src.indexOf("\n", i);
159
+ const to = end === -1 ? src.length : end;
160
+ blank(i, to);
161
+ i = to;
162
+ }
163
+ else if (c === "/" && n === "*") {
164
+ const end = src.indexOf("*/", i + 2);
165
+ const to = end === -1 ? src.length : end + 2;
166
+ blank(i, to);
167
+ i = to;
168
+ }
169
+ else if (c === '"' || c === "'") {
170
+ quoted(c);
171
+ prev = "a";
172
+ }
173
+ else if (c === "`") {
174
+ i++;
175
+ templateText();
176
+ prev = "a";
177
+ }
178
+ else if (c === "/" && (prev === "" || "(,=:[!&|?{};+-*%<>~^".includes(prev))) {
179
+ // A regular expression literal.
180
+ i++;
181
+ let cls = false;
182
+ while (i < src.length && src[i] !== "\n") {
183
+ if (src[i] === "\\")
184
+ i++;
185
+ else if (src[i] === "[")
186
+ cls = true;
187
+ else if (src[i] === "]")
188
+ cls = false;
189
+ else if (src[i] === "/" && !cls)
190
+ break;
191
+ i++;
192
+ }
193
+ i++;
194
+ prev = "a";
195
+ }
196
+ else {
197
+ if (c === "{")
198
+ depth++;
199
+ else if (c === "}") {
200
+ depth--;
201
+ if (templates.length > 0 && templates[templates.length - 1] === depth) {
202
+ templates.pop();
203
+ i++;
204
+ templateText();
205
+ prev = "a";
206
+ continue;
207
+ }
208
+ }
209
+ if (!/\s/.test(c))
210
+ prev = /[A-Za-z0-9_$)\]]/.test(c) ? "a" : c;
211
+ i++;
212
+ }
213
+ }
214
+ return { code: out.join(""), inString };
215
+ }
216
+ /** The line of each offset, from 1. */
217
+ function lineStarts(src) {
218
+ const starts = [0];
219
+ for (let i = 0; i < src.length; i++)
220
+ if (src[i] === "\n")
221
+ starts.push(i + 1);
222
+ return starts;
223
+ }
224
+ function lineAt(starts, offset) {
225
+ let lo = 0;
226
+ let hi = starts.length - 1;
227
+ while (lo < hi) {
228
+ const mid = (lo + hi + 1) >> 1;
229
+ if (starts[mid] <= offset)
230
+ lo = mid;
231
+ else
232
+ hi = mid - 1;
233
+ }
234
+ return lo + 1;
235
+ }
236
+ /**
237
+ * Whether `offset` in `code` (comments blanked) sits inside a `try { ... }`
238
+ * block that has a `catch`: an open brace before it, not yet closed, that
239
+ * follows `try`, and whose block is followed by `catch`. A `try` with only
240
+ * `finally` catches nothing. Braces in strings count too, which a template
241
+ * literal can throw off; the check is a heuristic, and
242
+ * `chant-dead-guards: keep` covers a miss.
243
+ */
244
+ export function insideTry(code, offset) {
245
+ let depth = 0;
246
+ for (let i = offset - 1; i >= 0; i--) {
247
+ const c = code[i];
248
+ if (c === "}")
249
+ depth++;
250
+ else if (c === "{") {
251
+ if (depth > 0)
252
+ depth--;
253
+ else if (/\btry\s*$/.test(code.slice(Math.max(0, i - 8), i))) {
254
+ let open = 0;
255
+ for (let j = i; j < code.length; j++) {
256
+ if (code[j] === "{")
257
+ open++;
258
+ else if (code[j] === "}" && --open === 0) {
259
+ if (/^\s*catch\b/.test(code.slice(j + 1, j + 24)))
260
+ return true;
261
+ break;
262
+ }
263
+ }
264
+ }
265
+ }
266
+ }
267
+ return false;
268
+ }
269
+ /**
270
+ * The feature-detects on a floor in one source file. `table` gives each
271
+ * floor's version; a name two files declare takes the higher one.
272
+ */
273
+ export function guardsIn(src, table = FLOOR_TABLE) {
274
+ const floors = new Map();
275
+ for (const r of table) {
276
+ const had = floors.get(r.name);
277
+ if (had === undefined || compareChantVersions(r.version, had) > 0)
278
+ floors.set(r.name, r.version);
279
+ }
280
+ // The lowest floor each subpath serves.
281
+ const modules = new Map();
282
+ for (const r of table) {
283
+ for (const m of r.modules) {
284
+ const had = modules.get(m);
285
+ if (had === undefined || compareChantVersions(r.version, had) < 0)
286
+ modules.set(m, r.version);
287
+ }
288
+ }
289
+ const { code, inString } = scanSource(src);
290
+ const codeLines = code.split("\n");
291
+ const starts = lineStarts(src);
292
+ const lines = src.split("\n");
293
+ const out = [];
294
+ const seen = new Set();
295
+ const push = (offset, kind, floor, version) => {
296
+ const line = lineAt(starts, offset);
297
+ const key = `${line}|${kind}|${floor}`;
298
+ if (seen.has(key))
299
+ return;
300
+ if (lines[line - 1]?.includes(KEEP) || /^\s*(?:\/\/|\/?\*).*chant-dead-guards: keep/.test(lines[line - 2] ?? ""))
301
+ return;
302
+ seen.add(key);
303
+ out.push({ line, kind, floor, version });
304
+ };
305
+ // Names bound by a static import or re-export, from anywhere: using one is
306
+ // using the part. And the spans of those statements, which hold no check.
307
+ const imported = new Set();
308
+ const statements = [];
309
+ for (const m of code.matchAll(/\b(?:import|export)\s+(?:type\s+)?\{([^}]*)\}\s*from\s*(["'])[^"'\n]*\2/g)) {
310
+ statements.push([m.index, m.index + m[0].length]);
311
+ if (!m[0].startsWith("import"))
312
+ continue;
313
+ for (const part of m[1].split(",")) {
314
+ const local = part.trim().replace(/^type\s+/, "").split(/\s+as\s+/).pop()?.trim();
315
+ if (local)
316
+ imported.add(local);
317
+ }
318
+ }
319
+ const inStatement = (at) => statements.some(([a, b]) => at >= a && at < b);
320
+ // `import * as chant from "@intentius/chant/x"`: `chant.X_FLOOR` is a use too.
321
+ const namespaces = new Set([...code.matchAll(/\bimport\s+\*\s+as\s+([A-Za-z_$][\w$]*)\s+from\s*["']/g)].map((m) => m[1]));
322
+ const declared = new Set([...code.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z][A-Z0-9_]*_FLOOR)\b/g)].map((m) => m[1]));
323
+ // floor: a table name read off a module, in a string, as a type member, or destructured.
324
+ for (const m of code.matchAll(/\b[A-Z][A-Z0-9_]*_FLOOR\b/g)) {
325
+ const at = m.index;
326
+ const name = m[0];
327
+ const version = floors.get(name);
328
+ if (version === undefined || inStatement(at))
329
+ continue;
330
+ if (inString[at]) {
331
+ // A name in a string is a check when the line asks a module for it:
332
+ // names a chant subpath or an import(), `"X_FLOOR" in m`, `m["X_FLOOR"]`.
333
+ const text = codeLines[lineAt(starts, at) - 1] ?? "";
334
+ if (/@intentius\/chant|\bimport\(|["'`]\s+in\s+[A-Za-z_$]/.test(text) || /[\w$\])]\s*\[\s*$/.test(code.slice(Math.max(0, at - 24), at - 1)))
335
+ push(at, "floor", name, version);
336
+ continue;
337
+ }
338
+ const owner = /([A-Za-z_$][\w$]*)\s*\??\.\s*$/.exec(code.slice(Math.max(0, at - 64), at));
339
+ if (owner || /\.\s*$/.test(code.slice(Math.max(0, at - 2), at))) {
340
+ if (!owner || !namespaces.has(owner[1]))
341
+ push(at, "floor", name, version);
342
+ continue;
343
+ }
344
+ if (imported.has(name) || declared.has(name))
345
+ continue;
346
+ push(at, "floor", name, version);
347
+ }
348
+ // module: a chant subpath loaded with import() inside a try, or with .catch( on the load.
349
+ for (const m of src.matchAll(/(["'`])(@intentius\/chant(?:\/[A-Za-z0-9_./-]+)?)\1/g)) {
350
+ const at = m.index;
351
+ const spec = m[2];
352
+ const version = modules.get(spec);
353
+ if (version === undefined || inStatement(at) || !inString[at + 1])
354
+ continue;
355
+ const end = at + m[0].length;
356
+ let site;
357
+ if (/\bimport\(\s*$/.test(code.slice(Math.max(0, at - 16), at))) {
358
+ if (/typeof\s+import\(\s*$/.test(code.slice(Math.max(0, at - 24), at)))
359
+ continue;
360
+ site = at;
361
+ }
362
+ else {
363
+ // `const specifier = "<subpath>"`, then `import(specifier)` below.
364
+ const bound = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::\s*string\s*)?=\s*$/.exec(code.slice(Math.max(0, at - 64), at));
365
+ if (!bound)
366
+ continue;
367
+ const call = new RegExp(`\\bimport\\(\\s*${bound[1].replace(/\$/g, "\\$")}\\s*\\)`).exec(code.slice(end, end + 2000));
368
+ if (!call)
369
+ continue;
370
+ site = end + call.index;
371
+ }
372
+ const after = code.slice(site, site + 400);
373
+ const caught = /^[^;\n]*?\)\s*\.catch\(/.test(after) || insideTry(code, site);
374
+ if (caught)
375
+ push(at, "module", spec, version);
376
+ }
377
+ // product-floor: the product's own constant for the chant it needs.
378
+ for (const m of code.matchAll(/\b(?:const|let|var)\s+([A-Z0-9_]*CHANT[A-Z0-9_]*_FLOOR)\s*(?::\s*string\s*)?=\s*/g)) {
379
+ const at = m.index + m[0].length;
380
+ const lit = /^(["'])(\d+\.\d+\.\d+)\1/.exec(src.slice(at, at + 24));
381
+ if (lit)
382
+ push(m.index, "product-floor", m[1], lit[2]);
383
+ }
384
+ return out.sort((a, b) => a.line - b.line || a.floor.localeCompare(b.floor));
385
+ }
386
+ /** The chant pin over `file` (relative to `productDir`): the nearest package.json with one, up to the product's root. */
387
+ function pinFor(productDir, file, cache) {
388
+ for (let dir = dirname(join(productDir, file));; dir = dirname(dir)) {
389
+ const manifest = join(dir, "package.json");
390
+ let range = cache.get(manifest);
391
+ if (range === undefined) {
392
+ range = existsSync(manifest) ? (chantRange(manifest) ?? null) : null;
393
+ cache.set(manifest, range);
394
+ }
395
+ if (range !== null)
396
+ return { pin: pinOf(range), manifest };
397
+ if (relative(productDir, dir) === "" || dir === dirname(dir))
398
+ return {};
399
+ }
400
+ }
401
+ /**
402
+ * Every feature-detect in the product at `productDir` and whether its pin
403
+ * meets it. `ok` is false when one does.
404
+ */
405
+ export function findDeadGuards(options) {
406
+ const { productDir, chant } = options;
407
+ const table = options.table ?? FLOOR_TABLE;
408
+ const files = productSources(productDir);
409
+ const cache = new Map();
410
+ const pins = new Map();
411
+ const dead = [];
412
+ const live = [];
413
+ const unpinned = [];
414
+ for (const file of files) {
415
+ const at = pinFor(productDir, file, cache);
416
+ const pin = chant ?? at.pin;
417
+ if (at.manifest && at.pin)
418
+ pins.set(relative(productDir, at.manifest).split(sep).join("/"), at.pin);
419
+ if (pin === undefined) {
420
+ unpinned.push(file);
421
+ continue;
422
+ }
423
+ const src = readFileSync(join(productDir, file), "utf8");
424
+ const lines = src.split("\n");
425
+ for (const g of guardsIn(src, table)) {
426
+ const row = { file, ...g, pin, text: (lines[g.line - 1] ?? "").trim() };
427
+ (compareChantVersions(pin, g.version) >= 0 ? dead : live).push(row);
428
+ }
429
+ }
430
+ return { ok: dead.length === 0, dead, live, pins: [...pins].map(([file, pin]) => ({ file, pin })).sort((a, b) => a.file.localeCompare(b.file)), files: files.length, unpinned };
431
+ }
432
+ /** One dead guard as a line: `file:line: ...`. */
433
+ export function deadGuardLine(g) {
434
+ const what = g.kind === "module" ? `loads ${g.floor} behind a catch` : g.kind === "product-floor" ? `declares ${g.floor}` : `checks ${g.floor}`;
435
+ return `${g.file}:${g.line}: ${what}, which chant ${g.version} has; the pin ${g.pin} meets it`;
436
+ }
@@ -54,7 +54,9 @@ export declare function isSourceFileName(name: string): boolean;
54
54
  * Find every TypeScript infrastructure file under `path`, through the one
55
55
  * discovery walk (`./walk.ts`, #2527): test and spec files, chant-generated
56
56
  * files, skip-marked files and whatever the walk's rules and the project's
57
- * globs skip are left out.
57
+ * globs skip are left out. Walked from the root of a project with no
58
+ * `sourceDir`, its top-level `scripts/` is left out too (#4794,
59
+ * `ROOT_SOURCE_EXCLUDES`), unless `include` brings it back.
58
60
  */
59
61
  export declare function findInfraFiles(path: string, options?: FindInfraFilesOptions): Promise<string[]>;
60
62
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/discovery/files.ts"],"names":[],"mappings":"AAIA,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAGvE;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,mDAA8C,CAAC;AAE5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,yBAAyB,CAAC;AAQlD,sFAAsF;AACtF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAYvE;AAED,iJAAiJ;AACjJ,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAG5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,SAAS,CAWjH;AAED,0CAA0C;AAC1C,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,KAAK,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAC/B;AAED,mEAAmE;AACnE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CASrG;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CASvJ"}
@@ -90,10 +90,12 @@ export function isSourceFileName(name) {
90
90
  * Find every TypeScript infrastructure file under `path`, through the one
91
91
  * discovery walk (`./walk.ts`, #2527): test and spec files, chant-generated
92
92
  * files, skip-marked files and whatever the walk's rules and the project's
93
- * globs skip are left out.
93
+ * globs skip are left out. Walked from the root of a project with no
94
+ * `sourceDir`, its top-level `scripts/` is left out too (#4794,
95
+ * `ROOT_SOURCE_EXCLUDES`), unless `include` brings it back.
94
96
  */
95
97
  export async function findInfraFiles(path, options) {
96
- const globs = options?.globs === null ? undefined : (options?.globs ?? (await resolveDiscoveryGlobs(path)));
98
+ const globs = options?.globs === null ? undefined : (options?.globs ?? (await resolveDiscoveryGlobs(path, { sourceWalk: true })));
97
99
  return walkDiscovery({
98
100
  walker: "source",
99
101
  root: path,
@@ -110,7 +112,7 @@ export async function findInfraFiles(path, options) {
110
112
  * child projects and the project's `exclude` globs are left out for it too.
111
113
  */
112
114
  export async function findSourceFiles(path, accept, options) {
113
- const globs = options?.globs === null ? undefined : (options?.globs ?? (await resolveDiscoveryGlobs(path)));
115
+ const globs = options?.globs === null ? undefined : (options?.globs ?? (await resolveDiscoveryGlobs(path, { sourceWalk: true })));
114
116
  return walkDiscovery({
115
117
  walker: "source",
116
118
  root: path,
@@ -0,0 +1,152 @@
1
+ /**
2
+ * One drift issue per environment (#4790).
3
+ *
4
+ * plywood, SQL Yodeler and terragucci each kept a tracking issue for an
5
+ * environment's drift through the forge client's `trackIssue` (#3759), and
6
+ * each wrote the rest itself: the hidden marker that finds the issue again,
7
+ * a fingerprint of the drift so a run that finds the same drift does not
8
+ * edit the issue, the body, and the comment that closes the issue when the
9
+ * drift clears. {@link keepDriftIssue} is that, once. A product passes its
10
+ * words and the run's drift records, and the call decides:
11
+ *
12
+ * - drift found (a record `drifted` or `missing`): open the issue, or update
13
+ * the open one when the fingerprint or the title changed. An issue that
14
+ * already carries the fingerprint is left as it is, so a body that names
15
+ * the run or the time does not edit it on every scheduled run;
16
+ * - no drift, and every record was read: close the open issue with the
17
+ * product's comment;
18
+ * - no drift, and a record is `not-observed`, or the caller says the read
19
+ * failed (`unknown`): leave the open issue as it is. A read that proves
20
+ * nothing neither closes nor opens one.
21
+ *
22
+ * Only open issues are read, so an issue closed by hand stays closed and the
23
+ * next drift opens a new one. It runs on GitHub, GitLab and Forgejo through
24
+ * any client with `trackIssue` (`@intentius/chant/pr-forge`), and needs no
25
+ * read of its own.
26
+ *
27
+ * ```ts
28
+ * import { forgeClient, forgeTargetFromEnv } from "@intentius/chant/pr-forge";
29
+ * import { keepDriftIssue } from "@intentius/chant/drift-issue";
30
+ *
31
+ * const forge = forgeClient(forgeTargetFromEnv(process.env, { kind: "github" }));
32
+ * const r = await keepDriftIssue(forge, { words, environment: "acme/prod", records });
33
+ * ```
34
+ *
35
+ * The module imports types only, apart from `node:crypto`, so a product's
36
+ * bundle gains this file and nothing else (`drift-issue-bundle.test.ts`).
37
+ */
38
+ import type { DriftRecord, DriftStatus } from "./drift-record.js";
39
+ import type { IssueResult, MarkerMatch, PrForge } from "./pr-forge.js";
40
+ /** The statuses that are drift for the issue: present and different, or gone. */
41
+ export declare const DRIFT_ISSUE_STATUSES: readonly DriftStatus[];
42
+ /** What the issue reads of a record. Any {@link DriftRecord} is one. */
43
+ export type DriftIssueRecord = Pick<DriftRecord, "member" | "address" | "status"> & Partial<Pick<DriftRecord, "resourceType" | "attributes" | "unobserved" | "observedAt">>;
44
+ /** What the issue says about the environment, for {@link DriftIssueWords}. */
45
+ export interface DriftIssueFacts {
46
+ environment: string;
47
+ /** The records that are drift, sorted by member and address. */
48
+ drifted: readonly DriftIssueRecord[];
49
+ /** The latest `observedAt` among the records, else the caller's, else now. */
50
+ observedAt: string;
51
+ }
52
+ /** A product's words for its drift issue. Only `product` and `title` are required. */
53
+ export interface DriftIssueWords {
54
+ /** The marker's and fingerprint's namespace, and the name in chant's default sentences: `plywood`, `yodel`, `terragucci`. */
55
+ product: string;
56
+ /** The issue's title. It may name what drifted; a new title updates the issue. */
57
+ title: (facts: DriftIssueFacts) => string;
58
+ /** The paragraph above the table. Default: `<product>'s drift check read <env> at <time> and found N resources that differ.` */
59
+ intro?: (facts: DriftIssueFacts) => string;
60
+ /** The table's first column. Default `Address`; plywood's is `URN`. */
61
+ address?: string;
62
+ /**
63
+ * The words for an attribute's two values, as `declared` and `live`. With
64
+ * them each attribute shows its values, `` `path`: declared `a`, live `b` ``;
65
+ * without them only its path. A sensitive attribute never shows a value.
66
+ */
67
+ values?: {
68
+ before: string;
69
+ after: string;
70
+ };
71
+ /** The heading over the records that could not be read. Default `Could not be read, so their state is unknown:`. */
72
+ unobserved?: string;
73
+ /** The paragraph below the table: how to correct the drift. */
74
+ advice?: (facts: DriftIssueFacts) => string;
75
+ /** The line that names the run. Default `Found by <url>.` */
76
+ foundBy?: (runUrl: string) => string;
77
+ /** The comment posted when the drift clears and the issue is closed. Default: `<product>'s drift check at <time> found <env> matching, so this issue is closed.` */
78
+ cleared?: (facts: DriftIssueFacts) => string;
79
+ }
80
+ export interface DriftIssueInput {
81
+ words: DriftIssueWords;
82
+ /** The environment the issue is for: a stack, an environment name, a project and environment. Keys the default marker. */
83
+ environment: string;
84
+ /** The run's drift records for the environment. */
85
+ records: readonly DriftIssueRecord[];
86
+ /**
87
+ * The read failed, and why: the open issue is left as it is, whatever
88
+ * `records` holds.
89
+ */
90
+ unknown?: string;
91
+ /**
92
+ * The issue's marker, when the product's open issues already carry one of
93
+ * their own (`<!-- yodel:drift project=. env=prod -->`). Default
94
+ * {@link driftIssueMarker}`(product, environment)`.
95
+ */
96
+ marker?: string;
97
+ /** The run's URL, for the line that names it. */
98
+ runUrl?: string;
99
+ /** Lines of the product's own below the table, such as who changed each attribute. */
100
+ notes?: readonly string[];
101
+ /** When the drift was read, when the records carry no `observedAt`. */
102
+ observedAt?: string;
103
+ /** How the marker is found, and whose issues count (`trackIssue`'s {@link MarkerMatch}). */
104
+ match?: MarkerMatch;
105
+ /**
106
+ * The statuses that are drift. Default {@link DRIFT_ISSUE_STATUSES}. A
107
+ * read with no snapshot, such as the sql lexicon's, gives a declared
108
+ * object the server lacks as `pending`, which SQL Yodeler reports as gone:
109
+ * it passes `["drifted", "missing", "pending"]`.
110
+ */
111
+ statuses?: readonly DriftStatus[];
112
+ }
113
+ /** What {@link keepDriftIssue} did. */
114
+ export interface DriftIssueResult {
115
+ /**
116
+ * `opened`, `updated` or `unchanged` for drift; `closed` or `none` (no open
117
+ * issue) when it cleared; `left` when the read proves nothing and an issue
118
+ * is open, which stays as it is.
119
+ */
120
+ action: IssueResult["action"];
121
+ number?: number;
122
+ url?: string;
123
+ created?: string;
124
+ marker: string;
125
+ /** The drift's fingerprint, when the run found drift. */
126
+ fingerprint?: string;
127
+ /** Why the issue was left as it is (`left`, or `none` with nothing open). */
128
+ why?: string;
129
+ }
130
+ /** The hidden first line that finds the environment's drift issue again: `<!-- <product>:drift <environment> -->`. */
131
+ export declare function driftIssueMarker(product: string, environment: string): string;
132
+ /** The hidden line that carries the fingerprint, which an unchanged drift's issue already holds. */
133
+ export declare function driftFingerprintLine(product: string, fingerprint: string): string;
134
+ /** The records that are drift, sorted by member and address. */
135
+ export declare function driftIssueRecords(records: readonly DriftIssueRecord[], statuses?: readonly DriftStatus[]): DriftIssueRecord[];
136
+ /**
137
+ * The drift's fingerprint: the same drift gives the same one, whenever and
138
+ * in whatever order it is read. It covers each drifted or missing record's
139
+ * member, address and status, and each attribute's path and, when the
140
+ * record carries them, its two values. The time, the run, the records that
141
+ * could not be read and those in sync are left out. 16 hex digits of a
142
+ * SHA-256.
143
+ */
144
+ export declare function driftIssueFingerprint(records: readonly DriftIssueRecord[], statuses?: readonly DriftStatus[]): string;
145
+ /** The issue's body: the marker, the product's intro, the table, what could not be read, the notes, the advice, the run, the fingerprint. */
146
+ export declare function driftIssueBody(input: DriftIssueInput, fingerprint?: string): string;
147
+ /**
148
+ * Bring the environment's one drift issue in line with the run; see the
149
+ * module comment for the three cases. Throws what the forge throws.
150
+ */
151
+ export declare function keepDriftIssue(forge: Pick<PrForge, "trackIssue">, input: DriftIssueInput): Promise<DriftIssueResult>;
152
+ //# sourceMappingURL=drift-issue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drift-issue.d.ts","sourceRoot":"","sources":["../src/drift-issue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAGH,OAAO,KA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