@intentius/chant-lexicon-terraform 0.57.0 → 0.59.0

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 (408) hide show
  1. package/README.md +9 -0
  2. package/dist/composites/terraform-adopt-op.d.ts +131 -0
  3. package/dist/composites/terraform-adopt-op.d.ts.map +1 -0
  4. package/dist/composites/terraform-apply-op.d.ts +70 -17
  5. package/dist/composites/terraform-apply-op.d.ts.map +1 -1
  6. package/dist/composites/terraform-watch-op.d.ts +104 -37
  7. package/dist/composites/terraform-watch-op.d.ts.map +1 -1
  8. package/dist/config.d.ts +49 -2
  9. package/dist/config.d.ts.map +1 -1
  10. package/dist/describe-resources.d.ts +256 -16
  11. package/dist/describe-resources.d.ts.map +1 -1
  12. package/dist/hcl/descend.d.ts +98 -0
  13. package/dist/hcl/descend.d.ts.map +1 -0
  14. package/dist/hcl/marker.d.ts +130 -0
  15. package/dist/hcl/marker.d.ts.map +1 -0
  16. package/dist/hcl/parse.d.ts +156 -9
  17. package/dist/hcl/parse.d.ts.map +1 -1
  18. package/dist/hcl/references.d.ts +76 -0
  19. package/dist/hcl/references.d.ts.map +1 -0
  20. package/dist/hcl/roots.d.ts +22 -3
  21. package/dist/hcl/roots.d.ts.map +1 -1
  22. package/dist/hcl/suppressions.d.ts +54 -0
  23. package/dist/hcl/suppressions.d.ts.map +1 -0
  24. package/dist/hcl/value.d.ts +77 -0
  25. package/dist/hcl/value.d.ts.map +1 -0
  26. package/dist/index.d.ts +5 -2
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/integrity.json +34 -5
  29. package/dist/lint/audit-catalog.d.ts +3 -2
  30. package/dist/lint/audit-catalog.d.ts.map +1 -1
  31. package/dist/lint/audit-lineage.d.ts +95 -0
  32. package/dist/lint/audit-lineage.d.ts.map +1 -1
  33. package/dist/lint/post-synth/blocks.d.ts +53 -0
  34. package/dist/lint/post-synth/blocks.d.ts.map +1 -0
  35. package/dist/lint/post-synth/fixtures/load.d.ts +37 -0
  36. package/dist/lint/post-synth/fixtures/load.d.ts.map +1 -0
  37. package/dist/lint/post-synth/index.d.ts.map +1 -1
  38. package/dist/lint/post-synth/module-source.d.ts +38 -0
  39. package/dist/lint/post-synth/module-source.d.ts.map +1 -0
  40. package/dist/lint/post-synth/scope.d.ts +65 -0
  41. package/dist/lint/post-synth/scope.d.ts.map +1 -0
  42. package/dist/lint/post-synth/tf001.d.ts +58 -6
  43. package/dist/lint/post-synth/tf001.d.ts.map +1 -1
  44. package/dist/lint/post-synth/tf002.d.ts +32 -0
  45. package/dist/lint/post-synth/tf002.d.ts.map +1 -0
  46. package/dist/lint/post-synth/tf003.d.ts +22 -0
  47. package/dist/lint/post-synth/tf003.d.ts.map +1 -0
  48. package/dist/lint/post-synth/tf004.d.ts +22 -0
  49. package/dist/lint/post-synth/tf004.d.ts.map +1 -0
  50. package/dist/lint/post-synth/tf005.d.ts +28 -0
  51. package/dist/lint/post-synth/tf005.d.ts.map +1 -0
  52. package/dist/lint/post-synth/tf006.d.ts +21 -0
  53. package/dist/lint/post-synth/tf006.d.ts.map +1 -0
  54. package/dist/lint/post-synth/tf007.d.ts +21 -0
  55. package/dist/lint/post-synth/tf007.d.ts.map +1 -0
  56. package/dist/lint/post-synth/tf008.d.ts +22 -0
  57. package/dist/lint/post-synth/tf008.d.ts.map +1 -0
  58. package/dist/lint/post-synth/tf009.d.ts +24 -0
  59. package/dist/lint/post-synth/tf009.d.ts.map +1 -0
  60. package/dist/lint/post-synth/tf010.d.ts +19 -0
  61. package/dist/lint/post-synth/tf010.d.ts.map +1 -0
  62. package/dist/lint/post-synth/tf011.d.ts +18 -0
  63. package/dist/lint/post-synth/tf011.d.ts.map +1 -0
  64. package/dist/lint/post-synth/tf012.d.ts +17 -0
  65. package/dist/lint/post-synth/tf012.d.ts.map +1 -0
  66. package/dist/lint/post-synth/tf013.d.ts +21 -0
  67. package/dist/lint/post-synth/tf013.d.ts.map +1 -0
  68. package/dist/lint/post-synth/tf014.d.ts +25 -0
  69. package/dist/lint/post-synth/tf014.d.ts.map +1 -0
  70. package/dist/lint/post-synth/tf015.d.ts +30 -0
  71. package/dist/lint/post-synth/tf015.d.ts.map +1 -0
  72. package/dist/lint/post-synth/tf016.d.ts +30 -0
  73. package/dist/lint/post-synth/tf016.d.ts.map +1 -0
  74. package/dist/lint/post-synth/tf017.d.ts +19 -0
  75. package/dist/lint/post-synth/tf017.d.ts.map +1 -0
  76. package/dist/lint/post-synth/tf018.d.ts +20 -0
  77. package/dist/lint/post-synth/tf018.d.ts.map +1 -0
  78. package/dist/lint/post-synth/tf019.d.ts +25 -0
  79. package/dist/lint/post-synth/tf019.d.ts.map +1 -0
  80. package/dist/lint/post-synth/tf020.d.ts +38 -0
  81. package/dist/lint/post-synth/tf020.d.ts.map +1 -0
  82. package/dist/lint/post-synth/tf021.d.ts +41 -0
  83. package/dist/lint/post-synth/tf021.d.ts.map +1 -0
  84. package/dist/lint/post-synth/tf022.d.ts +24 -0
  85. package/dist/lint/post-synth/tf022.d.ts.map +1 -0
  86. package/dist/lint/post-synth/tf024.d.ts +24 -0
  87. package/dist/lint/post-synth/tf024.d.ts.map +1 -0
  88. package/dist/lint/post-synth/tf025.d.ts +29 -0
  89. package/dist/lint/post-synth/tf025.d.ts.map +1 -0
  90. package/dist/lint/post-synth/tf026.d.ts +28 -0
  91. package/dist/lint/post-synth/tf026.d.ts.map +1 -0
  92. package/dist/lint/post-synth/tf027.d.ts +30 -0
  93. package/dist/lint/post-synth/tf027.d.ts.map +1 -0
  94. package/dist/lint/post-synth/tf028.d.ts +33 -0
  95. package/dist/lint/post-synth/tf028.d.ts.map +1 -0
  96. package/dist/lint/rules/fixtures/load.d.ts +13 -0
  97. package/dist/lint/rules/fixtures/load.d.ts.map +1 -0
  98. package/dist/lint/rules/plan-before-apply.d.ts +11 -0
  99. package/dist/lint/rules/plan-before-apply.d.ts.map +1 -1
  100. package/dist/lint/secret-shape.d.ts +68 -0
  101. package/dist/lint/secret-shape.d.ts.map +1 -0
  102. package/dist/live-ownership.d.ts +55 -0
  103. package/dist/live-ownership.d.ts.map +1 -0
  104. package/dist/lsp/option-keys.d.ts.map +1 -1
  105. package/dist/manifest.json +1 -1
  106. package/dist/okf/index.md +26 -0
  107. package/dist/okf/rules/TF002.md +11 -0
  108. package/dist/okf/rules/TF003.md +11 -0
  109. package/dist/okf/rules/TF004.md +11 -0
  110. package/dist/okf/rules/TF005.md +11 -0
  111. package/dist/okf/rules/TF006.md +11 -0
  112. package/dist/okf/rules/TF007.md +11 -0
  113. package/dist/okf/rules/TF008.md +11 -0
  114. package/dist/okf/rules/TF009.md +11 -0
  115. package/dist/okf/rules/TF010.md +11 -0
  116. package/dist/okf/rules/TF011.md +11 -0
  117. package/dist/okf/rules/TF012.md +11 -0
  118. package/dist/okf/rules/TF013.md +11 -0
  119. package/dist/okf/rules/TF014.md +11 -0
  120. package/dist/okf/rules/TF015.md +11 -0
  121. package/dist/okf/rules/TF016.md +11 -0
  122. package/dist/okf/rules/TF017.md +11 -0
  123. package/dist/okf/rules/TF018.md +11 -0
  124. package/dist/okf/rules/TF019.md +11 -0
  125. package/dist/okf/rules/TF020.md +11 -0
  126. package/dist/okf/rules/TF021.md +11 -0
  127. package/dist/okf/rules/TF022.md +11 -0
  128. package/dist/okf/rules/TF024.md +11 -0
  129. package/dist/okf/rules/TF025.md +11 -0
  130. package/dist/okf/rules/TF026.md +11 -0
  131. package/dist/okf/rules/TF027.md +11 -0
  132. package/dist/okf/rules/TF028.md +11 -0
  133. package/dist/op/activities/index.d.ts +13 -6
  134. package/dist/op/activities/index.d.ts.map +1 -1
  135. package/dist/op/activities/live-detect.d.ts +51 -0
  136. package/dist/op/activities/live-detect.d.ts.map +1 -0
  137. package/dist/op/activities/terraform.d.ts +466 -17
  138. package/dist/op/activities/terraform.d.ts.map +1 -1
  139. package/dist/op/activity-contracts.d.ts +148 -0
  140. package/dist/op/activity-contracts.d.ts.map +1 -0
  141. package/dist/op/adoption.d.ts +118 -0
  142. package/dist/op/adoption.d.ts.map +1 -0
  143. package/dist/op/builders.d.ts +48 -6
  144. package/dist/op/builders.d.ts.map +1 -1
  145. package/dist/op/resolve-root-mode.d.ts +59 -0
  146. package/dist/op/resolve-root-mode.d.ts.map +1 -0
  147. package/dist/plugin.d.ts.map +1 -1
  148. package/dist/rules/blocks.ts +109 -0
  149. package/dist/rules/module-source.ts +121 -0
  150. package/dist/rules/plan-before-apply.ts +11 -0
  151. package/dist/rules/scope.ts +107 -0
  152. package/dist/rules/tf001.ts +98 -18
  153. package/dist/rules/tf002.ts +151 -0
  154. package/dist/rules/tf003.ts +71 -0
  155. package/dist/rules/tf004.ts +63 -0
  156. package/dist/rules/tf005.ts +76 -0
  157. package/dist/rules/tf006.ts +53 -0
  158. package/dist/rules/tf007.ts +78 -0
  159. package/dist/rules/tf008.ts +75 -0
  160. package/dist/rules/tf009.ts +59 -0
  161. package/dist/rules/tf010.ts +51 -0
  162. package/dist/rules/tf011.ts +49 -0
  163. package/dist/rules/tf012.ts +47 -0
  164. package/dist/rules/tf013.ts +63 -0
  165. package/dist/rules/tf014.ts +72 -0
  166. package/dist/rules/tf015.ts +72 -0
  167. package/dist/rules/tf016.ts +75 -0
  168. package/dist/rules/tf017.ts +50 -0
  169. package/dist/rules/tf018.ts +72 -0
  170. package/dist/rules/tf019.ts +72 -0
  171. package/dist/rules/tf020.ts +123 -0
  172. package/dist/rules/tf021.ts +126 -0
  173. package/dist/rules/tf022.ts +61 -0
  174. package/dist/rules/tf024.ts +70 -0
  175. package/dist/rules/tf025.ts +101 -0
  176. package/dist/rules/tf026.ts +84 -0
  177. package/dist/rules/tf027.ts +74 -0
  178. package/dist/rules/tf028.ts +96 -0
  179. package/dist/skills/chant-terraform.md +1 -1
  180. package/dist/validate.d.ts.map +1 -1
  181. package/package.json +7 -2
  182. package/src/__fixtures__/ACCEPTANCE.md +181 -0
  183. package/src/__fixtures__/live/main.tf +28 -0
  184. package/src/__fixtures__/live-adopt/estate.chdf.hcl +6 -0
  185. package/src/__fixtures__/live-adopt/main.tf +21 -0
  186. package/src/__fixtures__/live-estate/README.md +58 -0
  187. package/src/__fixtures__/live-estate/compute.tf +10 -0
  188. package/src/__fixtures__/live-estate/estate.chdf.hcl +1 -0
  189. package/src/__fixtures__/live-estate/logs.tf +8 -0
  190. package/src/__fixtures__/live-estate/network.tf +24 -0
  191. package/src/__fixtures__/live-estate/rule.tf +11 -0
  192. package/src/__fixtures__/live-estate/unowned.tf +21 -0
  193. package/src/__fixtures__/live-estate/versions.tf +31 -0
  194. package/src/__fixtures__/live-ls.json +98 -0
  195. package/src/__fixtures__/live-plan.json +285 -0
  196. package/src/__fixtures__/live-sidecar/estate.chdf.hcl +3 -0
  197. package/src/__fixtures__/live-sidecar/main.tf +24 -0
  198. package/src/__fixtures__/module-tree/README.md +16 -0
  199. package/src/__fixtures__/module-tree/cycle/main.tf +3 -0
  200. package/src/__fixtures__/module-tree/cycle/modules/a/main.tf +9 -0
  201. package/src/__fixtures__/module-tree/cycle/modules/b/main.tf +9 -0
  202. package/src/__fixtures__/module-tree/missing/main.tf +9 -0
  203. package/src/__fixtures__/module-tree/outside/root/main.tf +9 -0
  204. package/src/__fixtures__/module-tree/root/main.tf +28 -0
  205. package/src/__fixtures__/module-tree/root/modules/cdn/main.tf +15 -0
  206. package/src/__fixtures__/module-tree/root/modules/cdn/modules/bucket/main.tf +11 -0
  207. package/src/__fixtures__/module-tree/shared/main.tf +5 -0
  208. package/src/__fixtures__/references/main.tf +56 -0
  209. package/src/__fixtures__/remote-backend/main.tf +34 -0
  210. package/src/__fixtures__/with-backend/main.tf +7 -0
  211. package/src/codegen/lint-rules-page.test.ts +45 -0
  212. package/src/composites/terraform-adopt-op.acceptance.test.ts +193 -0
  213. package/src/composites/terraform-adopt-op.test.ts +175 -0
  214. package/src/composites/terraform-adopt-op.ts +202 -0
  215. package/src/composites/terraform-apply-op.acceptance.test.ts +188 -5
  216. package/src/composites/terraform-apply-op.test.ts +179 -19
  217. package/src/composites/terraform-apply-op.ts +123 -30
  218. package/src/composites/terraform-watch-op.test.ts +169 -29
  219. package/src/composites/terraform-watch-op.ts +183 -75
  220. package/src/config.ts +32 -3
  221. package/src/describe-resources.live.test.ts +598 -0
  222. package/src/describe-resources.test.ts +53 -0
  223. package/src/describe-resources.ts +811 -28
  224. package/src/hcl/descend.test.ts +162 -0
  225. package/src/hcl/descend.ts +273 -0
  226. package/src/hcl/marker.test.ts +147 -0
  227. package/src/hcl/marker.ts +235 -0
  228. package/src/hcl/parse.test.ts +69 -0
  229. package/src/hcl/parse.ts +269 -27
  230. package/src/hcl/references.test.ts +116 -0
  231. package/src/hcl/references.ts +172 -0
  232. package/src/hcl/roots.ts +59 -5
  233. package/src/hcl/suppressions.test.ts +147 -0
  234. package/src/hcl/suppressions.ts +204 -0
  235. package/src/hcl/value.test.ts +73 -0
  236. package/src/hcl/value.ts +106 -0
  237. package/src/index.ts +31 -1
  238. package/src/lint/audit-catalog.ts +288 -3
  239. package/src/lint/audit-lineage.ts +384 -1
  240. package/src/lint/audit.test.ts +210 -3
  241. package/src/lint/post-synth/blocks.ts +109 -0
  242. package/src/lint/post-synth/fixtures/TF001/negative-cloud.tf +28 -0
  243. package/src/lint/post-synth/fixtures/TF001/negative.tf +30 -0
  244. package/src/lint/post-synth/fixtures/TF001/positive-local.tf +31 -0
  245. package/src/lint/post-synth/fixtures/TF001/positive.tf +24 -0
  246. package/src/lint/post-synth/fixtures/TF002/negative.tf +17 -0
  247. package/src/lint/post-synth/fixtures/TF002/positive-legacy.tf +10 -0
  248. package/src/lint/post-synth/fixtures/TF002/positive-no-version.tf +12 -0
  249. package/src/lint/post-synth/fixtures/TF002/positive.tf +7 -0
  250. package/src/lint/post-synth/fixtures/TF003/negative.tf +10 -0
  251. package/src/lint/post-synth/fixtures/TF003/positive.tf +8 -0
  252. package/src/lint/post-synth/fixtures/TF004/negative-git.tf +3 -0
  253. package/src/lint/post-synth/fixtures/TF004/negative-local.tf +3 -0
  254. package/src/lint/post-synth/fixtures/TF004/negative.tf +4 -0
  255. package/src/lint/post-synth/fixtures/TF004/positive.tf +3 -0
  256. package/src/lint/post-synth/fixtures/TF005/negative-local.tf +3 -0
  257. package/src/lint/post-synth/fixtures/TF005/negative-registry.tf +3 -0
  258. package/src/lint/post-synth/fixtures/TF005/negative-sha.tf +3 -0
  259. package/src/lint/post-synth/fixtures/TF005/negative.tf +3 -0
  260. package/src/lint/post-synth/fixtures/TF005/positive-branch.tf +3 -0
  261. package/src/lint/post-synth/fixtures/TF005/positive-non-semver.tf +3 -0
  262. package/src/lint/post-synth/fixtures/TF005/positive.tf +3 -0
  263. package/src/lint/post-synth/fixtures/TF006/negative.tf +5 -0
  264. package/src/lint/post-synth/fixtures/TF006/positive-empty-default.tf +11 -0
  265. package/src/lint/post-synth/fixtures/TF006/positive.tf +6 -0
  266. package/src/lint/post-synth/fixtures/TF007/negative.tf +10 -0
  267. package/src/lint/post-synth/fixtures/TF007/positive.tf +9 -0
  268. package/src/lint/post-synth/fixtures/TF008/negative-variable.tf +10 -0
  269. package/src/lint/post-synth/fixtures/TF008/negative.tf +8 -0
  270. package/src/lint/post-synth/fixtures/TF008/positive-other-provider.tf +10 -0
  271. package/src/lint/post-synth/fixtures/TF008/positive.tf +5 -0
  272. package/src/lint/post-synth/fixtures/TF009/negative.tf +10 -0
  273. package/src/lint/post-synth/fixtures/TF009/positive.tf +4 -0
  274. package/src/lint/post-synth/fixtures/TF010/negative.tf +5 -0
  275. package/src/lint/post-synth/fixtures/TF010/positive.tf +4 -0
  276. package/src/lint/post-synth/fixtures/TF011/negative.tf +5 -0
  277. package/src/lint/post-synth/fixtures/TF011/positive-blank.tf +5 -0
  278. package/src/lint/post-synth/fixtures/TF011/positive.tf +4 -0
  279. package/src/lint/post-synth/fixtures/TF012/negative.tf +4 -0
  280. package/src/lint/post-synth/fixtures/TF012/positive.tf +3 -0
  281. package/src/lint/post-synth/fixtures/TF013/negative.tf +8 -0
  282. package/src/lint/post-synth/fixtures/TF013/positive-data.tf +8 -0
  283. package/src/lint/post-synth/fixtures/TF013/positive.tf +8 -0
  284. package/src/lint/post-synth/fixtures/TF014/negative/main.tf +26 -0
  285. package/src/lint/post-synth/fixtures/TF014/negative/modules/cdn/main.tf +19 -0
  286. package/src/lint/post-synth/fixtures/TF014/positive/main.tf +16 -0
  287. package/src/lint/post-synth/fixtures/TF014/positive/modules/cdn/main.tf +15 -0
  288. package/src/lint/post-synth/fixtures/TF015/negative/main.tf +13 -0
  289. package/src/lint/post-synth/fixtures/TF015/negative/modules/cdn/main.tf +16 -0
  290. package/src/lint/post-synth/fixtures/TF015/positive/main.tf +13 -0
  291. package/src/lint/post-synth/fixtures/TF015/positive/modules/cdn/main.tf +14 -0
  292. package/src/lint/post-synth/fixtures/TF016/negative-template.tf +7 -0
  293. package/src/lint/post-synth/fixtures/TF016/negative.tf +16 -0
  294. package/src/lint/post-synth/fixtures/TF016/positive-shared-file.tf +12 -0
  295. package/src/lint/post-synth/fixtures/TF016/positive.tf +13 -0
  296. package/src/lint/post-synth/fixtures/TF017/negative.tf +4 -0
  297. package/src/lint/post-synth/fixtures/TF017/positive.tf +5 -0
  298. package/src/lint/post-synth/fixtures/TF018/negative.tf +9 -0
  299. package/src/lint/post-synth/fixtures/TF018/positive-data.tf +9 -0
  300. package/src/lint/post-synth/fixtures/TF018/positive.tf +4 -0
  301. package/src/lint/post-synth/fixtures/TF019/negative.tf +14 -0
  302. package/src/lint/post-synth/fixtures/TF019/positive-output.tf +5 -0
  303. package/src/lint/post-synth/fixtures/TF019/positive.tf +16 -0
  304. package/src/lint/post-synth/fixtures/TF020/negative.tf +43 -0
  305. package/src/lint/post-synth/fixtures/TF020/positive.tf +32 -0
  306. package/src/lint/post-synth/fixtures/TF020/scoped/main.tf +21 -0
  307. package/src/lint/post-synth/fixtures/TF020/scoped/modules/cdn/main.tf +13 -0
  308. package/src/lint/post-synth/fixtures/TF021/negative.tf +31 -0
  309. package/src/lint/post-synth/fixtures/TF021/positive-length.tf +8 -0
  310. package/src/lint/post-synth/fixtures/TF021/positive.tf +8 -0
  311. package/src/lint/post-synth/fixtures/TF022/negative-locator.tf +7 -0
  312. package/src/lint/post-synth/fixtures/TF022/negative.tf +10 -0
  313. package/src/lint/post-synth/fixtures/TF022/positive-nested.tf +10 -0
  314. package/src/lint/post-synth/fixtures/TF022/positive.tf +6 -0
  315. package/src/lint/post-synth/fixtures/TF023/negative/main.tf +15 -0
  316. package/src/lint/post-synth/fixtures/TF023/positive/main.tf +9 -0
  317. package/src/lint/post-synth/fixtures/TF023/positive/state.json +24 -0
  318. package/src/lint/post-synth/fixtures/TF024/live-clean/main.tf +9 -0
  319. package/src/lint/post-synth/fixtures/TF024/live-with-backend/main.tf +14 -0
  320. package/src/lint/post-synth/fixtures/TF024/live-with-cloud/main.tf +16 -0
  321. package/src/lint/post-synth/fixtures/TF025/live-clean/main.tf +13 -0
  322. package/src/lint/post-synth/fixtures/TF025/live-with-workspace-ref/main.tf +13 -0
  323. package/src/lint/post-synth/fixtures/TF026/live-default/main.tf +9 -0
  324. package/src/lint/post-synth/fixtures/TF026/live-explicit-delete/main.tf +13 -0
  325. package/src/lint/post-synth/fixtures/TF026/live-keep/main.tf +13 -0
  326. package/src/lint/post-synth/fixtures/TF027/live-default/main.tf +9 -0
  327. package/src/lint/post-synth/fixtures/TF027/live-untagged-delete/main.tf +13 -0
  328. package/src/lint/post-synth/fixtures/TF027/live-untagged-delete-scoped/main.tf +17 -0
  329. package/src/lint/post-synth/fixtures/TF027/live-untagged-report/main.tf +13 -0
  330. package/src/lint/post-synth/fixtures/TF028/live/main.tf +9 -0
  331. package/src/lint/post-synth/fixtures/TF028/stock/main.tf +10 -0
  332. package/src/lint/post-synth/fixtures/load.ts +108 -0
  333. package/src/lint/post-synth/index.ts +52 -0
  334. package/src/lint/post-synth/live-refusals-config-format.test.ts +143 -0
  335. package/src/lint/post-synth/module-rules.test.ts +153 -0
  336. package/src/lint/post-synth/module-source.test.ts +75 -0
  337. package/src/lint/post-synth/module-source.ts +121 -0
  338. package/src/lint/post-synth/post-synth.test.ts +73 -16
  339. package/src/lint/post-synth/scope.ts +107 -0
  340. package/src/lint/post-synth/single-block.test.ts +263 -0
  341. package/src/lint/post-synth/suppression.test.ts +110 -0
  342. package/src/lint/post-synth/tf001.ts +98 -18
  343. package/src/lint/post-synth/tf002.test.ts +93 -0
  344. package/src/lint/post-synth/tf002.ts +151 -0
  345. package/src/lint/post-synth/tf003.test.ts +75 -0
  346. package/src/lint/post-synth/tf003.ts +71 -0
  347. package/src/lint/post-synth/tf004.test.ts +47 -0
  348. package/src/lint/post-synth/tf004.ts +63 -0
  349. package/src/lint/post-synth/tf005.test.ts +57 -0
  350. package/src/lint/post-synth/tf005.ts +76 -0
  351. package/src/lint/post-synth/tf006.ts +53 -0
  352. package/src/lint/post-synth/tf007.ts +78 -0
  353. package/src/lint/post-synth/tf008.ts +75 -0
  354. package/src/lint/post-synth/tf009.ts +59 -0
  355. package/src/lint/post-synth/tf010.ts +51 -0
  356. package/src/lint/post-synth/tf011.ts +49 -0
  357. package/src/lint/post-synth/tf012.ts +47 -0
  358. package/src/lint/post-synth/tf013.ts +63 -0
  359. package/src/lint/post-synth/tf014.ts +72 -0
  360. package/src/lint/post-synth/tf015.ts +72 -0
  361. package/src/lint/post-synth/tf016.ts +75 -0
  362. package/src/lint/post-synth/tf017.ts +50 -0
  363. package/src/lint/post-synth/tf018.ts +72 -0
  364. package/src/lint/post-synth/tf019.ts +72 -0
  365. package/src/lint/post-synth/tf020.ts +123 -0
  366. package/src/lint/post-synth/tf021.ts +126 -0
  367. package/src/lint/post-synth/tf022.ts +61 -0
  368. package/src/lint/post-synth/tf024.test.ts +42 -0
  369. package/src/lint/post-synth/tf024.ts +70 -0
  370. package/src/lint/post-synth/tf025.test.ts +46 -0
  371. package/src/lint/post-synth/tf025.ts +101 -0
  372. package/src/lint/post-synth/tf026.test.ts +56 -0
  373. package/src/lint/post-synth/tf026.ts +84 -0
  374. package/src/lint/post-synth/tf027.test.ts +62 -0
  375. package/src/lint/post-synth/tf027.ts +74 -0
  376. package/src/lint/post-synth/tf028.test.ts +92 -0
  377. package/src/lint/post-synth/tf028.ts +96 -0
  378. package/src/lint/presets.test.ts +72 -0
  379. package/src/lint/rules/fixtures/TF101/negative-op.ts +2 -0
  380. package/src/lint/rules/fixtures/TF101/positive-op.ts +2 -0
  381. package/src/lint/rules/fixtures/load.ts +53 -0
  382. package/src/lint/rules/plan-before-apply.test.ts +112 -7
  383. package/src/lint/rules/plan-before-apply.ts +11 -0
  384. package/src/lint/secret-shape.test.ts +150 -0
  385. package/src/lint/secret-shape.ts +159 -0
  386. package/src/live-ownership.ts +60 -0
  387. package/src/lsp/completions.test.ts +3 -2
  388. package/src/lsp/option-keys.ts +12 -6
  389. package/src/op/activities/choudoufu.acceptance.test.ts +127 -0
  390. package/src/op/activities/choudoufu.test.ts +725 -0
  391. package/src/op/activities/index.ts +40 -4
  392. package/src/op/activities/live-detect.test.ts +143 -0
  393. package/src/op/activities/live-detect.ts +162 -0
  394. package/src/op/activities/registry.test.ts +11 -3
  395. package/src/op/activities/terraform.test.ts +7 -3
  396. package/src/op/activities/terraform.ts +861 -69
  397. package/src/op/activity-contracts.test.ts +147 -0
  398. package/src/op/activity-contracts.ts +178 -0
  399. package/src/op/adoption.test.ts +170 -0
  400. package/src/op/adoption.ts +241 -0
  401. package/src/op/builders.test.ts +60 -5
  402. package/src/op/builders.ts +95 -5
  403. package/src/op/resolve-root-mode.test.ts +85 -0
  404. package/src/op/resolve-root-mode.ts +86 -0
  405. package/src/plugin.test.ts +106 -0
  406. package/src/plugin.ts +186 -29
  407. package/src/skills/chant-terraform.md +1 -1
  408. package/src/validate.ts +10 -1
@@ -19,8 +19,12 @@
19
19
  */
20
20
  import { type Hcl2Json } from "@intentius/chant/terraform/parse";
21
21
  import { type Declarable } from "@intentius/chant/declarable";
22
+ import type { SuppressionDirective } from "@intentius/chant/lint/suppressions";
23
+ import type { TerraformDeleteMode } from "../config.js";
22
24
  /** A parsed HCL block body, as `@cdktf/hcl2json` encodes it. */
23
25
  export type BlockBody = Record<string, unknown>;
26
+ /** Whether a root runs under choudoufu with a declared estate (#2103). */
27
+ export type TerraformRootMode = "live" | "state";
24
28
  /** The entity every block becomes. `props` is what post-synth checks read. */
25
29
  export interface TerraformEntity extends Declarable {
26
30
  readonly lexicon: "terraform";
@@ -34,7 +38,70 @@ export interface TerraformEntity extends Declarable {
34
38
  readonly file: string;
35
39
  /** Configured root name this block belongs to. */
36
40
  readonly root: string;
41
+ /**
42
+ * The chain of `module.<name>` calls that reached this block, outermost
43
+ * first (chant #2112). Empty or absent on a block declared in the root
44
+ * module itself; `["module.cdn"]` on a block of the module `./modules/cdn`
45
+ * called as `cdn` from the root; `["module.cdn", "module.bucket"]` one
46
+ * level deeper. The same chain is in the entity key, which is
47
+ * `<root>/module.cdn/<address>` for the first case, so a reader can tell
48
+ * root scope from child scope from either.
49
+ *
50
+ * The names are the CALL names (`module.<label>`), not the directory the
51
+ * source points at, matching `terraform show -json`'s `child_modules[]`
52
+ * addresses, choudoufu's marker grammar, and tflint's `Callers:` chain.
53
+ */
54
+ readonly callers?: readonly string[];
55
+ /**
56
+ * Whether this root is live: `terraform.binary` is `"choudoufu"` and an
57
+ * estate is declared (a `live` block or an `estate.chdf.hcl` sidecar).
58
+ * Set on every entity of the root, not just the `Terraform::Live` one, so
59
+ * a post-synth check or `describeResources()` reads it without
60
+ * re-parsing (#2103). Absent when the caller supplied no `binary` (the
61
+ * `chant audit` content path, which has no project config to read).
62
+ */
63
+ readonly mode?: TerraformRootMode;
64
+ /** The declared estate name. Present only when `mode` is `"live"`. */
65
+ readonly estate?: string;
66
+ /** `terraform.roots.<name>.workspace`, recorded so TF025 can flag a non-default one on a live root. */
67
+ readonly workspace?: string;
68
+ /**
69
+ * `terraform.roots.<name>.delete` (#2106), recorded so TF026 can check a
70
+ * live root declaring `"never"` against its `policy` block's
71
+ * `undeclared_tagged` setting. Present regardless of mode, same as
72
+ * `workspace`; only a live root's TF026 reads it.
73
+ */
74
+ readonly delete?: TerraformDeleteMode;
75
+ /**
76
+ * 1-based line the block's header starts on, from a line scan over the
77
+ * raw source (chant #2111): hcl2json exposes no ranges to read this from
78
+ * instead (see `../hcl/suppressions.ts`). Undefined when the scan's block
79
+ * regex didn't recognize the header (unusual formatting); a suppression
80
+ * comment simply can't anchor to that block then.
81
+ */
82
+ readonly line?: number;
83
+ /**
84
+ * The raw text of the file this block came from, verbatim.
85
+ *
86
+ * Every other field here is post-`hcl2json`, and that parse is lossy in
87
+ * one way that matters: it renders a bare reference (`value = var.x`) and
88
+ * a quoted interpolation (`value = "${var.x}"`) as the same string,
89
+ * `"${var.x}"`. The second is the deprecated pre-0.12 form TF016 reports
90
+ * and the first is idiomatic, so a check written against `body` alone
91
+ * would flag every reference in the root. The source text is where the
92
+ * quotes still exist. Empty when a caller built the entity by hand.
93
+ */
94
+ readonly source: string;
37
95
  };
96
+ /**
97
+ * `# chant-ignore`/`chant-ignore-file`/`chant-ignore-block` directives that
98
+ * apply to this entity (chant #2111): the ones anchored to its own block,
99
+ * plus any file-level one. Read generically by
100
+ * `@intentius/chant/lint/suppressions`'s `entitySuppressions()`; see that
101
+ * module's doc comment for why this is a plain duck-typed field rather than
102
+ * a `PostSynthContext` addition.
103
+ */
104
+ readonly suppressions?: readonly SuppressionDirective[];
38
105
  }
39
106
  /** `entityType` per block kind. */
40
107
  export declare const TERRAFORM_TYPE = "Terraform::Terraform";
@@ -45,6 +112,10 @@ export declare const MODULE_TYPE = "Terraform::Module";
45
112
  export declare const VARIABLE_TYPE = "Terraform::Variable";
46
113
  export declare const OUTPUT_TYPE = "Terraform::Output";
47
114
  export declare const LOCALS_TYPE = "Terraform::Locals";
115
+ /** A `live { estate = "..." }` block, or an `estate.chdf.hcl` sidecar's content (#2103). */
116
+ export declare const LIVE_TYPE = "Terraform::Live";
117
+ /** The sidecar filename choudoufu reads an estate declaration from when no in-block `live { }` is used. */
118
+ export declare const LIVE_SIDECAR_FILENAME = "estate.chdf.hcl";
48
119
  /**
49
120
  * Build one entity. Written out rather than run through `createResource`
50
121
  * from `@intentius/chant/runtime`: that factory is for generated resource
@@ -53,7 +124,13 @@ export declare const LOCALS_TYPE = "Terraform::Locals";
53
124
  * carries the same marker, so `isDeclarable()` and `isResourceDeclarable()`
54
125
  * both hold.
55
126
  */
56
- export declare function terraformEntity(entityType: string, address: string, body: BlockBody, file: string, root: string): TerraformEntity;
127
+ export declare function terraformEntity(entityType: string, address: string, body: BlockBody, file: string, root: string, extra?: {
128
+ mode?: TerraformRootMode;
129
+ estate?: string;
130
+ workspace?: string;
131
+ delete?: TerraformDeleteMode;
132
+ callers?: readonly string[];
133
+ }, source?: string, line?: number, suppressions?: readonly SuppressionDirective[]): TerraformEntity;
57
134
  /** One `.tf` file's name and source. */
58
135
  export interface TerraformFile {
59
136
  name: string;
@@ -66,22 +143,92 @@ export interface TerraformFile {
66
143
  export declare function splitBundleContent(content: string, fallbackName?: string): TerraformFile[];
67
144
  /** Every `.tf` directly under `dir`, in filename order. Non-recursive. */
68
145
  export declare function listTerraformFiles(dir: string): string[];
146
+ /**
147
+ * Read the `estate.chdf.hcl` sidecar beside `dir`'s `.tf` files, if present.
148
+ * Sibling to {@link listTerraformFiles}: the sidecar is plain HCL (a bare
149
+ * `estate = "..."` attribute, no wrapper block) and is never a `.tf` file, so
150
+ * it falls outside that glob and needs its own read.
151
+ */
152
+ export declare function readLiveSidecarFile(dir: string): TerraformFile | undefined;
153
+ /**
154
+ * Options threading the config-level facts a root's mode depends on into the
155
+ * parse, so `blocksToEntities` can stamp `mode`/`estate`/`workspace` onto
156
+ * every entity without a second pass over the project config (#2103).
157
+ */
158
+ export interface TerraformRootModeOptions {
159
+ /** `terraform.binary`. A root is live only when this is `"choudoufu"` and an estate is declared. */
160
+ binary?: string;
161
+ /** `terraform.roots.<name>.workspace`, recorded verbatim regardless of mode. */
162
+ workspace?: string;
163
+ /** `terraform.roots.<name>.delete`, recorded verbatim regardless of mode (#2106). */
164
+ delete?: TerraformDeleteMode;
165
+ }
69
166
  /**
70
167
  * Parse a set of files into entities keyed `<root>/<address>`. Two blocks that
71
168
  * genuinely share an address (two `locals` blocks, or the same address in two
72
169
  * files of one root) are numbered `~2`, `~3` rather than overwriting.
170
+ *
171
+ * Recognises both ways an estate is declared: a `live { }` block nested in a
172
+ * `terraform { }` block of any file here, and, when `sidecar` is given, the
173
+ * `estate.chdf.hcl` sidecar's bare `estate = "..."` attribute. Either becomes
174
+ * a {@link LIVE_TYPE} entity, and the root is live (`mode: "live"`) exactly
175
+ * when `modeOptions.binary` is `"choudoufu"` and one of the two named an
176
+ * estate; that verdict, and the estate name when live, is then stamped onto
177
+ * every entity this call returns, sidecar and in-block declaration alike so
178
+ * a post-synth check or `describeResources()` reads it without re-parsing.
179
+ * When both forms are present the sidecar wins, matching choudoufu's own
180
+ * "the sidecar is the leading one" (choudoufu refuses the combination
181
+ * outright; this lexicon does not police that here, see TF024/TF025 for
182
+ * what it does police on a live root).
183
+ *
184
+ * `callers` is the module-call chain these files were reached through
185
+ * (chant #2112), empty for a root module. When it is non-empty the keys
186
+ * become `<root>/module.<name>/<address>` (one segment per caller) and every
187
+ * entity carries the chain on `props.callers`. `./descend.ts` is what fills
188
+ * it in; nothing else should pass it.
73
189
  */
74
- export declare function blocksToEntities(files: readonly TerraformFile[], root: string, hcl2json?: Hcl2Json): Promise<Map<string, Declarable>>;
190
+ export declare function blocksToEntities(files: readonly TerraformFile[], root: string, hcl2json?: Hcl2Json, modeOptions?: TerraformRootModeOptions, sidecar?: TerraformFile, callers?: readonly string[]): Promise<Map<string, Declarable>>;
75
191
  /**
76
- * Parse a root module directory. Reads every `.tf` directly under `dir`.
77
- * Throws whatever the parser throws for malformed HCL; `buildRoots()` is where
78
- * that becomes a warning.
192
+ * Parse a root module directory. Reads every `.tf` directly under `dir`, plus
193
+ * the `estate.chdf.hcl` sidecar beside them when present. Throws whatever the
194
+ * parser throws for malformed HCL; `buildRoots()` is where that becomes a
195
+ * warning.
79
196
  */
80
- export declare function parseTerraformRootDir(dir: string, root: string, hcl2json?: Hcl2Json): Promise<Map<string, Declarable>>;
197
+ export declare function parseTerraformRootDir(dir: string, root: string, hcl2json?: Hcl2Json, modeOptions?: TerraformRootModeOptions, callers?: readonly string[]): Promise<Map<string, Declarable>>;
81
198
  /**
82
199
  * Parse the joined-file string form `chant audit` produces for a discovered
83
- * root module (`AuditInput.content`). Unwired for now: #2085's
84
- * `auditEntities()` is what calls it.
200
+ * root module (`AuditInput.content`). `auditEntities()` is what calls it; that
201
+ * hook's single-argument contract carries no project config, so `modeOptions`
202
+ * is left undefined there and every entity gets `mode: "state"`; the audit
203
+ * path does not detect live mode (#2103). `modeOptions` exists here mainly for
204
+ * tests exercising the mode-stamping behaviour directly against inline HCL,
205
+ * the same way `parseTerraformRootDir`'s callers exercise it against files.
206
+ */
207
+ export declare function parseTerraformRootContent(content: string, root: string, hcl2json?: Hcl2Json, modeOptions?: TerraformRootModeOptions): Promise<Map<string, Declarable>>;
208
+ /** The root name an audit of the audited directory itself parses under. */
209
+ export declare const AUDIT_ROOT_NAME = "audit-root";
210
+ /**
211
+ * The root name one `chant audit` input parses under (#2217).
212
+ *
213
+ * A build names its roots from `terraform.roots`; an audit has no such
214
+ * config, so the name comes from the input's own path, which is the one thing
215
+ * that tells two discovered roots apart. `envs/prod` becomes `envs.prod`,
216
+ * because an entity key is `<root>/<address>` with the module chain between
217
+ * them and a `/` inside the root name would read as a module scope. The
218
+ * audited directory itself keeps the name {@link AUDIT_ROOT_NAME}, so a
219
+ * single-root audit reads the way it did before an input path was available.
220
+ */
221
+ export declare function auditRootName(path?: string): string;
222
+ /**
223
+ * The module scope an entity key names: the part before the address.
224
+ *
225
+ * `"app/aws_s3_bucket.assets"` is scope `"app"` (the root module);
226
+ * `"app/module.cdn/aws_s3_bucket.assets"` is scope `"app/module.cdn"`. Keys
227
+ * are built here (see {@link blocksToEntities}), so the split lives here too:
228
+ * the reference index (`./references.ts`) and the module-scoped checks read
229
+ * scopes through it rather than re-deriving the key shape.
85
230
  */
86
- export declare function parseTerraformRootContent(content: string, root: string, hcl2json?: Hcl2Json): Promise<Map<string, Declarable>>;
231
+ export declare function scopeOfKey(key: string): string;
232
+ /** The `module.<name>` chain in an entity key, outermost first. Empty for a root-module block. */
233
+ export declare function callersOfKey(key: string): string[];
87
234
  //# sourceMappingURL=parse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/hcl/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEjF,gEAAgE;AAChE,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEhD,8EAA8E;AAC9E,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE;QACd,kFAAkF;QAClF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,qFAAqF;QACrF,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;QACzB,6DAA6D;QAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,kDAAkD;QAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,mCAAmC;AACnC,eAAO,MAAM,cAAc,yBAAyB,CAAC;AACrD,eAAO,MAAM,aAAa,wBAAwB,CAAC;AACnD,eAAO,MAAM,aAAa,wBAAwB,CAAC;AACnD,eAAO,MAAM,SAAS,oBAAoB,CAAC;AAC3C,eAAO,MAAM,WAAW,sBAAsB,CAAC;AAC/C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,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAElC;AAED,2EAA2E;AAC3E,eAAO,MAAM,eAAe,eAAe,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAInD;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG9C;AAED,kGAAkG;AAClG,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAGlD"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Which declarations does a module scope actually reference (chant #2112)?
3
+ *
4
+ * One pass over every entity's body, collecting the reference forms Terraform
5
+ * writes as expressions: `var.<name>`, `local.<name>`, `data.<type>.<name>`,
6
+ * `module.<name>`, and the `provider = <type>.<alias>` / `providers = { <type>
7
+ * = <type>.<alias> }` meta-arguments. The result is keyed per module scope
8
+ * (`./parse.ts`'s `scopeOfKey`), because Terraform's own namespaces are: a
9
+ * `var.region` inside `module.cdn` is the child module's variable, never the
10
+ * root's, and a rule that pooled the two would call a genuinely unused root
11
+ * variable used.
12
+ *
13
+ * ## It is a string scan, and the rules built on it say so
14
+ *
15
+ * hcl2json gives back an expression as a STRING, with the `${...}` wrapper
16
+ * preserved: `count = length(var.subnets)` arrives as `"${length(var.subnets)}"`
17
+ * and `bucket = var.name` as `"${var.name}"`. There is no expression tree to
18
+ * walk, so this scans the strings with regexes. That reads a reference inside
19
+ * a comment-free body correctly and is deliberately generous at the edges: a
20
+ * name that appears inside a quoted literal (`description = "set var.region"`)
21
+ * counts as a reference, and a reference built dynamically
22
+ * (`lookup(local.by_env, terraform.workspace)` reaching a value nothing names
23
+ * directly) does not. Both directions are why TF020 is report-only and credits
24
+ * tflint's `terraform_unused_declarations` as `overlaps` rather than
25
+ * `equivalent`: it is the same question answered with a coarser instrument.
26
+ *
27
+ * The index records WHICH entity each reference came from, so a check can ask
28
+ * "is anything other than the declaration itself referring to this?". A
29
+ * `variable "port"` whose own `validation` block reads `var.port` is the case
30
+ * that needs it: without the exclusion every validated variable would look
31
+ * used.
32
+ */
33
+ import { type Declarable } from "@intentius/chant/declarable";
34
+ import { type BlockBody } from "./parse.js";
35
+ /**
36
+ * Every reference token in one string, in the vocabulary the index keys by:
37
+ * `var.region`, `local.tags`, `data.aws_ami.ubuntu`, `module.cdn`.
38
+ *
39
+ * `data.` is matched before `local.`/`var.` can see it, and a `module.cdn.url`
40
+ * yields `module.cdn`, since the call is what a reference makes used.
41
+ */
42
+ export declare function collectReferences(text: string): string[];
43
+ /**
44
+ * The `provider`/`providers` meta-argument's own reference form, which is not
45
+ * an interpolation and has no prefix of its own: `provider = aws.west` names
46
+ * the `provider "aws" { alias = "west" }` block. Returned in the index's
47
+ * vocabulary, `provider.aws.west`, so it cannot collide with a resource
48
+ * address that happens to look the same.
49
+ */
50
+ export declare function providerReference(value: unknown): string | undefined;
51
+ /** Every reference in one block body, provider meta-arguments included. */
52
+ export declare function referencesInBody(body: BlockBody): string[];
53
+ /**
54
+ * Every reference in one module scope: token to the entity keys whose body
55
+ * mentions it.
56
+ */
57
+ export type ScopeReferences = Map<string, Set<string>>;
58
+ /** Reference tokens per module scope (`<root>`, `<root>/module.<name>`). */
59
+ export interface ReferenceIndex {
60
+ readonly scopes: Map<string, ScopeReferences>;
61
+ }
62
+ /**
63
+ * Build the index over a whole build's entities. Scopes come from the entity
64
+ * keys, so a root and each of its descended child modules are separate, and
65
+ * two roots never pool.
66
+ */
67
+ export declare function buildReferenceIndex(entities: Map<string, Declarable>): ReferenceIndex;
68
+ /** The entity keys in `scope` whose body references `token`. */
69
+ export declare function referencesTo(index: ReferenceIndex, scope: string, token: string): Set<string>;
70
+ /**
71
+ * Is `token` referenced anywhere in `scope` other than by `declaredBy` itself?
72
+ * The exclusion is what keeps a variable read only by its own `validation`
73
+ * block, or a local read only by its own `locals` block, from looking used.
74
+ */
75
+ export declare function isReferenced(index: ReferenceIndex, scope: string, token: string, declaredBy?: string): boolean;
76
+ //# sourceMappingURL=references.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../../src/hcl/references.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAwB,KAAK,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAc,KAAK,SAAS,EAAwB,MAAM,SAAS,CAAC;AAc3E;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAOxD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAMpE;AAED,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,EAAE,CA6B1D;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAEvD,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC/C;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,cAAc,CAqBrF;AAED,gEAAgE;AAChE,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAE7F;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAMT"}
@@ -13,10 +13,16 @@
13
13
  * someone else's estate is the whole job here, and half of it parsing is more
14
14
  * useful than none of it, especially when the audit path (#2085) walks
15
15
  * repositories it did not write.
16
+ *
17
+ * A root's own directory is not the end of the parse: a `module` block with a
18
+ * local source is followed into its directory and parsed as a child scope of
19
+ * the root (#2112). `./descend.ts` owns that walk and every refusal in it; the
20
+ * refusals surface here as this render's warnings.
16
21
  */
17
- import type { Declarable } from "@intentius/chant/declarable";
22
+ import { type Declarable } from "@intentius/chant/declarable";
18
23
  import type { Hcl2Json } from "@intentius/chant/terraform/parse";
19
24
  import type { TerraformRootConfig } from "../config.js";
25
+ import { type CallModuleType } from "./descend.js";
20
26
  export interface TerraformRootsResult {
21
27
  entities: Map<string, Declarable>;
22
28
  warnings: string[];
@@ -26,12 +32,25 @@ export interface RenderTerraformRootsOptions {
26
32
  projectRoot: string;
27
33
  /** `terraform.roots`: name to root-module config. */
28
34
  roots: Readonly<Record<string, TerraformRootConfig>>;
35
+ /**
36
+ * `terraform.binary`. A root is live only when this is `"choudoufu"` and it
37
+ * declares an estate; anything else runs stock (#2103).
38
+ */
39
+ binary?: string;
40
+ /**
41
+ * `terraform.callModuleType` (#2112): how far each root's parse follows its
42
+ * `module` calls. Defaults to `"local"`, so a module sourced from `./` or
43
+ * `../` is parsed as a child scope of the root that calls it.
44
+ */
45
+ callModuleType?: CallModuleType;
29
46
  /** Injectable parser (tests); defaults to core's lazy-loaded `@cdktf/hcl2json`. */
30
47
  hcl2json?: Hcl2Json;
31
48
  }
32
49
  /**
33
- * Parse each configured root into entities keyed `<root>/<address>`. Roots are
34
- * visited in declaration order, and one root's failure never stops the next.
50
+ * Parse each configured root into entities keyed `<root>/<address>`, plus its
51
+ * local child modules, keyed `<root>/module.<name>/<address>` (#2112). Roots
52
+ * are visited in declaration order, and one root's failure never stops the
53
+ * next.
35
54
  */
36
55
  export declare function renderTerraformRoots(opts: RenderTerraformRootsOptions): Promise<TerraformRootsResult>;
37
56
  //# sourceMappingURL=roots.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"roots.d.ts","sourceRoot":"","sources":["../../src/hcl/roots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGrD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAClC,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,2BAA2B;IAC1C,wFAAwF;IACxF,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;IACrD,mFAAmF;IACnF,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,oBAAoB,CAAC,CAsB/B"}
1
+ {"version":3,"file":"roots.d.ts","sourceRoot":"","sources":["../../src/hcl/roots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,EAAwB,KAAK,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EAAyC,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAEvF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAClC,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,2BAA2B;IAC1C,wFAAwF;IACxF,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;IACrD;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,mFAAmF;IACnF,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,oBAAoB,CAAC,CAyD/B"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Read `# chant-ignore*` comments out of raw `.tf` text.
3
+ *
4
+ * `hcl2json` drops comments entirely, and a probe of its output confirmed it
5
+ * exposes no source ranges either, so a suppression comment has nothing to
6
+ * attach to once a file goes through `@cdktf/hcl2json`. This module runs a
7
+ * second, cheap pass over the SAME raw text `./parse.ts` hands the parser,
8
+ * entirely with line-oriented regexes: a brace-depth counter to find each
9
+ * top-level block's start line (`terraform`, `locals`, `provider "x"`,
10
+ * `module "x"`, `variable "x"`, `output "x"`, `resource "t" "n"`,
11
+ * `data "t" "n"`, the exact set `blocksToEntities` turns into entities, and
12
+ * the address format below MUST stay in sync with that function's `add()`
13
+ * calls), and a directive regex for the three comment forms.
14
+ *
15
+ * `scanSuppressions` returns per-file lookups keyed by ADDRESS (`./parse.ts`'s
16
+ * `TerraformEntity.props.address`, e.g. `provider.aws`, `aws_s3_bucket.assets`)
17
+ * rather than by entity, because `blocksToEntities` computes an entity's final
18
+ * map key (with a `~2`/`~3` collision suffix) only after this scan has already
19
+ * run. A FIFO queue per address reconciles the two traversal orders: this
20
+ * scan reads the file top to bottom, but `blocksToEntities` walks hcl2json's
21
+ * tree grouped by section (all `variable` blocks together, then all
22
+ * `resource` blocks, etc.), not in source order. Two blocks that share one
23
+ * address (the same genuinely-duplicated declaration) are matched to their
24
+ * queue slot in file order, same as they're numbered `~2`/`~3` in file order.
25
+ */
26
+ import type { SuppressionDirective } from "@intentius/chant/lint/suppressions";
27
+ /** One file's suppression scan: block start lines by address, and the parsed directives. */
28
+ export interface FileScan {
29
+ /** address -> start lines, in file order (a FIFO queue for repeated addresses). */
30
+ blockLineQueues: Map<string, number[]>;
31
+ /** The block start line a `chant-ignore`/`chant-ignore-block` comment anchors to -> directives found there. */
32
+ byAnchorLine: Map<number, SuppressionDirective[]>;
33
+ /** The file's `chant-ignore-file` directive, if any (`misplaced` set when it wasn't the first non-blank line). */
34
+ fileDirective?: SuppressionDirective;
35
+ }
36
+ /**
37
+ * Scan one `.tf` file's raw text. `fileName` only labels the directives it
38
+ * returns (for messages and dedup); the scan itself is pure text.
39
+ */
40
+ export declare function scanSuppressions(fileName: string, source: string): FileScan;
41
+ /** Pop the next recorded start line for `address` (FIFO; see module doc). */
42
+ export declare function popBlockLine(scan: FileScan, address: string): number | undefined;
43
+ /**
44
+ * Directives to attach to the entity being added for `address`: the ones
45
+ * anchored to its own start line (`chant-ignore`/`chant-ignore-block`), plus
46
+ * the file-level one, if any. Every entity in a file carries a file-level
47
+ * directive, misplaced or not (misplaced ones report themselves but suppress
48
+ * nothing; see `applyInlineSuppressions`).
49
+ */
50
+ export declare function directivesFor(scan: FileScan, address: string): {
51
+ line?: number;
52
+ suppressions?: SuppressionDirective[];
53
+ };
54
+ //# sourceMappingURL=suppressions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suppressions.d.ts","sourceRoot":"","sources":["../../src/hcl/suppressions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAkB,MAAM,oCAAoC,CAAC;AA0E/F,4FAA4F;AAC5F,MAAM,WAAW,QAAQ;IACvB,mFAAmF;IACnF,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACvC,+GAA+G;IAC/G,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAC,CAAC;IAClD,kHAAkH;IAClH,aAAa,CAAC,EAAE,oBAAoB,CAAC;CACtC;AAQD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CA8D3E;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIhF;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,oBAAoB,EAAE,CAAA;CAAE,CAKvH"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * A value envelope over a parsed block body (chant #2113).
3
+ *
4
+ * Every TF post-synth check reads `BlockBody` (`./parse.ts`), raw
5
+ * `@cdktf/hcl2json` output, and re-derives, by hand, whether an attribute is
6
+ * a plain literal, a reference/expression, or absent. tflint's OPA ruleset
7
+ * hands a policy `{value, unknown, sensitive, ephemeral, range}` per
8
+ * attribute so a check reads that uniformly instead of re-deriving it
9
+ * (`tflint-ruleset-opa`'s `docs/functions.md`, cited in the #2107 survey).
10
+ * `attr()` is the equivalent for chant's static string-based body.
11
+ *
12
+ * The shape here is narrower than tflint's for one structural reason.
13
+ * hcl2json converts HCL to plain JSON with no evaluation and no position
14
+ * data. There is no live Terraform graph behind this parse, so there is no
15
+ * `unknown` (this runs over source, not a plan), and no `sensitive`/
16
+ * `ephemeral` flag (those live on a `variable` block's own attributes, not on
17
+ * every attribute that happens to reference one; a check that cares reads
18
+ * the referenced variable's declaration itself). `range` is the one field
19
+ * tflint's envelope carries that this cannot. hcl2json's own output is bare
20
+ * values, JSON-round-tripped from HCL, with no line/column/byte-range
21
+ * attached anywhere in the tree, so there is nothing for `attr()` to read a
22
+ * position from. (#2111 adds a `props.line` to the *entity*, from a separate
23
+ * text-based mechanism this file does not touch and is not a substitute for
24
+ * per-attribute ranges. See that issue for how it gets a line at all.)
25
+ */
26
+ import type { BlockBody } from "./parse.js";
27
+ /** What kind of value an attribute holds, once template interpolation is accounted for. */
28
+ export type AttrKind = "literal" | "reference" | "template" | "absent";
29
+ /**
30
+ * The value envelope `attr()` returns for one attribute of a block body.
31
+ *
32
+ * `raw` is always the untouched `body[name]` (or `undefined` when absent),
33
+ * so a caller that needs the original hcl2json value for a case this
34
+ * envelope doesn't model can still reach it without a second lookup.
35
+ */
36
+ export interface AttrValue {
37
+ kind: AttrKind;
38
+ /**
39
+ * The attribute's value when `kind` is `"literal"`: a string, number,
40
+ * boolean, array or object, verbatim from hcl2json. Absent for every other
41
+ * kind (a reference/template's "value" is not known statically).
42
+ */
43
+ value?: unknown;
44
+ /**
45
+ * The expression(s) found inside `${...}` for `"reference"` and
46
+ * `"template"`: one entry for `"reference"` (the whole interpolation),
47
+ * one per `${...}` span in source order for `"template"`. Absent for
48
+ * `"literal"`/`"absent"`.
49
+ */
50
+ refs?: string[];
51
+ /** The untouched `body[name]`, regardless of `kind`. `undefined` when absent. */
52
+ raw: unknown;
53
+ }
54
+ /**
55
+ * Read one attribute of a parsed block body as a value envelope.
56
+ *
57
+ * - `"absent"`: `name` is not a key of `body` at all (or is `undefined`/`null`).
58
+ * - `"reference"`: the value is a string that is nothing but one
59
+ * `${...}` interpolation (`"${aws_s3_bucket.foo.id}"`, `"${var.x}"`,
60
+ * `"${lower(var.x)}"`; a function call counts, since the whole value is
61
+ * still one expression, not a literal). `refs` carries that one expression.
62
+ * - `"template"`: the value is a string with `${...}` interpolation mixed
63
+ * with literal text (`"prefix-${var.x}-suffix"`, or two interpolations in
64
+ * one string). `refs` carries every span found, in source order.
65
+ * - `"literal"`: anything else. A plain string with no interpolation, a
66
+ * number, a boolean, an array, or an object (which is how hcl2json encodes
67
+ * a nested block under the same key a caller might ask `attr()` about, so
68
+ * a nested block reads as `kind: "literal"` with `value` holding its body
69
+ * or bodies array). See `hasBlock()` in `../lint/post-synth/tf001.ts`,
70
+ * which is exactly that case.
71
+ *
72
+ * A malformed `${` with no matching `}` is not specially detected; it falls
73
+ * through to `"literal"` (no complete span found), matching hcl2json's own
74
+ * behavior of passing such text through as a plain string.
75
+ */
76
+ export declare function attr(body: BlockBody, name: string): AttrValue;
77
+ //# sourceMappingURL=value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value.d.ts","sourceRoot":"","sources":["../../src/hcl/value.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,2FAA2F;AAC3F,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,QAAQ,CAAC;IACf;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,iFAAiF;IACjF,GAAG,EAAE,OAAO,CAAC;CACd;AAcD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAc7D"}
package/dist/index.d.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  export { terraformPlugin } from "./plugin.js";
2
2
  export { terraformSerializer } from "./serializer.js";
3
3
  export { terraformConfigSchema, terraformRootSchema, type TerraformConfig, type TerraformRootConfig, type TerraformConfigNamespace, } from "./config.js";
4
- export { blocksToEntities, parseTerraformRootContent, parseTerraformRootDir, splitBundleContent, terraformEntity, DATA_TYPE, LOCALS_TYPE, MODULE_TYPE, OUTPUT_TYPE, PROVIDER_TYPE, RESOURCE_TYPE, TERRAFORM_TYPE, VARIABLE_TYPE, type BlockBody, type TerraformEntity, type TerraformFile, } from "./hcl/parse.js";
4
+ export { blocksToEntities, parseTerraformRootContent, parseTerraformRootDir, readLiveSidecarFile, splitBundleContent, terraformEntity, DATA_TYPE, LIVE_SIDECAR_FILENAME, LIVE_TYPE, LOCALS_TYPE, MODULE_TYPE, OUTPUT_TYPE, PROVIDER_TYPE, RESOURCE_TYPE, TERRAFORM_TYPE, VARIABLE_TYPE, type BlockBody, type TerraformEntity, type TerraformFile, type TerraformRootMode, type TerraformRootModeOptions, } from "./hcl/parse.js";
5
5
  export { renderTerraformRoots, type TerraformRootsResult } from "./hcl/roots.js";
6
- export { terraformInit, terraformPlan, terraformApply, terraformShow } from "./op/builders.js";
6
+ export { terraformInit, terraformPlan, terraformApply, terraformShow, choudoufuLivePlan, choudoufuLiveLs, choudoufuLiveCheck, choudoufuAdopt, } from "./op/builders.js";
7
+ export { parseAdoptionCommands, readAdoptionLedger, renderAdoptionLedger, type AdoptionCandidate, type AdoptionLedger, } from "./op/adoption.js";
7
8
  export { TerraformApplyOp } from "./composites/terraform-apply-op.js";
8
9
  export type { TerraformApplyOpConfig, TerraformApplyOpResources, TerraformGateMode, } from "./composites/terraform-apply-op.js";
9
10
  export { TerraformWatchOp } from "./composites/terraform-watch-op.js";
10
11
  export type { TerraformWatchOpConfig, TerraformWatchOpResources, TerraformFindingMode, } from "./composites/terraform-watch-op.js";
12
+ export { TerraformAdoptOp } from "./composites/terraform-adopt-op.js";
13
+ export type { TerraformAdoptOpConfig, TerraformAdoptOpResources } from "./composites/terraform-adopt-op.js";
11
14
  export { TERRAFORM_STATE_OWNERSHIP_KEYS } from "./state-ownership.js";
12
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,E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,gBAAgB,EAChB,yBAAyB,EACzB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,SAAS,EACT,qBAAqB,EACrB,SAAS,EACT,WAAW,EACX,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,cAAc,EACd,aAAa,EACb,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,GAC9B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,oBAAoB,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAK9E,OAAO,EACL,aAAa,EACb,aAAa,EACb,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,cAAc,GACf,MAAM,eAAe,CAAC;AAKvB,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,YAAY,EACV,sBAAsB,EACtB,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,YAAY,EACV,sBAAsB,EACtB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AAIzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,YAAY,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAKzG,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,12 +1,41 @@
1
1
  {
2
2
  "algorithm": "sha256",
3
3
  "artifacts": {
4
- "manifest.json": "8f4e78f1493a0dce03ed3956c7e35bd59583b665839b1d854212ce492cf000de",
4
+ "manifest.json": "72419cbdd570f0b9377021d5d5b5668a5bacdbdf57e157d6cdcbc86aaf97497b",
5
5
  "meta.json": "ca3d163bab055381827226140568f3bef7eaac187cebd76878e0b63e9e442356",
6
6
  "types/index.d.ts": "022927e6a7b351cc4cf52d5f973f60ccd140e5810e17b32fb8868965aa1db161",
7
- "rules/plan-before-apply.ts": "b902d738a9cd4596b569f66b404c8e0e8358e58749708e76eb2521c459fb2f47",
8
- "rules/tf001.ts": "1000540a1d2958efbae3356b221934f4c7ee76e977704d0e793a9864fd2d2936",
9
- "skills/chant-terraform.md": "37b719bc43242250d61b80a6ee5c91da8e0c67a959cc92e2c182e3951adb8912"
7
+ "rules/plan-before-apply.ts": "31b1b3176799fd365b2583fe3947edd187c2a863e3dc0094ed9e91ece2464c99",
8
+ "rules/blocks.ts": "d69f65c13b44ff425ccd465644f41c160e07b4c221bd60698d3ec84bf5d9cef8",
9
+ "rules/module-source.ts": "147025cf53eba006473ddcb771bf7452928fc476e6daee10bbb86bcc7ee3848a",
10
+ "rules/scope.ts": "a6d327d821f219c98a9d4ae6e6eed6325f3d3edf6286f3622b41be591d190dc8",
11
+ "rules/tf001.ts": "1f07f0f9172a7ddb9c726ba4be1bea08e54e25701fbe59cc54c3cf4401aca999",
12
+ "rules/tf002.ts": "27720fcb578cceb1bfff86849d46b0309276f5a88d092eddcb7d7b961d1f5cd8",
13
+ "rules/tf003.ts": "7b705a08f03769f353910e524bb3f1b4cc844bcb620e240a9063288d0fd60802",
14
+ "rules/tf004.ts": "59ef2108aa561cc6a40cd970fc54604be60872b51a035ed3bc3c53346a31d358",
15
+ "rules/tf005.ts": "17fbaf5ac205c8a768415eacd2cbfb7749e9a251c8f2d0c05dce7462db7fa821",
16
+ "rules/tf006.ts": "2d6a80d048cb337d189e735224437ac851b51d73d9ff55f5d1ffedf736c16fb0",
17
+ "rules/tf007.ts": "9a1eeb1dbaf230b841cc32f2753219e57a6e7a2296d9ed6c1fb1e8e38a9a594d",
18
+ "rules/tf008.ts": "b09eefcdf6c37207d9d7270d1753a7812a0a07d2e88767f8c7a7885e42c0a730",
19
+ "rules/tf009.ts": "8631838f4756e5fdc163ccc283e59002accdcbe4384d11ee20a2be9514f7b2a9",
20
+ "rules/tf010.ts": "fc5937dc3ad87f5a127395e9793878b6bcac402b3006a715be97aabc1857ae32",
21
+ "rules/tf011.ts": "e7406f1b07205782df76690bd3f4882a540da0309bdcd63b6bc019ab4d46a927",
22
+ "rules/tf012.ts": "071d542786a1d5c19d485ab3e8fadb16210ba1c90a51843bf18b620cf99fe2a3",
23
+ "rules/tf013.ts": "096c3e7e51a8a54fd4354f6a93dc1f3540e155ef5e6ef39407904465803aaa2c",
24
+ "rules/tf014.ts": "c17d6c75fe0d38984a0108f4238667e9c069a0a761811d59f8ef9f67b5d8c5f3",
25
+ "rules/tf015.ts": "7190c71139f66ed0862725aead01b5eb3e6d366d1318a0506060b4c3d2417364",
26
+ "rules/tf016.ts": "4dc8a815ee91bac7551bde90af0f5315bd8c03a0a090f19bd62ad305e0a06c93",
27
+ "rules/tf017.ts": "1b11c1a21aca33f5e634732fd23b57ac4c2e02af9ef531890d88c401fa593832",
28
+ "rules/tf018.ts": "188a56a73c53423ce4b653540cb4ab2b7aa64d10bb9bad090d392e2bfd821d0a",
29
+ "rules/tf019.ts": "ae1841a358e5b7a3f42c484f0b5cf1c1f5aa845a50516969a46d65b13e282951",
30
+ "rules/tf020.ts": "2210815c355e37459c34de0fe622f0b87b78010ee7c444135cf5abf7e048adf7",
31
+ "rules/tf021.ts": "ad3cd813a289437d33da866927697077e7a5b20f3c05341325193d286b57bbd5",
32
+ "rules/tf022.ts": "87483762b02e947aba94ec9b79fb9bf4dd6442287d602836306bc66b4a239a35",
33
+ "rules/tf024.ts": "c0c101f913bd3d0fdb5403ee57888e80d8fc612e363f0eb43d7ae759ac1d5651",
34
+ "rules/tf025.ts": "0c31be3885e940e2b3e9ac8e023067d8d6e2b42c04f628890405c9fc6db7d1ce",
35
+ "rules/tf026.ts": "8cf1e61bc9563aa2d3c149f243ffa02ad4f183eebb672f861cd6c4e6fba1d310",
36
+ "rules/tf027.ts": "0a6062a230cdaa707f82b2353be4b34dff81322d24075d46f732a47bcef15893",
37
+ "rules/tf028.ts": "81ef95659c40ad1774c83e663473ed769143d894a4ba0517c3defa31f00ba723",
38
+ "skills/chant-terraform.md": "d9ca7b7c28aed0038ce775a3491150298492eed2858fd3651ed9bfca0e577ae8"
10
39
  },
11
- "composite": "a69f5327abd011e634c05a6b123cb9680268a127a7f07e29615204bf1277c319"
40
+ "composite": "94781f63613068bbab5988a6ec1a8a42d3bc0e6c7a3e781da466289995866e5a"
12
41
  }
@@ -4,8 +4,9 @@
4
4
  * Every post-synth check needs an entry or it contributes nothing to
5
5
  * `chant audit`, silently, and `packages/core/src/audit/catalog.test.ts` fails.
6
6
  *
7
- * TF001 reads the chant model (`ctx.entities`), never emitted output, so
8
- * `yamlBased` is false. Prior-art lineage lives in ./audit-lineage.ts.
7
+ * TF001 and TF024 through TF028 all read the chant model (`ctx.entities`),
8
+ * never emitted output, so `yamlBased` is false for all of them. Prior-art
9
+ * lineage lives in ./audit-lineage.ts.
9
10
  */
10
11
  import type { RuleMeta } from "@intentius/chant/audit/catalog";
11
12
  export declare const terraformAuditCatalog: Record<string, RuleMeta>;
@@ -1 +1 @@
1
- {"version":3,"file":"audit-catalog.d.ts","sourceRoot":"","sources":["../../src/lint/audit-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAI/D,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAY1D,CAAC"}
1
+ {"version":3,"file":"audit-catalog.d.ts","sourceRoot":"","sources":["../../src/lint/audit-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAe1E,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CA6R1D,CAAC"}