@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
package/src/plugin.ts DELETED
@@ -1,272 +0,0 @@
1
- /**
2
- * Pulumi lexicon plugin (#4453).
3
- *
4
- * The lexicon declares no resource types, so `generate`, `validate` and
5
- * `coverage` have nothing to do, and `package` writes a bundle with an empty
6
- * registry (`./codegen/package.ts`). What it does carry:
7
- *
8
- * - the `pulumi` workspace member kind (`workspace-kinds.json`), moved here
9
- * from the terraform lexicon, whose graph block reads a member through
10
- * {@link pulumiPlugin}'s `buildRoots` (`./workspace-member.ts`);
11
- * - the change-set adapter over `pulumi preview --json` (`./change-set.ts`);
12
- * - the drift adapter over `pulumi refresh --preview-only --json`
13
- * (`./drift-record.ts`);
14
- * - the runner that calls those commands and no other (`./run.ts`);
15
- * - the stack outputs `member-outputs` feeds into chant parameters
16
- * (`./stack-outputs.ts`, `./member-outputs.ts`, #4455), contributed
17
- * through {@link pulumiCapabilityPlugin} (`./capability-plugin.ts`);
18
- * - `readDrift`, which `chant workspace drift --member <pulumi member>`
19
- * reaches through `chant lifecycle drift` in the member's reader project
20
- * (`./drift-read.ts`);
21
- * - `describeResources`, engine facts for a member on plunge from `plunge
22
- * graph --json` (`./describe-resources.ts`, #4529), and a plunge member's
23
- * checked-in `engine-graph.json` in the member read (`./engine-graph.ts`);
24
- * - the checks a pulumi surface admits (#4468): PUL101 over `pulumi.member`
25
- * in source, PUL001 and PUL002 over the member read (`./lint/`);
26
- * - completion and hover over `Pulumi.yaml`, a stack's `Pulumi.<stack>.yaml`,
27
- * the workspace member entry and `pulumi.member` (`./lsp/`);
28
- * - its docs section (`./codegen/docs.ts`, `docs/pages/`);
29
- * - audit metadata for PUL001 and PUL002 (`./lint/audit-catalog.ts`), the
30
- * `chant-pulumi` skill (`./skills/`), and the `PulumiWatchOp` composite
31
- * over the `pulumiPreview` and `pulumiDrift` activities (`./composites/`,
32
- * `./op/`), following the terraform lexicon (#4494);
33
- * - the tier-2 contract's remainder (#4510): PUL003 to PUL015 over the
34
- * member's export, two more skills, `detectTemplate` for a stack export or
35
- * a `Pulumi.yaml`, and three `chant init` templates (`./init-templates.ts`);
36
- * - review stacks in a pull request's environment (#4609): `prEnvTemplate`
37
- * takes a `<project>/<stack>` template, and `prEnvTeardown` removes the
38
- * environment's `pr-<n>` stacks (`./review-stack.ts`).
39
- */
40
- import { pulumiCheckSteps } from "./check-step";
41
- import { pulumiCiSetup } from "./ci-setup";
42
- import { basename, isAbsolute, resolve } from "node:path";
43
- import type { InitTemplateSet, LexiconPlugin } from "@intentius/chant/lexicon";
44
- import type { CompletionContext, HoverContext } from "@intentius/chant/lsp/types";
45
- import { createSkillsLoader } from "@intentius/chant/lexicon-plugin-helpers";
46
- import { pulumiConfigSchema, type PulumiConfig } from "./config";
47
- import { pulumiSerializer } from "./serializer";
48
- import { lastMemberReport, readPulumiMember, setLastMemberRead, setLastMemberReport } from "./workspace-member";
49
- import { rules } from "./lint/rules";
50
- import { postSynthChecks } from "./lint/post-synth";
51
- import { pulumiAuditCatalog } from "./lint/audit-catalog";
52
- import { completions } from "./lsp/completions";
53
- import { hover } from "./lsp/hover";
54
- import { PULUMI_RUNTIME_NAMES } from "./lsp/keys";
55
- import { pulumiInitTemplates } from "./init-templates";
56
- import { pulumiTemplateStack, reviewStackTeardown } from "./review-stack";
57
-
58
- const loadSkills = createSkillsLoader(import.meta.url, [
59
- {
60
- file: "chant-pulumi.md",
61
- name: "chant-pulumi",
62
- description:
63
- "Add a Pulumi program to a chant workspace as a member, read its preview into the change set and its refresh as drift, and watch it with PulumiWatchOp",
64
- },
65
- {
66
- file: "chant-pulumi-stack-export.md",
67
- name: "chant-pulumi-stack-export",
68
- description:
69
- "Keep a Pulumi member's checked-in stack-export.json current and clean, and fix what PUL001 to PUL015 report about it",
70
- },
71
- {
72
- file: "chant-pulumi-plunge.md",
73
- name: "chant-pulumi-plunge",
74
- description:
75
- "Read a Pulumi member that runs on plunge (a plunge backend URL or engine plunge), with plunge preview, plunge stack output and plunge drift",
76
- },
77
- ]);
78
-
79
- export const pulumiPlugin: LexiconPlugin = {
80
- name: "pulumi",
81
- serializer: pulumiSerializer,
82
- configSchema: pulumiConfigSchema,
83
-
84
- // #4550: the engine install lines for the pull request pipeline's default image.
85
- ciSetup(ctx: { dir: string }): string[] {
86
- return pulumiCiSetup(ctx);
87
- },
88
-
89
- // #4609: a ci.prEnvironment.template of the form <project>/<stack> names a Pulumi stack, so it needs no chant.config.ts environment.
90
- prEnvTemplate(template: string): string | undefined {
91
- return pulumiTemplateStack(template) ? `the Pulumi stack ${template}` : undefined;
92
- },
93
-
94
- // #4609: pr-env down and the sweep destroy and remove each review stack the environment's record names (./review-stack.ts).
95
- prEnvTeardown(ctx: { cwd: string }) {
96
- return reviewStackTeardown({ cwd: ctx.cwd });
97
- },
98
-
99
- // #4633: pulumi install, each stack's config against the project's schema, and pulumi about --json, per pulumi member in chant's check stage.
100
- checkSteps() {
101
- return pulumiCheckSteps();
102
- },
103
-
104
- // #4634: preview tips (rename without aliases, a replace forced by a name, what may register at up) as a note section per member.
105
- async prNoteDetail(input) {
106
- if (input.stage !== "plan") return undefined;
107
- const [{ pulumiTipsDetail }, { activeProductWords }] = await Promise.all([import("./preview-tips"), import("@intentius/chant/ci-product-words")]);
108
- const words = activeProductWords();
109
- return pulumiTipsDetail({ member: input.member, changeSet: input.changeSet, words: { product: words.product, noun: words.noun } });
110
- },
111
-
112
- // A pulumi workspace member's reader project (#3179): its stack export from
113
- // the index store, else the checked-in one, never the program. See ./workspace-member.ts. `chant workspace
114
- // graph` writes `dir` absolute; a project that writes the namespace itself
115
- // can write it relative to the project root (#4468).
116
- async buildRoots(ctx) {
117
- setLastMemberReport(undefined);
118
- setLastMemberRead(undefined);
119
- const configured = (ctx.config as { pulumi?: PulumiConfig }).pulumi?.member;
120
- if (!configured) return { entities: new Map() };
121
- const member =
122
- ctx.projectRoot && !isAbsolute(configured.dir) ? { ...configured, dir: resolve(ctx.projectRoot, configured.dir) } : configured;
123
- // The export the last apply through chant wrote to the index store
124
- // (#4546), else the checked-in stack-export.json.
125
- const { readStoredPulumiExport } = await import("./stack-export-snapshot");
126
- const fromStore = await readStoredPulumiExport({ dir: member.dir, ...(member.stack ? { stack: member.stack } : {}) });
127
- const read = readPulumiMember({ member, ...(fromStore ? { stored: { doc: fromStore.doc, where: fromStore.where, key: fromStore.key } } : {}) });
128
- setLastMemberReport(read.report);
129
- setLastMemberRead({
130
- dir: member.dir,
131
- label: member.label ?? basename(member.dir),
132
- ...(member.engine ? { engine: member.engine } : {}),
133
- ...(member.stack ? { stack: member.stack } : {}),
134
- ...(read.doc !== undefined ? { doc: read.doc } : {}),
135
- });
136
- return { entities: read.entities, warnings: read.warnings };
137
- },
138
-
139
- /**
140
- * The stacks a change touched (#3183, INTENTIUS/plywood#22): a changed
141
- * `Pulumi.<stack>.yaml` is that stack, any other file of a project is every
142
- * stack with a config beside its `Pulumi.yaml`. Named as a `pulumi-up`
143
- * step's deploy unit, so `chant components pr-plan` and `fan-out --base`
144
- * select the components that update them. See ./changed-units.ts.
145
- */
146
- async changedUnits(ctx) {
147
- const { pulumiChangedUnits } = await import("./changed-units");
148
- return pulumiChangedUnits(ctx.projectRoot, ctx.changedFiles);
149
- },
150
-
151
- graphMeta() {
152
- const report = lastMemberReport();
153
- return report ? { pulumiMember: report } : undefined;
154
- },
155
-
156
- /**
157
- * Engine facts for a member on plunge (#4529): one `plunge graph --json
158
- * --stack <stack>`, each node's facts on `ResourceMetadata.facts`, and
159
- * `ownership: "unknown"` on every resource, so nothing decides from it. A
160
- * stock member runs nothing and is not-observed. See
161
- * `./describe-resources.ts`.
162
- */
163
- async describeResources(options) {
164
- const { describePulumiResources } = await import("./describe-resources");
165
- return describePulumiResources(options);
166
- },
167
-
168
- /**
169
- * The member's drift, as drift-record stream lines (#4455): `pulumi
170
- * refresh --preview-only --target` per resource, or `plunge drift
171
- * --resource --stream` for a member on plunge. See `./drift-read.ts`.
172
- */
173
- async readDrift(options) {
174
- const { readPulumiDrift } = await import("./drift-read");
175
- return readPulumiDrift(options);
176
- },
177
-
178
- lintRules() {
179
- return rules;
180
- },
181
-
182
- postSynthChecks() {
183
- return postSynthChecks;
184
- },
185
-
186
- auditCatalog() {
187
- return pulumiAuditCatalog;
188
- },
189
-
190
- /**
191
- * No `mcpTools()` and no `mcpResources()`, deliberately, as in the
192
- * terraform lexicon (#2220, #4494). The two shapes other lexicons serve
193
- * have nothing to serve here: `createDiffTool` diffs one build's serializer
194
- * output against the last, and this serializer writes `{}` on every build
195
- * (`./serializer.ts`); `createCatalogResource` serves the generated
196
- * resource registry, and this lexicon generates none. A member's preview
197
- * and drift already reach MCP through core's workspace tools, so the two
198
- * tier-2 "registers" checks stay honest gaps rather than stubs.
199
- */
200
- skills: loadSkills,
201
-
202
- /**
203
- * A `pulumi stack export` document or a parsed `Pulumi.yaml`, recognised by
204
- * content (#4510), so `chant import` names this lexicon for either and then
205
- * says it has no template import, rather than finding no lexicon at all.
206
- *
207
- * A stack export is `{ version: <number>, deployment: { ... } }` with the
208
- * deployment holding a `manifest` or a `resources` list. A `Pulumi.yaml` has
209
- * a string `name` and a `runtime` that is one of Pulumi's runtime names,
210
- * as a string or as `{ name }`. Nothing else Pulumi writes carries either
211
- * shape, and neither matches a CloudFormation template, a Kubernetes
212
- * manifest or a Compose file. Anything else, a raw string included, is
213
- * false: neither file is read from text here.
214
- */
215
- detectTemplate(data: unknown) {
216
- if (typeof data !== "object" || data === null || Array.isArray(data)) return false;
217
- const doc = data as Record<string, unknown>;
218
- const deployment = doc.deployment as Record<string, unknown> | undefined;
219
- if (typeof doc.version === "number" && typeof deployment === "object" && deployment !== null && !Array.isArray(deployment)) {
220
- return typeof deployment.manifest === "object" || Array.isArray(deployment.resources);
221
- }
222
- if (typeof doc.name !== "string" || doc.name.length === 0) return false;
223
- const runtime = doc.runtime as unknown;
224
- const runtimeName =
225
- typeof runtime === "string" ? runtime : typeof runtime === "object" && runtime !== null ? (runtime as { name?: unknown }).name : undefined;
226
- return typeof runtimeName === "string" && PULUMI_RUNTIME_NAMES.includes(runtimeName);
227
- },
228
-
229
- /**
230
- * `chant init --lexicon pulumi [--template <name>]` (#4510): a project that
231
- * reads one Pulumi member, by default; `watch`, the same project with a
232
- * `PulumiWatchOp`; and `plunge`, the watch for a member on plunge. See
233
- * `./init-templates.ts`.
234
- */
235
- initTemplates(template?: string): InitTemplateSet {
236
- if (template === "watch") return pulumiInitTemplates.watch;
237
- if (template === "plunge") return pulumiInitTemplates.plunge;
238
- return pulumiInitTemplates.member;
239
- },
240
-
241
- completionProvider(ctx: CompletionContext) {
242
- return completions(ctx);
243
- },
244
-
245
- hoverProvider(ctx: HoverContext) {
246
- return hover(ctx);
247
- },
248
-
249
- async docs(options?) {
250
- const { generateDocs } = await import("./codegen/docs");
251
- return generateDocs(options);
252
- },
253
-
254
- // No declarable kinds, so no upstream spec to generate from, check against or measure.
255
- async generate(): Promise<void> {},
256
- async validate(): Promise<void> {},
257
- async coverage(): Promise<void> {},
258
-
259
- /** The bundle with `dist/manifest.json` (#4468); see `./codegen/package.ts`. */
260
- async package(options?: { verbose?: boolean; force?: boolean }): Promise<void> {
261
- const { packageLexicon } = await import("./codegen/package");
262
- const { writeBundleSpec } = await import("@intentius/chant/codegen/package");
263
- const { join, dirname } = await import("node:path");
264
- const { fileURLToPath } = await import("node:url");
265
-
266
- const { spec, stats } = await packageLexicon(options);
267
- const pkgDir = dirname(dirname(fileURLToPath(import.meta.url)));
268
- writeBundleSpec(spec, join(pkgDir, "dist"));
269
-
270
- console.error(`Packaged ${stats.resources} resources, ${stats.ruleCount} rules, ${stats.skillCount} skills`);
271
- },
272
- };
@@ -1,241 +0,0 @@
1
- /**
2
- * plunge's per-resource timings (INTENTIUS/plunge#55) in run records and
3
- * traces (INTENTIUS/chant#4579).
4
- *
5
- * The engine is a fake answering with `testdata/pulumi-stream` (the corpus
6
- * stream; see its README), with `metadata.plungeTimings` added to the
7
- * resources the update changed, in the shape plunge#55 prints. The trace goes
8
- * to a fake collector on 127.0.0.1. No pulumi or plunge binary runs here, and
9
- * nothing reaches a backend or a real endpoint.
10
- */
11
- import { execFileSync } from "node:child_process";
12
- import { mkdtempSync, readFileSync, writeFileSync } from "node:fs";
13
- import { createServer } from "node:http";
14
- import type { AddressInfo } from "node:net";
15
- import { tmpdir } from "node:os";
16
- import { join } from "node:path";
17
- import { afterEach, describe, expect, test } from "vitest";
18
- import { CapabilityRegistry, type Capability } from "@intentius/chant/components/capability";
19
- import { createOtlpExporter, otlpFromEnv } from "@intentius/chant/otlp";
20
- import { memoryGateLedgerPort } from "@intentius/chant/op/gate";
21
- import type { OpWavesSpec } from "@intentius/chant/op/op-waves";
22
- import { runOpWave, type OpWaveShowAtBase } from "@intentius/chant/op/op-waves-run";
23
- import type { OpRunRecordInput } from "@intentius/chant/op/runtime";
24
- import { plungeTimingOf, pulumiStreamSummary, pulumiStreamTimings, type PlungeTiming } from "./engine-events";
25
- import { plungeResourceProgress, plungeResourceSpan, plungeTimingSpans, plungeTimingTotals, pulumiUrnParts } from "./plunge-timings";
26
- import { createPulumiUpCapability } from "./pulumi-up";
27
- import type { PulumiRunner } from "./run";
28
- import { pulumiTraceFacts } from "./trace-facts";
29
-
30
- const testdata = join(import.meta.dirname, "testdata");
31
- const dir = join(testdata, "pulumi-preview");
32
- const stream = readFileSync(join(testdata, "pulumi-stream", "preview-stream.ndjson"), "utf-8");
33
- const upStream = stream.replaceAll(',"planning":true', "");
34
- const stackOutput = readFileSync(join(testdata, "pulumi-outputs", "stack-output.json"), "utf-8");
35
- const urn = (type: string, name: string) => `urn:pulumi:floci::corpus-aws-ts::${type}::${name}`;
36
-
37
- const at = (ms: number) => new Date(Date.parse("2026-10-27T12:00:00.000Z") + ms).toISOString().replace("Z", "123Z");
38
-
39
- /** plunge#55's entries for one changed resource: its provider calls, then its record write. */
40
- const timingsFor = (op: string, offset: number): PlungeTiming[] => [
41
- { kind: "provider", call: "diff", startedAt: at(offset), durationMs: 3.5 },
42
- { kind: "provider", call: op === "delete" ? "delete" : op === "replace" ? "create" : "update", startedAt: at(offset + 10), durationMs: 812.4 },
43
- { kind: "record", call: op === "delete" ? "delete" : "write", startedAt: at(offset + 830), durationMs: 21.25 },
44
- ];
45
-
46
- /** The corpus `up` stream as plunge prints it: every changed resource's outputs event carries its timings. */
47
- function plungeUpStream(): { text: string; timed: string[] } {
48
- const timed: string[] = [];
49
- const lines = upStream.split("\n").map((line, i) => {
50
- if (!line.includes('"resOutputsEvent"')) return line;
51
- const e = JSON.parse(line) as { resOutputsEvent: { metadata: { op: string; urn: string; plungeTimings?: unknown[] } } };
52
- const m = e.resOutputsEvent.metadata;
53
- if (m.op === "same") return line;
54
- m.plungeTimings = timingsFor(m.op, i * 1000);
55
- timed.push(m.urn);
56
- return JSON.stringify(e);
57
- });
58
- return { text: lines.join("\n"), timed };
59
- }
60
-
61
- /** A runner that answers by command, as pulumi-up.test.ts's does. */
62
- function engine(up: () => string): PulumiRunner {
63
- return async (args) => {
64
- const save = args.indexOf("--save-plan");
65
- if (save >= 0) writeFileSync(args[save + 1]!, "{}\n");
66
- return { stdout: args[0] === "preview" ? stream : args[0] === "up" ? up() : stackOutput };
67
- };
68
- }
69
-
70
- describe("reading plungeTimings (plunge#55)", () => {
71
- test("an entry is kind, call, startedAt and durationMs, with failed when it failed", () => {
72
- expect(plungeTimingOf({ kind: "provider", call: "create", startedAt: "2026-10-27T12:00:00.123456789Z", durationMs: 812.4 })).toEqual({ kind: "provider", call: "create", startedAt: "2026-10-27T12:00:00.123456789Z", durationMs: 812.4 });
73
- expect(plungeTimingOf({ kind: "record", call: "write", startedAt: "2026-10-27T12:00:01Z", durationMs: 2, failed: true })).toMatchObject({ failed: true });
74
- for (const bad of [null, [], { kind: "lock", call: "x", startedAt: "2026-10-27T12:00:00Z", durationMs: 1 }, { kind: "provider", call: "", startedAt: "2026-10-27T12:00:00Z", durationMs: 1 }, { kind: "provider", call: "create", startedAt: "soon", durationMs: 1 }, { kind: "provider", call: "create", startedAt: "2026-10-27T12:00:00Z", durationMs: -1 }]) {
75
- expect(plungeTimingOf(bad)).toBeUndefined();
76
- }
77
- });
78
-
79
- test("timings come from outputs and failure events, joined by URN across a replacement's two events", () => {
80
- const vpc = urn("aws:ec2/vpc:Vpc", "main");
81
- const line = (o: unknown) => `${JSON.stringify(o)}\n`;
82
- const text =
83
- line({ resourcePreEvent: { metadata: { op: "create-replacement", urn: vpc, plungeTimings: [{ kind: "provider", call: "check", startedAt: at(0), durationMs: 1 }] } } }) +
84
- line({ resOutputsEvent: { metadata: { op: "create-replacement", urn: vpc, plungeTimings: [{ kind: "provider", call: "create", startedAt: at(0), durationMs: 500 }, { kind: "record", call: "write", startedAt: at(500), durationMs: 5 }] } } }) +
85
- line({ resOutputsEvent: { metadata: { op: "delete-replaced", urn: vpc, plungeTimings: [{ kind: "provider", call: "delete", startedAt: at(600), durationMs: 300 }, { phase: "old shape" }] } } }) +
86
- line({ resOpFailedEvent: { metadata: { op: "update", urn: urn("aws:sqs/queue:Queue", "events"), plungeTimings: [{ kind: "provider", call: "update", startedAt: at(10), durationMs: 40, failed: true }] }, status: 1, steps: 0 } });
87
- const timings = pulumiStreamTimings(text);
88
- expect(timings[vpc]!.map((t) => t.call)).toEqual(["create", "write", "delete"]);
89
- expect(timings[urn("aws:sqs/queue:Queue", "events")]).toEqual([{ kind: "provider", call: "update", startedAt: at(10), durationMs: 40, failed: true }]);
90
- });
91
-
92
- test("a stock Pulumi stream has no timings, and its summary carries none", () => {
93
- expect(pulumiStreamTimings(upStream)).toEqual({});
94
- expect(pulumiStreamSummary(upStream)?.timings).toBeUndefined();
95
- });
96
- });
97
-
98
- describe("timings as spans (#4579)", () => {
99
- test("a resource is one span from its first call to its last, with a child per call", () => {
100
- const u = urn("corpus:index:Site$aws:s3/bucket:Bucket", "docs-assets");
101
- expect(pulumiUrnParts(u)).toEqual({ type: "aws:s3/bucket:Bucket", name: "docs-assets" });
102
- const span = plungeResourceSpan(u, timingsFor("update", 0))!;
103
- expect(span).toMatchObject({
104
- name: u,
105
- startedAt: "2026-10-27T12:00:00.000Z",
106
- durationMs: 851.25,
107
- attributes: { urn: u, "resource.type": "aws:s3/bucket:Bucket", "resource.name": "docs-assets", "plunge.calls": 3, "plunge.provider_ms": 815.9, "plunge.record_ms": 21.25 },
108
- });
109
- expect(span.children!.map((c) => [c.name, c.durationMs])).toEqual([["provider diff", 3.5], ["provider update", 812.4], ["record write", 21.25]]);
110
- expect(span.failed).toBeUndefined();
111
- });
112
-
113
- test("the stack's totals name the slowest call, and an empty set gives nothing", () => {
114
- const a = urn("aws:sqs/queue:Queue", "events");
115
- const b = urn("aws:ec2/vpc:Vpc", "main");
116
- const totals = plungeTimingTotals({ [a]: timingsFor("update", 0), [b]: [{ kind: "provider", call: "create", startedAt: at(0), durationMs: 2000, failed: true }] });
117
- expect(totals).toEqual({
118
- "plunge.resources": 2,
119
- "plunge.calls": 4,
120
- "plunge.provider_ms": 2815.9,
121
- "plunge.record_ms": 21.25,
122
- "plunge.failed_calls": 1,
123
- "plunge.slowest.urn": b,
124
- "plunge.slowest.call": "provider create",
125
- "plunge.slowest.ms": 2000,
126
- });
127
- expect(plungeTimingTotals({})).toEqual({});
128
- expect(plungeTimingSpans(undefined)).toEqual([]);
129
- });
130
-
131
- test("pulumi-up's facts carry a span per timed resource on plunge, and none on stock", () => {
132
- const { text, timed } = plungeUpStream();
133
- const summary = pulumiStreamSummary(text);
134
- const base = { member: "corpus-aws-ts/floci", stack: "floci", planDigest: "sha256:x", fromWavePlan: true, outputs: {} };
135
- const plunge = pulumiTraceFacts({ dir, stack: "floci" }, { output: { ...base, engine: "plunge", ...(summary ? { summary } : {}) } });
136
- expect(plunge.spans!.map((s) => s.name)).toEqual(timed);
137
- expect(plunge.attributes!["plunge.resources"]).toBe(timed.length);
138
- // chant#4615: a progress line per timed resource, in the same order.
139
- expect(plunge.resources!.map((r) => r.resource)).toEqual(timed);
140
- const stockSummary = pulumiStreamSummary(upStream);
141
- const stock = pulumiTraceFacts({ dir, stack: "floci" }, { output: { ...base, engine: "pulumi", ...(stockSummary ? { summary: stockSummary } : {}) } });
142
- expect(stock.spans).toBeUndefined();
143
- expect(stock.resources).toBeUndefined();
144
- expect(Object.keys(stock.attributes!).some((k) => k.startsWith("plunge."))).toBe(false);
145
- });
146
- });
147
-
148
- describe("a plunge up's timings in its run record and trace (#4579 acceptance, against fakes)", () => {
149
- let close: (() => Promise<void>) | undefined;
150
- afterEach(async () => {
151
- await close?.();
152
- close = undefined;
153
- });
154
-
155
- async function collector(): Promise<{ url: string; bodies: unknown[] }> {
156
- const bodies: unknown[] = [];
157
- const server = createServer((req, res) => {
158
- const chunks: Buffer[] = [];
159
- req.on("data", (c: Buffer) => chunks.push(c));
160
- req.on("end", () => {
161
- bodies.push(JSON.parse(Buffer.concat(chunks).toString("utf8")));
162
- res.end("{}");
163
- });
164
- });
165
- await new Promise<void>((done) => server.listen(0, "127.0.0.1", done));
166
- close = () => new Promise((done) => server.close(() => done()));
167
- return { url: `http://127.0.0.1:${(server.address() as AddressInfo).port}`, bodies };
168
- }
169
-
170
- async function wave(engineName: "plunge" | "pulumi", up: () => string) {
171
- const c = await collector();
172
- const runner = engine(up);
173
- const cap = createPulumiUpCapability({ ...(engineName === "plunge" ? { plunge: runner } : { run: runner }), env: {}, tmp: mkdtempSync(join(tmpdir(), "plunge-timings-")), snapshots: null });
174
- const registry = new CapabilityRegistry().register(cap as Capability<never, unknown>);
175
- const spec: OpWavesSpec = { name: "stacks", op: "pulumi-up", step: { kind: "pulumi-up", dir, stack: "floci", engine: engineName }, waves: [{ name: "floci", runs: [{ target: "site" }], gate: "never" }] };
176
- const cwd = mkdtempSync(join(tmpdir(), "plunge-timings-wave-"));
177
- // The wave's base is a real commit: a CrossGuard step reads its policy packs there (#4613).
178
- const base = execFileSync("git", ["rev-parse", "HEAD"], { cwd: dir, encoding: "utf-8" }).trim();
179
- const show: OpWaveShowAtBase = () => ({ sha: base, text: JSON.stringify(spec) });
180
- const records: OpRunRecordInput[] = [];
181
- const result = await runOpWave({
182
- spec,
183
- specFile: "waves.json",
184
- wave: 1,
185
- cwd,
186
- show,
187
- gates: memoryGateLedgerPort(),
188
- runs: { append: async (r) => void records.push(r) },
189
- capabilities: registry,
190
- lockGrain: "target",
191
- otlp: createOtlpExporter(otlpFromEnv({ OTEL_EXPORTER_OTLP_ENDPOINT: c.url }, { prefix: "plywood" })!),
192
- log: () => {},
193
- });
194
- type SpanJson = { name: string; spanId: string; parentSpanId?: string };
195
- const spans = (c.bodies[0] as { resourceSpans: Array<{ scopeSpans: Array<{ spans: SpanJson[] }> }> }).resourceSpans[0]!.scopeSpans[0]!.spans;
196
- return { result, record: records[0]!, spans };
197
- }
198
-
199
- test("a plunge up records each resource's timings in its run record, and its trace has a span per resource", async () => {
200
- const { text, timed } = plungeUpStream();
201
- const { result, record, spans } = await wave("plunge", () => text);
202
- expect(result).toMatchObject({ exitCode: 0, applied: ["site"] });
203
- const site = record.wave!.targets!.site!;
204
- expect(site.spans!.map((s) => s.name)).toEqual(timed);
205
- expect(site.spans![0]!.children).toHaveLength(3);
206
- expect(site.attributes).toMatchObject({ engine: "plunge", "plunge.resources": timed.length });
207
- const stack = spans.find((s) => s.name === "site")!;
208
- const resources = spans.filter((s) => s.parentSpanId === stack.spanId);
209
- expect(resources.map((s) => s.name)).toEqual(timed);
210
- for (const r of resources) expect(spans.filter((s) => s.parentSpanId === r.spanId)).toHaveLength(3);
211
- });
212
-
213
- test("a stock Pulumi up records no timings and is not an error", async () => {
214
- const { result, record, spans } = await wave("pulumi", () => upStream);
215
- expect(result).toMatchObject({ exitCode: 0, applied: ["site"] });
216
- expect(record.wave!.targets!.site!.spans).toBeUndefined();
217
- expect(record.status).toBe("ok");
218
- const stack = spans.find((s) => s.name === "site")!;
219
- expect(spans.filter((s) => s.parentSpanId === stack.spanId)).toEqual([]);
220
- });
221
- });
222
-
223
- describe("per-resource progress lines (chant#4615)", () => {
224
- test("one line per timed resource, with its type, name, time and calls, failed when a call failed", () => {
225
- const bucket = urn("aws:s3/bucket:Bucket", "assets");
226
- const role = urn("aws:iam/role:Role", "app");
227
- const lines = plungeResourceProgress({
228
- [bucket]: timingsFor("create", 0),
229
- [role]: [{ kind: "provider", call: "create", startedAt: at(2000), durationMs: 40, failed: true }],
230
- });
231
- expect(lines).toEqual([
232
- { resource: bucket, type: "aws:s3/bucket:Bucket", name: "assets", status: "ok", startedAt: plungeResourceSpan(bucket, timingsFor("create", 0))!.startedAt, durationMs: plungeResourceSpan(bucket, timingsFor("create", 0))!.durationMs, calls: 3 },
233
- { resource: role, type: "aws:iam/role:Role", name: "app", status: "failed", startedAt: plungeResourceSpan(role, [{ kind: "provider", call: "create", startedAt: at(2000), durationMs: 40, failed: true }])!.startedAt, durationMs: 40, calls: 1 },
234
- ]);
235
- });
236
-
237
- test("a stock stream gives none, and pulumiTraceFacts leaves resources out", () => {
238
- expect(plungeResourceProgress(undefined)).toEqual([]);
239
- expect(plungeResourceProgress({})).toEqual([]);
240
- });
241
- });
@@ -1,115 +0,0 @@
1
- /**
2
- * plunge's per-resource timings (INTENTIUS/plunge#55) as trace spans and run
3
- * record facts (INTENTIUS/chant#4579).
4
- *
5
- * `pulumiStreamTimings` (./engine-events.ts) reads each resource's provider
6
- * calls and record writes from `plunge up --json`. Here each resource becomes
7
- * one span, from its first call's start to its last call's end, with a child
8
- * span per call. `pulumi-up`'s `traceFacts` hands them to core, which puts
9
- * them under the stack's span in the op-wave job's trace and under the
10
- * stack's entry in the run record's `wave.targets` (chant#4555, chant#4551).
11
- * The stack's span also gets the totals.
12
- *
13
- * A stock Pulumi `up` prints no timings: the spans are empty and the totals
14
- * absent, which is not an error.
15
- */
16
-
17
- import type { CapabilityTraceFacts, CapabilityTraceSpan } from "@intentius/chant/otlp";
18
- import type { RunEventResource } from "@intentius/chant/run-event";
19
- import type { PlungeTiming } from "./engine-events";
20
-
21
- type Attrs = NonNullable<CapabilityTraceFacts["attributes"]>;
22
-
23
- /** A URN's type and name: `urn:pulumi:<stack>::<project>::<parent$type>::<name>`. Undefined when it is not a URN. */
24
- export function pulumiUrnParts(urn: string): { type: string; name: string } | undefined {
25
- const parts = urn.split("::");
26
- if (parts.length < 4 || !parts[0]!.startsWith("urn:pulumi:")) return undefined;
27
- const chain = parts[2]!;
28
- return { type: chain.slice(chain.lastIndexOf("$") + 1), name: parts.slice(3).join("::") };
29
- }
30
-
31
- /** Milliseconds rounded to the microsecond, so attributes stay readable. */
32
- const ms = (n: number): number => Math.round(n * 1000) / 1000;
33
-
34
- /** One resource's span, with a child per call. Undefined when no entry has a start that reads. */
35
- export function plungeResourceSpan(urn: string, timings: readonly PlungeTiming[]): CapabilityTraceSpan | undefined {
36
- const timed = timings.filter((t) => Number.isFinite(Date.parse(t.startedAt)));
37
- if (timed.length === 0) return undefined;
38
- // Date.parse keeps milliseconds; the sub-millisecond digits of a start stay in its child's startedAt.
39
- const starts = timed.map((t) => Date.parse(t.startedAt));
40
- const first = Math.min(...starts);
41
- const last = Math.max(...timed.map((t, i) => starts[i]! + t.durationMs));
42
- const sum = (kind: PlungeTiming["kind"]) => ms(timed.filter((t) => t.kind === kind).reduce((n, t) => n + t.durationMs, 0));
43
- const parts = pulumiUrnParts(urn);
44
- const failed = timed.some((t) => t.failed === true);
45
- return {
46
- name: urn,
47
- startedAt: new Date(first).toISOString(),
48
- durationMs: ms(last - first),
49
- attributes: {
50
- urn,
51
- ...(parts ? { "resource.type": parts.type, "resource.name": parts.name } : {}),
52
- "plunge.calls": timed.length,
53
- "plunge.provider_ms": sum("provider"),
54
- "plunge.record_ms": sum("record"),
55
- },
56
- ...(failed ? { failed: true } : {}),
57
- children: timed.map((t) => ({
58
- name: `${t.kind} ${t.call}`,
59
- startedAt: t.startedAt,
60
- durationMs: t.durationMs,
61
- attributes: { "plunge.kind": t.kind, "plunge.call": t.call },
62
- ...(t.failed ? { failed: true } : {}),
63
- })),
64
- };
65
- }
66
-
67
- /** A span per timed resource, in the order the stream first timed each. */
68
- export function plungeTimingSpans(timings: Readonly<Record<string, readonly PlungeTiming[]>> | undefined): CapabilityTraceSpan[] {
69
- return Object.entries(timings ?? {})
70
- .map(([urn, t]) => plungeResourceSpan(urn, t))
71
- .filter((s): s is CapabilityTraceSpan => s !== undefined);
72
- }
73
-
74
- /**
75
- * The stack's totals over every resource: the calls, the milliseconds in
76
- * provider calls and in record writes, the failed calls, and the slowest
77
- * call. Empty for a stack with no timings.
78
- */
79
- export function plungeTimingTotals(timings: Readonly<Record<string, readonly PlungeTiming[]>> | undefined): Attrs {
80
- const all = Object.entries(timings ?? {}).flatMap(([urn, ts]) => ts.map((t) => ({ urn, t })));
81
- if (all.length === 0) return {};
82
- const sum = (kind: PlungeTiming["kind"]) => ms(all.filter((x) => x.t.kind === kind).reduce((n, x) => n + x.t.durationMs, 0));
83
- const slowest = all.reduce((a, b) => (b.t.durationMs > a.t.durationMs ? b : a));
84
- const failed = all.filter((x) => x.t.failed === true).length;
85
- return {
86
- "plunge.resources": Object.keys(timings ?? {}).length,
87
- "plunge.calls": all.length,
88
- "plunge.provider_ms": sum("provider"),
89
- "plunge.record_ms": sum("record"),
90
- ...(failed > 0 ? { "plunge.failed_calls": failed } : {}),
91
- "plunge.slowest.urn": slowest.urn,
92
- "plunge.slowest.call": `${slowest.t.kind} ${slowest.t.call}`,
93
- "plunge.slowest.ms": ms(slowest.t.durationMs),
94
- };
95
- }
96
-
97
- /**
98
- * One progress line per timed resource (#4615), for the stack's
99
- * `step-settle` event and the job's log: the URN, its type and name, `failed`
100
- * when a call failed, the span's time and the number of calls. In the order
101
- * the stream first timed each, as the spans are.
102
- */
103
- export function plungeResourceProgress(timings: Readonly<Record<string, readonly PlungeTiming[]>> | undefined): RunEventResource[] {
104
- return plungeTimingSpans(timings).map((span) => {
105
- const parts = pulumiUrnParts(span.name);
106
- return {
107
- resource: span.name,
108
- ...(parts ? { type: parts.type, name: parts.name } : {}),
109
- status: span.failed ? "failed" : "ok",
110
- startedAt: span.startedAt,
111
- durationMs: span.durationMs,
112
- calls: span.children?.length ?? 0,
113
- };
114
- });
115
- }