@quolu/lattice 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (769) hide show
  1. package/LICENSE +25 -0
  2. package/README.md +20 -0
  3. package/bin/lattice-mcp.mjs +134 -0
  4. package/bin/lattice.mjs +78 -0
  5. package/package.json +47 -0
  6. package/sensor/LICENSE +21 -0
  7. package/sensor/NOTICE +30 -0
  8. package/sensor/dist/bin/codegraph.d.ts +26 -0
  9. package/sensor/dist/bin/codegraph.d.ts.map +1 -0
  10. package/sensor/dist/bin/codegraph.js +2279 -0
  11. package/sensor/dist/bin/codegraph.js.map +1 -0
  12. package/sensor/dist/bin/command-supervision.d.ts +49 -0
  13. package/sensor/dist/bin/command-supervision.d.ts.map +1 -0
  14. package/sensor/dist/bin/command-supervision.js +95 -0
  15. package/sensor/dist/bin/command-supervision.js.map +1 -0
  16. package/sensor/dist/bin/fatal-handler.d.ts +20 -0
  17. package/sensor/dist/bin/fatal-handler.d.ts.map +1 -0
  18. package/sensor/dist/bin/fatal-handler.js +118 -0
  19. package/sensor/dist/bin/fatal-handler.js.map +1 -0
  20. package/sensor/dist/bin/node-version-check.d.ts +37 -0
  21. package/sensor/dist/bin/node-version-check.d.ts.map +1 -0
  22. package/sensor/dist/bin/node-version-check.js +79 -0
  23. package/sensor/dist/bin/node-version-check.js.map +1 -0
  24. package/sensor/dist/bin/uninstall.d.ts +14 -0
  25. package/sensor/dist/bin/uninstall.d.ts.map +1 -0
  26. package/sensor/dist/bin/uninstall.js +36 -0
  27. package/sensor/dist/bin/uninstall.js.map +1 -0
  28. package/sensor/dist/context/formatter.d.ts +30 -0
  29. package/sensor/dist/context/formatter.d.ts.map +1 -0
  30. package/sensor/dist/context/formatter.js +263 -0
  31. package/sensor/dist/context/formatter.js.map +1 -0
  32. package/sensor/dist/context/index.d.ts +119 -0
  33. package/sensor/dist/context/index.d.ts.map +1 -0
  34. package/sensor/dist/context/index.js +1326 -0
  35. package/sensor/dist/context/index.js.map +1 -0
  36. package/sensor/dist/context/markers.d.ts +19 -0
  37. package/sensor/dist/context/markers.d.ts.map +1 -0
  38. package/sensor/dist/context/markers.js +22 -0
  39. package/sensor/dist/context/markers.js.map +1 -0
  40. package/sensor/dist/db/index.d.ts +264 -0
  41. package/sensor/dist/db/index.d.ts.map +1 -0
  42. package/sensor/dist/db/index.js +603 -0
  43. package/sensor/dist/db/index.js.map +1 -0
  44. package/sensor/dist/db/migrations.d.ts +44 -0
  45. package/sensor/dist/db/migrations.d.ts.map +1 -0
  46. package/sensor/dist/db/migrations.js +241 -0
  47. package/sensor/dist/db/migrations.js.map +1 -0
  48. package/sensor/dist/db/queries.d.ts +563 -0
  49. package/sensor/dist/db/queries.d.ts.map +1 -0
  50. package/sensor/dist/db/queries.js +2179 -0
  51. package/sensor/dist/db/queries.js.map +1 -0
  52. package/sensor/dist/db/schema.sql +196 -0
  53. package/sensor/dist/db/sqlite-adapter.d.ts +55 -0
  54. package/sensor/dist/db/sqlite-adapter.d.ts.map +1 -0
  55. package/sensor/dist/db/sqlite-adapter.js +135 -0
  56. package/sensor/dist/db/sqlite-adapter.js.map +1 -0
  57. package/sensor/dist/db/wal-valve.d.ts +106 -0
  58. package/sensor/dist/db/wal-valve.d.ts.map +1 -0
  59. package/sensor/dist/db/wal-valve.js +208 -0
  60. package/sensor/dist/db/wal-valve.js.map +1 -0
  61. package/sensor/dist/directory.d.ts +183 -0
  62. package/sensor/dist/directory.d.ts.map +1 -0
  63. package/sensor/dist/directory.js +797 -0
  64. package/sensor/dist/directory.js.map +1 -0
  65. package/sensor/dist/errors.d.ts +136 -0
  66. package/sensor/dist/errors.d.ts.map +1 -0
  67. package/sensor/dist/errors.js +219 -0
  68. package/sensor/dist/errors.js.map +1 -0
  69. package/sensor/dist/extraction/astro-extractor.d.ts +79 -0
  70. package/sensor/dist/extraction/astro-extractor.d.ts.map +1 -0
  71. package/sensor/dist/extraction/astro-extractor.js +320 -0
  72. package/sensor/dist/extraction/astro-extractor.js.map +1 -0
  73. package/sensor/dist/extraction/cfml-extractor.d.ts +107 -0
  74. package/sensor/dist/extraction/cfml-extractor.d.ts.map +1 -0
  75. package/sensor/dist/extraction/cfml-extractor.js +494 -0
  76. package/sensor/dist/extraction/cfml-extractor.js.map +1 -0
  77. package/sensor/dist/extraction/dfm-extractor.d.ts +31 -0
  78. package/sensor/dist/extraction/dfm-extractor.d.ts.map +1 -0
  79. package/sensor/dist/extraction/dfm-extractor.js +151 -0
  80. package/sensor/dist/extraction/dfm-extractor.js.map +1 -0
  81. package/sensor/dist/extraction/dynamic-import.d.ts +82 -0
  82. package/sensor/dist/extraction/dynamic-import.d.ts.map +1 -0
  83. package/sensor/dist/extraction/dynamic-import.js +313 -0
  84. package/sensor/dist/extraction/dynamic-import.js.map +1 -0
  85. package/sensor/dist/extraction/extraction-version.d.ts +25 -0
  86. package/sensor/dist/extraction/extraction-version.d.ts.map +1 -0
  87. package/sensor/dist/extraction/extraction-version.js +28 -0
  88. package/sensor/dist/extraction/extraction-version.js.map +1 -0
  89. package/sensor/dist/extraction/function-ref.d.ts +118 -0
  90. package/sensor/dist/extraction/function-ref.d.ts.map +1 -0
  91. package/sensor/dist/extraction/function-ref.js +727 -0
  92. package/sensor/dist/extraction/function-ref.js.map +1 -0
  93. package/sensor/dist/extraction/generated-detection.d.ts +30 -0
  94. package/sensor/dist/extraction/generated-detection.d.ts.map +1 -0
  95. package/sensor/dist/extraction/generated-detection.js +83 -0
  96. package/sensor/dist/extraction/generated-detection.js.map +1 -0
  97. package/sensor/dist/extraction/grammars.d.ts +138 -0
  98. package/sensor/dist/extraction/grammars.d.ts.map +1 -0
  99. package/sensor/dist/extraction/grammars.js +648 -0
  100. package/sensor/dist/extraction/grammars.js.map +1 -0
  101. package/sensor/dist/extraction/index.d.ts +251 -0
  102. package/sensor/dist/extraction/index.d.ts.map +1 -0
  103. package/sensor/dist/extraction/index.js +2563 -0
  104. package/sensor/dist/extraction/index.js.map +1 -0
  105. package/sensor/dist/extraction/kernel/decode.d.ts +9 -0
  106. package/sensor/dist/extraction/kernel/decode.d.ts.map +1 -0
  107. package/sensor/dist/extraction/kernel/decode.js +156 -0
  108. package/sensor/dist/extraction/kernel/decode.js.map +1 -0
  109. package/sensor/dist/extraction/kernel/index.d.ts +62 -0
  110. package/sensor/dist/extraction/kernel/index.d.ts.map +1 -0
  111. package/sensor/dist/extraction/kernel/index.js +165 -0
  112. package/sensor/dist/extraction/kernel/index.js.map +1 -0
  113. package/sensor/dist/extraction/kernel/layout.d.ts +92 -0
  114. package/sensor/dist/extraction/kernel/layout.d.ts.map +1 -0
  115. package/sensor/dist/extraction/kernel/layout.js +95 -0
  116. package/sensor/dist/extraction/kernel/layout.js.map +1 -0
  117. package/sensor/dist/extraction/kernel/loader.d.ts +61 -0
  118. package/sensor/dist/extraction/kernel/loader.d.ts.map +1 -0
  119. package/sensor/dist/extraction/kernel/loader.js +146 -0
  120. package/sensor/dist/extraction/kernel/loader.js.map +1 -0
  121. package/sensor/dist/extraction/languages/arkts.d.ts +3 -0
  122. package/sensor/dist/extraction/languages/arkts.d.ts.map +1 -0
  123. package/sensor/dist/extraction/languages/arkts.js +127 -0
  124. package/sensor/dist/extraction/languages/arkts.js.map +1 -0
  125. package/sensor/dist/extraction/languages/c-cpp.d.ts +111 -0
  126. package/sensor/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  127. package/sensor/dist/extraction/languages/c-cpp.js +878 -0
  128. package/sensor/dist/extraction/languages/c-cpp.js.map +1 -0
  129. package/sensor/dist/extraction/languages/cfquery.d.ts +12 -0
  130. package/sensor/dist/extraction/languages/cfquery.d.ts.map +1 -0
  131. package/sensor/dist/extraction/languages/cfquery.js +28 -0
  132. package/sensor/dist/extraction/languages/cfquery.js.map +1 -0
  133. package/sensor/dist/extraction/languages/cfscript.d.ts +3 -0
  134. package/sensor/dist/extraction/languages/cfscript.d.ts.map +1 -0
  135. package/sensor/dist/extraction/languages/cfscript.js +73 -0
  136. package/sensor/dist/extraction/languages/cfscript.js.map +1 -0
  137. package/sensor/dist/extraction/languages/cobol.d.ts +33 -0
  138. package/sensor/dist/extraction/languages/cobol.d.ts.map +1 -0
  139. package/sensor/dist/extraction/languages/cobol.js +499 -0
  140. package/sensor/dist/extraction/languages/cobol.js.map +1 -0
  141. package/sensor/dist/extraction/languages/csharp.d.ts +25 -0
  142. package/sensor/dist/extraction/languages/csharp.d.ts.map +1 -0
  143. package/sensor/dist/extraction/languages/csharp.js +175 -0
  144. package/sensor/dist/extraction/languages/csharp.js.map +1 -0
  145. package/sensor/dist/extraction/languages/dart.d.ts +3 -0
  146. package/sensor/dist/extraction/languages/dart.d.ts.map +1 -0
  147. package/sensor/dist/extraction/languages/dart.js +374 -0
  148. package/sensor/dist/extraction/languages/dart.js.map +1 -0
  149. package/sensor/dist/extraction/languages/erlang.d.ts +3 -0
  150. package/sensor/dist/extraction/languages/erlang.d.ts.map +1 -0
  151. package/sensor/dist/extraction/languages/erlang.js +350 -0
  152. package/sensor/dist/extraction/languages/erlang.js.map +1 -0
  153. package/sensor/dist/extraction/languages/go.d.ts +3 -0
  154. package/sensor/dist/extraction/languages/go.d.ts.map +1 -0
  155. package/sensor/dist/extraction/languages/go.js +111 -0
  156. package/sensor/dist/extraction/languages/go.js.map +1 -0
  157. package/sensor/dist/extraction/languages/index.d.ts +10 -0
  158. package/sensor/dist/extraction/languages/index.d.ts.map +1 -0
  159. package/sensor/dist/extraction/languages/index.js +71 -0
  160. package/sensor/dist/extraction/languages/index.js.map +1 -0
  161. package/sensor/dist/extraction/languages/java.d.ts +3 -0
  162. package/sensor/dist/extraction/languages/java.d.ts.map +1 -0
  163. package/sensor/dist/extraction/languages/java.js +315 -0
  164. package/sensor/dist/extraction/languages/java.js.map +1 -0
  165. package/sensor/dist/extraction/languages/javascript.d.ts +3 -0
  166. package/sensor/dist/extraction/languages/javascript.d.ts.map +1 -0
  167. package/sensor/dist/extraction/languages/javascript.js +106 -0
  168. package/sensor/dist/extraction/languages/javascript.js.map +1 -0
  169. package/sensor/dist/extraction/languages/kotlin.d.ts +3 -0
  170. package/sensor/dist/extraction/languages/kotlin.d.ts.map +1 -0
  171. package/sensor/dist/extraction/languages/kotlin.js +379 -0
  172. package/sensor/dist/extraction/languages/kotlin.js.map +1 -0
  173. package/sensor/dist/extraction/languages/lua.d.ts +3 -0
  174. package/sensor/dist/extraction/languages/lua.d.ts.map +1 -0
  175. package/sensor/dist/extraction/languages/lua.js +150 -0
  176. package/sensor/dist/extraction/languages/lua.js.map +1 -0
  177. package/sensor/dist/extraction/languages/luau.d.ts +3 -0
  178. package/sensor/dist/extraction/languages/luau.d.ts.map +1 -0
  179. package/sensor/dist/extraction/languages/luau.js +37 -0
  180. package/sensor/dist/extraction/languages/luau.js.map +1 -0
  181. package/sensor/dist/extraction/languages/nix.d.ts +3 -0
  182. package/sensor/dist/extraction/languages/nix.d.ts.map +1 -0
  183. package/sensor/dist/extraction/languages/nix.js +294 -0
  184. package/sensor/dist/extraction/languages/nix.js.map +1 -0
  185. package/sensor/dist/extraction/languages/objc.d.ts +3 -0
  186. package/sensor/dist/extraction/languages/objc.d.ts.map +1 -0
  187. package/sensor/dist/extraction/languages/objc.js +175 -0
  188. package/sensor/dist/extraction/languages/objc.js.map +1 -0
  189. package/sensor/dist/extraction/languages/pascal.d.ts +3 -0
  190. package/sensor/dist/extraction/languages/pascal.d.ts.map +1 -0
  191. package/sensor/dist/extraction/languages/pascal.js +77 -0
  192. package/sensor/dist/extraction/languages/pascal.js.map +1 -0
  193. package/sensor/dist/extraction/languages/php.d.ts +3 -0
  194. package/sensor/dist/extraction/languages/php.d.ts.map +1 -0
  195. package/sensor/dist/extraction/languages/php.js +196 -0
  196. package/sensor/dist/extraction/languages/php.js.map +1 -0
  197. package/sensor/dist/extraction/languages/python.d.ts +3 -0
  198. package/sensor/dist/extraction/languages/python.d.ts.map +1 -0
  199. package/sensor/dist/extraction/languages/python.js +56 -0
  200. package/sensor/dist/extraction/languages/python.js.map +1 -0
  201. package/sensor/dist/extraction/languages/r.d.ts +3 -0
  202. package/sensor/dist/extraction/languages/r.d.ts.map +1 -0
  203. package/sensor/dist/extraction/languages/r.js +314 -0
  204. package/sensor/dist/extraction/languages/r.js.map +1 -0
  205. package/sensor/dist/extraction/languages/ruby.d.ts +3 -0
  206. package/sensor/dist/extraction/languages/ruby.d.ts.map +1 -0
  207. package/sensor/dist/extraction/languages/ruby.js +149 -0
  208. package/sensor/dist/extraction/languages/ruby.js.map +1 -0
  209. package/sensor/dist/extraction/languages/rust.d.ts +3 -0
  210. package/sensor/dist/extraction/languages/rust.d.ts.map +1 -0
  211. package/sensor/dist/extraction/languages/rust.js +142 -0
  212. package/sensor/dist/extraction/languages/rust.js.map +1 -0
  213. package/sensor/dist/extraction/languages/scala.d.ts +3 -0
  214. package/sensor/dist/extraction/languages/scala.d.ts.map +1 -0
  215. package/sensor/dist/extraction/languages/scala.js +209 -0
  216. package/sensor/dist/extraction/languages/scala.js.map +1 -0
  217. package/sensor/dist/extraction/languages/solidity.d.ts +3 -0
  218. package/sensor/dist/extraction/languages/solidity.d.ts.map +1 -0
  219. package/sensor/dist/extraction/languages/solidity.js +293 -0
  220. package/sensor/dist/extraction/languages/solidity.js.map +1 -0
  221. package/sensor/dist/extraction/languages/swift.d.ts +3 -0
  222. package/sensor/dist/extraction/languages/swift.d.ts.map +1 -0
  223. package/sensor/dist/extraction/languages/swift.js +152 -0
  224. package/sensor/dist/extraction/languages/swift.js.map +1 -0
  225. package/sensor/dist/extraction/languages/terraform.d.ts +3 -0
  226. package/sensor/dist/extraction/languages/terraform.d.ts.map +1 -0
  227. package/sensor/dist/extraction/languages/terraform.js +641 -0
  228. package/sensor/dist/extraction/languages/terraform.js.map +1 -0
  229. package/sensor/dist/extraction/languages/typescript.d.ts +16 -0
  230. package/sensor/dist/extraction/languages/typescript.d.ts.map +1 -0
  231. package/sensor/dist/extraction/languages/typescript.js +167 -0
  232. package/sensor/dist/extraction/languages/typescript.js.map +1 -0
  233. package/sensor/dist/extraction/languages/vbnet.d.ts +11 -0
  234. package/sensor/dist/extraction/languages/vbnet.d.ts.map +1 -0
  235. package/sensor/dist/extraction/languages/vbnet.js +141 -0
  236. package/sensor/dist/extraction/languages/vbnet.js.map +1 -0
  237. package/sensor/dist/extraction/liquid-extractor.d.ts +59 -0
  238. package/sensor/dist/extraction/liquid-extractor.d.ts.map +1 -0
  239. package/sensor/dist/extraction/liquid-extractor.js +357 -0
  240. package/sensor/dist/extraction/liquid-extractor.js.map +1 -0
  241. package/sensor/dist/extraction/mybatis-extractor.d.ts +68 -0
  242. package/sensor/dist/extraction/mybatis-extractor.d.ts.map +1 -0
  243. package/sensor/dist/extraction/mybatis-extractor.js +300 -0
  244. package/sensor/dist/extraction/mybatis-extractor.js.map +1 -0
  245. package/sensor/dist/extraction/parse-pool.d.ts +160 -0
  246. package/sensor/dist/extraction/parse-pool.d.ts.map +1 -0
  247. package/sensor/dist/extraction/parse-pool.js +402 -0
  248. package/sensor/dist/extraction/parse-pool.js.map +1 -0
  249. package/sensor/dist/extraction/parse-worker.d.ts +8 -0
  250. package/sensor/dist/extraction/parse-worker.d.ts.map +1 -0
  251. package/sensor/dist/extraction/parse-worker.js +138 -0
  252. package/sensor/dist/extraction/parse-worker.js.map +1 -0
  253. package/sensor/dist/extraction/razor-extractor.d.ts +42 -0
  254. package/sensor/dist/extraction/razor-extractor.d.ts.map +1 -0
  255. package/sensor/dist/extraction/razor-extractor.js +285 -0
  256. package/sensor/dist/extraction/razor-extractor.js.map +1 -0
  257. package/sensor/dist/extraction/spawn-invokes.d.ts +101 -0
  258. package/sensor/dist/extraction/spawn-invokes.d.ts.map +1 -0
  259. package/sensor/dist/extraction/spawn-invokes.js +327 -0
  260. package/sensor/dist/extraction/spawn-invokes.js.map +1 -0
  261. package/sensor/dist/extraction/store-worker.d.ts +24 -0
  262. package/sensor/dist/extraction/store-worker.d.ts.map +1 -0
  263. package/sensor/dist/extraction/store-worker.js +110 -0
  264. package/sensor/dist/extraction/store-worker.js.map +1 -0
  265. package/sensor/dist/extraction/store-writer.d.ts +63 -0
  266. package/sensor/dist/extraction/store-writer.d.ts.map +1 -0
  267. package/sensor/dist/extraction/store-writer.js +174 -0
  268. package/sensor/dist/extraction/store-writer.js.map +1 -0
  269. package/sensor/dist/extraction/svelte-extractor.d.ts +56 -0
  270. package/sensor/dist/extraction/svelte-extractor.d.ts.map +1 -0
  271. package/sensor/dist/extraction/svelte-extractor.js +275 -0
  272. package/sensor/dist/extraction/svelte-extractor.js.map +1 -0
  273. package/sensor/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  274. package/sensor/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  275. package/sensor/dist/extraction/tree-sitter-helpers.js +153 -0
  276. package/sensor/dist/extraction/tree-sitter-helpers.js.map +1 -0
  277. package/sensor/dist/extraction/tree-sitter-types.d.ts +258 -0
  278. package/sensor/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  279. package/sensor/dist/extraction/tree-sitter-types.js +10 -0
  280. package/sensor/dist/extraction/tree-sitter-types.js.map +1 -0
  281. package/sensor/dist/extraction/tree-sitter.d.ts +724 -0
  282. package/sensor/dist/extraction/tree-sitter.d.ts.map +1 -0
  283. package/sensor/dist/extraction/tree-sitter.js +6721 -0
  284. package/sensor/dist/extraction/tree-sitter.js.map +1 -0
  285. package/sensor/dist/extraction/vue-extractor.d.ts +51 -0
  286. package/sensor/dist/extraction/vue-extractor.d.ts.map +1 -0
  287. package/sensor/dist/extraction/vue-extractor.js +254 -0
  288. package/sensor/dist/extraction/vue-extractor.js.map +1 -0
  289. package/sensor/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
  290. package/sensor/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  291. package/sensor/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
  292. package/sensor/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
  293. package/sensor/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
  294. package/sensor/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  295. package/sensor/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
  296. package/sensor/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
  297. package/sensor/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  298. package/sensor/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
  299. package/sensor/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  300. package/sensor/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  301. package/sensor/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
  302. package/sensor/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  303. package/sensor/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
  304. package/sensor/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
  305. package/sensor/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  306. package/sensor/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
  307. package/sensor/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
  308. package/sensor/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
  309. package/sensor/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  310. package/sensor/dist/extraction/wasm-runtime-flags.d.ts +53 -0
  311. package/sensor/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  312. package/sensor/dist/extraction/wasm-runtime-flags.js +130 -0
  313. package/sensor/dist/extraction/wasm-runtime-flags.js.map +1 -0
  314. package/sensor/dist/graph/index.d.ts +8 -0
  315. package/sensor/dist/graph/index.d.ts.map +1 -0
  316. package/sensor/dist/graph/index.js +13 -0
  317. package/sensor/dist/graph/index.js.map +1 -0
  318. package/sensor/dist/graph/queries.d.ts +106 -0
  319. package/sensor/dist/graph/queries.d.ts.map +1 -0
  320. package/sensor/dist/graph/queries.js +339 -0
  321. package/sensor/dist/graph/queries.js.map +1 -0
  322. package/sensor/dist/graph/traversal.d.ts +127 -0
  323. package/sensor/dist/graph/traversal.d.ts.map +1 -0
  324. package/sensor/dist/graph/traversal.js +599 -0
  325. package/sensor/dist/graph/traversal.js.map +1 -0
  326. package/sensor/dist/index.d.ts +653 -0
  327. package/sensor/dist/index.d.ts.map +1 -0
  328. package/sensor/dist/index.js +1646 -0
  329. package/sensor/dist/index.js.map +1 -0
  330. package/sensor/dist/installer/beta-signup.d.ts +54 -0
  331. package/sensor/dist/installer/beta-signup.d.ts.map +1 -0
  332. package/sensor/dist/installer/beta-signup.js +178 -0
  333. package/sensor/dist/installer/beta-signup.js.map +1 -0
  334. package/sensor/dist/installer/config-writer.d.ts +28 -0
  335. package/sensor/dist/installer/config-writer.d.ts.map +1 -0
  336. package/sensor/dist/installer/config-writer.js +91 -0
  337. package/sensor/dist/installer/config-writer.js.map +1 -0
  338. package/sensor/dist/installer/index.d.ts +142 -0
  339. package/sensor/dist/installer/index.d.ts.map +1 -0
  340. package/sensor/dist/installer/index.js +622 -0
  341. package/sensor/dist/installer/index.js.map +1 -0
  342. package/sensor/dist/installer/instructions-template.d.ts +41 -0
  343. package/sensor/dist/installer/instructions-template.d.ts.map +1 -0
  344. package/sensor/dist/installer/instructions-template.js +53 -0
  345. package/sensor/dist/installer/instructions-template.js.map +1 -0
  346. package/sensor/dist/installer/targets/antigravity.d.ts +57 -0
  347. package/sensor/dist/installer/targets/antigravity.d.ts.map +1 -0
  348. package/sensor/dist/installer/targets/antigravity.js +308 -0
  349. package/sensor/dist/installer/targets/antigravity.js.map +1 -0
  350. package/sensor/dist/installer/targets/claude.d.ts +62 -0
  351. package/sensor/dist/installer/targets/claude.d.ts.map +1 -0
  352. package/sensor/dist/installer/targets/claude.js +454 -0
  353. package/sensor/dist/installer/targets/claude.js.map +1 -0
  354. package/sensor/dist/installer/targets/codex.d.ts +18 -0
  355. package/sensor/dist/installer/targets/codex.d.ts.map +1 -0
  356. package/sensor/dist/installer/targets/codex.js +185 -0
  357. package/sensor/dist/installer/targets/codex.js.map +1 -0
  358. package/sensor/dist/installer/targets/cursor.d.ts +35 -0
  359. package/sensor/dist/installer/targets/cursor.d.ts.map +1 -0
  360. package/sensor/dist/installer/targets/cursor.js +254 -0
  361. package/sensor/dist/installer/targets/cursor.js.map +1 -0
  362. package/sensor/dist/installer/targets/gemini.d.ts +26 -0
  363. package/sensor/dist/installer/targets/gemini.d.ts.map +1 -0
  364. package/sensor/dist/installer/targets/gemini.js +165 -0
  365. package/sensor/dist/installer/targets/gemini.js.map +1 -0
  366. package/sensor/dist/installer/targets/hermes.d.ts +18 -0
  367. package/sensor/dist/installer/targets/hermes.d.ts.map +1 -0
  368. package/sensor/dist/installer/targets/hermes.js +359 -0
  369. package/sensor/dist/installer/targets/hermes.js.map +1 -0
  370. package/sensor/dist/installer/targets/kiro.d.ts +27 -0
  371. package/sensor/dist/installer/targets/kiro.d.ts.map +1 -0
  372. package/sensor/dist/installer/targets/kiro.js +178 -0
  373. package/sensor/dist/installer/targets/kiro.js.map +1 -0
  374. package/sensor/dist/installer/targets/opencode.d.ts +38 -0
  375. package/sensor/dist/installer/targets/opencode.d.ts.map +1 -0
  376. package/sensor/dist/installer/targets/opencode.js +288 -0
  377. package/sensor/dist/installer/targets/opencode.js.map +1 -0
  378. package/sensor/dist/installer/targets/registry.d.ts +35 -0
  379. package/sensor/dist/installer/targets/registry.d.ts.map +1 -0
  380. package/sensor/dist/installer/targets/registry.js +91 -0
  381. package/sensor/dist/installer/targets/registry.js.map +1 -0
  382. package/sensor/dist/installer/targets/shared.d.ts +101 -0
  383. package/sensor/dist/installer/targets/shared.d.ts.map +1 -0
  384. package/sensor/dist/installer/targets/shared.js +264 -0
  385. package/sensor/dist/installer/targets/shared.js.map +1 -0
  386. package/sensor/dist/installer/targets/toml.d.ts +52 -0
  387. package/sensor/dist/installer/targets/toml.d.ts.map +1 -0
  388. package/sensor/dist/installer/targets/toml.js +147 -0
  389. package/sensor/dist/installer/targets/toml.js.map +1 -0
  390. package/sensor/dist/installer/targets/types.d.ts +108 -0
  391. package/sensor/dist/installer/targets/types.d.ts.map +1 -0
  392. package/sensor/dist/installer/targets/types.js +16 -0
  393. package/sensor/dist/installer/targets/types.js.map +1 -0
  394. package/sensor/dist/mcp/daemon-manager.d.ts +42 -0
  395. package/sensor/dist/mcp/daemon-manager.d.ts.map +1 -0
  396. package/sensor/dist/mcp/daemon-manager.js +129 -0
  397. package/sensor/dist/mcp/daemon-manager.js.map +1 -0
  398. package/sensor/dist/mcp/daemon-paths.d.ts +73 -0
  399. package/sensor/dist/mcp/daemon-paths.d.ts.map +1 -0
  400. package/sensor/dist/mcp/daemon-paths.js +170 -0
  401. package/sensor/dist/mcp/daemon-paths.js.map +1 -0
  402. package/sensor/dist/mcp/daemon-registry.d.ts +54 -0
  403. package/sensor/dist/mcp/daemon-registry.d.ts.map +1 -0
  404. package/sensor/dist/mcp/daemon-registry.js +241 -0
  405. package/sensor/dist/mcp/daemon-registry.js.map +1 -0
  406. package/sensor/dist/mcp/daemon.d.ts +290 -0
  407. package/sensor/dist/mcp/daemon.d.ts.map +1 -0
  408. package/sensor/dist/mcp/daemon.js +867 -0
  409. package/sensor/dist/mcp/daemon.js.map +1 -0
  410. package/sensor/dist/mcp/dynamic-boundaries.d.ts +41 -0
  411. package/sensor/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  412. package/sensor/dist/mcp/dynamic-boundaries.js +360 -0
  413. package/sensor/dist/mcp/dynamic-boundaries.js.map +1 -0
  414. package/sensor/dist/mcp/early-ppid.d.ts +26 -0
  415. package/sensor/dist/mcp/early-ppid.d.ts.map +1 -0
  416. package/sensor/dist/mcp/early-ppid.js +29 -0
  417. package/sensor/dist/mcp/early-ppid.js.map +1 -0
  418. package/sensor/dist/mcp/engine.d.ts +130 -0
  419. package/sensor/dist/mcp/engine.d.ts.map +1 -0
  420. package/sensor/dist/mcp/engine.js +375 -0
  421. package/sensor/dist/mcp/engine.js.map +1 -0
  422. package/sensor/dist/mcp/index.d.ts +113 -0
  423. package/sensor/dist/mcp/index.d.ts.map +1 -0
  424. package/sensor/dist/mcp/index.js +551 -0
  425. package/sensor/dist/mcp/index.js.map +1 -0
  426. package/sensor/dist/mcp/liveness-watchdog.d.ts +35 -0
  427. package/sensor/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  428. package/sensor/dist/mcp/liveness-watchdog.js +267 -0
  429. package/sensor/dist/mcp/liveness-watchdog.js.map +1 -0
  430. package/sensor/dist/mcp/ppid-watchdog.d.ts +62 -0
  431. package/sensor/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  432. package/sensor/dist/mcp/ppid-watchdog.js +64 -0
  433. package/sensor/dist/mcp/ppid-watchdog.js.map +1 -0
  434. package/sensor/dist/mcp/proxy.d.ts +99 -0
  435. package/sensor/dist/mcp/proxy.d.ts.map +1 -0
  436. package/sensor/dist/mcp/proxy.js +737 -0
  437. package/sensor/dist/mcp/proxy.js.map +1 -0
  438. package/sensor/dist/mcp/query-pool.d.ts +108 -0
  439. package/sensor/dist/mcp/query-pool.d.ts.map +1 -0
  440. package/sensor/dist/mcp/query-pool.js +315 -0
  441. package/sensor/dist/mcp/query-pool.js.map +1 -0
  442. package/sensor/dist/mcp/query-worker.d.ts +24 -0
  443. package/sensor/dist/mcp/query-worker.d.ts.map +1 -0
  444. package/sensor/dist/mcp/query-worker.js +87 -0
  445. package/sensor/dist/mcp/query-worker.js.map +1 -0
  446. package/sensor/dist/mcp/server-instructions.d.ts +34 -0
  447. package/sensor/dist/mcp/server-instructions.d.ts.map +1 -0
  448. package/sensor/dist/mcp/server-instructions.js +106 -0
  449. package/sensor/dist/mcp/server-instructions.js.map +1 -0
  450. package/sensor/dist/mcp/session.d.ts +92 -0
  451. package/sensor/dist/mcp/session.d.ts.map +1 -0
  452. package/sensor/dist/mcp/session.js +355 -0
  453. package/sensor/dist/mcp/session.js.map +1 -0
  454. package/sensor/dist/mcp/startup-handshake.d.ts +44 -0
  455. package/sensor/dist/mcp/startup-handshake.d.ts.map +1 -0
  456. package/sensor/dist/mcp/startup-handshake.js +73 -0
  457. package/sensor/dist/mcp/startup-handshake.js.map +1 -0
  458. package/sensor/dist/mcp/stdin-teardown.d.ts +27 -0
  459. package/sensor/dist/mcp/stdin-teardown.d.ts.map +1 -0
  460. package/sensor/dist/mcp/stdin-teardown.js +49 -0
  461. package/sensor/dist/mcp/stdin-teardown.js.map +1 -0
  462. package/sensor/dist/mcp/tools.d.ts +651 -0
  463. package/sensor/dist/mcp/tools.d.ts.map +1 -0
  464. package/sensor/dist/mcp/tools.js +4574 -0
  465. package/sensor/dist/mcp/tools.js.map +1 -0
  466. package/sensor/dist/mcp/transport.d.ts +188 -0
  467. package/sensor/dist/mcp/transport.d.ts.map +1 -0
  468. package/sensor/dist/mcp/transport.js +377 -0
  469. package/sensor/dist/mcp/transport.js.map +1 -0
  470. package/sensor/dist/mcp/version.d.ts +30 -0
  471. package/sensor/dist/mcp/version.d.ts.map +1 -0
  472. package/sensor/dist/mcp/version.js +85 -0
  473. package/sensor/dist/mcp/version.js.map +1 -0
  474. package/sensor/dist/project-config.d.ts +94 -0
  475. package/sensor/dist/project-config.d.ts.map +1 -0
  476. package/sensor/dist/project-config.js +374 -0
  477. package/sensor/dist/project-config.js.map +1 -0
  478. package/sensor/dist/resolution/c-fnptr-synthesizer.d.ts +6 -0
  479. package/sensor/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
  480. package/sensor/dist/resolution/c-fnptr-synthesizer.js +1070 -0
  481. package/sensor/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
  482. package/sensor/dist/resolution/callback-synthesizer.d.ts +59 -0
  483. package/sensor/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  484. package/sensor/dist/resolution/callback-synthesizer.js +3961 -0
  485. package/sensor/dist/resolution/callback-synthesizer.js.map +1 -0
  486. package/sensor/dist/resolution/cooperative-yield.d.ts +40 -0
  487. package/sensor/dist/resolution/cooperative-yield.d.ts.map +1 -0
  488. package/sensor/dist/resolution/cooperative-yield.js +44 -0
  489. package/sensor/dist/resolution/cooperative-yield.js.map +1 -0
  490. package/sensor/dist/resolution/frameworks/astro.d.ts +9 -0
  491. package/sensor/dist/resolution/frameworks/astro.d.ts.map +1 -0
  492. package/sensor/dist/resolution/frameworks/astro.js +169 -0
  493. package/sensor/dist/resolution/frameworks/astro.js.map +1 -0
  494. package/sensor/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  495. package/sensor/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  496. package/sensor/dist/resolution/frameworks/cargo-workspace.js +225 -0
  497. package/sensor/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  498. package/sensor/dist/resolution/frameworks/cics.d.ts +20 -0
  499. package/sensor/dist/resolution/frameworks/cics.d.ts.map +1 -0
  500. package/sensor/dist/resolution/frameworks/cics.js +90 -0
  501. package/sensor/dist/resolution/frameworks/cics.js.map +1 -0
  502. package/sensor/dist/resolution/frameworks/csharp.d.ts +8 -0
  503. package/sensor/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  504. package/sensor/dist/resolution/frameworks/csharp.js +241 -0
  505. package/sensor/dist/resolution/frameworks/csharp.js.map +1 -0
  506. package/sensor/dist/resolution/frameworks/drupal.d.ts +51 -0
  507. package/sensor/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  508. package/sensor/dist/resolution/frameworks/drupal.js +367 -0
  509. package/sensor/dist/resolution/frameworks/drupal.js.map +1 -0
  510. package/sensor/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  511. package/sensor/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  512. package/sensor/dist/resolution/frameworks/expo-modules.js +148 -0
  513. package/sensor/dist/resolution/frameworks/expo-modules.js.map +1 -0
  514. package/sensor/dist/resolution/frameworks/express.d.ts +8 -0
  515. package/sensor/dist/resolution/frameworks/express.d.ts.map +1 -0
  516. package/sensor/dist/resolution/frameworks/express.js +308 -0
  517. package/sensor/dist/resolution/frameworks/express.js.map +1 -0
  518. package/sensor/dist/resolution/frameworks/fabric.d.ts +3 -0
  519. package/sensor/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  520. package/sensor/dist/resolution/frameworks/fabric.js +354 -0
  521. package/sensor/dist/resolution/frameworks/fabric.js.map +1 -0
  522. package/sensor/dist/resolution/frameworks/go.d.ts +8 -0
  523. package/sensor/dist/resolution/frameworks/go.d.ts.map +1 -0
  524. package/sensor/dist/resolution/frameworks/go.js +184 -0
  525. package/sensor/dist/resolution/frameworks/go.js.map +1 -0
  526. package/sensor/dist/resolution/frameworks/goframe.d.ts +41 -0
  527. package/sensor/dist/resolution/frameworks/goframe.d.ts.map +1 -0
  528. package/sensor/dist/resolution/frameworks/goframe.js +112 -0
  529. package/sensor/dist/resolution/frameworks/goframe.js.map +1 -0
  530. package/sensor/dist/resolution/frameworks/index.d.ts +50 -0
  531. package/sensor/dist/resolution/frameworks/index.d.ts.map +1 -0
  532. package/sensor/dist/resolution/frameworks/index.js +175 -0
  533. package/sensor/dist/resolution/frameworks/index.js.map +1 -0
  534. package/sensor/dist/resolution/frameworks/java.d.ts +8 -0
  535. package/sensor/dist/resolution/frameworks/java.d.ts.map +1 -0
  536. package/sensor/dist/resolution/frameworks/java.js +517 -0
  537. package/sensor/dist/resolution/frameworks/java.js.map +1 -0
  538. package/sensor/dist/resolution/frameworks/laravel.d.ts +13 -0
  539. package/sensor/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  540. package/sensor/dist/resolution/frameworks/laravel.js +257 -0
  541. package/sensor/dist/resolution/frameworks/laravel.js.map +1 -0
  542. package/sensor/dist/resolution/frameworks/nestjs.d.ts +26 -0
  543. package/sensor/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  544. package/sensor/dist/resolution/frameworks/nestjs.js +698 -0
  545. package/sensor/dist/resolution/frameworks/nestjs.js.map +1 -0
  546. package/sensor/dist/resolution/frameworks/play.d.ts +19 -0
  547. package/sensor/dist/resolution/frameworks/play.d.ts.map +1 -0
  548. package/sensor/dist/resolution/frameworks/play.js +111 -0
  549. package/sensor/dist/resolution/frameworks/play.js.map +1 -0
  550. package/sensor/dist/resolution/frameworks/python.d.ts +10 -0
  551. package/sensor/dist/resolution/frameworks/python.d.ts.map +1 -0
  552. package/sensor/dist/resolution/frameworks/python.js +400 -0
  553. package/sensor/dist/resolution/frameworks/python.js.map +1 -0
  554. package/sensor/dist/resolution/frameworks/react-native.d.ts +3 -0
  555. package/sensor/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  556. package/sensor/dist/resolution/frameworks/react-native.js +410 -0
  557. package/sensor/dist/resolution/frameworks/react-native.js.map +1 -0
  558. package/sensor/dist/resolution/frameworks/react.d.ts +8 -0
  559. package/sensor/dist/resolution/frameworks/react.d.ts.map +1 -0
  560. package/sensor/dist/resolution/frameworks/react.js +334 -0
  561. package/sensor/dist/resolution/frameworks/react.js.map +1 -0
  562. package/sensor/dist/resolution/frameworks/ruby.d.ts +8 -0
  563. package/sensor/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  564. package/sensor/dist/resolution/frameworks/ruby.js +302 -0
  565. package/sensor/dist/resolution/frameworks/ruby.js.map +1 -0
  566. package/sensor/dist/resolution/frameworks/rust.d.ts +8 -0
  567. package/sensor/dist/resolution/frameworks/rust.d.ts.map +1 -0
  568. package/sensor/dist/resolution/frameworks/rust.js +304 -0
  569. package/sensor/dist/resolution/frameworks/rust.js.map +1 -0
  570. package/sensor/dist/resolution/frameworks/svelte.d.ts +9 -0
  571. package/sensor/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  572. package/sensor/dist/resolution/frameworks/svelte.js +253 -0
  573. package/sensor/dist/resolution/frameworks/svelte.js.map +1 -0
  574. package/sensor/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  575. package/sensor/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  576. package/sensor/dist/resolution/frameworks/swift-objc.js +252 -0
  577. package/sensor/dist/resolution/frameworks/swift-objc.js.map +1 -0
  578. package/sensor/dist/resolution/frameworks/swift.d.ts +10 -0
  579. package/sensor/dist/resolution/frameworks/swift.d.ts.map +1 -0
  580. package/sensor/dist/resolution/frameworks/swift.js +400 -0
  581. package/sensor/dist/resolution/frameworks/swift.js.map +1 -0
  582. package/sensor/dist/resolution/frameworks/terraform.d.ts +38 -0
  583. package/sensor/dist/resolution/frameworks/terraform.d.ts.map +1 -0
  584. package/sensor/dist/resolution/frameworks/terraform.js +277 -0
  585. package/sensor/dist/resolution/frameworks/terraform.js.map +1 -0
  586. package/sensor/dist/resolution/frameworks/vue.d.ts +9 -0
  587. package/sensor/dist/resolution/frameworks/vue.d.ts.map +1 -0
  588. package/sensor/dist/resolution/frameworks/vue.js +303 -0
  589. package/sensor/dist/resolution/frameworks/vue.js.map +1 -0
  590. package/sensor/dist/resolution/go-module.d.ts +26 -0
  591. package/sensor/dist/resolution/go-module.d.ts.map +1 -0
  592. package/sensor/dist/resolution/go-module.js +78 -0
  593. package/sensor/dist/resolution/go-module.js.map +1 -0
  594. package/sensor/dist/resolution/goframe-synthesizer.d.ts +29 -0
  595. package/sensor/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
  596. package/sensor/dist/resolution/goframe-synthesizer.js +163 -0
  597. package/sensor/dist/resolution/goframe-synthesizer.js.map +1 -0
  598. package/sensor/dist/resolution/import-resolver.d.ts +84 -0
  599. package/sensor/dist/resolution/import-resolver.d.ts.map +1 -0
  600. package/sensor/dist/resolution/import-resolver.js +2172 -0
  601. package/sensor/dist/resolution/import-resolver.js.map +1 -0
  602. package/sensor/dist/resolution/index.d.ts +309 -0
  603. package/sensor/dist/resolution/index.d.ts.map +1 -0
  604. package/sensor/dist/resolution/index.js +2050 -0
  605. package/sensor/dist/resolution/index.js.map +1 -0
  606. package/sensor/dist/resolution/lru-cache.d.ts +24 -0
  607. package/sensor/dist/resolution/lru-cache.d.ts.map +1 -0
  608. package/sensor/dist/resolution/lru-cache.js +62 -0
  609. package/sensor/dist/resolution/lru-cache.js.map +1 -0
  610. package/sensor/dist/resolution/name-matcher.d.ts +126 -0
  611. package/sensor/dist/resolution/name-matcher.d.ts.map +1 -0
  612. package/sensor/dist/resolution/name-matcher.js +1968 -0
  613. package/sensor/dist/resolution/name-matcher.js.map +1 -0
  614. package/sensor/dist/resolution/path-aliases.d.ts +68 -0
  615. package/sensor/dist/resolution/path-aliases.d.ts.map +1 -0
  616. package/sensor/dist/resolution/path-aliases.js +238 -0
  617. package/sensor/dist/resolution/path-aliases.js.map +1 -0
  618. package/sensor/dist/resolution/resolver-pool.d.ts +66 -0
  619. package/sensor/dist/resolution/resolver-pool.d.ts.map +1 -0
  620. package/sensor/dist/resolution/resolver-pool.js +244 -0
  621. package/sensor/dist/resolution/resolver-pool.js.map +1 -0
  622. package/sensor/dist/resolution/resolver-worker.d.ts +17 -0
  623. package/sensor/dist/resolution/resolver-worker.d.ts.map +1 -0
  624. package/sensor/dist/resolution/resolver-worker.js +114 -0
  625. package/sensor/dist/resolution/resolver-worker.js.map +1 -0
  626. package/sensor/dist/resolution/strip-comments.d.ts +27 -0
  627. package/sensor/dist/resolution/strip-comments.d.ts.map +1 -0
  628. package/sensor/dist/resolution/strip-comments.js +492 -0
  629. package/sensor/dist/resolution/strip-comments.js.map +1 -0
  630. package/sensor/dist/resolution/swift-objc-bridge.d.ts +134 -0
  631. package/sensor/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  632. package/sensor/dist/resolution/swift-objc-bridge.js +256 -0
  633. package/sensor/dist/resolution/swift-objc-bridge.js.map +1 -0
  634. package/sensor/dist/resolution/types.d.ts +265 -0
  635. package/sensor/dist/resolution/types.d.ts.map +1 -0
  636. package/sensor/dist/resolution/types.js +8 -0
  637. package/sensor/dist/resolution/types.js.map +1 -0
  638. package/sensor/dist/resolution/workspace-packages.d.ts +58 -0
  639. package/sensor/dist/resolution/workspace-packages.d.ts.map +1 -0
  640. package/sensor/dist/resolution/workspace-packages.js +346 -0
  641. package/sensor/dist/resolution/workspace-packages.js.map +1 -0
  642. package/sensor/dist/search/identifier-segments.d.ts +60 -0
  643. package/sensor/dist/search/identifier-segments.d.ts.map +1 -0
  644. package/sensor/dist/search/identifier-segments.js +176 -0
  645. package/sensor/dist/search/identifier-segments.js.map +1 -0
  646. package/sensor/dist/search/query-parser.d.ts +57 -0
  647. package/sensor/dist/search/query-parser.d.ts.map +1 -0
  648. package/sensor/dist/search/query-parser.js +177 -0
  649. package/sensor/dist/search/query-parser.js.map +1 -0
  650. package/sensor/dist/search/query-utils.d.ts +87 -0
  651. package/sensor/dist/search/query-utils.d.ts.map +1 -0
  652. package/sensor/dist/search/query-utils.js +449 -0
  653. package/sensor/dist/search/query-utils.js.map +1 -0
  654. package/sensor/dist/sync/git-hooks.d.ts +45 -0
  655. package/sensor/dist/sync/git-hooks.d.ts.map +1 -0
  656. package/sensor/dist/sync/git-hooks.js +227 -0
  657. package/sensor/dist/sync/git-hooks.js.map +1 -0
  658. package/sensor/dist/sync/index.d.ts +19 -0
  659. package/sensor/dist/sync/index.d.ts.map +1 -0
  660. package/sensor/dist/sync/index.js +35 -0
  661. package/sensor/dist/sync/index.js.map +1 -0
  662. package/sensor/dist/sync/watch-policy.d.ts +48 -0
  663. package/sensor/dist/sync/watch-policy.d.ts.map +1 -0
  664. package/sensor/dist/sync/watch-policy.js +124 -0
  665. package/sensor/dist/sync/watch-policy.js.map +1 -0
  666. package/sensor/dist/sync/watcher.d.ts +372 -0
  667. package/sensor/dist/sync/watcher.d.ts.map +1 -0
  668. package/sensor/dist/sync/watcher.js +879 -0
  669. package/sensor/dist/sync/watcher.js.map +1 -0
  670. package/sensor/dist/sync/worktree.d.ts +63 -0
  671. package/sensor/dist/sync/worktree.d.ts.map +1 -0
  672. package/sensor/dist/sync/worktree.js +182 -0
  673. package/sensor/dist/sync/worktree.js.map +1 -0
  674. package/sensor/dist/telemetry/index.d.ts +157 -0
  675. package/sensor/dist/telemetry/index.d.ts.map +1 -0
  676. package/sensor/dist/telemetry/index.js +556 -0
  677. package/sensor/dist/telemetry/index.js.map +1 -0
  678. package/sensor/dist/types.d.ts +458 -0
  679. package/sensor/dist/types.d.ts.map +1 -0
  680. package/sensor/dist/types.js +117 -0
  681. package/sensor/dist/types.js.map +1 -0
  682. package/sensor/dist/ui/color.d.ts +21 -0
  683. package/sensor/dist/ui/color.d.ts.map +1 -0
  684. package/sensor/dist/ui/color.js +42 -0
  685. package/sensor/dist/ui/color.js.map +1 -0
  686. package/sensor/dist/ui/glyphs.d.ts +67 -0
  687. package/sensor/dist/ui/glyphs.d.ts.map +1 -0
  688. package/sensor/dist/ui/glyphs.js +125 -0
  689. package/sensor/dist/ui/glyphs.js.map +1 -0
  690. package/sensor/dist/ui/shimmer-progress.d.ts +11 -0
  691. package/sensor/dist/ui/shimmer-progress.d.ts.map +1 -0
  692. package/sensor/dist/ui/shimmer-progress.js +164 -0
  693. package/sensor/dist/ui/shimmer-progress.js.map +1 -0
  694. package/sensor/dist/ui/shimmer-worker.d.ts +2 -0
  695. package/sensor/dist/ui/shimmer-worker.d.ts.map +1 -0
  696. package/sensor/dist/ui/shimmer-worker.js +126 -0
  697. package/sensor/dist/ui/shimmer-worker.js.map +1 -0
  698. package/sensor/dist/ui/types.d.ts +15 -0
  699. package/sensor/dist/ui/types.d.ts.map +1 -0
  700. package/sensor/dist/ui/types.js +3 -0
  701. package/sensor/dist/ui/types.js.map +1 -0
  702. package/sensor/dist/upgrade/index.d.ts +171 -0
  703. package/sensor/dist/upgrade/index.d.ts.map +1 -0
  704. package/sensor/dist/upgrade/index.js +659 -0
  705. package/sensor/dist/upgrade/index.js.map +1 -0
  706. package/sensor/dist/upgrade/remove-binary.d.ts +87 -0
  707. package/sensor/dist/upgrade/remove-binary.d.ts.map +1 -0
  708. package/sensor/dist/upgrade/remove-binary.js +289 -0
  709. package/sensor/dist/upgrade/remove-binary.js.map +1 -0
  710. package/sensor/dist/upgrade/update-check.d.ts +92 -0
  711. package/sensor/dist/upgrade/update-check.d.ts.map +1 -0
  712. package/sensor/dist/upgrade/update-check.js +258 -0
  713. package/sensor/dist/upgrade/update-check.js.map +1 -0
  714. package/sensor/dist/utils.d.ts +224 -0
  715. package/sensor/dist/utils.d.ts.map +1 -0
  716. package/sensor/dist/utils.js +583 -0
  717. package/sensor/dist/utils.js.map +1 -0
  718. package/sensor/package.json +61 -0
  719. package/src/artifact-contracts-v2.mjs +325 -0
  720. package/src/artifact-contracts.mjs +895 -0
  721. package/src/bootstrap.mjs +88 -0
  722. package/src/boundary-compiler.mjs +712 -0
  723. package/src/boundary-observation-compiler-v2.mjs +339 -0
  724. package/src/codegraph-adapter.mjs +422 -0
  725. package/src/control-compiler.mjs +532 -0
  726. package/src/factory-diagnostics.mjs +187 -0
  727. package/src/isolation-runner.mjs +333 -0
  728. package/src/node-version-guard.mjs +43 -0
  729. package/src/rc1-black-box-oracle.mjs +906 -0
  730. package/src/rc1-comparison.mjs +154 -0
  731. package/src/rc1-evidence-bundle.mjs +456 -0
  732. package/src/rc1-v4-campaign.mjs +707 -0
  733. package/src/rc1-v4-transform.mjs +467 -0
  734. package/src/rc1-v5-artifact-set.mjs +855 -0
  735. package/src/rc1-v5-behavior-evidence.mjs +594 -0
  736. package/src/rc1-v5-campaign.mjs +796 -0
  737. package/src/rc1-v5-transform.mjs +421 -0
  738. package/src/rc1-v6-artifact-set.mjs +807 -0
  739. package/src/rc1-v6-behavior-evidence.mjs +273 -0
  740. package/src/rc1-v6-campaign.mjs +623 -0
  741. package/src/rc1-v6-causal-binding.mjs +471 -0
  742. package/src/rc1-v6-measurement.mjs +331 -0
  743. package/src/rc2-artifact-set.mjs +1579 -0
  744. package/src/rc2-campaign.mjs +1520 -0
  745. package/src/rc2-delivery-policy-front-end.mjs +1079 -0
  746. package/src/rc2-delivery-policy-oracle.mjs +134 -0
  747. package/src/rc2-delivery-policy-transform.mjs +1127 -0
  748. package/src/rc2-rc1-transfer-front-end.mjs +511 -0
  749. package/src/rc3-actual-dogfood.mjs +648 -0
  750. package/src/rc3-dogfood-scaffold.mjs +310 -0
  751. package/src/rc3-scripted-campaign.mjs +1301 -0
  752. package/src/rc4-stage1-dogfood.mjs +652 -0
  753. package/src/runtime-cli.mjs +504 -0
  754. package/src/runtime-contracts.mjs +631 -0
  755. package/src/runtime-decision-verifier.mjs +607 -0
  756. package/src/runtime-diff-observer.mjs +265 -0
  757. package/src/runtime-engine.mjs +674 -0
  758. package/src/runtime-errors.mjs +356 -0
  759. package/src/runtime-event-store.mjs +217 -0
  760. package/src/runtime-front-end.mjs +764 -0
  761. package/src/runtime-hold-recompile.mjs +606 -0
  762. package/src/runtime-projection.mjs +180 -0
  763. package/src/runtime-scripted-executor.mjs +163 -0
  764. package/src/runtime-worktree-executor.mjs +199 -0
  765. package/src/schedulability-compiler-v2.mjs +303 -0
  766. package/src/schedulability-verifier-v2.mjs +317 -0
  767. package/src/seam-transform.mjs +554 -0
  768. package/src/treatment-compiler.mjs +728 -0
  769. package/src/treatment-runner.mjs +658 -0
@@ -0,0 +1,2050 @@
1
+ "use strict";
2
+ /**
3
+ * Reference Resolution Orchestrator
4
+ *
5
+ * Coordinates all reference resolution strategies.
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
41
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.ReferenceResolver = void 0;
45
+ exports.createResolver = createResolver;
46
+ const fs = __importStar(require("fs"));
47
+ const path = __importStar(require("path"));
48
+ const name_matcher_1 = require("./name-matcher");
49
+ const import_resolver_1 = require("./import-resolver");
50
+ const resolver_pool_1 = require("./resolver-pool");
51
+ const frameworks_1 = require("./frameworks");
52
+ const callback_synthesizer_1 = require("./callback-synthesizer");
53
+ const cooperative_yield_1 = require("./cooperative-yield");
54
+ const path_aliases_1 = require("./path-aliases");
55
+ const go_module_1 = require("./go-module");
56
+ const workspace_packages_1 = require("./workspace-packages");
57
+ const errors_1 = require("../errors");
58
+ const lru_cache_1 = require("./lru-cache");
59
+ /** Node kinds that can declare supertypes (extends/implements). */
60
+ const SUPERTYPE_BEARING_KINDS = new Set([
61
+ 'class', 'struct', 'interface', 'trait', 'protocol', 'enum',
62
+ ]);
63
+ /**
64
+ * Languages whose chained static-factory/fluent calls defer to the conformance
65
+ * second pass. Dotted-receiver languages resolve via matchDottedCallChain; the
66
+ * `::`-receiver ones (Rust) via matchScopedCallChain.
67
+ */
68
+ const CHAIN_LANGUAGES = new Set(['java', 'kotlin', 'csharp', 'swift', 'rust', 'go', 'scala', 'dart', 'objc', 'pascal']);
69
+ const SCOPED_CHAIN_LANGUAGES = new Set(['rust']);
70
+ /**
71
+ * Languages Strategy 3's cross-*language* name-match gate applies between
72
+ * (ADR 0048, revised). js/ts/python all have explicit import semantics, but
73
+ * js<->ts is one family (see LANGUAGE_FAMILY in name-matcher.ts — ArkTS too),
74
+ * so the gate only fires when the ref and target languages are BOTH in this
75
+ * set AND belong to different families (i.e. python paired with js/ts).
76
+ * Same-language cross-file matches (js calling js) are intentionally left
77
+ * alone here — see the gate's own comment at the Strategy 3 call site for why
78
+ * (several existing features — destructured store actions, receiver-typed
79
+ * method calls, DI-constructor calls — legitimately rely on it; file-level
80
+ * corroboration for THEIR false positives is handled downstream by
81
+ * getDependentFilePaths / getDependencyFilePaths filtering on resolvedBy —
82
+ * see UNCORROBORATED_FILTER_LANGUAGES in src/db/queries.ts, a mirror of this
83
+ * same set for the same reason (import/require is these 3 languages' only
84
+ * legal cross-file binding mechanism; keep both lists in lockstep).
85
+ */
86
+ const CROSS_LANGUAGE_GATE_FAMILY = new Set(['javascript', 'typescript', 'python']);
87
+ /** The extractor's chained-receiver encoding: `<inner>().<method>`. */
88
+ const CHAIN_SHAPE = /^(.+)\(\)\.(\w+)$/;
89
+ /** PHP `$this->prop->method()` encoded as `this->prop.method` — no `()`, so CHAIN_SHAPE misses it. */
90
+ const PHP_PROP_SHAPE = /^this->\w+\.\w+$/;
91
+ /**
92
+ * Cache size limits. Each per-resolver cache is bounded so memory
93
+ * stays flat on large codebases (20k+ files). Sizes were chosen to
94
+ * cover the working set for typical resolution batches without
95
+ * exceeding a few hundred MB worst-case. Override via the env var
96
+ * `CODEGRAPH_RESOLVER_CACHE_SIZE` (single integer applied to all
97
+ * caches) when tuning for very large or very small projects.
98
+ */
99
+ const DEFAULT_CACHE_LIMIT = 5_000;
100
+ function resolveCacheLimit() {
101
+ const raw = process.env.CODEGRAPH_RESOLVER_CACHE_SIZE;
102
+ if (!raw)
103
+ return DEFAULT_CACHE_LIMIT;
104
+ const parsed = Number.parseInt(raw, 10);
105
+ if (Number.isFinite(parsed) && parsed > 0)
106
+ return parsed;
107
+ return DEFAULT_CACHE_LIMIT;
108
+ }
109
+ // Re-export types
110
+ __exportStar(require("./types"), exports);
111
+ // Pre-built Sets for O(1) built-in lookups (allocated once, shared across all instances)
112
+ const JS_BUILT_INS = new Set([
113
+ 'console', 'window', 'document', 'global', 'process',
114
+ 'Promise', 'Array', 'Object', 'String', 'Number', 'Boolean',
115
+ 'Date', 'Math', 'JSON', 'RegExp', 'Error', 'Map', 'Set',
116
+ 'setTimeout', 'setInterval', 'clearTimeout', 'clearInterval',
117
+ 'fetch', 'require', 'module', 'exports', '__dirname', '__filename',
118
+ ]);
119
+ const REACT_HOOKS = new Set([
120
+ 'useState', 'useEffect', 'useContext', 'useReducer', 'useCallback',
121
+ 'useMemo', 'useRef', 'useLayoutEffect', 'useImperativeHandle', 'useDebugValue',
122
+ ]);
123
+ const PYTHON_BUILT_INS = new Set([
124
+ 'print', 'len', 'range', 'str', 'int', 'float', 'list', 'dict', 'set', 'tuple',
125
+ 'open', 'input', 'type', 'isinstance', 'hasattr', 'getattr', 'setattr',
126
+ 'super', 'self', 'cls', 'None', 'True', 'False',
127
+ ]);
128
+ const PYTHON_BUILT_IN_TYPES = new Set([
129
+ 'list', 'dict', 'set', 'tuple', 'str', 'int', 'float', 'bool',
130
+ 'bytes', 'bytearray', 'frozenset', 'object', 'super',
131
+ ]);
132
+ const PYTHON_BUILT_IN_METHODS = new Set([
133
+ 'append', 'extend', 'insert', 'remove', 'pop', 'clear', 'sort', 'reverse', 'copy',
134
+ 'update', 'keys', 'values', 'items', 'get',
135
+ 'add', 'discard', 'union', 'intersection', 'difference',
136
+ 'split', 'join', 'strip', 'lstrip', 'rstrip', 'replace', 'lower', 'upper',
137
+ 'startswith', 'endswith', 'find', 'index', 'count', 'encode', 'decode',
138
+ 'format', 'isdigit', 'isalpha', 'isalnum',
139
+ 'read', 'write', 'readline', 'readlines', 'close', 'flush', 'seek',
140
+ ]);
141
+ const GO_STDLIB_PACKAGES = new Set([
142
+ 'fmt', 'os', 'io', 'net', 'http', 'log', 'math', 'sort', 'sync',
143
+ 'time', 'path', 'bytes', 'strings', 'strconv', 'errors', 'context',
144
+ 'json', 'xml', 'csv', 'html', 'template', 'regexp', 'reflect',
145
+ 'runtime', 'testing', 'flag', 'bufio', 'crypto', 'encoding',
146
+ 'filepath', 'hash', 'mime', 'rand', 'signal', 'sql', 'syscall',
147
+ 'unicode', 'unsafe', 'atomic', 'binary', 'debug', 'exec', 'heap',
148
+ 'ring', 'scanner', 'tar', 'zip', 'gzip', 'zlib', 'tls', 'url',
149
+ 'user', 'pprof', 'trace', 'ast', 'build', 'parser', 'printer',
150
+ 'token', 'types', 'cgo', 'plugin', 'race', 'ioutil',
151
+ // Kubernetes-common stdlib aliases
152
+ 'utilruntime', 'utilwait', 'utilnet',
153
+ ]);
154
+ const GO_BUILT_INS = new Set([
155
+ 'make', 'new', 'len', 'cap', 'append', 'copy', 'delete', 'close',
156
+ 'panic', 'recover', 'print', 'println', 'complex', 'real', 'imag',
157
+ 'error', 'nil', 'true', 'false', 'iota',
158
+ 'int', 'int8', 'int16', 'int32', 'int64',
159
+ 'uint', 'uint8', 'uint16', 'uint32', 'uint64', 'uintptr',
160
+ 'float32', 'float64', 'complex64', 'complex128',
161
+ 'string', 'bool', 'byte', 'rune', 'any',
162
+ ]);
163
+ const PASCAL_UNIT_PREFIXES = [
164
+ 'System.', 'Winapi.', 'Vcl.', 'Fmx.', 'Data.', 'Datasnap.',
165
+ 'Soap.', 'Xml.', 'Web.', 'REST.', 'FireDAC.', 'IBX.',
166
+ 'IdHTTP', 'IdTCP', 'IdSSL',
167
+ ];
168
+ const PASCAL_BUILT_INS = new Set([
169
+ 'System', 'SysUtils', 'Classes', 'Types', 'Variants', 'StrUtils',
170
+ 'Math', 'DateUtils', 'IOUtils', 'Generics.Collections', 'Generics.Defaults',
171
+ 'Rtti', 'TypInfo', 'SyncObjs', 'RegularExpressions',
172
+ 'SysInit', 'Windows', 'Messages', 'Graphics', 'Controls', 'Forms',
173
+ 'Dialogs', 'StdCtrls', 'ExtCtrls', 'ComCtrls', 'Menus', 'ActnList',
174
+ 'WriteLn', 'Write', 'ReadLn', 'Read', 'Inc', 'Dec', 'Ord', 'Chr',
175
+ 'Length', 'SetLength', 'High', 'Low', 'Assigned', 'FreeAndNil',
176
+ 'Format', 'IntToStr', 'StrToInt', 'FloatToStr', 'StrToFloat',
177
+ 'Trim', 'UpperCase', 'LowerCase', 'Pos', 'Copy', 'Delete', 'Insert',
178
+ 'Now', 'Date', 'Time', 'DateToStr', 'StrToDate',
179
+ 'Raise', 'Exit', 'Break', 'Continue', 'Abort',
180
+ 'True', 'False', 'nil', 'Self', 'Result',
181
+ 'Create', 'Destroy', 'Free',
182
+ 'TObject', 'TComponent', 'TPersistent', 'TInterfacedObject',
183
+ 'TList', 'TStringList', 'TStrings', 'TStream', 'TMemoryStream', 'TFileStream',
184
+ 'Exception', 'EAbort', 'EConvertError', 'EAccessViolation',
185
+ 'IInterface', 'IUnknown',
186
+ ]);
187
+ const C_BUILT_INS = new Set([
188
+ // Standard C library functions
189
+ 'printf', 'fprintf', 'sprintf', 'snprintf', 'scanf', 'fscanf', 'sscanf',
190
+ 'malloc', 'calloc', 'realloc', 'free',
191
+ 'memcpy', 'memmove', 'memset', 'memcmp', 'memchr',
192
+ 'strlen', 'strcpy', 'strncpy', 'strcat', 'strncat', 'strcmp', 'strncmp',
193
+ 'strstr', 'strchr', 'strrchr', 'strtok', 'strdup',
194
+ 'fopen', 'fclose', 'fread', 'fwrite', 'fgets', 'fputs', 'fputc', 'fgetc',
195
+ 'feof', 'ferror', 'fflush', 'fseek', 'ftell', 'rewind',
196
+ 'exit', 'abort', 'atexit', 'atoi', 'atol', 'atof', 'strtol', 'strtoul', 'strtod',
197
+ 'qsort', 'bsearch',
198
+ 'abs', 'labs', 'rand', 'srand',
199
+ 'sin', 'cos', 'tan', 'sqrt', 'pow', 'log', 'log10', 'exp', 'ceil', 'floor', 'fabs',
200
+ 'time', 'clock', 'difftime', 'mktime', 'localtime', 'gmtime', 'strftime', 'asctime',
201
+ 'assert', 'errno',
202
+ 'perror', 'remove', 'rename', 'tmpfile', 'tmpnam',
203
+ 'getenv', 'system',
204
+ 'signal', 'raise',
205
+ 'setjmp', 'longjmp',
206
+ 'va_start', 'va_end', 'va_arg', 'va_copy',
207
+ 'NULL', 'EOF', 'BUFSIZ', 'FILENAME_MAX', 'RAND_MAX', 'EXIT_SUCCESS', 'EXIT_FAILURE',
208
+ 'size_t', 'ptrdiff_t', 'wchar_t', 'intptr_t', 'uintptr_t',
209
+ 'int8_t', 'int16_t', 'int32_t', 'int64_t',
210
+ 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t',
211
+ 'FILE',
212
+ // POSIX additions commonly seen
213
+ 'stat', 'lstat', 'fstat', 'open', 'close', 'read', 'write', 'pipe',
214
+ 'fork', 'exec', 'waitpid', 'getpid', 'getppid', 'kill', 'sleep', 'usleep',
215
+ 'pthread_create', 'pthread_join', 'pthread_mutex_lock', 'pthread_mutex_unlock',
216
+ 'dlopen', 'dlsym', 'dlclose',
217
+ ]);
218
+ const CPP_BUILT_INS = new Set([
219
+ // iostream objects (often used without std:: prefix via using)
220
+ 'cout', 'cin', 'cerr', 'clog', 'endl', 'flush', 'ws',
221
+ 'std', // the namespace itself when used as std::something
222
+ // Common C++ keywords that leak as references
223
+ 'nullptr', 'true', 'false', 'this', 'sizeof', 'alignof', 'typeid',
224
+ 'static_cast', 'dynamic_cast', 'reinterpret_cast', 'const_cast',
225
+ 'make_unique', 'make_shared', 'make_pair',
226
+ 'move', 'forward', 'swap',
227
+ ]);
228
+ /**
229
+ * Reference Resolver
230
+ *
231
+ * Orchestrates reference resolution using multiple strategies.
232
+ */
233
+ class ReferenceResolver {
234
+ projectRoot;
235
+ queries;
236
+ context;
237
+ frameworks = [];
238
+ // Chained static-factory/fluent call refs the first pass couldn't resolve,
239
+ // collected in-memory (the batched resolver deletes unresolved refs from the
240
+ // DB, so they can't be re-read). Drained by resolveChainedCallsViaConformance
241
+ // once implements/extends edges exist, to resolve methods on a supertype the
242
+ // receiver conforms to (#750).
243
+ deferredChainRefs = [];
244
+ // `this.<member>` function-as-value refs whose member is NOT on the
245
+ // enclosing class itself — possibly inherited. Collected in-memory for the
246
+ // same reason as deferredChainRefs and drained by
247
+ // resolveDeferredThisMemberRefs once implements/extends edges exist (#808).
248
+ deferredThisMemberRefs = [];
249
+ // Per-`.razor`/`.cshtml`-file `@using` namespace set (own directives + folder
250
+ // `_Imports.razor`, cascading to the project root). Used to disambiguate a
251
+ // markup type ref to the right C# namespace.
252
+ razorUsingsCache = new Map();
253
+ // All per-resolver caches are LRU-bounded. Previously these were
254
+ // unbounded Maps that grew with every distinct lookup and OOM'd on
255
+ // codebases with 20k+ files (see issue: unbounded cache growth).
256
+ nodeCache; // per-file node cache
257
+ fileCache; // per-file content cache
258
+ importMappingCache;
259
+ reExportCache;
260
+ nameCache; // name → nodes cache
261
+ lowerNameCache; // lower(name) → nodes cache
262
+ qualifiedNameCache; // qualified_name → nodes cache
263
+ fileLinesCache; // file → split lines cache
264
+ methodMatchCache; // lang\0Type::method → matching method nodes
265
+ // Node kinds are a small fixed set (~24), so this is a plain Map, not an LRU.
266
+ // getNodesByKind returns the FULL node list for a kind; it was previously
267
+ // uncached — a per-ref `SELECT * FROM nodes WHERE kind=?` + row-mapping. Called
268
+ // for every dotted call ref by the Spring resolver (constants) and every
269
+ // `hook_` ref by the Drupal resolver (functions), that scan dominated
270
+ // resolution on large repos (#1180). The node set is stable within a
271
+ // resolution pass (same lifetime assumption as nameCache); clearCaches() resets
272
+ // it between passes. Callers must treat the returned array as read-only.
273
+ nodesByKindCache = new Map();
274
+ knownNames = null; // all known symbol names for fast pre-filtering
275
+ knownFiles = null;
276
+ cachesWarmed = false;
277
+ // tsconfig/jsconfig path-alias map. `undefined` = not yet computed,
278
+ // `null` = computed and absent. Treated as immutable for the
279
+ // resolver's lifetime; callers re-create the resolver if config changes.
280
+ projectAliases = undefined;
281
+ // go.mod module path. Same lazy/immutable convention as projectAliases.
282
+ goModule = undefined;
283
+ // Monorepo workspace member packages. Same lazy/immutable convention.
284
+ workspacePackages = undefined;
285
+ constructor(projectRoot, queries) {
286
+ this.projectRoot = projectRoot;
287
+ this.queries = queries;
288
+ const limit = resolveCacheLimit();
289
+ // The content cache is heavier (full file text), so we give it a
290
+ // smaller budget than the metadata caches.
291
+ const contentLimit = Math.max(64, Math.floor(limit / 5));
292
+ this.nodeCache = new lru_cache_1.LRUCache(limit);
293
+ this.fileCache = new lru_cache_1.LRUCache(contentLimit);
294
+ this.importMappingCache = new lru_cache_1.LRUCache(limit);
295
+ this.reExportCache = new lru_cache_1.LRUCache(limit);
296
+ this.nameCache = new lru_cache_1.LRUCache(limit);
297
+ this.lowerNameCache = new lru_cache_1.LRUCache(limit);
298
+ this.qualifiedNameCache = new lru_cache_1.LRUCache(limit);
299
+ // Split-lines arrays are heavier than content strings; refs arrive
300
+ // file-ordered, so a small cache still hits nearly always.
301
+ this.fileLinesCache = new lru_cache_1.LRUCache(contentLimit);
302
+ this.methodMatchCache = new lru_cache_1.LRUCache(limit);
303
+ this.context = this.createContext();
304
+ }
305
+ /**
306
+ * Initialize the resolver (detect frameworks, etc.)
307
+ */
308
+ initialize() {
309
+ this.frameworks = (0, frameworks_1.detectFrameworks)(this.context);
310
+ this.clearCaches();
311
+ }
312
+ /**
313
+ * Run each framework resolver's cross-file finalization pass and persist
314
+ * the returned node updates. Idempotent — safe to call after every indexAll
315
+ * and every incremental sync. Returns the number of nodes updated.
316
+ *
317
+ * Caches are cleared before/after so the post-extract pass sees fresh DB
318
+ * state and downstream queries see the updated names.
319
+ */
320
+ runPostExtract() {
321
+ let updated = 0;
322
+ this.clearCaches();
323
+ for (const fw of this.frameworks) {
324
+ if (!fw.postExtract)
325
+ continue;
326
+ try {
327
+ const nodes = fw.postExtract(this.context);
328
+ for (const node of nodes) {
329
+ this.queries.updateNode(node);
330
+ updated++;
331
+ }
332
+ }
333
+ catch (err) {
334
+ (0, errors_1.logDebug)(`Framework '${fw.name}' postExtract failed`, {
335
+ error: err instanceof Error ? err.message : String(err),
336
+ });
337
+ }
338
+ }
339
+ if (updated > 0)
340
+ this.clearCaches();
341
+ return updated;
342
+ }
343
+ /**
344
+ * Pre-build lightweight caches for resolution.
345
+ * Node lookups are now handled by indexed SQLite queries instead of
346
+ * loading all nodes into memory (which caused OOM on large codebases).
347
+ * We cache the set of known symbol names for fast pre-filtering.
348
+ */
349
+ warmCaches() {
350
+ if (this.cachesWarmed)
351
+ return;
352
+ // Only cache the set of known file paths (lightweight string set)
353
+ this.knownFiles = new Set(this.queries.getAllFilePaths());
354
+ // Cache all distinct symbol names for fast pre-filtering (just strings, not full nodes)
355
+ this.knownNames = new Set(this.queries.getAllNodeNames());
356
+ this.cachesWarmed = true;
357
+ }
358
+ /**
359
+ * warmCaches for the async resolution entry points: streams the distinct
360
+ * name set with periodic yields instead of one synchronous `.all()`. On a
361
+ * multi-million-node index the DISTINCT scan is a solid multi-second block
362
+ * (measured up to 28s inside `codegraph sync` on the Linux kernel index),
363
+ * long enough to matter to the #850 watchdog on slower hardware. Same
364
+ * result, same memory — only the event loop keeps turning.
365
+ */
366
+ async warmCachesYielding(onYield) {
367
+ if (this.cachesWarmed)
368
+ return;
369
+ this.knownFiles = new Set(this.queries.getAllFilePaths());
370
+ const names = new Set();
371
+ let scanned = 0;
372
+ for (const name of this.queries.iterateNodeNames()) {
373
+ names.add(name);
374
+ if ((++scanned & 8191) === 0)
375
+ await onYield();
376
+ }
377
+ this.knownNames = names;
378
+ this.cachesWarmed = true;
379
+ }
380
+ /**
381
+ * Clear internal caches
382
+ */
383
+ clearCaches() {
384
+ this.nodeCache.clear();
385
+ this.fileCache.clear();
386
+ this.importMappingCache.clear();
387
+ this.reExportCache.clear();
388
+ this.nameCache.clear();
389
+ this.lowerNameCache.clear();
390
+ this.qualifiedNameCache.clear();
391
+ this.fileLinesCache.clear();
392
+ this.methodMatchCache.clear();
393
+ this.nodesByKindCache.clear();
394
+ this.knownNames = null;
395
+ this.knownFiles = null;
396
+ this.cachesWarmed = false;
397
+ // The import-resolver's per-context memos assume the same stable window
398
+ // as the caches above — drop them together.
399
+ if (this.context)
400
+ (0, import_resolver_1.clearImportResolverMemos)(this.context);
401
+ }
402
+ /** `readFile` through the LRU content cache (null = read failed, also cached). */
403
+ readFileCached(filePath) {
404
+ if (this.fileCache.has(filePath)) {
405
+ return this.fileCache.get(filePath);
406
+ }
407
+ const fullPath = path.join(this.projectRoot, filePath);
408
+ try {
409
+ const content = fs.readFileSync(fullPath, 'utf-8');
410
+ this.fileCache.set(filePath, content);
411
+ return content;
412
+ }
413
+ catch (error) {
414
+ (0, errors_1.logDebug)('Failed to read file for resolution', { filePath, error: String(error) });
415
+ this.fileCache.set(filePath, null);
416
+ return null;
417
+ }
418
+ }
419
+ /**
420
+ * Create the resolution context
421
+ */
422
+ createContext() {
423
+ return {
424
+ getNodesInFile: (filePath) => {
425
+ if (!this.nodeCache.has(filePath)) {
426
+ this.nodeCache.set(filePath, this.queries.getNodesByFile(filePath));
427
+ }
428
+ return this.nodeCache.get(filePath);
429
+ },
430
+ getNodesByName: (name) => {
431
+ const cached = this.nameCache.get(name);
432
+ if (cached !== undefined)
433
+ return cached;
434
+ const result = this.queries.getNodesByName(name);
435
+ this.nameCache.set(name, result);
436
+ return result;
437
+ },
438
+ getMethodMatches: (typeName, methodName, language) => {
439
+ const key = `${language} ${typeName}::${methodName}`;
440
+ const cached = this.methodMatchCache.get(key);
441
+ if (cached !== undefined)
442
+ return cached;
443
+ let candidates = this.nameCache.get(methodName);
444
+ if (candidates === undefined) {
445
+ candidates = this.queries.getNodesByName(methodName);
446
+ this.nameCache.set(methodName, candidates);
447
+ }
448
+ const want = `${typeName}::${methodName}`;
449
+ const matches = [];
450
+ for (const m of candidates) {
451
+ if (m.kind !== 'method')
452
+ continue;
453
+ if (m.language !== language)
454
+ continue;
455
+ const qn = m.qualifiedName;
456
+ if (qn === want || qn.endsWith(`::${want}`))
457
+ matches.push(m);
458
+ }
459
+ this.methodMatchCache.set(key, matches);
460
+ return matches;
461
+ },
462
+ getNodesByQualifiedName: (qualifiedName) => {
463
+ const cached = this.qualifiedNameCache.get(qualifiedName);
464
+ if (cached !== undefined)
465
+ return cached;
466
+ const result = this.queries.getNodesByQualifiedNameExact(qualifiedName);
467
+ this.qualifiedNameCache.set(qualifiedName, result);
468
+ return result;
469
+ },
470
+ getNodesByKind: (kind) => {
471
+ const cached = this.nodesByKindCache.get(kind);
472
+ if (cached !== undefined)
473
+ return cached;
474
+ const result = this.queries.getNodesByKind(kind);
475
+ this.nodesByKindCache.set(kind, result);
476
+ return result;
477
+ },
478
+ // Streamed, uncached — synthesizers scan-and-filter whole kinds, and
479
+ // both the materialized array AND the per-kind cache retention are
480
+ // O(nodes) memory (#1212). Per-ref resolvers keep the cached array
481
+ // variant above.
482
+ iterateNodesByKind: (kind) => this.queries.iterateNodesByKind(kind),
483
+ fileExists: (filePath) => {
484
+ // Check pre-built known files set first (O(1))
485
+ if (this.knownFiles) {
486
+ const normalized = filePath.replace(/\\/g, '/');
487
+ if (this.knownFiles.has(filePath) || this.knownFiles.has(normalized)) {
488
+ return true;
489
+ }
490
+ }
491
+ // Fall back to filesystem for files not yet indexed
492
+ const fullPath = path.join(this.projectRoot, filePath);
493
+ try {
494
+ return fs.existsSync(fullPath);
495
+ }
496
+ catch (error) {
497
+ (0, errors_1.logDebug)('Error checking file existence', { filePath, error: String(error) });
498
+ return false;
499
+ }
500
+ },
501
+ readFile: (filePath) => this.readFileCached(filePath),
502
+ getFileLines: (filePath) => {
503
+ const cached = this.fileLinesCache.get(filePath);
504
+ if (cached !== undefined)
505
+ return cached;
506
+ const source = this.readFileCached(filePath);
507
+ const lines = source === null ? null : source.split(/\r?\n/);
508
+ this.fileLinesCache.set(filePath, lines);
509
+ return lines;
510
+ },
511
+ getProjectRoot: () => this.projectRoot,
512
+ getAllFiles: () => {
513
+ return this.queries.getAllFilePaths();
514
+ },
515
+ listDirectories: (relativePath) => {
516
+ const target = relativePath === '.' || relativePath === ''
517
+ ? this.projectRoot
518
+ : path.join(this.projectRoot, relativePath);
519
+ try {
520
+ return fs
521
+ .readdirSync(target, { withFileTypes: true })
522
+ .filter((entry) => entry.isDirectory())
523
+ .map((entry) => entry.name);
524
+ }
525
+ catch (error) {
526
+ (0, errors_1.logDebug)('Failed to list directory for resolution', {
527
+ relativePath,
528
+ error: String(error),
529
+ });
530
+ return [];
531
+ }
532
+ },
533
+ getNodesByLowerName: (lowerName) => {
534
+ const cached = this.lowerNameCache.get(lowerName);
535
+ if (cached !== undefined)
536
+ return cached;
537
+ const result = this.queries.getNodesByLowerName(lowerName);
538
+ this.lowerNameCache.set(lowerName, result);
539
+ return result;
540
+ },
541
+ getNodeById: (id) => {
542
+ return this.queries.getNodeById(id);
543
+ },
544
+ getSupertypes: (typeName, language) => {
545
+ // Union the `implements`/`extends` targets of every same-named type node.
546
+ // Matching by simple name (not id) reconciles a type declared in one node
547
+ // (`KF::Builder`) with conformance declared in a separate extension node
548
+ // (`KF.Builder: KFOptionSetter`) — both have name `Builder`.
549
+ const typeNodes = this.context
550
+ .getNodesByName(typeName)
551
+ .filter((n) => SUPERTYPE_BEARING_KINDS.has(n.kind) && n.language === language);
552
+ if (typeNodes.length === 0)
553
+ return [];
554
+ const supertypes = new Set();
555
+ for (const tn of typeNodes) {
556
+ for (const edge of this.queries.getOutgoingEdges(tn.id, ['implements', 'extends'])) {
557
+ const target = this.queries.getNodeById(edge.target);
558
+ if (target?.name && target.name !== typeName)
559
+ supertypes.add(target.name);
560
+ }
561
+ }
562
+ return [...supertypes];
563
+ },
564
+ getImportMappings: (filePath, language) => {
565
+ const cacheKey = filePath;
566
+ const cached = this.importMappingCache.get(cacheKey);
567
+ if (cached)
568
+ return cached;
569
+ const content = this.context.readFile(filePath);
570
+ if (!content) {
571
+ this.importMappingCache.set(cacheKey, []);
572
+ return [];
573
+ }
574
+ const mappings = (0, import_resolver_1.extractImportMappings)(filePath, content, language);
575
+ this.importMappingCache.set(cacheKey, mappings);
576
+ return mappings;
577
+ },
578
+ getProjectAliases: () => {
579
+ if (this.projectAliases === undefined) {
580
+ this.projectAliases = (0, path_aliases_1.loadProjectAliases)(this.projectRoot);
581
+ }
582
+ return this.projectAliases;
583
+ },
584
+ getGoModule: () => {
585
+ if (this.goModule === undefined) {
586
+ this.goModule = (0, go_module_1.loadGoModule)(this.projectRoot);
587
+ }
588
+ return this.goModule;
589
+ },
590
+ getWorkspacePackages: () => {
591
+ if (this.workspacePackages === undefined) {
592
+ this.workspacePackages = (0, workspace_packages_1.loadWorkspacePackages)(this.projectRoot);
593
+ }
594
+ return this.workspacePackages;
595
+ },
596
+ getReExports: (filePath, language) => {
597
+ const cached = this.reExportCache.get(filePath);
598
+ if (cached)
599
+ return cached;
600
+ const content = this.context.readFile(filePath);
601
+ if (!content) {
602
+ this.reExportCache.set(filePath, []);
603
+ return [];
604
+ }
605
+ // Re-exports are a JS/TS-only construct, and what matters is the
606
+ // BARREL file's own language — not the consuming reference's. A
607
+ // `.svelte`/`.vue` consumer threads its own language down the
608
+ // re-export chase, which would make extractReExports() bail on a
609
+ // `.ts` index barrel and silently break the chain (#629). Re-key
610
+ // the parse on the barrel's extension so the chase works no matter
611
+ // what kind of file imports through it.
612
+ const isJsFamily = /\.(?:d\.ts|[cm]?tsx?|[cm]?jsx?|ets)$/i.test(filePath);
613
+ const reExports = (0, import_resolver_1.extractReExports)(content, isJsFamily ? 'typescript' : language);
614
+ this.reExportCache.set(filePath, reExports);
615
+ return reExports;
616
+ },
617
+ getCppIncludeDirs: () => {
618
+ return (0, import_resolver_1.loadCppIncludeDirs)(this.projectRoot);
619
+ },
620
+ };
621
+ }
622
+ /**
623
+ * Resolve all unresolved references
624
+ */
625
+ resolveAll(unresolvedRefs, onProgress) {
626
+ // Pre-load all nodes into memory for fast lookups
627
+ this.warmCaches();
628
+ const resolved = [];
629
+ const unresolved = [];
630
+ const byMethod = {};
631
+ // Convert to our internal format, using denormalized fields when available
632
+ const refs = unresolvedRefs.map((ref) => ({
633
+ fromNodeId: ref.fromNodeId,
634
+ referenceName: ref.referenceName,
635
+ referenceKind: ref.referenceKind,
636
+ line: ref.line,
637
+ column: ref.column,
638
+ filePath: ref.filePath || this.getFilePathFromNodeId(ref.fromNodeId),
639
+ language: ref.language || this.getLanguageFromNodeId(ref.fromNodeId),
640
+ rowId: ref.rowId,
641
+ }));
642
+ const total = refs.length;
643
+ let lastReportedPercent = -1;
644
+ for (let i = 0; i < refs.length; i++) {
645
+ const ref = refs[i]; // Array index is guaranteed to be in bounds
646
+ const result = this.resolveOne(ref);
647
+ if (result) {
648
+ resolved.push(result);
649
+ byMethod[result.resolvedBy] = (byMethod[result.resolvedBy] || 0) + 1;
650
+ }
651
+ else {
652
+ unresolved.push(ref);
653
+ }
654
+ // Report progress every 1% to avoid too many updates
655
+ if (onProgress) {
656
+ const currentPercent = Math.floor((i / total) * 100);
657
+ if (currentPercent > lastReportedPercent) {
658
+ lastReportedPercent = currentPercent;
659
+ onProgress(i + 1, total);
660
+ }
661
+ }
662
+ }
663
+ // Final progress report
664
+ if (onProgress && total > 0) {
665
+ onProgress(total, total);
666
+ }
667
+ return {
668
+ resolved,
669
+ unresolved,
670
+ stats: {
671
+ total: refs.length,
672
+ resolved: resolved.length,
673
+ unresolved: unresolved.length,
674
+ byMethod,
675
+ },
676
+ };
677
+ }
678
+ /**
679
+ * Check if a reference name has any possible match in the codebase.
680
+ * Uses the pre-built knownNames set to skip expensive resolution
681
+ * for names that definitely don't exist as symbols.
682
+ */
683
+ hasAnyPossibleMatch(name) {
684
+ if (!this.knownNames)
685
+ return true; // no pre-filter available
686
+ // Direct name match
687
+ if (this.knownNames.has(name))
688
+ return true;
689
+ // For qualified names like "obj.method" or "Class::method", check the parts
690
+ const dotIdx = name.indexOf('.');
691
+ if (dotIdx > 0) {
692
+ const receiver = name.substring(0, dotIdx);
693
+ const member = name.substring(dotIdx + 1);
694
+ if (this.knownNames.has(receiver) || this.knownNames.has(member))
695
+ return true;
696
+ // Also check capitalized receiver (instance-method resolution)
697
+ const capitalized = receiver.charAt(0).toUpperCase() + receiver.slice(1);
698
+ if (this.knownNames.has(capitalized))
699
+ return true;
700
+ // JVM FQN: `com.example.foo.Bar` — the only useful segment is the
701
+ // last one (`Bar`); the earlier check finds `example.foo.Bar` which
702
+ // never matches a node name.
703
+ const lastDot = name.lastIndexOf('.');
704
+ if (lastDot > dotIdx) {
705
+ const tail = name.substring(lastDot + 1);
706
+ if (tail && this.knownNames.has(tail))
707
+ return true;
708
+ }
709
+ }
710
+ const colonIdx = name.indexOf('::');
711
+ if (colonIdx > 0) {
712
+ const receiver = name.substring(0, colonIdx);
713
+ const member = name.substring(colonIdx + 2);
714
+ if (this.knownNames.has(receiver) || this.knownNames.has(member))
715
+ return true;
716
+ // Multi-segment path `a::b::c` (a Rust/C++ module call like
717
+ // `database::profiles::find`) — the only segment that names a symbol is
718
+ // the last (`c`); `member` above is `b::c`, which never matches a node
719
+ // name, so without this the pre-filter drops the ref before the Rust path
720
+ // resolver ever sees it. Mirror the dotted-name leaf check above.
721
+ const lastColon = name.lastIndexOf('::');
722
+ if (lastColon > colonIdx) {
723
+ const tail = name.substring(lastColon + 2);
724
+ if (tail && this.knownNames.has(tail))
725
+ return true;
726
+ }
727
+ }
728
+ // Lua/Luau method calls use a single `:` (`lg:log`); R uses `$` (`lg$log`).
729
+ // Check the member (and receiver) around these separators too, so the ref
730
+ // isn't dropped here before the method-call resolver ever sees it. The `:`
731
+ // case is skipped when the name actually contains `::` (handled above).
732
+ for (const sep of [':', '$']) {
733
+ if (sep === ':' && name.includes('::'))
734
+ continue;
735
+ const sepIdx = name.indexOf(sep);
736
+ if (sepIdx > 0) {
737
+ const receiver = name.substring(0, sepIdx);
738
+ const member = name.substring(sepIdx + 1);
739
+ if (this.knownNames.has(member) || this.knownNames.has(receiver))
740
+ return true;
741
+ const capitalized = receiver.charAt(0).toUpperCase() + receiver.slice(1);
742
+ if (this.knownNames.has(capitalized))
743
+ return true;
744
+ }
745
+ }
746
+ // For path-like references (e.g., "snippets/drawer-menu.liquid"), check the filename
747
+ const slashIdx = name.lastIndexOf('/');
748
+ if (slashIdx > 0) {
749
+ const fileName = name.substring(slashIdx + 1);
750
+ if (this.knownNames.has(fileName))
751
+ return true;
752
+ }
753
+ return false;
754
+ }
755
+ /**
756
+ * Does `ref.referenceName` match an import declared in its containing
757
+ * file? Used as a pre-filter escape so re-export chain resolution
758
+ * still gets a chance when the name has no project-wide declaration.
759
+ */
760
+ matchesAnyImport(ref) {
761
+ const imports = this.context.getImportMappings(ref.filePath, ref.language);
762
+ if (imports.length === 0)
763
+ return false;
764
+ for (const imp of imports) {
765
+ if (imp.localName === ref.referenceName ||
766
+ ref.referenceName.startsWith(imp.localName + '.')) {
767
+ return true;
768
+ }
769
+ }
770
+ return false;
771
+ }
772
+ /**
773
+ * Resolve a single reference
774
+ */
775
+ resolveOne(ref) {
776
+ // Skip built-in/external references
777
+ if (this.isBuiltInOrExternal(ref)) {
778
+ return null;
779
+ }
780
+ // CFML component paths in inheritance (#1152): `extends="coldbox.system.web.
781
+ // Controller"` names the supertype by its dot-separated path (or `extends=
782
+ // "../base"` by relative file path) — the graph indexes the class under its
783
+ // final segment only, so these die at the fast pre-filter below and never
784
+ // resolved. Handled by a dedicated path-corroborated matcher, gated to
785
+ // inheritance refs only (a dotted `calls` ref is a member-access chain, not
786
+ // a component path). No fallthrough on miss: the full path string can only
787
+ // ever mis-match downstream, and an unresolvable supertype usually lives in
788
+ // an out-of-repo library (mxunit, testbox) — silent beats wrong.
789
+ if ((ref.language === 'cfml' || ref.language === 'cfscript') &&
790
+ (ref.referenceKind === 'extends' || ref.referenceKind === 'implements') &&
791
+ (ref.referenceName.includes('.') || ref.referenceName.includes('/'))) {
792
+ return this.resolveCfmlComponentPath(ref);
793
+ }
794
+ // Fast pre-filter: skip if no symbol with this name exists anywhere
795
+ // AND the name doesn't match a local import. The import escape is
796
+ // necessary because re-export rename chains (`import { login }
797
+ // from './barrel'` where the barrel has `export { signIn as login }
798
+ // from './auth'`) intentionally call a name that has no
799
+ // declaration anywhere — only the renamed upstream symbol does.
800
+ // ArkTS chained-attribute refs carry a leading dot (`.titleStyle`) that
801
+ // routes them to the decorator-gated matcher; the symbol itself is
802
+ // indexed under the bare name, so the existence check strips the dot.
803
+ // Nix static path imports (`import ./x.nix`) name a FILE, not a symbol —
804
+ // they bypass the symbol-existence check and resolve via resolveViaImport.
805
+ const existenceName = ref.language === 'arkts' && ref.referenceName.startsWith('.')
806
+ ? ref.referenceName.slice(1)
807
+ : ref.referenceName;
808
+ if (!(0, import_resolver_1.isNixPathImportRef)(ref) &&
809
+ !this.hasAnyPossibleMatch(existenceName) &&
810
+ !this.matchesAnyImport(ref) &&
811
+ !this.frameworks.some((f) => f.claimsReference?.(ref.referenceName))) {
812
+ return null;
813
+ }
814
+ // Function-as-value refs (#756) get a dedicated, strictly-gated path:
815
+ // import-based resolution first (an imported callback resolves through its
816
+ // import, the most precise cross-file signal), then matchFunctionRef
817
+ // (same-file first, unique-only cross-file, function/method targets only).
818
+ // They never reach the framework or fuzzy strategies below.
819
+ if (ref.referenceKind === 'function_ref') {
820
+ // `this.<member>` values (TS/JS) resolve ONLY against the enclosing
821
+ // class's own members — never a same-named symbol elsewhere.
822
+ if (ref.referenceName.startsWith('this.')) {
823
+ return this.gateLanguage(this.resolveThisMemberFnRef(ref), ref);
824
+ }
825
+ const viaImport = this.gateLanguage((0, import_resolver_1.resolveViaImport)(ref, this.context), ref);
826
+ if (viaImport) {
827
+ const target = this.queries.getNodeById(viaImport.targetNodeId);
828
+ if (target && (target.kind === 'function' || target.kind === 'method')) {
829
+ return viaImport;
830
+ }
831
+ }
832
+ return this.gateLanguage((0, name_matcher_1.matchFunctionRef)(ref, this.context), ref);
833
+ }
834
+ // `invokes` (ADR 0048, sensor fix c/1) resolves ONLY through
835
+ // resolveViaImport's exact-file-path branch — never the framework or
836
+ // name-matching strategies. The reference name is a folded child_process
837
+ // argv string ('git', 'node', a project-relative path): an external
838
+ // command whose name coincides with some project symbol must NOT
839
+ // name-match into an edge (fix (a)'s no-name-match-fallback principle;
840
+ // same rule as #660's PHP include paths below).
841
+ if (ref.referenceKind === 'invokes') {
842
+ return this.gateLanguage((0, import_resolver_1.resolveViaImport)(ref, this.context), ref);
843
+ }
844
+ // JVM FQN imports skip framework/name-matcher: `import com.example.Bar`
845
+ // resolves directly through the qualifiedName index, which is unambiguous
846
+ // even when several `Bar` classes exist in different packages.
847
+ const jvmImport = (0, import_resolver_1.resolveJvmImport)(ref, this.context);
848
+ if (jvmImport)
849
+ return jvmImport;
850
+ // Razor/Blazor: a markup or `@code` type ref resolves through the file's
851
+ // `@using` namespaces (incl. folder `_Imports.razor`). This precisely
852
+ // disambiguates a simple name that exists in several namespaces — e.g.
853
+ // `CatalogBrand` resolving to `BlazorShared.Models::CatalogBrand` (the DTO,
854
+ // which the `.razor` `@using`s) rather than the same-named domain entity.
855
+ if (ref.language === 'razor') {
856
+ const razorResult = this.resolveRazorUsing(ref);
857
+ if (razorResult)
858
+ return razorResult;
859
+ }
860
+ const candidates = [];
861
+ // Strategy 1: Try framework-specific resolution. Cross-language bridges
862
+ // are deliberately preserved (Drupal `routing.yml` → PHP controller, RN
863
+ // JS → native `calls`) — `gateFrameworkLanguage` only drops a type/import
864
+ // edge between two KNOWN families (see its doc), never a `calls` bridge or
865
+ // a config↔code edge.
866
+ for (const framework of this.frameworks) {
867
+ const result = this.gateFrameworkLanguage(framework.resolve(ref, this.context), ref);
868
+ if (result) {
869
+ if (result.confidence >= 0.9)
870
+ return result; // High confidence, return immediately
871
+ candidates.push(result);
872
+ }
873
+ }
874
+ // Strategy 2: Try import-based resolution
875
+ const importResult = this.gateLanguage((0, import_resolver_1.resolveViaImport)(ref, this.context), ref);
876
+ if (importResult) {
877
+ if (importResult.confidence >= 0.9)
878
+ return importResult;
879
+ candidates.push(importResult);
880
+ }
881
+ // PHP include/require paths resolve to files via import resolution only.
882
+ // If that didn't find the file, do NOT fall back to the symbol
883
+ // name-matcher — it would mis-connect e.g. "inc/db.php" to an unrelated
884
+ // db.php elsewhere in the tree (a wrong edge is worse than none, #660).
885
+ // Terraform refs are directory-scoped by language semantics — the
886
+ // framework resolver IS the whole rulebook (`var.X` can never legally
887
+ // bind outside its module directory), so the name-matcher's
888
+ // qualified-name fallback would only ever add wrong cross-module edges.
889
+ // Nix static path imports are file references for the same reason —
890
+ // falling through would let "./x.nix" name-match an unrelated node.
891
+ if ((0, import_resolver_1.isPhpIncludePathRef)(ref) || (0, import_resolver_1.isCobolCopybookRef)(ref) || (0, import_resolver_1.isNixPathImportRef)(ref) || ref.language === 'terraform') {
892
+ return candidates.length > 0
893
+ ? candidates.reduce((best, curr) => curr.confidence > best.confidence ? curr : best)
894
+ : null;
895
+ }
896
+ // Strategy 3: Try name matching
897
+ let nameResult = this.gateLanguage((0, name_matcher_1.matchReference)(ref, this.context), ref);
898
+ // Nix has no ambient cross-file namespace — a callee binds lexically
899
+ // (same file) or through explicit import/callPackage wiring (the import
900
+ // path above). A cross-file name match is wrong by construction: every
901
+ // module `inherit (lib) mkOption`s the same nixpkgs helpers, so the
902
+ // matcher would link each `mkOption` call to whichever file's inherit
903
+ // binding it happened to pick. Same-file matches only.
904
+ if (nameResult) {
905
+ const target = this.queries.getNodeById(nameResult.targetNodeId);
906
+ if (ref.language === 'nix') {
907
+ if (!target || target.filePath !== ref.filePath) {
908
+ nameResult = null;
909
+ }
910
+ }
911
+ else if (target && target.language === 'nix') {
912
+ // The reverse direction is just as impossible: no other language can
913
+ // symbolically call into a .nix binding (interop is eval/CLI, never a
914
+ // linkable symbol) — without this, a Python script's `split()` lands
915
+ // on some module's `split = ...` binding as a low-confidence match.
916
+ nameResult = null;
917
+ }
918
+ else if (
919
+ // Cross-*language* bare-name match between two of {javascript,
920
+ // typescript, python} (ADR 0048). js/ts are the same family
921
+ // (sameLanguageFamily) so a js<->ts hit is NOT gated here — only a
922
+ // genuine language crossing between this set is. Same logic as the
923
+ // nix rule above: Python can't symbolically call a JS/TS binding
924
+ // (interop is subprocess/CLI, never a linkable symbol) — without
925
+ // this, a Python script's bare `read()`/`decode()`/`flush()` landed
926
+ // on whichever unrelated .mjs file's same-named export happened to
927
+ // exist (real FP: `advisory-hook.py -> *.mjs`, resolvedBy
928
+ // exact-match, confidence 0.5). Same-language cross-file matches
929
+ // (js calling js, or import-aware destructuring/receiver-typed
930
+ // calls) are legitimate, existing, regression-tested behavior and
931
+ // are intentionally left alone — file-level corroboration for THOSE
932
+ // false positives is handled downstream by getDependentFilePaths /
933
+ // getDependencyFilePaths filtering on edges.resolvedBy instead.
934
+ target &&
935
+ target.filePath !== ref.filePath &&
936
+ target.language !== ref.language &&
937
+ CROSS_LANGUAGE_GATE_FAMILY.has(ref.language) &&
938
+ CROSS_LANGUAGE_GATE_FAMILY.has(target.language) &&
939
+ !(0, name_matcher_1.sameLanguageFamily)(target.language, ref.language) &&
940
+ nameResult.resolvedBy !== 'file-path') {
941
+ nameResult = null;
942
+ }
943
+ }
944
+ if (nameResult) {
945
+ candidates.push(nameResult);
946
+ }
947
+ if (candidates.length === 0) {
948
+ // Defer a chained static-factory/fluent call the first pass couldn't
949
+ // resolve — its method may live on a supertype the receiver conforms to,
950
+ // resolvable once implements/extends edges exist (the conformance pass).
951
+ if (ref.referenceKind === 'calls' &&
952
+ CHAIN_LANGUAGES.has(ref.language) &&
953
+ CHAIN_SHAPE.test(ref.referenceName)) {
954
+ this.deferredChainRefs.push(ref);
955
+ }
956
+ else if (
957
+ // PHP `$this->prop->method()` (encoded `this->prop.method`): its method
958
+ // may live on the property's declared supertype, resolvable only once
959
+ // implements/extends edges exist — defer to the same conformance pass.
960
+ ref.referenceKind === 'calls' &&
961
+ ref.language === 'php' &&
962
+ PHP_PROP_SHAPE.test(ref.referenceName)) {
963
+ this.deferredChainRefs.push(ref);
964
+ }
965
+ return null;
966
+ }
967
+ // Return highest confidence candidate
968
+ return candidates.reduce((best, curr) => curr.confidence > best.confidence ? curr : best);
969
+ }
970
+ /**
971
+ * Create edges from resolved references
972
+ */
973
+ createEdges(resolved) {
974
+ return resolved.map((ref) => {
975
+ // `function_ref` (#756) is internal-only: it persists as a `references`
976
+ // edge (the registration site depends on the callback), distinguishable
977
+ // by metadata.resolvedBy === 'function-ref'. callers/impact already
978
+ // traverse `references`, so registration sites surface with no
979
+ // graph-layer changes.
980
+ let kind = ref.original.referenceKind === 'function_ref' ? 'references' : ref.original.referenceKind;
981
+ // Promote "extends" to "implements" when a class/struct targets an interface
982
+ if (kind === 'extends') {
983
+ const targetNode = this.queries.getNodeById(ref.targetNodeId);
984
+ if (targetNode && (targetNode.kind === 'interface' || targetNode.kind === 'protocol')) {
985
+ const sourceNode = this.queries.getNodeById(ref.original.fromNodeId);
986
+ if (sourceNode && sourceNode.kind !== 'interface' && sourceNode.kind !== 'protocol') {
987
+ kind = 'implements';
988
+ }
989
+ }
990
+ }
991
+ // Promote "calls" to "instantiates" when the resolved target is a
992
+ // class/struct. Languages without a `new` keyword (Python, Ruby)
993
+ // express instantiation as `Foo()` — extraction can't tell that
994
+ // apart from a function call without symbol info, but resolution
995
+ // can: if `Foo` resolves to a class, the call IS an instantiation.
996
+ if (kind === 'calls') {
997
+ const targetNode = this.queries.getNodeById(ref.targetNodeId);
998
+ if (targetNode && (targetNode.kind === 'class' || targetNode.kind === 'struct')) {
999
+ kind = 'instantiates';
1000
+ }
1001
+ }
1002
+ return {
1003
+ source: ref.original.fromNodeId,
1004
+ target: ref.targetNodeId,
1005
+ kind,
1006
+ line: ref.original.line,
1007
+ column: ref.original.column,
1008
+ confidence: ref.confidence,
1009
+ resolvedBy: ref.resolvedBy,
1010
+ metadata: {
1011
+ confidence: ref.confidence,
1012
+ resolvedBy: ref.resolvedBy,
1013
+ // The ORIGINAL reference text (and kind, when edge-kind promotion
1014
+ // rewrote it — calls→instantiates, extends→implements,
1015
+ // function_ref→references). If this edge's target is later removed
1016
+ // by a re-index, the edge is resurrected as exactly this ref and
1017
+ // re-resolved (#1240 removal case) — a faithful resurrection, so
1018
+ // re-resolution can never bind anywhere a full re-index wouldn't.
1019
+ // Reconstruction from the target node's name instead would strip
1020
+ // receiver/qualifier context (`h.greet` → `greet`) and risk a
1021
+ // wrong rebind; edges without refName (pre-#1240, synthesized) are
1022
+ // deliberately NOT resurrected for the same reason.
1023
+ refName: ref.original.referenceName,
1024
+ ...(ref.original.referenceKind !== kind ? { refKind: ref.original.referenceKind } : {}),
1025
+ // Uniform marker for function-as-value edges (#756), regardless of
1026
+ // which strategy resolved them (import vs matchFunctionRef) — lets
1027
+ // tooling label "callback registration" and lets validation diff
1028
+ // exactly the edges this feature added.
1029
+ ...(ref.original.referenceKind === 'function_ref' ? { fnRef: true } : {}),
1030
+ },
1031
+ };
1032
+ });
1033
+ }
1034
+ /**
1035
+ * Split resolved refs into rows deletable by id and hand-built refs that
1036
+ * must fall back to the key-tuple delete. Rows loaded from the database
1037
+ * carry their row id and are deleted by exactly that id; the key tuple
1038
+ * omits line/col, so it also removes SIBLING rows — the same caller calling
1039
+ * the same callee at other lines — that a later batch hadn't attempted yet:
1040
+ * when a batch boundary split a caller's same-named call sites, the later
1041
+ * sites' edges were silently never created (#1269).
1042
+ */
1043
+ static partitionResolvedCleanup(resolved) {
1044
+ const rowIds = [];
1045
+ const legacyKeys = [];
1046
+ for (const r of resolved) {
1047
+ if (r.original.rowId != null)
1048
+ rowIds.push(r.original.rowId);
1049
+ else
1050
+ legacyKeys.push({
1051
+ fromNodeId: r.original.fromNodeId,
1052
+ referenceName: r.original.referenceName,
1053
+ referenceKind: r.original.referenceKind,
1054
+ });
1055
+ }
1056
+ return { rowIds, legacyKeys };
1057
+ }
1058
+ /**
1059
+ * Same row-id precision for parking unresolvable refs as status='failed'
1060
+ * (#1240): the key-tuple fallback would flip same-key sibling rows in later
1061
+ * batches to 'failed' before they were ever attempted, and resolution
1062
+ * outcome can differ per call site (receiver-type inference reads the
1063
+ * ref's line), so a sibling must not inherit this row's failure (#1269).
1064
+ */
1065
+ static partitionFailedCleanup(unresolved) {
1066
+ const byRowId = [];
1067
+ const legacyKeys = [];
1068
+ for (const r of unresolved) {
1069
+ if (r.rowId != null)
1070
+ byRowId.push({ rowId: r.rowId, referenceName: r.referenceName });
1071
+ else
1072
+ legacyKeys.push({
1073
+ fromNodeId: r.fromNodeId,
1074
+ referenceName: r.referenceName,
1075
+ referenceKind: r.referenceKind,
1076
+ });
1077
+ }
1078
+ return { byRowId, legacyKeys };
1079
+ }
1080
+ /**
1081
+ * Resolve and persist edges to database
1082
+ */
1083
+ resolveAndPersist(unresolvedRefs, onProgress) {
1084
+ const result = this.resolveAll(unresolvedRefs, onProgress);
1085
+ // Create edges from resolved references
1086
+ const edges = this.createEdges(result.resolved);
1087
+ // Insert edges into database
1088
+ if (edges.length > 0) {
1089
+ this.queries.insertEdges(edges);
1090
+ }
1091
+ // Clean up resolved refs from unresolved_refs table so metrics are accurate
1092
+ if (result.resolved.length > 0) {
1093
+ const { rowIds, legacyKeys } = ReferenceResolver.partitionResolvedCleanup(result.resolved);
1094
+ this.queries.deleteReferencesByRowIds(rowIds);
1095
+ this.queries.deleteSpecificResolvedReferences(legacyKeys);
1096
+ }
1097
+ // Park unresolvable refs as status='failed' — parity with
1098
+ // resolveAndPersistBatched. Deleting them was wrong (#1240): a ref whose
1099
+ // own file never changes is otherwise gone forever, so when a DIFFERENT
1100
+ // file later gains the export/symbol that would satisfy it, no sync can
1101
+ // recreate the edge — only a full re-index. Failed rows are excluded from
1102
+ // the pending readers, which preserves the #1187 orphan sweep's
1103
+ // invariant in status form: after a COMPLETED pass nothing it processed
1104
+ // is still 'pending', so any pending row at rest belongs to an
1105
+ // interrupted run and the sweep can key off the pending count.
1106
+ if (result.unresolved.length > 0) {
1107
+ const { byRowId, legacyKeys } = ReferenceResolver.partitionFailedCleanup(result.unresolved);
1108
+ this.queries.markReferencesFailedByRowIds(byRowId);
1109
+ this.queries.markReferencesFailed(legacyKeys);
1110
+ }
1111
+ return result;
1112
+ }
1113
+ /**
1114
+ * Yielding counterpart of {@link resolveAndPersist} for a caller-supplied
1115
+ * ref list — used by sync's failed-ref retry pass (#1240). Same persistence
1116
+ * semantics: resolved refs become edges and their rows are deleted;
1117
+ * still-unresolvable refs are (re-)marked failed (a no-op for rows already
1118
+ * in that status). Yields per-ref because sync can run on the daemon's
1119
+ * liveness-watchdog thread (#850/#1091) and a retry set is unbounded when
1120
+ * a large edit lands many popular symbol names at once.
1121
+ */
1122
+ async resolveAndPersistListYielding(refs) {
1123
+ const maybeYield = (0, cooperative_yield_1.createYielder)();
1124
+ const result = await this.resolveBatchYielding(refs, maybeYield);
1125
+ const PERSIST_CHUNK = 1000;
1126
+ const edges = this.createEdges(result.resolved);
1127
+ for (let i = 0; i < edges.length; i += PERSIST_CHUNK) {
1128
+ this.queries.insertEdges(edges.slice(i, i + PERSIST_CHUNK));
1129
+ await maybeYield();
1130
+ }
1131
+ const resolvedCleanup = ReferenceResolver.partitionResolvedCleanup(result.resolved);
1132
+ for (let i = 0; i < resolvedCleanup.rowIds.length; i += PERSIST_CHUNK) {
1133
+ this.queries.deleteReferencesByRowIds(resolvedCleanup.rowIds.slice(i, i + PERSIST_CHUNK));
1134
+ await maybeYield();
1135
+ }
1136
+ for (let i = 0; i < resolvedCleanup.legacyKeys.length; i += PERSIST_CHUNK) {
1137
+ this.queries.deleteSpecificResolvedReferences(resolvedCleanup.legacyKeys.slice(i, i + PERSIST_CHUNK));
1138
+ await maybeYield();
1139
+ }
1140
+ const failedCleanup = ReferenceResolver.partitionFailedCleanup(result.unresolved);
1141
+ for (let i = 0; i < failedCleanup.byRowId.length; i += PERSIST_CHUNK) {
1142
+ this.queries.markReferencesFailedByRowIds(failedCleanup.byRowId.slice(i, i + PERSIST_CHUNK));
1143
+ await maybeYield();
1144
+ }
1145
+ for (let i = 0; i < failedCleanup.legacyKeys.length; i += PERSIST_CHUNK) {
1146
+ this.queries.markReferencesFailed(failedCleanup.legacyKeys.slice(i, i + PERSIST_CHUNK));
1147
+ await maybeYield();
1148
+ }
1149
+ return result;
1150
+ }
1151
+ /**
1152
+ * Second resolution pass for chained static-factory / fluent calls whose
1153
+ * chained method is defined on a SUPERTYPE the receiver's type conforms to —
1154
+ * a protocol-extension / inherited / default-interface method (#750). The
1155
+ * first pass can't resolve these because `implements`/`extends` edges aren't
1156
+ * built yet; this runs AFTER edges are persisted, so `context.getSupertypes`
1157
+ * (and the conformance fallback in resolveMethodOnType) can walk them.
1158
+ *
1159
+ * Operates only on the leftover unresolved refs that have the `inner().method`
1160
+ * chain shape, for the dotted-chain languages — a small set — and is idempotent
1161
+ * (re-resolving an already-resolved ref is a no-op since it's been deleted).
1162
+ * Returns the number of newly-created edges.
1163
+ */
1164
+ async resolveChainedCallsViaConformance() {
1165
+ const deferred = this.deferredChainRefs;
1166
+ this.deferredChainRefs = [];
1167
+ if (deferred.length === 0)
1168
+ return 0;
1169
+ // Read fresh edges (the main pass built the implements/extends edges after
1170
+ // these refs were deferred). matchDottedCallChain now resolves a method on a
1171
+ // supertype via context.getSupertypes -> resolveMethodOnType's conformance walk.
1172
+ this.clearCaches();
1173
+ // This post-pass runs synchronously on the indexer's main thread; yield
1174
+ // periodically so the #850 liveness watchdog heartbeat can fire on a repo
1175
+ // with many deferred chained calls (#1091).
1176
+ const maybeYield = (0, cooperative_yield_1.createYielder)();
1177
+ const resolved = [];
1178
+ for (const ref of deferred) {
1179
+ // PHP `this->prop.method` resolves via matchMethodCall (declared-type
1180
+ // inference + resolveMethodOnType conformance walk); `::`-receiver
1181
+ // languages (Rust) split on `::` (matchScopedCallChain); other
1182
+ // dotted-receiver languages on `.` (matchDottedCallChain).
1183
+ const chainMatch = (ref.language === 'php' && PHP_PROP_SHAPE.test(ref.referenceName))
1184
+ ? (0, name_matcher_1.matchMethodCall)(ref, this.context)
1185
+ : SCOPED_CHAIN_LANGUAGES.has(ref.language)
1186
+ ? (0, name_matcher_1.matchScopedCallChain)(ref, this.context)
1187
+ : (0, name_matcher_1.matchDottedCallChain)(ref, this.context);
1188
+ const match = this.gateLanguage(chainMatch, ref);
1189
+ if (match)
1190
+ resolved.push(match);
1191
+ await maybeYield();
1192
+ }
1193
+ if (resolved.length === 0)
1194
+ return 0;
1195
+ const edges = this.createEdges(resolved);
1196
+ if (edges.length > 0) {
1197
+ this.queries.insertEdges(edges);
1198
+ this.clearCaches();
1199
+ }
1200
+ return edges.length;
1201
+ }
1202
+ /**
1203
+ * Resolve one batch with a yield checkpoint between EVERY ref so the #850
1204
+ * liveness heartbeat can fire on a slow/dense batch (#1091). The checkpoint
1205
+ * granularity is per-ref — not per-N-refs — because per-ref cost is unbounded
1206
+ * in the worst case (a collision-heavy method name whose candidate set misses
1207
+ * the LRU re-fetches tens of thousands of rows): any fixed N multiplies that
1208
+ * worst case into the watchdog window, which is how v1.2.0 still got killed
1209
+ * at "Resolving refs" on large Java monorepos (#1122). `maybeYield()` is a
1210
+ * ~ns time check when under budget, so per-ref checkpoints cost nothing.
1211
+ * Behaviourally identical to `resolveAll(batch)`: `warmCaches()` is
1212
+ * idempotent (guarded) and `resolveOne` is independent per ref, so yielding
1213
+ * between refs changes only timing, never which edges get created.
1214
+ */
1215
+ async resolveBatchYielding(batch, maybeYield) {
1216
+ this.warmCaches();
1217
+ const resolved = [];
1218
+ const unresolved = [];
1219
+ const byMethod = {};
1220
+ for (const raw of batch) {
1221
+ const ref = {
1222
+ fromNodeId: raw.fromNodeId,
1223
+ referenceName: raw.referenceName,
1224
+ referenceKind: raw.referenceKind,
1225
+ line: raw.line,
1226
+ column: raw.column,
1227
+ filePath: raw.filePath || this.getFilePathFromNodeId(raw.fromNodeId),
1228
+ language: raw.language || this.getLanguageFromNodeId(raw.fromNodeId),
1229
+ rowId: raw.rowId,
1230
+ };
1231
+ const result = this.resolveOne(ref);
1232
+ if (result) {
1233
+ resolved.push(result);
1234
+ byMethod[result.resolvedBy] = (byMethod[result.resolvedBy] || 0) + 1;
1235
+ }
1236
+ else {
1237
+ unresolved.push(ref);
1238
+ }
1239
+ // Fast-path the per-ref yield check: awaiting the async no-op costs a
1240
+ // microtask hop per ref, which dominates at ~10⁵ refs (see MaybeYield).
1241
+ const y = maybeYield();
1242
+ if (y)
1243
+ await y;
1244
+ }
1245
+ return {
1246
+ resolved,
1247
+ unresolved,
1248
+ stats: {
1249
+ total: batch.length,
1250
+ resolved: resolved.length,
1251
+ unresolved: unresolved.length,
1252
+ byMethod,
1253
+ },
1254
+ };
1255
+ }
1256
+ /**
1257
+ * Resolve a list of refs and return everything the ADMISSION side needs to
1258
+ * persist the outcome: resolutions, failures, the deferred post-pass refs
1259
+ * this run produced (drained, so the caller owns routing them), and stats.
1260
+ * This is the resolver-worker entry point — it runs the exact per-ref loop
1261
+ * of resolveBatchYielding, minus the main-thread yields (worker threads have
1262
+ * no watchdog heartbeat to starve). Results are in input order.
1263
+ */
1264
+ resolveListForAdmission(refs) {
1265
+ this.warmCaches();
1266
+ const resolved = [];
1267
+ const unresolved = [];
1268
+ const byMethod = {};
1269
+ for (const raw of refs) {
1270
+ const ref = {
1271
+ fromNodeId: raw.fromNodeId,
1272
+ referenceName: raw.referenceName,
1273
+ referenceKind: raw.referenceKind,
1274
+ line: raw.line,
1275
+ column: raw.column,
1276
+ filePath: raw.filePath || this.getFilePathFromNodeId(raw.fromNodeId),
1277
+ language: raw.language || this.getLanguageFromNodeId(raw.fromNodeId),
1278
+ rowId: raw.rowId,
1279
+ };
1280
+ const result = this.resolveOne(ref);
1281
+ if (result) {
1282
+ resolved.push(result);
1283
+ byMethod[result.resolvedBy] = (byMethod[result.resolvedBy] || 0) + 1;
1284
+ }
1285
+ else {
1286
+ unresolved.push(ref);
1287
+ }
1288
+ }
1289
+ return {
1290
+ resolved,
1291
+ unresolved,
1292
+ deferredChain: this.deferredChainRefs.splice(0),
1293
+ deferredThisMember: this.deferredThisMemberRefs.splice(0),
1294
+ byMethod,
1295
+ };
1296
+ }
1297
+ /**
1298
+ * The resolver's live ResolutionContext — resolver-pool workers use it to
1299
+ * run synthesis passes against their own read-only connection.
1300
+ */
1301
+ getResolutionContext() {
1302
+ return this.context;
1303
+ }
1304
+ /**
1305
+ * Re-queue deferred post-pass refs produced by resolver workers, preserving
1306
+ * their admission order so resolveChainedCallsViaConformance /
1307
+ * resolveDeferredThisMemberRefs process them exactly as the sequential path
1308
+ * would have.
1309
+ */
1310
+ appendDeferredFromWorkers(deferredChain, deferredThisMember) {
1311
+ this.deferredChainRefs.push(...deferredChain);
1312
+ this.deferredThisMemberRefs.push(...deferredThisMember);
1313
+ }
1314
+ /**
1315
+ * Resolve and persist in batches to keep memory bounded.
1316
+ * Processes unresolved references in chunks, persisting edges and cleaning
1317
+ * up resolved refs after each batch to avoid accumulating large arrays.
1318
+ */
1319
+ async resolveAndPersistBatched(onProgress, batchSize = 5000, onSynthesisProgress,
1320
+ // When provided, big batches fan out across a read-only resolver-worker
1321
+ // pool with results admitted in canonical order (see resolver-pool.ts).
1322
+ // Sequential fallback on any pool failure. CODEGRAPH_NO_PARALLEL_RESOLVE=1
1323
+ // disables entirely. bulkEdgeLoad hooks (when provided) bracket the batch
1324
+ // loop with drop/recreate of the non-unique edge indexes on big runs —
1325
+ // see DatabaseConnection.beginBulkEdgeLoad.
1326
+ parallel) {
1327
+ // Resolution runs on the indexer's MAIN thread, and the #850 liveness
1328
+ // watchdog SIGKILLs a process whose event loop stalls past its window (60s
1329
+ // by default). A single dense batch's resolveAll — or the synthesis pass
1330
+ // below — can exceed that on a large repo, killing a VALID in-progress index
1331
+ // (#1091). A shared yielder lets both give the watchdog heartbeat a regular
1332
+ // window to fire; see ./cooperative-yield.
1333
+ const maybeYield = (0, cooperative_yield_1.createYielder)();
1334
+ await this.warmCachesYielding(maybeYield);
1335
+ const total = this.queries.getUnresolvedReferencesCount();
1336
+ let processed = 0;
1337
+ const aggregateStats = {
1338
+ total: 0,
1339
+ resolved: 0,
1340
+ unresolved: 0,
1341
+ byMethod: {},
1342
+ };
1343
+ // Parallel pool, started immediately but never awaited up front: early
1344
+ // batches run sequentially while the workers boot (module load + readonly
1345
+ // DB open + framework detect + cache warm ≈ hundreds of ms), and the loop
1346
+ // switches to fan-out the moment the pool reports ready — so pool boot
1347
+ // costs zero wall-clock. Any failure downgrades to sequential permanently.
1348
+ let pool = null;
1349
+ let poolReady = false;
1350
+ const tPoolStart = Date.now();
1351
+ if (parallel && total >= (0, resolver_pool_1.minRefsForPool)()) {
1352
+ pool = resolver_pool_1.ResolverPool.tryCreate(parallel.dbPath, this.projectRoot);
1353
+ pool?.ready().then(() => {
1354
+ poolReady = true;
1355
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
1356
+ console.error(`[pool-timing] pool ready after ${Date.now() - tPoolStart}ms`);
1357
+ }, () => { void pool?.destroy().catch(() => undefined); pool = null; });
1358
+ }
1359
+ // Process in PIPELINED batches (double-buffer). The enumeration is the
1360
+ // head of the pending set in rowid order; every ref a persisted batch
1361
+ // processed leaves the pending set (resolved rows are deleted,
1362
+ // unresolvable ones flip to status='failed'), shifting the remaining
1363
+ // pending rows forward.
1364
+ let prevRemaining = Number.POSITIVE_INFINITY;
1365
+ // Begin one batch: fan out to the pool when it's ready and the batch is
1366
+ // big enough — workers then resolve batch k+1 WHILE the main thread
1367
+ // persists batch k (persist measured at ~58% of resolution wall on a
1368
+ // 255k-ref repo, all of it previously spent with the pool idle).
1369
+ // Sequential batches stay lazy: they run on the main thread at settle
1370
+ // time, where an early start would only contend with the persist.
1371
+ const beginBatch = (batch) => {
1372
+ if (pool && poolReady && resolver_pool_1.ResolverPool.worthParallel(batch.length)) {
1373
+ return {
1374
+ mode: 'pool',
1375
+ settled: pool.resolveBatch(batch).then((out) => ({ ok: true, out }), (err) => ({ ok: false, err })),
1376
+ };
1377
+ }
1378
+ return { mode: 'seq' };
1379
+ };
1380
+ // Settle an in-flight batch to a ResolutionResult. Deferred post-pass refs
1381
+ // are appended HERE, in loop order — never inside the fan-out promise — so
1382
+ // admission order stays exactly the sequential order even while a later
1383
+ // batch resolves concurrently. A pool failure downgrades to sequential
1384
+ // permanently and re-resolves this batch on the main thread.
1385
+ const settleBatch = async (inFlight, batch) => {
1386
+ if (inFlight.mode === 'pool') {
1387
+ const settled = await inFlight.settled;
1388
+ if (settled.ok) {
1389
+ this.appendDeferredFromWorkers(settled.out.deferredChain, settled.out.deferredThisMember);
1390
+ return {
1391
+ resolved: settled.out.resolved,
1392
+ unresolved: settled.out.unresolved,
1393
+ stats: {
1394
+ total: batch.length,
1395
+ resolved: settled.out.resolved.length,
1396
+ unresolved: settled.out.unresolved.length,
1397
+ byMethod: settled.out.byMethod,
1398
+ },
1399
+ };
1400
+ }
1401
+ (0, errors_1.logDebug)('Parallel resolution failed; falling back to sequential', {
1402
+ error: settled.err instanceof Error ? settled.err.message : String(settled.err),
1403
+ });
1404
+ if (pool)
1405
+ await pool.destroy().catch(() => undefined);
1406
+ pool = null;
1407
+ }
1408
+ return this.resolveBatchYielding(batch, maybeYield);
1409
+ };
1410
+ // Bulk edge load: on big runs, drop the non-unique edge indexes for the
1411
+ // duration of the batch loop (the identity index stays — OR IGNORE dedup
1412
+ // and the source-keyed supertype-walk reads both live on it). Recreated in
1413
+ // the inner finally BEFORE synthesis, whose passes read kind-keyed.
1414
+ // Measured on a 224k-edge resolution set: insert 2.8s → 1.1s + 0.3s
1415
+ // recreate. Same ref-count gate as the pool so small syncs never pay the
1416
+ // recreate cost.
1417
+ let bulkEdgesActive = false;
1418
+ if (parallel?.bulkEdgeLoad && total >= (0, resolver_pool_1.minRefsForPool)()) {
1419
+ try {
1420
+ parallel.bulkEdgeLoad.begin();
1421
+ bulkEdgesActive = true;
1422
+ }
1423
+ catch { /* keep the indexes; inserts just pay the per-row maintenance */ }
1424
+ }
1425
+ try {
1426
+ try {
1427
+ let batch = this.queries.getUnresolvedReferencesBatch(0, batchSize);
1428
+ let inFlight = batch.length > 0 ? beginBatch(batch) : null;
1429
+ while (batch.length > 0 && inFlight) {
1430
+ // Prefetch the NEXT batch before this one persists: this batch's rows
1431
+ // are still pending (nothing has mutated the table since they were
1432
+ // read), so skipping exactly batch.length rows in the same rowid
1433
+ // enumeration yields the following batch.
1434
+ const nextBatch = this.queries.getUnresolvedReferencesBatch(batch.length, batchSize);
1435
+ const tBatch = Date.now();
1436
+ const result = await settleBatch(inFlight, batch);
1437
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
1438
+ console.error(`[pool-timing] batch ${inFlight.mode}: ${batch.length} refs in ${Date.now() - tBatch}ms`);
1439
+ // Persist in bounded sub-transactions with yields between: a whole
1440
+ // batch's edge insert / keyed deletes are otherwise one solid
1441
+ // synchronous span each on a multi-GB index, sitting BETWEEN the
1442
+ // per-ref yields — the last unyielded stretch of the resolution loop.
1443
+ // Crash semantics are unchanged (already several transactions): edges
1444
+ // land before their refs are deleted, so a kill mid-way re-resolves
1445
+ // the remainder idempotently on the next run/sweep (#1187).
1446
+ const PERSIST_CHUNK = 1000;
1447
+ const tPersist = Date.now();
1448
+ // Persist edges BEFORE fanning out the next batch: later batches read
1449
+ // this batch's edges — resolveMethodOnType walks supertype chains over
1450
+ // `extends`/`implements` edges that earlier batches resolved, so a
1451
+ // receiver typed as a subclass only reaches a method declared on its
1452
+ // base class if those edges are visible. (Validated on dubbo: fanning
1453
+ // out first downgraded exactly those supertype-method resolutions from
1454
+ // the 0.9 typed-receiver path to the 0.65 word-overlap fallback.)
1455
+ const edges = this.createEdges(result.resolved);
1456
+ for (let i = 0; i < edges.length; i += PERSIST_CHUNK) {
1457
+ this.queries.insertEdges(edges.slice(i, i + PERSIST_CHUNK));
1458
+ await maybeYield();
1459
+ }
1460
+ // NOW fan the next batch out — workers see exactly the edge state the
1461
+ // sequential baseline would (every batch ≤ this one committed), while
1462
+ // the main thread spends the REST of the persist (ref deletes + failed
1463
+ // parking below) overlapped with their resolution — the double-buffer.
1464
+ const nextInFlight = nextBatch.length > 0 ? beginBatch(nextBatch) : null;
1465
+ // Clean up resolved refs so they don't appear in the next batch —
1466
+ // by row id, so a same-key sibling ref in a LATER batch (same caller
1467
+ // calling the same callee at another line) is left pending for its own
1468
+ // attempt instead of being swept out with this batch's rows (#1269).
1469
+ const resolvedCleanup = ReferenceResolver.partitionResolvedCleanup(result.resolved);
1470
+ for (let i = 0; i < resolvedCleanup.rowIds.length; i += PERSIST_CHUNK) {
1471
+ this.queries.deleteReferencesByRowIds(resolvedCleanup.rowIds.slice(i, i + PERSIST_CHUNK));
1472
+ await maybeYield();
1473
+ }
1474
+ for (let i = 0; i < resolvedCleanup.legacyKeys.length; i += PERSIST_CHUNK) {
1475
+ this.queries.deleteSpecificResolvedReferences(resolvedCleanup.legacyKeys.slice(i, i + PERSIST_CHUNK));
1476
+ await maybeYield();
1477
+ }
1478
+ // Park unresolvable refs from this batch as status='failed' so they
1479
+ // leave the pending set (the batch reader and non-progress guard below
1480
+ // only see pending rows) but stay retryable when a later sync adds a
1481
+ // symbol that could satisfy them (#1240).
1482
+ const failedCleanup = ReferenceResolver.partitionFailedCleanup(result.unresolved);
1483
+ for (let i = 0; i < failedCleanup.byRowId.length; i += PERSIST_CHUNK) {
1484
+ this.queries.markReferencesFailedByRowIds(failedCleanup.byRowId.slice(i, i + PERSIST_CHUNK));
1485
+ await maybeYield();
1486
+ }
1487
+ for (let i = 0; i < failedCleanup.legacyKeys.length; i += PERSIST_CHUNK) {
1488
+ this.queries.markReferencesFailed(failedCleanup.legacyKeys.slice(i, i + PERSIST_CHUNK));
1489
+ await maybeYield();
1490
+ }
1491
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
1492
+ console.error(`[pool-timing] batch persist: ${Date.now() - tPersist}ms`);
1493
+ // Aggregate stats
1494
+ aggregateStats.total += result.stats.total;
1495
+ aggregateStats.resolved += result.stats.resolved;
1496
+ aggregateStats.unresolved += result.stats.unresolved;
1497
+ for (const [method, count] of Object.entries(result.stats.byMethod)) {
1498
+ aggregateStats.byMethod[method] = (aggregateStats.byMethod[method] || 0) + count;
1499
+ }
1500
+ processed += batch.length;
1501
+ onProgress?.(processed, total);
1502
+ // Yield so progress UI can render between batches
1503
+ await new Promise(resolve => setImmediate(resolve));
1504
+ // NOTE: there used to be an extra early break here when a batch resolved
1505
+ // nothing (`result.unresolved.length === batch.length`). That was wrong:
1506
+ // an all-unresolvable batch still DELETES its rows (progress), yet the
1507
+ // break abandoned every batch after it in the same run — on a repo whose
1508
+ // first 5000 refs are all external/stdlib calls, resolution stopped at
1509
+ // batch one and left the rest of the table as permanent orphans (#1187).
1510
+ // The count-based guard below catches the true no-progress case.
1511
+ // Non-progress guard (defense-in-depth). Each iteration enumerates from
1512
+ // the head of the pending set, so the PENDING population MUST shrink
1513
+ // every iteration — resolved refs are deleted and unresolvable ones are
1514
+ // marked failed above, and both leave the pending set the batch reader
1515
+ // sees. If it didn't shrink, a resolver returned a match whose
1516
+ // `original.referenceName` differs from the stored row, so the keyed
1517
+ // delete/update no-ops, and we'd re-read + re-resolve + re-insert the
1518
+ // same rows forever (the runaway that grew a 99-file repo to 5M edges /
1519
+ // 1.4 GB before the Go-fallback fix). Stop rather than grow the graph
1520
+ // without bound. (An in-flight prefetched batch is abandoned unsettled —
1521
+ // fan-out has no side effects until settleBatch appends its results.)
1522
+ const remaining = this.queries.getUnresolvedReferencesCount();
1523
+ if (remaining >= prevRemaining)
1524
+ break;
1525
+ prevRemaining = remaining;
1526
+ // Advance the pipeline: the prefetched batch (already fanned out when
1527
+ // the pool is on) becomes the current one.
1528
+ batch = nextBatch;
1529
+ inFlight = nextInFlight;
1530
+ }
1531
+ }
1532
+ finally {
1533
+ // Recreate the edge indexes BEFORE synthesis (kind-keyed reads) and on
1534
+ // any error path. A crash before this line is healed by the next
1535
+ // DatabaseConnection open (schema.sql re-applies IF NOT EXISTS).
1536
+ if (bulkEdgesActive) {
1537
+ const tIdx = Date.now();
1538
+ await parallel.bulkEdgeLoad.end();
1539
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
1540
+ console.error(`[phase-timing] edge-index-recreate: ${Date.now() - tIdx}ms`);
1541
+ }
1542
+ }
1543
+ // Dynamic-edge synthesis: now that all base `calls` edges are persisted,
1544
+ // synthesize observer/callback dispatch edges (dispatcher → registered
1545
+ // callbacks) that static parsing leaves out. Best-effort — never fail the
1546
+ // index on it. The pool (when it survived resolution) is REUSED to fan the
1547
+ // independent passes across its read-only workers — that's why its destroy
1548
+ // lives in the finally below, after synthesis, not at the end of the batch
1549
+ // loop. See docs/design/callback-edge-synthesis.md.
1550
+ const tSynth = Date.now();
1551
+ try {
1552
+ aggregateStats.byMethod['callback-synthesis'] = await (0, callback_synthesizer_1.synthesizeCallbackEdges)(this.queries, this.context, onSynthesisProgress, pool);
1553
+ }
1554
+ catch {
1555
+ // synthesis is additive and optional; ignore failures
1556
+ }
1557
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
1558
+ console.error(`[phase-timing] callback-synthesis: ${Date.now() - tSynth}ms`);
1559
+ }
1560
+ finally {
1561
+ if (pool)
1562
+ await pool.destroy().catch(() => undefined);
1563
+ }
1564
+ return {
1565
+ resolved: [],
1566
+ unresolved: [],
1567
+ stats: aggregateStats,
1568
+ };
1569
+ }
1570
+ /**
1571
+ * Get detected frameworks
1572
+ */
1573
+ getDetectedFrameworks() {
1574
+ return this.frameworks.map((f) => f.name);
1575
+ }
1576
+ /**
1577
+ * Check if reference is to a built-in or external symbol
1578
+ */
1579
+ isBuiltInOrExternal(ref) {
1580
+ const name = ref.referenceName;
1581
+ const isJsTs = ref.language === 'typescript' || ref.language === 'javascript'
1582
+ || ref.language === 'tsx' || ref.language === 'jsx' || ref.language === 'arkts';
1583
+ // JavaScript/TypeScript built-ins
1584
+ if (isJsTs && JS_BUILT_INS.has(name)) {
1585
+ return true;
1586
+ }
1587
+ // ArkTS resource-reference intrinsics — `$r('app.string.x')` /
1588
+ // `$rawfile('x.png')` are framework-provided and appear dozens of times
1589
+ // per UI file; without this they can resolve to a stray same-named
1590
+ // symbol (e.g. a checked-in hvigor wrapper's `$r`).
1591
+ if (ref.language === 'arkts' && (name === '$r' || name === '$rawfile')) {
1592
+ return true;
1593
+ }
1594
+ // Common JS/TS library calls (console.log, Math.floor, JSON.parse)
1595
+ if (isJsTs && (name.startsWith('console.') || name.startsWith('Math.') || name.startsWith('JSON.'))) {
1596
+ return true;
1597
+ }
1598
+ // React hooks from React itself
1599
+ if (isJsTs && REACT_HOOKS.has(name)) {
1600
+ return true;
1601
+ }
1602
+ // Python built-ins (bare calls only — dotted calls like console.print are method calls)
1603
+ if (ref.language === 'python' && PYTHON_BUILT_INS.has(name)) {
1604
+ return true;
1605
+ }
1606
+ // Python built-in method calls (e.g., list.extend, dict.update)
1607
+ if (ref.language === 'python') {
1608
+ const dotIdx = name.indexOf('.');
1609
+ if (dotIdx > 0) {
1610
+ const receiver = name.substring(0, dotIdx);
1611
+ const method = name.substring(dotIdx + 1);
1612
+ // Filter calls on built-in types (list.append, dict.update, etc.)
1613
+ if (PYTHON_BUILT_IN_TYPES.has(receiver)) {
1614
+ return true;
1615
+ }
1616
+ // Filter built-in methods on non-class receivers
1617
+ // (e.g., items.append where items is a local list variable)
1618
+ // But allow if the capitalized receiver matches a known codebase class
1619
+ if (PYTHON_BUILT_IN_METHODS.has(method)) {
1620
+ const capitalized = receiver.charAt(0).toUpperCase() + receiver.slice(1);
1621
+ if (!this.knownNames?.has(capitalized)) {
1622
+ return true;
1623
+ }
1624
+ }
1625
+ }
1626
+ // A bare name colliding with a builtin method (index, get, update, count…)
1627
+ // is only a builtin when NOTHING in the codebase declares it. A declared
1628
+ // symbol with that exact name — e.g. a Flask/FastAPI view `def index()` or
1629
+ // `def get()` — is a real reference target. Mirrors the knownNames guard on
1630
+ // the dotted branch above; without it, every handler named after a builtin
1631
+ // method silently loses its route→handler edge.
1632
+ if (PYTHON_BUILT_IN_METHODS.has(name) && !this.knownNames?.has(name)) {
1633
+ return true;
1634
+ }
1635
+ }
1636
+ // Go standard library packages — refs like "fmt.Println", "http.ListenAndServe", etc.
1637
+ if (ref.language === 'go') {
1638
+ const dotIdx = name.indexOf('.');
1639
+ if (dotIdx > 0) {
1640
+ const pkg = name.substring(0, dotIdx);
1641
+ if (GO_STDLIB_PACKAGES.has(pkg)) {
1642
+ return true;
1643
+ }
1644
+ }
1645
+ if (GO_BUILT_INS.has(name)) {
1646
+ return true;
1647
+ }
1648
+ }
1649
+ // Pascal/Delphi built-ins and standard library units
1650
+ if (ref.language === 'pascal') {
1651
+ if (PASCAL_UNIT_PREFIXES.some((p) => name.startsWith(p))) {
1652
+ return true;
1653
+ }
1654
+ if (PASCAL_BUILT_INS.has(name)) {
1655
+ return true;
1656
+ }
1657
+ }
1658
+ // C/C++ standard library symbols (printf, malloc, std::vector, etc.).
1659
+ // Names that collide with user-defined symbols are NOT filtered —
1660
+ // C and C++ projects routinely shadow stdlib names (custom allocators
1661
+ // define `malloc`/`free`, stream wrappers define `read`/`write`/`open`,
1662
+ // containers define `move`/`swap`, logging libs wrap `printf`). Killing
1663
+ // those resolutions makes the graph wrong, not cleaner. We only filter
1664
+ // when there's no user node with this name — then name-matching would
1665
+ // produce zero edges anyway and the filter just short-circuits work.
1666
+ if (ref.language === 'c' || ref.language === 'cpp') {
1667
+ // C++ std:: namespace prefix — safe to filter unconditionally,
1668
+ // since `std::foo` is never a user-defined qualified name in
1669
+ // tree-sitter output.
1670
+ if (name.startsWith('std::'))
1671
+ return true;
1672
+ if (C_BUILT_INS.has(name) || CPP_BUILT_INS.has(name)) {
1673
+ return !this.hasAnyPossibleMatch(name);
1674
+ }
1675
+ }
1676
+ return false;
1677
+ }
1678
+ /**
1679
+ * Get file path from node ID
1680
+ */
1681
+ getFilePathFromNodeId(nodeId) {
1682
+ const node = this.queries.getNodeById(nodeId);
1683
+ return node?.filePath || '';
1684
+ }
1685
+ /**
1686
+ * Get language from node ID
1687
+ */
1688
+ getLanguageFromNodeId(nodeId) {
1689
+ const node = this.queries.getNodeById(nodeId);
1690
+ return node?.language || 'unknown';
1691
+ }
1692
+ /**
1693
+ * Drop an import/name-strategy resolution that crosses a language family.
1694
+ * Two regimes (mirrors `applyLanguageGate`'s candidate filter):
1695
+ * - `references` (type usage): STRICT — a `Type.member` static read names a
1696
+ * same-family type, never a coincidentally same-named symbol in another
1697
+ * language. Drops any non-same-family target.
1698
+ * - `imports` (import binding / `#include`): both-known — a C++ `#include
1699
+ * "X.h"` must not resolve to a same-named ObjC header on another platform
1700
+ * (basename collision), but a singleton-family / SFC language (`vue` →
1701
+ * `.ts`) importing across is left alone.
1702
+ * Applies to the import (strategy 2) + name-match (strategy 3) results.
1703
+ */
1704
+ /**
1705
+ * Collect the `@using` namespaces in scope for a `.razor`/`.cshtml` file: its
1706
+ * own `@using` directives plus every `_Imports.razor` from the file's folder up
1707
+ * to the project root (Razor `_Imports` cascade). Cached per file.
1708
+ */
1709
+ getRazorUsings(filePath) {
1710
+ const cached = this.razorUsingsCache.get(filePath);
1711
+ if (cached)
1712
+ return cached;
1713
+ const usings = new Set();
1714
+ const addFrom = (src) => {
1715
+ if (!src)
1716
+ return;
1717
+ for (const m of src.matchAll(/^\s*@using\s+(?:static\s+)?([A-Za-z_][\w.]*)/gm))
1718
+ usings.add(m[1]);
1719
+ };
1720
+ addFrom(this.context.readFile(filePath));
1721
+ let dir = filePath.includes('/') ? filePath.slice(0, filePath.lastIndexOf('/')) : '';
1722
+ // Walk up to the project root, reading each level's _Imports.razor.
1723
+ for (;;) {
1724
+ addFrom(this.context.readFile(dir ? `${dir}/_Imports.razor` : '_Imports.razor'));
1725
+ if (!dir)
1726
+ break;
1727
+ const slash = dir.lastIndexOf('/');
1728
+ dir = slash >= 0 ? dir.slice(0, slash) : '';
1729
+ }
1730
+ const arr = [...usings];
1731
+ this.razorUsingsCache.set(filePath, arr);
1732
+ return arr;
1733
+ }
1734
+ /**
1735
+ * Resolve a Razor/Blazor simple type ref through the file's `@using`
1736
+ * namespaces: `CatalogBrand` + `@using BlazorShared.Models` → the node whose
1737
+ * qualified name is `BlazorShared.Models::CatalogBrand`. Only resolves when the
1738
+ * `@using` set yields exactly ONE type (otherwise it stays ambiguous and falls
1739
+ * through to name-matching).
1740
+ */
1741
+ resolveRazorUsing(ref) {
1742
+ if (ref.referenceName.includes('.') || ref.referenceName.includes('::'))
1743
+ return null;
1744
+ const usings = this.getRazorUsings(ref.filePath);
1745
+ if (usings.length === 0)
1746
+ return null;
1747
+ const found = new Map();
1748
+ for (const ns of usings) {
1749
+ for (const cand of this.context.getNodesByQualifiedName(`${ns}::${ref.referenceName}`)) {
1750
+ found.set(cand.id, cand);
1751
+ }
1752
+ }
1753
+ if (found.size !== 1)
1754
+ return null;
1755
+ const target = found.values().next().value;
1756
+ return { original: ref, targetNodeId: target.id, confidence: 0.9, resolvedBy: 'import' };
1757
+ }
1758
+ /**
1759
+ * Resolve a CFML inheritance reference written as a component path (#1152).
1760
+ * Two forms exist in real code:
1761
+ *
1762
+ * - Dotted: `extends="coldbox.system.web.Controller"` — dots are directory
1763
+ * separators from the webroot or a CFML mapping. Mappings live in server
1764
+ * config / Application.cfc, so the leading segments may not exist in the
1765
+ * repo at all (in the coldbox repo itself the path is `system/web/
1766
+ * Controller.cfc` — the `coldbox.` root IS the repo). Matched by final
1767
+ * segment (the class), corroborated right-to-left against the candidate's
1768
+ * parent directories.
1769
+ * - Relative: `extends="../base"` / `extends="./base"` (the FW/1 style) —
1770
+ * resolved against the referencing file's own directory.
1771
+ *
1772
+ * Conservative by design: a candidate needs at least one corroborating
1773
+ * directory segment (a dotted path whose only same-named class sits in an
1774
+ * unrelated directory is almost always an out-of-repo library supertype —
1775
+ * mxunit/testbox/coldbox-as-dependency), and a corroboration tie yields no
1776
+ * edge. Directory comparison is case-insensitive (CFML path resolution is);
1777
+ * the class segment itself is matched exactly, which real code satisfies —
1778
+ * dotted paths are written to match the on-disk file name.
1779
+ */
1780
+ resolveCfmlComponentPath(ref) {
1781
+ const cfmlCandidates = (name) => this.context
1782
+ .getNodesByName(name)
1783
+ .filter((n) => (n.kind === 'class' || n.kind === 'interface') &&
1784
+ (n.language === 'cfml' || n.language === 'cfscript'));
1785
+ const norm = (p) => p.replace(/\\/g, '/').toLowerCase();
1786
+ // Relative-path form: `../base`, `./base`, `sub/thing` — resolve against
1787
+ // the referencing file's directory and require an exact (case-insensitive)
1788
+ // file match.
1789
+ if (ref.referenceName.includes('/')) {
1790
+ const rel = ref.referenceName.replace(/\.cfc$/i, '');
1791
+ const fromDir = ref.filePath.replace(/\\/g, '/').split('/').slice(0, -1);
1792
+ const parts = [...fromDir];
1793
+ for (const seg of rel.split('/')) {
1794
+ if (seg === '' || seg === '.')
1795
+ continue;
1796
+ if (seg === '..') {
1797
+ if (parts.length === 0)
1798
+ return null; // escapes the project root
1799
+ parts.pop();
1800
+ }
1801
+ else {
1802
+ parts.push(seg);
1803
+ }
1804
+ }
1805
+ const wantPath = norm(parts.join('/') + '.cfc');
1806
+ const className = parts[parts.length - 1];
1807
+ if (!className)
1808
+ return null;
1809
+ const target = cfmlCandidates(className).find((c) => norm(c.filePath) === wantPath);
1810
+ return target
1811
+ ? { original: ref, targetNodeId: target.id, confidence: 0.95, resolvedBy: 'file-path' }
1812
+ : null;
1813
+ }
1814
+ // Dotted form.
1815
+ const segments = ref.referenceName.split('.').map((s) => s.trim()).filter(Boolean);
1816
+ if (segments.length < 2)
1817
+ return null;
1818
+ const className = segments[segments.length - 1];
1819
+ const dirSegments = segments.slice(0, -1);
1820
+ let best = null;
1821
+ let bestScore = 0;
1822
+ let tie = false;
1823
+ for (const cand of cfmlCandidates(className)) {
1824
+ const dirs = cand.filePath.replace(/\\/g, '/').split('/').slice(0, -1);
1825
+ // Count matching directory segments right-to-left: for
1826
+ // `coldbox.system.web.Controller` vs `system/web/Controller.cfc`,
1827
+ // `web` and `system` match, then the repo root ends the run → score 2.
1828
+ let score = 0;
1829
+ while (score < dirSegments.length &&
1830
+ score < dirs.length &&
1831
+ dirSegments[dirSegments.length - 1 - score].toLowerCase() ===
1832
+ dirs[dirs.length - 1 - score].toLowerCase()) {
1833
+ score++;
1834
+ }
1835
+ if (score > bestScore) {
1836
+ best = cand;
1837
+ bestScore = score;
1838
+ tie = false;
1839
+ }
1840
+ else if (score === bestScore && score > 0) {
1841
+ tie = true;
1842
+ }
1843
+ }
1844
+ if (!best || bestScore === 0 || tie)
1845
+ return null;
1846
+ return { original: ref, targetNodeId: best.id, confidence: 0.9, resolvedBy: 'qualified-name' };
1847
+ }
1848
+ /**
1849
+ * Resolve a `this.<member>` function-as-value reference (#756/#808) to the
1850
+ * ENCLOSING CLASS's own member — never a same-named symbol elsewhere. The
1851
+ * registration idiom (`btn.on('click', this.handleClick)`) names a member
1852
+ * of the class being defined, so the only valid target shares the
1853
+ * from-symbol's qualified-name scope. Function/method targets only — a
1854
+ * property (a data field, post-#808 classification) yields no edge — same
1855
+ * file required, no fallback of any kind.
1856
+ */
1857
+ resolveThisMemberFnRef(ref) {
1858
+ const member = ref.referenceName.slice('this.'.length);
1859
+ if (!member)
1860
+ return null;
1861
+ const fromNode = this.queries.getNodeById(ref.fromNodeId);
1862
+ if (!fromNode)
1863
+ return null;
1864
+ // A hook declared at class-body level (Ruby `before_action :authenticate`)
1865
+ // attributes to the CLASS node itself — its qualified name IS the scope.
1866
+ // For members, strip the member segment.
1867
+ let classPrefix;
1868
+ if (SUPERTYPE_BEARING_KINDS.has(fromNode.kind) || fromNode.kind === 'module') {
1869
+ classPrefix = fromNode.qualifiedName;
1870
+ }
1871
+ else {
1872
+ const sep = fromNode.qualifiedName.lastIndexOf('::');
1873
+ if (sep <= 0)
1874
+ return null; // not inside a class scope
1875
+ classPrefix = fromNode.qualifiedName.slice(0, sep);
1876
+ }
1877
+ const candidates = this.context
1878
+ .getNodesByQualifiedName(`${classPrefix}::${member}`)
1879
+ .filter((n) => (n.kind === 'function' || n.kind === 'method') &&
1880
+ n.filePath === ref.filePath &&
1881
+ n.id !== ref.fromNodeId);
1882
+ if (candidates.length === 0) {
1883
+ // Not on the class itself — possibly INHERITED. implements/extends
1884
+ // edges don't exist yet in this pass, so retry in the supertype pass
1885
+ // (resolveDeferredThisMemberRefs) instead of giving up.
1886
+ this.deferredThisMemberRefs.push(ref);
1887
+ return null;
1888
+ }
1889
+ const target = candidates.reduce((a, b) => (a.startLine <= b.startLine ? a : b));
1890
+ return {
1891
+ original: ref,
1892
+ targetNodeId: target.id,
1893
+ confidence: 0.95,
1894
+ resolvedBy: 'function-ref',
1895
+ };
1896
+ }
1897
+ /**
1898
+ * Second pass for `this.<member>` refs whose member wasn't on the enclosing
1899
+ * class itself (#808): once implements/extends edges exist, walk the
1900
+ * class's supertypes (transitively, depth-capped) and resolve the member on
1901
+ * the nearest one that declares it — `this.handleSubmit` registered in a
1902
+ * subclass resolves to `FormBase::handleSubmit`. Validated targets only
1903
+ * (function/method kind, same language family); no match → no edge.
1904
+ * Mirrors resolveChainedCallsViaConformance's lifecycle. Returns the number
1905
+ * of newly-created edges.
1906
+ */
1907
+ async resolveDeferredThisMemberRefs() {
1908
+ const deferred = this.deferredThisMemberRefs;
1909
+ this.deferredThisMemberRefs = [];
1910
+ if (deferred.length === 0)
1911
+ return 0;
1912
+ this.clearCaches();
1913
+ // Synchronous main-thread post-pass with a per-ref supertype BFS — yield
1914
+ // periodically so the #850 liveness watchdog heartbeat can fire (#1091).
1915
+ const maybeYield = (0, cooperative_yield_1.createYielder)();
1916
+ const resolved = [];
1917
+ for (const ref of deferred) {
1918
+ await maybeYield();
1919
+ const member = ref.referenceName.slice('this.'.length);
1920
+ const fromNode = this.queries.getNodeById(ref.fromNodeId);
1921
+ if (!fromNode || !member)
1922
+ continue;
1923
+ // Class-body-level hooks (Ruby) attribute to the CLASS node itself.
1924
+ let className;
1925
+ if (SUPERTYPE_BEARING_KINDS.has(fromNode.kind) || fromNode.kind === 'module') {
1926
+ className = fromNode.name;
1927
+ }
1928
+ else {
1929
+ const sep = fromNode.qualifiedName.lastIndexOf('::');
1930
+ if (sep <= 0)
1931
+ continue;
1932
+ const classPrefix = fromNode.qualifiedName.slice(0, sep);
1933
+ className = classPrefix.includes('::')
1934
+ ? classPrefix.slice(classPrefix.lastIndexOf('::') + 2)
1935
+ : classPrefix;
1936
+ }
1937
+ // NODE-anchored BFS up the supertype graph: start from the class node
1938
+ // in the ref's own file (never a same-named class elsewhere — rails has
1939
+ // a dozen `Engine`s), follow implements/extends EDGES to supertype
1940
+ // NODES, and look members up through `contains` edges. No name-based
1941
+ // unions anywhere — a name-keyed getSupertypes('Engine') merged every
1942
+ // Engine's parents and produced a cross-class wrong edge on rails.
1943
+ let frontierNodes = this.context
1944
+ .getNodesByName(className)
1945
+ .filter((n) => SUPERTYPE_BEARING_KINDS.has(n.kind) &&
1946
+ n.filePath === ref.filePath);
1947
+ if (frontierNodes.length === 0) {
1948
+ // The class itself may be declared in another file (partial/reopened
1949
+ // classes); fall back to same-family nodes of that name.
1950
+ frontierNodes = this.context
1951
+ .getNodesByName(className)
1952
+ .filter((n) => SUPERTYPE_BEARING_KINDS.has(n.kind) &&
1953
+ (0, name_matcher_1.sameLanguageFamily)(n.language, ref.language));
1954
+ }
1955
+ const seenNodes = new Set(frontierNodes.map((n) => n.id));
1956
+ let target = null;
1957
+ for (let depth = 0; depth < 5 && frontierNodes.length > 0 && !target; depth++) {
1958
+ const next = [];
1959
+ for (const typeNode of frontierNodes) {
1960
+ for (const edge of this.queries.getOutgoingEdges(typeNode.id, ['implements', 'extends'])) {
1961
+ const superNode = this.queries.getNodeById(edge.target);
1962
+ if (!superNode || seenNodes.has(superNode.id))
1963
+ continue;
1964
+ seenNodes.add(superNode.id);
1965
+ if (!SUPERTYPE_BEARING_KINDS.has(superNode.kind))
1966
+ continue;
1967
+ // Member lookup anchored on the supertype's contains edges.
1968
+ for (const c of this.queries.getOutgoingEdges(superNode.id, ['contains'])) {
1969
+ const m = this.queries.getNodeById(c.target);
1970
+ if (m &&
1971
+ m.name === member &&
1972
+ (m.kind === 'function' || m.kind === 'method') &&
1973
+ (0, name_matcher_1.sameLanguageFamily)(m.language, ref.language)) {
1974
+ target = m;
1975
+ break;
1976
+ }
1977
+ }
1978
+ if (target)
1979
+ break;
1980
+ next.push(superNode);
1981
+ }
1982
+ if (target)
1983
+ break;
1984
+ }
1985
+ frontierNodes = next;
1986
+ }
1987
+ if (target) {
1988
+ resolved.push({
1989
+ original: ref,
1990
+ targetNodeId: target.id,
1991
+ confidence: 0.85,
1992
+ resolvedBy: 'function-ref',
1993
+ });
1994
+ }
1995
+ }
1996
+ if (resolved.length === 0)
1997
+ return 0;
1998
+ const edges = this.createEdges(resolved);
1999
+ if (edges.length > 0) {
2000
+ this.queries.insertEdges(edges);
2001
+ this.clearCaches();
2002
+ }
2003
+ return edges.length;
2004
+ }
2005
+ gateLanguage(result, ref) {
2006
+ if (!result)
2007
+ return result;
2008
+ const tgt = this.getLanguageFromNodeId(result.targetNodeId);
2009
+ if (!tgt || !ref.language)
2010
+ return result;
2011
+ if ((ref.referenceKind === 'references' || ref.referenceKind === 'function_ref') && !(0, name_matcher_1.sameLanguageFamily)(tgt, ref.language))
2012
+ return null;
2013
+ if (ref.referenceKind === 'imports' && (0, name_matcher_1.crossesKnownFamily)(tgt, ref.language))
2014
+ return null;
2015
+ return result;
2016
+ }
2017
+ /**
2018
+ * Drop a FRAMEWORK-strategy resolution that crosses two *known* language
2019
+ * families for a type-usage (`references`) or import-binding (`imports`)
2020
+ * edge. The framework strategy is intentionally ungated for cross-language
2021
+ * bridges, but those legitimate bridges are either `calls` edges (RN/Expo
2022
+ * JS → native) or config↔code edges whose config side (`yaml`/`blade`/…) is
2023
+ * not a known programming-language family. A `references`/`imports` edge
2024
+ * between two *known* families is always a coincidental name collision — the
2025
+ * React/Svelte/Vue PascalCase component resolvers name-match `getNodesByName`
2026
+ * without a language check, so a TS `<TestRunner>` ref happily matched a
2027
+ * Kotlin `class TestRunner`. Gating only the both-known-cross-family case
2028
+ * lets config bridges and `calls` bridges through untouched.
2029
+ */
2030
+ gateFrameworkLanguage(result, ref) {
2031
+ if (!result)
2032
+ return result;
2033
+ if (ref.referenceKind !== 'references' && ref.referenceKind !== 'imports')
2034
+ return result;
2035
+ const tgt = this.getLanguageFromNodeId(result.targetNodeId);
2036
+ if (tgt && ref.language && (0, name_matcher_1.crossesKnownFamily)(tgt, ref.language))
2037
+ return null;
2038
+ return result;
2039
+ }
2040
+ }
2041
+ exports.ReferenceResolver = ReferenceResolver;
2042
+ /**
2043
+ * Create a reference resolver instance
2044
+ */
2045
+ function createResolver(projectRoot, queries) {
2046
+ const resolver = new ReferenceResolver(projectRoot, queries);
2047
+ resolver.initialize();
2048
+ return resolver;
2049
+ }
2050
+ //# sourceMappingURL=index.js.map