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