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