@oscharko-dev/keiko 1.1.12 → 1.2.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 (1142) hide show
  1. package/README.md +21 -5
  2. package/dist/ui/csp-hashes.json +7 -7
  3. package/dist/ui/static/404.html +1 -1
  4. package/dist/ui/static/__next.__PAGE__.txt +12 -12
  5. package/dist/ui/static/__next._full.txt +23 -22
  6. package/dist/ui/static/__next._tree.txt +3 -3
  7. package/dist/ui/static/_next/static/chunks/0--s8pmsbkf62.js +1 -0
  8. package/dist/ui/static/_next/static/chunks/00_o0v2hokzqm.js +1 -0
  9. package/dist/ui/static/_next/static/chunks/0339vdalk0q6h.js +3 -0
  10. package/dist/ui/static/_next/static/chunks/{13fx5sqcncq4_.js → 05k2u3763ih_i.js} +1 -1
  11. package/dist/ui/static/_next/static/chunks/07f-n_9zq-s8q.js +1 -0
  12. package/dist/ui/static/_next/static/chunks/07l0sfn1-mid2.js +1 -0
  13. package/dist/ui/static/_next/static/chunks/07skh7tlpfo1v.js +1 -0
  14. package/dist/ui/static/_next/static/chunks/{2cn33khz2ae-h.js → 08v-jyhi2uk8t.js} +1 -1
  15. package/dist/ui/static/_next/static/chunks/09i_8713x46yr.js +1 -0
  16. package/dist/ui/static/_next/static/chunks/09zc5hgtb7s-z.js +1 -0
  17. package/dist/ui/static/_next/static/chunks/0_p-xs8nu7pby.js +1 -0
  18. package/dist/ui/static/_next/static/chunks/0_yx8_bs1t-27.js +1 -0
  19. package/dist/ui/static/_next/static/chunks/0a6ri2ug5xf10.js +1 -0
  20. package/dist/ui/static/_next/static/chunks/0bbrrvuzilpy5.js +1 -0
  21. package/dist/ui/static/_next/static/chunks/0bg7uh6tq8-dx.js +1 -0
  22. package/dist/ui/static/_next/static/chunks/0bpexy600ffpg.js +1 -0
  23. package/dist/ui/static/_next/static/chunks/0bz731buimrpv.js +1 -0
  24. package/dist/ui/static/_next/static/chunks/0cwy6mtvshbuo.js +1 -0
  25. package/dist/ui/static/_next/static/chunks/0fpbvpzg-omn0.js +1 -0
  26. package/dist/ui/static/_next/static/chunks/0fz9qig_5p73f.js +1 -0
  27. package/dist/ui/static/_next/static/chunks/0gf88p0jy1g5w.js +1 -0
  28. package/dist/ui/static/_next/static/chunks/0hvxxuef1gw9p.js +1 -0
  29. package/dist/ui/static/_next/static/chunks/0iu3dyqe7m7_7.js +1 -0
  30. package/dist/ui/static/_next/static/chunks/0ktvc8fs3spkb.js +1 -0
  31. package/dist/ui/static/_next/static/chunks/0kvy_ru-kodgv.js +1 -0
  32. package/dist/ui/static/_next/static/chunks/{0xhrzm-zp_lsx.js → 0l72usw6suk0h.js} +1 -1
  33. package/dist/ui/static/_next/static/chunks/0mcg_spbohpl3.css +1 -0
  34. package/dist/ui/static/_next/static/chunks/{3jb5u4g15g__m.css → 0mjsj7bp-ukgh.css} +17 -18
  35. package/dist/ui/static/_next/static/chunks/0parm4c86umwk.js +1 -0
  36. package/dist/ui/static/_next/static/chunks/0q_08tk2d3m2n.js +1 -0
  37. package/dist/ui/static/_next/static/chunks/0r2lwkgws6jm8.js +1 -0
  38. package/dist/ui/static/_next/static/chunks/0t73kckx3olud.js +1 -0
  39. package/dist/ui/static/_next/static/chunks/0w2fp3hjrfx32.js +1 -0
  40. package/dist/ui/static/_next/static/chunks/0wdn9qetndtsj.js +1 -0
  41. package/dist/ui/static/_next/static/chunks/0weojtwxo6qw7.js +1 -0
  42. package/dist/ui/static/_next/static/chunks/0x-r45yl06rdn.js +1 -0
  43. package/dist/ui/static/_next/static/chunks/0x42c1na2ia6m.js +1 -0
  44. package/dist/ui/static/_next/static/chunks/0xu2rnpdr4kzd.js +1 -0
  45. package/dist/ui/static/_next/static/chunks/{0o_lmzxpjfeky.js → 0yzmg9aoglud6.js} +1 -1
  46. package/dist/ui/static/_next/static/chunks/0zuaq_9l5pma_.js +1 -0
  47. package/dist/ui/static/_next/static/chunks/10kb8j7vggfwk.js +1 -0
  48. package/dist/ui/static/_next/static/chunks/14qdwomthzucj.js +1 -0
  49. package/dist/ui/static/_next/static/chunks/196257vfyrtgu.js +1 -0
  50. package/dist/ui/static/_next/static/chunks/{3kmozkq6tgqnz.js → 196x_tfexoucg.js} +1 -1
  51. package/dist/ui/static/_next/static/chunks/{17jlhx5dll_r6.js → 1_bezidc0febq.js} +1 -1
  52. package/dist/ui/static/_next/static/chunks/1a6ri-sriyu-m.js +1 -0
  53. package/dist/ui/static/_next/static/chunks/1a7ko-_7t4wjo.js +1 -0
  54. package/dist/ui/static/_next/static/chunks/1aivbuztyv67o.js +10 -0
  55. package/dist/ui/static/_next/static/chunks/1c0u0qq0vwkc4.js +1 -0
  56. package/dist/ui/static/_next/static/chunks/1czgn62g6km38.js +3 -0
  57. package/dist/ui/static/_next/static/chunks/1f05h21irrvbs.js +1 -0
  58. package/dist/ui/static/_next/static/chunks/1juiifi_xnx68.js +1 -0
  59. package/dist/ui/static/_next/static/chunks/1m-9yzfpcm7wc.js +1 -0
  60. package/dist/ui/static/_next/static/chunks/{36-tv3y56oau8.js → 1qh0x9_258ol2.js} +1 -1
  61. package/dist/ui/static/_next/static/chunks/{2kh0qihno0n1w.js → 1rp_smu1jjw45.js} +1 -1
  62. package/dist/ui/static/_next/static/chunks/1wg1s3jm779ro.js +3 -0
  63. package/dist/ui/static/_next/static/chunks/{0l7cc8q83migz.css → 1wj7exxi550gi.css} +1 -1
  64. package/dist/ui/static/_next/static/chunks/1zczte6xkwvcl.js +1 -0
  65. package/dist/ui/static/_next/static/chunks/1zudszthinjcb.js +1 -0
  66. package/dist/ui/static/_next/static/chunks/{1kacubgk0y2ki.js → 21-6b7rkmtvg8.js} +1 -1
  67. package/dist/ui/static/_next/static/chunks/224bbe_3ksnlw.js +1 -0
  68. package/dist/ui/static/_next/static/chunks/{3chx0gpjqrhod.js → 24u-5fslcj3n9.js} +3 -3
  69. package/dist/ui/static/_next/static/chunks/25x9hf4wdlde7.js +1 -0
  70. package/dist/ui/static/_next/static/chunks/263_uck8el32f.js +1 -0
  71. package/dist/ui/static/_next/static/chunks/26gmn1z4oegqh.js +1 -0
  72. package/dist/ui/static/_next/static/chunks/28ylcw-leje_k.js +1 -0
  73. package/dist/ui/static/_next/static/chunks/2937s9os9u2tn.js +1 -0
  74. package/dist/ui/static/_next/static/chunks/29rlw6dih8owf.js +1 -0
  75. package/dist/ui/static/_next/static/chunks/2b_t95bbpmtej.js +1 -0
  76. package/dist/ui/static/_next/static/chunks/2hq0zlnvfqol9.js +1 -0
  77. package/dist/ui/static/_next/static/chunks/{25j7z89g58y1-.css → 2hu5w89yy7_s-.css} +2 -2
  78. package/dist/ui/static/_next/static/chunks/2kylv1kq1_4p1.js +1 -0
  79. package/dist/ui/static/_next/static/chunks/{0m1163red7mw7.js → 2nlmtsm3kjmbh.js} +1 -1
  80. package/dist/ui/static/_next/static/chunks/2o584howfzzak.js +3 -0
  81. package/dist/ui/static/_next/static/chunks/{1c1gbfapof8m0.js → 2oq1uk07ft9l0.js} +1 -1
  82. package/dist/ui/static/_next/static/chunks/2ov72plu69iiv.js +1 -0
  83. package/dist/ui/static/_next/static/chunks/2p66e_a0j23r8.js +1 -0
  84. package/dist/ui/static/_next/static/chunks/2r4vn_6anv2cw.js +5 -0
  85. package/dist/ui/static/_next/static/chunks/2ribv7pn1hr-l.js +1 -0
  86. package/dist/ui/static/_next/static/chunks/2ta3xj9td_qot.js +1 -0
  87. package/dist/ui/static/_next/static/chunks/2tb2nt2wvu643.js +1 -0
  88. package/dist/ui/static/_next/static/chunks/2wuj7qxm6mleh.js +1 -0
  89. package/dist/ui/static/_next/static/chunks/2xynqzhclj1u-.js +27 -0
  90. package/dist/ui/static/_next/static/chunks/2y98z-sun8_ew.js +1 -0
  91. package/dist/ui/static/_next/static/chunks/2yot6vshhc19p.css +1 -0
  92. package/dist/ui/static/_next/static/chunks/2z5c2glupanq_.js +1 -0
  93. package/dist/ui/static/_next/static/chunks/3-7tka4cib69h.js +1 -0
  94. package/dist/ui/static/_next/static/chunks/3-dorttkhs3i2.js +1 -0
  95. package/dist/ui/static/_next/static/chunks/30j8jo5v60ga1.js +2 -0
  96. package/dist/ui/static/_next/static/chunks/30q9b_aw8driv.js +1 -0
  97. package/dist/ui/static/_next/static/chunks/{18qu5m_in_h3x.js → 3603jy78awb1p.js} +1 -1
  98. package/dist/ui/static/_next/static/chunks/36c8jty3kllje.js +1 -0
  99. package/dist/ui/static/_next/static/chunks/387k5c-bf1b2e.js +1 -0
  100. package/dist/ui/static/_next/static/chunks/388eokaf_2t9k.js +1 -0
  101. package/dist/ui/static/_next/static/chunks/389bs_l5-yv4y.css +1 -0
  102. package/dist/ui/static/_next/static/chunks/3946_dfcd9xr-.js +1 -0
  103. package/dist/ui/static/_next/static/chunks/39nyg25pqs1kv.js +1 -0
  104. package/dist/ui/static/_next/static/chunks/3_alxp77ewgk_.js +1 -0
  105. package/dist/ui/static/_next/static/chunks/3_ycy0h8pq58a.js +1 -0
  106. package/dist/ui/static/_next/static/chunks/3eduf6vevclfm.js +1 -0
  107. package/dist/ui/static/_next/static/chunks/3eg8pcox5copv.js +1 -0
  108. package/dist/ui/static/_next/static/chunks/3gyetohi_flhb.js +1 -0
  109. package/dist/ui/static/_next/static/chunks/{39w0xj7fyy7sp.js → 3h-rh_lx0l8_3.js} +1 -1
  110. package/dist/ui/static/_next/static/chunks/{1o2cihsnxhmh6.js → 3hclt6m3ok4n9.js} +1 -1
  111. package/dist/ui/static/_next/static/chunks/3ho1f5n8lir4r.js +1 -0
  112. package/dist/ui/static/_next/static/chunks/3kgc_j74tblcn.js +1 -0
  113. package/dist/ui/static/_next/static/chunks/3ksbq-nwkgwob.js +1 -0
  114. package/dist/ui/static/_next/static/chunks/3mxpjroefk8ou.js +1 -0
  115. package/dist/ui/static/_next/static/chunks/3or_0c84ozskx.js +1 -0
  116. package/dist/ui/static/_next/static/chunks/3q5jidle0lb3-.js +1 -0
  117. package/dist/ui/static/_next/static/chunks/3qjkuhjy_-_br.js +1 -0
  118. package/dist/ui/static/_next/static/chunks/3sgbsntbbci5y.js +1 -0
  119. package/dist/ui/static/_next/static/chunks/3tcw3qy3rrkyf.js +1 -0
  120. package/dist/ui/static/_next/static/chunks/3tqd6avtamgd5.js +1 -0
  121. package/dist/ui/static/_next/static/chunks/3ua7si017r4dg.js +1 -0
  122. package/dist/ui/static/_next/static/chunks/3v2iluxqnsug9.css +15 -0
  123. package/dist/ui/static/_next/static/chunks/{1ydfda18zlx4w.js → 3vjm30f1if00s.js} +1 -1
  124. package/dist/ui/static/_next/static/chunks/3z5edm1fpkcuq.js +1 -0
  125. package/dist/ui/static/_next/static/chunks/3z5f2s7yd35cu.js +1 -0
  126. package/dist/ui/static/_next/static/chunks/40co1uetczqcs.js +1 -0
  127. package/dist/ui/static/_next/static/chunks/43kutp14mqi-j.js +1 -0
  128. package/dist/ui/static/_next/static/chunks/43y3xn64quyo2.js +1 -0
  129. package/dist/ui/static/_next/static/chunks/{turbopack-2fb3mn6go2p-t.js → turbopack-2rwr7ign9ynaa.js} +1 -1
  130. package/dist/ui/static/_not-found/__next._full.txt +13 -13
  131. package/dist/ui/static/_not-found/__next._not-found.__PAGE__.txt +9 -9
  132. package/dist/ui/static/_not-found/__next._tree.txt +2 -2
  133. package/dist/ui/static/_not-found.html +1 -1
  134. package/dist/ui/static/_not-found.txt +13 -13
  135. package/dist/ui/static/atlassian-connectors/__next._full.txt +15 -15
  136. package/dist/ui/static/atlassian-connectors/__next._tree.txt +2 -2
  137. package/dist/ui/static/atlassian-connectors/__next.atlassian-connectors.__PAGE__.txt +11 -11
  138. package/dist/ui/static/atlassian-connectors.html +1 -1
  139. package/dist/ui/static/atlassian-connectors.txt +15 -15
  140. package/dist/ui/static/index.html +1 -1
  141. package/dist/ui/static/index.txt +23 -22
  142. package/dist/ui/static/launch/__next._full.txt +16 -16
  143. package/dist/ui/static/launch/__next._tree.txt +3 -3
  144. package/dist/ui/static/launch/__next.launch.__PAGE__.txt +12 -12
  145. package/dist/ui/static/launch.html +1 -1
  146. package/dist/ui/static/launch.txt +16 -16
  147. package/dist/ui/static/local-knowledge/__next._full.txt +16 -16
  148. package/dist/ui/static/local-knowledge/__next._tree.txt +3 -3
  149. package/dist/ui/static/local-knowledge/__next.local-knowledge.__PAGE__.txt +12 -12
  150. package/dist/ui/static/local-knowledge/capsule/__next._full.txt +25 -24
  151. package/dist/ui/static/local-knowledge/capsule/__next._tree.txt +2 -2
  152. package/dist/ui/static/local-knowledge/capsule/__next.local-knowledge.capsule.__PAGE__.txt +11 -11
  153. package/dist/ui/static/local-knowledge/capsule.html +1 -1
  154. package/dist/ui/static/local-knowledge/capsule.txt +25 -24
  155. package/dist/ui/static/local-knowledge.html +1 -1
  156. package/dist/ui/static/local-knowledge.txt +16 -16
  157. package/node_modules/@oscharko-dev/keiko-activity-log/dist/activity-log-store.d.ts +6 -2
  158. package/node_modules/@oscharko-dev/keiko-activity-log/dist/activity-log-store.d.ts.map +1 -1
  159. package/node_modules/@oscharko-dev/keiko-activity-log/dist/activity-log-store.js +54 -8
  160. package/node_modules/@oscharko-dev/keiko-activity-log/dist/defect-fingerprint.d.ts +35 -0
  161. package/node_modules/@oscharko-dev/keiko-activity-log/dist/defect-fingerprint.d.ts.map +1 -0
  162. package/node_modules/@oscharko-dev/keiko-activity-log/dist/defect-fingerprint.js +66 -0
  163. package/node_modules/@oscharko-dev/keiko-activity-log/dist/index.d.ts +2 -1
  164. package/node_modules/@oscharko-dev/keiko-activity-log/dist/index.d.ts.map +1 -1
  165. package/node_modules/@oscharko-dev/keiko-activity-log/dist/index.js +2 -1
  166. package/node_modules/@oscharko-dev/keiko-activity-log/dist/log-redaction.d.ts +13 -2
  167. package/node_modules/@oscharko-dev/keiko-activity-log/dist/log-redaction.d.ts.map +1 -1
  168. package/node_modules/@oscharko-dev/keiko-activity-log/dist/log-redaction.js +67 -126
  169. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/index.d.ts +4 -1
  170. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/index.d.ts.map +1 -1
  171. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/index.js +4 -1
  172. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-analyze-sufficiency.d.ts +10 -2
  173. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-analyze-sufficiency.d.ts.map +1 -1
  174. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-analyze-sufficiency.js +59 -46
  175. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-analyze.d.ts +13 -2
  176. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-analyze.d.ts.map +1 -1
  177. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-analyze.js +150 -52
  178. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-code-inventory.generated.d.ts +30 -0
  179. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-code-inventory.generated.d.ts.map +1 -0
  180. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-code-inventory.generated.js +3539 -0
  181. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-desktop-report-attribution.d.ts +5 -0
  182. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-desktop-report-attribution.d.ts.map +1 -0
  183. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-desktop-report-attribution.js +74 -0
  184. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-desktop-report.d.ts +25 -0
  185. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-desktop-report.d.ts.map +1 -0
  186. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-desktop-report.js +184 -0
  187. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-incident-resolution.d.ts +33 -0
  188. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-incident-resolution.d.ts.map +1 -0
  189. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-incident-resolution.js +195 -0
  190. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-lifetime.d.ts +7 -0
  191. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-lifetime.d.ts.map +1 -0
  192. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-lifetime.js +19 -0
  193. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-local-query.d.ts +11 -0
  194. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-local-query.d.ts.map +1 -0
  195. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-local-query.js +20 -0
  196. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-query.d.ts +6 -2
  197. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-query.d.ts.map +1 -1
  198. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-query.js +442 -60
  199. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-registry-history.generated.d.ts +38 -0
  200. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-registry-history.generated.d.ts.map +1 -0
  201. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-registry-history.generated.js +45 -0
  202. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-registry.d.ts +27 -0
  203. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-registry.d.ts.map +1 -0
  204. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-registry.js +46 -0
  205. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-report-json.d.ts +3 -0
  206. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-report-json.d.ts.map +1 -0
  207. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-report-json.js +5 -0
  208. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-report-privacy.d.ts +12 -0
  209. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-report-privacy.d.ts.map +1 -0
  210. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-report-privacy.js +226 -0
  211. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-report.d.ts +41 -0
  212. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-report.d.ts.map +1 -0
  213. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-report.js +672 -0
  214. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-segment-manifest.d.ts +4 -1
  215. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-segment-manifest.d.ts.map +1 -1
  216. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-segment-manifest.js +17 -5
  217. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-segment-scan.d.ts.map +1 -1
  218. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-segment-scan.js +16 -9
  219. package/node_modules/@oscharko-dev/keiko-activity-log/dist/server-log.d.ts +1 -1
  220. package/node_modules/@oscharko-dev/keiko-activity-log/dist/server-log.d.ts.map +1 -1
  221. package/node_modules/@oscharko-dev/keiko-activity-log/dist/server-log.js +20 -11
  222. package/node_modules/@oscharko-dev/keiko-activity-log/dist/support-incident-retention.d.ts +10 -0
  223. package/node_modules/@oscharko-dev/keiko-activity-log/dist/support-incident-retention.d.ts.map +1 -0
  224. package/node_modules/@oscharko-dev/keiko-activity-log/dist/support-incident-retention.js +21 -0
  225. package/node_modules/@oscharko-dev/keiko-activity-log/dist/support-incident-store.d.ts +11 -3
  226. package/node_modules/@oscharko-dev/keiko-activity-log/dist/support-incident-store.d.ts.map +1 -1
  227. package/node_modules/@oscharko-dev/keiko-activity-log/dist/support-incident-store.js +142 -23
  228. package/node_modules/@oscharko-dev/keiko-activity-log/dist/support-incident.d.ts +25 -22
  229. package/node_modules/@oscharko-dev/keiko-activity-log/dist/support-incident.d.ts.map +1 -1
  230. package/node_modules/@oscharko-dev/keiko-activity-log/dist/support-incident.js +694 -198
  231. package/node_modules/@oscharko-dev/keiko-activity-log/package.json +3 -3
  232. package/node_modules/@oscharko-dev/keiko-cli/dist/cli-control-state.d.ts +8 -0
  233. package/node_modules/@oscharko-dev/keiko-cli/dist/cli-control-state.d.ts.map +1 -1
  234. package/node_modules/@oscharko-dev/keiko-cli/dist/cli-control-state.js +25 -1
  235. package/node_modules/@oscharko-dev/keiko-cli/dist/investigate.js +1 -1
  236. package/node_modules/@oscharko-dev/keiko-cli/dist/process-activity-log.d.ts.map +1 -1
  237. package/node_modules/@oscharko-dev/keiko-cli/dist/process-activity-log.js +3 -1
  238. package/node_modules/@oscharko-dev/keiko-cli/dist/repair.d.ts.map +1 -1
  239. package/node_modules/@oscharko-dev/keiko-cli/dist/repair.js +1 -0
  240. package/node_modules/@oscharko-dev/keiko-cli/dist/runner.js +1 -1
  241. package/node_modules/@oscharko-dev/keiko-cli/dist/state-paths.d.ts +1 -1
  242. package/node_modules/@oscharko-dev/keiko-cli/dist/state-paths.d.ts.map +1 -1
  243. package/node_modules/@oscharko-dev/keiko-cli/dist/state-paths.js +19 -8
  244. package/node_modules/@oscharko-dev/keiko-cli/dist/support-export.d.ts +16 -113
  245. package/node_modules/@oscharko-dev/keiko-cli/dist/support-export.d.ts.map +1 -1
  246. package/node_modules/@oscharko-dev/keiko-cli/dist/support-export.js +71 -358
  247. package/node_modules/@oscharko-dev/keiko-cli/dist/support-incident.d.ts +1 -21
  248. package/node_modules/@oscharko-dev/keiko-cli/dist/support-incident.d.ts.map +1 -1
  249. package/node_modules/@oscharko-dev/keiko-cli/dist/support-incident.js +14 -112
  250. package/node_modules/@oscharko-dev/keiko-cli/dist/support-query-cli.d.ts +1 -1
  251. package/node_modules/@oscharko-dev/keiko-cli/dist/support-query-cli.d.ts.map +1 -1
  252. package/node_modules/@oscharko-dev/keiko-cli/dist/support-query-cli.js +6 -18
  253. package/node_modules/@oscharko-dev/keiko-cli/dist/support-query-evidence.d.ts +10 -0
  254. package/node_modules/@oscharko-dev/keiko-cli/dist/support-query-evidence.d.ts.map +1 -1
  255. package/node_modules/@oscharko-dev/keiko-cli/dist/support-query-evidence.js +2 -0
  256. package/node_modules/@oscharko-dev/keiko-cli/dist/support-report-cli.d.ts +23 -0
  257. package/node_modules/@oscharko-dev/keiko-cli/dist/support-report-cli.d.ts.map +1 -0
  258. package/node_modules/@oscharko-dev/keiko-cli/dist/support-report-cli.js +521 -0
  259. package/node_modules/@oscharko-dev/keiko-cli/dist/support-report-evidence.d.ts +647 -0
  260. package/node_modules/@oscharko-dev/keiko-cli/dist/support-report-evidence.d.ts.map +1 -0
  261. package/node_modules/@oscharko-dev/keiko-cli/dist/support-report-evidence.js +338 -0
  262. package/node_modules/@oscharko-dev/keiko-cli/dist/support-selective-export.d.ts +3 -5
  263. package/node_modules/@oscharko-dev/keiko-cli/dist/support-selective-export.d.ts.map +1 -1
  264. package/node_modules/@oscharko-dev/keiko-cli/dist/support-selective-export.js +6 -42
  265. package/node_modules/@oscharko-dev/keiko-cli/dist/support.d.ts +0 -18
  266. package/node_modules/@oscharko-dev/keiko-cli/dist/support.d.ts.map +1 -1
  267. package/node_modules/@oscharko-dev/keiko-cli/dist/support.js +118 -1276
  268. package/node_modules/@oscharko-dev/keiko-cli/package.json +15 -15
  269. package/node_modules/@oscharko-dev/keiko-connectors/dist/version.d.ts +1 -1
  270. package/node_modules/@oscharko-dev/keiko-connectors/dist/version.d.ts.map +1 -1
  271. package/node_modules/@oscharko-dev/keiko-connectors/dist/version.js +1 -1
  272. package/node_modules/@oscharko-dev/keiko-connectors/package.json +3 -3
  273. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-failure-class-contracts.d.ts +326 -106
  274. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-failure-class-contracts.d.ts.map +1 -1
  275. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-failure-class-contracts.js +534 -97
  276. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-label-policy.d.ts +4 -0
  277. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-label-policy.d.ts.map +1 -0
  278. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-label-policy.js +123 -0
  279. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-operations.generated.d.ts +29497 -0
  280. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-operations.generated.d.ts.map +1 -0
  281. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-operations.generated.js +32895 -0
  282. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-registry.generated.d.ts +8749 -31976
  283. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-registry.generated.d.ts.map +1 -1
  284. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-registry.generated.js +3997 -29458
  285. package/node_modules/@oscharko-dev/keiko-contracts/dist/bff-wire.d.ts +155 -0
  286. package/node_modules/@oscharko-dev/keiko-contracts/dist/bff-wire.d.ts.map +1 -1
  287. package/node_modules/@oscharko-dev/keiko-contracts/dist/bff-wire.js +40 -15
  288. package/node_modules/@oscharko-dev/keiko-contracts/dist/citation-markers.d.ts +49 -0
  289. package/node_modules/@oscharko-dev/keiko-contracts/dist/citation-markers.d.ts.map +1 -0
  290. package/node_modules/@oscharko-dev/keiko-contracts/dist/citation-markers.js +380 -0
  291. package/node_modules/@oscharko-dev/keiko-contracts/dist/client-defect-signature.d.ts +12 -0
  292. package/node_modules/@oscharko-dev/keiko-contracts/dist/client-defect-signature.d.ts.map +1 -0
  293. package/node_modules/@oscharko-dev/keiko-contracts/dist/client-defect-signature.js +63 -0
  294. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-repository-search.d.ts +24 -5
  295. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-repository-search.d.ts.map +1 -1
  296. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-repository-search.js +16 -5
  297. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench.d.ts +2 -0
  298. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench.d.ts.map +1 -1
  299. package/node_modules/@oscharko-dev/keiko-contracts/dist/connected-context.d.ts +12 -6
  300. package/node_modules/@oscharko-dev/keiko-contracts/dist/connected-context.d.ts.map +1 -1
  301. package/node_modules/@oscharko-dev/keiko-contracts/dist/connected-context.js +171 -100
  302. package/node_modules/@oscharko-dev/keiko-contracts/dist/connected-search-abstention.d.ts +7 -0
  303. package/node_modules/@oscharko-dev/keiko-contracts/dist/connected-search-abstention.d.ts.map +1 -0
  304. package/node_modules/@oscharko-dev/keiko-contracts/dist/connected-search-abstention.js +14 -0
  305. package/node_modules/@oscharko-dev/keiko-contracts/dist/context-engineering-compaction-validation.d.ts.map +1 -1
  306. package/node_modules/@oscharko-dev/keiko-contracts/dist/context-engineering-compaction-validation.js +34 -0
  307. package/node_modules/@oscharko-dev/keiko-contracts/dist/context-engineering-validation.d.ts.map +1 -1
  308. package/node_modules/@oscharko-dev/keiko-contracts/dist/context-engineering-validation.js +8 -1
  309. package/node_modules/@oscharko-dev/keiko-contracts/dist/context-engineering.d.ts +24 -1
  310. package/node_modules/@oscharko-dev/keiko-contracts/dist/context-engineering.d.ts.map +1 -1
  311. package/node_modules/@oscharko-dev/keiko-contracts/dist/context-engineering.js +20 -6
  312. package/node_modules/@oscharko-dev/keiko-contracts/dist/diagnostics.d.ts +131 -4
  313. package/node_modules/@oscharko-dev/keiko-contracts/dist/diagnostics.d.ts.map +1 -1
  314. package/node_modules/@oscharko-dev/keiko-contracts/dist/diagnostics.js +573 -11
  315. package/node_modules/@oscharko-dev/keiko-contracts/dist/editor-agent.d.ts +17 -12
  316. package/node_modules/@oscharko-dev/keiko-contracts/dist/editor-agent.d.ts.map +1 -1
  317. package/node_modules/@oscharko-dev/keiko-contracts/dist/editor-agent.js +76 -36
  318. package/node_modules/@oscharko-dev/keiko-contracts/dist/editor-m7.d.ts.map +1 -1
  319. package/node_modules/@oscharko-dev/keiko-contracts/dist/editor-m7.js +24 -10
  320. package/node_modules/@oscharko-dev/keiko-contracts/dist/evidence.d.ts +4 -0
  321. package/node_modules/@oscharko-dev/keiko-contracts/dist/evidence.d.ts.map +1 -1
  322. package/node_modules/@oscharko-dev/keiko-contracts/dist/gateway.d.ts +35 -6
  323. package/node_modules/@oscharko-dev/keiko-contracts/dist/gateway.d.ts.map +1 -1
  324. package/node_modules/@oscharko-dev/keiko-contracts/dist/gateway.js +50 -8
  325. package/node_modules/@oscharko-dev/keiko-contracts/dist/git-repository.d.ts +4 -0
  326. package/node_modules/@oscharko-dev/keiko-contracts/dist/git-repository.d.ts.map +1 -1
  327. package/node_modules/@oscharko-dev/keiko-contracts/dist/git-repository.js +13 -0
  328. package/node_modules/@oscharko-dev/keiko-contracts/dist/grounded-assessment.d.ts +27 -0
  329. package/node_modules/@oscharko-dev/keiko-contracts/dist/grounded-assessment.d.ts.map +1 -0
  330. package/node_modules/@oscharko-dev/keiko-contracts/dist/grounded-assessment.js +85 -0
  331. package/node_modules/@oscharko-dev/keiko-contracts/dist/index.d.ts +4 -4
  332. package/node_modules/@oscharko-dev/keiko-contracts/dist/index.d.ts.map +1 -1
  333. package/node_modules/@oscharko-dev/keiko-contracts/dist/no-evidence-answer.d.ts +15 -0
  334. package/node_modules/@oscharko-dev/keiko-contracts/dist/no-evidence-answer.d.ts.map +1 -0
  335. package/node_modules/@oscharko-dev/keiko-contracts/dist/no-evidence-answer.js +359 -0
  336. package/node_modules/@oscharko-dev/keiko-contracts/dist/observability.d.ts +26 -2
  337. package/node_modules/@oscharko-dev/keiko-contracts/dist/observability.d.ts.map +1 -1
  338. package/node_modules/@oscharko-dev/keiko-contracts/dist/observability.js +109 -6
  339. package/node_modules/@oscharko-dev/keiko-contracts/dist/store-fingerprint.d.ts +5 -6
  340. package/node_modules/@oscharko-dev/keiko-contracts/dist/store-fingerprint.d.ts.map +1 -1
  341. package/node_modules/@oscharko-dev/keiko-contracts/dist/store-fingerprint.js +16 -16
  342. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-incident.d.ts +33 -17
  343. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-incident.d.ts.map +1 -1
  344. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-incident.js +230 -26
  345. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-report-json.d.ts +13 -0
  346. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-report-json.d.ts.map +1 -0
  347. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-report-json.js +206 -0
  348. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-report-policy.d.ts +6 -0
  349. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-report-policy.d.ts.map +1 -0
  350. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-report-policy.js +11 -0
  351. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-report-producer.d.ts +26 -0
  352. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-report-producer.d.ts.map +1 -0
  353. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-report-producer.js +107 -0
  354. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-report.d.ts +118 -0
  355. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-report.d.ts.map +1 -0
  356. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-report.js +63 -0
  357. package/node_modules/@oscharko-dev/keiko-contracts/dist/version.d.ts +6 -2
  358. package/node_modules/@oscharko-dev/keiko-contracts/dist/version.d.ts.map +1 -1
  359. package/node_modules/@oscharko-dev/keiko-contracts/dist/version.js +71 -2
  360. package/node_modules/@oscharko-dev/keiko-contracts/dist/workspace-contract-primitives.d.ts +2 -0
  361. package/node_modules/@oscharko-dev/keiko-contracts/dist/workspace-contract-primitives.d.ts.map +1 -1
  362. package/node_modules/@oscharko-dev/keiko-contracts/dist/workspace-contract-primitives.js +2 -0
  363. package/node_modules/@oscharko-dev/keiko-contracts/dist/workspace.d.ts +1 -0
  364. package/node_modules/@oscharko-dev/keiko-contracts/dist/workspace.d.ts.map +1 -1
  365. package/node_modules/@oscharko-dev/keiko-contracts/package.json +17 -1
  366. package/node_modules/@oscharko-dev/keiko-evaluations/package.json +9 -9
  367. package/node_modules/@oscharko-dev/keiko-evidence/dist/compaction-evidence.d.ts.map +1 -1
  368. package/node_modules/@oscharko-dev/keiko-evidence/dist/compaction-evidence.js +16 -0
  369. package/node_modules/@oscharko-dev/keiko-evidence/dist/connected-context-evidence.d.ts.map +1 -1
  370. package/node_modules/@oscharko-dev/keiko-evidence/dist/connected-context-evidence.js +7 -4
  371. package/node_modules/@oscharko-dev/keiko-evidence/dist/context-assembly-redaction.d.ts.map +1 -1
  372. package/node_modules/@oscharko-dev/keiko-evidence/dist/context-assembly-redaction.js +1 -0
  373. package/node_modules/@oscharko-dev/keiko-evidence/dist/version.d.ts +1 -1
  374. package/node_modules/@oscharko-dev/keiko-evidence/dist/version.d.ts.map +1 -1
  375. package/node_modules/@oscharko-dev/keiko-evidence/dist/version.js +1 -1
  376. package/node_modules/@oscharko-dev/keiko-evidence/package.json +4 -4
  377. package/node_modules/@oscharko-dev/keiko-git/dist/version.d.ts +1 -1
  378. package/node_modules/@oscharko-dev/keiko-git/dist/version.d.ts.map +1 -1
  379. package/node_modules/@oscharko-dev/keiko-git/dist/version.js +1 -1
  380. package/node_modules/@oscharko-dev/keiko-git/package.json +1 -1
  381. package/node_modules/@oscharko-dev/keiko-harness/dist/version.d.ts +1 -1
  382. package/node_modules/@oscharko-dev/keiko-harness/dist/version.d.ts.map +1 -1
  383. package/node_modules/@oscharko-dev/keiko-harness/dist/version.js +1 -1
  384. package/node_modules/@oscharko-dev/keiko-harness/package.json +7 -7
  385. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/conversation/citation-attacher.d.ts +1 -0
  386. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/conversation/citation-attacher.d.ts.map +1 -1
  387. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/conversation/citation-attacher.js +49 -38
  388. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/conversation/grounded-answer-runner.d.ts.map +1 -1
  389. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/conversation/grounded-answer-runner.js +61 -25
  390. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/conversation/types.d.ts +14 -0
  391. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/conversation/types.d.ts.map +1 -1
  392. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/index.d.ts +1 -1
  393. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/index.d.ts.map +1 -1
  394. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/index.js +1 -1
  395. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/embedding-activity-log.d.ts.map +1 -1
  396. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/embedding-activity-log.js +1 -0
  397. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/orchestrator-activity-log.d.ts.map +1 -1
  398. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/orchestrator-activity-log.js +6 -0
  399. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/store-content-encryption.d.ts +0 -2
  400. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/store-content-encryption.d.ts.map +1 -1
  401. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/store-content-encryption.js +0 -11
  402. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/store.d.ts +0 -11
  403. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/store.d.ts.map +1 -1
  404. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/store.js +9 -78
  405. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/version.d.ts +1 -1
  406. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/version.d.ts.map +1 -1
  407. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/version.js +1 -1
  408. package/node_modules/@oscharko-dev/keiko-local-knowledge/package.json +5 -5
  409. package/node_modules/@oscharko-dev/keiko-memory-capture/dist/version.d.ts +1 -1
  410. package/node_modules/@oscharko-dev/keiko-memory-capture/dist/version.d.ts.map +1 -1
  411. package/node_modules/@oscharko-dev/keiko-memory-capture/dist/version.js +1 -1
  412. package/node_modules/@oscharko-dev/keiko-memory-capture/package.json +3 -3
  413. package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/consolidate.d.ts.map +1 -1
  414. package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/consolidate.js +3 -0
  415. package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/version.d.ts +1 -1
  416. package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/version.d.ts.map +1 -1
  417. package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/version.js +1 -1
  418. package/node_modules/@oscharko-dev/keiko-memory-consolidation/package.json +3 -3
  419. package/node_modules/@oscharko-dev/keiko-memory-governance/dist/version.d.ts +1 -1
  420. package/node_modules/@oscharko-dev/keiko-memory-governance/dist/version.d.ts.map +1 -1
  421. package/node_modules/@oscharko-dev/keiko-memory-governance/dist/version.js +1 -1
  422. package/node_modules/@oscharko-dev/keiko-memory-governance/package.json +3 -3
  423. package/node_modules/@oscharko-dev/keiko-memory-retrieval/dist/version.d.ts +1 -1
  424. package/node_modules/@oscharko-dev/keiko-memory-retrieval/dist/version.d.ts.map +1 -1
  425. package/node_modules/@oscharko-dev/keiko-memory-retrieval/dist/version.js +1 -1
  426. package/node_modules/@oscharko-dev/keiko-memory-retrieval/package.json +3 -3
  427. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/cipher.d.ts +0 -12
  428. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/cipher.d.ts.map +1 -1
  429. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/cipher.js +0 -32
  430. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/db.d.ts +2 -11
  431. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/db.d.ts.map +1 -1
  432. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/db.js +10 -144
  433. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/index.d.ts +1 -2
  434. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/index.d.ts.map +1 -1
  435. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/index.js +7 -14
  436. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/paths.d.ts +3 -2
  437. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/paths.d.ts.map +1 -1
  438. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/paths.js +17 -48
  439. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/vault-log.d.ts +2 -1
  440. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/vault-log.d.ts.map +1 -1
  441. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/vault.js +1 -1
  442. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/version.d.ts +1 -1
  443. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/version.d.ts.map +1 -1
  444. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/version.js +1 -1
  445. package/node_modules/@oscharko-dev/keiko-memory-vault/package.json +3 -3
  446. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/capabilities.d.ts +9 -0
  447. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/capabilities.d.ts.map +1 -1
  448. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/capabilities.js +24 -10
  449. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/config.d.ts +1 -0
  450. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/config.d.ts.map +1 -1
  451. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/config.js +100 -1
  452. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway.d.ts +24 -0
  453. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway.d.ts.map +1 -1
  454. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway.js +104 -34
  455. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/index.d.ts +3 -3
  456. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/index.d.ts.map +1 -1
  457. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/index.js +2 -2
  458. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/model-selection.d.ts.map +1 -1
  459. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/model-selection.js +33 -5
  460. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-adapter.d.ts +6 -0
  461. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-adapter.d.ts.map +1 -1
  462. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-adapter.js +115 -19
  463. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-embedding-adapter.d.ts.map +1 -1
  464. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-embedding-adapter.js +3 -0
  465. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/prDescription/generate.d.ts.map +1 -1
  466. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/prDescription/generate.js +4 -1
  467. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/prompt-admission.d.ts.map +1 -1
  468. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/prompt-admission.js +5 -2
  469. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/readiness-probe.d.ts +17 -0
  470. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/readiness-probe.d.ts.map +1 -1
  471. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/readiness-probe.js +48 -0
  472. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/resilience.d.ts +27 -2
  473. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/resilience.d.ts.map +1 -1
  474. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/resilience.js +300 -65
  475. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/types.d.ts +10 -0
  476. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/types.d.ts.map +1 -1
  477. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/version.d.ts +1 -1
  478. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/version.d.ts.map +1 -1
  479. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/version.js +1 -1
  480. package/node_modules/@oscharko-dev/keiko-model-gateway/package.json +4 -4
  481. package/node_modules/@oscharko-dev/keiko-quality-intelligence/package.json +3 -3
  482. package/node_modules/@oscharko-dev/keiko-sandbox/dist/backends.d.ts.map +1 -1
  483. package/node_modules/@oscharko-dev/keiko-sandbox/dist/backends.js +14 -3
  484. package/node_modules/@oscharko-dev/keiko-sandbox/dist/index.d.ts +1 -0
  485. package/node_modules/@oscharko-dev/keiko-sandbox/dist/index.d.ts.map +1 -1
  486. package/node_modules/@oscharko-dev/keiko-sandbox/dist/index.js +1 -0
  487. package/node_modules/@oscharko-dev/keiko-sandbox/dist/local-docker-endpoint.d.ts +16 -0
  488. package/node_modules/@oscharko-dev/keiko-sandbox/dist/local-docker-endpoint.d.ts.map +1 -0
  489. package/node_modules/@oscharko-dev/keiko-sandbox/dist/local-docker-endpoint.js +128 -0
  490. package/node_modules/@oscharko-dev/keiko-sandbox/dist/plan.d.ts.map +1 -1
  491. package/node_modules/@oscharko-dev/keiko-sandbox/dist/plan.js +25 -4
  492. package/node_modules/@oscharko-dev/keiko-sandbox/dist/types.d.ts.map +1 -1
  493. package/node_modules/@oscharko-dev/keiko-sandbox/package.json +2 -2
  494. package/node_modules/@oscharko-dev/keiko-sdk/package.json +9 -9
  495. package/node_modules/@oscharko-dev/keiko-security/dist/errors/gateway.d.ts +8 -2
  496. package/node_modules/@oscharko-dev/keiko-security/dist/errors/gateway.d.ts.map +1 -1
  497. package/node_modules/@oscharko-dev/keiko-security/dist/errors/gateway.js +15 -5
  498. package/node_modules/@oscharko-dev/keiko-security/dist/fs-hardening.d.ts +85 -1
  499. package/node_modules/@oscharko-dev/keiko-security/dist/fs-hardening.d.ts.map +1 -1
  500. package/node_modules/@oscharko-dev/keiko-security/dist/fs-hardening.js +128 -3
  501. package/node_modules/@oscharko-dev/keiko-security/dist/redaction.d.ts +3 -1
  502. package/node_modules/@oscharko-dev/keiko-security/dist/redaction.d.ts.map +1 -1
  503. package/node_modules/@oscharko-dev/keiko-security/dist/redaction.js +49 -14
  504. package/node_modules/@oscharko-dev/keiko-security/dist/version.d.ts +1 -1
  505. package/node_modules/@oscharko-dev/keiko-security/dist/version.d.ts.map +1 -1
  506. package/node_modules/@oscharko-dev/keiko-security/dist/version.js +1 -1
  507. package/node_modules/@oscharko-dev/keiko-security/package.json +2 -2
  508. package/node_modules/@oscharko-dev/keiko-server/dist/bounded-concurrency.d.ts +10 -0
  509. package/node_modules/@oscharko-dev/keiko-server/dist/bounded-concurrency.d.ts.map +1 -0
  510. package/node_modules/@oscharko-dev/keiko-server/dist/bounded-concurrency.js +84 -0
  511. package/node_modules/@oscharko-dev/keiko-server/dist/bounded-request-body.d.ts +13 -3
  512. package/node_modules/@oscharko-dev/keiko-server/dist/bounded-request-body.d.ts.map +1 -1
  513. package/node_modules/@oscharko-dev/keiko-server/dist/bounded-request-body.js +14 -25
  514. package/node_modules/@oscharko-dev/keiko-server/dist/chat-activity.d.ts.map +1 -1
  515. package/node_modules/@oscharko-dev/keiko-server/dist/chat-activity.js +17 -7
  516. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-evidence.d.ts +1 -0
  517. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-evidence.d.ts.map +1 -1
  518. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-evidence.js +4 -1
  519. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-model-call.d.ts +5 -0
  520. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-model-call.d.ts.map +1 -0
  521. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-model-call.js +29 -0
  522. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-model-summary.d.ts.map +1 -1
  523. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-model-summary.js +108 -59
  524. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-resurfacing.d.ts +4 -1
  525. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-resurfacing.d.ts.map +1 -1
  526. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-resurfacing.js +65 -8
  527. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-thresholds.d.ts +5 -0
  528. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-thresholds.d.ts.map +1 -0
  529. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-thresholds.js +8 -0
  530. package/node_modules/@oscharko-dev/keiko-server/dist/chat-context-breakdown.d.ts +25 -0
  531. package/node_modules/@oscharko-dev/keiko-server/dist/chat-context-breakdown.d.ts.map +1 -0
  532. package/node_modules/@oscharko-dev/keiko-server/dist/chat-context-breakdown.js +111 -0
  533. package/node_modules/@oscharko-dev/keiko-server/dist/chat-context-log.d.ts +6 -0
  534. package/node_modules/@oscharko-dev/keiko-server/dist/chat-context-log.d.ts.map +1 -0
  535. package/node_modules/@oscharko-dev/keiko-server/dist/chat-context-log.js +196 -0
  536. package/node_modules/@oscharko-dev/keiko-server/dist/chat-context-status.d.ts +5 -0
  537. package/node_modules/@oscharko-dev/keiko-server/dist/chat-context-status.d.ts.map +1 -0
  538. package/node_modules/@oscharko-dev/keiko-server/dist/chat-context-status.js +316 -0
  539. package/node_modules/@oscharko-dev/keiko-server/dist/chat-continuity-log.d.ts +23 -0
  540. package/node_modules/@oscharko-dev/keiko-server/dist/chat-continuity-log.d.ts.map +1 -0
  541. package/node_modules/@oscharko-dev/keiko-server/dist/chat-continuity-log.js +124 -0
  542. package/node_modules/@oscharko-dev/keiko-server/dist/chat-grounding.d.ts +4 -0
  543. package/node_modules/@oscharko-dev/keiko-server/dist/chat-grounding.d.ts.map +1 -0
  544. package/node_modules/@oscharko-dev/keiko-server/dist/chat-grounding.js +7 -0
  545. package/node_modules/@oscharko-dev/keiko-server/dist/chat-handlers.d.ts +9 -6
  546. package/node_modules/@oscharko-dev/keiko-server/dist/chat-handlers.d.ts.map +1 -1
  547. package/node_modules/@oscharko-dev/keiko-server/dist/chat-handlers.js +322 -154
  548. package/node_modules/@oscharko-dev/keiko-server/dist/chat-history-rehydration.d.ts +4 -0
  549. package/node_modules/@oscharko-dev/keiko-server/dist/chat-history-rehydration.d.ts.map +1 -0
  550. package/node_modules/@oscharko-dev/keiko-server/dist/chat-history-rehydration.js +137 -0
  551. package/node_modules/@oscharko-dev/keiko-server/dist/chat-history-snapshot.d.ts +41 -0
  552. package/node_modules/@oscharko-dev/keiko-server/dist/chat-history-snapshot.d.ts.map +1 -0
  553. package/node_modules/@oscharko-dev/keiko-server/dist/chat-history-snapshot.js +193 -0
  554. package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-budget-diagnostics.d.ts +1 -0
  555. package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-budget-diagnostics.d.ts.map +1 -1
  556. package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-budget-diagnostics.js +15 -1
  557. package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-budget.d.ts +12 -3
  558. package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-budget.d.ts.map +1 -1
  559. package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-budget.js +107 -20
  560. package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-compaction.d.ts +13 -0
  561. package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-compaction.d.ts.map +1 -0
  562. package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-compaction.js +163 -0
  563. package/node_modules/@oscharko-dev/keiko-server/dist/chat-scope-update-log.d.ts +3 -0
  564. package/node_modules/@oscharko-dev/keiko-server/dist/chat-scope-update-log.d.ts.map +1 -0
  565. package/node_modules/@oscharko-dev/keiko-server/dist/chat-scope-update-log.js +51 -0
  566. package/node_modules/@oscharko-dev/keiko-server/dist/chat-stream-handlers.d.ts.map +1 -1
  567. package/node_modules/@oscharko-dev/keiko-server/dist/chat-stream-handlers.js +87 -29
  568. package/node_modules/@oscharko-dev/keiko-server/dist/client-diagnostics-routes.d.ts.map +1 -1
  569. package/node_modules/@oscharko-dev/keiko-server/dist/client-diagnostics-routes.js +604 -27
  570. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/appSessionReadAuthority.d.ts +8 -0
  571. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/appSessionReadAuthority.d.ts.map +1 -1
  572. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/appSessionReadAuthority.js +112 -0
  573. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/codingAppSessionRoutes.d.ts +4 -4
  574. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/codingAppSessionRoutes.d.ts.map +1 -1
  575. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/codingAppSessionRoutes.js +31 -17
  576. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/sessionChannel.d.ts +6 -4
  577. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/sessionChannel.d.ts.map +1 -1
  578. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/sessionChannel.js +10 -10
  579. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/sessionCookie.d.ts +9 -2
  580. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/sessionCookie.d.ts.map +1 -1
  581. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/sessionCookie.js +13 -3
  582. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/sessionRegistry.d.ts +10 -0
  583. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/sessionRegistry.d.ts.map +1 -1
  584. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/sessionRegistry.js +59 -5
  585. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/githubIssueReaderAuthorization.d.ts.map +1 -1
  586. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/githubIssueReaderAuthorization.js +1 -0
  587. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingHistoryRoutes.d.ts.map +1 -1
  588. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingHistoryRoutes.js +8 -6
  589. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRepositorySearchHandler.d.ts.map +1 -1
  590. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRepositorySearchHandler.js +85 -2
  591. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolFacadePorts.d.ts +5 -0
  592. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolFacadePorts.d.ts.map +1 -1
  593. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeLaunchProfile.d.ts +1 -1
  594. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeLaunchProfile.d.ts.map +1 -1
  595. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeLaunchProfile.js +6 -4
  596. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionManagedWorktreeTools.d.ts.map +1 -1
  597. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionManagedWorktreeTools.js +7 -0
  598. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionWorkspaceHeadReader.js +23 -3
  599. package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-gateway.d.ts +1 -1
  600. package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-gateway.d.ts.map +1 -1
  601. package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-gateway.js +31 -4
  602. package/node_modules/@oscharko-dev/keiko-server/dist/conversation-compaction.d.ts +6 -2
  603. package/node_modules/@oscharko-dev/keiko-server/dist/conversation-compaction.d.ts.map +1 -1
  604. package/node_modules/@oscharko-dev/keiko-server/dist/conversation-compaction.js +181 -52
  605. package/node_modules/@oscharko-dev/keiko-server/dist/conversation-gateway.d.ts +5 -0
  606. package/node_modules/@oscharko-dev/keiko-server/dist/conversation-gateway.d.ts.map +1 -1
  607. package/node_modules/@oscharko-dev/keiko-server/dist/conversation-gateway.js +5 -2
  608. package/node_modules/@oscharko-dev/keiko-server/dist/deps.d.ts +27 -4
  609. package/node_modules/@oscharko-dev/keiko-server/dist/deps.d.ts.map +1 -1
  610. package/node_modules/@oscharko-dev/keiko-server/dist/deps.js +128 -20
  611. package/node_modules/@oscharko-dev/keiko-server/dist/diagnostics-log.d.ts +15 -1
  612. package/node_modules/@oscharko-dev/keiko-server/dist/diagnostics-log.d.ts.map +1 -1
  613. package/node_modules/@oscharko-dev/keiko-server/dist/diagnostics-log.js +102 -6
  614. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentAuthorityRegistry.d.ts +1 -3
  615. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentAuthorityRegistry.d.ts.map +1 -1
  616. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentAuthorityRegistry.js +5 -94
  617. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentProducerRoute.d.ts.map +1 -1
  618. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentProducerRoute.js +1 -0
  619. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentRoutes.d.ts.map +1 -1
  620. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentRoutes.js +50 -57
  621. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentSessionRegistry.d.ts +4 -0
  622. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentSessionRegistry.d.ts.map +1 -1
  623. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentSessionRegistry.js +81 -10
  624. package/node_modules/@oscharko-dev/keiko-server/dist/editor/bufferSafetyEvidence.d.ts +3 -0
  625. package/node_modules/@oscharko-dev/keiko-server/dist/editor/bufferSafetyEvidence.d.ts.map +1 -0
  626. package/node_modules/@oscharko-dev/keiko-server/dist/editor/bufferSafetyEvidence.js +35 -0
  627. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationExecution.d.ts +1 -1
  628. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationExecution.d.ts.map +1 -1
  629. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationExecution.js +29 -8
  630. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationRunner.d.ts.map +1 -1
  631. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationRunner.js +4 -0
  632. package/node_modules/@oscharko-dev/keiko-server/dist/editor/watch/workspaceWatchEvidence.d.ts +4 -0
  633. package/node_modules/@oscharko-dev/keiko-server/dist/editor/watch/workspaceWatchEvidence.d.ts.map +1 -0
  634. package/node_modules/@oscharko-dev/keiko-server/dist/editor/watch/workspaceWatchEvidence.js +75 -0
  635. package/node_modules/@oscharko-dev/keiko-server/dist/editor/watch/workspaceWatchRoutes.d.ts.map +1 -1
  636. package/node_modules/@oscharko-dev/keiko-server/dist/editor/watch/workspaceWatchRoutes.js +5 -0
  637. package/node_modules/@oscharko-dev/keiko-server/dist/editor/watch/workspaceWatchService.d.ts +3 -0
  638. package/node_modules/@oscharko-dev/keiko-server/dist/editor/watch/workspaceWatchService.d.ts.map +1 -1
  639. package/node_modules/@oscharko-dev/keiko-server/dist/editor/watch/workspaceWatchService.js +230 -34
  640. package/node_modules/@oscharko-dev/keiko-server/dist/files-deny.d.ts.map +1 -1
  641. package/node_modules/@oscharko-dev/keiko-server/dist/files-deny.js +3 -2
  642. package/node_modules/@oscharko-dev/keiko-server/dist/files.d.ts +2 -25
  643. package/node_modules/@oscharko-dev/keiko-server/dist/files.d.ts.map +1 -1
  644. package/node_modules/@oscharko-dev/keiko-server/dist/files.js +76 -35
  645. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-context-window.d.ts +56 -0
  646. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-context-window.d.ts.map +1 -0
  647. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-context-window.js +432 -0
  648. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-discovery-log.d.ts +15 -0
  649. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-discovery-log.d.ts.map +1 -1
  650. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-discovery-log.js +59 -0
  651. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-instance-cache.d.ts +4 -1
  652. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-instance-cache.d.ts.map +1 -1
  653. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-instance-cache.js +16 -5
  654. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-readiness.d.ts +18 -1
  655. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-readiness.d.ts.map +1 -1
  656. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-readiness.js +319 -46
  657. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-reranker-probe.d.ts +16 -0
  658. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-reranker-probe.d.ts.map +1 -0
  659. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-reranker-probe.js +30 -0
  660. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-setup.d.ts +24 -3
  661. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-setup.d.ts.map +1 -1
  662. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-setup.js +985 -229
  663. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-spend-budget.d.ts.map +1 -1
  664. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-spend-budget.js +6 -3
  665. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-tool-calling-probe.d.ts +1 -1
  666. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-tool-calling-probe.d.ts.map +1 -1
  667. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-tool-calling-probe.js +5 -3
  668. package/node_modules/@oscharko-dev/keiko-server/dist/gitChangeRoutes.d.ts.map +1 -1
  669. package/node_modules/@oscharko-dev/keiko-server/dist/gitChangeRoutes.js +30 -11
  670. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/ciObservationService.d.ts.map +1 -1
  671. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/ciObservationService.js +17 -0
  672. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/commitDraftQuality.d.ts.map +1 -1
  673. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/commitDraftQuality.js +5 -2
  674. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/commitRoutes.d.ts.map +1 -1
  675. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/commitRoutes.js +4 -1
  676. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/journeyObservationService.d.ts.map +1 -1
  677. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/journeyObservationService.js +1 -0
  678. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/journeyRoutes.d.ts.map +1 -1
  679. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/journeyRoutes.js +1 -0
  680. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prDescriptionProjection.d.ts.map +1 -1
  681. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prDescriptionProjection.js +1 -0
  682. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/verifiedCommitService.d.ts.map +1 -1
  683. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/verifiedCommitService.js +7 -0
  684. package/node_modules/@oscharko-dev/keiko-server/dist/gitRepositoryRoutes.d.ts +5 -1
  685. package/node_modules/@oscharko-dev/keiko-server/dist/gitRepositoryRoutes.d.ts.map +1 -1
  686. package/node_modules/@oscharko-dev/keiko-server/dist/gitRepositoryRoutes.js +68 -10
  687. package/node_modules/@oscharko-dev/keiko-server/dist/gitRoutes.d.ts.map +1 -1
  688. package/node_modules/@oscharko-dev/keiko-server/dist/gitRoutes.js +57 -1
  689. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer.d.ts +2 -0
  690. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer.d.ts.map +1 -1
  691. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer.js +1 -0
  692. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-citation-log.d.ts +39 -0
  693. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-citation-log.d.ts.map +1 -0
  694. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-citation-log.js +196 -0
  695. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-context-diagnostics.d.ts.map +1 -1
  696. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-context-diagnostics.js +25 -11
  697. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-context-pack-reranker.d.ts +2 -2
  698. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-context-pack-reranker.d.ts.map +1 -1
  699. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-context-pack-reranker.js +35 -3
  700. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-conversation-continuity.d.ts +18 -0
  701. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-conversation-continuity.d.ts.map +1 -0
  702. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-conversation-continuity.js +175 -0
  703. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-directory-iteration.d.ts +8 -0
  704. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-directory-iteration.d.ts.map +1 -0
  705. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-directory-iteration.js +60 -0
  706. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-document-evidence.d.ts +1 -1
  707. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-document-evidence.d.ts.map +1 -1
  708. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-document-evidence.js +2 -1
  709. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-entailment-stage.d.ts +1 -1
  710. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-entailment-stage.d.ts.map +1 -1
  711. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-entailment-stage.js +61 -1
  712. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-evidence-selection.d.ts +11 -2
  713. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-evidence-selection.d.ts.map +1 -1
  714. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-evidence-selection.js +78 -52
  715. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-faithfulness-eval.d.ts.map +1 -1
  716. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-faithfulness-eval.js +33 -4
  717. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-faithfulness.d.ts +37 -6
  718. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-faithfulness.d.ts.map +1 -1
  719. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-faithfulness.js +444 -101
  720. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-metadata-retention.d.ts +34 -0
  721. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-metadata-retention.d.ts.map +1 -0
  722. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-metadata-retention.js +123 -0
  723. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-multi-source-budget.d.ts.map +1 -1
  724. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-multi-source-budget.js +6 -6
  725. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-orchestrator.d.ts +24 -3
  726. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-orchestrator.d.ts.map +1 -1
  727. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-orchestrator.js +2338 -629
  728. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-overview-fallback.d.ts +3 -0
  729. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-overview-fallback.d.ts.map +1 -0
  730. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-overview-fallback.js +81 -0
  731. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-pack-validation.d.ts +22 -0
  732. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-pack-validation.d.ts.map +1 -0
  733. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-pack-validation.js +87 -0
  734. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-prompt-context.d.ts +19 -0
  735. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-prompt-context.d.ts.map +1 -0
  736. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-prompt-context.js +33 -0
  737. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-prompt.d.ts.map +1 -1
  738. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-prompt.js +11 -3
  739. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-hybrid.d.ts +18 -2
  740. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-hybrid.d.ts.map +1 -1
  741. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-hybrid.js +351 -164
  742. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-multi-source.d.ts +15 -3
  743. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-multi-source.d.ts.map +1 -1
  744. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-multi-source.js +242 -88
  745. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa.d.ts +29 -4
  746. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa.d.ts.map +1 -1
  747. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa.js +463 -122
  748. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-repo-semantic-search.d.ts.map +1 -1
  749. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-repo-semantic-search.js +16 -14
  750. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-rerank-facade.d.ts +2 -0
  751. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-rerank-facade.d.ts.map +1 -1
  752. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-rerank-facade.js +36 -2
  753. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-retrieval-eval.d.ts.map +1 -1
  754. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-retrieval-eval.js +4 -0
  755. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-scope-context.d.ts +32 -0
  756. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-scope-context.d.ts.map +1 -0
  757. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-scope-context.js +75 -0
  758. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-symbol-diagnostics.d.ts +4 -0
  759. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-symbol-diagnostics.d.ts.map +1 -0
  760. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-symbol-diagnostics.js +109 -0
  761. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-symbol-trace.d.ts +3 -3
  762. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-symbol-trace.d.ts.map +1 -1
  763. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-symbol-trace.js +2 -2
  764. package/node_modules/@oscharko-dev/keiko-server/dist/index.d.ts +1 -2
  765. package/node_modules/@oscharko-dev/keiko-server/dist/index.d.ts.map +1 -1
  766. package/node_modules/@oscharko-dev/keiko-server/dist/index.js +8 -13
  767. package/node_modules/@oscharko-dev/keiko-server/dist/knowledge-prompt-window.d.ts +44 -0
  768. package/node_modules/@oscharko-dev/keiko-server/dist/knowledge-prompt-window.d.ts.map +1 -0
  769. package/node_modules/@oscharko-dev/keiko-server/dist/knowledge-prompt-window.js +136 -0
  770. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-grounded-qa.d.ts +2 -1
  771. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-grounded-qa.d.ts.map +1 -1
  772. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-grounded-qa.js +232 -66
  773. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-handlers.d.ts.map +1 -1
  774. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-handlers.js +19 -4
  775. package/node_modules/@oscharko-dev/keiko-server/dist/memory-consolidation-handlers.d.ts.map +1 -1
  776. package/node_modules/@oscharko-dev/keiko-server/dist/memory-consolidation-handlers.js +11 -9
  777. package/node_modules/@oscharko-dev/keiko-server/dist/memory-conv-handlers.d.ts.map +1 -1
  778. package/node_modules/@oscharko-dev/keiko-server/dist/memory-conv-handlers.js +11 -9
  779. package/node_modules/@oscharko-dev/keiko-server/dist/memory-handlers.d.ts.map +1 -1
  780. package/node_modules/@oscharko-dev/keiko-server/dist/memory-handlers.js +43 -32
  781. package/node_modules/@oscharko-dev/keiko-server/dist/observability/route-template.d.ts.map +1 -1
  782. package/node_modules/@oscharko-dev/keiko-server/dist/observability/route-template.js +3 -0
  783. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/figma/figmaSnapshotBuilder.js +1 -1
  784. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/figma/index.d.ts +1 -1
  785. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/figma/index.d.ts.map +1 -1
  786. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/figma/index.js +1 -1
  787. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/handoffRoutes.d.ts.map +1 -1
  788. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/handoffRoutes.js +2 -2
  789. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/modelPolicyRoutes.d.ts +2 -2
  790. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/modelPolicyRoutes.d.ts.map +1 -1
  791. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/modelPolicyRoutes.js +36 -14
  792. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/runRoutes.d.ts.map +1 -1
  793. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/runRoutes.js +4 -2
  794. package/node_modules/@oscharko-dev/keiko-server/dist/routes.d.ts.map +1 -1
  795. package/node_modules/@oscharko-dev/keiko-server/dist/routes.js +11 -1
  796. package/node_modules/@oscharko-dev/keiko-server/dist/store/chat-grounding-scope-identity.d.ts +8 -0
  797. package/node_modules/@oscharko-dev/keiko-server/dist/store/chat-grounding-scope-identity.d.ts.map +1 -1
  798. package/node_modules/@oscharko-dev/keiko-server/dist/store/chat-grounding-scope-identity.js +21 -0
  799. package/node_modules/@oscharko-dev/keiko-server/dist/store/chats.d.ts.map +1 -1
  800. package/node_modules/@oscharko-dev/keiko-server/dist/store/chats.js +19 -3
  801. package/node_modules/@oscharko-dev/keiko-server/dist/store/codingHistoryIsolation.d.ts.map +1 -1
  802. package/node_modules/@oscharko-dev/keiko-server/dist/store/codingHistoryIsolation.js +8 -0
  803. package/node_modules/@oscharko-dev/keiko-server/dist/store/db.d.ts +0 -13
  804. package/node_modules/@oscharko-dev/keiko-server/dist/store/db.d.ts.map +1 -1
  805. package/node_modules/@oscharko-dev/keiko-server/dist/store/db.js +31 -130
  806. package/node_modules/@oscharko-dev/keiko-server/dist/store/index.d.ts +1 -1
  807. package/node_modules/@oscharko-dev/keiko-server/dist/store/index.d.ts.map +1 -1
  808. package/node_modules/@oscharko-dev/keiko-server/dist/store/index.js +1 -1
  809. package/node_modules/@oscharko-dev/keiko-server/dist/store/legacySchemaTestFixture.d.ts.map +1 -1
  810. package/node_modules/@oscharko-dev/keiko-server/dist/store/legacySchemaTestFixture.js +10 -1
  811. package/node_modules/@oscharko-dev/keiko-server/dist/store/messages.d.ts +2 -0
  812. package/node_modules/@oscharko-dev/keiko-server/dist/store/messages.d.ts.map +1 -1
  813. package/node_modules/@oscharko-dev/keiko-server/dist/store/messages.js +53 -82
  814. package/node_modules/@oscharko-dev/keiko-server/dist/store/paths.d.ts +2 -1
  815. package/node_modules/@oscharko-dev/keiko-server/dist/store/paths.d.ts.map +1 -1
  816. package/node_modules/@oscharko-dev/keiko-server/dist/store/paths.js +26 -42
  817. package/node_modules/@oscharko-dev/keiko-server/dist/store/schema.d.ts +1 -1
  818. package/node_modules/@oscharko-dev/keiko-server/dist/store/schema.d.ts.map +1 -1
  819. package/node_modules/@oscharko-dev/keiko-server/dist/store/schema.js +30 -3
  820. package/node_modules/@oscharko-dev/keiko-server/dist/store/types.d.ts +3 -0
  821. package/node_modules/@oscharko-dev/keiko-server/dist/store/types.d.ts.map +1 -1
  822. package/node_modules/@oscharko-dev/keiko-server/dist/store-handlers.d.ts +2 -0
  823. package/node_modules/@oscharko-dev/keiko-server/dist/store-handlers.d.ts.map +1 -1
  824. package/node_modules/@oscharko-dev/keiko-server/dist/store-handlers.js +141 -14
  825. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-download.d.ts +13 -0
  826. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-download.d.ts.map +1 -0
  827. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-download.js +239 -0
  828. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-evidence.d.ts +19 -0
  829. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-evidence.d.ts.map +1 -0
  830. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-evidence.js +347 -0
  831. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-job.d.ts +31 -0
  832. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-job.d.ts.map +1 -0
  833. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-job.js +169 -0
  834. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-routes.d.ts +4 -0
  835. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-routes.d.ts.map +1 -0
  836. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-routes.js +152 -0
  837. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-worker.d.ts +2 -0
  838. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-worker.d.ts.map +1 -0
  839. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-worker.js +43 -0
  840. package/node_modules/@oscharko-dev/keiko-server/dist/task-workspace/local-checkout.d.ts.map +1 -1
  841. package/node_modules/@oscharko-dev/keiko-server/dist/task-workspace/local-checkout.js +37 -4
  842. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolDispatch.d.ts.map +1 -1
  843. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolDispatch.js +8 -1
  844. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolSettlement.d.ts +1 -0
  845. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolSettlement.d.ts.map +1 -1
  846. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolSettlement.js +3 -0
  847. package/node_modules/@oscharko-dev/keiko-server/dist/update-preflight-registry.d.ts +1 -2
  848. package/node_modules/@oscharko-dev/keiko-server/dist/update-preflight-registry.d.ts.map +1 -1
  849. package/node_modules/@oscharko-dev/keiko-server/dist/update-preflight-registry.js +3 -35
  850. package/node_modules/@oscharko-dev/keiko-server/dist/voice-speech-text.d.ts.map +1 -1
  851. package/node_modules/@oscharko-dev/keiko-server/dist/voice-speech-text.js +4 -0
  852. package/node_modules/@oscharko-dev/keiko-server/dist/workspace-root-denial-log.d.ts +4 -1
  853. package/node_modules/@oscharko-dev/keiko-server/dist/workspace-root-denial-log.d.ts.map +1 -1
  854. package/node_modules/@oscharko-dev/keiko-server/dist/workspace-root-denial-log.js +76 -3
  855. package/node_modules/@oscharko-dev/keiko-server/dist/workspace-state-handlers.d.ts +3 -2
  856. package/node_modules/@oscharko-dev/keiko-server/dist/workspace-state-handlers.d.ts.map +1 -1
  857. package/node_modules/@oscharko-dev/keiko-server/dist/workspace-state-handlers.js +3 -100
  858. package/node_modules/@oscharko-dev/keiko-server/package.json +23 -23
  859. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/opencode.d.ts.map +1 -1
  860. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/opencode.js +3 -1
  861. package/node_modules/@oscharko-dev/keiko-tool-catalog/package.json +3 -3
  862. package/node_modules/@oscharko-dev/keiko-tools/dist/exec.d.ts.map +1 -1
  863. package/node_modules/@oscharko-dev/keiko-tools/dist/exec.js +36 -5
  864. package/node_modules/@oscharko-dev/keiko-tools/dist/version.d.ts +1 -1
  865. package/node_modules/@oscharko-dev/keiko-tools/dist/version.d.ts.map +1 -1
  866. package/node_modules/@oscharko-dev/keiko-tools/dist/version.js +1 -1
  867. package/node_modules/@oscharko-dev/keiko-tools/package.json +7 -7
  868. package/node_modules/@oscharko-dev/keiko-verification/dist/orchestrator.d.ts.map +1 -1
  869. package/node_modules/@oscharko-dev/keiko-verification/dist/orchestrator.js +3 -1
  870. package/node_modules/@oscharko-dev/keiko-verification/package.json +5 -5
  871. package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/index.d.ts +2 -1
  872. package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/index.d.ts.map +1 -1
  873. package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/index.js +2 -1
  874. package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/rehydration.d.ts +1 -0
  875. package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/rehydration.d.ts.map +1 -1
  876. package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/rehydration.js +2 -2
  877. package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/structured-digest.d.ts +1 -0
  878. package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/structured-digest.d.ts.map +1 -1
  879. package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/structured-digest.js +91 -27
  880. package/node_modules/@oscharko-dev/keiko-workflows/dist/contextpack/assemble.d.ts +10 -1
  881. package/node_modules/@oscharko-dev/keiko-workflows/dist/contextpack/assemble.d.ts.map +1 -1
  882. package/node_modules/@oscharko-dev/keiko-workflows/dist/contextpack/assemble.js +327 -45
  883. package/node_modules/@oscharko-dev/keiko-workflows/dist/contextpack/compaction.js +1 -1
  884. package/node_modules/@oscharko-dev/keiko-workflows/dist/contextpack/index.d.ts +1 -1
  885. package/node_modules/@oscharko-dev/keiko-workflows/dist/contextpack/index.d.ts.map +1 -1
  886. package/node_modules/@oscharko-dev/keiko-workflows/dist/contextpack/index.js +1 -1
  887. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/anchors.d.ts +4 -0
  888. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/anchors.d.ts.map +1 -1
  889. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/anchors.js +83 -32
  890. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/governor.js +1 -1
  891. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/index.d.ts +2 -2
  892. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/index.d.ts.map +1 -1
  893. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/index.js +1 -1
  894. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/intent.d.ts.map +1 -1
  895. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/intent.js +40 -3
  896. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/plan.d.ts +14 -1
  897. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/plan.d.ts.map +1 -1
  898. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/plan.js +209 -68
  899. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/filter.d.ts +2 -0
  900. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/filter.d.ts.map +1 -1
  901. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/filter.js +8 -2
  902. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/rank.d.ts.map +1 -1
  903. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/rank.js +7 -60
  904. package/node_modules/@oscharko-dev/keiko-workflows/package.json +10 -10
  905. package/node_modules/@oscharko-dev/keiko-workspace/dist/_memfs.d.ts.map +1 -1
  906. package/node_modules/@oscharko-dev/keiko-workspace/dist/_memfs.js +7 -0
  907. package/node_modules/@oscharko-dev/keiko-workspace/dist/binaryDetect.d.ts +5 -2
  908. package/node_modules/@oscharko-dev/keiko-workspace/dist/binaryDetect.d.ts.map +1 -1
  909. package/node_modules/@oscharko-dev/keiko-workspace/dist/binaryDetect.js +159 -38
  910. package/node_modules/@oscharko-dev/keiko-workspace/dist/codeIntelligence.js +2 -2
  911. package/node_modules/@oscharko-dev/keiko-workspace/dist/codeIntelligenceSurface.d.ts +2 -0
  912. package/node_modules/@oscharko-dev/keiko-workspace/dist/codeIntelligenceSurface.d.ts.map +1 -1
  913. package/node_modules/@oscharko-dev/keiko-workspace/dist/codeIntelligenceSurface.js +2 -0
  914. package/node_modules/@oscharko-dev/keiko-workspace/dist/codingRepositorySearch.d.ts +5 -1
  915. package/node_modules/@oscharko-dev/keiko-workspace/dist/codingRepositorySearch.d.ts.map +1 -1
  916. package/node_modules/@oscharko-dev/keiko-workspace/dist/codingRepositorySearch.js +140 -57
  917. package/node_modules/@oscharko-dev/keiko-workspace/dist/codingRepositorySearchResult.d.ts +1 -4
  918. package/node_modules/@oscharko-dev/keiko-workspace/dist/codingRepositorySearchResult.d.ts.map +1 -1
  919. package/node_modules/@oscharko-dev/keiko-workspace/dist/codingRepositorySearchResult.js +0 -15
  920. package/node_modules/@oscharko-dev/keiko-workspace/dist/discovery.d.ts +14 -0
  921. package/node_modules/@oscharko-dev/keiko-workspace/dist/discovery.d.ts.map +1 -1
  922. package/node_modules/@oscharko-dev/keiko-workspace/dist/discovery.js +235 -10
  923. package/node_modules/@oscharko-dev/keiko-workspace/dist/fs.d.ts +2 -1
  924. package/node_modules/@oscharko-dev/keiko-workspace/dist/fs.d.ts.map +1 -1
  925. package/node_modules/@oscharko-dev/keiko-workspace/dist/fs.js +48 -1
  926. package/node_modules/@oscharko-dev/keiko-workspace/dist/ignore.js +2 -2
  927. package/node_modules/@oscharko-dev/keiko-workspace/dist/importGraphEdges.js +1 -1
  928. package/node_modules/@oscharko-dev/keiko-workspace/dist/index.d.ts +3 -2
  929. package/node_modules/@oscharko-dev/keiko-workspace/dist/index.d.ts.map +1 -1
  930. package/node_modules/@oscharko-dev/keiko-workspace/dist/index.js +3 -2
  931. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearch.d.ts +31 -3
  932. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearch.d.ts.map +1 -1
  933. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearch.js +459 -137
  934. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchEntries.d.ts +8 -1
  935. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchEntries.d.ts.map +1 -1
  936. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchEntries.js +29 -24
  937. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchExcerptWindow.d.ts +16 -0
  938. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchExcerptWindow.d.ts.map +1 -0
  939. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchExcerptWindow.js +189 -0
  940. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchLineSelection.d.ts +3 -1
  941. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchLineSelection.d.ts.map +1 -1
  942. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchLineSelection.js +45 -18
  943. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchMatchers.d.ts +5 -1
  944. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchMatchers.d.ts.map +1 -1
  945. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchMatchers.js +89 -30
  946. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchPolicy.d.ts +21 -2
  947. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchPolicy.d.ts.map +1 -1
  948. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchPolicy.js +29 -5
  949. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchRetention.d.ts +15 -0
  950. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchRetention.d.ts.map +1 -0
  951. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchRetention.js +70 -0
  952. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchScan.d.ts +14 -2
  953. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchScan.d.ts.map +1 -1
  954. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchScan.js +178 -45
  955. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchSemantic.d.ts +14 -2
  956. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchSemantic.d.ts.map +1 -1
  957. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchSemantic.js +63 -5
  958. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchSourceInspection.d.ts +3 -0
  959. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchSourceInspection.d.ts.map +1 -0
  960. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchSourceInspection.js +37 -0
  961. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchStream.d.ts +30 -0
  962. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchStream.d.ts.map +1 -0
  963. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchStream.js +466 -0
  964. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralAdapterRequestContext.d.ts +6 -1
  965. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralAdapterRequestContext.d.ts.map +1 -1
  966. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralAdapterRequestContext.js +32 -6
  967. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralAdapters.js +1 -1
  968. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralExecution.d.ts +1 -1
  969. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralExecution.d.ts.map +1 -1
  970. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralExecution.js +60 -1
  971. package/node_modules/@oscharko-dev/keiko-workspace/dist/testSourcePairing.js +1 -1
  972. package/node_modules/@oscharko-dev/keiko-workspace/dist/testing.d.ts +2 -0
  973. package/node_modules/@oscharko-dev/keiko-workspace/dist/testing.d.ts.map +1 -1
  974. package/node_modules/@oscharko-dev/keiko-workspace/dist/testing.js +4 -0
  975. package/node_modules/@oscharko-dev/keiko-workspace/dist/version.d.ts +1 -1
  976. package/node_modules/@oscharko-dev/keiko-workspace/dist/version.d.ts.map +1 -1
  977. package/node_modules/@oscharko-dev/keiko-workspace/dist/version.js +1 -1
  978. package/node_modules/@oscharko-dev/keiko-workspace/dist/workspaceIndex.d.ts +2 -1
  979. package/node_modules/@oscharko-dev/keiko-workspace/dist/workspaceIndex.d.ts.map +1 -1
  980. package/node_modules/@oscharko-dev/keiko-workspace/dist/workspaceIndex.js +8 -1
  981. package/node_modules/@oscharko-dev/keiko-workspace/package.json +3 -3
  982. package/package.json +40 -33
  983. package/release-impact.catalog.json +198 -23
  984. package/scripts/lib/local-state-audit.mjs +26 -11
  985. package/vendor/oscharko-dev-keiko-activity-log-1.2.0.tgz +0 -0
  986. package/vendor/oscharko-dev-keiko-cli-1.2.0.tgz +0 -0
  987. package/vendor/{oscharko-dev-keiko-connectors-1.1.12.tgz → oscharko-dev-keiko-connectors-1.2.0.tgz} +0 -0
  988. package/vendor/oscharko-dev-keiko-contracts-1.2.0.tgz +0 -0
  989. package/vendor/{oscharko-dev-keiko-evaluations-1.1.12.tgz → oscharko-dev-keiko-evaluations-1.2.0.tgz} +0 -0
  990. package/vendor/oscharko-dev-keiko-evidence-1.2.0.tgz +0 -0
  991. package/vendor/oscharko-dev-keiko-git-1.2.0.tgz +0 -0
  992. package/vendor/{oscharko-dev-keiko-harness-1.1.12.tgz → oscharko-dev-keiko-harness-1.2.0.tgz} +0 -0
  993. package/vendor/oscharko-dev-keiko-local-knowledge-1.2.0.tgz +0 -0
  994. package/vendor/oscharko-dev-keiko-memory-capture-1.2.0.tgz +0 -0
  995. package/vendor/oscharko-dev-keiko-memory-consolidation-1.2.0.tgz +0 -0
  996. package/vendor/{oscharko-dev-keiko-memory-governance-1.1.12.tgz → oscharko-dev-keiko-memory-governance-1.2.0.tgz} +0 -0
  997. package/vendor/oscharko-dev-keiko-memory-retrieval-1.2.0.tgz +0 -0
  998. package/vendor/oscharko-dev-keiko-memory-vault-1.2.0.tgz +0 -0
  999. package/vendor/oscharko-dev-keiko-model-gateway-1.2.0.tgz +0 -0
  1000. package/vendor/{oscharko-dev-keiko-quality-intelligence-1.1.12.tgz → oscharko-dev-keiko-quality-intelligence-1.2.0.tgz} +0 -0
  1001. package/vendor/oscharko-dev-keiko-sandbox-1.2.0.tgz +0 -0
  1002. package/vendor/{oscharko-dev-keiko-sdk-1.1.12.tgz → oscharko-dev-keiko-sdk-1.2.0.tgz} +0 -0
  1003. package/vendor/oscharko-dev-keiko-security-1.2.0.tgz +0 -0
  1004. package/vendor/oscharko-dev-keiko-server-1.2.0.tgz +0 -0
  1005. package/vendor/oscharko-dev-keiko-tool-catalog-1.2.0.tgz +0 -0
  1006. package/vendor/oscharko-dev-keiko-tools-1.2.0.tgz +0 -0
  1007. package/vendor/oscharko-dev-keiko-verification-1.2.0.tgz +0 -0
  1008. package/vendor/oscharko-dev-keiko-workflows-1.2.0.tgz +0 -0
  1009. package/vendor/oscharko-dev-keiko-workspace-1.2.0.tgz +0 -0
  1010. package/dist/ui/static/_next/static/chunks/000t9p2ysi3dv.css +0 -1
  1011. package/dist/ui/static/_next/static/chunks/00dd_gyzi9unw.js +0 -1
  1012. package/dist/ui/static/_next/static/chunks/00n029ow-5_tt.js +0 -3
  1013. package/dist/ui/static/_next/static/chunks/06yzmh78cidsr.js +0 -1
  1014. package/dist/ui/static/_next/static/chunks/08kdz_q929mef.js +0 -1
  1015. package/dist/ui/static/_next/static/chunks/0_7ry-vzqryfq.js +0 -1
  1016. package/dist/ui/static/_next/static/chunks/0_p1naz51ki9i.js +0 -1
  1017. package/dist/ui/static/_next/static/chunks/0cksy9u2ysiuy.js +0 -1
  1018. package/dist/ui/static/_next/static/chunks/0elflgy2cg1jb.js +0 -1
  1019. package/dist/ui/static/_next/static/chunks/0k931k8qwqyft.js +0 -1
  1020. package/dist/ui/static/_next/static/chunks/0kmepj4rmkj19.js +0 -1
  1021. package/dist/ui/static/_next/static/chunks/0l46-80gche_i.js +0 -1
  1022. package/dist/ui/static/_next/static/chunks/0mkhgmj9-jvu-.js +0 -1
  1023. package/dist/ui/static/_next/static/chunks/0ojvvjnsf38bk.js +0 -1
  1024. package/dist/ui/static/_next/static/chunks/0qt-w4yzb50ov.js +0 -1
  1025. package/dist/ui/static/_next/static/chunks/0v9jkxfma7fks.js +0 -1
  1026. package/dist/ui/static/_next/static/chunks/0z5be09yla9lp.js +0 -1
  1027. package/dist/ui/static/_next/static/chunks/115f9zt0f5hm4.js +0 -1
  1028. package/dist/ui/static/_next/static/chunks/117xhn896fsmt.js +0 -1
  1029. package/dist/ui/static/_next/static/chunks/14rs31u4u36yy.js +0 -1
  1030. package/dist/ui/static/_next/static/chunks/159szpr5ffygs.js +0 -1
  1031. package/dist/ui/static/_next/static/chunks/15orau2hhjb1f.js +0 -1
  1032. package/dist/ui/static/_next/static/chunks/1b7ig6f2t71i_.js +0 -1
  1033. package/dist/ui/static/_next/static/chunks/1be0-x1mk56wu.js +0 -1
  1034. package/dist/ui/static/_next/static/chunks/1cjmlpaxzl17x.js +0 -1
  1035. package/dist/ui/static/_next/static/chunks/1cluynrv3wmyz.js +0 -1
  1036. package/dist/ui/static/_next/static/chunks/1dwc7p2rl-hs6.js +0 -1
  1037. package/dist/ui/static/_next/static/chunks/1hk335vrug1rc.js +0 -1
  1038. package/dist/ui/static/_next/static/chunks/1hnficrb11m9x.js +0 -1
  1039. package/dist/ui/static/_next/static/chunks/1jfpuw9-h8iaq.js +0 -1
  1040. package/dist/ui/static/_next/static/chunks/1kxhf3ld28pzk.js +0 -1
  1041. package/dist/ui/static/_next/static/chunks/1lrj3d157kay1.js +0 -5
  1042. package/dist/ui/static/_next/static/chunks/1nie2fvj8iyvq.js +0 -1
  1043. package/dist/ui/static/_next/static/chunks/1oe16odh9-wem.js +0 -1
  1044. package/dist/ui/static/_next/static/chunks/1pnysuel-a2r1.js +0 -1
  1045. package/dist/ui/static/_next/static/chunks/1rrylkj4wfhla.js +0 -1
  1046. package/dist/ui/static/_next/static/chunks/1uetvnnpa5z22.js +0 -1
  1047. package/dist/ui/static/_next/static/chunks/1uigiy7xdzirs.js +0 -1
  1048. package/dist/ui/static/_next/static/chunks/1uulmf99vtuyt.js +0 -1
  1049. package/dist/ui/static/_next/static/chunks/1uxrq3q9n5v4y.js +0 -1
  1050. package/dist/ui/static/_next/static/chunks/1x5aw_ayly-sh.js +0 -1
  1051. package/dist/ui/static/_next/static/chunks/1xzxhtenb7_sx.css +0 -1
  1052. package/dist/ui/static/_next/static/chunks/1yiiigw5l63v1.js +0 -36
  1053. package/dist/ui/static/_next/static/chunks/2-h3ow6f6ywtk.js +0 -1
  1054. package/dist/ui/static/_next/static/chunks/202kx3p8axlmr.js +0 -1
  1055. package/dist/ui/static/_next/static/chunks/20b456jf1ggzu.css +0 -1
  1056. package/dist/ui/static/_next/static/chunks/22tu2ta5xr5wj.js +0 -1
  1057. package/dist/ui/static/_next/static/chunks/22x3pxeia7hk_.js +0 -1
  1058. package/dist/ui/static/_next/static/chunks/22yars17p-i_a.js +0 -1
  1059. package/dist/ui/static/_next/static/chunks/233j_pai87f3k.js +0 -2
  1060. package/dist/ui/static/_next/static/chunks/252wybdcea74g.js +0 -1
  1061. package/dist/ui/static/_next/static/chunks/25lgzefdnbdh6.js +0 -1
  1062. package/dist/ui/static/_next/static/chunks/27490erridyaz.js +0 -1
  1063. package/dist/ui/static/_next/static/chunks/2_o61-akoq549.js +0 -1
  1064. package/dist/ui/static/_next/static/chunks/2b78j2josay3e.js +0 -1
  1065. package/dist/ui/static/_next/static/chunks/2e4prtd3wmn0a.js +0 -1
  1066. package/dist/ui/static/_next/static/chunks/2iatd917svh3o.js +0 -1
  1067. package/dist/ui/static/_next/static/chunks/2iehfums033xv.css +0 -3
  1068. package/dist/ui/static/_next/static/chunks/2j16o4ghz4iqx.js +0 -1
  1069. package/dist/ui/static/_next/static/chunks/2oxvgl3qb19wf.js +0 -1
  1070. package/dist/ui/static/_next/static/chunks/2s9-91g2jic6u.js +0 -1
  1071. package/dist/ui/static/_next/static/chunks/2tcon4aj5dc5t.js +0 -1
  1072. package/dist/ui/static/_next/static/chunks/2uewj5n3jrohk.js +0 -1
  1073. package/dist/ui/static/_next/static/chunks/2vcovdwo6s3-l.js +0 -1
  1074. package/dist/ui/static/_next/static/chunks/2wtsqscjch4bx.js +0 -1
  1075. package/dist/ui/static/_next/static/chunks/2xpud5k1hwfvf.js +0 -1
  1076. package/dist/ui/static/_next/static/chunks/2ywqac8g8us1n.css +0 -1
  1077. package/dist/ui/static/_next/static/chunks/306ima8lxo17-.js +0 -1
  1078. package/dist/ui/static/_next/static/chunks/32tief1094icq.js +0 -1
  1079. package/dist/ui/static/_next/static/chunks/351uy__m9eafa.js +0 -1
  1080. package/dist/ui/static/_next/static/chunks/365nk-5mmf_8c.js +0 -1
  1081. package/dist/ui/static/_next/static/chunks/36afhcug0i5mm.js +0 -1
  1082. package/dist/ui/static/_next/static/chunks/36t-jmpwnypy0.js +0 -1
  1083. package/dist/ui/static/_next/static/chunks/37f_o8ne61ty2.js +0 -1
  1084. package/dist/ui/static/_next/static/chunks/37mtn-h7j8ygx.js +0 -1
  1085. package/dist/ui/static/_next/static/chunks/3_cgafsc6hy1_.js +0 -1
  1086. package/dist/ui/static/_next/static/chunks/3_exo95bp9tt2.js +0 -1
  1087. package/dist/ui/static/_next/static/chunks/3_rof9w-g14_v.js +0 -3
  1088. package/dist/ui/static/_next/static/chunks/3_u5w33et675r.js +0 -1
  1089. package/dist/ui/static/_next/static/chunks/3aizxizjzdddj.js +0 -1
  1090. package/dist/ui/static/_next/static/chunks/3aqtjd-a1ygis.js +0 -1
  1091. package/dist/ui/static/_next/static/chunks/3bl12pe7lsanc.js +0 -1
  1092. package/dist/ui/static/_next/static/chunks/3f6svr_pokw6j.js +0 -1
  1093. package/dist/ui/static/_next/static/chunks/3hft62celuigp.js +0 -1
  1094. package/dist/ui/static/_next/static/chunks/3ibevys2o09xx.js +0 -1
  1095. package/dist/ui/static/_next/static/chunks/3iv5llh4xg-7v.js +0 -1
  1096. package/dist/ui/static/_next/static/chunks/3jtbes4v4ouyw.js +0 -1
  1097. package/dist/ui/static/_next/static/chunks/3lq5zd1qvhcfw.js +0 -1
  1098. package/dist/ui/static/_next/static/chunks/3n4gsbv-im5ia.js +0 -1
  1099. package/dist/ui/static/_next/static/chunks/3r4fz572q3l7s.js +0 -1
  1100. package/dist/ui/static/_next/static/chunks/3uovpxgynmdkk.js +0 -1
  1101. package/dist/ui/static/_next/static/chunks/3vnb2msty1ab4.js +0 -1
  1102. package/dist/ui/static/_next/static/chunks/3yqrxwndy9_f3.js +0 -1
  1103. package/dist/ui/static/_next/static/chunks/3zd1y0ze7hnsy.js +0 -1
  1104. package/dist/ui/static/_next/static/chunks/40g2_9ovqiuiu.js +0 -1
  1105. package/dist/ui/static/_next/static/chunks/412pf48_r8im3.js +0 -1
  1106. package/dist/ui/static/_next/static/chunks/413lmui4la1xe.js +0 -1
  1107. package/dist/ui/static/_next/static/chunks/41ca6l5ikqt65.js +0 -1
  1108. package/dist/ui/static/_next/static/chunks/434km55nqikg-.js +0 -7
  1109. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-selective-export.d.ts +0 -29
  1110. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-selective-export.d.ts.map +0 -1
  1111. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-selective-export.js +0 -30
  1112. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/figma/figmaConcurrency.d.ts +0 -8
  1113. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/figma/figmaConcurrency.d.ts.map +0 -1
  1114. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/figma/figmaConcurrency.js +0 -34
  1115. package/node_modules/@oscharko-dev/keiko-server/dist/store-fingerprints.d.ts +0 -29
  1116. package/node_modules/@oscharko-dev/keiko-server/dist/store-fingerprints.d.ts.map +0 -1
  1117. package/node_modules/@oscharko-dev/keiko-server/dist/store-fingerprints.js +0 -135
  1118. package/node_modules/@oscharko-dev/keiko-workspace/dist/codingRepositorySearchInventory.d.ts +0 -7
  1119. package/node_modules/@oscharko-dev/keiko-workspace/dist/codingRepositorySearchInventory.d.ts.map +0 -1
  1120. package/node_modules/@oscharko-dev/keiko-workspace/dist/codingRepositorySearchInventory.js +0 -24
  1121. package/vendor/oscharko-dev-keiko-activity-log-1.1.12.tgz +0 -0
  1122. package/vendor/oscharko-dev-keiko-cli-1.1.12.tgz +0 -0
  1123. package/vendor/oscharko-dev-keiko-contracts-1.1.12.tgz +0 -0
  1124. package/vendor/oscharko-dev-keiko-evidence-1.1.12.tgz +0 -0
  1125. package/vendor/oscharko-dev-keiko-git-1.1.12.tgz +0 -0
  1126. package/vendor/oscharko-dev-keiko-local-knowledge-1.1.12.tgz +0 -0
  1127. package/vendor/oscharko-dev-keiko-memory-capture-1.1.12.tgz +0 -0
  1128. package/vendor/oscharko-dev-keiko-memory-consolidation-1.1.12.tgz +0 -0
  1129. package/vendor/oscharko-dev-keiko-memory-retrieval-1.1.12.tgz +0 -0
  1130. package/vendor/oscharko-dev-keiko-memory-vault-1.1.12.tgz +0 -0
  1131. package/vendor/oscharko-dev-keiko-model-gateway-1.1.12.tgz +0 -0
  1132. package/vendor/oscharko-dev-keiko-sandbox-1.1.12.tgz +0 -0
  1133. package/vendor/oscharko-dev-keiko-security-1.1.12.tgz +0 -0
  1134. package/vendor/oscharko-dev-keiko-server-1.1.12.tgz +0 -0
  1135. package/vendor/oscharko-dev-keiko-tool-catalog-1.1.12.tgz +0 -0
  1136. package/vendor/oscharko-dev-keiko-tools-1.1.12.tgz +0 -0
  1137. package/vendor/oscharko-dev-keiko-verification-1.1.12.tgz +0 -0
  1138. package/vendor/oscharko-dev-keiko-workflows-1.1.12.tgz +0 -0
  1139. package/vendor/oscharko-dev-keiko-workspace-1.1.12.tgz +0 -0
  1140. /package/dist/ui/static/_next/static/{__kGQcCW6ht5xSodXZZBj → LNCY1B2FJBOe2AHFXpzB-}/_buildManifest.js +0 -0
  1141. /package/dist/ui/static/_next/static/{__kGQcCW6ht5xSodXZZBj → LNCY1B2FJBOe2AHFXpzB-}/_clientMiddlewareManifest.js +0 -0
  1142. /package/dist/ui/static/_next/static/{__kGQcCW6ht5xSodXZZBj → LNCY1B2FJBOe2AHFXpzB-}/_ssgManifest.js +0 -0
@@ -8,32 +8,40 @@
8
8
  // Pure orchestration: the only IO this module performs is delegated through the workspace
9
9
  // package's already-bounded WorkspaceFs port. Path validation is enforced by every composed
10
10
  // layer at its own boundary, so this file does not re-validate scope paths.
11
+ import { directoryCleanupTracker, observeDirectoryIteration, } from "./grounded-directory-iteration.js";
12
+ import { reconcileAndLogInlineCitations } from "./grounded-citation-log.js";
13
+ import { createSymbolReadFailureObserver, } from "./grounded-symbol-diagnostics.js";
14
+ import { mergeOverviewListing } from "./grounded-overview-fallback.js";
11
15
  import { Buffer } from "node:buffer";
12
16
  import { createHash } from "node:crypto";
13
17
  import { resolve } from "node:path";
14
- import { CONNECTED_CONTEXT_SCHEMA_VERSION, DEFAULT_EXPLORATION_BUDGET, isValidScopePath, } from "@oscharko-dev/keiko-contracts/connected-context";
18
+ import { connectedContextOmittedCount, connectedContextOmittedCounts, CONNECTED_CONTEXT_SCHEMA_VERSION, DEFAULT_EXPLORATION_BUDGET, MAX_OMITTED_CONTEXT_ENTRIES, isValidScopePath, } from "@oscharko-dev/keiko-contracts/connected-context";
15
19
  import { activityLogErrorKindOr, activityLogEvent, classifyErrorKind, defineActivityLogOperation, } from "@oscharko-dev/keiko-contracts/runtime/observability";
16
- import { advanceRing, applyUsage, assembleContextPack, canContinue, complete, contextPackIndexKey, planAndGovern, rankCandidates, } from "@oscharko-dev/keiko-workflows";
17
- import { CANONICAL_MANIFEST_BASENAMES, DEFAULT_SEARCH_LIMITS, FileTooLargeError, PathDeniedError, RepoSearchUnsupportedFileError, WorkspaceNotFoundError, detectWorkspaceAt, endpointContractAdapter, gitHistoryAdapter, isCanonicalMetadataFile, isEcosystemSourceFile, isDenied, readExcerpt, resolveWithinWorkspace, searchText, symbolGraphAdapter, containedRealPathInfo, evidenceAtomStableId, } from "@oscharko-dev/keiko-workspace";
20
+ import { advanceRing, applyUsage, assembleContextPack, canContinue, classifyRetrievalIntent, complete, contextPackIndexKey, extractAnchors, DEFAULT_FILTER_OPTIONS, planAndGovern, rankCandidates, isDirectEvidenceLookup, requiresRelationshipOrHistoryRings, resolveQueryTargetDecision, } from "@oscharko-dev/keiko-workflows";
21
+ import { CANONICAL_MANIFEST_BASENAMES, DEFAULT_SEARCH_LIMITS, FileTooLargeError, PathDeniedError, PathEscapeError, RepoSearchUnsupportedFileError, WorkspaceNotFoundError, WorkspaceReadError, detectWorkspaceAt, decodeTextFileBytes, endpointContractAdapter, findFiles, gitHistoryAdapter, isCanonicalMetadataFile, isEcosystemSourceFile, isDenied, readExcerpt, resolveWithinWorkspace, searchText, symbolGraphAdapter, containedRealPathInfo, evidenceAtomStableId, } from "@oscharko-dev/keiko-workspace";
18
22
  import { isAllowedContainedPathParent, isCanonicalAllowedContainedPath, } from "@oscharko-dev/keiko-workspace/internal/realpath-policy";
19
- import { createStructuralAdapterRequestContext, createEcosystemStructureAdapters, importGraphAdapter, runStructuralAdapters, testSourcePairingAdapter, } from "@oscharko-dev/keiko-workspace/code-intelligence";
23
+ import { createStructuralAdapterRequestContext, createEcosystemStructureAdapters, importGraphAdapter, runStructuralAdapters, repositorySourceLines, structuralLineLooksLikeSymbolDefinition, testSourcePairingAdapter, } from "@oscharko-dev/keiko-workspace/code-intelligence";
20
24
  import { CancelledError, ERROR_CODES } from "@oscharko-dev/keiko-model-gateway";
25
+ import { iterateSequentialResults, mapWithConcurrency } from "./bounded-concurrency.js";
26
+ import { BoundedMetadataPaths, MetadataRetention, } from "./grounded-metadata-retention.js";
27
+ import { compareStrings } from "@oscharko-dev/keiko-contracts/runtime/comparators";
21
28
  import { isWorkspacePathSnapshotCurrent, nodeWorkspaceFs, } from "@oscharko-dev/keiko-workspace/internal/fs";
22
29
  import { preserveOwnedRootAuthority } from "@oscharko-dev/keiko-workspace/internal/owned-root-preserve";
23
30
  import { normalizeGroundedAnswerPayload, } from "./grounded-answer.js";
24
- import { GROUNDED_NO_EVIDENCE_ANSWER, buildPackCitationIndex, incompleteAnswerMarker, missingCitationMarker, noEvidenceMarker, packHasUsableEvidence, reconcileInlineCitations, unsupportedCitationMarker, } from "./grounded-faithfulness.js";
31
+ import { connectedSearchNoEvidenceAnswer, buildPackCitationIndex, incompleteAnswerMarker, missingCitationMarkerFor, noEvidenceMarker, packHasUsableEvidence, unsupportedCitationMarker, } from "./grounded-faithfulness.js";
25
32
  import { collectDiscoveredSymbolTraceEvidence, collectFollowSymbolTraceEvidence, GROUNDED_TRACE_SEARCH_LIMITS, } from "./grounded-symbol-trace.js";
26
33
  import { defaultGitFileHistoryEvidenceProvider, } from "./grounded-git-history-evidence.js";
27
34
  import { collectConnectedDocumentEvidence, isConnectedDocumentPath, } from "./grounded-document-evidence.js";
28
- import { selectGroundedCandidateFiles, selectGroundedEvidenceAtoms, tracePriority, } from "./grounded-evidence-selection.js";
35
+ import { certifiedContentPaths, selectGroundedCandidateFiles, pathOnlyEvidencePaths, selectGroundedEvidenceAtoms, tracePriority, } from "./grounded-evidence-selection.js";
29
36
  import { directDefinitionSymbol } from "./grounded-query-shape.js";
30
- import { attachContextBudgetDiagnostics } from "./grounded-context-diagnostics.js";
37
+ import { KnownFitScopeContext } from "./grounded-scope-context.js";
38
+ import { attachContextBudgetDiagnostics, deriveGroundedContextAssembly, } from "./grounded-context-diagnostics.js";
31
39
  import { correlationIdOrUnknown } from "./correlation.js";
32
40
  import { createServerLogger, errorKindOf, reportServerLogFailure, startLogTimer, } from "./observability/index.js";
33
- import { causeChain, keikoStackFrames } from "@oscharko-dev/keiko-activity-log";
41
+ import { causeChain, contentFreeErrorClass, safeProperty, keikoStackFrames, } from "@oscharko-dev/keiko-activity-log";
34
42
  import { processServerLogSink } from "./process-log-sink.js";
35
43
  import { AbortDeadlineRaceError, raceAbortDeadline } from "./abort-race.js";
36
- import { resolveRecordedWorkspaceRoot } from "./workspace-root-denial-log.js";
44
+ import { resolveRecordedWorkspaceRoot, isExpectedWorkspaceRootFailure, } from "./workspace-root-denial-log.js";
37
45
  const SEARCH_CONNECTED_CONTEXT_STARTED_OPERATION = defineActivityLogOperation({
38
46
  contractKind: "activity-log-operation",
39
47
  schemaVersion: 1,
@@ -68,10 +76,12 @@ const SEARCH_CONNECTED_CONTEXT_STARTED_OPERATION = defineActivityLogOperation({
68
76
  maxResults: { type: "integer", dataClass: "count", required: false },
69
77
  searchCallsMax: { type: "integer", dataClass: "count", required: false },
70
78
  filesReadMax: { type: "integer", dataClass: "count", required: false },
79
+ filesReadBounded: { type: "boolean", dataClass: "closed-enum", required: true },
71
80
  excerptBytesMax: { type: "integer", dataClass: "count", required: false },
72
81
  modelInputTokensMax: { type: "integer", dataClass: "count", required: false },
73
82
  modelOutputTokensMax: { type: "integer", dataClass: "count", required: false },
74
83
  elapsedMsMax: { type: "integer", dataClass: "duration", required: false },
84
+ elapsedMsBounded: { type: "boolean", dataClass: "closed-enum", required: true },
75
85
  rerankCallsMax: { type: "integer", dataClass: "count", required: false },
76
86
  completeness: { type: "string", dataClass: "completeness-state", required: true },
77
87
  loss: { type: "string", dataClass: "loss-state", required: true },
@@ -99,15 +109,101 @@ const SEARCH_CONNECTED_CONTEXT_COMPLETED_OPERATION = defineActivityLogOperation(
99
109
  required: true,
100
110
  values: ["complete", "unavailable"],
101
111
  },
112
+ retrievalIntent: {
113
+ type: "string",
114
+ dataClass: "closed-enum",
115
+ required: false,
116
+ values: [
117
+ "project-metadata",
118
+ "repository-overview",
119
+ "targeted-code-search",
120
+ "diagnostic-search",
121
+ "clarification-needed",
122
+ ],
123
+ },
124
+ retrievalTargetDecision: {
125
+ type: "string",
126
+ dataClass: "closed-enum",
127
+ required: false,
128
+ values: ["literal-search", "direct-fact", "contextual"],
129
+ },
130
+ retrievalTargetCount: { type: "integer", dataClass: "count", required: false },
131
+ retrievalAnchorCount: { type: "integer", dataClass: "count", required: false },
102
132
  plannedRingCount: { type: "integer", dataClass: "count", required: false },
133
+ executedRingKinds: {
134
+ type: "string-array",
135
+ dataClass: "closed-enum",
136
+ required: false,
137
+ maxItems: 3,
138
+ values: ["lexical", "structural", "git-history"],
139
+ },
140
+ skippedRingKinds: {
141
+ type: "string-array",
142
+ dataClass: "closed-enum",
143
+ required: false,
144
+ maxItems: 3,
145
+ values: ["lexical", "structural", "git-history"],
146
+ },
147
+ stoppedRingKinds: {
148
+ type: "string-array",
149
+ dataClass: "closed-enum",
150
+ required: false,
151
+ maxItems: 3,
152
+ values: ["lexical", "structural", "git-history"],
153
+ },
154
+ augmentationDisposition: {
155
+ type: "string",
156
+ dataClass: "closed-enum",
157
+ required: false,
158
+ values: ["not-reached", "used", "skipped"],
159
+ },
160
+ ringSkipReasons: {
161
+ type: "string-array",
162
+ dataClass: "closed-enum",
163
+ required: false,
164
+ maxItems: 5,
165
+ values: [
166
+ "no-git-metadata",
167
+ "ordinary-document",
168
+ "literal-absence",
169
+ "complete-exact-lookup",
170
+ "verified-target-context",
171
+ ],
172
+ },
173
+ augmentationSkipped: { type: "boolean", dataClass: "closed-enum", required: false },
174
+ augmentationSkipReason: {
175
+ type: "string",
176
+ dataClass: "closed-enum",
177
+ required: false,
178
+ values: [
179
+ "no-git-metadata",
180
+ "ordinary-document",
181
+ "literal-absence",
182
+ "complete-exact-lookup",
183
+ "verified-target-context",
184
+ "budget-exhausted",
185
+ ],
186
+ },
103
187
  usageSearchCalls: { type: "integer", dataClass: "count", required: false },
104
188
  usageFilesRead: { type: "integer", dataClass: "count", required: false },
105
189
  usageExcerptBytes: { type: "integer", dataClass: "count", required: false },
190
+ excerptAnchoredWindowCount: { type: "integer", dataClass: "count", required: false },
191
+ excerptReadWindowCount: { type: "integer", dataClass: "count", required: false },
106
192
  usageModelInputTokens: { type: "integer", dataClass: "count", required: false },
107
193
  usageModelOutputTokens: { type: "integer", dataClass: "count", required: false },
108
194
  usageElapsedMs: { type: "integer", dataClass: "duration", required: false },
109
195
  usageRerankCalls: { type: "integer", dataClass: "count", required: false },
110
196
  selectedFileCount: { type: "integer", dataClass: "count", required: false },
197
+ scopeContextSelectedFileCount: { type: "integer", dataClass: "count", required: false },
198
+ contextSelectedExcerptCount: { type: "integer", dataClass: "count", required: false },
199
+ contextSelectedExcerptEstimatedTokens: { type: "integer", dataClass: "count", required: false },
200
+ contextBudgetPressure: {
201
+ type: "string",
202
+ dataClass: "closed-enum",
203
+ required: false,
204
+ values: ["low", "moderate", "high", "exceeded"],
205
+ },
206
+ contextRecencyLayoutApplied: { type: "boolean", dataClass: "closed-enum", required: false },
111
207
  omittedCount: { type: "integer", dataClass: "count", required: false },
112
208
  uncertaintyCount: { type: "integer", dataClass: "count", required: false },
113
209
  scopeIncompleteUncertaintyCount: { type: "integer", dataClass: "count", required: false },
@@ -125,8 +221,16 @@ const SEARCH_CONNECTED_CONTEXT_COMPLETED_OPERATION = defineActivityLogOperation(
125
221
  type: "string-array",
126
222
  dataClass: "closed-enum",
127
223
  required: false,
128
- maxItems: 5,
129
- values: ["aborted", "file-cap", "match-cap", "timeout", "depth-pruned"],
224
+ maxItems: 7,
225
+ values: [
226
+ "aborted",
227
+ "file-cap",
228
+ "match-cap",
229
+ "timeout",
230
+ "depth-pruned",
231
+ "io-error",
232
+ "unrepresentable-path",
233
+ ],
130
234
  },
131
235
  coverageFilesDiscovered: { type: "integer", dataClass: "count", required: false },
132
236
  coverageFilesScanned: { type: "integer", dataClass: "count", required: false },
@@ -144,6 +248,7 @@ const SEARCH_CONNECTED_CONTEXT_COMPLETED_OPERATION = defineActivityLogOperation(
144
248
  completeness: { type: "string", dataClass: "completeness-state", required: true },
145
249
  loss: { type: "string", dataClass: "loss-state", required: true },
146
250
  },
251
+ diagnosticWhen: [{ field: "activityDetailStatus", values: ["unavailable"] }],
147
252
  causal: "correlation",
148
253
  lifecycle: "end",
149
254
  analyzerProjection: "timeline",
@@ -167,6 +272,26 @@ const SEARCH_CONNECTED_CONTEXT_COMPLETION_DETAILS_OPERATION = defineActivityLogO
167
272
  required: true,
168
273
  values: ["complete", "unavailable"],
169
274
  },
275
+ excerptOmittedRangeCount: { type: "integer", dataClass: "count", required: false },
276
+ excerptTruncatedWindowCount: { type: "integer", dataClass: "count", required: false },
277
+ excerptUnreadFileCount: { type: "integer", dataClass: "count", required: false },
278
+ excerptStopReasons: {
279
+ type: "string-array",
280
+ dataClass: "closed-enum",
281
+ required: false,
282
+ maxItems: 3,
283
+ values: ["file-grant", "byte-grant", "deadline"],
284
+ },
285
+ scopeContextState: {
286
+ type: "string",
287
+ dataClass: "closed-enum",
288
+ required: false,
289
+ values: ["applied", "empty", "overflow", "incomplete-traversal", "gate-refused"],
290
+ },
291
+ scopeContextObservedFileCount: { type: "integer", dataClass: "count", required: false },
292
+ scopeContextRetainedFileCount: { type: "integer", dataClass: "count", required: false },
293
+ scopeContextChargedBytes: { type: "integer", dataClass: "count", required: false },
294
+ scopeContextCapacityBytes: { type: "integer", dataClass: "count", required: false },
170
295
  structuralContextCount: { type: "integer", dataClass: "count", required: false },
171
296
  structuralCandidateInventoryBuildCount: {
172
297
  type: "integer",
@@ -194,6 +319,7 @@ const SEARCH_CONNECTED_CONTEXT_COMPLETION_DETAILS_OPERATION = defineActivityLogO
194
319
  values: [
195
320
  "not-evaluated",
196
321
  "unused",
322
+ "live-scan",
197
323
  "live-fallback",
198
324
  "persistent-cold",
199
325
  "persistent-warm",
@@ -221,6 +347,7 @@ const SEARCH_CONNECTED_CONTEXT_COMPLETION_DETAILS_OPERATION = defineActivityLogO
221
347
  indexSearchCount: { type: "integer", dataClass: "count", required: false },
222
348
  indexReportCount: { type: "integer", dataClass: "count", required: false },
223
349
  indexFallbackSearchCount: { type: "integer", dataClass: "count", required: false },
350
+ indexBypassedSearchCount: { type: "integer", dataClass: "count", required: false },
224
351
  indexLoadFailures: { type: "integer", dataClass: "count", required: false },
225
352
  indexSaveFailures: { type: "integer", dataClass: "count", required: false },
226
353
  workspaceIoReadDirCalls: { type: "integer", dataClass: "count", required: false },
@@ -233,6 +360,7 @@ const SEARCH_CONNECTED_CONTEXT_COMPLETION_DETAILS_OPERATION = defineActivityLogO
233
360
  completeness: { type: "string", dataClass: "completeness-state", required: true },
234
361
  loss: { type: "string", dataClass: "loss-state", required: true },
235
362
  },
363
+ diagnosticWhen: [{ field: "activityDetailStatus", values: ["unavailable"] }],
236
364
  causal: "correlation",
237
365
  lifecycle: "state",
238
366
  analyzerProjection: "timeline",
@@ -240,6 +368,169 @@ const SEARCH_CONNECTED_CONTEXT_COMPLETION_DETAILS_OPERATION = defineActivityLogO
240
368
  proofIds: ["search.connected-context.completion-details.line"],
241
369
  releaseImpact: "patch",
242
370
  });
371
+ const SEARCH_CONNECTED_CONTEXT_SOURCE_DETAILS_OPERATION = defineActivityLogOperation({
372
+ contractKind: "activity-log-operation",
373
+ schemaVersion: 1,
374
+ op: "search.connected-context.source-details",
375
+ category: "search",
376
+ owner: "keiko-server",
377
+ emitter: "grounded-orchestrator.createConnectedContextActivity.sourceDetails",
378
+ fields: {
379
+ scopeIdentitySha256: { type: "string", dataClass: "digest", required: true, maxLength: 64 },
380
+ queryIdentitySha256: { type: "string", dataClass: "digest", required: true, maxLength: 64 },
381
+ activityDetailStatus: {
382
+ type: "string",
383
+ dataClass: "closed-enum",
384
+ required: true,
385
+ values: ["complete", "unavailable"],
386
+ },
387
+ directEvidenceLookup: { type: "boolean", dataClass: "closed-enum", required: false },
388
+ unrepresentablePathCount: { type: "integer", dataClass: "count", required: false },
389
+ reusedEvidenceAtomCount: { type: "integer", dataClass: "count", required: false },
390
+ semanticProviderDisposition: {
391
+ type: "string",
392
+ dataClass: "closed-enum",
393
+ required: false,
394
+ values: ["not-evaluated", "unavailable", "suppressed", "not-used", "used", "rejected"],
395
+ },
396
+ semanticProviderCallCount: { type: "integer", dataClass: "count", required: false },
397
+ overviewListingFallback: {
398
+ type: "string",
399
+ dataClass: "closed-enum",
400
+ required: false,
401
+ values: ["not-evaluated", "not-needed", "used", "skipped-budget", "skipped-stopped"],
402
+ },
403
+ semanticRejectedAtomCount: { type: "integer", dataClass: "count", required: false },
404
+ primaryContentPathCount: { type: "integer", dataClass: "count", required: false },
405
+ metadataUnavailableInspectionCount: { type: "integer", dataClass: "count", required: false },
406
+ metadataObservedCount: { type: "integer", dataClass: "count", required: false },
407
+ metadataRetainedCount: { type: "integer", dataClass: "count", required: false },
408
+ metadataDiscardedCount: { type: "integer", dataClass: "count", required: false },
409
+ metadataOmittedDetailCount: { type: "integer", dataClass: "count", required: false },
410
+ metadataRetentionLimit: { type: "integer", dataClass: "count", required: false },
411
+ omittedDetailRetainedCount: { type: "integer", dataClass: "count", required: false },
412
+ omittedDetailsClipped: { type: "boolean", dataClass: "closed-enum", required: false },
413
+ omittedOutsideScopeCount: { type: "integer", dataClass: "count", required: false },
414
+ omittedBinaryCount: { type: "integer", dataClass: "count", required: false },
415
+ omittedGeneratedCount: { type: "integer", dataClass: "count", required: false },
416
+ omittedIgnoredCount: { type: "integer", dataClass: "count", required: false },
417
+ omittedSizeExceededCount: { type: "integer", dataClass: "count", required: false },
418
+ omittedNearDuplicateCount: { type: "integer", dataClass: "count", required: false },
419
+ omittedLowRelevanceCount: { type: "integer", dataClass: "count", required: false },
420
+ omittedRedactedOnlyCount: { type: "integer", dataClass: "count", required: false },
421
+ omittedBudgetExhaustedCount: { type: "integer", dataClass: "count", required: false },
422
+ omittedToolUnavailableCount: { type: "integer", dataClass: "count", required: false },
423
+ omittedUnsupportedFormatCount: { type: "integer", dataClass: "count", required: false },
424
+ omittedNoTextLayerCount: { type: "integer", dataClass: "count", required: false },
425
+ omittedMalformedDocumentCount: { type: "integer", dataClass: "count", required: false },
426
+ omittedEncryptedDocumentCount: { type: "integer", dataClass: "count", required: false },
427
+ completeness: { type: "string", dataClass: "completeness-state", required: true },
428
+ loss: { type: "string", dataClass: "loss-state", required: true },
429
+ },
430
+ diagnosticWhen: [
431
+ { field: "activityDetailStatus", values: ["unavailable"] },
432
+ { field: "semanticRejectedAtomCount", positive: true },
433
+ { field: "unrepresentablePathCount", positive: true },
434
+ { field: "metadataUnavailableInspectionCount", positive: true },
435
+ ],
436
+ causal: "correlation",
437
+ lifecycle: "state",
438
+ analyzerProjection: "timeline",
439
+ failureClasses: ["connected-context-retrieval"],
440
+ proofIds: ["search.connected-context.source-details.line"],
441
+ releaseImpact: "patch",
442
+ });
443
+ const SEARCH_METADATA_UNAVAILABLE_OPERATION = defineActivityLogOperation({
444
+ contractKind: "activity-log-operation",
445
+ schemaVersion: 1,
446
+ op: "search.connected-context.metadata-unavailable",
447
+ category: "search",
448
+ owner: "keiko-server",
449
+ emitter: "grounded-orchestrator.createConnectedContextActivity.metadataUnavailable",
450
+ fields: {
451
+ scopeIdentitySha256: { type: "string", dataClass: "digest", required: true, maxLength: 64 },
452
+ queryIdentitySha256: { type: "string", dataClass: "digest", required: true, maxLength: 64 },
453
+ scopePathDigest: { type: "string", dataClass: "digest", required: true, maxLength: 64 },
454
+ reason: {
455
+ type: "string",
456
+ dataClass: "closed-enum",
457
+ required: true,
458
+ values: [
459
+ "permission-denied",
460
+ "filesystem-unavailable",
461
+ "containment-denied",
462
+ "directory-changed",
463
+ "streaming-unavailable",
464
+ "deadline",
465
+ "unexpected",
466
+ ],
467
+ },
468
+ failureKind: { type: "string", dataClass: "error-kind", required: true, maxLength: 64 },
469
+ frames: {
470
+ type: "string-array",
471
+ dataClass: "safe-platform-class",
472
+ required: false,
473
+ maxLength: 512,
474
+ maxItems: 8,
475
+ },
476
+ causeChain: {
477
+ type: "string-array",
478
+ dataClass: "error-kind",
479
+ required: false,
480
+ maxLength: 128,
481
+ maxItems: 5,
482
+ },
483
+ completeness: { type: "string", dataClass: "completeness-state", required: true },
484
+ loss: { type: "string", dataClass: "loss-state", required: true },
485
+ },
486
+ causal: "correlation",
487
+ lifecycle: "state",
488
+ analyzerProjection: "failure-cluster",
489
+ failureClasses: ["connected-context-retrieval"],
490
+ proofIds: ["search.connected-context.metadata-unavailable.line"],
491
+ releaseImpact: "patch",
492
+ });
493
+ const SEARCH_CONNECTED_CONTEXT_CLARIFICATION_OPERATION = defineActivityLogOperation({
494
+ contractKind: "activity-log-operation",
495
+ schemaVersion: 1,
496
+ op: "search.connected-context.clarification-needed",
497
+ category: "search",
498
+ owner: "keiko-server",
499
+ emitter: "grounded-orchestrator.createConnectedContextActivity.clarification",
500
+ fields: {
501
+ scopeIdentitySha256: { type: "string", dataClass: "digest", required: true, maxLength: 64 },
502
+ queryIdentitySha256: { type: "string", dataClass: "digest", required: true, maxLength: 64 },
503
+ clarificationReason: {
504
+ type: "string",
505
+ dataClass: "closed-enum",
506
+ required: true,
507
+ values: ["no-anchors", "too-generic", "scope-empty", "scope-invalid"],
508
+ },
509
+ retrievalIntent: {
510
+ type: "string",
511
+ dataClass: "closed-enum",
512
+ required: true,
513
+ values: [
514
+ "project-metadata",
515
+ "repository-overview",
516
+ "targeted-code-search",
517
+ "diagnostic-search",
518
+ "clarification-needed",
519
+ ],
520
+ },
521
+ directEvidenceLookup: { type: "boolean", dataClass: "closed-enum", required: true },
522
+ anchorCount: { type: "integer", dataClass: "count", required: true },
523
+ plannedRingCount: { type: "integer", dataClass: "count", required: true },
524
+ completeness: { type: "string", dataClass: "completeness-state", required: true },
525
+ loss: { type: "string", dataClass: "loss-state", required: true },
526
+ },
527
+ causal: "correlation",
528
+ lifecycle: "end",
529
+ analyzerProjection: "timeline",
530
+ failureClasses: ["connected-context-retrieval"],
531
+ proofIds: ["search.connected-context.clarification-needed.line"],
532
+ releaseImpact: "patch",
533
+ });
243
534
  const SEARCH_CONNECTED_CONTEXT_FAILED_OPERATION = defineActivityLogOperation({
244
535
  contractKind: "activity-log-operation",
245
536
  schemaVersion: 1,
@@ -276,6 +567,7 @@ const SEARCH_CONNECTED_CONTEXT_FAILED_OPERATION = defineActivityLogOperation({
276
567
  "ring-retrieval",
277
568
  "pack-assembly",
278
569
  "empty-pack-assembly",
570
+ "directory-cleanup",
279
571
  ],
280
572
  },
281
573
  plannedRingCount: { type: "integer", dataClass: "count", required: true },
@@ -302,6 +594,7 @@ const SEARCH_CONNECTED_CONTEXT_FAILED_OPERATION = defineActivityLogOperation({
302
594
  values: [
303
595
  "not-evaluated",
304
596
  "unused",
597
+ "live-scan",
305
598
  "live-fallback",
306
599
  "persistent-cold",
307
600
  "persistent-warm",
@@ -329,6 +622,7 @@ const SEARCH_CONNECTED_CONTEXT_FAILED_OPERATION = defineActivityLogOperation({
329
622
  indexSearchCount: { type: "integer", dataClass: "count", required: true },
330
623
  indexReportCount: { type: "integer", dataClass: "count", required: true },
331
624
  indexFallbackSearchCount: { type: "integer", dataClass: "count", required: true },
625
+ indexBypassedSearchCount: { type: "integer", dataClass: "count", required: true },
332
626
  indexLoadFailures: { type: "integer", dataClass: "count", required: true },
333
627
  indexSaveFailures: { type: "integer", dataClass: "count", required: true },
334
628
  workspaceIoReadDirCalls: { type: "integer", dataClass: "count", required: true },
@@ -338,6 +632,21 @@ const SEARCH_CONNECTED_CONTEXT_FAILED_OPERATION = defineActivityLogOperation({
338
632
  workspaceIoExistsCalls: { type: "integer", dataClass: "count", required: true },
339
633
  workspaceIoContentReadCalls: { type: "integer", dataClass: "count", required: true },
340
634
  workspaceIoContentReadBytes: { type: "integer", dataClass: "count", required: true },
635
+ directoryCleanupPendingCount: { type: "integer", dataClass: "count", required: false },
636
+ secondaryFailureCount: { type: "integer", dataClass: "count", required: false },
637
+ secondaryFailureKinds: {
638
+ type: "string-array",
639
+ dataClass: "error-kind",
640
+ required: false,
641
+ maxLength: 128,
642
+ maxItems: 16,
643
+ },
644
+ primaryFailureScopeDigest: {
645
+ type: "string",
646
+ dataClass: "digest",
647
+ required: false,
648
+ maxLength: 64,
649
+ },
341
650
  frames: {
342
651
  type: "string-array",
343
652
  dataClass: "safe-platform-class",
@@ -395,6 +704,15 @@ export function clarificationUserMessage(error) {
395
704
  const exampleText = examples.length > 0 ? ` Zum Beispiel: ${quotedExamples}` : "";
396
705
  return `${intro}${anchorHint}${exampleText}`;
397
706
  }
707
+ function emptySourceDecision(disposition) {
708
+ return {
709
+ overviewListingFallback: "not-evaluated",
710
+ semanticProviderDisposition: disposition,
711
+ semanticProviderCallCount: 0,
712
+ semanticRejectedAtomCount: 0,
713
+ primaryContentPathCount: 0,
714
+ };
715
+ }
398
716
  function searchLimitsKey(limits) {
399
717
  return JSON.stringify([
400
718
  limits.maxFilesScanned,
@@ -432,6 +750,7 @@ function emptyWorkspaceIndexActivityCounters() {
432
750
  searchCount: 0,
433
751
  reportCount: 0,
434
752
  fallbackSearchCount: 0,
753
+ bypassedSearchCount: 0,
435
754
  loadAttempts: 0,
436
755
  loadHits: 0,
437
756
  loadMisses: 0,
@@ -452,7 +771,11 @@ function addWorkspaceIndexResult(counters, result) {
452
771
  counters.searchCount += 1;
453
772
  const report = result.workspaceIndex;
454
773
  if (report === undefined) {
455
- if (!stoppedBeforeWorkspaceScan(result))
774
+ if (stoppedBeforeWorkspaceScan(result))
775
+ return;
776
+ if (result.coverage.limits.maxFilesScanned === null)
777
+ counters.bypassedSearchCount += 1;
778
+ else
456
779
  counters.fallbackSearchCount += 1;
457
780
  return;
458
781
  }
@@ -471,14 +794,18 @@ function workspaceIndexPersistenceSucceeded(providerStatus, counters) {
471
794
  return false;
472
795
  return counters.loadHits > 0 || counters.saveSuccesses > 0;
473
796
  }
797
+ function unindexedWorkspaceSearchMode(counters) {
798
+ if (counters.fallbackSearchCount > 0)
799
+ return "live-fallback";
800
+ return counters.bypassedSearchCount > 0 ? "live-scan" : "unused";
801
+ }
474
802
  function workspaceIndexSearchMode(providerStatus, counters) {
475
803
  if (providerStatus === "not-evaluated")
476
804
  return "not-evaluated";
477
805
  if (counters.searchCount === 0)
478
806
  return "unused";
479
- if (counters.reportCount === 0) {
480
- return counters.fallbackSearchCount > 0 ? "live-fallback" : "unused";
481
- }
807
+ if (counters.reportCount === 0)
808
+ return unindexedWorkspaceSearchMode(counters);
482
809
  const reconciled = counters.staleRecords + counters.deletedEntries + counters.droppedRecords > 0;
483
810
  const persistent = workspaceIndexPersistenceSucceeded(providerStatus, counters);
484
811
  if (reconciled)
@@ -507,7 +834,9 @@ function workspaceIndexSaveStatus(counters) {
507
834
  }
508
835
  function workspaceIndexActivityDiagnostics(providerStatus, counters) {
509
836
  return {
510
- providerStatus,
837
+ providerStatus: counters.reportCount + counters.loadAttempts + counters.saveAttempts > 0
838
+ ? providerStatus
839
+ : "not-evaluated",
511
840
  searchMode: workspaceIndexSearchMode(providerStatus, counters),
512
841
  loadStatus: workspaceIndexLoadStatus(counters),
513
842
  saveStatus: workspaceIndexSaveStatus(counters),
@@ -566,6 +895,7 @@ function observedStructuralContext(context, activity) {
566
895
  importGraph: context.importGraph.bind(context),
567
896
  endpointContractGraph: context.endpointContractGraph.bind(context),
568
897
  findFiles: context.findFiles.bind(context),
898
+ findFilesBatch: context.findFilesBatch.bind(context),
569
899
  searchText: async (query, limits, deps) => {
570
900
  const result = await context.searchText(query, limits, deps);
571
901
  activity.recordSearchResult(result);
@@ -617,6 +947,24 @@ function toPackDiagnostics(result) {
617
947
  ...coverageDiagnostics,
618
948
  };
619
949
  }
950
+ function onlyRetainedMatchesLimited(coverage) {
951
+ return (coverage.reasons.length === 1 &&
952
+ coverage.reasons[0] === "match-cap" &&
953
+ coverage.filesScanned === coverage.filesAfterPolicy &&
954
+ coverage.depthPrunedByDiscovery === 0 &&
955
+ coverage.maxFilesPrunedByDiscovery === 0);
956
+ }
957
+ function discoveryCoverageMarker(subject, coverage, details, nowMs) {
958
+ const retainedMatchesLimited = onlyRetainedMatchesLimited(coverage);
959
+ return {
960
+ kind: retainedMatchesLimited ? "budget-clipped" : "scope-incomplete",
961
+ claim: retainedMatchesLimited
962
+ ? `${subject}: all eligible files were searched; additional matching results were omitted from retained evidence (${details}); missing retained evidence does not prove a file or fact absent`
963
+ : `${subject} coverage was incomplete (${details}); relevant files may be missing from the context pack`,
964
+ impactedAtomIds: [],
965
+ emittedAtMs: nowMs,
966
+ };
967
+ }
620
968
  function coverageUncertainty(result, nowMs) {
621
969
  const coverage = result.coverage;
622
970
  if (!coverage.incomplete) {
@@ -635,17 +983,11 @@ function coverageUncertainty(result, nowMs) {
635
983
  `low-value-rescue-scanned ${String(coverage.lowValueRescueFilesScanned ?? 0)}`,
636
984
  `ignored ${String(coverage.ignoredByDiscovery)}`,
637
985
  `denied ${String(coverage.deniedByDiscovery)}`,
986
+ `unrepresentable entries ${String(coverage.unrepresentablePathsByDiscovery ?? 0)}`,
638
987
  `depth-pruned ${String(coverage.depthPrunedByDiscovery)}`,
639
988
  `max-files-pruned ${String(coverage.maxFilesPrunedByDiscovery)}`,
640
989
  ].join(", ");
641
- return [
642
- {
643
- kind: "scope-incomplete",
644
- claim: `repository search coverage was incomplete (${details}); relevant files may be missing from the context pack`,
645
- impactedAtomIds: [],
646
- emittedAtMs: nowMs,
647
- },
648
- ];
990
+ return [discoveryCoverageMarker("repository search", coverage, details, nowMs)];
649
991
  }
650
992
  function throwIfCancelled(signal) {
651
993
  if (signal?.aborted === true) {
@@ -670,11 +1012,11 @@ function usageDelta(overrides = {}) {
670
1012
  function clampUsageToBudget(usage, budget) {
671
1013
  return {
672
1014
  searchCalls: Math.min(usage.searchCalls, budget.searchCallsMax),
673
- filesRead: Math.min(usage.filesRead, budget.filesReadMax),
1015
+ filesRead: Math.min(usage.filesRead, budget.filesReadMax ?? Number.POSITIVE_INFINITY),
674
1016
  excerptBytes: Math.min(usage.excerptBytes, budget.excerptBytesMax),
675
1017
  modelInputTokens: Math.min(usage.modelInputTokens, budget.modelInputTokensMax),
676
1018
  modelOutputTokens: Math.min(usage.modelOutputTokens, budget.modelOutputTokensMax),
677
- elapsedMs: Math.min(usage.elapsedMs, budget.elapsedMsMax),
1019
+ elapsedMs: Math.min(usage.elapsedMs, budget.elapsedMsMax ?? Number.POSITIVE_INFINITY),
678
1020
  rerankCalls: Math.min(usage.rerankCalls, budget.rerankCallsMax),
679
1021
  };
680
1022
  }
@@ -710,7 +1052,7 @@ function toolUnavailable(claim, nowMs) {
710
1052
  }
711
1053
  function readBudgetStopReason(budget) {
712
1054
  const exhausted = [
713
- ...(budget.filesReadMax <= 0 ? ["filesRead"] : []),
1055
+ ...(budget.filesReadMax !== null && budget.filesReadMax <= 0 ? ["filesRead"] : []),
714
1056
  ...(budget.excerptBytesMax <= 0 ? ["excerptBytes"] : []),
715
1057
  ];
716
1058
  if (exhausted.length === 0) {
@@ -979,33 +1321,318 @@ function dedupeAtoms(atoms, cap) {
979
1321
  }
980
1322
  return out;
981
1323
  }
982
- async function runLexicalRing(ring, inputs) {
983
- const definitionSymbol = directDefinitionSymbol(inputs.query, inputs.anchors);
984
- const query = definitionSymbol === undefined
985
- ? inputs.query
986
- : { ...inputs.query, kind: "exact-symbol", text: definitionSymbol };
987
- const result = await searchText(inputs.searchScope, query, ring.searchLimits, {
1324
+ function primaryLexicalAnchors(query, anchors, retrievalIntent, decision = resolveQueryTargetDecision(query, anchors)) {
1325
+ if (query.kind !== "natural-language" || retrievalIntent === "repository-overview")
1326
+ return [];
1327
+ if (decision.kind === "contextual" &&
1328
+ (retrievalIntent === "diagnostic-search" ||
1329
+ requiresRelationshipOrHistoryRings(query) ||
1330
+ anchors.some((anchor) => anchor.kind === "path" ||
1331
+ (anchor.kind === "identifier" && /(?:Test|Tests|Spec)$/iu.test(anchor.term)))))
1332
+ return [];
1333
+ const sourceTerms = originalQueryAnchorTerms(query);
1334
+ return decision.targets.filter((anchor) => anchor.kind === "quoted" || sourceTerms.has(anchor.term));
1335
+ }
1336
+ function originalQueryAnchorTerms(query) {
1337
+ const originalText = query.text.toLowerCase();
1338
+ const words = query.text
1339
+ .toLowerCase()
1340
+ .split(/[^\p{L}\p{N}_.$-]+/u)
1341
+ .map(trimAnchorEdgeDots);
1342
+ // Preserve punctuation inside code quotes only when it occurs in the original text. Canonical
1343
+ // technical routing aliases cannot create an exact literal absent from the human's query.
1344
+ const original = extractAnchors({ text: query.text, maxAnchors: query.text.length }).anchors;
1345
+ return new Set([
1346
+ ...words,
1347
+ ...original
1348
+ .filter((anchor) => anchor.kind === "identifier" && originalText.includes(anchor.term))
1349
+ .map((anchor) => anchor.term),
1350
+ ]);
1351
+ }
1352
+ function trimAnchorEdgeDots(value) {
1353
+ let start = 0;
1354
+ let end = value.length;
1355
+ while (start < end && value[start] === ".")
1356
+ start += 1;
1357
+ while (start < end && value[end - 1] === ".")
1358
+ end -= 1;
1359
+ return value.slice(start, end);
1360
+ }
1361
+ function lexicalSourceSpellings(query, anchors) {
1362
+ if (!query.caseSensitive || query.kind !== "natural-language") {
1363
+ return anchors.map((anchor) => anchor.term);
1364
+ }
1365
+ const selected = new Set(anchors.map((anchor) => anchor.term));
1366
+ return extractAnchors({
1367
+ text: query.text,
1368
+ maxAnchors: query.text.length,
1369
+ caseSensitive: true,
1370
+ })
1371
+ .anchors.filter((anchor) => selected.has(anchor.term.toLowerCase()))
1372
+ .map((anchor) => anchor.term);
1373
+ }
1374
+ function anchoredLexicalTargets(inputs) {
1375
+ const anchors = primaryLexicalAnchors(inputs.query, inputs.anchors, inputs.retrievalIntent, inputs.targetDecision);
1376
+ return lexicalSourceSpellings(inputs.query, anchors);
1377
+ }
1378
+ function lexicalDefinitionSymbol(inputs) {
1379
+ const symbol = inputs.targetDecision.definitionSymbol;
1380
+ if (symbol === undefined || !inputs.query.caseSensitive)
1381
+ return symbol;
1382
+ const spellings = lexicalSourceSpellings(inputs.query, inputs.targetDecision.targets.filter((anchor) => anchor.term === symbol));
1383
+ return spellings.length === 1 ? spellings[0] : undefined;
1384
+ }
1385
+ function primaryContentPaths(rings) {
1386
+ // Capture provenance directly at the lexical producer, before later augmentation adds atoms.
1387
+ return certifiedContentPaths(rings.atoms, rings.primaryContentIdentities ?? []);
1388
+ }
1389
+ function certifiedLexicalContent(result, inputs) {
1390
+ const literal = !requiresRelationshipOrHistoryRings(inputs.query) &&
1391
+ (anchoredLexicalTargets(inputs).length > 0 ||
1392
+ inputs.targetDecision.definitionSymbol !== undefined ||
1393
+ inputs.query.kind === "exact-symbol");
1394
+ return result.atoms
1395
+ .filter((atom) => ((literal &&
1396
+ atom.provenance.kind === "lexical-search" &&
1397
+ atom.provenance.tool === "repo.searchText") ||
1398
+ (atom.provenance.kind === "file-listing" && atom.provenance.tool === "repo.findFiles")) &&
1399
+ atom.lineRange !== undefined)
1400
+ .map((atom) => ({
1401
+ stableId: atom.stableId,
1402
+ queryFingerprint: atom.provenance.queryFingerprint,
1403
+ }));
1404
+ }
1405
+ function primaryRankingAnchors(input, plan) {
1406
+ const anchors = [
1407
+ ...new Map([...plan.anchors, ...(plan.targetDecision?.targets ?? [])].map((anchor) => [
1408
+ `${anchor.kind}:${anchor.term}`,
1409
+ anchor,
1410
+ ])).values(),
1411
+ ];
1412
+ const targets = new Set(primaryLexicalAnchors(input.query, anchors, plan.retrievalIntent, plan.targetDecision).map((anchor) => anchor.term));
1413
+ return targets.size === 0 || requiresRelationshipOrHistoryRings(input.query)
1414
+ ? anchors
1415
+ : anchors.filter((anchor) => targets.has(anchor.term) || anchor.kind !== "literal" || !/^\d+$/u.test(anchor.term));
1416
+ }
1417
+ function lexicalSemanticProvider(inputs) {
1418
+ if (inputs.targetDecision.kind === "contextual")
1419
+ return inputs.repoSemanticSearchProvider;
1420
+ if (inputs.targetDecision.kind === "literal-search" ||
1421
+ inputs.targetDecision.definitionSymbol !== undefined ||
1422
+ isDirectEvidenceLookup(inputs.query, inputs.anchors, inputs.targetDecision))
1423
+ return undefined;
1424
+ return inputs.targetDecision.targets.some((anchor) => anchor.kind === "quoted")
1425
+ ? undefined
1426
+ : inputs.repoSemanticSearchProvider;
1427
+ }
1428
+ function lexicalSearchOptions(inputs) {
1429
+ return {
988
1430
  fs: inputs.fs,
989
1431
  nowMs: inputs.nowMs,
990
1432
  deadlineAtMs: inputs.deadlineAtMs,
991
- searchHints: { retrievalIntent: inputs.retrievalIntent },
1433
+ searchHints: { retrievalIntent: inputs.retrievalIntent, allowSourceInspection: true },
992
1434
  ...(inputs.signal === undefined ? {} : { signal: inputs.signal }),
1435
+ };
1436
+ }
1437
+ function lexicalQuery(inputs, terms, symbol) {
1438
+ if (symbol !== undefined)
1439
+ return { ...inputs.query, kind: "exact-symbol", text: symbol };
1440
+ return {
1441
+ ...inputs.query,
1442
+ text: terms.length === 0 || inputs.targetDecision.kind === "contextual"
1443
+ ? inputs.query.text
1444
+ : terms.join(" "),
1445
+ };
1446
+ }
1447
+ function observedLexicalSemanticProvider(inputs, observation) {
1448
+ const provider = lexicalSemanticProvider(inputs);
1449
+ if (provider === undefined) {
1450
+ observation.semanticProviderDisposition =
1451
+ inputs.repoSemanticSearchProvider === undefined ? "unavailable" : "suppressed";
1452
+ return undefined;
1453
+ }
1454
+ return {
1455
+ name: provider.name,
1456
+ search: (request) => {
1457
+ observation.semanticProviderDisposition = "used";
1458
+ observation.semanticProviderCallCount += 1;
1459
+ return provider.search(request);
1460
+ },
1461
+ };
1462
+ }
1463
+ async function searchLexicalTerms(ring, inputs) {
1464
+ const options = lexicalSearchOptions(inputs);
1465
+ const definitionSymbol = lexicalDefinitionSymbol(inputs);
1466
+ const terms = definitionSymbol === undefined ? anchoredLexicalTargets(inputs) : [];
1467
+ const query = lexicalQuery(inputs, terms, definitionSymbol);
1468
+ const sourceDecision = emptySourceDecision("not-used");
1469
+ const semanticSearchProvider = observedLexicalSemanticProvider(inputs, sourceDecision);
1470
+ const context = knownFitContextFor(inputs);
1471
+ const result = await searchText(inputs.searchScope, query, ring.searchLimits, {
1472
+ ...options,
1473
+ ...(context === undefined ? {} : { onEligibleTextFile: context.observe }),
993
1474
  ...(inputs.workspaceIndex === undefined ? {} : { workspaceIndex: inputs.workspaceIndex }),
994
- ...(definitionSymbol === undefined && inputs.repoSemanticSearchProvider !== undefined
995
- ? { semanticSearchProvider: inputs.repoSemanticSearchProvider }
1475
+ ...(terms.length === 0 ? {} : { queryInterpretation: { kind: "literal", terms } }),
1476
+ ...(semanticSearchProvider === undefined ? {} : { semanticSearchProvider }),
1477
+ });
1478
+ const readable = allowsReadableScopeContext(result.coverage);
1479
+ recordScopeContextObservation(inputs, context, readable);
1480
+ if (context === undefined || !readable)
1481
+ return { ...result, sourceDecision };
1482
+ return {
1483
+ ...result,
1484
+ sourceDecision,
1485
+ knownFitFileBytes: context.fileBytes(),
1486
+ atoms: [...result.atoms, ...context.atoms()],
1487
+ };
1488
+ }
1489
+ function allowsReadableScopeContext(coverage) {
1490
+ // Read failures leave these observed files individually verified. Keep that bounded readable
1491
+ // subset while preserving incomplete coverage; interrupted traversal cannot qualify it.
1492
+ return (!coverage.incomplete ||
1493
+ (coverage.reasons.length > 0 &&
1494
+ coverage.reasons.every((reason) => reason === "io-error" || reason === "match-cap")));
1495
+ }
1496
+ function recordScopeContextObservation(inputs, context, readable) {
1497
+ const observation = context?.observation() ?? {
1498
+ state: "gate-refused",
1499
+ observedFileCount: 0,
1500
+ retainedFileCount: 0,
1501
+ chargedBytes: 0,
1502
+ capacityBytes: inputs.scopeContextBytesMax,
1503
+ };
1504
+ inputs.observeScopeContext?.({
1505
+ ...observation,
1506
+ ...(!readable && context !== undefined && observation.state !== "overflow"
1507
+ ? { state: "incomplete-traversal", retainedFileCount: 0 }
996
1508
  : {}),
997
1509
  });
1510
+ }
1511
+ function isKnownFitSourceAnchor(anchor) {
1512
+ if (anchor.kind === "path" || anchor.kind === "quoted")
1513
+ return true;
1514
+ if (anchor.kind !== "identifier")
1515
+ return false;
1516
+ if (anchor.weight >= 0.9)
1517
+ return true;
1518
+ const intent = classifyRetrievalIntent(anchor.term);
1519
+ if (intent.intent === "project-metadata" &&
1520
+ intent.normalizedTerms.includes(anchor.term.toLowerCase()))
1521
+ return false;
1522
+ return true;
1523
+ }
1524
+ function hasKnownFitSourceTarget(inputs) {
1525
+ if (inputs.targetDecision.definitionRequested && inputs.targetDecision.kind !== "contextual")
1526
+ return true;
1527
+ // Preserve source spelling: plain technical routing hints are not independently selected
1528
+ // source symbols. Explicit paths, quotes and typed identifiers still refuse folder enrichment.
1529
+ const requested = extractAnchors({
1530
+ text: inputs.query.text,
1531
+ maxAnchors: inputs.query.text.length,
1532
+ caseSensitive: true,
1533
+ });
1534
+ return requested.anchors.some((anchor) => {
1535
+ if (anchor.kind !== "identifier" || anchor.weight >= 0.9 || /\s/u.test(anchor.term))
1536
+ return isKnownFitSourceAnchor(anchor);
1537
+ // Definition-pattern captures can be ordinary prose, not original technical selectors.
1538
+ const original = extractAnchors({ text: anchor.term, maxAnchors: 1 }).anchors[0];
1539
+ return original !== undefined && isKnownFitSourceAnchor(original);
1540
+ });
1541
+ }
1542
+ function knownFitContextFor(inputs) {
1543
+ return inputs.query.kind === "natural-language" &&
1544
+ inputs.targetDecision.kind !== "literal-search" &&
1545
+ inputs.retrievalIntent !== "diagnostic-search" &&
1546
+ !hasKnownFitSourceTarget(inputs)
1547
+ ? new KnownFitScopeContext(inputs.scopeContextBytesMax, inputs.searchScope.scopeId, projectMetadataQueryFingerprint(inputs.query), inputs.nowMs())
1548
+ : undefined;
1549
+ }
1550
+ async function lexicalRingSearch(ring, inputs) {
1551
+ const result = await searchLexicalTerms(ring, inputs);
1552
+ const decision = result.sourceDecision ?? emptySourceDecision("not-evaluated");
1553
+ decision.overviewListingFallback = overviewListingDecision(result, inputs);
1554
+ if (decision.overviewListingFallback !== "used")
1555
+ return { ...result, sourceDecision: decision };
1556
+ const listing = await findFiles(inputs.searchScope, { ...inputs.query, kind: "file-pattern", text: "**/*" }, ring.searchLimits, lexicalSearchOptions(inputs));
1557
+ return {
1558
+ ...mergeOverviewListing(result, listing),
1559
+ sourceDecision: decision,
1560
+ };
1561
+ }
1562
+ function overviewListingDecision(result, inputs) {
1563
+ if (inputs.retrievalIntent !== "repository-overview" || result.atoms.length > 0)
1564
+ return "not-needed";
1565
+ throwIfCancelled(inputs.signal);
1566
+ if (inputs.nowMs() >= inputs.deadlineAtMs ||
1567
+ result.coverage.reasons.some((reason) => reason === "timeout" || reason === "aborted"))
1568
+ return "skipped-stopped";
1569
+ return inputs.tryReserveAdditionalSearchCall?.() === true ? "used" : "skipped-budget";
1570
+ }
1571
+ function withoutNamedSemanticSubstitution(result, inputs) {
1572
+ if (inputs.targetDecision.kind === "contextual" ||
1573
+ requiresRelationshipOrHistoryRings(inputs.query) ||
1574
+ anchoredLexicalTargets(inputs).length === 0 ||
1575
+ certifiedLexicalContent(result, inputs).length > 0 ||
1576
+ result.atoms.length === 0)
1577
+ return result;
1578
+ if (result.sourceDecision !== undefined) {
1579
+ const rejected = result.atoms.filter((atom) => atom.provenance.tool.startsWith("repo.semanticSearch:")).length;
1580
+ result.sourceDecision.semanticRejectedAtomCount += rejected;
1581
+ if (rejected > 0)
1582
+ result.sourceDecision.semanticProviderDisposition = "rejected";
1583
+ }
1584
+ // An approximate concept match cannot stand in for a missing named literal. Corpus failures
1585
+ // and result truncation remain intact; only the unrelated semantic replacement is rejected.
1586
+ return {
1587
+ ...result,
1588
+ atoms: [],
1589
+ candidates: result.candidates.filter((candidate) => candidate.omitted !== undefined),
1590
+ diagnostics: result.diagnostics === undefined
1591
+ ? undefined
1592
+ : { ...result.diagnostics, rankedCandidates: [] },
1593
+ coverage: { ...result.coverage, matchesReturned: 0 },
1594
+ };
1595
+ }
1596
+ async function runLexicalRing(ring, inputs) {
1597
+ const result = withoutNamedSemanticSubstitution(await lexicalRingSearch(ring, inputs), inputs);
1598
+ const primaryContentIdentities = certifiedLexicalContent(result, inputs);
1599
+ const sourceDecision = result.sourceDecision ?? emptySourceDecision("not-evaluated");
1600
+ sourceDecision.primaryContentPathCount = certifiedContentPaths(result.atoms, primaryContentIdentities).size;
1601
+ inputs.observeSourceDecision(sourceDecision);
998
1602
  inputs.workspaceIndexActivity.recordSearchResult(result);
999
1603
  // Lexical scanning is transient: each candidate file is read to match lines, then discarded.
1000
1604
  // It does NOT consume the excerpt budget; excerpt reads are charged later by the assembler.
1001
1605
  return {
1606
+ knownFitFileBytes: result.knownFitFileBytes,
1002
1607
  atoms: result.atoms,
1608
+ primaryContentIdentities,
1003
1609
  omitted: omittedFromSearchCandidates(result.candidates, inputs.nowMs()),
1004
- uncertainty: coverageUncertainty(result, inputs.nowMs()),
1610
+ uncertainty: [
1611
+ ...coverageUncertainty(result, inputs.nowMs()),
1612
+ ...missingPrimaryContextMarker(result, inputs),
1613
+ ...(sourceDecision.overviewListingFallback === "skipped-budget"
1614
+ ? [budgetClipped("budget-exhausted on searchCalls", inputs.nowMs())]
1615
+ : []),
1616
+ ],
1005
1617
  usage: usageDelta({ elapsedMs: result.elapsedMs }),
1006
1618
  diagnostics: toPackDiagnostics(result),
1007
1619
  };
1008
1620
  }
1621
+ function missingPrimaryContextMarker(result, inputs) {
1622
+ if (inputs.targetDecision.kind !== "contextual" ||
1623
+ anchoredLexicalTargets(inputs).length === 0 ||
1624
+ !result.atoms.some((atom) => atom.provenance.tool.startsWith("repo.semanticSearch:")) ||
1625
+ result.atoms.some((atom) => atom.provenance.tool === "repo.searchText" && atom.lineRange !== undefined))
1626
+ return [];
1627
+ return [
1628
+ {
1629
+ kind: "low-confidence",
1630
+ claim: "No verified exact content match for the requested target; retained semantic evidence provides related context only.",
1631
+ impactedAtomIds: [],
1632
+ emittedAtMs: inputs.nowMs(),
1633
+ },
1634
+ ];
1635
+ }
1009
1636
  function registryForRing(ring) {
1010
1637
  // Keep the planner's ring split authoritative: the structural ring should only run the
1011
1638
  // structural adapters, while the git-history ring should only run the repo-level history
@@ -1026,12 +1653,30 @@ function registryForRing(ring) {
1026
1653
  async function runAdapterQueries(registry, ring, queries, inputs, requestContext) {
1027
1654
  if (inputs.nowMs() >= inputs.deadlineAtMs)
1028
1655
  return [];
1029
- return Promise.all(queries.map((query) => runStructuralAdapters(registry, inputs.searchScope, query, ring.searchLimits, inputs.fs, {
1656
+ const controller = new AbortController();
1657
+ const signal = parallelStageSignal(controller, inputs.signal);
1658
+ const pending = queries.map((query) => runStructuralAdapters(registry, inputs.searchScope, query, ring.searchLimits, inputs.fs, {
1030
1659
  nowMs: inputs.nowMs,
1031
1660
  deadlineAtMs: inputs.deadlineAtMs,
1032
- ...(inputs.signal === undefined ? {} : { signal: inputs.signal }),
1661
+ signal,
1033
1662
  ...(requestContext === undefined ? {} : { requestContext }),
1034
- })));
1663
+ }));
1664
+ return settleParallelStage(Promise.all(pending), pending, controller);
1665
+ }
1666
+ function parallelStageSignal(controller, parent) {
1667
+ return parent === undefined ? controller.signal : AbortSignal.any([parent, controller.signal]);
1668
+ }
1669
+ async function settleParallelStage(result, pending, controller) {
1670
+ try {
1671
+ return await result;
1672
+ }
1673
+ catch (error) {
1674
+ // Cancel stage siblings without aborting the caller's authority. Wait for admitted resources
1675
+ // to close before exposing the original failure or allowing a retry to start another walk.
1676
+ controller.abort();
1677
+ await Promise.allSettled(pending);
1678
+ throw error;
1679
+ }
1035
1680
  }
1036
1681
  async function runNonLexicalAdapters(ring, inputs) {
1037
1682
  const registry = registryForRing(ring);
@@ -1093,8 +1738,8 @@ function nonLexicalAtoms(ring, merged, gitAtoms, inputs, cap) {
1093
1738
  }), cap);
1094
1739
  }
1095
1740
  async function runNonLexicalRing(ring, inputs) {
1741
+ const startedAtMs = inputs.nowMs();
1096
1742
  const allResults = await runNonLexicalAdapters(ring, inputs);
1097
- const elapsedMs = allResults.reduce((sum, result) => sum + result.elapsedMs, 0);
1098
1743
  const cap = Math.min(ring.searchLimits.maxMatchesReturned, inputs.query.maxResults);
1099
1744
  const merged = mergeAtomsByStableId(allResults, cap);
1100
1745
  const git = await gitFileAtomsForRing(ring, inputs, cap);
@@ -1107,7 +1752,8 @@ async function runNonLexicalRing(ring, inputs) {
1107
1752
  atoms,
1108
1753
  omitted: [],
1109
1754
  uncertainty,
1110
- usage: usageDelta({ elapsedMs: elapsedMs + git.elapsedMs }),
1755
+ // Adapters run concurrently: their duration sum would double-charge the same wall time.
1756
+ usage: usageDelta({ elapsedMs: Math.max(0, Math.floor(inputs.nowMs() - startedAtMs)) }),
1111
1757
  };
1112
1758
  }
1113
1759
  async function runRing(ring, inputs) {
@@ -1175,57 +1821,199 @@ function initialBlockedRingSummary(governor, inputs) {
1175
1821
  atoms: [],
1176
1822
  omitted: [],
1177
1823
  governor: complete(governor),
1824
+ decisions: newRingDecisions(governor.plan.rings),
1178
1825
  uncertainty: [budgetClipped(reason, inputs.nowMs())],
1179
1826
  };
1180
1827
  }
1181
1828
  function elapsedDeadlineStop(governor, inputs) {
1182
1829
  if (inputs.nowMs() < inputs.deadlineAtMs)
1183
1830
  return undefined;
1184
- const remainingElapsedMs = Math.max(0, governor.plan.budget.elapsedMsMax - governor.usage.elapsedMs);
1831
+ const remainingElapsedMs = Math.max(0, (governor.plan.budget.elapsedMsMax ?? Number.POSITIVE_INFINITY) - governor.usage.elapsedMs);
1185
1832
  return {
1186
1833
  governor: applyUsage(governor, usageDelta({ elapsedMs: remainingElapsedMs })),
1187
1834
  marker: budgetClipped("budget-exhausted on elapsedMs", inputs.nowMs()),
1188
1835
  };
1189
1836
  }
1837
+ const DOCUMENT_EVIDENCE_PATH_RE = /\.(?:html?|txt|rst|adoc|xml)$/iu;
1838
+ function isCompleteExactLiteralLookup(query, diagnostics, decision) {
1839
+ const coverage = diagnostics?.coverage;
1840
+ return (decision.kind === "literal-search" &&
1841
+ coverage?.incomplete === false &&
1842
+ coverage.matchesReturned > 0 &&
1843
+ !requiresRelationshipOrHistoryRings(query) &&
1844
+ !requiresNamedDiscovery(decision));
1845
+ }
1846
+ function isOrdinaryDocumentLookup(query, hasGitMetadata, diagnostics) {
1847
+ const candidates = diagnostics?.rankedCandidates ?? [];
1848
+ return (!hasGitMetadata &&
1849
+ !requiresRelationshipOrHistoryRings(query) &&
1850
+ candidates.length > 0 &&
1851
+ candidates.every((candidate) => DOCUMENT_EVIDENCE_PATH_RE.test(candidate.scopePath)));
1852
+ }
1853
+ function isOrdinaryLiteralAbsence(query, hasGitMetadata, anchors, diagnostics) {
1854
+ const coverage = diagnostics?.coverage;
1855
+ const literalTarget = anchors.some((anchor) => anchor.kind === "quoted" || (anchor.kind === "identifier" && anchor.term.includes("_")));
1856
+ return (!hasGitMetadata &&
1857
+ literalTarget &&
1858
+ coverage?.incomplete === false &&
1859
+ coverage.matchesReturned === 0 &&
1860
+ !requiresRelationshipOrHistoryRings(query) &&
1861
+ directDefinitionSymbol(query, anchors) === undefined);
1862
+ }
1863
+ function lookupAugmentationSkipReason(query, anchors, hasGitMetadata, diagnostics, decision) {
1864
+ if (decision.kind === "contextual")
1865
+ return undefined;
1866
+ if (isCompleteExactLiteralLookup(query, diagnostics, decision))
1867
+ return "complete-exact-lookup";
1868
+ if (isOrdinaryDocumentLookup(query, hasGitMetadata, diagnostics))
1869
+ return "ordinary-document";
1870
+ if (isOrdinaryLiteralAbsence(query, hasGitMetadata, anchors, diagnostics))
1871
+ return "literal-absence";
1872
+ return undefined;
1873
+ }
1874
+ function optionalRingSkipReason(ring, inputs, evidence) {
1875
+ if (requiresRelationshipOrHistoryRings(inputs.query) || ring.kind === "lexical")
1876
+ return undefined;
1877
+ if (evidence.verifiedDefinitionContext === true)
1878
+ return "verified-target-context";
1879
+ if (hasVerifiedTargetContext(inputs.query, inputs.targetDecision, inputs.retrievalIntent, evidence))
1880
+ return "verified-target-context";
1881
+ if (inputs.targetDecision.kind !== "contextual" &&
1882
+ isCompleteExactLiteralLookup(inputs.query, evidence.diagnostics, inputs.targetDecision))
1883
+ return "complete-exact-lookup";
1884
+ if (ring.kind === "git-history")
1885
+ return inputs.hasGitMetadata ? undefined : "no-git-metadata";
1886
+ return lookupAugmentationSkipReason(inputs.query, inputs.anchors, inputs.hasGitMetadata, evidence.diagnostics, inputs.targetDecision);
1887
+ }
1888
+ function hasVerifiedTargetContext(query, decision, intent, evidence) {
1889
+ // The full contextual lexical/semantic request already ran. One certified target proves
1890
+ // presence only; it does not certify an answer or the completeness of contextual dimensions.
1891
+ return (decision.kind === "contextual" &&
1892
+ decision.targets.length === 1 &&
1893
+ !requiresNamedDiscovery(decision) &&
1894
+ intent !== "diagnostic-search" &&
1895
+ !requiresRelationshipOrHistoryRings(query) &&
1896
+ evidence.diagnostics?.coverage?.incomplete === false &&
1897
+ certifiedContentPaths(evidence.atoms, evidence.primaryContentIdentities ?? []).size > 0);
1898
+ }
1899
+ function requiresNamedDiscovery(decision) {
1900
+ return (decision.definitionRequested ||
1901
+ decision.targets.some((target) => DOCUMENT_REFERENCE_ANCHOR_RE.test(target.term)));
1902
+ }
1903
+ function reserveAvailableRing(governor, ring, inputs) {
1904
+ return elapsedDeadlineStop(governor, inputs) ?? reserveRingSearchCalls(governor, ring, inputs);
1905
+ }
1906
+ function lexicalContentIdentities(result, previous) {
1907
+ return result.primaryContentIdentities ?? previous;
1908
+ }
1909
+ function skipPlannedRing(ring, inputs, evidence, decisions) {
1910
+ const reason = optionalRingSkipReason(ring, inputs, evidence);
1911
+ if (reason === undefined)
1912
+ return false;
1913
+ decisions.skippedRingKinds.push(ring.kind);
1914
+ if (!decisions.ringSkipReasons.includes(reason))
1915
+ decisions.ringSkipReasons.push(reason);
1916
+ return true;
1917
+ }
1918
+ async function runReservedRing(ring, inputs, current, decisions) {
1919
+ const reservation = reserveAvailableRing(current, ring, inputs);
1920
+ if (reservation.marker !== undefined)
1921
+ return { governor: reservation.governor, marker: reservation.marker };
1922
+ let governor = reservation.governor;
1923
+ decisions.executedRingKinds.push(ring.kind);
1924
+ const result = await runRing(ring, {
1925
+ ...inputs,
1926
+ tryReserveAdditionalSearchCall: () => {
1927
+ if (governor.usage.searchCalls >= governor.plan.budget.searchCallsMax)
1928
+ return false;
1929
+ governor = applyUsage(governor, usageDelta({ searchCalls: 1 }));
1930
+ return true;
1931
+ },
1932
+ });
1933
+ return { governor, result };
1934
+ }
1935
+ function newRingEvidence() {
1936
+ return {
1937
+ atoms: [],
1938
+ omitted: [],
1939
+ uncertainty: [],
1940
+ diagnostics: undefined,
1941
+ primaryContentIdentities: [],
1942
+ };
1943
+ }
1944
+ function appendRingEvidence(evidence, result) {
1945
+ evidence.knownFitFileBytes ??= result.knownFitFileBytes;
1946
+ evidence.diagnostics ??= result.diagnostics;
1947
+ evidence.primaryContentIdentities = lexicalContentIdentities(result, evidence.primaryContentIdentities);
1948
+ for (const atom of result.atoms)
1949
+ evidence.atoms.push(atom);
1950
+ for (const omission of result.omitted)
1951
+ evidence.omitted.push(omission);
1952
+ for (const marker of result.uncertainty)
1953
+ evidence.uncertainty.push(marker);
1954
+ }
1955
+ function newRingDecisions(stopped = []) {
1956
+ return {
1957
+ executedRingKinds: [],
1958
+ skippedRingKinds: [],
1959
+ stoppedRingKinds: stopped.map((ring) => ring.kind),
1960
+ ringSkipReasons: [],
1961
+ augmentationDisposition: "not-reached",
1962
+ augmentationSkipped: false,
1963
+ };
1964
+ }
1965
+ function recordStoppedRings(rings, decisions) {
1966
+ for (const ring of rings) {
1967
+ if (!decisions.executedRingKinds.includes(ring.kind) &&
1968
+ !decisions.skippedRingKinds.includes(ring.kind))
1969
+ decisions.stoppedRingKinds.push(ring.kind);
1970
+ }
1971
+ }
1972
+ function declarationCoverageAllowsVerification(coverage) {
1973
+ return (coverage !== undefined &&
1974
+ coverage.filesScanned === coverage.filesAfterPolicy &&
1975
+ (!coverage.incomplete || onlyRetainedMatchesLimited(coverage)) &&
1976
+ coverage.reasons.every((reason) => reason === "match-cap"));
1977
+ }
1978
+ function shouldDiscoverDefinitionsBeforeGraphs(inputs, evidence) {
1979
+ return (evidence.symbolDiscovery === undefined &&
1980
+ inputs.targetDecision.kind === "contextual" &&
1981
+ inputs.targetDecision.definitionRequested &&
1982
+ inputs.retrievalIntent !== "diagnostic-search" &&
1983
+ !requiresRelationshipOrHistoryRings(inputs.query) &&
1984
+ declarationCoverageAllowsVerification(evidence.diagnostics?.coverage) &&
1985
+ certifiedContentPaths(evidence.atoms, evidence.primaryContentIdentities).size > 0);
1986
+ }
1190
1987
  async function runAllRings(rings, inputs, initialGovernor) {
1191
1988
  const blocked = initialBlockedRingSummary(initialGovernor, inputs);
1192
1989
  if (blocked !== undefined)
1193
1990
  return blocked;
1194
- const atoms = [];
1195
- const omitted = [];
1196
- const uncertainty = [];
1197
- // Ring order is fixed by the plan, so capturing the first lexical ring's diagnostics is
1198
- // deterministic. (There is normally exactly one lexical ring.)
1199
- let diagnostics;
1991
+ const evidence = newRingEvidence();
1200
1992
  let governor = initialGovernor;
1993
+ const decisions = newRingDecisions();
1201
1994
  for (const ring of rings) {
1202
1995
  throwIfCancelled(inputs.signal);
1203
- if (!canContinue(governor)) {
1204
- break;
1996
+ governor = await discoverRequiredDefinitionsForRing(ring, inputs, evidence, governor);
1997
+ if (skipPlannedRing(ring, inputs, evidence, decisions)) {
1998
+ governor = advanceRing(governor);
1999
+ continue;
1205
2000
  }
1206
- const deadlineStop = elapsedDeadlineStop(governor, inputs);
1207
- if (deadlineStop !== undefined) {
1208
- governor = deadlineStop.governor;
1209
- uncertainty.push(deadlineStop.marker);
2001
+ if (!canContinue(governor)) {
1210
2002
  break;
1211
2003
  }
1212
- const reservation = reserveRingSearchCalls(governor, ring, inputs);
1213
- governor = reservation.governor;
1214
- if (reservation.marker !== undefined) {
1215
- uncertainty.push(reservation.marker);
2004
+ const execution = await runReservedRing(ring, inputs, governor, decisions);
2005
+ governor = execution.governor;
2006
+ if (execution.marker !== undefined) {
2007
+ evidence.uncertainty.push(execution.marker);
1216
2008
  break;
1217
2009
  }
1218
- const result = await runRing(ring, inputs);
2010
+ const result = execution.result;
1219
2011
  throwIfCancelled(inputs.signal);
1220
- // First lexical ring wins (??= never overwrites once set); ring order is plan-fixed.
1221
- diagnostics ??= result.diagnostics;
2012
+ appendRingEvidence(evidence, result);
1222
2013
  const afterRing = applyUsage(governor, result.usage);
1223
- atoms.push(...result.atoms);
1224
- omitted.push(...result.omitted);
1225
- uncertainty.push(...result.uncertainty);
1226
2014
  if (afterRing.status === "budget-exhausted") {
1227
2015
  governor = afterRing;
1228
- uncertainty.push(budgetClipped(afterRing.stopReason ?? "budget exhausted", inputs.nowMs()));
2016
+ evidence.uncertainty.push(budgetClipped(afterRing.stopReason ?? "budget exhausted", inputs.nowMs()));
1229
2017
  break;
1230
2018
  }
1231
2019
  governor = advanceRing(afterRing);
@@ -1233,12 +2021,30 @@ async function runAllRings(rings, inputs, initialGovernor) {
1233
2021
  if (governor.status === "running") {
1234
2022
  governor = complete(governor);
1235
2023
  }
1236
- return { atoms, omitted, governor, uncertainty, diagnostics };
2024
+ recordStoppedRings(rings, decisions);
2025
+ return { ...evidence, governor, decisions };
2026
+ }
2027
+ async function discoverRequiredDefinitionsForRing(ring, inputs, evidence, governor) {
2028
+ if (ring.kind === "lexical" || !shouldDiscoverDefinitionsBeforeGraphs(inputs, evidence))
2029
+ return governor;
2030
+ const discovery = await inputs.discoverDefinitions(governor, evidence);
2031
+ throwIfCancelled(inputs.signal);
2032
+ evidence.symbolDiscovery = discovery.evidence;
2033
+ evidence.verifiedDefinitionContext = discovery.verified;
2034
+ const previousCount = evidence.atoms.length;
2035
+ const seen = new Set(evidence.atoms.map((atom) => atom.stableId));
2036
+ for (const atom of discovery.evidence.atoms)
2037
+ pushUniqueAtom(evidence.atoms, seen, atom);
2038
+ evidence.reusedEvidenceAtomCount =
2039
+ discovery.evidence.atoms.length - (evidence.atoms.length - previousCount);
2040
+ for (const marker of discovery.evidence.uncertainty)
2041
+ evidence.uncertainty.push(marker);
2042
+ return discovery.governor;
1237
2043
  }
1238
2044
  const DEFAULT_EXCERPT_WINDOW = { startLine: 1, endLine: 200 };
2045
+ const MAX_EXCERPT_WINDOW_BYTES = 8192;
1239
2046
  const SINGLE_LINE_EXCERPT_CONTEXT_LINES = 3;
1240
2047
  const DISCOVERED_DEFINITION_CONTEXT_AFTER = 24;
1241
- const MAX_EXCERPT_WINDOWS_PER_FILE = 8;
1242
2048
  const PROJECT_METADATA_QUERY_TERMS = [
1243
2049
  "abhängigkeit",
1244
2050
  "abhängigkeiten",
@@ -1308,9 +2114,7 @@ const REPOSITORY_OVERVIEW_FILENAMES = [
1308
2114
  "docs/adr/README.md",
1309
2115
  ];
1310
2116
  const WORKSPACE_PACKAGE_DIRS = ["packages", "apps", "services", "libs"];
1311
- const MAX_WORKSPACE_MANIFESTS = 24;
1312
- const WORKSPACE_MANIFEST_BYTES_MAX = 1_048_576;
1313
- const WORKSPACE_PATTERN_COUNT_MAX = 32;
2117
+ const WORKSPACE_MANIFEST_BYTES_MAX = DEFAULT_SEARCH_LIMITS.maxBytesPerFileScanned;
1314
2118
  const WORKSPACE_PATTERN_CHARS_MAX = 1_024;
1315
2119
  const SYMBOL_FILE_EXTENSIONS = [
1316
2120
  "cs",
@@ -1342,22 +2146,18 @@ const SYMBOL_FILE_EXTENSIONS = [
1342
2146
  "vue",
1343
2147
  ];
1344
2148
  const SYMBOL_FILE_EXTENSION_SET = new Set(SYMBOL_FILE_EXTENSIONS);
1345
- // Aggregate cap on firstSymbolLine reads across ALL terms in one question, so a vague code question
1346
- // on a large customer repo can never trigger an unbounded number of full-file reads even if many
1347
- // files match the symbol globs (each read also re-stats + splits the file — see firstSymbolLine).
1348
- const MAX_SYMBOL_LINE_READS = 64;
1349
2149
  const SYMBOL_FILE_MATCHES_MAX = 96;
1350
2150
  const DOCUMENT_REFERENCE_MATCHES_MAX = 8;
1351
2151
  const MAX_DOCUMENT_REFERENCE_ANCHORS = 4;
1352
2152
  const DOCUMENT_REFERENCE_ANCHOR_RE = /^(?:adr|rfc)-\d{3,6}$/u;
1353
2153
  const SYMBOL_FILE_SEARCH_LIMITS = {
1354
- maxFilesScanned: 10_000,
2154
+ maxFilesScanned: null,
1355
2155
  maxMatchesReturned: SYMBOL_FILE_MATCHES_MAX,
1356
2156
  maxBytesPerFileScanned: DEFAULT_SEARCH_LIMITS.maxBytesPerFileScanned,
1357
2157
  elapsedMsMax: DEFAULT_SEARCH_LIMITS.elapsedMsMax,
1358
2158
  };
1359
2159
  const DOCUMENT_REFERENCE_SEARCH_LIMITS = {
1360
- maxFilesScanned: 10_000,
2160
+ maxFilesScanned: null,
1361
2161
  maxMatchesReturned: DOCUMENT_REFERENCE_MATCHES_MAX,
1362
2162
  maxBytesPerFileScanned: DEFAULT_SEARCH_LIMITS.maxBytesPerFileScanned,
1363
2163
  elapsedMsMax: DEFAULT_SEARCH_LIMITS.elapsedMsMax,
@@ -1378,7 +2178,7 @@ function basename(scopePath) {
1378
2178
  return index >= 0 ? scopePath.slice(index + 1) : scopePath;
1379
2179
  }
1380
2180
  function compareByScopePath(a, b) {
1381
- return a.scopePath.localeCompare(b.scopePath);
2181
+ return compareStrings(a.scopePath, b.scopePath);
1382
2182
  }
1383
2183
  function isKeikoEvidenceArtifact(scopePath) {
1384
2184
  return scopePath.toLowerCase().startsWith(".keiko/evidence/");
@@ -1453,14 +2253,14 @@ function recordMetadataCoverageIssue(cache, issue, count = 1) {
1453
2253
  function descriptorReadExceededLimit(error) {
1454
2254
  return isRecord(error) && error.reason === "too-large";
1455
2255
  }
1456
- function readBoundedWorkspaceManifest(fs, absolutePath, cache) {
2256
+ async function readBoundedWorkspaceManifest(fs, absolutePath, cache) {
1457
2257
  try {
1458
2258
  const stat = fs.stat(absolutePath);
1459
2259
  if (!stat.isFile || stat.size > WORKSPACE_MANIFEST_BYTES_MAX) {
1460
2260
  recordMetadataCoverageIssue(cache, "workspace-manifest-byte-limit");
1461
2261
  return undefined;
1462
2262
  }
1463
- const boundedRead = fs.readFileUtf8SameDescriptor;
2263
+ const boundedRead = fs.readFileBytes;
1464
2264
  // ADR-0005 D1: a bounded lane, or no advisory metadata at all. Falling back to the unbounded
1465
2265
  // `readFileUtf8` and checking the cap afterwards materializes the entire file first, so the cap
1466
2266
  // stops bounding anything — the exact class this PR removed from the workspace read lanes.
@@ -1468,10 +2268,16 @@ function readBoundedWorkspaceManifest(fs, absolutePath, cache) {
1468
2268
  recordMetadataCoverageIssue(cache, "workspace-manifest-read-unavailable");
1469
2269
  return undefined;
1470
2270
  }
1471
- const read = boundedRead(absolutePath, WORKSPACE_MANIFEST_BYTES_MAX, "reject", stat);
1472
- return isWorkspacePathSnapshotCurrent(fs, absolutePath, absolutePath, stat)
1473
- ? read.rawText
1474
- : undefined;
2271
+ const bytes = await boundedRead.call(fs, absolutePath, WORKSPACE_MANIFEST_BYTES_MAX, "reject", stat);
2272
+ if (bytes.length !== stat.size ||
2273
+ !isWorkspacePathSnapshotCurrent(fs, absolutePath, absolutePath, stat)) {
2274
+ recordMetadataCoverageIssue(cache, "workspace-manifest-read-unavailable");
2275
+ return undefined;
2276
+ }
2277
+ const decoded = decodeTextFileBytes(bytes);
2278
+ if (decoded === undefined)
2279
+ recordMetadataCoverageIssue(cache, "workspace-manifest-shape-unsupported");
2280
+ return decoded?.text;
1475
2281
  }
1476
2282
  catch (error) {
1477
2283
  rethrowMetadataCancellation(error);
@@ -1494,9 +2300,8 @@ function workspacePatternEntries(workspaces, cache) {
1494
2300
  return undefined;
1495
2301
  }
1496
2302
  function boundedWorkspacePatterns(entries, cache) {
1497
- recordMetadataCoverageIssue(cache, "workspace-pattern-count-limit", Math.max(0, entries.length - WORKSPACE_PATTERN_COUNT_MAX));
1498
2303
  const patterns = [];
1499
- for (const entry of entries.slice(0, WORKSPACE_PATTERN_COUNT_MAX)) {
2304
+ for (const entry of entries) {
1500
2305
  if (typeof entry !== "string") {
1501
2306
  recordMetadataCoverageIssue(cache, "workspace-pattern-shape-unsupported");
1502
2307
  }
@@ -1509,7 +2314,7 @@ function boundedWorkspacePatterns(entries, cache) {
1509
2314
  }
1510
2315
  return patterns;
1511
2316
  }
1512
- function readWorkspacePatterns(searchScope, fs, control, existsCache) {
2317
+ async function readWorkspacePatterns(searchScope, fs, control, existsCache) {
1513
2318
  if (!metadataTraversalCanContinue(control))
1514
2319
  return [];
1515
2320
  if (!fileExistsInSearchScope(searchScope, fs, "package.json", existsCache)) {
@@ -1522,7 +2327,7 @@ function readWorkspacePatterns(searchScope, fs, control, existsCache) {
1522
2327
  recordMetadataCoverageIssue(existsCache, "workspace-manifest-read-unavailable");
1523
2328
  return [];
1524
2329
  }
1525
- rawText = readBoundedWorkspaceManifest(fs, contained.path, existsCache);
2330
+ rawText = await readBoundedWorkspaceManifest(fs, contained.path, existsCache);
1526
2331
  }
1527
2332
  catch (error) {
1528
2333
  rethrowMetadataCancellation(error);
@@ -1569,6 +2374,51 @@ export function normalizeWorkspacePattern(pattern) {
1569
2374
  }
1570
2375
  return normalized;
1571
2376
  }
2377
+ class MetadataDirectoryUnavailableError extends Error {
2378
+ reason;
2379
+ constructor(reason) {
2380
+ super("metadata directory inspection unavailable");
2381
+ this.reason = reason;
2382
+ this.name = "MetadataDirectoryUnavailableError";
2383
+ }
2384
+ }
2385
+ function metadataUnavailableReason(error) {
2386
+ if (error instanceof MetadataDirectoryUnavailableError)
2387
+ return error.reason;
2388
+ if (isMetadataTraversalDeadline(error))
2389
+ return "deadline";
2390
+ if (error instanceof PathEscapeError || error instanceof PathDeniedError)
2391
+ return "containment-denied";
2392
+ if (safeProperty(error, "reason") === "directory-membership-changed")
2393
+ return "directory-changed";
2394
+ const code = errorKindOf(error);
2395
+ if (code === "EACCES" || code === "EPERM")
2396
+ return "permission-denied";
2397
+ return isExpectedWorkspaceRootFailure(error) ? "filesystem-unavailable" : "unexpected";
2398
+ }
2399
+ function metadataUnavailableErrorKind(reason) {
2400
+ if (reason === "deadline")
2401
+ return "timeout";
2402
+ if (reason === "containment-denied" || reason === "permission-denied")
2403
+ return "permission-denied";
2404
+ return reason === "unexpected" ? "internal" : "unavailable";
2405
+ }
2406
+ function metadataUnavailableEvent(error, scopePath, identity, correlationId) {
2407
+ const reason = metadataUnavailableReason(error);
2408
+ const frames = keikoStackFrames(error);
2409
+ const causes = causeChain(error);
2410
+ return activityLogEvent(SEARCH_METADATA_UNAVAILABLE_OPERATION, { correlationId, errorKind: metadataUnavailableErrorKind(reason) }, {
2411
+ scopeIdentitySha256: identity.scopeIdentitySha256,
2412
+ queryIdentitySha256: identity.queryIdentitySha256,
2413
+ scopePathDigest: createHash("sha256").update(scopePath).digest("hex"),
2414
+ reason,
2415
+ failureKind: connectedContextFailureKind(error),
2416
+ ...(frames.length === 0 ? {} : { frames }),
2417
+ ...(causes.length === 0 ? {} : { causeChain: causes }),
2418
+ completeness: "partial",
2419
+ loss: "none",
2420
+ });
2421
+ }
1572
2422
  class MetadataTraversalDeadlineError extends Error {
1573
2423
  constructor() {
1574
2424
  super("project metadata traversal deadline reached");
@@ -1601,9 +2451,11 @@ function metadataTraversalOperation(control, run) {
1601
2451
  }
1602
2452
  function metadataTraversalFs(fs, control) {
1603
2453
  const descriptorRead = fs.readFileUtf8SameDescriptor;
2454
+ const byteRead = fs.readFileBytes;
1604
2455
  const canonicalRoot = fs.canonicalWorkspaceRoot;
1605
2456
  const run = (operation) => metadataTraversalOperation(control, operation);
1606
2457
  return preserveOwnedRootAuthority(fs, {
2458
+ ...(fs.iterateDirectory === undefined ? {} : { iterateDirectory: fs.iterateDirectory }),
1607
2459
  readFileUtf8: (path) => run(() => fs.readFileUtf8(path)),
1608
2460
  stat: (path) => run(() => fs.stat(path)),
1609
2461
  readDir: (path, maxEntries) => run(() => fs.readDir(path, maxEntries)),
@@ -1614,6 +2466,16 @@ function metadataTraversalFs(fs, control) {
1614
2466
  : {
1615
2467
  readFileUtf8SameDescriptor: (path, maxBytes, hardLinkPolicy, expected) => run(() => descriptorRead.call(fs, path, maxBytes, hardLinkPolicy, expected)),
1616
2468
  }),
2469
+ ...(byteRead === undefined
2470
+ ? {}
2471
+ : {
2472
+ readFileBytes: async (path, maxBytes, hardLinkPolicy, expected) => {
2473
+ assertMetadataTraversalActive(control);
2474
+ const bytes = await byteRead.call(fs, path, maxBytes, hardLinkPolicy, expected);
2475
+ assertMetadataTraversalActive(control);
2476
+ return bytes;
2477
+ },
2478
+ }),
1617
2479
  ...(canonicalRoot === undefined
1618
2480
  ? {}
1619
2481
  : {
@@ -1670,23 +2532,111 @@ function safeReadDir(searchScope, fs, scopePath, maxEntries) {
1670
2532
  return { entries: [], status: "unavailable" };
1671
2533
  }
1672
2534
  }
1673
- // Bound on how many service subdirectories under a `dir/*` pattern are scanned, so a monorepo with
1674
- // thousands of packages cannot trigger an unbounded directory fan-out (the per-result cap in the
1675
- // caller is MAX_WORKSPACE_MANIFESTS; this caps the WORK, not just the output).
1676
- const MAX_MONOREPO_SERVICE_DIRS = 96;
1677
- // Canonical project manifests of ANY ecosystem present directly inside `dir` (one bounded readDir,
1678
- // realpath-contained, no symlink following). Replaces the prior package.json-only probe so a
1679
- // polyglot monorepo surfaces service-local pom.xml / go.mod / Cargo.toml / *.csproj, not just
1680
- // JS packages. isDenied is applied even though the registry is deny-clean (defence in depth), and
1681
- // the result is sorted for deterministic evidence ordering.
1682
- function canonicalManifestScopePathsInDir(dir, searchScope, fs, maxEntries, existsCache) {
1683
- return cachedDirectoryEntries(searchScope, fs, dir, maxEntries, existsCache)
1684
- .entries.filter((entry) => !entry.isDirectory && !entry.isSymbolicLink)
1685
- .map((entry) => joinScopePath(dir, entry.name))
1686
- .filter((scopePath) => isCanonicalMetadataFile(scopePath) && !isDenied(scopePath))
1687
- .sort((a, b) => a.localeCompare(b));
1688
- }
1689
- function expandWorkspacePattern(pattern, searchScope, fs, control, existsCache) {
2535
+ function metadataDirectoryPath(searchScope, fs, scopePath) {
2536
+ if (scopePath.length > 0 && !isValidScopePath(scopePath, { mustBeRelative: true }))
2537
+ throw new MetadataDirectoryUnavailableError("containment-denied");
2538
+ const root = searchScope.workspace.root;
2539
+ const absolute = resolveWithinWorkspace(root, scopePath);
2540
+ const contained = containedRealPathInfo(fs, root, absolute);
2541
+ if (!isCanonicalAllowedContainedPath(contained, root, scopePath)) {
2542
+ if (isAllowedContainedPathParent(contained, root, scopePath) && !fs.exists(absolute))
2543
+ return undefined;
2544
+ throw new MetadataDirectoryUnavailableError("containment-denied");
2545
+ }
2546
+ const stat = fs.stat(contained.path);
2547
+ if (stat.isSymbolicLink)
2548
+ throw new MetadataDirectoryUnavailableError("containment-denied");
2549
+ return stat.isDirectory ? contained.path : undefined;
2550
+ }
2551
+ function recordUnavailableMetadataDirectory(error, scopePath, control, cache) {
2552
+ if (cache !== undefined)
2553
+ cache.unavailableDirectoryInspections += 1;
2554
+ control.recordUnavailable?.(error, scopePath);
2555
+ }
2556
+ async function visitMetadataDirectory(searchScope, fs, scopePath, control, cache, visit) {
2557
+ try {
2558
+ assertMetadataTraversalActive(control);
2559
+ const path = metadataDirectoryPath(searchScope, fs, scopePath);
2560
+ if (path === undefined)
2561
+ return true;
2562
+ const iterate = fs.iterateDirectory;
2563
+ if (iterate === undefined)
2564
+ throw new MetadataDirectoryUnavailableError("streaming-unavailable");
2565
+ for await (const entry of iterate.call(fs, path)) {
2566
+ assertMetadataTraversalActive(control);
2567
+ await visit(entry);
2568
+ }
2569
+ assertMetadataTraversalActive(control);
2570
+ if (metadataDirectoryPath(searchScope, fs, scopePath) !== path)
2571
+ throw new MetadataDirectoryUnavailableError("directory-changed");
2572
+ return true;
2573
+ }
2574
+ catch (error) {
2575
+ rethrowMetadataCancellation(error);
2576
+ recordUnavailableMetadataDirectory(error, scopePath, control, cache);
2577
+ return false;
2578
+ }
2579
+ }
2580
+ async function canonicalManifestScopePathsInDir(dir, searchScope, fs, maxResults, control, existsCache, policy = {}) {
2581
+ if (!beginMetadataDirectory(existsCache, dir, policy.rememberDirectory !== false))
2582
+ return [];
2583
+ const paths = new BoundedMetadataPaths(maxResults);
2584
+ const present = new Set();
2585
+ const complete = await visitMetadataDirectory(searchScope, fs, dir, control, existsCache, (entry) => {
2586
+ if (entry.isSymbolicLink || !entry.isFile)
2587
+ return;
2588
+ if (policy.cacheAbsentNames === true && PROJECT_METADATA_FILENAMES.includes(entry.name))
2589
+ present.add(entry.name);
2590
+ const path = joinScopePath(dir, entry.name);
2591
+ retainCanonicalMetadataPath(path, searchScope, fs, paths, existsCache);
2592
+ });
2593
+ if (complete && policy.cacheAbsentNames === true)
2594
+ cacheAbsentMetadataNames(existsCache, dir, present);
2595
+ return paths.sorted();
2596
+ }
2597
+ function beginMetadataDirectory(cache, dir, remember) {
2598
+ if (cache === undefined)
2599
+ return true;
2600
+ if (cache.metadataDirectories.has(dir))
2601
+ return false;
2602
+ if (remember && cache.metadataWildcardBases.has(dirname(dir)))
2603
+ return false;
2604
+ if (remember)
2605
+ cache.metadataDirectories.add(dir);
2606
+ return true;
2607
+ }
2608
+ function cacheAbsentMetadataNames(cache, dir, present) {
2609
+ if (cache === undefined)
2610
+ return;
2611
+ for (const name of PROJECT_METADATA_FILENAMES)
2612
+ if (!present.has(name))
2613
+ cache.files.set(joinScopePath(dir, name), false);
2614
+ }
2615
+ function isAdmittedMetadataPath(path, scope, cache) {
2616
+ if (!isValidScopePath(path, { mustBeRelative: true }) || isDenied(path))
2617
+ return false;
2618
+ if (scope.relativePaths.length === 0)
2619
+ return true;
2620
+ const selected = cache?.metadataScopePaths ?? new Set(scope.relativePaths);
2621
+ let ancestor = path;
2622
+ for (;;) {
2623
+ if (selected.has(ancestor))
2624
+ return true;
2625
+ const separator = ancestor.lastIndexOf("/");
2626
+ if (separator < 0)
2627
+ return false;
2628
+ ancestor = ancestor.slice(0, separator);
2629
+ }
2630
+ }
2631
+ function retainCanonicalMetadataPath(path, scope, fs, paths, cache) {
2632
+ if (!isCanonicalMetadataFile(path) ||
2633
+ !isAdmittedMetadataPath(path, scope, cache) ||
2634
+ !fileExistsByContainedStat(scope, fs, path))
2635
+ return;
2636
+ cache?.metadataRetention?.observe(path);
2637
+ paths.retain(path);
2638
+ }
2639
+ async function expandWorkspacePattern(pattern, searchScope, fs, control, maxResults, existsCache) {
1690
2640
  if (!metadataTraversalCanContinue(control))
1691
2641
  return [];
1692
2642
  const normalized = normalizeWorkspacePattern(pattern);
@@ -1698,60 +2648,49 @@ function expandWorkspacePattern(pattern, searchScope, fs, control, existsCache)
1698
2648
  const dir = normalized.endsWith("/package.json")
1699
2649
  ? normalized.slice(0, -"/package.json".length)
1700
2650
  : normalized;
1701
- return canonicalManifestScopePathsInDir(dir, searchScope, fs, MAX_WORKSPACE_MANIFESTS, existsCache);
2651
+ return canonicalManifestScopePathsInDir(dir, searchScope, fs, maxResults, control, existsCache);
1702
2652
  }
1703
2653
  if (!normalized.endsWith("/*") || normalized.slice(0, -2).includes("*")) {
1704
2654
  recordMetadataCoverageIssue(existsCache, "workspace-pattern-shape-unsupported");
1705
2655
  return [];
1706
2656
  }
1707
- return workspacePatternServiceManifests(normalized.slice(0, -2), searchScope, fs, control, existsCache);
2657
+ return workspacePatternServiceManifests(normalized.slice(0, -2), searchScope, fs, control, maxResults, existsCache);
1708
2658
  }
1709
- function workspacePatternServiceManifests(base, searchScope, fs, control, existsCache) {
1710
- if (!metadataTraversalCanContinue(control))
2659
+ async function workspacePatternServiceManifests(base, searchScope, fs, control, maxResults, existsCache) {
2660
+ if (existsCache?.metadataWildcardBases.has(base) === true)
1711
2661
  return [];
1712
- const serviceNames = cachedDirectoryEntries(searchScope, fs, base, MAX_MONOREPO_SERVICE_DIRS, existsCache)
1713
- .entries.filter((entry) => entry.isDirectory && !entry.isSymbolicLink)
1714
- .map((entry) => entry.name)
1715
- .sort((a, b) => a.localeCompare(b))
1716
- .slice(0, MAX_MONOREPO_SERVICE_DIRS);
1717
- const manifests = [];
1718
- for (const name of serviceNames) {
1719
- if (!metadataTraversalCanContinue(control))
1720
- break;
1721
- const remaining = MAX_WORKSPACE_MANIFESTS - manifests.length;
1722
- if (remaining <= 0)
1723
- break;
1724
- manifests.push(...canonicalManifestScopePathsInDir(joinScopePath(base, name), searchScope, fs, remaining, existsCache));
1725
- }
1726
- return manifests;
2662
+ const manifests = new BoundedMetadataPaths(maxResults);
2663
+ const complete = await visitMetadataDirectory(searchScope, fs, base, control, existsCache, async (entry) => {
2664
+ if (!entry.isDirectory || entry.isSymbolicLink)
2665
+ return;
2666
+ const dir = joinScopePath(base, entry.name);
2667
+ if (!isValidScopePath(dir, { mustBeRelative: true }) || isDenied(dir))
2668
+ return;
2669
+ for (const path of await canonicalManifestScopePathsInDir(dir, searchScope, fs, maxResults, control, existsCache, { rememberDirectory: false }))
2670
+ manifests.retain(path);
2671
+ });
2672
+ if (complete)
2673
+ existsCache?.metadataWildcardBases.add(base);
2674
+ return manifests.sorted();
1727
2675
  }
1728
- function workspacePackageManifestPaths(input, searchScope, fs, control, existsCache) {
1729
- if (input.scope.kind !== "workspace-root" || input.scope.relativePaths.length !== 0) {
2676
+ async function workspacePackageManifestPaths(input, searchScope, fs, control, maxResults, existsCache) {
2677
+ if (input.scope.kind !== "workspace-root" || input.scope.relativePaths.length !== 0)
1730
2678
  return [];
1731
- }
1732
2679
  if (!metadataTraversalCanContinue(control))
1733
2680
  return [];
1734
- const patterns = new Set(readWorkspacePatterns(searchScope, fs, control, existsCache));
1735
- for (const dir of WORKSPACE_PACKAGE_DIRS) {
2681
+ const patterns = new Set(await readWorkspacePatterns(searchScope, fs, control, existsCache));
2682
+ for (const dir of WORKSPACE_PACKAGE_DIRS)
1736
2683
  patterns.add(`${dir}/*`);
1737
- }
1738
- const paths = [];
1739
- const seen = new Set();
1740
- for (const pattern of [...patterns].sort((a, b) => a.localeCompare(b))) {
2684
+ const paths = new BoundedMetadataPaths(maxResults);
2685
+ for await (const expanded of iterateSequentialResults([...patterns].sort(compareStrings), (pattern) => metadataTraversalCanContinue(control)
2686
+ ? expandWorkspacePattern(pattern, searchScope, fs, control, maxResults, existsCache)
2687
+ : Promise.resolve([]))) {
2688
+ for (const path of expanded)
2689
+ paths.retain(path);
1741
2690
  if (!metadataTraversalCanContinue(control))
1742
2691
  break;
1743
- for (const scopePath of expandWorkspacePattern(pattern, searchScope, fs, control, existsCache)) {
1744
- if (seen.has(scopePath)) {
1745
- continue;
1746
- }
1747
- seen.add(scopePath);
1748
- paths.push(scopePath);
1749
- if (paths.length >= MAX_WORKSPACE_MANIFESTS) {
1750
- return paths;
1751
- }
1752
- }
1753
2692
  }
1754
- return paths;
2693
+ return paths.sorted();
1755
2694
  }
1756
2695
  function metadataAtom(scope, scopePath, queryFingerprint, nowMs) {
1757
2696
  return {
@@ -1817,54 +2756,52 @@ function documentReferenceAnchorTerms(plan) {
1817
2756
  .map((anchor) => anchor.term)
1818
2757
  .slice(0, MAX_DOCUMENT_REFERENCE_ANCHORS);
1819
2758
  }
1820
- function documentReferenceQuery(input, term) {
1821
- return {
1822
- kind: "file-pattern",
1823
- text: `**${term}*`,
1824
- caseSensitive: false,
1825
- maxResults: DOCUMENT_REFERENCE_MATCHES_MAX,
1826
- emittedAtMs: input.query.emittedAtMs,
1827
- };
1828
- }
1829
2759
  function documentReferenceCoverageMarker(term, coverage, nowMs) {
1830
2760
  if (!coverage.incomplete)
1831
2761
  return undefined;
1832
- return {
1833
- kind: "scope-incomplete",
1834
- claim: `Document reference discovery for "${term}" was incomplete: ` +
1835
- `reasons=${coverage.reasons.join(",")}; ` +
1836
- `filesScanned=${String(coverage.filesScanned)}, ` +
1837
- `filesSkipped=${String(coverage.filesSkipped)}, ` +
1838
- `matchesReturned=${String(coverage.matchesReturned)}.`,
1839
- impactedAtomIds: [],
1840
- emittedAtMs: nowMs(),
1841
- };
2762
+ return discoveryCoverageMarker(`Document reference discovery for "${term}"`, coverage, `reasons=${coverage.reasons.join(",")}; ` +
2763
+ `filesScanned=${String(coverage.filesScanned)}, ` +
2764
+ `filesSkipped=${String(coverage.filesSkipped)}, ` +
2765
+ `matchesReturned=${String(coverage.matchesReturned)}`, nowMs());
1842
2766
  }
1843
2767
  function reserveAugmentationSearchTerms(terms, signal, budget) {
1844
- const reserved = [];
1845
- for (const term of terms) {
1846
- throwIfCancelled(signal);
1847
- if (!budget.tryReserveSearchCall())
1848
- break;
1849
- reserved.push(term);
1850
- }
1851
- return reserved;
1852
- }
1853
- async function documentReferenceAtoms(input, plan, nowMs, signal, requestContext, budget) {
1854
- const terms = reserveAugmentationSearchTerms(documentReferenceAnchorTerms(plan), signal, budget);
1855
- const results = await Promise.all(terms.map(async (term) => {
1856
- throwIfCancelled(signal);
1857
- const result = await requestContext.findFiles(documentReferenceQuery(input, term), DOCUMENT_REFERENCE_SEARCH_LIMITS, {
1858
- ...(signal === undefined ? {} : { signal }),
1859
- searchHints: { retrievalIntent: plan.retrievalIntent },
2768
+ throwIfCancelled(signal);
2769
+ return terms.length > 0 && budget.tryReserveSearchCall() ? terms : [];
2770
+ }
2771
+ function filenameSearchTargets(inputs) {
2772
+ const { input, plan, signal, budget } = inputs;
2773
+ const symbols = reserveAugmentationSearchTerms(symbolFileAnchorTerms(plan), signal, budget);
2774
+ const documents = reserveAugmentationSearchTerms(documentReferenceAnchorTerms(plan), signal, budget);
2775
+ const targets = [];
2776
+ if (symbols.length > 0)
2777
+ targets.push({
2778
+ kind: "symbol",
2779
+ terms: symbols,
2780
+ request: {
2781
+ query: symbolFileQuery(input, "**/*"),
2782
+ limits: SYMBOL_FILE_SEARCH_LIMITS,
2783
+ filePatternGroups: {
2784
+ patterns: symbols.map((term) => `**/${term}.*`),
2785
+ maxMatchesPerPattern: SYMBOL_FILE_MATCHES_MAX,
2786
+ },
2787
+ },
1860
2788
  });
1861
- return { term, result };
1862
- }));
1863
- const markers = results.flatMap(({ term, result }) => {
1864
- const marker = documentReferenceCoverageMarker(term, result.coverage, nowMs);
1865
- return marker === undefined ? [] : [marker];
1866
- });
1867
- return { atoms: results.flatMap(({ result }) => result.atoms), uncertainty: markers };
2789
+ if (documents.length > 0) {
2790
+ const maxMatches = DOCUMENT_REFERENCE_MATCHES_MAX * documents.length;
2791
+ targets.push({
2792
+ kind: "document",
2793
+ terms: documents,
2794
+ request: {
2795
+ query: { ...symbolFileQuery(input, "**/*"), maxResults: maxMatches },
2796
+ limits: { ...DOCUMENT_REFERENCE_SEARCH_LIMITS, maxMatchesReturned: maxMatches },
2797
+ filePatternGroups: {
2798
+ patterns: documents.map((term) => `**${term}*`),
2799
+ maxMatchesPerPattern: DOCUMENT_REFERENCE_MATCHES_MAX,
2800
+ },
2801
+ },
2802
+ });
2803
+ }
2804
+ return targets;
1868
2805
  }
1869
2806
  // eslint-disable-next-line complexity -- Guard chain keeps symbol-anchor filtering explicit.
1870
2807
  function symbolFileAnchorTerms(plan) {
@@ -1874,11 +2811,13 @@ function symbolFileAnchorTerms(plan) {
1874
2811
  }
1875
2812
  const terms = [];
1876
2813
  const seen = new Set();
1877
- for (const anchor of plan.anchors) {
2814
+ for (const anchor of [...(plan.targetDecision?.targets ?? []), ...plan.anchors]) {
1878
2815
  if ((anchor.kind !== "identifier" && anchor.kind !== "quoted") || anchor.weight < 0.7) {
1879
2816
  continue;
1880
2817
  }
1881
- if (!/^[a-z_$][a-z0-9_$-]+$/u.test(anchor.term) || anchor.term.includes(".")) {
2818
+ if (!/^[a-z_$][a-z0-9_$-]+$/u.test(anchor.term) ||
2819
+ anchor.term.includes(".") ||
2820
+ DOCUMENT_REFERENCE_ANCHOR_RE.test(anchor.term)) {
1882
2821
  continue;
1883
2822
  }
1884
2823
  if (!seen.has(anchor.term)) {
@@ -1891,34 +2830,18 @@ function symbolFileAnchorTerms(plan) {
1891
2830
  }
1892
2831
  return terms;
1893
2832
  }
1894
- function escapeRegex(value) {
1895
- return value.replace(/[.*+?^${}()|[\]\\]/gu, String.raw `\$&`);
1896
- }
1897
- function symbolDefinitionPatterns(term) {
1898
- const escaped = escapeRegex(term);
1899
- return [
1900
- new RegExp(String.raw `\b(?:export\s+)?(?:async\s+)?function\s+${escaped}\b`, "iu"),
1901
- new RegExp(String.raw `\b(?:export\s+)?(?:class|interface|type|enum)\s+${escaped}\b`, "iu"),
1902
- new RegExp(String.raw `\b(?:export\s+)?(?:const|let|var)\s+${escaped}\b`, "iu"),
1903
- new RegExp(String.raw `\b(?:public\s+|private\s+|protected\s+|abstract\s+|final\s+|data\s+)*(?:class|interface|record|enum)\s+${escaped}\b`, "iu"),
1904
- new RegExp(String.raw `\b(?:public\s+|private\s+|protected\s+|static\s+|final\s+)*[A-Za-z_$][\w$<>, ?.[\]]+\s+${escaped}\s*\(`, "iu"),
1905
- new RegExp(String.raw `\b(?:def|func|fn|fun)\s+${escaped}\s*\(`, "iu"),
1906
- new RegExp(String.raw `\btype\s+${escaped}\s+(?:struct|interface)\b`, "iu"),
1907
- new RegExp(String.raw `\b(?:struct|trait|enum|class)\s+${escaped}\b`, "iu"),
1908
- ];
1909
- }
1910
- function lineDefinesSymbol(line, patterns) {
1911
- return patterns.some((pattern) => pattern.test(line));
1912
- }
1913
2833
  function symbolLineDeadlineReached(control) {
1914
2834
  return control.nowMs() >= control.deadlineMs;
1915
2835
  }
2836
+ function sourceLineDefinesSymbol(sourceLines, lineNumber, term) {
2837
+ const structural = sourceLines?.[lineNumber - 1]?.structural;
2838
+ return (structural !== undefined && structuralLineLooksLikeSymbolDefinition(structural, term, false));
2839
+ }
1916
2840
  // Exported only for deterministic cancellation/deadline regression coverage; this file is not a
1917
2841
  // package export. The per-line guard ensures a bounded-but-large 2 MiB source cannot run past the
1918
2842
  // request's absolute elapsed deadline after the descriptor read has completed.
1919
- export function scanFirstSymbolLine(rawText, term, control) {
2843
+ export function scanFirstSymbolLine(rawText, term, control, sourceLines) {
1920
2844
  const loweredTerm = term.toLowerCase();
1921
- const definitionPatterns = symbolDefinitionPatterns(term);
1922
2845
  let firstOccurrence;
1923
2846
  let lineNumber = 1;
1924
2847
  let start = 0;
@@ -1929,8 +2852,8 @@ export function scanFirstSymbolLine(rawText, term, control) {
1929
2852
  }
1930
2853
  const newline = rawText.indexOf("\n", start);
1931
2854
  const line = rawText.slice(start, newline < 0 ? rawText.length : newline);
1932
- if (lineDefinesSymbol(line, definitionPatterns)) {
1933
- return { lineNumber, deadlineReached: false };
2855
+ if (sourceLineDefinesSymbol(sourceLines, lineNumber, term)) {
2856
+ return { lineNumber, deadlineReached: false, definitionMatch: true };
1934
2857
  }
1935
2858
  if (firstOccurrence === undefined && line.toLowerCase().includes(loweredTerm)) {
1936
2859
  firstOccurrence = lineNumber;
@@ -1958,32 +2881,34 @@ function boundedSymbolFileText(fs, absolutePath) {
1958
2881
  ? read.rawText
1959
2882
  : undefined;
1960
2883
  }
1961
- function firstSymbolLine(searchScope, fs, scopePath, term, control) {
2884
+ function symbolLinesForPath(inputs, scopePath, terms, control) {
1962
2885
  throwIfCancelled(control.signal);
1963
- if (symbolLineDeadlineReached(control)) {
1964
- return { lineNumber: undefined, deadlineReached: true };
1965
- }
2886
+ if (symbolLineDeadlineReached(control))
2887
+ return new Map();
1966
2888
  try {
1967
- const contained = canonicalContainedSearchPath(searchScope, fs, scopePath);
1968
- if (contained === undefined)
1969
- return { lineNumber: undefined, deadlineReached: false };
2889
+ const contained = canonicalContainedSearchPath(inputs.searchScope, inputs.fs, scopePath);
1970
2890
  throwIfCancelled(control.signal);
1971
- if (symbolLineDeadlineReached(control)) {
1972
- return { lineNumber: undefined, deadlineReached: true };
1973
- }
1974
- const rawText = boundedSymbolFileText(fs, contained.path);
1975
- if (rawText === undefined)
1976
- return { lineNumber: undefined, deadlineReached: false };
1977
- return scanFirstSymbolLine(rawText, term, control);
2891
+ if (symbolLineDeadlineReached(control))
2892
+ return new Map();
2893
+ const text = contained === undefined ? undefined : boundedSymbolFileText(inputs.fs, contained.path);
2894
+ if (text === undefined)
2895
+ return new Map();
2896
+ throwIfCancelled(control.signal);
2897
+ if (symbolLineDeadlineReached(control))
2898
+ return new Map();
2899
+ const sourceLines = repositorySourceLines(text, scopePath);
2900
+ return new Map(terms.map((term) => [term, scanFirstSymbolLine(text, term, control, sourceLines)]));
1978
2901
  }
1979
2902
  catch (error) {
1980
2903
  if (error instanceof CancelledError)
1981
2904
  throw error;
1982
- return { lineNumber: undefined, deadlineReached: false };
2905
+ inputs.recordSymbolReadFailure(error, scopePath);
2906
+ return new Map();
1983
2907
  }
1984
2908
  }
1985
- function symbolLineAtom(scope, scopePath, lineNumber, queryFingerprint, nowMs) {
2909
+ function symbolLineAtom(scope, scopePath, lineNumber, queryFingerprint, nowMs, definitionMatch = false) {
1986
2910
  const lineRange = { startLine: lineNumber, endLine: lineNumber };
2911
+ const tool = definitionMatch ? "discovered-symbol-definition" : "repo.symbolFileDiscovery";
1987
2912
  return {
1988
2913
  schemaVersion: scope.schemaVersion,
1989
2914
  stableId: evidenceAtomStableId({
@@ -1991,7 +2916,7 @@ function symbolLineAtom(scope, scopePath, lineNumber, queryFingerprint, nowMs) {
1991
2916
  scopePath,
1992
2917
  lineRange,
1993
2918
  provenanceKind: "lexical-search",
1994
- provenanceTool: "repo.symbolFileDiscovery",
2919
+ provenanceTool: tool,
1995
2920
  queryFingerprint,
1996
2921
  }),
1997
2922
  scopePath,
@@ -1999,7 +2924,7 @@ function symbolLineAtom(scope, scopePath, lineNumber, queryFingerprint, nowMs) {
1999
2924
  score: 1,
2000
2925
  provenance: {
2001
2926
  kind: "lexical-search",
2002
- tool: "repo.symbolFileDiscovery",
2927
+ tool,
2003
2928
  queryFingerprint,
2004
2929
  },
2005
2930
  redactionState: "redacted",
@@ -2014,30 +2939,24 @@ function scopePathExtension(scopePath) {
2014
2939
  }
2015
2940
  // True when `scopePath` is a `<term>.<code-extension>` definition file. The single-walk symbol glob
2016
2941
  // `**/term.*` also matches multi-dot names like `term.test.tsx` (which the prior per-extension globs
2017
- // did not), so this restores the exact contract: keep only paths ending in `term.<ext>` for a code
2942
+ // did not), so this restores the exact contract: keep only basenames equal to `term.<ext>` for a code
2018
2943
  // extension — the implementation file, not its co-named spec/story. Exported for direct testing.
2019
2944
  export function isSymbolDefinitionPath(scopePath, term) {
2020
2945
  const extension = scopePathExtension(scopePath);
2021
2946
  return ((SYMBOL_FILE_EXTENSION_SET.has(extension) || isEcosystemSourceFile(scopePath)) &&
2022
- scopePath.toLowerCase().endsWith(`${term.toLowerCase()}.${extension}`));
2947
+ basename(scopePath).toLowerCase() === `${term.toLowerCase()}.${extension}`);
2023
2948
  }
2024
2949
  function symbolCoverageIncomplete(term, coverage, nowMs) {
2025
2950
  if (coverage?.incomplete !== true) {
2026
2951
  return undefined;
2027
2952
  }
2028
- return {
2029
- kind: "scope-incomplete",
2030
- claim: `Symbol file discovery for "${term}" was incomplete: ` +
2031
- `reasons=${coverage.reasons.join(",")}; ` +
2032
- `filesScanned=${String(coverage.filesScanned)}, ` +
2033
- `filesSkipped=${String(coverage.filesSkipped)}, ` +
2034
- `matchesReturned=${String(coverage.matchesReturned)}, ` +
2035
- `limits=maxFilesScanned:${String(coverage.limits.maxFilesScanned)},` +
2036
- `maxMatchesReturned:${String(coverage.limits.maxMatchesReturned)},` +
2037
- `elapsedMsMax:${String(coverage.limits.elapsedMsMax)}.`,
2038
- impactedAtomIds: [],
2039
- emittedAtMs: nowMs(),
2040
- };
2953
+ return discoveryCoverageMarker(`Symbol file discovery for "${term}"`, coverage, `reasons=${coverage.reasons.join(",")}; ` +
2954
+ `filesScanned=${String(coverage.filesScanned)}, ` +
2955
+ `filesSkipped=${String(coverage.filesSkipped)}, ` +
2956
+ `matchesReturned=${String(coverage.matchesReturned)}, ` +
2957
+ `limits=maxFilesScanned:${String(coverage.limits.maxFilesScanned)},` +
2958
+ `maxMatchesReturned:${String(coverage.limits.maxMatchesReturned)},` +
2959
+ `elapsedMsMax:${String(coverage.limits.elapsedMsMax)}`, nowMs());
2041
2960
  }
2042
2961
  function symbolDefinitionPriority(scopePath, term) {
2043
2962
  const loweredPath = scopePath.toLowerCase();
@@ -2053,19 +2972,6 @@ function compareSymbolMatches(a, b) {
2053
2972
  }
2054
2973
  return a.atom.scopePath.localeCompare(b.atom.scopePath);
2055
2974
  }
2056
- function symbolLineReadOverflow(overflowCount, terms, nowMs) {
2057
- if (overflowCount === 0) {
2058
- return undefined;
2059
- }
2060
- return {
2061
- kind: "scope-incomplete",
2062
- claim: `Symbol line lookup skipped ${String(overflowCount)} definition file(s) after ` +
2063
- `${String(MAX_SYMBOL_LINE_READS)} prioritized line reads; ` +
2064
- `file-level symbol matches remain available for terms=${terms.join(",")}.`,
2065
- impactedAtomIds: [],
2066
- emittedAtMs: nowMs(),
2067
- };
2068
- }
2069
2975
  function symbolLineDeadlineMarker(skippedCount, nowMs) {
2070
2976
  if (skippedCount === 0)
2071
2977
  return undefined;
@@ -2077,42 +2983,38 @@ function symbolLineDeadlineMarker(skippedCount, nowMs) {
2077
2983
  emittedAtMs: nowMs(),
2078
2984
  };
2079
2985
  }
2080
- // Walk the tree ONCE for `**/term.*` and keep only `term.<code-ext>` definition files. The single
2081
- // walk replaces the prior
2082
- // per-extension globs (up to 27 redundant full-tree walks per question, ~4.7s on a 3.5k-file repo).
2083
- async function symbolDefinitionMatchesForTerm(term, input, plan, nowMs, signal, requestContext) {
2084
- const result = await requestContext.findFiles(symbolFileQuery(input, `**/${term}.*`), SYMBOL_FILE_SEARCH_LIMITS, {
2085
- ...(signal === undefined ? {} : { signal }),
2086
- searchHints: { retrievalIntent: plan.retrievalIntent },
2087
- });
2986
+ function symbolFilenameMatches(terms, result, nowMs) {
2088
2987
  const matches = [];
2089
2988
  for (const atom of result.atoms) {
2090
- if (!isSymbolDefinitionPath(atom.scopePath, term)) {
2091
- continue;
2989
+ for (const term of terms) {
2990
+ if (isSymbolDefinitionPath(atom.scopePath, term)) {
2991
+ matches.push({ atom, term, priority: symbolDefinitionPriority(atom.scopePath, term) });
2992
+ }
2092
2993
  }
2093
- matches.push({
2094
- atom,
2095
- term,
2096
- priority: symbolDefinitionPriority(atom.scopePath, term),
2097
- });
2098
2994
  }
2099
- const marker = symbolCoverageIncomplete(term, result.coverage, nowMs);
2100
- return { matches, uncertainty: marker === undefined ? [] : [marker] };
2995
+ const marker = symbolCoverageIncomplete(terms.join(", "), result.coverage, nowMs);
2996
+ return { terms, matches, uncertainty: marker === undefined ? [] : [marker] };
2101
2997
  }
2102
- async function collectSymbolDefinitionMatches(terms, input, plan, nowMs, signal, requestContext, budget) {
2103
- const reservedTerms = reserveAugmentationSearchTerms(terms, signal, budget);
2104
- const results = await Promise.all(reservedTerms.map((term) => {
2105
- throwIfCancelled(signal);
2106
- return symbolDefinitionMatchesForTerm(term, input, plan, nowMs, signal, requestContext);
2107
- }));
2108
- const matches = [];
2109
- const uncertainty = [];
2110
- for (const result of results) {
2111
- throwIfCancelled(signal);
2112
- matches.push(...result.matches);
2113
- uncertainty.push(...result.uncertainty);
2998
+ async function collectFilenameMatches(inputs, requestContext) {
2999
+ const targets = filenameSearchTargets(inputs);
3000
+ const results = await requestContext.findFilesBatch(targets.map((target) => target.request), {
3001
+ signal: inputs.signal,
3002
+ searchHints: { retrievalIntent: inputs.plan.retrievalIntent },
3003
+ });
3004
+ let symbols = { terms: [], matches: [], uncertainty: [] };
3005
+ let documents = { atoms: [], uncertainty: [] };
3006
+ for (const [index, target] of targets.entries()) {
3007
+ const result = results[index];
3008
+ if (result === undefined)
3009
+ throw new TypeError("Missing filename search result.");
3010
+ if (target.kind === "symbol")
3011
+ symbols = symbolFilenameMatches(target.terms, result, inputs.nowMs);
3012
+ else {
3013
+ const marker = documentReferenceCoverageMarker(target.terms.join(", "), result.coverage, inputs.nowMs);
3014
+ documents = { atoms: result.atoms, uncertainty: marker === undefined ? [] : [marker] };
3015
+ }
2114
3016
  }
2115
- return { matches, uncertainty };
3017
+ return { symbols, documents };
2116
3018
  }
2117
3019
  function pushUniqueAtom(atoms, seen, atom) {
2118
3020
  if (seen.has(atom.stableId)) {
@@ -2122,20 +3024,50 @@ function pushUniqueAtom(atoms, seen, atom) {
2122
3024
  atoms.push(atom);
2123
3025
  }
2124
3026
  function pushSymbolLineAtom(inputs, target) {
2125
- const { match, atoms, seen, control } = target;
3027
+ const { match, atoms, seen, control, lookup } = target;
2126
3028
  const { atom, term } = match;
2127
- const lookup = firstSymbolLine(inputs.searchScope, inputs.fs, atom.scopePath, term, control);
2128
- if (lookup.lineNumber === undefined) {
2129
- return lookup.deadlineReached;
3029
+ if (lookup?.lineNumber === undefined) {
3030
+ return lookup?.deadlineReached === true || symbolLineDeadlineReached(control);
2130
3031
  }
2131
- pushUniqueAtom(atoms, seen, symbolLineAtom(inputs.input.scope, atom.scopePath, lookup.lineNumber, atom.provenance.queryFingerprint, inputs.nowMs));
3032
+ target.observedTerms.add(term);
3033
+ if (lookup.definitionMatch === true)
3034
+ target.verifiedTerms.add(term);
3035
+ pushUniqueAtom(atoms, seen, symbolLineAtom(inputs.input.scope, atom.scopePath, lookup.lineNumber, atom.provenance.queryFingerprint, inputs.nowMs, lookup.definitionMatch === true));
2132
3036
  return false;
2133
3037
  }
2134
- function collectPrioritizedSymbolAtoms(inputs, matches, terms) {
3038
+ function orderSymbolMatchesForTerms(matches, terms) {
3039
+ const sorted = [...matches].sort(compareSymbolMatches);
3040
+ const firstPerTerm = new Set();
3041
+ for (const term of terms) {
3042
+ const match = sorted.find((entry) => entry.term === term);
3043
+ if (match !== undefined)
3044
+ firstPerTerm.add(match);
3045
+ }
3046
+ return [...firstPerTerm, ...sorted.filter((match) => !firstPerTerm.has(match))];
3047
+ }
3048
+ function withLexicalSymbolCandidates(matches, terms, lexicalAtoms) {
3049
+ const combined = new Map(matches.map((match) => [`${match.atom.scopePath}\0${match.term}`, match]));
3050
+ for (const atom of lexicalAtoms) {
3051
+ for (const term of terms) {
3052
+ const key = `${atom.scopePath}\0${term}`;
3053
+ if (!combined.has(key))
3054
+ combined.set(key, { atom, term, priority: symbolDefinitionPriority(atom.scopePath, term) });
3055
+ }
3056
+ }
3057
+ return [...combined.values()];
3058
+ }
3059
+ function scheduledSymbolMatches(inputs, matches, terms, lookups) {
3060
+ return iterateSequentialResults(orderSymbolMatchesForTerms(matches, terms), (candidate) => lookups.has(candidate.atom.scopePath)
3061
+ ? Promise.resolve(candidate)
3062
+ : groundedSchedulingYield(inputs.signal).then(() => candidate));
3063
+ }
3064
+ async function collectPrioritizedSymbolAtoms(inputs, matches, terms) {
2135
3065
  const atoms = [];
2136
3066
  const seen = new Set();
2137
- let remainingLineReads = MAX_SYMBOL_LINE_READS;
2138
- let overflowCount = 0;
3067
+ const verifiedTerms = new Set();
3068
+ const observedTerms = new Set();
3069
+ const lookups = new Map();
3070
+ let complete = true;
2139
3071
  let deadlineSkippedCount = 0;
2140
3072
  let lineDeadlineReached = false;
2141
3073
  const control = {
@@ -2143,49 +3075,172 @@ function collectPrioritizedSymbolAtoms(inputs, matches, terms) {
2143
3075
  nowMs: inputs.nowMs,
2144
3076
  deadlineMs: inputs.deadlineAtMs,
2145
3077
  };
2146
- for (const match of [...matches].sort(compareSymbolMatches)) {
3078
+ for await (const match of scheduledSymbolMatches(inputs, matches, terms, lookups)) {
2147
3079
  throwIfCancelled(inputs.signal);
2148
3080
  pushUniqueAtom(atoms, seen, match.atom);
2149
3081
  if (lineDeadlineReached) {
2150
3082
  deadlineSkippedCount += 1;
2151
3083
  }
2152
- else if (remainingLineReads <= 0) {
2153
- overflowCount += 1;
2154
- }
2155
3084
  else {
2156
- remainingLineReads -= 1;
2157
- lineDeadlineReached = pushSymbolLineAtom(inputs, { match, atoms, seen, control });
3085
+ const fileLookups = cachedSymbolLines(inputs, match.atom.scopePath, terms, control, lookups);
3086
+ complete &&= fileLookups.size === terms.length;
3087
+ lineDeadlineReached = pushSymbolLineAtom(inputs, {
3088
+ match,
3089
+ atoms,
3090
+ seen,
3091
+ control,
3092
+ lookup: fileLookups.get(match.term),
3093
+ verifiedTerms,
3094
+ observedTerms,
3095
+ });
2158
3096
  if (lineDeadlineReached)
2159
3097
  deadlineSkippedCount += 1;
2160
3098
  }
2161
3099
  }
2162
3100
  return {
2163
3101
  atoms,
3102
+ verifiedTerms,
3103
+ observedTerms,
3104
+ complete: complete && !lineDeadlineReached,
3105
+ uncertainty: [symbolLineDeadlineMarker(deadlineSkippedCount, inputs.nowMs)].filter((marker) => marker !== undefined),
3106
+ };
3107
+ }
3108
+ function cachedSymbolLines(inputs, scopePath, terms, control, cache) {
3109
+ const existing = cache.get(scopePath);
3110
+ if (existing !== undefined)
3111
+ return existing;
3112
+ const lines = symbolLinesForPath(inputs, scopePath, terms, control);
3113
+ cache.set(scopePath, lines);
3114
+ return lines;
3115
+ }
3116
+ function deterministicEvidenceObservers(args) {
3117
+ return {
3118
+ recordMetadataUnavailable: args.recordMetadataUnavailable,
3119
+ recordSymbolReadFailure: args.recordSymbolReadFailure,
3120
+ };
3121
+ }
3122
+ async function collectSymbolFileAtoms(inputs, requestContext) {
3123
+ const { input, searchScope, fs, nowMs, signal, deadlineAtMs, recordSymbolReadFailure } = inputs;
3124
+ // Both requested filename families share discovery, including the early declaration phase.
3125
+ // Each remains a separately charged query with its own retention and coverage.
3126
+ const { symbols, documents } = await collectFilenameMatches(inputs, requestContext);
3127
+ const prioritized = await collectPrioritizedSymbolAtoms({ input, searchScope, fs, nowMs, signal, deadlineAtMs, recordSymbolReadFailure }, withLexicalSymbolCandidates(symbols.matches, symbols.terms, inputs.lexicalAtoms ?? []), symbols.terms);
3128
+ return {
3129
+ ...prioritized,
3130
+ atoms: [...prioritized.atoms, ...documents.atoms],
3131
+ uncertainty: [...symbols.uncertainty, ...prioritized.uncertainty, ...documents.uncertainty],
3132
+ };
3133
+ }
3134
+ const LOCAL_STRUCTURAL_FILESYSTEM_FAILURES = new Set([
3135
+ "EACCES",
3136
+ "EPERM",
3137
+ "ENOENT",
3138
+ "ENOTDIR",
3139
+ "EIO",
3140
+ "ESTALE",
3141
+ ]);
3142
+ function unavailableStructuralEvidence(error, inputs) {
3143
+ const path = error.requestedPath;
3144
+ const cause = safeProperty(error, "cause");
3145
+ const kind = errorKindOf(cause);
3146
+ if (path === "." ||
3147
+ !isAdmittedMetadataPath(path, inputs.searchScope, undefined) ||
3148
+ !LOCAL_STRUCTURAL_FILESYSTEM_FAILURES.has(kind))
3149
+ throw error;
3150
+ const root = inputs.searchScope.workspace.root;
3151
+ const currentFs = metadataTraversalFs(inputs.metadataFs, inputs);
3152
+ const contained = canonicalContainedSearchPath(inputs.searchScope, currentFs, "");
3153
+ if (contained?.path !== root)
3154
+ throw new PathDeniedError("Workspace root changed.", ".");
3155
+ // Root access remains mandatory; only a known unavailable descendant can be secondary evidence.
3156
+ currentFs.readDir(root, 1);
3157
+ inputs.recordMetadataUnavailable(cause, path);
3158
+ const emittedAtMs = inputs.nowMs();
3159
+ return {
3160
+ atoms: [],
2164
3161
  uncertainty: [
2165
- symbolLineReadOverflow(overflowCount, terms, inputs.nowMs),
2166
- symbolLineDeadlineMarker(deadlineSkippedCount, inputs.nowMs),
2167
- ].filter((marker) => marker !== undefined),
3162
+ toolUnavailable("Supplementary structural evidence is unavailable for a subtree.", emittedAtMs),
3163
+ {
3164
+ kind: "scope-incomplete",
3165
+ claim: "Supplementary structural discovery could not inspect an unavailable subtree.",
3166
+ impactedAtomIds: [],
3167
+ emittedAtMs,
3168
+ },
3169
+ ],
2168
3170
  };
2169
3171
  }
3172
+ async function availableStructuralEvidence(inputs, work) {
3173
+ try {
3174
+ return await work();
3175
+ }
3176
+ catch (error) {
3177
+ throwIfCancelled(inputs.signal);
3178
+ if (!(error instanceof WorkspaceReadError))
3179
+ throw error;
3180
+ return unavailableStructuralEvidence(error, inputs);
3181
+ }
3182
+ }
2170
3183
  async function symbolFileAtoms(inputs, requestContext) {
2171
- const { input, plan, searchScope, fs, nowMs, signal, deadlineAtMs, budget } = inputs;
2172
- const terms = symbolFileAnchorTerms(plan);
2173
- if (terms.length === 0) {
2174
- return { atoms: [], uncertainty: [] };
3184
+ try {
3185
+ return await collectSymbolFileAtoms(inputs, requestContext);
2175
3186
  }
2176
- const collected = await collectSymbolDefinitionMatches(terms, input, plan, nowMs, signal, requestContext, budget);
2177
- const prioritized = collectPrioritizedSymbolAtoms({
3187
+ catch (error) {
3188
+ throwIfCancelled(inputs.signal);
3189
+ if (!(error instanceof WorkspaceReadError))
3190
+ throw error;
3191
+ return unavailableStructuralEvidence(error, inputs);
3192
+ }
3193
+ }
3194
+ function requiredDeclarationTargets(query, decision) {
3195
+ const original = extractAnchors({ text: query.text, maxAnchors: query.text.length }).anchors;
3196
+ const required = new Set([...decision.targets, ...original]
3197
+ .filter((anchor) => anchor.kind === "quoted" || anchor.weight >= 0.9)
3198
+ .map((anchor) => anchor.term));
3199
+ for (const token of query.text.matchAll(/[\p{L}\p{N}_$.-]+/gu)) {
3200
+ const term = token[0].toLowerCase();
3201
+ const anchor = extractAnchors({ text: token[0], maxAnchors: 1 }).anchors[0];
3202
+ if (anchor?.kind === "identifier" && anchor.weight >= 0.85 && anchor.term === term)
3203
+ required.add(term);
3204
+ }
3205
+ return required;
3206
+ }
3207
+ function verifiedDefinitionDiscovery(evidence, query, decision) {
3208
+ const verified = evidence.verifiedTerms ?? new Set();
3209
+ return (evidence.complete === true &&
3210
+ evidence.uncertainty.length === 0 &&
3211
+ verified.size > 0 &&
3212
+ [...requiredDeclarationTargets(query, decision)].every((term) => verified.has(term)) &&
3213
+ [...(evidence.observedTerms ?? [])].every((term) => verified.has(term)));
3214
+ }
3215
+ function finishDefinitionDiscovery(args, evidence, result) {
3216
+ return {
3217
+ evidence: result.marker === undefined
3218
+ ? evidence
3219
+ : { ...evidence, uncertainty: [...evidence.uncertainty, result.marker] },
3220
+ governor: result.governor,
3221
+ verified: result.marker === undefined &&
3222
+ verifiedDefinitionDiscovery(evidence, args.input.query, args.plan.targetDecision ?? resolveQueryTargetDecision(args.input.query, args.plan.anchors)),
3223
+ };
3224
+ }
3225
+ async function discoverDefinitionsBeforeGraphs(args) {
3226
+ const { input, plan, rings, searchScope, fs, metadataFs, nowMs, structuralContexts, deadlineAtMs, deps, } = args;
3227
+ const budget = createAugmentationBudgetMeter(plan, rings.governor, nowMs, deadlineAtMs);
3228
+ const certifiedPaths = primaryContentPaths(rings);
3229
+ const evidence = await symbolFileAtoms({
3230
+ ...deterministicEvidenceObservers(args),
2178
3231
  input,
3232
+ plan,
2179
3233
  searchScope,
2180
3234
  fs,
3235
+ metadataFs,
2181
3236
  nowMs,
2182
- signal,
3237
+ structuralContexts,
2183
3238
  deadlineAtMs,
2184
- }, collected.matches, terms);
2185
- return {
2186
- atoms: prioritized.atoms,
2187
- uncertainty: [...collected.uncertainty, ...prioritized.uncertainty],
2188
- };
3239
+ budget,
3240
+ signal: deps.signal,
3241
+ lexicalAtoms: rings.atoms.filter((atom) => certifiedPaths.has(atom.scopePath) && atom.provenance.tool === "repo.searchText"),
3242
+ }, structuralContexts.forLimits(SYMBOL_FILE_SEARCH_LIMITS));
3243
+ return finishDefinitionDiscovery(args, evidence, budget.finish(rings.governor));
2189
3244
  }
2190
3245
  function selectedFileAtom(scope, scopePath, queryFingerprint, nowMs) {
2191
3246
  return {
@@ -2217,7 +3272,7 @@ function fileExistsInSearchScope(searchScope, fs, scopePath, existsCache) {
2217
3272
  return cached;
2218
3273
  const parentScopePath = dirname(scopePath);
2219
3274
  const entryName = basenameScopePath(scopePath);
2220
- const directory = cachedDirectoryEntries(searchScope, fs, parentScopePath, MAX_WORKSPACE_MANIFESTS, existsCache);
3275
+ const directory = cachedDirectoryEntries(searchScope, fs, parentScopePath, PROJECT_METADATA_FILENAMES.length, existsCache);
2221
3276
  const entry = directory.entries.find((candidate) => candidate.name === entryName);
2222
3277
  if (entry === undefined) {
2223
3278
  const exists = directory.status === "complete"
@@ -2253,13 +3308,15 @@ function isSafeRegularFile(stat) {
2253
3308
  function containedPathIsSafeRegularFile(fs, contained) {
2254
3309
  return contained === undefined ? false : isSafeRegularFile(fs.stat(contained.path));
2255
3310
  }
2256
- function createFileExistenceCache() {
3311
+ function createFileExistenceCache(scopePaths) {
2257
3312
  return {
2258
3313
  files: new Map(),
2259
3314
  directories: new Map(),
2260
- truncatedDirectories: new Set(),
2261
- unavailableDirectories: new Set(),
3315
+ unavailableDirectoryInspections: 0,
2262
3316
  metadataCoverageIssues: new Map(),
3317
+ metadataDirectories: new Set(),
3318
+ metadataWildcardBases: new Set(),
3319
+ metadataScopePaths: scopePaths === undefined ? undefined : new Set(scopePaths),
2263
3320
  };
2264
3321
  }
2265
3322
  function basenameScopePath(scopePath) {
@@ -2273,10 +3330,6 @@ function cachedDirectoryEntries(searchScope, fs, scopePath, maxEntries, existsCa
2273
3330
  return cached;
2274
3331
  const read = safeReadDir(searchScope, fs, scopePath, maxEntries);
2275
3332
  existsCache?.directories.set(cacheKey, read);
2276
- if (read.status === "truncated")
2277
- existsCache?.truncatedDirectories.add(scopePath);
2278
- if (read.status === "unavailable")
2279
- existsCache?.unavailableDirectories.add(scopePath);
2280
3333
  return read;
2281
3334
  }
2282
3335
  function selectedFileScopeAtoms(input, searchScope, fs, nowMs, existsCache, deadlineAtMs, signal) {
@@ -2325,47 +3378,36 @@ function acceptInjectionScopePath(scopePath, seen) {
2325
3378
  seen.add(scopePath);
2326
3379
  return true;
2327
3380
  }
2328
- // Bound on glob-manifest atoms injected per metadata root from a single directory listing (M4,
2329
- // risk #1). The exact-name loop above handles fixed basenames; this catches GLOB manifests at the
2330
- // root/scope dir (e.g. *.csproj, *.tf) that have no fixed name. Deny-checked + deduped + capped.
2331
- const MAX_ROOT_GLOB_MANIFESTS = 16;
2332
- // Bounded glob-manifest sweep of a single directory: returns the accepted (deduped, deny-clean,
2333
- // shape-valid) scope paths, capped at MAX_ROOT_GLOB_MANIFESTS. Mutates `seen` via the gate.
2334
- function rootGlobManifestPaths(root, searchScope, fs, seen, control, existsCache) {
3381
+ async function rootGlobManifestPaths(root, searchScope, fs, seen, control, maxResults, existsCache) {
2335
3382
  if (!metadataTraversalCanContinue(control))
2336
3383
  return [];
2337
- const paths = [];
2338
- for (const scopePath of canonicalManifestScopePathsInDir(root, searchScope, fs, MAX_ROOT_GLOB_MANIFESTS, existsCache)) {
2339
- if (paths.length >= MAX_ROOT_GLOB_MANIFESTS) {
2340
- break;
2341
- }
2342
- if (acceptInjectionScopePath(scopePath, seen)) {
2343
- paths.push(scopePath);
2344
- }
2345
- }
2346
- return paths;
3384
+ const paths = await canonicalManifestScopePathsInDir(root, searchScope, fs, maxResults, control, existsCache, { cacheAbsentNames: true });
3385
+ return paths.filter((path) => acceptInjectionScopePath(path, seen));
2347
3386
  }
2348
- function projectMetadataRootAtoms(root, context) {
2349
- const { input, searchScope, fs, nowMs, queryFingerprint, control, existsCache, seen } = context;
3387
+ async function projectMetadataRootAtoms(root, context) {
3388
+ const { input, searchScope, fs, nowMs, queryFingerprint, control, existsCache, seen, maxResults, } = context;
2350
3389
  const atoms = [];
3390
+ const globPaths = await rootGlobManifestPaths(root, searchScope, fs, seen, control, maxResults, existsCache);
2351
3391
  for (const filename of PROJECT_METADATA_FILENAMES) {
2352
3392
  if (!metadataTraversalCanContinue(control))
2353
3393
  break;
2354
3394
  const scopePath = joinScopePath(root, filename);
2355
- if (acceptInjectionScopePath(scopePath, seen) &&
3395
+ if (isAdmittedMetadataPath(scopePath, searchScope, existsCache) &&
3396
+ (globPaths.includes(scopePath) || acceptInjectionScopePath(scopePath, seen)) &&
2356
3397
  fileExistsInSearchScope(searchScope, fs, scopePath, existsCache)) {
3398
+ existsCache.metadataRetention?.observeRootFallback(scopePath);
2357
3399
  atoms.push(metadataAtom(input.scope, scopePath, queryFingerprint, nowMs));
2358
3400
  }
2359
3401
  }
2360
- for (const scopePath of rootGlobManifestPaths(root, searchScope, fs, seen, control, existsCache)) {
3402
+ for (const scopePath of globPaths.filter((path) => !atoms.some((atom) => atom.scopePath === path))) {
2361
3403
  atoms.push(metadataAtom(input.scope, scopePath, queryFingerprint, nowMs));
2362
3404
  }
2363
3405
  return atoms;
2364
3406
  }
2365
- function workspacePackageMetadataAtoms(context) {
2366
- const { input, searchScope, fs, nowMs, queryFingerprint, control, existsCache, seen } = context;
3407
+ async function workspacePackageMetadataAtoms(context) {
3408
+ const { input, searchScope, fs, nowMs, queryFingerprint, control, existsCache, seen, maxResults, } = context;
2367
3409
  const atoms = [];
2368
- for (const scopePath of workspacePackageManifestPaths(input, searchScope, fs, control, existsCache)) {
3410
+ for (const scopePath of await workspacePackageManifestPaths(input, searchScope, fs, control, maxResults, existsCache)) {
2369
3411
  if (!metadataTraversalCanContinue(control))
2370
3412
  break;
2371
3413
  if (acceptInjectionScopePath(scopePath, seen)) {
@@ -2374,20 +3416,25 @@ function workspacePackageMetadataAtoms(context) {
2374
3416
  }
2375
3417
  return atoms;
2376
3418
  }
2377
- function projectMetadataAtoms(inputs) {
3419
+ async function projectMetadataAtoms(inputs) {
2378
3420
  const { input, intent, control } = inputs;
2379
- if (!wantsProjectMetadata(input, intent) || !metadataTraversalCanContinue(control)) {
3421
+ if ((!wantsProjectMetadata(input, intent) && inputs.readableScopeManifest !== true) ||
3422
+ !metadataTraversalCanContinue(control)) {
2380
3423
  return [];
2381
3424
  }
2382
- const atoms = [];
2383
3425
  const context = { ...inputs, seen: new Set() };
2384
- for (const root of metadataRootsForScope(input.scope)) {
3426
+ const retained = new MetadataRetention(inputs.maxResults, MAX_OMITTED_CONTEXT_ENTRIES, metadataRootsForScope(input.scope), PROJECT_METADATA_FILENAMES);
3427
+ inputs.existsCache.metadataRetention = retained;
3428
+ for await (const _atoms of iterateSequentialResults(metadataRootsForScope(input.scope), (root) => metadataTraversalCanContinue(control)
3429
+ ? projectMetadataRootAtoms(root, context)
3430
+ : Promise.resolve([]))) {
2385
3431
  if (!metadataTraversalCanContinue(control))
2386
3432
  break;
2387
- atoms.push(...projectMetadataRootAtoms(root, context));
2388
3433
  }
2389
- atoms.push(...workspacePackageMetadataAtoms(context));
2390
- return atoms;
3434
+ await workspacePackageMetadataAtoms(context);
3435
+ return retained
3436
+ .retainedPaths()
3437
+ .map((path) => metadataAtom(input.scope, path, inputs.queryFingerprint, inputs.nowMs));
2391
3438
  }
2392
3439
  function repositoryOverviewAtoms(inputs) {
2393
3440
  const { input, intent, searchScope, fs, nowMs, queryFingerprint, control, existsCache } = inputs;
@@ -2413,26 +3460,20 @@ function repositoryOverviewAtoms(inputs) {
2413
3460
  }
2414
3461
  function mergeDeterministicEvidence(sources) {
2415
3462
  return {
3463
+ metadataRetention: sources.find((source) => source.metadataRetention !== undefined)
3464
+ ?.metadataRetention,
2416
3465
  atoms: sources.flatMap((source) => source.atoms),
2417
3466
  uncertainty: sources.flatMap((source) => source.uncertainty),
3467
+ omitted: sources.flatMap((source) => source.omitted ?? []),
2418
3468
  };
2419
3469
  }
2420
3470
  function metadataDirectoryCoverageUncertainty(cache, nowMs) {
2421
3471
  const markers = [];
2422
- if (cache.truncatedDirectories.size > 0) {
2423
- markers.push({
2424
- kind: "scope-incomplete",
2425
- claim: `project metadata discovery was truncated by bounded directory reads in ` +
2426
- `${String(cache.truncatedDirectories.size)} directory path(s); relevant manifests may be missing`,
2427
- impactedAtomIds: [],
2428
- emittedAtMs: nowMs,
2429
- });
2430
- }
2431
- if (cache.unavailableDirectories.size > 0) {
3472
+ if (cache.unavailableDirectoryInspections > 0) {
2432
3473
  markers.push({
2433
3474
  kind: "scope-incomplete",
2434
3475
  claim: `project metadata discovery could not enumerate ` +
2435
- `${String(cache.unavailableDirectories.size)} directory path(s); ` +
3476
+ `${String(cache.unavailableDirectoryInspections)} directory inspection(s); ` +
2436
3477
  `exact manifest probes were used but glob manifests may be missing`,
2437
3478
  impactedAtomIds: [],
2438
3479
  emittedAtMs: nowMs,
@@ -2457,10 +3498,12 @@ function metadataManifestCoverageUncertainty(cache, nowMs) {
2457
3498
  },
2458
3499
  ];
2459
3500
  }
2460
- function deterministicMetadataEvidence(input, plan, searchScope, fs, nowMs, signal, deadlineAtMs) {
2461
- const control = { signal, nowMs, deadlineAtMs };
2462
- const existsCache = createFileExistenceCache();
3501
+ async function deterministicMetadataEvidence(inputs) {
3502
+ const { input, plan, searchScope, metadataFs: fs, nowMs, signal, deadlineAtMs, recordMetadataUnavailable: recordUnavailable, } = inputs;
3503
+ const control = { signal, nowMs, deadlineAtMs, recordUnavailable };
3504
+ const existsCache = createFileExistenceCache(input.scope.relativePaths);
2463
3505
  const discovery = {
3506
+ ...(inputs.readableScopeManifest === true ? { readableScopeManifest: true } : {}),
2464
3507
  input,
2465
3508
  intent: plan.retrievalIntent,
2466
3509
  searchScope,
@@ -2469,68 +3512,96 @@ function deterministicMetadataEvidence(input, plan, searchScope, fs, nowMs, sign
2469
3512
  queryFingerprint: projectMetadataQueryFingerprint(input.query),
2470
3513
  control,
2471
3514
  existsCache,
3515
+ maxResults: plan.budget.filesReadMax ?? input.query.maxResults,
2472
3516
  };
2473
- const atoms = [...projectMetadataAtoms(discovery), ...repositoryOverviewAtoms(discovery)];
3517
+ const atoms = [...(await projectMetadataAtoms(discovery)), ...repositoryOverviewAtoms(discovery)];
2474
3518
  const emittedAtMs = nowMs();
2475
3519
  return {
2476
3520
  atoms,
3521
+ omitted: metadataRetentionOmissions(existsCache, emittedAtMs),
3522
+ metadataRetention: existsCache.metadataRetention?.observation(),
2477
3523
  uncertainty: [
2478
3524
  ...metadataDirectoryCoverageUncertainty(existsCache, emittedAtMs),
2479
3525
  ...metadataManifestCoverageUncertainty(existsCache, emittedAtMs),
3526
+ ...metadataRetentionUncertainty(existsCache, emittedAtMs),
2480
3527
  ],
2481
3528
  };
2482
3529
  }
3530
+ function metadataRetentionOmissions(cache, nowMs) {
3531
+ return (cache.metadataRetention?.omittedPaths() ?? []).map((scopePath) => ({
3532
+ scopePath,
3533
+ reason: "budget-exhausted",
3534
+ omittedAtMs: nowMs,
3535
+ }));
3536
+ }
3537
+ function metadataRetentionUncertainty(cache, nowMs) {
3538
+ const count = cache.metadataRetention?.discardedCount ?? 0;
3539
+ return count === 0
3540
+ ? []
3541
+ : [
3542
+ {
3543
+ kind: "budget-clipped",
3544
+ claim: `project metadata retention omitted ${String(count)} observed manifest candidates; ` +
3545
+ `canonical omission paths are bounded representative details, not an unfinished traversal`,
3546
+ impactedAtomIds: [],
3547
+ emittedAtMs: nowMs,
3548
+ },
3549
+ ];
3550
+ }
2483
3551
  async function collectParallelDeterministicEvidence(inputs, fileSearchContext, traceContext) {
2484
- const { input, plan, searchScope, fs, nowMs, signal, deadlineAtMs, budget } = inputs;
2485
- return Promise.all([
2486
- collectFollowSymbolTraceEvidence({
2487
- scope: input.scope,
2488
- query: input.query,
2489
- anchors: plan.anchors,
2490
- retrievalIntent: plan.retrievalIntent,
2491
- searchScope,
2492
- fs,
2493
- nowMs,
2494
- signal,
2495
- requestContext: traceContext,
2496
- deadlineAtMs,
2497
- tryReserveSearchCall: budget.tryReserveSearchCall,
2498
- }),
2499
- symbolFileAtoms(inputs, fileSearchContext),
2500
- documentReferenceAtoms(input, plan, nowMs, signal, fileSearchContext, budget),
2501
- ]);
3552
+ const controller = new AbortController();
3553
+ const signal = parallelStageSignal(controller, inputs.signal);
3554
+ const { input, plan, searchScope, fs, nowMs, deadlineAtMs, budget } = inputs;
3555
+ const pending = [
3556
+ inputs.skipOptionalTrace === true
3557
+ ? Promise.resolve({ atoms: [], uncertainty: [] })
3558
+ : availableStructuralEvidence({ ...inputs, signal }, () => collectFollowSymbolTraceEvidence({
3559
+ scope: input.scope,
3560
+ query: input.query,
3561
+ anchors: plan.anchors,
3562
+ retrievalIntent: plan.retrievalIntent,
3563
+ searchScope,
3564
+ fs,
3565
+ nowMs,
3566
+ signal,
3567
+ requestContext: traceContext,
3568
+ deadlineAtMs,
3569
+ tryReserveSearchCall: budget.tryReserveSearchCall,
3570
+ })),
3571
+ inputs.symbolDiscovery === undefined
3572
+ ? symbolFileAtoms({ ...inputs, signal }, fileSearchContext)
3573
+ : Promise.resolve({ atoms: [], uncertainty: [] }),
3574
+ ];
3575
+ return settleParallelStage(Promise.all(pending), pending, controller);
2502
3576
  }
2503
- // Project-metadata discovery (package.json/pom.xml et al.) intentionally reads directly against
2504
- // `metadataFs` — the request's plain, unwrapped fs — rather than the ring-retrieval discovery cache
2505
- // `deterministicContextEvidence` otherwise shares: it deliberately re-probes a directory at
2506
- // escalating small caps to detect and report a genuine enumeration failure (#3347 P1), and it is
2507
- // not bound to `structuralContexts`, so it never needs to match that pool's fs identity for
2508
- // assertGraphBinding.
2509
- function deterministicMetadataAtoms(inputs) {
3577
+ // Project metadata streams the admitted filesystem directly, retaining only the accepted evidence
3578
+ // budget. It does not depend on structural inventories or their filesystem identity binding.
3579
+ async function deterministicMetadataAtoms(inputs) {
2510
3580
  return inputs.budget.canContinue()
2511
- ? deterministicMetadataEvidence(inputs.input, inputs.plan, inputs.searchScope, inputs.metadataFs, inputs.nowMs, inputs.signal, inputs.deadlineAtMs)
3581
+ ? deterministicMetadataEvidence(inputs)
2512
3582
  : { atoms: [], uncertainty: [] };
2513
3583
  }
2514
3584
  async function deterministicContextEvidence(inputs) {
2515
3585
  const fileSearchContext = inputs.structuralContexts.forLimits(SYMBOL_FILE_SEARCH_LIMITS);
2516
3586
  const traceContext = inputs.structuralContexts.forLimits(GROUNDED_TRACE_SEARCH_LIMITS);
2517
- const [traceEvidence, symbolDiscovery, referencedDocuments] = await collectParallelDeterministicEvidence(inputs, fileSearchContext, traceContext);
2518
- const metadata = deterministicMetadataAtoms(inputs);
2519
- return mergeDeterministicEvidence([
2520
- symbolDiscovery,
2521
- traceEvidence,
2522
- referencedDocuments,
2523
- metadata,
2524
- ]);
3587
+ const [traceEvidence, filenameDiscovery] = await collectParallelDeterministicEvidence(inputs, fileSearchContext, traceContext);
3588
+ const metadata = await deterministicMetadataAtoms(inputs);
3589
+ return mergeDeterministicEvidence([filenameDiscovery, traceEvidence, metadata]);
2525
3590
  }
2526
3591
  async function withDeterministicContextAtoms(rings, inputs) {
3592
+ markAugmentationUsed(rings);
2527
3593
  const deterministic = await deterministicContextEvidence(inputs);
2528
- if (deterministic.atoms.length === 0 && deterministic.uncertainty.length === 0) {
3594
+ if (deterministic.atoms.length === 0 &&
3595
+ deterministic.uncertainty.length === 0 &&
3596
+ (deterministic.omitted?.length ?? 0) === 0 &&
3597
+ deterministic.metadataRetention === undefined) {
2529
3598
  return rings;
2530
3599
  }
2531
3600
  return {
2532
3601
  ...rings,
3602
+ metadataRetention: deterministic.metadataRetention,
2533
3603
  atoms: [...rings.atoms, ...deterministic.atoms],
3604
+ omitted: [...rings.omitted, ...(deterministic.omitted ?? [])],
2534
3605
  uncertainty: [...rings.uncertainty, ...deterministic.uncertainty],
2535
3606
  };
2536
3607
  }
@@ -2589,6 +3660,29 @@ function explicitlyTargetsLockfile(scopePath, queryText, anchors) {
2589
3660
  const name = basename(scopePath).toLowerCase();
2590
3661
  return queryTerms(queryText, anchors).some((term) => path.includes(term) || name === term);
2591
3662
  }
3663
+ function orderForDistinctEvidencePaths(kept, anchors, priorityPaths) {
3664
+ const selected = new Set(kept.slice(0, 1));
3665
+ for (const anchor of anchors) {
3666
+ if (anchor.kind === "literal" || anchor.weight < 0.7)
3667
+ continue;
3668
+ const term = anchor.term.toLowerCase();
3669
+ const candidate = [...selected].find((entry) => entry.scopePath.toLowerCase().includes(term)) ??
3670
+ kept.find((entry) => entry.scopePath.toLowerCase().includes(term));
3671
+ if (candidate !== undefined) {
3672
+ selected.add(candidate);
3673
+ priorityPaths.add(candidate.scopePath);
3674
+ }
3675
+ }
3676
+ const names = new Set([...selected].map((candidate) => basename(candidate.scopePath).toLowerCase()));
3677
+ for (const candidate of kept) {
3678
+ const name = basename(candidate.scopePath).toLowerCase();
3679
+ if (names.has(name))
3680
+ continue;
3681
+ names.add(name);
3682
+ selected.add(candidate);
3683
+ }
3684
+ return [...selected, ...kept.filter((candidate) => !selected.has(candidate))];
3685
+ }
2592
3686
  function refineCandidateOrdering(kept, omitted, query, anchors, diagnostics, nowMs) {
2593
3687
  const queryText = query.text;
2594
3688
  const preferred = [];
@@ -2610,25 +3704,37 @@ function refineCandidateOrdering(kept, omitted, query, anchors, diagnostics, now
2610
3704
  if (preferred.length === 0) {
2611
3705
  return { kept, omitted };
2612
3706
  }
2613
- const nextOmitted = [...omitted];
2614
- for (const candidate of runtimeArtifacts) {
2615
- nextOmitted.push({
2616
- scopePath: candidate.scopePath,
2617
- reason: "low-relevance",
2618
- omittedAtMs: nowMs,
2619
- });
2620
- }
2621
- nextOmitted.sort(compareByScopePath);
2622
- const useSearchOrder = queryTargetsRouteImplementation(queryText) ||
2623
- directDefinitionSymbol(query, anchors) !== undefined;
3707
+ const nextOmitted = runtimeArtifactOmissions(omitted, runtimeArtifacts, nowMs);
3708
+ const priorityPaths = new Set();
3709
+ const useSearchOrder = candidateOrderingUsesSearchOrder(query, anchors, diagnostics);
2624
3710
  const orderedPreferred = useSearchOrder
2625
- ? orderPreferredCandidates(preferred, diagnostics)
3711
+ ? orderPreferredCandidates(preferred, diagnostics, priorityPaths)
2626
3712
  : preferred;
2627
3713
  return {
2628
- kept: [...orderedPreferred, ...lockfiles],
3714
+ kept: [
3715
+ ...orderForDistinctEvidencePaths(orderedPreferred, anchors, priorityPaths),
3716
+ ...lockfiles,
3717
+ ],
2629
3718
  omitted: nextOmitted,
3719
+ priorityPaths,
2630
3720
  };
2631
3721
  }
3722
+ function runtimeArtifactOmissions(omitted, artifacts, nowMs) {
3723
+ return [
3724
+ ...omitted,
3725
+ ...artifacts.map((candidate) => ({
3726
+ scopePath: candidate.scopePath,
3727
+ reason: "low-relevance",
3728
+ omittedAtMs: nowMs,
3729
+ })),
3730
+ ].sort(compareByScopePath);
3731
+ }
3732
+ function candidateOrderingUsesSearchOrder(query, anchors, diagnostics) {
3733
+ return (queryTargetsRouteImplementation(query.text) ||
3734
+ directDefinitionSymbol(query, anchors) !== undefined ||
3735
+ (isOrdinaryDocumentLookup(query, false, diagnostics) &&
3736
+ anchors.some((anchor) => (anchor.kind === "identifier" || anchor.kind === "quoted") && anchor.weight >= 0.85)));
3737
+ }
2632
3738
  const ROUTE_METHOD_QUERY_RE = /\b(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\b/iu;
2633
3739
  const ROUTE_PATH_QUERY_RE = /\/[A-Za-z0-9:_?&=./-]*[A-Za-z0-9_}/-]/u;
2634
3740
  const ROUTE_INTENT_QUERY_RE = /\b(?:api|endpoint|handler|implement|implements|implemented|route)\b/iu;
@@ -2637,7 +3743,7 @@ function queryTargetsRouteImplementation(queryText) {
2637
3743
  ROUTE_PATH_QUERY_RE.test(queryText) &&
2638
3744
  ROUTE_INTENT_QUERY_RE.test(queryText));
2639
3745
  }
2640
- function orderPreferredCandidates(kept, diagnostics) {
3746
+ function orderPreferredCandidates(kept, diagnostics, priorityPaths) {
2641
3747
  const ranked = diagnostics?.rankedCandidates ?? [];
2642
3748
  if (ranked.length === 0 || kept.length <= 1) {
2643
3749
  return kept;
@@ -2648,6 +3754,7 @@ function orderPreferredCandidates(kept, diagnostics) {
2648
3754
  .find((candidate) => candidate !== undefined);
2649
3755
  if (routeCandidate === undefined)
2650
3756
  return kept;
3757
+ priorityPaths.add(routeCandidate.scopePath);
2651
3758
  return [routeCandidate, ...kept.filter((candidate) => candidate !== routeCandidate)];
2652
3759
  }
2653
3760
  function groupEvidenceAtomsByPath(atoms) {
@@ -2668,7 +3775,7 @@ function lineWindowForAtom(atom) {
2668
3775
  if (range === undefined) {
2669
3776
  return DEFAULT_EXCERPT_WINDOW;
2670
3777
  }
2671
- const isDiscoveredDefinition = atom.provenance.tool === "discovered-symbol-definition";
3778
+ const isDiscoveredDefinition = tracePriority(atom) === 2;
2672
3779
  const addSingleLineContext = range.startLine === range.endLine &&
2673
3780
  atom.provenance.kind !== "semantic-search" &&
2674
3781
  atom.provenance.kind !== "model-rerank";
@@ -2708,49 +3815,78 @@ function windowContainsAtom(window, atom) {
2708
3815
  const range = atom.lineRange;
2709
3816
  return (range === undefined || (window.startLine <= range.startLine && window.endLine >= range.endLine));
2710
3817
  }
2711
- function windowsOverlap(a, b) {
2712
- return a.startLine <= b.endLine && b.startLine <= a.endLine;
2713
- }
2714
3818
  function mergeWindowsByTracePriority(atomsForPath) {
2715
- const selected = [];
3819
+ let selected = [];
2716
3820
  for (const priority of [2, 1, 0]) {
2717
3821
  const windows = mergeLineWindows(atomsForPath.filter((atom) => tracePriority(atom) === priority).map(lineWindowForAtom));
2718
- selected.push(...windows.filter((window) => !selected.some((kept) => windowsOverlap(kept, window))));
3822
+ selected = selected
3823
+ .concat(nonOverlappingExcerptWindows(windows, selected))
3824
+ .sort((a, b) => a.startLine - b.startLine);
2719
3825
  }
2720
3826
  return selected;
2721
3827
  }
3828
+ function nonOverlappingExcerptWindows(windows, selected) {
3829
+ const retained = [];
3830
+ let index = 0;
3831
+ for (const window of windows) {
3832
+ while ((selected[index]?.endLine ?? Infinity) < window.startLine)
3833
+ index += 1;
3834
+ if ((selected[index]?.startLine ?? Infinity) > window.endLine)
3835
+ retained.push(window);
3836
+ }
3837
+ return retained;
3838
+ }
2722
3839
  function strongerExcerptWindow(candidate, current) {
2723
3840
  if (candidate.tracePriority !== current.tracePriority) {
2724
3841
  return candidate.tracePriority > current.tracePriority ? candidate : current;
2725
3842
  }
2726
3843
  return candidate.score > current.score ? candidate : current;
2727
3844
  }
2728
- function strongestAtomStrengthForWindow(window, atomsForPath) {
2729
- let strength = { tracePriority: 0, score: 0 };
2730
- for (const atom of atomsForPath) {
2731
- if (windowContainsAtom(window, atom)) {
2732
- strength = strongerExcerptWindow({ tracePriority: tracePriority(atom), score: atom.score }, strength);
3845
+ function windowIndexContainingLine(windows, line) {
3846
+ let low = 0;
3847
+ let high = windows.length;
3848
+ while (low < high) {
3849
+ const middle = Math.floor((low + high) / 2);
3850
+ if ((windows[middle]?.startLine ?? Infinity) <= line)
3851
+ low = middle + 1;
3852
+ else
3853
+ high = middle;
3854
+ }
3855
+ return low - 1;
3856
+ }
3857
+ function rankedExcerptWindows(windows, atoms) {
3858
+ const sorted = [...windows].sort((a, b) => a.startLine - b.startLine);
3859
+ const strengths = sorted.map(() => ({ tracePriority: 0, score: 0 }));
3860
+ let unlocated = { tracePriority: 0, score: 0 };
3861
+ for (const atom of atoms) {
3862
+ const strength = { tracePriority: tracePriority(atom), score: atom.score };
3863
+ const range = atom.lineRange;
3864
+ if (range === undefined) {
3865
+ unlocated = strongerExcerptWindow(strength, unlocated);
3866
+ continue;
2733
3867
  }
2734
- }
2735
- return strength;
2736
- }
2737
- function compareExcerptWindows(a, b, atomsForPath) {
2738
- const aStrength = strongestAtomStrengthForWindow(a, atomsForPath);
2739
- const bStrength = strongestAtomStrengthForWindow(b, atomsForPath);
2740
- const priorityDelta = bStrength.tracePriority - aStrength.tracePriority;
2741
- if (priorityDelta !== 0)
2742
- return priorityDelta;
2743
- const scoreDelta = bStrength.score - aStrength.score;
2744
- return scoreDelta === 0 ? a.startLine - b.startLine : scoreDelta;
3868
+ const index = windowIndexContainingLine(sorted, range.startLine);
3869
+ const window = sorted[index];
3870
+ const current = strengths[index];
3871
+ if (window !== undefined && current !== undefined && windowContainsAtom(window, atom))
3872
+ strengths[index] = strongerExcerptWindow(strength, current);
3873
+ }
3874
+ return sorted
3875
+ .map((window, index) => ({
3876
+ window,
3877
+ strength: strongerExcerptWindow(strengths[index] ?? unlocated, unlocated),
3878
+ }))
3879
+ .sort((a, b) => b.strength.tracePriority - a.strength.tracePriority ||
3880
+ b.strength.score - a.strength.score ||
3881
+ a.window.startLine - b.window.startLine)
3882
+ .map(({ window }) => window);
2745
3883
  }
2746
3884
  function excerptLineWindows(atomsForPath) {
2747
3885
  if (atomsForPath === undefined || atomsForPath.length === 0) {
2748
3886
  return { windows: [DEFAULT_EXCERPT_WINDOW], omittedWindowCount: 0 };
2749
3887
  }
2750
3888
  const merged = mergeWindowsByTracePriority(atomsForPath);
2751
- const selected = [...merged]
2752
- .sort((a, b) => compareExcerptWindows(a, b, atomsForPath))
2753
- .slice(0, MAX_EXCERPT_WINDOWS_PER_FILE);
3889
+ const selected = rankedExcerptWindows(merged, atomsForPath);
2754
3890
  return {
2755
3891
  windows: selected,
2756
3892
  omittedWindowCount: Math.max(0, merged.length - selected.length),
@@ -2762,86 +3898,132 @@ function exhaustedDimensions(remainingFiles, remainingBytes) {
2762
3898
  ...(remainingBytes <= 0 ? ["excerptBytes"] : []),
2763
3899
  ].join(", ");
2764
3900
  }
2765
- function readExcerptWindow(scopePath, window, maxBytes, inputs) {
2766
- return readExcerpt(inputs.searchScope, { scopePath, startLine: window.startLine, endLine: window.endLine, maxBytes }, {
3901
+ function appendReadExcerptWindows(result, windows) {
3902
+ let bytes = 0;
3903
+ let truncated = 0;
3904
+ let anchored = 0;
3905
+ const seen = new Set(windows.map(excerptWindowKey));
3906
+ for (const read of result.windows ?? [result]) {
3907
+ const range = read.atom.lineRange;
3908
+ if (range === undefined)
3909
+ continue;
3910
+ const identity = read.truncated
3911
+ ? connectedContextActivityDigest("keiko.excerpt-window.v1", [
3912
+ String(range.startLine),
3913
+ String(range.endLine),
3914
+ read.content,
3915
+ ])
3916
+ : undefined;
3917
+ const key = excerptWindowKey({ ...range, content: "", identity });
3918
+ if (seen.has(key))
3919
+ continue;
3920
+ seen.add(key);
3921
+ windows.push({
3922
+ ...range,
3923
+ content: read.content,
3924
+ ...(identity === undefined ? {} : { identity }),
3925
+ });
3926
+ bytes += utf8ByteLength(read.content);
3927
+ truncated += Number(read.truncated);
3928
+ anchored += Number(read.anchoredWindowApplied === true);
3929
+ }
3930
+ return { bytes, truncated, anchored };
3931
+ }
3932
+ function excerptWindowKey(window) {
3933
+ return JSON.stringify([window.startLine, window.endLine, window.identity ?? null]);
3934
+ }
3935
+ function remainingExcerptWindowBytes(scopePath, availableBytes, inputs) {
3936
+ return Math.min(inputs.knownFitFileBytes?.get(scopePath) ?? MAX_EXCERPT_WINDOW_BYTES, availableBytes);
3937
+ }
3938
+ function qualifiedWholeFileRanges(scopePath, windows, inputs) {
3939
+ if (inputs.knownFitFileBytes?.has(scopePath) !== true)
3940
+ return false;
3941
+ const wholeFile = (inputs.atomsByPath.get(scopePath) ?? []).find((atom) => atom.provenance.kind === "file-listing" &&
3942
+ atom.provenance.tool === "repo.findFiles" &&
3943
+ atom.lineRange !== undefined);
3944
+ return (wholeFile !== undefined && windows.every((window) => windowContainsAtom(window, wholeFile)));
3945
+ }
3946
+ async function readPathExcerptWindows(scopePath, inputs, remainingBytes) {
3947
+ const windows = [];
3948
+ const selection = excerptLineWindows(inputs.atomsByPath.get(scopePath));
3949
+ const containingRange = containingExcerptRange(selection.windows);
3950
+ throwIfCancelled(inputs.signal);
3951
+ if (inputs.nowMs() >= inputs.deadlineAtMs || remainingBytes <= 0)
3952
+ return unreadExcerptWindows(selection, inputs.nowMs() >= inputs.deadlineAtMs);
3953
+ const result = await readExcerpt(inputs.searchScope, {
3954
+ scopePath,
3955
+ ...containingRange,
3956
+ ranges: selection.windows,
3957
+ maxBytes: remainingExcerptWindowBytes(scopePath, remainingBytes, inputs),
3958
+ anchors: qualifiedWholeFileRanges(scopePath, selection.windows, inputs)
3959
+ ? undefined
3960
+ : inputs.anchors,
3961
+ maxTotalBytes: remainingBytes,
3962
+ maxWindows: Math.max(1, remainingBytes),
3963
+ }, {
2767
3964
  fs: inputs.fs,
2768
3965
  nowMs: inputs.nowMs,
2769
3966
  deadlineAtMs: inputs.deadlineAtMs,
2770
3967
  ...(inputs.signal === undefined ? {} : { signal: inputs.signal }),
2771
3968
  });
3969
+ throwIfCancelled(inputs.signal);
3970
+ if (inputs.nowMs() >= inputs.deadlineAtMs)
3971
+ return unreadExcerptWindows(selection, true);
3972
+ const appended = appendReadExcerptWindows(result, windows);
3973
+ return {
3974
+ windows,
3975
+ bytesConsumed: appended.bytes,
3976
+ truncatedWindowCount: appended.truncated,
3977
+ anchoredWindowCount: appended.anchored,
3978
+ deadlineReached: false,
3979
+ omittedWindowCount: selection.omittedWindowCount + (result.omittedRangeCount ?? 0),
3980
+ };
2772
3981
  }
2773
- async function readPathExcerptWindows(scopePath, inputs, remainingBytes) {
2774
- const windows = [];
2775
- let bytesConsumed = 0;
2776
- let truncatedWindowCount = 0;
2777
- let deadlineReached = false;
2778
- const selection = excerptLineWindows(inputs.atomsByPath.get(scopePath));
2779
- for (const window of selection.windows) {
2780
- throwIfCancelled(inputs.signal);
2781
- if (inputs.nowMs() >= inputs.deadlineAtMs) {
2782
- deadlineReached = true;
2783
- break;
2784
- }
2785
- const availableBytes = remainingBytes - bytesConsumed;
2786
- if (availableBytes <= 0) {
2787
- break;
2788
- }
2789
- const maxBytes = Math.min(8192, availableBytes);
2790
- const result = await readExcerptWindow(scopePath, window, maxBytes, inputs);
2791
- throwIfCancelled(inputs.signal);
2792
- if (inputs.nowMs() >= inputs.deadlineAtMs) {
2793
- // The absolute deadline is authoritative (#3347 P1). A read that only came back after it is
2794
- // dropped whole — the window is not appended and its bytes are not charged — so a late
2795
- // completion can neither enter the evidence pack nor spend an excerpt budget the request no
2796
- // longer has. Recording `deadlineReached` while keeping the content did both.
2797
- deadlineReached = true;
2798
- break;
2799
- }
2800
- if (result.truncated) {
2801
- truncatedWindowCount += 1;
2802
- }
2803
- const actualRange = result.atom.lineRange;
2804
- if (actualRange !== undefined) {
2805
- windows.push({ ...actualRange, content: result.content });
2806
- }
2807
- bytesConsumed += utf8ByteLength(result.content);
3982
+ function containingExcerptRange(windows) {
3983
+ let startLine = Infinity;
3984
+ let endLine = 1;
3985
+ for (const window of windows) {
3986
+ startLine = Math.min(startLine, window.startLine);
3987
+ endLine = Math.max(endLine, window.endLine);
2808
3988
  }
3989
+ return { startLine, endLine };
3990
+ }
3991
+ function unreadExcerptWindows(selection, deadlineReached) {
2809
3992
  return {
2810
- windows,
2811
- bytesConsumed,
2812
- omittedWindowCount: selection.omittedWindowCount,
2813
- truncatedWindowCount,
3993
+ windows: [],
3994
+ bytesConsumed: 0,
3995
+ truncatedWindowCount: 0,
3996
+ anchoredWindowCount: 0,
3997
+ omittedWindowCount: selection.omittedWindowCount + selection.windows.length,
2814
3998
  deadlineReached,
2815
3999
  };
2816
4000
  }
2817
- function excerptWindowUncertainty(scopePath, result, nowMs) {
2818
- const markers = [];
2819
- if (result.omittedWindowCount > 0) {
2820
- markers.push({
2821
- kind: "scope-incomplete",
2822
- claim: `excerpt window limit omitted ${String(result.omittedWindowCount)} additional matching range(s) in ${scopePath}`,
2823
- impactedAtomIds: [],
2824
- emittedAtMs: nowMs(),
2825
- });
2826
- }
2827
- if (result.truncatedWindowCount > 0) {
2828
- markers.push({
4001
+ function excerptReadLossSummary(state, nowMs) {
4002
+ if (state.omittedWindowCount === 0 &&
4003
+ state.truncatedWindowCount === 0 &&
4004
+ state.omitted.length === 0)
4005
+ return [];
4006
+ return [
4007
+ {
2829
4008
  kind: "scope-incomplete",
2830
- claim: `excerpt byte limit truncated ${String(result.truncatedWindowCount)} selected ` +
2831
- `range(s) in ${scopePath}`,
4009
+ claim: `excerpt read limits omitted ${String(state.omittedWindowCount)} additional matching range(s); ` +
4010
+ `excerpt byte limit truncated ${String(state.truncatedWindowCount)} selected range(s); ` +
4011
+ `${String(state.omitted.length)} files unavailable during excerpt reading`,
2832
4012
  impactedAtomIds: [],
2833
4013
  emittedAtMs: nowMs(),
2834
- });
2835
- }
2836
- return markers;
4014
+ },
4015
+ ];
2837
4016
  }
2838
- function largeFileExcerptOmitted(scopePath, nowMs) {
2839
- return {
2840
- kind: "scope-incomplete",
2841
- claim: `large file omitted from excerpt evidence because it exceeds the bounded read cap: ${scopePath}`,
2842
- impactedAtomIds: [],
2843
- emittedAtMs: nowMs(),
2844
- };
4017
+ function excerptOmissionReason(reason) {
4018
+ if (reason === "binary")
4019
+ return "binary";
4020
+ if (reason === "timeout" || reason === "aborted")
4021
+ return "budget-exhausted";
4022
+ if (reason === "denied" || reason === "outside-scope")
4023
+ return "outside-scope";
4024
+ if (reason === "ignored")
4025
+ return "ignored";
4026
+ return "tool-unavailable";
2845
4027
  }
2846
4028
  function distributeByteBudget(totalBytes, slots) {
2847
4029
  if (slots <= 0 || totalBytes <= 0)
@@ -2862,21 +4044,25 @@ async function readPathExcerptTask(scopePath, inputs, byteBudget) {
2862
4044
  // degrade to a skipped excerpt, never crash the whole grounded answer. Other kept files and
2863
4045
  // the rest of the pipeline continue; the file simply contributes no excerpt content.
2864
4046
  if (error instanceof FileTooLargeError) {
2865
- return { scopePath, skippedReason: "too-large" };
4047
+ return { scopePath, skippedReason: "too-large", omissionReason: "size-exceeded" };
2866
4048
  }
2867
4049
  if (error instanceof RepoSearchUnsupportedFileError) {
2868
4050
  // Preserve the stop reason (#3347 P1): the excerpt facade reports an elapsed-budget stop as
2869
4051
  // `timeout`, and flattening that to `unsupported` erased the only evidence that this file was
2870
4052
  // dropped because the request ran out of time — so no elapsed-budget marker was raised and
2871
4053
  // the completion status reported an unblocked elapsed budget.
2872
- return { scopePath, skippedReason: error.reason === "timeout" ? "timeout" : "unsupported" };
4054
+ return {
4055
+ scopePath,
4056
+ skippedReason: error.reason === "timeout" ? "timeout" : "unsupported",
4057
+ omissionReason: excerptOmissionReason(error.reason),
4058
+ };
2873
4059
  }
2874
4060
  throw error;
2875
4061
  }
2876
4062
  }
2877
4063
  function remainingExcerptCapacity(inputs) {
2878
4064
  return {
2879
- files: Math.max(0, inputs.budget.filesReadMax - inputs.initialUsage.filesRead),
4065
+ files: Math.max(0, (inputs.budget.filesReadMax ?? Number.POSITIVE_INFINITY) - inputs.initialUsage.filesRead),
2880
4066
  bytes: Math.max(0, inputs.budget.excerptBytesMax - inputs.initialUsage.excerptBytes),
2881
4067
  };
2882
4068
  }
@@ -2886,13 +4072,10 @@ function remainingExcerptCapacity(inputs) {
2886
4072
  function excerptTaskStoppedByDeadline({ result, skippedReason, }) {
2887
4073
  return result?.deadlineReached === true || skippedReason === "timeout";
2888
4074
  }
2889
- async function readKeptExcerpts(keptPaths, inputs) {
2890
- const excerpts = new Map();
2891
- const uncertainty = [];
2892
- const { files: remainingFiles, bytes: remainingBytes } = remainingExcerptCapacity(inputs);
4075
+ function stoppedExcerptReads(inputs, remainingFiles, remainingBytes) {
2893
4076
  if (inputs.nowMs() >= inputs.deadlineAtMs) {
2894
4077
  return {
2895
- excerpts,
4078
+ excerpts: new Map(),
2896
4079
  uncertainty: [budgetClipped("budget-exhausted on elapsedMs", inputs.nowMs())],
2897
4080
  elapsedBudgetBlocked: true,
2898
4081
  };
@@ -2900,36 +4083,145 @@ async function readKeptExcerpts(keptPaths, inputs) {
2900
4083
  if (remainingFiles <= 0 || remainingBytes <= 0) {
2901
4084
  const dimensions = exhaustedDimensions(remainingFiles, remainingBytes);
2902
4085
  return {
2903
- excerpts,
4086
+ excerpts: new Map(),
2904
4087
  uncertainty: [budgetClipped(`budget-exhausted on ${dimensions}`, inputs.nowMs())],
2905
4088
  elapsedBudgetBlocked: false,
2906
4089
  };
2907
4090
  }
4091
+ return undefined;
4092
+ }
4093
+ async function readKeptExcerpts(keptPaths, inputs) {
4094
+ const excerpts = new Map();
4095
+ const uncertainty = [];
4096
+ const { files: remainingFiles, bytes: remainingBytes } = remainingExcerptCapacity(inputs);
4097
+ const stopped = stoppedExcerptReads(inputs, remainingFiles, remainingBytes);
4098
+ if (stopped !== undefined)
4099
+ return {
4100
+ ...stopped,
4101
+ omitted: budgetExcerptOmissions(keptPaths, inputs.nowMs()),
4102
+ observation: excerptReadObservation(keptPaths.length, 0, 0, remainingFiles <= 0, remainingBytes <= 0, stopped.elapsedBudgetBlocked),
4103
+ };
2908
4104
  const readablePaths = keptPaths.slice(0, remainingFiles);
2909
4105
  if (readablePaths.length < keptPaths.length) {
2910
4106
  uncertainty.push(budgetClipped("budget-exhausted on filesRead", inputs.nowMs()));
2911
4107
  }
2912
- const byteBudgets = distributeByteBudget(remainingBytes, readablePaths.length);
2913
- const results = await Promise.all(readablePaths.map((scopePath, index) => {
2914
- throwIfCancelled(inputs.signal);
2915
- return readPathExcerptTask(scopePath, inputs, byteBudgets[index] ?? 0);
2916
- }));
2917
- for (const { scopePath, result, skippedReason } of results) {
4108
+ const state = {
4109
+ excerpts,
4110
+ uncertainty,
4111
+ remainingBytes,
4112
+ anchoredWindowCount: 0,
4113
+ elapsedBudgetBlocked: false,
4114
+ byteBudgetOmittedPaths: undefined,
4115
+ omitted: [],
4116
+ omittedWindowCount: 0,
4117
+ truncatedWindowCount: 0,
4118
+ };
4119
+ await readExcerptWaves(readablePaths, inputs, state);
4120
+ uncertainty.push(...excerptReadLossSummary(state, inputs.nowMs));
4121
+ if (state.elapsedBudgetBlocked) {
4122
+ uncertainty.push(budgetClipped("budget-exhausted on elapsedMs", inputs.nowMs()));
4123
+ }
4124
+ return completedExcerptSummary(keptPaths, readablePaths, state, inputs.nowMs);
4125
+ }
4126
+ function excerptReadObservation(unreadFileCount, omittedRangeCount, truncatedWindowCount, fileGrantBlocked, byteGrantBlocked, deadlineBlocked) {
4127
+ const stopReasons = [];
4128
+ if (fileGrantBlocked)
4129
+ stopReasons.push("file-grant");
4130
+ if (byteGrantBlocked)
4131
+ stopReasons.push("byte-grant");
4132
+ if (deadlineBlocked)
4133
+ stopReasons.push("deadline");
4134
+ return {
4135
+ unreadFileCount,
4136
+ omittedRangeCount,
4137
+ truncatedWindowCount,
4138
+ stopReasons,
4139
+ readBudgetBlocked: fileGrantBlocked || byteGrantBlocked,
4140
+ };
4141
+ }
4142
+ function budgetExcerptOmissions(paths, nowMs) {
4143
+ return paths.map((scopePath) => ({ scopePath, reason: "budget-exhausted", omittedAtMs: nowMs }));
4144
+ }
4145
+ function completedExcerptSummary(keptPaths, readablePaths, state, nowMs) {
4146
+ const accounted = new Set([
4147
+ ...state.excerpts.keys(),
4148
+ ...state.omitted.map((entry) => entry.scopePath),
4149
+ ]);
4150
+ const readable = new Set(readablePaths);
4151
+ const stoppedPaths = keptPaths.filter((path) => !accounted.has(path) && (state.elapsedBudgetBlocked || !readable.has(path)));
4152
+ return {
4153
+ excerpts: state.excerpts,
4154
+ uncertainty: state.uncertainty,
4155
+ observation: excerptReadObservation(keptPaths.length - state.excerpts.size, state.omittedWindowCount, state.truncatedWindowCount, readablePaths.length < keptPaths.length, (state.byteBudgetOmittedPaths?.length ?? 0) > 0 ||
4156
+ (state.remainingBytes <= 0 &&
4157
+ (state.omittedWindowCount > 0 || state.truncatedWindowCount > 0)), state.elapsedBudgetBlocked),
4158
+ omitted: [
4159
+ ...state.omitted,
4160
+ ...(stoppedPaths.length === 0 ? [] : budgetExcerptOmissions(stoppedPaths, nowMs())),
4161
+ ],
4162
+ elapsedBudgetBlocked: state.elapsedBudgetBlocked,
4163
+ readWindowCount: [...state.excerpts.values()].reduce((count, windows) => count + windows.length, 0),
4164
+ anchoredWindowCount: state.anchoredWindowCount,
4165
+ ...(state.byteBudgetOmittedPaths === undefined
4166
+ ? {}
4167
+ : { byteBudgetOmittedPaths: state.byteBudgetOmittedPaths }),
4168
+ };
4169
+ }
4170
+ function appendExcerptWave(results, inputs, state) {
4171
+ for (const task of results) {
2918
4172
  throwIfCancelled(inputs.signal);
4173
+ const { scopePath, result } = task;
4174
+ state.elapsedBudgetBlocked ||= excerptTaskStoppedByDeadline(task);
2919
4175
  if (result === undefined || result.windows.length === 0) {
2920
- if (skippedReason === "too-large") {
2921
- uncertainty.push(largeFileExcerptOmitted(scopePath, inputs.nowMs));
2922
- }
4176
+ if (task.omissionReason !== undefined)
4177
+ state.omitted.push({ scopePath, reason: task.omissionReason, omittedAtMs: inputs.nowMs() });
2923
4178
  continue;
2924
4179
  }
2925
- excerpts.set(scopePath, result.windows);
2926
- uncertainty.push(...excerptWindowUncertainty(scopePath, result, inputs.nowMs));
2927
- }
2928
- const elapsedBudgetBlocked = results.some(excerptTaskStoppedByDeadline);
2929
- if (elapsedBudgetBlocked) {
2930
- uncertainty.push(budgetClipped("budget-exhausted on elapsedMs", inputs.nowMs()));
2931
- }
2932
- return { excerpts, uncertainty, elapsedBudgetBlocked };
4180
+ state.remainingBytes -= result.bytesConsumed;
4181
+ state.anchoredWindowCount += result.anchoredWindowCount;
4182
+ state.excerpts.set(scopePath, result.windows);
4183
+ state.omittedWindowCount += result.omittedWindowCount;
4184
+ state.truncatedWindowCount += result.truncatedWindowCount;
4185
+ }
4186
+ }
4187
+ // The next wave depends on the bytes and deadline left after the preceding reads settle.
4188
+ // A lazy iterator retains one wave and lets the asynchronous consumer apply backpressure.
4189
+ function* pendingExcerptWaves(paths, inputs, state) {
4190
+ let next = 0;
4191
+ while (next < paths.length && state.remainingBytes > 0 && !state.elapsedBudgetBlocked) {
4192
+ throwIfCancelled(inputs.signal);
4193
+ if (inputs.nowMs() >= inputs.deadlineAtMs) {
4194
+ state.elapsedBudgetBlocked = true;
4195
+ break;
4196
+ }
4197
+ const slots = Math.min(8, paths.length - next, Math.max(1, Math.floor(state.remainingBytes / MAX_EXCERPT_WINDOW_BYTES)));
4198
+ const wave = paths.slice(next, next + slots);
4199
+ yield wave;
4200
+ next += wave.length;
4201
+ }
4202
+ if (next < paths.length && state.remainingBytes <= 0) {
4203
+ state.byteBudgetOmittedPaths = paths.slice(next);
4204
+ state.uncertainty.push(budgetClipped("budget-exhausted on excerptBytes", inputs.nowMs()));
4205
+ }
4206
+ }
4207
+ async function readExcerptWaves(paths, inputs, state) {
4208
+ for await (const results of iterateSequentialResults(pendingExcerptWaves(paths, inputs, state), (wave) => {
4209
+ const grants = excerptWaveGrants(wave, state.remainingBytes, inputs);
4210
+ return mapWithConcurrency(wave, 8, (scopePath, index) => {
4211
+ throwIfCancelled(inputs.signal);
4212
+ return readPathExcerptTask(scopePath, inputs, grants[index] ?? 0);
4213
+ });
4214
+ }))
4215
+ appendExcerptWave(results, inputs, state);
4216
+ }
4217
+ function excerptWaveGrants(paths, totalBytes, inputs) {
4218
+ const known = paths.map((path) => inputs.knownFitFileBytes?.get(path));
4219
+ const knownBytes = known.reduce((sum, bytes) => sum + (bytes ?? 0), 0);
4220
+ if (knownBytes > totalBytes || known.every((bytes) => bytes === undefined))
4221
+ return distributeByteBudget(totalBytes, paths.length);
4222
+ const remaining = distributeByteBudget(totalBytes - knownBytes, known.filter((bytes) => bytes === undefined).length);
4223
+ let next = 0;
4224
+ return known.map((bytes) => bytes ?? remaining[next++] ?? 0);
2933
4225
  }
2934
4226
  // Internal seam: package-local tests drive the excerpt-read step with a scripted clock, which the
2935
4227
  // whole-request path cannot do — every other phase reads the same clock, so a crossing aimed at one
@@ -2967,22 +4259,29 @@ function strongFileCacheIdentity(scopePath, canonicalRelativePath, stat) {
2967
4259
  hardLinkCount: stat.hardLinkCount,
2968
4260
  });
2969
4261
  }
2970
- function fileStateCacheIdentity(keptPaths, searchScope, fs, nowMs, deadlineAtMs, signal) {
4262
+ async function fileStateCacheIdentity(keptPaths, searchScope, fs, nowMs, deadlineAtMs, signal) {
2971
4263
  const identity = [];
2972
4264
  const guardedFs = cancellationGuardedWorkspaceFs(fs, signal);
4265
+ const readIdentity = (scopePath) => {
4266
+ throwIfCancelled(signal);
4267
+ if (nowMs() >= deadlineAtMs)
4268
+ return Promise.resolve(undefined);
4269
+ const target = canonicalContainedSearchPath(searchScope, guardedFs, scopePath);
4270
+ if (target === undefined)
4271
+ return Promise.resolve(undefined);
4272
+ throwIfCancelled(signal);
4273
+ if (nowMs() >= deadlineAtMs)
4274
+ return Promise.resolve(undefined);
4275
+ const stat = guardedFs.stat(target.path);
4276
+ const strongIdentity = strongFileCacheIdentity(scopePath, target.realRelative, stat);
4277
+ if (strongIdentity === undefined)
4278
+ return Promise.resolve(undefined);
4279
+ return (identity.length + 1) % 64 === 0
4280
+ ? groundedSchedulingYield(signal).then(() => strongIdentity)
4281
+ : Promise.resolve(strongIdentity);
4282
+ };
2973
4283
  try {
2974
- for (const scopePath of keptPaths) {
2975
- throwIfCancelled(signal);
2976
- if (nowMs() >= deadlineAtMs)
2977
- return undefined;
2978
- const target = canonicalContainedSearchPath(searchScope, guardedFs, scopePath);
2979
- if (target === undefined)
2980
- return undefined;
2981
- throwIfCancelled(signal);
2982
- if (nowMs() >= deadlineAtMs)
2983
- return undefined;
2984
- const stat = guardedFs.stat(target.path);
2985
- const strongIdentity = strongFileCacheIdentity(scopePath, target.realRelative, stat);
4284
+ for await (const strongIdentity of iterateSequentialResults(keptPaths, readIdentity)) {
2986
4285
  if (strongIdentity === undefined)
2987
4286
  return undefined;
2988
4287
  identity.push(strongIdentity);
@@ -2992,18 +4291,26 @@ function fileStateCacheIdentity(keptPaths, searchScope, fs, nowMs, deadlineAtMs,
2992
4291
  rethrowMetadataCancellation(error);
2993
4292
  return undefined;
2994
4293
  }
4294
+ if (nowMs() >= deadlineAtMs)
4295
+ return undefined;
2995
4296
  return identity.sort((left, right) => left.localeCompare(right));
2996
4297
  }
2997
4298
  // Internal mutation seam: package-local tests pin cancellation between synchronous cache-identity
2998
4299
  // probes without exposing this implementation detail from the server package root.
2999
- export function _fileStateCacheIdentityForTests(keptPaths, searchScope, fs, nowMs, deadlineAtMs, signal) {
4300
+ export async function _fileStateCacheIdentityForTests(keptPaths, searchScope, fs, nowMs, deadlineAtMs, signal) {
3000
4301
  return fileStateCacheIdentity(keptPaths, searchScope, fs, nowMs, deadlineAtMs, signal);
3001
4302
  }
3002
- function createReadyGovernedPlan(input, nowMs) {
4303
+ async function groundedSchedulingYield(signal) {
4304
+ // Scheduling batches bound event-loop monopolization, not eligible paths or cache coverage.
4305
+ await new Promise((resolve) => setImmediate(resolve));
4306
+ throwIfCancelled(signal);
4307
+ }
4308
+ function createReadyGovernedPlan(input, nowMs, progress) {
3003
4309
  const planned = planAndGovern(input.budget === undefined
3004
4310
  ? { scope: input.scope, query: input.query }
3005
4311
  : { scope: input.scope, query: input.query, budget: input.budget }, { nowMs });
3006
4312
  const { plan } = planned;
4313
+ progress.plan = plan;
3007
4314
  if (plan.state !== "ready") {
3008
4315
  if (plan.clarification !== undefined) {
3009
4316
  throw new ClarificationNeededError(plan.clarification);
@@ -3019,6 +4326,11 @@ function createReadyGovernedPlan(input, nowMs) {
3019
4326
  }
3020
4327
  return { plan, governor: planned.governor };
3021
4328
  }
4329
+ function knownFitAssembleOptions(options, rings) {
4330
+ return rings.knownFitFileBytes === undefined
4331
+ ? options
4332
+ : { ...options, maxBytesPerExcerptByPath: rings.knownFitFileBytes };
4333
+ }
3022
4334
  function deadlineBoundMicroIndex(index, nowMs, deadlineAtMs) {
3023
4335
  const canStart = () => nowMs() < deadlineAtMs;
3024
4336
  return {
@@ -3072,6 +4384,7 @@ function assembleOptionsFor(deps, nowMs, includeMicroIndex, includeReranker = tr
3072
4384
  : deadlineBoundReranker(deps.contextPackReranker, nowMs, deadlineAtMs, deps.signal);
3073
4385
  return {
3074
4386
  nowMs,
4387
+ includeSurroundingContext: true,
3075
4388
  ...(includeMicroIndex && microIndex !== undefined ? { microIndex } : {}),
3076
4389
  ...(includeReranker && reranker !== undefined ? { reranker } : {}),
3077
4390
  };
@@ -3105,7 +4418,7 @@ async function assembleEmptyGroundedPack({ input, deps, plan, governor, nowMs, s
3105
4418
  }, assembleOptions);
3106
4419
  return assemble.pack;
3107
4420
  }
3108
- function cachedGroundedPack({ input, plan, rings, atoms, ordered, cacheIdentity, initialUsage, assembleOptions, }) {
4421
+ function groundedPackCacheKey({ input, plan, rings, atoms, ordered, cacheIdentity, initialUsage, assembleOptions, }) {
3109
4422
  if (assembleOptions.microIndex === undefined || cacheIdentity === undefined) {
3110
4423
  return undefined;
3111
4424
  }
@@ -3120,27 +4433,85 @@ function cachedGroundedPack({ input, plan, rings, atoms, ordered, cacheIdentity,
3120
4433
  cacheIdentity,
3121
4434
  initialUsage,
3122
4435
  diagnostics: rings.diagnostics,
3123
- }, assembleOptions);
3124
- return assembleOptions.microIndex.get(key);
4436
+ initialUncertainty: rings.uncertainty,
4437
+ }, knownFitAssembleOptions(assembleOptions, rings));
4438
+ return key;
4439
+ }
4440
+ function selectPackAtoms(atoms, selectedPaths, input, plan) {
4441
+ const targetDecision = plan.targetDecision ?? resolveQueryTargetDecision(input.query, plan.anchors);
4442
+ return selectGroundedEvidenceAtoms(atoms, selectedPaths, input.scope.scopeId, targetDecision.definitionRequested);
3125
4443
  }
3126
- function preparePackAssembly(input, plan, rings, nowMs) {
3127
- const atoms = rings.atoms;
4444
+ function primaryCandidateFilter(rings) {
4445
+ const certifiedPaths = primaryContentPaths(rings);
4446
+ return {
4447
+ ...DEFAULT_FILTER_OPTIONS,
4448
+ minScoreExemptPaths: certifiedPaths,
4449
+ generatedExemptPaths: certifiedPaths,
4450
+ maxKept: new Set(rings.atoms.map((atom) => atom.scopePath)).size,
4451
+ };
4452
+ }
4453
+ function codeEvidenceAtoms(atoms, scope) {
4454
+ // Explicit documents belong to extraction, including its unsupported diagnostics. Keep them
4455
+ // off the code excerpt path before merging that exclusively document-owned result.
4456
+ return scope.kind === "files" && scope.explicitConnection === true
4457
+ ? atoms.filter((atom) => !isConnectedDocumentPath(atom.scopePath))
4458
+ : atoms;
4459
+ }
4460
+ function selectionEvidencePaths(input, plan, rings) {
4461
+ const paths = new Set(primaryContentPaths(rings));
4462
+ const decision = plan.targetDecision ?? resolveQueryTargetDecision(input.query, plan.anchors);
4463
+ if (decision.kind === "contextual") {
4464
+ for (const atom of rings.atoms) {
4465
+ if (atom.lineRange !== undefined && atom.provenance.tool.startsWith("repo.semanticSearch:"))
4466
+ paths.add(atom.scopePath);
4467
+ }
4468
+ }
4469
+ // This changes only relative selection, after normal absolute-score filtering. Semantic
4470
+ // context remains secondary and cannot certify literal presence or declaration discovery.
4471
+ return paths;
4472
+ }
4473
+ function rankingEvidence(rings, scope) {
4474
+ const sourceAtoms = codeEvidenceAtoms(rings.atoms, scope);
4475
+ const atoms = [];
4476
+ const seen = new Set();
4477
+ for (const atom of sourceAtoms)
4478
+ pushUniqueAtom(atoms, seen, atom);
4479
+ return {
4480
+ atoms,
4481
+ reusedEvidenceAtomCount: (rings.reusedEvidenceAtomCount ?? 0) + sourceAtoms.length - atoms.length,
4482
+ };
4483
+ }
4484
+ function preparePackAssembly(input, plan, rings, nowMs, hasGitMetadata) {
4485
+ const { atoms, reusedEvidenceAtomCount } = rankingEvidence(rings, input.scope);
3128
4486
  const initialUsage = clampUsageToBudget(rings.governor.usage, plan.budget);
3129
4487
  // M4: pass the classified retrieval intent so ranking can apply intent-conditioned signals
3130
4488
  // (canonical-metadata, structural-edge). Non-boosted intents (e.g. clarification) and the
3131
4489
  // no-context default are byte-identical — see weightsForIntent / isIntentBoosted.
3132
- const ranking = rankCandidates({ atoms, anchors: plan.anchors, context: { retrievalIntent: plan.retrievalIntent } }, { nowMs });
4490
+ const ranking = rankCandidates({
4491
+ atoms,
4492
+ anchors: primaryRankingAnchors(input, plan),
4493
+ context: { retrievalIntent: plan.retrievalIntent },
4494
+ ...(hasGitMetadata ? {} : { hints: { generatedPathPatterns: [] } }),
4495
+ }, {
4496
+ nowMs,
4497
+ // Retain the admitted evidence pool until distinct requested targets are ordered. The
4498
+ // accepted file/read/context budgets below still bound the material sent to the model.
4499
+ filter: primaryCandidateFilter(rings),
4500
+ });
3133
4501
  const refined = refineCandidateOrdering(ranking.kept, ranking.omitted, input.query, plan.anchors, rings.diagnostics, nowMs());
3134
4502
  const ordered = selectGroundedCandidateFiles({
3135
4503
  ...refined,
3136
4504
  scopeKind: input.scope.kind,
4505
+ protectedContentPaths: selectionEvidencePaths(input, plan, rings),
4506
+ pathOnlyPaths: pathOnlyEvidencePaths(atoms),
3137
4507
  filesReadMax: plan.budget.filesReadMax,
3138
4508
  nowMs: nowMs(),
3139
4509
  });
3140
4510
  const selectedPaths = new Set(ordered.kept.map((candidate) => candidate.scopePath));
3141
- const selectedAtoms = selectGroundedEvidenceAtoms(atoms, selectedPaths, input.scope.scopeId);
4511
+ const selectedAtoms = selectPackAtoms(atoms, selectedPaths, input, plan);
3142
4512
  return {
3143
4513
  atoms: selectedAtoms,
4514
+ reusedEvidenceAtomCount,
3144
4515
  initialUsage,
3145
4516
  ordered,
3146
4517
  atomsByPath: groupEvidenceAtomsByPath(selectedAtoms),
@@ -3148,30 +4519,40 @@ function preparePackAssembly(input, plan, rings, nowMs) {
3148
4519
  keptPaths: ordered.kept.map((c) => c.scopePath),
3149
4520
  };
3150
4521
  }
3151
- async function assemblePackFromReads({ input, plan, rings, prepared, excerptReads, documentEvidence, cacheIdentity, assembleOptions, }) {
4522
+ function afterExcerptReadOmissions(ordered, reads, nowMs) {
4523
+ const entries = [
4524
+ ...(reads.omitted ?? []),
4525
+ ...(reads.byteBudgetOmittedPaths ?? []).map((scopePath) => ({
4526
+ scopePath,
4527
+ reason: "budget-exhausted",
4528
+ omittedAtMs: nowMs,
4529
+ })),
4530
+ ];
4531
+ if (entries.length === 0)
4532
+ return ordered;
4533
+ const omitted = new Set(entries.map((entry) => entry.scopePath));
4534
+ return {
4535
+ kept: ordered.kept.filter((candidate) => !omitted.has(candidate.scopePath)),
4536
+ omitted: [...ordered.omitted, ...entries],
4537
+ };
4538
+ }
4539
+ async function assemblePackFromReads(inputs) {
4540
+ const { input, plan, rings, prepared, excerptReads, documentEvidence, assembleOptions } = inputs;
3152
4541
  const excerpts = mergeExcerptSources(excerptReads.excerpts, documentEvidence.excerpts);
3153
- const needsNoEvidenceMarker = excerpts.size === 0 &&
3154
- !prepared.evidenceUncertainty.some((marker) => marker.kind === "no-evidence");
4542
+ const ordered = afterExcerptReadOmissions(prepared.ordered, excerptReads, assembleOptions.nowMs());
3155
4543
  // Connected documents are owned exclusively by the bounded document-extraction path: they either
3156
4544
  // surface as document evidence or as a precise document diagnostic. The code-first lexical scan
3157
4545
  // also sees them as binary candidates, so strip any document-path omission it produced to avoid a
3158
4546
  // path that is both a selected file and an omitted entry (which the pack validator rejects).
3159
- const codeOmitted = [...rings.omitted, ...prepared.ordered.omitted].filter((entry) => !isConnectedDocumentPath(entry.scopePath));
4547
+ const codeOmitted = [...rings.omitted, ...ordered.omitted].filter((entry) => !isConnectedDocumentPath(entry.scopePath));
3160
4548
  const assemble = await assembleContextPack({
3161
4549
  scope: input.scope,
3162
4550
  query: input.query,
3163
4551
  budget: plan.budget,
3164
4552
  atoms: [...prepared.atoms, ...documentEvidence.atoms],
3165
- ranked: [...prepared.ordered.kept, ...documentEvidence.candidates],
4553
+ ranked: [...ordered.kept, ...documentEvidence.candidates],
3166
4554
  omittedFromRanking: [...codeOmitted, ...documentEvidence.omitted],
3167
4555
  excerpts,
3168
- // Document evidence is request-local and not part of the file-state cache key, so a pack that
3169
- // carries any document evidence — extracted atoms OR skipped-document omissions — must not be
3170
- // written into the micro-index under a code-only file-state key (it would orphan an entry the
3171
- // read-bypass gate never serves). Mirror the bypass condition in prepareGroundedAssembly.
3172
- cacheIdentity: documentEvidence.atoms.length > 0 || documentEvidence.omitted.length > 0
3173
- ? undefined
3174
- : cacheIdentity,
3175
4556
  initialUsage: prepared.initialUsage,
3176
4557
  diagnostics: rings.diagnostics,
3177
4558
  initialUncertainty: [
@@ -3179,11 +4560,31 @@ async function assemblePackFromReads({ input, plan, rings, prepared, excerptRead
3179
4560
  ...excerptReads.uncertainty,
3180
4561
  ...prepared.evidenceUncertainty,
3181
4562
  ...documentEvidence.uncertainty,
3182
- ...(needsNoEvidenceMarker ? [noEvidence(assembleOptions.nowMs())] : []),
4563
+ ...missingExcerptEvidence(prepared, excerpts.size, assembleOptions.nowMs()),
3183
4564
  ],
3184
- }, assembleOptions);
4565
+ }, withoutMicroIndex(knownFitAssembleOptions(assembleOptions, rings)));
4566
+ cacheAssembledGroundedPack(inputs, assemble.pack);
3185
4567
  return assemble.pack;
3186
4568
  }
4569
+ function missingExcerptEvidence(prepared, count, nowMs) {
4570
+ return count === 0 &&
4571
+ !prepared.evidenceUncertainty.some((marker) => marker.kind === "no-evidence")
4572
+ ? [noEvidence(nowMs)]
4573
+ : [];
4574
+ }
4575
+ function cacheAssembledGroundedPack(inputs, pack) {
4576
+ throwIfCancelled(inputs.signal);
4577
+ if (inputs.cacheIdentity === undefined ||
4578
+ inputs.cacheKey === undefined ||
4579
+ inputs.excerptReads.elapsedBudgetBlocked ||
4580
+ (inputs.excerptReads.omitted?.length ?? 0) !== 0)
4581
+ return;
4582
+ inputs.assembleOptions.microIndex?.set(inputs.cacheKey, pack);
4583
+ }
4584
+ function withoutMicroIndex(options) {
4585
+ const { microIndex, ...uncached } = options;
4586
+ return microIndex === undefined ? options : uncached;
4587
+ }
3187
4588
  function finishAugmentationBudget(rings, budget) {
3188
4589
  const result = budget.finish(rings.governor);
3189
4590
  return {
@@ -3199,7 +4600,14 @@ async function discoveredTraceForAugmentation(args, rings, budget) {
3199
4600
  if (!budget.canContinue())
3200
4601
  return { atoms: [], uncertainty: [] };
3201
4602
  const { input, deps, plan, searchScope, fs, nowMs, structuralContexts, workspaceIndex, deadlineAtMs, } = args;
3202
- return collectDiscoveredSymbolTraceEvidence({
4603
+ return availableStructuralEvidence({
4604
+ ...deterministicEvidenceObservers(args),
4605
+ searchScope,
4606
+ metadataFs: args.metadataFs,
4607
+ deadlineAtMs,
4608
+ nowMs,
4609
+ signal: deps.signal,
4610
+ }, () => collectDiscoveredSymbolTraceEvidence({
3203
4611
  scope: input.scope,
3204
4612
  query: input.query,
3205
4613
  anchors: plan.anchors,
@@ -3213,25 +4621,59 @@ async function discoveredTraceForAugmentation(args, rings, budget) {
3213
4621
  requestContext: structuralContexts.forLimits(GROUNDED_TRACE_SEARCH_LIMITS),
3214
4622
  deadlineAtMs,
3215
4623
  tryReserveSearchCall: budget.tryReserveSearchCall,
3216
- });
4624
+ }));
4625
+ }
4626
+ function markAugmentationSkipped(rings, reason) {
4627
+ if (rings.decisions === undefined)
4628
+ return;
4629
+ rings.decisions.augmentationDisposition = "skipped";
4630
+ rings.decisions.augmentationSkipped = true;
4631
+ rings.decisions.augmentationSkipReason = reason;
4632
+ }
4633
+ function markAugmentationUsed(rings) {
4634
+ if (rings.decisions !== undefined)
4635
+ rings.decisions.augmentationDisposition = "used";
4636
+ }
4637
+ function recordAugmentationSkip(args, rings) {
4638
+ const decision = args.plan.targetDecision ?? resolveQueryTargetDecision(args.input.query, args.plan.anchors);
4639
+ if (hasVerifiedTargetContext(args.input.query, decision, args.plan.retrievalIntent, rings)) {
4640
+ markAugmentationSkipped(rings, "verified-target-context");
4641
+ return true;
4642
+ }
4643
+ const reason = lookupAugmentationSkipReason(args.input.query, args.plan.anchors, args.hasGitMetadata, rings.diagnostics, decision);
4644
+ if (reason === undefined)
4645
+ return false;
4646
+ markAugmentationSkipped(rings, reason);
4647
+ return true;
4648
+ }
4649
+ function hasReadableScopeManifest(rings) {
4650
+ return [...(rings.knownFitFileBytes?.keys() ?? [])].some((path) => isCanonicalMetadataFile(path));
3217
4651
  }
3218
4652
  async function augmentRingsWithDeterministicAtoms(args) {
3219
- const { input, deps, plan, rings, searchScope, fs, metadataFs, nowMs, structuralContexts, deadlineAtMs, } = args;
4653
+ const { deps, plan, rings, searchScope, fs, nowMs, structuralContexts, deadlineAtMs } = args;
3220
4654
  const budget = createAugmentationBudgetMeter(plan, rings.governor, nowMs, deadlineAtMs);
3221
4655
  // Explicitly selected files are direct user scope, not another search. Preserve healthy files
3222
4656
  // when a planned ring consumed the search-call share (notably multi-source splits), while the
3223
4657
  // absolute deadline still prevents any new containment/stat work.
3224
4658
  const scopedRings = nowMs() < deadlineAtMs
3225
- ? withExplicitScopeAtoms(rings, input, searchScope, fs, nowMs, deadlineAtMs, deps.signal)
4659
+ ? withExplicitScopeAtoms(rings, args.input, searchScope, fs, nowMs, deadlineAtMs, deps.signal)
3226
4660
  : rings;
3227
- if (!budget.canContinue())
4661
+ if (!budget.canContinue()) {
4662
+ markAugmentationSkipped(scopedRings, "budget-exhausted");
4663
+ return finishAugmentationBudget(scopedRings, budget);
4664
+ }
4665
+ if (recordAugmentationSkip(args, scopedRings))
3228
4666
  return finishAugmentationBudget(scopedRings, budget);
3229
4667
  const deterministicRings = await withDeterministicContextAtoms(scopedRings, {
3230
- input,
4668
+ ...deterministicEvidenceObservers(args),
4669
+ readableScopeManifest: hasReadableScopeManifest(scopedRings),
4670
+ symbolDiscovery: scopedRings.symbolDiscovery,
4671
+ skipOptionalTrace: scopedRings.verifiedDefinitionContext === true,
4672
+ input: args.input,
3231
4673
  plan,
3232
4674
  searchScope,
3233
4675
  fs,
3234
- metadataFs,
4676
+ metadataFs: args.metadataFs,
3235
4677
  nowMs,
3236
4678
  signal: deps.signal,
3237
4679
  structuralContexts,
@@ -3245,7 +4687,7 @@ async function augmentRingsWithDeterministicAtoms(args) {
3245
4687
  uncertainty: [...deterministicRings.uncertainty, ...discoveredTrace.uncertainty],
3246
4688
  }, budget);
3247
4689
  }
3248
- function assemblyFileStateCacheIdentity(args, keptPaths) {
4690
+ async function assemblyFileStateCacheIdentity(args, keptPaths) {
3249
4691
  const { searchScope, fs, nowMs, deadlineAtMs, deps } = args;
3250
4692
  return fileStateCacheIdentity(keptPaths, searchScope, fs, nowMs, deadlineAtMs, deps.signal);
3251
4693
  }
@@ -3266,14 +4708,14 @@ async function prepareGroundedAssembly(args, augmentedRings, prepared) {
3266
4708
  const withinDeadline = nowMs() < deadlineAtMs;
3267
4709
  const cacheIdentity = deps.microIndex === undefined || hasDocumentEvidence || !withinDeadline
3268
4710
  ? undefined
3269
- : assemblyFileStateCacheIdentity(args, prepared.keptPaths);
4711
+ : await assemblyFileStateCacheIdentity(args, prepared.keptPaths);
3270
4712
  const canStartAssemblySeams = nowMs() < deadlineAtMs;
3271
4713
  const assembleOptions = assembleOptionsFor(deps, nowMs, !hasDocumentEvidence && canStartAssemblySeams, canStartAssemblySeams, deadlineAtMs);
3272
4714
  // The micro-index cache key does not model request-local document evidence, so a scope that
3273
4715
  // carried documents this run must not be served from (or written to) the shared cache.
3274
- const cached = hasDocumentEvidence
4716
+ const cacheKey = hasDocumentEvidence
3275
4717
  ? undefined
3276
- : cachedGroundedPack({
4718
+ : groundedPackCacheKey({
3277
4719
  input,
3278
4720
  plan,
3279
4721
  rings: augmentedRings,
@@ -3283,7 +4725,8 @@ async function prepareGroundedAssembly(args, augmentedRings, prepared) {
3283
4725
  initialUsage: prepared.initialUsage,
3284
4726
  assembleOptions,
3285
4727
  });
3286
- return { documentEvidence, cached, cacheIdentity, assembleOptions };
4728
+ const cached = cacheKey === undefined ? undefined : assembleOptions.microIndex?.get(cacheKey);
4729
+ return { documentEvidence, cached, cacheIdentity, cacheKey, assembleOptions };
3287
4730
  }
3288
4731
  // PR4-W1 (ADR-0055 D1): conditional diagnostics observer. When a ContextProfile is threaded
3289
4732
  // through OrchestratorDeps, the fully assembled pack is enriched with an additive
@@ -3305,10 +4748,10 @@ function withGroundedContextDiagnostics(pack, deps) {
3305
4748
  // claims. Re-derive the identity after the reads and keep it only when every kept path matches the
3306
4749
  // one proven before them; on any mismatch — or an identity that can no longer be established at all
3307
4750
  // — drop the identity so the pack is assembled but never inserted into the cache.
3308
- function excerptBoundCacheIdentity(args, keptPaths, captured) {
4751
+ async function excerptBoundCacheIdentity(args, keptPaths, captured) {
3309
4752
  if (captured === undefined)
3310
4753
  return undefined;
3311
- const current = assemblyFileStateCacheIdentity(args, keptPaths);
4754
+ const current = await assemblyFileStateCacheIdentity(args, keptPaths);
3312
4755
  if (current === undefined)
3313
4756
  return undefined;
3314
4757
  if (current.length !== captured.length)
@@ -3318,20 +4761,24 @@ function excerptBoundCacheIdentity(args, keptPaths, captured) {
3318
4761
  async function assembleGroundedPack(args) {
3319
4762
  const { input, deps, plan, searchScope, fs, nowMs, deadlineAtMs } = args;
3320
4763
  const augmentedRings = await augmentRingsWithDeterministicAtoms(args);
3321
- const prepared = preparePackAssembly(input, plan, augmentedRings, nowMs);
4764
+ const prepared = preparePackAssembly(input, plan, augmentedRings, nowMs, args.hasGitMetadata);
3322
4765
  const ctx = await prepareGroundedAssembly(args, augmentedRings, prepared);
3323
4766
  if (ctx.cached !== undefined) {
3324
4767
  return {
3325
4768
  pack: withGroundedContextDiagnostics(ctx.cached, deps),
4769
+ reusedEvidenceAtomCount: prepared.reusedEvidenceAtomCount,
4770
+ metadataRetention: augmentedRings.metadataRetention,
3326
4771
  elapsedBudgetBlocked: false,
3327
4772
  };
3328
4773
  }
3329
4774
  const excerptReads = await readKeptExcerpts(prepared.keptPaths, {
4775
+ knownFitFileBytes: augmentedRings.knownFitFileBytes,
3330
4776
  searchScope,
3331
4777
  fs,
3332
4778
  budget: plan.budget,
3333
4779
  initialUsage: prepared.initialUsage,
3334
4780
  atomsByPath: prepared.atomsByPath,
4781
+ anchors: plan.anchors.filter((anchor) => anchor.kind !== "path").map((anchor) => anchor.term),
3335
4782
  nowMs,
3336
4783
  signal: deps.signal,
3337
4784
  deadlineAtMs,
@@ -3343,12 +4790,19 @@ async function assembleGroundedPack(args) {
3343
4790
  prepared,
3344
4791
  excerptReads,
3345
4792
  documentEvidence: ctx.documentEvidence,
3346
- cacheIdentity: excerptBoundCacheIdentity(args, prepared.keptPaths, ctx.cacheIdentity),
4793
+ cacheIdentity: await excerptBoundCacheIdentity(args, prepared.keptPaths, ctx.cacheIdentity),
4794
+ cacheKey: ctx.cacheKey,
4795
+ signal: deps.signal,
3347
4796
  assembleOptions: ctx.assembleOptions,
3348
4797
  });
3349
4798
  return {
3350
4799
  pack: withGroundedContextDiagnostics(pack, deps),
4800
+ reusedEvidenceAtomCount: prepared.reusedEvidenceAtomCount,
4801
+ metadataRetention: augmentedRings.metadataRetention,
4802
+ excerptObservation: excerptReads.observation,
3351
4803
  elapsedBudgetBlocked: excerptReads.elapsedBudgetBlocked,
4804
+ anchoredWindowCount: excerptReads.anchoredWindowCount,
4805
+ readWindowCount: excerptReads.readWindowCount,
3352
4806
  };
3353
4807
  }
3354
4808
  const EMPTY_STRUCTURAL_DIAGNOSTICS = {
@@ -3367,15 +4821,22 @@ const NOT_EVALUATED_WORKSPACE_INDEX_DIAGNOSTICS = workspaceIndexActivityDiagnost
3367
4821
  // `elapsedBudgetBlocked` is reported by the assembly that observed it, never hardcoded (#3347 P1):
3368
4822
  // a live retrieval whose excerpt reads were stopped by the absolute deadline reached this status
3369
4823
  // claiming an unblocked elapsed budget, contradicting the elapsed-budget marker on its own pack.
3370
- function liveRetrievalCompletion(workspaceIndexAvailable, elapsedBudgetBlocked) {
4824
+ function liveRetrievalCompletion(workspaceIndexProviderStatus, assembled, decisions) {
3371
4825
  return {
3372
- readBudgetBlocked: false,
3373
- elapsedBudgetBlocked,
3374
- workspaceIndexProviderStatus: workspaceIndexAvailable ? "available" : "unavailable",
4826
+ anchoredExcerptWindowCount: assembled.anchoredWindowCount,
4827
+ excerptReadWindowCount: assembled.readWindowCount,
4828
+ excerptObservation: assembled.excerptObservation,
4829
+ metadataRetention: assembled.metadataRetention,
4830
+ reusedEvidenceAtomCount: assembled.reusedEvidenceAtomCount,
4831
+ decisions,
4832
+ readBudgetBlocked: assembled.excerptObservation?.readBudgetBlocked ?? false,
4833
+ elapsedBudgetBlocked: assembled.elapsedBudgetBlocked,
4834
+ workspaceIndexProviderStatus,
3375
4835
  };
3376
4836
  }
3377
- function stoppedRetrievalCompletion(readBudgetBlocked, elapsedBudgetBlocked) {
4837
+ function stoppedRetrievalCompletion(readBudgetBlocked, elapsedBudgetBlocked, rings) {
3378
4838
  return {
4839
+ decisions: newRingDecisions(rings),
3379
4840
  readBudgetBlocked,
3380
4841
  elapsedBudgetBlocked,
3381
4842
  workspaceIndexProviderStatus: "not-evaluated",
@@ -3395,7 +4856,7 @@ function activityString(record, key) {
3395
4856
  }
3396
4857
  function activityNumber(record, key) {
3397
4858
  const value = activityProperty(record, key);
3398
- return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : "invalid";
4859
+ return typeof value === "number" && Number.isInteger(value) && value >= 0 ? value : "invalid";
3399
4860
  }
3400
4861
  function activityBoolean(record, key) {
3401
4862
  const value = activityProperty(record, key);
@@ -3455,11 +4916,15 @@ function budgetActivityIdentity(input) {
3455
4916
  const budget = activityBudget(input);
3456
4917
  return {
3457
4918
  searchCallsMax: activityNumber(budget, "searchCallsMax"),
3458
- filesReadMax: activityNumber(budget, "filesReadMax"),
4919
+ filesReadMax: activityProperty(budget, "filesReadMax") === null
4920
+ ? null
4921
+ : activityNumber(budget, "filesReadMax"),
3459
4922
  excerptBytesMax: activityNumber(budget, "excerptBytesMax"),
3460
4923
  modelInputTokensMax: activityNumber(budget, "modelInputTokensMax"),
3461
4924
  modelOutputTokensMax: activityNumber(budget, "modelOutputTokensMax"),
3462
- elapsedMsMax: activityNumber(budget, "elapsedMsMax"),
4925
+ elapsedMsMax: activityProperty(budget, "elapsedMsMax") === null
4926
+ ? null
4927
+ : activityNumber(budget, "elapsedMsMax"),
3463
4928
  rerankCallsMax: activityNumber(budget, "rerankCallsMax"),
3464
4929
  };
3465
4930
  }
@@ -3487,7 +4952,7 @@ function connectedContextActivityIdentity(input) {
3487
4952
  };
3488
4953
  }
3489
4954
  function validActivityNumber(value) {
3490
- return value === "invalid" ? undefined : value;
4955
+ return typeof value === "number" ? value : undefined;
3491
4956
  }
3492
4957
  function connectedContextInputStatus(identity) {
3493
4958
  const values = [
@@ -3526,10 +4991,12 @@ function commonActivityExtra(identity) {
3526
4991
  ...(maxResults === undefined ? {} : { maxResults }),
3527
4992
  ...(searchCallsMax === undefined ? {} : { searchCallsMax }),
3528
4993
  ...(filesReadMax === undefined ? {} : { filesReadMax }),
4994
+ filesReadBounded: filesReadMax !== undefined,
3529
4995
  ...(excerptBytesMax === undefined ? {} : { excerptBytesMax }),
3530
4996
  ...(modelInputTokensMax === undefined ? {} : { modelInputTokensMax }),
3531
4997
  ...(modelOutputTokensMax === undefined ? {} : { modelOutputTokensMax }),
3532
4998
  ...(elapsedMsMax === undefined ? {} : { elapsedMsMax }),
4999
+ elapsedMsBounded: elapsedMsMax !== undefined,
3533
5000
  ...(rerankCallsMax === undefined ? {} : { rerankCallsMax }),
3534
5001
  completeness: "complete",
3535
5002
  loss: "none",
@@ -3544,6 +5011,7 @@ function uncertaintyActivityExtra(markers) {
3544
5011
  "tool-unavailable": 0,
3545
5012
  "low-confidence": 0,
3546
5013
  "unsupported-citation": 0,
5014
+ "uncited-answer": 0,
3547
5015
  "incomplete-answer": 0,
3548
5016
  "unsupported-claim": 0,
3549
5017
  "entailment-unavailable": 0,
@@ -3599,6 +5067,7 @@ function workspaceIndexActivityExtra(index) {
3599
5067
  indexSearchCount: index.searchCount,
3600
5068
  indexReportCount: index.reportCount,
3601
5069
  indexFallbackSearchCount: index.fallbackSearchCount,
5070
+ indexBypassedSearchCount: index.bypassedSearchCount,
3602
5071
  indexLoadFailures: index.loadFailures,
3603
5072
  indexSaveFailures: index.saveFailures,
3604
5073
  };
@@ -3614,6 +5083,57 @@ function workspaceIoActivityExtra(io) {
3614
5083
  workspaceIoContentReadBytes: io.contentReadBytes,
3615
5084
  };
3616
5085
  }
5086
+ function contextObservationActivityExtra(pack) {
5087
+ const profile = pack.diagnostics?.contextBudget?.profile;
5088
+ if (profile === undefined)
5089
+ return {};
5090
+ const observed = deriveGroundedContextAssembly(pack, profile);
5091
+ return {
5092
+ contextSelectedExcerptCount: observed.lanes.reduce((sum, lane) => sum + lane.includedItems, 0),
5093
+ contextSelectedExcerptEstimatedTokens: observed.totalEstimatedTokens,
5094
+ contextBudgetPressure: observed.budgetPressure,
5095
+ contextRecencyLayoutApplied: observed.orderedForRecency,
5096
+ };
5097
+ }
5098
+ function retrievalLossActivityExtra(status) {
5099
+ const { excerptObservation: excerpt } = status;
5100
+ return {
5101
+ ...scopeContextActivityExtra(status.scopeContextObservation),
5102
+ ...(excerpt === undefined
5103
+ ? {}
5104
+ : {
5105
+ excerptOmittedRangeCount: excerpt.omittedRangeCount,
5106
+ excerptTruncatedWindowCount: excerpt.truncatedWindowCount,
5107
+ excerptUnreadFileCount: excerpt.unreadFileCount,
5108
+ excerptStopReasons: excerpt.stopReasons,
5109
+ }),
5110
+ };
5111
+ }
5112
+ function metadataRetentionActivityExtra(status) {
5113
+ const { metadataRetention: metadata } = status;
5114
+ return {
5115
+ ...(metadata === undefined
5116
+ ? {}
5117
+ : {
5118
+ metadataObservedCount: metadata.observedCount,
5119
+ metadataRetainedCount: metadata.retainedCount,
5120
+ metadataDiscardedCount: metadata.discardedCount,
5121
+ metadataOmittedDetailCount: metadata.omittedDetailCount,
5122
+ metadataRetentionLimit: metadata.limit,
5123
+ }),
5124
+ };
5125
+ }
5126
+ function scopeContextActivityExtra(observation) {
5127
+ return observation === undefined
5128
+ ? {}
5129
+ : {
5130
+ scopeContextState: observation.state,
5131
+ scopeContextObservedFileCount: observation.observedFileCount,
5132
+ scopeContextRetainedFileCount: observation.retainedFileCount,
5133
+ scopeContextChargedBytes: observation.chargedBytes,
5134
+ scopeContextCapacityBytes: observation.capacityBytes,
5135
+ };
5136
+ }
3617
5137
  function completionActivityExtra(identity, execution) {
3618
5138
  const { pack, plan } = execution.output;
3619
5139
  return {
@@ -3621,15 +5141,30 @@ function completionActivityExtra(identity, execution) {
3621
5141
  queryIdentitySha256: identity.queryIdentitySha256,
3622
5142
  activityDetailStatus: "complete",
3623
5143
  plannedRingCount: plan.rings.length,
5144
+ retrievalIntent: plan.retrievalIntent,
5145
+ ...(plan.targetDecision === undefined
5146
+ ? {}
5147
+ : {
5148
+ retrievalTargetDecision: plan.targetDecision.kind,
5149
+ retrievalTargetCount: plan.targetDecision.targets.length,
5150
+ }),
5151
+ retrievalAnchorCount: plan.anchors.length,
5152
+ ...execution.status.decisions,
3624
5153
  usageSearchCalls: pack.usage.searchCalls,
3625
5154
  usageFilesRead: pack.usage.filesRead,
3626
5155
  usageExcerptBytes: pack.usage.excerptBytes,
5156
+ excerptAnchoredWindowCount: execution.status.anchoredExcerptWindowCount ?? 0,
5157
+ excerptReadWindowCount: execution.status.excerptReadWindowCount ?? 0,
3627
5158
  usageModelInputTokens: pack.usage.modelInputTokens,
3628
5159
  usageModelOutputTokens: pack.usage.modelOutputTokens,
3629
5160
  usageElapsedMs: pack.usage.elapsedMs,
3630
5161
  usageRerankCalls: pack.usage.rerankCalls,
3631
5162
  selectedFileCount: pack.files.length,
3632
- omittedCount: pack.omitted.length,
5163
+ scopeContextSelectedFileCount: pack.files.filter((file) => file.excerpts.some((excerpt) => excerpt.atom.provenance.kind === "file-listing" &&
5164
+ excerpt.atom.provenance.tool === "repo.findFiles" &&
5165
+ excerpt.atom.lineRange !== undefined)).length,
5166
+ ...contextObservationActivityExtra(pack),
5167
+ omittedCount: connectedContextOmittedCount(pack),
3633
5168
  uncertaintyCount: pack.uncertainty.length,
3634
5169
  ...uncertaintyActivityExtra(pack.uncertainty),
3635
5170
  ...coverageActivityExtra(pack),
@@ -3640,11 +5175,33 @@ function completionActivityExtra(identity, execution) {
3640
5175
  loss: "none",
3641
5176
  };
3642
5177
  }
5178
+ function omissionTotalsActivityExtra(pack) {
5179
+ const counts = connectedContextOmittedCounts(pack);
5180
+ return {
5181
+ omittedDetailRetainedCount: pack.omitted.length,
5182
+ omittedDetailsClipped: connectedContextOmittedCount(pack) > pack.omitted.length,
5183
+ omittedOutsideScopeCount: counts["outside-scope"],
5184
+ omittedBinaryCount: counts.binary,
5185
+ omittedGeneratedCount: counts.generated,
5186
+ omittedIgnoredCount: counts.ignored,
5187
+ omittedSizeExceededCount: counts["size-exceeded"],
5188
+ omittedNearDuplicateCount: counts["near-duplicate"],
5189
+ omittedLowRelevanceCount: counts["low-relevance"],
5190
+ omittedRedactedOnlyCount: counts["redacted-only"],
5191
+ omittedBudgetExhaustedCount: counts["budget-exhausted"],
5192
+ omittedToolUnavailableCount: counts["tool-unavailable"],
5193
+ omittedUnsupportedFormatCount: counts["unsupported-format"],
5194
+ omittedNoTextLayerCount: counts["no-text-layer"],
5195
+ omittedMalformedDocumentCount: counts["malformed-document"],
5196
+ omittedEncryptedDocumentCount: counts["encrypted-document"],
5197
+ };
5198
+ }
3643
5199
  function completionDetailsActivityExtra(identity, execution) {
3644
5200
  return {
3645
5201
  scopeIdentitySha256: identity.scopeIdentitySha256,
3646
5202
  queryIdentitySha256: identity.queryIdentitySha256,
3647
5203
  activityDetailStatus: "complete",
5204
+ ...retrievalLossActivityExtra(execution.status),
3648
5205
  ...structuralActivityExtra(execution.structural),
3649
5206
  ...workspaceIndexActivityExtra(execution.workspaceIndex),
3650
5207
  ...workspaceIoActivityExtra(execution.workspaceIo),
@@ -3652,8 +5209,67 @@ function completionDetailsActivityExtra(identity, execution) {
3652
5209
  loss: "none",
3653
5210
  };
3654
5211
  }
5212
+ function sourceDetailsActivityExtra(identity, execution, correlationId) {
5213
+ const shared = {
5214
+ scopeIdentitySha256: identity.scopeIdentitySha256,
5215
+ queryIdentitySha256: identity.queryIdentitySha256,
5216
+ completeness: "complete",
5217
+ loss: "none",
5218
+ };
5219
+ try {
5220
+ return {
5221
+ ...shared,
5222
+ activityDetailStatus: "complete",
5223
+ directEvidenceLookup: execution.output.plan.directEvidenceLookup,
5224
+ reusedEvidenceAtomCount: execution.status.reusedEvidenceAtomCount ?? 0,
5225
+ unrepresentablePathCount: execution.output.pack.diagnostics?.coverage?.unrepresentablePathsByDiscovery ?? 0,
5226
+ ...(execution.status.sourceDecision ?? emptySourceDecision("not-evaluated")),
5227
+ ...metadataRetentionActivityExtra(execution.status),
5228
+ ...omissionTotalsActivityExtra(execution.output.pack),
5229
+ };
5230
+ }
5231
+ catch (error) {
5232
+ reportServerLogFailure(error, { op: "search.connected-context.source-details", correlationId });
5233
+ return { ...shared, activityDetailStatus: "unavailable" };
5234
+ }
5235
+ }
5236
+ function originalSearchFailure(error) {
5237
+ if (contentFreeErrorClass(error) !== "AggregateError")
5238
+ return error;
5239
+ const primary = safeProperty(error, "cause");
5240
+ return isRecord(primary) ? (activityProperty(primary, "cause") ?? primary) : primary;
5241
+ }
5242
+ function aggregateSearchFailureDetails(error) {
5243
+ if (contentFreeErrorClass(error) !== "AggregateError")
5244
+ return {};
5245
+ const candidates = safeProperty(error, "errors");
5246
+ if (!Array.isArray(candidates))
5247
+ return {};
5248
+ const failures = candidates;
5249
+ const primary = safeProperty(error, "cause");
5250
+ const path = isRecord(primary) ? activityProperty(primary, "requestedPath") : undefined;
5251
+ const kinds = failures
5252
+ .slice(0, 16)
5253
+ .filter((failure) => failure !== primary)
5254
+ .map((failure) => {
5255
+ const cause = isRecord(failure) ? activityProperty(failure, "cause") : undefined;
5256
+ return contentFreeErrorClass(cause ?? failure);
5257
+ });
5258
+ return {
5259
+ secondaryFailureCount: failures.length - Number(failures.includes(primary)),
5260
+ secondaryFailureKinds: [...new Set(kinds)].sort(compareStrings),
5261
+ ...(typeof path !== "string"
5262
+ ? {}
5263
+ : {
5264
+ primaryFailureScopeDigest: createHash("sha256").update(path).digest("hex"),
5265
+ }),
5266
+ };
5267
+ }
5268
+ function pendingDirectoryCleanupCount(progress) {
5269
+ return progress.workspaceIoActivity?.pendingCleanupCount() ?? 0;
5270
+ }
3655
5271
  function failureActivityExtra(identity, error, progress, cancelled) {
3656
- const frames = keikoStackFrames(error);
5272
+ const frames = keikoStackFrames(originalSearchFailure(error));
3657
5273
  const chain = causeChain(error);
3658
5274
  const structural = progress.structuralContexts?.diagnostics() ?? EMPTY_STRUCTURAL_DIAGNOSTICS;
3659
5275
  const index = progress.workspaceIndexActivity?.diagnostics() ?? NOT_EVALUATED_WORKSPACE_INDEX_DIAGNOSTICS;
@@ -3669,6 +5285,8 @@ function failureActivityExtra(identity, error, progress, cancelled) {
3669
5285
  ...structuralActivityExtra(structural),
3670
5286
  ...workspaceIndexActivityExtra(index),
3671
5287
  ...workspaceIoActivityExtra(io),
5288
+ ...aggregateSearchFailureDetails(error),
5289
+ directoryCleanupPendingCount: pendingDirectoryCleanupCount(progress),
3672
5290
  ...(frames.length === 0 ? {} : { frames }),
3673
5291
  ...(chain.length === 0 ? {} : { causeChain: chain }),
3674
5292
  completeness: "complete",
@@ -3766,38 +5384,72 @@ function safeFailureActivityExtra(identity, error, progress, cancelled, correlat
3766
5384
  return unavailableFailureActivityExtra(identity, progress, cancelled);
3767
5385
  }
3768
5386
  }
3769
- function logConnectedContextCompletion(logger, identity, execution, correlationId, durationMs) {
5387
+ function logConnectedContextCompletion(logger, identity, execution, correlationId, durationMs, metadataUnavailableInspectionCount) {
3770
5388
  logger.info(() => activityLogEvent(SEARCH_CONNECTED_CONTEXT_COMPLETION_DETAILS_OPERATION, { correlationId }, safeCompletionDetailsActivityExtra(identity, execution, correlationId)));
5389
+ logger.info(() => activityLogEvent(SEARCH_CONNECTED_CONTEXT_SOURCE_DETAILS_OPERATION, { correlationId }, {
5390
+ ...sourceDetailsActivityExtra(identity, execution, correlationId),
5391
+ metadataUnavailableInspectionCount,
5392
+ }));
3771
5393
  logger.info(() => activityLogEvent(SEARCH_CONNECTED_CONTEXT_COMPLETED_OPERATION, { correlationId, durationMs }, safeCompletionActivityExtra(identity, execution, correlationId)));
3772
5394
  }
5395
+ function logConnectedContextClarification(logger, identity, plan, correlationId, durationMs) {
5396
+ logger.info(() => activityLogEvent(SEARCH_CONNECTED_CONTEXT_CLARIFICATION_OPERATION, { correlationId, durationMs }, {
5397
+ scopeIdentitySha256: identity.scopeIdentitySha256,
5398
+ queryIdentitySha256: identity.queryIdentitySha256,
5399
+ clarificationReason: plan.clarification?.reason ?? "scope-invalid",
5400
+ retrievalIntent: plan.retrievalIntent,
5401
+ directEvidenceLookup: plan.directEvidenceLookup,
5402
+ anchorCount: plan.anchors.length,
5403
+ plannedRingCount: plan.rings.length,
5404
+ completeness: "complete",
5405
+ loss: "none",
5406
+ }));
5407
+ }
5408
+ function logConnectedContextFailure(logger, identity, error, progress, correlationId, durationMs) {
5409
+ const errorKind = safeConnectedContextErrorKind(error);
5410
+ const cancelled = isConnectedContextCancellation(error, errorKind);
5411
+ const event = () => activityLogEvent(SEARCH_CONNECTED_CONTEXT_FAILED_OPERATION, { correlationId, durationMs, errorKind }, safeFailureActivityExtra(identity, error, progress, cancelled, correlationId));
5412
+ if (cancelled)
5413
+ logger.warn(event);
5414
+ else
5415
+ logger.error(event);
5416
+ }
3773
5417
  function createConnectedContextActivity(input, deps, nowMs, logicalStartMs) {
3774
- const sink = deps.activityLog ?? processServerLogSink();
3775
- const logger = createServerLogger({ sink, level: "debug" });
5418
+ const logger = createServerLogger({
5419
+ sink: deps.activityLog ?? processServerLogSink(),
5420
+ level: "debug",
5421
+ });
3776
5422
  const correlationId = correlationIdOrUnknown(deps.correlationId);
3777
5423
  const identity = connectedContextActivityIdentity(input);
3778
5424
  const logElapsed = startLogTimer();
5425
+ let metadataUnavailableInspectionCount = 0;
3779
5426
  return {
5427
+ symbolReadFailure: createSymbolReadFailureObserver(logger, correlationId),
3780
5428
  elapsedMs: () => Math.max(0, nowMs() - logicalStartMs),
3781
5429
  started: () => {
3782
5430
  logger.info(() => activityLogEvent(SEARCH_CONNECTED_CONTEXT_STARTED_OPERATION, { correlationId }, commonActivityExtra(identity)));
3783
5431
  },
3784
5432
  completed: (execution) => {
3785
- logConnectedContextCompletion(logger, identity, execution, correlationId, logElapsed());
5433
+ logConnectedContextCompletion(logger, identity, execution, correlationId, logElapsed(), metadataUnavailableInspectionCount);
5434
+ },
5435
+ clarification: (plan) => {
5436
+ logConnectedContextClarification(logger, identity, plan, correlationId, logElapsed());
5437
+ },
5438
+ metadataUnavailable: (error, scopePath) => {
5439
+ metadataUnavailableInspectionCount += 1;
5440
+ logger.warn(() => metadataUnavailableEvent(error, scopePath, identity, correlationId));
3786
5441
  },
3787
5442
  failed: (error, progress) => {
3788
- const errorKind = safeConnectedContextErrorKind(error);
3789
- const cancelled = isConnectedContextCancellation(error, errorKind);
3790
- const event = () => activityLogEvent(SEARCH_CONNECTED_CONTEXT_FAILED_OPERATION, { correlationId, durationMs: logElapsed(), errorKind }, safeFailureActivityExtra(identity, error, progress, cancelled, correlationId));
3791
- if (cancelled)
3792
- logger.warn(event);
3793
- else
3794
- logger.error(event);
5443
+ logConnectedContextFailure(logger, identity, error, progress, correlationId, logElapsed());
3795
5444
  },
3796
5445
  };
3797
5446
  }
3798
5447
  function fallbackConnectedContextActivity(nowMs, logicalStartMs) {
3799
5448
  return {
5449
+ symbolReadFailure: createSymbolReadFailureObserver(undefined, undefined),
3800
5450
  elapsedMs: () => Math.max(0, nowMs() - logicalStartMs),
5451
+ metadataUnavailable: () => undefined,
5452
+ clarification: () => undefined,
3801
5453
  started: () => undefined,
3802
5454
  completed: () => undefined,
3803
5455
  failed: () => undefined,
@@ -3832,8 +5484,18 @@ function connectedContextExecution(pack, plan, activity, status, structural, wor
3832
5484
  function connectedContextSearchInputs(input, deps, plan, runtime, context) {
3833
5485
  const { workspaceIndex } = context;
3834
5486
  return {
5487
+ observeSourceDecision: (observation) => {
5488
+ runtime.progress.sourceDecision = observation;
5489
+ },
5490
+ discoverDefinitions: (governor, evidence) => discoverDefinitionsBeforeGraphs(liveGroundedPackInputs(input, deps, plan, runtime, context, { ...evidence, governor })),
5491
+ scopeContextBytesMax: plan.budget.excerptBytesMax,
5492
+ observeScopeContext: (observation) => {
5493
+ runtime.progress.scopeContextObservation = observation;
5494
+ },
5495
+ hasGitMetadata: context.hasGitMetadata,
3835
5496
  searchScope: context.searchScope,
3836
5497
  query: input.query,
5498
+ targetDecision: plan.targetDecision ?? resolveQueryTargetDecision(input.query, plan.anchors),
3837
5499
  anchors: plan.anchors,
3838
5500
  retrievalIntent: plan.retrievalIntent,
3839
5501
  fs: context.ringFs,
@@ -3999,9 +5661,23 @@ function observedCanonicalWorkspaceRoot(fs, counters, canonicalRoots, observedRe
3999
5661
  canonicalRoots.set(key, canonical);
4000
5662
  return canonical;
4001
5663
  }
4002
- function requestScopedWorkspaceFs(fs) {
5664
+ function observedDirectoryIteration(fs, counters, onCleanupFailure, onCleanup) {
5665
+ const iterate = workspaceFsProperty(fs, "iterateDirectory");
5666
+ if (iterate === undefined)
5667
+ return {};
5668
+ return {
5669
+ iterateDirectory: (path) => {
5670
+ counters.readDirCalls += 1;
5671
+ return observeDirectoryIteration(iterate.call(fs, path), () => {
5672
+ addWorkspaceIoPayloadCount(counters, "readDirEntries", 1);
5673
+ }, onCleanupFailure, onCleanup);
5674
+ },
5675
+ };
5676
+ }
5677
+ function requestScopedWorkspaceFs(fs, onCleanupFailure) {
4003
5678
  const counters = emptyWorkspaceIoActivityDiagnostics();
4004
5679
  const canonicalRoots = new Map();
5680
+ const cleanup = directoryCleanupTracker();
4005
5681
  const observedRealPath = (absolutePath) => {
4006
5682
  counters.realPathCalls += 1;
4007
5683
  return fs.realPath(absolutePath);
@@ -4031,6 +5707,7 @@ function requestScopedWorkspaceFs(fs) {
4031
5707
  counters.existsCalls += 1;
4032
5708
  return fs.exists(absolutePath);
4033
5709
  },
5710
+ ...observedDirectoryIteration(fs, counters, onCleanupFailure, cleanup.observe),
4034
5711
  ...observedSynchronousContentReads(fs, counters),
4035
5712
  ...observedAsyncContentReads(fs, counters),
4036
5713
  canonicalWorkspaceRoot: (absoluteRoot) => observedCanonicalWorkspaceRoot(fs, counters, canonicalRoots, observedRealPath, absoluteRoot),
@@ -4038,6 +5715,7 @@ function requestScopedWorkspaceFs(fs) {
4038
5715
  return {
4039
5716
  fs: observedFs,
4040
5717
  diagnostics: () => ({ ...counters }),
5718
+ pendingCleanupCount: cleanup.pendingCount,
4041
5719
  };
4042
5720
  }
4043
5721
  // One request-wide sentinel cap for the ring-retrieval directory snapshot (#3347 P1). Ring
@@ -4146,8 +5824,13 @@ function detectionGuardedFs(fs, control) {
4146
5824
  exists: (path) => run(() => fs.exists(path)),
4147
5825
  });
4148
5826
  }
5827
+ function explorationDeadlineAtMs(startedAtMs, budget) {
5828
+ return budget.elapsedMsMax === null
5829
+ ? Number.POSITIVE_INFINITY
5830
+ : startedAtMs + Math.max(0, budget.elapsedMsMax);
5831
+ }
4149
5832
  function prepareLiveRetrievalContext(input, deps, plan, runtime) {
4150
- const deadlineAtMs = runtime.requestStartedAtMs + Math.max(0, plan.budget.elapsedMsMax);
5833
+ const deadlineAtMs = explorationDeadlineAtMs(runtime.requestStartedAtMs, plan.budget);
4151
5834
  runtime.progress.phase = "workspace-detection";
4152
5835
  const detectionControl = {
4153
5836
  signal: deps.signal,
@@ -4155,6 +5838,7 @@ function prepareLiveRetrievalContext(input, deps, plan, runtime) {
4155
5838
  deadlineAtMs,
4156
5839
  };
4157
5840
  const workspace = runtime.detect(runtime.workspaceRoot, detectionGuardedFs(runtime.fs, detectionControl));
5841
+ const hasGitMetadata = detectionGuardedFs(runtime.fs, detectionControl).exists(resolve(workspace.root, ".git"));
4158
5842
  const searchScope = buildSearchScope(input.scope, workspace);
4159
5843
  const workspaceIndexSource = runtime.nowMs() < deadlineAtMs ? deps.workspaceIndexForRoot?.(workspace.root) : undefined;
4160
5844
  const workspaceIndexActivity = createWorkspaceIndexActivity(workspaceIndexSource);
@@ -4163,17 +5847,19 @@ function prepareLiveRetrievalContext(input, deps, plan, runtime) {
4163
5847
  const structuralContexts = liveStructuralContexts(searchScope, ringFs, runtime, deadlineAtMs, workspaceIndexActivity, deps.signal);
4164
5848
  runtime.progress.structuralContexts = structuralContexts;
4165
5849
  return {
5850
+ hasGitMetadata,
4166
5851
  deadlineAtMs,
4167
5852
  searchScope,
4168
5853
  ringFs,
4169
5854
  structuralContexts,
4170
- workspaceIndexSource,
4171
5855
  workspaceIndexActivity,
4172
5856
  workspaceIndex: workspaceIndexActivity.workspaceIndex,
4173
5857
  };
4174
5858
  }
4175
5859
  function liveGroundedPackInputs(input, deps, plan, runtime, context, rings) {
4176
5860
  return {
5861
+ recordMetadataUnavailable: runtime.activity.metadataUnavailable,
5862
+ recordSymbolReadFailure: runtime.activity.symbolReadFailure,
4177
5863
  input,
4178
5864
  deps,
4179
5865
  plan,
@@ -4185,6 +5871,7 @@ function liveGroundedPackInputs(input, deps, plan, runtime, context, rings) {
4185
5871
  structuralContexts: context.structuralContexts,
4186
5872
  workspaceIndex: context.workspaceIndex,
4187
5873
  deadlineAtMs: context.deadlineAtMs,
5874
+ hasGitMetadata: context.hasGitMetadata,
4188
5875
  };
4189
5876
  }
4190
5877
  async function retrieveLiveConnectedContext(input, deps, plan, governor, runtime, context) {
@@ -4194,12 +5881,17 @@ async function retrieveLiveConnectedContext(input, deps, plan, governor, runtime
4194
5881
  runtime.progress.phase = "pack-assembly";
4195
5882
  const assembled = await assembleGroundedPack(liveGroundedPackInputs(input, deps, plan, runtime, context, rings));
4196
5883
  throwIfCancelled(deps.signal);
4197
- return connectedContextExecution(assembled.pack, plan, runtime.activity, liveRetrievalCompletion(context.workspaceIndexSource !== undefined, assembled.elapsedBudgetBlocked), context.structuralContexts.diagnostics(), context.workspaceIndexActivity.diagnostics(), runtime.workspaceIoActivity.diagnostics());
5884
+ const workspaceIndex = context.workspaceIndexActivity.diagnostics();
5885
+ return connectedContextExecution(assembled.pack, plan, runtime.activity, {
5886
+ ...liveRetrievalCompletion(workspaceIndex.providerStatus, assembled, rings.decisions),
5887
+ scopeContextObservation: runtime.progress.scopeContextObservation,
5888
+ sourceDecision: runtime.progress.sourceDecision,
5889
+ }, context.structuralContexts.diagnostics(), workspaceIndex, runtime.workspaceIoActivity.diagnostics());
4198
5890
  }
4199
5891
  async function emptyBudgetExhaustedRetrieval(input, deps, plan, governor, runtime, stop) {
4200
5892
  runtime.progress.phase = "empty-pack-assembly";
4201
5893
  const stoppedGovernor = stop.elapsedBudgetBlocked
4202
- ? applyUsage(governor, usageDelta({ elapsedMs: plan.budget.elapsedMsMax }))
5894
+ ? applyUsage(governor, usageDelta({ elapsedMs: plan.budget.elapsedMsMax ?? 0 }))
4203
5895
  : governor;
4204
5896
  const pack = await assembleEmptyGroundedPack({
4205
5897
  input,
@@ -4210,7 +5902,7 @@ async function emptyBudgetExhaustedRetrieval(input, deps, plan, governor, runtim
4210
5902
  stopReason: stop.stopReason,
4211
5903
  });
4212
5904
  throwIfCancelled(deps.signal);
4213
- return connectedContextExecution(pack, plan, runtime.activity, stoppedRetrievalCompletion(stop.readBudgetBlocked, stop.elapsedBudgetBlocked), EMPTY_STRUCTURAL_DIAGNOSTICS, NOT_EVALUATED_WORKSPACE_INDEX_DIAGNOSTICS, runtime.workspaceIoActivity.diagnostics());
5905
+ return connectedContextExecution(pack, plan, runtime.activity, stoppedRetrievalCompletion(stop.readBudgetBlocked, stop.elapsedBudgetBlocked, plan.rings), EMPTY_STRUCTURAL_DIAGNOSTICS, NOT_EVALUATED_WORKSPACE_INDEX_DIAGNOSTICS, runtime.workspaceIoActivity.diagnostics());
4214
5906
  }
4215
5907
  // #3347 P2: workspace detection is deadline/signal-guarded (see prepareLiveRetrievalContext) so a
4216
5908
  // request that is already out of budget by the time detection runs stops mid-traversal instead of
@@ -4239,7 +5931,7 @@ async function retrieveLiveOrDeadlineExhausted(input, deps, plan, governor, runt
4239
5931
  async function executeConnectedContextRetrieval(input, deps, runtime) {
4240
5932
  throwIfCancelled(deps.signal);
4241
5933
  runtime.progress.phase = "planning";
4242
- const { plan, governor } = createReadyGovernedPlan(input, runtime.nowMs);
5934
+ const { plan, governor } = createReadyGovernedPlan(input, runtime.nowMs, runtime.progress);
4243
5935
  runtime.progress.plannedRingCount = plan.rings.length;
4244
5936
  deps.recordPlan?.(plan);
4245
5937
  throwIfCancelled(deps.signal);
@@ -4250,7 +5942,7 @@ async function executeConnectedContextRetrieval(input, deps, runtime) {
4250
5942
  };
4251
5943
  runtime.progress.phase = "budget-evaluation";
4252
5944
  const readBudgetBlock = readBudgetStopReason(plan.budget);
4253
- const deadlineAtMs = runtime.requestStartedAtMs + Math.max(0, plan.budget.elapsedMsMax);
5945
+ const deadlineAtMs = explorationDeadlineAtMs(runtime.requestStartedAtMs, plan.budget);
4254
5946
  const elapsedBudgetBlock = runtime.nowMs() >= deadlineAtMs ? "budget-exhausted on elapsedMs" : undefined;
4255
5947
  const stopReason = readBudgetBlock ?? elapsedBudgetBlock;
4256
5948
  if (stopReason === undefined) {
@@ -4276,11 +5968,21 @@ function assertGroundedWorkspaceRootAllowed(fs, workspaceRoot, deps) {
4276
5968
  error instanceof CancelledError) {
4277
5969
  throw error;
4278
5970
  }
4279
- throw new WorkspaceNotFoundError("The workspace root is unavailable.", workspaceRoot, [
4280
- workspaceRoot,
4281
- ]);
5971
+ if (!isExpectedWorkspaceRootFailure(error))
5972
+ throw error;
5973
+ const unavailable = new WorkspaceNotFoundError("The workspace root is unavailable.", workspaceRoot, [workspaceRoot]);
5974
+ unavailable.cause = error;
5975
+ throw unavailable;
4282
5976
  }
4283
5977
  }
5978
+ function recordConnectedContextFailureOutcome(activity, error, progress) {
5979
+ if (progress.phase === "planning" &&
5980
+ progress.plan !== undefined &&
5981
+ progress.plan.state !== "ready")
5982
+ activity.clarification(progress.plan);
5983
+ else
5984
+ activity.failed(error, progress);
5985
+ }
4284
5986
  export async function retrieveConnectedContextPack(input, deps) {
4285
5987
  const nowMs = deps.nowMs ?? Date.now;
4286
5988
  const requestStartedAtMs = nowMs();
@@ -4291,7 +5993,9 @@ export async function retrieveConnectedContextPack(input, deps) {
4291
5993
  };
4292
5994
  activity.started();
4293
5995
  try {
4294
- const workspaceIoActivity = requestScopedWorkspaceFs(input.workspaceFs ?? deps.fs ?? nodeWorkspaceFs);
5996
+ const workspaceIoActivity = requestScopedWorkspaceFs(input.workspaceFs ?? deps.fs ?? nodeWorkspaceFs, (error) => {
5997
+ activity.failed(error, { ...progress, phase: "directory-cleanup" });
5998
+ });
4295
5999
  progress.workspaceIoActivity = workspaceIoActivity;
4296
6000
  const execution = await executeConnectedContextRetrieval(input, deps, {
4297
6001
  fs: workspaceIoActivity.fs,
@@ -4307,7 +6011,9 @@ export async function retrieveConnectedContextPack(input, deps) {
4307
6011
  return execution.output;
4308
6012
  }
4309
6013
  catch (error) {
4310
- activity.failed(error, progress);
6014
+ // A queued iterator return may be waiting on an OS read that JavaScript cannot interrupt.
6015
+ // Publish the original failure now; the owned observer still records later cleanup failures.
6016
+ recordConnectedContextFailureOutcome(activity, error, progress);
4311
6017
  throw error;
4312
6018
  }
4313
6019
  }
@@ -4316,12 +6022,12 @@ export async function retrieveConnectedContextPack(input, deps) {
4316
6022
  async function entailmentMarkersFor(deps, answerContent, pack, nowMs) {
4317
6023
  return (await deps.entailmentStage?.evaluate(answerContent, [pack], nowMs)) ?? [];
4318
6024
  }
4319
- function citationCoverageMarkerFor(answerContent, pack, nowMs) {
4320
- const reconciliation = reconcileInlineCitations(answerContent, buildPackCitationIndex([pack]));
6025
+ function citationCoverageMarkerFor(answerContent, pack, nowMs, correlationId) {
6026
+ const reconciliation = reconcileAndLogInlineCitations(answerContent, buildPackCitationIndex([pack]), correlationId);
4321
6027
  const unsupported = unsupportedCitationMarker(reconciliation.unsupported, nowMs);
4322
6028
  if (unsupported !== undefined || reconciliation.citedScopePaths.size > 0)
4323
6029
  return unsupported;
4324
- return missingCitationMarker(nowMs);
6030
+ return missingCitationMarkerFor(answerContent, nowMs);
4325
6031
  }
4326
6032
  function exhaustedAnswerBudgetDimensions(answer, pack, elapsedMs) {
4327
6033
  return [
@@ -4329,14 +6035,16 @@ function exhaustedAnswerBudgetDimensions(answer, pack, elapsedMs) {
4329
6035
  ...(answer.usage.completionTokens > pack.budget.modelOutputTokensMax
4330
6036
  ? ["modelOutputTokens"]
4331
6037
  : []),
4332
- ...(elapsedMs > pack.budget.elapsedMsMax ? ["elapsedMs"] : []),
6038
+ ...(pack.budget.elapsedMsMax !== null && elapsedMs > pack.budget.elapsedMsMax
6039
+ ? ["elapsedMs"]
6040
+ : []),
4333
6041
  ];
4334
6042
  }
4335
6043
  async function answerWithAvailableContext(input, deps, pack, plan, sourceEvidenceAvailable, start, nowMs) {
4336
6044
  const answer = normalizeGroundedAnswerPayload(await deps.answerer.answer(input.answerQuestion ?? input.query.text, pack));
4337
6045
  const elapsedMs = Math.max(0, nowMs() - start);
4338
6046
  const exhausted = exhaustedAnswerBudgetDimensions(answer, pack, elapsedMs);
4339
- const unsupportedMarker = citationCoverageMarkerFor(answer.content, pack, nowMs());
6047
+ const unsupportedMarker = citationCoverageMarkerFor(answer.content, pack, nowMs(), deps.correlationId);
4340
6048
  const entailmentMarkers = await entailmentMarkersFor(deps, answer.content, pack, nowMs());
4341
6049
  const groundedPack = {
4342
6050
  ...pack,
@@ -4344,7 +6052,7 @@ async function answerWithAvailableContext(input, deps, pack, plan, sourceEvidenc
4344
6052
  ...pack.usage,
4345
6053
  modelInputTokens: Math.min(answer.usage.promptTokens, pack.budget.modelInputTokensMax),
4346
6054
  modelOutputTokens: Math.min(answer.usage.completionTokens, pack.budget.modelOutputTokensMax),
4347
- elapsedMs: Math.min(Math.max(pack.usage.elapsedMs, elapsedMs), pack.budget.elapsedMsMax),
6055
+ elapsedMs: Math.min(Math.max(pack.usage.elapsedMs, elapsedMs), pack.budget.elapsedMsMax ?? Number.POSITIVE_INFINITY),
4348
6056
  },
4349
6057
  uncertainty: [
4350
6058
  ...pack.uncertainty,
@@ -4359,6 +6067,7 @@ async function answerWithAvailableContext(input, deps, pack, plan, sourceEvidenc
4359
6067
  assistantContent: answer.content,
4360
6068
  elapsedMs,
4361
6069
  modelInvoked: true,
6070
+ ...(answer.promptContext === undefined ? {} : { promptContext: answer.promptContext }),
4362
6071
  ...(plan === undefined ? {} : { plan }),
4363
6072
  ...(!sourceEvidenceAvailable ? { noEvidence: true } : {}),
4364
6073
  };
@@ -4380,7 +6089,7 @@ export async function runGroundedExploration(input, deps) {
4380
6089
  const elapsedMs = Math.max(0, nowMs() - start);
4381
6090
  return {
4382
6091
  pack,
4383
- assistantContent: GROUNDED_NO_EVIDENCE_ANSWER,
6092
+ assistantContent: connectedSearchNoEvidenceAnswer(input.currentQuestion ?? input.query.text),
4384
6093
  elapsedMs,
4385
6094
  plan,
4386
6095
  noEvidence: true,