@colbymchenry/codegraph-win32-arm64 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (622) hide show
  1. package/bin/codegraph +5 -0
  2. package/lib/dist/.test-build-engine.json +1 -0
  3. package/lib/dist/.test-build-viewer.json +1 -0
  4. package/lib/dist/bin/codegraph.d.ts +1 -0
  5. package/lib/dist/bin/codegraph.d.ts.map +1 -1
  6. package/lib/dist/bin/codegraph.js +599 -291
  7. package/lib/dist/bin/codegraph.js.map +1 -1
  8. package/lib/dist/bin/viewer-gate.d.ts +17 -0
  9. package/lib/dist/bin/viewer-gate.d.ts.map +1 -0
  10. package/lib/dist/bin/viewer-gate.js +31 -0
  11. package/lib/dist/bin/viewer-gate.js.map +1 -0
  12. package/lib/dist/context/index.d.ts.map +1 -1
  13. package/lib/dist/context/index.js +43 -2
  14. package/lib/dist/context/index.js.map +1 -1
  15. package/lib/dist/db/index.d.ts +21 -2
  16. package/lib/dist/db/index.d.ts.map +1 -1
  17. package/lib/dist/db/index.js +86 -31
  18. package/lib/dist/db/index.js.map +1 -1
  19. package/lib/dist/db/migrations.d.ts +1 -1
  20. package/lib/dist/db/migrations.d.ts.map +1 -1
  21. package/lib/dist/db/migrations.js +40 -1
  22. package/lib/dist/db/migrations.js.map +1 -1
  23. package/lib/dist/db/queries.d.ts +423 -3
  24. package/lib/dist/db/queries.d.ts.map +1 -1
  25. package/lib/dist/db/queries.js +1026 -33
  26. package/lib/dist/db/queries.js.map +1 -1
  27. package/lib/dist/db/schema.sql +11 -1
  28. package/lib/dist/db/sqlite-adapter.d.ts +2 -0
  29. package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
  30. package/lib/dist/db/sqlite-adapter.js +56 -7
  31. package/lib/dist/db/sqlite-adapter.js.map +1 -1
  32. package/lib/dist/db/synthesis-stage.d.ts +12 -0
  33. package/lib/dist/db/synthesis-stage.d.ts.map +1 -0
  34. package/lib/dist/db/synthesis-stage.js +89 -0
  35. package/lib/dist/db/synthesis-stage.js.map +1 -0
  36. package/lib/dist/db/wal-valve.d.ts +32 -12
  37. package/lib/dist/db/wal-valve.d.ts.map +1 -1
  38. package/lib/dist/db/wal-valve.js +65 -22
  39. package/lib/dist/db/wal-valve.js.map +1 -1
  40. package/lib/dist/db/wsl-shared-index.d.ts +53 -0
  41. package/lib/dist/db/wsl-shared-index.d.ts.map +1 -0
  42. package/lib/dist/db/wsl-shared-index.js +121 -0
  43. package/lib/dist/db/wsl-shared-index.js.map +1 -0
  44. package/lib/dist/directory.d.ts +101 -2
  45. package/lib/dist/directory.d.ts.map +1 -1
  46. package/lib/dist/directory.js +254 -23
  47. package/lib/dist/directory.js.map +1 -1
  48. package/lib/dist/errors.d.ts +14 -0
  49. package/lib/dist/errors.d.ts.map +1 -1
  50. package/lib/dist/errors.js +16 -1
  51. package/lib/dist/errors.js.map +1 -1
  52. package/lib/dist/extraction/cfml-extractor.d.ts +1 -0
  53. package/lib/dist/extraction/cfml-extractor.d.ts.map +1 -1
  54. package/lib/dist/extraction/cfml-extractor.js +15 -3
  55. package/lib/dist/extraction/cfml-extractor.js.map +1 -1
  56. package/lib/dist/extraction/dfm-extractor.d.ts.map +1 -1
  57. package/lib/dist/extraction/dfm-extractor.js +14 -10
  58. package/lib/dist/extraction/dfm-extractor.js.map +1 -1
  59. package/lib/dist/extraction/extraction-version.d.ts +1 -1
  60. package/lib/dist/extraction/extraction-version.js +1 -1
  61. package/lib/dist/extraction/function-ref.d.ts +6 -4
  62. package/lib/dist/extraction/function-ref.d.ts.map +1 -1
  63. package/lib/dist/extraction/function-ref.js +35 -14
  64. package/lib/dist/extraction/function-ref.js.map +1 -1
  65. package/lib/dist/extraction/grammars.d.ts +38 -0
  66. package/lib/dist/extraction/grammars.d.ts.map +1 -1
  67. package/lib/dist/extraction/grammars.js +77 -1
  68. package/lib/dist/extraction/grammars.js.map +1 -1
  69. package/lib/dist/extraction/index.d.ts +113 -15
  70. package/lib/dist/extraction/index.d.ts.map +1 -1
  71. package/lib/dist/extraction/index.js +599 -132
  72. package/lib/dist/extraction/index.js.map +1 -1
  73. package/lib/dist/extraction/languages/c-cpp.d.ts +58 -0
  74. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  75. package/lib/dist/extraction/languages/c-cpp.js +291 -15
  76. package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
  77. package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
  78. package/lib/dist/extraction/languages/dart.js +8 -3
  79. package/lib/dist/extraction/languages/dart.js.map +1 -1
  80. package/lib/dist/extraction/languages/javascript.js +1 -1
  81. package/lib/dist/extraction/languages/javascript.js.map +1 -1
  82. package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
  83. package/lib/dist/extraction/languages/kotlin.js +169 -36
  84. package/lib/dist/extraction/languages/kotlin.js.map +1 -1
  85. package/lib/dist/extraction/languages/lua.d.ts.map +1 -1
  86. package/lib/dist/extraction/languages/lua.js +4 -1
  87. package/lib/dist/extraction/languages/lua.js.map +1 -1
  88. package/lib/dist/extraction/languages/python.d.ts.map +1 -1
  89. package/lib/dist/extraction/languages/python.js +71 -0
  90. package/lib/dist/extraction/languages/python.js.map +1 -1
  91. package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
  92. package/lib/dist/extraction/languages/rust.js +3 -0
  93. package/lib/dist/extraction/languages/rust.js.map +1 -1
  94. package/lib/dist/extraction/languages/scala.d.ts.map +1 -1
  95. package/lib/dist/extraction/languages/scala.js +18 -3
  96. package/lib/dist/extraction/languages/scala.js.map +1 -1
  97. package/lib/dist/extraction/languages/typescript.d.ts.map +1 -1
  98. package/lib/dist/extraction/languages/typescript.js +9 -2
  99. package/lib/dist/extraction/languages/typescript.js.map +1 -1
  100. package/lib/dist/extraction/liquid-extractor.d.ts +18 -0
  101. package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -1
  102. package/lib/dist/extraction/liquid-extractor.js +98 -22
  103. package/lib/dist/extraction/liquid-extractor.js.map +1 -1
  104. package/lib/dist/extraction/mybatis-extractor.d.ts.map +1 -1
  105. package/lib/dist/extraction/mybatis-extractor.js +6 -4
  106. package/lib/dist/extraction/mybatis-extractor.js.map +1 -1
  107. package/lib/dist/extraction/syntax-tokens.d.ts +103 -0
  108. package/lib/dist/extraction/syntax-tokens.d.ts.map +1 -0
  109. package/lib/dist/extraction/syntax-tokens.js +381 -0
  110. package/lib/dist/extraction/syntax-tokens.js.map +1 -0
  111. package/lib/dist/extraction/tree-sitter-helpers.d.ts +5 -0
  112. package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
  113. package/lib/dist/extraction/tree-sitter-helpers.js +17 -0
  114. package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -1
  115. package/lib/dist/extraction/tree-sitter-types.d.ts +29 -3
  116. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  117. package/lib/dist/extraction/tree-sitter.d.ts +96 -17
  118. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
  119. package/lib/dist/extraction/tree-sitter.js +820 -82
  120. package/lib/dist/extraction/tree-sitter.js.map +1 -1
  121. package/lib/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  122. package/lib/dist/file-limits.d.ts +40 -0
  123. package/lib/dist/file-limits.d.ts.map +1 -0
  124. package/lib/dist/file-limits.js +147 -0
  125. package/lib/dist/file-limits.js.map +1 -0
  126. package/lib/dist/graph/branch-guards.d.ts +248 -0
  127. package/lib/dist/graph/branch-guards.d.ts.map +1 -0
  128. package/lib/dist/graph/branch-guards.js +2231 -0
  129. package/lib/dist/graph/branch-guards.js.map +1 -0
  130. package/lib/dist/graph/dead-code.d.ts +251 -0
  131. package/lib/dist/graph/dead-code.d.ts.map +1 -0
  132. package/lib/dist/graph/dead-code.js +776 -0
  133. package/lib/dist/graph/dead-code.js.map +1 -0
  134. package/lib/dist/graph/dynamic-boundary-report.d.ts +121 -0
  135. package/lib/dist/graph/dynamic-boundary-report.d.ts.map +1 -0
  136. package/lib/dist/graph/dynamic-boundary-report.js +283 -0
  137. package/lib/dist/graph/dynamic-boundary-report.js.map +1 -0
  138. package/lib/dist/graph/index.d.ts +4 -0
  139. package/lib/dist/graph/index.d.ts.map +1 -1
  140. package/lib/dist/graph/index.js +16 -1
  141. package/lib/dist/graph/index.js.map +1 -1
  142. package/lib/dist/graph/named-symbol-flow.d.ts +125 -0
  143. package/lib/dist/graph/named-symbol-flow.d.ts.map +1 -0
  144. package/lib/dist/graph/named-symbol-flow.js +552 -0
  145. package/lib/dist/graph/named-symbol-flow.js.map +1 -0
  146. package/lib/dist/graph/symbol-lookup.d.ts +83 -0
  147. package/lib/dist/graph/symbol-lookup.d.ts.map +1 -0
  148. package/lib/dist/graph/symbol-lookup.js +181 -0
  149. package/lib/dist/graph/symbol-lookup.js.map +1 -0
  150. package/lib/dist/graph/traversal.d.ts +9 -0
  151. package/lib/dist/graph/traversal.d.ts.map +1 -1
  152. package/lib/dist/graph/traversal.js +61 -35
  153. package/lib/dist/graph/traversal.js.map +1 -1
  154. package/lib/dist/graph/type-hierarchy.d.ts +155 -0
  155. package/lib/dist/graph/type-hierarchy.d.ts.map +1 -0
  156. package/lib/dist/graph/type-hierarchy.js +382 -0
  157. package/lib/dist/graph/type-hierarchy.js.map +1 -0
  158. package/lib/dist/index.d.ts +251 -11
  159. package/lib/dist/index.d.ts.map +1 -1
  160. package/lib/dist/index.js +395 -34
  161. package/lib/dist/index.js.map +1 -1
  162. package/lib/dist/installer/index.d.ts.map +1 -1
  163. package/lib/dist/installer/index.js +3 -2
  164. package/lib/dist/installer/index.js.map +1 -1
  165. package/lib/dist/installer/targets/antigravity.d.ts.map +1 -1
  166. package/lib/dist/installer/targets/antigravity.js +14 -2
  167. package/lib/dist/installer/targets/antigravity.js.map +1 -1
  168. package/lib/dist/installer/targets/claude.d.ts +3 -0
  169. package/lib/dist/installer/targets/claude.d.ts.map +1 -1
  170. package/lib/dist/installer/targets/claude.js +35 -7
  171. package/lib/dist/installer/targets/claude.js.map +1 -1
  172. package/lib/dist/installer/targets/codex.d.ts +2 -1
  173. package/lib/dist/installer/targets/codex.d.ts.map +1 -1
  174. package/lib/dist/installer/targets/codex.js +14 -4
  175. package/lib/dist/installer/targets/codex.js.map +1 -1
  176. package/lib/dist/installer/targets/copilot-cli.d.ts.map +1 -1
  177. package/lib/dist/installer/targets/copilot-cli.js +7 -1
  178. package/lib/dist/installer/targets/copilot-cli.js.map +1 -1
  179. package/lib/dist/installer/targets/opencode.d.ts +16 -5
  180. package/lib/dist/installer/targets/opencode.d.ts.map +1 -1
  181. package/lib/dist/installer/targets/opencode.js +73 -22
  182. package/lib/dist/installer/targets/opencode.js.map +1 -1
  183. package/lib/dist/installer/targets/shared.d.ts +14 -3
  184. package/lib/dist/installer/targets/shared.d.ts.map +1 -1
  185. package/lib/dist/installer/targets/shared.js +39 -11
  186. package/lib/dist/installer/targets/shared.js.map +1 -1
  187. package/lib/dist/installer/targets/types.d.ts +7 -0
  188. package/lib/dist/installer/targets/types.d.ts.map +1 -1
  189. package/lib/dist/mcp/answer-freshness.d.ts +10 -0
  190. package/lib/dist/mcp/answer-freshness.d.ts.map +1 -0
  191. package/lib/dist/mcp/answer-freshness.js +68 -0
  192. package/lib/dist/mcp/answer-freshness.js.map +1 -0
  193. package/lib/dist/mcp/daemon-manager.d.ts.map +1 -1
  194. package/lib/dist/mcp/daemon-manager.js +16 -0
  195. package/lib/dist/mcp/daemon-manager.js.map +1 -1
  196. package/lib/dist/mcp/daemon-paths.d.ts +2 -0
  197. package/lib/dist/mcp/daemon-paths.d.ts.map +1 -1
  198. package/lib/dist/mcp/daemon-paths.js +12 -3
  199. package/lib/dist/mcp/daemon-paths.js.map +1 -1
  200. package/lib/dist/mcp/daemon-registry.d.ts +7 -4
  201. package/lib/dist/mcp/daemon-registry.d.ts.map +1 -1
  202. package/lib/dist/mcp/daemon-registry.js +91 -29
  203. package/lib/dist/mcp/daemon-registry.js.map +1 -1
  204. package/lib/dist/mcp/daemon.d.ts +17 -7
  205. package/lib/dist/mcp/daemon.d.ts.map +1 -1
  206. package/lib/dist/mcp/daemon.js +116 -24
  207. package/lib/dist/mcp/daemon.js.map +1 -1
  208. package/lib/dist/mcp/dynamic-boundaries.d.ts +1 -10
  209. package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -1
  210. package/lib/dist/mcp/dynamic-boundaries.js +46 -42
  211. package/lib/dist/mcp/dynamic-boundaries.js.map +1 -1
  212. package/lib/dist/mcp/engine.d.ts +28 -9
  213. package/lib/dist/mcp/engine.d.ts.map +1 -1
  214. package/lib/dist/mcp/engine.js +146 -62
  215. package/lib/dist/mcp/engine.js.map +1 -1
  216. package/lib/dist/mcp/explore-dedup.d.ts +5 -2
  217. package/lib/dist/mcp/explore-dedup.d.ts.map +1 -1
  218. package/lib/dist/mcp/explore-dedup.js +8 -5
  219. package/lib/dist/mcp/explore-dedup.js.map +1 -1
  220. package/lib/dist/mcp/index-freshness-worker.d.ts +2 -0
  221. package/lib/dist/mcp/index-freshness-worker.d.ts.map +1 -0
  222. package/lib/dist/mcp/index-freshness-worker.js +30 -0
  223. package/lib/dist/mcp/index-freshness-worker.js.map +1 -0
  224. package/lib/dist/mcp/index-freshness.d.ts +7 -0
  225. package/lib/dist/mcp/index-freshness.d.ts.map +1 -0
  226. package/lib/dist/mcp/index-freshness.js +94 -0
  227. package/lib/dist/mcp/index-freshness.js.map +1 -0
  228. package/lib/dist/mcp/index.d.ts +3 -1
  229. package/lib/dist/mcp/index.d.ts.map +1 -1
  230. package/lib/dist/mcp/index.js +95 -11
  231. package/lib/dist/mcp/index.js.map +1 -1
  232. package/lib/dist/mcp/liveness-watchdog.d.ts +4 -1
  233. package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -1
  234. package/lib/dist/mcp/liveness-watchdog.js +11 -2
  235. package/lib/dist/mcp/liveness-watchdog.js.map +1 -1
  236. package/lib/dist/mcp/project-lifecycle.d.ts +9 -0
  237. package/lib/dist/mcp/project-lifecycle.d.ts.map +1 -0
  238. package/lib/dist/mcp/project-lifecycle.js +181 -0
  239. package/lib/dist/mcp/project-lifecycle.js.map +1 -0
  240. package/lib/dist/mcp/proxy.d.ts.map +1 -1
  241. package/lib/dist/mcp/proxy.js +9 -0
  242. package/lib/dist/mcp/proxy.js.map +1 -1
  243. package/lib/dist/mcp/query-pool.d.ts +2 -2
  244. package/lib/dist/mcp/query-pool.d.ts.map +1 -1
  245. package/lib/dist/mcp/query-pool.js +9 -7
  246. package/lib/dist/mcp/query-pool.js.map +1 -1
  247. package/lib/dist/mcp/query-worker.js +2 -2
  248. package/lib/dist/mcp/query-worker.js.map +1 -1
  249. package/lib/dist/mcp/server-instructions.d.ts +1 -1
  250. package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
  251. package/lib/dist/mcp/server-instructions.js +6 -3
  252. package/lib/dist/mcp/server-instructions.js.map +1 -1
  253. package/lib/dist/mcp/startup-handshake.d.ts +3 -1
  254. package/lib/dist/mcp/startup-handshake.d.ts.map +1 -1
  255. package/lib/dist/mcp/startup-handshake.js +10 -2
  256. package/lib/dist/mcp/startup-handshake.js.map +1 -1
  257. package/lib/dist/mcp/tools.d.ts +276 -36
  258. package/lib/dist/mcp/tools.d.ts.map +1 -1
  259. package/lib/dist/mcp/tools.js +2295 -980
  260. package/lib/dist/mcp/tools.js.map +1 -1
  261. package/lib/dist/mcp/writer-lock.d.ts +61 -0
  262. package/lib/dist/mcp/writer-lock.d.ts.map +1 -0
  263. package/lib/dist/mcp/writer-lock.js +260 -0
  264. package/lib/dist/mcp/writer-lock.js.map +1 -0
  265. package/lib/dist/resolution/alias-binding.d.ts +56 -0
  266. package/lib/dist/resolution/alias-binding.d.ts.map +1 -0
  267. package/lib/dist/resolution/alias-binding.js +127 -0
  268. package/lib/dist/resolution/alias-binding.js.map +1 -0
  269. package/lib/dist/resolution/callback-synthesizer.d.ts +23 -1
  270. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  271. package/lib/dist/resolution/callback-synthesizer.js +291 -143
  272. package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
  273. package/lib/dist/resolution/cpp-constructor.d.ts +4 -0
  274. package/lib/dist/resolution/cpp-constructor.d.ts.map +1 -0
  275. package/lib/dist/resolution/cpp-constructor.js +123 -0
  276. package/lib/dist/resolution/cpp-constructor.js.map +1 -0
  277. package/lib/dist/resolution/cpp-macro-visibility.d.ts +12 -0
  278. package/lib/dist/resolution/cpp-macro-visibility.d.ts.map +1 -0
  279. package/lib/dist/resolution/cpp-macro-visibility.js +342 -0
  280. package/lib/dist/resolution/cpp-macro-visibility.js.map +1 -0
  281. package/lib/dist/resolution/expo-router-synthesizer.d.ts +32 -0
  282. package/lib/dist/resolution/expo-router-synthesizer.d.ts.map +1 -0
  283. package/lib/dist/resolution/expo-router-synthesizer.js +189 -0
  284. package/lib/dist/resolution/expo-router-synthesizer.js.map +1 -0
  285. package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -1
  286. package/lib/dist/resolution/frameworks/csharp.js +96 -2
  287. package/lib/dist/resolution/frameworks/csharp.js.map +1 -1
  288. package/lib/dist/resolution/frameworks/expo-router.d.ts +189 -0
  289. package/lib/dist/resolution/frameworks/expo-router.d.ts.map +1 -0
  290. package/lib/dist/resolution/frameworks/expo-router.js +785 -0
  291. package/lib/dist/resolution/frameworks/expo-router.js.map +1 -0
  292. package/lib/dist/resolution/frameworks/express.d.ts.map +1 -1
  293. package/lib/dist/resolution/frameworks/express.js +251 -16
  294. package/lib/dist/resolution/frameworks/express.js.map +1 -1
  295. package/lib/dist/resolution/frameworks/index.d.ts +5 -0
  296. package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
  297. package/lib/dist/resolution/frameworks/index.js +29 -1
  298. package/lib/dist/resolution/frameworks/index.js.map +1 -1
  299. package/lib/dist/resolution/frameworks/java.d.ts.map +1 -1
  300. package/lib/dist/resolution/frameworks/java.js +79 -47
  301. package/lib/dist/resolution/frameworks/java.js.map +1 -1
  302. package/lib/dist/resolution/frameworks/nestjs.d.ts.map +1 -1
  303. package/lib/dist/resolution/frameworks/nestjs.js +6 -14
  304. package/lib/dist/resolution/frameworks/nestjs.js.map +1 -1
  305. package/lib/dist/resolution/frameworks/nextjs.d.ts +76 -0
  306. package/lib/dist/resolution/frameworks/nextjs.d.ts.map +1 -0
  307. package/lib/dist/resolution/frameworks/nextjs.js +328 -0
  308. package/lib/dist/resolution/frameworks/nextjs.js.map +1 -0
  309. package/lib/dist/resolution/frameworks/object-literal.d.ts +32 -0
  310. package/lib/dist/resolution/frameworks/object-literal.d.ts.map +1 -0
  311. package/lib/dist/resolution/frameworks/object-literal.js +139 -0
  312. package/lib/dist/resolution/frameworks/object-literal.js.map +1 -0
  313. package/lib/dist/resolution/frameworks/package-deps.d.ts +14 -0
  314. package/lib/dist/resolution/frameworks/package-deps.d.ts.map +1 -0
  315. package/lib/dist/resolution/frameworks/package-deps.js +78 -0
  316. package/lib/dist/resolution/frameworks/package-deps.js.map +1 -0
  317. package/lib/dist/resolution/frameworks/python.d.ts.map +1 -1
  318. package/lib/dist/resolution/frameworks/python.js +166 -0
  319. package/lib/dist/resolution/frameworks/python.js.map +1 -1
  320. package/lib/dist/resolution/frameworks/react-native.d.ts +26 -0
  321. package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -1
  322. package/lib/dist/resolution/frameworks/react-native.js +153 -14
  323. package/lib/dist/resolution/frameworks/react-native.js.map +1 -1
  324. package/lib/dist/resolution/frameworks/react-router.d.ts +46 -0
  325. package/lib/dist/resolution/frameworks/react-router.d.ts.map +1 -0
  326. package/lib/dist/resolution/frameworks/react-router.js +187 -0
  327. package/lib/dist/resolution/frameworks/react-router.js.map +1 -0
  328. package/lib/dist/resolution/frameworks/react.d.ts +2 -1
  329. package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
  330. package/lib/dist/resolution/frameworks/react.js +188 -139
  331. package/lib/dist/resolution/frameworks/react.js.map +1 -1
  332. package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -1
  333. package/lib/dist/resolution/frameworks/svelte.js +6 -1
  334. package/lib/dist/resolution/frameworks/svelte.js.map +1 -1
  335. package/lib/dist/resolution/frameworks/sveltekit-router.d.ts +36 -0
  336. package/lib/dist/resolution/frameworks/sveltekit-router.d.ts.map +1 -0
  337. package/lib/dist/resolution/frameworks/sveltekit-router.js +156 -0
  338. package/lib/dist/resolution/frameworks/sveltekit-router.js.map +1 -0
  339. package/lib/dist/resolution/frameworks/tanstack-router.d.ts +84 -0
  340. package/lib/dist/resolution/frameworks/tanstack-router.d.ts.map +1 -0
  341. package/lib/dist/resolution/frameworks/tanstack-router.js +437 -0
  342. package/lib/dist/resolution/frameworks/tanstack-router.js.map +1 -0
  343. package/lib/dist/resolution/frameworks/vue-router.d.ts +82 -0
  344. package/lib/dist/resolution/frameworks/vue-router.d.ts.map +1 -0
  345. package/lib/dist/resolution/frameworks/vue-router.js +377 -0
  346. package/lib/dist/resolution/frameworks/vue-router.js.map +1 -0
  347. package/lib/dist/resolution/import-resolver.d.ts +38 -0
  348. package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
  349. package/lib/dist/resolution/import-resolver.js +376 -26
  350. package/lib/dist/resolution/import-resolver.js.map +1 -1
  351. package/lib/dist/resolution/index.d.ts +89 -25
  352. package/lib/dist/resolution/index.d.ts.map +1 -1
  353. package/lib/dist/resolution/index.js +552 -145
  354. package/lib/dist/resolution/index.js.map +1 -1
  355. package/lib/dist/resolution/js-builtins.d.ts +13 -0
  356. package/lib/dist/resolution/js-builtins.d.ts.map +1 -0
  357. package/lib/dist/resolution/js-builtins.js +46 -0
  358. package/lib/dist/resolution/js-builtins.js.map +1 -0
  359. package/lib/dist/resolution/name-matcher.d.ts +69 -22
  360. package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
  361. package/lib/dist/resolution/name-matcher.js +1902 -87
  362. package/lib/dist/resolution/name-matcher.js.map +1 -1
  363. package/lib/dist/resolution/next-router-synthesizer.d.ts +27 -0
  364. package/lib/dist/resolution/next-router-synthesizer.d.ts.map +1 -0
  365. package/lib/dist/resolution/next-router-synthesizer.js +113 -0
  366. package/lib/dist/resolution/next-router-synthesizer.js.map +1 -0
  367. package/lib/dist/resolution/react-router-synthesizer.d.ts +33 -0
  368. package/lib/dist/resolution/react-router-synthesizer.d.ts.map +1 -0
  369. package/lib/dist/resolution/react-router-synthesizer.js +126 -0
  370. package/lib/dist/resolution/react-router-synthesizer.js.map +1 -0
  371. package/lib/dist/resolution/resolver-pool.d.ts +2 -0
  372. package/lib/dist/resolution/resolver-pool.d.ts.map +1 -1
  373. package/lib/dist/resolution/resolver-pool.js +4 -0
  374. package/lib/dist/resolution/resolver-pool.js.map +1 -1
  375. package/lib/dist/resolution/strip-comments.d.ts +6 -0
  376. package/lib/dist/resolution/strip-comments.d.ts.map +1 -1
  377. package/lib/dist/resolution/strip-comments.js +58 -0
  378. package/lib/dist/resolution/strip-comments.js.map +1 -1
  379. package/lib/dist/resolution/sveltekit-synthesizer.d.ts +58 -0
  380. package/lib/dist/resolution/sveltekit-synthesizer.d.ts.map +1 -0
  381. package/lib/dist/resolution/sveltekit-synthesizer.js +173 -0
  382. package/lib/dist/resolution/sveltekit-synthesizer.js.map +1 -0
  383. package/lib/dist/resolution/synth-utils.d.ts +26 -0
  384. package/lib/dist/resolution/synth-utils.d.ts.map +1 -0
  385. package/lib/dist/resolution/synth-utils.js +75 -0
  386. package/lib/dist/resolution/synth-utils.js.map +1 -0
  387. package/lib/dist/resolution/tanstack-router-synthesizer.d.ts +31 -0
  388. package/lib/dist/resolution/tanstack-router-synthesizer.d.ts.map +1 -0
  389. package/lib/dist/resolution/tanstack-router-synthesizer.js +114 -0
  390. package/lib/dist/resolution/tanstack-router-synthesizer.js.map +1 -0
  391. package/lib/dist/resolution/tier-synthesizer.d.ts +49 -0
  392. package/lib/dist/resolution/tier-synthesizer.d.ts.map +1 -0
  393. package/lib/dist/resolution/tier-synthesizer.js +931 -0
  394. package/lib/dist/resolution/tier-synthesizer.js.map +1 -0
  395. package/lib/dist/resolution/types.d.ts +78 -2
  396. package/lib/dist/resolution/types.d.ts.map +1 -1
  397. package/lib/dist/resolution/types.js +64 -0
  398. package/lib/dist/resolution/types.js.map +1 -1
  399. package/lib/dist/resolution/vue-router-synthesizer.d.ts +30 -0
  400. package/lib/dist/resolution/vue-router-synthesizer.d.ts.map +1 -0
  401. package/lib/dist/resolution/vue-router-synthesizer.js +115 -0
  402. package/lib/dist/resolution/vue-router-synthesizer.js.map +1 -0
  403. package/lib/dist/search/query-paths.d.ts +50 -1
  404. package/lib/dist/search/query-paths.d.ts.map +1 -1
  405. package/lib/dist/search/query-paths.js +227 -12
  406. package/lib/dist/search/query-paths.js.map +1 -1
  407. package/lib/dist/search/query-utils.d.ts +15 -0
  408. package/lib/dist/search/query-utils.d.ts.map +1 -1
  409. package/lib/dist/search/query-utils.js +35 -7
  410. package/lib/dist/search/query-utils.js.map +1 -1
  411. package/lib/dist/sync/watch-policy.d.ts +14 -0
  412. package/lib/dist/sync/watch-policy.d.ts.map +1 -1
  413. package/lib/dist/sync/watch-policy.js +19 -0
  414. package/lib/dist/sync/watch-policy.js.map +1 -1
  415. package/lib/dist/sync/watcher.d.ts +52 -35
  416. package/lib/dist/sync/watcher.d.ts.map +1 -1
  417. package/lib/dist/sync/watcher.js +236 -100
  418. package/lib/dist/sync/watcher.js.map +1 -1
  419. package/lib/dist/telemetry/index.d.ts +4 -2
  420. package/lib/dist/telemetry/index.d.ts.map +1 -1
  421. package/lib/dist/telemetry/index.js +92 -41
  422. package/lib/dist/telemetry/index.js.map +1 -1
  423. package/lib/dist/types.d.ts +1 -1
  424. package/lib/dist/types.d.ts.map +1 -1
  425. package/lib/dist/types.js +1 -0
  426. package/lib/dist/types.js.map +1 -1
  427. package/lib/dist/ui-server/api/deadcode.d.ts +84 -0
  428. package/lib/dist/ui-server/api/deadcode.d.ts.map +1 -0
  429. package/lib/dist/ui-server/api/deadcode.js +136 -0
  430. package/lib/dist/ui-server/api/deadcode.js.map +1 -0
  431. package/lib/dist/ui-server/api/effects.d.ts +87 -0
  432. package/lib/dist/ui-server/api/effects.d.ts.map +1 -0
  433. package/lib/dist/ui-server/api/effects.js +499 -0
  434. package/lib/dist/ui-server/api/effects.js.map +1 -0
  435. package/lib/dist/ui-server/api/entrypoints.d.ts +86 -0
  436. package/lib/dist/ui-server/api/entrypoints.d.ts.map +1 -0
  437. package/lib/dist/ui-server/api/entrypoints.js +279 -0
  438. package/lib/dist/ui-server/api/entrypoints.js.map +1 -0
  439. package/lib/dist/ui-server/api/events.d.ts +183 -0
  440. package/lib/dist/ui-server/api/events.d.ts.map +1 -0
  441. package/lib/dist/ui-server/api/events.js +430 -0
  442. package/lib/dist/ui-server/api/events.js.map +1 -0
  443. package/lib/dist/ui-server/api/file.d.ts +66 -0
  444. package/lib/dist/ui-server/api/file.d.ts.map +1 -0
  445. package/lib/dist/ui-server/api/file.js +235 -0
  446. package/lib/dist/ui-server/api/file.js.map +1 -0
  447. package/lib/dist/ui-server/api/filecode.d.ts +126 -0
  448. package/lib/dist/ui-server/api/filecode.d.ts.map +1 -0
  449. package/lib/dist/ui-server/api/filecode.js +205 -0
  450. package/lib/dist/ui-server/api/filecode.js.map +1 -0
  451. package/lib/dist/ui-server/api/flow.d.ts +226 -0
  452. package/lib/dist/ui-server/api/flow.d.ts.map +1 -0
  453. package/lib/dist/ui-server/api/flow.js +612 -0
  454. package/lib/dist/ui-server/api/flow.js.map +1 -0
  455. package/lib/dist/ui-server/api/hierarchy.d.ts +81 -0
  456. package/lib/dist/ui-server/api/hierarchy.d.ts.map +1 -0
  457. package/lib/dist/ui-server/api/hierarchy.js +92 -0
  458. package/lib/dist/ui-server/api/hierarchy.js.map +1 -0
  459. package/lib/dist/ui-server/api/index.d.ts +90 -0
  460. package/lib/dist/ui-server/api/index.d.ts.map +1 -0
  461. package/lib/dist/ui-server/api/index.js +332 -0
  462. package/lib/dist/ui-server/api/index.js.map +1 -0
  463. package/lib/dist/ui-server/api/map.d.ts +238 -0
  464. package/lib/dist/ui-server/api/map.d.ts.map +1 -0
  465. package/lib/dist/ui-server/api/map.js +681 -0
  466. package/lib/dist/ui-server/api/map.js.map +1 -0
  467. package/lib/dist/ui-server/api/node.d.ts +81 -0
  468. package/lib/dist/ui-server/api/node.d.ts.map +1 -0
  469. package/lib/dist/ui-server/api/node.js +388 -0
  470. package/lib/dist/ui-server/api/node.js.map +1 -0
  471. package/lib/dist/ui-server/api/nodes.d.ts +25 -0
  472. package/lib/dist/ui-server/api/nodes.d.ts.map +1 -0
  473. package/lib/dist/ui-server/api/nodes.js +45 -0
  474. package/lib/dist/ui-server/api/nodes.js.map +1 -0
  475. package/lib/dist/ui-server/api/program.d.ts +139 -0
  476. package/lib/dist/ui-server/api/program.d.ts.map +1 -0
  477. package/lib/dist/ui-server/api/program.js +315 -0
  478. package/lib/dist/ui-server/api/program.js.map +1 -0
  479. package/lib/dist/ui-server/api/respond.d.ts +76 -0
  480. package/lib/dist/ui-server/api/respond.d.ts.map +1 -0
  481. package/lib/dist/ui-server/api/respond.js +186 -0
  482. package/lib/dist/ui-server/api/respond.js.map +1 -0
  483. package/lib/dist/ui-server/api/route-roots.d.ts +39 -0
  484. package/lib/dist/ui-server/api/route-roots.d.ts.map +1 -0
  485. package/lib/dist/ui-server/api/route-roots.js +96 -0
  486. package/lib/dist/ui-server/api/route-roots.js.map +1 -0
  487. package/lib/dist/ui-server/api/routes.d.ts +59 -0
  488. package/lib/dist/ui-server/api/routes.d.ts.map +1 -0
  489. package/lib/dist/ui-server/api/routes.js +108 -0
  490. package/lib/dist/ui-server/api/routes.js.map +1 -0
  491. package/lib/dist/ui-server/api/screens.d.ts +117 -0
  492. package/lib/dist/ui-server/api/screens.d.ts.map +1 -0
  493. package/lib/dist/ui-server/api/screens.js +611 -0
  494. package/lib/dist/ui-server/api/screens.js.map +1 -0
  495. package/lib/dist/ui-server/api/search.d.ts +29 -0
  496. package/lib/dist/ui-server/api/search.d.ts.map +1 -0
  497. package/lib/dist/ui-server/api/search.js +232 -0
  498. package/lib/dist/ui-server/api/search.js.map +1 -0
  499. package/lib/dist/ui-server/api/session.d.ts +52 -0
  500. package/lib/dist/ui-server/api/session.d.ts.map +1 -0
  501. package/lib/dist/ui-server/api/session.js +196 -0
  502. package/lib/dist/ui-server/api/session.js.map +1 -0
  503. package/lib/dist/ui-server/api/source.d.ts +200 -0
  504. package/lib/dist/ui-server/api/source.d.ts.map +1 -0
  505. package/lib/dist/ui-server/api/source.js +422 -0
  506. package/lib/dist/ui-server/api/source.js.map +1 -0
  507. package/lib/dist/ui-server/api/stats.d.ts +27 -0
  508. package/lib/dist/ui-server/api/stats.d.ts.map +1 -0
  509. package/lib/dist/ui-server/api/stats.js +164 -0
  510. package/lib/dist/ui-server/api/stats.js.map +1 -0
  511. package/lib/dist/ui-server/api/steps.d.ts +274 -0
  512. package/lib/dist/ui-server/api/steps.d.ts.map +1 -0
  513. package/lib/dist/ui-server/api/steps.js +1446 -0
  514. package/lib/dist/ui-server/api/steps.js.map +1 -0
  515. package/lib/dist/ui-server/api/trail-store.d.ts +142 -0
  516. package/lib/dist/ui-server/api/trail-store.d.ts.map +1 -0
  517. package/lib/dist/ui-server/api/trail-store.js +323 -0
  518. package/lib/dist/ui-server/api/trail-store.js.map +1 -0
  519. package/lib/dist/ui-server/api/trails.d.ts +163 -0
  520. package/lib/dist/ui-server/api/trails.d.ts.map +1 -0
  521. package/lib/dist/ui-server/api/trails.js +369 -0
  522. package/lib/dist/ui-server/api/trails.js.map +1 -0
  523. package/lib/dist/ui-server/api/when.d.ts +125 -0
  524. package/lib/dist/ui-server/api/when.d.ts.map +1 -0
  525. package/lib/dist/ui-server/api/when.js +251 -0
  526. package/lib/dist/ui-server/api/when.js.map +1 -0
  527. package/lib/dist/ui-server/api/wire.d.ts +179 -0
  528. package/lib/dist/ui-server/api/wire.d.ts.map +1 -0
  529. package/lib/dist/ui-server/api/wire.js +231 -0
  530. package/lib/dist/ui-server/api/wire.js.map +1 -0
  531. package/lib/dist/ui-server/assets.d.ts +40 -0
  532. package/lib/dist/ui-server/assets.d.ts.map +1 -0
  533. package/lib/dist/ui-server/assets.js +110 -0
  534. package/lib/dist/ui-server/assets.js.map +1 -0
  535. package/lib/dist/ui-server/constants.d.ts +32 -0
  536. package/lib/dist/ui-server/constants.d.ts.map +1 -0
  537. package/lib/dist/ui-server/constants.js +35 -0
  538. package/lib/dist/ui-server/constants.js.map +1 -0
  539. package/lib/dist/ui-server/highlight/index.d.ts +113 -0
  540. package/lib/dist/ui-server/highlight/index.d.ts.map +1 -0
  541. package/lib/dist/ui-server/highlight/index.js +307 -0
  542. package/lib/dist/ui-server/highlight/index.js.map +1 -0
  543. package/lib/dist/ui-server/highlight/languages.d.ts +36 -0
  544. package/lib/dist/ui-server/highlight/languages.d.ts.map +1 -0
  545. package/lib/dist/ui-server/highlight/languages.js +50 -0
  546. package/lib/dist/ui-server/highlight/languages.js.map +1 -0
  547. package/lib/dist/ui-server/index.d.ts +92 -0
  548. package/lib/dist/ui-server/index.d.ts.map +1 -0
  549. package/lib/dist/ui-server/index.js +399 -0
  550. package/lib/dist/ui-server/index.js.map +1 -0
  551. package/lib/dist/ui-server/open-browser.d.ts +31 -0
  552. package/lib/dist/ui-server/open-browser.d.ts.map +1 -0
  553. package/lib/dist/ui-server/open-browser.js +79 -0
  554. package/lib/dist/ui-server/open-browser.js.map +1 -0
  555. package/lib/dist/ui-server/security.d.ts +127 -0
  556. package/lib/dist/ui-server/security.d.ts.map +1 -0
  557. package/lib/dist/ui-server/security.js +332 -0
  558. package/lib/dist/ui-server/security.js.map +1 -0
  559. package/lib/dist/ui-server/static.d.ts +45 -0
  560. package/lib/dist/ui-server/static.d.ts.map +1 -0
  561. package/lib/dist/ui-server/static.js +165 -0
  562. package/lib/dist/ui-server/static.js.map +1 -0
  563. package/lib/dist/utils.d.ts +14 -2
  564. package/lib/dist/utils.d.ts.map +1 -1
  565. package/lib/dist/utils.js +25 -10
  566. package/lib/dist/utils.js.map +1 -1
  567. package/lib/dist/viewer/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
  568. package/lib/dist/viewer/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
  569. package/lib/dist/viewer/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
  570. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-2syK4fUT.woff +0 -0
  571. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-CBJ8pzag.woff2 +0 -0
  572. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  573. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  574. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
  575. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
  576. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-CTOM6hUh.woff2 +0 -0
  577. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-fLZuRloM.woff +0 -0
  578. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-B4oTjJdl.woff +0 -0
  579. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-CBjNughH.woff2 +0 -0
  580. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  581. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  582. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
  583. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
  584. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-9HEixskS.woff +0 -0
  585. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-V-xxqcpd.woff2 +0 -0
  586. package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-italic-66oory27.woff +0 -0
  587. package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-italic-BqAiT5Ww.woff2 +0 -0
  588. package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  589. package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  590. package/lib/dist/viewer/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  591. package/lib/dist/viewer/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  592. package/lib/dist/viewer/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  593. package/lib/dist/viewer/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
  594. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-B7_fu1kp.woff2 +0 -0
  595. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-Bg0ZHwF4.woff +0 -0
  596. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  597. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  598. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
  599. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
  600. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-D38SheWl.woff2 +0 -0
  601. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-DmB0ttJJ.woff +0 -0
  602. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-D6eaYXMU.woff +0 -0
  603. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-DRuN92E5.woff2 +0 -0
  604. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  605. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  606. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
  607. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
  608. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-D2EvbN8M.woff2 +0 -0
  609. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-iLQfcSjf.woff +0 -0
  610. package/lib/dist/viewer/assets/index-CF9yvio6.css +1 -0
  611. package/lib/dist/viewer/assets/index-D4S7YUPf.js +97 -0
  612. package/lib/dist/viewer/index.html +16 -0
  613. package/lib/kernel/codegraph-kernel.node +2 -2
  614. package/lib/node_modules/.package-lock.json +4 -4
  615. package/lib/node_modules/picomatch/README.md +56 -51
  616. package/lib/node_modules/picomatch/lib/constants.js +4 -0
  617. package/lib/node_modules/picomatch/lib/parse.js +341 -1
  618. package/lib/node_modules/picomatch/lib/picomatch.js +25 -5
  619. package/lib/node_modules/picomatch/lib/scan.js +30 -18
  620. package/lib/node_modules/picomatch/package.json +4 -4
  621. package/lib/package.json +9 -2
  622. package/package.json +1 -1
@@ -40,6 +40,23 @@ function isLowValueFile(filePath, generated) {
40
40
  (0, generated_detection_1.isGeneratedFile)(filePath));
41
41
  }
42
42
  const SQLITE_PARAM_CHUNK_SIZE = 500;
43
+ /**
44
+ * A SQL predicate: is the node aliased `alias` a member an INTERFACE declares?
45
+ *
46
+ * `method_signature` / `property_signature` enter the graph as `method` /
47
+ * `property` nodes hung off their interface by a `contains` edge (#1638). They
48
+ * have no body and originate no behaviour, so for a structural judgement about
49
+ * a FILE they are the interface restated, not an extra thing the file declares.
50
+ * See {@link QueryBuilder.getAmbientDeclarationPathsAmong}, the one caller, for
51
+ * why treating them as opaque would break that rule in three places at once.
52
+ *
53
+ * Seeks `idx_edges_target_kind`, so it costs a key lookup per row rather than a
54
+ * join over the whole edge table.
55
+ */
56
+ const IS_INTERFACE_MEMBER = (alias) => `EXISTS (
57
+ SELECT 1 FROM edges ce JOIN nodes owner ON owner.id = ce.source
58
+ WHERE ce.target = ${alias}.id AND ce.kind = 'contains' AND owner.kind = 'interface'
59
+ )`;
43
60
  /**
44
61
  * How much of the exact-name bonus a `deprioritize`d path keeps (#982). Damped
45
62
  * rather than zeroed: a query that genuinely targets that tree must still rank
@@ -139,9 +156,15 @@ class QueryBuilder {
139
156
  // Set once by the CodeGraph instance; empty by default (no down-weighting).
140
157
  projectNameTokens = new Set();
141
158
  isDeprioritizedPath;
159
+ // FTS5 availability flag — detected once at construction time (#1532)
160
+ _fts5Available;
142
161
  // Node cache for frequently accessed nodes (LRU-style, max 1000 entries)
143
162
  nodeCache = new Map();
144
163
  maxCacheSize = 1000;
164
+ // getDominantFile()'s answer, tagged with the database change stamp it was
165
+ // computed under (see getChangeStamp). Query-independent, so one value
166
+ // serves every explore until the database changes (#1864).
167
+ dominantFileMemo;
145
168
  // Prepared statements (lazily initialized)
146
169
  stmts = {};
147
170
  // Names whose segments were already written this session — skips re-splitting
@@ -158,6 +181,11 @@ class QueryBuilder {
158
181
  // (and therefore resolution's insertion-order disambiguation) is identical
159
182
  // to the one-row-per-run path.
160
183
  batchStmts = new Map();
184
+ // Kind-filtered edge reads build their SQL per call (a variable IN list),
185
+ // but from a handful of kind sets: prepare each shape once. Supertype walks
186
+ // and the member-lookup passes issue them per node, and preparing cost
187
+ // about a third of the read.
188
+ edgeKindStmts = new Map();
161
189
  static BATCH_SIZES = [128, 32, 8, 1];
162
190
  /**
163
191
  * Run `rows` through a multi-row `INSERT` built as `head + (tuple,)*n`,
@@ -193,6 +221,14 @@ class QueryBuilder {
193
221
  }
194
222
  constructor(db) {
195
223
  this.db = db;
224
+ // Detect FTS5 availability once (#1532)
225
+ try {
226
+ db.prepare("SELECT * FROM nodes_fts LIMIT 0").get();
227
+ this._fts5Available = true;
228
+ }
229
+ catch {
230
+ this._fts5Available = false;
231
+ }
196
232
  }
197
233
  /**
198
234
  * Swap the underlying connection in place. Used by pool workers'
@@ -210,6 +246,21 @@ class QueryBuilder {
210
246
  this.db = db;
211
247
  this.stmts = {};
212
248
  this.batchStmts.clear();
249
+ this.edgeKindStmts.clear();
250
+ // The change stamp is per connection, and fresh connections to two
251
+ // different databases report the same one — the memo goes with the old
252
+ // connection, or a worker following a rebuilt index keeps its answer (#1864).
253
+ this.dominantFileMemo = undefined;
254
+ }
255
+ edgeKindStmt(sql) {
256
+ let stmt = this.edgeKindStmts.get(sql);
257
+ if (!stmt) {
258
+ if (this.edgeKindStmts.size >= 64)
259
+ this.edgeKindStmts.delete(this.edgeKindStmts.keys().next().value);
260
+ stmt = this.db.prepare(sql);
261
+ this.edgeKindStmts.set(sql, stmt);
262
+ }
263
+ return stmt;
213
264
  }
214
265
  /** Set the normalized project-name tokens used to down-weight non-discriminative
215
266
  * query words in path scoring (#720). Called once when the project opens. */
@@ -688,10 +739,16 @@ class QueryBuilder {
688
739
  const uniqueIds = [...new Set(ids)];
689
740
  for (let i = 0; i < uniqueIds.length; i += SQLITE_PARAM_CHUNK_SIZE) {
690
741
  const chunk = uniqueIds.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
691
- const placeholders = chunk.map(() => '?').join(',');
692
- const rows = this.db
693
- .prepare(`SELECT id FROM nodes WHERE id IN (${placeholders})`)
694
- .all(...chunk);
742
+ // Every edge insert checks its endpoints here, a chunk at a time: the
743
+ // full-size statement is prepared once, the final partial chunk ad hoc.
744
+ let stmt;
745
+ if (chunk.length === SQLITE_PARAM_CHUNK_SIZE) {
746
+ stmt = this.stmts.existingNodeIdsFull ??= this.db.prepare(`SELECT id FROM nodes WHERE id IN (${new Array(SQLITE_PARAM_CHUNK_SIZE).fill('?').join(',')})`);
747
+ }
748
+ else {
749
+ stmt = this.db.prepare(`SELECT id FROM nodes WHERE id IN (${chunk.map(() => '?').join(',')})`);
750
+ }
751
+ const rows = stmt.all(...chunk);
695
752
  for (const row of rows) {
696
753
  out.add(row.id);
697
754
  }
@@ -717,16 +774,58 @@ class QueryBuilder {
717
774
  clearCache() {
718
775
  this.nodeCache.clear();
719
776
  }
777
+ /**
778
+ * Whether any node in `filePath` is exported — `getNodesByFile(f).some((n) =>
779
+ * n.isExported)` as one indexed probe, without decoding the file's nodes.
780
+ */
781
+ fileHasExportedNode(filePath) {
782
+ if (!this.stmts.fileHasExportedNode) {
783
+ this.stmts.fileHasExportedNode = this.db.prepare('SELECT 1 FROM nodes WHERE file_path = ? AND is_exported = 1 LIMIT 1');
784
+ }
785
+ return this.stmts.fileHasExportedNode.get(filePath) !== undefined;
786
+ }
787
+ /** The exported nodes of a file, in {@link getNodesByFile} order, decoding only those rows. */
788
+ getExportedNodesByFile(filePath) {
789
+ if (!this.stmts.getExportedNodesByFile) {
790
+ this.stmts.getExportedNodesByFile = this.db.prepare('SELECT * FROM nodes WHERE file_path = ? AND is_exported = 1 ORDER BY start_line, id');
791
+ }
792
+ return this.stmts.getExportedNodesByFile.all(filePath).map(rowToNode);
793
+ }
794
+ /** The nodes of a file with one name, in {@link getNodesByFile} order, decoding only those rows. */
795
+ getNodesByFileAndName(filePath, name) {
796
+ if (!this.stmts.getNodesByFileAndName) {
797
+ this.stmts.getNodesByFileAndName = this.db.prepare('SELECT * FROM nodes WHERE file_path = ? AND name = ? ORDER BY start_line, id');
798
+ }
799
+ return this.stmts.getNodesByFileAndName.all(filePath, name).map(rowToNode);
800
+ }
720
801
  /**
721
802
  * Get all nodes in a file
722
803
  */
723
804
  getNodesByFile(filePath) {
724
805
  if (!this.stmts.getNodesByFile) {
725
- this.stmts.getNodesByFile = this.db.prepare('SELECT * FROM nodes WHERE file_path = ? ORDER BY start_line');
806
+ this.stmts.getNodesByFile = this.db.prepare('SELECT * FROM nodes WHERE file_path = ? ORDER BY start_line, id');
726
807
  }
727
808
  const rows = this.stmts.getNodesByFile.all(filePath);
728
809
  return rows.map(rowToNode);
729
810
  }
811
+ /**
812
+ * Get all nodes in several files at once — one chunked `IN` query rather than
813
+ * one {@link getNodesByFile} per file (#1975).
814
+ */
815
+ getNodesByFiles(filePaths) {
816
+ const unique = [...new Set(filePaths)];
817
+ const out = [];
818
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
819
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
820
+ const placeholders = chunk.map(() => '?').join(',');
821
+ const rows = this.db
822
+ .prepare(`SELECT * FROM nodes WHERE file_path IN (${placeholders})`)
823
+ .all(...chunk);
824
+ for (const row of rows)
825
+ out.push(rowToNode(row));
826
+ }
827
+ return out;
828
+ }
730
829
  /**
731
830
  * Find the file that holds the densest concentration of the project's
732
831
  * internal call graph — the "core" file. Used by context-builder to
@@ -744,8 +843,46 @@ class QueryBuilder {
744
843
  * Excludes test/spec files from candidacy via path-pattern. The agent's
745
844
  * typical question is "how does X work", not "how is X tested", so
746
845
  * boosting a test file's directory would be a misfire.
846
+ *
847
+ * The answer depends only on the graph, never on the query, and the
848
+ * aggregation behind it scans every edge — seconds on a large index, paid
849
+ * by every generic explore (#1864). So it is memoized per database change
850
+ * stamp: recomputed only after something wrote to the database.
747
851
  */
748
852
  getDominantFile() {
853
+ // total_changes() counts writes that are later rolled back, so a result
854
+ // read inside a transaction could outlive a ROLLBACK under an unchanged
855
+ // stamp. Never keep one; `undefined` (a runtime without the getter) is
856
+ // treated the same way.
857
+ if (this.db.inTransaction !== false) {
858
+ this.dominantFileMemo = undefined;
859
+ return this.computeDominantFile();
860
+ }
861
+ const stamp = this.getChangeStamp();
862
+ if (this.dominantFileMemo?.stamp === stamp)
863
+ return this.dominantFileMemo.value;
864
+ const value = this.computeDominantFile();
865
+ this.dominantFileMemo = { stamp, value };
866
+ return value;
867
+ }
868
+ /**
869
+ * A value that differs whenever the database content may have changed
870
+ * since the last call, whoever changed it: `total_changes()` counts the
871
+ * rows this connection inserted, updated or deleted, and
872
+ * `PRAGMA data_version` moves when any OTHER connection — another process's
873
+ * sync, a CLI `codegraph index` beside a running MCP server — commits. Both
874
+ * are O(1), so no write path has to remember to invalidate anything.
875
+ * Coarse on purpose: any write, not just one to nodes/edges, forces a
876
+ * recompute, which only costs time, never a stale answer.
877
+ */
878
+ getChangeStamp() {
879
+ if (!this.stmts.getChangeStamp) {
880
+ this.stmts.getChangeStamp = this.db.prepare('SELECT total_changes() AS changes, (SELECT data_version FROM pragma_data_version) AS version');
881
+ }
882
+ const row = this.stmts.getChangeStamp.get();
883
+ return `${row.changes}:${row.version}`;
884
+ }
885
+ computeDominantFile() {
749
886
  if (!this.stmts.getDominantFile) {
750
887
  // Pull top 20 candidates; we then filter out test/generated files
751
888
  // in code (regex-grade matching that SQL LIKE can't express). The
@@ -831,6 +968,9 @@ class QueryBuilder {
831
968
  this.stmts.getRoutingManifest = this.db.prepare(`
832
969
  SELECT
833
970
  r.name AS url,
971
+ r.id AS route_id,
972
+ r.file_path AS route_file,
973
+ r.start_line AS route_line,
834
974
  h.name AS handler,
835
975
  h.file_path AS handler_file,
836
976
  h.start_line AS handler_line,
@@ -840,7 +980,7 @@ class QueryBuilder {
840
980
  JOIN nodes h ON e.target = h.id
841
981
  WHERE r.kind = 'route'
842
982
  AND e.kind IN ('references', 'calls')
843
- AND h.kind IN ('function', 'method', 'class')
983
+ AND h.kind IN ('function', 'method', 'class', 'constant', 'variable')
844
984
  ORDER BY r.file_path, r.start_line
845
985
  LIMIT ?
846
986
  `);
@@ -871,6 +1011,9 @@ class QueryBuilder {
871
1011
  handlerFile: r.handler_file,
872
1012
  handlerLine: r.handler_line,
873
1013
  handlerKind: r.handler_kind,
1014
+ routeId: r.route_id,
1015
+ routeFile: r.route_file,
1016
+ routeLine: r.route_line,
874
1017
  })),
875
1018
  topHandlerFile,
876
1019
  topHandlerFileCount,
@@ -882,7 +1025,7 @@ class QueryBuilder {
882
1025
  */
883
1026
  getNodesByKind(kind) {
884
1027
  if (!this.stmts.getNodesByKind) {
885
- this.stmts.getNodesByKind = this.db.prepare('SELECT * FROM nodes WHERE kind = ?');
1028
+ this.stmts.getNodesByKind = this.db.prepare('SELECT * FROM nodes WHERE kind = ? ORDER BY file_path, start_line, id');
886
1029
  }
887
1030
  const rows = this.stmts.getNodesByKind.all(kind);
888
1031
  return rows.map(rowToNode);
@@ -897,11 +1040,29 @@ class QueryBuilder {
897
1040
  *iterateNodesByKind(kind) {
898
1041
  // Fresh statement per call (not a cached one): an iterator holds an open
899
1042
  // cursor, so a shared statement would conflict across overlapping scans.
900
- const stmt = this.db.prepare('SELECT * FROM nodes WHERE kind = ?');
1043
+ // Synthesis uses first/last-match precedence and caps: insertion order
1044
+ // changes on sync. idx_nodes_kind streams this canonical order without
1045
+ // materializing/sorting all of a large project's methods in memory.
1046
+ const stmt = this.db.prepare('SELECT * FROM nodes WHERE kind = ? ORDER BY file_path, start_line, id');
901
1047
  for (const row of stmt.iterate(kind)) {
902
1048
  yield rowToNode(row);
903
1049
  }
904
1050
  }
1051
+ /**
1052
+ * iterateNodesByKind narrowed to some languages, in the same canonical
1053
+ * order — the ORDER BY is total (`id` is unique), so this yields exactly the
1054
+ * nodes a caller filtering iterateNodesByKind by language would keep, in the
1055
+ * same sequence. A Go pass on a TypeScript monorepo otherwise materialized
1056
+ * every method in the project to find a couple of Go ones.
1057
+ */
1058
+ *iterateNodesByKindIn(kind, languages) {
1059
+ if (languages.length === 0)
1060
+ return;
1061
+ const stmt = this.db.prepare(`SELECT * FROM nodes WHERE kind = ? AND language IN (${languages.map(() => '?').join(', ')}) ORDER BY file_path, start_line, id`);
1062
+ for (const row of stmt.iterate(kind, ...languages)) {
1063
+ yield rowToNode(row);
1064
+ }
1065
+ }
905
1066
  /**
906
1067
  * Get all nodes in the database
907
1068
  */
@@ -921,7 +1082,7 @@ class QueryBuilder {
921
1082
  *iterateNodesByLanguageWithDecorator(language, decorator) {
922
1083
  // Fresh statement per call — an iterator holds an open cursor (see
923
1084
  // iterateNodesByKind).
924
- const stmt = this.db.prepare("SELECT * FROM nodes WHERE language = ? AND decorators LIKE '%' || ? || '%'");
1085
+ const stmt = this.db.prepare("SELECT * FROM nodes WHERE language = ? AND decorators LIKE '%' || ? || '%' ORDER BY file_path, start_line, id");
925
1086
  for (const row of stmt.iterate(language, `"${decorator}"`)) {
926
1087
  yield rowToNode(row);
927
1088
  }
@@ -956,7 +1117,7 @@ class QueryBuilder {
956
1117
  */
957
1118
  getNodesByName(name) {
958
1119
  if (!this.stmts.getNodesByName) {
959
- this.stmts.getNodesByName = this.db.prepare('SELECT * FROM nodes WHERE name = ? ORDER BY file_path, start_line');
1120
+ this.stmts.getNodesByName = this.db.prepare('SELECT * FROM nodes WHERE name = ? ORDER BY file_path, start_line, id');
960
1121
  }
961
1122
  const rows = this.stmts.getNodesByName.all(name);
962
1123
  return rows.map(rowToNode);
@@ -972,12 +1133,20 @@ class QueryBuilder {
972
1133
  const rows = this.stmts.getNodesByNamePrefix.all(prefix, prefix + '￿', limit);
973
1134
  return rows.map(rowToNode);
974
1135
  }
1136
+ /** File nodes whose basename starts with `prefix`, without a result cap. */
1137
+ getFileNodesByNamePrefix(prefix) {
1138
+ if (!this.stmts.getFileNodesByNamePrefix) {
1139
+ this.stmts.getFileNodesByNamePrefix = this.db.prepare("SELECT * FROM nodes WHERE kind = 'file' AND name >= ? AND name < ? ORDER BY name");
1140
+ }
1141
+ const rows = this.stmts.getFileNodesByNamePrefix.all(prefix, prefix + '￿');
1142
+ return rows.map(rowToNode);
1143
+ }
975
1144
  /**
976
1145
  * Get nodes by exact qualified name match (uses idx_nodes_qualified_name index)
977
1146
  */
978
1147
  getNodesByQualifiedNameExact(qualifiedName) {
979
1148
  if (!this.stmts.getNodesByQualifiedNameExact) {
980
- this.stmts.getNodesByQualifiedNameExact = this.db.prepare('SELECT * FROM nodes WHERE qualified_name = ?');
1149
+ this.stmts.getNodesByQualifiedNameExact = this.db.prepare('SELECT * FROM nodes WHERE qualified_name = ? ORDER BY file_path, start_line, id');
981
1150
  }
982
1151
  const rows = this.stmts.getNodesByQualifiedNameExact.all(qualifiedName);
983
1152
  return rows.map(rowToNode);
@@ -1033,9 +1202,9 @@ class QueryBuilder {
1033
1202
  const text = parsed.text;
1034
1203
  const kinds = mergedKinds;
1035
1204
  const languages = mergedLanguages;
1036
- // First try FTS5 with prefix matching
1205
+ // First try FTS5 with prefix matching (skip if FTS5 not available, #1532)
1037
1206
  let results = text
1038
- ? this.searchNodesFTS(text, { kinds, languages, limit, offset })
1207
+ ? (this._fts5Available !== false ? this.searchNodesFTS(text, { kinds, languages, limit, offset }) : [])
1039
1208
  // Over-fetch by 5× when running filter-only (no text). The
1040
1209
  // post-scoring path: + name: filters can be very selective, so
1041
1210
  // a smaller multiplier risks returning fewer than `limit`
@@ -1227,6 +1396,46 @@ class QueryBuilder {
1227
1396
  }
1228
1397
  return results;
1229
1398
  }
1399
+ /** Bounded miss diagnostics, independent of relevance filters and ranking. */
1400
+ getExploreMissDiagnostics(query) {
1401
+ const words = [...new Set((query.match(/[\p{L}\p{N}]+/gu) ?? []).map(w => w.toLowerCase()))];
1402
+ const checked = words.filter(w => w.length <= 64).slice(0, 16);
1403
+ const limited = checked.length !== words.length;
1404
+ if (checked.length === 0)
1405
+ return { matched: [], unmatched: [], candidates: [], limited };
1406
+ // EXISTS uses FTS postings and the segment primary key, never source scans.
1407
+ // Vocab rows can outlive deleted definitions, so verify them against nodes.
1408
+ const rows = this.db.prepare(`
1409
+ WITH words(word, pattern) AS (VALUES ${checked.map(() => '(?, ?)').join(', ')})
1410
+ SELECT word, (
1411
+ EXISTS (SELECT 1 FROM nodes_fts WHERE nodes_fts MATCH pattern)
1412
+ OR EXISTS (
1413
+ SELECT 1 FROM name_segment_vocab v WHERE v.segment = word
1414
+ AND EXISTS (SELECT 1 FROM nodes n WHERE n.name = v.name AND n.kind NOT IN ('file', 'import'))
1415
+ )
1416
+ ) AS matched FROM words
1417
+ `).all(...checked.flatMap(w => [w, `{name qualified_name signature docstring} : "${w}"*`]));
1418
+ const names = this.db.prepare(`
1419
+ SELECT name FROM (
1420
+ SELECT v.name FROM name_segment_vocab v
1421
+ WHERE v.segment IN (${checked.map(() => '?').join(', ')})
1422
+ AND EXISTS (SELECT 1 FROM nodes n WHERE n.name = v.name AND n.kind NOT IN ('file', 'import'))
1423
+ LIMIT 12
1424
+ )
1425
+ UNION ALL
1426
+ SELECT name FROM (
1427
+ SELECT n.name FROM nodes_fts JOIN nodes n ON n.rowid = nodes_fts.rowid
1428
+ WHERE nodes_fts MATCH ? AND n.kind NOT IN ('file', 'import')
1429
+ LIMIT 12
1430
+ )
1431
+ `).all(...checked, `name : (${checked.map(w => `"${w}"*`).join(' OR ')})`);
1432
+ return {
1433
+ matched: rows.filter(r => r.matched).map(r => r.word),
1434
+ unmatched: rows.filter(r => !r.matched).map(r => r.word),
1435
+ candidates: [...new Set(names.map(r => r.name))].slice(0, 12),
1436
+ limited,
1437
+ };
1438
+ }
1230
1439
  /**
1231
1440
  * FTS5 search with prefix matching
1232
1441
  */
@@ -1464,6 +1673,30 @@ class QueryBuilder {
1464
1673
  // ===========================================================================
1465
1674
  // Edge Operations
1466
1675
  // ===========================================================================
1676
+ /** Must run before file replacement/deletion cascades the endpoint edges. */
1677
+ hasSynthesizedEdgesTouchingFile(filePath) {
1678
+ const owned = "CASE WHEN json_valid(e.metadata) THEN json_extract(e.metadata, '$.synthesizedBy') END IS NOT NULL";
1679
+ for (const endpoint of ['source', 'target']) {
1680
+ if (this.db.prepare(`SELECT 1 FROM nodes n JOIN edges e ON e.${endpoint} = n.id
1681
+ WHERE n.file_path = ? AND ${owned} LIMIT 1`).get(filePath))
1682
+ return true;
1683
+ }
1684
+ // Wiring often lives in a third file, with neither endpoint in it.
1685
+ return !!this.db.prepare(`SELECT 1 FROM edges e WHERE ${owned}
1686
+ AND CASE WHEN json_valid(e.metadata) THEN json_extract(e.metadata, '$.registeredAt') END >= ?
1687
+ AND CASE WHEN json_valid(e.metadata) THEN json_extract(e.metadata, '$.registeredAt') END < ? LIMIT 1`).get(`${filePath}:`, `${filePath};`);
1688
+ }
1689
+ wasSynthesisInput(filePath) {
1690
+ return !!this.db.prepare('SELECT 1 FROM synthesis_inputs WHERE file_path = ?').get(filePath);
1691
+ }
1692
+ replaceSynthesisInputs(files) {
1693
+ this.db.transaction(() => {
1694
+ this.db.exec('DELETE FROM synthesis_inputs');
1695
+ const insert = this.db.prepare('INSERT INTO synthesis_inputs(file_path) VALUES (?)');
1696
+ for (const file of files)
1697
+ insert.run(file);
1698
+ })();
1699
+ }
1467
1700
  /**
1468
1701
  * Insert a new edge
1469
1702
  */
@@ -1525,7 +1758,8 @@ class QueryBuilder {
1525
1758
  this.stmts.deleteEdgesBySource.run(sourceId);
1526
1759
  }
1527
1760
  /**
1528
- * Get outgoing edges from a node
1761
+ * Get outgoing edges from a node. Preserve the source/kind index order
1762
+ * (calls before imports/references), then break ties deterministically.
1529
1763
  */
1530
1764
  getOutgoingEdges(sourceId, kinds, provenance) {
1531
1765
  if ((kinds && kinds.length > 0) || provenance) {
@@ -1539,30 +1773,640 @@ class QueryBuilder {
1539
1773
  sql += ' AND provenance = ?';
1540
1774
  params.push(provenance);
1541
1775
  }
1542
- const rows = this.db.prepare(sql).all(...params);
1776
+ sql += ' ORDER BY kind, target, line, col';
1777
+ const rows = this.edgeKindStmt(sql).all(...params);
1543
1778
  return rows.map(rowToEdge);
1544
1779
  }
1545
1780
  if (!this.stmts.getEdgesBySource) {
1546
- this.stmts.getEdgesBySource = this.db.prepare('SELECT * FROM edges WHERE source = ?');
1781
+ this.stmts.getEdgesBySource = this.db.prepare('SELECT * FROM edges WHERE source = ? ORDER BY kind, target, line, col');
1547
1782
  }
1548
1783
  const rows = this.stmts.getEdgesBySource.all(sourceId);
1549
1784
  return rows.map(rowToEdge);
1550
1785
  }
1551
1786
  /**
1552
- * Get incoming edges to a node
1787
+ * Get incoming edges to a node. Kind must precede opaque source IDs:
1788
+ * file IDs sort before function IDs, so source-first ordering lets imports
1789
+ * displace actual calls in capped caller lists. Keep deterministic ties
1790
+ * without changing the target/kind index's established kind precedence.
1553
1791
  */
1554
1792
  getIncomingEdges(targetId, kinds) {
1555
1793
  if (kinds && kinds.length > 0) {
1556
- const sql = `SELECT * FROM edges WHERE target = ? AND kind IN (${kinds.map(() => '?').join(',')})`;
1557
- const rows = this.db.prepare(sql).all(targetId, ...kinds);
1794
+ const sql = `SELECT * FROM edges WHERE target = ? AND kind IN (${kinds.map(() => '?').join(',')}) ORDER BY kind, source, line, col`;
1795
+ const rows = this.edgeKindStmt(sql).all(targetId, ...kinds);
1558
1796
  return rows.map(rowToEdge);
1559
1797
  }
1560
1798
  if (!this.stmts.getEdgesByTarget) {
1561
- this.stmts.getEdgesByTarget = this.db.prepare('SELECT * FROM edges WHERE target = ?');
1799
+ this.stmts.getEdgesByTarget = this.db.prepare('SELECT * FROM edges WHERE target = ? ORDER BY kind, source, line, col');
1562
1800
  }
1563
1801
  const rows = this.stmts.getEdgesByTarget.all(targetId);
1564
1802
  return rows.map(rowToEdge);
1565
1803
  }
1804
+ /**
1805
+ * Outgoing edges for MANY source nodes in one query.
1806
+ *
1807
+ * The batch form of {@link getOutgoingEdges}. Building a nested outline needs
1808
+ * the `contains` edges of every container in a file at once; doing that one
1809
+ * source at a time is a query per symbol on files that have hundreds.
1810
+ */
1811
+ getOutgoingEdgesFrom(sourceIds, kinds) {
1812
+ if (sourceIds.length === 0)
1813
+ return [];
1814
+ const unique = [...new Set(sourceIds)];
1815
+ const out = [];
1816
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
1817
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
1818
+ const placeholders = chunk.map(() => '?').join(',');
1819
+ let sql = `SELECT * FROM edges WHERE source IN (${placeholders})`;
1820
+ const params = [...chunk];
1821
+ if (kinds && kinds.length > 0) {
1822
+ sql += ` AND kind IN (${kinds.map(() => '?').join(',')})`;
1823
+ params.push(...kinds);
1824
+ }
1825
+ const rows = this.db.prepare(sql).all(...params);
1826
+ for (const row of rows)
1827
+ out.push(rowToEdge(row));
1828
+ }
1829
+ return out;
1830
+ }
1831
+ /**
1832
+ * Fan-in (total incoming edge count) for MANY nodes in one query.
1833
+ *
1834
+ * The per-node alternative — `getIncomingEdges(id).length` — is an indexed
1835
+ * lookup each, but a symbol screen rendering a couple of hundred callees
1836
+ * would issue a couple of hundred of them. Ids with no incoming edges are
1837
+ * absent from the map rather than present as 0, so callers can tell "no
1838
+ * edges" from "not asked about".
1839
+ */
1840
+ countIncomingEdges(ids) {
1841
+ const out = new Map();
1842
+ if (ids.length === 0)
1843
+ return out;
1844
+ const unique = [...new Set(ids)];
1845
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
1846
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
1847
+ const placeholders = chunk.map(() => '?').join(',');
1848
+ const rows = this.db
1849
+ .prepare(`SELECT target, COUNT(*) AS count FROM edges WHERE target IN (${placeholders}) GROUP BY target`)
1850
+ .all(...chunk);
1851
+ for (const row of rows)
1852
+ out.set(row.target, row.count);
1853
+ }
1854
+ return out;
1855
+ }
1856
+ /**
1857
+ * Incoming edges for MANY target nodes in one query — the mirror of
1858
+ * {@link getOutgoingEdgesFrom}. Needed wherever a whole file's inbound edges
1859
+ * are wanted at once ("which files import anything in this one?").
1860
+ */
1861
+ getIncomingEdgesTo(targetIds, kinds) {
1862
+ if (targetIds.length === 0)
1863
+ return [];
1864
+ const unique = [...new Set(targetIds)];
1865
+ const out = [];
1866
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
1867
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
1868
+ const placeholders = chunk.map(() => '?').join(',');
1869
+ let sql = `SELECT * FROM edges WHERE target IN (${placeholders})`;
1870
+ const params = [...chunk];
1871
+ if (kinds && kinds.length > 0) {
1872
+ sql += ` AND kind IN (${kinds.map(() => '?').join(',')})`;
1873
+ params.push(...kinds);
1874
+ }
1875
+ const rows = this.db.prepare(sql).all(...params);
1876
+ for (const row of rows)
1877
+ out.push(rowToEdge(row));
1878
+ }
1879
+ return out;
1880
+ }
1881
+ /**
1882
+ * Fan-out (total outgoing edge count) for MANY nodes in one query — the
1883
+ * mirror of {@link countIncomingEdges}. Ids with no outgoing edges are absent
1884
+ * from the map rather than present as 0.
1885
+ */
1886
+ countOutgoingEdges(ids) {
1887
+ const out = new Map();
1888
+ if (ids.length === 0)
1889
+ return out;
1890
+ const unique = [...new Set(ids)];
1891
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
1892
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
1893
+ const placeholders = chunk.map(() => '?').join(',');
1894
+ const rows = this.db
1895
+ .prepare(`SELECT source, COUNT(*) AS count FROM edges WHERE source IN (${placeholders}) GROUP BY source`)
1896
+ .all(...chunk);
1897
+ for (const row of rows)
1898
+ out.set(row.source, row.count);
1899
+ }
1900
+ return out;
1901
+ }
1902
+ /**
1903
+ * Symbols nothing in the index points at — the candidate set behind the dead
1904
+ * code list (`src/graph/dead-code.ts`).
1905
+ *
1906
+ * "Points at" is every edge kind EXCEPT `contains`: a class containing a
1907
+ * method is structure, not use, and counting it would make every member look
1908
+ * reached by its own container. A self-edge is excluded for the same reason
1909
+ * a recursive function is not its own caller.
1910
+ *
1911
+ * One scan, one index probe per candidate. `NOT EXISTS` over
1912
+ * `idx_edges_target_kind` is what keeps it that way — the alternative
1913
+ * (`LEFT JOIN edges … GROUP BY`) builds a row per edge for the whole table
1914
+ * before discarding all but the empty groups. Ordered by position so the
1915
+ * answer is stable across runs and groups by file without a second sort.
1916
+ *
1917
+ * The result is deliberately NOT called dead code: an unreferenced symbol is
1918
+ * a symbol with no STATIC reference, and the caller applies the exclusions
1919
+ * (tests, generated files, overrides, unresolved names) that turn the
1920
+ * candidate set into a claim worth making.
1921
+ */
1922
+ getUnreferencedNodes(kinds, limit) {
1923
+ if (kinds.length === 0 || limit <= 0)
1924
+ return [];
1925
+ const placeholders = kinds.map(() => '?').join(',');
1926
+ const rows = this.db
1927
+ .prepare(`SELECT n.*, COALESCE(f.generated, 0) AS file_generated
1928
+ FROM nodes n
1929
+ LEFT JOIN files f ON f.path = n.file_path
1930
+ WHERE n.kind IN (${placeholders})
1931
+ AND NOT EXISTS (
1932
+ SELECT 1 FROM edges e
1933
+ WHERE e.target = n.id
1934
+ AND e.kind != 'contains'
1935
+ AND e.source != n.id
1936
+ )
1937
+ ORDER BY n.file_path, n.start_line, n.name
1938
+ LIMIT ?`)
1939
+ .all(...kinds, limit);
1940
+ return rows.map((row) => ({ node: rowToNode(row), generated: row.file_generated === 1 }));
1941
+ }
1942
+ /**
1943
+ * Which of `names` the index holds an UNRESOLVED reference to.
1944
+ *
1945
+ * The point is honesty about our own blind spots. A `failed` row in
1946
+ * `unresolved_refs` records that some file referenced a name and the resolver
1947
+ * could not decide what it meant — so a symbol with that name cannot be
1948
+ * called unreferenced, whatever the edge table says. It is deliberately
1949
+ * matched loosely, on the reference name AND on its tail (`util.greet` →
1950
+ * `greet`), because the question being asked is "could this name be the one
1951
+ * we failed to follow", and a maybe has to count as a yes.
1952
+ *
1953
+ * Bounded-lookup like {@link getGeneratedPathsAmong}: the caller holds a
1954
+ * candidate list, so this is a chunked probe over `idx_unresolved_name`, not
1955
+ * a scan of the table.
1956
+ */
1957
+ getUnresolvedNamesAmong(names) {
1958
+ const unique = [...new Set(names)].filter((name) => name.length > 0);
1959
+ const found = new Set();
1960
+ if (unique.length === 0)
1961
+ return found;
1962
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
1963
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
1964
+ const placeholders = chunk.map(() => '?').join(',');
1965
+ const rows = this.db
1966
+ .prepare(`SELECT DISTINCT reference_name AS name FROM unresolved_refs
1967
+ WHERE reference_name IN (${placeholders})
1968
+ UNION
1969
+ SELECT DISTINCT name_tail AS name FROM unresolved_refs
1970
+ WHERE name_tail IN (${placeholders})`)
1971
+ .all(...chunk, ...chunk);
1972
+ for (const row of rows)
1973
+ found.add(row.name);
1974
+ }
1975
+ return found;
1976
+ }
1977
+ /**
1978
+ * Which of `nodeIds` extend or implement a type the resolver could not follow.
1979
+ * An ancestor outside the index (`React.Component`, `stream.Transform`, a
1980
+ * framework interface) leaves no edge, only this `extends` / `implements`
1981
+ * row, so it is the one record that such an ancestor exists (#1973).
1982
+ * Chunked probe over `idx_unresolved_from_node`.
1983
+ */
1984
+ getUnresolvedSupertypeSourcesAmong(nodeIds) {
1985
+ const unique = [...new Set(nodeIds)];
1986
+ const found = new Set();
1987
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
1988
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
1989
+ const placeholders = chunk.map(() => '?').join(',');
1990
+ const rows = this.db
1991
+ .prepare(`SELECT DISTINCT from_node_id AS id FROM unresolved_refs
1992
+ WHERE from_node_id IN (${placeholders})
1993
+ AND reference_kind IN ('extends', 'implements')`)
1994
+ .all(...chunk);
1995
+ for (const row of rows)
1996
+ found.add(row.id);
1997
+ }
1998
+ return found;
1999
+ }
2000
+ /**
2001
+ * Which of `names` are carried by MORE THAN ONE symbol, at least one of which
2002
+ * something points at.
2003
+ *
2004
+ * The false positive this exists to kill: `CodeGraph.getTopRouteFile` calls
2005
+ * `this.queries.getTopRouteFile()`, and the resolver — which prefers a
2006
+ * same-name definition in the call site's own file — attaches that edge to
2007
+ * the *calling* method. One of the two ends up with a self-edge and the other
2008
+ * with nothing at all, and neither is unreferenced. From the edge table the
2009
+ * mis-resolution and a genuinely unused twin are the same picture, so the
2010
+ * claim is not made about either.
2011
+ *
2012
+ * Both halves of the condition are load-bearing. **More than one symbol**:
2013
+ * a uniquely-named function that only calls itself is genuinely dead, and
2014
+ * excluding every recursive function would gut the list. **Self-edges
2015
+ * counted**: the self-edge IS the fingerprint of the mis-resolution above, so
2016
+ * it has to count as evidence that this name resolves somewhere.
2017
+ *
2018
+ * Chunked probe over `idx_nodes_name`, bounded by the caller's candidate list.
2019
+ */
2020
+ getAmbiguousReferencedNames(names) {
2021
+ const unique = [...new Set(names)].filter((name) => name.length > 0);
2022
+ const found = new Set();
2023
+ if (unique.length === 0)
2024
+ return found;
2025
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
2026
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
2027
+ const placeholders = chunk.map(() => '?').join(',');
2028
+ const rows = this.db
2029
+ .prepare(`SELECT name FROM (
2030
+ SELECT n.name AS name,
2031
+ EXISTS (
2032
+ SELECT 1 FROM edges e
2033
+ WHERE e.target = n.id AND e.kind != 'contains'
2034
+ ) AS referenced
2035
+ FROM nodes n
2036
+ WHERE n.name IN (${placeholders})
2037
+ )
2038
+ GROUP BY name
2039
+ HAVING COUNT(*) > 1 AND SUM(referenced) > 0`)
2040
+ .all(...chunk);
2041
+ for (const row of rows)
2042
+ found.add(row.name);
2043
+ }
2044
+ return found;
2045
+ }
2046
+ /**
2047
+ * Which of the given languages the index records an EXPORT marker for.
2048
+ *
2049
+ * A self-measurement, and the honest basis for a whole class of exclusion.
2050
+ * The dead code report's strongest filter is "exported symbols may be reached
2051
+ * from outside this repository" — and that filter silently does nothing for a
2052
+ * language whose exports are not recorded, either because the extractor does
2053
+ * not record them (Rust `pub`) or because the language has no such concept at
2054
+ * all (Python, C, Ruby: the header or the module IS the surface). Rather than
2055
+ * carry a table of which is which, ask the index: if nothing in this language
2056
+ * is marked exported, the filter did not run, and no claim about outside
2057
+ * reachability can be made for it.
2058
+ *
2059
+ * `idx_nodes_language` covers the grouping; the caller passes the handful of
2060
+ * languages its candidates are actually in.
2061
+ */
2062
+ getLanguagesWithExports(languages) {
2063
+ const unique = [...new Set(languages)].filter((language) => language.length > 0);
2064
+ const found = new Set();
2065
+ if (unique.length === 0)
2066
+ return found;
2067
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
2068
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
2069
+ const placeholders = chunk.map(() => '?').join(',');
2070
+ const rows = this.db
2071
+ .prepare(`SELECT language, MAX(is_exported) AS any_exported
2072
+ FROM nodes
2073
+ WHERE language IN (${placeholders})
2074
+ GROUP BY language`)
2075
+ .all(...chunk);
2076
+ for (const row of rows)
2077
+ if (row.any_exported === 1)
2078
+ found.add(row.language);
2079
+ }
2080
+ return found;
2081
+ }
2082
+ /**
2083
+ * The nodes with the most DISTINCT dependents, most first.
2084
+ *
2085
+ * "Distinct" is the difference that matters: a helper called forty times from
2086
+ * one function has a fan-in of 40 but exactly one dependent. This counts the
2087
+ * second thing — the number a reader means by "N callers" — so the top of
2088
+ * this list is the set of symbols a change actually radiates furthest from.
2089
+ *
2090
+ * `contains` is excluded because it is structure, not dependency: counting it
2091
+ * would rank every file and class above the code they hold.
2092
+ */
2093
+ getTopDependedOn(limit) {
2094
+ if (limit <= 0)
2095
+ return [];
2096
+ const rows = this.db
2097
+ .prepare(`SELECT target AS nodeId, COUNT(DISTINCT source) AS dependents
2098
+ FROM edges
2099
+ WHERE kind != 'contains' AND source != target
2100
+ GROUP BY target
2101
+ ORDER BY dependents DESC
2102
+ LIMIT ?`)
2103
+ .all(limit);
2104
+ return rows;
2105
+ }
2106
+ /**
2107
+ * The graph's executable roots — files that RUN something at module level,
2108
+ * ranked by how much of the project they set in motion.
2109
+ *
2110
+ * The engine records a statement at the top level of a file as an edge from
2111
+ * the *file* node, so `src/bin/codegraph.ts` calling `program.parse()` at
2112
+ * module scope is a `calls` edge out of a `file`. That set is what makes the
2113
+ * roots of a dependency graph visible: a library module holds definitions and
2114
+ * runs nothing until someone imports it, while a CLI, a worker entry or a
2115
+ * build script does its work on the way down the file. `instantiates` counts
2116
+ * the same way — `new Server(...)` at module scope is the same act.
2117
+ *
2118
+ * A call made while initializing a module-level `variable` / `constant` —
2119
+ * `const service = new Service()`, `app = FastAPI()` — is attributed to the
2120
+ * declared name (#693), not to the file, so the file's own edges alone would
2121
+ * miss most of what a real entry point runs. Those names are the file's
2122
+ * top-level code too, so `tops` counts them alongside the file node.
2123
+ *
2124
+ * Ranking multiplies the two things an entry point does: it runs (calls), and
2125
+ * it wires the project together (distinct other files its symbols reach). One
2126
+ * alone is misleading — a registration table makes hundreds of module-level
2127
+ * calls into itself, and a barrel file imports everything and runs nothing.
2128
+ * The product puts the file that does both at the top.
2129
+ */
2130
+ getTopCallingFiles(limit) {
2131
+ if (limit <= 0)
2132
+ return [];
2133
+ return this.db
2134
+ .prepare(`WITH tops AS (
2135
+ SELECT n.id AS file_id, n.id AS src
2136
+ FROM nodes n
2137
+ WHERE n.kind = 'file'
2138
+ UNION ALL
2139
+ SELECT c.source AS file_id, c.target AS src
2140
+ FROM edges c
2141
+ JOIN nodes f ON f.id = c.source
2142
+ JOIN nodes v ON v.id = c.target
2143
+ WHERE c.kind = 'contains'
2144
+ AND f.kind = 'file'
2145
+ AND v.kind IN ('variable', 'constant')
2146
+ ),
2147
+ runs AS (
2148
+ SELECT t.file_id AS id, COUNT(*) AS calls
2149
+ FROM tops t
2150
+ JOIN edges e ON e.source = t.src
2151
+ WHERE e.kind IN ('calls', 'instantiates')
2152
+ GROUP BY t.file_id
2153
+ ),
2154
+ cand AS (
2155
+ SELECT r.id AS id, n.file_path AS fp, r.calls AS calls
2156
+ FROM runs r JOIN nodes n ON n.id = r.id
2157
+ ),
2158
+ wires AS (
2159
+ SELECT sn.file_path AS fp, COUNT(DISTINCT tn.file_path) AS reaches
2160
+ FROM edges e
2161
+ JOIN nodes sn ON sn.id = e.source
2162
+ JOIN nodes tn ON tn.id = e.target
2163
+ WHERE e.kind != 'contains'
2164
+ AND sn.file_path <> tn.file_path
2165
+ AND sn.file_path IN (SELECT fp FROM cand)
2166
+ GROUP BY sn.file_path
2167
+ )
2168
+ SELECT c.id AS nodeId,
2169
+ c.fp AS filePath,
2170
+ c.calls AS calls,
2171
+ COALESCE(w.reaches, 0) AS reaches,
2172
+ c.calls * (1 + COALESCE(w.reaches, 0)) AS score
2173
+ FROM cand c LEFT JOIN wires w ON w.fp = c.fp
2174
+ ORDER BY score DESC, calls DESC, filePath
2175
+ LIMIT ?`)
2176
+ .all(limit);
2177
+ }
2178
+ /**
2179
+ * How many OTHER files depend on each of the given files.
2180
+ *
2181
+ * Counted through the symbols, not the file nodes: an `imports` edge points
2182
+ * at the imported symbol, so a file node almost never receives one and
2183
+ * counting edges into it would report every file as depended on by nobody.
2184
+ * Same-file edges are excluded, which is what makes zero mean "nothing else
2185
+ * in the index reaches into this file" — the honest reading of a root.
2186
+ */
2187
+ getFileDependentCounts(filePaths) {
2188
+ if (filePaths.length === 0)
2189
+ return [];
2190
+ return this.db
2191
+ .prepare(`SELECT tn.file_path AS filePath, COUNT(DISTINCT sn.file_path) AS dependents
2192
+ FROM edges e
2193
+ JOIN nodes tn ON tn.id = e.target
2194
+ JOIN nodes sn ON sn.id = e.source
2195
+ WHERE e.kind != 'contains'
2196
+ AND tn.file_path IN (SELECT value FROM json_each(?))
2197
+ AND sn.file_path <> tn.file_path
2198
+ GROUP BY tn.file_path`)
2199
+ .all(JSON.stringify(filePaths));
2200
+ }
2201
+ /**
2202
+ * How far each of the given files reaches OUT: distinct other files its
2203
+ * symbols touch, and how many references that is.
2204
+ *
2205
+ * The mirror of {@link getFileDependentCounts}, and the same reasoning about
2206
+ * `contains` and same-file edges applies. It is driven from `nodes` rather
2207
+ * than from `edges` so the work is proportional to the files asked about —
2208
+ * the entry-points endpoint asks it about every test file in the index, and
2209
+ * an edge-first plan would scan the whole table to answer a question about a
2210
+ * tenth of it.
2211
+ */
2212
+ getFileReachCounts(filePaths) {
2213
+ if (filePaths.length === 0)
2214
+ return [];
2215
+ return this.db
2216
+ .prepare(`SELECT sn.file_path AS filePath,
2217
+ COUNT(DISTINCT tn.file_path) AS reaches,
2218
+ COUNT(*) AS refs
2219
+ FROM nodes sn
2220
+ JOIN edges e ON e.source = sn.id
2221
+ JOIN nodes tn ON tn.id = e.target
2222
+ WHERE sn.file_path IN (SELECT value FROM json_each(?))
2223
+ AND e.kind != 'contains'
2224
+ AND tn.file_path <> sn.file_path
2225
+ GROUP BY sn.file_path`)
2226
+ .all(JSON.stringify(filePaths));
2227
+ }
2228
+ /**
2229
+ * The `file` nodes for the given paths, in one query.
2230
+ *
2231
+ * A file's own node is what makes a file row navigable, and looking it up
2232
+ * with {@link getNodesInFile} means materialising every symbol in the file to
2233
+ * throw all but one away.
2234
+ */
2235
+ getFileNodes(filePaths) {
2236
+ if (filePaths.length === 0)
2237
+ return [];
2238
+ const rows = this.db
2239
+ .prepare(`SELECT * FROM nodes
2240
+ WHERE kind = 'file'
2241
+ AND file_path IN (SELECT value FROM json_each(?))`)
2242
+ .all(JSON.stringify(filePaths));
2243
+ return rows.map(rowToNode);
2244
+ }
2245
+ /**
2246
+ * Roll the whole edge table up to module granularity in one pass.
2247
+ *
2248
+ * The caller decides what a module IS — it hands in a file → module
2249
+ * assignment and gets back the cross-module traffic. That split is
2250
+ * deliberate: naming modules is a *policy* (top-level directories, a façade
2251
+ * file kept separate, a monorepo root) that belongs where the reader lives,
2252
+ * while grouping a million edges by it is *mechanics* that must happen in
2253
+ * SQLite. Doing the fold in JavaScript instead means materialising every
2254
+ * cross-file edge in memory; doing the naming in SQL means a tower of
2255
+ * `instr`/`substr` no one can read.
2256
+ *
2257
+ * The assignment lands in a TEMP table with a primary key, so the join is
2258
+ * indexed and the result set is bounded by modules², not by edges. Temp
2259
+ * tables live in SQLite's own temp database, so this stays valid against a
2260
+ * read-only main.
2261
+ *
2262
+ * Two result sets, because they need two different groupings over the same
2263
+ * join: `links` counts edges per (module, module, kind), and `pairs` names
2264
+ * the busiest symbol pairs behind each link (the map's tooltip). `pairs` is
2265
+ * ranked and cut inside SQLite — the un-cut grouping is the one thing here
2266
+ * that scales with distinct symbol names rather than with modules. Pairs are
2267
+ * ranked by `declared` before raw count, so a link's tooltip names the
2268
+ * symbols the source actually points at rather than whichever `has`/`get`
2269
+ * happened to name-match most often.
2270
+ *
2271
+ * `declared` is the subset of a link's edges that came from something the
2272
+ * source *writes down*: an import, a qualified name, an inheritance clause,
2273
+ * or a call through a typed receiver. It exists because bare name matching
2274
+ * (`resolvedBy: 'exact-match'`) is what invents cross-module links out of
2275
+ * common method names — `run`, `push`, `finish` — and a map that lets those
2276
+ * decide the layering puts the storage layer above the CLI.
2277
+ */
2278
+ aggregateModuleGraph(assignments, options) {
2279
+ if (assignments.length === 0 || options.kinds.length === 0)
2280
+ return { links: [], pairs: [] };
2281
+ const CONFIDENCE = `COALESCE(json_extract(e.metadata, '$.confidence'), 1)`;
2282
+ const DECLARED = `(json_extract(e.metadata, '$.resolvedBy') IN ('import', 'qualified-name')
2283
+ OR e.kind IN ('extends', 'implements')
2284
+ OR (json_extract(e.metadata, '$.resolvedBy') = 'instance-method'
2285
+ AND ${CONFIDENCE} >= 0.9))`;
2286
+ this.db.exec('DROP TABLE IF EXISTS temp.cg_module_map');
2287
+ this.db.exec('CREATE TEMP TABLE cg_module_map (path TEXT PRIMARY KEY, mod TEXT NOT NULL)');
2288
+ try {
2289
+ const insert = this.db.prepare('INSERT OR REPLACE INTO cg_module_map (path, mod) VALUES (?, ?)');
2290
+ this.db.exec('BEGIN');
2291
+ try {
2292
+ for (const row of assignments)
2293
+ insert.run(row.filePath, row.module);
2294
+ this.db.exec('COMMIT');
2295
+ }
2296
+ catch (err) {
2297
+ this.db.exec('ROLLBACK');
2298
+ throw err;
2299
+ }
2300
+ // ONE pass over the edge table. Grouping by the symbol names as well as
2301
+ // the modules costs nothing extra in scan time — the join is what is
2302
+ // expensive — and it buys both results from a single scan. Measured on
2303
+ // this index inflated to 1.6M edges: 1.66s for this query against 3.0s
2304
+ // for the module-level and name-level queries run separately, which is
2305
+ // the difference between meeting and missing the map's cold budget on a
2306
+ // ten-thousand-file repository.
2307
+ const rows = this.db
2308
+ .prepare(`SELECT ms.mod AS source, mt.mod AS target, e.kind AS kind,
2309
+ sn.name AS "from", tn.name AS "to",
2310
+ SUM(CASE WHEN ${CONFIDENCE} >= ? THEN 1 ELSE 0 END) AS count,
2311
+ SUM(CASE WHEN ${CONFIDENCE} >= ? AND ${DECLARED} THEN 1 ELSE 0 END) AS declared,
2312
+ SUM(CASE WHEN ${CONFIDENCE} < ? THEN 1 ELSE 0 END) AS uncertain
2313
+ FROM edges e
2314
+ JOIN nodes sn ON sn.id = e.source
2315
+ JOIN nodes tn ON tn.id = e.target
2316
+ JOIN cg_module_map ms ON ms.path = sn.file_path
2317
+ JOIN cg_module_map mt ON mt.path = tn.file_path
2318
+ WHERE e.kind IN (SELECT value FROM json_each(?))
2319
+ AND ms.mod <> mt.mod
2320
+ GROUP BY ms.mod, mt.mod, e.kind, sn.name, tn.name`)
2321
+ .all(options.minConfidence, options.minConfidence, options.minConfidence, JSON.stringify(options.kinds));
2322
+ return foldModuleRows(rows, options);
2323
+ }
2324
+ finally {
2325
+ this.db.exec('DROP TABLE IF EXISTS temp.cg_module_map');
2326
+ }
2327
+ }
2328
+ /**
2329
+ * Every ordered pair of files where one reaches into the other, once each.
2330
+ *
2331
+ * The input a cycle finder wants: file-level circular dependencies are the
2332
+ * strongly connected components of this graph. One query instead of the
2333
+ * dependency lookup per file that {@link GraphQueryManager.findCircularDependencies}
2334
+ * does — which matters because a cycle report is only interesting on a large
2335
+ * repo, and that is exactly where a query per file stops being affordable.
2336
+ *
2337
+ * `contains` is excluded (a file "contains" its own symbols, which is not a
2338
+ * dependency), and so are same-file edges and low-confidence name matches:
2339
+ * a cycle conjured by a common method name is a false alarm a reader cannot
2340
+ * check.
2341
+ */
2342
+ getCrossFileDependencyPairs(minConfidence) {
2343
+ return this.db
2344
+ .prepare(`SELECT DISTINCT sn.file_path AS source, tn.file_path AS target
2345
+ FROM edges e
2346
+ JOIN nodes sn ON sn.id = e.source
2347
+ JOIN nodes tn ON tn.id = e.target
2348
+ WHERE e.kind <> 'contains'
2349
+ AND sn.file_path <> tn.file_path
2350
+ AND COALESCE(json_extract(e.metadata, '$.confidence'), 1) >= ?`)
2351
+ .all(minConfidence);
2352
+ }
2353
+ /**
2354
+ * Every unresolved reference recorded in one FILE, ordered by line.
2355
+ *
2356
+ * The per-symbol form above answers "what does this body reach that the
2357
+ * index does not hold". A whole-file reader asks the same question of every
2358
+ * line at once, and asking it one symbol at a time is a query per symbol —
2359
+ * 153 of them on this repo's largest file. `unresolved_refs.file_path` is
2360
+ * indexed, so this is one lookup whatever the file holds.
2361
+ *
2362
+ * `limit` bounds the answer rather than the work: the caller draws a marker
2363
+ * per row, and a generated file with fifty thousand of them would ship
2364
+ * megabytes to say something a count already says. Rows come back in line
2365
+ * order, so a cap trims the END of the file, which is at least legible.
2366
+ */
2367
+ getUnresolvedReferencesInFile(filePath, limit = 5000) {
2368
+ if (!this.stmts.getUnresolvedInFile) {
2369
+ this.stmts.getUnresolvedInFile = this.db.prepare('SELECT * FROM unresolved_refs WHERE file_path = ? ORDER BY line, col LIMIT ?');
2370
+ }
2371
+ const rows = this.stmts.getUnresolvedInFile.all(filePath, limit);
2372
+ return rows.map((row) => ({
2373
+ fromNodeId: row.from_node_id,
2374
+ referenceName: row.reference_name,
2375
+ referenceKind: row.reference_kind,
2376
+ line: row.line,
2377
+ column: row.col,
2378
+ candidates: row.candidates ? (0, utils_1.safeJsonParse)(row.candidates, undefined) : undefined,
2379
+ filePath: row.file_path,
2380
+ language: row.language,
2381
+ rowId: row.id,
2382
+ }));
2383
+ }
2384
+ /**
2385
+ * References recorded against a symbol that never resolved to a node — the
2386
+ * calls and type mentions that leave the index (a third-party package, a
2387
+ * runtime builtin, a language construct extraction doesn't model).
2388
+ *
2389
+ * Read-only. It exists so a reader can say "N calls into symbols outside the
2390
+ * index" instead of silently showing a callee list shorter than the body's
2391
+ * call sites, which reads as "nothing else happens here".
2392
+ */
2393
+ getUnresolvedReferencesFrom(fromNodeId) {
2394
+ if (!this.stmts.getUnresolvedFromNode) {
2395
+ this.stmts.getUnresolvedFromNode = this.db.prepare('SELECT * FROM unresolved_refs WHERE from_node_id = ?');
2396
+ }
2397
+ const rows = this.stmts.getUnresolvedFromNode.all(fromNodeId);
2398
+ return rows.map((row) => ({
2399
+ fromNodeId: row.from_node_id,
2400
+ referenceName: row.reference_name,
2401
+ referenceKind: row.reference_kind,
2402
+ line: row.line,
2403
+ column: row.col,
2404
+ candidates: row.candidates ? (0, utils_1.safeJsonParse)(row.candidates, undefined) : undefined,
2405
+ filePath: row.file_path,
2406
+ language: row.language,
2407
+ rowId: row.id,
2408
+ }));
2409
+ }
1566
2410
  /**
1567
2411
  * Find all edges where both source and target are in the given node set.
1568
2412
  * Useful for recovering inter-node connectivity after BFS.
@@ -1755,6 +2599,29 @@ class QueryBuilder {
1755
2599
  * restricted to the candidate list: the file that imports it is usually
1756
2600
  * not itself a candidate.
1757
2601
  *
2602
+ * ### Interface MEMBERS are transparent to all four conditions
2603
+ *
2604
+ * A `method_signature` / `property_signature` inside an interface enters the
2605
+ * graph as a `method` / `property` node (#1638). Read literally that would
2606
+ * break every condition here at once: condition 2 sees non-type kinds and
2607
+ * stops flagging, and — worse, because it is silent — condition 4 starts
2608
+ * seeing inbound `calls` edges the moment a call site through the shim's API
2609
+ * finally has a signature to land on. An ambient `.d.ts` would quietly lose
2610
+ * its damping precisely BECAUSE the platform API it declares is widely used.
2611
+ *
2612
+ * So an interface-owned member is treated the way `parameter` already is: it
2613
+ * neither qualifies, disqualifies, nor counts as inbound dependency. That is
2614
+ * not a new judgement call, it is what keeps the rule measuring what it was
2615
+ * measured on — before #1638 these nodes did not exist, so excluding them
2616
+ * reproduces the 0–4% flag rate the thresholds above were tuned against. It
2617
+ * is also the semantically right answer: a signature with no body is on the
2618
+ * same side of the line as the interface that owns it, and a call edge
2619
+ * landing on one is still not a file that can answer a flow question.
2620
+ *
2621
+ * The interface ITSELF is untouched: the `references` edges an importing
2622
+ * module aims at `UploadStorage` still disqualify the file under (4), which
2623
+ * is what keeps a depended-on `types.ts` out of the flag.
2624
+ *
1758
2625
  * Bounded-lookup like {@link getGeneratedPathsAmong}: callers hold a ranked
1759
2626
  * candidate list, so this is a partial-index probe over a handful of paths.
1760
2627
  */
@@ -1770,14 +2637,15 @@ class QueryBuilder {
1770
2637
  // things the file declares, so they neither qualify nor disqualify.
1771
2638
  const rows = this.db
1772
2639
  .prepare(`
1773
- SELECT file_path,
1774
- SUM(CASE WHEN kind NOT IN ('file','import','export','parameter')
2640
+ SELECT n.file_path AS file_path,
2641
+ SUM(CASE WHEN n.kind NOT IN ('file','import','export','parameter')
2642
+ AND NOT ${IS_INTERFACE_MEMBER('n')}
1775
2643
  THEN 1 ELSE 0 END) AS declared,
1776
- SUM(CASE WHEN kind IN ('interface','type_alias','enum','enum_member','namespace')
2644
+ SUM(CASE WHEN n.kind IN ('interface','type_alias','enum','enum_member','namespace')
1777
2645
  THEN 1 ELSE 0 END) AS typeDeclared
1778
- FROM nodes
1779
- WHERE file_path IN (${placeholders})
1780
- GROUP BY file_path
2646
+ FROM nodes n
2647
+ WHERE n.file_path IN (${placeholders})
2648
+ GROUP BY n.file_path
1781
2649
  `)
1782
2650
  .all(...chunk);
1783
2651
  let candidates = rows
@@ -1793,17 +2661,22 @@ class QueryBuilder {
1793
2661
  .all(...candidates).map((r) => r.file_path));
1794
2662
  candidates = candidates.filter((p) => !hit.has(p));
1795
2663
  };
1796
- // (3) originates behaviour
2664
+ // (3) originates behaviour — a signature has no body to originate from,
2665
+ // so an edge attributed to one is not evidence about this file.
1797
2666
  disqualify(`
1798
2667
  SELECT DISTINCT n.file_path AS file_path
1799
2668
  FROM edges e JOIN nodes n ON n.id = e.source
1800
2669
  WHERE e.kind IN ('calls','instantiates') AND n.file_path IN ($IN$)
2670
+ AND NOT ${IS_INTERFACE_MEMBER('n')}
1801
2671
  `);
1802
- // (4) something outside the file depends on it
2672
+ // (4) something outside the file depends on it — but a call that lands on
2673
+ // an interface's own signature is a use of the API, not a dependency on
2674
+ // this file's structure. The edges aimed at the interface still count.
1803
2675
  disqualify(`
1804
2676
  SELECT DISTINCT t.file_path AS file_path
1805
2677
  FROM edges e JOIN nodes t ON t.id = e.target JOIN nodes s ON s.id = e.source
1806
2678
  WHERE t.file_path IN ($IN$) AND s.file_path <> t.file_path
2679
+ AND NOT ${IS_INTERFACE_MEMBER('t')}
1807
2680
  `);
1808
2681
  for (const path of candidates)
1809
2682
  found.add(path);
@@ -1868,6 +2741,40 @@ class QueryBuilder {
1868
2741
  .get();
1869
2742
  return row?.last ?? null;
1870
2743
  }
2744
+ /**
2745
+ * The index's revision marker: how far the last sync got, and how many files
2746
+ * it left behind — one query, both numbers.
2747
+ *
2748
+ * This is the cheapest honest answer to "has the index moved since I last
2749
+ * looked". `MAX(indexed_at)` alone is not enough: a sync that only DELETES
2750
+ * files (a branch checkout that removed a directory) advances nothing, and
2751
+ * the graph the viewer is showing has still changed underneath it. The row
2752
+ * count catches exactly that case.
2753
+ */
2754
+ getIndexRevision() {
2755
+ const row = this.db
2756
+ .prepare('SELECT MAX(indexed_at) AS last, COUNT(*) AS files FROM files')
2757
+ .get();
2758
+ return { lastIndexedAt: row?.last ?? null, fileCount: row?.files ?? 0 };
2759
+ }
2760
+ /**
2761
+ * Files re-indexed strictly after `since` (ms since epoch), newest first.
2762
+ *
2763
+ * `total` is the real count; `paths` is capped at `limit`. Used by the
2764
+ * viewer's live channel to name what a sync just picked up. A file the same
2765
+ * sync DELETED cannot appear here — it has no row left — which is why the
2766
+ * caller compares {@link getIndexRevision} as well rather than treating an
2767
+ * empty list as "nothing happened".
2768
+ */
2769
+ getFilesIndexedSince(since, limit) {
2770
+ const count = this.db
2771
+ .prepare('SELECT COUNT(*) AS n FROM files WHERE indexed_at > ?')
2772
+ .get(since);
2773
+ const rows = this.db
2774
+ .prepare('SELECT path FROM files WHERE indexed_at > ? ORDER BY indexed_at DESC, path LIMIT ?')
2775
+ .all(since, Math.max(0, limit));
2776
+ return { paths: rows.map((r) => r.path), total: count?.n ?? rows.length };
2777
+ }
1871
2778
  /**
1872
2779
  * Get files that need re-indexing (hash changed)
1873
2780
  */
@@ -2022,11 +2929,19 @@ class QueryBuilder {
2022
2929
  * (§7a.2) — while the seek is O(batch) forever. `id` is the rowid alias, so
2023
2930
  * the enumeration order is identical to the OFFSET reader's.
2024
2931
  */
2025
- getUnresolvedReferencesBatchAfter(afterRowId, limit) {
2026
- if (!this.stmts.getUnresolvedBatchAfter) {
2027
- this.stmts.getUnresolvedBatchAfter = this.db.prepare("SELECT * FROM unresolved_refs WHERE status = 'pending' AND id > ? ORDER BY id LIMIT ?");
2028
- }
2029
- const rows = this.stmts.getUnresolvedBatchAfter.all(afterRowId, limit);
2932
+ getUnresolvedReferencesBatchAfter(afterRowId, limit, prerequisites) {
2933
+ // Resolution prerequisites must be committed before dependent calls,
2934
+ // even when an interrupted sync queued their rows in a different order
2935
+ // from a clean index (#1577). Each phase still seeks by row id in bounded
2936
+ // memory; the default preserves the public reader's original enumeration.
2937
+ const key = prerequisites === undefined ? 'getUnresolvedBatchAfter'
2938
+ : prerequisites ? 'getUnresolvedPrerequisitesAfter' : 'getUnresolvedDependentsAfter';
2939
+ if (!this.stmts[key]) {
2940
+ const filter = prerequisites === undefined ? ''
2941
+ : ` AND reference_kind ${prerequisites ? 'IN' : 'NOT IN'} ('imports', 'extends', 'implements')`;
2942
+ this.stmts[key] = this.db.prepare(`SELECT * FROM unresolved_refs WHERE status = 'pending' AND id > ?${filter} ORDER BY id LIMIT ?`);
2943
+ }
2944
+ const rows = this.stmts[key].all(afterRowId, limit);
2030
2945
  return rows.map((row) => ({
2031
2946
  fromNodeId: row.from_node_id,
2032
2947
  referenceName: row.reference_name,
@@ -2370,6 +3285,17 @@ class QueryBuilder {
2370
3285
  })();
2371
3286
  return changed;
2372
3287
  }
3288
+ /**
3289
+ * Replace resolution edges with their original unresolved references as one
3290
+ * transaction. If ref insertion fails, the edge deletion is rolled back.
3291
+ */
3292
+ replaceResolutionEdgesWithUnresolvedRefs(edgeIds, refs) {
3293
+ return this.db.transaction(() => {
3294
+ const changed = this.deleteEdgesByIds(edgeIds);
3295
+ this.insertUnresolvedRefsBatch(refs);
3296
+ return changed;
3297
+ })();
3298
+ }
2373
3299
  /**
2374
3300
  * Distinct node names present in the given files — the symbol names a sync
2375
3301
  * pass uses to look up retryable failed refs after those files changed.
@@ -2517,4 +3443,71 @@ class QueryBuilder {
2517
3443
  }
2518
3444
  }
2519
3445
  exports.QueryBuilder = QueryBuilder;
3446
+ function foldModuleRows(rows, options) {
3447
+ // A module id is a path and may contain anything printable, so the key
3448
+ // separator has to be something a path cannot hold.
3449
+ const SEP = '\u0000';
3450
+ const links = new Map();
3451
+ const pairKinds = new Set(options.pairKinds);
3452
+ const wantPairs = options.topPairsPerLink > 0 && pairKinds.size > 0;
3453
+ const pairTotals = new Map();
3454
+ for (const row of rows) {
3455
+ const linkKey = `${row.source}${SEP}${row.target}${SEP}${row.kind}`;
3456
+ const link = links.get(linkKey);
3457
+ if (link) {
3458
+ link.count += row.count;
3459
+ link.declared += row.declared;
3460
+ link.uncertain += row.uncertain;
3461
+ }
3462
+ else {
3463
+ links.set(linkKey, {
3464
+ source: row.source,
3465
+ target: row.target,
3466
+ kind: row.kind,
3467
+ count: row.count,
3468
+ declared: row.declared,
3469
+ uncertain: row.uncertain,
3470
+ });
3471
+ }
3472
+ // Only the confident half of a row can be named: an uncertain edge is a
3473
+ // guess, and printing "a to b, 12" for twelve guesses is the map claiming
3474
+ // something it does not know.
3475
+ if (!wantPairs || row.count === 0 || !pairKinds.has(row.kind))
3476
+ continue;
3477
+ const pairKey = `${row.source}${SEP}${row.target}${SEP}${row.from}${SEP}${row.to}`;
3478
+ const pair = pairTotals.get(pairKey);
3479
+ if (pair) {
3480
+ pair.count += row.count;
3481
+ pair.declared += row.declared;
3482
+ }
3483
+ else {
3484
+ pairTotals.set(pairKey, {
3485
+ source: row.source,
3486
+ target: row.target,
3487
+ from: row.from,
3488
+ to: row.to,
3489
+ count: row.count,
3490
+ declared: row.declared,
3491
+ });
3492
+ }
3493
+ }
3494
+ const byLink = new Map();
3495
+ for (const pair of pairTotals.values()) {
3496
+ const key = `${pair.source}${SEP}${pair.target}`;
3497
+ let list = byLink.get(key);
3498
+ if (!list)
3499
+ byLink.set(key, (list = []));
3500
+ list.push(pair);
3501
+ }
3502
+ const pairs = [];
3503
+ for (const list of byLink.values()) {
3504
+ list.sort((a, b) => b.declared - a.declared ||
3505
+ b.count - a.count ||
3506
+ a.from.localeCompare(b.from) ||
3507
+ a.to.localeCompare(b.to));
3508
+ for (const pair of list.slice(0, options.topPairsPerLink))
3509
+ pairs.push(pair);
3510
+ }
3511
+ return { links: [...links.values()], pairs };
3512
+ }
2520
3513
  //# sourceMappingURL=queries.js.map