@quolu/lattice 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (769) hide show
  1. package/LICENSE +25 -0
  2. package/README.md +20 -0
  3. package/bin/lattice-mcp.mjs +134 -0
  4. package/bin/lattice.mjs +78 -0
  5. package/package.json +47 -0
  6. package/sensor/LICENSE +21 -0
  7. package/sensor/NOTICE +30 -0
  8. package/sensor/dist/bin/codegraph.d.ts +26 -0
  9. package/sensor/dist/bin/codegraph.d.ts.map +1 -0
  10. package/sensor/dist/bin/codegraph.js +2279 -0
  11. package/sensor/dist/bin/codegraph.js.map +1 -0
  12. package/sensor/dist/bin/command-supervision.d.ts +49 -0
  13. package/sensor/dist/bin/command-supervision.d.ts.map +1 -0
  14. package/sensor/dist/bin/command-supervision.js +95 -0
  15. package/sensor/dist/bin/command-supervision.js.map +1 -0
  16. package/sensor/dist/bin/fatal-handler.d.ts +20 -0
  17. package/sensor/dist/bin/fatal-handler.d.ts.map +1 -0
  18. package/sensor/dist/bin/fatal-handler.js +118 -0
  19. package/sensor/dist/bin/fatal-handler.js.map +1 -0
  20. package/sensor/dist/bin/node-version-check.d.ts +37 -0
  21. package/sensor/dist/bin/node-version-check.d.ts.map +1 -0
  22. package/sensor/dist/bin/node-version-check.js +79 -0
  23. package/sensor/dist/bin/node-version-check.js.map +1 -0
  24. package/sensor/dist/bin/uninstall.d.ts +14 -0
  25. package/sensor/dist/bin/uninstall.d.ts.map +1 -0
  26. package/sensor/dist/bin/uninstall.js +36 -0
  27. package/sensor/dist/bin/uninstall.js.map +1 -0
  28. package/sensor/dist/context/formatter.d.ts +30 -0
  29. package/sensor/dist/context/formatter.d.ts.map +1 -0
  30. package/sensor/dist/context/formatter.js +263 -0
  31. package/sensor/dist/context/formatter.js.map +1 -0
  32. package/sensor/dist/context/index.d.ts +119 -0
  33. package/sensor/dist/context/index.d.ts.map +1 -0
  34. package/sensor/dist/context/index.js +1326 -0
  35. package/sensor/dist/context/index.js.map +1 -0
  36. package/sensor/dist/context/markers.d.ts +19 -0
  37. package/sensor/dist/context/markers.d.ts.map +1 -0
  38. package/sensor/dist/context/markers.js +22 -0
  39. package/sensor/dist/context/markers.js.map +1 -0
  40. package/sensor/dist/db/index.d.ts +264 -0
  41. package/sensor/dist/db/index.d.ts.map +1 -0
  42. package/sensor/dist/db/index.js +603 -0
  43. package/sensor/dist/db/index.js.map +1 -0
  44. package/sensor/dist/db/migrations.d.ts +44 -0
  45. package/sensor/dist/db/migrations.d.ts.map +1 -0
  46. package/sensor/dist/db/migrations.js +241 -0
  47. package/sensor/dist/db/migrations.js.map +1 -0
  48. package/sensor/dist/db/queries.d.ts +563 -0
  49. package/sensor/dist/db/queries.d.ts.map +1 -0
  50. package/sensor/dist/db/queries.js +2179 -0
  51. package/sensor/dist/db/queries.js.map +1 -0
  52. package/sensor/dist/db/schema.sql +196 -0
  53. package/sensor/dist/db/sqlite-adapter.d.ts +55 -0
  54. package/sensor/dist/db/sqlite-adapter.d.ts.map +1 -0
  55. package/sensor/dist/db/sqlite-adapter.js +135 -0
  56. package/sensor/dist/db/sqlite-adapter.js.map +1 -0
  57. package/sensor/dist/db/wal-valve.d.ts +106 -0
  58. package/sensor/dist/db/wal-valve.d.ts.map +1 -0
  59. package/sensor/dist/db/wal-valve.js +208 -0
  60. package/sensor/dist/db/wal-valve.js.map +1 -0
  61. package/sensor/dist/directory.d.ts +183 -0
  62. package/sensor/dist/directory.d.ts.map +1 -0
  63. package/sensor/dist/directory.js +797 -0
  64. package/sensor/dist/directory.js.map +1 -0
  65. package/sensor/dist/errors.d.ts +136 -0
  66. package/sensor/dist/errors.d.ts.map +1 -0
  67. package/sensor/dist/errors.js +219 -0
  68. package/sensor/dist/errors.js.map +1 -0
  69. package/sensor/dist/extraction/astro-extractor.d.ts +79 -0
  70. package/sensor/dist/extraction/astro-extractor.d.ts.map +1 -0
  71. package/sensor/dist/extraction/astro-extractor.js +320 -0
  72. package/sensor/dist/extraction/astro-extractor.js.map +1 -0
  73. package/sensor/dist/extraction/cfml-extractor.d.ts +107 -0
  74. package/sensor/dist/extraction/cfml-extractor.d.ts.map +1 -0
  75. package/sensor/dist/extraction/cfml-extractor.js +494 -0
  76. package/sensor/dist/extraction/cfml-extractor.js.map +1 -0
  77. package/sensor/dist/extraction/dfm-extractor.d.ts +31 -0
  78. package/sensor/dist/extraction/dfm-extractor.d.ts.map +1 -0
  79. package/sensor/dist/extraction/dfm-extractor.js +151 -0
  80. package/sensor/dist/extraction/dfm-extractor.js.map +1 -0
  81. package/sensor/dist/extraction/dynamic-import.d.ts +82 -0
  82. package/sensor/dist/extraction/dynamic-import.d.ts.map +1 -0
  83. package/sensor/dist/extraction/dynamic-import.js +313 -0
  84. package/sensor/dist/extraction/dynamic-import.js.map +1 -0
  85. package/sensor/dist/extraction/extraction-version.d.ts +25 -0
  86. package/sensor/dist/extraction/extraction-version.d.ts.map +1 -0
  87. package/sensor/dist/extraction/extraction-version.js +28 -0
  88. package/sensor/dist/extraction/extraction-version.js.map +1 -0
  89. package/sensor/dist/extraction/function-ref.d.ts +118 -0
  90. package/sensor/dist/extraction/function-ref.d.ts.map +1 -0
  91. package/sensor/dist/extraction/function-ref.js +727 -0
  92. package/sensor/dist/extraction/function-ref.js.map +1 -0
  93. package/sensor/dist/extraction/generated-detection.d.ts +30 -0
  94. package/sensor/dist/extraction/generated-detection.d.ts.map +1 -0
  95. package/sensor/dist/extraction/generated-detection.js +83 -0
  96. package/sensor/dist/extraction/generated-detection.js.map +1 -0
  97. package/sensor/dist/extraction/grammars.d.ts +138 -0
  98. package/sensor/dist/extraction/grammars.d.ts.map +1 -0
  99. package/sensor/dist/extraction/grammars.js +648 -0
  100. package/sensor/dist/extraction/grammars.js.map +1 -0
  101. package/sensor/dist/extraction/index.d.ts +251 -0
  102. package/sensor/dist/extraction/index.d.ts.map +1 -0
  103. package/sensor/dist/extraction/index.js +2563 -0
  104. package/sensor/dist/extraction/index.js.map +1 -0
  105. package/sensor/dist/extraction/kernel/decode.d.ts +9 -0
  106. package/sensor/dist/extraction/kernel/decode.d.ts.map +1 -0
  107. package/sensor/dist/extraction/kernel/decode.js +156 -0
  108. package/sensor/dist/extraction/kernel/decode.js.map +1 -0
  109. package/sensor/dist/extraction/kernel/index.d.ts +62 -0
  110. package/sensor/dist/extraction/kernel/index.d.ts.map +1 -0
  111. package/sensor/dist/extraction/kernel/index.js +165 -0
  112. package/sensor/dist/extraction/kernel/index.js.map +1 -0
  113. package/sensor/dist/extraction/kernel/layout.d.ts +92 -0
  114. package/sensor/dist/extraction/kernel/layout.d.ts.map +1 -0
  115. package/sensor/dist/extraction/kernel/layout.js +95 -0
  116. package/sensor/dist/extraction/kernel/layout.js.map +1 -0
  117. package/sensor/dist/extraction/kernel/loader.d.ts +61 -0
  118. package/sensor/dist/extraction/kernel/loader.d.ts.map +1 -0
  119. package/sensor/dist/extraction/kernel/loader.js +146 -0
  120. package/sensor/dist/extraction/kernel/loader.js.map +1 -0
  121. package/sensor/dist/extraction/languages/arkts.d.ts +3 -0
  122. package/sensor/dist/extraction/languages/arkts.d.ts.map +1 -0
  123. package/sensor/dist/extraction/languages/arkts.js +127 -0
  124. package/sensor/dist/extraction/languages/arkts.js.map +1 -0
  125. package/sensor/dist/extraction/languages/c-cpp.d.ts +111 -0
  126. package/sensor/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  127. package/sensor/dist/extraction/languages/c-cpp.js +878 -0
  128. package/sensor/dist/extraction/languages/c-cpp.js.map +1 -0
  129. package/sensor/dist/extraction/languages/cfquery.d.ts +12 -0
  130. package/sensor/dist/extraction/languages/cfquery.d.ts.map +1 -0
  131. package/sensor/dist/extraction/languages/cfquery.js +28 -0
  132. package/sensor/dist/extraction/languages/cfquery.js.map +1 -0
  133. package/sensor/dist/extraction/languages/cfscript.d.ts +3 -0
  134. package/sensor/dist/extraction/languages/cfscript.d.ts.map +1 -0
  135. package/sensor/dist/extraction/languages/cfscript.js +73 -0
  136. package/sensor/dist/extraction/languages/cfscript.js.map +1 -0
  137. package/sensor/dist/extraction/languages/cobol.d.ts +33 -0
  138. package/sensor/dist/extraction/languages/cobol.d.ts.map +1 -0
  139. package/sensor/dist/extraction/languages/cobol.js +499 -0
  140. package/sensor/dist/extraction/languages/cobol.js.map +1 -0
  141. package/sensor/dist/extraction/languages/csharp.d.ts +25 -0
  142. package/sensor/dist/extraction/languages/csharp.d.ts.map +1 -0
  143. package/sensor/dist/extraction/languages/csharp.js +175 -0
  144. package/sensor/dist/extraction/languages/csharp.js.map +1 -0
  145. package/sensor/dist/extraction/languages/dart.d.ts +3 -0
  146. package/sensor/dist/extraction/languages/dart.d.ts.map +1 -0
  147. package/sensor/dist/extraction/languages/dart.js +374 -0
  148. package/sensor/dist/extraction/languages/dart.js.map +1 -0
  149. package/sensor/dist/extraction/languages/erlang.d.ts +3 -0
  150. package/sensor/dist/extraction/languages/erlang.d.ts.map +1 -0
  151. package/sensor/dist/extraction/languages/erlang.js +350 -0
  152. package/sensor/dist/extraction/languages/erlang.js.map +1 -0
  153. package/sensor/dist/extraction/languages/go.d.ts +3 -0
  154. package/sensor/dist/extraction/languages/go.d.ts.map +1 -0
  155. package/sensor/dist/extraction/languages/go.js +111 -0
  156. package/sensor/dist/extraction/languages/go.js.map +1 -0
  157. package/sensor/dist/extraction/languages/index.d.ts +10 -0
  158. package/sensor/dist/extraction/languages/index.d.ts.map +1 -0
  159. package/sensor/dist/extraction/languages/index.js +71 -0
  160. package/sensor/dist/extraction/languages/index.js.map +1 -0
  161. package/sensor/dist/extraction/languages/java.d.ts +3 -0
  162. package/sensor/dist/extraction/languages/java.d.ts.map +1 -0
  163. package/sensor/dist/extraction/languages/java.js +315 -0
  164. package/sensor/dist/extraction/languages/java.js.map +1 -0
  165. package/sensor/dist/extraction/languages/javascript.d.ts +3 -0
  166. package/sensor/dist/extraction/languages/javascript.d.ts.map +1 -0
  167. package/sensor/dist/extraction/languages/javascript.js +106 -0
  168. package/sensor/dist/extraction/languages/javascript.js.map +1 -0
  169. package/sensor/dist/extraction/languages/kotlin.d.ts +3 -0
  170. package/sensor/dist/extraction/languages/kotlin.d.ts.map +1 -0
  171. package/sensor/dist/extraction/languages/kotlin.js +379 -0
  172. package/sensor/dist/extraction/languages/kotlin.js.map +1 -0
  173. package/sensor/dist/extraction/languages/lua.d.ts +3 -0
  174. package/sensor/dist/extraction/languages/lua.d.ts.map +1 -0
  175. package/sensor/dist/extraction/languages/lua.js +150 -0
  176. package/sensor/dist/extraction/languages/lua.js.map +1 -0
  177. package/sensor/dist/extraction/languages/luau.d.ts +3 -0
  178. package/sensor/dist/extraction/languages/luau.d.ts.map +1 -0
  179. package/sensor/dist/extraction/languages/luau.js +37 -0
  180. package/sensor/dist/extraction/languages/luau.js.map +1 -0
  181. package/sensor/dist/extraction/languages/nix.d.ts +3 -0
  182. package/sensor/dist/extraction/languages/nix.d.ts.map +1 -0
  183. package/sensor/dist/extraction/languages/nix.js +294 -0
  184. package/sensor/dist/extraction/languages/nix.js.map +1 -0
  185. package/sensor/dist/extraction/languages/objc.d.ts +3 -0
  186. package/sensor/dist/extraction/languages/objc.d.ts.map +1 -0
  187. package/sensor/dist/extraction/languages/objc.js +175 -0
  188. package/sensor/dist/extraction/languages/objc.js.map +1 -0
  189. package/sensor/dist/extraction/languages/pascal.d.ts +3 -0
  190. package/sensor/dist/extraction/languages/pascal.d.ts.map +1 -0
  191. package/sensor/dist/extraction/languages/pascal.js +77 -0
  192. package/sensor/dist/extraction/languages/pascal.js.map +1 -0
  193. package/sensor/dist/extraction/languages/php.d.ts +3 -0
  194. package/sensor/dist/extraction/languages/php.d.ts.map +1 -0
  195. package/sensor/dist/extraction/languages/php.js +196 -0
  196. package/sensor/dist/extraction/languages/php.js.map +1 -0
  197. package/sensor/dist/extraction/languages/python.d.ts +3 -0
  198. package/sensor/dist/extraction/languages/python.d.ts.map +1 -0
  199. package/sensor/dist/extraction/languages/python.js +56 -0
  200. package/sensor/dist/extraction/languages/python.js.map +1 -0
  201. package/sensor/dist/extraction/languages/r.d.ts +3 -0
  202. package/sensor/dist/extraction/languages/r.d.ts.map +1 -0
  203. package/sensor/dist/extraction/languages/r.js +314 -0
  204. package/sensor/dist/extraction/languages/r.js.map +1 -0
  205. package/sensor/dist/extraction/languages/ruby.d.ts +3 -0
  206. package/sensor/dist/extraction/languages/ruby.d.ts.map +1 -0
  207. package/sensor/dist/extraction/languages/ruby.js +149 -0
  208. package/sensor/dist/extraction/languages/ruby.js.map +1 -0
  209. package/sensor/dist/extraction/languages/rust.d.ts +3 -0
  210. package/sensor/dist/extraction/languages/rust.d.ts.map +1 -0
  211. package/sensor/dist/extraction/languages/rust.js +142 -0
  212. package/sensor/dist/extraction/languages/rust.js.map +1 -0
  213. package/sensor/dist/extraction/languages/scala.d.ts +3 -0
  214. package/sensor/dist/extraction/languages/scala.d.ts.map +1 -0
  215. package/sensor/dist/extraction/languages/scala.js +209 -0
  216. package/sensor/dist/extraction/languages/scala.js.map +1 -0
  217. package/sensor/dist/extraction/languages/solidity.d.ts +3 -0
  218. package/sensor/dist/extraction/languages/solidity.d.ts.map +1 -0
  219. package/sensor/dist/extraction/languages/solidity.js +293 -0
  220. package/sensor/dist/extraction/languages/solidity.js.map +1 -0
  221. package/sensor/dist/extraction/languages/swift.d.ts +3 -0
  222. package/sensor/dist/extraction/languages/swift.d.ts.map +1 -0
  223. package/sensor/dist/extraction/languages/swift.js +152 -0
  224. package/sensor/dist/extraction/languages/swift.js.map +1 -0
  225. package/sensor/dist/extraction/languages/terraform.d.ts +3 -0
  226. package/sensor/dist/extraction/languages/terraform.d.ts.map +1 -0
  227. package/sensor/dist/extraction/languages/terraform.js +641 -0
  228. package/sensor/dist/extraction/languages/terraform.js.map +1 -0
  229. package/sensor/dist/extraction/languages/typescript.d.ts +16 -0
  230. package/sensor/dist/extraction/languages/typescript.d.ts.map +1 -0
  231. package/sensor/dist/extraction/languages/typescript.js +167 -0
  232. package/sensor/dist/extraction/languages/typescript.js.map +1 -0
  233. package/sensor/dist/extraction/languages/vbnet.d.ts +11 -0
  234. package/sensor/dist/extraction/languages/vbnet.d.ts.map +1 -0
  235. package/sensor/dist/extraction/languages/vbnet.js +141 -0
  236. package/sensor/dist/extraction/languages/vbnet.js.map +1 -0
  237. package/sensor/dist/extraction/liquid-extractor.d.ts +59 -0
  238. package/sensor/dist/extraction/liquid-extractor.d.ts.map +1 -0
  239. package/sensor/dist/extraction/liquid-extractor.js +357 -0
  240. package/sensor/dist/extraction/liquid-extractor.js.map +1 -0
  241. package/sensor/dist/extraction/mybatis-extractor.d.ts +68 -0
  242. package/sensor/dist/extraction/mybatis-extractor.d.ts.map +1 -0
  243. package/sensor/dist/extraction/mybatis-extractor.js +300 -0
  244. package/sensor/dist/extraction/mybatis-extractor.js.map +1 -0
  245. package/sensor/dist/extraction/parse-pool.d.ts +160 -0
  246. package/sensor/dist/extraction/parse-pool.d.ts.map +1 -0
  247. package/sensor/dist/extraction/parse-pool.js +402 -0
  248. package/sensor/dist/extraction/parse-pool.js.map +1 -0
  249. package/sensor/dist/extraction/parse-worker.d.ts +8 -0
  250. package/sensor/dist/extraction/parse-worker.d.ts.map +1 -0
  251. package/sensor/dist/extraction/parse-worker.js +138 -0
  252. package/sensor/dist/extraction/parse-worker.js.map +1 -0
  253. package/sensor/dist/extraction/razor-extractor.d.ts +42 -0
  254. package/sensor/dist/extraction/razor-extractor.d.ts.map +1 -0
  255. package/sensor/dist/extraction/razor-extractor.js +285 -0
  256. package/sensor/dist/extraction/razor-extractor.js.map +1 -0
  257. package/sensor/dist/extraction/spawn-invokes.d.ts +101 -0
  258. package/sensor/dist/extraction/spawn-invokes.d.ts.map +1 -0
  259. package/sensor/dist/extraction/spawn-invokes.js +327 -0
  260. package/sensor/dist/extraction/spawn-invokes.js.map +1 -0
  261. package/sensor/dist/extraction/store-worker.d.ts +24 -0
  262. package/sensor/dist/extraction/store-worker.d.ts.map +1 -0
  263. package/sensor/dist/extraction/store-worker.js +110 -0
  264. package/sensor/dist/extraction/store-worker.js.map +1 -0
  265. package/sensor/dist/extraction/store-writer.d.ts +63 -0
  266. package/sensor/dist/extraction/store-writer.d.ts.map +1 -0
  267. package/sensor/dist/extraction/store-writer.js +174 -0
  268. package/sensor/dist/extraction/store-writer.js.map +1 -0
  269. package/sensor/dist/extraction/svelte-extractor.d.ts +56 -0
  270. package/sensor/dist/extraction/svelte-extractor.d.ts.map +1 -0
  271. package/sensor/dist/extraction/svelte-extractor.js +275 -0
  272. package/sensor/dist/extraction/svelte-extractor.js.map +1 -0
  273. package/sensor/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  274. package/sensor/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  275. package/sensor/dist/extraction/tree-sitter-helpers.js +153 -0
  276. package/sensor/dist/extraction/tree-sitter-helpers.js.map +1 -0
  277. package/sensor/dist/extraction/tree-sitter-types.d.ts +258 -0
  278. package/sensor/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  279. package/sensor/dist/extraction/tree-sitter-types.js +10 -0
  280. package/sensor/dist/extraction/tree-sitter-types.js.map +1 -0
  281. package/sensor/dist/extraction/tree-sitter.d.ts +724 -0
  282. package/sensor/dist/extraction/tree-sitter.d.ts.map +1 -0
  283. package/sensor/dist/extraction/tree-sitter.js +6721 -0
  284. package/sensor/dist/extraction/tree-sitter.js.map +1 -0
  285. package/sensor/dist/extraction/vue-extractor.d.ts +51 -0
  286. package/sensor/dist/extraction/vue-extractor.d.ts.map +1 -0
  287. package/sensor/dist/extraction/vue-extractor.js +254 -0
  288. package/sensor/dist/extraction/vue-extractor.js.map +1 -0
  289. package/sensor/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
  290. package/sensor/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  291. package/sensor/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
  292. package/sensor/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
  293. package/sensor/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
  294. package/sensor/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  295. package/sensor/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
  296. package/sensor/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
  297. package/sensor/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  298. package/sensor/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
  299. package/sensor/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  300. package/sensor/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  301. package/sensor/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
  302. package/sensor/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  303. package/sensor/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
  304. package/sensor/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
  305. package/sensor/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  306. package/sensor/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
  307. package/sensor/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
  308. package/sensor/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
  309. package/sensor/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  310. package/sensor/dist/extraction/wasm-runtime-flags.d.ts +53 -0
  311. package/sensor/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  312. package/sensor/dist/extraction/wasm-runtime-flags.js +130 -0
  313. package/sensor/dist/extraction/wasm-runtime-flags.js.map +1 -0
  314. package/sensor/dist/graph/index.d.ts +8 -0
  315. package/sensor/dist/graph/index.d.ts.map +1 -0
  316. package/sensor/dist/graph/index.js +13 -0
  317. package/sensor/dist/graph/index.js.map +1 -0
  318. package/sensor/dist/graph/queries.d.ts +106 -0
  319. package/sensor/dist/graph/queries.d.ts.map +1 -0
  320. package/sensor/dist/graph/queries.js +339 -0
  321. package/sensor/dist/graph/queries.js.map +1 -0
  322. package/sensor/dist/graph/traversal.d.ts +127 -0
  323. package/sensor/dist/graph/traversal.d.ts.map +1 -0
  324. package/sensor/dist/graph/traversal.js +599 -0
  325. package/sensor/dist/graph/traversal.js.map +1 -0
  326. package/sensor/dist/index.d.ts +653 -0
  327. package/sensor/dist/index.d.ts.map +1 -0
  328. package/sensor/dist/index.js +1646 -0
  329. package/sensor/dist/index.js.map +1 -0
  330. package/sensor/dist/installer/beta-signup.d.ts +54 -0
  331. package/sensor/dist/installer/beta-signup.d.ts.map +1 -0
  332. package/sensor/dist/installer/beta-signup.js +178 -0
  333. package/sensor/dist/installer/beta-signup.js.map +1 -0
  334. package/sensor/dist/installer/config-writer.d.ts +28 -0
  335. package/sensor/dist/installer/config-writer.d.ts.map +1 -0
  336. package/sensor/dist/installer/config-writer.js +91 -0
  337. package/sensor/dist/installer/config-writer.js.map +1 -0
  338. package/sensor/dist/installer/index.d.ts +142 -0
  339. package/sensor/dist/installer/index.d.ts.map +1 -0
  340. package/sensor/dist/installer/index.js +622 -0
  341. package/sensor/dist/installer/index.js.map +1 -0
  342. package/sensor/dist/installer/instructions-template.d.ts +41 -0
  343. package/sensor/dist/installer/instructions-template.d.ts.map +1 -0
  344. package/sensor/dist/installer/instructions-template.js +53 -0
  345. package/sensor/dist/installer/instructions-template.js.map +1 -0
  346. package/sensor/dist/installer/targets/antigravity.d.ts +57 -0
  347. package/sensor/dist/installer/targets/antigravity.d.ts.map +1 -0
  348. package/sensor/dist/installer/targets/antigravity.js +308 -0
  349. package/sensor/dist/installer/targets/antigravity.js.map +1 -0
  350. package/sensor/dist/installer/targets/claude.d.ts +62 -0
  351. package/sensor/dist/installer/targets/claude.d.ts.map +1 -0
  352. package/sensor/dist/installer/targets/claude.js +454 -0
  353. package/sensor/dist/installer/targets/claude.js.map +1 -0
  354. package/sensor/dist/installer/targets/codex.d.ts +18 -0
  355. package/sensor/dist/installer/targets/codex.d.ts.map +1 -0
  356. package/sensor/dist/installer/targets/codex.js +185 -0
  357. package/sensor/dist/installer/targets/codex.js.map +1 -0
  358. package/sensor/dist/installer/targets/cursor.d.ts +35 -0
  359. package/sensor/dist/installer/targets/cursor.d.ts.map +1 -0
  360. package/sensor/dist/installer/targets/cursor.js +254 -0
  361. package/sensor/dist/installer/targets/cursor.js.map +1 -0
  362. package/sensor/dist/installer/targets/gemini.d.ts +26 -0
  363. package/sensor/dist/installer/targets/gemini.d.ts.map +1 -0
  364. package/sensor/dist/installer/targets/gemini.js +165 -0
  365. package/sensor/dist/installer/targets/gemini.js.map +1 -0
  366. package/sensor/dist/installer/targets/hermes.d.ts +18 -0
  367. package/sensor/dist/installer/targets/hermes.d.ts.map +1 -0
  368. package/sensor/dist/installer/targets/hermes.js +359 -0
  369. package/sensor/dist/installer/targets/hermes.js.map +1 -0
  370. package/sensor/dist/installer/targets/kiro.d.ts +27 -0
  371. package/sensor/dist/installer/targets/kiro.d.ts.map +1 -0
  372. package/sensor/dist/installer/targets/kiro.js +178 -0
  373. package/sensor/dist/installer/targets/kiro.js.map +1 -0
  374. package/sensor/dist/installer/targets/opencode.d.ts +38 -0
  375. package/sensor/dist/installer/targets/opencode.d.ts.map +1 -0
  376. package/sensor/dist/installer/targets/opencode.js +288 -0
  377. package/sensor/dist/installer/targets/opencode.js.map +1 -0
  378. package/sensor/dist/installer/targets/registry.d.ts +35 -0
  379. package/sensor/dist/installer/targets/registry.d.ts.map +1 -0
  380. package/sensor/dist/installer/targets/registry.js +91 -0
  381. package/sensor/dist/installer/targets/registry.js.map +1 -0
  382. package/sensor/dist/installer/targets/shared.d.ts +101 -0
  383. package/sensor/dist/installer/targets/shared.d.ts.map +1 -0
  384. package/sensor/dist/installer/targets/shared.js +264 -0
  385. package/sensor/dist/installer/targets/shared.js.map +1 -0
  386. package/sensor/dist/installer/targets/toml.d.ts +52 -0
  387. package/sensor/dist/installer/targets/toml.d.ts.map +1 -0
  388. package/sensor/dist/installer/targets/toml.js +147 -0
  389. package/sensor/dist/installer/targets/toml.js.map +1 -0
  390. package/sensor/dist/installer/targets/types.d.ts +108 -0
  391. package/sensor/dist/installer/targets/types.d.ts.map +1 -0
  392. package/sensor/dist/installer/targets/types.js +16 -0
  393. package/sensor/dist/installer/targets/types.js.map +1 -0
  394. package/sensor/dist/mcp/daemon-manager.d.ts +42 -0
  395. package/sensor/dist/mcp/daemon-manager.d.ts.map +1 -0
  396. package/sensor/dist/mcp/daemon-manager.js +129 -0
  397. package/sensor/dist/mcp/daemon-manager.js.map +1 -0
  398. package/sensor/dist/mcp/daemon-paths.d.ts +73 -0
  399. package/sensor/dist/mcp/daemon-paths.d.ts.map +1 -0
  400. package/sensor/dist/mcp/daemon-paths.js +170 -0
  401. package/sensor/dist/mcp/daemon-paths.js.map +1 -0
  402. package/sensor/dist/mcp/daemon-registry.d.ts +54 -0
  403. package/sensor/dist/mcp/daemon-registry.d.ts.map +1 -0
  404. package/sensor/dist/mcp/daemon-registry.js +241 -0
  405. package/sensor/dist/mcp/daemon-registry.js.map +1 -0
  406. package/sensor/dist/mcp/daemon.d.ts +290 -0
  407. package/sensor/dist/mcp/daemon.d.ts.map +1 -0
  408. package/sensor/dist/mcp/daemon.js +867 -0
  409. package/sensor/dist/mcp/daemon.js.map +1 -0
  410. package/sensor/dist/mcp/dynamic-boundaries.d.ts +41 -0
  411. package/sensor/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  412. package/sensor/dist/mcp/dynamic-boundaries.js +360 -0
  413. package/sensor/dist/mcp/dynamic-boundaries.js.map +1 -0
  414. package/sensor/dist/mcp/early-ppid.d.ts +26 -0
  415. package/sensor/dist/mcp/early-ppid.d.ts.map +1 -0
  416. package/sensor/dist/mcp/early-ppid.js +29 -0
  417. package/sensor/dist/mcp/early-ppid.js.map +1 -0
  418. package/sensor/dist/mcp/engine.d.ts +130 -0
  419. package/sensor/dist/mcp/engine.d.ts.map +1 -0
  420. package/sensor/dist/mcp/engine.js +375 -0
  421. package/sensor/dist/mcp/engine.js.map +1 -0
  422. package/sensor/dist/mcp/index.d.ts +113 -0
  423. package/sensor/dist/mcp/index.d.ts.map +1 -0
  424. package/sensor/dist/mcp/index.js +551 -0
  425. package/sensor/dist/mcp/index.js.map +1 -0
  426. package/sensor/dist/mcp/liveness-watchdog.d.ts +35 -0
  427. package/sensor/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  428. package/sensor/dist/mcp/liveness-watchdog.js +267 -0
  429. package/sensor/dist/mcp/liveness-watchdog.js.map +1 -0
  430. package/sensor/dist/mcp/ppid-watchdog.d.ts +62 -0
  431. package/sensor/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  432. package/sensor/dist/mcp/ppid-watchdog.js +64 -0
  433. package/sensor/dist/mcp/ppid-watchdog.js.map +1 -0
  434. package/sensor/dist/mcp/proxy.d.ts +99 -0
  435. package/sensor/dist/mcp/proxy.d.ts.map +1 -0
  436. package/sensor/dist/mcp/proxy.js +737 -0
  437. package/sensor/dist/mcp/proxy.js.map +1 -0
  438. package/sensor/dist/mcp/query-pool.d.ts +108 -0
  439. package/sensor/dist/mcp/query-pool.d.ts.map +1 -0
  440. package/sensor/dist/mcp/query-pool.js +315 -0
  441. package/sensor/dist/mcp/query-pool.js.map +1 -0
  442. package/sensor/dist/mcp/query-worker.d.ts +24 -0
  443. package/sensor/dist/mcp/query-worker.d.ts.map +1 -0
  444. package/sensor/dist/mcp/query-worker.js +87 -0
  445. package/sensor/dist/mcp/query-worker.js.map +1 -0
  446. package/sensor/dist/mcp/server-instructions.d.ts +34 -0
  447. package/sensor/dist/mcp/server-instructions.d.ts.map +1 -0
  448. package/sensor/dist/mcp/server-instructions.js +106 -0
  449. package/sensor/dist/mcp/server-instructions.js.map +1 -0
  450. package/sensor/dist/mcp/session.d.ts +92 -0
  451. package/sensor/dist/mcp/session.d.ts.map +1 -0
  452. package/sensor/dist/mcp/session.js +355 -0
  453. package/sensor/dist/mcp/session.js.map +1 -0
  454. package/sensor/dist/mcp/startup-handshake.d.ts +44 -0
  455. package/sensor/dist/mcp/startup-handshake.d.ts.map +1 -0
  456. package/sensor/dist/mcp/startup-handshake.js +73 -0
  457. package/sensor/dist/mcp/startup-handshake.js.map +1 -0
  458. package/sensor/dist/mcp/stdin-teardown.d.ts +27 -0
  459. package/sensor/dist/mcp/stdin-teardown.d.ts.map +1 -0
  460. package/sensor/dist/mcp/stdin-teardown.js +49 -0
  461. package/sensor/dist/mcp/stdin-teardown.js.map +1 -0
  462. package/sensor/dist/mcp/tools.d.ts +651 -0
  463. package/sensor/dist/mcp/tools.d.ts.map +1 -0
  464. package/sensor/dist/mcp/tools.js +4574 -0
  465. package/sensor/dist/mcp/tools.js.map +1 -0
  466. package/sensor/dist/mcp/transport.d.ts +188 -0
  467. package/sensor/dist/mcp/transport.d.ts.map +1 -0
  468. package/sensor/dist/mcp/transport.js +377 -0
  469. package/sensor/dist/mcp/transport.js.map +1 -0
  470. package/sensor/dist/mcp/version.d.ts +30 -0
  471. package/sensor/dist/mcp/version.d.ts.map +1 -0
  472. package/sensor/dist/mcp/version.js +85 -0
  473. package/sensor/dist/mcp/version.js.map +1 -0
  474. package/sensor/dist/project-config.d.ts +94 -0
  475. package/sensor/dist/project-config.d.ts.map +1 -0
  476. package/sensor/dist/project-config.js +374 -0
  477. package/sensor/dist/project-config.js.map +1 -0
  478. package/sensor/dist/resolution/c-fnptr-synthesizer.d.ts +6 -0
  479. package/sensor/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
  480. package/sensor/dist/resolution/c-fnptr-synthesizer.js +1070 -0
  481. package/sensor/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
  482. package/sensor/dist/resolution/callback-synthesizer.d.ts +59 -0
  483. package/sensor/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  484. package/sensor/dist/resolution/callback-synthesizer.js +3961 -0
  485. package/sensor/dist/resolution/callback-synthesizer.js.map +1 -0
  486. package/sensor/dist/resolution/cooperative-yield.d.ts +40 -0
  487. package/sensor/dist/resolution/cooperative-yield.d.ts.map +1 -0
  488. package/sensor/dist/resolution/cooperative-yield.js +44 -0
  489. package/sensor/dist/resolution/cooperative-yield.js.map +1 -0
  490. package/sensor/dist/resolution/frameworks/astro.d.ts +9 -0
  491. package/sensor/dist/resolution/frameworks/astro.d.ts.map +1 -0
  492. package/sensor/dist/resolution/frameworks/astro.js +169 -0
  493. package/sensor/dist/resolution/frameworks/astro.js.map +1 -0
  494. package/sensor/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  495. package/sensor/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  496. package/sensor/dist/resolution/frameworks/cargo-workspace.js +225 -0
  497. package/sensor/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  498. package/sensor/dist/resolution/frameworks/cics.d.ts +20 -0
  499. package/sensor/dist/resolution/frameworks/cics.d.ts.map +1 -0
  500. package/sensor/dist/resolution/frameworks/cics.js +90 -0
  501. package/sensor/dist/resolution/frameworks/cics.js.map +1 -0
  502. package/sensor/dist/resolution/frameworks/csharp.d.ts +8 -0
  503. package/sensor/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  504. package/sensor/dist/resolution/frameworks/csharp.js +241 -0
  505. package/sensor/dist/resolution/frameworks/csharp.js.map +1 -0
  506. package/sensor/dist/resolution/frameworks/drupal.d.ts +51 -0
  507. package/sensor/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  508. package/sensor/dist/resolution/frameworks/drupal.js +367 -0
  509. package/sensor/dist/resolution/frameworks/drupal.js.map +1 -0
  510. package/sensor/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  511. package/sensor/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  512. package/sensor/dist/resolution/frameworks/expo-modules.js +148 -0
  513. package/sensor/dist/resolution/frameworks/expo-modules.js.map +1 -0
  514. package/sensor/dist/resolution/frameworks/express.d.ts +8 -0
  515. package/sensor/dist/resolution/frameworks/express.d.ts.map +1 -0
  516. package/sensor/dist/resolution/frameworks/express.js +308 -0
  517. package/sensor/dist/resolution/frameworks/express.js.map +1 -0
  518. package/sensor/dist/resolution/frameworks/fabric.d.ts +3 -0
  519. package/sensor/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  520. package/sensor/dist/resolution/frameworks/fabric.js +354 -0
  521. package/sensor/dist/resolution/frameworks/fabric.js.map +1 -0
  522. package/sensor/dist/resolution/frameworks/go.d.ts +8 -0
  523. package/sensor/dist/resolution/frameworks/go.d.ts.map +1 -0
  524. package/sensor/dist/resolution/frameworks/go.js +184 -0
  525. package/sensor/dist/resolution/frameworks/go.js.map +1 -0
  526. package/sensor/dist/resolution/frameworks/goframe.d.ts +41 -0
  527. package/sensor/dist/resolution/frameworks/goframe.d.ts.map +1 -0
  528. package/sensor/dist/resolution/frameworks/goframe.js +112 -0
  529. package/sensor/dist/resolution/frameworks/goframe.js.map +1 -0
  530. package/sensor/dist/resolution/frameworks/index.d.ts +50 -0
  531. package/sensor/dist/resolution/frameworks/index.d.ts.map +1 -0
  532. package/sensor/dist/resolution/frameworks/index.js +175 -0
  533. package/sensor/dist/resolution/frameworks/index.js.map +1 -0
  534. package/sensor/dist/resolution/frameworks/java.d.ts +8 -0
  535. package/sensor/dist/resolution/frameworks/java.d.ts.map +1 -0
  536. package/sensor/dist/resolution/frameworks/java.js +517 -0
  537. package/sensor/dist/resolution/frameworks/java.js.map +1 -0
  538. package/sensor/dist/resolution/frameworks/laravel.d.ts +13 -0
  539. package/sensor/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  540. package/sensor/dist/resolution/frameworks/laravel.js +257 -0
  541. package/sensor/dist/resolution/frameworks/laravel.js.map +1 -0
  542. package/sensor/dist/resolution/frameworks/nestjs.d.ts +26 -0
  543. package/sensor/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  544. package/sensor/dist/resolution/frameworks/nestjs.js +698 -0
  545. package/sensor/dist/resolution/frameworks/nestjs.js.map +1 -0
  546. package/sensor/dist/resolution/frameworks/play.d.ts +19 -0
  547. package/sensor/dist/resolution/frameworks/play.d.ts.map +1 -0
  548. package/sensor/dist/resolution/frameworks/play.js +111 -0
  549. package/sensor/dist/resolution/frameworks/play.js.map +1 -0
  550. package/sensor/dist/resolution/frameworks/python.d.ts +10 -0
  551. package/sensor/dist/resolution/frameworks/python.d.ts.map +1 -0
  552. package/sensor/dist/resolution/frameworks/python.js +400 -0
  553. package/sensor/dist/resolution/frameworks/python.js.map +1 -0
  554. package/sensor/dist/resolution/frameworks/react-native.d.ts +3 -0
  555. package/sensor/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  556. package/sensor/dist/resolution/frameworks/react-native.js +410 -0
  557. package/sensor/dist/resolution/frameworks/react-native.js.map +1 -0
  558. package/sensor/dist/resolution/frameworks/react.d.ts +8 -0
  559. package/sensor/dist/resolution/frameworks/react.d.ts.map +1 -0
  560. package/sensor/dist/resolution/frameworks/react.js +334 -0
  561. package/sensor/dist/resolution/frameworks/react.js.map +1 -0
  562. package/sensor/dist/resolution/frameworks/ruby.d.ts +8 -0
  563. package/sensor/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  564. package/sensor/dist/resolution/frameworks/ruby.js +302 -0
  565. package/sensor/dist/resolution/frameworks/ruby.js.map +1 -0
  566. package/sensor/dist/resolution/frameworks/rust.d.ts +8 -0
  567. package/sensor/dist/resolution/frameworks/rust.d.ts.map +1 -0
  568. package/sensor/dist/resolution/frameworks/rust.js +304 -0
  569. package/sensor/dist/resolution/frameworks/rust.js.map +1 -0
  570. package/sensor/dist/resolution/frameworks/svelte.d.ts +9 -0
  571. package/sensor/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  572. package/sensor/dist/resolution/frameworks/svelte.js +253 -0
  573. package/sensor/dist/resolution/frameworks/svelte.js.map +1 -0
  574. package/sensor/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  575. package/sensor/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  576. package/sensor/dist/resolution/frameworks/swift-objc.js +252 -0
  577. package/sensor/dist/resolution/frameworks/swift-objc.js.map +1 -0
  578. package/sensor/dist/resolution/frameworks/swift.d.ts +10 -0
  579. package/sensor/dist/resolution/frameworks/swift.d.ts.map +1 -0
  580. package/sensor/dist/resolution/frameworks/swift.js +400 -0
  581. package/sensor/dist/resolution/frameworks/swift.js.map +1 -0
  582. package/sensor/dist/resolution/frameworks/terraform.d.ts +38 -0
  583. package/sensor/dist/resolution/frameworks/terraform.d.ts.map +1 -0
  584. package/sensor/dist/resolution/frameworks/terraform.js +277 -0
  585. package/sensor/dist/resolution/frameworks/terraform.js.map +1 -0
  586. package/sensor/dist/resolution/frameworks/vue.d.ts +9 -0
  587. package/sensor/dist/resolution/frameworks/vue.d.ts.map +1 -0
  588. package/sensor/dist/resolution/frameworks/vue.js +303 -0
  589. package/sensor/dist/resolution/frameworks/vue.js.map +1 -0
  590. package/sensor/dist/resolution/go-module.d.ts +26 -0
  591. package/sensor/dist/resolution/go-module.d.ts.map +1 -0
  592. package/sensor/dist/resolution/go-module.js +78 -0
  593. package/sensor/dist/resolution/go-module.js.map +1 -0
  594. package/sensor/dist/resolution/goframe-synthesizer.d.ts +29 -0
  595. package/sensor/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
  596. package/sensor/dist/resolution/goframe-synthesizer.js +163 -0
  597. package/sensor/dist/resolution/goframe-synthesizer.js.map +1 -0
  598. package/sensor/dist/resolution/import-resolver.d.ts +84 -0
  599. package/sensor/dist/resolution/import-resolver.d.ts.map +1 -0
  600. package/sensor/dist/resolution/import-resolver.js +2172 -0
  601. package/sensor/dist/resolution/import-resolver.js.map +1 -0
  602. package/sensor/dist/resolution/index.d.ts +309 -0
  603. package/sensor/dist/resolution/index.d.ts.map +1 -0
  604. package/sensor/dist/resolution/index.js +2050 -0
  605. package/sensor/dist/resolution/index.js.map +1 -0
  606. package/sensor/dist/resolution/lru-cache.d.ts +24 -0
  607. package/sensor/dist/resolution/lru-cache.d.ts.map +1 -0
  608. package/sensor/dist/resolution/lru-cache.js +62 -0
  609. package/sensor/dist/resolution/lru-cache.js.map +1 -0
  610. package/sensor/dist/resolution/name-matcher.d.ts +126 -0
  611. package/sensor/dist/resolution/name-matcher.d.ts.map +1 -0
  612. package/sensor/dist/resolution/name-matcher.js +1968 -0
  613. package/sensor/dist/resolution/name-matcher.js.map +1 -0
  614. package/sensor/dist/resolution/path-aliases.d.ts +68 -0
  615. package/sensor/dist/resolution/path-aliases.d.ts.map +1 -0
  616. package/sensor/dist/resolution/path-aliases.js +238 -0
  617. package/sensor/dist/resolution/path-aliases.js.map +1 -0
  618. package/sensor/dist/resolution/resolver-pool.d.ts +66 -0
  619. package/sensor/dist/resolution/resolver-pool.d.ts.map +1 -0
  620. package/sensor/dist/resolution/resolver-pool.js +244 -0
  621. package/sensor/dist/resolution/resolver-pool.js.map +1 -0
  622. package/sensor/dist/resolution/resolver-worker.d.ts +17 -0
  623. package/sensor/dist/resolution/resolver-worker.d.ts.map +1 -0
  624. package/sensor/dist/resolution/resolver-worker.js +114 -0
  625. package/sensor/dist/resolution/resolver-worker.js.map +1 -0
  626. package/sensor/dist/resolution/strip-comments.d.ts +27 -0
  627. package/sensor/dist/resolution/strip-comments.d.ts.map +1 -0
  628. package/sensor/dist/resolution/strip-comments.js +492 -0
  629. package/sensor/dist/resolution/strip-comments.js.map +1 -0
  630. package/sensor/dist/resolution/swift-objc-bridge.d.ts +134 -0
  631. package/sensor/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  632. package/sensor/dist/resolution/swift-objc-bridge.js +256 -0
  633. package/sensor/dist/resolution/swift-objc-bridge.js.map +1 -0
  634. package/sensor/dist/resolution/types.d.ts +265 -0
  635. package/sensor/dist/resolution/types.d.ts.map +1 -0
  636. package/sensor/dist/resolution/types.js +8 -0
  637. package/sensor/dist/resolution/types.js.map +1 -0
  638. package/sensor/dist/resolution/workspace-packages.d.ts +58 -0
  639. package/sensor/dist/resolution/workspace-packages.d.ts.map +1 -0
  640. package/sensor/dist/resolution/workspace-packages.js +346 -0
  641. package/sensor/dist/resolution/workspace-packages.js.map +1 -0
  642. package/sensor/dist/search/identifier-segments.d.ts +60 -0
  643. package/sensor/dist/search/identifier-segments.d.ts.map +1 -0
  644. package/sensor/dist/search/identifier-segments.js +176 -0
  645. package/sensor/dist/search/identifier-segments.js.map +1 -0
  646. package/sensor/dist/search/query-parser.d.ts +57 -0
  647. package/sensor/dist/search/query-parser.d.ts.map +1 -0
  648. package/sensor/dist/search/query-parser.js +177 -0
  649. package/sensor/dist/search/query-parser.js.map +1 -0
  650. package/sensor/dist/search/query-utils.d.ts +87 -0
  651. package/sensor/dist/search/query-utils.d.ts.map +1 -0
  652. package/sensor/dist/search/query-utils.js +449 -0
  653. package/sensor/dist/search/query-utils.js.map +1 -0
  654. package/sensor/dist/sync/git-hooks.d.ts +45 -0
  655. package/sensor/dist/sync/git-hooks.d.ts.map +1 -0
  656. package/sensor/dist/sync/git-hooks.js +227 -0
  657. package/sensor/dist/sync/git-hooks.js.map +1 -0
  658. package/sensor/dist/sync/index.d.ts +19 -0
  659. package/sensor/dist/sync/index.d.ts.map +1 -0
  660. package/sensor/dist/sync/index.js +35 -0
  661. package/sensor/dist/sync/index.js.map +1 -0
  662. package/sensor/dist/sync/watch-policy.d.ts +48 -0
  663. package/sensor/dist/sync/watch-policy.d.ts.map +1 -0
  664. package/sensor/dist/sync/watch-policy.js +124 -0
  665. package/sensor/dist/sync/watch-policy.js.map +1 -0
  666. package/sensor/dist/sync/watcher.d.ts +372 -0
  667. package/sensor/dist/sync/watcher.d.ts.map +1 -0
  668. package/sensor/dist/sync/watcher.js +879 -0
  669. package/sensor/dist/sync/watcher.js.map +1 -0
  670. package/sensor/dist/sync/worktree.d.ts +63 -0
  671. package/sensor/dist/sync/worktree.d.ts.map +1 -0
  672. package/sensor/dist/sync/worktree.js +182 -0
  673. package/sensor/dist/sync/worktree.js.map +1 -0
  674. package/sensor/dist/telemetry/index.d.ts +157 -0
  675. package/sensor/dist/telemetry/index.d.ts.map +1 -0
  676. package/sensor/dist/telemetry/index.js +556 -0
  677. package/sensor/dist/telemetry/index.js.map +1 -0
  678. package/sensor/dist/types.d.ts +458 -0
  679. package/sensor/dist/types.d.ts.map +1 -0
  680. package/sensor/dist/types.js +117 -0
  681. package/sensor/dist/types.js.map +1 -0
  682. package/sensor/dist/ui/color.d.ts +21 -0
  683. package/sensor/dist/ui/color.d.ts.map +1 -0
  684. package/sensor/dist/ui/color.js +42 -0
  685. package/sensor/dist/ui/color.js.map +1 -0
  686. package/sensor/dist/ui/glyphs.d.ts +67 -0
  687. package/sensor/dist/ui/glyphs.d.ts.map +1 -0
  688. package/sensor/dist/ui/glyphs.js +125 -0
  689. package/sensor/dist/ui/glyphs.js.map +1 -0
  690. package/sensor/dist/ui/shimmer-progress.d.ts +11 -0
  691. package/sensor/dist/ui/shimmer-progress.d.ts.map +1 -0
  692. package/sensor/dist/ui/shimmer-progress.js +164 -0
  693. package/sensor/dist/ui/shimmer-progress.js.map +1 -0
  694. package/sensor/dist/ui/shimmer-worker.d.ts +2 -0
  695. package/sensor/dist/ui/shimmer-worker.d.ts.map +1 -0
  696. package/sensor/dist/ui/shimmer-worker.js +126 -0
  697. package/sensor/dist/ui/shimmer-worker.js.map +1 -0
  698. package/sensor/dist/ui/types.d.ts +15 -0
  699. package/sensor/dist/ui/types.d.ts.map +1 -0
  700. package/sensor/dist/ui/types.js +3 -0
  701. package/sensor/dist/ui/types.js.map +1 -0
  702. package/sensor/dist/upgrade/index.d.ts +171 -0
  703. package/sensor/dist/upgrade/index.d.ts.map +1 -0
  704. package/sensor/dist/upgrade/index.js +659 -0
  705. package/sensor/dist/upgrade/index.js.map +1 -0
  706. package/sensor/dist/upgrade/remove-binary.d.ts +87 -0
  707. package/sensor/dist/upgrade/remove-binary.d.ts.map +1 -0
  708. package/sensor/dist/upgrade/remove-binary.js +289 -0
  709. package/sensor/dist/upgrade/remove-binary.js.map +1 -0
  710. package/sensor/dist/upgrade/update-check.d.ts +92 -0
  711. package/sensor/dist/upgrade/update-check.d.ts.map +1 -0
  712. package/sensor/dist/upgrade/update-check.js +258 -0
  713. package/sensor/dist/upgrade/update-check.js.map +1 -0
  714. package/sensor/dist/utils.d.ts +224 -0
  715. package/sensor/dist/utils.d.ts.map +1 -0
  716. package/sensor/dist/utils.js +583 -0
  717. package/sensor/dist/utils.js.map +1 -0
  718. package/sensor/package.json +61 -0
  719. package/src/artifact-contracts-v2.mjs +325 -0
  720. package/src/artifact-contracts.mjs +895 -0
  721. package/src/bootstrap.mjs +88 -0
  722. package/src/boundary-compiler.mjs +712 -0
  723. package/src/boundary-observation-compiler-v2.mjs +339 -0
  724. package/src/codegraph-adapter.mjs +422 -0
  725. package/src/control-compiler.mjs +532 -0
  726. package/src/factory-diagnostics.mjs +187 -0
  727. package/src/isolation-runner.mjs +333 -0
  728. package/src/node-version-guard.mjs +43 -0
  729. package/src/rc1-black-box-oracle.mjs +906 -0
  730. package/src/rc1-comparison.mjs +154 -0
  731. package/src/rc1-evidence-bundle.mjs +456 -0
  732. package/src/rc1-v4-campaign.mjs +707 -0
  733. package/src/rc1-v4-transform.mjs +467 -0
  734. package/src/rc1-v5-artifact-set.mjs +855 -0
  735. package/src/rc1-v5-behavior-evidence.mjs +594 -0
  736. package/src/rc1-v5-campaign.mjs +796 -0
  737. package/src/rc1-v5-transform.mjs +421 -0
  738. package/src/rc1-v6-artifact-set.mjs +807 -0
  739. package/src/rc1-v6-behavior-evidence.mjs +273 -0
  740. package/src/rc1-v6-campaign.mjs +623 -0
  741. package/src/rc1-v6-causal-binding.mjs +471 -0
  742. package/src/rc1-v6-measurement.mjs +331 -0
  743. package/src/rc2-artifact-set.mjs +1579 -0
  744. package/src/rc2-campaign.mjs +1520 -0
  745. package/src/rc2-delivery-policy-front-end.mjs +1079 -0
  746. package/src/rc2-delivery-policy-oracle.mjs +134 -0
  747. package/src/rc2-delivery-policy-transform.mjs +1127 -0
  748. package/src/rc2-rc1-transfer-front-end.mjs +511 -0
  749. package/src/rc3-actual-dogfood.mjs +648 -0
  750. package/src/rc3-dogfood-scaffold.mjs +310 -0
  751. package/src/rc3-scripted-campaign.mjs +1301 -0
  752. package/src/rc4-stage1-dogfood.mjs +652 -0
  753. package/src/runtime-cli.mjs +504 -0
  754. package/src/runtime-contracts.mjs +631 -0
  755. package/src/runtime-decision-verifier.mjs +607 -0
  756. package/src/runtime-diff-observer.mjs +265 -0
  757. package/src/runtime-engine.mjs +674 -0
  758. package/src/runtime-errors.mjs +356 -0
  759. package/src/runtime-event-store.mjs +217 -0
  760. package/src/runtime-front-end.mjs +764 -0
  761. package/src/runtime-hold-recompile.mjs +606 -0
  762. package/src/runtime-projection.mjs +180 -0
  763. package/src/runtime-scripted-executor.mjs +163 -0
  764. package/src/runtime-worktree-executor.mjs +199 -0
  765. package/src/schedulability-compiler-v2.mjs +303 -0
  766. package/src/schedulability-verifier-v2.mjs +317 -0
  767. package/src/seam-transform.mjs +554 -0
  768. package/src/treatment-compiler.mjs +728 -0
  769. package/src/treatment-runner.mjs +658 -0
@@ -0,0 +1,3961 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SYNTH_PROGRESS_STEPS = exports.SYNTH_PASSES = void 0;
4
+ exports.synthesizeCallbackEdges = synthesizeCallbackEdges;
5
+ const generated_detection_1 = require("../extraction/generated-detection");
6
+ const strip_comments_1 = require("./strip-comments");
7
+ const c_fnptr_synthesizer_1 = require("./c-fnptr-synthesizer");
8
+ const goframe_synthesizer_1 = require("./goframe-synthesizer");
9
+ const cooperative_yield_1 = require("./cooperative-yield");
10
+ const REGISTRAR_NAME = /^(on[A-Z]\w*|subscribe|addListener|addEventListener|register|watch|listen|addCallback)$/;
11
+ const DISPATCHER_NAME = /(emit|trigger|notify|dispatch|fire|publish|flush)/i;
12
+ const MAX_CALLBACKS_PER_CHANNEL = 40;
13
+ const EVENT_FANOUT_CAP = 6; // skip events with more handlers/dispatchers than this (too generic without type info)
14
+ const ON_RE = /\.(?:on|once|addListener)\(\s*['"]([^'"]+)['"]\s*,\s*(?:function\s+(\w+)|(?:this\.)?(\w+))/g;
15
+ const EMIT_RE = /\.(?:emit|fire|dispatchEvent)\(\s*['"]([^'"]+)['"]/g;
16
+ const SETSTATE_RE = /this\.setState\s*\(/;
17
+ const FLUTTER_SETSTATE_RE = /\bsetState\s*\(/; // Flutter: setState((){…}) / this.setState
18
+ const JSX_TAG_RE = /<([A-Z][A-Za-z0-9_]*)[\s/>]/g;
19
+ const MAX_JSX_CHILDREN = 30;
20
+ // Vue SFC templates: kebab-case child components (<el-button> → ElButton) and
21
+ // event bindings (@click="fn" / v-on:click="fn"). PascalCase children (<VPNav/>)
22
+ // are already caught by JSX_TAG_RE via the SFC component node.
23
+ const VUE_KEBAB_RE = /<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)[\s/>]/g;
24
+ // PascalCase component tags — `<MediaCard ...>`, `<NavBar/>`. HTML elements are
25
+ // lowercase, so an uppercase-initial tag is a component usage; built-ins
26
+ // (`<NuxtLink>`, `<Transition>`) simply resolve to nothing and emit no edge.
27
+ const VUE_PASCAL_RE = /<([A-Z][A-Za-z0-9]*)[\s/>]/g;
28
+ const VUE_HANDLER_RE = /(?:@|v-on:)([a-zA-Z][\w-]*)(?:\.[\w]+)*\s*=\s*"([^"]+)"/g;
29
+ // Composable/hook destructure: `const { close: closeSidebar } = useSidebarControl()`.
30
+ // Captures the destructure body + the called composable; only `use*` calls qualify.
31
+ const VUE_DESTRUCTURE_RE = /(?:const|let|var)\s*\{([^}]+)\}\s*=\s*(\w+)\s*\(/g;
32
+ // Closure-collection dynamic dispatch (language-agnostic, Swift-first). A method
33
+ // appends a closure to a collection property; another method iterates that
34
+ // property *invoking each element* (`coll.forEach { $0() }` / `{ it() }`). The
35
+ // element-invoke (`$0(` / `it(`) PROVES the collection holds closures, so pairing
36
+ // a dispatcher to same-named registrars (`.append`/`.add`/`.push`/`.insert`,
37
+ // incl. Swift `prop.write { $0.append }`) is high-precision. Cross-file/class by
38
+ // design: Alamofire appends in `DataRequest.validate` but iterates in the base
39
+ // `Request.didCompleteTask` — neither same-file nor same-class pairing reaches it.
40
+ const CC_DISPATCH_RE = /(\w+)\.forEach\s*\{\s*(?:\$0|it)\s*\(/g;
41
+ const CC_APPEND_WRITE_RE = /(\w+)\.write\s*\{\s*\$0(?:\.(\w+))?\.(?:append|add|push|insert)\s*\(/g;
42
+ const CC_APPEND_DIRECT_RE = /(\w+)\.(?:append|add|push|insert)\s*\(/g;
43
+ const CC_FANOUT_CAP = 8; // skip a field name with more dispatchers/registrars than this (too generic to pair confidently)
44
+ // The dispatcher gate — `{ $0( ` / `{ it( ` element-invocation — is Swift/Kotlin
45
+ // trailing-closure syntax, so ONLY those languages can ever contribute a
46
+ // dispatcher, and a cross-language registrar pairing (a JS `.push(` against a
47
+ // Swift dispatcher's field name) would be a wrong edge, not a missed one.
48
+ // Gating both sides here isn't just precision: `.push(`/`.add(` is everywhere
49
+ // in JS/PHP, so an ungated scan slices + regexes nearly every function on repos
50
+ // where the pass cannot emit a single edge — on a 12k-file PHP/JS app that was
51
+ // 20+ minutes of the "Resolving refs" tail and a #850 watchdog kill (#1235).
52
+ const CC_LANGUAGES = new Set(['swift', 'kotlin']);
53
+ function kebabToPascal(s) {
54
+ return s.split('-').map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join('');
55
+ }
56
+ /**
57
+ * Nuxt auto-import name for a component, derived from its path UNDER `components/`:
58
+ * `components/media/Card.vue` → `MediaCard`, `components/base/foo/Bar.vue` →
59
+ * `BaseFooBar`. Each directory segment and the filename is PascalCased and
60
+ * concatenated; a directory whose PascalCase name prefixes the next segment is
61
+ * collapsed (Nuxt's de-dup: `base/BaseButton.vue` → `BaseButton`, not
62
+ * `BaseBaseButton`). Returns null for a flat component (`components/NavBar.vue`)
63
+ * — its node is already named by basename, so a direct tag match finds it.
64
+ */
65
+ function nuxtComponentName(filePath) {
66
+ const marker = filePath.lastIndexOf('components/');
67
+ if (marker === -1)
68
+ return null;
69
+ const rel = filePath.slice(marker + 'components/'.length).replace(/\.(vue|ts|tsx|js|jsx)$/i, '');
70
+ const segs = rel.split('/').filter(Boolean).map(kebabToPascal);
71
+ if (segs.length < 2)
72
+ return null;
73
+ const out = [];
74
+ for (const s of segs) {
75
+ const prev = out[out.length - 1];
76
+ if (prev && s.startsWith(prev))
77
+ out[out.length - 1] = s;
78
+ else
79
+ out.push(s);
80
+ }
81
+ return out.join('');
82
+ }
83
+ function sliceLines(content, startLine, endLine) {
84
+ if (!startLine || !endLine)
85
+ return null;
86
+ return content.split('\n').slice(startLine - 1, endLine).join('\n');
87
+ }
88
+ /**
89
+ * Per-match line resolver over `src`, 1-based at `baseLine`. The inline
90
+ * `src.slice(0, idx).split('\n').length` idiom is O(source-length) PER MATCH,
91
+ * which goes quadratic on a match-dense source (a generated function full of
92
+ * `.push(` calls re-scanned tens of thousands of times was most of the #1235
93
+ * indexing wedge). Builds the newline index once — lazily, since most sources
94
+ * never produce a match — then answers each call with a binary search.
95
+ */
96
+ function makeLineAt(src, baseLine) {
97
+ let nl = null;
98
+ return (idx) => {
99
+ if (!nl) {
100
+ nl = [];
101
+ for (let i = src.indexOf('\n'); i !== -1; i = src.indexOf('\n', i + 1))
102
+ nl.push(i);
103
+ }
104
+ // Count newlines strictly before idx.
105
+ let lo = 0;
106
+ let hi = nl.length;
107
+ while (lo < hi) {
108
+ const mid = (lo + hi) >> 1;
109
+ if (nl[mid] < idx)
110
+ lo = mid + 1;
111
+ else
112
+ hi = mid;
113
+ }
114
+ return baseLine + lo;
115
+ };
116
+ }
117
+ function registrarField(src) {
118
+ const m = src.match(/this\.(\w+)\.(?:add|push|set)\(/);
119
+ return m ? m[1] : null;
120
+ }
121
+ function dispatcherField(src) {
122
+ const forOf = src.match(/\bof\s+(?:Array\.from\(\s*)?this\.(\w+)/);
123
+ if (forOf && /\b\w+\s*\(/.test(src))
124
+ return forOf[1];
125
+ const forEach = src.match(/this\.(\w+)\.forEach\(/);
126
+ if (forEach)
127
+ return forEach[1];
128
+ return null;
129
+ }
130
+ const FN_KINDS = new Set(['method', 'function', 'component']);
131
+ /** Innermost function/method node whose line range contains `line`. */
132
+ function enclosingFn(nodesInFile, line) {
133
+ let best = null;
134
+ for (const n of nodesInFile) {
135
+ if (!FN_KINDS.has(n.kind))
136
+ continue;
137
+ const end = n.endLine ?? n.startLine;
138
+ if (n.startLine <= line && end >= line) {
139
+ if (!best || n.startLine >= best.startLine)
140
+ best = n; // prefer the tightest (latest-starting) encloser
141
+ }
142
+ }
143
+ return best;
144
+ }
145
+ /**
146
+ * Stream method + function nodes lazily. The synthesizers only scan-and-filter
147
+ * down to a tiny matched subset, so materializing every function/method (which
148
+ * is gigabytes on a symbol-dense project) just to iterate it once is what OOM'd
149
+ * #610. Iterating keeps memory O(1) in the node count.
150
+ */
151
+ function* methodAndFunctionNodes(queries) {
152
+ yield* queries.iterateNodesByKind('method');
153
+ yield* queries.iterateNodesByKind('function');
154
+ }
155
+ /** Phase 1: field-backed observer channels (registrar/dispatcher share a store). */
156
+ async function fieldChannelEdges(queries, ctx, onYield) {
157
+ const registrars = [];
158
+ const dispatchers = [];
159
+ let scanned = 0;
160
+ for (const m of methodAndFunctionNodes(queries)) {
161
+ if ((++scanned & 255) === 0)
162
+ await onYield(); // #1091: yield mid-scan on huge graphs
163
+ const isReg = REGISTRAR_NAME.test(m.name);
164
+ const isDisp = DISPATCHER_NAME.test(m.name);
165
+ if (!isReg && !isDisp)
166
+ continue;
167
+ const content = ctx.readFile(m.filePath);
168
+ const src = content && sliceLines(content, m.startLine, m.endLine);
169
+ if (!src)
170
+ continue;
171
+ if (isReg) {
172
+ const f = registrarField(src);
173
+ if (f)
174
+ registrars.push({ node: m, field: f });
175
+ }
176
+ if (isDisp) {
177
+ const f = dispatcherField(src);
178
+ if (f)
179
+ dispatchers.push({ node: m, field: f });
180
+ }
181
+ }
182
+ const edges = [];
183
+ const seen = new Set();
184
+ for (const reg of registrars) {
185
+ const chDispatchers = dispatchers.filter((d) => d.node.filePath === reg.node.filePath && d.field === reg.field);
186
+ if (chDispatchers.length === 0)
187
+ continue;
188
+ const argRe = new RegExp(`${reg.node.name}\\s*\\(\\s*(?:this\\.)?(\\w+)`);
189
+ let added = 0;
190
+ for (const e of queries.getIncomingEdges(reg.node.id, ['calls'])) {
191
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
192
+ break;
193
+ if (!e.line)
194
+ continue;
195
+ const caller = queries.getNodeById(e.source);
196
+ if (!caller)
197
+ continue;
198
+ const line = ctx.readFile(caller.filePath)?.split('\n')[e.line - 1];
199
+ const am = line?.match(argRe);
200
+ if (!am)
201
+ continue;
202
+ const fn = ctx.getNodesByName(am[1]).find((n) => n.kind === 'method' || n.kind === 'function');
203
+ if (!fn)
204
+ continue;
205
+ for (const disp of chDispatchers) {
206
+ if (disp.node.id === fn.id)
207
+ continue;
208
+ const key = `${disp.node.id}>${fn.id}`;
209
+ if (seen.has(key))
210
+ continue;
211
+ seen.add(key);
212
+ edges.push({
213
+ source: disp.node.id, target: fn.id, kind: 'calls', line: disp.node.startLine,
214
+ provenance: 'heuristic',
215
+ metadata: {
216
+ synthesizedBy: 'callback', via: reg.node.name, field: reg.field,
217
+ // Where the callback was wired up (`scene.onUpdate(this.triggerRender)`).
218
+ // This is the #1 thing an agent reads/greps to explain the flow — surface
219
+ // it so node/trace/context can show it without a callers() + Read round-trip.
220
+ registeredAt: `${caller.filePath}:${e.line}`,
221
+ },
222
+ });
223
+ added++;
224
+ }
225
+ }
226
+ }
227
+ return edges;
228
+ }
229
+ /**
230
+ * Closure-collection dispatch: dispatcher iterates a closure-collection property
231
+ * invoking each element; registrar appends a closure to the same-named property.
232
+ * Emits dispatcher → registrar so a flow reaches the registration site (where the
233
+ * appended closure's body — and its callers — live). High-precision: the
234
+ * dispatcher's element-invoke is the gate (a `.forEach` that does NOT invoke its
235
+ * element is ignored), so a repo with no closure-collection dispatch yields zero
236
+ * edges regardless of how many `.append`/`.push` sites it has.
237
+ *
238
+ * Pairs globally by field name (cross-file/class is required — see Alamofire's
239
+ * base-class `Request.didCompleteTask` iterating `validators` appended by the
240
+ * subclass `DataRequest.validate`), bounded by a fan-out cap so a generic field
241
+ * name shared across unrelated classes can't fan out into noise.
242
+ */
243
+ async function closureCollectionEdges(queries, ctx, onYield) {
244
+ const dispatchers = new Map(); // field → dispatcher methods + forEach line
245
+ const registrars = new Map(); // field → registrar methods + append line
246
+ const addReg = (field, node, absLine) => {
247
+ if (!field || /^\d+$/.test(field))
248
+ return; // `$0.append` mis-captures the `0`; the write-RE owns that field
249
+ const arr = registrars.get(field) ?? [];
250
+ if (!arr.some((r) => r.node.id === node.id))
251
+ arr.push({ node, line: absLine });
252
+ registrars.set(field, arr);
253
+ };
254
+ // Slices EVERY Swift/Kotlin method/function's source (no cheap name-gate), so
255
+ // on a repo with a huge file this is the heaviest synthesis pass — yield
256
+ // mid-scan (and mid-match-loop below: a single generated function dense with
257
+ // matches must not starve the watchdog either) so it can't wedge the #850
258
+ // watchdog on its own (#1091, #1235).
259
+ let scanned = 0;
260
+ let matchTick = 0;
261
+ for (const m of methodAndFunctionNodes(queries)) {
262
+ if ((++scanned & 127) === 0)
263
+ await onYield();
264
+ if (!CC_LANGUAGES.has(m.language))
265
+ continue;
266
+ const content = ctx.readFile(m.filePath);
267
+ const src = content && sliceLines(content, m.startLine, m.endLine);
268
+ if (!src)
269
+ continue;
270
+ const hasForEach = src.includes('.forEach');
271
+ const hasAppend = src.includes('.append(') || src.includes('.add(') || src.includes('.push(') || src.includes('.insert(');
272
+ if (!hasForEach && !hasAppend)
273
+ continue;
274
+ const lineAt = makeLineAt(src, m.startLine ?? 1);
275
+ if (hasForEach) {
276
+ CC_DISPATCH_RE.lastIndex = 0;
277
+ let d;
278
+ while ((d = CC_DISPATCH_RE.exec(src))) {
279
+ if ((++matchTick & 255) === 0)
280
+ await onYield();
281
+ const arr = dispatchers.get(d[1]) ?? [];
282
+ if (!arr.some((n) => n.node.id === m.id))
283
+ arr.push({ node: m, line: lineAt(d.index) });
284
+ dispatchers.set(d[1], arr);
285
+ }
286
+ }
287
+ if (hasAppend) {
288
+ CC_APPEND_WRITE_RE.lastIndex = 0;
289
+ let w;
290
+ while ((w = CC_APPEND_WRITE_RE.exec(src))) {
291
+ if ((++matchTick & 255) === 0)
292
+ await onYield();
293
+ addReg(w[2] || w[1], m, lineAt(w.index)); // nested `$0.streams` else the `.write` receiver
294
+ }
295
+ CC_APPEND_DIRECT_RE.lastIndex = 0;
296
+ let a;
297
+ while ((a = CC_APPEND_DIRECT_RE.exec(src))) {
298
+ if ((++matchTick & 255) === 0)
299
+ await onYield();
300
+ addReg(a[1], m, lineAt(a.index));
301
+ }
302
+ }
303
+ }
304
+ const edges = [];
305
+ const seen = new Set();
306
+ for (const [field, disps] of dispatchers) {
307
+ const regs = registrars.get(field);
308
+ if (!regs || regs.length === 0)
309
+ continue;
310
+ if (disps.length > CC_FANOUT_CAP || regs.length > CC_FANOUT_CAP)
311
+ continue; // generic field — can't pair confidently
312
+ for (const disp of disps)
313
+ for (const reg of regs) {
314
+ if (disp.node.id === reg.node.id)
315
+ continue;
316
+ const key = `${disp.node.id}>${reg.node.id}`;
317
+ if (seen.has(key))
318
+ continue;
319
+ seen.add(key);
320
+ edges.push({
321
+ source: disp.node.id, target: reg.node.id, kind: 'calls', line: disp.line,
322
+ provenance: 'heuristic',
323
+ metadata: { synthesizedBy: 'closure-collection', field, registeredAt: `${reg.node.filePath}:${reg.line}` },
324
+ });
325
+ }
326
+ }
327
+ return edges;
328
+ }
329
+ /** Phase 2: string-keyed EventEmitter channels (on('e', fn) ↔ emit('e')). */
330
+ async function eventEmitterEdges(ctx, onYield) {
331
+ let scannedFiles = 0;
332
+ const emitsByEvent = new Map(); // event → dispatcher node ids
333
+ const handlersByEvent = new Map(); // event → handler id → registration site (file:line)
334
+ let scanned = 0;
335
+ for (const file of ctx.getAllFiles()) {
336
+ if ((++scannedFiles & 15) === 0)
337
+ await onYield();
338
+ if ((++scanned & 255) === 0)
339
+ await onYield(); // #1091: yield mid-scan on huge graphs
340
+ const content = ctx.readFile(file);
341
+ if (!content)
342
+ continue;
343
+ const hasEmit = content.includes('.emit(') || content.includes('.fire(') || content.includes('.dispatchEvent(');
344
+ const hasOn = content.includes('.on(') || content.includes('.once(') || content.includes('.addListener(');
345
+ if (!hasEmit && !hasOn)
346
+ continue;
347
+ const nodesInFile = ctx.getNodesInFile(file);
348
+ const lineOf = makeLineAt(content, 1);
349
+ if (hasEmit) {
350
+ EMIT_RE.lastIndex = 0;
351
+ let m;
352
+ while ((m = EMIT_RE.exec(content))) {
353
+ const disp = enclosingFn(nodesInFile, lineOf(m.index));
354
+ if (!disp)
355
+ continue;
356
+ const set = emitsByEvent.get(m[1]) ?? new Set();
357
+ set.add(disp.id);
358
+ emitsByEvent.set(m[1], set);
359
+ }
360
+ }
361
+ if (hasOn) {
362
+ ON_RE.lastIndex = 0;
363
+ let m;
364
+ while ((m = ON_RE.exec(content))) {
365
+ const handlerName = m[2] || m[3];
366
+ if (!handlerName)
367
+ continue;
368
+ const handler = ctx.getNodesByName(handlerName).find((n) => n.kind === 'function' || n.kind === 'method');
369
+ if (!handler)
370
+ continue;
371
+ const map = handlersByEvent.get(m[1]) ?? new Map();
372
+ map.set(handler.id, `${file}:${lineOf(m.index)}`);
373
+ handlersByEvent.set(m[1], map);
374
+ }
375
+ }
376
+ }
377
+ const edges = [];
378
+ const seen = new Set();
379
+ for (const [event, dispatchers] of emitsByEvent) {
380
+ const handlers = handlersByEvent.get(event);
381
+ if (!handlers)
382
+ continue;
383
+ // Precision guard: a generic event name with many handlers/dispatchers can't
384
+ // be matched without receiver-type info (Phase 3) — skip rather than over-link.
385
+ if (dispatchers.size > EVENT_FANOUT_CAP || handlers.size > EVENT_FANOUT_CAP)
386
+ continue;
387
+ for (const d of dispatchers)
388
+ for (const [h, registeredAt] of handlers) {
389
+ if (d === h)
390
+ continue;
391
+ const key = `${d}>${h}`;
392
+ if (seen.has(key))
393
+ continue;
394
+ seen.add(key);
395
+ edges.push({ source: d, target: h, kind: 'calls', provenance: 'heuristic', metadata: { synthesizedBy: 'event-emitter', event, registeredAt } });
396
+ }
397
+ }
398
+ return edges;
399
+ }
400
+ /**
401
+ * Phase 4: React class-component re-render. `this.setState(...)` re-runs the
402
+ * component's `render()`, but that hop is React-internal — no static edge — so a
403
+ * flow like "mutation → setState → canvas repaint" dead-ends at setState even
404
+ * though `render → getRenderableElements → …` is fully call-connected after it.
405
+ * Bridge it: for each class that has a `render` method, link every sibling method
406
+ * whose body calls `this.setState(` → `render`. The setState gate keeps this to
407
+ * React class components (a non-React class with a `render` method won't call
408
+ * `this.setState`). Over-approximation (all setState methods reach render) is
409
+ * accepted — it's reachability-correct, like the callback channels.
410
+ */
411
+ async function reactRenderEdges(queries, ctx, onYield) {
412
+ let scanned255 = 0;
413
+ const edges = [];
414
+ const seen = new Set();
415
+ for (const cls of queries.iterateNodesByKind('class')) {
416
+ if ((++scanned255 & 63) === 0)
417
+ await onYield();
418
+ const children = queries.getOutgoingEdges(cls.id, ['contains'])
419
+ .map((e) => queries.getNodeById(e.target))
420
+ .filter((n) => !!n && n.kind === 'method');
421
+ const render = children.find((n) => n.name === 'render');
422
+ if (!render)
423
+ continue;
424
+ let added = 0;
425
+ for (const m of children) {
426
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
427
+ break;
428
+ if (m.id === render.id)
429
+ continue;
430
+ const content = ctx.readFile(m.filePath);
431
+ const src = content && sliceLines(content, m.startLine, m.endLine);
432
+ if (!src || !SETSTATE_RE.test(src))
433
+ continue;
434
+ const key = `${m.id}>${render.id}`;
435
+ if (seen.has(key))
436
+ continue;
437
+ seen.add(key);
438
+ edges.push({
439
+ source: m.id, target: render.id, kind: 'calls', line: m.startLine,
440
+ provenance: 'heuristic',
441
+ metadata: { synthesizedBy: 'react-render', via: 'setState', registeredAt: `${render.filePath}:${render.startLine}` },
442
+ });
443
+ added++;
444
+ }
445
+ }
446
+ return edges;
447
+ }
448
+ /**
449
+ * Phase 4b: Flutter setState → build (the Dart analog of react-render). In a
450
+ * StatefulWidget's State class, `setState(() {…})` re-runs `build(context)`, but
451
+ * that hop is framework-internal (Flutter calls build), so a flow like
452
+ * "onPressed → _increment → setState → rebuilt UI" dead-ends at setState. Bridge
453
+ * it: for each Dart class with a `build` method, link every sibling method whose
454
+ * body calls `setState(` → `build`. The setState gate + `.dart` file keep this to
455
+ * Flutter State classes. Over-approximation accepted (reachability-correct).
456
+ */
457
+ async function flutterBuildEdges(queries, ctx, onYield) {
458
+ let scanned255 = 0;
459
+ const edges = [];
460
+ const seen = new Set();
461
+ for (const cls of queries.iterateNodesByKind('class')) {
462
+ if ((++scanned255 & 63) === 0)
463
+ await onYield();
464
+ const children = queries.getOutgoingEdges(cls.id, ['contains'])
465
+ .map((e) => queries.getNodeById(e.target))
466
+ .filter((n) => !!n && n.kind === 'method');
467
+ const build = children.find((n) => n.name === 'build');
468
+ if (!build || !build.filePath.endsWith('.dart'))
469
+ continue;
470
+ let added = 0;
471
+ for (const m of children) {
472
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
473
+ break;
474
+ if (m.id === build.id)
475
+ continue;
476
+ const content = ctx.readFile(m.filePath);
477
+ const src = content && sliceLines(content, m.startLine, m.endLine);
478
+ if (!src || !FLUTTER_SETSTATE_RE.test(src))
479
+ continue;
480
+ const key = `${m.id}>${build.id}`;
481
+ if (seen.has(key))
482
+ continue;
483
+ seen.add(key);
484
+ edges.push({
485
+ source: m.id, target: build.id, kind: 'calls', line: m.startLine,
486
+ provenance: 'heuristic',
487
+ metadata: { synthesizedBy: 'flutter-build', via: 'setState', registeredAt: `${build.filePath}:${build.startLine}` },
488
+ });
489
+ added++;
490
+ }
491
+ }
492
+ return edges;
493
+ }
494
+ /**
495
+ * Reactive ArkUI property decorators: assigning a property carrying one of
496
+ * these re-runs the owning struct's `build()`. Covers both state models —
497
+ * V1 (`@Component`: State/Prop/Link/Provide/Consume/Storage*) and V2
498
+ * (`@ComponentV2`: Local/Provider/Consumer; `@Param` is read-only in V2 so
499
+ * the assignment gate never fires on it, and `@Trace` lives on `@ObservedV2`
500
+ * data classes, not struct properties).
501
+ */
502
+ const ARKUI_REACTIVE_DECORATORS = new Set([
503
+ 'State', 'Prop', 'Link', 'Provide', 'Consume', 'StorageLink', 'StorageProp',
504
+ 'LocalStorageLink', 'LocalStorageProp', 'ObjectLink',
505
+ 'Local', 'Provider', 'Consumer',
506
+ ]);
507
+ /** ArkUI-observed array mutators — `this.todos.push(x)` re-renders like an assignment. */
508
+ const ARKUI_ARRAY_MUTATORS = 'push|pop|shift|unshift|splice|sort|reverse|fill';
509
+ /**
510
+ * Phase 4b-ets: ArkUI state → build (the ArkTS analog of react-render /
511
+ * flutter-build). Assigning a reactive-decorated property (`@State count`,
512
+ * `@Link selected`, …) re-runs the `@Component struct`'s `build()`, but that
513
+ * hop is framework-internal — no static edge — so "onClick → markAllDone →
514
+ * this.todos = […] → rebuilt list" dead-ends at the assignment. Bridge it:
515
+ * for each arkts struct with a `build()` method and at least one reactive
516
+ * property, link every sibling method whose body ASSIGNS (or array-mutates)
517
+ * one of those properties → `build`. Assignment-gated on the struct's OWN
518
+ * reactive property names — a method that merely reads state, or a struct
519
+ * with no reactive properties, gets nothing (this is the precision line the
520
+ * all-sibling-methods design would erase).
521
+ */
522
+ async function arkuiStateBuildEdges(queries, ctx, onYield) {
523
+ let scanned255 = 0;
524
+ const edges = [];
525
+ const seen = new Set();
526
+ for (const struct of queries.iterateNodesByKind('struct')) {
527
+ if ((++scanned255 & 63) === 0)
528
+ await onYield();
529
+ if (struct.language !== 'arkts')
530
+ continue;
531
+ const children = queries.getOutgoingEdges(struct.id, ['contains'])
532
+ .map((e) => queries.getNodeById(e.target))
533
+ .filter((n) => !!n);
534
+ const build = children.find((n) => n.kind === 'method' && n.name === 'build');
535
+ if (!build)
536
+ continue;
537
+ const reactiveProps = children.filter((n) => n.kind === 'property' && (n.decorators ?? []).some((d) => ARKUI_REACTIVE_DECORATORS.has(d)));
538
+ if (reactiveProps.length === 0)
539
+ continue;
540
+ const propAlternation = reactiveProps
541
+ .map((p) => p.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
542
+ .join('|');
543
+ // `this.count = …` / `+=` / `++` / `--` / `this.todos.push(…)`. The
544
+ // `=(?!=)` keeps `this.done == x` comparisons out.
545
+ const mutationRe = new RegExp(`this\\.(?:${propAlternation})\\s*(?:=(?!=)|\\+\\+|--|[+\\-*/%&|^]=|\\.(?:${ARKUI_ARRAY_MUTATORS})\\s*\\()`);
546
+ let added = 0;
547
+ for (const m of children) {
548
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
549
+ break;
550
+ if (m.kind !== 'method' || m.id === build.id)
551
+ continue;
552
+ const content = ctx.readFile(m.filePath);
553
+ const src = content && sliceLines(content, m.startLine, m.endLine);
554
+ if (!src || !mutationRe.test((0, strip_comments_1.stripCommentsForRegex)(src, 'typescript')))
555
+ continue;
556
+ const key = `${m.id}>${build.id}`;
557
+ if (seen.has(key))
558
+ continue;
559
+ seen.add(key);
560
+ edges.push({
561
+ source: m.id, target: build.id, kind: 'calls', line: m.startLine,
562
+ provenance: 'heuristic',
563
+ metadata: { synthesizedBy: 'arkui-state', via: 'state assignment', registeredAt: `${build.filePath}:${build.startLine}` },
564
+ });
565
+ added++;
566
+ }
567
+ }
568
+ return edges;
569
+ }
570
+ /** Emit/subscribe call sites of HarmonyOS's `@ohos.events.emitter` bus. */
571
+ const ARKUI_EMITTER_CALL_RE = /\bemitter\s*\.\s*(emit|on|once)\s*\(\s*([A-Za-z_$][\w$.]*|\{[^)]{0,120}?\beventId\s*:\s*[^,}]+[^)]*?\})/g;
572
+ /** Cap per event bucket — a generic key with many parties is dynamic routing, not a static pair. */
573
+ const ARKUI_EMITTER_FANOUT_CAP = 8;
574
+ /**
575
+ * Phase 4b-ets2: HarmonyOS `@ohos.events.emitter` bridge. The cross-component
576
+ * bus — `emitter.emit(eventId)` fires `emitter.on(eventId, cb)` — is
577
+ * framework-internal, so an order flow riding it (OrangeShopping's
578
+ * add-to-cart) dead-ends at the emit. Link emit-site enclosing
579
+ * function/method → on/once-site enclosing function/method when both
580
+ * reference the SAME statically-recoverable event key.
581
+ *
582
+ * Key recovery, per call site (comment-stripped enclosing-file source): the
583
+ * first argument is an `{ eventId: K }` literal, a `Names.Dotted` constant, or
584
+ * a local whose same-file declaration is `new EventsId(K)` / `= K` — chase one
585
+ * level. Precision scoping learned from the samples monorepo (thousands of
586
+ * unrelated samples, most using eventId 1): NUMERIC keys pair within the same
587
+ * FILE only; NAMED keys pair within the same workspace module directory (or
588
+ * the whole project when it declares no modules — the single-app case), both
589
+ * behind a fan-out cap. Inline `on(id, (e) => {…})` arrows need no special
590
+ * handling — their bodies' calls already attribute to the registering method,
591
+ * so targeting that method keeps the chain connected.
592
+ */
593
+ async function arkuiEmitterEdges(ctx, onYield) {
594
+ let scannedFiles = 0;
595
+ // bucket key -> emit sites / handler sites
596
+ const emits = new Map();
597
+ const handlers = new Map();
598
+ const moduleDirs = (() => {
599
+ const ws = ctx.getWorkspacePackages?.();
600
+ return ws ? [...new Set(ws.byName.values())].sort((a, b) => b.length - a.length) : [];
601
+ })();
602
+ const moduleScopeOf = (file) => {
603
+ for (const dir of moduleDirs) {
604
+ if (file === dir || file.startsWith(dir + '/'))
605
+ return dir;
606
+ }
607
+ return '';
608
+ };
609
+ for (const file of ctx.getAllFiles()) {
610
+ if ((++scannedFiles & 15) === 0)
611
+ await onYield();
612
+ if (!file.endsWith('.ets'))
613
+ continue;
614
+ const content = ctx.readFile(file);
615
+ if (!content || !content.includes('emitter.'))
616
+ continue;
617
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'typescript');
618
+ const nodes = ctx.getNodesInFile(file)
619
+ .filter((n) => n.kind === 'method' || n.kind === 'function');
620
+ ARKUI_EMITTER_CALL_RE.lastIndex = 0;
621
+ let m;
622
+ while ((m = ARKUI_EMITTER_CALL_RE.exec(safe))) {
623
+ const verb = m[1];
624
+ const arg = m[2].trim();
625
+ const line = safe.slice(0, m.index).split('\n').length;
626
+ const encl = nodes
627
+ .filter((n) => n.startLine <= line && n.endLine >= line)
628
+ .sort((a, b) => (a.endLine - a.startLine) - (b.endLine - b.startLine))[0];
629
+ if (!encl)
630
+ continue;
631
+ // Recover the event key from the first argument.
632
+ let key = null;
633
+ const idLit = arg.startsWith('{') ? arg.match(/\beventId\s*:\s*([\w$.]+)/)?.[1] : undefined;
634
+ const token = idLit ?? arg;
635
+ if (token !== undefined) {
636
+ if (/^\d+$/.test(token)) {
637
+ key = `num:${file}:${token}`; // numeric: same-file only
638
+ }
639
+ else if (token.includes('.')) {
640
+ key = `name:${moduleScopeOf(file)}:${token}`;
641
+ }
642
+ else {
643
+ // Local variable — chase its same-file declaration one level:
644
+ // `let x = new EventsId(K)` / `const x = K`.
645
+ const declRe = new RegExp(`\\b${token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b\\s*(?::[^=\\n]+)?=\\s*(?:new\\s+[\\w$.]+\\(\\s*([^)\\n]+?)\\s*\\)|([\\w$.]+))`);
646
+ const decl = safe.match(declRe);
647
+ const inner = (decl?.[1] ?? decl?.[2])?.trim();
648
+ if (inner && /^\d+$/.test(inner))
649
+ key = `num:${file}:${inner}`;
650
+ else if (inner && /^[\w$.]+$/.test(inner))
651
+ key = `name:${moduleScopeOf(file)}:${inner}`;
652
+ }
653
+ }
654
+ if (!key)
655
+ continue;
656
+ const site = { nodeId: encl.id, file, line };
657
+ if (verb === 'emit') {
658
+ (emits.get(key) ?? emits.set(key, []).get(key)).push(site);
659
+ }
660
+ else {
661
+ (handlers.get(key) ?? handlers.set(key, []).get(key)).push(site);
662
+ }
663
+ }
664
+ }
665
+ const edges = [];
666
+ const seen = new Set();
667
+ for (const [key, emitSites] of emits) {
668
+ const handlerSites = handlers.get(key);
669
+ if (!handlerSites)
670
+ continue;
671
+ if (emitSites.length > ARKUI_EMITTER_FANOUT_CAP || handlerSites.length > ARKUI_EMITTER_FANOUT_CAP)
672
+ continue;
673
+ const eventLabel = key.slice(key.lastIndexOf(':') + 1);
674
+ for (const e of emitSites)
675
+ for (const h of handlerSites) {
676
+ if (e.nodeId === h.nodeId)
677
+ continue;
678
+ const dedupe = `${e.nodeId}>${h.nodeId}`;
679
+ if (seen.has(dedupe))
680
+ continue;
681
+ seen.add(dedupe);
682
+ edges.push({
683
+ source: e.nodeId, target: h.nodeId, kind: 'calls', line: e.line,
684
+ provenance: 'heuristic',
685
+ metadata: { synthesizedBy: 'arkui-emitter', event: eventLabel, registeredAt: `${h.file}:${h.line}` },
686
+ });
687
+ }
688
+ }
689
+ return edges;
690
+ }
691
+ /** `router.pushUrl({ url: 'pages/Detail' })` / replaceUrl — literal urls only. */
692
+ const ARKUI_ROUTER_RE = /\brouter\s*\.\s*(?:pushUrl|replaceUrl)\s*\(\s*\{[^)]{0,200}?\burl\s*:\s*['"]([\w\-./]+)['"]/g;
693
+ /**
694
+ * Phase 4b-ets3: HarmonyOS page navigation. `router.pushUrl({ url:
695
+ * 'pages/Detail' })` reaches the `@Entry struct` of
696
+ * `<module>/src/main/ets/pages/Detail.ets`, but the hop is a string — no
697
+ * static edge — so "tap → openDetail → ???" ends at the router call. Bridge
698
+ * literal urls to the page struct: the url resolves against the standard
699
+ * `src/main/ets/` layout (what main_pages.json entries name); candidates
700
+ * prefer the caller's own workspace module (routes are module-scoped), and
701
+ * anything still ambiguous is dropped rather than guessed. Only `@Entry`
702
+ * structs qualify as targets — the decorator is what makes a file a page.
703
+ */
704
+ async function arkuiRouterEdges(ctx, onYield) {
705
+ const edges = [];
706
+ const seen = new Set();
707
+ const allFiles = ctx.getAllFiles();
708
+ const moduleDirs = (() => {
709
+ const ws = ctx.getWorkspacePackages?.();
710
+ return ws ? [...new Set(ws.byName.values())].sort((a, b) => b.length - a.length) : [];
711
+ })();
712
+ const moduleScopeOf = (file) => {
713
+ for (const dir of moduleDirs) {
714
+ if (file === dir || file.startsWith(dir + '/'))
715
+ return dir;
716
+ }
717
+ return '';
718
+ };
719
+ let scannedFiles = 0;
720
+ for (const file of allFiles) {
721
+ if ((++scannedFiles & 15) === 0)
722
+ await onYield();
723
+ if (!file.endsWith('.ets'))
724
+ continue;
725
+ const content = ctx.readFile(file);
726
+ if (!content || !content.includes('router.'))
727
+ continue;
728
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'typescript');
729
+ const nodes = ctx.getNodesInFile(file)
730
+ .filter((n) => n.kind === 'method' || n.kind === 'function');
731
+ ARKUI_ROUTER_RE.lastIndex = 0;
732
+ let m;
733
+ while ((m = ARKUI_ROUTER_RE.exec(safe))) {
734
+ const url = m[1];
735
+ const line = safe.slice(0, m.index).split('\n').length;
736
+ const encl = nodes
737
+ .filter((n) => n.startLine <= line && n.endLine >= line)
738
+ .sort((a, b) => (a.endLine - a.startLine) - (b.endLine - b.startLine))[0];
739
+ if (!encl)
740
+ continue;
741
+ const suffix = `/src/main/ets/${url}.ets`;
742
+ let candidates = allFiles.filter((f) => f.endsWith(suffix));
743
+ if (candidates.length > 1) {
744
+ const scope = moduleScopeOf(file);
745
+ const sameModule = candidates.filter((f) => moduleScopeOf(f) === scope);
746
+ if (sameModule.length > 0)
747
+ candidates = sameModule;
748
+ }
749
+ if (candidates.length !== 1)
750
+ continue; // ambiguous or unresolved — never guess
751
+ const page = ctx.getNodesInFile(candidates[0]).find((n) => n.kind === 'struct' && (n.decorators ?? []).includes('Entry'));
752
+ if (!page)
753
+ continue;
754
+ const key = `${encl.id}>${page.id}`;
755
+ if (seen.has(key))
756
+ continue;
757
+ seen.add(key);
758
+ edges.push({
759
+ source: encl.id, target: page.id, kind: 'calls', line,
760
+ provenance: 'heuristic',
761
+ metadata: { synthesizedBy: 'arkui-route', event: url, registeredAt: `${candidates[0]}:${page.startLine}` },
762
+ });
763
+ }
764
+ }
765
+ return edges;
766
+ }
767
+ /**
768
+ * Phase 4c: C++ virtual override. A call through a base/interface pointer
769
+ * (`db->Get(...)`, `iter->Next()`) dispatches at runtime to a subclass override,
770
+ * but that hop is a vtable indirection — no static call edge — so a flow stops at
771
+ * the abstract base method. Bridge it like react-render: for each C++ class that
772
+ * `extends` a base, link each base method → the subclass method of the same name
773
+ * (the override), so trace/callees from the interface method reach the
774
+ * implementation(s). Over-approximation accepted (reachability-correct); capped
775
+ * per class and gated to C++ to avoid touching other languages' dispatch.
776
+ */
777
+ async function cppOverrideEdges(queries, onYield) {
778
+ let scanned255 = 0;
779
+ const edges = [];
780
+ const seen = new Set();
781
+ const methodsOf = (classId) => queries
782
+ .getOutgoingEdges(classId, ['contains'])
783
+ .map((e) => queries.getNodeById(e.target))
784
+ .filter((n) => !!n && n.kind === 'method');
785
+ for (const cls of queries.iterateNodesByKind('class')) {
786
+ if ((++scanned255 & 63) === 0)
787
+ await onYield();
788
+ const subMethods = methodsOf(cls.id).filter((n) => n.language === 'cpp');
789
+ if (subMethods.length === 0)
790
+ continue;
791
+ for (const ext of queries.getOutgoingEdges(cls.id, ['extends'])) {
792
+ const base = queries.getNodeById(ext.target);
793
+ if (!base || base.language !== 'cpp' || base.id === cls.id)
794
+ continue;
795
+ const baseMethods = new Map(methodsOf(base.id).map((m) => [m.name, m]));
796
+ let added = 0;
797
+ for (const m of subMethods) {
798
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
799
+ break;
800
+ const bm = baseMethods.get(m.name);
801
+ if (!bm || bm.id === m.id)
802
+ continue;
803
+ const key = `${bm.id}>${m.id}`;
804
+ if (seen.has(key))
805
+ continue;
806
+ seen.add(key);
807
+ edges.push({
808
+ source: bm.id,
809
+ target: m.id,
810
+ kind: 'calls',
811
+ line: bm.startLine,
812
+ provenance: 'heuristic',
813
+ metadata: { synthesizedBy: 'cpp-override', via: m.name, registeredAt: `${m.filePath}:${m.startLine}` },
814
+ });
815
+ added++;
816
+ }
817
+ }
818
+ }
819
+ return edges;
820
+ }
821
+ /**
822
+ * Phase 5.5: interface / abstract dispatch (Java, Kotlin). A call through an
823
+ * injected interface (`@Autowired FooService svc; svc.list()`) or an abstract
824
+ * base dispatches at runtime to the implementing class's override — a vtable
825
+ * indirection with no static call edge — so a request→service flow stops at the
826
+ * interface method. Bridge it like cpp-override: for each class that
827
+ * `implements` an interface (or `extends` an abstract base), link each
828
+ * base/interface method → the class's same-name method (the override) so
829
+ * trace/callees reach the implementation. Over-approximation accepted
830
+ * (reachability-correct); capped per class, gated to JVM languages.
831
+ */
832
+ // Languages whose static `implements`/`extends` edges should bridge an
833
+ // interface (or abstract base) method to the matching concrete-class method.
834
+ // The set is "languages with explicit nominal subtyping and a single class
835
+ // kind that holds methods" — i.e. the shape this loop expects. Swift and
836
+ // Scala fit shape-wise (Swift `protocol`/`class`, Scala `trait`/`class`)
837
+ // and are added below; their concrete-side nodes can be a `struct` (Swift)
838
+ // or an `object` (Scala) so the loop also iterates those kinds.
839
+ const IFACE_OVERRIDE_LANGS = new Set([
840
+ 'java', 'kotlin', 'csharp', 'typescript', 'javascript', 'swift', 'scala', 'go', 'rust',
841
+ 'arkts',
842
+ ]);
843
+ /**
844
+ * Go implicit interface satisfaction (#584). Go has no `implements` keyword — a
845
+ * struct satisfies an interface structurally when its method set covers the
846
+ * interface's. Synthesize the missing `implements` edge (struct → interface) by
847
+ * matching method-NAME sets, so impl-navigation works and the interface-dispatch
848
+ * bridge ({@link interfaceOverrideEdges}, now 'go'-enabled) can link an interface
849
+ * method call to the concrete overrides.
850
+ *
851
+ * Name-only matching (signatures ignored) — over-approximation accepted, in line
852
+ * with the other dispatch synthesizers; capped per interface. Empty interfaces
853
+ * (`any`) are skipped so they don't match every struct.
854
+ */
855
+ async function goImplementsEdges(queries, onYield) {
856
+ let scanned255 = 0;
857
+ const edges = [];
858
+ const seen = new Set();
859
+ const methodNameSet = (id) => new Set(queries
860
+ .getOutgoingEdges(id, ['contains'])
861
+ .map((e) => queries.getNodeById(e.target))
862
+ .filter((n) => !!n && n.kind === 'method')
863
+ .map((n) => n.name));
864
+ // Materializes GO structs only (the pass is language-gated by the caller),
865
+ // never the whole struct kind — that array is O(nodes) on struct-heavy
866
+ // repos like the Linux kernel (#1212).
867
+ const goStructs = [];
868
+ for (const s of queries.iterateNodesByKind('struct')) {
869
+ if ((++scanned255 & 63) === 0)
870
+ await onYield();
871
+ if (s.language === 'go')
872
+ goStructs.push(s);
873
+ }
874
+ const structMethods = new Map();
875
+ for (const s of goStructs)
876
+ structMethods.set(s.id, methodNameSet(s.id));
877
+ for (const iface of queries.iterateNodesByKind('interface')) {
878
+ if ((++scanned255 & 63) === 0)
879
+ await onYield();
880
+ if ((++scanned255 & 63) === 0)
881
+ await onYield();
882
+ if (iface.language !== 'go')
883
+ continue;
884
+ const want = methodNameSet(iface.id);
885
+ if (want.size === 0)
886
+ continue; // empty interface (`any`) — would match everything
887
+ let added = 0;
888
+ for (const s of goStructs) {
889
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
890
+ break;
891
+ const have = structMethods.get(s.id);
892
+ if (!have || have.size < want.size)
893
+ continue;
894
+ let all = true;
895
+ for (const m of want) {
896
+ if (!have.has(m)) {
897
+ all = false;
898
+ break;
899
+ }
900
+ }
901
+ if (!all)
902
+ continue;
903
+ const key = `${s.id}>${iface.id}`;
904
+ if (seen.has(key))
905
+ continue;
906
+ seen.add(key);
907
+ edges.push({
908
+ source: s.id,
909
+ target: iface.id,
910
+ kind: 'implements',
911
+ line: s.startLine,
912
+ provenance: 'heuristic',
913
+ metadata: { synthesizedBy: 'go-implements', via: iface.name, registeredAt: `${s.filePath}:${s.startLine}` },
914
+ });
915
+ added++;
916
+ }
917
+ }
918
+ return edges;
919
+ }
920
+ /**
921
+ * Cross-file Go method → receiver-type `contains` edges. In Go a type's methods
922
+ * are commonly declared in a different file from the `type` declaration itself
923
+ * (`type User struct{…}` in `user.go`, `func (u *User) Save()` in
924
+ * `user_store.go`). Extraction attaches the struct→method `contains` edge only
925
+ * when the receiver type is in the SAME file — the owner lookup in
926
+ * `tree-sitter.ts` is scoped to the file being parsed — so a cross-file method
927
+ * is left orphaned from its type (it's still `contains`ed by its file, just not
928
+ * its struct). That breaks `codegraph_node` member outlines, any
929
+ * callers/callees/impact traversal that goes through the type's `contains`
930
+ * edges, and the {@link goImplementsEdges} method-set computation (which derives
931
+ * a struct's method set from those same edges, so it under-counts interfaces a
932
+ * cross-file struct satisfies).
933
+ *
934
+ * Go guarantees a method's receiver type is declared in the SAME PACKAGE as the
935
+ * method, and a Go package is a single directory — so this is a deterministic
936
+ * structural link, not a heuristic: find the same-named type in the method's own
937
+ * directory and add the missing `contains` edge (no `provenance: 'heuristic'`,
938
+ * matching the same-file edges extraction already emits). Skips methods that
939
+ * already have a type parent (the same-file case). (#583, cross-file half)
940
+ */
941
+ async function goCrossFileMethodContainsEdges(queries, onYield) {
942
+ let scanned255 = 0;
943
+ const edges = [];
944
+ const seen = new Set();
945
+ const TYPE_KINDS = new Set(['struct', 'class', 'interface', 'enum', 'type_alias']);
946
+ const dirOf = (p) => {
947
+ const i = p.replace(/\\/g, '/').lastIndexOf('/');
948
+ return i >= 0 ? p.slice(0, i) : '';
949
+ };
950
+ for (const method of queries.iterateNodesByKind('method')) {
951
+ if ((++scanned255 & 63) === 0)
952
+ await onYield();
953
+ if ((++scanned255 & 63) === 0)
954
+ await onYield();
955
+ if (method.language !== 'go')
956
+ continue;
957
+ // The receiver type is encoded in the method's qualifiedName as `Recv::name`
958
+ // (extraction sets `${receiverType}::${name}` for receiver methods).
959
+ const qn = method.qualifiedName;
960
+ if (!qn)
961
+ continue;
962
+ const sep = qn.lastIndexOf('::');
963
+ if (sep <= 0)
964
+ continue;
965
+ const receiver = qn.slice(0, sep);
966
+ if (!receiver)
967
+ continue;
968
+ // Already attached to its type (same-file case handled at extraction)?
969
+ const hasTypeParent = queries
970
+ .getIncomingEdges(method.id, ['contains'])
971
+ .some((e) => {
972
+ const src = queries.getNodeById(e.source);
973
+ return src != null && TYPE_KINDS.has(src.kind);
974
+ });
975
+ if (hasTypeParent)
976
+ continue;
977
+ // Find the receiver type in the SAME directory (= same Go package). Go forbids
978
+ // duplicate type names within a package, so a same-name same-dir match is
979
+ // unambiguous; scoping to the directory avoids linking to a same-named type
980
+ // in another package.
981
+ const dir = dirOf(method.filePath);
982
+ const owner = queries
983
+ .getNodesByName(receiver)
984
+ .find((n) => n.language === 'go' && TYPE_KINDS.has(n.kind) && dirOf(n.filePath) === dir);
985
+ if (!owner)
986
+ continue;
987
+ const key = `${owner.id}>${method.id}`;
988
+ if (seen.has(key))
989
+ continue;
990
+ seen.add(key);
991
+ edges.push({ source: owner.id, target: method.id, kind: 'contains', line: method.startLine });
992
+ }
993
+ return edges;
994
+ }
995
+ /**
996
+ * Kotlin Multiplatform `expect`/`actual` linking. A `common` source set declares
997
+ * `expect fun foo()` / `expect class Bar`; each platform source set (jvm, native,
998
+ * js, …) provides an `actual` implementation with the IDENTICAL fully-qualified
999
+ * name in a different file. Callers in common code resolve to the `expect`
1000
+ * declaration, so every `actual` impl ends up with zero dependents — invisible to
1001
+ * impact/affected even though editing it can break every caller of the API.
1002
+ *
1003
+ * Synthesize a `calls` edge from the common declaration to each platform `actual`
1004
+ * (mirroring the interface-impl bridge: abstract → concrete), so editing a
1005
+ * platform impl surfaces the common `expect` and its callers, and the impl file
1006
+ * participates in the graph.
1007
+ *
1008
+ * `expect`/`actual` are captured onto the node's `decorators` list at extraction
1009
+ * (kotlin.ts `extractModifiers`). Members of an `expect class` are NOT themselves
1010
+ * keyword-marked, so the declaration side is matched as the same-FQN, same-kind
1011
+ * node that is NOT marked `actual`. Requiring an `actual`-marked counterpart also
1012
+ * gates out plain cross-file overloads (neither side is marked).
1013
+ */
1014
+ // Kinds that an `expect`/`actual` pair may legitimately straddle. `expect class`
1015
+ // is routinely fulfilled by an `actual typealias` (e.g. `actual typealias
1016
+ // CancellationException = …`, `actual typealias SchedulerTask = Task`), so a
1017
+ // strict kind match would miss those one-line alias files. Same-FQN + the
1018
+ // `actual` marker already gates out unrelated symbols, so widening to the
1019
+ // type-like kinds is safe.
1020
+ const KMP_TYPE_KINDS = new Set(['class', 'interface', 'struct', 'enum', 'type_alias']);
1021
+ function kmpKindsCompatible(a, b) {
1022
+ return a === b || (KMP_TYPE_KINDS.has(a) && KMP_TYPE_KINDS.has(b));
1023
+ }
1024
+ async function kotlinExpectActualEdges(queries, onYield) {
1025
+ let scanned255 = 0;
1026
+ const edges = [];
1027
+ const seen = new Set();
1028
+ // SQL-side language+decorator pre-filter, streamed. The old
1029
+ // `getAllNodes().filter(...)` hydrated the ENTIRE node table into one array
1030
+ // just to find kotlin `actual` declarations — on a 2M-node graph that alone
1031
+ // exceeded Node's default heap and killed the index (#1212). The LIKE
1032
+ // pre-filter can over-match (substring), so the exact decorator check stays.
1033
+ for (const act of queries.iterateNodesByLanguageWithDecorator('kotlin', 'actual')) {
1034
+ if ((++scanned255 & 63) === 0)
1035
+ await onYield();
1036
+ if (!act.decorators?.includes('actual'))
1037
+ continue;
1038
+ let added = 0;
1039
+ for (const cand of queries.getNodesByQualifiedNameExact(act.qualifiedName)) {
1040
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
1041
+ break;
1042
+ // The declaration side: same FQN + compatible kind, a different file, NOT
1043
+ // itself an `actual` (that would be a sibling platform impl, not the decl).
1044
+ if (cand.language !== 'kotlin' || cand.id === act.id)
1045
+ continue;
1046
+ if (!kmpKindsCompatible(cand.kind, act.kind) || cand.filePath === act.filePath)
1047
+ continue;
1048
+ if (cand.decorators?.includes('actual'))
1049
+ continue;
1050
+ const key = `${cand.id}>${act.id}`;
1051
+ if (seen.has(key))
1052
+ continue;
1053
+ seen.add(key);
1054
+ edges.push({
1055
+ source: cand.id,
1056
+ target: act.id,
1057
+ kind: 'calls',
1058
+ line: cand.startLine,
1059
+ provenance: 'heuristic',
1060
+ metadata: {
1061
+ synthesizedBy: 'kotlin-expect-actual',
1062
+ via: act.name,
1063
+ registeredAt: `${act.filePath}:${act.startLine}`,
1064
+ },
1065
+ });
1066
+ added++;
1067
+ }
1068
+ }
1069
+ return edges;
1070
+ }
1071
+ async function interfaceOverrideEdges(queries, onYield) {
1072
+ let scanned255 = 0;
1073
+ const edges = [];
1074
+ const seen = new Set();
1075
+ const methodsOf = (classId) => queries
1076
+ .getOutgoingEdges(classId, ['contains'])
1077
+ .map((e) => queries.getNodeById(e.target))
1078
+ .filter((n) => !!n && n.kind === 'method');
1079
+ // Concrete-side kinds vary by language: `class` covers Java / Kotlin /
1080
+ // C# / TS / Swift-classes / Scala-classes; `struct` covers Swift value
1081
+ // types that conform to protocols. Iterate both.
1082
+ const concreteKinds = ['class', 'struct'];
1083
+ for (const kind of concreteKinds) {
1084
+ for (const cls of queries.iterateNodesByKind(kind)) {
1085
+ if ((++scanned255 & 63) === 0)
1086
+ await onYield();
1087
+ const implMethods = methodsOf(cls.id).filter((n) => IFACE_OVERRIDE_LANGS.has(n.language));
1088
+ if (implMethods.length === 0)
1089
+ continue;
1090
+ for (const sup of queries.getOutgoingEdges(cls.id, ['implements', 'extends'])) {
1091
+ const base = queries.getNodeById(sup.target);
1092
+ if (!base || !IFACE_OVERRIDE_LANGS.has(base.language) || base.id === cls.id)
1093
+ continue;
1094
+ // Group impl methods by name to handle OVERLOADS: an interface `list()` and
1095
+ // `list(params)` are distinct nodes and a call may resolve to either, so
1096
+ // link every base overload → every same-name impl overload (keying by name
1097
+ // alone would drop all but one and miss the resolved overload).
1098
+ const implByName = new Map();
1099
+ for (const m of implMethods) {
1100
+ const arr = implByName.get(m.name);
1101
+ if (arr)
1102
+ arr.push(m);
1103
+ else
1104
+ implByName.set(m.name, [m]);
1105
+ }
1106
+ let added = 0;
1107
+ for (const bm of methodsOf(base.id)) {
1108
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
1109
+ break;
1110
+ for (const m of implByName.get(bm.name) ?? []) {
1111
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
1112
+ break;
1113
+ if (bm.id === m.id)
1114
+ continue;
1115
+ const key = `${bm.id}>${m.id}`;
1116
+ if (seen.has(key))
1117
+ continue;
1118
+ seen.add(key);
1119
+ edges.push({
1120
+ source: bm.id,
1121
+ target: m.id,
1122
+ kind: 'calls',
1123
+ line: bm.startLine,
1124
+ provenance: 'heuristic',
1125
+ metadata: { synthesizedBy: 'interface-impl', via: m.name, registeredAt: `${m.filePath}:${m.startLine}` },
1126
+ });
1127
+ added++;
1128
+ }
1129
+ }
1130
+ }
1131
+ }
1132
+ }
1133
+ return edges;
1134
+ }
1135
+ /**
1136
+ * Go gRPC stub → impl bridge. The protoc-gen-go-grpc codegen emits an
1137
+ * `UnimplementedXxxServer` struct in `*_grpc.pb.go` carrying one method
1138
+ * per service RPC; the real handler is a hand-written struct in another
1139
+ * file (`x/bank/keeper/msg_server.go::msgServer.Send` in cosmos-sdk).
1140
+ * Go's structural typing means no `implements` edge exists for our
1141
+ * resolver to follow, so `trace("Send","SendCoins")` lands on the
1142
+ * empty stub and reports "no path" (validated empirically — the cosmos
1143
+ * Q1 r1 trace failure that drove this work).
1144
+ *
1145
+ * Bridge: for each `UnimplementedXxxServer` whose RPC-method names are
1146
+ * a SUBSET of some other Go struct's method names, emit `calls` edges
1147
+ * `stub.method → impl.method` (paired by name). Excludes the gRPC
1148
+ * internal markers `mustEmbedUnimplementedXxxServer` and
1149
+ * `testEmbeddedByValue`, and skips candidate impls that themselves
1150
+ * live in a generated file (their `xxxClient` / sibling stubs would
1151
+ * otherwise look like impls).
1152
+ *
1153
+ * Multiple candidates is allowed and capped at MAX_CALLBACKS_PER_CHANNEL —
1154
+ * a service often has both a production impl and one or more test
1155
+ * mocks; linking to all preserves trace utility without false-favoring.
1156
+ *
1157
+ * Provenance: `heuristic`, `synthesizedBy: 'go-grpc-stub-impl'`. The
1158
+ * stub's source line is the wiring site shown in the trace trail.
1159
+ */
1160
+ async function goGrpcStubImplEdges(queries, onYield) {
1161
+ let scanned255 = 0;
1162
+ const edges = [];
1163
+ const seen = new Set();
1164
+ const STUB_RE = /^Unimplemented.*Server$/;
1165
+ // gRPC internal-helper methods that appear on every Unimplemented*Server;
1166
+ // not part of the service contract, so exclude when computing the RPC-method
1167
+ // signature used to match impls.
1168
+ const isInternalMarker = (n) => n.startsWith('mustEmbed') || n === 'testEmbeddedByValue';
1169
+ // Methods directly contained by each Go struct, name-only. Built once.
1170
+ const methodNamesByStruct = new Map();
1171
+ const methodNodesByStruct = new Map();
1172
+ const goStructs = [];
1173
+ for (const s of queries.iterateNodesByKind('struct')) {
1174
+ if ((++scanned255 & 63) === 0)
1175
+ await onYield();
1176
+ if (s.language !== 'go')
1177
+ continue;
1178
+ goStructs.push(s);
1179
+ const ms = queries
1180
+ .getOutgoingEdges(s.id, ['contains'])
1181
+ .map((e) => queries.getNodeById(e.target))
1182
+ .filter((n) => !!n && n.kind === 'method');
1183
+ methodNodesByStruct.set(s.id, ms);
1184
+ methodNamesByStruct.set(s.id, new Set(ms.map((m) => m.name)));
1185
+ }
1186
+ for (const stub of goStructs) {
1187
+ if (!STUB_RE.test(stub.name))
1188
+ continue;
1189
+ // The stub MUST live in a generated file — that's what tells us this is
1190
+ // a protoc-emitted scaffold rather than someone naming a struct
1191
+ // `UnimplementedXxxServer` by hand. Without this gate we'd also bridge
1192
+ // such hand-written structs and create misleading edges.
1193
+ if (!(0, generated_detection_1.isGeneratedFile)(stub.filePath))
1194
+ continue;
1195
+ const stubMethods = (methodNodesByStruct.get(stub.id) ?? []).filter((m) => !isInternalMarker(m.name));
1196
+ if (stubMethods.length === 0)
1197
+ continue;
1198
+ const stubMethodNames = stubMethods.map((m) => m.name);
1199
+ for (const cand of goStructs) {
1200
+ if (cand.id === stub.id)
1201
+ continue;
1202
+ // Skip generated-file candidates — they're siblings (msgClient,
1203
+ // UnsafeMsgServer, …) whose method sets coincidentally match.
1204
+ if ((0, generated_detection_1.isGeneratedFile)(cand.filePath))
1205
+ continue;
1206
+ const candNames = methodNamesByStruct.get(cand.id);
1207
+ if (!candNames)
1208
+ continue;
1209
+ // Subset: every RPC method must exist on the candidate by name.
1210
+ // Signature-level match would tighten this further, but name-match
1211
+ // alone already gives one-to-one pairing in real codebases because
1212
+ // gRPC method-name sets are highly distinctive (Send + MultiSend +
1213
+ // UpdateParams + SetSendEnabled is unique to bank's MsgServer).
1214
+ if (!stubMethodNames.every((n) => candNames.has(n)))
1215
+ continue;
1216
+ const candMethods = methodNodesByStruct.get(cand.id) ?? [];
1217
+ let added = 0;
1218
+ for (const sm of stubMethods) {
1219
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
1220
+ break;
1221
+ for (const cm of candMethods) {
1222
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
1223
+ break;
1224
+ if (cm.name !== sm.name)
1225
+ continue;
1226
+ const key = `${sm.id}>${cm.id}`;
1227
+ if (seen.has(key))
1228
+ continue;
1229
+ seen.add(key);
1230
+ edges.push({
1231
+ source: sm.id,
1232
+ target: cm.id,
1233
+ kind: 'calls',
1234
+ line: sm.startLine,
1235
+ provenance: 'heuristic',
1236
+ metadata: {
1237
+ synthesizedBy: 'go-grpc-stub-impl',
1238
+ via: cm.name,
1239
+ registeredAt: `${cm.filePath}:${cm.startLine}`,
1240
+ },
1241
+ });
1242
+ added++;
1243
+ }
1244
+ }
1245
+ }
1246
+ }
1247
+ return edges;
1248
+ }
1249
+ /**
1250
+ * Phase 5: React JSX child rendering. A component that returns `<Child .../>`
1251
+ * mounts Child — React calls it — but JSX instantiation isn't a static call edge,
1252
+ * so a render tree (App.render → StaticCanvas → renderStaticScene) breaks at the
1253
+ * JSX hop. Link parent → each capitalized JSX child it renders. File-oriented
1254
+ * (read each JSX file once). Precision gate: the child name must resolve to a
1255
+ * component/function/class node — TS generics like `Array<Foo>` resolve to a type
1256
+ * (or nothing) and are dropped.
1257
+ */
1258
+ async function reactJsxChildEdges(ctx, onYield) {
1259
+ let scannedFiles = 0;
1260
+ const edges = [];
1261
+ const seen = new Set();
1262
+ const PARENT_KINDS = new Set(['method', 'function', 'component']);
1263
+ let scanned = 0;
1264
+ for (const file of ctx.getAllFiles()) {
1265
+ if ((++scannedFiles & 15) === 0)
1266
+ await onYield();
1267
+ if ((++scanned & 255) === 0)
1268
+ await onYield(); // #1091: yield mid-scan on huge graphs
1269
+ const content = ctx.readFile(file);
1270
+ if (!content || (!content.includes('</') && !content.includes('/>')))
1271
+ continue; // JSX-file gate
1272
+ const parents = ctx.getNodesInFile(file).filter((n) => PARENT_KINDS.has(n.kind));
1273
+ for (const parent of parents) {
1274
+ const src = sliceLines(content, parent.startLine, parent.endLine);
1275
+ if (!src || (!src.includes('</') && !src.includes('/>')))
1276
+ continue;
1277
+ const names = new Set();
1278
+ JSX_TAG_RE.lastIndex = 0;
1279
+ let m;
1280
+ while ((m = JSX_TAG_RE.exec(src)))
1281
+ names.add(m[1]);
1282
+ let added = 0;
1283
+ for (const name of names) {
1284
+ if (added >= MAX_JSX_CHILDREN)
1285
+ break;
1286
+ const child = ctx.getNodesByName(name).find((n) => n.kind === 'component' || n.kind === 'function' || n.kind === 'class');
1287
+ if (!child || child.id === parent.id)
1288
+ continue;
1289
+ const key = `${parent.id}>${child.id}`;
1290
+ if (seen.has(key))
1291
+ continue;
1292
+ seen.add(key);
1293
+ edges.push({
1294
+ source: parent.id, target: child.id, kind: 'calls', line: parent.startLine,
1295
+ provenance: 'heuristic',
1296
+ metadata: { synthesizedBy: 'jsx-render', via: name },
1297
+ });
1298
+ added++;
1299
+ }
1300
+ }
1301
+ }
1302
+ return edges;
1303
+ }
1304
+ /**
1305
+ * Phase 6: Vue SFC templates. The `.vue` extractor only parses `<script>`, so
1306
+ * template usage is invisible — child components and event handlers used ONLY in
1307
+ * the template have no edge to them. PascalCase children (`<VPNav/>`) are already
1308
+ * caught by reactJsxChildEdges (which scans the SFC component node), so this adds
1309
+ * the two Vue-specific shapes:
1310
+ * - kebab-case children: `<el-button>` → `ElButton` component (renders).
1311
+ * - event bindings: `@click="onClick"` / `v-on:submit="save"` → handler method.
1312
+ * Scoped to the `<template>` block of `.vue` files; resolution gate (kebab→
1313
+ * component, handler→function/method) keeps precision; inline arrows / `$emit`
1314
+ * skipped.
1315
+ */
1316
+ async function vueTemplateEdges(ctx, onYield) {
1317
+ let scannedFiles = 0;
1318
+ let scanned255 = 0;
1319
+ const edges = [];
1320
+ const seen = new Set();
1321
+ const COMPONENT_KINDS = new Set(['component', 'function', 'class']);
1322
+ const HANDLER_KINDS = new Set(['method', 'function']);
1323
+ // A composable's returned member may be a fn (`function close(){}`) or an
1324
+ // arrow assigned to a const (`const close = () => {}`).
1325
+ const RETURN_KINDS = new Set(['method', 'function', 'variable', 'constant']);
1326
+ // Nuxt auto-imports nested components by a DIRECTORY-PREFIXED name —
1327
+ // `components/media/Card.vue` is used as `<MediaCard/>`, not `<Card/>` — but
1328
+ // the component node is named by basename (`Card`), so a direct tag match
1329
+ // misses it (flat components match by basename and don't need this). Map each
1330
+ // nested component's Nuxt name → node so those template usages resolve.
1331
+ const nuxtComponents = new Map();
1332
+ for (const c of (ctx.iterateNodesByKind?.('component') ?? ctx.getNodesByKind('component'))) {
1333
+ if ((++scanned255 & 63) === 0)
1334
+ await onYield();
1335
+ const nn = nuxtComponentName(c.filePath);
1336
+ if (nn && !nuxtComponents.has(nn))
1337
+ nuxtComponents.set(nn, c);
1338
+ }
1339
+ for (const file of ctx.getAllFiles()) {
1340
+ if ((++scannedFiles & 15) === 0)
1341
+ await onYield();
1342
+ if (!file.endsWith('.vue'))
1343
+ continue;
1344
+ const content = ctx.readFile(file);
1345
+ const tpl = content && content.match(/<template[^>]*>([\s\S]*)<\/template>/i)?.[1];
1346
+ if (!tpl)
1347
+ continue;
1348
+ const comp = ctx.getNodesInFile(file).find((n) => n.kind === 'component');
1349
+ if (!comp)
1350
+ continue;
1351
+ // Composable-destructure map: alias → { composable, key }. Lets us resolve a
1352
+ // template handler that isn't a local function but a destructured composable
1353
+ // return (`@click="closeSidebar"` ← `const { close: closeSidebar } = useSidebarControl()`).
1354
+ const script = content.match(/<script[^>]*>([\s\S]*?)<\/script>/i)?.[1] ?? '';
1355
+ const destructured = new Map();
1356
+ VUE_DESTRUCTURE_RE.lastIndex = 0;
1357
+ let dm;
1358
+ while ((dm = VUE_DESTRUCTURE_RE.exec(script))) {
1359
+ if (!/^use[A-Z]/.test(dm[2]))
1360
+ continue; // composables / hooks only
1361
+ for (const part of dm[1].split(',')) {
1362
+ const pm = part.trim().match(/^(\w+)\s*(?::\s*(\w+))?$/); // key | key: alias
1363
+ if (pm)
1364
+ destructured.set(pm[2] || pm[1], { composable: dm[2], key: pm[1] });
1365
+ }
1366
+ }
1367
+ let added = 0;
1368
+ const addEdge = (target, meta) => {
1369
+ if (added >= MAX_JSX_CHILDREN || !target || target.id === comp.id)
1370
+ return;
1371
+ const k = `${comp.id}>${target.id}>${meta.synthesizedBy}`;
1372
+ if (seen.has(k))
1373
+ return;
1374
+ seen.add(k);
1375
+ edges.push({ source: comp.id, target: target.id, kind: 'calls', line: comp.startLine, provenance: 'heuristic', metadata: meta });
1376
+ added++;
1377
+ };
1378
+ // Prefer a target in THIS SFC (handlers live in the same file's script) —
1379
+ // avoids cross-file mis-match when a name repeats across a monorepo.
1380
+ const resolve = (name, kinds) => {
1381
+ const matches = ctx.getNodesByName(name).filter((n) => kinds.has(n.kind));
1382
+ return matches.find((n) => n.filePath === file) ?? matches[0];
1383
+ };
1384
+ let m;
1385
+ VUE_KEBAB_RE.lastIndex = 0;
1386
+ while ((m = VUE_KEBAB_RE.exec(tpl))) {
1387
+ const tag = kebabToPascal(m[1]);
1388
+ addEdge(resolve(tag, COMPONENT_KINDS) ?? nuxtComponents.get(tag), { synthesizedBy: 'jsx-render', via: m[1] });
1389
+ }
1390
+ // PascalCase component tags. Try a direct name match first (flat components
1391
+ // and explicit registrations), then the Nuxt dir-prefixed auto-import name
1392
+ // (`<MediaCard>` → components/media/Card.vue). Built-ins match neither → no edge.
1393
+ VUE_PASCAL_RE.lastIndex = 0;
1394
+ while ((m = VUE_PASCAL_RE.exec(tpl))) {
1395
+ const tag = m[1];
1396
+ addEdge(resolve(tag, COMPONENT_KINDS) ?? nuxtComponents.get(tag), { synthesizedBy: 'jsx-render', via: tag });
1397
+ }
1398
+ VUE_HANDLER_RE.lastIndex = 0;
1399
+ while ((m = VUE_HANDLER_RE.exec(tpl))) {
1400
+ const event = m[1];
1401
+ const expr = m[2].trim();
1402
+ if (expr.includes('=>') || expr.startsWith('$'))
1403
+ continue; // inline arrow / $emit
1404
+ const name = expr.match(/^([A-Za-z_]\w*)/)?.[1];
1405
+ if (!name)
1406
+ continue;
1407
+ const direct = resolve(name, HANDLER_KINDS);
1408
+ if (direct) {
1409
+ addEdge(direct, { synthesizedBy: 'vue-handler', event });
1410
+ continue;
1411
+ }
1412
+ // Composable-destructure handler → resolve to the composable's returned fn.
1413
+ const d = destructured.get(name);
1414
+ if (!d)
1415
+ continue;
1416
+ const composable = resolve(d.composable, HANDLER_KINDS);
1417
+ // Resolve to the SPECIFIC returned member (e.g. `close`) defined in the
1418
+ // composable's file. No fallback to the composable itself — the component
1419
+ // already has a static `useX()` call edge, so that would just be redundant
1420
+ // and less precise.
1421
+ const keyFn = composable
1422
+ ? ctx.getNodesByName(d.key).find((n) => RETURN_KINDS.has(n.kind) && n.filePath === composable.filePath)
1423
+ : undefined;
1424
+ if (keyFn)
1425
+ addEdge(keyFn, { synthesizedBy: 'vue-handler', event, via: d.composable });
1426
+ }
1427
+ }
1428
+ return edges;
1429
+ }
1430
+ /**
1431
+ * React Native cross-language event channel (Phase 3 of the mixed-iOS/RN
1432
+ * bridging effort). Same shape as `eventEmitterEdges` but cross-language:
1433
+ *
1434
+ * Native (ObjC, on RCTEventEmitter subclass):
1435
+ * [self sendEventWithName:@"locationUpdate" body:@{...}];
1436
+ *
1437
+ * Native (Java/Kotlin, via the JS module dispatcher):
1438
+ * emitter.emit("locationUpdate", body);
1439
+ * reactContext.getJSModule(RCTDeviceEventEmitter.class).emit("locationUpdate", body);
1440
+ *
1441
+ * JS (subscriber):
1442
+ * new NativeEventEmitter(NativeModules.Geo).addListener("locationUpdate", handler);
1443
+ * DeviceEventEmitter.addListener("locationUpdate", handler);
1444
+ *
1445
+ * Synthesize: native dispatch site → JS handler, keyed by the literal
1446
+ * event name. Only matches NAMED handlers (the existing `ON_RE` named-
1447
+ * capture form). Inline arrow handlers like `addListener('x', d => …)`
1448
+ * aren't named at extraction time and would need link-through-body
1449
+ * support; matches the deliberate scope of the in-language synthesizer.
1450
+ *
1451
+ * Provenance `'heuristic'`, synthesizedBy `'rn-event-channel'`.
1452
+ */
1453
+ // ObjC's `[self sendEventWithName:@"X" body:...]` shape (bracket syntax,
1454
+ // `@` string literals).
1455
+ const RN_OBJC_SEND_RE = /\bsendEventWithName\s*:\s*@"([^"]+)"/g;
1456
+ // Swift's `sendEvent(withName: "X", body: ...)` shape — same RCTEventEmitter
1457
+ // method, different call syntax. Both Objective-C and Swift subclass
1458
+ // RCTEventEmitter so this catches the Swift-side equivalent emission sites
1459
+ // (e.g. RNFusedLocation.swift's `sendEvent(withName: "geolocationDidChange",
1460
+ // body: locationData)`).
1461
+ const RN_SWIFT_SEND_RE = /\bsendEvent\s*\(\s*withName\s*:\s*"([^"]+)"/g;
1462
+ // JVM-side emitter calls: `emitter.emit("X", body)`. Matches both Java
1463
+ // and Kotlin syntax because the call form is identical. Restricted to
1464
+ // JVM source files in the consumer so we don't re-process JS emits
1465
+ // (which `eventEmitterEdges` already handles).
1466
+ const RN_JVM_EMIT_RE = /\.emit\s*\(\s*"([^"]+)"\s*,/g;
1467
+ // Custom `sendEvent(reactContext, "X", body)` wrapper — extremely common
1468
+ // (react-native-device-info and many libs wrap `DeviceEventManagerModule…emit`
1469
+ // behind a helper whose `.emit(eventName, …)` uses a VARIABLE, so RN_JVM_EMIT_RE
1470
+ // misses it; the literal lives in the wrapper CALL instead). Captures the first
1471
+ // string literal inside a `sendEvent(...)` call. `[^;{}]*?` keeps it on one
1472
+ // statement and stops at a block boundary, so the wrapper DEFINITION (whose `(`
1473
+ // is followed by `… ) {`) never matches. Multi-line tolerant. (java/kotlin/swift)
1474
+ const RN_NATIVE_SENDEVENT_RE = /\bsendEvent\s*\([^;{}]*?"([^"]+)"/g;
1475
+ async function rnEventEdges(ctx, onYield) {
1476
+ let scannedFiles = 0;
1477
+ // Native dispatchers (source = the native method whose body sends the
1478
+ // event) and JS handlers (target = the function/method registered as
1479
+ // the listener) keyed by event name.
1480
+ const nativeDispatchersByEvent = new Map();
1481
+ const jsHandlersByEvent = new Map();
1482
+ for (const file of ctx.getAllFiles()) {
1483
+ if ((++scannedFiles & 15) === 0)
1484
+ await onYield();
1485
+ const content = ctx.readFile(file);
1486
+ if (!content)
1487
+ continue;
1488
+ const nodesInFile = ctx.getNodesInFile(file);
1489
+ const lineOf = makeLineAt(content, 1);
1490
+ const addDispatcher = (event, line) => {
1491
+ const disp = enclosingFn(nodesInFile, line);
1492
+ if (!disp)
1493
+ return;
1494
+ const set = nativeDispatchersByEvent.get(event) ?? new Set();
1495
+ set.add(disp.id);
1496
+ nativeDispatchersByEvent.set(event, set);
1497
+ };
1498
+ // ObjC side: `sendEventWithName:@"X"` only fires inside `.m`/`.mm`
1499
+ // files (RCTEventEmitter subclasses).
1500
+ if (file.endsWith('.m') || file.endsWith('.mm')) {
1501
+ RN_OBJC_SEND_RE.lastIndex = 0;
1502
+ let m;
1503
+ while ((m = RN_OBJC_SEND_RE.exec(content))) {
1504
+ if (m[1])
1505
+ addDispatcher(m[1], lineOf(m.index));
1506
+ }
1507
+ }
1508
+ // Swift side: same RCTEventEmitter method, parens/named-args syntax.
1509
+ if (file.endsWith('.swift')) {
1510
+ RN_SWIFT_SEND_RE.lastIndex = 0;
1511
+ let m;
1512
+ while ((m = RN_SWIFT_SEND_RE.exec(content))) {
1513
+ if (m[1])
1514
+ addDispatcher(m[1], lineOf(m.index));
1515
+ }
1516
+ RN_NATIVE_SENDEVENT_RE.lastIndex = 0;
1517
+ while ((m = RN_NATIVE_SENDEVENT_RE.exec(content))) {
1518
+ if (m[1])
1519
+ addDispatcher(m[1], lineOf(m.index));
1520
+ }
1521
+ }
1522
+ // JVM side: `.emit("X", …)` in Java/Kotlin, plus the common
1523
+ // `sendEvent(ctx, "X", body)` wrapper. (We pattern-match anywhere in the
1524
+ // file; the JS in-language path uses a separate emitter object pattern and
1525
+ // is already handled by eventEmitterEdges.)
1526
+ if (file.endsWith('.java') || file.endsWith('.kt')) {
1527
+ let m;
1528
+ RN_JVM_EMIT_RE.lastIndex = 0;
1529
+ while ((m = RN_JVM_EMIT_RE.exec(content))) {
1530
+ if (m[1])
1531
+ addDispatcher(m[1], lineOf(m.index));
1532
+ }
1533
+ RN_NATIVE_SENDEVENT_RE.lastIndex = 0;
1534
+ while ((m = RN_NATIVE_SENDEVENT_RE.exec(content))) {
1535
+ if (m[1])
1536
+ addDispatcher(m[1], lineOf(m.index));
1537
+ }
1538
+ }
1539
+ // JS subscribers (.addListener("X", handler)). Restrict to JS-family
1540
+ // files so a native file's `addListener:` (the ObjC method) doesn't
1541
+ // get mistaken for a JS subscription — they're entirely different
1542
+ // things despite sharing a name.
1543
+ if (file.endsWith('.js') ||
1544
+ file.endsWith('.jsx') ||
1545
+ file.endsWith('.ts') ||
1546
+ file.endsWith('.tsx') ||
1547
+ file.endsWith('.mjs') ||
1548
+ file.endsWith('.cjs')) {
1549
+ // Match BOTH the named-handler form (`.addListener('x', fn)`) and
1550
+ // an unnamed-handler form (`.addListener('x', listener)` where
1551
+ // `listener` is a parameter — common in RN wrapper APIs like
1552
+ // RNFirebase's `messaging().onMessageReceived(listener)`). For the
1553
+ // unnamed case we attribute the subscription to the ENCLOSING JS
1554
+ // function (the abstraction layer), giving a reachability-correct
1555
+ // hop even when the actual user-side handler lives one call up.
1556
+ const ADDLISTENER_ANY = /\.(?:on|once|addListener)\(\s*['"]([^'"]+)['"]\s*,\s*([A-Za-z_][\w.]*)/g;
1557
+ ADDLISTENER_ANY.lastIndex = 0;
1558
+ let m;
1559
+ while ((m = ADDLISTENER_ANY.exec(content))) {
1560
+ const event = m[1];
1561
+ const arg = m[2];
1562
+ if (!event || !arg)
1563
+ continue;
1564
+ const bareName = arg.includes('.') ? arg.slice(arg.lastIndexOf('.') + 1) : arg;
1565
+ // Try a named-symbol match first (matches the in-language semantic).
1566
+ const namedHandler = ctx
1567
+ .getNodesByName(bareName)
1568
+ .find((n) => n.kind === 'function' || n.kind === 'method');
1569
+ let targetId = namedHandler?.id ?? null;
1570
+ if (!targetId) {
1571
+ // Fall back to the enclosing function — the subscribe-wrapper
1572
+ // pattern means the event fires THROUGH this function on its
1573
+ // way to user code. Reachability-correct attribution.
1574
+ const enclosing = enclosingFn(nodesInFile, lineOf(m.index));
1575
+ targetId = enclosing?.id ?? null;
1576
+ }
1577
+ if (!targetId) {
1578
+ // Broader fallback for JS object-literal API shape
1579
+ // (`const Foo = { watchX(...) { … addListener(...) … } }`):
1580
+ // method shorthand inside an object literal isn't extracted
1581
+ // as a method node, so enclosingFn returns null. Attribute to
1582
+ // the smallest enclosing `constant` / `variable` node — that's
1583
+ // the API surface a downstream caller would `import` and
1584
+ // invoke. Reachability-correct.
1585
+ const line = lineOf(m.index);
1586
+ let smallest = null;
1587
+ for (const n of nodesInFile) {
1588
+ if (n.kind !== 'constant' && n.kind !== 'variable')
1589
+ continue;
1590
+ const end = n.endLine ?? n.startLine;
1591
+ if (n.startLine <= line && end >= line) {
1592
+ if (!smallest || n.startLine >= smallest.startLine)
1593
+ smallest = n;
1594
+ }
1595
+ }
1596
+ targetId = smallest?.id ?? null;
1597
+ }
1598
+ if (!targetId)
1599
+ continue;
1600
+ const map = jsHandlersByEvent.get(event) ?? new Map();
1601
+ map.set(targetId, `${file}:${lineOf(m.index)}`);
1602
+ jsHandlersByEvent.set(event, map);
1603
+ }
1604
+ }
1605
+ }
1606
+ const edges = [];
1607
+ const seen = new Set();
1608
+ for (const [event, dispatchers] of nativeDispatchersByEvent) {
1609
+ const handlers = jsHandlersByEvent.get(event);
1610
+ if (!handlers)
1611
+ continue;
1612
+ // Same fan-out guard as the in-language channel: generic event names
1613
+ // (e.g. 'change', 'error', 'data') with many handlers/dispatchers
1614
+ // can't be matched precisely without receiver-type info.
1615
+ if (dispatchers.size > EVENT_FANOUT_CAP || handlers.size > EVENT_FANOUT_CAP)
1616
+ continue;
1617
+ for (const d of dispatchers) {
1618
+ for (const [h, registeredAt] of handlers) {
1619
+ if (d === h)
1620
+ continue;
1621
+ const key = `${d}>${h}`;
1622
+ if (seen.has(key))
1623
+ continue;
1624
+ seen.add(key);
1625
+ edges.push({
1626
+ source: d,
1627
+ target: h,
1628
+ kind: 'calls',
1629
+ provenance: 'heuristic',
1630
+ metadata: { synthesizedBy: 'rn-event-channel', event, registeredAt },
1631
+ });
1632
+ }
1633
+ }
1634
+ }
1635
+ return edges;
1636
+ }
1637
+ /**
1638
+ * Phase 6 — React Native Fabric/Codegen view component bridge.
1639
+ *
1640
+ * The Fabric framework extractor (`frameworks/fabric.ts`) emits
1641
+ * `component` nodes named after the JS-visible component (e.g.
1642
+ * `RNSScreenStack`) from each `codegenNativeComponent<Props>('Name')`
1643
+ * spec declaration. The native implementation lives in an ObjC++/.mm or
1644
+ * Kotlin/Java class whose name follows one of RN's conventions:
1645
+ *
1646
+ * - Exact: `RNSScreenStack`
1647
+ * - With suffix: `RNSScreenStackView`, `RNSScreenStackViewManager`,
1648
+ * `RNSScreenStackComponentView`, `RNSScreenStackManager`
1649
+ *
1650
+ * This synthesizer walks every Fabric component node and looks for a
1651
+ * native class matching one of those names; when found, emits a
1652
+ * `calls` edge `component → native class` (provenance `'heuristic'`,
1653
+ * `synthesizedBy:'fabric-native-impl'`) so trace from JSX usage of the
1654
+ * component continues into native.
1655
+ *
1656
+ * The convention-based suffix lookup is precise: there's no name
1657
+ * collision in RN view-manager codebases by design (Codegen output would
1658
+ * conflict otherwise).
1659
+ */
1660
+ const FABRIC_NATIVE_SUFFIXES = ['', 'View', 'ViewManager', 'ComponentView', 'Manager'];
1661
+ /**
1662
+ * Expo Modules cross-platform pairing. An Expo Module exposes the SAME
1663
+ * JS-visible method (`AsyncFunction("getBatteryLevelAsync")`) from BOTH an iOS
1664
+ * (Swift) and an Android (Kotlin) implementation. A JS callsite name-resolves to
1665
+ * only ONE of them, so the other platform's impl looked like nothing called it
1666
+ * (and editing it showed no blast radius). Link the iOS and Android impls of the
1667
+ * same `<module>.<method>` to each other (both directions), so a JS call that
1668
+ * reaches one platform reaches the other, and editing either surfaces the JS
1669
+ * caller. The Expo method nodes are id-prefixed `expo-module:` and qualified
1670
+ * `<file>::<module>.<method>` by the framework extractor.
1671
+ */
1672
+ async function expoCrossPlatformEdges(queries, onYield) {
1673
+ let scanned255 = 0;
1674
+ const edges = [];
1675
+ const seen = new Set();
1676
+ const byKey = new Map();
1677
+ for (const m of queries.iterateNodesByKind('method')) {
1678
+ if ((++scanned255 & 63) === 0)
1679
+ await onYield();
1680
+ if (!m.id.startsWith('expo-module:'))
1681
+ continue;
1682
+ const key = m.qualifiedName.split('::').pop(); // `<module>.<method>`
1683
+ if (!key)
1684
+ continue;
1685
+ const arr = byKey.get(key);
1686
+ if (arr)
1687
+ arr.push(m);
1688
+ else
1689
+ byKey.set(key, [m]);
1690
+ }
1691
+ for (const group of byKey.values()) {
1692
+ if (group.length < 2)
1693
+ continue;
1694
+ for (const a of group) {
1695
+ for (const b of group) {
1696
+ if (a.id === b.id || a.language === b.language)
1697
+ continue; // cross-platform only
1698
+ const key = `${a.id}>${b.id}`;
1699
+ if (seen.has(key))
1700
+ continue;
1701
+ seen.add(key);
1702
+ edges.push({
1703
+ source: a.id,
1704
+ target: b.id,
1705
+ kind: 'calls',
1706
+ line: a.startLine,
1707
+ provenance: 'heuristic',
1708
+ metadata: { synthesizedBy: 'expo-cross-platform', via: a.name },
1709
+ });
1710
+ }
1711
+ }
1712
+ }
1713
+ return edges;
1714
+ }
1715
+ /**
1716
+ * Classic React Native NativeModules cross-platform pairing. A native module
1717
+ * method (`@ReactMethod` on Android, `RCT_EXPORT_METHOD` on iOS) is implemented
1718
+ * on BOTH platforms, but a JS callsite name-resolves to only ONE — so the other
1719
+ * platform's impl looked like nothing called it. A native method that HAS a JS
1720
+ * caller is a confirmed bridge method; link it to the same-named native method
1721
+ * in another language (the other platform's impl) so a JS call reaching one
1722
+ * platform reaches the other, and editing either surfaces the JS caller.
1723
+ *
1724
+ * Names are normalized to the first selector keyword (`getFreeDiskStorage:` →
1725
+ * `getFreeDiskStorage`) — that's the JS-visible name, and how the iOS selector
1726
+ * lines up with the bare Android method name.
1727
+ */
1728
+ async function rnCrossPlatformEdges(queries, onYield) {
1729
+ let scanned255 = 0;
1730
+ const edges = [];
1731
+ const seen = new Set();
1732
+ const NATIVE = new Set(['java', 'kotlin', 'objc', 'cpp']);
1733
+ const JS = new Set(['typescript', 'tsx', 'javascript', 'jsx']);
1734
+ // RN module INFRASTRUCTURE methods exist on every native module (called by the
1735
+ // RN runtime, not user JS), so pairing them by name would cross-link unrelated
1736
+ // modules in a multi-module repo. Skip them — they aren't user-facing methods.
1737
+ const RN_INFRA = new Set([
1738
+ 'addListener', 'removeListeners', 'getConstants', 'constantsToExport', 'getName',
1739
+ 'invalidate', 'initialize', 'getDefaultEventTypes', 'supportedEvents',
1740
+ 'requiresMainQueueSetup', 'methodQueue',
1741
+ ]);
1742
+ const norm = (name) => {
1743
+ const i = name.indexOf(':');
1744
+ return i >= 0 ? name.slice(0, i) : name;
1745
+ };
1746
+ // Index native methods by their JS-visible (normalized) name. Only names with
1747
+ // impls in ≥2 native languages can pair, so the per-method JS-caller check
1748
+ // below only runs for genuine cross-platform candidates.
1749
+ const byName = new Map();
1750
+ for (const m of queries.iterateNodesByKind('method')) {
1751
+ if ((++scanned255 & 63) === 0)
1752
+ await onYield();
1753
+ if (!NATIVE.has(m.language))
1754
+ continue;
1755
+ const key = norm(m.name);
1756
+ const arr = byName.get(key);
1757
+ if (arr)
1758
+ arr.push(m);
1759
+ else
1760
+ byName.set(key, [m]);
1761
+ }
1762
+ for (const [groupName, group] of byName) {
1763
+ if (RN_INFRA.has(groupName))
1764
+ continue;
1765
+ const langs = new Set(group.map((m) => m.language));
1766
+ if (langs.size < 2)
1767
+ continue; // single-platform — nothing to pair
1768
+ for (const m of group) {
1769
+ // Is m a bridge method? (a JS-language `calls` edge points at it)
1770
+ const incoming = queries.getIncomingEdges(m.id, ['calls']);
1771
+ if (incoming.length === 0)
1772
+ continue;
1773
+ const sources = queries.getNodesByIds(incoming.map((e) => e.source));
1774
+ const isBridge = incoming.some((e) => {
1775
+ const s = sources.get(e.source);
1776
+ return !!s && JS.has(s.language);
1777
+ });
1778
+ if (!isBridge)
1779
+ continue;
1780
+ // Link to the other-platform impls (both directions).
1781
+ for (const sib of group) {
1782
+ if (sib.id === m.id || sib.language === m.language)
1783
+ continue;
1784
+ for (const [a, b] of [[m, sib], [sib, m]]) {
1785
+ const key = `${a.id}>${b.id}`;
1786
+ if (seen.has(key))
1787
+ continue;
1788
+ seen.add(key);
1789
+ edges.push({
1790
+ source: a.id,
1791
+ target: b.id,
1792
+ kind: 'calls',
1793
+ line: a.startLine,
1794
+ provenance: 'heuristic',
1795
+ metadata: { synthesizedBy: 'rn-cross-platform', via: norm(m.name) },
1796
+ });
1797
+ }
1798
+ }
1799
+ }
1800
+ }
1801
+ return edges;
1802
+ }
1803
+ async function fabricNativeImplEdges(ctx, onYield) {
1804
+ let scanned255 = 0;
1805
+ const edges = [];
1806
+ const seen = new Set();
1807
+ // The Fabric extractor IDs are prefixed `fabric-component:` so we can
1808
+ // filter to just those while streaming — never materializing the whole
1809
+ // `component` kind (#1212).
1810
+ const components = [];
1811
+ for (const n of (ctx.iterateNodesByKind?.('component') ?? ctx.getNodesByKind('component'))) {
1812
+ if ((++scanned255 & 63) === 0)
1813
+ await onYield();
1814
+ if (n.id.startsWith('fabric-component:'))
1815
+ components.push(n);
1816
+ }
1817
+ if (components.length === 0)
1818
+ return edges;
1819
+ // Pre-index native classes by name for O(1) lookup.
1820
+ const nativeClassesByName = new Map();
1821
+ for (const n of (ctx.iterateNodesByKind?.('class') ?? ctx.getNodesByKind('class'))) {
1822
+ if ((++scanned255 & 63) === 0)
1823
+ await onYield();
1824
+ if (n.language !== 'objc' && n.language !== 'kotlin' && n.language !== 'java' && n.language !== 'cpp')
1825
+ continue;
1826
+ const arr = nativeClassesByName.get(n.name);
1827
+ if (arr)
1828
+ arr.push(n);
1829
+ else
1830
+ nativeClassesByName.set(n.name, [n]);
1831
+ }
1832
+ for (const component of components) {
1833
+ for (const suffix of FABRIC_NATIVE_SUFFIXES) {
1834
+ const candidate = component.name + suffix;
1835
+ const matches = nativeClassesByName.get(candidate);
1836
+ if (!matches || matches.length === 0)
1837
+ continue;
1838
+ // Link the component node to every matching native class (iOS +
1839
+ // Android each have one).
1840
+ for (const native of matches) {
1841
+ const key = `${component.id}>${native.id}`;
1842
+ if (seen.has(key))
1843
+ continue;
1844
+ seen.add(key);
1845
+ edges.push({
1846
+ source: component.id,
1847
+ target: native.id,
1848
+ kind: 'calls',
1849
+ provenance: 'heuristic',
1850
+ metadata: {
1851
+ synthesizedBy: 'fabric-native-impl',
1852
+ viaSuffix: suffix || '(exact)',
1853
+ componentName: component.name,
1854
+ },
1855
+ });
1856
+ }
1857
+ }
1858
+ }
1859
+ return edges;
1860
+ }
1861
+ /**
1862
+ * MyBatis: link a Java mapper interface method to the XML statement that holds
1863
+ * its SQL. The XML extractor (`src/extraction/mybatis-extractor.ts`) qualifies
1864
+ * each `<select|insert|update|delete|sql id="X">` as `<namespace>::<id>` where
1865
+ * `<namespace>` is the Java FQN of the mapper interface. A Java method's
1866
+ * qualifiedName ends with `<ClassName>::<methodName>`, so we suffix-match the
1867
+ * last two segments of the XML qualified name to find a unique Java method by
1868
+ * `<ClassName>::<methodName>` (`ClassName` = last dotted segment of the XML
1869
+ * namespace). Cross-mapper `<include refid="other.X">` references go through
1870
+ * the normal qualified-name resolver — only the Java↔XML bridge is synthetic.
1871
+ *
1872
+ * Precision over recall: ambiguous mappers (multiple Java classes with the
1873
+ * same simple name) are dropped. We need-not bridge by package because Java
1874
+ * mapper interfaces are typically uniquely named within a project.
1875
+ */
1876
+ async function mybatisJavaXmlEdges(queries, onYield) {
1877
+ let scanned255 = 0;
1878
+ const edges = [];
1879
+ const seen = new Set();
1880
+ // Index Java methods by `<ClassName>::<methodName>` for O(1) lookup.
1881
+ const javaIndex = new Map();
1882
+ for (const m of queries.iterateNodesByKind('method')) {
1883
+ if ((++scanned255 & 63) === 0)
1884
+ await onYield();
1885
+ if (m.language !== 'java' && m.language !== 'kotlin')
1886
+ continue;
1887
+ const parts = m.qualifiedName.split('::');
1888
+ const last = parts[parts.length - 1];
1889
+ const cls = parts[parts.length - 2];
1890
+ if (!last || !cls)
1891
+ continue;
1892
+ const key = `${cls}::${last}`;
1893
+ const arr = javaIndex.get(key);
1894
+ if (arr)
1895
+ arr.push(m);
1896
+ else
1897
+ javaIndex.set(key, [m]);
1898
+ }
1899
+ for (const xml of queries.iterateNodesByKind('method')) {
1900
+ if ((++scanned255 & 63) === 0)
1901
+ await onYield();
1902
+ if (xml.language !== 'xml')
1903
+ continue;
1904
+ // Qualified name: `<namespace>::<id>`. Extract the simple class name.
1905
+ const colonIdx = xml.qualifiedName.lastIndexOf('::');
1906
+ if (colonIdx < 0)
1907
+ continue;
1908
+ const namespace = xml.qualifiedName.slice(0, colonIdx);
1909
+ const id = xml.qualifiedName.slice(colonIdx + 2);
1910
+ if (!namespace || !id)
1911
+ continue;
1912
+ const dotIdx = namespace.lastIndexOf('.');
1913
+ const className = dotIdx >= 0 ? namespace.slice(dotIdx + 1) : namespace;
1914
+ const candidates = javaIndex.get(`${className}::${id}`);
1915
+ if (!candidates || candidates.length === 0)
1916
+ continue;
1917
+ // Drop ambiguous matches (multiple same-name classes); the user can
1918
+ // disambiguate by adding the package-suffix match in a future enhancement.
1919
+ if (candidates.length > 1)
1920
+ continue;
1921
+ const java = candidates[0];
1922
+ const key = `${java.id}>${xml.id}`;
1923
+ if (seen.has(key))
1924
+ continue;
1925
+ seen.add(key);
1926
+ edges.push({
1927
+ source: java.id,
1928
+ target: xml.id,
1929
+ kind: 'calls',
1930
+ line: java.startLine,
1931
+ provenance: 'heuristic',
1932
+ metadata: {
1933
+ synthesizedBy: 'mybatis-java-xml',
1934
+ via: `${className}.${id}`,
1935
+ registeredAt: `${xml.filePath}:${xml.startLine}`,
1936
+ },
1937
+ });
1938
+ }
1939
+ return edges;
1940
+ }
1941
+ /**
1942
+ * Gin middleware chain. Gin runs its entire handler chain through one dynamic
1943
+ * line in `(*Context).Next`:
1944
+ * for c.index < len(c.handlers) { c.handlers[c.index](c); c.index++ }
1945
+ * `c.handlers` is a `HandlersChain` (`[]HandlerFunc`) assembled at registration
1946
+ * time by `combineHandlers` from the funcs passed to `r.Use(...)` /
1947
+ * `r.GET("/path", h...)` / `r.Handle(...)`. Because the call is a computed index
1948
+ * into a runtime-built slice, tree-sitter resolves `c.handlers[c.index](c)` to
1949
+ * NOTHING — so `callees(Next)` is just the `len()` helper and the flow
1950
+ * `ServeHTTP → handleHTTPRequest → Next` dead-ends at the exact symbol the
1951
+ * "how do requests flow through the middleware chain" question is about. The
1952
+ * agent then re-queries Next and falls back to Read/grep (validated: the gin
1953
+ * WITH-arm rabbit-holed on precisely this dead-end).
1954
+ *
1955
+ * Bridge it: find the chain DISPATCHER (a Go method whose body invokes a
1956
+ * `handlers` slice by index) and link it → every HandlerFunc registered via a
1957
+ * gin registration call, so `callees(Next)` and `trace(ServeHTTP, <handler>)`
1958
+ * connect end-to-end. Named handlers only (`gin.Logger()` → `Logger`,
1959
+ * `authMiddleware`); inline closures are anonymous and skipped. Like
1960
+ * react-render / interface-impl this is a deliberate over-approximation —
1961
+ * reachability-correct (any registered handler CAN run for some route), capped,
1962
+ * and gated on the dispatcher existing so it never runs on non-gin Go repos.
1963
+ * Provenance `heuristic`, `synthesizedBy:'gin-middleware-chain'`; `registeredAt`
1964
+ * is the `.Use`/`.GET` site an agent would otherwise grep for.
1965
+ */
1966
+ const GIN_DISPATCH_RE = /\.handlers\s*\[[^\]]*\]\s*\(/; // c.handlers[c.index](c)
1967
+ const GIN_REG_RE = /\.(?:Use|GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD|Any|Handle)\s*\(/g;
1968
+ /** Balanced `(...)` body starting at the '(' index; null if unbalanced. */
1969
+ function goBalancedArgs(s, openIdx) {
1970
+ let depth = 0;
1971
+ for (let i = openIdx; i < s.length; i++) {
1972
+ const c = s[i];
1973
+ if (c === '(')
1974
+ depth++;
1975
+ else if (c === ')') {
1976
+ depth--;
1977
+ if (depth === 0)
1978
+ return s.slice(openIdx + 1, i);
1979
+ }
1980
+ }
1981
+ return null;
1982
+ }
1983
+ /** Split a top-level comma list, respecting nested () [] {}. */
1984
+ function goSplitArgs(args) {
1985
+ const out = [];
1986
+ let depth = 0, cur = '';
1987
+ for (const c of args) {
1988
+ if (c === '(' || c === '[' || c === '{') {
1989
+ depth++;
1990
+ cur += c;
1991
+ }
1992
+ else if (c === ')' || c === ']' || c === '}') {
1993
+ depth--;
1994
+ cur += c;
1995
+ }
1996
+ else if (c === ',' && depth === 0) {
1997
+ out.push(cur);
1998
+ cur = '';
1999
+ }
2000
+ else
2001
+ cur += c;
2002
+ }
2003
+ if (cur.trim())
2004
+ out.push(cur);
2005
+ return out;
2006
+ }
2007
+ /** Tail ident of a handler arg: `gin.Logger()`→`Logger`, `mw`→`mw`; null for string paths / closures. */
2008
+ function goHandlerIdent(expr) {
2009
+ const cleaned = expr.trim().replace(/\(\s*\)$/, ''); // drop a trailing call ()
2010
+ if (!cleaned || cleaned.startsWith('"') || cleaned.startsWith('`') || cleaned.startsWith('func'))
2011
+ return null;
2012
+ const m = cleaned.match(/(?:\.|^)([A-Za-z_]\w*)$/);
2013
+ return m ? m[1] : null;
2014
+ }
2015
+ async function ginMiddlewareChainEdges(queries, ctx, onYield) {
2016
+ let scanned255 = 0;
2017
+ let scannedFiles = 0;
2018
+ // 1. Find the chain dispatcher(s): a Go method that invokes a `handlers` slice by index.
2019
+ const dispatchers = [];
2020
+ for (const n of queries.iterateNodesByKind('method')) {
2021
+ if ((++scanned255 & 63) === 0)
2022
+ await onYield();
2023
+ if (n.language !== 'go')
2024
+ continue;
2025
+ const content = ctx.readFile(n.filePath);
2026
+ const src = content && sliceLines(content, n.startLine, n.endLine);
2027
+ if (src && GIN_DISPATCH_RE.test(src))
2028
+ dispatchers.push(n);
2029
+ }
2030
+ if (dispatchers.length === 0)
2031
+ return []; // not a gin repo — bail
2032
+ // 2. Collect handler identifiers registered via gin registration calls
2033
+ // (.Use / .GET / … / .Handle). String args (paths/methods) and inline
2034
+ // closures are dropped by goHandlerIdent; the rest are HandlerFuncs.
2035
+ const registered = new Map(); // name → registeredAt (file:line)
2036
+ for (const file of ctx.getAllFiles()) {
2037
+ if ((++scannedFiles & 15) === 0)
2038
+ await onYield();
2039
+ if (!file.endsWith('.go'))
2040
+ continue;
2041
+ const content = ctx.readFile(file);
2042
+ if (!content || (!content.includes('.Use(') && !/\.(?:GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD|Any|Handle)\(/.test(content)))
2043
+ continue;
2044
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'go');
2045
+ GIN_REG_RE.lastIndex = 0;
2046
+ let m;
2047
+ while ((m = GIN_REG_RE.exec(safe))) {
2048
+ const parenIdx = m.index + m[0].length - 1;
2049
+ const argStr = goBalancedArgs(safe, parenIdx);
2050
+ if (!argStr)
2051
+ continue;
2052
+ const line = safe.slice(0, m.index).split('\n').length;
2053
+ for (const arg of goSplitArgs(argStr)) {
2054
+ const name = goHandlerIdent(arg);
2055
+ if (name && !registered.has(name))
2056
+ registered.set(name, `${file}:${line}`);
2057
+ }
2058
+ }
2059
+ }
2060
+ if (registered.size === 0)
2061
+ return [];
2062
+ // 3. Link each dispatcher → each registered handler node (dedup, capped).
2063
+ const edges = [];
2064
+ const seen = new Set();
2065
+ for (const disp of dispatchers) {
2066
+ let added = 0;
2067
+ for (const [name, registeredAt] of registered) {
2068
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
2069
+ break;
2070
+ const handler = ctx.getNodesByName(name).find((n) => (n.kind === 'function' || n.kind === 'method') && n.language === 'go');
2071
+ if (!handler || handler.id === disp.id)
2072
+ continue;
2073
+ const key = `${disp.id}>${handler.id}`;
2074
+ if (seen.has(key))
2075
+ continue;
2076
+ seen.add(key);
2077
+ edges.push({
2078
+ source: disp.id, target: handler.id, kind: 'calls', line: disp.startLine,
2079
+ provenance: 'heuristic',
2080
+ metadata: { synthesizedBy: 'gin-middleware-chain', via: name, registeredAt },
2081
+ });
2082
+ added++;
2083
+ }
2084
+ }
2085
+ return edges;
2086
+ }
2087
+ /**
2088
+ * Delphi form code-behind: a form unit `UFRMAbout.pas` owns its visual form
2089
+ * definition `UFRMAbout.dfm` (VCL) / `.fmx` (FireMonkey) — paired by basename in
2090
+ * the same directory, wired by the `{$R *.dfm}` directive rather than a `uses`
2091
+ * clause. Link the unit → its form so a `.dfm`/`.fmx` used only as a form
2092
+ * definition isn't orphaned, and editing the form surfaces its code-behind unit.
2093
+ */
2094
+ async function pascalFormEdges(ctx, onYield) {
2095
+ let scannedFiles = 0;
2096
+ const edges = [];
2097
+ const allFiles = new Set(ctx.getAllFiles());
2098
+ for (const file of allFiles) {
2099
+ if ((++scannedFiles & 255) === 0)
2100
+ await onYield();
2101
+ if (!/\.(dfm|fmx)$/i.test(file))
2102
+ continue;
2103
+ const pasFile = file.replace(/\.(dfm|fmx)$/i, '.pas');
2104
+ if (!allFiles.has(pasFile))
2105
+ continue;
2106
+ const formNode = ctx.getNodesInFile(file).find((n) => n.kind === 'file');
2107
+ const unitNode = ctx.getNodesInFile(pasFile).find((n) => n.kind === 'file');
2108
+ if (!formNode || !unitNode)
2109
+ continue;
2110
+ edges.push({
2111
+ source: unitNode.id,
2112
+ target: formNode.id,
2113
+ kind: 'references',
2114
+ line: unitNode.startLine,
2115
+ provenance: 'heuristic',
2116
+ metadata: { synthesizedBy: 'pascal-form', registeredAt: pasFile },
2117
+ });
2118
+ }
2119
+ return edges;
2120
+ }
2121
+ /**
2122
+ * SvelteKit file-convention data flow. A route directory's `+page.svelte` (a
2123
+ * `component` node) receives its `data` from the sibling `+page.server.{ts,js}`
2124
+ * / `+page.{ts,js}` `load` function and posts forms to its `actions` — wired by
2125
+ * the framework BY FILE PATH, with no static import between them. So editing a
2126
+ * `load` shows no impact on the page it feeds, and the page looks like it has no
2127
+ * server-side dependency. Link the page component to its sibling loader's
2128
+ * `load` / `actions` (same for `+layout`). The pairing is path-deterministic
2129
+ * (same directory, matching `+page`/`+layout` prefix), so it's precise — but
2130
+ * it's a framework-convention edge, so provenance stays `heuristic`.
2131
+ *
2132
+ * Direction: page → load, so `getImpactRadius(load)` surfaces the page (editing
2133
+ * a loader's data shows the page it feeds) and the page's dependencies include
2134
+ * its loader.
2135
+ */
2136
+ async function svelteKitLoadEdges(ctx, onYield) {
2137
+ let scannedFiles = 0;
2138
+ const edges = [];
2139
+ const allFiles = new Set(ctx.getAllFiles());
2140
+ const HOOKS = new Set(['load', 'actions']);
2141
+ const HOOK_KINDS = new Set(['function', 'method', 'constant', 'variable']);
2142
+ for (const file of allFiles) {
2143
+ if ((++scannedFiles & 255) === 0)
2144
+ await onYield();
2145
+ const m = file.match(/(.*\/)(\+(?:page|layout))\.svelte$/);
2146
+ if (!m)
2147
+ continue;
2148
+ const dir = m[1];
2149
+ const prefix = m[2];
2150
+ const page = ctx.getNodesInFile(file).find((n) => n.kind === 'component');
2151
+ if (!page)
2152
+ continue;
2153
+ for (const ext of ['.server.ts', '.server.js', '.ts', '.js']) {
2154
+ const loaderFile = `${dir}${prefix}${ext}`;
2155
+ if (!allFiles.has(loaderFile))
2156
+ continue;
2157
+ for (const hook of ctx.getNodesInFile(loaderFile)) {
2158
+ if (!HOOK_KINDS.has(hook.kind) || !HOOKS.has(hook.name))
2159
+ continue;
2160
+ edges.push({
2161
+ source: page.id,
2162
+ target: hook.id,
2163
+ kind: 'references',
2164
+ line: page.startLine,
2165
+ provenance: 'heuristic',
2166
+ metadata: {
2167
+ synthesizedBy: 'sveltekit-load',
2168
+ via: hook.name,
2169
+ registeredAt: `${loaderFile}:${hook.startLine ?? 0}`,
2170
+ },
2171
+ });
2172
+ }
2173
+ }
2174
+ }
2175
+ return edges;
2176
+ }
2177
+ /**
2178
+ * Redux-thunk dispatch chain. `export const X = createAsyncThunk(prefix, async (a, api) => {...})`
2179
+ * (or a wrapper like trezor's `createThunk(...)`) passes the async body as an ARGUMENT, so
2180
+ * tree-sitter never extracts it as a function node: `X` is a `constant` whose body's calls are
2181
+ * ORPHANED. The `dispatch(nextThunk(...))` calls that drive a thunk chain forward therefore produce
2182
+ * no edges, so `callees(X)` is empty and a flow `dispatch(X(...)) → X → nextThunk` dead-ends at the
2183
+ * constant (validated on trezor-suite: the signXxxThunk constants had ZERO outgoing edges). Bridge
2184
+ * it: body-scan each thunk constant for `dispatch(Y(...))` and link `X → Y`, so the dispatch chain
2185
+ * connects. High-precision — the `dispatch(` keyword plus `Y` must resolve to a function/constant/
2186
+ * method node; capped; gated on thunk constants existing so it never runs on non-RTK repos.
2187
+ * Cross-file by design (a suite thunk dispatches a wallet-core thunk). Provenance `heuristic`,
2188
+ * `synthesizedBy:'redux-thunk'`; `registeredAt` is the dispatch site.
2189
+ */
2190
+ const THUNK_DECL_RE = /create(?:Async)?Thunk/;
2191
+ const THUNK_DISPATCH_RE = /\bdispatch\s*\(\s*([A-Za-z_]\w*)\s*[(),]/g;
2192
+ const THUNK_FANOUT_CAP = 24;
2193
+ async function reduxThunkEdges(queries, ctx, onYield) {
2194
+ let scanned255 = 0;
2195
+ const edges = [];
2196
+ const seen = new Set();
2197
+ for (const node of queries.iterateNodesByKind('constant')) {
2198
+ if ((++scanned255 & 63) === 0)
2199
+ await onYield();
2200
+ // Cheap gate: the initializer (captured in `signature`) must be a create(Async)Thunk call —
2201
+ // avoids reading every constant's body on a large repo.
2202
+ if (!node.signature || !THUNK_DECL_RE.test(node.signature))
2203
+ continue;
2204
+ const content = ctx.readFile(node.filePath);
2205
+ const src = content && sliceLines(content, node.startLine, node.endLine);
2206
+ if (!src)
2207
+ continue;
2208
+ // Thunks are TS/JS-family (same // and /* */ comment syntax); map to a CommentLang.
2209
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(src, node.language === 'javascript' || node.language === 'jsx' ? 'javascript' : 'typescript');
2210
+ THUNK_DISPATCH_RE.lastIndex = 0;
2211
+ let m;
2212
+ let added = 0;
2213
+ while ((m = THUNK_DISPATCH_RE.exec(safe)) && added < THUNK_FANOUT_CAP) {
2214
+ const name = m[1];
2215
+ if (name === node.name)
2216
+ continue; // self-dispatch (recursive thunk) — skip
2217
+ // Resolve the dispatched name, PREFERRING the thunk/action-creator over a same-named
2218
+ // service function. `dispatch(X(...))` dispatches a thunk or an action-creator (both
2219
+ // `constant`s) — never an unrelated helper that merely shares the name. On octo-call,
2220
+ // `leaveCall` is BOTH a `createAsyncThunk` const AND a service function, and the bare
2221
+ // `.find()` picked the function (wrong). Order: thunk const > other const > same-file
2222
+ // callable > first match. A single candidate (no collision) is unaffected.
2223
+ const cands = ctx
2224
+ .getNodesByName(name)
2225
+ .filter((n) => n.kind === 'constant' || n.kind === 'function' || n.kind === 'method');
2226
+ const target = cands.find((n) => !!n.signature && THUNK_DECL_RE.test(n.signature)) ??
2227
+ cands.find((n) => n.kind === 'constant') ??
2228
+ cands.find((n) => n.filePath === node.filePath) ??
2229
+ cands[0];
2230
+ if (!target || target.id === node.id)
2231
+ continue;
2232
+ const key = `${node.id}>${target.id}`;
2233
+ if (seen.has(key))
2234
+ continue;
2235
+ seen.add(key);
2236
+ const line = node.startLine + safe.slice(0, m.index).split('\n').length - 1;
2237
+ edges.push({
2238
+ source: node.id,
2239
+ target: target.id,
2240
+ kind: 'calls',
2241
+ line,
2242
+ provenance: 'heuristic',
2243
+ metadata: { synthesizedBy: 'redux-thunk', via: name, registeredAt: `${node.filePath}:${line}` },
2244
+ });
2245
+ added++;
2246
+ }
2247
+ }
2248
+ return edges;
2249
+ }
2250
+ // ── Object-literal registry dispatch ─────────────────────────────────────────
2251
+ // A command/handler registry maps string keys → handler class/function symbols in an
2252
+ // object literal, then dispatches by a RUNTIME key static parsing can't follow:
2253
+ // this.commands = { [Cmd.ADD]: AddObjectCommand, ... } // registration
2254
+ // new this.commands[command](args).execute() // dynamic dispatch
2255
+ // Bridge it like gin-middleware-chain: link each dispatching function → each registered
2256
+ // handler's callable entry (a class's execute/run/handle/… method — preferring the method
2257
+ // chained at the dispatch site — or the function value). Scoped to a registry + dispatch in
2258
+ // the SAME file (the cross-file barrel-namespace variant, e.g. trezor's getMethod, is
2259
+ // deferred). Gated on a real object literal with ≥2 entries that RESOLVE to callables (a
2260
+ // `{ width: 5 }` literal resolves to nothing → no edges); fan-out capped.
2261
+ const REGISTRY_ASSIGN_RE = /(?:(?:const|let|var)\s+([A-Za-z_$][\w$]*)|((?:this\.)?[A-Za-z_$][\w$]*))\s*=\s*\{/g;
2262
+ const REGISTRY_DISPATCH_RE = /(?:\bnew\s+)?((?:this\.)?[A-Za-z_$][\w$]*)\s*\[\s*([A-Za-z_$][\w$.]*)\s*\]\s*(?:\(|\.[A-Za-z_$])/g;
2263
+ const REGISTRY_MIN_ENTRIES = 2;
2264
+ const REGISTRY_FANOUT_CAP = 40;
2265
+ const REGISTRY_CLASS_ENTRY = new Set(['execute', 'run', 'handle', 'perform', 'process', 'call', 'apply', 'dispatch']);
2266
+ const REGISTRY_JS_EXT = /\.(?:ts|tsx|js|jsx|mjs|cjs)$/;
2267
+ /** From the index of an opening `{`, return the brace-balanced body up to its matching `}`. */
2268
+ function braceBody(src, openIdx) {
2269
+ let depth = 0;
2270
+ for (let i = openIdx; i < src.length; i++) {
2271
+ if (src[i] === '{')
2272
+ depth++;
2273
+ else if (src[i] === '}' && --depth === 0)
2274
+ return src.slice(openIdx + 1, i);
2275
+ }
2276
+ return null;
2277
+ }
2278
+ /** Top-level `key: Identifier` entries of an object-literal body. DEPTH-AWARE: only depth-0
2279
+ * segments are considered, so method-shorthand bodies (`number(a,b){…}`), arrow values
2280
+ * (`x: () => …`), and nested objects (`x: { … }`) don't leak their inner `k: v` pairs as
2281
+ * bogus handlers. The per-segment anchor (`^… key: Ident …$`) keeps only pure identifier
2282
+ * values — a data value (`x: 5`), call, or arrow fails to match. */
2283
+ function registryEntryNames(body) {
2284
+ const segs = [];
2285
+ let depth = 0;
2286
+ let start = 0;
2287
+ for (let i = 0; i < body.length; i++) {
2288
+ const c = body[i];
2289
+ if (c === '{' || c === '(' || c === '[')
2290
+ depth++;
2291
+ else if (c === '}' || c === ')' || c === ']')
2292
+ depth--;
2293
+ else if (c === ',' && depth === 0) {
2294
+ segs.push(body.slice(start, i));
2295
+ start = i + 1;
2296
+ }
2297
+ }
2298
+ segs.push(body.slice(start));
2299
+ const names = [];
2300
+ for (const seg of segs) {
2301
+ const m = /^\s*(?:\[[^\]]+\]|['"]?[\w$]+['"]?)\s*:\s*([A-Za-z_$][\w$]*)\s*$/.exec(seg);
2302
+ if (m && m[1].length >= 3 && !names.includes(m[1]))
2303
+ names.push(m[1]);
2304
+ }
2305
+ return names;
2306
+ }
2307
+ /** Resolve a registered handler name to its callable entry: a function value, or a class's
2308
+ * `execute`-like method (preferring the method chained at the dispatch site), else the class. */
2309
+ function resolveRegistryHandler(ctx, name, chained) {
2310
+ const cands = ctx.getNodesByName(name);
2311
+ const fn = cands.find((n) => n.kind === 'function');
2312
+ if (fn)
2313
+ return fn;
2314
+ const cls = cands.find((n) => n.kind === 'class' || n.kind === 'struct');
2315
+ if (cls) {
2316
+ const methods = ctx
2317
+ .getNodesInFile(cls.filePath)
2318
+ .filter((n) => n.kind === 'method' && n.startLine >= cls.startLine && n.startLine <= (cls.endLine ?? cls.startLine));
2319
+ const want = chained && REGISTRY_CLASS_ENTRY.has(chained) ? chained : null;
2320
+ const entry = (want && methods.find((m) => m.name === want)) ||
2321
+ methods.find((m) => REGISTRY_CLASS_ENTRY.has(m.name)) ||
2322
+ methods.find((m) => m.name === 'constructor');
2323
+ return entry ?? cls;
2324
+ }
2325
+ // Require a CALLABLE target — a registry dispatched as `reg[k](…)` invokes a function/
2326
+ // method, never a data `constant` (dropping it removes false positives like a `{ x: URL }`
2327
+ // entry resolving to the global URL constant).
2328
+ return cands.find((n) => n.kind === 'method') ?? null;
2329
+ }
2330
+ async function objectRegistryEdges(ctx, onYield) {
2331
+ let scannedFiles = 0;
2332
+ const edges = [];
2333
+ const seen = new Set();
2334
+ let scanned = 0;
2335
+ for (const file of ctx.getAllFiles()) {
2336
+ if ((++scannedFiles & 15) === 0)
2337
+ await onYield();
2338
+ if ((++scanned & 255) === 0)
2339
+ await onYield(); // #1091: yield mid-scan on huge graphs
2340
+ if (!REGISTRY_JS_EXT.test(file))
2341
+ continue;
2342
+ const content = ctx.readFile(file);
2343
+ // Cheap pre-filter: a computed member access BY NAME (`ident[ident`) — the dispatch shape.
2344
+ if (!content || !/[\w$]\s*\[\s*[A-Za-z_$]/.test(content))
2345
+ continue;
2346
+ // Skip minified/generated bundles (draco, three.min, base64…): their pervasive `h[x](...)`
2347
+ // calls + single-letter `{a:b}` literals are a false-positive minefield. Average line
2348
+ // length is the reliable tell — real source ~30–80, minified in the hundreds/thousands.
2349
+ const newlines = (content.match(/\n/g)?.length ?? 0) + 1;
2350
+ if (content.length / newlines > 200)
2351
+ continue;
2352
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, /\.(?:jsx?|mjs|cjs)$/.test(file) ? 'javascript' : 'typescript');
2353
+ // 1. Dispatch sites: `(new )?<ref>[<ident-key>]` followed by a call or a chained method.
2354
+ // A quoted-string key (`['save']`) does NOT match — that's a static access, not dispatch.
2355
+ REGISTRY_DISPATCH_RE.lastIndex = 0;
2356
+ const dispatches = [];
2357
+ let dm;
2358
+ while ((dm = REGISTRY_DISPATCH_RE.exec(safe))) {
2359
+ const win = safe.slice(dm.index, dm.index + 160);
2360
+ const cm = /\]\s*\([^)]*\)\s*\.\s*([A-Za-z_$][\w$]*)/.exec(win) || /\]\s*\.\s*([A-Za-z_$][\w$]*)/.exec(win);
2361
+ dispatches.push({ ref: dm[1], line: safe.slice(0, dm.index).split('\n').length, chained: cm ? cm[1] : null });
2362
+ }
2363
+ if (!dispatches.length)
2364
+ continue;
2365
+ // Normalize a leading `this.` so a class FIELD-INITIALIZER registry (`commands = {…}`)
2366
+ // matches a `this.commands[k]` dispatch, not just the constructor form `this.commands = {…}`.
2367
+ const norm = (r) => r.replace(/^this\./, '');
2368
+ const refs = new Set(dispatches.map((d) => norm(d.ref)));
2369
+ // 2. Registries: an object literal assigned to a dispatched ref, ≥2 entries resolving to callables.
2370
+ REGISTRY_ASSIGN_RE.lastIndex = 0;
2371
+ const registries = new Map();
2372
+ let am;
2373
+ while ((am = REGISTRY_ASSIGN_RE.exec(safe))) {
2374
+ const lhs = norm(am[1] ?? am[2]);
2375
+ if (!refs.has(lhs) || registries.has(lhs))
2376
+ continue;
2377
+ const body = braceBody(safe, am.index + am[0].length - 1);
2378
+ if (!body)
2379
+ continue;
2380
+ const names = registryEntryNames(body); // depth-0 `key: Identifier` entries only
2381
+ if (names.length >= REGISTRY_MIN_ENTRIES) {
2382
+ registries.set(lhs, { names, line: safe.slice(0, am.index).split('\n').length });
2383
+ }
2384
+ }
2385
+ if (!registries.size)
2386
+ continue;
2387
+ // 3. Link each dispatcher → each registered handler's callable entry.
2388
+ const nodesInFile = ctx.getNodesInFile(file);
2389
+ for (const d of dispatches) {
2390
+ const reg = registries.get(norm(d.ref));
2391
+ if (!reg)
2392
+ continue;
2393
+ const disp = enclosingFn(nodesInFile, d.line);
2394
+ if (!disp)
2395
+ continue;
2396
+ let added = 0;
2397
+ for (const name of reg.names) {
2398
+ if (added >= REGISTRY_FANOUT_CAP)
2399
+ break;
2400
+ const target = resolveRegistryHandler(ctx, name, d.chained);
2401
+ if (!target || target.id === disp.id)
2402
+ continue;
2403
+ const key = `${disp.id}>${target.id}`;
2404
+ if (seen.has(key))
2405
+ continue;
2406
+ seen.add(key);
2407
+ edges.push({
2408
+ source: disp.id,
2409
+ target: target.id,
2410
+ kind: 'calls',
2411
+ line: d.line,
2412
+ provenance: 'heuristic',
2413
+ metadata: { synthesizedBy: 'object-registry', via: name, registeredAt: `${file}:${reg.line}` },
2414
+ });
2415
+ added++;
2416
+ }
2417
+ }
2418
+ }
2419
+ return edges;
2420
+ }
2421
+ // ── RTK Query generated-hook → endpoint ──────────────────────────────────────
2422
+ // RTK Query generates one `useGetXQuery`/`useUpdateYMutation` hook per endpoint
2423
+ // (`createApi({ endpoints: b => ({ getX: b.query(...) }) })`). Components call the
2424
+ // hook; the fetch logic lives in the endpoint's queryFn. The hook↔endpoint link is
2425
+ // pure NAMING CONVENTION (no static edge): strip `use` + the optional `Lazy`
2426
+ // variant + the `Query|Mutation` suffix, lowercase the head → the endpoint key.
2427
+ // Both are extracted as function nodes (the hook from its `export const {…}=api`
2428
+ // binding, carrying a sentinel signature; the endpoint from the createApi object),
2429
+ // so bridging hook→endpoint connects `component → useGetXQuery → getX → queryFn`.
2430
+ // Gated on the extraction sentinel so it only ever fires on genuinely-generated
2431
+ // hooks (never a hand-written `useFooQuery`), and on a SAME-FILE endpoint (RTK
2432
+ // colocates the hooks and their api in one module) — 0 on any non-RTK repo.
2433
+ const RTK_HOOK_DERIVE_RE = /^use([A-Z][A-Za-z0-9]*?)(?:Query|Mutation)$/;
2434
+ // MUST match the signature set in tree-sitter.ts `extractRtkHookBindings`.
2435
+ const RTK_GENERATED_HOOK_SIGNATURE = '= RTK Query generated hook';
2436
+ /** Derive the endpoint key from a generated-hook name (`useLazyGetRecordsQuery`
2437
+ * → `getRecords`), or null if it doesn't fit the convention. */
2438
+ function rtkEndpointNameFromHook(hook) {
2439
+ const m = RTK_HOOK_DERIVE_RE.exec(hook);
2440
+ if (!m)
2441
+ return null;
2442
+ let mid = m[1];
2443
+ if (mid.startsWith('Lazy'))
2444
+ mid = mid.slice(4); // useLazyGetX → getX (same endpoint)
2445
+ if (!mid)
2446
+ return null;
2447
+ return mid.charAt(0).toLowerCase() + mid.slice(1);
2448
+ }
2449
+ async function rtkQueryEdges(queries, ctx, onYield) {
2450
+ let scanned255 = 0;
2451
+ const edges = [];
2452
+ const seen = new Set();
2453
+ for (const hook of queries.iterateNodesByKind('function')) {
2454
+ if ((++scanned255 & 63) === 0)
2455
+ await onYield();
2456
+ // Only our extracted generated-hook bindings (sentinel) — not a real hook fn.
2457
+ if (hook.signature !== RTK_GENERATED_HOOK_SIGNATURE)
2458
+ continue;
2459
+ const endpointName = rtkEndpointNameFromHook(hook.name);
2460
+ if (!endpointName)
2461
+ continue;
2462
+ // The endpoint is a same-file function by the derived name (RTK colocates the
2463
+ // api definition and its generated-hook exports in one module).
2464
+ const target = ctx
2465
+ .getNodesByName(endpointName)
2466
+ .find((n) => n.kind === 'function' && n.filePath === hook.filePath);
2467
+ if (!target || target.id === hook.id)
2468
+ continue;
2469
+ const key = `${hook.id}>${target.id}`;
2470
+ if (seen.has(key))
2471
+ continue;
2472
+ seen.add(key);
2473
+ edges.push({
2474
+ source: hook.id,
2475
+ target: target.id,
2476
+ kind: 'calls',
2477
+ line: hook.startLine,
2478
+ provenance: 'heuristic',
2479
+ metadata: { synthesizedBy: 'rtk-query', via: endpointName, registeredAt: `${hook.filePath}:${hook.startLine}` },
2480
+ });
2481
+ }
2482
+ return edges;
2483
+ }
2484
+ // ── Pinia useStore().action() dispatch bridge ────────────────────────────────
2485
+ // A Pinia store factory `export const useXStore = defineStore(...)` exposes its
2486
+ // actions as methods on the store instance; a consumer does `const s = useXStore()`
2487
+ // then `s.action()`. The call is a method-on-instance with no static edge to the
2488
+ // action (which lives in the store's module). Bridge it: map each factory → its
2489
+ // file, bind `const <var> = useXStore()` per consumer file, and link the enclosing
2490
+ // function → the `<var>.method()` action node IN THE STORE'S FILE. The same-store-
2491
+ // file gate keeps it precise (a Pinia built-in like `$patch` or an unrelated
2492
+ // same-named method resolves to nothing). Covers both the options and setup store
2493
+ // forms uniformly (the action is a function node in the store file either way).
2494
+ const PINIA_CONSUMER_EXT = /\.(?:ts|tsx|js|jsx|mjs|cjs|vue)$/;
2495
+ const PINIA_FACTORY_RE = /\b(?:export\s+)?const\s+(\w+)\s*=\s*defineStore\s*\(/g;
2496
+ const PINIA_BIND_RE = /\bconst\s+(\w+)\s*=\s*(?:await\s+)?(\w+)\s*\(/g;
2497
+ const PINIA_CALL_RE = /(\w+)\s*\.\s*(\w+)\s*\(/g;
2498
+ const PINIA_FANOUT_CAP = 80;
2499
+ async function piniaStoreEdges(ctx, onYield) {
2500
+ let scannedFiles = 0;
2501
+ // 1. Map each `const useXStore = defineStore(...)` factory → its store file.
2502
+ const factoryFile = new Map();
2503
+ for (const file of ctx.getAllFiles()) {
2504
+ if ((++scannedFiles & 15) === 0)
2505
+ await onYield();
2506
+ if (!PINIA_CONSUMER_EXT.test(file))
2507
+ continue;
2508
+ const content = ctx.readFile(file);
2509
+ if (!content || !content.includes('defineStore'))
2510
+ continue;
2511
+ PINIA_FACTORY_RE.lastIndex = 0;
2512
+ let m;
2513
+ while ((m = PINIA_FACTORY_RE.exec(content)))
2514
+ factoryFile.set(m[1], file);
2515
+ }
2516
+ if (!factoryFile.size)
2517
+ return [];
2518
+ const edges = [];
2519
+ const seen = new Set();
2520
+ for (const file of ctx.getAllFiles()) {
2521
+ if ((++scannedFiles & 15) === 0)
2522
+ await onYield();
2523
+ if (!PINIA_CONSUMER_EXT.test(file))
2524
+ continue;
2525
+ const content = ctx.readFile(file);
2526
+ if (!content || !content.includes('Store'))
2527
+ continue;
2528
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, /\.(?:jsx?|mjs|cjs)$/.test(file) ? 'javascript' : 'typescript');
2529
+ // 2. Bind store vars in this file: `const <var> = <known-factory>(...)`.
2530
+ const varStore = new Map();
2531
+ PINIA_BIND_RE.lastIndex = 0;
2532
+ let bm;
2533
+ while ((bm = PINIA_BIND_RE.exec(safe))) {
2534
+ const sf = factoryFile.get(bm[2]);
2535
+ if (sf)
2536
+ varStore.set(bm[1], sf);
2537
+ }
2538
+ if (!varStore.size)
2539
+ continue;
2540
+ // 3. Link `<var>.<method>(` → the action function node in the store's file.
2541
+ const nodesInFile = ctx.getNodesInFile(file);
2542
+ const fallbackDispatcher = nodesInFile.find((n) => n.kind === 'component'); // .vue top-level setup
2543
+ PINIA_CALL_RE.lastIndex = 0;
2544
+ let cm;
2545
+ let added = 0;
2546
+ while ((cm = PINIA_CALL_RE.exec(safe)) && added < PINIA_FANOUT_CAP) {
2547
+ const storeFile = varStore.get(cm[1]);
2548
+ if (!storeFile)
2549
+ continue;
2550
+ const method = cm[2];
2551
+ const line = safe.slice(0, cm.index).split('\n').length;
2552
+ const disp = enclosingFn(nodesInFile, line) ?? fallbackDispatcher;
2553
+ if (!disp)
2554
+ continue;
2555
+ const target = ctx
2556
+ .getNodesByName(method)
2557
+ .find((n) => n.kind === 'function' && n.filePath === storeFile);
2558
+ if (!target || target.id === disp.id)
2559
+ continue;
2560
+ const key = `${disp.id}>${target.id}`;
2561
+ if (seen.has(key))
2562
+ continue;
2563
+ seen.add(key);
2564
+ edges.push({
2565
+ source: disp.id,
2566
+ target: target.id,
2567
+ kind: 'calls',
2568
+ line,
2569
+ provenance: 'heuristic',
2570
+ metadata: { synthesizedBy: 'pinia-store', via: method, registeredAt: `${file}:${line}` },
2571
+ });
2572
+ added++;
2573
+ }
2574
+ }
2575
+ return edges;
2576
+ }
2577
+ // ── Vuex string-keyed dispatch / commit bridge ───────────────────────────────
2578
+ // Vuex dispatches actions/mutations by a runtime STRING key: `dispatch('user/login')`
2579
+ // / `commit('SET_TOKEN')` / `this.$store.dispatch('app/toggleDevice')`. The action
2580
+ // & mutation definitions are object-literal methods in store module files (now
2581
+ // extracted as function nodes). Bridge the string key to its node: the LAST `/`
2582
+ // segment is the action/mutation name; the preceding segment is the namespace
2583
+ // (≈ the store module's file). Resolve the name to a function node IN A STORE FILE
2584
+ // (the store-file gate excludes a same-named `api/` helper — `getInfo`/`login`
2585
+ // commonly collide), disambiguated by the namespace appearing in the path (or, for
2586
+ // a root key, the same file — Vuex's local-module `commit('M')` inside an action).
2587
+ const VUEX_DISPATCH_RE = /\b(?:dispatch|commit)\s*\(\s*['"]([A-Za-z][\w/]*)['"]/g;
2588
+ const VUEX_STORE_SIGNAL = /\bdefineStore\b|\bcreateStore\b|\bVuex\b|\bmutations\b|\bactions\b|\bgetters\b|\bnamespaced\b/g;
2589
+ const VUEX_FANOUT_CAP = 120;
2590
+ /** A path segment (dir or filename stem) equals `seg` — `…/modules/user.js` has
2591
+ * the segment `user` for namespace `user`. */
2592
+ function pathHasSegment(filePath, seg) {
2593
+ return new RegExp('[\\\\/]' + seg.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '[\\\\/.]').test(filePath);
2594
+ }
2595
+ async function vuexDispatchEdges(ctx, onYield) {
2596
+ let scannedFiles = 0;
2597
+ const storeFileCache = new Map();
2598
+ const isStoreFile = (file) => {
2599
+ let v = storeFileCache.get(file);
2600
+ if (v === undefined) {
2601
+ const c = ctx.readFile(file);
2602
+ const seen = new Set();
2603
+ if (c) {
2604
+ VUEX_STORE_SIGNAL.lastIndex = 0;
2605
+ let sm;
2606
+ while ((sm = VUEX_STORE_SIGNAL.exec(c))) {
2607
+ seen.add(sm[0]);
2608
+ if (seen.size >= 2)
2609
+ break;
2610
+ }
2611
+ }
2612
+ v = seen.size >= 2;
2613
+ storeFileCache.set(file, v);
2614
+ }
2615
+ return v;
2616
+ };
2617
+ const resolve = (key, dispatchFile) => {
2618
+ const segs = key.split('/');
2619
+ const action = segs[segs.length - 1];
2620
+ const cands = ctx.getNodesByName(action).filter((n) => n.kind === 'function' && isStoreFile(n.filePath));
2621
+ if (!cands.length)
2622
+ return null;
2623
+ if (segs.length > 1) {
2624
+ const mod = segs[segs.length - 2]; // immediate namespace ≈ the module file
2625
+ return cands.find((c) => pathHasSegment(c.filePath, mod)) ?? (cands.length === 1 ? cands[0] : null);
2626
+ }
2627
+ // Root key: a local `commit('M')` inside an action targets the same module file;
2628
+ // otherwise accept only an unambiguous single store-wide match.
2629
+ return cands.find((c) => c.filePath === dispatchFile) ?? (cands.length === 1 ? cands[0] : null);
2630
+ };
2631
+ const edges = [];
2632
+ const seen = new Set();
2633
+ for (const file of ctx.getAllFiles()) {
2634
+ if ((++scannedFiles & 15) === 0)
2635
+ await onYield();
2636
+ if (!PINIA_CONSUMER_EXT.test(file))
2637
+ continue;
2638
+ const content = ctx.readFile(file);
2639
+ if (!content || (!content.includes('dispatch(') && !content.includes('commit(')))
2640
+ continue;
2641
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, /\.(?:jsx?|mjs|cjs)$/.test(file) ? 'javascript' : 'typescript');
2642
+ const nodesInFile = ctx.getNodesInFile(file);
2643
+ const fallback = nodesInFile.find((n) => n.kind === 'component'); // .vue top-level
2644
+ VUEX_DISPATCH_RE.lastIndex = 0;
2645
+ let m;
2646
+ let added = 0;
2647
+ while ((m = VUEX_DISPATCH_RE.exec(safe)) && added < VUEX_FANOUT_CAP) {
2648
+ const key = m[1];
2649
+ const line = safe.slice(0, m.index).split('\n').length;
2650
+ const disp = enclosingFn(nodesInFile, line) ?? fallback;
2651
+ if (!disp)
2652
+ continue;
2653
+ const target = resolve(key, file);
2654
+ if (!target || target.id === disp.id)
2655
+ continue;
2656
+ const edgeKey = `${disp.id}>${target.id}`;
2657
+ if (seen.has(edgeKey))
2658
+ continue;
2659
+ seen.add(edgeKey);
2660
+ edges.push({
2661
+ source: disp.id,
2662
+ target: target.id,
2663
+ kind: 'calls',
2664
+ line,
2665
+ provenance: 'heuristic',
2666
+ metadata: { synthesizedBy: 'vuex-dispatch', via: key, registeredAt: `${file}:${line}` },
2667
+ });
2668
+ added++;
2669
+ }
2670
+ }
2671
+ return edges;
2672
+ }
2673
+ // ── Celery task dispatch (Python) ─────────────────────────────────────────────
2674
+ // Celery decouples a task's call site from its body through async dispatch:
2675
+ // # tasks.py
2676
+ // @shared_task # also @app.task / @celery_app.task / @<app>.task / @task
2677
+ // def process(account_ids): ...
2678
+ // # views.py — a DIFFERENT module
2679
+ // process.apply_async(kwargs={...}) # or process.delay(...) — dynamic, no static edge
2680
+ // Bridge it: link the enclosing function/method at each `.delay(`/`.apply_async(` site → the
2681
+ // task function body. Precision rests on the DECORATOR gate — the dispatched name must resolve
2682
+ // to a Python function carrying a celery task decorator (read from the source lines above its
2683
+ // `def`, since the def's own startLine excludes the decorator). A `.delay()` on a non-task
2684
+ // object resolves to no task node → no edge, so a Celery-free repo yields 0. Same-file /
2685
+ // unique-candidate disambiguation like vuex. (Canvas forms — `group(t).delay()`, `t.s()`/`.si()`
2686
+ // — have no single identifier before `.delay`/`.apply_async`, so they're skipped, not mis-bridged.)
2687
+ const CELERY_DISPATCH_RE = /\b([A-Za-z_]\w*)\s*\.\s*(?:delay|apply_async)\s*\(/g;
2688
+ // A task decorator: bare `@shared_task`/`@task` or attribute `@app.task`/`@celery_app.task`,
2689
+ // each optionally called with args. `\b`-bounded and `@`-anchored so `@mytask`, or a symbol
2690
+ // merely named `task`, can't match. No `/g`, so `.test()` is stateless across reuse.
2691
+ const CELERY_TASK_DECORATOR_RE = /@\s*(?:[A-Za-z_][\w.]*\.)?(?:shared_task|task)\b/;
2692
+ const CELERY_PY_EXT = /\.py$/;
2693
+ const CELERY_FANOUT_CAP = 80;
2694
+ const CELERY_DECORATOR_LOOKBACK = 12; // max lines above a `def` to scan for its decorators
2695
+ async function celeryDispatchEdges(ctx, onYield) {
2696
+ let scannedFiles = 0;
2697
+ // Memoize the decorator check per task-candidate node: it reads the file and scans a few
2698
+ // lines above the def. Only called on names that are actually `.delay`/`.apply_async`
2699
+ // receivers, so the candidate set stays small.
2700
+ const taskCache = new Map();
2701
+ const isCeleryTask = (node) => {
2702
+ let v = taskCache.get(node.id);
2703
+ if (v !== undefined)
2704
+ return v;
2705
+ v = false;
2706
+ if (node.kind === 'function' && CELERY_PY_EXT.test(node.filePath)) {
2707
+ const content = ctx.readFile(node.filePath);
2708
+ if (content) {
2709
+ const lines = content.split('\n');
2710
+ // startLine is the `def` line (decorators sit ABOVE it). Walk upward, stopping at the
2711
+ // previous declaration so a non-task def can never inherit the prior def's decorator.
2712
+ const stop = Math.max(0, node.startLine - 1 - CELERY_DECORATOR_LOOKBACK);
2713
+ for (let i = node.startLine - 2; i >= stop; i--) {
2714
+ const t = (lines[i] ?? '').trim();
2715
+ if (/^(?:async\s+def|def|class)\b/.test(t))
2716
+ break; // previous decl → stop
2717
+ if (CELERY_TASK_DECORATOR_RE.test(t)) {
2718
+ v = true;
2719
+ break;
2720
+ }
2721
+ }
2722
+ }
2723
+ }
2724
+ taskCache.set(node.id, v);
2725
+ return v;
2726
+ };
2727
+ const resolve = (name, dispatchFile) => {
2728
+ const cands = ctx.getNodesByName(name).filter((n) => n.kind === 'function' && isCeleryTask(n));
2729
+ if (!cands.length)
2730
+ return null;
2731
+ if (cands.length === 1)
2732
+ return cands[0];
2733
+ // Cross-module name collision: prefer a task defined in the dispatching file, else bail
2734
+ // (ambiguous — precision over recall, like vuex's root-key resolution).
2735
+ return cands.find((c) => c.filePath === dispatchFile) ?? null;
2736
+ };
2737
+ const edges = [];
2738
+ const seen = new Set();
2739
+ for (const file of ctx.getAllFiles()) {
2740
+ if ((++scannedFiles & 15) === 0)
2741
+ await onYield();
2742
+ if (!CELERY_PY_EXT.test(file))
2743
+ continue;
2744
+ const content = ctx.readFile(file);
2745
+ if (!content || (!content.includes('.delay(') && !content.includes('.apply_async(')))
2746
+ continue;
2747
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'python');
2748
+ const nodesInFile = ctx.getNodesInFile(file);
2749
+ CELERY_DISPATCH_RE.lastIndex = 0;
2750
+ let m;
2751
+ let added = 0;
2752
+ while ((m = CELERY_DISPATCH_RE.exec(safe)) && added < CELERY_FANOUT_CAP) {
2753
+ const name = m[1];
2754
+ const line = safe.slice(0, m.index).split('\n').length;
2755
+ const disp = enclosingFn(nodesInFile, line);
2756
+ if (!disp)
2757
+ continue; // module-level dispatch — no source symbol to attribute
2758
+ const target = resolve(name, file);
2759
+ if (!target || target.id === disp.id)
2760
+ continue;
2761
+ const key = `${disp.id}>${target.id}`;
2762
+ if (seen.has(key))
2763
+ continue;
2764
+ seen.add(key);
2765
+ edges.push({
2766
+ source: disp.id,
2767
+ target: target.id,
2768
+ kind: 'calls',
2769
+ line,
2770
+ provenance: 'heuristic',
2771
+ metadata: { synthesizedBy: 'celery-dispatch', via: name, registeredAt: `${file}:${line}` },
2772
+ });
2773
+ added++;
2774
+ }
2775
+ }
2776
+ return edges;
2777
+ }
2778
+ // ── Spring application events (Java) ──────────────────────────────────────────
2779
+ // Spring decouples an event PUBLISHER from its LISTENER(s) through the application
2780
+ // event bus, linked by the EVENT TYPE (not a name):
2781
+ // // SomeService.java
2782
+ // eventPublisher.publishEvent(new PasswordChangedEvent(this, username)); // publish
2783
+ // // RememberMeTokenRevoker.java — a DIFFERENT file
2784
+ // @EventListener(PasswordChangedEvent.class) // listen
2785
+ // public void onPasswordChanged(PasswordChangedEvent event) { ... }
2786
+ // Bridge it: link the enclosing method at each `publishEvent(new XEvent(...))` site →
2787
+ // every listener method of XEvent. Listeners are `@EventListener` / `@TransactionalEventListener`
2788
+ // methods (event type = the first param type, or the `@EventListener(X.class)` value form) and
2789
+ // the older `class … implements ApplicationListener<X> { void onApplicationEvent(X e) }`. Keyed
2790
+ // by exact type name, usually cross-file. A repo with no `@EventListener`/`publishEvent` yields 0.
2791
+ // (Java method nodes INCLUDE their leading annotations in the range — startLine is the first
2792
+ // `@…` line — so the annotation block is scanned DOWNWARD from startLine, bounded to consecutive
2793
+ // `@`-lines so it can't bleed into an adjacent method.)
2794
+ const SPRING_PUBLISH_RE = /\.publishEvent\s*\(\s*new\s+([A-Z][A-Za-z0-9_]*)/g;
2795
+ const SPRING_LISTENER_ANNO_RE = /@(?:EventListener|TransactionalEventListener)\b/;
2796
+ const SPRING_ANNO_TYPE_RE = /@(?:EventListener|TransactionalEventListener)\s*\(\s*([A-Z][A-Za-z0-9_]*)\.class/;
2797
+ const SPRING_APP_LISTENER_RE = /\bApplicationListener\s*</;
2798
+ const SPRING_JAVA_EXT = /\.java$/;
2799
+ const SPRING_FANOUT_CAP = 80;
2800
+ /** The first parameter's type from a Java method `signature` (`"void (XEvent e)"` → `XEvent`).
2801
+ * Skips a leading `final`/`@Anno`, strips generics, and requires a PascalCase class name (event
2802
+ * types are classes) — so a no-arg or primitive-param method yields null. */
2803
+ function springFirstParamType(sig) {
2804
+ if (!sig)
2805
+ return null;
2806
+ const open = sig.indexOf('(');
2807
+ if (open < 0)
2808
+ return null;
2809
+ const close = sig.indexOf(')', open);
2810
+ const inner = sig.slice(open + 1, close < 0 ? sig.length : close).trim();
2811
+ if (!inner)
2812
+ return null;
2813
+ const first = inner.split(',')[0].trim();
2814
+ const toks = first.split(/\s+/).filter((t) => t && t !== 'final' && !t.startsWith('@'));
2815
+ if (toks.length < 2)
2816
+ return null; // need `Type name`
2817
+ const type = toks[toks.length - 2].replace(/<.*$/, ''); // drop generic args
2818
+ return /^[A-Z][A-Za-z0-9_]*$/.test(type) ? type : null;
2819
+ }
2820
+ async function springEventEdges(ctx, onYield) {
2821
+ let scannedFiles = 0;
2822
+ // Pass 1 — event-type → listener methods, scanning only event-relevant files.
2823
+ // This is the ONLY full read sweep: publisher files are recorded here so
2824
+ // pass 2 re-reads just those instead of every .java file again (#1212 —
2825
+ // the double full-repo read was one of the tail's longest unyielded spans).
2826
+ const listeners = new Map();
2827
+ const publisherFiles = [];
2828
+ for (const file of ctx.getAllFiles()) {
2829
+ if ((++scannedFiles & 15) === 0)
2830
+ await onYield();
2831
+ if (!SPRING_JAVA_EXT.test(file))
2832
+ continue;
2833
+ const content = ctx.readFile(file);
2834
+ if (!content)
2835
+ continue;
2836
+ if (content.includes('.publishEvent('))
2837
+ publisherFiles.push(file);
2838
+ const hasAnno = content.includes('@EventListener') || content.includes('@TransactionalEventListener');
2839
+ const hasAppListener = SPRING_APP_LISTENER_RE.test(content);
2840
+ if (!hasAnno && !hasAppListener)
2841
+ continue;
2842
+ const lines = content.split('\n');
2843
+ for (const node of ctx.getNodesInFile(file)) {
2844
+ if (node.kind !== 'method')
2845
+ continue;
2846
+ // Collect this method's own leading annotation block (consecutive `@`-lines from startLine).
2847
+ const annoLines = [];
2848
+ for (let i = node.startLine - 1; i < lines.length && i < node.startLine + 7; i++) {
2849
+ const t = (lines[i] ?? '').trim();
2850
+ if (!t.startsWith('@'))
2851
+ break; // reached the declaration → stop (no bleed into next method)
2852
+ annoLines.push(t);
2853
+ }
2854
+ const head = annoLines.join('\n');
2855
+ const annotated = hasAnno && SPRING_LISTENER_ANNO_RE.test(head);
2856
+ const isAppListener = hasAppListener && node.name === 'onApplicationEvent';
2857
+ if (!annotated && !isAppListener)
2858
+ continue;
2859
+ let type = springFirstParamType(node.signature);
2860
+ if (!type && annotated) {
2861
+ const m = SPRING_ANNO_TYPE_RE.exec(head);
2862
+ if (m)
2863
+ type = m[1];
2864
+ }
2865
+ if (!type)
2866
+ continue;
2867
+ let arr = listeners.get(type);
2868
+ if (!arr) {
2869
+ arr = [];
2870
+ listeners.set(type, arr);
2871
+ }
2872
+ arr.push(node);
2873
+ }
2874
+ }
2875
+ if (!listeners.size)
2876
+ return [];
2877
+ // Pass 2 — link each publishEvent(new XEvent(...)) site → every listener of
2878
+ // XEvent. Only the publisher files recorded in pass 1 are (re-)read.
2879
+ const edges = [];
2880
+ const seen = new Set();
2881
+ for (const file of publisherFiles) {
2882
+ if ((++scannedFiles & 15) === 0)
2883
+ await onYield();
2884
+ const content = ctx.readFile(file);
2885
+ if (!content || !content.includes('.publishEvent('))
2886
+ continue;
2887
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'java');
2888
+ const nodesInFile = ctx.getNodesInFile(file);
2889
+ SPRING_PUBLISH_RE.lastIndex = 0;
2890
+ let m;
2891
+ let added = 0;
2892
+ while ((m = SPRING_PUBLISH_RE.exec(safe)) && added < SPRING_FANOUT_CAP) {
2893
+ const targets = listeners.get(m[1]);
2894
+ if (!targets || !targets.length)
2895
+ continue;
2896
+ const line = safe.slice(0, m.index).split('\n').length;
2897
+ const disp = enclosingFn(nodesInFile, line);
2898
+ if (!disp)
2899
+ continue;
2900
+ for (const target of targets) {
2901
+ if (target.id === disp.id)
2902
+ continue;
2903
+ const key = `${disp.id}>${target.id}`;
2904
+ if (seen.has(key))
2905
+ continue;
2906
+ seen.add(key);
2907
+ edges.push({
2908
+ source: disp.id,
2909
+ target: target.id,
2910
+ kind: 'calls',
2911
+ line,
2912
+ provenance: 'heuristic',
2913
+ metadata: { synthesizedBy: 'spring-event', via: m[1], registeredAt: `${file}:${line}` },
2914
+ });
2915
+ added++;
2916
+ }
2917
+ }
2918
+ }
2919
+ return edges;
2920
+ }
2921
+ // ── MediatR request/notification dispatch (C#/.NET) ───────────────────────────
2922
+ // MediatR decouples a Send/Publish call site from its Handle method through a mediator,
2923
+ // linked by the request/notification TYPE (the IRequestHandler<T,…> generic):
2924
+ // // CancelOrderCommandHandler.cs — the handler
2925
+ // public class CancelOrderCommandHandler : IRequestHandler<CancelOrderCommand, bool> {
2926
+ // public async Task<bool> Handle(CancelOrderCommand request, CancellationToken ct) { … }
2927
+ // // some controller — the dispatch (usually a DIFFERENT file)
2928
+ // var command = new CancelOrderCommand(orderId); await _mediator.Send(command);
2929
+ // Bridge it: link the enclosing method at each mediator `.Send(x)`/`.Publish(x)` site → the
2930
+ // `Handle` method of the handler for x's type. The sent type is resolved from the argument —
2931
+ // inline `new X(…)`, a local `var v = new X(…)`, or a parameter/local declared `X v` — bounded
2932
+ // to the enclosing method. Precision rests on TWO gates: the receiver must be mediator-ish
2933
+ // (`mediator`/`sender`/`publisher`, so MAUI `MessagingCenter.Send` is ignored) AND the resolved
2934
+ // type must be a known handler request type (so a same-named non-request DTO is never bridged).
2935
+ // C# has no `signature` on method nodes, so the handler's request type is read from the class
2936
+ // base-list source (`: IRequestHandler<X,…>`), not a param signature.
2937
+ const MEDIATR_HANDLER_BASE_RE = /(?:IRequestHandler|INotificationHandler)\s*<\s*([A-Za-z_]\w*)/;
2938
+ const MEDIATR_DISPATCH_RE = /([A-Za-z_][\w.]*)\s*\.\s*(?:Send|Publish)\s*\(\s*(new\s+[A-Z]\w*|[A-Za-z_]\w*)/g;
2939
+ const MEDIATR_RECEIVER_RE = /(?:mediator|sender|publisher)/i;
2940
+ const MEDIATR_CS_EXT = /\.cs$/;
2941
+ const MEDIATR_FANOUT_CAP = 80;
2942
+ const MEDIATR_HANDLER_DECL_LOOKAHEAD = 4; // lines from a class startLine to find a wrapped base list
2943
+ /** The type sent at a MediatR `.Send(arg)`/`.Publish(arg)` site: an inline `new X(…)`, else
2944
+ * `arg` as an identifier resolved within the enclosing method — a `… arg = new X(…)` assignment
2945
+ * (wins), or a parameter/local declared `X arg`. Returns null when the type can't be seen. */
2946
+ function resolveMediatrArgType(arg, lines, methodStart, dispatchLine) {
2947
+ const inl = /^new\s+([A-Z]\w*)/.exec(arg);
2948
+ if (inl)
2949
+ return inl[1];
2950
+ if (!/^[A-Za-z_]\w*$/.test(arg))
2951
+ return null;
2952
+ const assignRe = new RegExp(`\\b${arg}\\b\\s*=\\s*new\\s+([A-Z]\\w*)`);
2953
+ const declRe = new RegExp(`\\b([A-Z]\\w*)\\b\\s+${arg}\\b`);
2954
+ let declType = null;
2955
+ for (let i = Math.max(0, methodStart - 1); i < dispatchLine && i < lines.length; i++) {
2956
+ const ln = lines[i] ?? '';
2957
+ const a = assignRe.exec(ln);
2958
+ if (a)
2959
+ return a[1]; // an explicit `arg = new X` is the most specific — take it
2960
+ if (!declType) {
2961
+ const d = declRe.exec(ln);
2962
+ if (d)
2963
+ declType = d[1]; // a `X arg` declaration — remember, but keep scanning for an assignment
2964
+ }
2965
+ }
2966
+ return declType;
2967
+ }
2968
+ async function mediatrDispatchEdges(ctx, onYield) {
2969
+ let scannedFiles = 0;
2970
+ // Pass 1 — request/notification type → the Handle method of each handler class.
2971
+ const handlers = new Map();
2972
+ for (const file of ctx.getAllFiles()) {
2973
+ if ((++scannedFiles & 15) === 0)
2974
+ await onYield();
2975
+ if (!MEDIATR_CS_EXT.test(file))
2976
+ continue;
2977
+ const content = ctx.readFile(file);
2978
+ if (!content || (!content.includes('IRequestHandler<') && !content.includes('INotificationHandler<')))
2979
+ continue;
2980
+ const lines = content.split('\n');
2981
+ const nodesInFile = ctx.getNodesInFile(file);
2982
+ for (const cls of nodesInFile) {
2983
+ if (cls.kind !== 'class')
2984
+ continue;
2985
+ const decl = lines.slice(cls.startLine - 1, cls.startLine - 1 + MEDIATR_HANDLER_DECL_LOOKAHEAD).join('\n');
2986
+ const m = MEDIATR_HANDLER_BASE_RE.exec(decl);
2987
+ if (!m)
2988
+ continue;
2989
+ const type = m[1];
2990
+ const end = cls.endLine ?? cls.startLine;
2991
+ const handle = nodesInFile.find((n) => n.kind === 'method' && n.name === 'Handle' && n.startLine >= cls.startLine && n.startLine <= end);
2992
+ if (!handle)
2993
+ continue;
2994
+ let arr = handlers.get(type);
2995
+ if (!arr) {
2996
+ arr = [];
2997
+ handlers.set(type, arr);
2998
+ }
2999
+ arr.push(handle);
3000
+ }
3001
+ }
3002
+ if (!handlers.size)
3003
+ return [];
3004
+ // Pass 2 — link each mediator-ish .Send(x)/.Publish(x) → the handler of x's type.
3005
+ const edges = [];
3006
+ const seen = new Set();
3007
+ for (const file of ctx.getAllFiles()) {
3008
+ if ((++scannedFiles & 15) === 0)
3009
+ await onYield();
3010
+ if (!MEDIATR_CS_EXT.test(file))
3011
+ continue;
3012
+ const content = ctx.readFile(file);
3013
+ if (!content || (!content.includes('.Send(') && !content.includes('.Publish(')))
3014
+ continue;
3015
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'csharp');
3016
+ const safeLines = safe.split('\n');
3017
+ const nodesInFile = ctx.getNodesInFile(file);
3018
+ MEDIATR_DISPATCH_RE.lastIndex = 0;
3019
+ let m;
3020
+ let added = 0;
3021
+ while ((m = MEDIATR_DISPATCH_RE.exec(safe)) && added < MEDIATR_FANOUT_CAP) {
3022
+ if (!MEDIATR_RECEIVER_RE.test(m[1]))
3023
+ continue; // not a mediator (MessagingCenter, HttpClient, …)
3024
+ const line = safe.slice(0, m.index).split('\n').length;
3025
+ const disp = enclosingFn(nodesInFile, line);
3026
+ if (!disp)
3027
+ continue;
3028
+ const type = resolveMediatrArgType(m[2], safeLines, disp.startLine, line);
3029
+ if (!type)
3030
+ continue;
3031
+ const targets = handlers.get(type);
3032
+ if (!targets)
3033
+ continue;
3034
+ for (const target of targets) {
3035
+ if (target.id === disp.id)
3036
+ continue;
3037
+ const key = `${disp.id}>${target.id}`;
3038
+ if (seen.has(key))
3039
+ continue;
3040
+ seen.add(key);
3041
+ edges.push({
3042
+ source: disp.id,
3043
+ target: target.id,
3044
+ kind: 'calls',
3045
+ line,
3046
+ provenance: 'heuristic',
3047
+ metadata: { synthesizedBy: 'mediatr-dispatch', via: type, registeredAt: `${file}:${line}` },
3048
+ });
3049
+ added++;
3050
+ }
3051
+ }
3052
+ }
3053
+ return edges;
3054
+ }
3055
+ // ── Sidekiq job dispatch (Ruby) ───────────────────────────────────────────────
3056
+ // Sidekiq decouples a job's enqueue site from the worker's `perform`, linked by the WORKER
3057
+ // CLASS NAME:
3058
+ // # app/workers/destroy_user_worker.rb
3059
+ // class DestroyUserWorker
3060
+ // include Sidekiq::Worker # or Sidekiq::Job (the modern alias)
3061
+ // def perform(user_id) … end
3062
+ // # app/services/… — a DIFFERENT file
3063
+ // DestroyUserWorker.perform_async(user.id) # also .perform_in(t, …) / .perform_at(t, …)
3064
+ // Bridge it: link the enclosing method at each `Worker.perform_async/_in/_at(…)` site → that
3065
+ // worker's instance `perform`. Name-keyed (like Celery): the receiver class must be a Sidekiq
3066
+ // worker — gated by reading `include Sidekiq::Job|Worker` from the class body, since that mixin
3067
+ // is an external gem module that forms no resolvable edge. ActiveJob's `perform_later`/`_now` is
3068
+ // a different shape and deliberately not matched, so an ActiveJob-only app yields 0.
3069
+ const SIDEKIQ_DISPATCH_RE = /([A-Z][A-Za-z0-9_]*(?:::[A-Z][A-Za-z0-9_]*)*)\s*\.\s*perform_(?:async|in|at)\b/g;
3070
+ const SIDEKIQ_WORKER_RE = /\binclude\s+Sidekiq::(?:Job|Worker)\b/;
3071
+ const SIDEKIQ_RB_EXT = /\.rb$/;
3072
+ const SIDEKIQ_FANOUT_CAP = 80;
3073
+ async function sidekiqDispatchEdges(ctx, onYield) {
3074
+ let scannedFiles = 0;
3075
+ // class node id → its instance `perform` method (null if the class isn't a Sidekiq worker),
3076
+ // memoized. Reads the class body for the mixin; only consulted for actual dispatch receivers.
3077
+ const performCache = new Map();
3078
+ const performOf = (cls) => {
3079
+ let v = performCache.get(cls.id);
3080
+ if (v !== undefined)
3081
+ return v;
3082
+ v = null;
3083
+ const content = ctx.readFile(cls.filePath);
3084
+ if (content) {
3085
+ const end = cls.endLine ?? cls.startLine;
3086
+ const body = content.split('\n').slice(cls.startLine - 1, end).join('\n');
3087
+ if (SIDEKIQ_WORKER_RE.test(body)) {
3088
+ v = ctx.getNodesInFile(cls.filePath).find((n) => n.kind === 'method' && n.name === 'perform' && n.startLine >= cls.startLine && n.startLine <= end) ?? null;
3089
+ }
3090
+ }
3091
+ performCache.set(cls.id, v);
3092
+ return v;
3093
+ };
3094
+ // Resolve a (possibly namespaced) worker reference to its `perform`. A namespaced ref is
3095
+ // matched by EXACT qualified name first, so same-named workers in different namespaces
3096
+ // (forem has four `SendEmailNotificationWorker`s) resolve to the right one; an unqualified
3097
+ // ref falls back to the simple name and links only when a single worker bears it — an
3098
+ // ambiguous collision bails (precision over recall).
3099
+ const resolve = (ref) => {
3100
+ if (ref.includes('::')) {
3101
+ const q = ctx.getNodesByQualifiedName(ref).find((n) => n.kind === 'class' && performOf(n));
3102
+ if (q)
3103
+ return performOf(q);
3104
+ }
3105
+ const workers = ctx.getNodesByName(ref.split('::').pop()).filter((n) => n.kind === 'class' && performOf(n));
3106
+ return workers.length === 1 ? performOf(workers[0]) : null;
3107
+ };
3108
+ const edges = [];
3109
+ const seen = new Set();
3110
+ for (const file of ctx.getAllFiles()) {
3111
+ if ((++scannedFiles & 15) === 0)
3112
+ await onYield();
3113
+ if (!SIDEKIQ_RB_EXT.test(file))
3114
+ continue;
3115
+ const content = ctx.readFile(file);
3116
+ if (!content || !/\.perform_(?:async|in|at)\b/.test(content))
3117
+ continue;
3118
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'ruby');
3119
+ const nodesInFile = ctx.getNodesInFile(file);
3120
+ SIDEKIQ_DISPATCH_RE.lastIndex = 0;
3121
+ let m;
3122
+ let added = 0;
3123
+ while ((m = SIDEKIQ_DISPATCH_RE.exec(safe)) && added < SIDEKIQ_FANOUT_CAP) {
3124
+ const line = safe.slice(0, m.index).split('\n').length;
3125
+ const disp = enclosingFn(nodesInFile, line);
3126
+ if (!disp)
3127
+ continue;
3128
+ const target = resolve(m[1]);
3129
+ if (!target || target.id === disp.id)
3130
+ continue;
3131
+ const key = `${disp.id}>${target.id}`;
3132
+ if (seen.has(key))
3133
+ continue;
3134
+ seen.add(key);
3135
+ edges.push({
3136
+ source: disp.id,
3137
+ target: target.id,
3138
+ kind: 'calls',
3139
+ line,
3140
+ provenance: 'heuristic',
3141
+ metadata: { synthesizedBy: 'sidekiq-dispatch', via: m[1], registeredAt: `${file}:${line}` },
3142
+ });
3143
+ added++;
3144
+ }
3145
+ }
3146
+ return edges;
3147
+ }
3148
+ // ── Erlang behaviour-callback dispatch ────────────────────────────────────────
3149
+ // An Erlang behaviour is a compile-checked callback contract: the behaviour
3150
+ // module declares `-callback init(...) -> ...`, implementers declare
3151
+ // `-behaviour(B)` and export the callbacks, and the framework side dispatches
3152
+ // through a VARIABLE module — cowboy's `Handler:init(Req, Opts)` and
3153
+ // `Middleware:execute(Req, Env)` folds, ejabberd's `Mod:start/2`. Extraction
3154
+ // deliberately leaves var-module calls silent (no static target), so the flow
3155
+ // breaks at exactly the hop agents ask about (request → handler init). Bridge:
3156
+ //
3157
+ // dispatch site `Var:fn(args…)` → every in-repo implementer of the behaviour
3158
+ // declaring `fn` with the SITE's arity — provided exactly ONE in-repo
3159
+ // behaviour declares (fn, arity); a name+arity collision across behaviours
3160
+ // bails (silent beats wrong) — and the implementer defines and exports `fn`.
3161
+ //
3162
+ // Behaviours are discovered by scanning every Erlang file for `-callback`
3163
+ // declarations (not just `implements` targets), so a behaviour with zero
3164
+ // implementers still participates in the ambiguity gate. Fan-out control: a
3165
+ // mega-behaviour (ejabberd's gen_mod, ~200 mod_* implementers) would mint
3166
+ // hundreds of edges per site that READ as complete coverage while being
3167
+ // arbitrary — above the cap the site is skipped entirely and the boundary
3168
+ // stays visibly dynamic (explore's boundary announcer covers it) instead of
3169
+ // silently truncated.
3170
+ const ERLANG_EXT = /\.(?:erl|hrl)$/;
3171
+ // `Var:fn(` — variable (capitalized) module, lowercase function, immediate
3172
+ // open-paren. The leading char class rejects `?MODULE:fn(` (macro), `a:b(`
3173
+ // (static remote call, already linked), and mid-word matches.
3174
+ const ERLANG_DISPATCH_RE = /(^|[^?\w@'])([A-Z][A-Za-z0-9_@]*):([a-z][A-Za-z0-9_@]*)\(/g;
3175
+ const ERLANG_CALLBACK_DECL_RE = /(^|\n)\s*-callback\s+('[^'\n]+'|[a-z][A-Za-z0-9_@]*)\s*\(/g;
3176
+ const ERLANG_BEHAVIOUR_FANOUT_CAP = 24;
3177
+ /**
3178
+ * Argument count of the call/declaration whose `(` sits at `openIdx` —
3179
+ * top-level commas + 1, `()` → 0, unbalanced/oversized → -1. Skips nested
3180
+ * (), [], {}, <<>> content, `"strings"`, `'atoms'`, and `$c` char literals,
3181
+ * so `-callback init(fun((a, b) -> ok), #{k => v}) -> ok.` counts 2.
3182
+ */
3183
+ function erlangArityAt(src, openIdx) {
3184
+ let depth = 1;
3185
+ let commas = 0;
3186
+ let sawArg = false;
3187
+ const limit = Math.min(src.length, openIdx + 4000);
3188
+ for (let i = openIdx + 1; i < limit; i++) {
3189
+ const ch = src[i];
3190
+ if (ch === '"' || ch === "'") {
3191
+ i++;
3192
+ while (i < limit && src[i] !== ch) {
3193
+ if (src[i] === '\\')
3194
+ i++;
3195
+ i++;
3196
+ }
3197
+ sawArg = true;
3198
+ continue;
3199
+ }
3200
+ if (ch === '$') {
3201
+ i++;
3202
+ if (src[i] === '\\')
3203
+ i++;
3204
+ sawArg = true;
3205
+ continue;
3206
+ }
3207
+ if (ch === '(' || ch === '[' || ch === '{') {
3208
+ depth++;
3209
+ sawArg = true;
3210
+ continue;
3211
+ }
3212
+ if (ch === ')' || ch === ']' || ch === '}') {
3213
+ depth--;
3214
+ if (depth === 0)
3215
+ return sawArg ? commas + 1 : 0;
3216
+ continue;
3217
+ }
3218
+ if (ch === ',' && depth === 1) {
3219
+ commas++;
3220
+ continue;
3221
+ }
3222
+ if (!/\s/.test(ch))
3223
+ sawArg = true;
3224
+ }
3225
+ return -1;
3226
+ }
3227
+ /**
3228
+ * Nix module-system option wiring. A NixOS/home-manager/nix-darwin option is
3229
+ * DECLARED in one module (`options.launchd.user.agents = mkOption { ... }`)
3230
+ * and SET in others (`launchd.user.agents.yabai = { ... }` inside a module's
3231
+ * config) — the connection happens by option-path unification inside the
3232
+ * module-system evaluator, so there is no static call/import edge to follow
3233
+ * and flow questions ("how does services.yabai.enable become a launchd
3234
+ * service?") go dark at the module boundary.
3235
+ *
3236
+ * This pass links each config-write binding to the option declaration whose
3237
+ * path is the longest static-segment prefix of the write path. Precision gates:
3238
+ * - only STATIC segments participate: plain identifiers, plus quoted segments
3239
+ * (`"git/config"`, `"com.apple.dock"`) as opaque verbatim tokens that match
3240
+ * only quote-exactly; an interpolated (`${name}`) segment ends the prefix,
3241
+ * so dynamic paths never match beyond their static head;
3242
+ * - matched prefixes must be ≥2 segments: 1-segment paths would wrongly link
3243
+ * every package's `meta = { ... }` attrset to nixos's `options.meta`;
3244
+ * - a prefix declared in more than one file is ambiguous → no edge (a wrong
3245
+ * edge is worse than none);
3246
+ * - writes physically inside an options block are declaration internals
3247
+ * (types, defaults, examples), never config writes → excluded.
3248
+ * Both declaration spellings register: flat (`options.a.b = ...`) by name, and
3249
+ * nested (`options = { a.b = ...; }`) by line-span containment.
3250
+ */
3251
+ function nixLeadingPlainSegments(name) {
3252
+ const segs = [];
3253
+ let i = 0;
3254
+ const n = name.length;
3255
+ while (i < n) {
3256
+ if (name[i] === '"') {
3257
+ // Quoted segment — an opaque verbatim token (quotes kept, so it can
3258
+ // never collide with a plain identifier). `NSGlobalDomain."com.apple.
3259
+ // mouse.tapBehavior"` must match ITS OWN quoted declaration, not
3260
+ // whichever sibling registered the shared plain prefix first.
3261
+ let j = i + 1;
3262
+ while (j < n && name[j] !== '"') {
3263
+ if (name[j] === '\\')
3264
+ j++;
3265
+ j++;
3266
+ }
3267
+ if (j >= n)
3268
+ return segs; // unterminated — stop at the static head
3269
+ const tok = name.slice(i, j + 1);
3270
+ if (tok.includes('${'))
3271
+ return segs; // interpolated → dynamic → stop
3272
+ segs.push(tok);
3273
+ i = j + 1;
3274
+ if (i >= n)
3275
+ break;
3276
+ if (name[i] !== '.')
3277
+ return segs;
3278
+ i++;
3279
+ continue;
3280
+ }
3281
+ let j = i;
3282
+ while (j < n && name[j] !== '.') {
3283
+ if (name[j] === '"' || (name[j] === '$' && name[j + 1] === '{'))
3284
+ return segs;
3285
+ j++;
3286
+ }
3287
+ const seg = name.slice(i, j);
3288
+ if (!/^[A-Za-z_][A-Za-z0-9_'-]*$/.test(seg))
3289
+ return segs;
3290
+ segs.push(seg);
3291
+ i = j + 1;
3292
+ }
3293
+ return segs;
3294
+ }
3295
+ async function nixOptionPathEdges(queries, onYield) {
3296
+ let scanned255 = 0;
3297
+ // One streaming pass over nix bindings (variables + the odd function-valued
3298
+ // option); memory stays O(bindings-kept), not O(all nodes) (#610).
3299
+ const byFile = new Map();
3300
+ let scanned = 0;
3301
+ for (const kind of ['variable', 'function']) {
3302
+ for (const node of queries.iterateNodesByKind(kind)) {
3303
+ if ((++scanned255 & 63) === 0)
3304
+ await onYield();
3305
+ if ((++scanned & 0x3fff) === 0 && onYield)
3306
+ await onYield();
3307
+ if (node.language !== 'nix')
3308
+ continue;
3309
+ const segs = nixLeadingPlainSegments(node.name);
3310
+ if (segs.length === 0)
3311
+ continue;
3312
+ const rec = {
3313
+ id: node.id,
3314
+ filePath: node.filePath,
3315
+ startLine: node.startLine,
3316
+ endLine: node.endLine,
3317
+ segs,
3318
+ };
3319
+ const arr = byFile.get(node.filePath);
3320
+ if (arr)
3321
+ arr.push(rec);
3322
+ else
3323
+ byFile.set(node.filePath, [rec]);
3324
+ }
3325
+ }
3326
+ // Per file: walk bindings outermost-first with a stack of active option
3327
+ // spans, composing nested declaration paths (`options = { services.foo = {
3328
+ // enable = mkOption ...; }; }` registers services.foo AND services.foo.enable).
3329
+ // An `options` binding nested inside another option span is a SUBMODULE's
3330
+ // own namespace (`attrsOf (submodule { options = ...; })`) — its internals
3331
+ // are not globally addressable, so the sentinel blocks registration below it
3332
+ // while still excluding the region from write candidates.
3333
+ const SUBMODULE = 'submodule';
3334
+ const decls = new Map();
3335
+ const writes = [];
3336
+ const register = (path, rec) => {
3337
+ if (path.length < 2 || path.includes(SUBMODULE))
3338
+ return;
3339
+ const key = path.join('.');
3340
+ const arr = decls.get(key);
3341
+ if (arr)
3342
+ arr.push(rec);
3343
+ else
3344
+ decls.set(key, [rec]);
3345
+ };
3346
+ for (const recs of byFile.values()) {
3347
+ recs.sort((a, b) => a.startLine - b.startLine || b.endLine - a.endLine);
3348
+ const stack = [];
3349
+ for (const rec of recs) {
3350
+ while (stack.length > 0 && stack[stack.length - 1].end < rec.startLine)
3351
+ stack.pop();
3352
+ // Strict containment at line granularity: a one-line nested binding is
3353
+ // indistinguishable from its container, so it stays unclassified (rare
3354
+ // in module code, where option blocks are multi-line).
3355
+ const enclosing = stack.length > 0 &&
3356
+ rec.startLine >= stack[stack.length - 1].start &&
3357
+ rec.endLine <= stack[stack.length - 1].end &&
3358
+ !(rec.startLine === stack[stack.length - 1].start && rec.endLine === stack[stack.length - 1].end)
3359
+ ? stack[stack.length - 1]
3360
+ : null;
3361
+ if (rec.segs[0] === 'options') {
3362
+ const ownPath = rec.segs.slice(1); // [] for the bare `options = { ... }` spelling
3363
+ const prefix = enclosing ? [SUBMODULE] : ownPath;
3364
+ register(prefix, rec);
3365
+ stack.push({ start: rec.startLine, end: rec.endLine, prefix });
3366
+ continue;
3367
+ }
3368
+ if (enclosing) {
3369
+ const composed = [...enclosing.prefix, ...rec.segs];
3370
+ register(composed, rec);
3371
+ stack.push({ start: rec.startLine, end: rec.endLine, prefix: composed });
3372
+ continue;
3373
+ }
3374
+ if (rec.segs.length >= 2) {
3375
+ writes.push(rec);
3376
+ }
3377
+ }
3378
+ }
3379
+ if (decls.size === 0 || writes.length === 0)
3380
+ return [];
3381
+ const edges = [];
3382
+ for (const w of writes) {
3383
+ // `config.services.x = ...` spells the same write with an explicit prefix.
3384
+ const segs = w.segs[0] === 'config' ? w.segs.slice(1) : w.segs;
3385
+ if (segs.length < 2)
3386
+ continue;
3387
+ // Longest prefix wins; an ambiguous longest match does NOT fall back to a
3388
+ // shorter one (that would link `services.nginx.virtualHosts.x` to
3389
+ // `options.services.nginx` when virtualHosts is the contested path).
3390
+ for (let len = Math.min(segs.length, 6); len >= 2; len--) {
3391
+ const candidates = decls.get(segs.slice(0, len).join('.'));
3392
+ if (!candidates || candidates.length === 0)
3393
+ continue;
3394
+ const files = new Set(candidates.map((c) => c.filePath));
3395
+ if (files.size === 1) {
3396
+ const target = candidates[0];
3397
+ if (target.id !== w.id) {
3398
+ edges.push({
3399
+ source: w.id,
3400
+ target: target.id,
3401
+ kind: 'references',
3402
+ line: w.startLine,
3403
+ provenance: 'heuristic',
3404
+ metadata: {
3405
+ synthesizedBy: 'nix-option-path',
3406
+ optionPath: segs.slice(0, len).join('.'),
3407
+ registeredAt: `${target.filePath}:${target.startLine}`,
3408
+ },
3409
+ });
3410
+ }
3411
+ }
3412
+ break; // longest hit decides, matched or ambiguous
3413
+ }
3414
+ }
3415
+ return edges;
3416
+ }
3417
+ async function erlangBehaviourDispatchEdges(queries, ctx, onYield) {
3418
+ let scannedFiles = 0;
3419
+ let scanned255 = 0;
3420
+ // Cheap language gate: no Erlang modules → no cost beyond one streamed
3421
+ // kind scan (never a materialized array of every namespace — #1212).
3422
+ const erlangModules = [];
3423
+ for (const n of queries.iterateNodesByKind('namespace')) {
3424
+ if ((++scanned255 & 63) === 0)
3425
+ await onYield();
3426
+ if (n.language === 'erlang')
3427
+ erlangModules.push(n);
3428
+ }
3429
+ if (erlangModules.length === 0)
3430
+ return [];
3431
+ // Pass 1 — scan every Erlang file with `-callback` decls: behaviour module →
3432
+ // its (name, arity) callback set, and the global `name/arity` → declaring
3433
+ // behaviours map that drives the ambiguity gate.
3434
+ const moduleByFile = new Map();
3435
+ for (const ns of erlangModules) {
3436
+ if (!moduleByFile.has(ns.filePath))
3437
+ moduleByFile.set(ns.filePath, ns);
3438
+ }
3439
+ const declaringBehaviours = new Map(); // `fn/arity` → behaviour namespaces
3440
+ const callbackNames = new Set();
3441
+ for (const file of ctx.getAllFiles()) {
3442
+ if ((++scannedFiles & 15) === 0)
3443
+ await onYield();
3444
+ if (!ERLANG_EXT.test(file))
3445
+ continue;
3446
+ const behaviour = moduleByFile.get(file);
3447
+ if (!behaviour)
3448
+ continue; // a .hrl or module-less file can't be a behaviour
3449
+ const content = ctx.readFile(file);
3450
+ if (!content || !content.includes('-callback'))
3451
+ continue;
3452
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'erlang');
3453
+ ERLANG_CALLBACK_DECL_RE.lastIndex = 0;
3454
+ let m;
3455
+ while ((m = ERLANG_CALLBACK_DECL_RE.exec(safe))) {
3456
+ const name = m[2].replace(/^'|'$/g, '');
3457
+ const arity = erlangArityAt(safe, m.index + m[0].length - 1);
3458
+ if (arity < 0)
3459
+ continue;
3460
+ const key = `${name}/${arity}`;
3461
+ const arr = declaringBehaviours.get(key);
3462
+ if (arr) {
3463
+ if (!arr.some((b) => b.id === behaviour.id))
3464
+ arr.push(behaviour);
3465
+ }
3466
+ else {
3467
+ declaringBehaviours.set(key, [behaviour]);
3468
+ }
3469
+ callbackNames.add(name);
3470
+ }
3471
+ }
3472
+ if (declaringBehaviours.size === 0)
3473
+ return [];
3474
+ // Implementer target lookup, lazy per (behaviour, fn): implementers come
3475
+ // from the `implements` edges extraction resolved, and the target is the
3476
+ // implementer module's own exported `fn` function node.
3477
+ const targetCache = new Map();
3478
+ const targetsOf = (behaviour, fn) => {
3479
+ const cacheKey = `${behaviour.id}#${fn}`;
3480
+ let targets = targetCache.get(cacheKey);
3481
+ if (targets)
3482
+ return targets;
3483
+ targets = [];
3484
+ for (const e of queries.getIncomingEdges(behaviour.id, ['implements'])) {
3485
+ const impl = queries.getNodeById(e.source);
3486
+ if (!impl || impl.language !== 'erlang' || impl.kind !== 'namespace')
3487
+ continue;
3488
+ const fnNode = ctx
3489
+ .getNodesInFile(impl.filePath)
3490
+ .find((n) => n.kind === 'function' && n.name === fn && n.isExported !== false);
3491
+ if (fnNode)
3492
+ targets.push(fnNode);
3493
+ }
3494
+ targetCache.set(cacheKey, targets);
3495
+ return targets;
3496
+ };
3497
+ // Pass 2 — dispatch sites. Only files containing a var-module call shape are
3498
+ // scanned in full.
3499
+ const edges = [];
3500
+ const seen = new Set();
3501
+ for (const file of ctx.getAllFiles()) {
3502
+ if ((++scannedFiles & 15) === 0)
3503
+ await onYield();
3504
+ if (!ERLANG_EXT.test(file))
3505
+ continue;
3506
+ const content = ctx.readFile(file);
3507
+ if (!content || !/[A-Z][A-Za-z0-9_@]*:[a-z]/.test(content))
3508
+ continue;
3509
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'erlang');
3510
+ const nodesInFile = ctx.getNodesInFile(file);
3511
+ ERLANG_DISPATCH_RE.lastIndex = 0;
3512
+ let m;
3513
+ while ((m = ERLANG_DISPATCH_RE.exec(safe))) {
3514
+ const fn = m[3];
3515
+ if (!callbackNames.has(fn))
3516
+ continue;
3517
+ const openIdx = m.index + m[0].length - 1;
3518
+ const arity = erlangArityAt(safe, openIdx);
3519
+ if (arity < 0)
3520
+ continue;
3521
+ const behaviours = declaringBehaviours.get(`${fn}/${arity}`);
3522
+ if (!behaviours || behaviours.length !== 1)
3523
+ continue; // unknown or ambiguous
3524
+ const behaviour = behaviours[0];
3525
+ const targets = targetsOf(behaviour, fn);
3526
+ if (targets.length === 0 || targets.length > ERLANG_BEHAVIOUR_FANOUT_CAP)
3527
+ continue;
3528
+ const line = safe.slice(0, m.index).split('\n').length;
3529
+ const disp = enclosingFn(nodesInFile, line);
3530
+ if (!disp)
3531
+ continue;
3532
+ for (const target of targets) {
3533
+ if (target.id === disp.id)
3534
+ continue;
3535
+ const key = `${disp.id}>${target.id}`;
3536
+ if (seen.has(key))
3537
+ continue;
3538
+ seen.add(key);
3539
+ edges.push({
3540
+ source: disp.id,
3541
+ target: target.id,
3542
+ kind: 'calls',
3543
+ line,
3544
+ provenance: 'heuristic',
3545
+ metadata: {
3546
+ synthesizedBy: 'erlang-behaviour',
3547
+ via: `${behaviour.name}:${fn}/${arity}`,
3548
+ registeredAt: `${file}:${line}`,
3549
+ },
3550
+ });
3551
+ }
3552
+ }
3553
+ }
3554
+ return edges;
3555
+ }
3556
+ // ── Laravel events (PHP) ──────────────────────────────────────────────────────
3557
+ // Laravel decouples an event dispatch from its listener(s), linked by the EVENT CLASS:
3558
+ // // app/Events/PlaybackStarted.php + app/Listeners/UpdateLastfmNowPlaying.php
3559
+ // class UpdateLastfmNowPlaying { public function handle(PlaybackStarted $event) { … } }
3560
+ // // a controller / service — a DIFFERENT file
3561
+ // event(new PlaybackStarted($song, $user));
3562
+ // Bridge it: link the enclosing method at each `event(new XEvent(...))` site → every listener's
3563
+ // `handle` for XEvent. Listeners come from TWO registration mechanisms (both real, both needed):
3564
+ // (A) auto-discovery — a `handle(EventType $e)` typed first param (also splits a union A|B);
3565
+ // (B) the `protected $listen = [ XEvent::class => [Listener::class, …] ]` map in an
3566
+ // EventServiceProvider, which also covers a listener whose `handle()` is UNTYPED.
3567
+ // Only `event(new X)` is matched — queued JOBS dispatch via `::dispatch()` and their `handle()`
3568
+ // takes an injected service, never an event type, so jobs are excluded by construction.
3569
+ const LARAVEL_DISPATCH_RE = /\bevent\s*\(\s*new\s+\\?([A-Za-z_][\w\\]*)/g;
3570
+ const LARAVEL_PHP_EXT = /\.php$/;
3571
+ const LARAVEL_FANOUT_CAP = 200;
3572
+ // A `$listen` entry: `Event::class => [Listener::class, …]`, key/values as `::class` or strings.
3573
+ const LISTEN_ENTRY_RE = /(?:([A-Za-z_\\][\w\\]*)::class|'([^']+)'|"([^"]+)")\s*=>\s*\[([^\]]*)\]/g;
3574
+ const LISTEN_CLASS_RE = /(?:([A-Za-z_\\][\w\\]*)::class|'([^']+)'|"([^"]+)")/g;
3575
+ /** Short class name from a PHP reference: `\App\Events\Foo` / `App\Events::Foo` → `Foo`. */
3576
+ function phpSimpleName(s) {
3577
+ return s.replace(/^\\/, '').split('\\').pop().split('::').pop().trim();
3578
+ }
3579
+ /** The first-parameter class type(s) of a `handle(...)` declaration — union-split, short-named,
3580
+ * primitives dropped. `handle(A|B $e)` → [A, B]; `handle(string $x)` / `handle()` → []. */
3581
+ function laravelHandleEventTypes(decl) {
3582
+ const m = /function\s+handle\s*\(\s*(?:\.\.\.\s*)?(\??[A-Za-z_\\][\w\\|]*)\s+&?\s*(?:\.\.\.\s*)?\$/.exec(decl);
3583
+ if (!m)
3584
+ return [];
3585
+ return m[1]
3586
+ .replace(/^\?/, '')
3587
+ .split('|')
3588
+ .map((t) => phpSimpleName(t))
3589
+ .filter((t) => /^[A-Z]\w*$/.test(t));
3590
+ }
3591
+ /** From an opening `[`, the bracket-balanced body up to its matching `]`. */
3592
+ function phpArrayBody(src, openIdx) {
3593
+ let depth = 0;
3594
+ for (let i = openIdx; i < src.length; i++) {
3595
+ if (src[i] === '[')
3596
+ depth++;
3597
+ else if (src[i] === ']' && --depth === 0)
3598
+ return src.slice(openIdx + 1, i);
3599
+ }
3600
+ return null;
3601
+ }
3602
+ async function laravelEventEdges(ctx, onYield) {
3603
+ let scannedFiles = 0;
3604
+ // event short name → its listener `handle` methods (deduped by node id).
3605
+ const listeners = new Map();
3606
+ const add = (event, handle) => {
3607
+ let m = listeners.get(event);
3608
+ if (!m) {
3609
+ m = new Map();
3610
+ listeners.set(event, m);
3611
+ }
3612
+ m.set(handle.id, handle);
3613
+ };
3614
+ const handleOf = (cls) => ctx
3615
+ .getNodesInFile(cls.filePath)
3616
+ .find((n) => n.kind === 'method' && n.name === 'handle'
3617
+ && n.startLine >= cls.startLine && n.startLine <= (cls.endLine ?? cls.startLine)) ?? null;
3618
+ // Pass 1 — build the event→handle map from both registration mechanisms.
3619
+ for (const file of ctx.getAllFiles()) {
3620
+ if ((++scannedFiles & 15) === 0)
3621
+ await onYield();
3622
+ if (!LARAVEL_PHP_EXT.test(file))
3623
+ continue;
3624
+ const content = ctx.readFile(file);
3625
+ if (!content)
3626
+ continue;
3627
+ // (A) typed listener handles — node-driven, so a commented-out method can't leak in.
3628
+ if (content.includes('function handle')) {
3629
+ const lines = content.split('\n');
3630
+ for (const node of ctx.getNodesInFile(file)) {
3631
+ if (node.kind !== 'method' || node.name !== 'handle')
3632
+ continue;
3633
+ const decl = lines.slice(node.startLine - 1, node.startLine + 2).join('\n');
3634
+ for (const ev of laravelHandleEventTypes(decl))
3635
+ add(ev, node);
3636
+ }
3637
+ }
3638
+ // (B) the EventServiceProvider `$listen` map — parsed from comment-stripped source so a
3639
+ // fully-commented map (firefly's, on auto-discovery) contributes nothing.
3640
+ if (content.includes('$listen')) {
3641
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'php');
3642
+ const decl = safe.search(/\$listen\s*=\s*\[/);
3643
+ const body = decl >= 0 ? phpArrayBody(safe, safe.indexOf('[', decl)) : null;
3644
+ if (body) {
3645
+ LISTEN_ENTRY_RE.lastIndex = 0;
3646
+ let em;
3647
+ while ((em = LISTEN_ENTRY_RE.exec(body))) {
3648
+ const event = phpSimpleName(em[1] ?? em[2] ?? em[3] ?? '');
3649
+ LISTEN_CLASS_RE.lastIndex = 0;
3650
+ let lm;
3651
+ while ((lm = LISTEN_CLASS_RE.exec(em[4]))) {
3652
+ const ln = phpSimpleName(lm[1] ?? lm[2] ?? lm[3] ?? '');
3653
+ const cls = ctx.getNodesByName(ln).find((n) => n.kind === 'class' && handleOf(n));
3654
+ if (cls)
3655
+ add(event, handleOf(cls));
3656
+ }
3657
+ }
3658
+ }
3659
+ }
3660
+ }
3661
+ if (!listeners.size)
3662
+ return [];
3663
+ // Pass 2 — link each event(new X(...)) site → every listener of X.
3664
+ const edges = [];
3665
+ const seen = new Set();
3666
+ for (const file of ctx.getAllFiles()) {
3667
+ if ((++scannedFiles & 15) === 0)
3668
+ await onYield();
3669
+ if (!LARAVEL_PHP_EXT.test(file))
3670
+ continue;
3671
+ const content = ctx.readFile(file);
3672
+ if (!content || !content.includes('event('))
3673
+ continue;
3674
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'php');
3675
+ const nodesInFile = ctx.getNodesInFile(file);
3676
+ LARAVEL_DISPATCH_RE.lastIndex = 0;
3677
+ let m;
3678
+ let added = 0;
3679
+ while ((m = LARAVEL_DISPATCH_RE.exec(safe)) && added < LARAVEL_FANOUT_CAP) {
3680
+ const targets = listeners.get(phpSimpleName(m[1]));
3681
+ if (!targets)
3682
+ continue;
3683
+ const line = safe.slice(0, m.index).split('\n').length;
3684
+ const disp = enclosingFn(nodesInFile, line);
3685
+ if (!disp)
3686
+ continue;
3687
+ for (const target of targets.values()) {
3688
+ if (target.id === disp.id)
3689
+ continue;
3690
+ const key = `${disp.id}>${target.id}`;
3691
+ if (seen.has(key))
3692
+ continue;
3693
+ seen.add(key);
3694
+ edges.push({
3695
+ source: disp.id,
3696
+ target: target.id,
3697
+ kind: 'calls',
3698
+ line,
3699
+ provenance: 'heuristic',
3700
+ metadata: { synthesizedBy: 'laravel-event', via: phpSimpleName(m[1]), registeredAt: `${file}:${line}` },
3701
+ });
3702
+ added++;
3703
+ }
3704
+ }
3705
+ }
3706
+ return edges;
3707
+ }
3708
+ /**
3709
+ * Synthesize dispatcher→callback edges (field observers + EventEmitters +
3710
+ * React re-render + JSX children + Vue templates + SvelteKit load + RN event
3711
+ * channel + Fabric native-impl + MyBatis Java↔XML + Gin middleware chain +
3712
+ * Redux-thunk dispatch chain + object-literal registry dispatch + RTK Query
3713
+ * generated-hook → endpoint + Pinia useStore().action() + Vuex string dispatch +
3714
+ * Celery task .delay()/.apply_async() → task body + Spring publishEvent → @EventListener +
3715
+ * MediatR Send/Publish → IRequestHandler/INotificationHandler +
3716
+ * Sidekiq Worker.perform_async → #perform + Laravel event(new X) → listener handle).
3717
+ * Returns the count added. Never throws into indexing — callers wrap in try/catch.
3718
+ */
3719
+ /**
3720
+ * Number of progress steps synthesizeCallbackEdges reports: one per `__mark()`
3721
+ * call (every synthesis pass, plus the dedupe-merge and edge-insert steps).
3722
+ * Cosmetic only — drift just makes the progress bar end early or jump — and a
3723
+ * test pins it to the actual step count (registry passes + the fixed
3724
+ * pre/post marks) so adding a pass without bumping this fails loudly instead
3725
+ * of silently skewing the bar.
3726
+ */
3727
+ const JS_FAMILY = ['typescript', 'javascript', 'tsx', 'jsx'];
3728
+ const ALWAYS = () => true;
3729
+ /**
3730
+ * The independent passes, in MERGE ORDER — the first-seen dedup in
3731
+ * synthesizeCallbackEdges follows this array, so reordering entries changes
3732
+ * which duplicate edge wins. The two Go pre-passes (cross-file method
3733
+ * `contains`, implicit `implements`) are NOT here: they persist before these
3734
+ * run because interfaceOverrideEdges reads their edges from the DB.
3735
+ */
3736
+ exports.SYNTH_PASSES = [
3737
+ { name: 'fieldEdges', gate: ALWAYS, run: (q, c, y) => fieldChannelEdges(q, c, y) },
3738
+ { name: 'closureCollEdges', gate: ALWAYS, run: (q, c, y) => closureCollectionEdges(q, c, y) },
3739
+ { name: 'emitterEdges', gate: ALWAYS, run: (_q, c, y) => eventEmitterEdges(c, y) },
3740
+ { name: 'renderEdges', gate: ALWAYS, run: (q, c, y) => reactRenderEdges(q, c, y) },
3741
+ { name: 'jsxEdges', gate: ALWAYS, run: (_q, c, y) => reactJsxChildEdges(c, y) },
3742
+ { name: 'vueEdges', gate: (has) => has('vue'), run: (_q, c, y) => vueTemplateEdges(c, y) },
3743
+ { name: 'svelteKitEdges', gate: (has) => has('svelte'), run: (_q, c, y) => svelteKitLoadEdges(c, y) },
3744
+ { name: 'pascalEdges', gate: ALWAYS, run: (_q, c, y) => pascalFormEdges(c, y) },
3745
+ { name: 'flutterEdges', gate: (has) => has('dart'), run: (q, c, y) => flutterBuildEdges(q, c, y) },
3746
+ { name: 'arkuiStateEdges', gate: (has) => has('arkts'), run: (q, c, y) => arkuiStateBuildEdges(q, c, y) },
3747
+ { name: 'arkuiEmitter', gate: (has) => has('arkts'), run: (_q, c, y) => arkuiEmitterEdges(c, y) },
3748
+ { name: 'arkuiRoutes', gate: (has) => has('arkts'), run: (_q, c, y) => arkuiRouterEdges(c, y) },
3749
+ { name: 'cppEdges', gate: (has) => has('cpp'), run: (q, _c, y) => cppOverrideEdges(q, y) },
3750
+ {
3751
+ name: 'ifaceEdges',
3752
+ gate: (has) => has('java', 'kotlin', 'csharp', 'swift', 'scala', 'go', 'rust', 'arkts', ...JS_FAMILY),
3753
+ run: (q, _c, y) => interfaceOverrideEdges(q, y),
3754
+ },
3755
+ { name: 'kotlinExpectActual', gate: (has) => has('kotlin'), run: (q, _c, y) => kotlinExpectActualEdges(q, y) },
3756
+ { name: 'goGrpcEdges', gate: (has) => has('go'), run: (q, _c, y) => goGrpcStubImplEdges(q, y) },
3757
+ { name: 'rnEventEdgesList', gate: (has) => has(...JS_FAMILY), run: (_q, c, y) => rnEventEdges(c, y) },
3758
+ { name: 'fabricNativeEdges', gate: ALWAYS, run: (_q, c, y) => fabricNativeImplEdges(c, y) },
3759
+ { name: 'expoXPlatEdges', gate: ALWAYS, run: (q, _c, y) => expoCrossPlatformEdges(q, y) },
3760
+ { name: 'rnXPlatEdges', gate: ALWAYS, run: (q, _c, y) => rnCrossPlatformEdges(q, y) },
3761
+ {
3762
+ name: 'mybatisEdges',
3763
+ gate: (has) => has('java', 'kotlin') && has('xml'),
3764
+ run: (q, _c, y) => mybatisJavaXmlEdges(q, y),
3765
+ },
3766
+ { name: 'ginEdges', gate: (has) => has('go'), run: (q, c, y) => ginMiddlewareChainEdges(q, c, y) },
3767
+ { name: 'thunkEdges', gate: (has) => has(...JS_FAMILY), run: (q, c, y) => reduxThunkEdges(q, c, y) },
3768
+ { name: 'registryEdges', gate: ALWAYS, run: (_q, c, y) => objectRegistryEdges(c, y) },
3769
+ { name: 'rtkEdges', gate: (has) => has(...JS_FAMILY), run: (q, c, y) => rtkQueryEdges(q, c, y) },
3770
+ { name: 'piniaEdges', gate: (has) => has('vue', ...JS_FAMILY), run: (_q, c, y) => piniaStoreEdges(c, y) },
3771
+ { name: 'vuexEdges', gate: (has) => has('vue', ...JS_FAMILY), run: (_q, c, y) => vuexDispatchEdges(c, y) },
3772
+ { name: 'celeryEdges', gate: (has) => has('python'), run: (_q, c, y) => celeryDispatchEdges(c, y) },
3773
+ { name: 'springEdges', gate: (has) => has('java'), run: (_q, c, y) => springEventEdges(c, y) },
3774
+ { name: 'mediatrEdges', gate: (has) => has('csharp'), run: (_q, c, y) => mediatrDispatchEdges(c, y) },
3775
+ { name: 'sidekiqEdges', gate: (has) => has('ruby'), run: (_q, c, y) => sidekiqDispatchEdges(c, y) },
3776
+ {
3777
+ name: 'erlangBehaviourEdges',
3778
+ gate: (has) => has('erlang'),
3779
+ run: (q, c, y) => erlangBehaviourDispatchEdges(q, c, y),
3780
+ },
3781
+ { name: 'laravelEdges', gate: (has) => has('php'), run: (_q, c, y) => laravelEventEdges(c, y) },
3782
+ {
3783
+ name: 'cFnPtrEdges',
3784
+ gate: (has) => has('c', 'cpp'),
3785
+ run: (q, c, y, sub) => (0, c_fnptr_synthesizer_1.cFnPointerDispatchEdges)(q, c, y, sub),
3786
+ },
3787
+ { name: 'goframeEdges', gate: (has) => has('go'), run: (_q, c, y) => (0, goframe_synthesizer_1.goframeRouteEdges)(c, y) },
3788
+ { name: 'nixOptionEdges', gate: (has) => has('nix'), run: (q, _c, y) => nixOptionPathEdges(q, y) },
3789
+ ];
3790
+ /** Fixed non-registry steps: goMethodContains, goImplements, dedupe-merge, insertMergedEdges. */
3791
+ const FIXED_SYNTH_STEPS = 4;
3792
+ exports.SYNTH_PROGRESS_STEPS = exports.SYNTH_PASSES.length + FIXED_SYNTH_STEPS;
3793
+ async function synthesizeCallbackEdges(queries, ctx, onProgress,
3794
+ // A live resolver pool to fan the independent passes across (structural type
3795
+ // so this file never imports the pool — resolver-worker imports THIS file).
3796
+ // Null/omitted → the sequential path, byte-identical to the pool path.
3797
+ pool) {
3798
+ // Each sub-pass below is a whole-graph scan, and there are ~30 of them, all
3799
+ // running synchronously on the indexer's main thread. Their AGGREGATE can run
3800
+ // for well over a minute on a large repo — long enough for the #850 liveness
3801
+ // watchdog to SIGKILL the process mid-index (#1091), since its heartbeat lives
3802
+ // on this same thread. Yield between passes so the heartbeat can fire; a pass
3803
+ // that itself hangs (a real wedge) never reaches the next yield, so the
3804
+ // watchdog still catches that. See ./cooperative-yield.
3805
+ const yieldToLoop = (0, cooperative_yield_1.createYielder)();
3806
+ // Synthesis runs AFTER the resolution progress bar reaches 100%, so without
3807
+ // its own progress the UI freezes at "Resolving refs 100%" for the whole
3808
+ // tail — long enough on big repos that users conclude the index hung and
3809
+ // kill it. Report each completed pass; the caller surfaces it as its own
3810
+ // progress phase. Emit 0/total up front so the phase flips immediately.
3811
+ // Emissions are throttled to whole-percent movement (each consumes a UI
3812
+ // message); values may be fractional steps from within-pass reporting.
3813
+ let passesDone = 0;
3814
+ let lastPct = -1;
3815
+ const emit = (value) => {
3816
+ if (!onProgress)
3817
+ return;
3818
+ const v = Math.min(value, exports.SYNTH_PROGRESS_STEPS);
3819
+ const pct = Math.floor((v / exports.SYNTH_PROGRESS_STEPS) * 100);
3820
+ if (pct === lastPct)
3821
+ return;
3822
+ lastPct = pct;
3823
+ onProgress(v, exports.SYNTH_PROGRESS_STEPS);
3824
+ };
3825
+ // A single long pass otherwise parks the bar between steps; a pass that
3826
+ // takes this callback reports a 0..1 fraction of its own work, surfaced
3827
+ // here as fractional progress within its step.
3828
+ const subProgress = (fraction) => emit(passesDone + Math.max(0, Math.min(fraction, 1)));
3829
+ emit(0);
3830
+ // Per-pass wall-clock timing to stderr, opt-in via CODEGRAPH_SYNTH_TIMINGS
3831
+ // (=1: passes over 250ms; =all: every pass). This is the diagnostic that
3832
+ // located both the #1091/#1122 watchdog stalls and the #1212 OOM — keep it.
3833
+ const markT = { t: Date.now() };
3834
+ const __mark = (label) => {
3835
+ const now = Date.now();
3836
+ const dt = now - markT.t;
3837
+ markT.t = now;
3838
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS && (dt > 250 || process.env.CODEGRAPH_SYNTH_TIMINGS === 'all')) {
3839
+ console.error(`[synth-timing] ${label}: ${dt}ms`);
3840
+ }
3841
+ passesDone++;
3842
+ emit(passesDone);
3843
+ };
3844
+ // Language gating: one indexed DISTINCT over the files table lets a pass
3845
+ // whose own filters reference a specific language/extension be skipped
3846
+ // outright when the project has no such files — its result is provably
3847
+ // empty, so skipping is behavior-identical and the cost drops to zero
3848
+ // (the Kotlin pass was the OOM culprit on the pure-C Linux kernel, #1212).
3849
+ // Passes without an explicit language filter always run.
3850
+ const langs = queries.getDistinctFileLanguages();
3851
+ const has = (...ls) => ls.some((l) => langs.has(l));
3852
+ const NONE = [];
3853
+ // Cross-file Go method→type `contains` edges must be synthesized AND persisted
3854
+ // FIRST: a method declared in a different file from its receiver type is
3855
+ // otherwise orphaned from the struct, and goImplementsEdges (next) derives a
3856
+ // struct's method set from its `contains` edges — so without this it would
3857
+ // under-count the interfaces a cross-file struct satisfies. (#583)
3858
+ const goMethodContains = has('go') ? await goCrossFileMethodContainsEdges(queries, yieldToLoop) : NONE;
3859
+ for (let i = 0; i < goMethodContains.length; i += 2000) {
3860
+ queries.insertEdges(goMethodContains.slice(i, i + 2000));
3861
+ await yieldToLoop();
3862
+ }
3863
+ await yieldToLoop();
3864
+ __mark('goMethodContains');
3865
+ // Go implicit `implements` edges must be synthesized AND persisted next: the
3866
+ // interface-dispatch bridge below reads `implements` edges from the DB, and
3867
+ // Go has none statically. (Other languages already have static implements
3868
+ // edges from extraction, so they don't need this pre-pass.)
3869
+ const goImpl = has('go') ? await goImplementsEdges(queries, yieldToLoop) : NONE;
3870
+ for (let i = 0; i < goImpl.length; i += 2000) {
3871
+ queries.insertEdges(goImpl.slice(i, i + 2000));
3872
+ await yieldToLoop();
3873
+ }
3874
+ await yieldToLoop();
3875
+ __mark('goImplements');
3876
+ // Run the independent passes (see SYNTH_PASSES). Their results are merged in
3877
+ // REGISTRY ORDER below regardless of execution order, and none of their edges
3878
+ // persist until that merge — so every pass sees the same committed
3879
+ // post-resolution DB state whether it runs sequentially here or on a resolver
3880
+ // pool worker. With a live pool (already booted on ≥150k-ref repos), passes
3881
+ // fan out across its read-only workers and the per-pass wall-clock comes from
3882
+ // the worker; a pass that fails on a worker falls back to running on the main
3883
+ // thread, so a worker crash isolates to a retry instead of failing synthesis.
3884
+ const passEdges = new Array(exports.SYNTH_PASSES.length).fill(NONE);
3885
+ const markPass = (label, dt) => {
3886
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS && (dt > 250 || process.env.CODEGRAPH_SYNTH_TIMINGS === 'all')) {
3887
+ console.error(`[synth-timing] ${label}: ${dt}ms`);
3888
+ }
3889
+ passesDone++;
3890
+ emit(passesDone);
3891
+ };
3892
+ const runPassOnMain = async (i) => {
3893
+ const pass = exports.SYNTH_PASSES[i];
3894
+ const t0 = Date.now();
3895
+ passEdges[i] = await pass.run(queries, ctx, yieldToLoop, subProgress);
3896
+ await yieldToLoop();
3897
+ markPass(pass.name, Date.now() - t0);
3898
+ };
3899
+ const gatedIn = [];
3900
+ for (let i = 0; i < exports.SYNTH_PASSES.length; i++) {
3901
+ if (exports.SYNTH_PASSES[i].gate(has))
3902
+ gatedIn.push(i);
3903
+ else
3904
+ markPass(exports.SYNTH_PASSES[i].name, 0);
3905
+ }
3906
+ // Above this node count, a pass that OOM-killed its worker must NOT be
3907
+ // retried on the main thread — the retry would OOM the whole process and
3908
+ // take the index with it (the #1212 failure class). Below it, a worker
3909
+ // failure is more likely a transient crash than a memory ceiling, and the
3910
+ // main-thread retry keeps coverage. Skipping loses only that pass's
3911
+ // synthesized edges; the index still completes.
3912
+ const MAIN_RETRY_MAX_NODES = 1_500_000;
3913
+ const graphNodes = queries.getNodeAndEdgeCount().nodes;
3914
+ if (pool && gatedIn.length > 1) {
3915
+ await Promise.all(gatedIn.map(async (i) => {
3916
+ const pass = exports.SYNTH_PASSES[i];
3917
+ try {
3918
+ const out = await pool.runSynthPass(pass.name);
3919
+ passEdges[i] = out.edges;
3920
+ markPass(pass.name, out.ms);
3921
+ }
3922
+ catch (err) {
3923
+ if (graphNodes > MAIN_RETRY_MAX_NODES) {
3924
+ // Worker died at a scale where the main-thread retry is a process
3925
+ // OOM risk: skip the pass, keep the index alive, and say so.
3926
+ console.error(`[synthesis] pass '${pass.name}' failed on a worker at ${graphNodes} nodes — skipped (edges from this pass are absent): ${err instanceof Error ? err.message : String(err)}`);
3927
+ markPass(`${pass.name} (skipped at scale)`, 0);
3928
+ return;
3929
+ }
3930
+ // Worker-side failure (crash, OOM, unknown pass after a version
3931
+ // mismatch): retry this one pass on the main thread.
3932
+ await runPassOnMain(i);
3933
+ }
3934
+ }));
3935
+ }
3936
+ else {
3937
+ for (const i of gatedIn) {
3938
+ await runPassOnMain(i);
3939
+ }
3940
+ }
3941
+ const merged = [];
3942
+ const seen = new Set();
3943
+ for (const e of passEdges.flat()) {
3944
+ const key = `${e.source}>${e.target}`;
3945
+ if (seen.has(key))
3946
+ continue;
3947
+ seen.add(key);
3948
+ merged.push(e);
3949
+ }
3950
+ __mark('dedupe-merge');
3951
+ // Chunked insert with yields: on the Linux kernel the merged synthesized
3952
+ // edge set is ~275k rows, and one transaction for all of them was a 20s
3953
+ // unyielded main-thread span (#1212 follow-up) — the last one in the tail.
3954
+ for (let i = 0; i < merged.length; i += 2000) {
3955
+ queries.insertEdges(merged.slice(i, i + 2000));
3956
+ await yieldToLoop();
3957
+ }
3958
+ __mark('insertMergedEdges');
3959
+ return merged.length + goImpl.length + goMethodContains.length;
3960
+ }
3961
+ //# sourceMappingURL=callback-synthesizer.js.map