@intentius/chant 0.124.43 → 0.124.45

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 (72) hide show
  1. package/dist/ci-identity.d.ts +183 -12
  2. package/dist/ci-identity.d.ts.map +1 -1
  3. package/dist/ci-identity.js +362 -53
  4. package/dist/cli/handlers/build.d.ts.map +1 -1
  5. package/dist/cli/handlers/build.js +17 -1
  6. package/dist/cli/handlers/pr-env.d.ts +8 -2
  7. package/dist/cli/handlers/pr-env.d.ts.map +1 -1
  8. package/dist/cli/handlers/pr-env.js +126 -225
  9. package/dist/cli/handlers/pr.d.ts +3 -0
  10. package/dist/cli/handlers/pr.d.ts.map +1 -1
  11. package/dist/cli/handlers/pr.js +1 -0
  12. package/dist/components/cli-support.d.ts +2 -0
  13. package/dist/components/cli-support.d.ts.map +1 -1
  14. package/dist/components/cli-support.js +4 -2
  15. package/dist/components/fan-out-support.d.ts +3 -0
  16. package/dist/components/fan-out-support.d.ts.map +1 -1
  17. package/dist/components/fan-out-support.js +1 -1
  18. package/dist/components/pr-env-run.d.ts +270 -0
  19. package/dist/components/pr-env-run.d.ts.map +1 -0
  20. package/dist/components/pr-env-run.js +440 -0
  21. package/dist/components/pr-environment.d.ts +89 -14
  22. package/dist/components/pr-environment.d.ts.map +1 -1
  23. package/dist/components/pr-environment.js +94 -8
  24. package/dist/components/pr-pipeline.d.ts +10 -1
  25. package/dist/components/pr-pipeline.d.ts.map +1 -1
  26. package/dist/op/op-waves.d.ts +17 -0
  27. package/dist/op/op-waves.d.ts.map +1 -1
  28. package/dist/op/op-waves.js +23 -1
  29. package/dist/pr-forge.d.ts +15 -1
  30. package/dist/pr-forge.d.ts.map +1 -1
  31. package/dist/pr-forge.js +28 -16
  32. package/dist/pr-requires.d.ts +5 -1
  33. package/dist/pr-requires.d.ts.map +1 -1
  34. package/dist/wave-runtime.mjs +179 -179
  35. package/dist/workspace/ci-cloud-identity.d.ts +3 -1
  36. package/dist/workspace/ci-cloud-identity.d.ts.map +1 -1
  37. package/dist/workspace/ci-cloud-identity.js +16 -1
  38. package/dist/workspace/ci-run.d.ts +35 -8
  39. package/dist/workspace/ci-run.d.ts.map +1 -1
  40. package/dist/workspace/ci-run.js +95 -21
  41. package/dist/workspace/ci-secrets.d.ts.map +1 -1
  42. package/dist/workspace/ci-secrets.js +4 -3
  43. package/dist/workspace/declaration.d.ts +10 -0
  44. package/dist/workspace/declaration.d.ts.map +1 -1
  45. package/dist/workspace/declaration.js +17 -1
  46. package/dist/workspace/declaration.schema.json +36 -1
  47. package/package.json +1 -1
  48. package/src/ci-identity-targets.test.ts +275 -0
  49. package/src/ci-identity.ts +394 -61
  50. package/src/cli/handlers/build.ts +15 -1
  51. package/src/cli/handlers/pr-env.ts +136 -227
  52. package/src/cli/handlers/pr.ts +4 -0
  53. package/src/components/cli-support.ts +6 -1
  54. package/src/components/fan-out-support.ts +4 -1
  55. package/src/components/pr-env-run.test.ts +290 -0
  56. package/src/components/pr-env-run.ts +634 -0
  57. package/src/components/pr-environment.ts +159 -12
  58. package/src/components/pr-pipeline.ts +10 -1
  59. package/src/op/op-waves.ts +38 -1
  60. package/src/pr-forge-bundle.test.ts +1 -1
  61. package/src/pr-forge.ts +44 -17
  62. package/src/pr-requires.test.ts +43 -6
  63. package/src/pr-requires.ts +5 -1
  64. package/src/workspace/ci-cloud-identity.test.ts +20 -0
  65. package/src/workspace/ci-cloud-identity.ts +14 -1
  66. package/src/workspace/ci-run.test.ts +74 -1
  67. package/src/workspace/ci-run.ts +122 -29
  68. package/src/workspace/ci-secrets.test.ts +1 -1
  69. package/src/workspace/ci-secrets.ts +4 -3
  70. package/src/workspace/declaration.schema.json +36 -1
  71. package/src/workspace/declaration.test.ts +7 -0
  72. package/src/workspace/declaration.ts +24 -2
@@ -0,0 +1,440 @@
1
+ /**
2
+ * Running a pull request's environment (#4330): `up`, `down` and `sweep` as
3
+ * functions over an adapter, so a product that plans and applies with a tool
4
+ * chant does not run (terragucci, with Terraform roots under suffixed state
5
+ * keys) keeps its own plan, apply and teardown and takes the rest from chant:
6
+ *
7
+ * - the gate: a non-empty plan applies only once a person's approval of its
8
+ * digest stands under gate `pr-env` (ws-080, ws-104), and an empty one
9
+ * applies at once;
10
+ * - the records on chant/lifecycle (`_pr-envs/records.jsonl`), the TTL and
11
+ * which environments stand ({@link livePrEnvironments});
12
+ * - the ownership check on teardown ({@link teardownRefusal}), and the
13
+ * marker check on every candidate before anything is deleted
14
+ * ({@link tearDownPrEnvironment});
15
+ * - the sweep over expired and closed pull requests;
16
+ * - the report and the note ({@link renderPrEnvNote}).
17
+ *
18
+ * `chant components pr-env` (../cli/handlers/pr-env.ts) runs these with the
19
+ * components adapter and the lexicons' teardown. The ports default to
20
+ * chant/lifecycle in the working directory and the gate ledger there
21
+ * ({@link lifecyclePrEnvPorts}).
22
+ */
23
+ import { spawnSync } from "node:child_process";
24
+ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
25
+ import { tmpdir } from "node:os";
26
+ import { join } from "node:path";
27
+ import { withoutForgeTokens } from "../ci-handover.js";
28
+ import { PR_ENV_EXIT, PR_ENV_GATE, PR_ENV_LEDGER_DIR, PR_ENV_LEDGER_FILE, expired, livePrEnvironments, parsePrEnvRecords, prEnvNoteMarker, prEnvStatusContext, prEnvStatusDescription, prEnvStatusState, prEnvironmentName, renderPrEnvNote, teardownComplete, teardownCounts, tearDownPrEnvironment, ttlMs, } from "./pr-environment.js";
29
+ /** The op a pull request's gate is recorded under, as `prOp` in ../pr-loop.ts names it. */
30
+ export function prEnvOp(pr, member) {
31
+ return member ? `pr-${pr}-${member}` : `pr-${pr}`;
32
+ }
33
+ /** The approve command an adapter's caller prints, the same the note shows. */
34
+ export { prEnvApproveCommand } from "./pr-environment.js";
35
+ const ttlOf = (ttl) => (ttl ? ttlMs(ttl) : undefined) ?? ttlMs("72h");
36
+ /**
37
+ * Plan pull request `pr`'s environment through the adapter and apply it once
38
+ * the plan is empty or an approval of its digest stands under gate `pr-env`.
39
+ * An apply that failed part way is kept as live too, so what applied is torn
40
+ * down with the rest.
41
+ */
42
+ export async function prEnvUp(input) {
43
+ const { pr, ports } = input;
44
+ const env = prEnvironmentName(pr);
45
+ const target = {
46
+ pr,
47
+ env,
48
+ template: input.template,
49
+ marker: { stack: input.stack, env },
50
+ head: input.head,
51
+ ...(input.member ? { member: input.member } : {}),
52
+ op: prEnvOp(pr, input.member),
53
+ ...(input.endpoint ? { endpoint: input.endpoint } : {}),
54
+ };
55
+ const base = {
56
+ stage: "up",
57
+ pr,
58
+ env,
59
+ ...(input.member ? { member: input.member } : {}),
60
+ template: input.template,
61
+ head: input.head,
62
+ op: target.op,
63
+ gate: PR_ENV_GATE,
64
+ digest: "",
65
+ status: "nothing",
66
+ ...(input.endpoint ? { endpoint: input.endpoint } : {}),
67
+ components: [],
68
+ };
69
+ const settle = async (report, exit, record) => {
70
+ await ports.publish?.(report);
71
+ return { exit, report, ...(record ? { record } : {}) };
72
+ };
73
+ let planned;
74
+ try {
75
+ planned = await input.adapter.plan(target);
76
+ }
77
+ catch (err) {
78
+ return settle({ ...base, status: "plan-failed", message: messageOf(err) }, PR_ENV_EXIT.failed);
79
+ }
80
+ if (planned.rows.length === 0) {
81
+ ports.log?.(`pr-env up: nothing this change touches is deployed, so ${env} gets nothing`);
82
+ return settle({ ...base, ...(planned.message ? { message: planned.message } : {}) }, PR_ENV_EXIT.done);
83
+ }
84
+ const digest = planned.digest;
85
+ if (planned.failed) {
86
+ return settle({ ...base, digest, status: "plan-failed", ...(planned.message ? { message: planned.message } : {}), components: planned.rows }, PR_ENV_EXIT.failed);
87
+ }
88
+ // ws-080, ws-104: a non-empty plan applies only under a person's approval of its digest. An empty one passes.
89
+ let approvedBy;
90
+ if (!planned.empty) {
91
+ let approval;
92
+ try {
93
+ approval = await ports.decideGate({ op: target.op, gate: PR_ENV_GATE, digest, description: `${env}: ${planned.rows.map((r) => r.component).join(", ")}` });
94
+ }
95
+ catch (err) {
96
+ return settle({ ...base, digest, status: "failed", message: `could not read the gate ledger, so ${env} does not apply: ${messageOf(err)}`, components: planned.rows }, PR_ENV_EXIT.failed);
97
+ }
98
+ if (approval.status !== "approved") {
99
+ ports.log?.(`pr-env up: ${env} waits for an approval of ${digest}`);
100
+ return settle({ ...base, digest, status: approval.status === "changed" ? "changed" : "waiting", components: planned.rows }, PR_ENV_EXIT.waiting);
101
+ }
102
+ approvedBy = approval.approvedBy ?? [];
103
+ }
104
+ let applied;
105
+ try {
106
+ applied = await input.adapter.apply(target, { planned, ...(approvedBy ? { approvedBy } : {}) });
107
+ }
108
+ catch (err) {
109
+ applied = { status: "failed", rows: planned.rows, message: messageOf(err) };
110
+ }
111
+ if (applied.status === "stopped") {
112
+ return settle({ ...base, digest, status: "failed", components: applied.rows, ...(approvedBy ? { approvedBy } : {}), ...(applied.message ? { message: applied.message } : {}) }, PR_ENV_EXIT.failed);
113
+ }
114
+ const ok = applied.status === "applied";
115
+ const now = (input.now ?? (() => new Date()))();
116
+ const expiresAt = new Date(now.getTime() + ttlOf(input.ttl)).toISOString();
117
+ const record = {
118
+ version: 1,
119
+ kind: "up",
120
+ pr,
121
+ env,
122
+ ...(input.member ? { member: input.member } : {}),
123
+ template: input.template,
124
+ marker: { ...target.marker },
125
+ commit: input.head,
126
+ components: planned.rows.map((r) => r.component),
127
+ ...(applied.locations && Object.keys(applied.locations).length > 0 ? { locations: { ...applied.locations } } : {}),
128
+ planDigest: digest,
129
+ result: ok ? "applied" : "failed",
130
+ by: input.actor ?? "chant",
131
+ timestamp: now.toISOString(),
132
+ expiresAt,
133
+ ...(approvedBy ? { approvedBy } : {}),
134
+ releaseTarget: false,
135
+ ...(input.runUrl ? { runUrl: input.runUrl } : {}),
136
+ };
137
+ // A copy that failed part way is live too: what applied is torn down on close or at expiry like the rest.
138
+ await ports.appendRecord(record);
139
+ const message = ok
140
+ ? applied.afterFailure ?? applied.message
141
+ : applied.message ?? (applied.status === "waiting" ? "A component read an upstream output that moved when it applied; run the job again to plan it against the new value." : "A component failed to apply; what applied stays in the environment and is torn down with it.");
142
+ ports.log?.(`pr-env up: ${env} ${ok ? "applied" : applied.status}; it expires ${expiresAt}`);
143
+ return settle({ ...base, digest, status: ok ? "applied" : "failed", components: applied.rows, ...(approvedBy ? { approvedBy } : {}), expiresAt, ...(message ? { message } : {}) }, ok && !applied.afterFailure ? PR_ENV_EXIT.done : PR_ENV_EXIT.failed, record);
144
+ }
145
+ /**
146
+ * Tear down pull request `pr`'s environment: the ownership check first, then
147
+ * only what carries `{ stack, env: "pr-<n>" }`, through the lexicons and the
148
+ * adapters. No gate holds it: closing the pull request, or the TTL the base
149
+ * set, is the decision. A teardown that left something keeps the
150
+ * environment live for the next sweep.
151
+ */
152
+ export async function prEnvDown(input) {
153
+ const { pr, ports, reason } = input;
154
+ const env = prEnvironmentName(pr);
155
+ const live = input.live ?? livePrEnvironments(await ports.readRecords()).get(env);
156
+ const report = { stage: "down", pr, env, ...(input.member ? { member: input.member } : {}), template: live?.template ?? "", head: "", op: prEnvOp(pr, input.member), gate: PR_ENV_GATE, digest: "", status: "absent", components: [] };
157
+ if (!live) {
158
+ ports.log?.(`pr-env down: ${env} has no live record, so there is nothing to tear down`);
159
+ await ports.publish?.(report);
160
+ return { exit: PR_ENV_EXIT.done, report };
161
+ }
162
+ const torn = await tearDownPrEnvironment({ pr, live, ...(input.config ? { config: input.config } : {}), ...(input.plugins ? { plugins: input.plugins } : {}), ...(input.adapters ? { adapters: input.adapters } : {}), ...(ports.warn ? { warn: ports.warn } : {}) });
163
+ if ("refusal" in torn) {
164
+ const refused = { ...report, template: live.template, status: "refused", message: torn.refusal };
165
+ await ports.publish?.(refused);
166
+ return { exit: PR_ENV_EXIT.failed, report: refused };
167
+ }
168
+ const { report: result, dropped, marker } = torn;
169
+ const counts = teardownCounts(result);
170
+ const complete = teardownComplete(result);
171
+ const now = (input.now ?? (() => new Date()))();
172
+ const record = {
173
+ version: 1,
174
+ kind: "down",
175
+ pr,
176
+ env,
177
+ ...(live.member ? { member: live.member } : {}),
178
+ template: live.template,
179
+ marker,
180
+ commit: input.commit,
181
+ components: [...new Set(result.outcomes.map((o) => o.lexicon))].sort(),
182
+ planDigest: "",
183
+ result: complete ? "destroyed" : "incomplete",
184
+ by: input.actor ?? "chant",
185
+ timestamp: now.toISOString(),
186
+ reason,
187
+ outcomes: counts,
188
+ releaseTarget: false,
189
+ ...(input.runUrl ? { runUrl: input.runUrl } : {}),
190
+ };
191
+ await ports.appendRecord(record);
192
+ const why = [];
193
+ if (dropped > 0)
194
+ why.push(`${dropped} candidate${dropped === 1 ? "" : "s"} whose marker was not ${marker.stack}/${env} left alone`);
195
+ if (result.unimplemented.length > 0)
196
+ why.push(`no teardown execution in ${result.unimplemented.join(", ")}`);
197
+ if (result.plan.holes.length > 0)
198
+ why.push(`${result.plan.holes.length} part${result.plan.holes.length === 1 ? "" : "s"} could not be read`);
199
+ for (const o of result.outcomes.filter((x) => x.outcome === "failed"))
200
+ why.push(`${o.lexicon} ${o.name}: ${o.detail ?? "failed"}`);
201
+ const done = { ...report, template: live.template, status: complete ? "destroyed" : "incomplete", outcomes: counts, ...(why.length > 0 ? { message: why.join("; ") } : {}) };
202
+ ports.log?.(`pr-env down: ${env} ${complete ? "torn down" : "not wholly torn down; it stays live and the sweep tries again"} (${counts.deleted} deleted, ${counts.failed} failed, ${counts.skipped} skipped)`);
203
+ await ports.publish?.(done);
204
+ return { exit: complete ? PR_ENV_EXIT.done : PR_ENV_EXIT.failed, report: done, record };
205
+ }
206
+ /**
207
+ * Tear down each live environment whose TTL passed, or whose pull request
208
+ * the forge says is closed or merged. A state that cannot be read leaves the
209
+ * TTL to decide. Exits 1 when any teardown did not finish.
210
+ */
211
+ export async function prEnvSweep(input) {
212
+ const { ports } = input;
213
+ const live = [...livePrEnvironments(await ports.readRecords()).values()].filter((e) => input.member === undefined || e.member === input.member);
214
+ if (live.length === 0) {
215
+ ports.log?.("pr-env sweep: no pull request environment is live");
216
+ return { exit: PR_ENV_EXIT.done, results: [] };
217
+ }
218
+ const now = (input.now ?? (() => new Date()))();
219
+ let exit = PR_ENV_EXIT.done;
220
+ const results = [];
221
+ for (const e of live) {
222
+ let reason = expired(e, now) ? "expired" : undefined;
223
+ if (!reason && ports.pullRequestState) {
224
+ try {
225
+ if ((await ports.pullRequestState(e.pr)) !== "open")
226
+ reason = "closed";
227
+ }
228
+ catch (err) {
229
+ ports.warn?.(`could not read whether #${e.pr} is open (${messageOf(err)}); its TTL still holds`);
230
+ }
231
+ }
232
+ if (!reason) {
233
+ ports.log?.(`pr-env sweep: ${e.env} stays; it expires ${e.expiresAt}`);
234
+ continue;
235
+ }
236
+ const r = await prEnvDown({ ...input, pr: e.pr, reason, live: e, ...(e.member ? { member: e.member } : {}) });
237
+ results.push(r);
238
+ if (r.exit !== PR_ENV_EXIT.done)
239
+ exit = PR_ENV_EXIT.failed;
240
+ }
241
+ return { exit, results };
242
+ }
243
+ // ── the ports chant itself uses ────────────────────────────────────────────
244
+ /**
245
+ * The note and the `chant/pr-env` status on the forge. A refusal from the
246
+ * forge warns and never fails the run.
247
+ */
248
+ export function forgePrEnvPublisher(forge, warn = () => { }) {
249
+ return async (report) => {
250
+ const { forgePrincipalOf } = await import("../pr-forge.js");
251
+ const note = renderPrEnvNote(report, forgePrincipalOf(forge.kind, forge.host, "<your-login>"));
252
+ if (report.head) {
253
+ try {
254
+ await forge.setStatus(report.head, { context: prEnvStatusContext(report.member), state: prEnvStatusState(report), description: prEnvStatusDescription(report), ...(forge.runUrl ? { url: forge.runUrl } : {}) });
255
+ }
256
+ catch (err) {
257
+ warn(`could not set the ${prEnvStatusContext(report.member)} status: ${messageOf(err)}`);
258
+ }
259
+ }
260
+ try {
261
+ await forge.upsertNote(report.pr, prEnvNoteMarker(report.env, report.member), note);
262
+ }
263
+ catch (err) {
264
+ warn(`could not post the note on #${report.pr}: ${messageOf(err)}`);
265
+ }
266
+ };
267
+ }
268
+ /**
269
+ * The ports over chant/lifecycle in `cwd` (default the working directory):
270
+ * the records at `_pr-envs/records.jsonl`, appended and pushed, and the gate
271
+ * ledger read without writing a pending fact. With `forge`, the note and
272
+ * status are posted and the sweep asks it whether a pull request is open.
273
+ */
274
+ export function lifecyclePrEnvPorts(opts = {}) {
275
+ const at = opts.cwd ? { cwd: opts.cwd } : undefined;
276
+ const warn = opts.warn ?? (() => { });
277
+ const forge = opts.forge;
278
+ return {
279
+ async readRecords() {
280
+ const { fetchLifecycle, readBlobFromPath } = await import("../lifecycle/git.js");
281
+ await fetchLifecycle(at).catch(() => false);
282
+ return parsePrEnvRecords(await readBlobFromPath(PR_ENV_LEDGER_DIR, PR_ENV_LEDGER_FILE, at));
283
+ },
284
+ async appendRecord(record) {
285
+ const { appendLedgerLine, fetchLifecycle, pushLifecycleReport } = await import("../lifecycle/git.js");
286
+ try {
287
+ await fetchLifecycle(at).catch(() => false);
288
+ await appendLedgerLine(PR_ENV_LEDGER_DIR, PR_ENV_LEDGER_FILE, JSON.stringify(record), `Pull request environment ${record.env} ${record.kind} (${record.result})`, at);
289
+ const pushed = await pushLifecycleReport(at);
290
+ if (pushed.pushWarning)
291
+ warn(pushed.pushWarning);
292
+ }
293
+ catch (err) {
294
+ warn(`could not record ${record.env}'s ${record.kind} on chant/lifecycle: ${messageOf(err)}`);
295
+ }
296
+ },
297
+ async decideGate(input) {
298
+ const { approvalOf, decidePrGate, readOnlyLedger } = await import("./pr-run.js");
299
+ const { gitGateLedgerPort } = await import("../op/gate.js");
300
+ const approval = approvalOf(await decidePrGate(readOnlyLedger(gitGateLedgerPort(at)), input));
301
+ return { status: approval.status, ...(approval.approvedBy ? { approvedBy: approval.approvedBy } : {}) };
302
+ },
303
+ ...(forge ? { publish: forgePrEnvPublisher(forge, warn) } : {}),
304
+ ...(forge?.pullRequestState ? { pullRequestState: (pr) => forge.pullRequestState(pr) } : {}),
305
+ ...(opts.log ? { log: opts.log } : {}),
306
+ warn,
307
+ };
308
+ }
309
+ /** The variables a teardown command reads. */
310
+ export const PR_ENV_TEARDOWN_ENV = {
311
+ /** `owned` or `teardown`. */
312
+ stage: "CHANT_PR_ENV_STAGE",
313
+ /** `pr-<n>`. */
314
+ env: "CHANT_PR_ENV",
315
+ pr: "CHANT_PR_NUMBER",
316
+ stack: "CHANT_PR_ENV_STACK",
317
+ template: "CHANT_PR_ENV_TEMPLATE",
318
+ /** The commit last applied to the environment. */
319
+ commit: "CHANT_PR_ENV_COMMIT",
320
+ /** A JSON file: `{ components, locations }` from the records. */
321
+ live: "CHANT_PR_ENV_LIVE",
322
+ /** `teardown` only: a JSON file holding the candidates to delete. */
323
+ candidates: "CHANT_PR_ENV_CANDIDATES",
324
+ /** The JSON file the command writes its answer to. */
325
+ result: "CHANT_PR_ENV_RESULT",
326
+ };
327
+ const spawnTeardown = (argv, cwd, env) => {
328
+ const r = spawnSync(argv[0], argv.slice(1), { cwd, env, stdio: ["ignore", "inherit", "inherit"] });
329
+ if (r.error)
330
+ throw r.error;
331
+ return r.status ?? 1;
332
+ };
333
+ const MARKER_OK = (m) => typeof m === "object" && m !== null && typeof m.stack === "string" && typeof m.env === "string";
334
+ /** The candidates and holes a teardown command wrote, checked as data. Throws when they do not read. */
335
+ export function readTeardownEnumeration(raw) {
336
+ const doc = raw;
337
+ if (typeof doc !== "object" || doc === null || !Array.isArray(doc.candidates))
338
+ throw new Error("the teardown command's owned stage wrote no { candidates: [...] }");
339
+ const candidates = [];
340
+ for (const c of doc.candidates) {
341
+ if (typeof c?.name !== "string" || typeof c.type !== "string" || !MARKER_OK(c.marker))
342
+ throw new Error("each candidate needs a name, a type and the marker { stack, env } read back from it");
343
+ candidates.push({ name: c.name, type: c.type, ...(typeof c.physicalId === "string" ? { physicalId: c.physicalId } : {}), marker: { stack: c.marker.stack, env: c.marker.env } });
344
+ }
345
+ const holes = [];
346
+ for (const h of Array.isArray(doc.holes) ? doc.holes : []) {
347
+ if (typeof h?.name !== "string")
348
+ continue;
349
+ holes.push({ name: h.name, reason: "read-failed", ...(typeof h.type === "string" ? { type: h.type } : {}), ...(typeof h.detail === "string" ? { detail: h.detail } : {}) });
350
+ }
351
+ return { candidates, holes };
352
+ }
353
+ /** The outcomes a teardown command wrote, checked as data. A candidate it leaves out counts as failed in core. */
354
+ export function readTeardownOutcomes(raw) {
355
+ const doc = raw;
356
+ if (typeof doc !== "object" || doc === null || !Array.isArray(doc.outcomes))
357
+ throw new Error("the teardown command's teardown stage wrote no { outcomes: [...] }");
358
+ const kinds = new Set(["deleted", "failed", "not-prunable", "retained"]);
359
+ return doc.outcomes
360
+ .filter((o) => typeof o?.name === "string" && typeof o.outcome === "string" && kinds.has(o.outcome))
361
+ .map((o) => ({ name: o.name, outcome: o.outcome, ...(typeof o.detail === "string" ? { detail: o.detail } : {}) }));
362
+ }
363
+ /**
364
+ * `ci.prEnvironment.teardown` as an adapter (#4330). chant runs the command
365
+ * twice, in `cwd`, with the job's environment less every forge token
366
+ * variable, and these besides ({@link PR_ENV_TEARDOWN_ENV}):
367
+ *
368
+ * - `CHANT_PR_ENV_STAGE=owned`: the command writes `{ candidates, holes }`
369
+ * to `CHANT_PR_ENV_RESULT`, each candidate with the marker it read back.
370
+ * - `CHANT_PR_ENV_STAGE=teardown`: it deletes the candidates in
371
+ * `CHANT_PR_ENV_CANDIDATES`, which chant has checked against the marker,
372
+ * and writes `{ outcomes }` to `CHANT_PR_ENV_RESULT`.
373
+ *
374
+ * A non-zero exit, or an answer that does not read, is a hole (`owned`) or a
375
+ * failure for every candidate (`teardown`), so the environment stays live.
376
+ */
377
+ export function commandTeardownAdapter(hook, opts) {
378
+ const exec = opts.exec ?? spawnTeardown;
379
+ const name = hook.name ?? "teardown";
380
+ const run = (stage, input, candidates) => {
381
+ const dir = mkdtempSync(join(tmpdir(), "chant-pr-env-teardown-"));
382
+ try {
383
+ const result = join(dir, "result.json");
384
+ const liveFile = join(dir, "live.json");
385
+ writeFileSync(liveFile, JSON.stringify({ components: input.live.components, locations: input.live.locations ?? {} }));
386
+ const extra = {
387
+ [PR_ENV_TEARDOWN_ENV.stage]: stage,
388
+ [PR_ENV_TEARDOWN_ENV.env]: input.environment,
389
+ [PR_ENV_TEARDOWN_ENV.pr]: String(input.live.pr),
390
+ [PR_ENV_TEARDOWN_ENV.stack]: input.marker.stack,
391
+ [PR_ENV_TEARDOWN_ENV.template]: input.live.template,
392
+ [PR_ENV_TEARDOWN_ENV.commit]: input.live.commit,
393
+ [PR_ENV_TEARDOWN_ENV.live]: liveFile,
394
+ [PR_ENV_TEARDOWN_ENV.result]: result,
395
+ };
396
+ if (candidates) {
397
+ const file = join(dir, "candidates.json");
398
+ writeFileSync(file, JSON.stringify(candidates));
399
+ extra[PR_ENV_TEARDOWN_ENV.candidates] = file;
400
+ }
401
+ const base = {};
402
+ for (const [k, v] of Object.entries(withoutForgeTokens(opts.env ?? process.env)))
403
+ if (v !== undefined)
404
+ base[k] = v;
405
+ const argv = hook.command.map((a) => a.split("{env}").join(input.environment).split("{pr}").join(String(input.live.pr)).split("{stage}").join(stage));
406
+ const code = exec(argv, opts.cwd, { ...base, ...extra });
407
+ if (code !== 0)
408
+ throw new Error(`${argv.join(" ")} exited ${code} in its ${stage} stage`);
409
+ let text;
410
+ try {
411
+ text = readFileSync(result, "utf-8");
412
+ }
413
+ catch {
414
+ throw new Error(`${argv.join(" ")} wrote nothing to ${PR_ENV_TEARDOWN_ENV.result} in its ${stage} stage`);
415
+ }
416
+ return JSON.parse(text);
417
+ }
418
+ finally {
419
+ rmSync(dir, { recursive: true, force: true });
420
+ }
421
+ };
422
+ return {
423
+ name,
424
+ ...(hook.lexicons ? { lexicons: [...hook.lexicons] } : {}),
425
+ async owned(input) {
426
+ return readTeardownEnumeration(run("owned", input));
427
+ },
428
+ async teardown(input) {
429
+ try {
430
+ return { outcomes: readTeardownOutcomes(run("teardown", input, input.candidates)) };
431
+ }
432
+ catch (err) {
433
+ return { outcomes: input.candidates.map((c) => ({ name: c.name, outcome: "failed", detail: messageOf(err) })) };
434
+ }
435
+ },
436
+ };
437
+ }
438
+ function messageOf(err) {
439
+ return err instanceof Error ? err.message : String(err);
440
+ }
@@ -32,12 +32,17 @@
32
32
  *
33
33
  * terragucci's `ephemeral.ts` gives each copy a suffixed Terraform state key.
34
34
  * That part is Terraform's own and stays there; chant keys ownership on the
35
- * marker its lexicons stamp and read back (`../lifecycle/teardown.ts`).
35
+ * marker its lexicons stamp and read back (`../lifecycle/teardown.ts`). A
36
+ * product supplies the rest as adapters (#4330): its plan and apply
37
+ * (`./pr-env-run.ts`), and a teardown for what no lexicon tears down
38
+ * ({@link PrEnvTeardownAdapter}), which reads the marker back from the copy
39
+ * as a lexicon does.
36
40
  */
37
41
  import { type ChantConfig, type EnvironmentDeclaration } from "../config.js";
38
42
  import type { OwnershipMarker } from "../ownership.js";
39
43
  import { type TeardownPlan, type TeardownPlanEntry, type TeardownReport } from "../lifecycle/teardown.js";
40
- import type { ObservationLexicon } from "../lexicon.js";
44
+ import type { ObservationLexicon, TeardownCandidate, TeardownEnumeration, TeardownExecution } from "../lexicon.js";
45
+ import type { ComponentEnvironmentDeclaration } from "./component.js";
41
46
  /** The gate a pull request's environment waits on, under the pull request's op `pr-<n>`. */
42
47
  export declare const PR_ENV_GATE = "pr-env";
43
48
  /** Where the records live on chant/lifecycle, under the member's ledger prefix. */
@@ -97,6 +102,18 @@ export type PrEnvDerivation = {
97
102
  * would not take the name, or does not declare the template.
98
103
  */
99
104
  export declare function derivePrEnvironment(config: ChantConfig, template: string, pr: number): PrEnvDerivation;
105
+ /** The placeholder a template's site URL or domain names the environment with (#4330). */
106
+ export declare const PR_ENV_SITE_PLACEHOLDER = "{env}";
107
+ /**
108
+ * A component's site in `env`, a pull request's environment, carried over
109
+ * from its site in `template` (#4330). An entry the component declares for
110
+ * `env` itself wins. Otherwise the template's runtime and lifecycle remote
111
+ * carry over as they are. Its URL and domain carry over only when they name
112
+ * the environment with `{env}`, which becomes `pr-<n>`: a literal URL or
113
+ * domain is the template's own release, so it is left out rather than
114
+ * pointing pr-<n> at it. Undefined when neither is declared.
115
+ */
116
+ export declare function prEnvironmentSite(declared: readonly ComponentEnvironmentDeclaration[] | undefined, template: string, env: string): ComponentEnvironmentDeclaration | undefined;
100
117
  /** One line of `_pr-envs/records.jsonl`: an apply, or a teardown. */
101
118
  export interface PrEnvRecord {
102
119
  version: 1;
@@ -117,6 +134,12 @@ export interface PrEnvRecord {
117
134
  commit: string;
118
135
  /** The components applied (up) or the lexicons torn down (down). */
119
136
  components: string[];
137
+ /**
138
+ * Up (#4330): where each component's copy lives, by component, as the
139
+ * adapter that applied it says (a Terraform root's suffixed state key).
140
+ * A teardown adapter reads it back from the live environment.
141
+ */
142
+ locations?: Record<string, string>;
120
143
  /** The change-set digest applied; empty for a teardown. */
121
144
  planDigest: string;
122
145
  /** `incomplete`: a teardown that left something, so the environment stays live and the sweep tries again. */
@@ -157,6 +180,8 @@ export interface LivePrEnvironment {
157
180
  commit: string;
158
181
  /** Every component an apply of it ever touched. */
159
182
  components: string[];
183
+ /** Where each component's copy lives, merged over every up (#4330). */
184
+ locations?: Record<string, string>;
160
185
  applied: string;
161
186
  expiresAt: string;
162
187
  /** Its last teardown left something, so the sweep tries again. */
@@ -188,12 +213,51 @@ export declare function ownedEntries(plan: TeardownPlan, marker: OwnershipMarker
188
213
  plan: TeardownPlan;
189
214
  dropped: TeardownPlanEntry[];
190
215
  };
216
+ /**
217
+ * A teardown a product supplies for what no lexicon tears down (#4330), such
218
+ * as a Terraform root's copy under a suffixed state key: chant has no
219
+ * Terraform runner, so terragucci supplies this. It takes part in the same
220
+ * two halves a lexicon's teardown does (`../lifecycle/teardown.ts`): `owned`
221
+ * names what the environment owns, each with the marker read back from it,
222
+ * and `teardown` deletes the candidates chant hands back. Every candidate
223
+ * whose marker is not exactly `{ stack, env: "pr-<n>" }` is dropped before
224
+ * `teardown` sees it, and a candidate it says nothing about counts as failed.
225
+ */
226
+ export interface PrEnvTeardownAdapter {
227
+ /** The name outcomes are attributed to, as a lexicon's are. */
228
+ name: string;
229
+ /**
230
+ * The lexicons this adapter tears down in place of (`terraform`). Their own
231
+ * teardown is left out, so a lexicon with no teardown execution does not
232
+ * leave the environment incomplete when the adapter covers it.
233
+ */
234
+ lexicons?: string[];
235
+ /** What the environment owns: candidates with their read-back markers, and what could not be read. */
236
+ owned(input: PrEnvTeardownAdapterInput): Promise<TeardownEnumeration>;
237
+ /** Delete the candidates: one outcome per candidate, keyed by name. */
238
+ teardown(input: PrEnvTeardownAdapterInput & {
239
+ candidates: TeardownCandidate[];
240
+ }): Promise<TeardownExecution>;
241
+ }
242
+ /** What a {@link PrEnvTeardownAdapter} is told about the environment. */
243
+ export interface PrEnvTeardownAdapterInput {
244
+ /** `pr-<n>`. */
245
+ environment: string;
246
+ /** The marker everything is selected on. */
247
+ marker: OwnershipMarker;
248
+ /** The environment as its records say it stands: the commit last applied, its components and their locations. */
249
+ live: LivePrEnvironment;
250
+ }
191
251
  /** What {@link tearDownPrEnvironment} needs. */
192
252
  export interface PrEnvTeardownInput {
193
253
  pr: number;
194
254
  live: LivePrEnvironment;
195
- config: ChantConfig;
196
- plugins: ObservationLexicon[];
255
+ /** The project's config, for its environments and stacks. Absent: a product with no chant.config.ts, whose adapters do the teardown. */
256
+ config?: ChantConfig;
257
+ /** The lexicons whose teardown runs. Default none. */
258
+ plugins?: ObservationLexicon[];
259
+ /** Teardowns a product supplies (#4330), run after the lexicons'. */
260
+ adapters?: PrEnvTeardownAdapter[];
197
261
  warn?: (message: string) => void;
198
262
  }
199
263
  /**
@@ -201,8 +265,9 @@ export interface PrEnvTeardownInput {
201
265
  * before any read when {@link teardownRefusal} says so; otherwise the live
202
266
  * resources under the record's marker are planned, every entry whose marker
203
267
  * is not exactly `{ stack, env: "pr-<n>" }` is dropped ({@link ownedEntries}),
204
- * and only the rest go to each lexicon's teardown. The endpoint is the one
205
- * the environment was applied at: its own `pr-*` entry's, else the template's.
268
+ * and only the rest go to each lexicon's or adapter's teardown. The endpoint
269
+ * is the one the environment was applied at: its own `pr-*` entry's, else the
270
+ * template's. A lexicon an adapter covers (`lexicons`) is left out.
206
271
  */
207
272
  export declare function tearDownPrEnvironment(input: PrEnvTeardownInput): Promise<{
208
273
  refusal: string;
@@ -263,6 +328,23 @@ export declare function handedPrEnvReport(raw: unknown, check: {
263
328
  } | {
264
329
  refusal: string;
265
330
  };
331
+ /** One component's row in the report and the note. */
332
+ export interface PrEnvReportRow {
333
+ component: string;
334
+ status: string;
335
+ create: number;
336
+ update: number;
337
+ replace: number;
338
+ delete: number;
339
+ /** Where its copy lives, as the adapter says (#4330). */
340
+ location?: string;
341
+ /** Its site in pr-<n>: the runtime, URL and domain carried over from the template's (#4330, {@link prEnvironmentSite}). */
342
+ site?: {
343
+ runtime?: string;
344
+ url?: string;
345
+ domain?: string;
346
+ };
347
+ }
266
348
  /** What one `pr-env up` or `down` run came to, as `pr-env.json` holds it. */
267
349
  export interface PrEnvReport {
268
350
  stage: "up" | "down";
@@ -277,14 +359,7 @@ export interface PrEnvReport {
277
359
  status: "applied" | "nothing" | "waiting" | "changed" | "plan-failed" | "failed" | "refused" | "destroyed" | "incomplete" | "absent";
278
360
  message?: string;
279
361
  endpoint?: string;
280
- components: Array<{
281
- component: string;
282
- status: string;
283
- create: number;
284
- update: number;
285
- replace: number;
286
- delete: number;
287
- }>;
362
+ components: PrEnvReportRow[];
288
363
  approvedBy?: string[];
289
364
  expiresAt?: string;
290
365
  outcomes?: PrEnvRecord["outcomes"];
@@ -1 +1 @@
1
- {"version":3,"file":"pr-environment.d.ts","sourceRoot":"","sources":["../../src/components/pr-environment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAsI,KAAK,WAAW,EAAE,KAAK,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAC9M,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAiC,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAE,KAAK,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