@intentius/chant-lexicon-pulumi 0.124.101 → 0.124.103

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 (71) hide show
  1. package/dist/change-set.d.ts +5 -0
  2. package/dist/change-set.js +4 -0
  3. package/dist/chant-floors.d.ts +36 -0
  4. package/dist/chant-floors.js +36 -0
  5. package/dist/cost-hold.d.ts +45 -0
  6. package/dist/cost-hold.js +49 -0
  7. package/dist/describe-resources.d.ts +10 -0
  8. package/dist/describe-resources.js +79 -3
  9. package/dist/disruption.d.ts +50 -0
  10. package/dist/disruption.js +104 -0
  11. package/dist/engine-graph.d.ts +1 -1
  12. package/dist/engine-graph.js +40 -1
  13. package/dist/health-targets.d.ts +25 -0
  14. package/dist/health-targets.js +57 -0
  15. package/dist/index.d.ts +7 -0
  16. package/dist/index.js +8 -0
  17. package/dist/integrity.json +18 -18
  18. package/dist/lint/post-synth/member-read-helpers.d.ts +1 -1
  19. package/dist/lint/post-synth/member-read-helpers.js +1 -1
  20. package/dist/lint/post-synth/pul001.js +1 -1
  21. package/dist/lint/post-synth/pul002.js +1 -1
  22. package/dist/lint/post-synth/pul003.js +1 -1
  23. package/dist/lint/post-synth/pul004.js +1 -1
  24. package/dist/lint/post-synth/pul005.js +1 -1
  25. package/dist/lint/post-synth/pul006.js +1 -1
  26. package/dist/lint/post-synth/pul007.js +1 -1
  27. package/dist/lint/post-synth/pul008.js +1 -1
  28. package/dist/lint/post-synth/pul009.js +1 -1
  29. package/dist/lint/post-synth/pul010.js +1 -1
  30. package/dist/lint/post-synth/pul011.js +1 -1
  31. package/dist/lint/post-synth/pul012.js +1 -1
  32. package/dist/lint/post-synth/pul013.js +1 -1
  33. package/dist/lint/post-synth/pul014.js +1 -1
  34. package/dist/lint/post-synth/pul015.js +1 -1
  35. package/dist/manifest.json +1 -1
  36. package/dist/member-outputs.js +1 -1
  37. package/dist/member-report.d.ts +32 -0
  38. package/dist/member-report.js +23 -0
  39. package/dist/plugin.js +35 -2
  40. package/dist/preview-observation.d.ts +97 -0
  41. package/dist/preview-observation.js +218 -0
  42. package/dist/pulumi-up.d.ts +44 -3
  43. package/dist/pulumi-up.js +71 -11
  44. package/dist/reference-catalog.d.ts +84 -0
  45. package/dist/reference-catalog.js +383 -0
  46. package/dist/reference-props.d.ts +19 -0
  47. package/dist/reference-props.js +93 -0
  48. package/dist/rules/member-read-helpers.ts +1 -1
  49. package/dist/rules/pul001.ts +1 -1
  50. package/dist/rules/pul002.ts +1 -1
  51. package/dist/rules/pul003.ts +1 -1
  52. package/dist/rules/pul004.ts +1 -1
  53. package/dist/rules/pul005.ts +1 -1
  54. package/dist/rules/pul006.ts +1 -1
  55. package/dist/rules/pul007.ts +1 -1
  56. package/dist/rules/pul008.ts +1 -1
  57. package/dist/rules/pul009.ts +1 -1
  58. package/dist/rules/pul010.ts +1 -1
  59. package/dist/rules/pul011.ts +1 -1
  60. package/dist/rules/pul012.ts +1 -1
  61. package/dist/rules/pul013.ts +1 -1
  62. package/dist/rules/pul014.ts +1 -1
  63. package/dist/rules/pul015.ts +1 -1
  64. package/dist/run.js +1 -1
  65. package/dist/stack-export-snapshot.js +1 -1
  66. package/dist/stack-references.js +6 -1
  67. package/dist/workspace-member.d.ts +1 -26
  68. package/dist/workspace-member.js +11 -21
  69. package/dist/workspace-stack-reads.d.ts +12 -0
  70. package/dist/workspace-stack-reads.js +60 -0
  71. package/package.json +3 -3
@@ -0,0 +1,218 @@
1
+ import { isPulumiNodeless, pulumiNodeKey } from "@intentius/chant/pulumi-urn";
2
+ import { pulumiStepStates, pulumiSteps, pulumiStepsAction } from "./change-set.js";
3
+ import { isNameSized, mayCarryKey, referenceProps } from "./reference-props.js";
4
+ import { holdsUnknown, isObject, isSecret, isUnknown, propertyKeys, propertyPathSegments, sameJson, topLevelKey } from "./values.js";
5
+ /** The environment variable that sets how deep a pulumi member is read (#5332). */
6
+ export const PULUMI_OBSERVE_ENV = "CHANT_PULUMI_OBSERVE";
7
+ /** The `sources` value on each resource the preview answered. */
8
+ export const PREVIEW_SOURCE = "preview";
9
+ /** What stands in for a value the preview can't know yet, as in the terraform plan observation. */
10
+ export const KNOWN_AFTER_APPLY = "(known after apply)";
11
+ /** The status of a node that exists only in the preview. */
12
+ export const PLANNED_STATUS = "planned";
13
+ /** Every attribute the preview depth adds to a node, named as the terraform plan depth names them. */
14
+ export const PREVIEW_ATTRIBUTE_NAMES = ["planAction", "planActions", "planActionReason", "planReplacePaths", "planAfterUnknown", "planChanges"];
15
+ /** Why a preview read did not answer, on `rootReads[...].reason`. */
16
+ export const PREVIEW_READ_REASONS = {
17
+ "no-credentials": "the cloud provider or the backend refused the engine's credentials, or none were found",
18
+ "needs-install": "the program's dependencies or a provider plugin are not installed; chant never runs `pulumi install` on a read",
19
+ "no-stack": "the member names no stack and the engine has none selected, or the stack does not exist",
20
+ "no-binary": "the engine binary is not on PATH",
21
+ "preview-failed": "the preview failed for another reason; the engine's first error line is in the note",
22
+ };
23
+ /** The reason an engine error maps to. First match wins, in the order of {@link PREVIEW_READ_REASONS} less `preview-failed`. */
24
+ export function previewReadReason(error) {
25
+ if (/binary was not found|command not found|ENOENT/i.test(error))
26
+ return "no-binary";
27
+ if (/no stack selected|no stacks? (found|exist)|no stack named|stack ['"]?[\w./:-]+['"]? (does not exist|not found)|stack not found/i.test(error))
28
+ return "no-stack";
29
+ if (/pulumi install|npm install|yarn install|pnpm install|cannot find module|node_modules|no resource plugin|failed to load language plugin|could not find (a )?(compatible )?plugin|ModuleNotFoundError|No module named/i.test(error)) {
30
+ return "needs-install";
31
+ }
32
+ if (/no valid credential sources|NoCredentialProviders|could not find default credentials|InvalidAccessKeyId|failed to refresh cached credentials|AADSTS|token has expired|PULUMI_ACCESS_TOKEN|not logged in|you must be logged in|no credentials|unauthorized|authentication required/i.test(error)) {
33
+ return "no-credentials";
34
+ }
35
+ return "preview-failed";
36
+ }
37
+ /** Render one path as one string: keys joined with `.`, indexes and non-identifier keys in brackets. */
38
+ export function renderPath(segments) {
39
+ let out = "";
40
+ for (const segment of segments) {
41
+ if (typeof segment === "number")
42
+ out += `[${segment}]`;
43
+ else if (/^[A-Za-z_][A-Za-z0-9_-]*$/.test(segment))
44
+ out += out ? `.${segment}` : segment;
45
+ else
46
+ out += `[${JSON.stringify(segment)}]`;
47
+ }
48
+ return out;
49
+ }
50
+ const containerOf = (v) => Array.isArray(v) || isObject(v);
51
+ /** A scalar for the before side of an unknown, or null. */
52
+ function scalar(v) {
53
+ if (v === undefined || v === null || containerOf(v) || isSecret(v))
54
+ return null;
55
+ if (typeof v === "string" && !isNameSized(v))
56
+ return null;
57
+ return v;
58
+ }
59
+ /**
60
+ * The leaves where two input values differ, filtered as the module comment
61
+ * says. `unknownPaths` collects every path whose after side is unknown.
62
+ */
63
+ function diffValues(type, before, after, at, changes, unknownPaths) {
64
+ const last = at[at.length - 1];
65
+ if (typeof last === "string" && !mayCarryKey(last, { type, topLevel: at.length === 1 }))
66
+ return;
67
+ if (isSecret(before) || isSecret(after))
68
+ return;
69
+ const path = renderPath(at) || "*";
70
+ if (isUnknown(after)) {
71
+ unknownPaths.push(path);
72
+ changes.push({ path, before: scalar(before), after: KNOWN_AFTER_APPLY });
73
+ return;
74
+ }
75
+ if (sameJson(before, after))
76
+ return;
77
+ if (Array.isArray(before) || Array.isArray(after)) {
78
+ const b = Array.isArray(before) ? before : [];
79
+ const a = Array.isArray(after) ? after : [];
80
+ for (let i = 0; i < Math.max(b.length, a.length); i++)
81
+ diffValues(type, b[i], a[i], [...at, i], changes, unknownPaths);
82
+ return;
83
+ }
84
+ if (isObject(before) || isObject(after)) {
85
+ const b = isObject(before) ? before : {};
86
+ const a = isObject(after) ? after : {};
87
+ for (const key of [...new Set([...Object.keys(b), ...Object.keys(a)])].sort()) {
88
+ if (key.startsWith("__"))
89
+ continue;
90
+ diffValues(type, b[key], a[key], [...at, key], changes, unknownPaths);
91
+ }
92
+ return;
93
+ }
94
+ if ((typeof before === "string" && !isNameSized(before)) || (typeof after === "string" && !isNameSized(after)))
95
+ return;
96
+ changes.push({ path, before: before === undefined ? null : before, after: after === undefined ? null : after });
97
+ }
98
+ /** The plan attributes of one URN's steps. */
99
+ function attributesOf(urn, steps) {
100
+ const states = pulumiStepStates(steps);
101
+ const mapped = pulumiStepsAction(steps);
102
+ const type = states.after?.type ?? states.before?.type ?? "unknown";
103
+ const knownId = [states.after?.id, states.before?.id].find((v) => typeof v === "string" && v !== "" && !isUnknown(v));
104
+ const ops = steps.map((s) => s.op ?? "");
105
+ const action = mapped ? mapped.action : ops.join(",");
106
+ const after = isObject(states.after?.inputs) ? states.after.inputs : {};
107
+ const before = isObject(states.before?.inputs) ? states.before.inputs : {};
108
+ const named = new Set();
109
+ const replaceReasons = [];
110
+ for (const s of steps) {
111
+ for (const k of s.diffReasons ?? [])
112
+ named.add(topLevelKey(k));
113
+ for (const [path] of Object.entries(s.detailedDiff ?? {}))
114
+ named.add(topLevelKey(path));
115
+ for (const k of s.replaceReasons ?? [])
116
+ if (!replaceReasons.includes(k))
117
+ replaceReasons.push(k);
118
+ }
119
+ const changes = [];
120
+ const unknownPaths = [];
121
+ if (mapped?.action === "create") {
122
+ for (const k of propertyKeys(after).sort()) {
123
+ if (holdsUnknown(after[k]))
124
+ diffValues(type, undefined, after[k], [k], [], unknownPaths);
125
+ }
126
+ }
127
+ else if (mapped?.action === "update" || mapped?.action === "replace") {
128
+ const keys = new Set([...named, ...propertyKeys(after).filter((k) => holdsUnknown(after[k]))]);
129
+ for (const k of [...keys].filter((k) => !k.startsWith("__")).sort())
130
+ diffValues(type, before[k], after[k], [k], changes, unknownPaths);
131
+ }
132
+ const reasons = [];
133
+ if (mapped?.action === "replace" && mapped.disruption === "destroy")
134
+ reasons.push("delete-before-replace");
135
+ if (mapped?.importing)
136
+ reasons.push("import");
137
+ const replacePaths = replaceReasons
138
+ .filter((p) => propertyPathSegments(p).every((seg, i) => typeof seg === "number" || mayCarryKey(seg, { type, topLevel: i === 0 })))
139
+ .map((p) => renderPath(propertyPathSegments(p)));
140
+ return {
141
+ type,
142
+ ...(knownId ? { id: knownId } : {}),
143
+ attributes: {
144
+ urn,
145
+ planAction: action,
146
+ planActions: { [urn]: ops },
147
+ ...(reasons.length > 0 ? { planActionReason: reasons.join(",") } : {}),
148
+ ...(replacePaths.length > 0 ? { planReplacePaths: replacePaths.sort() } : {}),
149
+ ...(unknownPaths.length > 0 ? { planAfterUnknown: [...new Set(unknownPaths)].sort() } : {}),
150
+ ...(changes.length > 0 ? { planChanges: changes } : {}),
151
+ },
152
+ };
153
+ }
154
+ /**
155
+ * The member's preview as resources keyed `<label>/<urn tail>`, the key the
156
+ * graph read uses. `declared` are the entities the graph already holds.
157
+ * Returns undefined when the document has no steps.
158
+ */
159
+ export function observePreview(opts) {
160
+ const steps = pulumiSteps(opts.preview);
161
+ if (steps === undefined)
162
+ return undefined;
163
+ const byUrn = new Map();
164
+ for (const s of steps) {
165
+ const list = byUrn.get(s.urn) ?? [];
166
+ list.push(s);
167
+ byUrn.set(s.urn, list);
168
+ }
169
+ const resources = {};
170
+ const queried = {};
171
+ const sources = {};
172
+ const parents = new Map();
173
+ let unmapped = 0;
174
+ for (const [urn, list] of byUrn) {
175
+ const key = pulumiNodeKey(urn);
176
+ if (key === null)
177
+ continue;
178
+ const { type, id, attributes } = attributesOf(urn, list);
179
+ if (isPulumiNodeless(type))
180
+ continue;
181
+ const name = `${opts.label}/${key}`;
182
+ if (!pulumiStepsAction(list))
183
+ unmapped++;
184
+ const declared = opts.declared.has(name);
185
+ const states = pulumiStepStates(list);
186
+ const parent = states.after?.parent ?? states.before?.parent;
187
+ const parentKey = typeof parent === "string" ? pulumiNodeKey(parent) : null;
188
+ if (parentKey !== null && parentKey !== key)
189
+ parents.set(name, `${opts.label}/${parentKey}`);
190
+ const inputs = declared ? {} : referenceProps({ type, id, inputs: states.after?.inputs ?? states.before?.inputs, outputs: states.before?.outputs });
191
+ resources[name] = {
192
+ type,
193
+ ...(id ? { physicalId: id } : {}),
194
+ status: declared ? "recorded" : PLANNED_STATUS,
195
+ // Never a verdict: a preview says what would run, not whose the resource is.
196
+ ownership: "unknown",
197
+ attributes: { ...inputs, ...attributes },
198
+ };
199
+ queried[name] = `${urn} (preview)`;
200
+ sources[name] = PREVIEW_SOURCE;
201
+ }
202
+ // The component that registered each node (#5403), when the graph will hold it.
203
+ for (const [name, parent] of parents) {
204
+ if (resources[parent] || opts.declared.has(parent))
205
+ resources[name].component = parent;
206
+ }
207
+ const unobserved = {};
208
+ for (const [name, entity] of opts.declared) {
209
+ if (resources[name])
210
+ continue;
211
+ unobserved[name] = {
212
+ type: entity.entityType,
213
+ reason: "not-reached",
214
+ detail: `the preview lists no step for ${name}; a preview narrowed with --target lists only its targets`,
215
+ };
216
+ }
217
+ return { resources, unobserved, queried, sources, unmapped };
218
+ }
@@ -135,7 +135,7 @@
135
135
  * `pr-env up` keeps on the environment's record and `pr-env down` and the
136
136
  * TTL sweep read back to destroy and remove it (`reviewStackTeardown`).
137
137
  */
138
- import type { Capability, DeclaredRead, DeclaredReadMember, DeclaredReadsContext, ReleaseInputs, ReleaseInputsContext, ReleaseInputsUnbound } from "@intentius/chant/components/capability";
138
+ import type { Capability, DeclaredRead, DeclaredReadMember, DeclaredReadsContext, GraphRead, ReleaseInputs, ReleaseInputsContext, ReleaseInputsUnbound } from "@intentius/chant/components/capability";
139
139
  import { type PlanShape } from "@intentius/chant/components/covered-round";
140
140
  import type { GatePolicyFindings } from "@intentius/chant/gate-policy";
141
141
  import type { SnapshotStore } from "@intentius/chant/lifecycle/snapshot-store";
@@ -236,6 +236,12 @@ export interface PulumiUpArtifact {
236
236
  scratch: string;
237
237
  /** plunge's saved plan. plunge only. */
238
238
  planFile?: string;
239
+ /**
240
+ * The preview as a JSON document (`steps`, `diagnostics`, `changeSummary`),
241
+ * in `scratch`, for a wave's cost hold to price as `{planJson}` (#5341).
242
+ * Both engines write it.
243
+ */
244
+ planJson?: string;
239
245
  /** The scratch copy of the stack's config, when the step has `config`. */
240
246
  configFile?: string;
241
247
  /** CrossGuard's findings from the plan's preview. */
@@ -376,9 +382,33 @@ export declare function pulumiReviewStep(input: PulumiUpStepInput, env: string |
376
382
  export declare function pulumiUpEngineBin(input: Pick<PulumiUpStepInput, "engineVersion" | "engineRoot">, engine: PulumiMemberEngine): string | undefined;
377
383
  /** When the exported stack last updated (#4617): `deployment.manifest.time`, when it is a time. */
378
384
  export declare function exportUpdatedAt(exported: unknown): string | undefined;
385
+ /** One step `StackReference` reads resolved: who reads, which stack, and the outputs the export recorded. */
386
+ export interface PulumiStackRead {
387
+ reader: string;
388
+ index: number;
389
+ ref: string;
390
+ /** The component that deploys the stack read, or the stack as `org/project/stack` (`project/stack` with no org named) when none does. */
391
+ target: {
392
+ upstream: string;
393
+ } | {
394
+ external: string;
395
+ };
396
+ /** Recorded outputs, secret ones left out (a secret one has no value to wire). */
397
+ outputs: string[];
398
+ /** Recorded outputs that are secret. Their names are read; no value is. */
399
+ secretOutputs: string[];
400
+ }
401
+ /**
402
+ * The one reader behind `declaredReads` (#4547) and `graphReads` (#5331):
403
+ * each step's `StackReference`s, read from its export (the index store's,
404
+ * else the checked-in one), each resolved to the one other `pulumi-up` step
405
+ * whose project and stack it names, else to the stack it names.
406
+ */
407
+ export declare function pulumiStackReads(ctx: DeclaredReadsContext, members: readonly DeclaredReadMember[], opts?: {
408
+ exportStore?: SnapshotStore | null;
409
+ }): Promise<PulumiStackRead[]>;
379
410
  /**
380
- * `declaredReads` (#4547): each step's `StackReference`s, read from its
381
- * export (the index store's, else the checked-in one), as reads of the one
411
+ * `declaredReads` (#4547): each step's `StackReference`s as reads of the one
382
412
  * other `pulumi-up` step whose project and stack the reference names, one
383
413
  * per output the export recorded that is not secret, placed at
384
414
  * `/stackReferences/<reference name>/<output>`.
@@ -386,6 +416,15 @@ export declare function exportUpdatedAt(exported: unknown): string | undefined;
386
416
  export declare function pulumiDeclaredReads(ctx: DeclaredReadsContext, members: readonly DeclaredReadMember[], opts?: {
387
417
  exportStore?: SnapshotStore | null;
388
418
  }): Promise<DeclaredRead[]>;
419
+ /**
420
+ * `graphReads` (#5331): the same reads, for `chant graph --components`. One
421
+ * per output the reference recorded, secret ones included by name, or one
422
+ * with no output when the export recorded none. A stack no `pulumi-up` step
423
+ * applies is `external`.
424
+ */
425
+ export declare function pulumiGraphReads(ctx: DeclaredReadsContext, members: readonly DeclaredReadMember[], opts?: {
426
+ exportStore?: SnapshotStore | null;
427
+ }): Promise<GraphRead[]>;
389
428
  /**
390
429
  * What a failed `up`'s stream still says (#4579): its `summaryEvent`, or,
391
430
  * when the engine stopped before printing one, the per-resource timings
@@ -397,4 +436,6 @@ export declare function failedUpSummary(stream: string): PulumiApplySummary | un
397
436
  export declare function pulumiReleaseInputs(input: PulumiUpStepInput, ctx: ReleaseInputsContext): ReleaseInputs | ReleaseInputsUnbound | null;
398
437
  /** The `pulumi-up` capability, with injectable runners for tests. */
399
438
  export declare function createPulumiUpCapability(opts?: PulumiUpOptions): Capability<PulumiUpStepInput, PulumiUpStepOutput>;
439
+ /** The outputs `pulumi stack output --show-secrets=false` printed as `[secret]` (#5345), sorted. */
440
+ export declare function pulumiSecretOutputNames(outputs: Record<string, unknown>): string[];
400
441
  export declare const pulumiUpCapability: Capability<PulumiUpStepInput, PulumiUpStepOutput>;
package/dist/pulumi-up.js CHANGED
@@ -538,6 +538,15 @@ async function planStack(ctx, original, opts) {
538
538
  throw err;
539
539
  }
540
540
  const planDigest = read.part.member.planDigest;
541
+ // #5341: the preview document beside the plan, which a wave's cost hold reads as {planJson}.
542
+ const planJson = join(files.scratch, `${fileSafe(r.member)}.preview.json`);
543
+ let wrotePreview = true;
544
+ try {
545
+ writeFileSync(planJson, JSON.stringify(read.preview), { mode: 0o600 });
546
+ }
547
+ catch {
548
+ wrotePreview = false;
549
+ }
541
550
  const references = stackReferencesOf(read.prior, input);
542
551
  const planned = pulumiMemberPlannedOutputs(r.member, {
543
552
  part: read.part,
@@ -556,6 +565,7 @@ async function planStack(ctx, original, opts) {
556
565
  shape: read.shape,
557
566
  scratch: files.scratch,
558
567
  ...(files.planFile ? { planFile: files.planFile } : {}),
568
+ ...(wrotePreview ? { planJson } : {}),
559
569
  ...(files.configFile ? { configFile: files.configFile } : {}),
560
570
  policy: read.policy,
561
571
  ...(packs.read ? { policyPacks: packs.read } : {}),
@@ -602,13 +612,12 @@ export function exportUpdatedAt(exported) {
602
612
  return typeof time === "string" && !Number.isNaN(Date.parse(time)) ? time : undefined;
603
613
  }
604
614
  /**
605
- * `declaredReads` (#4547): each step's `StackReference`s, read from its
606
- * export (the index store's, else the checked-in one), as reads of the one
607
- * other `pulumi-up` step whose project and stack the reference names, one
608
- * per output the export recorded that is not secret, placed at
609
- * `/stackReferences/<reference name>/<output>`.
615
+ * The one reader behind `declaredReads` (#4547) and `graphReads` (#5331):
616
+ * each step's `StackReference`s, read from its export (the index store's,
617
+ * else the checked-in one), each resolved to the one other `pulumi-up` step
618
+ * whose project and stack it names, else to the stack it names.
610
619
  */
611
- export async function pulumiDeclaredReads(ctx, members, opts = {}) {
620
+ export async function pulumiStackReads(ctx, members, opts = {}) {
612
621
  const steps = members
613
622
  .map((m) => {
614
623
  const step = m.step;
@@ -625,15 +634,54 @@ export async function pulumiDeclaredReads(ctx, members, opts = {}) {
625
634
  const exported = await memberExportOf(s.dir, { stack: s.step.stack, ...(opts.exportStore !== undefined ? { store: opts.exportStore } : {}) });
626
635
  for (const ref of pulumiStackReferences(exported)) {
627
636
  const found = stackReferenceOwner(ref, { component: s.m.component, project: s.project }, owners);
628
- if (!("owner" in found))
629
- continue;
630
- for (const output of ref.outputs) {
631
- out.push({ reader: s.m.component, index: s.m.index, upstream: found.owner.component, output, at: `/stackReferences/${pointerSegment(ref.name)}/${pointerSegment(output)}` });
632
- }
637
+ const stack = [ref.org, ref.project ?? s.project, ref.stack].filter((p) => p !== undefined).join("/");
638
+ out.push({
639
+ reader: s.m.component,
640
+ index: s.m.index,
641
+ ref: ref.name,
642
+ target: "owner" in found ? { upstream: found.owner.component } : { external: stack },
643
+ outputs: ref.outputs,
644
+ secretOutputs: ref.secretOutputs,
645
+ });
646
+ }
647
+ }
648
+ return out;
649
+ }
650
+ /**
651
+ * `declaredReads` (#4547): each step's `StackReference`s as reads of the one
652
+ * other `pulumi-up` step whose project and stack the reference names, one
653
+ * per output the export recorded that is not secret, placed at
654
+ * `/stackReferences/<reference name>/<output>`.
655
+ */
656
+ export async function pulumiDeclaredReads(ctx, members, opts = {}) {
657
+ const out = [];
658
+ for (const r of await pulumiStackReads(ctx, members, opts)) {
659
+ if (!("upstream" in r.target))
660
+ continue;
661
+ for (const output of r.outputs) {
662
+ out.push({ reader: r.reader, index: r.index, upstream: r.target.upstream, output, at: `/stackReferences/${pointerSegment(r.ref)}/${pointerSegment(output)}` });
633
663
  }
634
664
  }
635
665
  return out;
636
666
  }
667
+ /**
668
+ * `graphReads` (#5331): the same reads, for `chant graph --components`. One
669
+ * per output the reference recorded, secret ones included by name, or one
670
+ * with no output when the export recorded none. A stack no `pulumi-up` step
671
+ * applies is `external`.
672
+ */
673
+ export async function pulumiGraphReads(ctx, members, opts = {}) {
674
+ const out = [];
675
+ for (const r of await pulumiStackReads(ctx, members, opts)) {
676
+ const outputs = [...r.outputs, ...r.secretOutputs].sort();
677
+ const where = "upstream" in r.target ? { upstream: r.target.upstream } : { external: r.target.external };
678
+ if (outputs.length === 0)
679
+ out.push({ reader: r.reader, index: r.index, ...where });
680
+ for (const output of outputs)
681
+ out.push({ reader: r.reader, index: r.index, ...where, output });
682
+ }
683
+ return out;
684
+ }
637
685
  /** An `up` that exited non-zero, read through the exit-code table (#4553). */
638
686
  function upFailure(r, err, policy) {
639
687
  const f = pulumiRunFailure(err);
@@ -834,6 +882,13 @@ export function createPulumiUpCapability(opts = {}) {
834
882
  ...runnerOptions(r, opts),
835
883
  });
836
884
  },
885
+ // #5345: a secret prints as `[secret]` under --show-secrets=false: the engine's mark, which a replan keeps no digest of.
886
+ async markedOutputs(ctx, original) {
887
+ const { step: input } = pulumiReviewStep(original, ctx.env, templateOf(opts));
888
+ const r = resolveStep(input, opts);
889
+ const outputs = await pulumiMemberStackOutputs({ dir: r.dir, stack: input.stack, engine: r.engine, ...runnerOptions(r, opts) });
890
+ return { outputs, sensitive: pulumiSecretOutputNames(outputs) };
891
+ },
837
892
  releaseInputs: (input, ctx) => pulumiReleaseInputs(input, ctx),
838
893
  // #4552: resource on plunge, the stack (target) on stock Pulumi.
839
894
  defaultLockGrain(input) {
@@ -870,6 +925,11 @@ export function createPulumiUpCapability(opts = {}) {
870
925
  // #4555: the stack, the engine and the summary's counts, for the step's span and run record.
871
926
  traceFacts: (input, outcome) => pulumiTraceFacts(input, outcome),
872
927
  declaredReads: (ctx, members) => pulumiDeclaredReads(ctx, members, opts.snapshots !== undefined ? { exportStore: opts.snapshots } : {}),
928
+ graphReads: (ctx, members) => pulumiGraphReads(ctx, members, opts.snapshots !== undefined ? { exportStore: opts.snapshots } : {}),
873
929
  };
874
930
  }
931
+ /** The outputs `pulumi stack output --show-secrets=false` printed as `[secret]` (#5345), sorted. */
932
+ export function pulumiSecretOutputNames(outputs) {
933
+ return Object.keys(outputs).filter((name) => outputs[name] === "[secret]").sort();
934
+ }
875
935
  export const pulumiUpCapability = createPulumiUpCapability();
@@ -0,0 +1,84 @@
1
+ /**
2
+ * How the resources of a Pulumi stack name each other, as a `ReferenceCatalog`
3
+ * over the aws, gcp, azure and kubernetes providers (#5330).
4
+ *
5
+ * `chant workspace graph` runs each lexicon's catalog over the composed
6
+ * nodes (`packages/core/src/workspace/catalog-edges.ts`), and behold keeps
7
+ * its own name matcher for a lexicon that has none. This is the pulumi
8
+ * lexicon's, shaped like the terraform lexicon's
9
+ * (`../../terraform/src/behaviour/reference-catalog.ts`): rules grouped by
10
+ * the relation they produce, a short list of kinds known to reference
11
+ * nothing, and `identities` for what else names a kind.
12
+ *
13
+ * ## Shape
14
+ *
15
+ * A node's kind is the Pulumi type token (`aws:ec2/subnet:Subnet`), which is
16
+ * what the member read gives it (`./workspace-member.ts`). Its attrs are the
17
+ * resource's inputs as the stack export records them, in Pulumi's camelCase
18
+ * (`vpcId`, `networkConfiguration.subnets[]`), plus an `outputs` object
19
+ * holding its `id` and top-level string outputs (`outputs.arn`,
20
+ * `outputs.selfLink`), from `./reference-props.ts`. An export holds resolved
21
+ * values, so a reference reads as the physical id, ARN or name of its
22
+ * target, and the rules match that against the target's identities.
23
+ *
24
+ * ## Ids, ARNs and names
25
+ *
26
+ * Every target is identified by `outputs.id`, `outputs.arn`, `outputs.name`
27
+ * and the `name` input, with the extra names its provider uses
28
+ * ({@link EXTRA_IDS}): a bucket's `bucket`, a service account's `accountId`
29
+ * and `email`, a Kubernetes object's `metadata.name`. A rule names the kind
30
+ * it expects, so a name that two kinds share joins neither to the wrong one.
31
+ *
32
+ * ## Targets in other members
33
+ *
34
+ * A reference can name a resource that another member declares. The
35
+ * terraform lexicon identifies a few kinds by name (`aws_iam_role`,
36
+ * `aws_eks_cluster`, `aws_secretsmanager_secret`, `google_service_account`,
37
+ * `google_container_cluster`, `google_secret_manager_secret`,
38
+ * `azurerm_kubernetes_cluster`), and the k8s lexicon identifies its objects
39
+ * by `metadata.name`. A rule toward one of those has a second rule for the
40
+ * other lexicon's kind, under the same id, so a value that names a node of
41
+ * either is found and the other is not reported as missing. A Terraform
42
+ * block that names no identity (a VPC's id before it is applied) is not
43
+ * reachable by value; the edge appears once the id is on the node.
44
+ *
45
+ * ## Kubernetes
46
+ *
47
+ * A name is unique only inside its namespace. The namespaced kinds are
48
+ * `scopes` on `metadata.namespace`, and a pod spec's references to a service
49
+ * account, a ConfigMap or a Secret are `join` rules that look the name up in
50
+ * the holder's namespace across members, so a Deployment in this lexicon
51
+ * reaches a ServiceAccount of the k8s lexicon in the same namespace. A
52
+ * namespaced object also has an `in namespace` containment toward its
53
+ * `Namespace`, optional because most namespaces are created elsewhere.
54
+ *
55
+ * ## What "no rule" means
56
+ *
57
+ * A kind with no rule produces no edges. {@link REFERENCES_NOTHING} lists
58
+ * kinds looked at and found to hold no argument that identifies another
59
+ * resource, so {@link isUnresolvedKind} separates "nobody wrote a rule" from
60
+ * "there is nothing to find".
61
+ *
62
+ * ## Adding a rule
63
+ *
64
+ * A rule is one call to `rule` in the list for its provider: holder kind,
65
+ * input path, target kind or kinds, label. A target kind that others name
66
+ * goes in {@link EXTRA_IDS} or {@link NAMED_KINDS}. The test "each rule draws
67
+ * its edge" covers a new rule with no test of its own.
68
+ */
69
+ import { type ReferenceCatalog } from "@intentius/chant/graph-refs";
70
+ /**
71
+ * Pulumi kinds this catalog has looked at and found to hold no input that
72
+ * identifies another resource. A node of one of these kinds is not an
73
+ * unresolved kind: nothing was looked for because there is nothing to find.
74
+ */
75
+ export declare const REFERENCES_NOTHING: ReadonlySet<string>;
76
+ /** The catalog. Rules are grouped by provider; each provider lists containment before references. */
77
+ export declare const PULUMI_REFERENCE_CATALOG: ReferenceCatalog;
78
+ /** Every Pulumi kind the catalog has at least one rule from. */
79
+ export declare const CATALOGUED_KINDS: ReadonlySet<string>;
80
+ /**
81
+ * True when nothing would be looked for on a node of this kind: no rule is
82
+ * written for it, and it is not one of the kinds known to reference nothing.
83
+ */
84
+ export declare function isUnresolvedKind(kind: string): boolean;