@md-code/follow-architecture 0.3.0 → 0.3.3

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 (382) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +1341 -472
  3. package/dist/args.d.ts +4 -0
  4. package/dist/args.js +18 -1
  5. package/dist/bin/follow-architecture.js +3 -3
  6. package/dist/closure-project.d.ts +4 -0
  7. package/dist/closure-project.js +122 -0
  8. package/dist/code-entities/classify.d.ts +11 -0
  9. package/dist/code-entities/classify.js +45 -0
  10. package/dist/code-entities/connector.d.ts +8 -0
  11. package/dist/code-entities/connector.js +119 -0
  12. package/dist/code-entities/entities.d.ts +9 -0
  13. package/dist/{code-roles/roles.js → code-entities/entities.js} +81 -54
  14. package/dist/code-entities/project.d.ts +21 -0
  15. package/dist/code-entities/project.js +249 -0
  16. package/dist/code-entities/walk.d.ts +31 -0
  17. package/dist/code-entities/walk.js +95 -0
  18. package/dist/config-options.d.ts +23 -0
  19. package/dist/config-options.js +18 -1
  20. package/dist/config-project.js +10 -2
  21. package/dist/config-report.d.ts +1 -1
  22. package/dist/config-report.js +20 -3
  23. package/dist/config-rule.d.ts +25 -0
  24. package/dist/config-rule.js +89 -6
  25. package/dist/config-state.d.ts +14 -3
  26. package/dist/config-state.js +180 -17
  27. package/dist/config.d.ts +25 -0
  28. package/dist/css/index.d.ts +11 -7
  29. package/dist/css/index.js +124 -23
  30. package/dist/css/syntax/css/gate.js +5 -5
  31. package/dist/css/syntax/css/index.d.ts +1 -1
  32. package/dist/css/syntax/css/index.js +1 -1
  33. package/dist/css/syntax/css/reference.d.ts +1 -1
  34. package/dist/css/syntax/css/reference.js +15 -3
  35. package/dist/css/syntax/language.d.ts +1 -1
  36. package/dist/css/syntax/language.js +4 -2
  37. package/dist/css/syntax/scss/index.d.ts +2 -2
  38. package/dist/css/syntax/scss/index.js +1 -1
  39. package/dist/css/syntax/scss/reference.d.ts +1 -1
  40. package/dist/css/syntax/scss/reference.js +7 -1
  41. package/dist/css/syntax/styled/document.d.ts +3 -3
  42. package/dist/css/syntax/styled/document.js +17 -7
  43. package/dist/css/syntax/styled/markup.d.ts +1 -1
  44. package/dist/css/syntax/styled/markup.js +22 -14
  45. package/dist/css/syntax/styled/tags.d.ts +2 -0
  46. package/dist/css/syntax/styled/tags.js +22 -0
  47. package/dist/css/syntax/styled/template.js +10 -4
  48. package/dist/css/syntax/tailwind/tailwind.js +4 -4
  49. package/dist/css/value/check.d.ts +1 -1
  50. package/dist/css/value/check.js +1 -1
  51. package/dist/css/value/expression/arithmetic.d.ts +2 -2
  52. package/dist/css/value/expression/arithmetic.js +7 -3
  53. package/dist/css/value/expression/block.d.ts +2 -2
  54. package/dist/css/value/expression/block.js +4 -3
  55. package/dist/css/value/expression/conditional.d.ts +2 -2
  56. package/dist/css/value/expression/conditional.js +1 -1
  57. package/dist/css/value/expression/index.d.ts +2 -2
  58. package/dist/css/value/expression/index.js +10 -6
  59. package/dist/css/value/expression/map.d.ts +2 -2
  60. package/dist/css/value/expression/map.js +2 -2
  61. package/dist/css/value/object/index.d.ts +2 -2
  62. package/dist/css/value/object/index.js +14 -4
  63. package/dist/css/value/object/members.d.ts +2 -2
  64. package/dist/css/value/object/node.js +9 -4
  65. package/dist/css/value/object/path.d.ts +3 -3
  66. package/dist/css/value/object/path.js +10 -4
  67. package/dist/css/value/pieces.d.ts +3 -3
  68. package/dist/css/value/pieces.js +14 -4
  69. package/dist/css/value/resolve.js +15 -5
  70. package/dist/css/value/scope.d.ts +3 -2
  71. package/dist/css/value/scope.js +25 -7
  72. package/dist/css/value/substitute.js +43 -11
  73. package/dist/entities/architecture.d.ts +28 -25
  74. package/dist/entities/ast/assignments-raw.d.ts +1 -1
  75. package/dist/entities/ast/assignments-raw.js +61 -8
  76. package/dist/entities/ast/assignments-tagged.d.ts +1 -1
  77. package/dist/entities/ast/assignments-tagged.js +22 -7
  78. package/dist/entities/ast/assignments.d.ts +1 -1
  79. package/dist/entities/ast/assignments.js +6 -4
  80. package/dist/entities/ast/branches.d.ts +1 -1
  81. package/dist/entities/ast/calls.d.ts +1 -1
  82. package/dist/entities/ast/calls.js +19 -3
  83. package/dist/entities/ast/classes.d.ts +1 -1
  84. package/dist/entities/ast/classes.js +5 -1
  85. package/dist/entities/ast/comments.d.ts +3 -2
  86. package/dist/entities/ast/comments.js +47 -17
  87. package/dist/entities/ast/declaration.d.ts +1 -1
  88. package/dist/entities/ast/depth.d.ts +2 -2
  89. package/dist/entities/ast/depth.js +15 -8
  90. package/dist/entities/ast/enums.d.ts +1 -1
  91. package/dist/entities/ast/export-chain.d.ts +15 -0
  92. package/dist/entities/ast/export-chain.js +171 -0
  93. package/dist/entities/ast/file-exports.d.ts +1 -1
  94. package/dist/entities/ast/file-exports.js +26 -3
  95. package/dist/entities/ast/file-facts.d.ts +6 -3
  96. package/dist/entities/ast/file-facts.js +33 -4
  97. package/dist/entities/ast/file-imports.d.ts +1 -1
  98. package/dist/entities/ast/file-imports.js +26 -3
  99. package/dist/entities/ast/file.d.ts +2 -2
  100. package/dist/entities/ast/file.js +2 -1
  101. package/dist/entities/ast/functions.d.ts +1 -1
  102. package/dist/entities/ast/functions.js +13 -4
  103. package/dist/entities/ast/heritage.d.ts +1 -1
  104. package/dist/entities/ast/heritage.js +9 -1
  105. package/dist/entities/ast/index.d.ts +6 -3
  106. package/dist/entities/ast/index.js +82 -26
  107. package/dist/entities/ast/kind.d.ts +1 -1
  108. package/dist/entities/ast/kind.js +7 -1
  109. package/dist/entities/ast/modifiers.d.ts +1 -1
  110. package/dist/entities/ast/modifiers.js +4 -4
  111. package/dist/entities/ast/project.js +33 -2
  112. package/dist/entities/ast/properties.d.ts +1 -1
  113. package/dist/entities/ast/properties.js +10 -5
  114. package/dist/entities/ast/resolve.d.ts +1 -1
  115. package/dist/entities/ast/resolve.js +4 -4
  116. package/dist/entities/ast/tree.d.ts +4 -2
  117. package/dist/entities/ast/tree.js +184 -17
  118. package/dist/entities/ast/types.d.ts +1 -1
  119. package/dist/entities/ast/types.js +2 -1
  120. package/dist/entities/ast/usage.d.ts +1 -1
  121. package/dist/entities/ast/usage.js +1 -1
  122. package/dist/entities/ast/variables.d.ts +1 -1
  123. package/dist/entities/context.d.ts +4 -4
  124. package/dist/entities/facts.d.ts +36 -13
  125. package/dist/entities/findings.d.ts +3 -3
  126. package/dist/entities/kinds.d.ts +1 -1
  127. package/dist/entities/kinds.js +131 -30
  128. package/dist/entities/location/homes.d.ts +10 -10
  129. package/dist/entities/location/homes.js +74 -48
  130. package/dist/entities/location/place.d.ts +1 -1
  131. package/dist/entities/location/place.js +10 -3
  132. package/dist/entities/location/where.d.ts +8 -6
  133. package/dist/entities/location/where.js +79 -30
  134. package/dist/entities/location.d.ts +3 -3
  135. package/dist/entities/location.js +17 -17
  136. package/dist/entities/operators.js +1 -1
  137. package/dist/entities/overview/data.d.ts +6 -6
  138. package/dist/entities/overview/decision.d.ts +11 -11
  139. package/dist/entities/overview/finding.d.ts +10 -10
  140. package/dist/entities/overview/graph.d.ts +28 -11
  141. package/dist/entities/overview/input.d.ts +2 -2
  142. package/dist/entities/overview/summaries.d.ts +17 -15
  143. package/dist/entities/queries.d.ts +1 -1
  144. package/dist/entities/queries.js +72 -12
  145. package/dist/entities/repair.d.ts +1 -1
  146. package/dist/entities/repair.js +8 -2
  147. package/dist/entities/schema.d.ts +17 -3
  148. package/dist/entities/schema.js +74 -16
  149. package/dist/entities/story.d.ts +5 -5
  150. package/dist/entities/structure-facts.d.ts +1 -1
  151. package/dist/entities/token.d.ts +4 -4
  152. package/dist/entities/tree/build.d.ts +4 -3
  153. package/dist/entities/tree/build.js +95 -44
  154. package/dist/entities/tree/entries.d.ts +3 -3
  155. package/dist/entities/tree/entries.js +41 -16
  156. package/dist/entities/tree/index.d.ts +2 -2
  157. package/dist/entities/tree/index.js +1 -1
  158. package/dist/entities/tree/match.d.ts +2 -2
  159. package/dist/entities/tree/match.js +9 -5
  160. package/dist/fa-index.d.ts +16 -0
  161. package/dist/fa-index.js +165 -0
  162. package/dist/fa-open.d.ts +51 -0
  163. package/dist/fa-open.js +232 -0
  164. package/dist/fa-store.d.ts +22 -0
  165. package/dist/fa-store.js +222 -0
  166. package/dist/fa-values.d.ts +37 -0
  167. package/dist/fa-values.js +104 -0
  168. package/dist/facts-record.d.ts +45 -0
  169. package/dist/facts-record.js +287 -0
  170. package/dist/frameworks/angular/index.d.ts +2 -2
  171. package/dist/frameworks/angular/index.js +2 -1
  172. package/dist/frameworks/facet.d.ts +3 -1
  173. package/dist/frameworks/facet.js +13 -0
  174. package/dist/frameworks/index.d.ts +1 -1
  175. package/dist/frameworks/index.js +8 -4
  176. package/dist/frameworks/react/index.d.ts +2 -2
  177. package/dist/frameworks/react/index.js +33 -10
  178. package/dist/frameworks/test/index.d.ts +6 -0
  179. package/dist/frameworks/test/index.js +157 -0
  180. package/dist/frameworks/vue/index.d.ts +2 -2
  181. package/dist/frameworks/vue/index.js +2 -1
  182. package/dist/ignore.d.ts +3 -0
  183. package/dist/ignore.js +48 -0
  184. package/dist/index-file.d.ts +43 -0
  185. package/dist/index-file.js +218 -0
  186. package/dist/index-run.d.ts +39 -0
  187. package/dist/index-run.js +217 -0
  188. package/dist/index-zone.d.ts +25 -0
  189. package/dist/index-zone.js +209 -0
  190. package/dist/main.d.ts +5 -2
  191. package/dist/main.js +207 -34
  192. package/dist/nodes/child-entities.d.ts +3 -0
  193. package/dist/nodes/child-entities.js +12 -0
  194. package/dist/nodes/children.d.ts +4 -4
  195. package/dist/nodes/children.js +54 -11
  196. package/dist/nodes/finally/emit.d.ts +3 -3
  197. package/dist/nodes/finally/emit.js +26 -10
  198. package/dist/nodes/finally/entities.d.ts +13 -0
  199. package/dist/nodes/finally/entities.js +42 -0
  200. package/dist/nodes/finally/index.d.ts +6 -6
  201. package/dist/nodes/finally/index.js +8 -8
  202. package/dist/nodes/finally/queries.d.ts +2 -2
  203. package/dist/nodes/finally/queries.js +7 -4
  204. package/dist/nodes/finally/relations-access.d.ts +2 -2
  205. package/dist/nodes/finally/relations-access.js +22 -18
  206. package/dist/nodes/finally/relations-edge.d.ts +5 -5
  207. package/dist/nodes/finally/relations-edge.js +67 -44
  208. package/dist/nodes/finally/relations-group.d.ts +7 -7
  209. package/dist/nodes/finally/relations-group.js +28 -25
  210. package/dist/nodes/finally/relations.d.ts +2 -2
  211. package/dist/nodes/finally/relations.js +16 -12
  212. package/dist/nodes/finally/required.d.ts +3 -3
  213. package/dist/nodes/finally/required.js +9 -7
  214. package/dist/nodes/finally/violation.d.ts +2 -2
  215. package/dist/nodes/similar.d.ts +3 -3
  216. package/dist/nodes/similar.js +61 -49
  217. package/dist/piece-forms.d.ts +9 -0
  218. package/dist/piece-forms.js +68 -0
  219. package/dist/{pipeline-roles.d.ts → pipeline-entities.d.ts} +2 -2
  220. package/dist/{pipeline-roles.js → pipeline-entities.js} +32 -28
  221. package/dist/pipeline-facts.d.ts +4 -3
  222. package/dist/pipeline-facts.js +47 -55
  223. package/dist/{pipeline-unroled.d.ts → pipeline-unclassified.d.ts} +2 -2
  224. package/dist/{pipeline-unroled.js → pipeline-unclassified.js} +58 -63
  225. package/dist/pipeline.js +19 -64
  226. package/dist/release-file.d.ts +3 -0
  227. package/dist/release-file.js +13 -0
  228. package/dist/report/asks.d.ts +3 -3
  229. package/dist/report/asks.js +16 -6
  230. package/dist/report/configErrors.d.ts +55 -27
  231. package/dist/report/configErrors.js +81 -35
  232. package/dist/report/errorTypes/codes/structure.d.ts +1 -1
  233. package/dist/report/errorTypes/codes/structure.js +9 -9
  234. package/dist/report/errorTypes/decision-maker.d.ts +5 -5
  235. package/dist/report/errorTypes/decision-maker.js +4 -4
  236. package/dist/report/errorTypes/destinations.d.ts +5 -5
  237. package/dist/report/errorTypes/destinations.js +52 -34
  238. package/dist/report/errorTypes/finding-type.d.ts +3 -3
  239. package/dist/report/errorTypes/index.d.ts +1 -1
  240. package/dist/report/errorTypes/types/fileContents.d.ts +4 -4
  241. package/dist/report/errorTypes/types/fileContents.js +11 -5
  242. package/dist/report/errorTypes/types/unknownEntity.d.ts +9 -0
  243. package/dist/report/errorTypes/types/{unknownRole.js → unknownEntity.js} +12 -7
  244. package/dist/report/errorTypes/types/wrongAction.d.ts +5 -5
  245. package/dist/report/errorTypes/types/wrongAction.js +18 -13
  246. package/dist/report/errorTypes/types/wrongPlacement.d.ts +4 -4
  247. package/dist/report/errorTypes/types/wrongPlacement.js +19 -9
  248. package/dist/report/errorTypes/vocabulary/ids.d.ts +2 -2
  249. package/dist/report/errorTypes/vocabulary/ids.js +3 -3
  250. package/dist/report/errorTypes/vocabulary/phrases.d.ts +2 -2
  251. package/dist/report/errorTypes/vocabulary/phrases.js +39 -26
  252. package/dist/report/errorTypes/vocabulary/places.d.ts +3 -3
  253. package/dist/report/errorTypes/vocabulary/places.js +13 -13
  254. package/dist/report/finding-from.d.ts +3 -3
  255. package/dist/report/finding-from.js +14 -9
  256. package/dist/report/notices.d.ts +6 -1
  257. package/dist/report/notices.js +46 -20
  258. package/dist/report/observed.d.ts +19 -0
  259. package/dist/report/observed.js +87 -0
  260. package/dist/report/render-report.d.ts +1 -1
  261. package/dist/report/render-report.js +33 -30
  262. package/dist/report/user-report/build/bundle.js +9 -0
  263. package/dist/report/user-report/build/bundle.prebuilt.js +799 -297
  264. package/dist/report/user-report/data/collect.d.ts +2 -2
  265. package/dist/report/user-report/data/collect.js +15 -12
  266. package/dist/report/user-report/data/entities.d.ts +7 -0
  267. package/dist/report/user-report/data/{roles.js → entities.js} +27 -22
  268. package/dist/report/user-report/data/{role-examples.d.ts → entity-examples.d.ts} +3 -3
  269. package/dist/report/user-report/data/entity-examples.js +126 -0
  270. package/dist/report/user-report/data/{role-filters.d.ts → entity-filters.d.ts} +2 -2
  271. package/dist/report/user-report/data/{role-filters.js → entity-filters.js} +7 -7
  272. package/dist/report/user-report/data/entity-marks.d.ts +5 -0
  273. package/dist/report/user-report/data/{role-marks.js → entity-marks.js} +11 -11
  274. package/dist/report/user-report/data/file-tree.d.ts +3 -3
  275. package/dist/report/user-report/data/file-tree.js +13 -5
  276. package/dist/report/user-report/data/finding-boundary.d.ts +4 -4
  277. package/dist/report/user-report/data/finding-boundary.js +2 -2
  278. package/dist/report/user-report/data/finding-plan.d.ts +5 -5
  279. package/dist/report/user-report/data/finding-plan.js +10 -10
  280. package/dist/report/user-report/data/finding-title.d.ts +2 -2
  281. package/dist/report/user-report/data/finding-title.js +8 -8
  282. package/dist/report/user-report/data/findings.d.ts +4 -4
  283. package/dist/report/user-report/data/findings.js +30 -20
  284. package/dist/report/user-report/data/graph-edges.d.ts +4 -4
  285. package/dist/report/user-report/data/graph-edges.js +19 -19
  286. package/dist/report/user-report/data/graph-entities.d.ts +6 -0
  287. package/dist/report/user-report/data/graph-entities.js +158 -0
  288. package/dist/report/user-report/data/graph-helpers.d.ts +5 -5
  289. package/dist/report/user-report/data/graph-helpers.js +15 -15
  290. package/dist/report/user-report/data/graph.d.ts +5 -4
  291. package/dist/report/user-report/data/graph.js +28 -21
  292. package/dist/report/user-report/data/nodes.d.ts +2 -2
  293. package/dist/report/user-report/data/nodes.js +16 -16
  294. package/dist/report/user-report/data/rules.d.ts +7 -0
  295. package/dist/report/user-report/data/{invariants.js → rules.js} +13 -13
  296. package/dist/report/user-report/data/scan.d.ts +1 -1
  297. package/dist/report/user-report/data/scan.js +2 -2
  298. package/dist/report/user-report/html/shell.d.ts +1 -1
  299. package/dist/report/user-report/html/shell.js +1 -1
  300. package/dist/report/user-report/index.d.ts +1 -1
  301. package/dist/report/user-report/shared/describe.d.ts +1 -1
  302. package/dist/report/user-report/shared/describe.js +6 -6
  303. package/dist/rules/index.d.ts +7 -0
  304. package/dist/{invariants → rules}/index.js +85 -57
  305. package/dist/{invariants → rules}/list-vars.d.ts +2 -2
  306. package/dist/{invariants → rules}/list-vars.js +9 -3
  307. package/dist/{invariants → rules}/name.js +2 -2
  308. package/dist/rules/normalize.d.ts +5 -0
  309. package/dist/{invariants → rules}/normalize.js +35 -32
  310. package/dist/{invariants → rules}/vars.d.ts +9 -7
  311. package/dist/{invariants → rules}/vars.js +5 -5
  312. package/dist/scan-run.d.ts +20 -0
  313. package/dist/scan-run.js +130 -0
  314. package/dist/scripts/audit-report.js +2 -2
  315. package/dist/usage-index.d.ts +4 -0
  316. package/dist/usage-index.js +272 -0
  317. package/dist/usage-mode.d.ts +7 -0
  318. package/dist/usage-mode.js +16 -0
  319. package/dist/usage-pass.d.ts +19 -0
  320. package/dist/usage-pass.js +136 -0
  321. package/dist/usage-prepare.d.ts +2 -0
  322. package/dist/usage-prepare.js +22 -0
  323. package/dist/usage-sweep.d.ts +10 -0
  324. package/dist/usage-sweep.js +254 -0
  325. package/dist/utils/aliases.d.ts +22 -0
  326. package/dist/utils/aliases.js +163 -0
  327. package/dist/utils/classify.d.ts +2 -2
  328. package/dist/utils/classify.js +4 -4
  329. package/dist/utils/distinct.js +4 -2
  330. package/dist/utils/files.js +24 -30
  331. package/dist/utils/fixpoint.js +2 -2
  332. package/dist/utils/host.d.ts +1 -1
  333. package/dist/utils/host.js +4 -1
  334. package/dist/utils/imports.js +66 -12
  335. package/dist/utils/keyed.js +2 -2
  336. package/dist/utils/map-record.js +2 -2
  337. package/dist/utils/packages.d.ts +15 -0
  338. package/dist/utils/packages.js +197 -0
  339. package/dist/utils/path-label.js +3 -1
  340. package/dist/utils/pattern.d.ts +5 -4
  341. package/dist/utils/pattern.js +38 -8
  342. package/dist/utils/permission.d.ts +3 -3
  343. package/dist/utils/permission.js +4 -2
  344. package/dist/utils/plural.js +2 -2
  345. package/dist/utils/qualified.js +4 -4
  346. package/dist/utils/rank.js +2 -2
  347. package/dist/utils/record.js +1 -1
  348. package/dist/utils/search.js +7 -2
  349. package/dist/utils/speak.js +1 -1
  350. package/dist/utils/split.js +14 -1
  351. package/dist/utils/template.d.ts +1 -1
  352. package/dist/utils/template.js +1 -1
  353. package/dist/utils/tokenize.js +6 -1
  354. package/dist/utils/typed-field.js +2 -2
  355. package/dist/utils/verdicts.js +1 -1
  356. package/entities/operators.ts +1 -1
  357. package/package.json +101 -90
  358. package/report/errorTypes/vocabulary/ids.ts +7 -2
  359. package/report/errorTypes/vocabulary/phrases.ts +47 -27
  360. package/report/errorTypes/vocabulary/places.ts +21 -16
  361. package/report/user-report/shared/describe.ts +7 -7
  362. package/dist/code-roles/classify.d.ts +0 -11
  363. package/dist/code-roles/classify.js +0 -43
  364. package/dist/code-roles/connector.d.ts +0 -5
  365. package/dist/code-roles/connector.js +0 -114
  366. package/dist/code-roles/project.d.ts +0 -12
  367. package/dist/code-roles/project.js +0 -122
  368. package/dist/code-roles/roles.d.ts +0 -8
  369. package/dist/invariants/index.d.ts +0 -6
  370. package/dist/invariants/normalize.d.ts +0 -4
  371. package/dist/nodes/child-roles.d.ts +0 -3
  372. package/dist/nodes/child-roles.js +0 -12
  373. package/dist/nodes/finally/roles.d.ts +0 -13
  374. package/dist/nodes/finally/roles.js +0 -41
  375. package/dist/report/errorTypes/types/unknownRole.d.ts +0 -9
  376. package/dist/report/user-report/data/graph-roles.d.ts +0 -5
  377. package/dist/report/user-report/data/graph-roles.js +0 -71
  378. package/dist/report/user-report/data/invariants.d.ts +0 -7
  379. package/dist/report/user-report/data/role-examples.js +0 -94
  380. package/dist/report/user-report/data/role-marks.d.ts +0 -5
  381. package/dist/report/user-report/data/roles.d.ts +0 -7
  382. /package/dist/{invariants → rules}/name.d.ts +0 -0
@@ -1,56 +1,60 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkRoleHomes = void 0;
4
- // The ROLE-HOME phase: every candidate must fit its ROLE's declared home. A
5
- // role says where its code may be declared; code of that role anywhere else is
6
- // reported with the place it belongs. ONE finding per role per file — four
3
+ exports.checkEntityHomes = void 0;
4
+ // The ENTITY-HOME phase: every candidate must fit its ENTITY's declared home. A
5
+ // entity says where its code may be declared; code of that entity anywhere else is
6
+ // reported with the place it belongs. ONE finding per entity per file — four
7
7
  // helpers in one file are one decision, not four copies of the same sentence.
8
8
  const location_1 = require("./entities/location");
9
9
  const finally_1 = require("./nodes/finally");
10
10
  const asks_1 = require("./report/asks");
11
11
  const cli_report_1 = require("./report/cli-report");
12
12
  const qualified_1 = require("./utils/qualified");
13
- // Is this candidate a misfit? A role's report is about a NAME: an anonymous
13
+ // Is this candidate a misfit? An entity's report is about a NAME: an anonymous
14
14
  // function is the argument or the body of something else, and naming it would
15
- // produce a sentence with a hole in it. A role nobody declares, or one with no
15
+ // produce a sentence with a hole in it. An entity nobody declares, or one with no
16
16
  // home, restricts nothing. The guards are the shared qualified-answer walk;
17
- // the home question is `fitsRole`'s own.
18
- const misfitRoleOf = (c, arch, rel) => (0, qualified_1.answerWhenAllPass)(c, [(x) => Boolean(x.role && arch.codeRoles?.[x.role] && x.name), (x) => (0, location_1.homesOf)(arch, x.role ?? "").length > 0, (x) => !(0, finally_1.fitsRole)(x.role ?? "", arch, rel)], (x) => x.role ?? null);
19
- // The misfits by role: every named candidate of a declared role with homes,
17
+ // the home question is `fitsEntity`'s own.
18
+ const misfitEntityOf = (c, arch, rel) => (0, qualified_1.answerWhenAllPass)(c, [
19
+ (x) => Boolean(x.entity && arch.entities?.[x.entity] && x.name),
20
+ (x) => (0, location_1.homesOf)(arch, x.entity ?? "").length > 0,
21
+ (x) => !(0, finally_1.fitsEntity)(x.entity ?? "", arch, rel),
22
+ ], (x) => x.entity ?? null);
23
+ // The misfits by entity: every named candidate of a declared entity with homes,
20
24
  // sitting outside every one of them.
21
- const misfitsOf = (withRoles, arch, rel) => {
25
+ const misfitsOf = (withEntities, arch, rel) => {
22
26
  const misfits = new Map();
23
- for (const c of withRoles) {
24
- const role = misfitRoleOf(c, arch, rel);
25
- if (!role || !c.name)
27
+ for (const c of withEntities) {
28
+ const entity = misfitEntityOf(c, arch, rel);
29
+ if (!entity || !c.name)
26
30
  continue;
27
- misfits.set(role, [...(misfits.get(role) ?? []), { name: c.name, line: c.lines?.[0] ?? 1 }]);
31
+ misfits.set(entity, [...(misfits.get(entity) ?? []), { name: c.name, line: c.lines?.[0] ?? 1 }]);
28
32
  }
29
33
  return misfits;
30
34
  };
31
- // The reason a misfit is a misfit: the role's own wording when the config has
35
+ // The reason a misfit is a misfit: the entity's own wording when the config has
32
36
  // one (a clause, not a sentence — the subject and the place are the frame's
33
37
  // job), else the plain statement of what the code is and what to fill in.
34
- const whyOf = (role, names, place, arch) => {
35
- const own = arch.codeRoles[role].report;
38
+ const whyOf = (entity, names, place, arch) => {
39
+ const own = arch.entities[entity].report;
36
40
  const ownMessage = typeof own === "object" && own !== null ? own.message : null;
37
41
  if (ownMessage)
38
42
  return ownMessage;
39
- // A role with NO place for this file must not reach `place.path`: widening the
43
+ // An entity with NO place for this file must not reach `place.path`: widening the
40
44
  // rules to `packages` put such a file in front of this line and it crashed.
41
45
  const fill = !place || place.concrete ? "" : `; fill ${(0, location_1.placeholdersOf)(place.path)} for the instance this code belongs to`;
42
- return `${names.length > 1 ? "They are" : "It is"} \`${role}\` code${fill}.`;
46
+ return `${names.length > 1 ? "They are" : "It is"} \`${entity}\` code${fill}.`;
43
47
  };
44
- // One role's misfit finding: the demand and its sentence come from the ONE
48
+ // One entity's misfit finding: the demand and its sentence come from the ONE
45
49
  // vocabulary in report/asks — "this code belongs elsewhere" is a `move`, said
46
50
  // the same way here and in the folder check. The BOX the sentence names is
47
51
  // resolved here, once, so the picture and the sentence cannot disagree.
48
- const misfitFinding = (role, found, ctx, arch) => {
52
+ const misfitFinding = (entity, found, ctx, arch) => {
49
53
  const names = found.map((x) => x.name);
50
54
  const list = names.map((n) => `\`${n}\``).join(", ");
51
55
  // WHERE this code belongs — asked of the ONE implementation in homes, so
52
56
  // this message and the folder-level one can never name different places.
53
- const place = (0, location_1.placeFor)(arch, role, ctx.rel);
57
+ const place = (0, location_1.placeFor)(arch, entity, ctx.rel);
54
58
  const where = place ? `\`${place.path}\`` : null;
55
59
  const report = asks_1.asks.move({
56
60
  what: list,
@@ -60,16 +64,16 @@ const misfitFinding = (role, found, ctx, arch) => {
60
64
  // The path WITHOUT backticks: the text decorates, the data does not.
61
65
  path: place?.path ?? null,
62
66
  // `findingFrom` substitutes `{what}` / `{destination}` from the vars below.
63
- why: whyOf(role, names, place, arch),
67
+ why: whyOf(entity, names, place, arch),
64
68
  });
65
- return (0, cli_report_1.findingFrom)({ report, line: found[0].line }, "codeRoles", role, `role:${role}:report`, {
69
+ return (0, cli_report_1.findingFrom)({ report, line: found[0].line }, "entities", entity, `entity:${entity}:report`, {
66
70
  path: ctx.rel,
67
71
  what: names.join(", "),
68
72
  destination: place?.path ?? null,
69
73
  });
70
74
  };
71
- const checkRoleHomes = (withRoles, ctx, arch, out) => {
72
- for (const [role, found] of misfitsOf(withRoles, arch, ctx.rel))
73
- out.push(misfitFinding(role, found, ctx, arch));
75
+ const checkEntityHomes = (withEntities, ctx, arch, out) => {
76
+ for (const [entity, found] of misfitsOf(withEntities, arch, ctx.rel))
77
+ out.push(misfitFinding(entity, found, ctx, arch));
74
78
  };
75
- exports.checkRoleHomes = checkRoleHomes;
79
+ exports.checkEntityHomes = checkEntityHomes;
@@ -1,11 +1,12 @@
1
1
  import type { Project } from "ts-morph";
2
+ declare const needsUsage: (arch: Arch) => boolean;
2
3
  import type { Arch } from "./entities/architecture";
3
4
  import type { FileContext } from "./entities/context";
4
5
  import type { Candidate, FileFacts } from "./entities/facts";
5
- import type { SeenStore } from "./utils/seen";
6
- declare const collectFacts: (abs: string, arch: Arch, project: Project, repoFiles: string[], dedupe: SeenStore) => {
6
+ declare const collectFacts: (abs: string, arch: Arch, project: Project, repoFiles: string[], usage?: boolean, record?: boolean, inText?: string) => {
7
7
  ctx: FileContext;
8
8
  candidates: Candidate[];
9
9
  fileFacts: FileFacts;
10
+ text: string;
10
11
  };
11
- export { collectFacts };
12
+ export { needsUsage, collectFacts };
@@ -23,19 +23,38 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.collectFacts = void 0;
26
+ exports.collectFacts = exports.needsUsage = void 0;
27
27
  // The FACTS phase of the per-file pipeline: load the source file, collect the
28
28
  // candidates once, attach the facet readings (framework, CSS, call depth), and
29
29
  // build the file's fact set. Classification and the file facts both consume the
30
30
  // same candidates, so nothing is collected twice.
31
31
  const path = __importStar(require("node:path"));
32
- const fs = __importStar(require("node:fs"));
33
32
  const imports_1 = require("./utils/imports");
34
- const ast_1 = require("./entities/ast");
35
- const css_1 = require("./css");
36
- const values_1 = require("./css/value/values");
37
- const frameworks_1 = require("./frameworks");
38
- const depth_1 = require("./entities/ast/depth");
33
+ const walk_1 = require("./code-entities/walk");
34
+ // Does the config ever READ the checker facts (`references`, `implementations`)?
35
+ // Answering either is a project-wide type-checker call per exported name — the
36
+ // heaviest fact a scan produces — so the extraction only asks for them when some
37
+ // filter can actually use them. A conservative scan of the serialized policy:
38
+ // when the key appears anywhere, it computes (never silently drops a fact a rule
39
+ // depends on).
40
+ const configMentions = (arch, fact) => {
41
+ try {
42
+ return JSON.stringify({ rules: arch.rules, entities: arch.entities }).includes(`"${fact}"`);
43
+ }
44
+ catch {
45
+ return true;
46
+ }
47
+ };
48
+ const usageNeeded = new WeakMap();
49
+ const needsUsage = (arch) => {
50
+ const cached = usageNeeded.get(arch);
51
+ if (cached !== undefined)
52
+ return cached;
53
+ const need = configMentions(arch, "references") || configMentions(arch, "implementations");
54
+ usageNeeded.set(arch, need);
55
+ return need;
56
+ };
57
+ exports.needsUsage = needsUsage;
39
58
  // The file's place and the run's shared state, before any fact is collected.
40
59
  const buildFileContext = (abs, arch, load) => {
41
60
  const repoRoot = arch.repoRoot ?? ".";
@@ -51,62 +70,35 @@ const buildFileContext = (abs, arch, load) => {
51
70
  // The built architecture — scope entries (`{ node: slug }`) resolve
52
71
  // against the tree, and filters may reference it too.
53
72
  arch,
54
- roles: [],
55
- roleCtx: null,
73
+ entities: [],
74
+ entityCtx: null,
56
75
  facts: null,
57
76
  repoFiles: load.repoFiles,
58
- // Shared across the run: lets node-level checks report once per folder
59
- // instead of once per file inside it.
60
- dedupe: load.dedupe,
61
77
  };
62
78
  };
63
- const classifyMembers = (members) => {
64
- for (const member of members ?? []) {
65
- if (typeof member.value === "string")
66
- member.css = (0, values_1.classifyValue)(member.value, member.line ?? null);
67
- classifyMembers(member.members);
68
- }
69
- };
70
- // The candidates with every facet reading attached: call depth (a FACT, so a
71
- // rule can refuse a chain nobody can follow), the framework and style readings
72
- // of the same AST (attached before classification, so a code role can be
73
- // defined on them exactly like on `kind` — both are optional namespaces, a
74
- // plain `.ts` file gets neither), and the CSS grammar reading of string members.
75
- const withFacets = (candidates, run) => {
76
- const { ctx, sf, text, project, arch, repoFiles, importMap } = run;
77
- (0, depth_1.attachCallDepth)(candidates, {
78
- rel: ctx.rel,
79
- project,
80
- repoRoot: arch.repoRoot ?? ctx.repoRoot ?? ".",
81
- aliases: ctx.aliases,
79
+ // The file's facts are needed BEFORE classification — an entity may be recognised
80
+ // by what the file depends on (`file.imports`), not only by the candidate's own
81
+ // shape. That whole walk (load → candidates → facets → file facts → classify) is
82
+ // ONE function (`code-entities/walk`), shared with the editor's index and the
83
+ // report's cards; this phase only adds what the pipeline itself needs: the file's
84
+ // context, and the decision whether the checker facts are worth computing.
85
+ const collectFacts = (...args) => {
86
+ const [abs, arch, project, repoFiles, usage = true, record = false, inText] = args;
87
+ const walked = (0, walk_1.walkFile)({
88
+ rel: (0, imports_1.toRel)(arch.repoRoot ?? ".", abs),
89
+ arch,
90
+ repoRoot: arch.repoRoot ?? ".",
82
91
  repoFiles,
83
- cache: (arch.depthCache ??= { memo: new Map(), files: new Map() }),
92
+ aliases: arch.aliases,
93
+ project,
94
+ text: inText,
95
+ usage,
96
+ record,
84
97
  });
85
- (0, frameworks_1.enrich)(candidates, { rel: ctx.rel, sf, text, repoRoot: arch.repoRoot ?? ctx.repoRoot, importMap });
86
- (0, css_1.attachToCandidates)(candidates, { sf });
87
- for (const candidate of candidates)
88
- classifyMembers(candidate.kind?.initializer?.members);
89
- return candidates;
90
- };
91
- // Load → candidates → facets → file facts. The file's facts are needed BEFORE
92
- // classification — a role may be recognised by what the file depends on
93
- // (`file.imports`), not only by the candidate's own shape. The only fields that
94
- // need the classification are `candidates` and `roles`, so they are filled in
95
- // afterwards; every candidate holds the same facts object, so `infer` sees
96
- // everything the file facts offer, not a hand-picked subset.
97
- const collectFacts = (...args) => {
98
- const [abs, arch, project, repoFiles, dedupe] = args;
99
- const text = fs.readFileSync(abs, "utf8");
100
- const sf = (0, ast_1.loadSourceFile)(project, abs, text);
101
- const ctx = buildFileContext(abs, arch, { sf, repoFiles, dedupe });
102
- const importMap = (0, ast_1.importNameModules)(sf, ctx.repoRoot ?? ".", ctx.aliases, repoFiles);
103
98
  // `repoRoot` lets the type-resolved facts (`assignments[].type`,
104
99
  // `parameters[].typeFile`) be repo-relative, which is what
105
100
  // `location: { node: … }` matches against.
106
- const candidates = withFacets((0, ast_1.collectCandidates)(sf, importMap, ctx.rel, ctx.repoRoot ?? "."), { ctx, sf, text, project, arch, repoFiles, importMap });
107
- const fileFacts = (0, ast_1.collectFileFacts)(sf, { rel: ctx.rel, repoFiles, aliases: ctx.aliases, repoRoot: ctx.repoRoot ?? ".", candidates: [] });
108
- for (const c of candidates)
109
- c.file = fileFacts;
110
- return { ctx, candidates, fileFacts };
101
+ const ctx = buildFileContext(abs, arch, { sf: walked.sf, repoFiles });
102
+ return { ctx, candidates: walked.candidates, fileFacts: walked.fileFacts, text: walked.text };
111
103
  };
112
104
  exports.collectFacts = collectFacts;
@@ -3,7 +3,7 @@ import type { Arch } from "./entities/architecture";
3
3
  import type { FileContext } from "./entities/context";
4
4
  import type { Candidate } from "./entities/facts";
5
5
  import type { Finding } from "./entities/findings";
6
- declare const checkUnroled: (withRoles: readonly Candidate[], run: {
6
+ declare const checkUnclassified: (withEntities: readonly Candidate[], run: {
7
7
  present: readonly string[];
8
8
  ctx: FileContext;
9
9
  arch: Arch;
@@ -11,4 +11,4 @@ declare const checkUnroled: (withRoles: readonly Candidate[], run: {
11
11
  repoFiles: string[];
12
12
  out: Finding[];
13
13
  }) => void;
14
- export { checkUnroled };
14
+ export { checkUnclassified };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkUnroled = void 0;
3
+ exports.checkUnclassified = void 0;
4
4
  const tree_1 = require("./entities/tree");
5
5
  const location_1 = require("./entities/location");
6
6
  const similar_1 = require("./nodes/similar");
@@ -9,32 +9,37 @@ const asks_1 = require("./report/asks");
9
9
  const cli_report_1 = require("./report/cli-report");
10
10
  const speak_1 = require("./utils/speak");
11
11
  const field_1 = require("./utils/field");
12
- const child_roles_1 = require("./nodes/child-roles");
12
+ const child_entities_1 = require("./nodes/child-entities");
13
+ const piece_forms_1 = require("./piece-forms");
13
14
  // The child whose PATTERN this file matches — `store.ts` literally,
14
15
  // `{kebab-case}.ts` by the convention it is written in. One rule, the same one
15
16
  // the tree uses.
16
17
  const ownChildOf = (kids, basename) => kids.find((k) => !k.folder && k.re.test(basename)) ?? null;
17
- // The roles this place declares: the child whose pattern the file matches,
18
+ // The entities this place declares: the child whose pattern the file matches,
18
19
  // else — for a file NODE (`apps/backend/{kebab-case}/controller.ts` is a node
19
- // of its own) — the node's own roles. Nothing lists a file node as a child, so
20
- // its own roles are what applies here. The child's roles are the shared
21
- // `rolesOfChild` reading.
22
- const declaredRolesOf = (match, own, arch) => {
23
- const childRoles = (0, child_roles_1.rolesOfChild)(arch, own);
24
- if (childRoles.length)
25
- return childRoles;
26
- const isFileNode = (match?.node?.variants ?? []).some((v) => v.isFile);
27
- return isFileNode ? (match?.node?.roles ?? []) : [];
20
+ // of its own) — the node's own entities. Nothing lists a file node as a child, so
21
+ // its own entities are what applies here. The child's entities are the shared
22
+ // `entitiesOfChild` reading.
23
+ // The place holds its own KINDS when it is a file NODE (nothing lists a file
24
+ // node as a child) or when it names no children at all — a node with `entity:`
25
+ // and no `children:` closes kinds, not file names. Both are the same reading the
26
+ // tree's `reportUndeclared` uses; the node's own list is what applies.
27
+ const declaredByNode = (match) => (match?.node?.variants ?? []).some((v) => v.isFile) || (match?.node?.children ?? []).length === 0;
28
+ const declaredEntitiesOf = (match, own, arch) => {
29
+ const childEntities = (0, child_entities_1.entitiesOfChild)(arch, own);
30
+ if (childEntities.length)
31
+ return childEntities;
32
+ return declaredByNode(match) ? (match?.node?.entities ?? []) : [];
28
33
  };
29
34
  const declarationOf = (ctx, arch) => {
30
35
  const match = (0, tree_1.deepestMatch)(ctx.rel, arch);
31
36
  const owner = match?.node?.slug ?? null;
32
37
  const kids = owner ? (arch.nodes.bySlug[owner]?.children ?? []) : [];
33
38
  const own = ownChildOf(kids, ctx.basename ?? "");
34
- return { owner, declaredHere: declaredRolesOf(match, own, arch) };
39
+ return { owner, declaredHere: declaredEntitiesOf(match, own, arch) };
35
40
  };
36
- // The roles a place declares, in the reader's words.
37
- const listOf = (roles) => roles.map((r) => `\`${r}\``).join(" / ");
41
+ // The entities a place declares, in the reader's words.
42
+ const listOf = (entities) => entities.map((r) => `\`${r}\``).join(" / ");
38
43
  // The piece's own words for what it IS: a local alias, a wrapper, a write, the
39
44
  // declaration's text — each fact answers before the generic fallback.
40
45
  const aliasShape = (c) => {
@@ -71,11 +76,11 @@ const shapeOf = (c) => {
71
76
  return specific;
72
77
  return (c.kind?.own?.is ?? "") === "VariableDeclaration" ? "a plain variable" : "a plain function";
73
78
  };
74
- // The reason a piece has no role: what the place declares (and what the piece
79
+ // The reason a piece has no entity: what the place declares (and what the piece
75
80
  // is), or that nothing declares this file, or that it is outside the tree.
76
- const whyUnroled = (ctx, decl, piece, offered) => {
81
+ const whyUnclassified = (ctx, decl, piece, offered) => {
77
82
  const shape = shapeOf(piece);
78
- const what2 = shape ? `this is ${shape} — not code a role describes` : "this is something else";
83
+ const what2 = shape ? `this is ${shape} — not code an entity describes` : "this is something else";
79
84
  if (decl.declaredHere.length)
80
85
  return `only ${listOf(decl.declaredHere)} is declared here, and ${what2}.${offered}`;
81
86
  if (decl.owner)
@@ -84,83 +89,64 @@ const whyUnroled = (ctx, decl, piece, offered) => {
84
89
  };
85
90
  // What the folder looks like, in the reader's words: the entities it resembles
86
91
  // and how much of each it holds.
87
- const lookalikeText = (like) => (like.length ? ` It looks like ${like.map((n) => `\`${n.path ?? n.slug}\` (${n.hit}/${n.total})`).join(" or ")}.` : "");
92
+ const lookalikeText = (like) => like.length ? ` It looks like ${like.map((n) => `\`${n.path ?? n.slug}\` (${n.hit}/${n.total})`).join(" or ")}.` : "";
88
93
  // "Nothing describes this code" — one of the four demands in report/asks, so
89
94
  // the sentence and the repair read the same here as anywhere else. Moving is
90
95
  // offered only where the folder really resembles something — the destination
91
96
  // is the entity's own words, and there may be several.
92
- const noRole = (what, piece, view) => {
93
- const demand = asks_1.asks.role({ what: `\`${what}\``, why: whyUnroled(view.ctx, view.decl, piece, lookalikeText(view.like)) });
97
+ const noEntity = (what, piece, view) => {
98
+ const demand = asks_1.asks.entity({
99
+ what: `\`${what}\``,
100
+ why: whyUnclassified(view.ctx, view.decl, piece, lookalikeText(view.like)),
101
+ });
94
102
  if (!view.like.length)
95
103
  return demand;
96
104
  demand.fix = `Move \`${what}\` into ${view.like.map((n) => `\`${n.path ?? n.slug}\``).join(" or ")} — this folder already has ${view.like[0].hit} of the ${view.like[0].total} things that entity declares.`;
97
105
  return demand;
98
106
  };
99
- // A PIECE is a candidate that can carry a role. Every candidate the AST layer
100
- // collects is one, except two structural cases: a variable declared INSIDE a
101
- // function (the function answers for it) and an anonymous function handed
102
- // straight to a call — that is the call's ARGUMENT (`.map(x => …)`), not code
103
- // with a life of its own. A `const` is a piece only at MODULE scope.
104
- const isPiece = (c) => {
105
- if ((c.kind?.own?.is ?? null) === "VariableDeclaration")
106
- return !c.location?.nested;
107
- return c.name != null || c.kind?.parent?.is !== "CallExpression";
108
- };
109
107
  // The edges the file's facts produce — every relation, once.
110
108
  const edgesOf = (facts) => Object.values(kinds_1.EDGE_FACTS).flatMap((produce) => produce(facts));
111
- // The pieces that touch something: a piece that touches nothing needs no role
109
+ // The pieces that touch something: a piece that touches nothing needs no entity
112
110
  // — "nothing is allowed from it" is not a statement about code that does not
113
111
  // reach anything. Silence for those is not permission — it is the absence of a
114
112
  // question.
115
113
  const piecesWithEdges = (edges) => new Set(edges.map((e) => e.piece).filter((p) => Boolean(p)));
116
- // A piece whose VALUE is judged by the css-fact invariants, not by a role: a
117
- // styled/createGlobalStyle/css fragment (a tagged template), or a DATA literal
118
- // (a token group, a breakpoint table, a rhythm origin). These are values, not
119
- // behaviour — the settled model leaves them unroled on purpose and checks their
120
- // contents instead (`proper-values`, `proper-naming`, `proper-documentation`).
121
- const VALUE_INITIALIZERS = new Set(["TaggedTemplateExpression", "ObjectLiteralExpression", "SatisfiesExpression", "AsExpression", "ArrayLiteralExpression", "NoSubstitutionTemplateLiteral"]);
122
- const governedByValues = (c) => VALUE_INITIALIZERS.has(c.kind?.initializer?.is ?? "");
123
- // Is this candidate an unroled PIECE that touches something? One piece may be
124
- // described by two candidates — a `const` holding an arrow is the same code
125
- // seen twice; when one of them got a role, the piece is described. A piece
126
- // carrying css TEMPLATES, or whose whole value is DATA, is governed by the
127
- // css-fact invariants, not by a role.
128
- const isRoled = (c, roledLines) => Boolean(c.role) || roledLines.has(c.lines?.[0] ?? 1);
129
- const governedByValuesOrCss = (c) => Boolean(c.css?.templates?.length) || governedByValues(c);
130
- const unroledPiece = (c, roledLines, touching) => !isRoled(c, roledLines) && isPiece(c) && Boolean(c.name) && touching.has(c.name ?? "") && !governedByValuesOrCss(c);
131
- // One unroled piece's finding, once per piece.
132
- const unroledFindings = (withRoles, scene, out) => {
133
- const roledLines = new Set(withRoles.filter((x) => x.role).map((x) => x.lines?.[0] ?? 1));
114
+ // One unclassified piece's finding, once per piece.
115
+ const unclassifiedFindings = (withEntities, scene, out) => {
116
+ const described = {
117
+ lines: new Set(withEntities.filter((x) => x.entity).map((x) => x.lines?.[0] ?? 1)),
118
+ names: new Set(withEntities.filter((x) => x.entity && x.name).map((x) => x.name ?? "")),
119
+ };
134
120
  const touching = piecesWithEdges(scene.edges);
135
121
  const seenPieces = new Set();
136
- const pieces = withRoles.filter((c) => unroledPiece(c, roledLines, touching));
122
+ const pieces = withEntities.filter((c) => (0, piece_forms_1.unclassifiedPiece)(c, described, touching));
137
123
  for (const c of pieces) {
138
124
  const what = c.name ?? `the anonymous function at line ${c.lines?.[0] ?? 1}`;
139
125
  if (!(0, speak_1.speakOnce)(seenPieces, what))
140
126
  continue;
141
- out.push((0, cli_report_1.findingFrom)({ ...noRole(what, c, scene), line: c.lines?.[0] ?? 1 }, "nodes", scene.decl.owner ?? scene.ctx.rel, `unroled:${scene.decl.owner ?? "tree"}:${what}`, { path: scene.ctx.rel, what }));
127
+ out.push((0, cli_report_1.findingFrom)({ ...noEntity(what, c, scene), line: c.lines?.[0] ?? 1 }, "nodes", scene.decl.owner ?? scene.ctx.rel, `unclassified:${scene.decl.owner ?? "tree"}:${what}`, { path: scene.ctx.rel, what }));
142
128
  }
143
129
  return seenPieces.size;
144
130
  };
145
- // A file NOTHING describes: no role present and no piece to say it about (a
131
+ // A file NOTHING describes: no entity present and no piece to say it about (a
146
132
  // file of re-exports, a file of imports). Said once, for the file — and only
147
133
  // when the file actually does something. A BARREL (every export re-exports
148
- // another module) holds no code of its own, so it is not a thing to role: its
149
- // re-exports are governed by `no-re-exports`'s place list, not by a role.
134
+ // another module) holds no code of its own, so it is not a thing to entity: its
135
+ // re-exports are governed by `no-re-exports`'s place list, not by an entity.
150
136
  const reexportOnly = (scene) => {
151
137
  const exports = scene.ctx.facts?.exports ?? [];
152
138
  return exports.length > 0 && exports.every((entry) => Boolean(entry.from));
153
139
  };
154
140
  // A file whose every piece is DATA or a style fragment holds no behaviour to
155
- // role: its values are judged by the css-fact invariants.
156
- const isValuePiece = (c) => governedByValues(c) || Boolean(c.role) || Boolean(c.css?.templates?.length);
141
+ // entity: its values are judged by the css-fact rules.
142
+ const isValuePiece = (c) => (0, piece_forms_1.governedByValues)(c) || Boolean(c.entity) || Boolean(c.framework?.css?.templates?.length);
157
143
  const onlyValuePieces = (candidates) => candidates.length > 0 && candidates.every(isValuePiece);
158
144
  const fileFinding = (scene, out) => {
159
145
  if (!scene.edges.some((e) => e.path !== scene.ctx.rel))
160
146
  return;
161
147
  if (reexportOnly(scene) || onlyValuePieces(scene.ctx.facts?.candidates ?? []))
162
148
  return;
163
- out.push((0, cli_report_1.findingFrom)({ ...noRole(scene.ctx.rel, null, scene) }, "nodes", scene.decl.owner ?? scene.ctx.rel, `unroled:${scene.decl.owner ?? "tree"}:file`, { path: scene.ctx.rel, what: scene.ctx.rel }));
149
+ out.push((0, cli_report_1.findingFrom)({ ...noEntity(scene.ctx.rel, null, scene) }, "nodes", scene.decl.owner ?? scene.ctx.rel, `unclassified:${scene.decl.owner ?? "tree"}:file`, { path: scene.ctx.rel, what: scene.ctx.rel }));
164
150
  };
165
151
  // The scan view the lookalike question needs: the project, the repo anchor,
166
152
  // the aliases, the file list, and the run's similarity cache.
@@ -175,10 +161,19 @@ const similarScanOf = (ctx, arch, project, repoFiles) => ({
175
161
  // The pipeline fills `ctx.facts` before this phase runs; the fallback keeps
176
162
  // the producers total for a context that carries none.
177
163
  const factsOf = (ctx, repoFiles) => {
178
- const empty = { lines: [], imports: [], exports: [], location: (0, location_1.placeOf)(ctx.rel), reads: [], kind: { own: { is: "SourceFile" }, descendants: [] }, candidates: [], roles: [] };
164
+ const empty = {
165
+ lines: [],
166
+ imports: [],
167
+ exports: [],
168
+ location: (0, location_1.placeOf)(ctx.rel),
169
+ reads: [],
170
+ kind: { own: { is: "SourceFile" }, descendants: [] },
171
+ candidates: [],
172
+ entities: [],
173
+ };
179
174
  return { ...(ctx.facts ?? empty), repoFiles };
180
175
  };
181
- const checkUnroled = (withRoles, run) => {
176
+ const checkUnclassified = (withEntities, run) => {
182
177
  const { present, ctx, arch, project, repoFiles, out } = run;
183
178
  const decl = declarationOf(ctx, arch);
184
179
  // What this folder LOOKS LIKE, if anything: every declared entity whose shape
@@ -186,8 +181,8 @@ const checkUnroled = (withRoles, run) => {
186
181
  // place — a folder may be 80% a feature and 66% a type home, and both are offered.
187
182
  const like = (0, similar_1.similarNodes)(arch, (0, location_1.dirOf)(ctx.rel), similarScanOf(ctx, arch, project, repoFiles));
188
183
  const edges = edgesOf(factsOf(ctx, repoFiles));
189
- const unroled = unroledFindings(withRoles, { ctx, decl, like, edges }, out);
190
- if (!present.length && !unroled)
184
+ const unclassified = unclassifiedFindings(withEntities, { ctx, decl, like, edges }, out);
185
+ if (!present.length && !unclassified)
191
186
  fileFinding({ ctx, decl, like, edges }, out);
192
187
  };
193
- exports.checkUnroled = checkUnroled;
188
+ exports.checkUnclassified = checkUnclassified;
package/dist/pipeline.js CHANGED
@@ -3,71 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTsProject = exports.checkFile = void 0;
4
4
  const ast_1 = require("./entities/ast");
5
5
  Object.defineProperty(exports, "createTsProject", { enumerable: true, get: function () { return ast_1.createTsProject; } });
6
- const classify_1 = require("./code-roles/classify");
7
- const project_1 = require("./code-roles/project");
8
- const tree_1 = require("./entities/tree");
9
- const finally_1 = require("./nodes/finally");
10
- const invariants_1 = require("./invariants");
11
- const cli_report_1 = require("./report/cli-report");
12
- const pipeline_facts_1 = require("./pipeline-facts");
13
- const pipeline_roles_1 = require("./pipeline-roles");
14
- const pipeline_unroled_1 = require("./pipeline-unroled");
15
- // Does any filter name the project-wide `codeRole` scope (as a field or a
16
- // `$codeRole.…` reference)? Only then is the project-wide classify pass worth
17
- // running — a config that never asks for it pays nothing.
18
- const filterNamesCodeRole = (filter) => {
19
- if (typeof filter === "string")
20
- return filter.includes("$codeRole");
21
- if (Array.isArray(filter))
22
- return filter.some(filterNamesCodeRole);
23
- if (filter === null || typeof filter !== "object")
24
- return false;
25
- return Object.entries(filter).some(([key, value]) => key === "codeRole" || filterNamesCodeRole(value));
26
- };
27
- const invariantNamesCodeRole = (inv) => inv.when !== null && filterNamesCodeRole(inv.when) ? true : inv.infer.some(filterNamesCodeRole) || inv.children.some(invariantNamesCodeRole);
28
- const namesCodeRole = (invs) => invs.some(invariantNamesCodeRole);
29
- // The lazy `codeRole` scope: role slug → the project-wide classified pieces.
30
- // Defined as a getter so the whole-project scan runs only when a filter reads
31
- // it, and memoised in the closure so it runs once per file.
32
- const defineCodeRole = (facts, build) => {
33
- let cached = null;
34
- Object.defineProperty(facts, "codeRole", {
35
- enumerable: true,
36
- configurable: true,
37
- get: () => (cached ??= build()),
38
- });
39
- };
6
+ const facts_record_1 = require("./facts-record");
7
+ const release_file_1 = require("./release-file");
40
8
  const checkFile = (...args) => {
41
9
  const [abs, arch, project, repoFiles, dedupe] = args;
42
- // 1. LOAD → FACTS: candidates once, facets attached, the file's fact set.
43
- const { ctx, candidates, fileFacts } = (0, pipeline_facts_1.collectFacts)(abs, arch, project, repoFiles, dedupe);
44
- // 2. ROLES: classify, then fill the two fields that need the classification.
45
- const { present, roleCtx, candidates: withRoles } = (0, classify_1.classifyRoles)(candidates, arch.codeRoles ?? {}, arch, fileFacts);
46
- ctx.roles = present;
47
- ctx.roleCtx = roleCtx;
48
- // `c.file` is the snapshot every candidate carries, and roles are known only
49
- // now: filling them here keeps "the file this piece sits in" complete instead
50
- // of a copy that silently lacks the one field a rule asks about.
51
- fileFacts.roles = [...new Set(present)];
52
- // File facts (candidates attached) — the invariants' filter target.
53
- // `repoFiles` travels with the facts: an edge's module is a repo FILE or a
54
- // library SPECIFIER, and the file list is the one place that tells them apart.
55
- ctx.facts = { ...fileFacts, candidates: withRoles, roles: [...new Set(present)], repoFiles };
56
- // The project-wide role index serves two things, both lazy: the `codeRole`
57
- // scope a filter can navigate, and the objects resolution resolves against.
58
- if (namesCodeRole(arch.invariants))
59
- defineCodeRole(ctx.facts, () => (0, project_1.codeRoleScope)((0, project_1.projectRoleIndex)(project, arch, repoFiles)));
60
- ctx.objectsFor = (slugs) => (0, project_1.objectsFor)((0, project_1.projectRoleIndex)(project, arch, repoFiles), slugs);
61
- const out = [];
62
- // 3. ROLE HOMES: every candidate must fit its role's declared home.
63
- (0, pipeline_roles_1.checkRoleHomes)(withRoles, ctx, arch, out);
64
- // 4. UNROLED: the pieces no role describes, and the file nothing describes.
65
- (0, pipeline_unroled_1.checkUnroled)(withRoles, { present, ctx, arch, project, repoFiles, out });
66
- // 5. STRUCTURE: the node tree, then the built-in structure rule (kind +
67
- // declaration), then the invariants.
68
- (0, tree_1.checkTree)(ctx.rel, arch, out, cli_report_1.findingFrom, ctx.facts, ctx.repoFiles);
69
- (0, finally_1.checkFinally)(ctx, arch, out, cli_report_1.findingFrom);
70
- (0, invariants_1.checkInvariants)(arch.invariants, ctx, out, cli_report_1.findingFrom, dedupe);
71
- return out;
10
+ // `FA_CHECKS=live` runs the checks on the facts as they were collected, with no
11
+ // record in between — the reference a parity run compares the record path to.
12
+ const sf = project.getSourceFile(abs);
13
+ let parts;
14
+ if (process.env.FA_CHECKS === "live") {
15
+ parts = (0, facts_record_1.checkLive)(abs, { arch, project, repoFiles, dedupe });
16
+ }
17
+ else {
18
+ // The checker's answers are asked by the record path itself, on this file's
19
+ // syntax: a plain run has no index to store them in and no pass to ask them in.
20
+ parts = (0, facts_record_1.checkRecord)((0, facts_record_1.extractFileFacts)(abs, { arch, project, repoFiles }), { arch, project, repoFiles, dedupe, sf });
21
+ }
22
+ // The file is measured and its findings are plain data: the syntax memoised for
23
+ // it is given back here, so a run holds one file's tree instead of every file's.
24
+ if (sf)
25
+ (0, release_file_1.releaseFile)(sf);
26
+ return [...parts.before, ...parts.nodes, ...parts.after];
72
27
  };
73
28
  exports.checkFile = checkFile;
@@ -0,0 +1,3 @@
1
+ import type { SourceFile } from "ts-morph";
2
+ declare const releaseFile: (sf: SourceFile) => void;
3
+ export { releaseFile };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.releaseFile = void 0;
4
+ const ast_1 = require("./entities/ast");
5
+ const scope_1 = require("./css/value/scope");
6
+ // Forget everything the run remembers about one file's syntax. The compiler AST
7
+ // is untouched (ts-morph recreates wrappers on demand), so a caller may still
8
+ // ask the file for text — only the memoised walk products are gone.
9
+ const releaseFile = (sf) => {
10
+ (0, ast_1.releaseFile)(sf);
11
+ (0, scope_1.releaseSourceScope)(sf);
12
+ };
13
+ exports.releaseFile = releaseFile;
@@ -1,5 +1,5 @@
1
- import type { StatedRepair } from "../entities/repair";
2
- import type { ReportObject } from "../entities/architecture";
1
+ import type { StatedRepair } from "@md-code/follow-architecture/entities/repair";
2
+ import type { ReportObject } from "@md-code/follow-architecture/entities/architecture";
3
3
  declare const q: (text: string) => string;
4
4
  declare const names: (list: readonly string[]) => string;
5
5
  declare const repair: (spec: {
@@ -33,7 +33,7 @@ declare const __exported_asks: {
33
33
  message: string;
34
34
  fix: string;
35
35
  };
36
- role: (args: {
36
+ entity: (args: {
37
37
  what: string;
38
38
  why: string;
39
39
  }) => {