@intentius/chant-lexicon-pulumi 0.124.97 → 0.124.99

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 (316) hide show
  1. package/dist/adopt.d.ts +0 -1
  2. package/dist/capability-plugin.d.ts +0 -1
  3. package/dist/change-set.d.ts +0 -1
  4. package/dist/changed-units.d.ts +0 -1
  5. package/dist/check-step.d.ts +0 -1
  6. package/dist/ci-setup.d.ts +0 -1
  7. package/dist/codegen/docs-cli.d.ts +0 -1
  8. package/dist/codegen/docs.d.ts +0 -1
  9. package/dist/codegen/package.d.ts +0 -1
  10. package/dist/composites/pulumi-adopt-op.d.ts +0 -1
  11. package/dist/composites/pulumi-watch-op.d.ts +0 -1
  12. package/dist/config.d.ts +0 -1
  13. package/dist/describe-resources.d.ts +0 -1
  14. package/dist/drift-read.d.ts +0 -1
  15. package/dist/drift-record.d.ts +0 -1
  16. package/dist/engine-events.d.ts +0 -1
  17. package/dist/engine-graph.d.ts +0 -1
  18. package/dist/exit-codes.d.ts +0 -1
  19. package/dist/index.d.ts +0 -1
  20. package/dist/init-templates.d.ts +0 -1
  21. package/dist/integrity.json +2 -2
  22. package/dist/lint/audit-catalog.d.ts +0 -1
  23. package/dist/lint/post-synth/index.d.ts +0 -1
  24. package/dist/lint/post-synth/member-read-helpers.d.ts +0 -1
  25. package/dist/lint/post-synth/pul001.d.ts +0 -1
  26. package/dist/lint/post-synth/pul002.d.ts +0 -1
  27. package/dist/lint/post-synth/pul003.d.ts +0 -1
  28. package/dist/lint/post-synth/pul004.d.ts +0 -1
  29. package/dist/lint/post-synth/pul005.d.ts +0 -1
  30. package/dist/lint/post-synth/pul006.d.ts +0 -1
  31. package/dist/lint/post-synth/pul007.d.ts +0 -1
  32. package/dist/lint/post-synth/pul008.d.ts +0 -1
  33. package/dist/lint/post-synth/pul009.d.ts +0 -1
  34. package/dist/lint/post-synth/pul010.d.ts +0 -1
  35. package/dist/lint/post-synth/pul011.d.ts +0 -1
  36. package/dist/lint/post-synth/pul012.d.ts +0 -1
  37. package/dist/lint/post-synth/pul013.d.ts +0 -1
  38. package/dist/lint/post-synth/pul014.d.ts +0 -1
  39. package/dist/lint/post-synth/pul015.d.ts +0 -1
  40. package/dist/lint/rules/index.d.ts +0 -1
  41. package/dist/lint/rules/member-dir-absolute.d.ts +0 -1
  42. package/dist/lock-rows.d.ts +0 -1
  43. package/dist/lsp/completions.d.ts +0 -1
  44. package/dist/lsp/documents.d.ts +0 -1
  45. package/dist/lsp/hover.d.ts +0 -1
  46. package/dist/lsp/keys.d.ts +0 -1
  47. package/dist/lsp/object-path.d.ts +0 -1
  48. package/dist/lsp/yaml-cursor.d.ts +0 -1
  49. package/dist/manifest.json +1 -1
  50. package/dist/member-engine.d.ts +0 -1
  51. package/dist/member-outputs.d.ts +0 -1
  52. package/dist/op/activities/index.d.ts +0 -1
  53. package/dist/op/activities/pulumi-adopt.d.ts +0 -1
  54. package/dist/op/activities/pulumi.d.ts +0 -1
  55. package/dist/op/activity-contracts.d.ts +0 -1
  56. package/dist/op/builders.d.ts +0 -1
  57. package/dist/package-cli.d.ts +0 -1
  58. package/dist/plan-shape.d.ts +0 -1
  59. package/dist/planned-output-changes.d.ts +0 -1
  60. package/dist/plugin.d.ts +0 -1
  61. package/dist/plunge-timings.d.ts +0 -1
  62. package/dist/preview-tips.d.ts +0 -1
  63. package/dist/pulumi-up.d.ts +0 -1
  64. package/dist/release-copy.d.ts +0 -1
  65. package/dist/review-stack.d.ts +0 -1
  66. package/dist/run.d.ts +0 -1
  67. package/dist/serializer.d.ts +0 -1
  68. package/dist/stack-export-snapshot.d.ts +0 -1
  69. package/dist/stack-ops.d.ts +0 -1
  70. package/dist/stack-outputs.d.ts +0 -1
  71. package/dist/stack-references.d.ts +0 -1
  72. package/dist/trace-facts.d.ts +0 -1
  73. package/dist/values.d.ts +0 -1
  74. package/dist/workspace-member.d.ts +0 -1
  75. package/package.json +3 -4
  76. package/dist/adopt.d.ts.map +0 -1
  77. package/dist/capability-plugin.d.ts.map +0 -1
  78. package/dist/change-set.d.ts.map +0 -1
  79. package/dist/changed-units.d.ts.map +0 -1
  80. package/dist/check-step.d.ts.map +0 -1
  81. package/dist/ci-setup.d.ts.map +0 -1
  82. package/dist/codegen/docs-cli.d.ts.map +0 -1
  83. package/dist/codegen/docs.d.ts.map +0 -1
  84. package/dist/codegen/package.d.ts.map +0 -1
  85. package/dist/composites/pulumi-adopt-op.d.ts.map +0 -1
  86. package/dist/composites/pulumi-watch-op.d.ts.map +0 -1
  87. package/dist/config.d.ts.map +0 -1
  88. package/dist/describe-resources.d.ts.map +0 -1
  89. package/dist/drift-read.d.ts.map +0 -1
  90. package/dist/drift-record.d.ts.map +0 -1
  91. package/dist/engine-events.d.ts.map +0 -1
  92. package/dist/engine-graph.d.ts.map +0 -1
  93. package/dist/exit-codes.d.ts.map +0 -1
  94. package/dist/index.d.ts.map +0 -1
  95. package/dist/init-templates.d.ts.map +0 -1
  96. package/dist/lint/audit-catalog.d.ts.map +0 -1
  97. package/dist/lint/post-synth/index.d.ts.map +0 -1
  98. package/dist/lint/post-synth/member-read-helpers.d.ts.map +0 -1
  99. package/dist/lint/post-synth/pul001.d.ts.map +0 -1
  100. package/dist/lint/post-synth/pul002.d.ts.map +0 -1
  101. package/dist/lint/post-synth/pul003.d.ts.map +0 -1
  102. package/dist/lint/post-synth/pul004.d.ts.map +0 -1
  103. package/dist/lint/post-synth/pul005.d.ts.map +0 -1
  104. package/dist/lint/post-synth/pul006.d.ts.map +0 -1
  105. package/dist/lint/post-synth/pul007.d.ts.map +0 -1
  106. package/dist/lint/post-synth/pul008.d.ts.map +0 -1
  107. package/dist/lint/post-synth/pul009.d.ts.map +0 -1
  108. package/dist/lint/post-synth/pul010.d.ts.map +0 -1
  109. package/dist/lint/post-synth/pul011.d.ts.map +0 -1
  110. package/dist/lint/post-synth/pul012.d.ts.map +0 -1
  111. package/dist/lint/post-synth/pul013.d.ts.map +0 -1
  112. package/dist/lint/post-synth/pul014.d.ts.map +0 -1
  113. package/dist/lint/post-synth/pul015.d.ts.map +0 -1
  114. package/dist/lint/rules/index.d.ts.map +0 -1
  115. package/dist/lint/rules/member-dir-absolute.d.ts.map +0 -1
  116. package/dist/lock-rows.d.ts.map +0 -1
  117. package/dist/lsp/completions.d.ts.map +0 -1
  118. package/dist/lsp/documents.d.ts.map +0 -1
  119. package/dist/lsp/hover.d.ts.map +0 -1
  120. package/dist/lsp/keys.d.ts.map +0 -1
  121. package/dist/lsp/object-path.d.ts.map +0 -1
  122. package/dist/lsp/yaml-cursor.d.ts.map +0 -1
  123. package/dist/member-engine.d.ts.map +0 -1
  124. package/dist/member-outputs.d.ts.map +0 -1
  125. package/dist/op/activities/index.d.ts.map +0 -1
  126. package/dist/op/activities/pulumi-adopt.d.ts.map +0 -1
  127. package/dist/op/activities/pulumi.d.ts.map +0 -1
  128. package/dist/op/activity-contracts.d.ts.map +0 -1
  129. package/dist/op/builders.d.ts.map +0 -1
  130. package/dist/package-cli.d.ts.map +0 -1
  131. package/dist/plan-shape.d.ts.map +0 -1
  132. package/dist/planned-output-changes.d.ts.map +0 -1
  133. package/dist/plugin.d.ts.map +0 -1
  134. package/dist/plunge-timings.d.ts.map +0 -1
  135. package/dist/preview-tips.d.ts.map +0 -1
  136. package/dist/pulumi-up.d.ts.map +0 -1
  137. package/dist/release-copy.d.ts.map +0 -1
  138. package/dist/review-stack.d.ts.map +0 -1
  139. package/dist/run.d.ts.map +0 -1
  140. package/dist/serializer.d.ts.map +0 -1
  141. package/dist/stack-export-snapshot.d.ts.map +0 -1
  142. package/dist/stack-ops.d.ts.map +0 -1
  143. package/dist/stack-outputs.d.ts.map +0 -1
  144. package/dist/stack-references.d.ts.map +0 -1
  145. package/dist/trace-facts.d.ts.map +0 -1
  146. package/dist/values.d.ts.map +0 -1
  147. package/dist/workspace-member.d.ts.map +0 -1
  148. package/src/adopt.ts +0 -202
  149. package/src/capability-plugin.ts +0 -34
  150. package/src/change-set.test.ts +0 -245
  151. package/src/change-set.ts +0 -508
  152. package/src/changed-units.test.ts +0 -87
  153. package/src/changed-units.ts +0 -96
  154. package/src/check-step.test.ts +0 -191
  155. package/src/check-step.ts +0 -316
  156. package/src/ci-setup.test.ts +0 -234
  157. package/src/ci-setup.ts +0 -224
  158. package/src/codegen/docs-cli.ts +0 -4
  159. package/src/codegen/docs.ts +0 -58
  160. package/src/codegen/package.ts +0 -63
  161. package/src/composites/pulumi-adopt-op.test.ts +0 -258
  162. package/src/composites/pulumi-adopt-op.ts +0 -193
  163. package/src/composites/pulumi-watch-op.test.ts +0 -42
  164. package/src/composites/pulumi-watch-op.ts +0 -85
  165. package/src/config.ts +0 -43
  166. package/src/describe-resources.test.ts +0 -112
  167. package/src/describe-resources.ts +0 -118
  168. package/src/drift-read.test.ts +0 -178
  169. package/src/drift-read.ts +0 -94
  170. package/src/drift-record.test.ts +0 -197
  171. package/src/drift-record.ts +0 -326
  172. package/src/engine-events.test.ts +0 -160
  173. package/src/engine-events.ts +0 -395
  174. package/src/engine-graph.test.ts +0 -141
  175. package/src/engine-graph.ts +0 -149
  176. package/src/exit-codes.test.ts +0 -21
  177. package/src/exit-codes.ts +0 -71
  178. package/src/index.ts +0 -139
  179. package/src/init-templates.ts +0 -85
  180. package/src/lint/audit-catalog.test.ts +0 -33
  181. package/src/lint/audit-catalog.ts +0 -174
  182. package/src/lint/post-synth/index.ts +0 -35
  183. package/src/lint/post-synth/member-read-helpers.ts +0 -122
  184. package/src/lint/post-synth/post-synth.test.ts +0 -245
  185. package/src/lint/post-synth/pul001.ts +0 -38
  186. package/src/lint/post-synth/pul002.ts +0 -38
  187. package/src/lint/post-synth/pul003.ts +0 -43
  188. package/src/lint/post-synth/pul004.ts +0 -32
  189. package/src/lint/post-synth/pul005.ts +0 -31
  190. package/src/lint/post-synth/pul006.ts +0 -31
  191. package/src/lint/post-synth/pul007.ts +0 -35
  192. package/src/lint/post-synth/pul008.ts +0 -35
  193. package/src/lint/post-synth/pul009.ts +0 -32
  194. package/src/lint/post-synth/pul010.ts +0 -42
  195. package/src/lint/post-synth/pul011.ts +0 -38
  196. package/src/lint/post-synth/pul012.ts +0 -35
  197. package/src/lint/post-synth/pul013.ts +0 -35
  198. package/src/lint/post-synth/pul014.ts +0 -32
  199. package/src/lint/post-synth/pul015.ts +0 -39
  200. package/src/lint/rules/index.ts +0 -7
  201. package/src/lint/rules/member-dir-absolute.test.ts +0 -37
  202. package/src/lint/rules/member-dir-absolute.ts +0 -83
  203. package/src/lock-rows.test.ts +0 -60
  204. package/src/lock-rows.ts +0 -56
  205. package/src/lsp/completions.test.ts +0 -69
  206. package/src/lsp/completions.ts +0 -119
  207. package/src/lsp/documents.ts +0 -48
  208. package/src/lsp/hover.test.ts +0 -56
  209. package/src/lsp/hover.ts +0 -83
  210. package/src/lsp/keys.ts +0 -169
  211. package/src/lsp/object-path.ts +0 -71
  212. package/src/lsp/yaml-cursor.ts +0 -85
  213. package/src/member-engine.test.ts +0 -112
  214. package/src/member-engine.ts +0 -97
  215. package/src/member-outputs.test.ts +0 -339
  216. package/src/member-outputs.ts +0 -157
  217. package/src/op/activities/index.ts +0 -36
  218. package/src/op/activities/pulumi-adopt.ts +0 -345
  219. package/src/op/activities/pulumi.ts +0 -136
  220. package/src/op/activity-contracts.ts +0 -129
  221. package/src/op/builders.ts +0 -67
  222. package/src/package-cli.ts +0 -14
  223. package/src/plan-shape.test.ts +0 -91
  224. package/src/plan-shape.ts +0 -105
  225. package/src/planned-output-changes.test.ts +0 -85
  226. package/src/planned-output-changes.ts +0 -141
  227. package/src/plugin.test.ts +0 -96
  228. package/src/plugin.ts +0 -272
  229. package/src/plunge-timings.test.ts +0 -241
  230. package/src/plunge-timings.ts +0 -115
  231. package/src/plunge-up-failed.test.ts +0 -54
  232. package/src/pr-note.test.ts +0 -87
  233. package/src/preview-generated.test.ts +0 -124
  234. package/src/preview-tips.test.ts +0 -134
  235. package/src/preview-tips.ts +0 -128
  236. package/src/pulumi-up.test.ts +0 -581
  237. package/src/pulumi-up.ts +0 -1102
  238. package/src/pulumi-urn-node.test.ts +0 -94
  239. package/src/release-copy.test.ts +0 -162
  240. package/src/release-copy.ts +0 -223
  241. package/src/review-stack.test.ts +0 -254
  242. package/src/review-stack.ts +0 -266
  243. package/src/run-plan-flags.test.ts +0 -53
  244. package/src/run.test.ts +0 -540
  245. package/src/run.ts +0 -1129
  246. package/src/serializer.test.ts +0 -9
  247. package/src/serializer.ts +0 -15
  248. package/src/skills/chant-pulumi-plunge.md +0 -51
  249. package/src/skills/chant-pulumi-stack-export.md +0 -54
  250. package/src/skills/chant-pulumi.md +0 -83
  251. package/src/stack-export-snapshot.test.ts +0 -192
  252. package/src/stack-export-snapshot.ts +0 -312
  253. package/src/stack-ops.fake-binary.test.ts +0 -323
  254. package/src/stack-ops.test.ts +0 -511
  255. package/src/stack-ops.ts +0 -1082
  256. package/src/stack-outputs.ts +0 -66
  257. package/src/stack-references.test.ts +0 -96
  258. package/src/stack-references.ts +0 -110
  259. package/src/testdata/plunge-drift/README.md +0 -10
  260. package/src/testdata/plunge-drift/assets-drifted.ndjson +0 -3
  261. package/src/testdata/plunge-drift/component-unsupported.ndjson +0 -3
  262. package/src/testdata/plunge-drift/role-in-sync.ndjson +0 -3
  263. package/src/testdata/plunge-drift/settled-empty.ndjson +0 -2
  264. package/src/testdata/plunge-graph/Pulumi.yaml +0 -4
  265. package/src/testdata/plunge-graph/README.md +0 -12
  266. package/src/testdata/plunge-graph/engine-graph.json +0 -158
  267. package/src/testdata/plunge-graph/stack-export.json +0 -49
  268. package/src/testdata/plunge-member/Pulumi.yaml +0 -4
  269. package/src/testdata/plunge-member/README.md +0 -3
  270. package/src/testdata/plunge-member/stack-export.json +0 -480
  271. package/src/testdata/plunge-outputs/Pulumi.yaml +0 -9
  272. package/src/testdata/plunge-outputs/README.md +0 -7
  273. package/src/testdata/plunge-outputs/stack-export.json +0 -2003
  274. package/src/testdata/plunge-outputs/stack-output.json +0 -19
  275. package/src/testdata/pulumi-member/Pulumi.yaml +0 -2
  276. package/src/testdata/pulumi-member/README.md +0 -50
  277. package/src/testdata/pulumi-member/recording/Pulumi.dev.yaml +0 -19
  278. package/src/testdata/pulumi-member/recording/Pulumi.yaml +0 -7
  279. package/src/testdata/pulumi-member/recording/index.js +0 -47
  280. package/src/testdata/pulumi-member/recording/package-lock.json +0 -2707
  281. package/src/testdata/pulumi-member/recording/package.json +0 -9
  282. package/src/testdata/pulumi-member/stack-export.json +0 -746
  283. package/src/testdata/pulumi-outputs/Pulumi.yaml +0 -7
  284. package/src/testdata/pulumi-outputs/README.md +0 -9
  285. package/src/testdata/pulumi-outputs/preview-replaced.json +0 -2894
  286. package/src/testdata/pulumi-outputs/preview-settled.json +0 -2894
  287. package/src/testdata/pulumi-outputs/stack-export.json +0 -1919
  288. package/src/testdata/pulumi-outputs/stack-output.json +0 -19
  289. package/src/testdata/pulumi-preview/Pulumi.yaml +0 -7
  290. package/src/testdata/pulumi-preview/README.md +0 -9
  291. package/src/testdata/pulumi-preview/preview-create.json +0 -992
  292. package/src/testdata/pulumi-preview/preview.json +0 -2894
  293. package/src/testdata/pulumi-preview/stack-export.json +0 -1919
  294. package/src/testdata/pulumi-refresh/Pulumi.yaml +0 -7
  295. package/src/testdata/pulumi-refresh/README.md +0 -14
  296. package/src/testdata/pulumi-refresh/all.json +0 -3742
  297. package/src/testdata/pulumi-refresh/bucket-edited.json +0 -468
  298. package/src/testdata/pulumi-refresh/policy-deleted.json +0 -95
  299. package/src/testdata/pulumi-refresh/queue-edited.json +0 -250
  300. package/src/testdata/pulumi-refresh/role-same.json +0 -242
  301. package/src/testdata/pulumi-refresh/secret-edited.json +0 -247
  302. package/src/testdata/pulumi-refresh/stack-export.json +0 -1907
  303. package/src/testdata/pulumi-stream/README.md +0 -16
  304. package/src/testdata/pulumi-stream/preview-stream.ndjson +0 -42
  305. package/src/testdata/pulumi-stream/up-failed-plunge.ndjson +0 -5
  306. package/src/testdata/pulumi-unexported/Pulumi.yaml +0 -2
  307. package/src/testdata/pulumi-urn-node/Pulumi.yaml +0 -7
  308. package/src/testdata/pulumi-urn-node/README.md +0 -9
  309. package/src/testdata/pulumi-urn-node/preview.json +0 -2894
  310. package/src/testdata/pulumi-urn-node/stack-export.json +0 -1919
  311. package/src/trace-facts.test.ts +0 -38
  312. package/src/trace-facts.ts +0 -83
  313. package/src/values.ts +0 -147
  314. package/src/workspace-kinds.test.ts +0 -47
  315. package/src/workspace-member.test.ts +0 -127
  316. package/src/workspace-member.ts +0 -304
@@ -1,197 +0,0 @@
1
- /**
2
- * The Pulumi drift adapter (#4453): `pulumi refresh --preview-only --json
3
- * --target <urn>` into drift records, read `refresh`.
4
- *
5
- * The documents in `testdata/pulumi-refresh` are recorded (#4475, see its
6
- * README): pulumi 3.272.0 against the plunge corpus's aws-ts stack on floci,
7
- * after four out-of-band edits through floci's own API: a tag on the site
8
- * bucket changed, the bucket policy deleted, the SecureString parameter
9
- * overwritten (floci drops its tags when it does) and the events queue's
10
- * retention lowered. `stack-export.json` is the stack before the edits.
11
- * Nothing here runs Pulumi.
12
- */
13
- import { readFileSync } from "node:fs";
14
- import { join } from "node:path";
15
- import { describe, expect, test } from "vitest";
16
- import { driftDocument } from "@intentius/chant/drift-record";
17
- import { contract } from "../../../packages/core/src/workspace/__fixtures__/contract-repo";
18
- import schema from "../../../packages/core/src/workspace/drift.schema.json";
19
- import { plungeDriftArgs, plungeDriftStreamRecords, pulumiRefreshArgs, pulumiRefreshDocumentRecords, pulumiRefreshDriftRecords } from "./drift-record";
20
- import { readPulumiMember } from "./workspace-member";
21
-
22
- const dir = join(import.meta.dirname, "testdata", "pulumi-refresh");
23
- const read = (name: string): unknown => JSON.parse(readFileSync(join(dir, name), "utf-8"));
24
- const urn = (type: string, name: string) => `urn:pulumi:floci::corpus-aws-ts::${type}::${name}`;
25
- const BUCKET = urn("aws:s3/bucket:Bucket", "site-bucket");
26
- const ROLE = urn("aws:iam/role:Role", "app-role");
27
- const GONE = urn("aws:s3/bucketPolicy:BucketPolicy", "site-bucket-policy");
28
- const DBPW = urn("aws:ssm/parameter:Parameter", "db-password");
29
- const EVENTS = urn("aws:sqs/queue:Queue", "events");
30
- const ASSETS = urn("corpus:index:Site$aws:s3/bucket:Bucket", "docs-assets");
31
-
32
- const observedAt = "2026-10-26T05:30:00Z";
33
- // The member graph of the recorded export: node keys ignore stack and project.
34
- const graph = { member: null, at: null, ids: [...readPulumiMember({ member: { dir, label: "site" } }).entities.keys()] };
35
-
36
- const { expectValid } = contract(schema);
37
-
38
- function records() {
39
- return pulumiRefreshDriftRecords({
40
- member: "site",
41
- observedAt,
42
- graph,
43
- stack: "floci",
44
- reads: [
45
- { urn: BUCKET, refresh: read("bucket-edited.json") },
46
- { urn: ROLE, refresh: read("role-same.json") },
47
- { urn: GONE, refresh: read("policy-deleted.json") },
48
- { urn: DBPW, refresh: read("secret-edited.json") },
49
- { urn: EVENTS, refresh: read("queue-edited.json") },
50
- ],
51
- });
52
- }
53
- const at = (address: string) => records().find((r) => r.address === address)!;
54
-
55
- describe("pulumi refresh --preview-only --json to drift records (#4453)", () => {
56
- test("the argv: one resource, preview only, JSON", () => {
57
- expect(pulumiRefreshArgs({ urn: BUCKET, stack: "floci" })).toEqual(["refresh", "--preview-only", "--json", "--stack", "floci", "--target", BUCKET]);
58
- expect(pulumiRefreshArgs()).toEqual(["refresh", "--preview-only", "--json"]);
59
- });
60
-
61
- test("an out-of-band edit yields a drifted record with the detailedDiff paths, state before, provider after", () => {
62
- const bucket = at(BUCKET);
63
- expect(bucket).toMatchObject({
64
- member: "site",
65
- engine: "pulumi",
66
- address: BUCKET,
67
- resourceType: "aws:s3/bucket:Bucket",
68
- node: "site/aws:s3/bucket:Bucket::site-bucket",
69
- observedAt,
70
- read: "refresh",
71
- status: "drifted",
72
- evidence: { tool: "pulumi", command: `pulumi refresh --preview-only --json --stack floci --target ${BUCKET}`, engineCode: "update" },
73
- });
74
- // Pulumi's property paths as printed. The provider also names replicationConfiguration.role, null on both sides.
75
- expect(bucket.attributes).toEqual([
76
- { path: "replicationConfiguration.role" },
77
- { path: 'tagsAll["corpus-owner"]', before: "plunge", after: "hotfix" },
78
- { path: 'tags["corpus-owner"]', before: "plunge", after: "hotfix" },
79
- ]);
80
- expect(at(EVENTS).attributes).toEqual([{ path: "messageRetentionSeconds", before: 3600, after: 600 }]);
81
- });
82
-
83
- test("an unchanged resource prints a refresh step and is in-sync; a delete is missing", () => {
84
- expect(at(ROLE)).toMatchObject({ status: "in-sync", node: "site/aws:iam/role:Role::app-role", evidence: { engineCode: "refresh" } });
85
- expect(at(ROLE).attributes).toBeUndefined();
86
- expect(at(GONE)).toMatchObject({ status: "missing", node: "site/aws:s3/bucketPolicy:BucketPolicy::site-bucket-policy", evidence: { engineCode: "delete" } });
87
- });
88
-
89
- test("a blinded secret is sensitive, with neither side; a path only the inputs hold reads the inputs", () => {
90
- expect(at(DBPW).status).toBe("drifted");
91
- expect(at(DBPW).attributes).toEqual([
92
- { path: 'tagsAll["corpus-owner"]', before: "plunge" },
93
- { path: 'tagsAll["corpus-program"]', before: "aws-ts" },
94
- { path: 'tags["corpus-owner"]', before: "plunge" },
95
- { path: 'tags["corpus-program"]', before: "aws-ts" },
96
- { path: "value", sensitive: true },
97
- { path: "version", before: 1, after: 2 },
98
- ]);
99
- expect(JSON.stringify(at(DBPW))).not.toContain("[secret]");
100
- });
101
-
102
- test("a refresh step with both states and no diff is compared on its outputs", () => {
103
- // Derived from the recorded role-same.json: the same refresh step with one output moved.
104
- const doc = JSON.parse(JSON.stringify(read("role-same.json"))) as { steps: { newState: { outputs: Record<string, unknown> } }[] };
105
- doc.steps[0].newState.outputs.maxSessionDuration = 7200;
106
- const [moved] = pulumiRefreshDriftRecords({ member: "site", observedAt, graph, reads: [{ urn: ROLE, refresh: doc }] });
107
- expect(moved.status).toBe("drifted");
108
- expect(moved.attributes).toEqual([{ path: "maxSessionDuration", before: 3600, after: 7200 }]);
109
- });
110
-
111
- test("a target the refresh printed nothing for is not-reached; a failed run carries its reason", () => {
112
- // Records come back sorted by address, so the role (aws:iam) is first.
113
- const [failed, none] = pulumiRefreshDriftRecords({
114
- member: "site",
115
- observedAt,
116
- reads: [
117
- { urn: BUCKET, refresh: read("role-same.json") },
118
- { urn: ROLE, failed: { reason: "no-credentials", detail: "error: no credentials" } },
119
- ],
120
- });
121
- expect(none).toMatchObject({ address: BUCKET, status: "not-observed", unobserved: { reason: "not-reached", queried: BUCKET } });
122
- expect(failed).toMatchObject({ address: ROLE, status: "not-observed", unobserved: { reason: "no-credentials", detail: "error: no credentials", queried: ROLE } });
123
- expect(failed.node).toBeNull();
124
- });
125
-
126
- test("records are sorted by address and make a valid drift document", () => {
127
- const list = records();
128
- expect(list.map((r) => r.address)).toEqual([...list.map((r) => r.address)].sort());
129
- const doc = driftDocument(list);
130
- expectValid(doc);
131
- expect(doc.counts).toMatchObject({ drifted: 3, "in-sync": 1, missing: 1 });
132
- });
133
-
134
- test("an untargeted refresh gives a record per resource, the stack and providers left out", () => {
135
- const list = pulumiRefreshDocumentRecords({ member: "site", observedAt, refresh: read("all.json") });
136
- expect(list).toHaveLength(15);
137
- expect(list.filter((r) => r.status !== "in-sync").map((r) => [r.address, r.status])).toEqual(
138
- [
139
- [DBPW, "drifted"],
140
- [urn("aws:ssm/parameter:Parameter", "vpc-id"), "drifted"],
141
- [GONE, "missing"],
142
- [EVENTS, "drifted"],
143
- [BUCKET, "drifted"],
144
- ].sort((a, b) => (a[0] < b[0] ? -1 : 1)),
145
- );
146
- expect(list[0].evidence.command).toBe("pulumi refresh --preview-only --json");
147
- expect(() => pulumiRefreshDocumentRecords({ member: "site", observedAt, refresh: {} })).toThrow(/no top-level "steps"/);
148
- });
149
- });
150
-
151
- describe("a member on plunge: plunge drift --resource <urn> --stream through chant's decoder (#4453)", () => {
152
- // Recorded from plunge v0.1.0-dev.0 (pulumi 3.272.0 compatible) on floci; settled-empty.ndjson is derived (README).
153
- const stream = (name: string) => readFileSync(join(import.meta.dirname, "testdata", "plunge-drift", name), "utf-8");
154
-
155
- test("the argv: one resource, streamed", () => {
156
- expect(plungeDriftArgs({ urn: ASSETS, stack: "floci", member: "site" })).toEqual(["drift", "--resource", ASSETS, "--stream", "--stack", "floci", "--member", "site"]);
157
- });
158
-
159
- test("the stream's records keep plunge's verdict and get their node from the URN rule", () => {
160
- const list = plungeDriftStreamRecords({
161
- member: "site",
162
- observedAt,
163
- graph,
164
- reads: [
165
- { urn: ASSETS, stream: stream("assets-drifted.ndjson") },
166
- { urn: ROLE, stream: stream("role-in-sync.ndjson") },
167
- ],
168
- });
169
- expect(list.map((r) => [r.address, r.engine, r.read, r.status, r.node])).toEqual([
170
- [ROLE, "plunge", "refresh", "in-sync", "site/aws:iam/role:Role::app-role"],
171
- [ASSETS, "plunge", "refresh", "drifted", "site/corpus:index:Site$aws:s3/bucket:Bucket::docs-assets"],
172
- ]);
173
- expect(list.find((r) => r.address === ASSETS)!.attributes).toEqual([
174
- { path: 'tagsAll["corpus-owner"]', before: "plunge", after: "hotfix" },
175
- { path: 'tags["corpus-owner"]', before: "plunge", after: "hotfix" },
176
- ]);
177
- expect(list.find((r) => r.address === ASSETS)!.evidence).toMatchObject({ tool: "plunge", version: "v0.1.0-dev.0" });
178
- expectValid(driftDocument(list));
179
- });
180
-
181
- test("a stream that settles without the URN is not-reached; one that does not decode, or a failed run, is not-observed", () => {
182
- const [empty] = plungeDriftStreamRecords({ member: "site", observedAt, graph, reads: [{ urn: ROLE, stream: stream("settled-empty.ndjson") }] });
183
- expect(empty).toMatchObject({ address: ROLE, engine: "plunge", status: "not-observed", unobserved: { reason: "not-reached" }, node: "site/aws:iam/role:Role::app-role" });
184
- // Sorted by address: the role (aws:iam) before the bucket (corpus:index).
185
- const [failed, garbled] = plungeDriftStreamRecords({
186
- member: "site",
187
- observedAt,
188
- reads: [
189
- { urn: ASSETS, stream: "not json\n" },
190
- // What plunge prints for a URN the stack holds no record for, exit 1 (recorded).
191
- { urn: ROLE, failed: { reason: "read-failed", detail: "error: plunge: the stack holds no record for " + ROLE } },
192
- ],
193
- });
194
- expect(garbled).toMatchObject({ address: ASSETS, status: "not-observed", unobserved: { reason: "read-failed", detail: expect.stringMatching(/did not decode/) } });
195
- expect(failed).toMatchObject({ address: ROLE, status: "not-observed", unobserved: { reason: "read-failed", detail: expect.stringMatching(/holds no record/) } });
196
- });
197
- });
@@ -1,326 +0,0 @@
1
- /**
2
- * The drift adapter for a Pulumi member (#4453): `pulumi refresh
3
- * --preview-only --json` into `@intentius/chant/drift-record` records, read
4
- * `refresh`, engine `pulumi`.
5
- *
6
- * A refresh preview reads each resource from its provider and says how it
7
- * differs from the stack's state, without writing the state. chant narrows it
8
- * to one resource with `--target <urn>`, so one slow or failing resource
9
- * holds back only its own record, and a stream can send each record as its
10
- * read finishes. {@link pulumiRefreshDriftRecords} takes one read per URN;
11
- * {@link pulumiRefreshDocumentRecords} takes one untargeted refresh and makes
12
- * a record per resource in it.
13
- *
14
- * | step | status |
15
- * |---|---|
16
- * | `same` | in-sync |
17
- * | `update` | drifted, a path per `detailedDiff` key (else per `diffReasons` key, else per output that differs) |
18
- * | `delete` | missing |
19
- * | `refresh` | by its states: no new state, or one marked `delete`, is missing; outputs that differ are drifted; else in-sync |
20
- * | anything else | not-observed, `read-failed`, the op in `evidence.engineCode` |
21
- * | no step for the target | not-observed, `not-reached` |
22
- * | the run failed | not-observed, with the reason the runner gave |
23
- *
24
- * `before` is what the state recorded and `after` what the provider read.
25
- * A path whose `detailedDiff` says `inputDiff` reads the inputs, any other
26
- * the outputs, then the inputs when neither output side holds it. Paths are
27
- * Pulumi's property paths as it prints them (`tags["corpus-owner"]`). A value that is or holds a secret, on either side, is
28
- * `sensitive: true` with neither value; the record constructor's key-name
29
- * pass runs after. The URN is the record's `address`, and its `node` the one
30
- * URN rule's (`@intentius/chant/pulumi-urn`, #4456) through the change set's
31
- * `pulumi` planner. Providers and the root stack are not resources anyone
32
- * drifts and get no record.
33
- *
34
- * The design record (#4450) takes the step ops as `same`, `update` and
35
- * `delete`. Recorded against the plunge corpus on floci (pulumi 3.272.0,
36
- * #4475, fixtures in `testdata/pulumi-refresh`): a resource the provider
37
- * reads unchanged prints `refresh` with both states, an edited one `update`
38
- * with a `detailedDiff`, one deleted out of band `delete` with no new state.
39
- * A `--target`ed refresh prints only the target's step, no stack and no
40
- * provider. `same` is still read, for older CLIs. The CLI refuses
41
- * `--preview-only` under `PULUMI_SKIP_CONFIRMATIONS`, so the runner unsets it.
42
- *
43
- * ## A member on plunge
44
- *
45
- * A Pulumi member whose stack runs on plunge reads drift with `plunge drift
46
- * --resource <urn> --stream`, which prints chant's own drift-record v1
47
- * NDJSON (engine `plunge`, read `refresh`, the URN as `address`, `node`
48
- * null, a settle line with plunge's `reads`). {@link plungeDriftStreamRecords}
49
- * passes each stream through chant's decoder (`decodeDriftLines`,
50
- * `foldDriftLines`), keeps the records for the URN asked about, and fills
51
- * `node` by the URN rule, which `placeDriftRecord` applies to plunge as to
52
- * pulumi. Which members run on plunge is `./run.ts`'s
53
- * `pulumiMemberEngine`. The fixtures in `testdata/plunge-drift` are
54
- * recorded from plunge on floci (#4475). plunge answers a component with a
55
- * not-observed `unsupported-kind` record, and a URN its stack holds no
56
- * record for with exit 1 and no stream.
57
- *
58
- * Imports chant's `drift-record` and `pulumi-urn` subpaths and `./values`,
59
- * never the lexicon's entry point, so it bundles small (#3421).
60
- */
61
-
62
- import {
63
- decodeDriftLines,
64
- driftRecord,
65
- foldDriftLines,
66
- placeDriftRecord,
67
- type DriftAdapterBase,
68
- type DriftAttribute,
69
- type DriftEvidence,
70
- type DriftRecord,
71
- } from "@intentius/chant/drift-record";
72
- import type { UnobservedReason } from "@intentius/chant/observation";
73
- import { isPulumiNodeless, parsePulumiUrn } from "@intentius/chant/pulumi-urn";
74
- import { pulumiSteps, type PulumiStep, type PulumiStepState } from "./change-set";
75
- import { holdsSecret, isObject, isUnknown, propertyKeys, sameJson, valueAtPath } from "./values";
76
-
77
- const byString = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);
78
-
79
- /** The argv chant runs for one resource's refresh read, after `pulumi`. */
80
- export function pulumiRefreshArgs(opts: { urn?: string; stack?: string } = {}): string[] {
81
- return [
82
- "refresh",
83
- "--preview-only",
84
- "--json",
85
- ...(opts.stack ? ["--stack", opts.stack] : []),
86
- ...(opts.urn ? ["--target", opts.urn] : []),
87
- ];
88
- }
89
-
90
- /** One `--target`ed refresh read: the URN asked for, and the document or why there is none. */
91
- export interface PulumiRefreshRead {
92
- urn: string;
93
- /** `pulumi refresh --preview-only --json --target <urn>`, parsed. */
94
- refresh?: unknown;
95
- /** The run failed or printed nothing readable. */
96
- failed?: { reason: UnobservedReason; detail?: string };
97
- }
98
-
99
- export interface PulumiRefreshDriftInput extends DriftAdapterBase {
100
- reads: readonly PulumiRefreshRead[];
101
- /** The stack read, for the evidence's command line. */
102
- stack?: string;
103
- }
104
-
105
- /** What every refresh adapter takes: the adapter base and the stack. */
106
- type RefreshBase = DriftAdapterBase & { stack?: string };
107
-
108
- function evidenceFor(input: Pick<RefreshBase, "version" | "stack">, urn: string | undefined, op?: string): DriftEvidence {
109
- return {
110
- tool: "pulumi",
111
- ...(input.version ? { version: input.version } : {}),
112
- command: `pulumi ${pulumiRefreshArgs({ urn, stack: input.stack }).join(" ")}`,
113
- ...(op ? { engineCode: op } : {}),
114
- };
115
- }
116
-
117
- function common(input: DriftAdapterBase, urn: string, state?: PulumiStepState) {
118
- const type = state?.type ?? parsePulumiUrn(urn)?.type;
119
- return {
120
- member: input.member,
121
- engine: "pulumi" as const,
122
- address: urn,
123
- ...(type ? { resourceType: type } : {}),
124
- ...placeDriftRecord(input, "pulumi", urn),
125
- observedAt: input.observedAt,
126
- read: "refresh" as const,
127
- ...(input.fellBackFrom !== undefined ? { fellBackFrom: input.fellBackFrom } : {}),
128
- };
129
- }
130
-
131
- /** The paths that differ between a refresh step's states, and which side of the state each reads. */
132
- function driftPaths(step: PulumiStep): { path: string; inputs: boolean }[] {
133
- const detailed = isObject(step.detailedDiff) ? step.detailedDiff : undefined;
134
- if (detailed && Object.keys(detailed).length > 0) {
135
- return Object.entries(detailed).map(([path, d]) => ({ path, inputs: d?.inputDiff === true }));
136
- }
137
- if (Array.isArray(step.diffReasons) && step.diffReasons.length > 0) {
138
- return step.diffReasons.map((path) => ({ path: String(path), inputs: false }));
139
- }
140
- const before = step.oldState?.outputs ?? {};
141
- const after = step.newState?.outputs ?? {};
142
- return [...new Set([...propertyKeys(before), ...propertyKeys(after)])]
143
- .filter((k) => !sameJson(before[k] ?? null, after[k] ?? null))
144
- .map((path) => ({ path, inputs: false }));
145
- }
146
-
147
- function attributesOf(step: PulumiStep): DriftAttribute[] {
148
- const seen = new Set<string>();
149
- const out: DriftAttribute[] = [];
150
- for (const { path, inputs } of driftPaths(step)) {
151
- if (seen.has(path)) continue;
152
- seen.add(path);
153
- let before = valueAtPath(inputs ? step.oldState?.inputs : step.oldState?.outputs, path);
154
- let after = valueAtPath(inputs ? step.newState?.inputs : step.newState?.outputs, path);
155
- // A refresh can name a path that only the inputs hold, with inputDiff false (recorded, #4475: tags an emulator
156
- // never echoed into the outputs, dropped out of band). Neither output side holds it, so the inputs answer.
157
- if (!inputs && (before === undefined || before === null) && (after === undefined || after === null)) {
158
- before = valueAtPath(step.oldState?.inputs, path);
159
- after = valueAtPath(step.newState?.inputs, path);
160
- }
161
- if (holdsSecret(before) || holdsSecret(after)) {
162
- out.push({ path, sensitive: true });
163
- continue;
164
- }
165
- out.push({
166
- path,
167
- ...(before !== undefined && before !== null && !isUnknown(before) ? { before } : {}),
168
- ...(after !== undefined && after !== null && !isUnknown(after) ? { after } : {}),
169
- });
170
- }
171
- return out;
172
- }
173
-
174
- /** The record one URN's refresh steps give. */
175
- function recordFor(input: RefreshBase, urn: string, steps: PulumiStep[], targeted: boolean): DriftRecord {
176
- const step = steps[steps.length - 1];
177
- const op = step.op ?? "";
178
- const state = step.newState ?? step.oldState;
179
- const at = common(input, urn, state);
180
- const evidence = evidenceFor(input, targeted ? urn : undefined, op || undefined);
181
- const missing = () => driftRecord({ ...at, status: "missing", evidence });
182
- const compared = () => {
183
- const attributes = attributesOf(step);
184
- return attributes.length === 0
185
- ? driftRecord({ ...at, status: "in-sync", evidence })
186
- : driftRecord({ ...at, status: "drifted", attributes, evidence });
187
- };
188
- switch (op) {
189
- case "same":
190
- return driftRecord({ ...at, status: "in-sync", evidence });
191
- case "update":
192
- return compared();
193
- case "delete":
194
- return missing();
195
- case "refresh":
196
- if (!isObject(step.newState) || step.newState.delete === true) return missing();
197
- return compared();
198
- default:
199
- return driftRecord({
200
- ...at,
201
- status: "not-observed",
202
- unobserved: { reason: "read-failed", detail: `pulumi printed ${op ? `op ${op}` : "a step with no op"} for the URN, which a refresh read does not map`, queried: urn },
203
- evidence,
204
- });
205
- }
206
- }
207
-
208
- /**
209
- * One record per `--target`ed read: what the refresh found for the URN asked
210
- * for. Steps for other URNs in the same document (the stack, a provider)
211
- * are not this read's answer and are left out. Sorted by address.
212
- */
213
- export function pulumiRefreshDriftRecords(input: PulumiRefreshDriftInput): DriftRecord[] {
214
- const out: DriftRecord[] = [];
215
- for (const read of input.reads) {
216
- const at = common(input, read.urn);
217
- if (read.failed) {
218
- out.push(driftRecord({ ...at, status: "not-observed", unobserved: { ...read.failed, queried: read.urn }, evidence: evidenceFor(input, read.urn) }));
219
- continue;
220
- }
221
- const steps = (pulumiSteps(read.refresh) ?? []).filter((s) => s.urn === read.urn);
222
- if (steps.length === 0) {
223
- const why = pulumiSteps(read.refresh) === undefined ? 'the refresh printed no "steps"' : "the refresh printed no step for the URN";
224
- out.push(driftRecord({ ...at, status: "not-observed", unobserved: { reason: "not-reached", detail: why, queried: read.urn }, evidence: evidenceFor(input, read.urn) }));
225
- continue;
226
- }
227
- out.push(recordFor(input, read.urn, steps, true));
228
- }
229
- return out.sort((a, b) => byString(a.address, b.address));
230
- }
231
-
232
- export interface PulumiRefreshDocumentInput extends DriftAdapterBase {
233
- /** One untargeted `pulumi refresh --preview-only --json`, parsed. */
234
- refresh: unknown;
235
- stack?: string;
236
- }
237
-
238
- /**
239
- * One record per resource of an untargeted refresh, providers and the root
240
- * stack left out. Throws when the document has no `steps`. Sorted by address.
241
- */
242
- export function pulumiRefreshDocumentRecords(input: PulumiRefreshDocumentInput): DriftRecord[] {
243
- const steps = pulumiSteps(input.refresh);
244
- if (steps === undefined) throw new Error('not a pulumi refresh --preview-only --json document: no top-level "steps"');
245
- const byUrn = new Map<string, PulumiStep[]>();
246
- for (const s of steps) {
247
- const type = s.newState?.type ?? s.oldState?.type ?? parsePulumiUrn(s.urn!)?.type ?? "";
248
- if (isPulumiNodeless(type)) continue;
249
- byUrn.set(s.urn!, [...(byUrn.get(s.urn!) ?? []), s]);
250
- }
251
- return [...byUrn].map(([urn, list]) => recordFor(input, urn, list, false)).sort((a, b) => byString(a.address, b.address));
252
- }
253
-
254
- // ── a member on plunge ─────────────────────────────────────────────────────────
255
-
256
- /** The argv chant runs for one resource's drift read on plunge, after `plunge`. */
257
- export function plungeDriftArgs(opts: { urn: string; stack?: string; member?: string }): string[] {
258
- return ["drift", "--resource", opts.urn, "--stream", ...(opts.stack ? ["--stack", opts.stack] : []), ...(opts.member ? ["--member", opts.member] : [])];
259
- }
260
-
261
- /** One `plunge drift --resource <urn> --stream` read: the URN asked for, and its NDJSON or why there is none. */
262
- export interface PlungeDriftRead {
263
- urn: string;
264
- /** The stream plunge printed. */
265
- stream?: string;
266
- failed?: { reason: UnobservedReason; detail?: string };
267
- }
268
-
269
- export interface PlungeDriftInput extends DriftAdapterBase {
270
- reads: readonly PlungeDriftRead[];
271
- stack?: string;
272
- }
273
-
274
- /**
275
- * One record per plunge read, from its stream decoded by chant's own
276
- * decoder. The stream's record for the URN keeps plunge's status,
277
- * attributes and evidence; its `member` becomes this member and its `node`
278
- * the URN rule's. A stream that does not decode, names another engine, or
279
- * reports nothing for the URN gives a not-observed record. Sorted by address.
280
- */
281
- export function plungeDriftStreamRecords(input: PlungeDriftInput): DriftRecord[] {
282
- const out: DriftRecord[] = [];
283
- for (const read of input.reads) {
284
- const evidence: DriftEvidence = {
285
- tool: "plunge",
286
- ...(input.version ? { version: input.version } : {}),
287
- command: `plunge ${plungeDriftArgs({ urn: read.urn, stack: input.stack, member: input.member }).join(" ")}`,
288
- };
289
- const base = {
290
- member: input.member,
291
- engine: "plunge" as const,
292
- address: read.urn,
293
- ...(parsePulumiUrn(read.urn) ? { resourceType: parsePulumiUrn(read.urn)!.type } : {}),
294
- ...placeDriftRecord(input, "plunge", read.urn),
295
- observedAt: input.observedAt,
296
- read: "refresh" as const,
297
- ...(input.fellBackFrom !== undefined ? { fellBackFrom: input.fellBackFrom } : {}),
298
- };
299
- const unobserved = (reason: UnobservedReason, detail: string) =>
300
- driftRecord({ ...base, status: "not-observed", unobserved: { reason, detail, queried: read.urn }, evidence });
301
- if (read.failed) {
302
- out.push(unobserved(read.failed.reason, read.failed.detail ?? "plunge drift failed"));
303
- continue;
304
- }
305
- let records: DriftRecord[];
306
- try {
307
- records = foldDriftLines(decodeDriftLines(read.stream ?? "")).document.records;
308
- } catch (err) {
309
- out.push(unobserved("read-failed", `the plunge drift stream did not decode: ${(err as Error).message}`));
310
- continue;
311
- }
312
- const mine = records.filter((r) => r.address === read.urn);
313
- if (mine.length === 0) {
314
- out.push(unobserved("not-reached", "the plunge drift stream reported nothing for the URN"));
315
- continue;
316
- }
317
- for (const { instanceOf: _i, ...r } of mine) {
318
- if (r.engine !== "plunge") {
319
- out.push(unobserved("read-failed", `the plunge drift stream names engine ${r.engine}, not plunge`));
320
- continue;
321
- }
322
- out.push(driftRecord({ ...r, member: input.member, ...placeDriftRecord(input, "plunge", read.urn) }));
323
- }
324
- }
325
- return out.sort((a, b) => byString(a.address, b.address) || byString(a.read, b.read));
326
- }