scip-query 0.23.0 → 0.26.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 (650) hide show
  1. package/CHANGELOG.md +491 -2
  2. package/README.md +111 -122
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/by-kind-PRVFAGTQ.js +2 -0
  5. package/dist/call-graph-DVPAQV2F.js +2 -0
  6. package/dist/call-graph-evidence-CUtj8V2I.d.ts +19 -0
  7. package/dist/chunk-2FSBGL5P.js +2 -0
  8. package/dist/chunk-2HLAFUCY.js +2 -0
  9. package/dist/chunk-2IWUT6CJ.js +3 -0
  10. package/dist/chunk-2KNN7GTQ.js +2 -0
  11. package/dist/chunk-2LHXRE2B.js +8 -0
  12. package/dist/{chunk-EG2CPZMJ.js → chunk-2YXE77TJ.js} +2 -2
  13. package/dist/chunk-36SGVCGX.js +2 -0
  14. package/dist/chunk-3ABBFPTP.js +2 -0
  15. package/dist/chunk-3IVFU4FD.js +3 -0
  16. package/dist/chunk-3JIQS44J.js +7 -0
  17. package/dist/chunk-3ZRB6DNK.js +7 -0
  18. package/dist/{chunk-6YTSKJJ3.js → chunk-42EOW5VI.js} +1 -1
  19. package/dist/{chunk-6I6L7Z62.js → chunk-4BHGBMNO.js} +2 -2
  20. package/dist/chunk-4BP3UBDG.js +2 -0
  21. package/dist/chunk-4D6RO7G4.js +2 -0
  22. package/dist/chunk-4FEWQ6RH.js +2 -0
  23. package/dist/chunk-4IGEOBG7.js +2 -0
  24. package/dist/chunk-4QZXBUKC.js +2 -0
  25. package/dist/chunk-4WBDEVX2.js +4 -0
  26. package/dist/chunk-4WCUBZU3.js +8 -0
  27. package/dist/chunk-4WTUBQ36.js +40 -0
  28. package/dist/chunk-4XQ4O6IM.js +3 -0
  29. package/dist/chunk-55UQAMZO.js +4 -0
  30. package/dist/chunk-5D2LVK7O.js +125 -0
  31. package/dist/chunk-5IYJ56TT.js +2 -0
  32. package/dist/chunk-5PLMJC7Q.js +2 -0
  33. package/dist/chunk-5TNQJUR2.js +5 -0
  34. package/dist/chunk-62BDNPMI.js +2 -0
  35. package/dist/chunk-64DZ5TXR.js +7 -0
  36. package/dist/chunk-65245JCM.js +2 -0
  37. package/dist/chunk-6FFVZZL4.js +2 -0
  38. package/dist/chunk-6KO5JHAR.js +2 -0
  39. package/dist/chunk-6LRXOOSX.js +2 -0
  40. package/dist/chunk-6LSEIIF7.js +2 -0
  41. package/dist/chunk-6YMNWD3H.js +6 -0
  42. package/dist/chunk-72AD6ZRR.js +5 -0
  43. package/dist/chunk-73AAKPUC.js +4 -0
  44. package/dist/chunk-76CZ77DF.js +2 -0
  45. package/dist/chunk-7VPEEAAG.js +2 -0
  46. package/dist/chunk-7WTPQ4NX.js +14 -0
  47. package/dist/chunk-7Y5T6XDP.js +2 -0
  48. package/dist/chunk-A2IIGFMJ.js +5 -0
  49. package/dist/chunk-AB5KCTEV.js +2 -0
  50. package/dist/chunk-AC566WBP.js +6 -0
  51. package/dist/chunk-AGWFSTXC.js +3 -0
  52. package/dist/chunk-AOSIYPTA.js +2 -0
  53. package/dist/chunk-AUVEWPIF.js +2 -0
  54. package/dist/chunk-B56T42J3.js +25 -0
  55. package/dist/chunk-BIQEF5NE.js +2 -0
  56. package/dist/chunk-BL6XJKTA.js +3 -0
  57. package/dist/chunk-BMKOQJRI.js +2 -0
  58. package/dist/chunk-BOZ4EXBB.js +3 -0
  59. package/dist/chunk-BUTWYEPH.js +2 -0
  60. package/dist/chunk-BZB4QPIP.js +2 -0
  61. package/dist/{chunk-ILTDAWEF.js → chunk-CE357GEE.js} +4 -4
  62. package/dist/chunk-CFN45HFP.js +2 -0
  63. package/dist/chunk-CFYMZFXT.js +368 -0
  64. package/dist/chunk-CN5EH7O3.js +2 -0
  65. package/dist/chunk-D254DNNQ.js +4 -0
  66. package/dist/chunk-D3FDISIC.js +2 -0
  67. package/dist/chunk-D3NX5XIE.js +3 -0
  68. package/dist/chunk-DA7RPPDF.js +3 -0
  69. package/dist/chunk-DDMC3FON.js +3 -0
  70. package/dist/chunk-DIO3FUSG.js +2 -0
  71. package/dist/chunk-DJ2NNSUK.js +3 -0
  72. package/dist/chunk-DKYQIM3C.js +18 -0
  73. package/dist/{chunk-JTQVMR42.js → chunk-DOOEL2IV.js} +2 -2
  74. package/dist/chunk-DVFP6PZI.js +2 -0
  75. package/dist/chunk-E3FDPXZK.js +2 -0
  76. package/dist/chunk-E7YNJLCB.js +2 -0
  77. package/dist/chunk-EFGW5JPH.js +2 -0
  78. package/dist/chunk-EJVTR244.js +13 -0
  79. package/dist/chunk-EOV7RTRZ.js +2 -0
  80. package/dist/chunk-ETOIKRHO.js +2 -0
  81. package/dist/chunk-EYK3ZAO2.js +3 -0
  82. package/dist/chunk-F2V2LPET.js +52 -0
  83. package/dist/chunk-F4LUHJTF.js +2 -0
  84. package/dist/chunk-F4PUT6IT.js +2 -0
  85. package/dist/chunk-F56GCXXS.js +5 -0
  86. package/dist/chunk-FC2EVQRM.js +2 -0
  87. package/dist/chunk-FL7NBMHP.js +3 -0
  88. package/dist/chunk-FMRN2TRL.js +3 -0
  89. package/dist/chunk-FVULPZDF.js +20 -0
  90. package/dist/chunk-GCKCF5FL.js +43 -0
  91. package/dist/chunk-GH2PYF46.js +2 -0
  92. package/dist/chunk-GHJAGXIP.js +2 -0
  93. package/dist/{chunk-WIWY3CRX.js → chunk-GMVSHUKZ.js} +2 -2
  94. package/dist/chunk-GS6KDO4R.js +2 -0
  95. package/dist/chunk-GUUBXNN7.js +2 -0
  96. package/dist/chunk-GVWX5T43.js +80 -0
  97. package/dist/chunk-GZKFETP5.js +2 -0
  98. package/dist/chunk-H4EQHO6J.js +9 -0
  99. package/dist/chunk-H73WY2RM.js +2 -0
  100. package/dist/chunk-H75GSPRV.js +60 -0
  101. package/dist/chunk-HDR3AHSV.js +61 -0
  102. package/dist/chunk-HQBSL74Y.js +2 -0
  103. package/dist/chunk-HRRFKWPZ.js +2 -0
  104. package/dist/chunk-HXENDJC6.js +2 -0
  105. package/dist/chunk-IIBAZNSW.js +21 -0
  106. package/dist/chunk-INLMWEUU.js +12 -0
  107. package/dist/chunk-IWQPAF4F.js +2 -0
  108. package/dist/chunk-IZJ6YUKP.js +35 -0
  109. package/dist/chunk-J2TMAIN5.js +60 -0
  110. package/dist/chunk-J5FJMODQ.js +142 -0
  111. package/dist/chunk-J7HZPIO3.js +2 -0
  112. package/dist/chunk-JEVRKFRL.js +2 -0
  113. package/dist/chunk-JFXSGAEB.js +30 -0
  114. package/dist/chunk-JVRTHGFS.js +3 -0
  115. package/dist/chunk-JYWEX7RR.js +360 -0
  116. package/dist/chunk-K3YL22N6.js +2 -0
  117. package/dist/chunk-K4CN7GXK.js +12 -0
  118. package/dist/chunk-K5TBVXU4.js +30 -0
  119. package/dist/chunk-KDDIE2DP.js +9 -0
  120. package/dist/chunk-KHWRRPV4.js +2 -0
  121. package/dist/chunk-KI6NBKDY.js +14 -0
  122. package/dist/chunk-KU3QRSTH.js +2 -0
  123. package/dist/chunk-KZBJWZJB.js +2 -0
  124. package/dist/chunk-L7GFM3NP.js +3 -0
  125. package/dist/chunk-LMO6PK3V.js +35 -0
  126. package/dist/chunk-LN4YXJJU.js +2 -0
  127. package/dist/chunk-LOVIZBJ4.js +43 -0
  128. package/dist/chunk-LPCRK4A2.js +11 -0
  129. package/dist/chunk-MMHZKBFA.js +2 -0
  130. package/dist/{chunk-M2O5NY6W.js → chunk-MOQQBQRD.js} +2 -2
  131. package/dist/chunk-N2WN6I3L.js +2 -0
  132. package/dist/chunk-N3ORQT7L.js +2 -0
  133. package/dist/chunk-NAZ3RAIW.js +2 -0
  134. package/dist/chunk-NDUNO5JQ.js +2 -0
  135. package/dist/chunk-NEIWRNAZ.js +4 -0
  136. package/dist/chunk-NJJMVD65.js +2 -0
  137. package/dist/chunk-NLOQOBXI.js +20 -0
  138. package/dist/chunk-NOLZOVCU.js +2 -0
  139. package/dist/chunk-NOWINRRN.js +2 -0
  140. package/dist/chunk-NZAXKGRL.js +16 -0
  141. package/dist/chunk-O2C4UILI.js +2 -0
  142. package/dist/chunk-O3RHA6ZT.js +3 -0
  143. package/dist/chunk-O4UZSPPI.js +3 -0
  144. package/dist/chunk-OGFV2BUX.js +2 -0
  145. package/dist/chunk-OZCJXZK6.js +499 -0
  146. package/dist/chunk-P6ODM7BY.js +2 -0
  147. package/dist/{chunk-XBGWL66K.js → chunk-PAVGPRHJ.js} +2 -2
  148. package/dist/chunk-PH52RA7D.js +2 -0
  149. package/dist/chunk-PKN354TH.js +3 -0
  150. package/dist/chunk-PWOASWEG.js +11 -0
  151. package/dist/chunk-QIWXRW72.js +2 -0
  152. package/dist/chunk-QJRMOK5N.js +2 -0
  153. package/dist/{chunk-YXPUP5G2.js → chunk-QOIXNWQR.js} +2 -2
  154. package/dist/chunk-QXEUDXBT.js +3 -0
  155. package/dist/chunk-QYUVVBMR.js +6 -0
  156. package/dist/chunk-QZ7KQZRN.js +2 -0
  157. package/dist/chunk-R6LQBUDH.js +2 -0
  158. package/dist/chunk-RBS42E55.js +20 -0
  159. package/dist/chunk-RSJKPCFX.js +26 -0
  160. package/dist/chunk-S6CZA3MV.js +2 -0
  161. package/dist/chunk-STMVAHJP.js +2 -0
  162. package/dist/chunk-SYVPTTVW.js +2 -0
  163. package/dist/chunk-T3I6NHBH.js +2 -0
  164. package/dist/chunk-T6DK3ZP7.js +2 -0
  165. package/dist/chunk-TKD34PHN.js +4 -0
  166. package/dist/chunk-TNNQFH7W.js +2 -0
  167. package/dist/chunk-TNV7SSUF.js +2 -0
  168. package/dist/chunk-TO7ZR3EH.js +8 -0
  169. package/dist/chunk-TOU3CHK4.js +2 -0
  170. package/dist/chunk-TRBI4UKT.js +2 -0
  171. package/dist/chunk-TZCVNCAN.js +4 -0
  172. package/dist/chunk-U4LZA5LL.js +3 -0
  173. package/dist/chunk-U5RIG3JP.js +3 -0
  174. package/dist/chunk-UP5KXN2I.js +2 -0
  175. package/dist/chunk-UQFR3NDH.js +5 -0
  176. package/dist/chunk-UXYXF7GV.js +2 -0
  177. package/dist/chunk-VB3GOKOS.js +2 -0
  178. package/dist/chunk-VF5JZICY.js +2 -0
  179. package/dist/chunk-VTY3VK6E.js +2 -0
  180. package/dist/chunk-VX2O4RIS.js +2 -0
  181. package/dist/chunk-WKPV2TDZ.js +2 -0
  182. package/dist/chunk-WOFQ5DTB.js +2 -0
  183. package/dist/chunk-WS4C6TCK.js +2 -0
  184. package/dist/chunk-WXU3DGPU.js +2 -0
  185. package/dist/chunk-X6RMKHJQ.js +81 -0
  186. package/dist/{chunk-4ILJCCXV.js → chunk-XHMN6ZX7.js} +2 -2
  187. package/dist/chunk-XHTVFLWW.js +2 -0
  188. package/dist/chunk-XKIDJCIK.js +2 -0
  189. package/dist/chunk-XTYTYZPT.js +2 -0
  190. package/dist/chunk-Y2JHHTTA.js +2 -0
  191. package/dist/chunk-YGVRMGYN.js +4 -0
  192. package/dist/chunk-YNQCGEQE.js +2 -0
  193. package/dist/chunk-YOQVEXVE.js +14 -0
  194. package/dist/chunk-YRT2WLYY.js +2 -0
  195. package/dist/chunk-YTAP5Y2G.js +2 -0
  196. package/dist/chunk-YTYWI7VB.js +2 -0
  197. package/dist/chunk-YULZRALL.js +2 -0
  198. package/dist/chunk-Z33WQG4Q.js +2 -0
  199. package/dist/chunk-ZGTYGDMF.js +16 -0
  200. package/dist/chunk-ZHMRSZFD.js +43 -0
  201. package/dist/chunk-ZHSP366W.js +10 -0
  202. package/dist/chunk-ZIBYCYKK.js +7 -0
  203. package/dist/{chunk-GAS2LJMP.js → chunk-ZLADLUE6.js} +3 -3
  204. package/dist/chunk-ZO4YXUT6.js +4 -0
  205. package/dist/{chunk-HYO3NP5Q.js → chunk-ZR4HBC2H.js} +2 -2
  206. package/dist/cli-main.js +6 -6
  207. package/dist/cli.js +1 -1
  208. package/dist/{code-B17qEMbt.d.ts → code-BNyrCF3_.d.ts} +3 -2
  209. package/dist/code-IL5WH3NZ.js +2 -0
  210. package/dist/code-result-json-ANTBEDFP.js +4 -0
  211. package/dist/command-descriptors-HEEMDHTU.js +222 -0
  212. package/dist/deps-EOWFC6FD.js +2 -0
  213. package/dist/direct-navigation-Y5B6OSIQ.js +3 -0
  214. package/dist/{exploration-topology-BG4v30HZ.d.ts → exploration-topology-CSgEyAz-.d.ts} +3 -1
  215. package/dist/files-K4AI3JUM.js +2 -0
  216. package/dist/frontend-profile-roles-D7eCum8P.d.ts +10 -0
  217. package/dist/{health-CPp2Jf1Z.d.ts → health-BtfmNrfa.d.ts} +58 -74
  218. package/dist/hierarchy-6W5NDIFI.js +2 -0
  219. package/dist/imports-WH365QY4.js +2 -0
  220. package/dist/index.d.ts +13 -1
  221. package/dist/index.js +1 -1
  222. package/dist/members-K3PHMF5S.js +2 -0
  223. package/dist/methods-E7KVMBX4.js +2 -0
  224. package/dist/output-continuation-command-BJSY67SN.js +3 -0
  225. package/dist/output-pagination-UZJ5ACIX.js +24 -0
  226. package/dist/postinstall.js +1 -1
  227. package/dist/project-reindex-EP24WT4X.js +3 -0
  228. package/dist/queries/affected.js +1 -1
  229. package/dist/queries/architecture.d.ts +15 -4
  230. package/dist/queries/architecture.js +1 -1
  231. package/dist/queries/bottlenecks.js +1 -1
  232. package/dist/queries/by-kind.js +1 -1
  233. package/dist/queries/call-graph.d.ts +3 -1
  234. package/dist/queries/call-graph.js +1 -1
  235. package/dist/queries/change-surface.d.ts +1 -0
  236. package/dist/queries/change-surface.js +1 -1
  237. package/dist/queries/cleanup-plan.d.ts +3 -3
  238. package/dist/queries/cleanup-plan.js +1 -1
  239. package/dist/queries/co-change.d.ts +20 -2
  240. package/dist/queries/co-change.js +1 -1
  241. package/dist/queries/code.d.ts +1 -1
  242. package/dist/queries/code.js +1 -1
  243. package/dist/queries/complexity.d.ts +6 -3
  244. package/dist/queries/complexity.js +1 -1
  245. package/dist/queries/context.d.ts +1 -7
  246. package/dist/queries/context.js +1 -1
  247. package/dist/queries/coupling.js +1 -1
  248. package/dist/queries/cycles.js +1 -1
  249. package/dist/queries/dead.d.ts +2 -0
  250. package/dist/queries/dead.js +1 -1
  251. package/dist/queries/decorative-checkers.js +1 -1
  252. package/dist/queries/dependence-slice.d.ts +46 -22
  253. package/dist/queries/dependence-slice.js +1 -1
  254. package/dist/queries/dependency-depth.d.ts +1 -7
  255. package/dist/queries/dependency-depth.js +1 -1
  256. package/dist/queries/deps.js +1 -1
  257. package/dist/queries/diff-impact.d.ts +3 -1
  258. package/dist/queries/diff-impact.js +1 -1
  259. package/dist/queries/doc-drift.js +1 -1
  260. package/dist/queries/drift.d.ts +1 -1
  261. package/dist/queries/drift.js +1 -1
  262. package/dist/queries/duplicate-bodies.d.ts +29 -2
  263. package/dist/queries/duplicate-bodies.js +1 -1
  264. package/dist/queries/entry-map.d.ts +2 -4
  265. package/dist/queries/entry-map.js +1 -1
  266. package/dist/queries/evidence.d.ts +121 -61
  267. package/dist/queries/evidence.js +1 -1
  268. package/dist/queries/fan.js +1 -1
  269. package/dist/queries/files.js +1 -1
  270. package/dist/queries/health.d.ts +1 -1
  271. package/dist/queries/health.js +1 -1
  272. package/dist/queries/hierarchy.d.ts +2 -2
  273. package/dist/queries/hierarchy.js +1 -1
  274. package/dist/queries/hotspots.d.ts +1 -1
  275. package/dist/queries/hotspots.js +1 -1
  276. package/dist/queries/imports.d.ts +1 -0
  277. package/dist/queries/imports.js +1 -1
  278. package/dist/queries/incomplete-migration.d.ts +3 -3
  279. package/dist/queries/incomplete-migration.js +1 -1
  280. package/dist/queries/index.d.ts +17 -65
  281. package/dist/queries/index.js +1 -1
  282. package/dist/queries/locality-candidates.d.ts +4 -4
  283. package/dist/queries/locality-candidates.js +1 -1
  284. package/dist/queries/members.d.ts +2 -2
  285. package/dist/queries/members.js +1 -1
  286. package/dist/queries/methods.js +1 -1
  287. package/dist/queries/not-implemented.d.ts +2 -6
  288. package/dist/queries/not-implemented.js +1 -1
  289. package/dist/queries/outline.js +1 -1
  290. package/dist/queries/passthrough-candidates.d.ts +9 -1
  291. package/dist/queries/passthrough-candidates.js +1 -1
  292. package/dist/queries/react-component-duplicates.d.ts +19 -3
  293. package/dist/queries/react-component-duplicates.js +1 -1
  294. package/dist/queries/react-hook-candidates.d.ts +22 -3
  295. package/dist/queries/react-hook-candidates.js +1 -1
  296. package/dist/queries/react-large-component-pressure.d.ts +17 -3
  297. package/dist/queries/react-large-component-pressure.js +1 -1
  298. package/dist/queries/recent-duplicates.js +1 -1
  299. package/dist/queries/redundant-reexports.d.ts +4 -14
  300. package/dist/queries/redundant-reexports.js +1 -1
  301. package/dist/queries/refs.d.ts +4 -1
  302. package/dist/queries/refs.js +1 -1
  303. package/dist/queries/review.d.ts +188 -0
  304. package/dist/queries/review.js +2 -0
  305. package/dist/queries/similar-files.d.ts +7 -10
  306. package/dist/queries/similar-files.js +1 -1
  307. package/dist/queries/similar-signatures.js +1 -1
  308. package/dist/queries/similar.d.ts +19 -1
  309. package/dist/queries/similar.js +1 -1
  310. package/dist/queries/slice-cohesion.d.ts +205 -0
  311. package/dist/queries/slice-cohesion.js +2 -0
  312. package/dist/queries/source-inspection.d.ts +6 -202
  313. package/dist/queries/source-inspection.js +1 -1
  314. package/dist/queries/source-search.d.ts +2 -3
  315. package/dist/queries/source-search.js +1 -1
  316. package/dist/queries/stats.d.ts +1 -0
  317. package/dist/queries/stats.js +1 -1
  318. package/dist/queries/surface.js +1 -1
  319. package/dist/queries/symbols.js +1 -1
  320. package/dist/queries/system.d.ts +4 -2
  321. package/dist/queries/system.js +1 -1
  322. package/dist/queries/test-quality.d.ts +1 -1
  323. package/dist/queries/test-quality.js +1 -1
  324. package/dist/queries/twin-drift.d.ts +23 -7
  325. package/dist/queries/twin-drift.js +1 -1
  326. package/dist/queries/unused-imports.js +1 -1
  327. package/dist/queries/unused-params.d.ts +3 -15
  328. package/dist/queries/unused-params.js +1 -1
  329. package/dist/queries/vue-component-duplicates.js +1 -1
  330. package/dist/queries/vue-composable-candidates.js +1 -1
  331. package/dist/queries/vue-large-view-pressure.js +1 -1
  332. package/dist/query-service-fastpath.js +5 -5
  333. package/dist/query-service-server.js +4 -4
  334. package/dist/refs-CCBJG7WK.js +2 -0
  335. package/dist/refs-pagination-DRNLVU4S.js +2 -0
  336. package/dist/reindex-worker.js +79 -29
  337. package/dist/reindex.js +45 -45
  338. package/dist/repository-cache-worker.js +2 -0
  339. package/dist/runtime.d.ts +8 -8
  340. package/dist/runtime.js +3 -4
  341. package/dist/rust-semantic-session-server.js +1 -1
  342. package/dist/rust-semantic-session-worker.js +1 -1
  343. package/dist/rust-semantic-worker.js +1 -1
  344. package/dist/service-queries-2WAJI7R6.js +6 -0
  345. package/dist/source-inspection-91U9zdO3.d.ts +341 -0
  346. package/dist/{source-search-types-Dwz8KeuW.d.ts → source-search-types-DWGYNg8M.d.ts} +15 -2
  347. package/dist/stats-G7DIV6VU.js +2 -0
  348. package/dist/surface-IO55UALI.js +2 -0
  349. package/dist/system-ZBMSHJXU.js +2 -0
  350. package/dist/{queries/trace.d.ts → trace-BMjw3prn.d.ts} +1 -18
  351. package/dist/typescript-indexer.js +2 -0
  352. package/dist/typescript-mailbox-worker.js +1 -1
  353. package/dist/watch-server.js +3 -3
  354. package/docs/AGENT_GUIDE.md +19 -128
  355. package/docs/CLI_JSON_OUTPUT.md +21 -17
  356. package/docs/COMMAND_REFERENCE.md +34 -49
  357. package/docs/CURRENT_COMMANDS.md +123 -0
  358. package/docs/DETECTOR_EVIDENCE_CONTRACTS.md +0 -40
  359. package/docs/DETECTOR_GUIDE.md +55 -12
  360. package/docs/PRODUCT_VISION.md +135 -0
  361. package/docs/PROPERTY_TESTING.md +73 -0
  362. package/docs/REVIEW.md +76 -0
  363. package/docs/SKILLS.md +51 -0
  364. package/docs/WINDOWS_SIDECAR_RELEASE.md +12 -3
  365. package/docs/accuracy-audit-checklist.md +70 -13
  366. package/docs/analyzer-inventory.md +2 -2
  367. package/docs/locality-analyzer-design.md +9 -9
  368. package/package.json +18 -80
  369. package/scripts/evidence-product-contract.mjs +7 -3
  370. package/scripts/record-review-coverage.mjs +118 -0
  371. package/scripts/scip-windows-provenance.mjs +29 -19
  372. package/skills/scip-architecture-review/SKILL.md +57 -0
  373. package/skills/scip-architecture-review/agents/openai.yaml +4 -0
  374. package/skills/scip-architecture-review/references/design-checks.md +17 -0
  375. package/skills/scip-explore/SKILL.md +15 -59
  376. package/skills/scip-explore/agents/openai.yaml +3 -3
  377. package/skills/scip-explore/references/external-evidence.md +2 -2
  378. package/skills/scip-explore/references/information-model.md +26 -29
  379. package/skills/scip-explore/scripts/capture-evidence.mjs +68 -34
  380. package/skills/scip-integrity-audit/SKILL.md +53 -181
  381. package/skills/scip-integrity-audit/agents/openai.yaml +3 -3
  382. package/skills/scip-integrity-audit/references/integrity-probes.md +27 -0
  383. package/skills/scip-plan/SKILL.md +39 -65
  384. package/skills/scip-plan/agents/openai.yaml +2 -2
  385. package/skills/scip-query/SKILL.md +28 -81
  386. package/skills/scip-query/agents/openai.yaml +2 -2
  387. package/skills/scip-query/references/command-guide.md +169 -0
  388. package/skills/scip-setup/SKILL.md +4 -2
  389. package/skills/scip-setup/agents/openai.yaml +3 -3
  390. package/dist/by-kind-XI2CSWEY.js +0 -2
  391. package/dist/call-graph-UONR6JR5.js +0 -2
  392. package/dist/call-graph-evidence-lZa2dwQA.d.ts +0 -11
  393. package/dist/chunk-26CT72HM.js +0 -2
  394. package/dist/chunk-2E7CX53V.js +0 -2
  395. package/dist/chunk-2GRUZAQF.js +0 -43
  396. package/dist/chunk-2LDBDR6J.js +0 -29
  397. package/dist/chunk-2OOY75BW.js +0 -2
  398. package/dist/chunk-2R3V3PSD.js +0 -4
  399. package/dist/chunk-2WC2OEDO.js +0 -4
  400. package/dist/chunk-35NLDRZC.js +0 -2
  401. package/dist/chunk-3AF4TUFK.js +0 -3
  402. package/dist/chunk-3D3QG236.js +0 -2
  403. package/dist/chunk-3FHOF22C.js +0 -21
  404. package/dist/chunk-3JKSW6LJ.js +0 -2
  405. package/dist/chunk-3L2ZBPEX.js +0 -133
  406. package/dist/chunk-3PJABJSU.js +0 -2
  407. package/dist/chunk-3SVF22I5.js +0 -2
  408. package/dist/chunk-3WR4E3A3.js +0 -3
  409. package/dist/chunk-4FTZ4P5G.js +0 -2
  410. package/dist/chunk-4UX2F3JX.js +0 -2
  411. package/dist/chunk-4WNW27SX.js +0 -2
  412. package/dist/chunk-5ENOG4VP.js +0 -61
  413. package/dist/chunk-64BFSI5I.js +0 -2
  414. package/dist/chunk-66DVSJQG.js +0 -455
  415. package/dist/chunk-6HFCYNYE.js +0 -9
  416. package/dist/chunk-6PQNKL3G.js +0 -3
  417. package/dist/chunk-6V5CNXL6.js +0 -2
  418. package/dist/chunk-6VVV4WRR.js +0 -4
  419. package/dist/chunk-7BWFZPPZ.js +0 -2
  420. package/dist/chunk-7CYG22FH.js +0 -2
  421. package/dist/chunk-7F45LJKI.js +0 -2
  422. package/dist/chunk-7IWV2EG3.js +0 -3
  423. package/dist/chunk-7KCZELVM.js +0 -2
  424. package/dist/chunk-AFHTBORT.js +0 -2
  425. package/dist/chunk-AVRYW5OZ.js +0 -2
  426. package/dist/chunk-B3X6KU75.js +0 -2
  427. package/dist/chunk-B5D7QPBE.js +0 -4
  428. package/dist/chunk-BBCIS4DX.js +0 -16
  429. package/dist/chunk-BDUVI7TO.js +0 -3
  430. package/dist/chunk-BE7ZZTMC.js +0 -2
  431. package/dist/chunk-BHVUJOCQ.js +0 -3
  432. package/dist/chunk-BJT7LSPK.js +0 -3
  433. package/dist/chunk-BKVWUP7Y.js +0 -2
  434. package/dist/chunk-BQGB4HBD.js +0 -2
  435. package/dist/chunk-BRV7PIFF.js +0 -2
  436. package/dist/chunk-CEEZJXEF.js +0 -2
  437. package/dist/chunk-CIYLO6SI.js +0 -7
  438. package/dist/chunk-CJZXN4NU.js +0 -2
  439. package/dist/chunk-CNO7TOKL.js +0 -2
  440. package/dist/chunk-COF23M5F.js +0 -2
  441. package/dist/chunk-CWFP7GM5.js +0 -2
  442. package/dist/chunk-D2DHWI3D.js +0 -2
  443. package/dist/chunk-D4N5SQ2M.js +0 -4
  444. package/dist/chunk-DBRSYFXR.js +0 -2
  445. package/dist/chunk-DHUIOLDT.js +0 -2
  446. package/dist/chunk-DIRJWYBM.js +0 -6
  447. package/dist/chunk-DIUFNHRJ.js +0 -35
  448. package/dist/chunk-DRENNWRG.js +0 -2
  449. package/dist/chunk-DTZCKZEU.js +0 -4
  450. package/dist/chunk-DULC3QFP.js +0 -5
  451. package/dist/chunk-DYGHBZ2N.js +0 -16
  452. package/dist/chunk-E5R6AQ73.js +0 -40
  453. package/dist/chunk-E73UNJTF.js +0 -38
  454. package/dist/chunk-EKV5HX33.js +0 -2
  455. package/dist/chunk-EQHFIL6T.js +0 -3
  456. package/dist/chunk-ESIQ66Z7.js +0 -2
  457. package/dist/chunk-EVFUMY4R.js +0 -3
  458. package/dist/chunk-F7DY272B.js +0 -2
  459. package/dist/chunk-FBN2FGXG.js +0 -2
  460. package/dist/chunk-FDLOBR6P.js +0 -4
  461. package/dist/chunk-FESCRNVV.js +0 -5
  462. package/dist/chunk-FFRKR4EQ.js +0 -2
  463. package/dist/chunk-FGA2U4OR.js +0 -8
  464. package/dist/chunk-FIQRSHVM.js +0 -2
  465. package/dist/chunk-FPYLNQPT.js +0 -2
  466. package/dist/chunk-FRUSVINH.js +0 -2
  467. package/dist/chunk-GSP44ENC.js +0 -2
  468. package/dist/chunk-GUFSG5TX.js +0 -2
  469. package/dist/chunk-GYIZ4NXB.js +0 -2
  470. package/dist/chunk-GZIUDL6G.js +0 -2
  471. package/dist/chunk-H5EXS3HM.js +0 -2
  472. package/dist/chunk-HCXEQRFF.js +0 -18
  473. package/dist/chunk-HEHOQQKH.js +0 -2
  474. package/dist/chunk-HKGFPJ4T.js +0 -4
  475. package/dist/chunk-HLZTEXRA.js +0 -2
  476. package/dist/chunk-HOENASQM.js +0 -3
  477. package/dist/chunk-HVF5VBG6.js +0 -2
  478. package/dist/chunk-I55I7XXP.js +0 -2
  479. package/dist/chunk-IDFEUFKS.js +0 -2
  480. package/dist/chunk-IHGQTTVW.js +0 -2
  481. package/dist/chunk-IICPE7B2.js +0 -20
  482. package/dist/chunk-IL676XCC.js +0 -18
  483. package/dist/chunk-IW5XQG5G.js +0 -2
  484. package/dist/chunk-IZDPJ2QI.js +0 -2
  485. package/dist/chunk-J66VOFW6.js +0 -5
  486. package/dist/chunk-JFMEXGFE.js +0 -2
  487. package/dist/chunk-JGKUET5J.js +0 -3
  488. package/dist/chunk-JS4PGXMV.js +0 -3
  489. package/dist/chunk-JWTGMPIT.js +0 -80
  490. package/dist/chunk-JYR66JN5.js +0 -5
  491. package/dist/chunk-KFOYCQAJ.js +0 -9
  492. package/dist/chunk-KLFEXGQA.js +0 -2
  493. package/dist/chunk-KMVGRIO2.js +0 -2
  494. package/dist/chunk-KYSDI3GE.js +0 -5
  495. package/dist/chunk-L6PJPETJ.js +0 -29
  496. package/dist/chunk-LDVT66YM.js +0 -2
  497. package/dist/chunk-LEECKFCJ.js +0 -2
  498. package/dist/chunk-LMZ5PRUV.js +0 -2
  499. package/dist/chunk-LQRQN2XA.js +0 -2
  500. package/dist/chunk-LXABEJX3.js +0 -2
  501. package/dist/chunk-MNV5FSBW.js +0 -3
  502. package/dist/chunk-MPQ4OTBM.js +0 -2
  503. package/dist/chunk-MTDBHTSF.js +0 -2
  504. package/dist/chunk-MV3CDXPI.js +0 -38
  505. package/dist/chunk-MWN53KRN.js +0 -60
  506. package/dist/chunk-MXNGIEPU.js +0 -3
  507. package/dist/chunk-N2ZSIIGR.js +0 -117
  508. package/dist/chunk-N5B2NILC.js +0 -5
  509. package/dist/chunk-NJITK2GP.js +0 -2
  510. package/dist/chunk-NOGJXYFO.js +0 -2
  511. package/dist/chunk-NOYBFVJA.js +0 -554
  512. package/dist/chunk-NWQXSFFU.js +0 -3
  513. package/dist/chunk-ODDUPDP7.js +0 -13
  514. package/dist/chunk-OLIWTZI3.js +0 -3
  515. package/dist/chunk-OLNV6I6U.js +0 -2
  516. package/dist/chunk-OR2E3AGZ.js +0 -2
  517. package/dist/chunk-OSR2GEHQ.js +0 -2
  518. package/dist/chunk-OSSESPDX.js +0 -3
  519. package/dist/chunk-OWOOWNJ5.js +0 -7
  520. package/dist/chunk-P42EIXTA.js +0 -2
  521. package/dist/chunk-PJFGPYTU.js +0 -2
  522. package/dist/chunk-PP7KNN7L.js +0 -2
  523. package/dist/chunk-PU7T5QYQ.js +0 -2
  524. package/dist/chunk-PWWAJSKV.js +0 -74
  525. package/dist/chunk-PZL5T7SU.js +0 -73
  526. package/dist/chunk-QBE3YX64.js +0 -23
  527. package/dist/chunk-QGVTFRY2.js +0 -7
  528. package/dist/chunk-QOJONDS7.js +0 -2
  529. package/dist/chunk-QU5XRYB5.js +0 -4
  530. package/dist/chunk-QUU5OBVK.js +0 -11
  531. package/dist/chunk-RBLQNW26.js +0 -20
  532. package/dist/chunk-RTQ7NEKG.js +0 -81
  533. package/dist/chunk-SQXRS7BG.js +0 -4
  534. package/dist/chunk-SSK6LDPC.js +0 -2
  535. package/dist/chunk-SZHGTCPP.js +0 -7
  536. package/dist/chunk-T4N4P2K5.js +0 -16
  537. package/dist/chunk-TA3QKLLU.js +0 -2
  538. package/dist/chunk-TEBQMNVI.js +0 -43
  539. package/dist/chunk-TPFHAQ2G.js +0 -2
  540. package/dist/chunk-TQPCBMWT.js +0 -5
  541. package/dist/chunk-TQZV7KV4.js +0 -2
  542. package/dist/chunk-TRNAEQ6P.js +0 -3
  543. package/dist/chunk-TY7CRN3Z.js +0 -2
  544. package/dist/chunk-UHFYCMZO.js +0 -35
  545. package/dist/chunk-UICY4GTQ.js +0 -7
  546. package/dist/chunk-UVGEWT4Y.js +0 -26
  547. package/dist/chunk-UXW33INU.js +0 -29
  548. package/dist/chunk-VMPRET3I.js +0 -5
  549. package/dist/chunk-VNLGKHS6.js +0 -6
  550. package/dist/chunk-VQILFTEH.js +0 -2
  551. package/dist/chunk-VUPHCS7Y.js +0 -57
  552. package/dist/chunk-VVZSBTSU.js +0 -23
  553. package/dist/chunk-VZRNID6A.js +0 -2
  554. package/dist/chunk-W5OXRYGE.js +0 -7
  555. package/dist/chunk-W6STWDQI.js +0 -57
  556. package/dist/chunk-W7CXK74K.js +0 -2
  557. package/dist/chunk-WB3WYIRE.js +0 -4
  558. package/dist/chunk-WDNVY4E7.js +0 -20
  559. package/dist/chunk-WK46TNUM.js +0 -3
  560. package/dist/chunk-WNTFFKAX.js +0 -12
  561. package/dist/chunk-WOIKCX6A.js +0 -2
  562. package/dist/chunk-WUN6KBHV.js +0 -2
  563. package/dist/chunk-WYCTJDVR.js +0 -2
  564. package/dist/chunk-WYPL7GF7.js +0 -2
  565. package/dist/chunk-XDAUYDFT.js +0 -2
  566. package/dist/chunk-XDQMU3BT.js +0 -2
  567. package/dist/chunk-XFA4SSO3.js +0 -3
  568. package/dist/chunk-XGZEP6GR.js +0 -8
  569. package/dist/chunk-XPDPNWTQ.js +0 -368
  570. package/dist/chunk-XRYABF57.js +0 -8
  571. package/dist/chunk-YBGKCQIS.js +0 -2
  572. package/dist/chunk-YEN6CYC7.js +0 -16
  573. package/dist/chunk-YF5IB2LF.js +0 -2
  574. package/dist/chunk-YI2AWIHC.js +0 -3
  575. package/dist/chunk-YPWBKGFU.js +0 -2
  576. package/dist/chunk-YPWHBBIS.js +0 -2
  577. package/dist/chunk-YSH6U3L4.js +0 -3
  578. package/dist/chunk-YU5DZUZI.js +0 -10
  579. package/dist/chunk-YWO5DDRC.js +0 -16
  580. package/dist/chunk-Z4CDXYNQ.js +0 -2
  581. package/dist/chunk-ZF5KHH7C.js +0 -2
  582. package/dist/chunk-ZOHS7AQV.js +0 -21
  583. package/dist/chunk-ZTI4SBFV.js +0 -3
  584. package/dist/code-MI6F2TTU.js +0 -2
  585. package/dist/code-result-json-FXALY4HE.js +0 -2
  586. package/dist/command-descriptors-P34VABY5.js +0 -343
  587. package/dist/dataflow-4KEMJPC6.js +0 -2
  588. package/dist/dependence-slice-R7FPWD5M.js +0 -2
  589. package/dist/deps-7EMQUYUT.js +0 -2
  590. package/dist/direct-navigation-6YO234F2.js +0 -3
  591. package/dist/entry-map-KOOLR26E.js +0 -2
  592. package/dist/files-OPIPJIGZ.js +0 -2
  593. package/dist/graph-evidence-Bjyky2V4.d.ts +0 -126
  594. package/dist/hierarchy-QPD2CAER.js +0 -2
  595. package/dist/imports-M6HUXRXC.js +0 -2
  596. package/dist/members-I5MEFOCT.js +0 -2
  597. package/dist/methods-5JYGGHXA.js +0 -2
  598. package/dist/next-anchor-candidates-BwMczMvX.d.ts +0 -90
  599. package/dist/output-continuation-command-UPQAAKBP.js +0 -3
  600. package/dist/output-pagination-3OFL2MJV.js +0 -19
  601. package/dist/project-reindex-UKKQ5PLS.js +0 -3
  602. package/dist/queries/anchors.d.ts +0 -123
  603. package/dist/queries/anchors.js +0 -2
  604. package/dist/queries/complexity-hotspots.d.ts +0 -40
  605. package/dist/queries/complexity-hotspots.js +0 -2
  606. package/dist/queries/convergence.d.ts +0 -33
  607. package/dist/queries/convergence.js +0 -2
  608. package/dist/queries/dataflow.d.ts +0 -77
  609. package/dist/queries/dataflow.js +0 -2
  610. package/dist/queries/deep-chains.d.ts +0 -5
  611. package/dist/queries/deep-chains.js +0 -2
  612. package/dist/queries/extract-candidates.d.ts +0 -52
  613. package/dist/queries/extract-candidates.js +0 -2
  614. package/dist/queries/isolated.d.ts +0 -24
  615. package/dist/queries/isolated.js +0 -2
  616. package/dist/queries/plan-context.d.ts +0 -33
  617. package/dist/queries/plan-context.js +0 -2
  618. package/dist/queries/reference-neighborhood.d.ts +0 -4
  619. package/dist/queries/reference-neighborhood.js +0 -2
  620. package/dist/queries/reference-reachability.d.ts +0 -48
  621. package/dist/queries/reference-reachability.js +0 -2
  622. package/dist/queries/self-audit.d.ts +0 -63
  623. package/dist/queries/self-audit.js +0 -2
  624. package/dist/queries/similar-chains.d.ts +0 -48
  625. package/dist/queries/similar-chains.js +0 -2
  626. package/dist/queries/slice.d.ts +0 -4
  627. package/dist/queries/slice.js +0 -2
  628. package/dist/queries/stale-abstractions.d.ts +0 -72
  629. package/dist/queries/stale-abstractions.js +0 -2
  630. package/dist/queries/system-map.d.ts +0 -449
  631. package/dist/queries/system-map.js +0 -2
  632. package/dist/queries/trace.js +0 -2
  633. package/dist/queries/twin-ab.d.ts +0 -66
  634. package/dist/queries/twin-ab.js +0 -2
  635. package/dist/queries/value-flow.d.ts +0 -43
  636. package/dist/queries/value-flow.js +0 -2
  637. package/dist/queries/wrapper-candidates.d.ts +0 -34
  638. package/dist/queries/wrapper-candidates.js +0 -2
  639. package/dist/refs-PSU4JZZW.js +0 -2
  640. package/dist/refs-pagination-JG6CJMRC.js +0 -2
  641. package/dist/slice-HYRATV64.js +0 -2
  642. package/dist/source-snippet-_wrcgmZc.d.ts +0 -15
  643. package/dist/stats-OOJ74B32.js +0 -2
  644. package/dist/surface-VTGDYWF5.js +0 -2
  645. package/dist/symbol-resolution-WD5EU5JE.js +0 -2
  646. package/dist/system-LRQNFOR2.js +0 -2
  647. package/dist/trace-F4B6OLL4.js +0 -2
  648. package/dist/value-flow-VRPZY72V.js +0 -2
  649. package/skills/concrete-plan/SKILL.md +0 -8
  650. package/skills/concrete-plan/agents/openai.yaml +0 -4
@@ -1,2 +0,0 @@
1
- function N(h){let u=new Map,r=[],d=new Map,t=new Map,i=new Set,a=[],s=0,g=o=>(h.get(o)??[]).values();for(let o of h.keys()){if(d.has(o))continue;let l=[];for(d.set(o,s),t.set(o,s),s+=1,a.push(o),i.add(o),l.push({node:o,iter:g(o),pendingChild:null});l.length>0;){let e=l[l.length-1];if(e.pendingChild!==null){let c=e.pendingChild;e.pendingChild=null,t.set(e.node,Math.min(t.get(e.node),t.get(c)))}let m=e.iter.next();if(m.done){if(t.get(e.node)===d.get(e.node)){let c=[];for(;;){let p=a.pop();if(i.delete(p),c.push(p),u.set(p,r.length),p===e.node)break}r.push(c)}l.pop();continue}let n=m.value;d.has(n)?i.has(n)&&t.set(e.node,Math.min(t.get(e.node),d.get(n))):(d.set(n,s),t.set(n,s),s+=1,a.push(n),i.add(n),e.pendingChild=n,l.push({node:n,iter:g(n),pendingChild:null}))}}return{components:r,componentOf:u}}export{N as a};
2
- //# sourceMappingURL=chunk-35NLDRZC.js.map
@@ -1,3 +0,0 @@
1
- import{a as S}from"./chunk-B3PYOSCX.js";import{a as v,b as f,c as O}from"./chunk-JFMEXGFE.js";import{h as I,n as R,o as p}from"./chunk-7F45LJKI.js";import{randomUUID as N}from"crypto";import{closeSync as _,fsyncSync as T,linkSync as C,mkdirSync as q,openSync as M,statSync as h,unlinkSync as z,writeSync as G}from"fs";import{dirname as b}from"path";var F="scip-query-process-lock",L=1,y=Object.freeze({wallNow:()=>Date.now(),isProcessAlive:S,readProcessIdentity:O,randomToken:()=>N(),makeDirectory:r=>q(r,{recursive:!0}),openFile:(r,e,t)=>M(r,e,t),writeFile:(r,e,t,i)=>G(r,e,t,i),syncFile:r=>T(r),closeFile:r=>_(r),linkFile:(r,e)=>C(r,e),readFile:r=>I(r,"process lock record"),statFile:r=>{let e=h(r);return{dev:e.dev,ino:e.ino,size:e.size,mtimeMs:e.mtimeMs}},removeFile:r=>z(r)});function Z(r,e){let t=e.runtime??y;t.makeDirectory(b(r));let i;for(let o=0;o<2;o+=1)try{return{kind:"acquired",lock:D(r,e,t),...i?{reclaimed:i}:{}}}catch(n){if(n.code!=="EEXIST")throw n;let s=d(r,{parseLegacy:e.parseLegacy,runtime:t});if(o===0&&K(r,s,{creationGraceMs:e.creationGraceMs,parseLegacy:e.parseLegacy,runtime:t})){i=s;continue}return{kind:"contended",observation:s}}return{kind:"contended",observation:d(r,{parseLegacy:e.parseLegacy,runtime:t})}}function d(r,e={}){let t=e.runtime??y,i,o;try{i=t.statFile(r),o=t.readFile(r)}catch(l){return l.code==="ENOENT"?{state:"missing"}:{state:"malformed"}}let n;try{n=JSON.parse(o)}catch{return{state:"malformed",raw:o,identity:i}}let s=J(n);if(s)return{state:"valid",raw:o,identity:i,record:s,owner:j(s),parsed:n};let c=e.parseLegacy?.(n)??null;return c?{state:"legacy",raw:o,identity:i,owner:c,parsed:n}:{state:"malformed",raw:o,identity:i,parsed:n}}function J(r){if(!r||typeof r!="object"||Array.isArray(r))return null;let e=r;if(e.protocol!==F||e.version!==L||typeof e.kind!="string"||e.kind.trim()===""||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0||typeof e.token!="string"||e.token.trim()===""||typeof e.startedAt!="string"||!Number.isFinite(Date.parse(e.startedAt))||e.detail!==void 0&&(typeof e.detail!="object"||e.detail===null||Array.isArray(e.detail)))return null;let t=e.processIdentity===void 0?null:v(e.processIdentity);return e.processIdentity!==void 0&&(!t||t.pid!==e.pid)?null:{protocol:F,version:L,kind:e.kind,pid:e.pid,token:e.token,...t?{processIdentity:t}:{},startedAt:e.startedAt,...e.detail?{detail:e.detail}:{}}}function K(r,e,t={}){let i=t.runtime??y;if(!P(e,i))return!1;let o=$(`${r}.reclaim`,i);if(!o)return!1;try{let n=d(r,{parseLegacy:t.parseLegacy,runtime:i});return!x(e,n)||!P(n,i)?!1:g(r,i)}finally{o.release()}}function D(r,e,t){let i=e.directoryDurability??"durable",o=e.pid??process.pid,n=t.randomToken(),s=e.processIdentity===void 0?t.readProcessIdentity(o):e.processIdentity,c={protocol:F,version:L,kind:e.kind,pid:o,token:n,...s?{processIdentity:s}:{},startedAt:new Date(t.wallNow()).toISOString(),...e.detail?{detail:e.detail}:{}},l=`${r}.${n}.candidate`,k=t.openFile(l,"wx",384),u;try{R(k,Buffer.from(`${JSON.stringify(c)}
2
- `),t,"process lock"),t.syncFile(k)}catch(a){u=a}try{t.closeFile(k)}catch(a){u??=a}if(u!==void 0)throw m(l,t),u;try{t.linkFile(l,r)}catch(a){throw m(l,t),a}if(m(l,t),i==="durable")try{A(b(r),t)}catch(a){throw U(r,c,t),a}let w=!1;return{path:r,record:c,release:()=>w?!1:(w=!0,E(r,c,t,i))}}function U(r,e,t=y){return E(r,e,t,"durable")}function E(r,e,t,i){let o=d(r,{runtime:t});return o.state!=="valid"||!o.record||o.record.pid!==e.pid||o.record.token!==e.token||e.processIdentity&&(!o.record.processIdentity||!f(e.processIdentity,o.record.processIdentity))?!1:g(r,t,i)}function $(r,e){for(let t=0;t<2;t+=1)try{return D(r,{kind:"reclaim-guard",runtime:e},e)}catch(i){if(i.code!=="EEXIST")return null;let o=d(r,{runtime:e});if(t>0||!P(o,e))return null;let n=d(r,{runtime:e});if(!x(o,n)||!g(r,e))return null}return null}function P(r,e){if(r.state==="missing")return!1;if(r.owner){if(!e.isProcessAlive(r.owner.pid))return!0;if(!r.owner.processIdentity)return!1;let t=e.readProcessIdentity(r.owner.pid);return t!==null&&!f(r.owner.processIdentity,t)}return!1}function x(r,e){return r.state===e.state&&r.raw===e.raw&&r.identity!==void 0&&e.identity!==void 0&&r.identity.dev===e.identity.dev&&r.identity.ino===e.identity.ino&&r.identity.size===e.identity.size&&r.identity.mtimeMs===e.identity.mtimeMs}function j(r){return{pid:r.pid,...r.processIdentity?{processIdentity:r.processIdentity}:{}}}function A(r,e){let t;try{t=e.openFile(r,"r")}catch(i){if(p(i,process.platform))return;throw i}try{e.syncFile(t)}catch(i){if(!p(i,process.platform))throw i}finally{e.closeFile(t)}}function g(r,e,t="durable"){try{return e.removeFile(r),t==="durable"&&A(b(r),e),!0}catch{return!1}}function m(r,e){try{e.removeFile(r)}catch{}}export{y as a,Z as b,d as c,K as d};
3
- //# sourceMappingURL=chunk-3AF4TUFK.js.map
@@ -1,2 +0,0 @@
1
- import{a as g}from"./chunk-WUN6KBHV.js";import{c as d}from"./chunk-CJZXN4NU.js";import{b as c}from"./chunk-DYGHBZ2N.js";import{d as p}from"./chunk-N2ZSIIGR.js";import{n as o}from"./chunk-ODDUPDP7.js";import{z as u}from"./chunk-ZOHS7AQV.js";function F(r,a={}){let{scope:l,limit:s=30,scanLimit:b}=a,f=new d(r);return g({candidates:()=>f.productionCallableDefinitions({scope:l,files:a.files,minLoc:2,excludeRootedSymbols:!0,requireFunctionLikeSymbol:!0}),filterCandidate:e=>y(e.relativePath),scanLimit:b,profile:{name:"unused-params"},evaluate:e=>{let n=o(r,e.relativePath)?.callables.find(t=>t.startLine===e.startLine&&t.endLine===e.endLine);if(!n||n.params.length===0||n.params.some(t=>!t.simple)||n.paramsEndLine>=n.endLine)return null;let L=c(r,e.relativePath),m=[];for(let t=n.params.length-1;t>=0;t--){let i=n.params[t];if(i.name===""||i.name.startsWith("_")||h(L.get(i.name),n.paramsEndLine,n.endLine))break;m.unshift(i.name)}return m.length===0?null:{symbol:e.symbol,shortName:p(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,paramCount:n.paramCount,unusedTrailing:m}},orderResults:(e,n)=>n.unusedTrailing.length-e.unusedTrailing.length||e.file.localeCompare(n.file)||e.startLine-n.startLine,limit:s})}function y(r){let a=u(r);return a==="typescript"||a==="tsx"||a==="javascript"}function h(r,a,l){return r?r.some(s=>s>a&&s<=l):!1}export{F as a};
2
- //# sourceMappingURL=chunk-3D3QG236.js.map
@@ -1,21 +0,0 @@
1
- import{a as ye}from"./chunk-3TNRNKAT.js";import{b as ne,c as Xe}from"./chunk-7KCZELVM.js";import{a as Jn}from"./chunk-XBGWL66K.js";import{a as yt,b as ht,c as Yn,d as Ye,e as Yt,f as Me,g as Xt,h as Zt}from"./chunk-B5D7QPBE.js";import{b as Xn,c as Zn,e as bt}from"./chunk-2WC2OEDO.js";import{a as Wt,b as Un,c as Hn,d as Vn,h as Qt,i as Qn}from"./chunk-W6STWDQI.js";import{a as je}from"./chunk-MPQ4OTBM.js";import{b as mt}from"./chunk-FRUSVINH.js";import{a as Ee,d as ft,e as Wn,f as gt,n as Vt}from"./chunk-YEN6CYC7.js";import{b as Ht}from"./chunk-HOENASQM.js";import{b as jn,c as Kn}from"./chunk-TQZV7KV4.js";import{B as pt,C as J,E as ge,G as Ut,K as xe,M as Gn,T as X,U as zn,_ as Ge,i as dt,l as le,r as ut,t as zt,y as Y}from"./chunk-3L2ZBPEX.js";import{a as Bn,b as On}from"./chunk-YXPUP5G2.js";import{b as qn,c as ee,h as re}from"./chunk-DRENNWRG.js";import{c as _n}from"./chunk-IW5XQG5G.js";import{p as Pe}from"./chunk-KYSDI3GE.js";import{c as $n,f as Dn}from"./chunk-7F45LJKI.js";import{createHash as mc}from"crypto";var Xr=[{id:"general-interprocedural-value-flow",families:["dataflow"],capability:"Whole-program definition-use flow through arbitrary calls and returns is unavailable.",consequence:"Missing dataflow edges cannot establish that a value never crosses an unmodeled call.",recoverWith:["value-flow","dependence-slice","inspect","code"]},{id:"heap-aliasing",families:["dataflow","state"],capability:"Heap points-to and cross-instance alias analysis are unavailable.",consequence:"Missing field or state edges cannot establish that two references never reach the same object.",recoverWith:["value-flow","dependence-slice","inspect","code"]},{id:"exceptional-flow",families:["execution","dataflow","temporal"],capability:"Interprocedural exception propagation and finally completion flow are unavailable.",consequence:"Normal-path reachability and ordering do not establish behavior after a throw or rejection.",recoverWith:["dependence-slice","inspect","code"]},{id:"reflection",families:["execution","runtime","identity","dependencies"],capability:"Reflective lookup, dynamic loading, and name-computed invocation are unavailable without exact evidence.",consequence:"Missing static edges cannot establish that a construct is unreachable through reflection.",recoverWith:["search","inspect","code"]},{id:"generated-dispatch",families:["execution","runtime","identity"],capability:"Dispatch tables or names created only by generated or unavailable source are unavailable.",consequence:"Missing dispatch edges cannot establish that no generated consumer exists.",recoverWith:["search","inspect","code"]},{id:"unsupported-framework-adapters",families:["runtime","dataflow","state","temporal"],capability:"Framework runtime crossings without a registered source adapter are unavailable.",consequence:"Missing boundary edges cannot establish that no producer, consumer, state effect, or ordering exists.",recoverWith:["search","inspect","code"]}];function Zr(e){let t=new Set(e);return Xr.filter(n=>n.families.some(o=>t.has(o)))}function eo(e){return Zr(e).map(t=>`[${t.id}] ${t.capability} ${t.consequence} Recover selected paths with: ${t.recoverWith.map(n=>`scip-query ${n}`).join(", ")}.`)}var Jr=["incoming","outgoing","both"];function W(e,t,n,o={}){return{family:e,subtype:t,...o.match?{match:o.match}:{},directions:Jr,evidenceStrengths:o.strengths??["exact","derived","mixed"],supportCeiling:o.supportCeiling??"partial",establishes:n,nonClaims:o.nonClaims??[],recoverWith:o.recoverWith??["inspect","code"]}}var ei=["predicate-consequence","predicate-alternative","predicate-fallthrough","predicate-case","predicate-default","predicate-return","predicate-throw","loop-iteration","loop-exit","exception-handler","finally-cleanup","handler-return","handler-throw"],ti=["captured-value-to-state","constant-to-state","expression-to-state","property-to-state","return-to-state","value-to-state"],ni=["await-completion-before","awaits-completion","inside-lock-scope","lexical-successor"],oi=[{id:"indexed-program-identity",label:"SCIP/compiler identity and source ownership",requirements:["indexed-graph"],relations:[W("execution","call","The source construct may call the resolved target.",{strengths:["exact","derived","candidate","mixed"],nonClaims:["Static may-call reachability does not prove that an invocation occurred at runtime."],recoverWith:["call-graph","inspect","code"]}),W("execution","result-callback","The referenced callable can produce the result consumed by this path.",{nonClaims:["A callback relationship does not prove invocation order or runtime selection."],recoverWith:["call-graph","inspect","code"]}),W("contract","uses-contract-symbol","The source construct refers to the identified contract symbol.",{supportCeiling:"exact",nonClaims:["Contract identity does not prove runtime invocation or behavioral conformance."],recoverWith:["hierarchy","inspect","code"]}),W("identity","references","The occurrence resolves to the identified compiler-owned symbol.",{supportCeiling:"exact",nonClaims:["A reference does not establish execution or value transfer."],recoverWith:["refs","trace","inspect"]}),W("ownership","contains","The owner contains the identified program construct.",{supportCeiling:"exact",nonClaims:["Structural containment does not establish runtime lifetime or sharing scope."],recoverWith:["outline","inspect"]}),W("ownership","contains-","The owner contains the identified program construct.",{match:"prefix",supportCeiling:"exact",nonClaims:["Structural containment does not establish runtime lifetime or sharing scope."],recoverWith:["outline","inspect"]}),W("ownership","owns-","The owner owns the identified source or runtime observation.",{match:"prefix",supportCeiling:"exact",nonClaims:["Observation ownership does not establish singleton lifetime or exclusive ownership."],recoverWith:["inspect","code"]}),W("dependencies","imports","The source file or module statically imports the indexed target.",{nonClaims:["An import does not establish that imported code executes."],recoverWith:["imports","deps","code"]}),W("dependencies","imports-external","The source region statically imports an external package.",{nonClaims:["An external import does not establish which package behavior executes."],recoverWith:["imports","code"]})]},{id:"runtime-boundary-join",label:"source-grounded runtime-boundary joins",requirements:["indexed-graph","source-facts"],relations:[W("runtime","runtime-handoff","A producer and consumer share a source-grounded runtime rendezvous.",{strengths:["exact","derived","candidate","mixed"],nonClaims:["A candidate or unresolved join does not prove a runtime handoff."],recoverWith:["evidence","inspect","code"]}),W("runtime","discriminator-dispatch","A serialized discriminator selects the reported consumer.",{strengths:["exact","derived","mixed"],nonClaims:["The dispatch edge does not prove delivery, retry, or successful handling."],recoverWith:["evidence","inspect","code"]}),W("dataflow","serialized-discriminator-transfer","The producer serializes the discriminator consumed by dispatch.",{strengths:["exact","derived","mixed"],nonClaims:["This edge does not establish the flow of every payload field."],recoverWith:["value-flow","inspect","code"]}),W("temporal","enqueue-before-consume","The reported enqueue precedes a possible consume through the queue.",{strengths:["exact","derived","mixed"],nonClaims:["Queue order does not establish delivery time, uniqueness, retry count, or durability."],recoverWith:["evidence","inspect","code"]})]},{id:"parser-control-dependence",label:"parser-proved intraprocedural control dependence",requirements:["indexed-graph","source-facts"],relations:[...ei.map(e=>W("execution",e,"The outcome is control-dependent on the reported predicate or handler.",{strengths:["exact"],nonClaims:["Local control dependence does not establish that the containing function executes."],recoverWith:["dependence-slice","inspect","code"]})),W("execution","returns","The selected construct contains the reported return terminal.",{strengths:["exact"],nonClaims:["A local return terminal does not establish that the containing callable executes."],recoverWith:["inspect","code"]}),W("execution","throws","The selected construct contains the reported throw terminal.",{strengths:["exact"],nonClaims:["A local throw terminal does not establish propagation, handling, or callable execution."],recoverWith:["inspect","code"]})]},{id:"bounded-static-value-flow",label:"compiler callsites and bounded static value evaluation",requirements:["indexed-graph","source-facts"],relations:["argument-to-parameter","constant-to-parameter","property-to-parameter","return-to-parameter","return-to-call-result"].map(e=>W("dataflow",e,"The reported value may reach the target through the evidenced callsite transfer.",{strengths:["exact","derived","mixed"],nonClaims:["This provider does not establish general local definition-use, alias, field, or heap flow."],recoverWith:["value-flow","dependence-slice","inspect","code"]}))},{id:"typescript-local-dependence",label:"TypeScript compiler identities, control-flow graph, and reaching definitions",requirements:["typescript-semantic"],relations:[W("dataflow","definition-to-use","The definition reaches the reported read on a feasible local control-flow path.",{strengths:["exact"],nonClaims:["Local reaching definitions do not establish heap aliasing, exceptional flow, or the runtime order of closure invocation."],recoverWith:["value-flow","dependence-slice","inspect","code"]}),W("dataflow","value-to-definition","The reported right-hand-side read supplies the assigned local definition.",{strengths:["exact"],nonClaims:["A local assignment edge does not establish field or heap points-to flow."],recoverWith:["value-flow","dependence-slice","inspect","code"]}),W("dataflow","closure-capture","The nested callable reads the reported binding from an enclosing callable.",{strengths:["candidate"],supportCeiling:"candidate",nonClaims:["Closure capture does not establish whether or when the nested callable executes."],recoverWith:["call-graph","inspect","code"]}),W("dataflow","field-definition-to-use","The reported same-owner field definition can reach the field read.",{strengths:["exact","candidate"],nonClaims:["Field-name identity does not establish whole-program heap aliasing or cross-instance flow."],recoverWith:["value-flow","dependence-slice","inspect","code"]}),W("execution","control-dependence","Execution of the reported statement depends on the outcome of the predicate.",{strengths:["exact"],nonClaims:["Intraprocedural control dependence does not establish that the containing callable executes."],recoverWith:["dependence-slice","inspect","code"]})]},{id:"parser-state-temporal",label:"parser-proved local state and temporal facts",requirements:["indexed-graph","source-facts"],relations:[...ti.map(e=>W("dataflow",e,"The reported source value is assigned into the identified state resource.",{strengths:["exact"],nonClaims:["The edge does not establish alias, heap, or later read flow."],recoverWith:["value-flow","inspect","code"]})),...["writes-resource","deletes-resource","reads-resource","enqueues-resource","consumes-resource"].map(e=>W("state",e,"The reported construct performs the named operation on the identified resource.",{strengths:["exact"],nonClaims:["A state operation does not establish transactionality, durability, or exclusive ownership."],recoverWith:["evidence","inspect","code"]})),...ni.map(e=>W("temporal",e,"The reported source constructs have the named local ordering relationship.",{strengths:["exact"],nonClaims:["Local source order does not establish cross-process happens-before or durable completion."],recoverWith:["evidence","inspect","code"]}))]}];function to(e,t){let n=oi.flatMap(o=>o.relations.filter(r=>r.family===e&&(r.match==="prefix"?t.startsWith(r.subtype):t===r.subtype)).map(r=>({provider:o,relation:r})));if(n.length>1)throw new Error(`Ambiguous graph relation provider for ${e}/${t}: ${n.map(o=>o.provider.id).join(", ")}`);return n[0]??null}var Ce=["execution","runtime","dataflow","state","temporal","contract","identity","ownership","dependencies"];function Ke(e){return e.includes("symbol-anchor")?0:e.includes("literal-owner")?1:e.some(t=>t.startsWith("boundary-import:"))?2:e.includes("reference-owner")?3:4}function no(e,t){return Ke(e.origins)-Ke(t.origins)||e.depth-t.depth||e.startLine-t.startLine||e.shortName.localeCompare(t.shortName)}var oo=new WeakMap,ro=new WeakMap,io=new WeakMap,ao=new WeakMap,so=new WeakMap;function lo(e,t){let n=ro.get(e);n||(n=new Map,ro.set(e,n));let o=n.get(t);if(o)return o;let r=Y(e,t)?.rootNode;if(!r)return n.set(t,[]),[];let a=new Set;he(r,d=>{if(d.type!=="call_expression")return;let c=d.childForFieldName("function")??d.namedChild(0),u=/^([A-Za-z_$][\w$]*(?:\.Service)?)\.of$/u.exec(c?.text.replace(/\s+/gu,"")??"");u&&a.add(u[1])});let i=xe(e,t).filter(d=>!!d.sourcePath),s=new Set;for(let d of a){let c=/^([A-Za-z_$][\w$]*)\.Service$/u.exec(d);if(c){for(let u of i)u.localName===c[1]&&s.add(u.sourcePath);continue}if(d==="Service"){X(e,t).some(u=>u.leaf==="Service")&&s.add(t);for(let u of i)(u.localName??u.importedName)==="Service"&&s.add(u.sourcePath)}}let l=nn([...s]).sort();return n.set(t,l),l}function Jt(e,t,n={}){let r=Ut(e,t)?.filter(m=>!n.ranges||n.ranges.some(p=>m.line>=p.startLine&&m.line<=p.endLine));if(!r)return{targets:[],unresolvedCallsites:0};let a=xe(e,t).filter(m=>!!m.sourcePath),i=vi(dt(e,t)??""),s=Y(e,t)?.rootNode??null,l=s?ii(s):co(),d=new Map,c=gt(e),u=[],f=0;for(let m of r){if(!m.memberAccess)continue;let p=ft(t,c.get(m.calleeLeaf)??[]);if(n.excludeIndexedTargets!==!1&&Wn(e,t,p,!0,m.calleeQualifier))continue;let g=m.calleeQualifier,b=bi(e,t,m,a);if(b){u.push(b);continue}let C=ri(e,t,m,a,ai(l,m.calleeQualifier,m.line));if(C.length>0){u.push(...C);continue}let S=si(e,t,m);if(S.length>0){u.push(...S);continue}let v=g?i.get(g)??g:null,y=(v?nn(a.filter(L=>(L.localName??L.importedName)===v).map(L=>L.sourcePath)):[]).flatMap(L=>{let x=d.get(L);return x||(x=ge(e,L)??[],d.set(L,x)),x.filter(M=>M.name===m.calleeLeaf).map(M=>({file:L,callable:M}))});if(y.length!==1){f+=1;continue}let N=y[0];u.push({calleeLeaf:m.calleeLeaf,line:m.line,sourceFile:t,targetFile:N.file,targetStartLine:N.callable.startLine,targetEndLine:N.callable.endLine,resolution:"direct-import-receiver",strength:"candidate"})}return{targets:u,unresolvedCallsites:f}}function ri(e,t,n,o,r){let a=n.calleeQualifier;if(!a||!/^[A-Za-z_$][\w$]*$/u.test(a))return[];if(r.size!==1)return[];let i=[...r][0],s=nn(o.filter(c=>c.localName===i||c.importedName===i).map(c=>c.sourcePath));if(s.length!==1)return[];let l=s[0],d=ui(e,l,n.calleeLeaf);return d.map(c=>({calleeLeaf:c.name,line:n.line,sourceFile:t,targetFile:c.file,targetStartLine:c.startLine,targetEndLine:c.endLine,serviceFile:l,resolutionAlternativeCount:d.length,resolution:"imported-service-object-member",strength:"candidate"}))}function co(){return{declarations:new Map,callbacks:[]}}function ii(e){let t=co();return he(e,n=>{if(n.type==="variable_declarator"){let l=n.childForFieldName("name")??n.namedChild(0),d=n.childForFieldName("value")??n.namedChild(1);if(l?.type!=="identifier"||!d)return;let c=new Set;if(he(d,u=>{if(u.type!=="member_expression")return;let f=u.childForFieldName("object")??u.namedChild(0),m=u.childForFieldName("property")??u.namedChild(1);f?.type==="identifier"&&m?.text==="Service"&&c.add(f.text)}),c.size===1){let u=t.declarations.get(l.text)??[];u.push({line:n.startPosition.row,alias:[...c][0]}),t.declarations.set(l.text,u)}return}if(!["arrow_function","function_expression","generator_function"].includes(n.type))return;let o=n.childForFieldName("parameters")??n.childForFieldName("parameter");if(!o)return;let r=n.parent;for(;r&&r.type!=="call_expression";)r=r.parent;if(!r)return;let a=r.childForFieldName("function")??r.namedChild(0),i=/^([A-Za-z_$][\w$]*)\.Service\.use$/u.exec(a?.text??"");if(!i)return;let s=new Set;he(o,l=>{l.type==="identifier"&&s.add(l.text)}),s.size!==0&&t.callbacks.push({startLine:n.startPosition.row,endLine:n.endPosition.row,receivers:s,alias:i[1]})}),t}function ai(e,t,n){if(!t||!/^[A-Za-z_$][\w$]*$/u.test(t))return new Set;let o=new Set((e.declarations.get(t)??[]).filter(r=>r.line<=n).map(r=>r.alias));for(let r of e.callbacks)r.startLine<=n&&r.endLine>=n&&r.receivers.has(t)&&o.add(r.alias);return o}function si(e,t,n){let o=n.calleeQualifier;if(!o||!/^[A-Za-z_$][\w$]*$/u.test(o))return[];let r=Y(e,t)?.rootNode;if(!r)return[];let a=li(e,t,r,n.line,n.calleeLeaf,o),i=a?di(a,o):null;if(!i)return[];if(!ci(i))return[];let s=(ge(e,t)??[]).filter(m=>m.startLine<=i.startPosition.row&&m.endLine>=i.endPosition.row).sort((m,p)=>m.endLine-m.startLine-(p.endLine-p.startLine))[0];if(!s)return[];let l=X(e,t).filter(m=>m.isFunctionLike&&m.leaf===s.name);if(l.length!==1)return[];let d=l[0],c=ao.get(e);c||(c=new Map,ao.set(e,c));let u=`${d.symbol}\0${n.calleeLeaf}`,f=c.get(u);if(!f){let m=[];for(let p of Vt(e,d)){let g=Y(e,p.file)?.rootNode;if(!g)continue;let b=ut(g,"call_expression").filter(v=>v.startPosition.row>p.line||v.endPosition.row<p.line?!1:(v.childForFieldName("function")??v.namedChild(0))?.text.replace(/\s+/gu,"").replace(/<[^<>]*>$/u,"").match(/[A-Za-z_$][\w$]*$/u)?.[0]===d.leaf);if(b.length!==1)continue;let S=b[0].childForFieldName("arguments")?.namedChildren.find(v=>Ae(v).type==="object");if(S)for(let v of Ae(S).namedChildren){if(v.type==="shorthand_property_identifier"&&v.text===n.calleeLeaf){m.push(...St(e,p.file,n.calleeLeaf,v,v));continue}if(v.type!=="pair")continue;let R=v.childForFieldName("key")??v.namedChild(0),y=v.childForFieldName("value")??v.namedChild(1);vt(R?.text)!==n.calleeLeaf||!y||m.push(...St(e,p.file,n.calleeLeaf,y,v))}}f=m.filter((p,g,b)=>b.findIndex(C=>C.file===p.file&&C.startLine===p.startLine&&C.endLine===p.endLine&&C.name===p.name)===g),c.set(u,f)}return f.map(m=>({calleeLeaf:m.name,line:n.line,sourceFile:t,targetFile:m.file,targetStartLine:m.startLine,targetEndLine:m.endLine,resolutionAlternativeCount:f.length,resolution:"factory-callback-member",strength:f.length===1?"exact":"candidate"}))}function li(e,t,n,o,r,a){let i=io.get(e);i||(i=new Map,io.set(e,i));let s=i.get(t);if(!s){s=new Map;for(let l of ut(n,"call_expression")){let d=l.childForFieldName("function")??l.namedChild(0),c=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(d?.text.replace(/\s+/gu,"")??"");if(c)for(let u=l.startPosition.row;u<=l.endPosition.row;u+=1){let f=`${u}\0${c[1]}\0${c[2]}`,m=s.get(f);(!m||l.endIndex-l.startIndex<m.endIndex-m.startIndex)&&s.set(f,l)}}i.set(t,s)}return s.get(`${o}\0${a}\0${r}`)??null}function ci(e){return e.descendantsOfType("return_statement").some(t=>{let n=t.childForFieldName("argument")??t.namedChild(0);return!!(n&&Ae(n).type==="object")})}function di(e,t){let n=e.parent;for(;n;){if(/(?:function|method|lambda)/u.test(n.type)||n.type==="arrow_function"){let o=n.childForFieldName("parameters")??n.childForFieldName("parameter"),r=!1;if(o&&he(o,a=>{a.type==="identifier"&&a.text===t&&(r=!0)}),r)return n}n=n.parent}return null}function St(e,t,n,o,r){if(o.type==="identifier")return(ge(e,t)??[]).filter(l=>l.name===o.text).map(l=>({...l,file:t}));let a=en(e,t,o.text);if(a.length>0)return a;if(!tn(o))return[];let s=(ge(e,t)??[]).filter(l=>l.startLine>=r.startPosition.row&&l.endLine<=r.endPosition.row&&(l.name===n||l.name.startsWith("source@"))).sort((l,d)=>l.endLine-l.startLine-(d.endLine-d.startLine))[0];return[s?{...s,file:t}:{name:n,file:t,startLine:r.startPosition.row,endLine:r.endPosition.row}]}function ui(e,t,n){let o=so.get(e);o||(o=new Map,so.set(e,o));let r=`${t}\0${n}`,a=o.get(r);if(a)return a;let i=fi(e,t).flatMap(s=>pi(e,s,t,n));return o.set(r,i),i}function pi(e,t,n,o){let r=Y(e,t)?.rootNode,a=ge(e,t)??[];if(!r)return[];let i=gi(e,t,n);if(i.size===0)return[];let s=new Set,l=[],d=[],c=[];return he(r,f=>{if(mi(f,i)){if(f.type==="pair"){let m=f.childForFieldName("key")??f.namedChild(0),p=f.childForFieldName("value")??f.namedChild(1);if(vt(m?.text)!==o||!p)return;if(p.type==="identifier")s.add(p.text);else if(tn(p))l.push({name:o,startLine:f.startPosition.row,endLine:f.endPosition.row});else{let g=yi(e,t,p.text),b=en(e,t,p.text);if(g.length>0)c.push(...g);else if(b.length>0)c.push(...b);else{let C=hi(f);C&&d.push(C)}}return}f.type==="shorthand_property_identifier"&&f.text===o&&s.add(o)}}),[...a.filter(f=>s.has(f.name)).map(f=>({...f,file:t})),...l.map(f=>({...f,file:t})),...d.map(f=>({...f,file:t})),...c].filter((f,m,p)=>p.findIndex(g=>g.file===f.file&&g.name===f.name&&g.startLine===f.startLine&&g.endLine===f.endLine)===m)}function mi(e,t){let n=e,o=null;for(;n;){if(n.type==="object"&&(o=n),n.type==="call_expression"){if(!o)return!1;let r=n.childForFieldName("function")??n.namedChild(0);return r?t.has(r.text.replace(/\.of$/u,""))&&r.text.endsWith(".of"):!1}n=n.parent}return!1}function fi(e,t){let n=oo.get(e);n||(n=new Map,oo.set(e,n));let o=n.get(t);if(o)return o;let r=new Set([t]),a=X(e,t).filter(s=>s.leaf==="Service"&&s.isTypeLike);for(let s of a)for(let l of Vt(e,s))r.add(l.file);let i=[...r].sort();return n.set(t,i),i}function gi(e,t,n){let o=new Set;Pe(t,n)&&o.add("Service");for(let r of xe(e,t)){if(!r.sourcePath||!Pe(r.sourcePath,n))continue;if(r.kind==="namespace"&&r.localName){o.add(`${r.localName}.Service`);continue}(r.importedName==="default"?r.localName:r.importedName)==="Service"?o.add(r.localName??r.importedName):r.localName&&r.importedName!=="default"&&o.add(`${r.localName}.Service`)}return o}function en(e,t,n){let o=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(n.replace(/\s+/gu,""));if(!o)return[];let r=Y(e,t)?.rootNode;if(!r)return[];let a=uo(r,o[1]),i=a?po(a):null;if(!i)return[];let s=i.childForFieldName("function")??i.namedChild(0),l=s?mo(e,t,s.text):[];if(l.length!==1)return[];let d=l[0],c=Y(e,d.relativePath)?.rootNode;if(!c)return[];let u=zt(c,d.startLine,d.endLine);if(!u)return[];let f=[];for(let m of u.descendantsOfType("return_statement")){let p=m.childForFieldName("argument")??m.namedChild(0);if(!p)continue;let g=Ae(p);if(g.type==="object")for(let b of g.namedChildren){if(b.type==="shorthand_property_identifier"&&b.text===o[2]){for(let v of ge(e,d.relativePath)??[])v.name===o[2]&&f.push({...v,file:d.relativePath});continue}if(b.type!=="pair")continue;let C=b.childForFieldName("key")??b.namedChild(0),S=b.childForFieldName("value")??b.namedChild(1);if(!(vt(C?.text)!==o[2]||!S))if(S.type==="identifier")for(let v of ge(e,d.relativePath)??[])v.name===S.text&&f.push({...v,file:d.relativePath});else tn(S)&&f.push({name:o[2],startLine:b.startPosition.row,endLine:b.endPosition.row,file:d.relativePath})}}return f.filter((m,p,g)=>g.findIndex(b=>b.file===m.file&&b.name===m.name&&b.startLine===m.startLine&&b.endLine===m.endLine)===p)}function yi(e,t,n){let o=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(n.replace(/\s+/gu,""));if(!o)return[];let r=Y(e,t)?.rootNode;if(!r)return[];let a=uo(r,o[1]),i=a?po(a):null,s=i?.childForFieldName("function")??i?.namedChild(0),l=s?mo(e,t,s.text):[];if(l.length!==1||!i)return[];let d=l[0],c=Y(e,d.relativePath)?.rootNode;if(!c)return[];let u=zt(c,d.startLine,d.endLine);if(!u)return[];let f=new Set,m=u.childForFieldName("parameters")??u.childForFieldName("parameter");if(m&&he(m,L=>{L.type==="identifier"&&f.add(L.text)}),f.size===0)return[];let p=en(e,t,n);if(p.length===0)return[];let g=(ge(e,d.relativePath)??[]).filter(L=>L.startLine>=d.startLine&&L.endLine<=d.endLine),b=(Ut(e,d.relativePath)??[]).filter(L=>L.line>=d.startLine&&L.line<=d.endLine),C=new Set,S=p.map(L=>({name:L.name,startLine:L.startLine,endLine:L.endLine})),v=new Set;for(;S.length>0&&v.size<32;){let L=S.shift(),x=`${L.name}\0${L.startLine}\0${L.endLine}`;if(!v.has(x)){v.add(x);for(let M of b.filter(h=>h.line>=L.startLine&&h.line<=L.endLine)){if(M.memberAccess&&M.calleeQualifier&&f.has(M.calleeQualifier)){C.add(M.calleeLeaf);continue}if(M.memberAccess)continue;let h=g.filter(P=>P.name===M.calleeLeaf);h.length===1&&S.push(h[0])}}}if(C.size===0)return[];let y=i.childForFieldName("arguments")?.namedChildren.find(L=>Ae(L).type==="object");if(!y)return[];let N=[];for(let L of Ae(y).namedChildren){if(L.type==="shorthand_property_identifier"&&C.has(L.text)){N.push(...St(e,t,L.text,L,L));continue}if(L.type!=="pair")continue;let x=L.childForFieldName("key")??L.namedChild(0),M=L.childForFieldName("value")??L.namedChild(1),h=vt(x?.text);!h||!C.has(h)||!M||N.push(...St(e,t,h,M,L))}return N.filter((L,x,M)=>M.findIndex(h=>h.file===L.file&&h.name===L.name&&h.startLine===L.startLine&&h.endLine===L.endLine)===x)}function uo(e,t){for(let n of ut(e,"variable_declarator"))if((n.childForFieldName("name")??n.namedChild(0))?.text===t)return n.childForFieldName("value")??n.namedChild(1);return null}function po(e){return e.type==="call_expression"?e:e.descendantsOfType("call_expression")[0]??null}function mo(e,t,n){let o=n.replace(/\s+/gu,"").replace(/<[^<>]*>$/u,""),r=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(o);if(r){let u=xe(e,t).filter(p=>p.localName===r[1]&&p.sourcePath);if(u.length!==1||!u[0].sourcePath)return[];let f=u[0].sourcePath,m=je(e,f,r[2]).filter(p=>p.isFunctionLike);return m.length>0?m:(ge(e,f)??[]).filter(p=>p.name===r[2]).map(p=>({...p,relativePath:f}))}if(!/^[A-Za-z_$][\w$]*$/u.test(o))return[];let a=X(e,t).filter(u=>u.leaf===o&&u.isFunctionLike);if(a.length>0)return a;let i=(ge(e,t)??[]).filter(u=>u.name===o).map(u=>({...u,relativePath:t}));if(i.length>0)return i;let s=xe(e,t).filter(u=>u.localName===o&&u.sourcePath&&u.kind!=="namespace");if(s.length!==1||!s[0].sourcePath)return[];let l=s[0].sourcePath,d=s[0].importedName==="default"?o:s[0].importedName,c=je(e,l,d).filter(u=>u.isFunctionLike);return c.length>0?c:(ge(e,l)??[]).filter(u=>u.name===d).map(u=>({...u,relativePath:l}))}function tn(e){return["arrow_function","function_expression","generator_function"].includes(e.type)||e.descendantsOfType(["arrow_function","function_expression","generator_function"]).length>0}function hi(e){let t=e.parent;for(;t;){if(t.type==="variable_declarator"){let n=t.childForFieldName("name")??t.namedChild(0);if(n?.type==="identifier")return{name:n.text,startLine:t.startPosition.row,endLine:t.endPosition.row}}t=t.parent}return null}function vt(e){return e?e.replace(/^(?:['"])(.*)(?:['"])$/u,"$1"):null}function bi(e,t,n,o){let r=/^this\.([A-Za-z_$][\w$]*)$/u.exec(n.calleeQualifier??"");if(!r)return null;let a=Y(e,t)?.rootNode;if(!a)return null;let i=Si(a,n.line);if(!i)return null;let s=new Set;if(he(i,g=>{if(g.type!=="assignment_expression")return;let b=g.childForFieldName("left")??g.namedChild(0),C=g.childForFieldName("right")??g.namedChild(g.namedChildCount-1);if(b?.text.replace(/\s+/gu,"")!==`this.${r[1]}`||!C)return;let S=Ae(C);if(S.type!=="new_expression")return;let R=(S.childForFieldName("constructor")??S.namedChild(0))?.text.match(/[A-Za-z_$][\w$]*$/u)?.[0];R&&s.add(R)}),s.size!==1)return null;let l=[...s][0],d=o.filter(g=>g.localName===l);if(d.length!==1)return null;let c=d[0].importedName==="default"?l:d[0].importedName,u=d[0].importedName==="default"?je(e,d[0].sourcePath,l):[],f=u.length===1?u[0].leaf:c,m=X(e,d[0].sourcePath).filter(g=>g.isFunctionLike&&g.leaf===n.calleeLeaf&&qn(g.symbol)===f);if(m.length!==1)return null;let p=m[0];return{calleeLeaf:n.calleeLeaf,line:n.line,sourceFile:t,targetFile:p.relativePath,targetStartLine:p.startLine,targetEndLine:p.endLine,targetSymbol:p.symbol,resolution:"constructed-member-receiver",strength:"exact"}}function Si(e,t){let n=[];return he(e,o=>{["class","class_declaration","class_definition"].includes(o.type)&&o.startPosition.row<=t&&o.endPosition.row>=t&&n.push(o)}),n.sort((o,r)=>o.endPosition.row-o.startPosition.row-(r.endPosition.row-r.startPosition.row))[0]??null}function Ae(e){let t=e;for(;["parenthesized_expression","as_expression","type_assertion","satisfies_expression"].includes(t.type)&&t.namedChildCount===1;)t=t.namedChild(0);return t}function he(e,t){t(e);for(let n of e.namedChildren)he(n,t)}function vi(e){let t=new Map,n=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*([A-Za-z_$][\w$]*)\s*;/gu;for(let o of e.matchAll(n)){let r=o[1],a=o[2];r&&a&&t.set(r,a)}return t}function nn(e){let t=[];for(let n of e)t.some(o=>Pe(o,n))||t.push(n);return t}import{existsSync as Ei}from"fs";import{SymbolRole as Ci}from"@c4312/scip";import{deserializeSCIP as xi}from"@c4312/scip";function fo(e,t){return xi(Dn(e,{inputKind:t,maxBytes:$n}))}var on=new WeakMap;function xt(e,t,n,o){let r=J(e,t),a=(r?.callSites??[]).filter(m=>m.line>=n&&m.line<=o);if(!r||a.length===0)return{available:!!r,targets:[],resolvedCallsites:0,unresolvedCallsites:0};let i=an(e);if(!i)return{available:!1,targets:[],resolvedCallsites:0,unresolvedCallsites:a.length};let s=(i.byFile.get(t)??[]).filter(m=>m.sourceLine>=n&&m.sourceLine<=o).map(m=>({...m,calleeLeaf:m.definition.leaf})),l=go(a.map(m=>({line:m.line,leaf:m.calleeLeaf}))),d=go(s.map(m=>({line:m.sourceLine,leaf:m.calleeLeaf}))),c=new Set([...l].flatMap(([m,p])=>d.get(m)===p?[m]:[])),u=s.filter(m=>c.has(ho(m.sourceLine,m.calleeLeaf))),f=[...c].reduce((m,p)=>m+(l.get(p)??0),0);return{available:!0,targets:u,resolvedCallsites:f,unresolvedCallsites:Math.max(0,a.length-f)}}function rn(e,t,n,o){let r=an(e);return r?{available:!0,targets:(r.byFile.get(t)??[]).filter(a=>a.sourceLine>=n&&a.sourceLine<=o)}:{available:!1,targets:[]}}function yo(e,t,n,o){let r=an(e);return r?{available:!0,targets:(r.byFile.get(t)??[]).filter(a=>a.sourceLine>=n&&a.sourceLine<=o&&Et(e,a.definition)).map(a=>({...a,calleeLeaf:a.definition.leaf}))}:{available:!1,targets:[]}}function an(e){if(on.has(e))return on.get(e)??null;let t=Li(e);return on.set(e,t),t}function Li(e){if(!e.generation.indexPath||!Ei(e.generation.indexPath))return null;try{let t=zn(e),n=new Map(t.map(a=>[a.symbol,a])),o=fo(e.generation.indexPath,"SCIP source-range call-target index"),r=new Map;for(let a of o.documents??[]){let i=a.relativePath;if(!i||e.isIgnored(i))continue;let s=[];for(let l of a.occurrences??[]){if(!l.symbol||(l.symbolRoles&Ci.Definition)!==0)continue;let d=n.get(l.symbol),c=l.range?.[0];!d||!Number.isInteger(c)||s.push({sourceLine:c,definition:d})}r.set(i,s)}return{byFile:r}}catch{return null}}function Et(e,t){if(!t.isFunctionLike)return!1;let n=J(e,t.relativePath);return!n||n.callables.some(o=>o.name===t.leaf&&o.startLine===t.startLine&&o.endLine===t.endLine)?!0:Ii(t)}function Ii(e){let t=e.documentation;if(!t)return!1;let n=e.leaf.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`\\bfunction\\s+${n}\\s*(?:<[^>]*>)?\\s*\\(`,"u").test(t)||new RegExp(`\\b(?:const|let|var)\\s+${n}\\s*:\\s*(?:<[^>]*>\\s*)?\\([^\\n]*\\)\\s*=>`,"u").test(t)}function go(e){let t=new Map;for(let n of e){let o=ho(n.line,n.leaf);t.set(o,(t.get(o)??0)+1)}return t}function ho(e,t){return`${e}\0${t}`}var wi=16,Ni=4,Mi=3e3,Ri=800,Ti=new Set(["assignment","const_declaration","const_item","field_declaration","lexical_declaration","local_declaration_statement","local_variable_declaration","static_item","variable_declaration"]);function Co(e,t,n={}){let o=n.maxSteps??wi;if(!Number.isSafeInteger(o)||o<=0)throw new RangeError(`maxSteps must be a positive safe integer; received ${o}`);let r=new Map(t.nodes.map(E=>[E.id,E])),a=_i(n.focusLocations??[]),i=new Set,s=new Map(t.edges.map(E=>[E.id,E])),l=Le(t.paths.flatMap(E=>E.nodeIds)),d=Le(t.anchors.filter(E=>E.status==="matched").flatMap(E=>E.nodeIds)),c=t.nodes.filter(E=>E.disposition==="emitted"&&E.attributes.upstreamCausalPath===!0).sort((E,k)=>Number(k.attributes.upstreamCausalDistance??0)-Number(E.attributes.upstreamCausalDistance??0)||E.id.localeCompare(k.id)).map(E=>E.id),u=new Set(c),f=Math.max(0,o-d.length),p=Fi(t,d,a,f).slice(0,f),g=new Set(p),b=new Set(p),C=new Set([...l,...c,...d]),S=t.edges.filter(E=>E.disposition==="emitted"&&E.kind!=="structural-membership"),v=t.edges.filter(E=>E.disposition!=="excluded"&&E.disposition!=="unsupported"&&E.kind!=="structural-membership"),R=new Set([...t.paths.flatMap(E=>E.edgeIds),...S.filter(E=>u.has(E.fromNodeId)&&u.has(E.toNodeId)).map(E=>E.id)]),y=t.paths.some(E=>E.edgeIds.length>0),N=new Set(d);for(let E of p)N.add(E);for(let E of t.paths){let k=E.nodeIds[0],G=s.get(E.edgeIds[0]??""),H=E.nodeIds[1];k&&H&&G?.fromNodeId===k&&G.toNodeId===H&&N.add(k)}if(t.paths.every(E=>E.nodeIds.length===0))for(let E of t.anchors)for(let k of E.nodeIds)N.add(k);let L=Ki(d,v,r,Ni),x=Le(S.filter(E=>E.kind==="call"&&d.includes(E.fromNodeId)).map(E=>E.toNodeId)),M=new Set(Le([...L,...y?[]:x]));for(let E of M)N.add(E);let h=Le(S.flatMap(E=>C.has(E.fromNodeId)||C.has(E.toNodeId)?[E.fromNodeId,E.toNodeId]:[])),P=t.nodes.filter(E=>E.disposition==="emitted"&&E.kind!=="structural-region"&&S.some(k=>k.fromNodeId===E.id||k.toNodeId===E.id)).map(E=>E.id),D=Le([...c,...l,...d,...p,...M,...h,...P]).filter(E=>r.has(E)),O=[];for(let E of D)y&&!C.has(E)&&!g.has(E)&&!M.has(E)||O.length>=o&&!C.has(E)||O.push(E);let w=new Set(O),T=new Map(O.map(E=>[E,zi(E)])),I=new Set([...l,...c]),_=new Set(t.anchors.flatMap(E=>E.nodeIds)),A=O.map((E,k)=>{let G=r.get(E),H=Di(G,a);for(let me of H)i.add(qe(G.location.file,me));return{id:T.get(E),nodeId:E,order:k,role:_.has(E)?"anchor":I.has(E)?"connector":"junction",kind:G.kind,label:G.label,location:G.location,behavior:Pi(e,G,_.has(E),[...new Set([...H,...$i(e,G,v,r,R,N)])],H,N.has(G.id)&&(H.length===0||_.has(G.id)),M.has(G.id),b.has(G.id)&&H.length===0)}}),j=new Map;for(let E of t.paths)for(let k=0;k<E.edgeIds.length;k+=1){let G=s.get(E.edgeIds[k]),H=E.nodeIds[k],me=E.nodeIds[k+1];!G||!H||!me||j.set(G.id,G.fromNodeId===H&&G.toNodeId===me?"forward":"reverse")}let B=v.filter(E=>w.has(E.fromNodeId)&&w.has(E.toNodeId)).sort((E,k)=>qi(E,k,t)).map((E,k)=>({id:Ui(E.id),edgeId:E.id,order:k,kind:E.kind,fromStepId:T.get(E.fromNodeId),toStepId:T.get(E.toNodeId),directed:!0,pathTraversal:j.get(E.id)??"adjacent",evidence:E.evidence})),U=new Map(B.map(E=>[E.edgeId,E.id])),q=t.paths.map(E=>({id:E.id,status:E.status,stepIds:E.nodeIds.flatMap(k=>{let G=T.get(k);return G?[G]:[]}),transitionIds:E.edgeIds.flatMap(k=>{let G=U.get(k);return G?[G]:[]})})),se=A.flatMap(E=>E.location?[`${E.location.file}:${E.location.line+1}`]:[]),Ne=t.anchors.some(E=>E.status==="ambiguous"),Oe=q.some(E=>E.status==="connected"||E.status==="candidate"),ve=q.some(E=>E.status==="partial");return{status:A.length===0?"unavailable":Ne?"ambiguous":Oe&&!ve?"connected":ve?"partial":"connected",steps:A,transitions:B,paths:q,coverage:{candidateNodes:D.length,returnedNodes:O.length,omittedNodeIds:D.filter(E=>!w.has(E)),returnedTransitions:B.length,withheldStatements:A.reduce((E,k)=>E+(k.behavior?.coverage.omittedStatements??0),0),requestedFocusLocations:a,matchedFocusLocations:a.filter(E=>i.has(qe(E.file,E.line))),unmatchedFocusLocations:a.filter(E=>!i.has(qe(E.file,E.line)))},behaviorCommand:Eo(se,"behavior"),exactSourceCommand:Eo(se,"source")}}function Fi(e,t,n,o){if(o<=0||n.length===0)return[];let r=new Set(t),a=new Set(n.map(i=>qe(i.file,i.line)));return Le(e.edges.filter(i=>i.disposition!=="excluded"&&i.disposition!=="unsupported"&&["call","runtime-boundary"].includes(i.kind)&&r.has(i.fromNodeId)&&i.evidence.some(s=>!["candidate","unknown"].includes(s.strength)&&s.location&&a.has(qe(s.location.file,s.location.line)))).sort((i,s)=>{let l=i.evidence.find(c=>c.location)?.location,d=s.evidence.find(c=>c.location)?.location;return(l?.file??"").localeCompare(d?.file??"")||(l?.line??Number.MAX_SAFE_INTEGER)-(d?.line??Number.MAX_SAFE_INTEGER)||i.id.localeCompare(s.id)}).map(i=>i.toNodeId)).slice(0,o)}function Pi(e,t,n,o,r,a,i,s){if(!t.location||!["symbol","source-construct","runtime-boundary-participant"].includes(t.kind))return null;let l=t.location.endLine??t.location.line,d=le(e,t.location.file),c=o.length>0?o:[t.location.line],u=t.kind==="runtime-boundary-participant"?Ye(e,t.location.file,0,Math.max(0,d.length-1),[t.location.line]):Ye(e,t.location.file,t.location.line,l,c),f=o.filter(M=>M>=u.startLine&&M<=u.endLine),m=yt(e,t.location.file,u.startLine,u.endLine,f),p=m??(f.length>0?yt(e,t.location.file,u.startLine,u.endLine,f,{requireSavings:!1}):null),g=f.length>0?Bi(e,t,u.startLine,u.endLine,f,p,a):null,b=d.slice(u.startLine,u.endLine+1).join(`
2
- `).length,C=Me(e,t.location.file,u.startLine,u.endLine),S=d.slice(u.startLine,u.endLine+1).some((M,h)=>M.length>Ri&&(C.get(u.startLine+h)??[]).some(P=>["binding","branch","loop","call","return","throw","mutation"].includes(P))),v=M=>Ai(e,t,u.startLine,u.endLine,r.filter(h=>h>=u.startLine&&h<=u.endLine),M),R=(i||t.kind==="runtime-boundary-participant"||t.anchorIds.length>0)&&b<=Mi,y=n&&(f.length===0||R);if(m&&(s||y))return v(bo(m));if(!s&&!y&&g&&!S&&!R&&g.renderedCharacters<(p?.outlineCharacters??b))return v(g);if(m)return v(bo(m));let N=d.slice(u.startLine,u.endLine+1),L=N.join(`
3
- `),x=Me(e,t.location.file,u.startLine,u.endLine);return v({kind:"source",constructKind:"source construct",signature:N.find(M=>M.trim().length>0)?.trim()??t.label,lines:N.map((M,h)=>({line:u.startLine+h,endLine:u.startLine+h,depth:0,signals:x.get(u.startLine+h)??[],text:M,copied:!0})),coverage:{sourceStatements:N.length,representedStatements:N.length,copiedStatements:N.length,omittedStatements:0},rawCharacters:L.length,renderedCharacters:L.length})}function Ai(e,t,n,o,r,a){if(!t.location)return a;let i=rn(e,t.location.file,n,o);if(!i.available)return a;let s=Me(e,t.location.file,n,o),l=le(e,t.location.file),d=new Set(r);for(let S of r){let v=Ct(l[S]??"");if(!v)continue;let R=Ee(e,t.location.file,v).find(y=>y>S&&y<=o);R!==void 0&&d.add(R)}let c=[...new Map(i.targets.flatMap(S=>{let v=S.definition,R=v.relativePath===t.location.file&&v.startLine<=o&&v.endLine>=n;if(v.isTypeLike||R)return[];let y=Et(e,v),N=r.length>0&&y&&s.get(S.sourceLine)?.includes("return"),L=y&&d.has(S.sourceLine);return y&&!N&&!L?[]:[[v.symbol,{definition:v,kind:N?"return-value-transformer":L?"focused-causal-target":"compiler-referenced-declaration"}]]})).values()].sort((S,v)=>S.definition.relativePath.localeCompare(v.definition.relativePath)||S.definition.startLine-v.definition.startLine||S.definition.symbol.localeCompare(v.definition.symbol)),u=[],f=c.filter(({kind:S})=>S!=="compiler-referenced-declaration").map(({definition:S})=>({owner:S,depth:1})),m=new Set,p=new Set(c.map(({definition:S})=>S.symbol));for(;f.length>0;){let S=f.shift();if(!S||m.has(S.owner.symbol))continue;m.add(S.owner.symbol);let{owner:v,depth:R}=S,y=rn(e,v.relativePath,v.startLine,v.endLine);if(!y.available)continue;let N=Me(e,v.relativePath,v.startLine,v.endLine),L=le(e,v.relativePath);for(let x of y.targets){let M=x.definition,h=M.relativePath===v.relativePath&&M.startLine<=v.endLine&&M.endLine>=v.startLine;if(M.isTypeLike||h)continue;let P=Et(e,M),D=Ct(L[x.sourceLine]??""),O=P&&D!==null&&Ee(e,v.relativePath,D).some(T=>T>x.sourceLine&&T<=v.endLine&&(N.get(T)??[]).some(I=>["branch","return","throw"].includes(I))),w=P&&((N.get(x.sourceLine)??[]).some(T=>["branch","return","throw"].includes(T))||O);P&&!w||(p.has(M.symbol)||(p.add(M.symbol),u.push({definition:M,kind:P?"focused-causal-target":"compiler-referenced-declaration"})),P&&R<2&&f.push({owner:M,depth:R+1}))}}let g=[...new Map([...c,...u].map(S=>[S.definition.symbol,S])).values()].sort((S,v)=>S.definition.relativePath.localeCompare(v.definition.relativePath)||S.definition.startLine-v.definition.startLine||S.definition.symbol.localeCompare(v.definition.symbol)),b=[],C=[];for(let{definition:S,kind:v}of g){let R=v==="compiler-referenced-declaration"?ki(e,S.relativePath,S.startLine,S.endLine):{startLine:S.startLine,endLine:S.endLine},y=le(e,S.relativePath).slice(R.startLine,R.endLine+1).join(`
4
- `),N=v==="compiler-referenced-declaration"?null:yt(e,S.relativePath,S.startLine,S.endLine,[]),L=N?[N.signature,...N.lines.map(D=>`${D.line+1}${D.signals.length>0?`[${D.signals.join(",")}]`:""} ${D.text}`)].join(" | "):null,x=L&&L.length<y.length?L:y,M={symbol:S.symbol,label:S.leaf,file:S.relativePath,line:R.startLine,endLine:R.endLine},h=v==="compiler-referenced-declaration"?1e3:8e3,P=v==="compiler-referenced-declaration"?12:120;if(x.length>h||R.endLine-R.startLine>P){C.push({...M,reason:"source-too-large"});continue}b.push({kind:v,...M,text:x})}return{...a,...b.length===0?{}:{supportingDeclarations:b},...C.length===0?{}:{omittedSupportingDeclarations:C}}}function ki(e,t,n,o){let r=Y(e,t);if(!r)return{startLine:n,endLine:o};let a=[];Lo(r.rootNode,s=>{Ti.has(s.type)&&s.startPosition.row<=n&&s.endPosition.row>=o&&a.push(s)});let i=a.sort((s,l)=>s.endPosition.row-s.startPosition.row-(l.endPosition.row-l.startPosition.row)||s.endIndex-s.startIndex-(l.endIndex-l.startIndex))[0];return i?{startLine:i.startPosition.row,endLine:i.endPosition.row}:{startLine:n,endLine:o}}function Lo(e,t){t(e);for(let n of e.namedChildren)Lo(n,t)}function bo(e){return{kind:"outline",constructKind:e.constructKind,signature:e.signature,lines:e.lines,coverage:e.coverage,rawCharacters:e.rawCharacters,renderedCharacters:e.outlineCharacters}}function $i(e,t,n,o,r,a){if(!t.location||!["symbol","source-construct","runtime-boundary-participant"].includes(t.kind))return[];let i=new Set,s=new Set(J(e,t.location.file)?.callSites.map(l=>l.line)??[]);if(t.kind==="runtime-boundary-participant"&&i.add(t.location.line),a.has(t.id))for(let l of Qt(e,{files:[t.location.file]}))l.source.startLine>=t.location.line&&l.source.startLine<=(t.location.endLine??t.location.line)&&i.add(l.source.startLine);for(let l of n){if(l.fromNodeId!==t.id&&l.toNodeId!==t.id)continue;let d=o.get(l.fromNodeId===t.id?l.toNodeId:l.fromNodeId),c=a.has(t.id)&&["call","reference","runtime-boundary"].includes(l.kind)&&l.fromNodeId===t.id,u=(d?.anchorIds.length??0)>0;if(!r.has(l.id)&&!c&&!u)continue;let f=l.evidence.flatMap(C=>C.location?.file===t.location.file?[C.location.line]:[]),m=f.filter(C=>s.has(C));for(let C of m.length>0?m:f)i.add(C);let p=d?.attributes.leaf;if(typeof p!="string"||p.length===0)continue;let g=Ee(e,t.location.file,p).filter(C=>C>=t.location.line&&C<=(t.location.endLine??t.location.line)),b=g.find(C=>s.has(C))??g[0];b!==void 0&&i.add(b)}return[...i].sort((l,d)=>l-d)}function Di(e,t){if(!e.location)return[];let n=e.location.endLine??e.location.line;return t.filter(o=>o.file===e.location.file&&o.line>=e.location.line&&o.line<=n).map(o=>o.line)}function _i(e){let t=new Map;for(let n of e){if(!n.file||!Number.isSafeInteger(n.line)||n.line<0)throw new RangeError(`Behavior focus locations require a repository file and non-negative line; received ${JSON.stringify(n)}.`);t.set(qe(n.file,n.line),{file:n.file,line:n.line})}return[...t.values()].sort((n,o)=>n.file.localeCompare(o.file)||n.line-o.line)}function qe(e,t){return`${e}\0${t}`}function Bi(e,t,n,o,r,a,i){if(!t.location)return null;let s=le(e,t.location.file),l=Me(e,t.location.file,n,o),d=[...l].filter(([,w])=>w.length>0).map(([w])=>w).sort((w,T)=>w-T),c=r.map(w=>(l.get(w)??[]).length>0?w:d.find(T=>T>w&&T-w<=8)??w),u=new Set([...r,...c]),f=i?Yt(e,t.location.file,n,o,{minimumBodyLines:0}):null,m=a?[...new Map(c.flatMap(w=>a.lines.filter(T=>T.text.length<=500&&T.signals.some(I=>["branch","loop","catch","finally"].includes(I))&&w>=T.line&&w<=T.endLine).sort((T,I)=>T.endLine-T.line-(I.endLine-I.line)||T.line-I.line).slice(0,2).map(T=>[`${T.line}\0${T.endLine}`,T]))).values()]:ht(e,t.location.file,n,o,c);for(let w of f?.lines??[])u.add(w.line);for(let w of m)u.add(w.line);for(let[w,T]of l)T.includes("call")&&T.includes("shape")&&u.add(w);let p=[];for(let w of c){let T=Ct(s[w]??"");if(!T)continue;let I=Ee(e,t.location.file,T).filter(B=>B>w&&B<=o),_=I[0];_!==void 0&&u.add(_);let A=I.find(B=>(l.get(B)??[]).some(U=>U==="branch"||U==="loop"));if(A===void 0)continue;u.add(A);let j=(a?.lines??[]).find(B=>B.line===A)??{line:A,endLine:Math.min(o,A+40),depth:0,signals:l.get(A)??[],text:(s[A]??"").trim(),copied:!0},$=a?.lines??s.slice(j.line,j.endLine+1).map((B,U)=>{let q=j.line+U;return{line:q,endLine:q,depth:0,signals:l.get(q)??[],text:B.trim(),copied:!0}});p.push({focusLine:w,governingUse:A,lines:$.filter(B=>B.line>=j.line&&B.line<=j.endLine&&B.text.length<=500&&B.signals.some(U=>["binding","branch","call","mutation"].includes(U)))})}for(let w of p.sort((T,I)=>I.governingUse-I.focusLine-(T.governingUse-T.focusLine)||T.focusLine-I.focusLine).slice(0,2))for(let T of w.lines.slice(0,14))u.add(T.line);let g=new Set(["binding","branch","loop","call","return","throw","mutation"]);for(let w of m)for(let T of a?.lines??[])T.line<w.line||T.line>w.endLine||T.signals.some(I=>g.has(I))&&u.add(T.line);let b=s.slice(n,o+1).flatMap((w,T)=>{let I=Ct(w);return I?[{name:I,line:n+T}]:[]}),C=!0;for(;C;){C=!1;for(let w of b)if([...u].some(I=>Gi(s[I]??"",w.name))){u.has(w.line)||(u.add(w.line),C=!0);for(let I of Ee(e,t.location.file,w.name))I<n||I>o||u.has(I)||(l.get(I)??[]).some(_=>g.has(_))&&(u.add(I),C=!0)}}for(let w of a?.lines??[])if(w.signals.some(T=>["branch","loop","catch","finally"].includes(T))&&u.has(w.line))for(let T of a?.lines??[])T.line<w.line||T.line>w.endLine||T.signals.some(I=>g.has(I))&&u.add(T.line);let S=J(e,t.location.file),v=new Set(S?.callSites.map(w=>w.line)??[]),R=l,y=new Map([...a?.lines??[],...m].filter(w=>w.signals.some(T=>["branch","loop","catch","finally"].includes(T))).map(w=>[w.line,w])),N=new Map((a?.lines??[]).filter(w=>w.text.length<=500&&w.signals.includes("shape")&&(w.signals.includes("call")||w.signals.includes("mutation")||w.signals.includes("return"))).sort((w,T)=>w.endLine-w.line-(T.endLine-T.line)||w.line-T.line).map(w=>[w.line,w])),L=new Map((f?.lines??[]).map(w=>[w.line,w.signals.filter(T=>T!=="lifecycle")])),x=[...u].filter(w=>w>=n&&w<=o).sort((w,T)=>w-T).map(w=>{let T=y.get(w)??N.get(w);return{line:w,endLine:T?.endLine??w,depth:T?.depth??0,signals:Oi([...R.get(w)??[],...a?.lines.filter(I=>w>=I.line&&w<=I.endLine).flatMap(I=>I.signals)??[],...L.get(w)??[],...r.includes(w)?["anchor"]:[],...v.has(w)?["call"]:[]]),text:T?.text??(s[w]??"").trim(),copied:T?.copied??!0}}).filter(w=>w.text.length>0);if(x.length===0)return null;let M=f?.candidateLines??Yt(e,t.location.file,n,o,{minimumBodyLines:0})?.candidateLines??0,h=Math.max(a?.coverage.sourceStatements??0,M,x.length),P=a?.signature??(s[n]??t.label).trim(),D=P.length+x.reduce((w,T)=>w+T.text.length+T.signals.join(",").length+12,0),O=s.slice(n,o+1).join(`
5
- `).length;return{kind:"connector-slice",constructKind:a?.constructKind??"source construct",signature:P,lines:x,coverage:{sourceStatements:h,representedStatements:x.length,copiedStatements:x.length,omittedStatements:Math.max(0,h-x.length)},rawCharacters:O,renderedCharacters:D}}function Oi(e){let t=["anchor","signature","binding","branch","loop","call","await","return","throw","mutation","shape","spread","catch","finally"],n=new Set(e);return t.filter(o=>n.has(o))}function Ct(e){return/\b(?:const|let|var)\s+([\p{L}_$][\p{L}\p{N}_$]*)\s*(?:=|\bof\b|\bin\b)/u.exec(e)?.[1]??null}function Gi(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`(?:^|[^\\p{L}\\p{N}_$])${n}(?:$|[^\\p{L}\\p{N}_$])`,"u").test(e)}function ji(e,t,n){return Le(e.flatMap(o=>{let r=n.get(o),a=t.filter(i=>i.kind==="call"&&i.toNodeId===o).map(i=>({edge:i,node:n.get(i.fromNodeId)})).filter(i=>i.node!==void 0&&["symbol","source-construct","runtime-boundary-participant"].includes(i.node.kind)&&i.node.location!==null).sort((i,s)=>{let l=So(s.edge)-So(i.edge);if(l!==0)return l;let d=vo(i.node,r)?0:1,c=vo(s.node,r)?0:1,u=(i.node.location?.endLine??i.node.location?.line??0)-(i.node.location?.line??0),f=(s.node.location?.endLine??s.node.location?.line??0)-(s.node.location?.line??0);return d-c||u-f||i.node.label.localeCompare(s.node.label)});return a[0]?[a[0].node.id]:[]}))}function So(e){let t={exact:4,mixed:3,derived:2,candidate:1,unknown:0};return Math.max(0,...e.evidence.map(n=>t[n.strength]))}function vo(e,t){return!e.location||!t?.location?!1:xo(e.location.file)===xo(t.location.file)}function xo(e){return e.split("/").filter(Boolean).slice(0,2).join("/")}function Ki(e,t,n,o){let r=new Set(e),a=new Set,i=[],s=Le(e);for(let l=0;l<o&&s.length>0;l+=1){let d=s.filter(u=>!a.has(u));for(let u of d)a.add(u);let c=ji(d,t,n);s=[];for(let u of c)!r.has(u)&&!i.includes(u)&&i.push(u),a.has(u)||s.push(u)}return i}function qi(e,t,n){let o=new Map(n.paths.flatMap(r=>r.edgeIds).map((r,a)=>[r,a]));return(o.get(e.id)??Number.MAX_SAFE_INTEGER)-(o.get(t.id)??Number.MAX_SAFE_INTEGER)||e.id.localeCompare(t.id)}function zi(e){return`step:${e}`}function Ui(e){return`transition:${e}`}function Eo(e,t){return e.length===0?null:`scip-query inspect ${e.map(n=>`--at ${Wi(n)}`).join(" ")} --view ${t}`}function Wi(e){return`'${e.replace(/'/gu,`'"'"'`)}'`}function Le(e){return[...new Set(e)]}var Hi=6;function Io(e,t,n){return`${e}\0${t}\0${n??t}`}function Ro(e,t,n,o={}){let r=o.limit??Hi;if(!Number.isSafeInteger(r)||r<=0)throw new RangeError(`next-anchor limit must be a positive safe integer; received ${r}`);let a=o.sourceAllowed??(()=>!0),i=new Map(t.nodes.map(x=>[x.id,x])),s=new Set(n.steps.map(x=>x.nodeId)),l=new Set(n.steps.flatMap(x=>{let M=sn(i.get(x.nodeId));return M?[M]:[]})),d=new Set;for(let x of n.steps)for(let M of x.behavior?.supportingDeclarations??[])l.add(M.symbol),d.add(Io(M.file,M.line,M.endLine));let c=x=>x.symbol!==null&&l.has(x.symbol)||d.has(Io(x.file,x.line,x.endLine)),u=new Map(n.steps.flatMap(x=>{if(!x.location)return[];let M=sn(i.get(x.nodeId));if(!M)return[];let h=X(e,x.location.file).find(P=>P.symbol===M);return h?[[x.id,h]]:[]})),f=new bt(e).calleeMap([...u.values()],{additive:!1,semantic:!0}),m=[],p=new Set,g=new Set,b=0,C=0,S=0,v=0,R=0,y=0,N=0,L=0;for(let x of n.steps){if(!x.location||!x.behavior)continue;let M=Vi(x,{db:e,topology:t,nodeById:i,returnedNodeIds:s,sourceAllowed:a,alternativeAlreadyReturned:c});m.push(...M.candidates),y+=M.upstreamCandidates,L+=M.runtimeCandidates,N+=M.resultCandidates;let h=Qi(x,{db:e,topology:t,nodeById:i,returnedNodeIds:s,sourceAllowed:a,alternativeAlreadyReturned:c},p);m.push(...h);let P=Yi(x,{db:e,topology:t,nodeById:i,returnedNodeIds:s,sourceAllowed:a,alternativeAlreadyReturned:c},{evidencedCallsiteKeys:p,consideredCandidateKeys:g,calleeMap:f,stepDefinition:u.get(x.id)});m.push(...P.candidates),b+=P.scannedBehaviorSteps,C+=P.visibleCallsites,S+=P.identityCandidateCallsites,v+=P.ambiguousCallsites,R+=P.unresolvedCallsites}return Xi(e,m,n.steps,r,{scannedBehaviorSteps:b,visibleCallsites:C,graphEvidencedCallsites:p.size,identityCandidateCallsites:S,ambiguousCallsites:v,unresolvedCallsites:R,upstreamCandidates:y,resultCandidates:N,runtimeCandidates:L},o.selectionTerms)}function Vi(e,t){let n=[],o=0,r=0,a=0;if(!e.location||!e.behavior)return{candidates:n,upstreamCandidates:o,resultCandidates:r,runtimeCandidates:a};let i=t.topology.edges.filter(l=>["call","runtime-boundary"].includes(l.kind)&&(l.fromNodeId===e.nodeId||l.toNodeId===e.nodeId)&&l.disposition!=="excluded"&&l.disposition!=="unsupported");for(let l of i){let d=l.toNodeId===e.nodeId,c=d?l.fromNodeId:l.toNodeId;if(t.returnedNodeIds.has(c))continue;let u=t.nodeById.get(c);if(!u?.location||!t.sourceAllowed(u.location.file))continue;let f=l.kind==="call"?ln(t.db,u):pn(u);if(!f||t.alternativeAlreadyReturned(f))continue;let m=cn(l,u.location.file)??u.location,p=le(t.db,m.file)[m.line]?.trim(),g=d?"upstream":"downstream",b=l.kind==="runtime-boundary"?d?"runtime-producer":"runtime-consumer":d?"caller":"callee",C=dn(l.evidence),S=Je(u);n.push({anchor:{id:ze(e.id,m.line,u.id),status:C,source:"graph-relation",direction:g,causalRole:b,relationKind:l.kind,fromStepId:e.id,fromLabel:e.label,callsite:{file:m.file,line:m.line,endLine:m.endLine??m.line,text:p||`${u.label} \u2192 ${e.label}`,signals:["call"],calleeLeaf:S},alternatives:[f],alternativeCount:1,evidence:l.evidence}}),d&&(o+=1),l.kind==="runtime-boundary"&&(a+=1)}let s=t.topology.edges.filter(l=>l.kind==="reference"&&l.fromNodeId===e.nodeId&&l.disposition!=="excluded"&&l.disposition!=="unsupported"&&!t.returnedNodeIds.has(l.toNodeId));for(let l of s){let d=t.nodeById.get(l.toNodeId);if(!d?.location||!t.sourceAllowed(d.location.file))continue;let c=ln(t.db,d);if(!c||t.alternativeAlreadyReturned(c))continue;let u=Je(d),f=cn(l,e.location.file)?.line,m=e.behavior.lines.find(b=>(f===void 0||f>=b.line&&f<=b.endLine)&&b.text.includes(u));if(!m)continue;let p=Fo(m.signals),g=dn(l.evidence);n.push({anchor:{id:ze(e.id,m.line,d.id),status:g,source:"graph-relation",direction:"downstream",causalRole:p,relationKind:"reference",fromStepId:e.id,fromLabel:e.label,callsite:{file:e.location.file,line:m.line,endLine:m.endLine,text:m.text,signals:m.signals,calleeLeaf:u},alternatives:[c],alternativeCount:1,evidence:l.evidence}}),p==="result-callback"&&(r+=1)}return{candidates:n,upstreamCandidates:o,resultCandidates:r,runtimeCandidates:a}}function Qi(e,t,n){let o=[];if(!e.location)return o;let r=xt(t.db,e.location.file,e.location.line,e.location.endLine??e.location.line),a=le(t.db,e.location.file),i=Me(t.db,e.location.file,e.location.line,e.location.endLine??e.location.line);for(let s of r.targets){if(!t.sourceAllowed(s.definition.relativePath))continue;let l=Lt(e.location.file,s.sourceLine,s.calleeLeaf);if(n.has(l))continue;n.add(l);let d=Ji(i.get(s.sourceLine)),c={symbol:s.definition.symbol,label:s.definition.leaf,file:s.definition.relativePath,line:s.definition.startLine,endLine:s.definition.endLine};t.alternativeAlreadyReturned(c)||o.push({anchor:{id:ze(e.id,s.sourceLine,s.definition.symbol),status:"exact",source:"graph-call",direction:"downstream",causalRole:"callee",relationKind:"call",fromStepId:e.id,fromLabel:e.label,callsite:{file:e.location.file,line:s.sourceLine,endLine:s.sourceLine,text:a[s.sourceLine]?.trim()||`${s.calleeLeaf}()`,signals:d,calleeLeaf:s.calleeLeaf},alternatives:[c],alternativeCount:1,evidence:[{method:"scip-occurrence-callsite",strength:"exact",identity:s.definition.symbol,location:{file:e.location.file,line:s.sourceLine}}]}})}return o}function Yi(e,t,n){let o={candidates:[],scannedBehaviorSteps:0,visibleCallsites:0,identityCandidateCallsites:0,ambiguousCallsites:0,unresolvedCallsites:0};if(!e.location||!e.behavior)return o;let r=e.behavior.lines.filter(p=>p.signals.includes("call"));if(r.length===0)return o;let a=[],i=0,s=0,l=0,d=(J(t.db,e.location.file)?.callSites??[]).filter(p=>r.some(g=>p.line>=g.line&&p.line<=g.endLine)),c=t.topology.edges.filter(p=>p.kind==="call"&&p.fromNodeId===e.nodeId&&p.disposition!=="excluded"&&p.disposition!=="unsupported"),u=new Map;for(let p of c){let g=t.nodeById.get(p.toNodeId);if(!g)continue;let b=Je(g);u.set(b,(u.get(b)??0)+1)}let f=ea(t.db,n.stepDefinition?n.calleeMap.get(n.stepDefinition.symbolId)??[]:[]),m=ta(f);for(let p of f){if(!t.sourceAllowed(p.alternative.file)||t.alternativeAlreadyReturned(p.alternative))continue;let g=Xe(p.alternative.label),b=No(d,r,g,p.row.callsiteLine,m.get(g)===1);if(!b)continue;let C=Ze(r,b.line,g);if(!C)continue;let S=Lt(e.location.file,b.line,g);if(n.evidencedCallsiteKeys.has(S))continue;n.evidencedCallsiteKeys.add(S);let v=Ao(p.row.source);a.push({anchor:{id:ze(e.id,b.line,p.alternative.symbol??p.alternative.file),status:v,source:"graph-call",direction:"downstream",causalRole:"callee",relationKind:"call",fromStepId:e.id,fromLabel:e.label,callsite:{file:e.location.file,line:C.line,endLine:C.endLine,text:C.text,signals:C.signals,calleeLeaf:g},alternatives:[p.alternative],alternativeCount:1,evidence:[{method:p.row.source,strength:v,identity:p.row.symbol,location:{file:e.location.file,line:b.line}}]}})}for(let p of c){if(t.returnedNodeIds.has(p.toNodeId))continue;let g=t.nodeById.get(p.toNodeId);if(!g?.location||!t.sourceAllowed(g.location.file))continue;let b=Je(g),C=p.evidence.find(L=>{let x=L.location;return x!==null&&x.file===e.location?.file&&x.line>=0})?.location?.line,S=No(d,r,b,C,u.get(b)===1);if(!S)continue;let v=Ze(r,S.line,b);if(!v)continue;let R=Lt(e.location.file,S.line,b);if(n.evidencedCallsiteKeys.has(R))continue;n.evidencedCallsiteKeys.add(R);let y=pn(g);if(!y||t.alternativeAlreadyReturned(y))continue;let N=dn(p.evidence);a.push({anchor:{id:ze(e.id,S.line,g.id),status:N,source:"graph-call",direction:"downstream",causalRole:"callee",relationKind:"call",fromStepId:e.id,fromLabel:e.label,callsite:{file:e.location.file,line:v.line,endLine:v.endLine,text:v.text,signals:v.signals,calleeLeaf:b},alternatives:[y],alternativeCount:1,evidence:p.evidence}})}for(let p of d){let g=Lt(e.location.file,p.line,p.calleeLeaf);if(n.evidencedCallsiteKeys.has(g))continue;let b=Ze(r,p.line,p.calleeLeaf);if(!b)continue;let C=ft(e.location.file,gt(t.db).get(p.calleeLeaf)??[]).flatMap(y=>X(t.db,y.file).filter(N=>N.symbol===y.symbol&&N.isFunctionLike)).filter(y=>t.sourceAllowed(y.relativePath)&&!t.alternativeAlreadyReturned({symbol:y.symbol,label:y.leaf,file:y.relativePath,line:y.startLine,endLine:y.endLine})),S=un(C.map(y=>({symbol:y.symbol,label:y.leaf??p.calleeLeaf,file:y.relativePath,line:y.startLine,endLine:y.endLine})));if(S.length===0){l+=1;continue}let v=`${e.id}\0${p.line}\0${p.calleeLeaf}`;if(n.consideredCandidateKeys.has(v))continue;n.consideredCandidateKeys.add(v);let R=S.length>1;R?s+=1:i+=1,a.push({anchor:{id:ze(e.id,p.line,p.calleeLeaf),status:R?"ambiguous":"candidate",source:"leaf-identity-candidate",direction:"downstream",causalRole:"callee",relationKind:"call",fromStepId:e.id,fromLabel:e.label,callsite:{file:e.location.file,line:b.line,endLine:b.endLine,text:b.text,signals:b.signals,calleeLeaf:p.calleeLeaf},alternatives:S.slice(0,3),alternativeCount:S.length,evidence:[]}})}return{candidates:a,scannedBehaviorSteps:1,visibleCallsites:d.length,identityCandidateCallsites:i,ambiguousCallsites:s,unresolvedCallsites:l}}function To(e,t,n){let o=new Map(t.nodes.map(r=>[r.id,r]));for(let r of n.steps)if(!(!r.behavior||!r.location))for(let a of t.edges){if(a.kind!=="reference"||a.fromNodeId!==r.nodeId||a.disposition==="excluded"||a.disposition==="unsupported")continue;let i=o.get(a.toNodeId);if(!i?.location||!ln(e,i))continue;let s=Je(i),l=cn(a,r.location.file)?.line,d=r.behavior.lines.find(c=>(l===void 0||l>=c.line&&l<=c.endLine)&&c.text.includes(s));!d||Fo(d.signals)!=="result-callback"||a.semantics?.some(({family:c,subtype:u})=>c==="control"&&u==="result-callback")||(a.semantics=[...a.semantics??[],{family:"control",subtype:"result-callback",attributes:{evidenceRole:"result-producing-callable-reference"}}])}}function Fo(e){return e.includes("call")&&e.some(t=>["return","mutation","shape","spread","binding"].includes(t))?"result-callback":"callable-reference"}function Xi(e,t,n,o,r,a=[]){let i=na(t).sort(Po),s=i.filter(p=>Zi(e,p)).slice(0,o),l=new Set(s.map(p=>p.anchor.id)),d=i.filter(p=>!l.has(p.anchor.id)),c=s.map(p=>p.anchor),u=d.map(p=>p.anchor),f=un(c.flatMap(p=>p.alternativeCount===1?p.alternatives:[])),m=un(u.flatMap(p=>p.alternativeCount===1?p.alternatives:[]));return{anchors:c,withheldAnchors:u,candidateAnchors:i.length,omittedAnchors:Math.max(0,i.length-c.length),...r,inspectCommand:f.length===0?null:`scip-query inspect ${f.map(Mo).join(" ")} --view behavior`,remainingInspectCommands:ra(m,8).map(p=>`scip-query inspect ${p.map(Mo).join(" ")} --view behavior`)}}function Po(e,t){let n=e.anchor.alternatives[0],o=t.anchor.alternatives[0];return It(e.anchor.status)-It(t.anchor.status)||(e.anchor.direction??"").localeCompare(t.anchor.direction??"")||(e.anchor.relationKind??"").localeCompare(t.anchor.relationKind??"")||(e.anchor.causalRole??"").localeCompare(t.anchor.causalRole??"")||e.anchor.fromStepId.localeCompare(t.anchor.fromStepId)||e.anchor.callsite.file.localeCompare(t.anchor.callsite.file)||e.anchor.callsite.line-t.anchor.callsite.line||(n?.file??"").localeCompare(o?.file??"")||(n?.line??0)-(o?.line??0)||e.anchor.id.localeCompare(t.anchor.id)}function Zi(e,t){if(t.anchor.alternativeCount!==1)return!0;let n=t.anchor.alternatives[0],o=n.endLine??n.line;return le(e,n.file).slice(n.line,o+1).join(`
6
- `).length<=2e4}function Ji(e){return e?.includes("call")?[...e]:["call",...e??[]]}function ea(e,t){let n=new Map;for(let o of t){let r=X(e,o.file).find(s=>s.symbol===o.symbol&&s.isFunctionLike);if(!r)continue;let a={symbol:r.symbol,label:r.leaf,file:r.relativePath,line:r.startLine,endLine:r.endLine},i=n.get(r.symbol);!i||wo(o.source)>wo(i.row.source)?n.set(r.symbol,{row:{...o,...o.callsiteLine===void 0&&i?.row.callsiteLine!==void 0?{callsiteLine:i.row.callsiteLine}:{}},alternative:a}):i.row.callsiteLine===void 0&&o.callsiteLine!==void 0&&n.set(r.symbol,{...i,row:{...i.row,callsiteLine:o.callsiteLine}})}return[...n.values()]}function ta(e){let t=new Map;for(let n of e){let o=Xe(n.alternative.label);t.set(o,(t.get(o)??0)+1)}return t}function Ao(e){return e==="semantic-callee"||e==="scip-chunk"?"exact":"derived"}function wo(e){return Ao(e)==="exact"?2:1}function Ze(e,t,n){return e.find(o=>t>=o.line&&t<=o.endLine&&o.text.includes(n))??e.find(o=>t>=o.line&&t<=o.endLine)??null}function No(e,t,n,o,r){if(o!==void 0)return e.find(i=>i.line===o&&i.calleeLeaf===n&&Ze(t,i.line,n)!==null)??null;let a=e.filter(i=>i.calleeLeaf===n&&Ze(t,i.line,i.calleeLeaf)!==null);return r&&a.length===1?a[0]:null}function Je(e){let t=e.attributes.leaf;if(typeof t=="string"&&t.length>0)return Xe(t);let n=e.label.slice(e.label.lastIndexOf(":")+1);return Xe(n)}function sn(e){if(e?.kind!=="symbol"||!e.id.startsWith("symbol:"))return null;try{return decodeURIComponent(e.id.slice(7))}catch{return null}}function pn(e){return e.location?{symbol:sn(e),label:e.label,file:e.location.file,line:e.location.line,endLine:e.location.endLine??null}:null}function ln(e,t){let n=pn(t);return n?.symbol&&X(e,n.file).some(r=>r.symbol===n.symbol&&r.isFunctionLike)?n:null}function cn(e,t){return e.evidence.find(n=>n.location?.file===t)?.location??e.evidence.find(n=>n.location!==null)?.location??null}function dn(e){let t={exact:5,derived:4,mixed:3,candidate:2,unknown:1};return e.reduce((n,o)=>t[o.strength]>t[n]?o.strength:n,"unknown")}function na(e){let t=new Map;for(let n of e){let r=n.anchor.alternatives[0]?.symbol??`${n.anchor.callsite.file}:${n.anchor.callsite.line}:${n.anchor.callsite.calleeLeaf}`,a=t.get(r);(!a||oa(n,a)<0)&&t.set(r,n)}return[...t.values()]}function oa(e,t){return It(e.anchor.status)-It(t.anchor.status)||e.anchor.alternativeCount-t.anchor.alternativeCount||Po(e,t)}function It(e){return{exact:0,derived:1,mixed:2,candidate:3,unknown:4,ambiguous:5}[e]}function un(e){let t=new Map;for(let n of e)t.set(n.symbol??`${n.file}:${n.line}`,n);return[...t.values()].sort((n,o)=>n.file.localeCompare(o.file)||n.line-o.line||n.label.localeCompare(o.label))}function Mo(e){return`--at ${ia(`${e.file}:${e.line+1}`)}`}function ra(e,t){let n=[];for(let o=0;o<e.length;o+=t)n.push(e.slice(o,o+t));return n}function ia(e){return`'${e.replaceAll("'","'\\''")}'`}function Lt(e,t,n){return`${e}\0${t}\0${n}`}function ze(e,t,n){return["next-anchor",e,String(t),n].map(encodeURIComponent).join(":")}var ko=["call","contract-symbol","import","reference","runtime-boundary"],aa={call:[{family:"control",subtype:"call"}],"contract-symbol":[{family:"contract",subtype:"uses-contract-symbol"}],import:[{family:"identity",subtype:"imports"}],reference:[{family:"identity",subtype:"references"}]},sa={"structural-membership":[{family:"identity",subtype:"contains"}],"boundary-observation":[{family:"identity",subtype:"owns-runtime-observation"}],"external-import":[{family:"identity",subtype:"imports-external"}]};function $o(e){if(e.kind!=="runtime-boundary")return Do(aa[e.kind]);let t=e.fromBoundaryParticipant?.protocol??e.toBoundaryParticipant?.protocol,n={crossesRuntimeBoundary:!0,...t?{protocol:t}:{},...e.runtimeBoundaryKey?{runtimeKey:e.runtimeBoundaryKey}:{}},o=[{family:"control",subtype:"runtime-handoff",context:n}];return e.evidence==="runtime-boundary:carrier.discriminator"&&(o.push({family:"control",subtype:"discriminator-dispatch",context:{...n},attributes:{joinRule:"carrier.discriminator",...e.fromBoundaryParticipant?.action?{producerAction:e.fromBoundaryParticipant.action}:{},...e.toBoundaryParticipant?.action?{consumerAction:e.toBoundaryParticipant.action}:{}}}),o.push({family:"data",subtype:"serialized-discriminator-transfer",context:{...n},attributes:{joinRule:"carrier.discriminator"}})),e.evidence==="runtime-boundary:queue.address"&&e.fromBoundaryParticipant?.action==="queue.send"&&e.toBoundaryParticipant?.action==="queue.consume"&&o.push({family:"temporal",subtype:"enqueue-before-consume",context:{...n},attributes:{producerAction:e.fromBoundaryParticipant.action,consumerAction:e.toBoundaryParticipant.action,retryPolicy:"unknown"}}),o}function wt(e){return Do(sa[e])}function Do(e){return e.map(t=>({...t,...t.context?{context:{...t.context}}:{},...t.attributes?{attributes:{...t.attributes}}:{}}))}import{join as Aa}from"path";import{createRequire as la}from"module";import{resolve as tt}from"path";var ca=la(import.meta.url),et;function Bo(e,t,n){let o=da();if(!o)return mn("The TypeScript compiler runtime is unavailable.");let r=ua(o,e,t),a=r.getSourceFile(tt(t))??r.getSourceFile(t);if(!a)return mn(`The TypeScript compiler did not materialize ${t}.`);let i={ts:o,sourceFile:a,checker:r.getTypeChecker(),points:new Map,edges:new Map,unsupported:new Set,nextCfgId:0},s=ma(o,a,n);if(s.length===0)return mn("No function-like construct intersects the selected source range.");let l=new Map(s.map(u=>[u,fa(a,u)])),d=s.map(u=>ya(i,u,ga(o,u,l),l.get(u)));for(let u of d)ha(i,u),xa(i,u),La(i,u);wa(i,d);let c=[...i.unsupported].sort();return{points:[...i.points.values()].map(({node:u,...f})=>f).sort(Pa),edges:[...i.edges.values()].sort((u,f)=>u.id.localeCompare(f.id)),coverage:{status:c.length===0?"complete":"partial",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:c}}}function da(){if(et!==void 0)return et;try{et=ca("typescript")}catch{et=Kn()?.ts??null}return et}function ua(e,t,n){let o=tt(n),r={target:e.ScriptTarget.ESNext,module:e.ModuleKind.NodeNext,moduleResolution:e.ModuleResolutionKind.NodeNext,skipLibCheck:!0,noResolve:!0},a=e.createSourceFile(o,t,r.target,!0,pa(e,o)),i=e.createCompilerHost(r,!0),s=i.getSourceFile.bind(i),l=i.readFile.bind(i),d=i.fileExists.bind(i);return i.getSourceFile=(c,u,f,m)=>tt(c)===o?a:s(c,u,f,m),i.readFile=c=>tt(c)===o?t:l(c),i.fileExists=c=>tt(c)===o||d(c),e.createProgram([o],r,i)}function pa(e,t){return/\.tsx$/iu.test(t)?e.ScriptKind.TSX:/\.[cm]?js$/iu.test(t)?e.ScriptKind.JS:/\.jsx$/iu.test(t)?e.ScriptKind.JSX:e.ScriptKind.TS}function ma(e,t,n){let o=[],r=a=>{if(Oo(e,a)){let i=t.getLineAndCharacterOfPosition(a.getStart(t)).line,s=t.getLineAndCharacterOfPosition(a.getEnd()).line;(!n||i<=n.endLine&&s>=n.startLine)&&o.push(a)}a.forEachChild(r)};return t.forEachChild(r),o.sort((a,i)=>a.getStart(t)-i.getStart(t))}function Oo(e,t){return e.isFunctionLike(t)&&"body"in t&&t.body!==void 0}function fa(e,t){return`callable:${encodeURIComponent(e.fileName)}:${t.getStart(e)}:${t.getEnd()}`}function ga(e,t,n){for(let o=t.parent;o;o=o.parent)if(Oo(e,o)&&n.has(o))return n.get(o);return null}function ya(e,t,n,o){let r=new Map,a=te(e,r,"exit",null),i=t.body,s=a.id;if(i&&e.ts.isBlock(i))s=fn(e,r,[...i.statements],a.id,{breakTarget:null,continueTarget:null});else if(i){let d=te(e,r,"statement",i);Q(r,d.id,a.id),s=d.id}let l=te(e,r,"entry",t);return Q(r,l.id,s),{id:o,node:t,parentId:n,cfg:r,entryId:l.id,exitId:a.id}}function fn(e,t,n,o,r){let a=o;for(let i=n.length-1;i>=0;i-=1)a=ke(e,t,n[i],a,r);return a}function ke(e,t,n,o,r){let a=e.ts;if(a.isBlock(n))return fn(e,t,[...n.statements],o,r);if(a.isIfStatement(n)){let s=te(e,t,"predicate",n.expression),l=ke(e,t,n.thenStatement,o,r),d=n.elseStatement?ke(e,t,n.elseStatement,o,r):o;return Q(t,s.id,l),Q(t,s.id,d),s.id}if(a.isWhileStatement(n)){let s=te(e,t,"predicate",n.expression),l=ke(e,t,n.statement,s.id,{breakTarget:o,continueTarget:s.id});return Q(t,s.id,l),Q(t,s.id,o),s.id}if(a.isDoStatement(n)){let s=te(e,t,"predicate",n.expression),l=ke(e,t,n.statement,s.id,{breakTarget:o,continueTarget:s.id});return Q(t,s.id,l),Q(t,s.id,o),l}if(a.isForStatement(n)){let s=te(e,t,"predicate",n.condition??n),l=n.incrementor?te(e,t,"statement",n.incrementor):null;l&&Q(t,l.id,s.id);let d=l?.id??s.id,c=ke(e,t,n.statement,d,{breakTarget:o,continueTarget:d});if(Q(t,s.id,c),n.condition&&Q(t,s.id,o),!n.initializer)return s.id;let u=te(e,t,"statement",n.initializer);return Q(t,u.id,s.id),u.id}if(a.isForInStatement(n)||a.isForOfStatement(n)){e.unsupported.add("for-in/for-of iterator assignment is conservatively represented without iterable element flow.");let s=te(e,t,"predicate",n.expression),l=te(e,t,"statement",n.initializer),d=ke(e,t,n.statement,s.id,{breakTarget:o,continueTarget:s.id});return Q(t,s.id,l.id),Q(t,s.id,o),Q(t,l.id,d),s.id}if(a.isSwitchStatement(n)){e.unsupported.add("switch fallthrough is represented conservatively; discriminant-to-case value refinement is unsupported.");let s=te(e,t,"predicate",n.expression),l=o,d=[];for(let c=n.caseBlock.clauses.length-1;c>=0;c-=1){let u=n.caseBlock.clauses[c];l=fn(e,t,[...u.statements],l,{...r,breakTarget:o}),d.push(l)}for(let c of d)Q(t,s.id,c);return Q(t,s.id,o),s.id}if(a.isReturnStatement(n)||a.isThrowStatement(n)){let s=te(e,t,"statement",n),l=[...t.values()].find(d=>d.kind==="exit");return Q(t,s.id,l.id),s.id}if(a.isBreakStatement(n)){let s=te(e,t,"statement",n);return r.breakTarget||e.unsupported.add("A break statement could not be attached to a structured target."),Q(t,s.id,r.breakTarget??o),s.id}if(a.isContinueStatement(n)){let s=te(e,t,"statement",n);return r.continueTarget||e.unsupported.add("A continue statement could not be attached to a structured target."),Q(t,s.id,r.continueTarget??o),s.id}if(a.isTryStatement(n)){e.unsupported.add("Exceptional control-flow and finally completion are not included in the local compiler CFG.");let s=te(e,t,"statement",n);return s.invalidatesAllDefinitions=!0,Q(t,s.id,o),s.id}let i=te(e,t,"statement",n);return Q(t,i.id,o),i.id}function te(e,t,n,o){let r={id:`cfg:${e.nextCfgId++}`,kind:n,ast:o,successors:new Set,predecessors:new Set,definitions:[],uses:[],displayPoint:null,invalidatesAllDefinitions:!1};return t.set(r.id,r),r}function Q(e,t,n){e.get(t).successors.add(n),e.get(n).predecessors.add(t)}function ha(e,t){let n=t.cfg.get(t.entryId);for(let o of t.node.parameters){let r=$e(e,o.name);if(!r){e.unsupported.add("Destructured parameter definition-use is not implemented.");continue}n.definitions.push({point:De(e,r.node,"parameter-definition",r.symbolKey,r.name,t.id),rhsUseIds:[]})}for(let o of t.cfg.values())!o.ast||o.kind==="entry"||o.kind==="exit"||(o.kind==="predicate"&&(o.displayPoint=De(e,o.ast,"predicate",null,"predicate",t.id)),ba(e,t,o,o.ast),!o.displayPoint&&o.definitions.length===0&&o.uses.length===0&&(o.displayPoint=De(e,o.ast,"statement",null,Ma(e,o.ast),t.id)))}function ba(e,t,n,o){let r=e.ts;if(r.isTryStatement(o))return;let a=i=>{if(!(i!==o&&r.isFunctionLike(i))){if(r.isVariableDeclaration(i)){let s=i.initializer?Nt(e,t.id,i.initializer,n):[];n.uses.push(...s);let l=$e(e,i.name);l?n.definitions.push({point:De(e,l.node,"definition",l.symbolKey,l.name,t.id),rhsUseIds:s.map(d=>d.point.id)}):(n.invalidatesAllDefinitions=!0,e.unsupported.add("Destructured variable reaching definitions are not implemented."));return}if(r.isBinaryExpression(i)&&Ko(r,i.operatorToken.kind)){let s=Nt(e,t.id,i.right,n);i.operatorToken.kind!==r.SyntaxKind.EqualsToken&&s.push(...Nt(e,t.id,i.left,n)),n.uses.push(...s);let l=$e(e,i.left);l?n.definitions.push({point:De(e,l.node,"definition",l.symbolKey,l.name,t.id),rhsUseIds:s.map(d=>d.point.id)}):(n.invalidatesAllDefinitions=!0,e.unsupported.add("Dynamic or destructured assignment targets are not included in reaching definitions."));return}if((r.isPrefixUnaryExpression(i)||r.isPostfixUnaryExpression(i))&&(i.operator===r.SyntaxKind.PlusPlusToken||i.operator===r.SyntaxKind.MinusMinusToken)){let s=Nt(e,t.id,i.operand,n);n.uses.push(...s);let l=$e(e,i.operand);l&&n.definitions.push({point:De(e,l.node,"definition",l.symbolKey,l.name,t.id),rhsUseIds:s.map(d=>d.point.id)});return}if(!(r.isFunctionDeclaration(i)||r.isClassDeclaration(i)||r.isInterfaceDeclaration(i))){if(Go(e,i)){let s=jo(e,t.id,i);s&&n.uses.push(s),r.isPropertyAccessExpression(i)&&a(i.expression);return}i.forEachChild(a)}}};a(o),n.uses=qo(n.uses)}function Nt(e,t,n,o){let r=[],a=i=>{if(!e.ts.isFunctionLike(i)){if(e.ts.isBinaryExpression(i)&&Ko(e.ts,i.operatorToken.kind)){o.invalidatesAllDefinitions=!0,e.unsupported.add("Nested assignment expressions are not included in ordered local definition-use flow."),i.operatorToken.kind!==e.ts.SyntaxKind.EqualsToken&&a(i.left),a(i.right);return}if(Go(e,i)){let s=jo(e,t,i);s&&r.push(s),e.ts.isPropertyAccessExpression(i)&&a(i.expression);return}i.forEachChild(a)}};return a(n),qo(r)}function Go(e,t){if(e.ts.isPropertyAccessExpression(t))return!0;if(!e.ts.isIdentifier(t))return!1;let n=t.parent;return!(e.ts.isPropertyAccessExpression(n)&&n.name===t||"name"in n&&n.name===t&&Sa(e.ts,n)||e.ts.isPropertyAssignment(n)&&n.name===t||e.ts.isBindingElement(n)&&n.propertyName===t||e.ts.isLabeledStatement(n)||e.ts.isBreakOrContinueStatement(n)||va(e.ts,t))}function Sa(e,t){return e.isVariableDeclaration(t)||e.isParameter(t)||e.isFunctionDeclaration(t)||e.isFunctionExpression(t)||e.isClassDeclaration(t)||e.isMethodDeclaration(t)||e.isPropertyDeclaration(t)||e.isInterfaceDeclaration(t)||e.isTypeAliasDeclaration(t)||e.isImportSpecifier(t)||e.isImportClause(t)||e.isNamespaceImport(t)}function va(e,t){for(let n=t.parent;n;n=n.parent){if(e.isExpression(n)||e.isStatement(n)||e.isSourceFile(n))return!1;if(e.isTypeNode(n))return!0}return!1}function jo(e,t,n){let o=$e(e,n);return o?{point:De(e,o.node,"use",o.symbolKey,o.name,t),property:e.ts.isPropertyAccessExpression(n)}:null}function $e(e,t){let n=e.ts;if(n.isIdentifier(t)){let o=_o(e,t);return o?{node:t,symbolKey:o,name:t.text}:null}if(n.isPropertyAccessExpression(t)){let o=_o(e,t.name);return o?{node:t,symbolKey:o,name:t.getText(e.sourceFile)}:null}return n.isParenthesizedExpression(t)||n.isAsExpression(t)||n.isTypeAssertionExpression(t)||n.isNonNullExpression(t)?$e(e,t.expression):((n.isArrayLiteralExpression(t)||n.isObjectLiteralExpression(t))&&e.unsupported.add("Heap aggregate identity and destructured assignment are not included in local points-to flow."),null)}function _o(e,t){let n=e.checker.getSymbolAtLocation(t);if(!n)return null;if((n.flags&e.ts.SymbolFlags.Alias)!==0)try{n=e.checker.getAliasedSymbol(n)}catch{}let o=n.valueDeclaration??n.declarations?.[0];return o?`symbol:${encodeURIComponent(o.getSourceFile().fileName)}:${o.getStart()}:${n.getName()}`:`symbol:${n.getName()}`}function De(e,t,n,o,r,a){let i=t.getStart(e.sourceFile),s=t.getEnd(),l=e.sourceFile.getLineAndCharacterOfPosition(i),d=`flow-point:${encodeURIComponent(e.sourceFile.fileName)}:${i}:${s}:${n}:${encodeURIComponent(o??r)}`,c=e.points.get(d);if(c)return c;let u={id:d,kind:n,name:r,symbolKey:o,callableId:a,start:i,end:s,line:l.line,column:l.character,node:t};return e.points.set(d,u),u}function xa(e,t){let n=[...t.cfg.values()].flatMap(l=>l.definitions),o=new Map(n.map(l=>[l.point.id,l])),r=Ea(n),a=new Map,i=new Map;for(let l of t.cfg.values())a.set(l.id,new Set),i.set(l.id,new Set);let s=!0;for(;s;){s=!1;for(let l of t.cfg.values()){let d=Ta([...l.predecessors].map(f=>i.get(f))),c=new Set(d);l.invalidatesAllDefinitions&&c.clear();let u=Ca(l.definitions);for(let f of u){for(let m of r.get(f.point.symbolKey)??[])c.delete(m.point.id);c.add(f.point.id)}gn(a.get(l.id),d)||(a.set(l.id,d),s=!0),gn(i.get(l.id),c)||(i.set(l.id,c),s=!0)}}for(let l of t.cfg.values()){let d=a.get(l.id);for(let c of l.uses){let u=l.definitions.filter(m=>m.point.symbolKey===c.point.symbolKey&&m.point.start<c.point.start&&!m.rhsUseIds.includes(c.point.id)).sort((m,p)=>p.point.start-m.point.start)[0],f=u?[u.point.id]:d;for(let m of f){let p=o.get(m);p.point.symbolKey===c.point.symbolKey&&nt(e,"reaching-definition",p.point.id,c.point.id,"exact","A CFG path reaches this use without an intervening definition.")}}for(let c of l.definitions)for(let u of c.rhsUseIds)nt(e,"value-source",u,c.point.id,"exact","This right-hand-side use supplies the new definition.")}}function Ea(e){let t=new Map;for(let n of e){if(!n.point.symbolKey)continue;let o=t.get(n.point.symbolKey)??[];o.push(n),t.set(n.point.symbolKey,o)}return t}function Ca(e){let t=new Map;for(let n of e)n.point.symbolKey&&t.set(n.point.symbolKey,n);return[...t.values()]}function La(e,t){let n=Ia(t);for(let o of t.cfg.values()){if(o.successors.size<2||!o.displayPoint)continue;let r=n.get(o.id);for(let a of o.successors)for(let i of n.get(a)??[]){if(r.has(i)||i===t.exitId)continue;let s=t.cfg.get(i),l=[...s.definitions.map(d=>d.point),...s.uses.map(d=>d.point),...s.displayPoint?[s.displayPoint]:[]];for(let d of Ra(l))nt(e,"control-dependence",o.displayPoint.id,d.id,"exact","The target postdominates a branch successor but does not postdominate the predicate.")}}}function Ia(e){let t=[...e.cfg.keys()],n=new Set(t),o=new Map;for(let a of t)o.set(a,a===e.exitId?new Set([a]):new Set(n));let r=!0;for(;r;){r=!1;for(let a of e.cfg.values()){if(a.id===e.exitId)continue;let i=[...a.successors].map(l=>o.get(l)),s=new Set([a.id,...Fa(i)]);gn(o.get(a.id),s)||(o.set(a.id,s),r=!0)}}return o}function wa(e,t){let n=new Map(t.map(i=>[i.id,i.parentId])),o=t.flatMap(i=>[...i.cfg.values()].flatMap(s=>s.definitions.map(l=>l.point))),r=new Map;for(let i of o){if(!i.symbolKey)continue;let s=r.get(i.symbolKey)??[];s.push(i),r.set(i.symbolKey,s)}let a=new Set([...e.edges.values()].filter(i=>i.kind==="reaching-definition").map(i=>i.toPointId));for(let i of t)for(let s of[...i.cfg.values()].flatMap(l=>l.uses)){if(!s.point.symbolKey||a.has(s.point.id))continue;let l=r.get(s.point.symbolKey)??[];for(let d of l)Na(d.callableId,s.point.callableId,n)?nt(e,"closure-capture",d.id,s.point.id,"candidate","Compiler identity proves the captured binding, but invocation order can select among outer definitions."):s.property&&nt(e,"field-definition-to-use",d.id,s.point.id,"candidate","Compiler identity matches the field; cross-callable receiver and execution order remain unresolved.")}[...e.edges.values()].some(i=>i.kind==="closure-capture")&&e.unsupported.add("Closure capture identity is known, but invocation order and intervening writes remain candidate flow."),[...e.edges.values()].some(i=>i.kind==="field-definition-to-use")&&e.unsupported.add("Cross-callable field flow lacks receiver points-to and invocation-order analysis.")}function Na(e,t,n){for(let o=n.get(t)??null;o;o=n.get(o)??null)if(o===e)return!0;return!1}function nt(e,t,n,o,r,a){let i=`local-flow-edge:${t}:${encodeURIComponent(n)}:${encodeURIComponent(o)}`;e.edges.set(i,{id:i,kind:t,fromPointId:n,toPointId:o,strength:r,reason:a})}function Ko(e,t){return t>=e.SyntaxKind.FirstAssignment&&t<=e.SyntaxKind.LastAssignment}function Ma(e,t){let n=t.getText(e.sourceFile).replace(/\s+/gu," ").trim();return n.length>80?`${n.slice(0,77)}...`:n||e.ts.SyntaxKind[t.kind]||"statement"}function qo(e){return[...new Map(e.map(t=>[t.point.id,t])).values()]}function Ra(e){return[...new Map(e.map(t=>[t.id,t])).values()]}function Ta(e){return new Set(e.flatMap(t=>[...t]))}function Fa(e){return e.length===0?new Set:new Set([...e[0]].filter(t=>e.slice(1).every(n=>n.has(t))))}function gn(e,t){return e.size===t.size&&[...e].every(n=>t.has(n))}function Pa(e,t){return e.start-t.start||e.kind.localeCompare(t.kind)||e.id.localeCompare(t.id)}function mn(e){return{points:[],edges:[],coverage:{status:"unsupported",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:[e]}}}var ka=_n("typescript-local-flow",{clearGroups:["whole-project","source-file","semantic-provider"]});function yn(e,t,n,o){if(!jn(t))return null;let r=`${t}\0${n}\0${o}`;return ka.get(e,r,()=>{let a=dt(e,t);return a?Bo(a,Aa(e.config.projectRoot,t),{startLine:n,endLine:o}):{points:[],edges:[],coverage:{status:"unsupported",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:[`Current source is unavailable for ${t}.`]}}})}function $a(e,t=new Map){let n=new Map,o=new Map,r=[];for(let a of e.transfers){if(!e.caller)continue;let i=Mt(e.caller,a.callerPosition),s=Mt(e.callee,a.calleePosition);ot(n,i),ot(n,s),bn(o,e.caller,i),bn(o,e.callee,s);let l=oe("edge","data-transfer",a.proof.file,String(a.proof.startLine),String(a.callerPosition),String(a.calleePosition));o.set(l,{id:l,kind:"data-transfer",fromNodeId:i.id,toNodeId:s.id,directed:!0,disposition:"folded",semantics:[{family:"data",subtype:"argument-to-parameter",attributes:{argumentText:a.argumentText,callerPosition:a.callerPosition,calleePosition:a.calleePosition}}],evidence:[{method:"compiler-callsite-direct-parameter-transfer",strength:"exact",identity:`${e.caller.symbol}:${a.callerPosition} -> ${e.callee.symbol}:${a.calleePosition}`,location:{file:a.proof.file,line:a.proof.startLine,endLine:a.proof.endLine}}]})}return e.unknown.forEach((a,i)=>{let s=Mt(e.callee,a.calleePosition);ot(n,s),bn(o,e.callee,s);let l=t.get(a.calleePosition);if(l&&Wa(l)){Ua(o,n,e,a.calleePosition,a.argumentText,l);return}let d=qa(e,a.calleePosition,a.argumentText);ot(n,d);let c=oe("edge","data-transfer-unsupported",a.proof.file,String(a.proof.startLine),String(a.calleePosition),String(i));o.set(c,{id:c,kind:"data-transfer",fromNodeId:d.id,toNodeId:s.id,directed:!0,disposition:"unsupported",semantics:[{family:"data",subtype:"argument-to-parameter",attributes:{argumentText:a.argumentText,calleePosition:a.calleePosition}}],evidence:[{method:"compiler-callsite-argument-expression",strength:"exact",identity:a.argumentText,location:{file:a.proof.file,line:a.proof.startLine,endLine:a.proof.endLine}}]}),r.push({id:oe("frontier","data-transfer",c),kind:"data-transfer",direction:"unresolved",fromNodeIds:[d.id],edgeIds:[c],memberNodeIds:[s.id],memberCount:1,disposition:"unsupported",reason:l?.derivation.rule??a.reason,expansion:null})}),{nodes:[...n.values()],edges:[...o.values()],frontiers:r,blindSpots:[]}}function Uo(e,t,n=[]){let o=Wo(),r=new Map,a=new Set;for(let i of t){if(i.kind!=="call"||!i.fromSymbol||!i.toSymbol||i.line===null)continue;let s=Ka(r,e,i.toFile,i.toSymbol);if(!s)continue;let l=Hn(e,s),d=l.sites.filter(g=>g.file===i.fromFile&&g.startLine<=i.line&&g.endLine>=i.line&&g.caller?.symbol===i.fromSymbol);if(d.length!==1){let g=l.unresolved.find(b=>b.file===i.fromFile&&b.line===i.line);g&&o.blindSpots.push(`Parameter flow unresolved at ${i.fromFile}:${i.line+1}: ${g.reason}.`);continue}let c=d[0],u=`${c.file}\0${c.callNode.startIndex}\0${c.callNode.endIndex}\0${s.symbol}`;if(a.has(u))continue;a.add(u);let f=Vn(e,c),m=Y(e,c.file)?.rootNode,p=new Map;if(m)for(let g of f.unknown){let b=Un({db:e,file:c.file,root:m},c.arguments[g.calleePosition]);b&&p.set(g.calleePosition,b)}zo(o,$a(f,p)),f.caller&&Ga(c.callNode)&&ja(o,f,c.callNode)}for(let i of n){if(!i.location||!["source-construct","symbol"].includes(i.kind))continue;let s=i.location.endLine??i.location.line,l=yn(e,i.location.file,i.location.line,s);if(l){zo(o,Da(i,l.points,l.edges));for(let d of l.coverage.unsupported)o.blindSpots.push(`TypeScript local flow is partial for ${i.location.file}:${i.location.line+1}-${s+1}: ${d} Recover with: scip-query inspect --at '${i.location.file}:${i.location.line+1}-${s+1}' --view behavior.`)}}return o.blindSpots=[...new Set(o.blindSpots)].sort(),o}function Da(e,t,n){let o=Wo(),r=new Map,a=new Map,i=new Map,s=e.location.file;for(let l of t){let d=_a(e,s,l);i.set(l.id,d.id),r.set(d.id,d),Ba(a,e,d)}for(let l of n){let d=i.get(l.fromPointId),c=i.get(l.toPointId);if(!d||!c)continue;let u=Oa(l),f=oe("edge","typescript-local-flow",s,l.id);a.set(f,{id:f,kind:l.kind==="control-dependence"?"control-dependence":"data-transfer",fromNodeId:d,toNodeId:c,directed:!0,disposition:"folded",semantics:[u],evidence:[{method:"typescript-compiler-cfg-reaching-definitions",strength:l.strength,identity:l.reason,location:r.get(d)?.location??e.location}]})}return o.nodes=[...r.values()],o.edges=[...a.values()],o}function _a(e,t,n){return{id:oe("local-flow-point",t,String(n.start),String(n.end),n.kind,n.symbolKey??n.name),kind:n.kind==="parameter-definition"||n.kind==="definition"?"local-definition":n.kind==="use"?"local-use":n.kind==="predicate"?"control-predicate":"local-statement",label:n.name,disposition:"folded",location:{file:t,line:n.line,endLine:n.line},anchorIds:[],attributes:{ownerNodeId:e.id,pointKind:n.kind,callableId:n.callableId,symbolKey:n.symbolKey,column:n.column}}}function Ba(e,t,n){let o=oe("edge","local-flow-owner",t.id,n.id);e.has(o)||e.set(o,{id:o,kind:"local-flow-owner",fromNodeId:t.id,toNodeId:n.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:"contains"}],evidence:[{method:"typescript-compiler-local-flow-owner",strength:"exact",identity:t.id,location:n.location}]})}function Oa(e){switch(e.kind){case"reaching-definition":return{family:"data",subtype:"definition-to-use"};case"value-source":return{family:"data",subtype:"value-to-definition"};case"closure-capture":return{family:"data",subtype:"closure-capture"};case"field-definition-to-use":return{family:"data",subtype:"field-definition-to-use"};case"control-dependence":return{family:"control",subtype:"control-dependence"}}}function Ga(e){let t=e;for(;t.parent&&["await_expression","yield_expression","parenthesized_expression","as_expression","type_assertion"].includes(t.parent.type);)t=t.parent;return t.parent!==null&&t.parent.type!=="expression_statement"}function ja(e,t,n){if(!t.caller)return;let o={id:oe("call-result",t.call.file,String(n.startIndex),String(n.endIndex),t.callee.symbol),kind:"call-result",label:`result of ${t.callee.leaf}`,disposition:"folded",location:{file:t.call.file,line:t.call.startLine,endLine:t.call.endLine},anchorIds:[],attributes:{calleeSymbol:t.callee.symbol,callerSymbol:t.caller.symbol}},r=oe("edge","return-to-call-result",t.callee.symbol,o.id),a=oe("edge","call-result-owner",t.caller.symbol,o.id);e.nodes.push(o),e.edges.push({id:r,kind:"data-transfer",fromNodeId:Sn(t.callee.symbol),toNodeId:o.id,directed:!0,disposition:"folded",semantics:[{family:"data",subtype:"return-to-call-result"}],evidence:[{method:"compiler-callsite-used-result",strength:"exact",identity:`${t.callee.symbol} -> ${t.caller.symbol}`,location:o.location}]},{id:a,kind:"call-result-owner",fromNodeId:Sn(t.caller.symbol),toNodeId:o.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:"contains-call-result"}],evidence:[{method:"compiler-call-result-owner",strength:"exact",identity:t.caller.symbol,location:o.location}]})}function Wo(){return{nodes:[],edges:[],frontiers:[],blindSpots:[]}}function zo(e,t){hn(e.nodes,t.nodes),hn(e.edges,t.edges),hn(e.frontiers,t.frontiers),e.blindSpots.push(...t.blindSpots)}function hn(e,t){let n=new Set(e.map(o=>o.id));for(let o of t)n.has(o.id)||(n.add(o.id),e.push(o))}function Ka(e,t,n,o){let r=`${n}\0${o}`,a=e.get(r);if(a!==void 0)return a;let i=X(t,n).find(s=>s.symbol===o)??null;return e.set(r,i),i}function Mt(e,t){return{id:Qa(e.symbol,t),kind:"parameter",label:`${e.leaf} parameter ${t}`,disposition:"folded",location:{file:e.relativePath,line:e.startLine,endLine:e.endLine},anchorIds:[],attributes:{ownerSymbol:e.symbol,position:t}}}function qa(e,t,n){return{id:oe("argument-expression",e.call.file,String(e.call.startLine),String(e.call.endLine),String(t)),kind:"argument-expression",label:n,disposition:"unsupported",location:{file:e.call.file,line:e.call.startLine,endLine:e.call.endLine},anchorIds:[],attributes:{calleeSymbol:e.callee.symbol,position:t}}}function za(e,t,n){return{id:oe("static-value",e.call.file,String(e.call.startLine),String(e.call.endLine),String(t)),kind:"static-value",label:n.value,disposition:"folded",location:{file:e.call.file,line:e.call.startLine,endLine:e.call.endLine},anchorIds:[],attributes:{value:n.value,precision:n.precision,evidence:n.evidence,termKind:n.term.kind,derivationRule:n.derivation.rule}}}function Ua(e,t,n,o,r,a){let i=za(n,o,a),s=Mt(n.callee,o);ot(t,i);let l=oe("edge","static-value-transfer",n.call.file,String(n.call.startLine),String(o));e.set(l,{id:l,kind:"data-transfer",fromNodeId:i.id,toNodeId:s.id,directed:!0,disposition:"folded",semantics:[{family:"data",subtype:Ha(a),attributes:{argumentText:r,calleePosition:o,value:a.value,precision:a.precision,derivationRule:a.derivation.rule}}],evidence:Va(a,n)})}function Wa(e){return e.derivation.kind!=="heuristic"&&e.precision!=="symbolic"&&e.precision!=="unknown"}function Ha(e){return e.derivation.rule==="bounded-call-return"?"return-to-parameter":e.derivation.rule==="member-constant"||e.term.kind==="property"?"property-to-parameter":"constant-to-parameter"}function Va(e,t){return(e.derivation.sourceSpans.length>0?e.derivation.sourceSpans:[t.call]).map(o=>({method:`static-value:${e.derivation.rule}`,strength:e.derivation.kind==="direct"?"exact":"derived",identity:e.derivation.inputFactIds.join(",")||e.value,location:{file:o.file,line:o.startLine,endLine:o.endLine}}))}function ot(e,t){e.has(t.id)||e.set(t.id,t)}function bn(e,t,n){let o=oe("edge","parameter-owner",t.symbol,n.id);e.has(o)||e.set(o,{id:o,kind:"parameter-owner",fromNodeId:Sn(t.symbol),toNodeId:n.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:"contains"}],evidence:[{method:"compiler-parameter-owner",strength:"exact",identity:t.symbol,location:{file:t.relativePath,line:t.startLine,endLine:t.endLine}}]})}function Qa(e,t){return oe("parameter",e,String(t))}function Sn(e){return oe("symbol",e)}function oe(...e){return e.map(t=>encodeURIComponent(t)).join(":")}function Ho(e,t){let n=new Map,o=new Map,r=new Map,a=new Set;for(let i of t){if(!i.location||!["source-construct","symbol"].includes(i.kind))continue;let s=i.location.endLine??i.location.line,l=Yn(e,i.location.file,i.location.line,s);if(!l){a.add(`Control dependence unavailable for ${i.location.file}:${i.location.line+1}-${s+1}: no supported syntax tree or covering construct.`);continue}for(let d of l.facts){let c=vn(i,d.controller),u=vn(i,d.outcome);n.set(c.id,c),n.set(u.id,u),Ya(o,i,c);let f=_e("edge","control-dependence",c.id,u.id,d.subtype);o.set(f,{id:f,kind:"control-dependence",fromNodeId:c.id,toNodeId:u.id,directed:!0,disposition:"folded",semantics:[{family:"control",subtype:d.subtype,attributes:{...d.attributes}}],evidence:[{method:"parser-control-dependence",strength:"exact",identity:`${i.location.file}:${d.controller.startLine+1}-${d.outcome.startLine+1}`,location:{file:i.location.file,line:d.controller.startLine,endLine:d.controller.endLine}}]})}for(let d of l.terminals){let c=vn(i,d);n.set(c.id,c);let u=d.label.startsWith("throw")||d.label.startsWith("raise")?"throw":"return",f=_e("edge","control-terminal",i.id,c.id,u);o.set(f,{id:f,kind:"control-terminal",fromNodeId:i.id,toNodeId:c.id,directed:!0,disposition:"folded",semantics:[{family:"control",subtype:u==="throw"?"throws":"returns"}],evidence:[{method:"parser-terminal-statement",strength:"exact",identity:d.label,location:{file:i.location.file,line:d.startLine,endLine:d.endLine}}]})}for(let d of l.unsupported){let c=_e("control-unsupported",i.location.file,String(d.startLine),String(d.endLine),d.reason);n.set(c,{id:c,kind:"control-unsupported",label:d.reason,disposition:"unsupported",location:{file:i.location.file,line:d.startLine,endLine:d.endLine},anchorIds:[],attributes:{ownerNodeId:i.id}});let u=_e("edge","control-unsupported",i.id,c);o.set(u,{id:u,kind:"control-dependence",fromNodeId:i.id,toNodeId:c,directed:!0,disposition:"unsupported",semantics:[{family:"control",subtype:"unresolved-control-construct"}],evidence:[{method:"parser-control-construct",strength:"exact",identity:d.reason,location:{file:i.location.file,line:d.startLine,endLine:d.endLine}}]});let f=_e("frontier","control-dependence",c);r.set(f,{id:f,kind:"control-dependence",direction:"unresolved",fromNodeIds:[i.id],edgeIds:[u],memberNodeIds:[c],memberCount:1,disposition:"unsupported",reason:d.reason,expansion:null})}}return{nodes:[...n.values()],edges:[...o.values()],frontiers:[...r.values()],blindSpots:[...a].sort()}}function vn(e,t){let n=e.location.file;return{id:_e(`control-${t.kind}`,n,String(t.startLine),String(t.endLine),t.label),kind:`control-${t.kind}`,label:t.label,disposition:"folded",location:{file:n,line:t.startLine,endLine:t.endLine},anchorIds:[],attributes:{ownerNodeId:e.id,constructKind:t.kind,implicit:t.implicit}}}function Ya(e,t,n){let o=_e("edge","control-owner",t.id,n.id);e.has(o)||e.set(o,{id:o,kind:"control-owner",fromNodeId:t.id,toNodeId:n.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:"contains-control"}],evidence:[{method:"parser-control-owner",strength:"exact",identity:t.id,location:t.location}]})}function _e(...e){return e.map(t=>encodeURIComponent(t)).join(":")}var Rt=new Set(["arrow_function","constructor_declaration","function_declaration","function_definition","function_expression","generator_function","generator_function_declaration","function_item","lambda","lambda_expression","method","method_declaration","method_definition"]),it=new Set(["block","body","compound_statement","declaration_list","statement_block"]),Xa=new Set(["assignment","assignment_expression","augmented_assignment_expression"]),En=new Set(["update_expression"]),Xo=new Set(["array_access","element_access_expression","subscript_expression"]),Zo=new Set(["attribute","field_access","field_expression","member_access_expression","member_expression","selector_expression"]),Za=new Set(["false","null","null_literal","number","number_literal","string","string_literal","template_string","true"]),Ja=new Set(["call_expression","method_invocation","object_creation_expression"]),es=new Set(["comment","else_clause","formal_parameters","parameters","type_parameters"]);function Jo(e,t,n,o){let r=Y(e,t);if(!r)return null;let a=ls(r.rootNode,n,o);if(!a)return null;let i=[],s=[],l=[];return Be(a,d=>{if(Xa.has(d.type)||En.has(d.type)||tr(d)){let c=ts(d);c?i.push(c):l.push({family:"state",startLine:d.startPosition.row,endLine:d.endPosition.row,reason:`Mutation target ${be(d.text)} could not be resolved to an exact source resource.`})}}),Be(a,d=>{if(!it.has(d.type))return;let c=as(d);for(let u=0;u<c.length-1;u+=1)s.push({from:rt(c[u]),to:rt(c[u+1]),subtype:"lexical-successor",synchronizationScope:null,attributes:{sameScope:!0,executionConditional:!0}});for(let u=0;u<c.length;u+=1){let f=c[u],m=ds(f).filter(p=>p.type==="await_expression");for(let p of m){let g=at("event",`await ${be(p.text.replace(/^await\s+/u,""))}`,p);s.push({from:rt(f),to:g,subtype:"awaits-completion",synchronizationScope:null,attributes:{completionRequired:!0}});let b=c[u+1];b&&s.push({from:g,to:rt(b),subtype:"await-completion-before",synchronizationScope:null,attributes:{continuationOnly:!0}})}}}),Be(a,d=>{if(d.type!=="synchronized_statement")return;let c=d.childForFieldName("object")??d.childForFieldName("condition")??d.namedChildren.find(g=>!it.has(g.type)),u=d.childForFieldName("body")??d.namedChildren.find(g=>it.has(g.type));if(!c||!u){l.push({family:"temporal",startLine:d.startPosition.row,endLine:d.endPosition.row,reason:"Synchronized scope has no structurally resolved monitor or body."});return}let f=be(c.text).replace(/^\(|\)$/gu,""),m=at("lock",f,c),p=cs(u).filter(g=>g.parent!==null&&nr(g));for(let g of ss(p))s.push({from:m,to:rt(g),subtype:"inside-lock-scope",synchronizationScope:f,attributes:{syntaxNative:!0}})}),{mutations:i,temporal:s,unsupported:l}}function ts(e){let t=tr(e),n=e.childForFieldName("left")??e.childForFieldName("argument")??(t?e.namedChildren.at(-1)??null:e.namedChildren[0]??null);if(!n)return null;let o=ns(n);if(!o)return null;let r=t?"delete":En.has(e.type)||!is(e,n).startsWith("=")?"update":"assign",a=t||En.has(e.type)?null:e.childForFieldName("right");return{event:at("event",be(e.text),e),resource:{kind:"resource",label:o.name,startLine:n.startPosition.row,endLine:n.endPosition.row},operation:r,durabilityClass:"in-memory",recordIdentity:o.recordIdentity,value:a?at("value",be(a.text),a):null,dataSubtype:a?os(a,e):null}}function ns(e){if(Xo.has(e.type)){let t=e.childForFieldName("object")??e.childForFieldName("array")??e.namedChildren[0]??null,n=e.childForFieldName("index")??e.childForFieldName("subscript")??e.namedChildren[1]??null;return!t||!n?null:{name:`${be(t.text)}[]`,recordIdentity:be(n.text)}}return Zo.has(e.type)?{name:be(e.text),recordIdentity:null}:/^(?:identifier|property_identifier|field_identifier)$/u.test(e.type)?{name:be(e.text),recordIdentity:null}:null}function os(e,t){return Za.has(e.type)||/(?:integer|float|decimal|boolean|character)_literal$/u.test(e.type)?"constant-to-state":Ja.has(e.type)?"return-to-state":Zo.has(e.type)||Xo.has(e.type)?"property-to-state":/identifier$/u.test(e.type)?rs(e.text,t)?"captured-value-to-state":"value-to-state":"expression-to-state"}function rs(e,t){let n=xn(t.parent);if(!n||Vo(n,e))return!1;let o=xn(n.parent);for(;o;){if(Vo(o,e))return!0;o=xn(o.parent)}return!1}function xn(e){let t=e;for(;t;){if(Rt.has(t.type))return t;t=t.parent}return null}function Vo(e,t){let n=e.childForFieldName("parameters")??e.namedChildren.find(a=>["formal_parameters","parameters"].includes(a.type));if(n&&Qo(n,t))return!0;let o=e.childForFieldName("body")??e.namedChildren.find(a=>it.has(a.type));if(!o)return!1;let r=!1;return er(o,e,a=>{if(r||!/(?:declarator|declaration|parameter)$/u.test(a.type))return;let i=a.childForFieldName("name")??a.childForFieldName("pattern")??a.namedChildren[0];i&&Qo(i,t)&&(r=!0)}),r}function Qo(e,t){let n=!1;return Be(e,o=>{/identifier$/u.test(o.type)&&o.text===t&&(n=!0)}),n}function er(e,t,n){n(e);for(let o of e.namedChildren)o!==t&&Rt.has(o.type)||er(o,t,n)}function is(e,t){let n=e.childForFieldName("right"),o=Math.max(0,t.endIndex-e.startIndex),r=n?Math.max(o,n.startIndex-e.startIndex):e.text.length;return e.text.slice(o,r).trim()}function tr(e){return(e.type==="delete_expression"||e.type==="unary_expression")&&/^delete\b/u.test(e.text.trim())}function as(e){return e.namedChildren.filter(t=>nr(t))}function nr(e){return es.has(e.type)||it.has(e.type)?!1:/(?:statement|declaration)$/u.test(e.type)||e.type==="expression_statement"||e.type==="local_variable_declaration"}function ss(e){let t=new Set(e);return e.filter(n=>{let o=n.parent;for(;o;){if(t.has(o))return!1;o=o.parent}return!0})}function rt(e){return at("event",be(e.text),e)}function at(e,t,n){return{kind:e,label:t,startLine:n.startPosition.row,endLine:n.endPosition.row}}function ls(e,t,n){let o=[];return Be(e,a=>{a.startPosition.row<=t&&a.endPosition.row>=n&&o.push(a)}),o.filter(a=>Rt.has(a.type)).sort(Yo)[0]??o.sort(Yo)[0]??null}function Yo(e,t){return e.endIndex-e.startIndex-(t.endIndex-t.startIndex)||e.startIndex-t.startIndex}function cs(e){let t=[];return Be(e,n=>t.push(n)),t}function ds(e){let t=[],n=o=>{t.push(o);for(let r of o.namedChildren)r!==e&&Rt.has(r.type)||n(r)};return n(e),t}function Be(e,t){t(e);for(let n of e.namedChildren)Be(n,t)}function be(e){return e.trim().replace(/\s+/gu," ")}function ir(e,t,n=[]){let o=new Map,r=new Map,a=new Map,i=new Set;for(let s of t){if(!s.location||!["source-construct","symbol"].includes(s.kind))continue;let l=s.location.endLine??s.location.line,d=Jo(e,s.location.file,s.location.line,l);if(!d){i.add(`State and temporal analysis unavailable for ${s.location.file}:${s.location.line+1}-${l+1}: no supported syntax tree or covering construct.`);continue}for(let c of d.mutations){let u=Ft(s,c.event),f=ys(s,c.resource,c.durabilityClass);if(o.set(u.id,u),o.set(f.id,f),Pt(r,s,u,"contains-state-effect"),At(r,{kind:"state-resource",from:u,to:f,semantics:[{family:"state",subtype:c.operation==="delete"?"deletes-resource":"writes-resource",attributes:{operation:c.operation,durabilityClass:c.durabilityClass,resource:c.resource.label,recordIdentity:c.recordIdentity,transactionMembership:"unknown"}}],method:"parser-state-mutation",identity:c.event.label}),c.value&&c.dataSubtype){let m=Ft(s,c.value);o.set(m.id,m),At(r,{kind:"data-to-state",from:m,to:f,semantics:[{family:"data",subtype:c.dataSubtype,attributes:{operation:c.operation,resource:c.resource.label,recordIdentity:c.recordIdentity,value:c.value.label}}],method:"parser-assignment-value",identity:`${c.value.label} -> ${c.resource.label}`})}}for(let c of d.temporal){let u=Ft(s,c.from),f=Ft(s,c.to);o.set(u.id,u),o.set(f.id,f),Pt(r,s,u,c.from.kind==="lock"?"contains-lock-scope":"contains-event"),Pt(r,s,f,"contains-event"),At(r,{kind:"temporal-order",from:u,to:f,semantics:[{family:"temporal",subtype:c.subtype,context:c.synchronizationScope?{synchronizationScope:c.synchronizationScope}:void 0,attributes:{...c.attributes}}],method:c.subtype==="inside-lock-scope"?"parser-synchronized-scope":"parser-program-order",identity:`${c.from.label} -> ${c.to.label}`})}for(let c of d.unsupported){let u=Ie(`${c.family}-unsupported`,s.location.file,String(c.startLine),String(c.endLine),c.reason);o.set(u,{id:u,kind:`${c.family}-unsupported`,label:c.reason,disposition:"unsupported",location:{file:s.location.file,line:c.startLine,endLine:c.endLine},anchorIds:[],attributes:{ownerNodeId:s.id}});let f=Ie("edge",`${c.family}-unsupported`,s.id,u);r.set(f,{id:f,kind:`${c.family}-unsupported`,fromNodeId:s.id,toNodeId:u,directed:!0,disposition:"unsupported",semantics:[{family:c.family,subtype:`unresolved-${c.family}-construct`}],evidence:[{method:`parser-${c.family}-construct`,strength:"exact",identity:c.reason,location:{file:s.location.file,line:c.startLine,endLine:c.endLine}}]});let m=Ie("frontier",c.family,u);a.set(m,{id:m,kind:c.family,direction:"unresolved",fromNodeIds:[s.id],edgeIds:[f],memberNodeIds:[u],memberCount:1,disposition:"unsupported",reason:c.reason,expansion:null})}}for(let s of t.filter(l=>l.kind==="runtime-boundary-participant")){let l=Tt(s,"protocol"),d=Tt(s,"action"),c=Tt(s,"address")??s.label;!l||!d||!rr(l,d)||or(o,r,s,{observationId:s.id,action:d,strength:"exact",file:s.location?.file??"",line:s.location?.line??0,address:c,protocol:l,role:Tt(s,"role")??void 0,resolution:"locally-linked"})}for(let s of n){if(!s.protocol||!rr(s.protocol,s.action))continue;let l=fs(t,s.file,s.line,s.ownerShortName??null);if(!l){i.add(`State observation ${s.observationId} at ${s.file}:${s.line+1} has no materialized owner node.`);continue}or(o,r,l,s)}return{nodes:[...o.values()],edges:[...r.values()],frontiers:[...a.values()],blindSpots:[...i].sort()}}function or(e,t,n,o){let r=ps(o),i={id:Ie("runtime-state-event",o.observationId),kind:"runtime-state-event",label:`${o.action} ${r}`,disposition:"folded",location:{file:o.file,line:o.line},anchorIds:[],attributes:{action:o.action,protocol:o.protocol??null,modality:o.modality??null,resolution:o.resolution??null}},s=o.protocol==="database"?"external-durable-intent":"external",l={id:Ie("runtime-state-resource",o.protocol??"unknown",r),kind:"runtime-state-resource",label:r,disposition:"folded",location:{file:o.file,line:o.line},anchorIds:[],attributes:{protocol:o.protocol??null,durabilityClass:s}};e.set(i.id,i),e.set(l.id,l),Pt(t,n,i,"contains-runtime-state-effect");let d=us(o.action);At(t,{kind:"runtime-state-resource",from:i,to:l,semantics:[{family:"state",subtype:d,context:{crossesRuntimeBoundary:!0,protocol:o.protocol},attributes:{operation:o.action,durabilityClass:s,resource:r,recordIdentity:ms(o),modality:o.modality??null,resolution:o.resolution??null,transactionMembership:"unknown",commitState:o.protocol==="database"?"unknown":null}}],method:`runtime-boundary-${o.strength}`,identity:o.observationId})}function us(e){return e==="database.read"?"reads-resource":e==="queue.send"?"enqueues-resource":e==="queue.consume"?"consumes-resource":"writes-resource"}function ps(e){return(e.keyParts?.find(n=>["address","resource"].includes(n.name))?.value??e.address)||e.observationId}function ms(e){return e.keyParts?.find(n=>/^(?:id|key|record)$/u.test(n.name))?.value??null}function rr(e,t){return e==="database"&&["database.read","database.write"].includes(t)||e==="queue"&&["queue.consume","queue.send"].includes(t)}function Tt(e,t){let n=e.attributes[t];return typeof n=="string"?n:null}function fs(e,t,n,o){let r=e.filter(i=>i.location?.file===t&&["source-construct","symbol"].includes(i.kind)),a=r.filter(i=>i.location.line<=n&&(i.location.endLine??i.location.line)>=n).sort(gs)[0];if(a)return a;if(o){let i=r.find(s=>s.label===o||s.label.endsWith(`.${o}`)||s.label.includes(o));if(i)return i}return r.length===1?r[0]:null}function gs(e,t){let n=(e.location?.endLine??e.location?.line??0)-(e.location?.line??0),o=(t.location?.endLine??t.location?.line??0)-(t.location?.line??0);return n-o}function Ft(e,t){let n=e.location.file;return{id:Ie(`program-${t.kind}`,n,String(t.startLine),String(t.endLine),t.label),kind:`program-${t.kind}`,label:t.label,disposition:"folded",location:{file:n,line:t.startLine,endLine:t.endLine},anchorIds:[],attributes:{ownerNodeId:e.id,constructKind:t.kind}}}function ys(e,t,n){let o=e.location.file;return{id:Ie("program-resource",o,e.id,t.label,n),kind:"program-resource",label:t.label,disposition:"folded",location:{file:o,line:t.startLine,endLine:t.endLine},anchorIds:[],attributes:{ownerNodeId:e.id,durabilityClass:n}}}function Pt(e,t,n,o){let r=Ie("edge","program-owner",t.id,n.id,o);e.has(r)||e.set(r,{id:r,kind:"program-owner",fromNodeId:t.id,toNodeId:n.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:o}],evidence:[{method:"parser-program-owner",strength:"exact",identity:t.id,location:n.location}]})}function At(e,t){let n=Ie("edge",t.kind,t.from.id,t.to.id,t.semantics[0].subtype);e.set(n,{id:n,kind:t.kind,fromNodeId:t.from.id,toNodeId:t.to.id,directed:!0,disposition:"folded",semantics:t.semantics,evidence:[{method:t.method,strength:"exact",identity:t.identity,location:t.from.location}]})}function Ie(...e){return e.map(t=>encodeURIComponent(t)).join(":")}var hs=new Set(["control","data","state","temporal"]),kt=new Set(["contains-control","contains-event","contains-lock-scope","contains-state-effect","contains-runtime-state-effect","contains","owns-parameter","owns-runtime-observation"]),cr=new Set(["discriminator-dispatch","result-callback","returns","runtime-handoff","throws"]);function dr(e,t={}){let n=new Map(e.nodes.map(x=>[x.id,x])),o=Ls(e.nodes,t.focusLocations),r=Is(e.edges,t.focusLocations),a=ws(e.edges,r),i=new Set(e.paths.flatMap(x=>x.edgeIds)),s=we(e.anchors.filter(x=>x.status==="matched").flatMap(x=>x.nodeIds)),d=e.edges.filter(lr).filter(x=>bs(x,o,r,i)),c=d.filter(x=>Es(x,o,r,a,n,i)),u=ar(s,c,"forward"),f=xs(u,c),m=ar(f,c,"backward"),p=new Set([...u].filter(x=>m.has(x)));for(let x of s)p.add(x);let g=new Set(c.filter(x=>p.has(x.fromNodeId)&&p.has(x.toNodeId)).map(x=>x.id)),b=new Set(p),C=new Set(g);Ss(d,b,C,o,r);let S=e.frontiers.filter(x=>Ms(x,b)),v=we(S.filter(x=>x.disposition==="unsupported").map(x=>x.id)),R=we(e.edges.filter(x=>!lr(x)&&pr(x)&&Ns(x,b)).map(x=>x.id)),y=we(S.map(x=>x.id)),N=[];s.length===0&&N.push("No matched anchor node starts the corridor."),f.length===0&&N.push("No proved mechanical outcome is reachable from a matched anchor."),v.length>0&&N.push(`${v.length} unsupported frontier(s) touch the protected corridor.`),R.length>0&&N.push(`${R.length} candidate or unknown edge(s) touch the protected corridor.`);let L=N.length===0?"complete":"incomplete";return{schemaVersion:1,status:L,startNodeIds:s,outcomeNodeIds:f,baseNodeIds:we([...p]),baseEdgeIds:we([...g]),nodeIds:we([...b]),edgeIds:we([...C]),accountedFrontierIds:y,unresolvedFrontierIds:v,unresolvedEdgeIds:R,coverage:{protectedNodes:b.size,protectedEdges:C.size,baseNodes:p.size,baseEdges:g.size,accountedFrontiers:y.length,unresolvedFrontiers:v.length,unresolvedEdges:R.length},explanation:L==="complete"?"Every proved anchor-to-outcome path is closed over its material causal facts within reported coverage.":N.join(" ")}}function bs(e,t,n,o){return t===null||e.disposition==="emitted"||o.has(e.id)||n?.has(e.id)===!0?!0:(e.semantics??[]).some(r=>{if(r.family==="identity"&&kt.has(r.subtype))return t.has(e.toNodeId);if(r.family==="contract")return t.has(e.fromNodeId)&&t.has(e.toNodeId);if(r.family==="state")return t.has(e.fromNodeId);if(r.family==="data"||r.family==="temporal")return t.has(e.fromNodeId)||t.has(e.toNodeId);if(r.family==="control"){if(mr(r))return t.has(e.fromNodeId);if(["returns","throws"].includes(r.subtype))return t.has(e.toNodeId);if(r.subtype==="completion-callback")return t.has(e.fromNodeId)||t.has(e.toNodeId)}return!1})}function Ss(e,t,n,o,r){let a=!0;for(;a;){a=!1;for(let i of e)vs(i,t,o,r)&&(n.has(i.id)||(n.add(i.id),a=!0),t.has(i.fromNodeId)||(t.add(i.fromNodeId),a=!0),t.has(i.toNodeId)||(t.add(i.toNodeId),a=!0))}}function vs(e,t,n,o){let r=t.has(e.fromNodeId),a=t.has(e.toNodeId);return!r&&!a?!1:(e.semantics??[]).some(i=>i.family==="identity"?kt.has(i.subtype)&&(a||n===null||n.has(e.toNodeId)):i.family==="contract"?!0:i.family==="state"?r&&(n===null||n.has(e.fromNodeId)):i.family==="temporal"?i.subtype==="lexical-successor"?r&&a:!0:i.family==="data"?a&&(r||n===null||n.has(e.fromNodeId)||o?.has(e.id)===!0):i.family==="control"?ur(i)||["returns","throws"].includes(i.subtype)&&!a&&n!==null&&!n.has(e.toNodeId)?!1:cr.has(i.subtype)||mr(i)||i.subtype==="completion-callback":!1)}function xs(e,t){let n=new Set,o=new Map,r=new Map;for(let a of t)!e.has(a.fromNodeId)||!e.has(a.toNodeId)||(o.set(a.fromNodeId,(o.get(a.fromNodeId)??0)+1),r.set(a.toNodeId,(r.get(a.toNodeId)??0)+1),(a.semantics??[]).some(i=>i.family==="state"||i.family==="control"&&cr.has(i.subtype))&&n.add(a.toNodeId));for(let a of e)(r.get(a)??0)>0&&(o.get(a)??0)===0&&n.add(a);return we([...n])}function ar(e,t,n){let o=new Map;for(let i of t){let s=n==="forward"?i.fromNodeId:i.toNodeId,l=n==="forward"?i.toNodeId:i.fromNodeId,d=o.get(s)??[];d.push(l),o.set(s,d)}let r=new Set(e),a=[...e];for(;a.length>0;){let i=a.shift();for(let s of o.get(i)??[])r.has(s)||(r.add(s),a.push(s))}return r}function Es(e,t,n,o,r,a){return(e.semantics??[]).some(i=>e.disposition==="emitted"||a.has(e.id)?!0:i.family==="identity"&&kt.has(i.subtype)?t===null||t.has(e.toNodeId)||o?.has(e.toNodeId)===!0:!hs.has(i.family)||ur(i)?!1:i.family==="control"&&["returns","throws"].includes(i.subtype)&&t!==null?t.has(e.toNodeId):t===null?!0:i.family==="state"?t.has(e.fromNodeId):i.family==="data"?t.has(e.fromNodeId)||t.has(e.toNodeId)||n?.has(e.id)===!0:i.family==="temporal"?i.subtype==="lexical-successor"?t.has(e.fromNodeId)&&t.has(e.toNodeId):t.has(e.fromNodeId)||t.has(e.toNodeId):i.family==="control"?Cs(e,r)&&(t.has(e.fromNodeId)||t.has(e.toNodeId)):!1)}function ur(e){return e.family==="control"&&["call","discriminator-dispatch","result-callback","runtime-handoff"].includes(e.subtype)}function Cs(e,t){let n=t.get(e.fromNodeId),o=t.get(e.toNodeId);if(!n||!o)return!1;let r=sr(n,"ownerNodeId")??(n.kind==="symbol"?n.id:null),a=sr(o,"ownerNodeId")??(o.kind==="symbol"?o.id:null);return r!==null&&r===a}function Ls(e,t){if(!t)return null;let n=new Map;for(let o of t){let r=n.get(o.file)??[];r.push(o.line),n.set(o.file,r)}return new Set(e.filter(o=>{if(!o.location||o.kind==="parameter")return!1;let r=n.get(o.location.file)??[],a=o.location.endLine??o.location.line;return r.some(i=>i>=o.location.line&&i<=a)}).map(o=>o.id))}function Is(e,t){if(!t)return null;let n=new Map;for(let o of t){let r=n.get(o.file)??[];r.push(o.line),n.set(o.file,r)}return new Set(e.filter(o=>o.evidence.some(r=>{if(!r.location)return!1;let a=n.get(r.location.file)??[],i=r.location.endLine??r.location.line;return a.some(s=>s>=r.location.line&&s<=i)})).map(o=>o.id))}function ws(e,t){return t===null?null:new Set(e.filter(n=>t.has(n.id)).flatMap(n=>[n.fromNodeId,n.toNodeId]))}function sr(e,t){let n=e.attributes[t];return typeof n=="string"?n:null}function lr(e){return e.disposition==="excluded"||e.disposition==="unsupported"||!pr(e)?!1:e.evidence.some(t=>t.strength==="exact"||t.strength==="derived")}function pr(e){return(e.semantics??[]).some(t=>t.family!=="identity"||kt.has(t.subtype))}function mr(e){return e.subtype.startsWith("predicate-")||e.subtype.startsWith("loop-")||e.subtype.startsWith("exception-")||e.subtype.startsWith("finally-")||e.subtype.startsWith("handler-")}function Ns(e,t){return t.has(e.fromNodeId)||t.has(e.toNodeId)}function Ms(e,t){return[...e.fromNodeIds,...e.memberNodeIds].some(n=>t.has(n))}function we(e){return[...new Set(e)].sort()}import{createHash as Rs}from"crypto";var $t=["identity","contract","control","data","state","temporal"],Ts=new Set($t);function _t(e){let t=We(e.anchors,"anchor"),n=We(e.nodes,"node"),o=We(e.edges,"edge"),r=We(e.paths??[],"path"),a=We(e.frontiers??[],"frontier"),i=new Set(t.map(m=>m.id)),s=new Set(n.map(m=>m.id)),l=new Set(o.map(m=>m.id)),d=e.routeCatalog?{...e.routeCatalog,routes:We(e.routeCatalog.routes,"route"),selectedRouteIds:ie(e.routeCatalog.selectedRouteIds)}:void 0;for(let m of t)ce(`anchor ${m.id}`,[...m.nodeIds,...m.candidateNodeIds],s,"node");for(let m of n)ce(`node ${m.id}`,m.anchorIds,i,"anchor");for(let m of o){if(ce(`edge ${m.id}`,[m.fromNodeId,m.toNodeId],s,"node"),m.evidence.length===0)throw new Error(`Exploration edge ${m.id} has no evidence source.`);As(m)}for(let m of r)ce(`path ${m.id}`,[m.fromAnchorId,m.toAnchorId],i,"anchor"),ce(`path ${m.id}`,m.nodeIds,s,"node"),ce(`path ${m.id}`,m.edgeIds,l,"edge");for(let m of a)if(ce(`frontier ${m.id}`,m.fromNodeIds,s,"node"),ce(`frontier ${m.id}`,m.edgeIds,l,"edge"),ce(`frontier ${m.id}`,m.memberNodeIds,s,"node"),m.memberCount!==m.memberNodeIds.length)throw new Error(`Exploration frontier ${m.id} reports ${m.memberCount} member(s) but identifies ${m.memberNodeIds.length}.`);for(let m of d?.routes??[])ce(`route ${m.id}`,m.nodeIds,s,"node"),ce(`route ${m.id}`,m.edgeIds,l,"edge"),ce(`route ${m.id}`,[m.anchorNodeId,m.endpointNodeId],s,"node");d&&ce("route catalog selection",d.selectedRouteIds,new Set(d.routes.map(m=>m.id)),"route");let c=ie(e.incompleteReasons??[]),u=c.length===0?"accounted":"incomplete",f=t.reduce((m,p)=>m+p.omittedCandidates,0);return{schemaVersion:1,anchors:t,nodes:n,edges:o,paths:r,frontiers:a,coverage:{status:u,scope:e.scope,nodes:Er(n),edges:Er(o),matchedAnchors:t.filter(m=>m.status==="matched").length,ambiguousAnchors:t.filter(m=>m.status==="ambiguous").length,missingAnchors:t.filter(m=>m.status==="missing").length,omittedCandidates:f,frontierGroups:a.length,programEdges:Ps(o),blindSpots:ie(e.blindSpots??[]),explanation:u==="accounted"?"Every node and edge discovered within the declared query scope is emitted, folded with recoverable identity, explicitly excluded, or reported unsupported.":`The declared query scope is not fully accounted for: ${c.join("; ")}`},completion:Ds(u,r,e.scope),...d?{routeCatalog:d}:{}}}function Fs(e){return e.flatMap(t=>ks(t.semantics??[]).map(n=>({id:$s(t.id,n),sourceEdgeId:t.id,sourceKind:t.kind,fromNodeId:t.fromNodeId,toNodeId:t.toNodeId,directed:!0,disposition:t.disposition,evidence:[...t.evidence],family:n.family,subtype:n.subtype,...n.context?{context:{...n.context}}:{},...n.attributes?{attributes:{...n.attributes}}:{}}))).sort((t,n)=>t.id.localeCompare(n.id))}function Ps(e){let t=Fs(e),n=new Set(t.map(i=>i.sourceEdgeId)),o=new Map($t.map(i=>[i,new Set])),r=new Map($t.map(i=>[i,new Set])),a=new Map($t.map(i=>[i,0]));for(let i of t)o.get(i.family).add(i.sourceEdgeId),r.get(i.family).add(i.subtype),a.set(i.family,a.get(i.family)+1);return{sourceEdges:e.length,mappedSourceEdges:n.size,projectedEdges:t.length,unmappedSourceEdges:e.length-n.size,unsupportedSourceEdges:e.filter(i=>i.disposition==="unsupported").length,unmappedKinds:ie(e.filter(i=>!n.has(i.id)).map(i=>i.kind)),families:{identity:Ue("identity",o,a,r),contract:Ue("contract",o,a,r),control:Ue("control",o,a,r),data:Ue("data",o,a,r),state:Ue("state",o,a,r),temporal:Ue("temporal",o,a,r)}}}function Ue(e,t,n,o){return{sourceEdges:t.get(e)?.size??0,projectedEdges:n.get(e)??0,subtypes:[...o.get(e)??[]].sort()}}function As(e){let t=new Set;for(let n of e.semantics??[]){if(!Ts.has(n.family))throw new Error(`Exploration edge ${e.id} has unknown program edge family: ${n.family}.`);if(n.subtype.trim().length===0)throw new Error(`Exploration edge ${e.id} has an empty program edge subtype.`);let o=Cn(n);if(t.has(o))throw new Error(`Exploration edge ${e.id} repeats program edge semantic ${o}.`);t.add(o)}}function ks(e){return[...e].sort((t,n)=>Cn(t).localeCompare(Cn(n)))}function Cn(e){return`${e.family}:${e.subtype}`}function $s(e,t){return`program:${encodeURIComponent(e)}:${t.family}:${encodeURIComponent(t.subtype)}`}function Ds(e,t,n){return e==="incomplete"||t.some(o=>o.status!=="connected")?{status:"coverage-incomplete",scope:n,explanation:"The declared graph query has an ambiguous, missing, candidate-only, or disconnected anchor relationship."}:t.length>0?{status:"connector-complete",scope:n,explanation:"Every requested anchor pair has a selected path supported by proved repository relationships."}:{status:"frontier-accounted",scope:n,explanation:"Every discovered direction in the declared graph query is emitted or represented by an exact frontier."}}function Cr(e,t={}){let n=t.maxSelectedNodes??24;if(!Number.isSafeInteger(n)||n<=0)throw new RangeError(`maxSelectedNodes must be a positive safe integer; received ${n}`);let o=new Set(e.anchors.flatMap(h=>[...h.nodeIds,...h.candidateNodeIds])),r=[],a=e.anchors.filter(h=>h.status!=="missing"&&h.nodeIds.length+h.candidateNodeIds.length>0);for(let h=0;h<a.length;h+=1)for(let P=h+1;P<a.length;P+=1){let D=a[h],O=a[P],w=br(e,D,O,!1),I=w??br(e,D,O,!0);I?(I.nodeIds.forEach(_=>o.add(_)),r.push({id:Dt("path",D.id,O.id),fromAnchorId:D.id,toAnchorId:O.id,status:!w||D.status==="ambiguous"||O.status==="ambiguous"?"candidate":"connected",nodeIds:I.nodeIds,edgeIds:I.edgeIds})):r.push({id:Dt("path",D.id,O.id),fromAnchorId:D.id,toAnchorId:O.id,status:"partial",nodeIds:[],edgeIds:[]})}let i=ie(t.routeIds??[]),s=_s(e,i),l=new Set(s.routes.map(h=>h.id)),d=i.filter(h=>!l.has(h));if(d.length>0)throw new Error(`Unknown exploration route id(s): ${d.join(", ")}`);let u=s.routes.filter(h=>i.includes(h.id)).map(h=>({anchorNodeId:h.anchorNodeId,endpointNodeId:h.endpointNodeId,endpointKind:h.endpointKind,endpointPriority:2,nodeIds:[...h.nodeIds].reverse(),edgeIds:[...h.edgeIds].reverse()}));for(let h of u)h.nodeIds.forEach(P=>o.add(P));let f=r.length===0||r.some(h=>h.edgeIds.length>0);f&&vr(e,o,n);let m=xr(e,o),p=new Set(t.expandedFrontierIds??[]),g=new Set(m.map(h=>h.id)),b=[...p].filter(h=>!g.has(h)).sort();if(b.length>0)throw new Error(`Unknown exploration frontier id(s): ${b.join(", ")}`);for(let h of m)p.has(h.id)&&h.memberNodeIds.forEach(P=>o.add(P));f&&vr(e,o,n);let C=new Map(u.map(h=>[h.endpointNodeId,h.endpointKind])),S=new Set(u.flatMap(h=>h.nodeIds)),v=new Map;for(let h of u)for(let P=0;P<h.nodeIds.length;P+=1){let D=h.nodeIds[P],O=P;v.set(D,Math.max(v.get(D)??0,O))}let R=e.nodes.map(h=>{let P=C.get(h.id),D=S.has(h.id)?{upstreamCausalPath:!0,upstreamCausalDistance:v.get(h.id)??0,...P?{upstreamCausalEndpoint:P}:{}}:{};return{...h,attributes:{...h.attributes,...D},disposition:h.disposition==="excluded"||h.disposition==="unsupported"?h.disposition:o.has(h.id)?"emitted":"folded"}}),y=new Set([...r.flatMap(h=>h.edgeIds),...u.flatMap(h=>h.edgeIds)]),N=e.edges.map(h=>({...h,disposition:h.disposition==="excluded"||h.disposition==="unsupported"?h.disposition:y.has(h.id)||o.has(h.fromNodeId)&&o.has(h.toNodeId)?"emitted":"folded"})),L=_t({anchors:e.anchors,nodes:R,edges:N,paths:r,frontiers:[...e.frontiers.filter(h=>h.disposition!=="folded"),...xr({...e,nodes:R,edges:N},o)],scope:e.coverage.scope,blindSpots:e.coverage.blindSpots,incompleteReasons:e.coverage.status==="incomplete"?[e.coverage.explanation]:[],routeCatalog:s}),x=new Set(L.frontiers.flatMap(h=>h.edgeIds)),M=L.edges.filter(h=>h.disposition==="folded"&&!x.has(h.id)).map(h=>h.id);if(M.length>0)throw new Error(`Folded exploration edge(s) are not frontier-accounted: ${M.sort().join(", ")}`);return L}var fr=10;function _s(e,t=[]){let n=new Map(e.nodes.map(b=>[b.id,b])),o=new Map(e.edges.map(b=>[b.id,b])),r=new Map;for(let b of e.edges){if(!Bs(b))continue;let C=r.get(b.toNodeId)??[];C.push(b),r.set(b.toNodeId,C)}for(let b of r.values())b.sort((C,S)=>Number(st(S))-Number(st(C))||hr(S)-hr(C)||C.fromNodeId.localeCompare(S.fromNodeId)||C.id.localeCompare(S.id));let a=ie(e.anchors.filter(b=>b.status==="matched").flatMap(b=>b.nodeIds)),i=new Map,s=new Set,l=(b,C,S)=>{let v=C.nodeIds[C.nodeIds.length-1],R=n.get(v),y=n.get(b);if(!R?.location||!y)return;let N=[...C.nodeIds].reverse(),L=[...C.edgeIds].reverse(),x=new Set(N),M=L.flatMap(w=>{let T=o.get(w);return T?[T]:[]}),h=e.edges.filter(w=>w.disposition!=="excluded"&&w.disposition!=="unsupported"&&(x.has(w.fromNodeId)||x.has(w.toNodeId))),P={id:Dt("route",b,v,S,...L),status:"proved",anchorNodeId:b,anchorLabel:y.label,endpointNodeId:v,endpointLabel:R.label,endpointLocation:{...R.location},endpointKind:S,nodeIds:N,edgeIds:L,evidenceStrengths:ie(M.flatMap(w=>w.evidence.map(T=>T.strength))),spineEdgeFamilies:gr(M,!0),relatedEdgeFamilies:gr(h,!1),crossesRuntimeBoundary:M.some(st)},D=`${b}\0${v}\0${S}`,O=i.get(D);(!O||yr(P,O)<0)&&i.set(D,P)};for(let b of a){n.get(b)?.attributes.publicEntry===!0&&l(b,{nodeIds:[b],edgeIds:[]},"public-entry");let C=[{nodeIds:[b],edgeIds:[]}],S=new Map([[b,0]]);for(let v=0;v<C.length;v+=1){let R=C[v],y=R.nodeIds[R.nodeIds.length-1];R.edgeIds.length>0&&n.get(y)?.location&&n.get(y)?.attributes.publicEntry===!0&&l(b,R,"public-entry");let N=r.get(y)??[];if(R.edgeIds.length>=fr){N.some(L=>!R.nodeIds.includes(L.fromNodeId))&&s.add(b);continue}for(let L of N){if(R.nodeIds.includes(L.fromNodeId))continue;let x=R.edgeIds.length+1,M=S.get(L.fromNodeId);if(M!==void 0&&M<=x)continue;let h={nodeIds:[...R.nodeIds,L.fromNodeId],edgeIds:[...R.edgeIds,L.id]};if(S.set(L.fromNodeId,x),st(L)&&n.get(L.fromNodeId)?.location){l(b,h,"runtime-boundary");continue}C.push(h)}}}let d=[...i.values()].sort(yr),c=new Set(d.map(b=>b.id)),u=ie(t.filter(b=>c.has(b))),f=ie(d.map(b=>b.anchorNodeId)),m=a.filter(b=>!f.includes(b)),p=[...s].sort(),g=e.coverage.status==="accounted"&&p.length===0?"accounted":"incomplete";return{schemaVersion:1,routes:d,selectedRouteIds:u,coverage:{status:g,scope:"Distinct proved public-entry and runtime-boundary endpoints reachable upstream in the supplied topology.",enumeration:"one-shortest-proved-path-per-endpoint",maximumDepth:fr,anchorNodeIds:a,anchorsWithRoutes:f,anchorsWithoutRoutes:m,depthLimitedAnchorNodeIds:p,routeCount:d.length,explanation:g==="accounted"?"Every distinct proved upstream public/runtime endpoint in the supplied topology has one stable shortest route.":"Route enumeration is incomplete because the supplied topology has incomplete coverage or a traversal reached the route-depth bound."}}}function gr(e,t){let n=e.flatMap(o=>o.semantics?.map(r=>r.family)??[]);return t&&e.length>0&&n.length===0&&n.push("control"),ie(n)}function yr(e,t){return e.anchorNodeId.localeCompare(t.anchorNodeId)||e.edgeIds.length-t.edgeIds.length||e.endpointKind.localeCompare(t.endpointKind)||e.endpointNodeId.localeCompare(t.endpointNodeId)||e.id.localeCompare(t.id)}function Bs(e){return e.disposition!=="excluded"&&e.disposition!=="unsupported"&&Os(e)&&e.evidence.some(t=>["exact","derived","mixed"].includes(t.strength))}function Os(e){return st(e)||e.kind==="boundary-observation"||e.kind==="call"||e.kind==="compiler:call"}function st(e){return e.kind==="runtime-boundary"||e.kind.startsWith("runtime:")}function hr(e){let t={exact:5,derived:4,mixed:3,candidate:1,unknown:0};return Math.max(0,...e.evidence.map(n=>t[n.strength]))}function br(e,t,n,o){return Sr(e,t,n,o)??Sr(e,n,t,o)}function Sr(e,t,n,o){let r=[...t.nodeIds,...t.candidateNodeIds].sort(),a=new Set([...n.nodeIds,...n.candidateNodeIds]);if(r.some(c=>a.has(c)))return{nodeIds:[r.find(u=>a.has(u))],edgeIds:[]};let i=new Set(e.nodes.filter(c=>c.kind==="structural-region").map(c=>c.id)),s=new Map;for(let c of e.edges)c.disposition==="excluded"||c.disposition==="unsupported"||c.kind==="structural-membership"||i.has(c.fromNodeId)||i.has(c.toNodeId)||c.evidence.every(f=>["candidate","unknown"].includes(f.strength))&&!o||Gs(s,c.fromNodeId,c.toNodeId,c.id);for(let c of s.values())c.sort((u,f)=>u.nodeId.localeCompare(f.nodeId)||u.edgeId.localeCompare(f.edgeId));let l=r.map(c=>({nodeId:c,nodeIds:[c],edgeIds:[]})),d=new Set(r);for(let c=0;c<l.length;c+=1){let u=l[c];for(let f of s.get(u.nodeId)??[]){if(d.has(f.nodeId))continue;let m={nodeId:f.nodeId,nodeIds:[...u.nodeIds,f.nodeId],edgeIds:[...u.edgeIds,f.edgeId]};if(a.has(f.nodeId))return m;d.add(f.nodeId),l.push(m)}}return null}function Gs(e,t,n,o){let r=e.get(t)??[];r.push({nodeId:n,edgeId:o}),e.set(t,r)}function js(e,t,n){let o=new Map;for(let s of e.edges){let l=o.get(s.fromNodeId)??{incoming:0,outgoing:0},d=o.get(s.toNodeId)??{incoming:0,outgoing:0};l.outgoing+=1,d.incoming+=1,o.set(s.fromNodeId,l),o.set(s.toNodeId,d)}let r=new Set,a=new Map;for(let s of e.edges){let l=t.has(s.fromNodeId),d=t.has(s.toNodeId);if(l===d)continue;let c=l?s.toNodeId:s.fromNodeId,u=l?s.fromNodeId:s.toNodeId,f=e.nodes.find(g=>g.id===c);if(f?.kind==="structural-region")continue;let m=a.get(c)??new Set;m.add(u),a.set(c,m),(/(?:runtime-boundary|external)/u.test(s.kind)||f&&/(?:frontier|external)/u.test(f.kind))&&r.add(c)}let i=[...a].filter(([s,l])=>{if(r.has(s))return!0;let d=o.get(s)??{incoming:0,outgoing:0};return(d.incoming>1||d.outgoing>1)&&l.size>1}).sort(([s,l],[d,c])=>Number(r.has(d))-Number(r.has(s))||c.size-l.size||s.localeCompare(d)).map(([s])=>s);for(let s of i){if(t.size>=n)break;t.add(s)}}function vr(e,t,n){let o=-1;for(;t.size!==o&&t.size<n;)o=t.size,js(e,t,n)}function xr(e,t){let n=new Set(e.nodes.filter(i=>!t.has(i.id)&&i.disposition!=="excluded"&&i.disposition!=="unsupported").map(i=>i.id)),o=new Map;for(let i of e.edges){if(!n.has(i.fromNodeId)||!n.has(i.toNodeId))continue;let s=o.get(i.fromNodeId)??new Set,l=o.get(i.toNodeId)??new Set;s.add(i.toNodeId),l.add(i.fromNodeId),o.set(i.fromNodeId,s),o.set(i.toNodeId,l)}let r=[],a=new Set;for(let i of[...n].sort()){if(a.has(i))continue;let s=[],l=[i];a.add(i);for(let d=0;d<l.length;d+=1){let c=l[d];s.push(c);for(let u of[...o.get(c)??[]].sort())a.has(u)||(a.add(u),l.push(u))}r.push(s.sort())}return r.map(i=>{let s=new Set(i),l=e.edges.filter(p=>s.has(p.fromNodeId)||s.has(p.toNodeId)),d=l.filter(p=>s.has(p.fromNodeId)!==s.has(p.toNodeId)),c=ie(d.map(p=>s.has(p.fromNodeId)?p.toNodeId:p.fromNodeId)),u=new Set(d.map(p=>s.has(p.toNodeId)?"outgoing":"incoming")),f=ie(l.map(p=>p.id)),m=ie(d.map(p=>p.kind));return{id:Dt("frontier",...i,...f),kind:m.join("+")||"disconnected",direction:u.size===1?[...u][0]:"undirected",fromNodeIds:c,edgeIds:f,memberNodeIds:i,memberCount:i.length,disposition:"folded",reason:d.length>0?"Connected evidence is folded beyond the first edge leaving the selected connector graph.":"Discovered evidence is disconnected from every selected anchor connector under the declared relation scope.",expansion:null}})}function Dt(e,...t){let n=Rs("sha256").update(t.join("\0")).digest("hex").slice(0,16);return`${e}:${n}`}function We(e,t){let n=[...e].sort((o,r)=>o.id.localeCompare(r.id));for(let o=1;o<n.length;o+=1)if(n[o-1].id===n[o].id)throw new Error(`Duplicate exploration ${t} id: ${n[o].id}`);return n}function ce(e,t,n,o){let r=ie(t.filter(a=>!n.has(a)));if(r.length>0)throw new Error(`Exploration ${e} references missing ${o}(s): ${r.join(", ")}`)}function Er(e){return{total:e.length,emitted:e.filter(t=>t.disposition==="emitted").length,folded:e.filter(t=>t.disposition==="folded").length,excluded:e.filter(t=>t.disposition==="excluded").length,unsupported:e.filter(t=>t.disposition==="unsupported").length}}function ie(e){return[...new Set(e)].sort()}var Ks=5,qs=12,zs=8,Us=3,Lr=8,Ws=6,Hs=12,Ir=12,Vs=12,Qs=2,Ys=new Set(["branch","loop","call","await","return","throw","mutation","catch","finally"]),Xs=9e3,wr=ko,Nr=new WeakMap;function _r(e,t){return ll(e,t,"topology")}function Zs(e,t,n,o,r,a=!1){let i=e.get(t);if(i)return i.depth=Math.min(i.depth,n),i.primary||=r,i.promoteBoundaryImports||=a,i.origins.add(o),i;let s={file:t,depth:n,primary:r,promoteBoundaryImports:a,origins:new Set([o]),processed:!1};return e.set(t,s),s}function Js(e,t,n,o,r,a,i="none",s=!1){let l=e.get(n.symbol);if(l)return l.depth=Math.min(l.depth,o),l.origins.add(r),a&&l.anchorQueries.add(a),l.referenceScope=Zl(l.referenceScope,i),t(n.relativePath,o,r,!0,s),l;let d={definition:n,depth:o,origins:new Set([r]),anchorQueries:new Set(a?[a]:[]),referenceScope:i,processed:!1};return e.set(n.symbol,d),t(n.relativePath,o,r,!0,s),d}function el(e,t,n,o,r,a,i=!1,s=!0){let l=Se(n),d=e.get(l);if(d)return d.depth=Math.min(d.depth,o),d.origins.add(r),a&&d.anchorQueries.add(a),d.reverseCallExpansion||=i,d.traversalEligible||=s,t(n.file,o,r,d.traversalEligible,!0),d;let c={...n,depth:o,origins:new Set([r]),anchorQueries:new Set(a?[a]:[]),reverseCallExpansion:i,traversalEligible:s};return e.set(l,c),t(n.file,o,r,s,!0),c}function tl(e){let{db:t,index:n,pendingRelations:o,addFile:r,addSymbol:a,addSourceConstruct:i,observation:s,depth:l,origin:d}=e;r(s.source.file,l,d,!0,!0),s.owner.file!==s.source.file&&r(s.owner.file,l,`${d}:owner`,!0,!0);let c=X(t,s.owner.file),u=s.owner.symbol?Te(t,n,s.owner.symbol).matches.find(p=>p.relativePath===s.owner.file):null,f=(u&&!re(u.symbol)?u:null)??Ge(c,s.source.startLine);if(f&&!re(f.symbol))return a(f,l,d,void 0,"none",!0),f.symbol;s.owner.name&&i({file:s.owner.file,name:s.owner.name,startLine:s.owner.startLine,endLine:s.owner.endLine},l,`${d}:source-owner`,void 0,!0);let m=e.index.definitionsForFile(s.source.file).filter(p=>!!p.leaf&&Ee(t,s.source.file,p.leaf).some(g=>g>=s.source.startLine&&g<=s.source.endLine));if(m.length===1){let p=m[0];a(p,l,`${d}:handler-identifier`,void 0,"none",!0),pe(o,{kind:"runtime-boundary",evidence:"runtime-boundary:handler-identifier",fromFile:s.source.file,fromSymbol:null,toFile:p.relativePath,toSymbol:p.symbol,fromBoundaryParticipant:Ve(s),line:s.source.startLine,strength:"derived"})}return null}function nl(e){let t=0,n=0,o=0;for(let r of e.searches){let a=$l(e.db,e.index,r,e.boundaryObservationLocations),i=a.filter(c=>Gl(c,e.sourceAllowed)),s=!e.opts.fullLiteralTraversal&&(a.length>qs||i.length>zs),l=s?[]:a,d=new Set((s?[]:e.opts.fullLiteralTraversal?i:[...i].sort(Dl).slice(0,Us)).map(Pr));s&&(n+=1,o+=a.length);for(let c of l){let u=d.has(Pr(c)),f=u&&!c.ownerSymbol&&c.ownerStartLine!==null&&c.ownerEndLine!==null;if(e.addFile(c.relativePath,0,`${u?"literal-anchor":"literal-match"}:${r}`,f,f),f&&e.addSourceConstruct({file:c.relativePath,name:c.ownerShortName??`${c.relativePath}:${c.ownerStartLine+1}`,startLine:c.ownerStartLine,endLine:c.ownerEndLine},0,`literal-source-owner:${r}`,r,!0),u&&c.ownerSymbol){let m=Te(e.db,e.index,c.ownerSymbol).matches[0];m&&!re(m.symbol)&&e.addSymbol(m,0,"literal-owner",r,"all",!0)}e.literalHits.push({query:r,file:c.relativePath,line:c.line,ownerSymbol:c.ownerSymbol,ownerShortName:c.ownerShortName,ownerStartLine:c.ownerStartLine,ownerEndLine:c.ownerEndLine,sourceLine:c.sourceLine.trim(),matchKind:c.matchKind,traversalSeed:u})}e.anchors.push({kind:"literal",query:r,status:a.length>0?"matched":"missing",matchedRegionIds:[],matchingLines:a.length,seedMatchingLines:s?0:d.size,matchOnlyLines:a.length-d.size,eligibleSeedMatchingLines:i.length,materializedMatchingLines:l.length,withheldMatchingLines:s?a.length:0,literalTraversal:s?"withheld-broad":"materialized",representativeMatches:s?jl(r,a):void 0,narrowingCommands:s?ql(r,a):void 0,exhaustiveTraversalCommand:s||d.size<i.length?`scip-query system-map --search ${V(r)} --full-literal-traversal`:void 0,seedRegionIds:[],matchOnlyRegionIds:[]})}for(let r of e.symbolQueries){let a=Te(e.db,e.index,r);t+=a.omitted;let i=_l(e.db,r),s=a.matches.filter(f=>!re(f.symbol)),l=i!==null&&s.length===0;l&&e.addSourceConstruct(i,0,"source-construct-anchor",r,!0);let d=l?s:a.matches;for(let f of d)e.addSymbol(f,0,"symbol-anchor",r,"all",!0);let c=l?Bl(i):null,u=l?1:a.total;e.anchors.push({kind:"symbol",query:r,status:u===0?"missing":u===1?"matched":"ambiguous",matchedRegionIds:[],symbolCandidates:[...c?[c]:[],...d.map(Vl)],totalSymbolCandidates:u,omittedSymbolCandidates:a.omitted})}return{omittedSymbolCandidates:t,broadLiteralAnchors:n,withheldLiteralMatches:o}}function ol(e){let{db:t,opts:n,mode:o,searches:r,symbolQueries:a,maxDepth:i,maxTopologyCharacters:s,requestedRelationKinds:l,evidenceFloor:d,includedSourceScopes:c,workspaces:u,runtimeBoundaries:f,boundaryObservations:m,representedBoundaryLinkIds:p,files:g,symbols:b,sourceConstructs:C,literalHits:S,pendingRelations:v,externalImports:R,anchors:y,omittedSymbolCandidates:N,broadLiteralAnchors:L,withheldLiteralMatches:x,filteredUnverifiedCallEdges:M,memberCallCandidateEdges:h,unresolvedMemberCallsites:P,sourceAllowed:D}=e,O=new Set(l),w=new Map;for(let F of g.keys())w.set(F,lt(F,u));let T=[...v.values()].filter(F=>w.has(F.fromFile)&&w.has(F.toFile)).map(F=>({...F,fromRegionId:w.get(F.fromFile).id,toRegionId:w.get(F.toFile).id})).sort(jr),I=sc(T),_=new Set(n.expand??[]),A=oc(g,b,S,T,I,w,_),j=new Set([...g.values()].filter(F=>[...F.origins].some(K=>K.startsWith("literal-anchor:")||K==="literal-owner"||K==="symbol-anchor")).map(F=>w.get(F.file).id)),$=Pl(A),B=new Set(A.map(F=>F.id)),U=[..._].filter(F=>!B.has(F)).sort();for(let F of y)if(F.matchedRegionIds=cc(F,S,b,w),F.kind==="literal"){let K=S.filter(Z=>Z.query===F.query);F.seedRegionIds=z(K.filter(Z=>Z.traversalSeed).map(Z=>w.get(Z.file).id)),F.matchOnlyRegionIds=z(K.filter(Z=>!Z.traversalSeed).map(Z=>w.get(Z.file).id))}let q=[...b.values()].filter(F=>!F.processed).length,se=[...g.values()].filter(F=>F.primary&&!F.processed).length,Ne=[...g.values()].filter(F=>!F.primary&&!F.processed).length,Oe=[...b.values()].filter(F=>F.processed),ve=(f?.frontiers??[]).flatMap(F=>{let K=m.get(F.observationId);return!K&&F.source&&F.action&&F.strength?!O.has("runtime-boundary")||!D(F.source.file)||d==="exact"||!g.has(F.source.file)?[]:[{observationId:F.observationId,action:F.action,strength:F.strength,file:F.source.file,line:F.source.startLine,ownerShortName:F.ownerShortName??null,address:F.address??F.missingKeyParts.join(", "),reason:F.reason}]:!O.has("runtime-boundary")||!K||!D(K.source.file)||d==="exact"&&K.strength!=="exact"||!g.has(K.source.file)?[]:[{observationId:K.id,action:K.action,strength:K.strength,file:K.source.file,line:K.source.startLine,ownerShortName:K.owner.name,address:Gr(K),reason:F.reason,protocol:K.protocol,role:K.role,modality:K.modality,resolution:K.resolution,sourceScope:K.sourceScope,keyParts:K.keyParts.map(Z=>({name:Z.name,value:Z.value,evidence:Z.evidence}))}]}).sort((F,K)=>F.file.localeCompare(K.file)||F.line-K.line),E=(f?.links??[]).filter(F=>{if(!O.has("runtime-boundary")||d==="exact"&&F.strength!=="exact")return!1;let K=m.get(F.from),Z=m.get(F.to);return!!(K&&Z&&D(K.source.file)&&D(Z.source.file)&&(g.has(K.source.file)||g.has(Z.source.file)))}),k=E.filter(F=>F.strength==="exact").length,G=E.filter(F=>F.strength==="derived").length,H=E.filter(F=>F.strength==="candidate").length,me=f?.links.filter(F=>F.strength==="exact").length??0,Fe=f?.links.filter(F=>F.strength==="derived").length??0,Qe=f?.links.filter(F=>F.strength==="candidate").length??0,Kt=lc(R,w),qt=N===0?"accounted":"incomplete",Fn=[...L>0?[`${L} broad literal anchor(s) withheld ${x} exact match(es) before graph traversal; representative identities and scoped search commands preserve recovery without treating every textual occurrence as relevant.`]:[],`Literal matches outside the included source scopes (${c.join(", ")}) remain visible as match-only evidence and do not seed traversal.`,f?"Built-in runtime-boundary extractors traverse direct and replayably derived links; heuristic candidates, unsupported frameworks, reflection, generated names, and dependency wiring not recoverable from compiler occurrences or constructor assignments remain disclosed frontiers.":"Runtime-boundary evidence is unavailable for this index; run scip-query reindex with this build to extract supported HTTP, event, registry, and persistence observations.","Reverse references do not recursively expand from discovered callers or callees.","Member calls use compiler occurrences, exact constructor-assigned fields, bounded unique service providers, direct factory-return members, and compiler-resolved object-literal callbacks when available. Ambiguous providers remain candidate frontiers; callback values routed through mutation, reflection, or unsupported dependency containers remain unrepresented.","Literal traversal is bounded to the smallest parser-delimited source construct; parser gaps may reduce an owner to one source line and leave its continuation untraversed.","Schema consumers stay within forward-flow regions; cross-workspace contracts may discover consumers in other workspaces. Add an explicit symbol anchor to widen either scope.",`Traversal stops after depth ${i}; nonzero frontier counts identify evidence that was discovered but not traversed.`,"Region labels are structural path groupings, not inferred runtime or architectural boundaries."],fe=xl({db:t,anchors:y,regions:A,symbolStates:b,sourceConstructStates:C,literalHits:S,relations:T,externalBoundaries:Kt,boundaryFrontiers:ve,regionForFile:w,closureStatus:qt,omittedSymbolCandidates:N,maxDepth:i,requestedRelationKinds:l,evidenceFloor:d,includedSourceScopes:c,blindSpots:Fn,topologyFrontiers:n.topologyFrontiers??[],routeIds:n.routeIds??[],expandedRegionIds:[..._],maxTopologyCharacters:s,fullLiteralTraversal:n.fullLiteralTraversal??!1});if(o==="topology")return fe;let Pn=(n.behaviorFocusLocations?.length??0)>0?new Set([...fe.anchors.flatMap(F=>F.nodeIds),...fe.paths.flatMap(F=>F.nodeIds)]).size:void 0,ct=Co(t,fe,{focusLocations:n.behaviorFocusLocations,...Pn?{maxSteps:Pn}:{}});To(t,fe,ct);let Vr=cl(t,fe,ct,n.behaviorFocusLocations??[]);fe.corridor=dr(fe,{focusLocations:Vr});let An=Ro(t,fe,ct,{sourceAllowed:D,selectionTerms:n.selectionTerms}),kn=wl(fe),Qr=Tl(r,a,i,l,d,c,n.fullLiteralTraversal??!1,s,A,I,j,_,kn),Yr=Rl(r,a,i,A.filter(F=>kn.has(F.id)),j,l,d,c,n.fullLiteralTraversal??!1,s);return{anchors:y,regions:A,regionRelations:I,externalBoundaries:Kt,boundaryFrontiers:ve,unmatchedExpansions:U,expansion:Yr,drilldown:$,presentation:Qr,topology:fe,behavior:ct,nextAnchors:An,closure:{status:qt,emitted:{regions:A.length,relations:T.length,runtimeLinks:p.size},withheld:{symbols:q,files:se+Ne,regions:fe.nodes.filter(F=>F.kind==="structural-region"&&F.disposition==="folded").length,drillAnchors:($?.omittedAnchors??0)+An.omittedAnchors,literalMatches:x},ambiguous:{anchors:y.filter(F=>F.status==="ambiguous").length,omittedSymbolCandidates:N},external:Kt.length,unresolved:ve.length,explanation:qt==="accounted"?"Every fact reached under the declared anchors, relations, depth, evidence floor, source scopes, and installed analyzers is accounted for as emitted, withheld, ambiguous, external, or unresolved.":"Some ambiguous symbol candidates were not identified, so the declared query is not fully accounted for."},coverage:{explicitAnchorCount:y.length,requestedRelationKinds:l,evidenceFloor:d,includedSourceScopes:c,matchedAnchorCount:y.filter(F=>F.status!=="missing").length,literalSearchesComplete:!0,broadLiteralAnchors:L,withheldLiteralMatches:x,symbolCandidateSetsComplete:N===0,omittedSymbolCandidates:N,maxTraversalDepth:i,frontierSymbols:q,frontierFiles:se,supportFilesNotTraversed:Ne,filteredUnverifiedCallEdges:M,memberCallCandidateEdges:h,unresolvedMemberCallsites:P,runtimeBoundaryEvidenceAvailable:f!==null,runtimeBoundaryObservations:f?.observations.length??0,runtimeBoundaryExactLinks:k,runtimeBoundaryDerivedLinks:G,runtimeBoundaryCandidateLinks:H,repositoryRuntimeBoundaryExactLinks:me,repositoryRuntimeBoundaryDerivedLinks:Fe,repositoryRuntimeBoundaryCandidateLinks:Qe,runtimeBoundaryTraversedLinks:p.size,runtimeBoundaryFrontiers:ve.length,referenceExpansionEligibleSymbols:Oe.filter(F=>F.referenceScope!=="none").length,referenceExpansionSkippedSymbols:Oe.filter(F=>F.referenceScope==="none").length,dynamicDispatchRepresented:f?.links.some(F=>F.joinRule==="carrier.discriminator"&&p.has(F.id))??!1,runtimeGeneratedLinksRepresented:f!==null,regionBoundariesAreStructural:!0,relationFamilies:{"literal-anchor":{evidence:"exact-source",scope:"all indexed documents for each explicit literal",completeWithinScope:!0},reference:{evidence:"compiler-graph",scope:"all cross-file indexed/source-attributed sites for explicit anchors and promoted non-module boundary symbols",completeWithinScope:!0},call:{evidence:"mixed",scope:"static callees plus exact SCIP call occurrences in traversed source ranges, exact constructor-assigned member receivers, and uniquely attributed direct-import member candidates",completeWithinScope:!0},"contract-symbol":{evidence:"compiler-graph",scope:"compiler-resolved symbol identities referenced across inferred workspace boundaries",completeWithinScope:!0},import:{evidence:"compiler-graph",scope:"all indexed or source-resolved imports of traversed primary files",completeWithinScope:!0},"runtime-boundary":{evidence:"exact-source",scope:"direct and mechanically derived links produced by grounded runtime adapters and factorized relation groups",completeWithinScope:!0}},blindSpots:Fn}}}function rl(e,t){let{db:n,relationPolicy:o,sourceConstructs:r,reverseExpandedSourceConstructs:a,pendingRelations:i,reverseFileGraph:s,serviceCallerFilesBySourceConstruct:l,sourceAllowed:d,memberCallTargetsForWholeFile:c,addSymbol:u,addSourceConstruct:f}=e;if(o.has("call")){let m=[...r.values()].filter(p=>p.traversalEligible&&p.reverseCallExpansion&&p.depth<=t&&!a.has(Se(p)));for(let p of m){a.add(Se(p));let g=J(n,p.file);if((g?.callables??[]).filter(S=>S.name===p.name&&S.startLine<=p.endLine&&S.endLine>=p.startLine).length===1){let S=(g?.callSites??[]).filter(v=>v.calleeLeaf===p.name&&!v.memberAccess);for(let v of S){let R=t+1,y=Ge(X(n,p.file),v.line),N=null,L=null;if(y&&!re(y.symbol)){if(y.relativePath===p.file&&y.startLine<=p.endLine&&y.endLine>=p.startLine)continue;u(y,R,"reverse-local-call-owner",void 0,"forward-regions",!0),N=y.symbol}else{let x=Ln(n,p.file,v.line);x&&Se(x)!==Se(p)&&(L=f(x,R,"reverse-local-call-source-owner",void 0,!0))}!N&&!L||pe(i,{kind:"call",evidence:"ast-callsite",fromFile:p.file,fromSymbol:N,toFile:p.file,toSymbol:null,fromSourceConstruct:L?ae(L):void 0,toSourceConstruct:ae(p),line:v.line,strength:"derived"})}}let C=new Set([...s.get(p.file)??[],...l.get(Se(p))??[],...lo(n,p.file).flatMap(S=>[...s.get(S)??[]])]);for(let S of C){if(!d(S))continue;let R=c(S).targets.filter(y=>y.targetFile===p.file&&y.targetStartLine<=p.endLine&&y.targetEndLine>=p.startLine);for(let y of R){let N=t+1,L=Ge(X(n,S),y.line),x=null,M=null;if(L&&!re(L.symbol))u(L,N,"reverse-member-call-owner",void 0,"cross-workspace-or-forward",!0),x=L.symbol;else{let h=Ln(n,S,y.line);h&&(M=f(h,N,"reverse-member-call-source-owner",void 0,!0))}!x&&!M||pe(i,{kind:"call",evidence:"ast-service-member-callsite",fromFile:S,fromSymbol:x,toFile:p.file,toSymbol:null,fromSourceConstruct:M?ae(M):void 0,toSourceConstruct:ae(p),line:y.line,strength:y.strength==="exact"?"exact":"derived"})}}}}}function il(e,t){let{db:n,index:o,relationPolicy:r,symbols:a,sourceAllowed:i,files:s,workspaces:l,addFile:d,addSymbol:c,addSourceConstruct:u,pendingRelations:f,fileGraph:m,traversalMetrics:p}=e,g=[...a.values()].filter(C=>!C.processed&&C.depth<=t),b=r.has("call")?o.calleeMap(g.map(C=>C.definition),{additive:!1,semantic:!1}):new Map;for(let C of g){C.processed=!0;let S=C.definition;if(C.referenceScope!=="none"&&(r.has("call")||r.has("reference")||r.has("contract-symbol"))){let v=Ul(n,o,S).filter(y=>i(y.file)&&Xl(C,y.file,s,l)),R=new Set(v.flatMap(y=>{if(!(r.has("call")&&J(n,y.file)?.callSites.some(x=>x.line===y.line&&Mr(n,y.file,x,S))===!0)||!y.enclosingSymbol)return[];let L=Te(n,o,y.enclosingSymbol).matches[0];return L&&!re(L.symbol)?[{owner:L,site:y}]:[]}).sort((y,N)=>{let L=de(S.relativePath,l).relativeDir,x=de(y.owner.relativePath,l).relativeDir===L,M=de(N.owner.relativePath,l).relativeDir===L,h=Rr(n,y.owner),P=Rr(n,N.owner),D=y.owner.endLine-y.owner.startLine,O=N.owner.endLine-N.owner.startLine;return Number(M)-Number(x)||P-h||D-O||y.owner.symbol.localeCompare(N.owner.symbol)}).filter((y,N,L)=>L.findIndex(x=>x.owner.symbol===y.owner.symbol)===N).reduce((y,N)=>{if(y.length>=Qs)return y;let L=de(N.owner.relativePath,l).relativeDir;return y.some(x=>x.workspace===L)||y.push({symbol:N.owner.symbol,workspace:L}),y},[]).map(y=>y.symbol));for(let y of v){let N=t+1;d(y.file,N,`reference:${ee(S.symbol)}`,!0);let L=r.has("call")&&J(n,y.file)?.callSites.some(h=>h.line===y.line&&Mr(n,y.file,h,S))===!0,x=null,M=null;if(y.enclosingSymbol){let h=Te(n,o,y.enclosingSymbol).matches[0];h&&!re(h.symbol)&&(c(h,N,"reference-owner",void 0,L&&R.has(h.symbol)?C.referenceScope:"none"),x=h.symbol)}if(!x&&y.line!==null){let h=Ln(n,y.file,y.line);h&&(M=u(h,N,"reference-source-owner",void 0,L))}r.has("reference")&&pe(f,{kind:"reference",evidence:"indexed-or-source-reference",fromFile:y.file,fromSymbol:x,toFile:S.relativePath,toSymbol:S.symbol,fromSourceConstruct:M?ae(M):void 0,line:y.line,strength:"mixed"}),L&&pe(f,{kind:"call",evidence:"ast-callsite",fromFile:y.file,fromSymbol:x,toFile:S.relativePath,toSymbol:S.symbol,fromSourceConstruct:M?ae(M):void 0,line:y.line,strength:"derived"}),r.has("contract-symbol")&&de(y.file,l).relativeDir!==de(S.relativePath,l).relativeDir&&pe(f,{kind:"contract-symbol",evidence:"compiler-cross-workspace-symbol",fromFile:y.file,fromSymbol:x,toFile:S.relativePath,toSymbol:S.symbol,fromSourceConstruct:M?ae(M):void 0,line:y.line,strength:"exact"})}}for(let v of b.get(S.symbolId)??[]){let R=Te(n,o,v.symbol).matches.find(N=>N.relativePath===v.file);if(!R||!i(R.relativePath))continue;if(!(R.relativePath===S.relativePath||(m.get(S.relativePath)??new Set).has(R.relativePath))){p.filteredUnverifiedCallEdges+=1;continue}c(R,t+1,`call:${ee(S.symbol)}`,void 0,"none",!0),pe(f,{kind:"call",evidence:v.source,fromFile:S.relativePath,fromSymbol:S.symbol,toFile:R.relativePath,toSymbol:R.symbol,line:null,strength:Ml(v.source)})}}}function al(e,t){let{db:n,index:o,relationPolicy:r,files:a,sourceConstructs:i,symbols:s,boundaryObservations:l,boundaryObservationDepths:d,sourceAllowed:c,addSymbol:u,pendingRelations:f,traversalMetrics:m,addSourceConstruct:p,serviceCallerFilesBySourceConstruct:g,reverseFileGraph:b,externalImports:C,addFile:S,workspaces:v}=e,R=[...a.values()].filter(y=>!y.processed&&y.primary&&y.depth<=t);for(let y of R){y.processed=!0;let N=[...i.values()].filter(I=>I.traversalEligible&&I.file===y.file&&I.depth<=t),L=[...s.values()].filter(I=>I.definition.relativePath===y.file&&I.depth<=t).map(I=>{let _=Xt(n,y.file,I.definition.startLine);return{startLine:_?.startLine??I.definition.startLine,endLine:_?.endLine??I.definition.endLine}}),x=I=>[...s.values()].filter(_=>_.definition.relativePath===y.file&&_.definition.startLine<=I&&_.definition.endLine>=I).sort((_,A)=>_.definition.endLine-_.definition.startLine-(A.definition.endLine-A.definition.startLine)||_.definition.startLine-A.definition.startLine)[0],M=[...l.values()].filter(I=>I.source.file===y.file&&d.has(I.id)),h=[...N.map(I=>({startLine:I.startLine,endLine:I.endLine})),...M.map(I=>({...Bt(n,I)}))],P=[...L,...h],D=(J(n,y.file)?.callSites??[]).filter(I=>P.some(_=>I.line>=_.startLine&&I.line<=_.endLine)),O=new Set;if(r.has("call"))for(let I of P){let _=xt(n,y.file,I.startLine,I.endLine);for(let A of _.targets){if(!c(A.definition.relativePath))continue;let j=x(A.sourceLine),$=N.find(U=>U.startLine<=A.sourceLine&&U.endLine>=A.sourceLine),B=M.find(U=>{let q=Bt(n,U);return q.startLine<=A.sourceLine&&q.endLine>=A.sourceLine});u(A.definition,t+1,`scip-occurrence-call:${y.file}:${A.sourceLine+1}`,void 0,"none",!0),pe(f,{kind:"call",evidence:"scip-occurrence-callsite",fromFile:y.file,fromSymbol:j?.definition.symbol??null,toFile:A.definition.relativePath,toSymbol:A.definition.symbol,fromBoundaryParticipant:B?Ve(B):void 0,fromSourceConstruct:$?ae($):void 0,line:A.sourceLine,strength:"exact"}),O.add(`${A.sourceLine}\0${A.calleeLeaf}`)}}if(r.has("reference"))for(let I of P){let _=yo(n,y.file,I.startLine,I.endLine);for(let A of _.targets){if(!c(A.definition.relativePath)||O.has(`${A.sourceLine}\0${A.calleeLeaf}`))continue;let j=x(A.sourceLine);if(j?.definition.symbol===A.definition.symbol)continue;let $=N.find(U=>U.startLine<=A.sourceLine&&U.endLine>=A.sourceLine),B=M.find(U=>{let q=Bt(n,U);return q.startLine<=A.sourceLine&&q.endLine>=A.sourceLine});u(A.definition,t+1,`scip-occurrence-reference:${y.file}:${A.sourceLine+1}`,void 0,"none",!0),pe(f,{kind:"reference",evidence:"scip-occurrence-reference",fromFile:y.file,fromSymbol:j?.definition.symbol??null,toFile:A.definition.relativePath,toSymbol:A.definition.symbol,fromBoundaryParticipant:B?Ve(B):void 0,fromSourceConstruct:$?ae($):void 0,line:A.sourceLine,strength:"exact"})}}let w=r.has("call")?Jt(n,y.file,{ranges:P,excludeIndexedTargets:!1}):{targets:[],unresolvedCallsites:0};m.unresolvedMemberCallsites+=w.unresolvedCallsites;let T=w.targets.filter(I=>!O.has(`${I.line}\0${I.calleeLeaf}`));m.memberCallCandidateEdges+=T.filter(I=>I.strength!=="exact"&&(I.resolution!=="imported-service-object-member"||(I.resolutionAlternativeCount??0)>1)).length;for(let I of T){let _=(I.resolutionAlternativeCount??1)===1,A=I.targetSymbol?X(n,I.targetFile).find(q=>q.symbol===I.targetSymbol):void 0,j=A?null:p({file:I.targetFile,name:I.calleeLeaf,startLine:I.targetStartLine,endLine:I.targetEndLine},t+1,`member-call:${y.file}`,void 0,I.resolution==="imported-service-object-member"&&_,_);if(j&&I.serviceFile){let q=Se(j),se=g.get(q)??new Set;for(let Ne of b.get(I.serviceFile)??[])se.add(Ne);g.set(q,se)}A&&u(A,t+1,`member-call:${y.file}`,void 0,"none",!0);let $=N.find(q=>q.startLine<=I.line&&q.endLine>=I.line),B=x(I.line),U=M.find(q=>{let se=Bt(n,q);return se.startLine<=I.line&&se.endLine>=I.line});pe(f,{kind:"call",evidence:I.resolution==="constructed-member-receiver"?"ast-constructed-member-callsite":I.resolution==="factory-callback-member"?"ast-factory-callback-callsite":I.resolution==="imported-service-object-member"?"ast-service-member-callsite":"ast-member-import-candidate",fromFile:y.file,fromSymbol:B?.definition.symbol??null,toFile:I.targetFile,toSymbol:A?.symbol??null,fromBoundaryParticipant:U?Ve(U):void 0,fromSourceConstruct:$?ae($):void 0,toSourceConstruct:j?ae(j):void 0,line:I.line,strength:I.resolution==="imported-service-object-member"?(I.resolutionAlternativeCount??0)===1?"derived":"candidate":I.strength??"candidate"})}for(let I of r.has("import")||r.has("call")?Wl(n,y.file):[]){if(!I.fromFile){if(r.has("import")){let A=C.get(I.shortName)??{name:I.shortName,fromFiles:new Set};A.fromFiles.add(y.file),C.set(I.shortName,A)}continue}if(!c(I.fromFile))continue;if(r.has("import")&&(S(I.fromFile,t+1,`import:${y.file}`,!1),pe(f,{kind:"import",evidence:"indexed-or-source-import",fromFile:y.file,fromSymbol:null,toFile:I.fromFile,toSymbol:I.symbol,line:null,strength:"mixed"})),r.has("call")&&D.length>0){let A=(I.source==="compiler"?Te(n,o,I.symbol).matches:je(n,I.fromFile,I.importedName)).filter(j=>!re(j.symbol));for(let j of A){let $=D.filter(B=>B.calleeLeaf===I.localName).map(B=>B.line);if($.length!==0){u(j,t+1,`source-call:${y.file}`,void 0,"none",!0);for(let B of $)pe(f,{kind:"call",evidence:"ast-callsite",fromFile:y.file,fromSymbol:null,toFile:j.relativePath,toSymbol:j.symbol,line:B,strength:"derived"})}}}if(!y.promoteBoundaryImports||!Ql(y.file,I.fromFile,v))continue;let _=Te(n,o,I.symbol);for(let A of _.matches)if(Yl(A.relativePath,I.fromFile,v)&&!re(A.symbol)){let j=de(y.file,v).relativeDir!==de(A.relativePath,v).relativeDir;u(A,t+1,`boundary-import:${y.file}`,void 0,j?"cross-workspace-or-forward":"forward-regions")}}}}function sl(e,t){let{relationPolicy:n,runtimeBoundaries:o,evidenceFloor:r,representedBoundaryLinkIds:a,boundaryObservations:i,sourceAllowed:s,boundaryObservationDepths:l,symbols:d,sourceConstructs:c,addBoundaryObservation:u,pendingRelations:f}=e;for(let m of n.has("runtime-boundary")?o?.links??[]:[]){if(m.strength==="candidate"||r==="exact"&&m.strength!=="exact"||a.has(m.id))continue;let p=i.get(m.from),g=i.get(m.to);if(!p||!g||!s(p.source.file)||!s(g.source.file))continue;let b=$r(p,t,l,d,c),C=$r(g,t,l,d,c);if(b===null&&C===null)continue;let S=t+1,v=u(p,b??S,`runtime-boundary:${m.joinRule}`),R=u(g,C??S,`runtime-boundary:${m.joinRule}`),y=v?null:kr(c,p),N=R?null:kr(c,g);l.set(p.id,b??S),l.set(g.id,C??S),pe(f,{kind:"runtime-boundary",evidence:`runtime-boundary:${m.joinRule}`,fromFile:p.source.file,fromSymbol:v,toFile:g.source.file,toSymbol:R,fromBoundaryParticipant:Ve(p),toBoundaryParticipant:Ve(g),fromSourceConstruct:y?ae(y):void 0,toSourceConstruct:N?ae(N):void 0,runtimeBoundaryKey:m.matchedKeyParts.map(L=>`${L.name}=${L.value}`).join(" "),line:p.source.startLine,strength:m.strength}),a.add(m.id)}}function ll(e,t,n){let o=ne(t.searches??[]),r=ne(t.symbols??[]),a=ne(t.relations&&t.relations.length>0?t.relations:wr),i=a.filter(k=>!wr.includes(k));if(i.length>0)throw new Error(`Unsupported system-map relation kind(s): ${i.join(", ")}`);let s=new Set(a),l=t.evidenceFloor??"derived";if(l!=="exact"&&l!=="derived")throw new Error(`Unsupported system-map evidence floor: ${l}`);let d=ne(t.sourceScopes&&t.sourceScopes.length>0?t.sourceScopes:["production"]),c=["production","test","fixture","example","generated","script","unknown"],u=d.filter(k=>!c.includes(k));if(u.length>0)throw new Error(`Unsupported system-map source scope(s): ${u.join(", ")}`);let f=new Set(d),m=k=>f.has(Wt(k));if(o.length===0&&r.length===0)throw new Error("system-map requires at least one --search or --symbol anchor.");let p=t.maxDepth??Ks;if(!Number.isSafeInteger(p)||p<0)throw new RangeError(`maxDepth must be a non-negative safe integer; received ${p}`);let g=t.maxTopologyCharacters??Xs;if(!Number.isSafeInteger(g)||g<=0)throw new RangeError(`maxTopologyCharacters must be a positive safe integer; received ${g}`);let b=new bt(e),{fileGraph:C,reverseFileGraph:S,workspaces:v,runtimeBoundaries:R}=Jl(e,b),y=new Map((R?.observations??[]).map(k=>[k.id,k])),N=new Set((R?.observations??[]).map(k=>`${k.source.file}\0${k.source.startLine}`)),L=new Set,x=new Map,M=new Map,h=new Map,P=new Map,D=[],O=new Map,w=new Map,T=[],I={filteredUnverifiedCallEdges:0,memberCallCandidateEdges:0,unresolvedMemberCallsites:0},_=new Set,A=new Map,j=new Map,$=k=>{let G=j.get(k);if(G)return G;let H=Jt(e,k,{excludeIndexedTargets:!1});return j.set(k,H),H},B=(k,G,H,me,Fe=!1)=>Zs(M,k,G,H,me,Fe),U=(k,G,H,me,Fe="none",Qe=!1)=>Js(h,B,k,G,H,me,Fe,Qe),q=(k,G,H,me,Fe=!1,Qe=!0)=>el(P,B,k,G,H,me,Fe,Qe),se=(k,G,H)=>tl({db:e,index:b,pendingRelations:O,addFile:B,addSymbol:U,addSourceConstruct:q,observation:k,depth:G,origin:H}),{omittedSymbolCandidates:Ne,broadLiteralAnchors:Oe,withheldLiteralMatches:ve}=nl({db:e,index:b,searches:o,symbolQueries:r,opts:t,boundaryObservationLocations:N,sourceAllowed:m,addFile:B,addSymbol:U,addSourceConstruct:q,literalHits:D,anchors:T}),E={db:e,index:b,relationPolicy:s,evidenceFloor:l,sourceAllowed:m,fileGraph:C,reverseFileGraph:S,workspaces:v,runtimeBoundaries:R,boundaryObservations:y,boundaryObservationDepths:x,representedBoundaryLinkIds:L,files:M,symbols:h,sourceConstructs:P,pendingRelations:O,externalImports:w,reverseExpandedSourceConstructs:_,serviceCallerFilesBySourceConstruct:A,traversalMetrics:I,memberCallTargetsForWholeFile:$,addFile:B,addSymbol:U,addSourceConstruct:q,addBoundaryObservation:se};for(let k=0;k<p;k+=1)rl(E,k),il(E,k),al(E,k),sl(E,k);return ol({db:e,opts:t,mode:n,searches:o,symbolQueries:r,maxDepth:p,maxTopologyCharacters:g,requestedRelationKinds:a,evidenceFloor:l,includedSourceScopes:d,workspaces:v,runtimeBoundaries:R,boundaryObservations:y,representedBoundaryLinkIds:L,files:M,symbols:h,sourceConstructs:P,literalHits:D,pendingRelations:O,externalImports:w,anchors:T,omittedSymbolCandidates:Ne,broadLiteralAnchors:Oe,withheldLiteralMatches:ve,filteredUnverifiedCallEdges:I.filteredUnverifiedCallEdges,memberCallCandidateEdges:I.memberCallCandidateEdges,unresolvedMemberCallsites:I.unresolvedMemberCallsites,sourceAllowed:m})}function cl(e,t,n,o){let r=new Map,a=l=>{r.set(`${l.file}\0${l.line}`,l)};for(let l of o)a(l);let i=new Set(t.anchors.filter(l=>l.status==="matched").flatMap(l=>l.nodeIds));for(let l of n.steps)if(!(!l.location||!i.has(l.nodeId)||(l.behavior?.rawCharacters??1/0)>3e3))for(let d of l.behavior?.lines??[])d.signals.some(c=>Ys.has(c))&&a({file:l.location.file,line:d.line,endLine:d.endLine});let s=t.edges.filter(l=>l.disposition==="emitted").flatMap(l=>l.evidence.flatMap(d=>d.location?[d.location]:[]));for(let l of s){a(l);let d=t.nodes.filter(u=>u.location?.file===l.file&&["symbol","source-construct","runtime-boundary-participant"].includes(u.kind)&&u.location.line<=l.line&&(u.location.endLine??u.location.line)>=l.line).sort((u,f)=>(u.location.endLine??u.location.line)-u.location.line-((f.location.endLine??f.location.line)-f.location.line)||u.id.localeCompare(f.id))[0];if(!d?.location)continue;let c=ht(e,l.file,d.location.line,d.location.endLine??d.location.line,[l.line]);for(let u of c)a({file:l.file,line:u.line,endLine:u.endLine})}return[...r.values()].sort((l,d)=>l.file.localeCompare(d.file)||l.line-d.line)}function dl(e){if(e.ownerStartLine===null||e.ownerStartLine===void 0)throw new Error(`Literal hit ${e.file}:${e.line+1} has no source-owner start line.`);if(e.ownerEndLine===null||e.ownerEndLine===void 0)throw new Error(`Literal hit ${e.file}:${e.line+1} has no source-owner end line.`);return{file:e.file,name:e.ownerShortName??`${e.file}:${e.ownerStartLine+1}`,startLine:e.ownerStartLine,endLine:e.ownerEndLine}}function Se(e){return`${e.file}\0${e.startLine}\0${e.endLine}\0${e.name}`}function ae(e){return{file:e.file,name:e.name,startLine:e.startLine,endLine:e.endLine}}function Mr(e,t,n,o){if(n.calleeLeaf===o.leaf)return!0;let r=Gn(e,t,n.calleeLeaf);return r!==null&&r.importedName===o.leaf&&r.sourcePath!==null&&Pe(r.sourcePath,o.relativePath)}function Ot(e,t){let n=pt(J(e,t.file)?.callables??[],t.startLine);if(n&&n.endLine>=t.endLine)return{file:t.file,name:/^source@\d+$/u.test(n.name)&&!/^source@\d+$/u.test(t.name)?t.name:n.name,startLine:n.startLine,endLine:n.endLine};let o=Or(e,t.file,t.startLine);return o&&o.endLine>=t.endLine?{file:t.file,name:o.name,startLine:o.startLine,endLine:o.endLine}:ae(t)}function He(e){return ue("source-construct",e.file,String(e.startLine),String(e.endLine),e.name)}function Gt(e,t){let n=Xn(e,t.symbol,t.relativePath),o=new Set(["package-surface-file","transitive-package-surface"]),r=n.filter(i=>!o.has(i)||Jn(e,t)),a=r.some(i=>!o.has(i));return{evidence:r,priority:a||Zn(e,t.symbol,t.relativePath)?2:1}}function Rr(e,t){let n=Gt(e,t);return n.evidence.length>0?n.priority:0}function ul(e,t){let n=X(e,t.file),o=n.filter(r=>r.startLine<=t.startLine&&r.endLine>=t.startLine).sort((r,a)=>r.endLine-r.startLine-(a.endLine-a.startLine)||r.startLine-a.startLine);for(let r of o){let a=Gt(e,r);if(a.evidence.length>0)return a}for(let r of pl(e,t.file,t.startLine)){let a=n.filter(i=>i.leaf===r.name).sort((i,s)=>Math.abs(i.startLine-r.startLine)-Math.abs(s.startLine-r.startLine)||i.symbol.localeCompare(s.symbol));for(let i of a){let s=Gt(e,i);if(s.evidence.length>0)return s}return{evidence:[],priority:0}}return{evidence:[],priority:0}}function pl(e,t,n){let o=Y(e,t)?.rootNode;if(!o||o.startPosition.row>n||o.endPosition.row<n)return[];let r=[],a=Nn(o,n);for(;a;){if(a.type==="variable_declarator"||a.type==="function_declaration"||a.type==="generator_function_declaration"||a.type==="class_declaration"){let i=a.childForFieldName("name")??a.namedChild(0);(i?.type==="identifier"||i?.type==="type_identifier")&&r.push({name:i.text,startLine:a.startPosition.row})}a=a.parent}return r}function ml(e){return[...new Map([...e.sourceConstructStates.values()].map(t=>Ot(e.db,t)).map(t=>[Se(t),t])).values()].sort((t,n)=>t.file.localeCompare(n.file)||t.startLine-n.startLine||t.endLine-n.endLine)}function fl(e,t){return e.anchors.map((n,o)=>{let r=ue("anchor",String(o),n.kind,n.query),a=[...e.symbolStates.values()].filter(c=>c.anchorQueries.has(n.query)).flatMap(c=>{if(!re(c.definition.symbol))return[Re(c.definition.symbol)];let u=t.filter(f=>f.file===c.definition.relativePath).map(f=>He(f));return u.length>0?u:[Re(c.definition.symbol)]}),i=[...e.sourceConstructStates.values()].filter(c=>c.anchorQueries.has(n.query)).map(c=>He(Ot(e.db,c))),s=e.literalHits.filter(c=>c.query===n.query&&c.traversalSeed===!0&&c.ownerSymbol&&e.symbolStates.has(c.ownerSymbol)).map(c=>Re(c.ownerSymbol)),l=e.literalHits.filter(c=>c.query===n.query&&c.traversalSeed===!0&&!c.ownerSymbol&&c.ownerStartLine!==null&&c.ownerStartLine!==void 0&&c.ownerEndLine!==null&&c.ownerEndLine!==void 0).map(c=>He(Ot(e.db,dl(c)))),d=z(n.kind==="symbol"?[...a,...i]:s.length+l.length>0?[...s,...l]:n.seedRegionIds??[]);return{id:r,kind:n.kind,query:n.query,status:n.status,nodeIds:n.status==="ambiguous"?[]:d,candidateNodeIds:n.status==="ambiguous"?d:[],omittedCandidates:n.omittedSymbolCandidates??0}})}function gl(e){let t=new Map;for(let n of e)for(let o of[...n.nodeIds,...n.candidateNodeIds]){let r=t.get(o)??[];r.push(n.id),t.set(o,r)}return t}function yl(e,t,n){let o=e.relations.flatMap(i=>[i.fromBoundaryParticipant,i.toBoundaryParticipant].flatMap(s=>s?.ownerName?[s]:[])),r=e.regions.map(i=>({id:i.id,kind:"structural-region",label:i.label,disposition:"folded",location:null,anchorIds:z(n.get(i.id)??[]),attributes:{workspace:i.workspace,structuralPath:i.structuralPath,minimumDepth:i.minDepth,files:i.fileCount,symbols:i.symbolCount,expanded:i.expanded}}));for(let i of e.symbolStates.values()){let s=e.regionForFile.get(i.definition.relativePath)?.id;if(!s)throw new Error(`System-map symbol ${i.definition.symbol} has no structural region.`);let l=Re(i.definition.symbol),d=Gt(e.db,i.definition);r.push({id:l,kind:"symbol",label:ee(i.definition.symbol),disposition:(n.get(l)?.length??0)>0?"emitted":"folded",location:{file:i.definition.relativePath,line:i.definition.startLine,endLine:i.definition.endLine},anchorIds:z(n.get(l)??[]),attributes:{regionId:s,depth:i.depth,leaf:i.definition.leaf??ee(i.definition.symbol),referenceScope:i.referenceScope,...d.evidence.length>0?{publicEntry:!0,publicEntryPriority:d.priority,publicEntryEvidence:d.evidence.join(",")}:{}}})}for(let i of t){let s=e.regionForFile.get(i.file)?.id;if(!s)throw new Error(`Source construct ${i.name} has no structural region.`);let l=He(i),c=o.find(f=>f.file===i.file&&f.line>=i.startLine&&f.line<=i.endLine)?.ownerName??i.name,u=ul(e.db,i);r.push({id:l,kind:"source-construct",label:c,disposition:(n.get(l)?.length??0)>0?"emitted":"folded",location:{file:i.file,line:i.startLine,endLine:i.endLine},anchorIds:z(n.get(l)??[]),attributes:{regionId:s,leaf:c,sourceOwned:!0,...u.evidence.length>0?{publicEntry:!0,publicEntryPriority:u.priority,publicEntryEvidence:u.evidence.join(",")}:{}}})}let a=new Map;for(let i of e.relations)i.fromBoundaryParticipant&&a.set(i.fromBoundaryParticipant.observationId,i.fromBoundaryParticipant),i.toBoundaryParticipant&&a.set(i.toBoundaryParticipant.observationId,i.toBoundaryParticipant);for(let i of[...a.values()].sort((s,l)=>s.observationId.localeCompare(l.observationId))){let s=e.regionForFile.get(i.file)?.id;if(!s)throw new Error(`Runtime-boundary participant ${i.observationId} has no structural region.`);r.push({id:Mn(i.observationId),kind:"runtime-boundary-participant",label:i.address||i.ownerName||`${i.role} ${i.action}`,disposition:"folded",location:{file:i.file,line:i.line,endLine:i.endLine},anchorIds:[],attributes:{regionId:s,action:i.action,protocol:i.protocol,role:i.role,...i.address?{address:i.address}:{},ownerSymbol:i.ownerSymbol}})}return r}function hl(e,t,n,o,r,a,i,s,l,d=!1){let c=o?Re(o):null;if(c&&t.has(c)&&!re(o))return c;let u=r?Mn(r.observationId):null;if(d&&u&&t.has(u))return u;let f=a?He(Ot(e,a)):null;if(f&&t.has(f))return f;if(u&&t.has(u))return u;let m=l===null?null:(n.get(s)??[]).filter(p=>p.startLine<=l&&p.endLine>=l).sort((p,g)=>p.endLine-p.startLine-(g.endLine-g.startLine)||p.startLine-g.startLine)[0]??null;return m?He(m):c&&t.has(c)?c:i}function bl(e,t,n){let o=new Set(t.map(d=>d.id)),r=ye(n,d=>d.file),a=(d,c,u,f,m,p,g=!1)=>hl(e.db,o,r,d,c,u,f,m,p,g),i=[];for(let d of e.symbolStates.values()){let c=e.regionForFile.get(d.definition.relativePath)?.id;if(!c)continue;let u=Re(d.definition.symbol);i.push({id:ue("edge","structural-membership",c,u),kind:"structural-membership",fromNodeId:c,toNodeId:u,directed:!0,disposition:"folded",semantics:wt("structural-membership"),evidence:[{method:"indexed-definition-file",strength:"exact",identity:d.definition.symbol,location:{file:d.definition.relativePath,line:d.definition.startLine,endLine:d.definition.endLine}}]})}let s=ye(e.relations,d=>`${a(d.fromSymbol,d.fromBoundaryParticipant,d.fromSourceConstruct,d.fromRegionId,d.fromFile,d.line,d.kind==="runtime-boundary")}\0${a(d.toSymbol,d.toBoundaryParticipant,d.toSourceConstruct,d.toRegionId,d.toFile,null)}\0${d.kind}`),l=new Set;for(let d of s.values()){let c=d[0],u=a(c.fromSymbol,c.fromBoundaryParticipant,c.fromSourceConstruct,c.fromRegionId,c.fromFile,c.line,c.kind==="runtime-boundary"),f=a(c.toSymbol,c.toBoundaryParticipant,c.toSourceConstruct,c.toRegionId,c.toFile,null);if(c.kind==="runtime-boundary"&&c.fromBoundaryParticipant){let p=Mn(c.fromBoundaryParticipant.observationId),g=a(c.fromSymbol,void 0,c.fromSourceConstruct,c.fromRegionId,c.fromFile,c.line);g!==p&&!l.has(p)&&(l.add(p),i.push({id:ue("edge","boundary-observation",g,p),kind:"boundary-observation",fromNodeId:g,toNodeId:p,directed:!0,disposition:"folded",semantics:wt("boundary-observation"),evidence:[{method:"runtime-boundary-observation-owner",strength:c.strength??"unknown",identity:c.fromBoundaryParticipant.observationId,location:{file:c.fromBoundaryParticipant.file,line:c.fromBoundaryParticipant.line,endLine:c.fromBoundaryParticipant.endLine}}]}))}(u===f?t.find(p=>p.id===u):null)?.kind!=="structural-region"&&i.push({id:ue("edge",c.kind,u,f),kind:c.kind,fromNodeId:u,toNodeId:f,directed:!0,disposition:"folded",semantics:$o(c),evidence:Nl(d.map(p=>({method:p.evidence,strength:p.strength??"unknown",identity:p.kind==="runtime-boundary"&&p.runtimeBoundaryKey?p.runtimeBoundaryKey:`${p.fromSymbol??p.fromFile} -> ${p.toSymbol??p.toFile}`,location:p.line===null?null:{file:p.fromFile,line:p.line}})))})}return i}function Sl(e,t,n){for(let r of e.externalBoundaries){let a=ue("external",r.kind,r.name),i=z(r.fromRegionIds);t.push({id:a,kind:r.kind,label:r.name,disposition:"folded",location:null,anchorIds:[],attributes:{}});for(let s of i)n.push({id:ue("edge",r.kind,s,a),kind:r.kind,fromNodeId:s,toNodeId:a,directed:!0,disposition:"folded",semantics:wt("external-import"),evidence:[{method:"indexed-or-source-import",strength:"mixed",identity:`${s} -> ${r.name}`,location:null}]})}let o=[];return e.boundaryFrontiers.forEach((r,a)=>{let i=e.regionForFile.get(r.file)?.id;if(!i)throw new Error(`Runtime-boundary frontier ${r.observationId} has no system-map region.`);let s=ue("unsupported","runtime-boundary",r.observationId,String(a)),l=ue("edge","runtime-boundary-frontier",i,s);t.push({id:s,kind:"runtime-boundary-frontier",label:r.address,disposition:"unsupported",location:{file:r.file,line:r.line},anchorIds:[],attributes:{action:r.action,strength:r.strength,owner:r.ownerShortName}}),n.push({id:l,kind:"runtime-boundary-frontier",fromNodeId:i,toNodeId:s,directed:!0,disposition:"unsupported",evidence:[{method:"runtime-boundary-extractor",strength:r.strength,identity:r.observationId,location:{file:r.file,line:r.line}}]}),o.push({id:ue("frontier","runtime-boundary",r.observationId,String(a)),kind:"runtime-boundary",direction:"unresolved",fromNodeIds:[i],edgeIds:[l],memberNodeIds:[s],memberCount:1,disposition:"unsupported",reason:r.reason,expansion:null})}),o}function vl(e,t){let n=t.topologyFrontiers.some(p=>p==="frontier:program-facts"),o=Cr(e,{expandedFrontierIds:t.topologyFrontiers.filter(p=>p!=="frontier:program-facts"),routeIds:t.routeIds}),r=o.nodes.filter(p=>p.disposition==="emitted"||o.anchors.some(g=>g.status==="matched"&&g.nodeIds.includes(p.id))),a=t.relations.filter(p=>r.some(g=>El(p,g))),i=t.boundaryFrontiers.filter(p=>r.some(g=>Cl(p,g))),s=Uo(t.db,a,r),l=Ho(t.db,r),d=ir(t.db,r,i),c=[...s.nodes,...l.nodes,...d.nodes].map(p=>n&&p.disposition==="folded"?{...p,disposition:"emitted"}:p),u=[...s.edges,...l.edges,...d.edges].map(p=>n&&p.disposition==="folded"?{...p,disposition:"emitted"}:p),f=n?null:Ll(r,c,u),m=_t({anchors:o.anchors,nodes:[...o.nodes,...c],edges:[...o.edges,...u],paths:o.paths,frontiers:[...o.frontiers,...s.frontiers,...l.frontiers,...d.frontiers,...f?[f]:[]],scope:o.coverage.scope,blindSpots:[...o.coverage.blindSpots,...s.blindSpots,...l.blindSpots,...d.blindSpots],incompleteReasons:o.coverage.status==="incomplete"?[o.coverage.explanation]:[],...o.routeCatalog?{routeCatalog:o.routeCatalog}:{}});m.completion=o.completion;for(let p of m.frontiers)p.disposition==="folded"&&(p.id.startsWith("frontier:program-facts:")||(p.expansion=Il(t,p.id)));return m}function xl(e){let t=ml(e),n=fl(e,t),o=yl(e,t,gl(n)),r=bl(e,o,t),a=Sl(e,o,r);return vl(_t({anchors:n,nodes:o,edges:r,paths:[],frontiers:a,scope:`explicit anchors; relations ${e.requestedRelationKinds.join(", ")}; depth ${e.maxDepth}; evidence floor ${e.evidenceFloor}; source scopes ${e.includedSourceScopes.join(", ")}`,blindSpots:[...e.blindSpots],incompleteReasons:e.closureStatus==="incomplete"?[`${e.omittedSymbolCandidates} ambiguous symbol candidate(s) were omitted`]:[]}),e)}function El(e,t){if(e.fromSymbol&&t.id===Re(e.fromSymbol)||e.toSymbol&&t.id===Re(e.toSymbol))return!0;if(!t.location)return!1;let n=t.location.endLine??t.location.line;return t.location.file===e.fromFile&&e.line!==null&&e.line>=t.location.line&&e.line<=n||t.location.file===e.toFile}function Cl(e,t){if(!t.location||t.location.file!==e.file)return!1;let n=t.location.endLine??t.location.line;return e.line>=t.location.line&&e.line<=n||t.label===e.ownerShortName||typeof e.ownerShortName=="string"&&t.label.includes(e.ownerShortName)}function Ll(e,t,n){let o=z(t.filter(a=>a.disposition==="folded").map(a=>a.id)),r=z(n.filter(a=>a.disposition==="folded").map(a=>a.id));return o.length===0&&r.length===0?null:{id:ue("frontier","program-facts"),kind:"program-facts",direction:"outgoing",fromNodeIds:z(e.map(a=>a.id)),edgeIds:r,memberNodeIds:o,memberCount:o.length,disposition:"folded",reason:"Control, data, state, and temporal facts are folded beneath the selected high-level owners.",expansion:null}}function Il(e,t){return`scip-query system-map ${[...e.anchors.flatMap(o=>o.kind==="literal"?[`--search ${V(o.query)}`]:[`--symbol ${V(o.query)}`]),`--depth ${e.maxDepth}`,...e.requestedRelationKinds.map(o=>`--relation ${V(o)}`),`--evidence-floor ${V(e.evidenceFloor)}`,...e.includedSourceScopes.map(o=>`--source-scope ${V(o)}`),...e.fullLiteralTraversal?["--full-literal-traversal"]:[],`--topology-characters ${e.maxTopologyCharacters}`,...e.expandedRegionIds.map(o=>`--expand ${V(o)}`),...e.topologyFrontiers.map(o=>`--frontier ${V(o)}`),...e.routeIds.map(o=>`--route ${V(o)}`),`--frontier ${V(t)}`].join(" ")}`}function wl(e){let t=new Set;for(let n of e.nodes){if(n.disposition!=="emitted")continue;n.kind==="structural-region"&&t.add(n.id);let o=n.attributes.regionId;typeof o=="string"&&t.add(o)}return t}function Nl(e){let t=new Map;for(let n of e){let o=n.location?`${n.location.file}:${n.location.line}`:"";t.set(`${n.method}\0${n.strength}\0${n.identity??""}\0${o}`,n)}return[...t.values()].sort((n,o)=>n.method.localeCompare(o.method)||(n.identity??"").localeCompare(o.identity??"")||(n.location?.file??"").localeCompare(o.location?.file??"")||(n.location?.line??0)-(o.location?.line??0))}function ue(...e){return e.map(t=>encodeURIComponent(t)).join(":")}function Re(e){return ue("symbol",e)}function Ml(e){return e==="semantic-callee"||e==="scip-chunk"?"exact":"derived"}function Rl(e,t,n,o,r,a,i,s,l,d){let c=[...o].sort((g,b)=>Br(g,b,r)),f=c.slice(0,Ir).map(g=>g.id),m=c.slice(Ir).map(g=>g.id),p=[...e.map(g=>`--search ${V(g)}`),...t.map(g=>`--symbol ${V(g)}`),`--depth ${n}`,...a.map(g=>`--relation ${V(g)}`),`--evidence-floor ${V(i)}`,...s.map(g=>`--source-scope ${V(g)}`),...l?["--full-literal-traversal"]:[],`--topology-characters ${d}`,...f.map(g=>`--expand ${V(g)}`)];return{command:f.length===0?null:`scip-query system-map ${p.join(" ")}`,regionCount:f.length,regionIds:f,candidateRegionCount:o.length,omittedRegionIds:m}}function Tl(e,t,n,o,r,a,i,s,l,d,c,u,f){let m=[...l].sort((h,P)=>Br(h,P,c)).filter(h=>!f||f.has(h.id)||u.has(h.id)),p=d.length>0?Math.floor(s*.4):0,g=s-p,b=new Set,C=0;for(let h of m){let P=Tr(h);!u.has(h.id)&&b.size>0&&C+P>g||(b.add(h.id),C+=P)}let S=d.filter(h=>b.has(h.fromRegionId)&&b.has(h.toRegionId)).sort(Fl),v=[];for(let h of S){let P=Fr(h);v.length>0&&C+P>s||(v.push(jt(h)),C+=P)}let R=l.filter(h=>!b.has(h.id)).map(h=>h.id).sort(),y=new Set(v),N=d.filter(h=>!y.has(jt(h))).length,L=l.reduce((h,P)=>h+Tr(P),0)+d.reduce((h,P)=>h+Fr(P),0),x=m.every(h=>b.has(h.id))&&v.length===S.length,M=[...e.map(h=>`--search ${V(h)}`),...t.map(h=>`--symbol ${V(h)}`),`--depth ${n}`,...o.map(h=>`--relation ${V(h)}`),`--evidence-floor ${V(r)}`,...a.map(h=>`--source-scope ${V(h)}`),...i?["--full-literal-traversal"]:[],`--topology-characters ${Math.max(s,L)}`];return{maxCharacters:s,estimatedCharacters:C,totalEstimatedCharacters:L,regionIds:[...b],omittedRegionIds:R,relationKeys:v,omittedRelations:N,complete:x,expansionCommand:x?null:`scip-query system-map ${M.join(" ")}`}}function Tr(e){return 120+e.id.length+e.anchorQueries.join(",").length+e.relationKinds.join(",").length+e.notableSymbols.slice(0,2).reduce((t,n)=>t+n.shortName.length+n.file.length,0)}function Fr(e){return 70+e.fromRegionId.length+e.toRegionId.length+e.kinds.join(",").length+e.evidence.join(",").length}function Fl(e,t){let n=o=>o.kinds.includes("runtime-boundary")?0:o.kinds.includes("contract-symbol")?1:2;return n(e)-n(t)||t.relationCount-e.relationCount||jt(e).localeCompare(jt(t))}function jt(e){return`${e.fromRegionId}\0${e.toRegionId}`}function Br(e,t,n){let o=s=>n.has(s.id)?0:1,r=s=>s.sourceFileCount===0?1:0,a=s=>s.symbolCount+s.literalHitCount>0?0:1,i=s=>[...s.incomingRegionIds,...s.outgoingRegionIds].filter(l=>n.has(l)).length;return o(e)-o(t)||a(e)-a(t)||r(e)-r(t)||e.minDepth-t.minDepth||i(t)-i(e)||t.literalHitCount-e.literalHitCount||e.testFileCount-t.testFileCount||e.label.localeCompare(t.label)}function Pl(e){let t=[],n=new Set;for(let r of e.filter(a=>a.expanded)){for(let l of r.symbols)l.origins.includes("symbol-anchor")&&n.add(l.file);let a=ye(r.symbols,l=>l.file),i=ye(r.literalHits,l=>l.file),s=[...r.files].sort((l,d)=>kl(l,d,a,i));for(let l of s){let d=(a.get(l.file)??[]).sort(no)[0];if(d){t.push({kind:"symbol",regionId:r.id,file:d.file,line:d.startLine,endLine:d.endLine,label:d.shortName});continue}let c=(i.get(l.file)??[]).sort(Kr)[0];c&&t.push({kind:"literal",regionId:r.id,file:c.file,line:c.line,endLine:null,label:c.ownerShortName??c.query})}}let o=Al(t,n);return{command:o.length===0?null:`scip-query inspect ${o.map(r=>`--at ${V(`${r.file}:${r.line+1}`)}`).join(" ")} --view behavior`,definitionCommand:null,candidateAnchors:t.length,selectedAnchors:o.length,omittedAnchors:t.length-o.length,anchors:o}}function Al(e,t){let n=[...ye(e,i=>i.regionId).values()],o=[],r=new Set,a=Math.min(Vs,24);for(let i of e)if(!(!t.has(i.file)||r.has(i.file))&&(o.push(i),r.add(i.file),o.length===a))return o;for(let i=0;o.length<a;i+=1){let s=!1;for(let l of n){let d=l[i];if(d&&(s=!0,!r.has(d.file)&&(o.push(d),r.add(d.file),o.length===a)))break}if(!s)break}return o}function kl(e,t,n,o){let r=s=>s.kind==="test"?2:s.kind==="barrel"?1:0,a=s=>(o.get(s.file)??[]).some(l=>l.traversalSeed)?0:1,i=s=>{let l=n.get(s.file)??[];return Math.min(5,...l.map(d=>Ke(d.origins)))};return r(e)-r(t)||a(e)-a(t)||i(e)-i(t)||e.depth-t.depth||e.file.localeCompare(t.file)}function V(e){return`'${e.replaceAll("'","'\\''")}'`}function $l(e,t,n,o){let r=[];for(let a of Bn(e,{includeIgnored:!1})){let i=le(e,a);if(i.length===0)continue;let s=[];for(let c=0;c<i.length;c+=1){let u=i[c]??"";u.includes(n)&&s.push({line:c,sourceLine:u})}if(s.length===0)continue;let l=t.definitionsForFile(a),d=J(e,a)?.callables??[];for(let{line:c,sourceLine:u}of s){let f=Ge(l,c),m=pt(d,c),p=f&&!re(f.symbol)?f:null,g=p?.startLine??m?.startLine??f?.startLine??c,b=p?.endLine??m?.endLine??f?.endLine??c,C=Zt(e,a,c,g,b),S=o.has(`${a}\0${c}`),v=!!(p?.isFunctionLike||m);r.push({relativePath:a,line:c,sourceLine:u,ownerSymbol:p?.symbol??null,ownerShortName:p?ee(p.symbol):m?.name??(f?ee(f.symbol):null),ownerStartLine:C.startLine,ownerEndLine:C.endLine,matchKind:Ol(u,n),seedPriority:S?0:v?1:2})}}return r}function Dl(e,t){let n={"exact-value":0,boundary:1,embedded:2};return e.seedPriority-t.seedPriority||n[e.matchKind]-n[t.matchKind]||e.relativePath.localeCompare(t.relativePath)||e.line-t.line}function Pr(e){return`${e.relativePath}\0${e.line}`}function Ln(e,t,n){let r=pt(J(e,t)?.callables??[],n)??Or(e,t,n);if(!r)return null;let a=Zt(e,t,n,r.startLine,r.endLine);return{file:t,name:r.name,startLine:a.startLine,endLine:a.endLine}}function Or(e,t,n){let o=Y(e,t)?.rootNode;if(!o||o.startPosition.row>n||o.endPosition.row<n)return null;let r=Nn(o,n);for(;r;){if(r.type==="variable_declarator"){let i=r.childForFieldName("name")??r.namedChild(0),s=r.childForFieldName("value")??r.namedChild(1);if(i?.type==="identifier"&&s&&In(s,n))return{name:i.text,startLine:r.startPosition.row,endLine:r.endPosition.row}}if(r.type==="pair"){let i=r.childForFieldName("key")??r.namedChild(0),s=r.childForFieldName("value")??r.namedChild(1),l=i?.text.replace(/^(?:['"])(.*)(?:['"])$/u,"$1");if(l&&s&&/^[A-Za-z_$][\w$]*$/u.test(l)&&In(s,n))return{name:l,startLine:r.startPosition.row,endLine:r.endPosition.row}}r=r.parent}let a=Xt(e,t,n);return a?{name:`source@${n+1}`,startLine:a.startLine,endLine:a.endLine}:null}function In(e,t){return["arrow_function","function_expression","generator_function","generator_function_declaration"].includes(e.type)&&e.startPosition.row<=t&&e.endPosition.row>=t?!0:e.namedChildren.some(n=>n.startPosition.row<=t&&n.endPosition.row>=t&&In(n,t))}function Nn(e,t){let n=e.namedChildren.filter(o=>o.startPosition.row<=t&&o.endPosition.row>=t).sort((o,r)=>o.endIndex-o.startIndex-(r.endIndex-r.startIndex)||o.startPosition.row-r.startPosition.row)[0];return n?Nn(n,t):e}function _l(e,t){let n=t.match(/^(.+):(\d+)(?:-(\d+))?$/u);if(!n)return null;let o=On(e,n[1],{allowMultiple:!1})[0]?.relativePath;if(!o)return null;let r=Math.max(0,Number.parseInt(n[2],10)-1),a=n[3]?Math.max(r,Number.parseInt(n[3],10)-1):r,i=(J(e,o)?.callables??[]).filter(s=>s.startLine<=r&&s.endLine>=a).sort((s,l)=>s.endLine-s.startLine-(l.endLine-l.startLine)||s.startLine-l.startLine)[0];return i?{file:o,name:i.name,startLine:i.startLine,endLine:i.endLine}:null}function Bl(e){return{symbol:`source-construct:${e.file}:${e.startLine}:${e.endLine}:${e.name}`,shortName:e.name,relativePath:e.file,startLine:e.startLine,endLine:e.endLine}}function Ol(e,t){let n=/[\p{L}\p{N}_$]/u,o=e.indexOf(t);for(;o>=0;){let r=e[o-1]??"",a=e[o+t.length]??"";if((r==="'"||r==='"'||r==="`")&&a===r)return"exact-value";if(!n.test(r)&&!n.test(a))return"boundary";o=e.indexOf(t,o+Math.max(1,t.length))}return"embedded"}function wn(e){return mt(e)==="test"?!1:!/(?:^|[/._-])(?:fixtures?|mocks?|previews?|demos?|examples?|stories)(?:[/._-]|$)/iu.test(e)}function Gl(e,t){return e.matchKind!=="embedded"&&t(e.relativePath)&&(Wt(e.relativePath)!=="production"||wn(e.relativePath))}function jl(e,t){let n=[...t].sort(Kl),o=[],r=new Set;for(let a of n)if(!r.has(a.relativePath)&&(o.push(a),r.add(a.relativePath),o.length>=Lr))break;for(let a of n){if(o.length>=Lr)break;o.includes(a)||o.push(a)}return o.map(a=>({query:e,file:a.relativePath,line:a.line,ownerSymbol:a.ownerSymbol,ownerShortName:a.ownerShortName,ownerStartLine:a.ownerStartLine,ownerEndLine:a.ownerEndLine,sourceLine:a.sourceLine.trim(),matchKind:a.matchKind,traversalSeed:!1}))}function Kl(e,t){let n={"exact-value":0,boundary:1,embedded:2};return n[e.matchKind]-n[t.matchKind]||+(t.ownerSymbol!==null)-+(e.ownerSymbol!==null)||+!wn(e.relativePath)-+!wn(t.relativePath)||e.relativePath.localeCompare(t.relativePath)||e.line-t.line}function ql(e,t){let n=new Map;for(let o of t){let r=zl(o.relativePath);n.set(r,(n.get(r)??0)+1)}return[...n].sort(([o,r],[a,i])=>i-r||o.localeCompare(a)).slice(0,Ws).map(([o])=>`scip-query search ${V(e)} --scope ${V(o)}`)}function zl(e){let t=e.split("/").filter(Boolean);if(t.length<=1)return e;let n=t.slice(0,-1),o=n.lastIndexOf("src");return o>=0?n.slice(0,Math.min(n.length,o+3)).join("/"):n.slice(0,Math.min(n.length,3)).join("/")}function Ul(e,t,n){let o=t.callerFileMap([n],{semantic:!1}).get(n.symbolId)??new Set,r=[];for(let a of[...o].sort()){let i=xe(e,a).filter(c=>c.importedName===n.leaf&&c.sourcePath!==null&&Pe(c.sourcePath,n.relativePath)),s=new Set;if(i.length>0)for(let c of i)s.add(c.localName??c.importedName);else n.leaf&&s.add(n.leaf);let l=[...new Set([...s].flatMap(c=>Ee(e,a,c)))].sort((c,u)=>c-u);if(l.length===0){r.push({file:a,line:null,enclosingSymbol:null});continue}let d=t.definitionsForFile(a);for(let c of l)r.push({file:a,line:c,enclosingSymbol:Ge(d,c)?.symbol??null})}return r}function Wl(e,t){let n=e.all(`SELECT DISTINCT gs.symbol, def_d.relative_path AS from_file
7
- FROM mentions m
8
- JOIN chunks c ON m.chunk_id = c.id
9
- JOIN documents imp_d ON c.document_id = imp_d.id
10
- JOIN global_symbols gs ON m.symbol_id = gs.id
11
- LEFT JOIN (
12
- SELECT m2.symbol_id, c2.document_id
13
- FROM mentions m2
14
- JOIN chunks c2 ON m2.chunk_id = c2.id
15
- WHERE m2.role = 1
16
- GROUP BY m2.symbol_id
17
- ) sym_def ON sym_def.symbol_id = gs.id
18
- LEFT JOIN documents def_d ON sym_def.document_id = def_d.id
19
- WHERE imp_d.relative_path = ? AND m.role = 2
20
- ORDER BY def_d.relative_path, gs.symbol`,t);return n.length>0?n.map(o=>({symbol:o.symbol,shortName:ee(o.symbol),importedName:Ar(ee(o.symbol)),localName:Ar(ee(o.symbol)),fromFile:o.from_file,source:"compiler"})):xe(e,t).map(o=>{let r=Hl(o.importedName,o.localName,o.kind),a=o.localName??o.importedName,i=o.importedName==="default"?a:o.importedName;return{symbol:r,shortName:r,importedName:i,localName:a,fromFile:o.sourcePath,source:"parsed-source"}})}function Ar(e){return e.slice(e.lastIndexOf(":")+1).replace(/\(\)$/u,"")||e}function Hl(e,t,n){return n==="namespace"&&e==="*"&&t?`* as ${t}`:n==="default"&&t?`default as ${t}`:n==="side-effect"?"(side effect import)":t&&t!==e?`${e} as ${t}`:e}function Te(e,t,n){let o=Ht(e,n);if(!o.match)return{matches:[],total:0,omitted:0};let r=[o.match,...o.candidates.map(i=>Ht(e,i.symbol).match)].filter(i=>i!==null),a=new Map;for(let i of r){let s=t.definitionsForFile(i.relativePath).find(l=>l.symbol===i.symbol);s&&a.set(s.symbol,s)}return{matches:[...a.values()],total:o.total,omitted:Math.max(0,o.total-a.size)}}function Vl(e){return{symbol:e.symbol,shortName:ee(e.symbol),relativePath:e.relativePath,startLine:e.startLine,endLine:e.endLine}}function pe(e,t){let n=[t.kind,t.fromFile,t.fromSymbol??"",t.toFile,t.toSymbol??"",t.fromBoundaryParticipant?.observationId??"",t.toBoundaryParticipant?.observationId??"",t.fromSourceConstruct?Se(t.fromSourceConstruct):"",t.toSourceConstruct?Se(t.toSourceConstruct):"",t.runtimeBoundaryKey??"",t.line??""].join("\0");e.set(n,t)}function Ve(e){return{observationId:e.id,action:e.action,protocol:e.protocol,role:e.role,address:Gr(e),file:e.source.file,line:e.source.startLine,endLine:e.source.endLine,ownerName:e.owner.name,ownerSymbol:e.owner.symbol}}function Bt(e,t){let n=le(e,t.source.file);return Ye(e,t.source.file,0,Math.max(0,n.length-1),[t.source.startLine])}function kr(e,t){let n=[...e.values()];for(let o of[t.owner,t.source]){let r=n.filter(a=>a.file===o.file&&a.startLine<=o.startLine&&a.endLine>=o.startLine).sort((a,i)=>a.endLine-a.startLine-(i.endLine-i.startLine)||a.startLine-i.startLine)[0];if(r)return r}return null}function $r(e,t,n,o,r){let a=[],i=n.get(e.id);i!==void 0&&i<=t&&a.push(i);for(let s of o.values()){if(s.depth>t)continue;let l=s.definition;Dr(l,e)&&a.push(s.depth)}for(let s of r.values())s.depth>t||Dr(s,e)&&a.push(s.depth);return a.length>0?Math.min(...a):null}function Dr(e,t){let n=e.relativePath??e.file;return[t.owner,t.source].some(o=>n===o.file&&e.startLine<=o.startLine&&e.endLine>=o.startLine)}function Mn(e){return ue("runtime-boundary-participant",e)}function Ql(e,t,n){let o=de(e,n),r=de(t,n);return o.relativeDir!==r.relativeDir?!0:/(?:^|\/)(?:contracts?|schemas?|db\/schema)(?:\/|$)/u.test(t)}function Yl(e,t,n){return lt(e,n).id===lt(t,n).id}function Xl(e,t,n,o){if(e.referenceScope==="all")return!0;let r=lt(t,o).id;return[...n.values()].some(i=>i.promoteBoundaryImports&&lt(i.file,o).id===r)?!0:e.referenceScope!=="cross-workspace-or-forward"?!1:de(t,o).relativeDir!==de(e.definition.relativePath,o).relativeDir}function Zl(e,t){let n={none:0,"forward-regions":1,"cross-workspace-or-forward":2,all:3};return n[e]>=n[t]?e:t}function Jl(e,t){let n=Nr.get(e);if(n)return n;let o=t.fileDependencyGraph(),r={fileGraph:o,reverseFileGraph:ec(o),workspaces:tc(t.sourceFiles()),runtimeBoundaries:Qn(e)};return Nr.set(e,r),r}function ec(e){let t=new Map;for(let[n,o]of e)for(let r of o){let a=t.get(r)??new Set;a.add(n),t.set(r,a)}return t}function de(e,t){return t.find(n=>e===n.relativeDir||e.startsWith(`${n.relativeDir}/`))??{name:"root",relativeDir:""}}function tc(e){let t=new Set(["apps","packages","services","crates","libs","tools"]),n=new Map;for(let o of e){let r=o.split("/").filter(Boolean);if(r.length<3||!t.has(r[0]))continue;let a=`${r[0]}/${r[1]}`;n.set(a,{name:r[1],relativeDir:a})}return[...n.values()].sort((o,r)=>r.relativeDir.length-o.relativeDir.length)}function lt(e,t){let n=de(e,t),r=(n.relativeDir?e.slice(n.relativeDir.length+1):e).split("/").filter(Boolean);r[0]==="src"&&r.shift();let a=nc(r);return{id:`region:${n.relativeDir||"root"}:${a}`,label:`${n.name}:${a}`,workspace:n.name,structuralPath:a}}function nc(e){if(e.length<=1)return"root";let t=e[0],n=e[1];return["components","features","modules"].includes(t)?`${t}/${n}`:t==="db"?`${t}/${n}`:["contracts","routes","services"].includes(t)?t:t==="tests"||t==="__tests__"?"tests":t}function oc(e,t,n,o,r,a,i){let s=ye([...e.values()],m=>a.get(m.file).id),l=ye([...t.values()],m=>a.get(m.definition.relativePath).id),d=ye(n,m=>a.get(m.file).id),c=new Map;for(let m of o)for(let p of new Set([m.fromRegionId,m.toRegionId])){let g=c.get(p)??[];g.push(m),c.set(p,g)}let u=ye(r,m=>m.toRegionId),f=ye(r,m=>m.fromRegionId);return[...s.entries()].map(([m,p])=>{let g=a.get(p[0].file),b=l.get(m)??[],C=d.get(m)??[],S=c.get(m)??[],v=i.has(m),R=b.map(ac).sort(dc).slice(0,Hs),y=p.filter(N=>mt(N.file)==="test").length;return{id:m,label:g.label,workspace:g.workspace,structuralPath:g.structuralPath,minDepth:Math.min(...p.map(N=>N.depth)),fileCount:p.length,sourceFileCount:p.length-y,testFileCount:y,symbolCount:b.length,literalHitCount:C.length,anchorQueries:z([...C.map(N=>N.query),...b.flatMap(N=>[...N.anchorQueries])]),relationKinds:z(S.map(N=>N.kind)),incomingRegionIds:z((u.get(m)??[]).map(N=>N.fromRegionId)),outgoingRegionIds:z((f.get(m)??[]).map(N=>N.toRegionId)),memberCallCandidateRelationCount:S.filter(N=>N.evidence==="ast-member-import-candidate").length,notableSymbols:R,omittedNotableSymbols:Math.max(0,b.length-R.length),expanded:v,files:v?p.map(rc).sort(uc):[],symbols:v?b.map(ic).sort(pc):[],literalHits:v?[...C].sort(Kr):[],relations:v?[...S].sort(jr):[]}}).sort((m,p)=>m.minDepth-p.minDepth||m.label.localeCompare(p.label))}function rc(e){return{file:e.file,kind:mt(e.file),depth:e.depth,origins:z([...e.origins])}}function ic(e){return{symbol:e.definition.symbol,shortName:ee(e.definition.symbol),file:e.definition.relativePath,startLine:e.definition.startLine,endLine:e.definition.endLine,depth:e.depth,origins:z([...e.origins]),anchorQueries:z([...e.anchorQueries]),referenceExpansion:e.referenceScope!=="none",referenceScope:e.referenceScope}}function ac(e){return{shortName:ee(e.definition.symbol),file:e.definition.relativePath,origins:z([...e.origins])}}function sc(e){return[...ye(e.filter(n=>n.fromRegionId!==n.toRegionId),n=>`${n.fromRegionId}\0${n.toRegionId}`).values()].map(n=>({fromRegionId:n[0].fromRegionId,toRegionId:n[0].toRegionId,kinds:z(n.map(o=>o.kind)),relationCount:n.length,fromFiles:z(n.map(o=>o.fromFile)),toFiles:z(n.map(o=>o.toFile)),fromSymbols:z(n.flatMap(o=>o.fromSymbol?[ee(o.fromSymbol)]:[])),toSymbols:z(n.flatMap(o=>o.toSymbol?[ee(o.toSymbol)]:[])),evidence:z(n.map(o=>o.evidence)),strengths:z(n.map(o=>o.strength??"unknown"))})).sort((n,o)=>n.fromRegionId.localeCompare(o.fromRegionId)||n.toRegionId.localeCompare(o.toRegionId))}function lc(e,t){return[...e.values()].map(n=>({kind:"external-import",name:n.name,fromRegionIds:z([...n.fromFiles].flatMap(o=>{let r=t.get(o);return r?[r.id]:[]})),fromFiles:z([...n.fromFiles])})).sort((n,o)=>n.name.localeCompare(o.name))}function cc(e,t,n,o){let r=e.kind==="literal"?t.filter(a=>a.query===e.query).map(a=>a.file):[...n.values()].filter(a=>a.anchorQueries.has(e.query)).map(a=>a.definition.relativePath);return z(r.map(a=>o.get(a)?.id).filter(a=>!!a))}function Gr(e){return e.keyParts.map(t=>`${t.name}=${t.value}`).join(" ")}function z(e){return[...new Set(e)].sort()}function jr(e,t){return e.fromRegionId.localeCompare(t.fromRegionId)||e.toRegionId.localeCompare(t.toRegionId)||e.kind.localeCompare(t.kind)||e.fromFile.localeCompare(t.fromFile)||e.toFile.localeCompare(t.toFile)||(e.line??-1)-(t.line??-1)}function dc(e,t){return Ke(e.origins)-Ke(t.origins)||e.shortName.localeCompare(t.shortName)}function uc(e,t){return e.depth-t.depth||e.file.localeCompare(t.file)}function pc(e,t){return e.depth-t.depth||e.file.localeCompare(t.file)||e.symbol.localeCompare(t.symbol)}function Kr(e,t){return e.file.localeCompare(t.file)||e.line-t.line||e.query.localeCompare(t.query)}var fc={causal:["execution","runtime","dataflow","state","temporal"],structure:["contract","identity","ownership","dependencies"],complete:Ce},gc=2,yc=48,qr=64,hc=5e4;function ju(e,t,n={}){let o=ne([...t.symbols??[],...t.locations??[]]),r=ne(t.searches??[]);if(o.length===0&&r.length===0)throw new Error("evidence requires at least one positional symbol, --symbol, --at, or --search selector.");let a=n.view??"causal",i=bc(n.families,a),s=n.direction??"both",l=ne(n.subtypes??[]),d=n.connecting??!1,c=n.inventoryOnly??!1,u=ne(n.foldIds??[]),f=n.maxDepth??gc,m=n.maxEdges??yc;if(!Number.isSafeInteger(f)||f<0)throw new RangeError(`Evidence depth must be a non-negative safe integer; received ${f}.`);if(!Number.isSafeInteger(m)||m<=0)throw new RangeError(`Evidence max edges must be a positive safe integer; received ${m}.`);if(!["incoming","outgoing","both"].includes(s))throw new Error(`Unsupported graph evidence direction: ${s}.`);if(c&&u.length>0)throw new Error("Evidence fold materialization cannot be combined with --inventory-only.");let p=_r(e,{symbols:o,searches:r,maxDepth:f,maxTopologyCharacters:hc,relations:Sc(i)}),g=new Map(p.nodes.map($=>[$.id,$])),b=p.edges.filter($=>$.disposition==="emitted"||$.disposition==="folded").flatMap($=>vc($,g)),C=b.filter($=>i.includes($.family)).filter($=>l.length===0||l.includes($.subtype)),S=new Set(p.anchors.flatMap($=>$.nodeIds));if(d&&S.size<2)throw new Error("Connecting evidence requires at least two resolved root nodes.");let v=new Set(C.map($=>$.id)),R=Rn(b,S,"incoming").filter($=>v.has($.id)),y=Rn(b,S,"outgoing").filter($=>v.has($.id)),N=Rn(b,S,"both").filter($=>v.has($.id)),L=Ic(i,l,R,y,N),x=s==="incoming"?R:s==="outgoing"?y:N,M=d?Pc(x,[...S],s):x,h=kc(M,S,s),P=[...M].sort(($,B)=>$c($,B,h)),D=wc(P,m),O=Mc(D,u),w=c?[]:u.length>0?P.filter($=>O.has($.id)):P,T=u.length>0?w:w.slice(0,m),I=u.length>0||c?[]:D,_=Math.max(0,w.length-T.length),A=p.frontiers.filter($=>$.disposition==="unsupported").length,j=p.coverage.status==="incomplete"?"incomplete":_>0?"bounded":"accounted";return{kind:"graph",view:n.families&&n.families.length>0?"custom":a,families:i,selection:{direction:s,subtypes:l,connecting:d,inventoryOnly:c,foldIds:u},targets:p.anchors.map($=>({kind:$.kind,query:$.query,status:$.status,nodeIds:[...$.nodeIds],omittedCandidates:$.omittedCandidates})),inventory:L,edges:T,folds:I,coverage:{status:j,topologyStatus:p.coverage.status,scope:p.coverage.scope,maxDepth:f,maxEdges:m,matchedEdges:P.length,eligibleEdges:w.length,returnedEdges:T.length,omittedEdges:_,frontierGroups:p.frontiers.length,unsupportedFrontiers:A,blindSpots:ne([...p.coverage.blindSpots,...eo(i)]),explanation:c?`${P.length} relationship(s) match the explicit projection; only exact inventory counts were requested.`:u.length>0?`Every relationship in ${u.length} explicitly selected recoverable fold(s) was emitted.`:j==="accounted"?"Every selected relationship in the bounded topology was emitted.":j==="bounded"?`${_} selected relationship(s) were withheld by the explicit edge budget.`:p.coverage.explanation}}}function bc(e,t){let n=e&&e.length>0?e:fc[t],o=n.filter(r=>!Ce.includes(r));if(o.length>0)throw new Error(`Unsupported graph evidence family: ${o.join(", ")}.`);return ne(n)}function Sc(e){return["call","contract-symbol","import","reference","runtime-boundary"]}function vc(e,t){let n=t.get(e.fromNodeId),o=t.get(e.toNodeId);return!n||!o?[]:(e.semantics??[]).flatMap((r,a)=>{let i=Ec(r);if(!i)return[];let s=to(i,r.subtype);if(!s)throw new Error(`No graph relation provider contract is registered for ${i}/${r.subtype}.`);let l=Lc(e);return s.relation.evidenceStrengths.includes(l)?[{id:`${e.id}:${a}:${i}`,family:i,semanticFamily:r.family,subtype:r.subtype,from:zr(n),to:zr(o),sourceKind:e.kind,providerId:s.provider.id,supportCeiling:s.relation.supportCeiling,establishes:s.relation.establishes,nonClaims:[...s.relation.nonClaims],recoverWith:[...s.relation.recoverWith],evidenceStrength:l,evidenceMethods:ne(e.evidence.map(d=>d.method)),evidenceConstituents:xc(e.evidence),context:r.context?{...r.context}:null,attributes:r.attributes?{...r.attributes}:null}]:[]})}function xc(e){let t=new Map;for(let n of e)t.set(`${n.method}\0${n.strength}`,n);return[...t.values()].map(({method:n,strength:o})=>({method:n,strength:o}))}function Ec(e){switch(e.family){case"control":return e.context?.crossesRuntimeBoundary===!0||e.subtype==="runtime-handoff"?"runtime":"execution";case"data":return"dataflow";case"state":return"state";case"temporal":return"temporal";case"contract":return"contract";case"identity":return e.subtype.startsWith("contains")||e.subtype.startsWith("owns-")?"ownership":e.subtype.startsWith("import")?"dependencies":"identity"}}function zr(e){let t=Cc(e);return{id:e.id,kind:e.kind,label:t?ee(t):e.label,symbol:t,location:e.location?{...e.location}:null}}function Cc(e){return e.kind!=="symbol"||!e.id.startsWith("symbol:")?null:decodeURIComponent(e.id.slice(7))}function Lc(e){let t=ne(e.evidence.map(n=>n.strength));return t.length===1?t[0]:t.includes("exact")&&t.every(n=>n==="exact"||n==="derived")?"mixed":t.includes("candidate")?"candidate":t.includes("unknown")||t.length===0?"unknown":"mixed"}function Rn(e,t,n){let o=Tn(e,n),r=new Map,a=new Map,i=[...t].sort();for(let s of i)a.set(s,0);for(let s=0;s<i.length;s+=1){let l=i[s],d=a.get(l);for(let c of o.get(l)??[])r.set(c.edge.id,c.edge),!a.has(c.next)&&(a.set(c.next,d+1),i.push(c.next))}return[...r.values()]}function Tn(e,t){let n=new Map,o=(r,a,i)=>{let s=n.get(r)??[];s.push({edge:i,next:a}),n.set(r,s)};for(let r of e)t!=="incoming"&&o(r.from.id,r.to.id,r),t!=="outgoing"&&o(r.to.id,r.from.id,r);for(let r of n.values())r.sort((a,i)=>a.edge.id.localeCompare(i.edge.id)||a.next.localeCompare(i.next));return n}function Ic(e,t,n,o,r){let a=new Set;for(let c of[...n,...o,...r])a.add(`${c.family}\0${c.subtype}`);if(t.length>0)for(let c of e)for(let u of t)a.add(`${c}\0${u}`);let i=c=>{let u=new Map;for(let f of c){let m=`${f.family}\0${f.subtype}`;u.set(m,(u.get(m)??0)+1)}return u},s=i(n),l=i(o),d=i(r);return[...a].map(c=>{let[u,f]=c.split("\0");return{family:u,subtype:f,incoming:s.get(c)??0,outgoing:l.get(c)??0,both:d.get(c)??0}}).sort((c,u)=>Ce.indexOf(c.family)-Ce.indexOf(u.family)||c.subtype.localeCompare(u.subtype))}function wc(e,t){let n=e.slice(t),o=new Map;for(let i of n){let s=Nc(i),l=`${i.family}\0${s}`,d=o.get(l)??[];d.push(i),o.set(l,d)}let r=new Map(e.map((i,s)=>[i.id,s+1])),a=[];for(let[i,s]of[...o].sort(([l],[d])=>l.localeCompare(d))){let[l,d]=i.split("\0"),c=[...s].sort((u,f)=>u.id.localeCompare(f.id));for(let u=0;u<c.length;u+=qr){let f=c.slice(u,u+qr),m=f.map(C=>C.id),p=ne(f.map(C=>C.subtype)).sort(),g=p.length===1?p[0]:"mixed",b=[...new Set(f.flatMap(C=>[C.from.id,C.to.id]))].sort();a.push({id:Fc(l,p.join("\0"),m),mode:Rc(f),family:l,subtype:g,subtypes:p,region:d,edgeCount:m.length,edgeIds:m,nodeIds:b,minimumMaxEdges:Math.max(...m.map(C=>r.get(C)??e.length))})}}return a.sort((i,s)=>Ce.indexOf(i.family)-Ce.indexOf(s.family)||(i.region??"").localeCompare(s.region??"")||i.id.localeCompare(s.id))}function Nc(e){let t=e.from.location?.file??`kind:${e.from.kind}`,n=e.to.location?.file??`kind:${e.to.kind}`;return t===n?t:`${t} -> ${n}`}function Mc(e,t){if(t.length===0)return new Set;let n=new Map(e.map(r=>[r.id,r])),o=t.filter(r=>!n.has(r));if(o.length>0){let r=e.map(a=>a.id).sort();throw new Error(`Unknown evidence fold ${o.join(", ")} for this projection. Available folds: ${r.join(", ")||"(none)"}.`)}return new Set(t.flatMap(r=>n.get(r).edgeIds))}function Rc(e){let t=new Map,n=new Map,o=new Set;for(let a of e){o.add(a.from.id),o.add(a.to.id);let i=t.get(a.from.id)??new Set;i.add(a.to.id),t.set(a.from.id,i);let s=n.get(a.to.id)??new Set;s.add(a.from.id),n.set(a.to.id,s)}return Tc(o,t)?"scc":[...o].every(a=>(n.get(a)?.size??0)<=1&&(t.get(a)?.size??0)<=1)?"linear":"topology"}function Tc(e,t){let n=new Set,o=new Set,r=a=>{if(n.has(a))return!0;if(o.has(a))return!1;n.add(a);for(let i of t.get(a)??[])if(r(i))return!0;return n.delete(a),o.add(a),!1};return[...e].some(r)}function Fc(e,t,n){return`fold:${mc("sha256").update([e,t,...n].join("\0")).digest("hex").slice(0,16)}`}function Pc(e,t,n){let o=new Map,r=[...new Set(t)].sort();for(let a=0;a<r.length;a+=1)for(let i=a+1;i<r.length;i+=1)for(let s of Ac(e,r[a],r[i],n))o.set(s.id,s);return[...o.values()]}function Ac(e,t,n,o){let r=Tn(e,o),a=new Map([[t,0]]),i=new Map,s=[t];for(let d=0;d<s.length;d+=1){let c=s[d],u=a.get(c);if(c!==n)for(let f of r.get(c)??[])a.has(f.next)||(a.set(f.next,u+1),i.set(f.next,{node:c,edge:f.edge}),s.push(f.next))}if(!a.has(n))return[];let l=[];for(let d=n;d!==t;){let c=i.get(d);if(!c)return[];l.push(c.edge),d=c.node}return l.reverse()}function kc(e,t,n){let o=Tn(e,n),r=new Map,a=[...t];for(let i of t)r.set(i,0);for(let i=0;i<a.length;i+=1){let s=a[i],l=r.get(s);for(let{next:d}of o.get(s)??[])r.has(d)||(r.set(d,l+1),a.push(d))}return r}function $c(e,t,n){return Ur(e,n)-Ur(t,n)||Wr(e)-Wr(t)||Hr(e.evidenceStrength)-Hr(t.evidenceStrength)||Ce.indexOf(e.family)-Ce.indexOf(t.family)||e.from.label.localeCompare(t.from.label)||e.to.label.localeCompare(t.to.label)||e.subtype.localeCompare(t.subtype)||e.id.localeCompare(t.id)}function Ur(e,t){return Math.min(t.get(e.from.id)??Number.MAX_SAFE_INTEGER,t.get(e.to.id)??Number.MAX_SAFE_INTEGER)}function Wr(e){let t=[e.from,e.to].filter(n=>n.kind==="structural-region").length;return t===2?2:t}function Hr(e){switch(e){case"exact":return 0;case"mixed":return 1;case"derived":return 2;case"candidate":return 3;case"unknown":return 4}}export{ju as a};
21
- //# sourceMappingURL=chunk-3FHOF22C.js.map
@@ -1,2 +0,0 @@
1
- import{a as b,b as y}from"./chunk-2E7CX53V.js";import{a as R,b as H,c as B,e as h,f as k}from"./chunk-B3X6KU75.js";import{a as p,b as g}from"./chunk-KMVGRIO2.js";import{P as v}from"./chunk-ZOHS7AQV.js";function V(e,s={}){let{minSimilarity:m=.45,minSharedBehaviors:i=6,limit:o=20,scope:c,scanLimit:n,filePattern:d,focusFiles:f}=s,l=v(e).reactProfiles({scope:c,minBehaviorTokens:Math.max(3,i),scanLimit:n}).map(r=>({file:r.file,component:r.name,tokens:r.behaviorTokens,profile:r})),t=b(l,r=>r.tokens);return y({profiles:l,limit:o,filePattern:d,focusFiles:f,candidateIndex:t,profile:{name:"react-hook-candidates"},compare:(r,a)=>C(r,a,m,i),sort:(r,a)=>a.similarity-r.similarity||r.fileA.localeCompare(a.fileA)||r.componentA.localeCompare(a.componentA)||r.fileB.localeCompare(a.fileB)||r.componentB.localeCompare(a.componentB)})}function C(e,s,m,i){let o=p(e.tokens,s.tokens);if(o.size<i||!E(o))return null;let c=H(e.tokens,s.tokens);if(c<m)return null;let n=h(o,"hook:"),d=h(o,"react-hook:"),f=h(o,"effect:"),l=h(o,"state:"),t=h(o,"request:"),r=h(o,"handler:"),a=h(o,"handler-verb:"),u=A({sharedHooks:n,sharedReactHooks:d,sharedEffects:f,sharedState:l,sharedRequests:t,sharedHandlers:r,sharedHandlerVerbs:a});return{fileA:e.file,componentA:e.component,fileB:s.file,componentB:s.component,similarity:c,tokenCountA:e.tokens.size,tokenCountB:s.tokens.size,sharedTokens:k(o),sharedHooks:n,sharedReactHooks:d,sharedEffects:f,sharedState:l,sharedRequests:t,sharedHandlers:r,sharedHandlerVerbs:a,evidenceClass:u.evidenceClass,actionTier:u.actionTier,evidenceClassReasons:u.reasons,recommendation:u.recommendation,uniqueToA:k(g(e.tokens,s.tokens)).slice(0,25),uniqueToB:k(g(s.tokens,e.tokens)).slice(0,25),reason:P({sharedHooks:n,sharedReactHooks:d,sharedEffects:f,sharedState:l,sharedRequests:t,sharedHandlers:r,sharedHandlerVerbs:a}),locA:e.profile.loc,locB:s.profile.loc}}function A(e){return R({genericWords:q,stripPrefixes:w,primitiveGroups:[{values:e.sharedReactHooks,reasonPrefix:"shared React primitives",bucket:"generic"},{values:e.sharedEffects,reasonPrefix:"shared lifecycle primitive",bucket:"generic"}],nameGroups:[{names:e.sharedHooks,label:"shared hook",fallbackBucket:"shared-abstraction"},{names:e.sharedRequests,label:"shared request",fallbackBucket:"generic"},{names:e.sharedState,label:"shared state",fallbackBucket:"generic"},{names:e.sharedHandlers,label:"shared handler",fallbackBucket:"generic"},{names:e.sharedHandlerVerbs,label:"shared action verb",fallbackBucket:"generic"}],recommendation:S})}function S(e){switch(e){case"domain-behavior":return"Review for a shared hook, controller, or feature module around the named domain behavior.";case"mixed":return"Separate generic React mechanics from domain-specific behavior before extracting a shared hook.";case"shared-abstraction":return"Review the existing shared hook usage first; extract only if duplicated behavior remains outside it.";case"generic-workflow-scaffolding":return"Treat as support evidence for a repeated workflow shape, not direct hook-extraction evidence."}}function E(e){let s=0,m=0,i=0,o=0,c=0,n=0,d=0;for(let t of e)t.startsWith("hook:")?s+=1:t.startsWith("react-hook:")?m+=1:t.startsWith("effect:")?i+=1:t.startsWith("request:")?o+=1:t.startsWith("handler:")||t.startsWith("handler-verb:")?c+=1:t.startsWith("state:")?n+=1:t.startsWith("state-hook:")&&(d+=1);let f=n+d,l=s+m+i+o+c+f;return B([{name:"requests",count:o},{name:"customHooks",count:s},{name:"namedStates",count:n},{name:"handlers",count:c},{name:"effects",count:i},{name:"reactHooks",count:m},{name:"namedBehavior",count:l}],[{min:{requests:1,namedBehavior:4},reason:"shared request workflow"},{min:{customHooks:1,requests:1,namedBehavior:5},reason:"shared custom hook and request workflow"},{min:{customHooks:1,namedStates:1,namedBehavior:5},reason:"shared custom hook and state"},{min:{customHooks:1,handlers:2,namedBehavior:5},reason:"shared custom hook and handlers"},{min:{namedStates:1,handlers:2,effects:1,namedBehavior:5},reason:"shared stateful effects"},{min:{namedStates:1,handlers:2,reactHooks:2,namedBehavior:5},reason:"shared stateful React primitives"}]).pass}function P(e){let s=[];return e.sharedHooks.length&&s.push(`shared hooks: ${e.sharedHooks.join(", ")}`),e.sharedReactHooks.length&&s.push(`shared React hooks: ${e.sharedReactHooks.join(", ")}`),e.sharedEffects.length&&s.push(`shared effects: ${e.sharedEffects.join(", ")}`),e.sharedState.length&&s.push(`shared state: ${e.sharedState.join(", ")}`),e.sharedRequests.length&&s.push(`shared requests: ${e.sharedRequests.join(", ")}`),e.sharedHandlers.length&&s.push(`shared handlers: ${e.sharedHandlers.slice(0,6).join(", ")}`),e.sharedHandlerVerbs.length&&s.push(`shared action verbs: ${e.sharedHandlerVerbs.slice(0,6).join(", ")}`),s.join("; ")||"shared React behavior profile"}var q=new Set(["add","apply","async","callback","cancel","change","clear","close","create","data","delete","draft","edit","effect","error","fetch","filter","form","handle","has","is","item","items","load","loader","loading","memo","name","open","reducer","refresh","ref","remove","request","reset","resource","row","rows","save","saving","search","select","selected","state","store","submit","toggle","update","use","value"]),w=[/^use(?=[A-Z])/,/^handle(?=[A-Z])/,/^is(?=[A-Z])/,/^has(?=[A-Z])/];export{V as a};
2
- //# sourceMappingURL=chunk-3JKSW6LJ.js.map