@backbencher/brain 0.0.0-stage → 0.1.1

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 (319) hide show
  1. package/CHANGELOG.md +298 -0
  2. package/EMBEDDINGS.md +355 -0
  3. package/LICENSE +21 -0
  4. package/README.md +415 -2
  5. package/bin/bb +13 -0
  6. package/dist/analysis-exclusions-7ZJDXOVZ.js +35 -0
  7. package/dist/brain-index-health-Q5APTJQL.js +17 -0
  8. package/dist/brain-relationship-enrichment-MYR2AM4F.js +558 -0
  9. package/dist/brain.sql-EIM4WS4D.js +29 -0
  10. package/dist/chunk-22V37YTK.js +1758 -0
  11. package/dist/chunk-2BSKD7O3.js +40 -0
  12. package/dist/chunk-2DE27DVC.js +1314 -0
  13. package/dist/chunk-2RRBMNBQ.js +322 -0
  14. package/dist/chunk-2WXYNLBA.js +29 -0
  15. package/dist/chunk-3CTFIJJB.js +17 -0
  16. package/dist/chunk-3ZTOHHSW.js +2104 -0
  17. package/dist/chunk-4H22TLOT.js +543 -0
  18. package/dist/chunk-5BVAH26D.js +340 -0
  19. package/dist/chunk-62DHLYW6.js +3427 -0
  20. package/dist/chunk-7AN7U5IZ.js +371 -0
  21. package/dist/chunk-7DRPNVIN.js +782 -0
  22. package/dist/chunk-7MBYT777.js +174 -0
  23. package/dist/chunk-AHDWGM7Q.js +236 -0
  24. package/dist/chunk-B5GEAAYF.js +818 -0
  25. package/dist/chunk-BEIZZ73B.js +1479 -0
  26. package/dist/chunk-BQ3OVQ3P.js +125 -0
  27. package/dist/chunk-D2Q4Y47A.js +53 -0
  28. package/dist/chunk-DIYAGQJL.js +34 -0
  29. package/dist/chunk-DWKXZ6IF.js +336 -0
  30. package/dist/chunk-DYM4FQEE.js +90 -0
  31. package/dist/chunk-ENW4BTBA.js +930 -0
  32. package/dist/chunk-EWMWK7WN.js +75 -0
  33. package/dist/chunk-EY5ZZUUA.js +626 -0
  34. package/dist/chunk-GBI7V7KY.js +69 -0
  35. package/dist/chunk-GEFFO6O2.js +152 -0
  36. package/dist/chunk-HJEWO5EV.js +247 -0
  37. package/dist/chunk-HQSPJDHI.js +613 -0
  38. package/dist/chunk-KAET47ZL.js +125 -0
  39. package/dist/chunk-KCDECRJY.js +440 -0
  40. package/dist/chunk-L5TDYKYK.js +76 -0
  41. package/dist/chunk-MLKGABMK.js +9 -0
  42. package/dist/chunk-NO3U3FJQ.js +201 -0
  43. package/dist/chunk-OWISBAOF.js +61 -0
  44. package/dist/chunk-QKTRECYS.js +1119 -0
  45. package/dist/chunk-QLK6ED4Q.js +235 -0
  46. package/dist/chunk-R2GW4F6R.js +19 -0
  47. package/dist/chunk-RCMTFSEF.js +87 -0
  48. package/dist/chunk-RM3PY6TG.js +376 -0
  49. package/dist/chunk-ROMM6KMC.js +433 -0
  50. package/dist/chunk-SGGCSHAX.js +12050 -0
  51. package/dist/chunk-SK6YVHFZ.js +211 -0
  52. package/dist/chunk-SM7RFQRO.js +214 -0
  53. package/dist/chunk-UGR4QIGS.js +67 -0
  54. package/dist/chunk-UQNQZXHY.js +711 -0
  55. package/dist/chunk-UUNHHX4M.js +13 -0
  56. package/dist/chunk-VL52PL2T.js +71 -0
  57. package/dist/chunk-WIG36E67.js +196 -0
  58. package/dist/chunk-XHK3WWGB.js +7436 -0
  59. package/dist/chunk-XTQM2IP3.js +2863 -0
  60. package/dist/chunk-ZE2LG76D.js +1296 -0
  61. package/dist/chunk-ZETTGPAW.js +6950 -0
  62. package/dist/cli/index.js +37 -0
  63. package/dist/config-HZAAYDP3.js +10 -0
  64. package/dist/content-search-7XIP555Q.js +593 -0
  65. package/dist/database-76RP44JG.js +9 -0
  66. package/dist/doctor-ANGETYMN.js +395 -0
  67. package/dist/edit-engine-CG72LDZD.js +51 -0
  68. package/dist/engine-BKEOGN7N.js +11 -0
  69. package/dist/engine-VIW6NSKO.js +18 -0
  70. package/dist/fingerprint-OBLIMZLP.js +33 -0
  71. package/dist/framework-intelligence-3LORTPOX.js +860 -0
  72. package/dist/freshness-3K6VU5OT.js +174 -0
  73. package/dist/graph-engine-HBSQNPTB.js +21 -0
  74. package/dist/graph_request-Q6NKB6N2.js +350 -0
  75. package/dist/impact_request-LYP672WE.js +68 -0
  76. package/dist/index-space-IUUN5WYV.js +15 -0
  77. package/dist/index-status-7OVGYSGW.js +34 -0
  78. package/dist/index.js +159 -0
  79. package/dist/instance-FO6QZRLH.js +19 -0
  80. package/dist/language-detection-DFCAU5DZ.js +11 -0
  81. package/dist/lsp/server.js +4301 -0
  82. package/dist/mcp/server.js +132 -0
  83. package/dist/onboard-DIQZV2NW.js +161 -0
  84. package/dist/override-companion-pass-XR7MHTP7.js +117 -0
  85. package/dist/parallel-indexer-FK2XKZXY.js +88 -0
  86. package/dist/pool-worker.js +1153 -0
  87. package/dist/project-health-6XPENVAA.js +94 -0
  88. package/dist/project-index-5SDPHITE.js +57 -0
  89. package/dist/project-registry-ZJ3DVUGO.js +355 -0
  90. package/dist/real-bash-analyzer-EJAU5LW5.js +2201 -0
  91. package/dist/real-c-analyzer-HBD3FNNH.js +5942 -0
  92. package/dist/real-clean-analyzer-4EEZLPV5.js +3470 -0
  93. package/dist/real-clojure-analyzer-Q55EBOO2.js +2818 -0
  94. package/dist/real-cpp-analyzer-IVVOD25R.js +4101 -0
  95. package/dist/real-csharp-analyzer-ZBNLNJZJ.js +3298 -0
  96. package/dist/real-css-analyzer-6XRQLUN7.js +15 -0
  97. package/dist/real-dart-analyzer-OLR72EFW.js +3944 -0
  98. package/dist/real-elixir-analyzer-MQWGAH2I.js +2192 -0
  99. package/dist/real-erlang-analyzer-7BVPQEHO.js +1731 -0
  100. package/dist/real-fsharp-analyzer-C2UPFNOA.js +2390 -0
  101. package/dist/real-go-analyzer-UKGI43YS.js +4126 -0
  102. package/dist/real-graphql-analyzer-VE2EEFII.js +1442 -0
  103. package/dist/real-groovy-analyzer-W26VACFW.js +2285 -0
  104. package/dist/real-haskell-analyzer-5CVVAJRX.js +2533 -0
  105. package/dist/real-hcl-analyzer-5ZT4U43N.js +725 -0
  106. package/dist/real-html-analyzer-JWNX3C6I.js +1759 -0
  107. package/dist/real-java-analyzer-GU42VBGQ.js +4677 -0
  108. package/dist/real-javascript-analyzer-QA4QOJ6W.js +14 -0
  109. package/dist/real-json-analyzer-MPA6PRXL.js +1640 -0
  110. package/dist/real-julia-analyzer-22CWYQMN.js +2085 -0
  111. package/dist/real-kotlin-analyzer-QDZJLXXU.js +3956 -0
  112. package/dist/real-lua-analyzer-G7NHLYKS.js +1957 -0
  113. package/dist/real-makefile-analyzer-OCY3GT5N.js +920 -0
  114. package/dist/real-markdown-analyzer-TEJK2JXJ.js +1215 -0
  115. package/dist/real-matlab-analyzer-Q5SWLN7Z.js +480 -0
  116. package/dist/real-nim-analyzer-YLXSK563.js +3603 -0
  117. package/dist/real-objective-c-analyzer-D23ACC2R.js +1518 -0
  118. package/dist/real-perl-analyzer-WWTRHYDT.js +1865 -0
  119. package/dist/real-php-analyzer-JNKJHTCL.js +9368 -0
  120. package/dist/real-powershell-analyzer-XRSNQERV.js +2915 -0
  121. package/dist/real-protobuf-analyzer-3OKUCZ7T.js +867 -0
  122. package/dist/real-python-analyzer-VXAFWI72.js +4880 -0
  123. package/dist/real-r-analyzer-ZGAIDVI4.js +2596 -0
  124. package/dist/real-ruby-analyzer-X2KTLVBH.js +2429 -0
  125. package/dist/real-rust-analyzer-OFFHPL2A.js +3359 -0
  126. package/dist/real-scala-analyzer-TSTW27J6.js +3293 -0
  127. package/dist/real-scss-analyzer-AVWYPSOQ.js +1515 -0
  128. package/dist/real-solidity-analyzer-UCI2KWUB.js +2608 -0
  129. package/dist/real-sql-analyzer-F77ZMQXR.js +3840 -0
  130. package/dist/real-svelte-analyzer-SF7NRUO5.js +2532 -0
  131. package/dist/real-swift-analyzer-MN5QT3QN.js +2311 -0
  132. package/dist/real-toml-analyzer-66L7BDCQ.js +929 -0
  133. package/dist/real-typescript-analyzer-6KEMVDWQ.js +14 -0
  134. package/dist/real-vb-analyzer-VICVPOP7.js +3145 -0
  135. package/dist/real-vba-analyzer-HXLTTHKM.js +466 -0
  136. package/dist/real-vue-analyzer-QXR56CFV.js +2680 -0
  137. package/dist/real-xml-analyzer-YL465ZJW.js +2405 -0
  138. package/dist/real-yaml-analyzer-SUBCBNSI.js +3528 -0
  139. package/dist/real-zig-analyzer-HIQLZMGY.js +2430 -0
  140. package/dist/regex-search-NJKHMZNO.js +239 -0
  141. package/dist/rules-ACHPB7QU.js +152 -0
  142. package/dist/scoped-path-MJYWJZQX.js +11 -0
  143. package/dist/setup-show-NT5ZHYNE.js +15 -0
  144. package/dist/setup-wizard-G5YYR5T6.js +24 -0
  145. package/dist/symbol-search-GZJIM2J2.js +16 -0
  146. package/dist/taint-KXUHHPIE.js +202 -0
  147. package/dist/taint-analyzer-N7YLZU3N.js +163 -0
  148. package/dist/tool-handlers-OJDC35DI.js +72 -0
  149. package/dist/tool-registry-BPEJNSZG.js +17 -0
  150. package/dist/tool-validation-Q57YMMBX.js +32 -0
  151. package/dist/type-inference-QMT2RMLV.js +13 -0
  152. package/dist/vector-binary-LMY4QGAN.js +19 -0
  153. package/dist/version-ABP2TUL2.js +9 -0
  154. package/dist/wasm-NMWO3WXY.js +16 -0
  155. package/docs/EMBEDDINGS.md +132 -0
  156. package/docs/README.md +178 -0
  157. package/docs/data/m10-baseline.json +602 -0
  158. package/docs/data/m10-benchmark-baseline.json +57 -0
  159. package/docs/data/m10-benchmark-last-run.json +127 -0
  160. package/docs/data/m10-final-audit.json +215 -0
  161. package/docs/data/m12-final-audit.json +138 -0
  162. package/docs/data/m12-surface-matrix.json +50 -0
  163. package/docs/data/public-tools.json +1902 -0
  164. package/docs/indexing/DEAD-ASSETS.md +88 -0
  165. package/docs/indexing/INDEXER-REVIEW.md +634 -0
  166. package/docs/indexing/PERFORMANCE-FINDINGS.md +106 -0
  167. package/docs/indexing/README.md +427 -0
  168. package/docs/indexing/discovery-matrix.md +41 -0
  169. package/docs/indexing/embeddings.md +325 -0
  170. package/docs/indexing/environment-variables.md +77 -0
  171. package/docs/indexing/performance.md +323 -0
  172. package/docs/indexing/resume.md +345 -0
  173. package/docs/indexing/troubleshooting.md +391 -0
  174. package/docs/man/bb.1 +190 -0
  175. package/docs/tools/bb_analyze.md +147 -0
  176. package/docs/tools/bb_annotate.md +110 -0
  177. package/docs/tools/bb_annotations.md +106 -0
  178. package/docs/tools/bb_ask.md +101 -0
  179. package/docs/tools/bb_cross_language.md +103 -0
  180. package/docs/tools/bb_doc.md +169 -0
  181. package/docs/tools/bb_edit.md +185 -0
  182. package/docs/tools/bb_graph.md +169 -0
  183. package/docs/tools/bb_health.md +156 -0
  184. package/docs/tools/bb_impact.md +117 -0
  185. package/docs/tools/bb_index.md +108 -0
  186. package/docs/tools/bb_migrate.md +135 -0
  187. package/docs/tools/bb_patterns.md +140 -0
  188. package/docs/tools/bb_search.md +150 -0
  189. package/docs/tools/bb_security.md +100 -0
  190. package/docs/tools/bb_visualize.md +184 -0
  191. package/grammars/README.md +57 -0
  192. package/grammars/THIRD-PARTY-NOTICES.md +50 -0
  193. package/grammars/tree-sitter-c/LICENSE +21 -0
  194. package/grammars/tree-sitter-clojure/LICENSE.md +21 -0
  195. package/grammars/tree-sitter-cpp/LICENSE +21 -0
  196. package/grammars/tree-sitter-csharp/LICENSE +21 -0
  197. package/grammars/tree-sitter-css/LICENSE +21 -0
  198. package/grammars/tree-sitter-css/README.md +21 -0
  199. package/grammars/tree-sitter-dart/LICENSE +20 -0
  200. package/grammars/tree-sitter-dart-upstream/LICENSE +20 -0
  201. package/grammars/tree-sitter-dart-upstream/README.md +18 -0
  202. package/grammars/tree-sitter-elixir/LICENSE +176 -0
  203. package/grammars/tree-sitter-elixir/README.md +11 -0
  204. package/grammars/tree-sitter-fsharp/LICENSE +21 -0
  205. package/grammars/tree-sitter-fsharp/README.md +45 -0
  206. package/grammars/tree-sitter-graphql/LICENSE +21 -0
  207. package/grammars/tree-sitter-graphql/README.md +106 -0
  208. package/grammars/tree-sitter-groovy/LICENSE +21 -0
  209. package/grammars/tree-sitter-groovy/README.md +4 -0
  210. package/grammars/tree-sitter-haskell/LICENSE +21 -0
  211. package/grammars/tree-sitter-haskell/README.md +394 -0
  212. package/grammars/tree-sitter-hcl/CHANGELOG.md +102 -0
  213. package/grammars/tree-sitter-hcl/LICENSE +201 -0
  214. package/grammars/tree-sitter-hcl/README.md +39 -0
  215. package/grammars/tree-sitter-html/LICENSE +21 -0
  216. package/grammars/tree-sitter-html/README.md +21 -0
  217. package/grammars/tree-sitter-julia/LICENSE +21 -0
  218. package/grammars/tree-sitter-julia/README.md +24 -0
  219. package/grammars/tree-sitter-kotlin/LICENSE +9 -0
  220. package/grammars/tree-sitter-lua/LICENSE.md +21 -0
  221. package/grammars/tree-sitter-lua/README.md +29 -0
  222. package/grammars/tree-sitter-make/LICENSE +21 -0
  223. package/grammars/tree-sitter-matlab/LICENSE +19 -0
  224. package/grammars/tree-sitter-matlab/README.md +99 -0
  225. package/grammars/tree-sitter-nim/LICENSE +373 -0
  226. package/grammars/tree-sitter-nim/README.md +46 -0
  227. package/grammars/tree-sitter-objc/LICENSE +21 -0
  228. package/grammars/tree-sitter-objc/README.md +20 -0
  229. package/grammars/tree-sitter-perl/LICENSE +7 -0
  230. package/grammars/tree-sitter-perl/README.md +100 -0
  231. package/grammars/tree-sitter-powershell/LICENSE +21 -0
  232. package/grammars/tree-sitter-powershell/README.md +7 -0
  233. package/grammars/tree-sitter-proto/LICENSE +21 -0
  234. package/grammars/tree-sitter-proto/README.md +105 -0
  235. package/grammars/tree-sitter-r/LICENSE +9 -0
  236. package/grammars/tree-sitter-r/README.md +66 -0
  237. package/grammars/tree-sitter-ruby/LICENSE +22 -0
  238. package/grammars/tree-sitter-scss/LICENSE +21 -0
  239. package/grammars/tree-sitter-scss/README.md +17 -0
  240. package/grammars/tree-sitter-solidity/LICENSE +7 -0
  241. package/grammars/tree-sitter-sql/LICENSE +21 -0
  242. package/grammars/tree-sitter-typescript/LICENSE +21 -0
  243. package/grammars/tree-sitter-vba/LICENSE +21 -0
  244. package/grammars/tree-sitter-vba/README.md +738 -0
  245. package/grammars/tree-sitter-vbnet/LICENSE +21 -0
  246. package/grammars/tree-sitter-vbnet/README.md +322 -0
  247. package/grammars/tree-sitter-xml/LICENSE +19 -0
  248. package/grammars/tree-sitter-yaml/LICENSE +20 -0
  249. package/grammars/tree-sitter-yaml/README.md +21 -0
  250. package/package.json +184 -4
  251. package/wasm/dart.wasm +0 -0
  252. package/wasm/tree-sitter-bash.wasm +0 -0
  253. package/wasm/tree-sitter-c.wasm +0 -0
  254. package/wasm/tree-sitter-c_sharp.wasm +0 -0
  255. package/wasm/tree-sitter-clean.wasm +0 -0
  256. package/wasm/tree-sitter-clojure.wasm +0 -0
  257. package/wasm/tree-sitter-core_schema.wasm +0 -0
  258. package/wasm/tree-sitter-cpp.wasm +0 -0
  259. package/wasm/tree-sitter-css.wasm +0 -0
  260. package/wasm/tree-sitter-dart.wasm +0 -0
  261. package/wasm/tree-sitter-elisp.wasm +0 -0
  262. package/wasm/tree-sitter-elixir.wasm +0 -0
  263. package/wasm/tree-sitter-elm.wasm +0 -0
  264. package/wasm/tree-sitter-embedded_template.wasm +0 -0
  265. package/wasm/tree-sitter-erlang.wasm +0 -0
  266. package/wasm/tree-sitter-fsharp.wasm +0 -0
  267. package/wasm/tree-sitter-fsharp_signature.wasm +0 -0
  268. package/wasm/tree-sitter-go.wasm +0 -0
  269. package/wasm/tree-sitter-graphql.wasm +0 -0
  270. package/wasm/tree-sitter-groovy.wasm +0 -0
  271. package/wasm/tree-sitter-haskell.wasm +0 -0
  272. package/wasm/tree-sitter-hcl.wasm +0 -0
  273. package/wasm/tree-sitter-html.wasm +0 -0
  274. package/wasm/tree-sitter-java.wasm +0 -0
  275. package/wasm/tree-sitter-javascript.wasm +0 -0
  276. package/wasm/tree-sitter-json.wasm +0 -0
  277. package/wasm/tree-sitter-json_schema.wasm +0 -0
  278. package/wasm/tree-sitter-julia.wasm +0 -0
  279. package/wasm/tree-sitter-kotlin.wasm +0 -0
  280. package/wasm/tree-sitter-lua.wasm +0 -0
  281. package/wasm/tree-sitter-make.wasm +0 -0
  282. package/wasm/tree-sitter-markdown.wasm +0 -0
  283. package/wasm/tree-sitter-markdown_inline.wasm +0 -0
  284. package/wasm/tree-sitter-matlab.wasm +0 -0
  285. package/wasm/tree-sitter-nim.wasm +0 -0
  286. package/wasm/tree-sitter-objc.wasm +0 -0
  287. package/wasm/tree-sitter-ocaml.wasm +0 -0
  288. package/wasm/tree-sitter-perl.wasm +0 -0
  289. package/wasm/tree-sitter-php.wasm +0 -0
  290. package/wasm/tree-sitter-php_only.wasm +0 -0
  291. package/wasm/tree-sitter-powershell.wasm +0 -0
  292. package/wasm/tree-sitter-protobuf.wasm +0 -0
  293. package/wasm/tree-sitter-python.wasm +0 -0
  294. package/wasm/tree-sitter-ql.wasm +0 -0
  295. package/wasm/tree-sitter-r.wasm +0 -0
  296. package/wasm/tree-sitter-rescript.wasm +0 -0
  297. package/wasm/tree-sitter-ruby.wasm +0 -0
  298. package/wasm/tree-sitter-rust.wasm +0 -0
  299. package/wasm/tree-sitter-scala.wasm +0 -0
  300. package/wasm/tree-sitter-scss.wasm +0 -0
  301. package/wasm/tree-sitter-solidity.wasm +0 -0
  302. package/wasm/tree-sitter-sql.wasm +0 -0
  303. package/wasm/tree-sitter-svelte.wasm +0 -0
  304. package/wasm/tree-sitter-swift.wasm +0 -0
  305. package/wasm/tree-sitter-systemrdl.wasm +0 -0
  306. package/wasm/tree-sitter-terraform.wasm +0 -0
  307. package/wasm/tree-sitter-tlaplus.wasm +0 -0
  308. package/wasm/tree-sitter-toml.wasm +0 -0
  309. package/wasm/tree-sitter-tsx.wasm +0 -0
  310. package/wasm/tree-sitter-typescript.wasm +0 -0
  311. package/wasm/tree-sitter-vba.wasm +0 -0
  312. package/wasm/tree-sitter-vbnet.wasm +0 -0
  313. package/wasm/tree-sitter-vue.wasm +0 -0
  314. package/wasm/tree-sitter-xml.wasm +0 -0
  315. package/wasm/tree-sitter-yaml.wasm +0 -0
  316. package/wasm/tree-sitter-zig.wasm +0 -0
  317. package/wasm/tree-sitter.wasm +0 -0
  318. package/wasm/tsx.wasm +0 -0
  319. package/wasm/typescript.wasm +0 -0
@@ -0,0 +1,929 @@
1
+ import {
2
+ dirOf,
3
+ fileClaimForTarget,
4
+ projectRelativeOf
5
+ } from "./chunk-EWMWK7WN.js";
6
+ import {
7
+ applyDocumentScope,
8
+ documentDirScope
9
+ } from "./chunk-2WXYNLBA.js";
10
+ import {
11
+ ASTEngine
12
+ } from "./chunk-3ZTOHHSW.js";
13
+ import "./chunk-BQ3OVQ3P.js";
14
+ import "./chunk-SK6YVHFZ.js";
15
+ import "./chunk-2BSKD7O3.js";
16
+ import "./chunk-KAET47ZL.js";
17
+ import "./chunk-KCDECRJY.js";
18
+ import "./chunk-MLKGABMK.js";
19
+
20
+ // src/ast/real-toml-analyzer.ts
21
+ import * as path from "path";
22
+ import { readFileSync, statSync } from "fs";
23
+ var DEPENDENCY_MANIFESTS = ["Cargo.toml", "Project.toml", "JuliaProject.toml", "pyproject.toml", "Package.toml"];
24
+ var PUBLISH_SURFACE_KEYS = /* @__PURE__ */ new Set([
25
+ "export",
26
+ "exports",
27
+ "expose",
28
+ "exposed",
29
+ "pub",
30
+ "public",
31
+ "publish",
32
+ "main",
33
+ "module",
34
+ "mod",
35
+ "entrypoint"
36
+ ]);
37
+ function isPathOrUriShaped(value) {
38
+ if (value.includes("/") || value.includes("\\")) return true;
39
+ for (let i = 0; i < value.length; i++) {
40
+ const c = value.charCodeAt(i);
41
+ const letter = c >= 65 && c <= 90 || c >= 97 && c <= 122;
42
+ if (i === 0) {
43
+ if (!letter) return false;
44
+ continue;
45
+ }
46
+ if (c === 58) return true;
47
+ if (!(letter || c >= 48 && c <= 57 || c === 43 || c === 45 || c === 46)) return false;
48
+ }
49
+ return false;
50
+ }
51
+ function dependencyFileClaim(written, filePath, projectRoot, base) {
52
+ if (projectRoot === null || projectRoot.length === 0) return null;
53
+ const root = path.resolve(projectRoot);
54
+ const fileRel = path.relative(root, filePath).split(path.sep).join("/");
55
+ const posix = projectRelativeOf(dirOf(fileRel), written.trim());
56
+ const extraCandidates = [];
57
+ if (posix !== null) {
58
+ for (const m of DEPENDENCY_MANIFESTS) extraCandidates.push(posix.length === 0 ? m : `${posix}/${m}`);
59
+ if (posix.length > 0) extraCandidates.push(posix);
60
+ }
61
+ const standard = fileClaimForTarget({
62
+ projectRoot: root,
63
+ filePath,
64
+ written,
65
+ admittedExtensions: ["toml"],
66
+ extraCandidates
67
+ });
68
+ if (standard !== null) return standard;
69
+ if (base === null) return null;
70
+ const baseCandidates = pathBaseCandidates(base, written, filePath, root);
71
+ if (baseCandidates.length === 0) return null;
72
+ return fileClaimForTarget({
73
+ projectRoot: root,
74
+ filePath,
75
+ written,
76
+ admittedExtensions: ["toml"],
77
+ extraCandidates: [...baseCandidates, ...extraCandidates]
78
+ });
79
+ }
80
+ function pathBaseValueIn(configText, base) {
81
+ let inSection = false;
82
+ let found = null;
83
+ for (const raw of configText.split("\n")) {
84
+ const uncommented = stripCommentOutsideQuotes(raw);
85
+ if (uncommented === null) return null;
86
+ const line = uncommented.trim();
87
+ if (line.length === 0) continue;
88
+ if (line.charCodeAt(0) === 91) {
89
+ const close = line.indexOf("]");
90
+ if (close < 0) return null;
91
+ inSection = line.slice(1, close).trim() === "path-bases";
92
+ continue;
93
+ }
94
+ if (!inSection) continue;
95
+ const eq = line.indexOf("=");
96
+ if (eq < 0) return null;
97
+ if (unquoteKey(line.slice(0, eq).trim()) !== base) continue;
98
+ const value = line.slice(eq + 1).trim();
99
+ if (value.length < 2) return null;
100
+ const q = value.charCodeAt(0);
101
+ if (q !== 34 && q !== 39 || value.charCodeAt(value.length - 1) !== q) return null;
102
+ const inner = value.slice(1, -1);
103
+ if (inner.includes("\\")) return null;
104
+ if (found !== null) return null;
105
+ found = inner;
106
+ }
107
+ return found;
108
+ }
109
+ function stripCommentOutsideQuotes(line) {
110
+ let quote = 0;
111
+ for (let i = 0; i < line.length; i++) {
112
+ const c = line.charCodeAt(i);
113
+ if (quote !== 0) {
114
+ if (c === 92) {
115
+ i++;
116
+ continue;
117
+ }
118
+ if (c === quote) quote = 0;
119
+ continue;
120
+ }
121
+ if (c === 34 || c === 39) {
122
+ quote = c;
123
+ continue;
124
+ }
125
+ if (c === 35) return line.slice(0, i);
126
+ }
127
+ return quote === 0 ? line : null;
128
+ }
129
+ function pathBaseCandidates(base, written, filePath, projectRoot) {
130
+ const root = path.resolve(projectRoot);
131
+ let dir = path.dirname(path.resolve(filePath));
132
+ for (let depth = 0; depth < 64; depth++) {
133
+ const configPath = path.join(dir, ".cargo", "config.toml");
134
+ let text = null;
135
+ try {
136
+ if (statSync(configPath).isFile()) text = readFileSync(configPath, "utf8");
137
+ } catch {
138
+ text = null;
139
+ }
140
+ if (text !== null) {
141
+ const value = pathBaseValueIn(text, base);
142
+ if (value !== null) {
143
+ const joined = path.resolve(path.resolve(dir, value), written.trim());
144
+ const rel = path.relative(root, joined).split(path.sep).join("/");
145
+ if (rel.length === 0 || rel === ".." || rel.startsWith("../")) return [];
146
+ const out = [];
147
+ for (const m of DEPENDENCY_MANIFESTS) out.push(`${rel}/${m}`);
148
+ out.push(rel);
149
+ return out;
150
+ }
151
+ }
152
+ const parent = path.dirname(dir);
153
+ if (dir === root || parent === dir) break;
154
+ dir = parent;
155
+ }
156
+ return [];
157
+ }
158
+ function workspaceDeclaredPaths(text) {
159
+ const paths = /* @__PURE__ */ new Set();
160
+ let table = "";
161
+ for (const raw of text.split("\n")) {
162
+ const line = raw.trim();
163
+ if (line.length === 0 || line.charAt(0) === "#") continue;
164
+ if (line.charAt(0) === "[") {
165
+ const close = line.indexOf("]");
166
+ table = close < 0 ? "" : line.slice(1, close).trim();
167
+ continue;
168
+ }
169
+ const eq = line.indexOf("=");
170
+ if (eq < 0) continue;
171
+ let key = line.slice(0, eq).trim();
172
+ if (key.length >= 2) {
173
+ const q = key.charCodeAt(0);
174
+ if ((q === 34 || q === 39) && key.charCodeAt(key.length - 1) === q) key = key.slice(1, -1);
175
+ }
176
+ if (key.length === 0) continue;
177
+ paths.add(table.length > 0 ? `${table}.${key}` : key);
178
+ }
179
+ return paths;
180
+ }
181
+ function declaresWorkspace(text) {
182
+ for (const raw of text.split("\n")) if (raw.trim() === "[workspace]") return true;
183
+ return false;
184
+ }
185
+ function findWorkspaceRoot(filePath, projectRoot) {
186
+ if (projectRoot === null || projectRoot.length === 0) return null;
187
+ const root = path.resolve(projectRoot);
188
+ let dir = path.dirname(path.resolve(filePath));
189
+ for (let depth = 0; depth < 64; depth++) {
190
+ for (const m of ["Cargo.toml", "Project.toml", "pyproject.toml", "Package.toml"]) {
191
+ const abs = path.join(dir, m);
192
+ let text = null;
193
+ try {
194
+ if (statSync(abs).isFile()) text = readFileSync(abs, "utf8");
195
+ } catch {
196
+ text = null;
197
+ }
198
+ if (text === null || !declaresWorkspace(text)) continue;
199
+ const stem = path.basename(abs, path.extname(abs)) || "document";
200
+ return { abs, moduleName: applyDocumentScope(stem, documentDirScope(abs, root)) };
201
+ }
202
+ const parent = path.dirname(dir);
203
+ if (dir === root || parent === dir) break;
204
+ dir = parent;
205
+ }
206
+ return null;
207
+ }
208
+ function unquoteKey(text) {
209
+ if (text.length < 2) return text;
210
+ const first = text.charCodeAt(0);
211
+ if (first !== 34 && first !== 39) return text;
212
+ const inner = text.slice(1, -1);
213
+ if (first === 39) return inner;
214
+ let out = "";
215
+ for (let i = 0; i < inner.length; i++) {
216
+ const c = inner.charCodeAt(i);
217
+ if (c !== 92) {
218
+ out += inner[i];
219
+ continue;
220
+ }
221
+ const n = inner.charCodeAt(i + 1);
222
+ i++;
223
+ if (n === 110) out += "\n";
224
+ else if (n === 116) out += " ";
225
+ else if (n === 114) out += "\r";
226
+ else if (n === 34) out += '"';
227
+ else if (n === 92) out += "\\";
228
+ else if (n === 117 || n === 85) {
229
+ const hex = inner.slice(i + 1, i + 5);
230
+ if (hex.length === 4) {
231
+ const v = Number.parseInt(hex, 16);
232
+ if (Number.isFinite(v)) {
233
+ out += String.fromCharCode(v);
234
+ i += 4;
235
+ continue;
236
+ }
237
+ }
238
+ out += "\\u";
239
+ } else {
240
+ out += "\\";
241
+ out += inner[i] ?? "";
242
+ }
243
+ }
244
+ return out;
245
+ }
246
+ function segmentsOf(node) {
247
+ const chain = [];
248
+ let cur = node;
249
+ while (cur.type === "dotted_key") {
250
+ chain.push(cur);
251
+ const first = (cur.namedChildren ?? [])[0];
252
+ if (!first) break;
253
+ cur = first;
254
+ }
255
+ const out = [];
256
+ if (cur.type === "bare_key" || cur.type === "quoted_key") out.push(unquoteKey(cur.text));
257
+ for (let i = chain.length - 1; i >= 0; i--) {
258
+ const kids = chain[i].namedChildren ?? [];
259
+ const rest = kids.length > 0 ? kids[kids.length - 1] : void 0;
260
+ if (rest && (rest.type === "bare_key" || rest.type === "quoted_key")) {
261
+ out.push(unquoteKey(rest.text));
262
+ } else if (rest) {
263
+ for (const seg of segmentsOf(rest)) out.push(seg);
264
+ }
265
+ }
266
+ return out;
267
+ }
268
+ function namesSomething(segments) {
269
+ for (const s of segments) if (s.length > 0) return true;
270
+ return false;
271
+ }
272
+ function joinPath(segments) {
273
+ let out = "";
274
+ for (let i = 0; i < segments.length; i++) {
275
+ if (i > 0) out += ".";
276
+ out += spellSegment(segments[i]);
277
+ }
278
+ return out;
279
+ }
280
+ function spellSegment(seg) {
281
+ let bare = seg.length > 0;
282
+ for (let k = 0; bare && k < seg.length; k++) {
283
+ const c = seg.charCodeAt(k);
284
+ bare = c >= 65 && c <= 90 || c >= 97 && c <= 122 || c >= 48 && c <= 57 || c === 95 || c === 45;
285
+ }
286
+ if (bare) return seg;
287
+ let out = '"';
288
+ for (let k = 0; k < seg.length; k++) {
289
+ const c = seg.charCodeAt(k);
290
+ if (c === 34 || c === 92) out += "\\";
291
+ out += seg[k];
292
+ }
293
+ return out + '"';
294
+ }
295
+ function valueOf(pair) {
296
+ const kids = pair.namedChildren ?? [];
297
+ for (let i = kids.length - 1; i >= 1; i--) {
298
+ const k = kids[i];
299
+ if (k.type === "comment") continue;
300
+ return k;
301
+ }
302
+ return null;
303
+ }
304
+ function keyOf(pair) {
305
+ const first = (pair.namedChildren ?? [])[0];
306
+ if (!first) return null;
307
+ return first.type === "bare_key" || first.type === "quoted_key" || first.type === "dotted_key" ? first : null;
308
+ }
309
+ function headerKeyOf(node) {
310
+ for (const child of node.namedChildren ?? []) {
311
+ if (child.type === "bare_key" || child.type === "quoted_key" || child.type === "dotted_key") return child;
312
+ }
313
+ return null;
314
+ }
315
+ function isScalarValueNode(node) {
316
+ if (!node) return false;
317
+ return node.type === "string" || node.type === "integer" || node.type === "float" || node.type === "boolean";
318
+ }
319
+ function stringValueOf(node) {
320
+ if (!node || node.type !== "string") return null;
321
+ const text = (node.text ?? "").trim();
322
+ if (text.length < 2) return null;
323
+ const q = text[0];
324
+ if (q !== "'" && q !== '"') return null;
325
+ if (text[text.length - 1] !== q) return null;
326
+ return text.slice(1, -1);
327
+ }
328
+ function inlineRefAliases(inlineTable) {
329
+ const out = [];
330
+ for (const child of inlineTable.namedChildren ?? []) {
331
+ if (child.type !== "pair") continue;
332
+ const ck = keyOf(child);
333
+ if (!ck) continue;
334
+ const segs = segmentsOf(ck);
335
+ if (segs.length === 0) continue;
336
+ if (segs[segs.length - 1] !== "ref") continue;
337
+ const alias = stringValueOf(valueOf(child));
338
+ if (!alias) continue;
339
+ out.push({ keyPath: joinPath(segs), alias });
340
+ }
341
+ return out;
342
+ }
343
+ function valueKind(node) {
344
+ if (!node) return "none";
345
+ switch (node.type) {
346
+ case "string":
347
+ return "string";
348
+ case "integer":
349
+ return "integer";
350
+ case "float":
351
+ return "float";
352
+ case "boolean":
353
+ return "boolean";
354
+ case "array":
355
+ return "array";
356
+ case "inline_table":
357
+ return "inline-table";
358
+ case "offset_date_time":
359
+ case "local_date_time":
360
+ case "local_date":
361
+ case "local_time":
362
+ return "datetime";
363
+ default:
364
+ return node.type;
365
+ }
366
+ }
367
+ var RealTomlAnalyzer = class {
368
+ analyze(rootNode, content, filePath, context) {
369
+ const stem = path.basename(filePath, path.extname(filePath)) || "document";
370
+ const moduleName = applyDocumentScope(stem, documentDirScope(filePath, context?.projectRoot));
371
+ const projectRoot = typeof context?.projectRoot === "string" && context.projectRoot.length > 0 ? context.projectRoot : null;
372
+ const qualified = (name) => name === moduleName ? moduleName : `${moduleName}.${name}`;
373
+ const symbols = [];
374
+ const relationships = [];
375
+ const errors = [];
376
+ const patterns = [];
377
+ const usedNames = { [moduleName]: 1 };
378
+ const declaredTables = {};
379
+ const allocate = (want) => {
380
+ const seen = usedNames[want];
381
+ if (seen === void 0) {
382
+ usedNames[want] = 1;
383
+ return want;
384
+ }
385
+ let n = seen;
386
+ let name = want;
387
+ do {
388
+ n++;
389
+ name = `${want}#${n}`;
390
+ } while (usedNames[name] !== void 0);
391
+ usedNames[name] = 1;
392
+ usedNames[want] = n;
393
+ return name;
394
+ };
395
+ const range = (node) => ({
396
+ startLine: node.startPosition.row + 1,
397
+ startColumn: node.startPosition.column + 1,
398
+ endLine: node.endPosition.row + 1,
399
+ endColumn: node.endPosition.column + 1,
400
+ startIndex: node.startIndex,
401
+ endIndex: node.endIndex
402
+ });
403
+ if (rootNode.hasError) {
404
+ const errStack = [rootNode];
405
+ while (errStack.length > 0) {
406
+ const n = errStack.pop();
407
+ if (n.type === "ERROR" || n.isMissing) {
408
+ errors.push({
409
+ message: `Syntax ${n.type} detected. The Brain Engine is bypassing this broken node.`,
410
+ range: range(n),
411
+ severity: "warning"
412
+ });
413
+ }
414
+ for (let i = n.childCount - 1; i >= 0; i--) {
415
+ const child = n.child(i);
416
+ if (child) errStack.push(child);
417
+ }
418
+ }
419
+ }
420
+ symbols.push({
421
+ name: moduleName,
422
+ qualifiedName: moduleName,
423
+ kind: ASTEngine.SymbolKind.Module,
424
+ range: range(rootNode),
425
+ scope: "",
426
+ visibility: "public",
427
+ ownerName: void 0,
428
+ ownerKind: void 0,
429
+ metadata: {
430
+ tomlSpecific: true,
431
+ isDocumentRoot: true,
432
+ evidenceClass: "structural"
433
+ }
434
+ });
435
+ let tableCount = 0;
436
+ let keyCount = 0;
437
+ let arrayOfTablesCount = 0;
438
+ let inlineTableCount = 0;
439
+ let maxDepth = 0;
440
+ const sectionRecords = [];
441
+ let reOwnedSections = 0;
442
+ const resolveOwner = (segments) => {
443
+ const implied = [];
444
+ let owner = moduleName;
445
+ const acc = [];
446
+ for (let i = 0; i < segments.length - 1; i++) {
447
+ acc.push(segments[i]);
448
+ const prefix = joinPath(acc);
449
+ const declared = declaredTables[prefix];
450
+ if (declared !== void 0) owner = declared;
451
+ else implied.push(prefix);
452
+ }
453
+ return { owner, implied };
454
+ };
455
+ const declaredByFinalSegment = /* @__PURE__ */ new Map();
456
+ const ambiguousFinalSegments = /* @__PURE__ */ new Set();
457
+ const pendingAliases = [];
458
+ const DEPENDENCY_SECTIONS = /* @__PURE__ */ new Set([
459
+ "dependencies",
460
+ "dev-dependencies",
461
+ "build-dependencies",
462
+ "workspace.dependencies",
463
+ "sources",
464
+ "patch.crates-io"
465
+ ]);
466
+ const pendingImports = [];
467
+ const pendingWorkspace = [];
468
+ const pendingPublishSurface = [];
469
+ const isBooleanTrue = (pair) => {
470
+ const v = valueOf(pair);
471
+ return v !== null && v.type === "boolean" && String(v.text).trim() === "true";
472
+ };
473
+ const containsWorkspaceTrue = (pair) => {
474
+ const v = valueOf(pair);
475
+ if (!v || v.type !== "inline_table") return false;
476
+ for (const inner of v.namedChildren ?? []) {
477
+ if (inner.type !== "pair") continue;
478
+ const ik = keyOf(inner);
479
+ if (!ik) continue;
480
+ if (segmentsOf(ik)[0] !== "workspace") continue;
481
+ if (isBooleanTrue(inner)) return true;
482
+ }
483
+ return false;
484
+ };
485
+ const inheritedPathOf = (pathSegs, keySegs, tableForm) => {
486
+ const DEP = /* @__PURE__ */ new Set(["dependencies", "dev-dependencies", "build-dependencies"]);
487
+ const depIndex = pathSegs.findIndex((s) => DEP.has(s));
488
+ const last = keySegs[keySegs.length - 1];
489
+ if (last !== "workspace") return null;
490
+ if (depIndex >= 0) {
491
+ const name = tableForm ? pathSegs[pathSegs.length - 1] : keySegs.length >= 2 ? keySegs[keySegs.length - 2] : "";
492
+ return name.length > 0 ? `workspace.dependencies.${name}` : null;
493
+ }
494
+ if (pathSegs.length === 1 && pathSegs[0] === "package" && keySegs.length >= 2) {
495
+ return `workspace.package.${keySegs.slice(0, -1).join(".")}`;
496
+ }
497
+ if (pathSegs.length === 1 && pathSegs[0] === "lints") return "workspace.lints";
498
+ return null;
499
+ };
500
+ const stringMemberOf = (pair, leaf) => {
501
+ const value = valueOf(pair);
502
+ if (!value || value.type !== "inline_table") return null;
503
+ for (const inner of value.namedChildren ?? []) {
504
+ if (inner.type !== "pair") continue;
505
+ const ik = keyOf(inner);
506
+ if (!ik) continue;
507
+ const isegs = segmentsOf(ik);
508
+ if (isegs[isegs.length - 1] !== leaf) continue;
509
+ const v = stringValueOf(valueOf(inner));
510
+ if (v && v.length > 0) return v;
511
+ }
512
+ return null;
513
+ };
514
+ const pathDependencyOf = (pair) => stringMemberOf(pair, "path");
515
+ const emitKey = (pair, path2, owner) => {
516
+ const keyNode = keyOf(pair);
517
+ if (!keyNode) return;
518
+ const name = allocate(path2);
519
+ const value = valueOf(pair);
520
+ const inlineKeys = [];
521
+ if (value && value.type === "inline_table") {
522
+ inlineTableCount++;
523
+ for (const child of value.namedChildren ?? []) {
524
+ const ck = keyOf(child);
525
+ if (ck) inlineKeys.push(joinPath(segmentsOf(ck)));
526
+ }
527
+ }
528
+ const line = keyNode.startPosition.row + 1;
529
+ {
530
+ const ksegs = segmentsOf(keyNode);
531
+ const leaf = ksegs.length > 0 ? ksegs[ksegs.length - 1] : "";
532
+ if (PUBLISH_SURFACE_KEYS.has(leaf) && value !== null && value.type === "string") {
533
+ const sv = stringValueOf(value);
534
+ if (sv !== null && sv.length > 0) pendingPublishSurface.push({ siteName: name, sitePath: path2, value: sv, line });
535
+ }
536
+ }
537
+ symbols.push({
538
+ name,
539
+ qualifiedName: qualified(name),
540
+ kind: ASTEngine.SymbolKind.Property,
541
+ range: range(pair),
542
+ scope: "",
543
+ visibility: "public",
544
+ ownerName: owner,
545
+ ownerKind: owner === moduleName ? ASTEngine.SymbolKind.Module : ASTEngine.SymbolKind.Namespace,
546
+ metadata: {
547
+ tomlSpecific: true,
548
+ isDocumentRoot: owner === moduleName,
549
+ keyText: joinPath(segmentsOf(keyNode)),
550
+ valueType: valueKind(value),
551
+ ...inlineKeys.length > 0 ? { inlineKeys } : {},
552
+ evidenceClass: "structural"
553
+ }
554
+ });
555
+ relationships.push({
556
+ // BOTH ENDS CARRY THE FILE-SCOPED IDENTITY. A document-relative target names N
557
+ // declarations the moment a project holds two manifests with the same shape, and
558
+ // the resolver can only bind an exact qualified-name match — see the header note.
559
+ source: qualified(owner),
560
+ target: qualified(name),
561
+ type: ASTEngine.RelationshipType.Contains,
562
+ confidence: 1,
563
+ line_number: line,
564
+ metadata: {
565
+ tomlSpecific: true,
566
+ isKeyContainment: true,
567
+ evidenceClass: "structural"
568
+ }
569
+ });
570
+ keyCount++;
571
+ if (isScalarValueNode(value)) {
572
+ const segs = segmentsOf(keyNode);
573
+ if (segs.length > 0) {
574
+ const finalSeg = segs[segs.length - 1];
575
+ if (!declaredByFinalSegment.has(finalSeg)) {
576
+ declaredByFinalSegment.set(finalSeg, name);
577
+ } else {
578
+ ambiguousFinalSegments.add(finalSeg);
579
+ }
580
+ }
581
+ }
582
+ if (value && value.type === "inline_table") {
583
+ for (const { keyPath, alias } of inlineRefAliases(value)) {
584
+ pendingAliases.push({ source: name, keyPath, alias, line });
585
+ }
586
+ }
587
+ };
588
+ for (const node of rootNode.namedChildren ?? []) {
589
+ if (node.type === "table" || node.type === "table_array_element") {
590
+ const header = headerKeyOf(node);
591
+ if (!header) continue;
592
+ const segments = segmentsOf(header);
593
+ if (!namesSomething(segments)) continue;
594
+ const path2 = joinPath(segments);
595
+ const { owner, implied } = resolveOwner(segments);
596
+ const isArray = node.type === "table_array_element";
597
+ if (isArray) arrayOfTablesCount++;
598
+ const name = allocate(path2);
599
+ declaredTables[path2] = name;
600
+ tableCount++;
601
+ if (segments.length > maxDepth) maxDepth = segments.length;
602
+ const symbolIndex = symbols.length;
603
+ const relIndex = relationships.length;
604
+ symbols.push({
605
+ name,
606
+ qualifiedName: qualified(name),
607
+ kind: ASTEngine.SymbolKind.Namespace,
608
+ // The section's whole span, from its `[` to the line before the next
609
+ // header — which is exactly the region its keys live in, so a key's
610
+ // range is inside its table's and containment is checkable.
611
+ range: range(node),
612
+ scope: "",
613
+ visibility: "public",
614
+ ownerName: owner,
615
+ ownerKind: owner === moduleName ? ASTEngine.SymbolKind.Module : ASTEngine.SymbolKind.Namespace,
616
+ metadata: {
617
+ tomlSpecific: true,
618
+ isDocumentRoot: owner === moduleName,
619
+ isArrayOfTables: isArray,
620
+ headerText: header.text,
621
+ keyPath: path2,
622
+ ...implied.length > 0 ? { impliedParents: implied } : {},
623
+ evidenceClass: "structural"
624
+ }
625
+ });
626
+ relationships.push({
627
+ source: qualified(owner),
628
+ target: qualified(name),
629
+ type: ASTEngine.RelationshipType.Contains,
630
+ confidence: 1,
631
+ line_number: node.startPosition.row + 1,
632
+ metadata: {
633
+ tomlSpecific: true,
634
+ isTableHeader: true,
635
+ isArrayOfTables: isArray,
636
+ ...implied.length > 0 ? { hasImpliedParents: true } : {},
637
+ evidenceClass: "structural"
638
+ }
639
+ });
640
+ sectionRecords.push({ segments, owner, symbolIndex, relIndex });
641
+ for (const child of node.namedChildren ?? []) {
642
+ if (child.type !== "pair") continue;
643
+ const ck = keyOf(child);
644
+ if (!ck) continue;
645
+ const segs = segmentsOf(ck);
646
+ if (!namesSomething(segs)) continue;
647
+ emitKey(child, `${name}.${joinPath(segs)}`, name);
648
+ if (DEPENDENCY_SECTIONS.has(path2)) {
649
+ const depPath = pathDependencyOf(child);
650
+ if (depPath !== null) {
651
+ pendingImports.push({
652
+ source: `${name}.${joinPath(segs)}`,
653
+ pathValue: depPath,
654
+ section: path2,
655
+ line: ck.startPosition.row + 1,
656
+ base: stringMemberOf(child, "base")
657
+ });
658
+ }
659
+ }
660
+ {
661
+ const keyLeafIsWorkspace = segs[segs.length - 1] === "workspace" && isBooleanTrue(child);
662
+ const valueHoldsWorkspace = containsWorkspaceTrue(child);
663
+ if (keyLeafIsWorkspace || valueHoldsWorkspace) {
664
+ const tableForm = keyLeafIsWorkspace && segs.length === 1;
665
+ const keySegs = valueHoldsWorkspace ? [...segs, "workspace"] : segs;
666
+ const inherited = inheritedPathOf(segments, keySegs, tableForm);
667
+ if (inherited !== null) {
668
+ pendingWorkspace.push({
669
+ source: `${name}.${joinPath(segs)}`,
670
+ tableName: name,
671
+ inherited,
672
+ line: ck.startPosition.row + 1
673
+ });
674
+ }
675
+ }
676
+ }
677
+ }
678
+ } else if (node.type === "pair") {
679
+ const ck = keyOf(node);
680
+ if (!ck) continue;
681
+ const segs = segmentsOf(ck);
682
+ if (!namesSomething(segs)) continue;
683
+ emitKey(node, joinPath(segs), moduleName);
684
+ if (segs.length > maxDepth) maxDepth = segs.length;
685
+ }
686
+ }
687
+ for (const rec of sectionRecords) {
688
+ const { owner, implied } = resolveOwner(rec.segments);
689
+ if (owner === rec.owner) continue;
690
+ const symbol = symbols[rec.symbolIndex];
691
+ symbol.ownerName = owner;
692
+ symbol.ownerKind = owner === moduleName ? ASTEngine.SymbolKind.Module : ASTEngine.SymbolKind.Namespace;
693
+ const meta = symbol.metadata ?? (symbol.metadata = {});
694
+ meta.isDocumentRoot = owner === moduleName;
695
+ if (implied.length > 0) meta.impliedParents = implied;
696
+ else delete meta.impliedParents;
697
+ const rel = relationships[rec.relIndex];
698
+ rel.source = qualified(owner);
699
+ const relMeta = rel.metadata ?? (rel.metadata = {});
700
+ if (implied.length > 0) relMeta.hasImpliedParents = true;
701
+ else delete relMeta.hasImpliedParents;
702
+ reOwnedSections++;
703
+ }
704
+ let aliasEdges = 0;
705
+ let aliasUnresolved = 0;
706
+ let aliasAmbiguous = 0;
707
+ for (const { source, keyPath, alias, line } of pendingAliases) {
708
+ const target = declaredByFinalSegment.get(alias);
709
+ if (ambiguousFinalSegments.has(alias)) {
710
+ aliasAmbiguous++;
711
+ continue;
712
+ }
713
+ if (!target) {
714
+ aliasUnresolved++;
715
+ continue;
716
+ }
717
+ aliasEdges++;
718
+ relationships.push({
719
+ source: qualified(source),
720
+ target: qualified(target),
721
+ type: ASTEngine.RelationshipType.References,
722
+ confidence: 1,
723
+ line_number: line,
724
+ metadata: {
725
+ tomlSpecific: true,
726
+ isAliasReference: true,
727
+ // WHICH key inside the owning inline table made the reference. The edge
728
+ // is anchored at `source` because `source.keyPath` is NOT a node: the
729
+ // analyzer publishes the inline table's keys as `inlineKeys` metadata on
730
+ // the owning symbol and never as symbols of their own. Measured over the
731
+ // corpus, 167 of 167 emitted edges carried a source that bound to 0
732
+ // symbols in its own file, against 167 of 167 targets binding to exactly
733
+ // 1 — an edge reachable by no incoming query, since `traceCallers` JOINs
734
+ // `brain_symbol` on the source. The anchor was carrying the specificity
735
+ // the metadata now carries.
736
+ aliasKeyPath: keyPath,
737
+ resolvedBy: "final-segment",
738
+ evidenceClass: "structural"
739
+ }
740
+ });
741
+ }
742
+ if (aliasEdges > 0) patterns.push(`alias-refs x${aliasEdges}`);
743
+ if (aliasUnresolved > 0) patterns.push(`alias-unresolved x${aliasUnresolved}`);
744
+ if (aliasAmbiguous > 0) patterns.push(`alias-ambiguous x${aliasAmbiguous}`);
745
+ let importEdges = 0;
746
+ let workspaceRefs = 0;
747
+ let workspaceSkippedLints = 0;
748
+ let workspaceSkippedNoRoot = 0;
749
+ let workspaceSkippedNoDecl = 0;
750
+ if (pendingWorkspace.length > 0) {
751
+ const wsRoot = findWorkspaceRoot(filePath, projectRoot);
752
+ if (wsRoot === null) workspaceSkippedNoRoot = pendingWorkspace.length;
753
+ else {
754
+ let declared = null;
755
+ for (const site of pendingWorkspace) {
756
+ if (site.inherited === null || site.inherited === "workspace.lints") {
757
+ workspaceSkippedLints++;
758
+ continue;
759
+ }
760
+ if (declared === null) {
761
+ try {
762
+ declared = workspaceDeclaredPaths(readFileSync(wsRoot.abs, "utf8"));
763
+ } catch {
764
+ declared = /* @__PURE__ */ new Set();
765
+ }
766
+ }
767
+ if (!declared.has(site.inherited)) {
768
+ workspaceSkippedNoDecl++;
769
+ continue;
770
+ }
771
+ workspaceRefs++;
772
+ relationships.push({
773
+ source: qualified(site.source),
774
+ target: `${wsRoot.moduleName}.${site.inherited}`,
775
+ type: ASTEngine.RelationshipType.References,
776
+ confidence: 1,
777
+ line_number: site.line,
778
+ metadata: {
779
+ tomlSpecific: true,
780
+ isWorkspaceInheritance: true,
781
+ inheritedFrom: wsRoot.moduleName,
782
+ inheritedPath: site.inherited,
783
+ evidenceClass: "structural"
784
+ }
785
+ });
786
+ }
787
+ }
788
+ }
789
+ if (workspaceRefs > 0) patterns.push(`workspace-inheritance-refs x${workspaceRefs}`);
790
+ let publishSurfaceSites = 0;
791
+ let publishSurfaceExports = 0;
792
+ if (pendingPublishSurface.length > 0) {
793
+ const declared = /* @__PURE__ */ new Set();
794
+ for (const s of symbols) {
795
+ const n = String(s.name ?? "");
796
+ if (n.length > 0) declared.add(n);
797
+ }
798
+ const seenTargets = /* @__PURE__ */ new Set();
799
+ for (const site of pendingPublishSurface) {
800
+ publishSurfaceSites++;
801
+ if (site.value === moduleName || site.value === site.siteName) continue;
802
+ if (site.value === site.sitePath || site.sitePath.startsWith(`${site.value}.`) || site.value.startsWith(`${site.sitePath}.`)) continue;
803
+ if (!declared.has(site.value)) continue;
804
+ const target = qualified(site.value);
805
+ if (seenTargets.has(target)) continue;
806
+ seenTargets.add(target);
807
+ publishSurfaceExports++;
808
+ relationships.push({
809
+ source: moduleName,
810
+ target,
811
+ type: ASTEngine.RelationshipType.Exports,
812
+ confidence: 1,
813
+ line_number: site.line,
814
+ metadata: {
815
+ tomlSpecific: true,
816
+ isPublishSurfaceExport: true,
817
+ exportForm: "manifest_publish_surface",
818
+ evidenceClass: "structural"
819
+ }
820
+ });
821
+ }
822
+ }
823
+ if (publishSurfaceExports > 0) patterns.push(`publish-surface-exports x${publishSurfaceExports}`);
824
+ for (const { source, pathValue, section, line, base } of pendingImports) {
825
+ importEdges++;
826
+ const fileClaim = dependencyFileClaim(pathValue, filePath, projectRoot, base);
827
+ relationships.push({
828
+ source: qualified(source),
829
+ target: pathValue,
830
+ type: ASTEngine.RelationshipType.Imports,
831
+ confidence: 1,
832
+ line_number: line,
833
+ metadata: {
834
+ tomlSpecific: true,
835
+ isPathDependency: true,
836
+ dependencySection: section,
837
+ // Still declared, not resolved: the consuming tool turns this path into a
838
+ // module and nothing in the document does. The claim below is about the
839
+ // PATH, not about a symbol.
840
+ resolvedBy: null,
841
+ ...fileClaim !== null ? { importProjectFile: fileClaim } : {},
842
+ // THE SOURCE-PATH CLAIM (task-24). When no admitted file answers this path, the claim states
843
+ // the ONE thing that can be checked about it: the source string does not resolve inside this
844
+ // project's admitted population — verified against that list, and REFUTED the moment the project
845
+ // ships the file (measured before it was built: adding the file flips `verifyFileClaim`).
846
+ //
847
+ // ONLY PATH-SHAPED TARGETS. A bare name (`"dependency"`, `"SubProjectB"`) has no shape to check
848
+ // and is never claimed — that is the laundering vector yaml's shape rule exists to refuse, and
849
+ // 27 of this lane's unresolved targets are bare. They stay `unresolved`, which is the honest
850
+ // outcome for a target nothing can check.
851
+ ...fileClaim === null && isPathOrUriShaped(pathValue) ? { sourcePathClaim: [pathValue] } : {},
852
+ // THE TIER IS `import_based`, NOT `structural` — section D of the completeness
853
+ // inventory requires the lane to pin MORE THAN ONE evidence class, and the lane
854
+ // was writing `structural` on every edge it emitted, so it could not. This one
855
+ // was the wrong classification, not a missing pin: the fleet's tier vocabulary
856
+ // (`script/m14/audit-analyzer-grammar.ts:146`: structural · import_based ·
857
+ // usage_contextual · inferred) defines `import_based` as "the target is a FILE,
858
+ // taken from a path the document itself writes", and a `path` dependency in
859
+ // Cargo.toml is exactly that — `core = { path = "../core" }` names a directory
860
+ // the manifest writes, and `dependencyFileClaim` even checks it against the
861
+ // project's admitted files. `structural` means the fact needs nothing outside
862
+ // the file; this edge's whole point is that it points outside it.
863
+ evidenceClass: "import_based"
864
+ }
865
+ });
866
+ }
867
+ if (importEdges > 0) patterns.push(`path-deps x${importEdges}`);
868
+ if (arrayOfTablesCount > 0) patterns.push(`array-of-tables x${arrayOfTablesCount}`);
869
+ if (inlineTableCount > 0) patterns.push(`inline-tables x${inlineTableCount}`);
870
+ return {
871
+ language: "toml",
872
+ symbols,
873
+ relationships,
874
+ imports: [],
875
+ exports: [],
876
+ errors,
877
+ rawContent: content,
878
+ metadata: {
879
+ // Structural depth is the DEEPEST key path, not a node count: a flat
880
+ // document with 10,000 sibling keys is not deeper than one with three
881
+ // levels, and reporting the former as complexity would be meaningless.
882
+ complexity: maxDepth,
883
+ linesOfCode: content.split("\n").length,
884
+ cyclomaticComplexity: 1 + tableCount,
885
+ framework: "TOML",
886
+ patterns,
887
+ detectedFrameworks: [],
888
+ frameworkPatterns: [],
889
+ architecturalInsights: [],
890
+ architecturalScore: 0,
891
+ codeQuality: "unknown",
892
+ hasTypeInference: false,
893
+ hasFrameworkIntelligence: false,
894
+ analysisVersion: "m14-toml-identity-v1",
895
+ documentMetrics: {
896
+ tableCount,
897
+ keyCount,
898
+ arrayOfTablesCount,
899
+ inlineTableCount,
900
+ maxKeyPathDepth: maxDepth,
901
+ // How many sections the second pass moved. Zero on every file whose
902
+ // headers declare their ancestors first, which is the overwhelming
903
+ // majority; a non-zero value names the count of sections in this file
904
+ // whose `contains` source was corrected.
905
+ reOwnedSections,
906
+ // WORKSPACE-INHERITANCE ACCOUNTING — the four numbers behind TOML-G1, so a reader (and the
907
+ // lane's own instrument) can sum them over the population instead of inferring the residual
908
+ // from a difference. `refs` are the `references` edges this file emitted; the three skips are
909
+ // the sites it deliberately did not, each with its own reason: `lints` has no single target,
910
+ // `noDecl` means the root does not declare the inherited path (Cargo errors on those), and
911
+ // `noRoot` means no ancestor manifest declares `[workspace]` (or no project root was given).
912
+ workspaceInheritanceRefs: workspaceRefs,
913
+ workspaceInheritanceSkippedLints: workspaceSkippedLints,
914
+ workspaceInheritanceSkippedNoDecl: workspaceSkippedNoDecl,
915
+ workspaceInheritanceSkippedNoRoot: workspaceSkippedNoRoot,
916
+ // THE `exports` ACCOUNTING: candidates seen by the conventional leaves, and the ones the
917
+ // DATA test turned into edges. Over the whole admitted population this reads 174 and 0 —
918
+ // the number the ruling is about, measured at the emission site instead of counted by a
919
+ // predicate that cannot tell a path from a name.
920
+ publishSurfaceSites,
921
+ publishSurfaceExports
922
+ }
923
+ }
924
+ };
925
+ }
926
+ };
927
+ export {
928
+ RealTomlAnalyzer
929
+ };