@oscharko-dev/keiko 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1015) hide show
  1. package/README.md +10 -2
  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 +2 -2
  7. package/dist/ui/static/_next/static/chunks/014h2nyfet3kr.js +1 -0
  8. package/dist/ui/static/_next/static/chunks/02ahxxpsbao7z.js +1 -0
  9. package/dist/ui/static/_next/static/chunks/0851fl0j1ja4e.js +1 -0
  10. package/dist/ui/static/_next/static/chunks/08896ukd2zxg6.js +1 -0
  11. package/dist/ui/static/_next/static/chunks/08nml2svyd9vv.js +4 -0
  12. package/dist/ui/static/_next/static/chunks/08tg5xjyy073b.js +1 -0
  13. package/dist/ui/static/_next/static/chunks/09p2ty64ellxo.js +1 -0
  14. package/dist/ui/static/_next/static/chunks/0b7xat6jxvrmr.js +1 -0
  15. package/dist/ui/static/_next/static/chunks/{196257vfyrtgu.js → 0d3a8-uxb000v.js} +1 -1
  16. package/dist/ui/static/_next/static/chunks/{388eokaf_2t9k.js → 0jjhji-e9mg99.js} +1 -1
  17. package/dist/ui/static/_next/static/chunks/0jtp8te-03j1-.js +1 -0
  18. package/dist/ui/static/_next/static/chunks/0lw_ax6yn_z8w.js +1 -0
  19. package/dist/ui/static/_next/static/chunks/0oocu54xdbxf3.js +2 -0
  20. package/dist/ui/static/_next/static/chunks/{3h-rh_lx0l8_3.js → 0pf5ot48kepng.js} +1 -1
  21. package/dist/ui/static/_next/static/chunks/0rs9egrg2q85w.js +1 -0
  22. package/dist/ui/static/_next/static/chunks/{3hclt6m3ok4n9.js → 0rsutf6da798_.js} +1 -1
  23. package/dist/ui/static/_next/static/chunks/0rw0et8bt6w-b.js +1 -0
  24. package/dist/ui/static/_next/static/chunks/{2b_t95bbpmtej.js → 0su17ctiaqfp0.js} +1 -1
  25. package/dist/ui/static/_next/static/chunks/0wok-g3ndtvch.js +1 -0
  26. package/dist/ui/static/_next/static/chunks/0y3402xorco2c.js +1 -0
  27. package/dist/ui/static/_next/static/chunks/10p1rdlk7n_9w.js +1 -0
  28. package/dist/ui/static/_next/static/chunks/12aem44im45f-.js +1 -0
  29. package/dist/ui/static/_next/static/chunks/18kcx5kpyxr16.js +1 -0
  30. package/dist/ui/static/_next/static/chunks/1ggcq_lho062y.js +1 -0
  31. package/dist/ui/static/_next/static/chunks/1o-own3kgpojf.js +1 -0
  32. package/dist/ui/static/_next/static/chunks/{0l72usw6suk0h.js → 1osovjtjgxmbl.js} +1 -1
  33. package/dist/ui/static/_next/static/chunks/1uu9slkxpbe4y.js +1 -0
  34. package/dist/ui/static/_next/static/chunks/1vy80v9kp_rqv.js +1 -0
  35. package/dist/ui/static/_next/static/chunks/1x-sfb1_rl15-.js +1 -0
  36. package/dist/ui/static/_next/static/chunks/1zqfkyeqq5cl8.js +1 -0
  37. package/dist/ui/static/_next/static/chunks/{3603jy78awb1p.js → 1zw11x_e-3fzu.js} +1 -1
  38. package/dist/ui/static/_next/static/chunks/20-u8pg5ve_cz.js +1 -0
  39. package/dist/ui/static/_next/static/chunks/22zxuap4am9bs.js +1 -0
  40. package/dist/ui/static/_next/static/chunks/23lstlpeh2rb-.js +1 -0
  41. package/dist/ui/static/_next/static/chunks/261euyxjrb0lv.js +1 -0
  42. package/dist/ui/static/_next/static/chunks/2astwwmbb8e53.js +1 -0
  43. package/dist/ui/static/_next/static/chunks/2duxlo7cg_s7_.js +3 -0
  44. package/dist/ui/static/_next/static/chunks/2dwrkrp-gqyej.js +1 -0
  45. package/dist/ui/static/_next/static/chunks/{1m-9yzfpcm7wc.js → 2ef4l5re80dgi.js} +1 -1
  46. package/dist/ui/static/_next/static/chunks/2g_pljoa8f0e-.js +1 -0
  47. package/dist/ui/static/_next/static/chunks/{09zc5hgtb7s-z.js → 2h4vqb2rt3mr1.js} +1 -1
  48. package/dist/ui/static/_next/static/chunks/{3qjkuhjy_-_br.js → 2imh4llefx9d1.js} +1 -1
  49. package/dist/ui/static/_next/static/chunks/2jsnrkl0syr4y.js +1 -0
  50. package/dist/ui/static/_next/static/chunks/{0--s8pmsbkf62.js → 2ta3jr_uw2j0x.js} +1 -1
  51. package/dist/ui/static/_next/static/chunks/{2y98z-sun8_ew.js → 2u5_pu1uc6seh.js} +1 -1
  52. package/dist/ui/static/_next/static/chunks/2xd3_a4jlxum2.css +1 -0
  53. package/dist/ui/static/_next/static/chunks/{0mjsj7bp-ukgh.css → 2yuvdrio9ki3a.css} +26 -9
  54. package/dist/ui/static/_next/static/chunks/3-pcgkdsv7x4z.js +1 -0
  55. package/dist/ui/static/_next/static/chunks/{0yzmg9aoglud6.js → 3007ncr8g751a.js} +1 -1
  56. package/dist/ui/static/_next/static/chunks/307xuhrdmetj7.js +1 -0
  57. package/dist/ui/static/_next/static/chunks/30og31pxg8wrp.js +1 -0
  58. package/dist/ui/static/_next/static/chunks/32jgtvf2y-f54.js +1 -0
  59. package/dist/ui/static/_next/static/chunks/35ivnhnxr9dmz.js +1 -0
  60. package/dist/ui/static/_next/static/chunks/363iuc3t94rie.js +1 -0
  61. package/dist/ui/static/_next/static/chunks/37qsy798-g74f.js +1 -0
  62. package/dist/ui/static/_next/static/chunks/37v998g0cm36x.js +1 -0
  63. package/dist/ui/static/_next/static/chunks/3b05n-007vc3e.js +1 -0
  64. package/dist/ui/static/_next/static/chunks/3cpuzx4fetu6y.js +1 -0
  65. package/dist/ui/static/_next/static/chunks/3d27ozm1boe_5.js +3 -0
  66. package/dist/ui/static/_next/static/chunks/{1a6ri-sriyu-m.js → 3ftqojkan-5cl.js} +1 -1
  67. package/dist/ui/static/_next/static/chunks/3fwt6-8rc2mya.js +1 -0
  68. package/dist/ui/static/_next/static/chunks/{196x_tfexoucg.js → 3g4px251sg85e.js} +1 -1
  69. package/dist/ui/static/_next/static/chunks/3hjs3gk92eave.js +1 -0
  70. package/dist/ui/static/_next/static/chunks/{1n3b0bhd9q0p6.js → 3l3xw2fmr7pct.js} +3 -3
  71. package/dist/ui/static/_next/static/chunks/3neoxf-shnu-d.js +1 -0
  72. package/dist/ui/static/_next/static/chunks/3payvp5ps2fne.css +3 -0
  73. package/dist/ui/static/_next/static/chunks/3q-93bizla3k1.js +1 -0
  74. package/dist/ui/static/_next/static/chunks/{3eduf6vevclfm.js → 3qbbcm9fuk494.js} +1 -1
  75. package/dist/ui/static/_next/static/chunks/{2ta3xj9td_qot.js → 3rhep1yhgo6a7.js} +1 -1
  76. package/dist/ui/static/_next/static/chunks/{0bpexy600ffpg.js → 3ty06iqiblqi4.js} +1 -1
  77. package/dist/ui/static/_next/static/chunks/{0iu3dyqe7m7_7.js → 3wz98o059mhtf.js} +1 -1
  78. package/dist/ui/static/_next/static/chunks/{2kylv1kq1_4p1.js → 3x2p8mgrihuet.js} +1 -1
  79. package/dist/ui/static/_next/static/chunks/3xi3iilmw9_vy.js +5 -0
  80. package/dist/ui/static/_next/static/chunks/3zxbqudoeow_a.js +1 -0
  81. package/dist/ui/static/_next/static/chunks/3zxwlxhzm5swe.js +1 -0
  82. package/dist/ui/static/_next/static/chunks/{24u-5fslcj3n9.js → 405vbzo164i84.js} +2 -2
  83. package/dist/ui/static/_next/static/chunks/42pls95xys34g.js +1 -0
  84. package/dist/ui/static/_next/static/chunks/43z5mfwx4lk4w.js +1 -0
  85. package/dist/ui/static/_next/static/chunks/{turbopack-2rwr7ign9ynaa.js → turbopack-34k8wgx0iwdzg.js} +1 -1
  86. package/dist/ui/static/_not-found/__next._full.txt +21 -20
  87. package/dist/ui/static/_not-found/__next._not-found.__PAGE__.txt +9 -9
  88. package/dist/ui/static/_not-found/__next._tree.txt +1 -1
  89. package/dist/ui/static/_not-found.html +1 -1
  90. package/dist/ui/static/_not-found.txt +21 -20
  91. package/dist/ui/static/atlassian-connectors/__next._full.txt +23 -22
  92. package/dist/ui/static/atlassian-connectors/__next._tree.txt +1 -1
  93. package/dist/ui/static/atlassian-connectors/__next.atlassian-connectors.__PAGE__.txt +11 -11
  94. package/dist/ui/static/atlassian-connectors.html +1 -1
  95. package/dist/ui/static/atlassian-connectors.txt +23 -22
  96. package/dist/ui/static/index.html +1 -1
  97. package/dist/ui/static/index.txt +23 -22
  98. package/dist/ui/static/launch/__next._full.txt +26 -25
  99. package/dist/ui/static/launch/__next._tree.txt +2 -2
  100. package/dist/ui/static/launch/__next.launch.__PAGE__.txt +12 -12
  101. package/dist/ui/static/launch.html +1 -1
  102. package/dist/ui/static/launch.txt +26 -25
  103. package/dist/ui/static/local-knowledge/__next._full.txt +26 -25
  104. package/dist/ui/static/local-knowledge/__next._tree.txt +2 -2
  105. package/dist/ui/static/local-knowledge/__next.local-knowledge.__PAGE__.txt +12 -12
  106. package/dist/ui/static/local-knowledge/capsule/__next._full.txt +11 -11
  107. package/dist/ui/static/local-knowledge/capsule/__next._tree.txt +1 -1
  108. package/dist/ui/static/local-knowledge/capsule/__next.local-knowledge.capsule.__PAGE__.txt +11 -11
  109. package/dist/ui/static/local-knowledge/capsule.html +1 -1
  110. package/dist/ui/static/local-knowledge/capsule.txt +11 -11
  111. package/dist/ui/static/local-knowledge.html +1 -1
  112. package/dist/ui/static/local-knowledge.txt +26 -25
  113. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-analyze.d.ts +5 -1
  114. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-analyze.d.ts.map +1 -1
  115. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-analyze.js +26 -1
  116. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-code-inventory.generated.d.ts +5 -0
  117. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-code-inventory.generated.d.ts.map +1 -1
  118. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-code-inventory.generated.js +112 -1
  119. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-registry-history.generated.d.ts +12 -5
  120. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-registry-history.generated.d.ts.map +1 -1
  121. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-registry-history.generated.js +14 -6
  122. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-retrieval-miss.d.ts +13 -0
  123. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-retrieval-miss.d.ts.map +1 -0
  124. package/node_modules/@oscharko-dev/keiko-activity-log/dist/reader/support-retrieval-miss.js +363 -0
  125. package/node_modules/@oscharko-dev/keiko-activity-log/package.json +3 -3
  126. package/node_modules/@oscharko-dev/keiko-cli/dist/init.d.ts.map +1 -1
  127. package/node_modules/@oscharko-dev/keiko-cli/dist/init.js +1 -0
  128. package/node_modules/@oscharko-dev/keiko-cli/dist/lifecycle-browser-activity.d.ts +22 -0
  129. package/node_modules/@oscharko-dev/keiko-cli/dist/lifecycle-browser-activity.d.ts.map +1 -0
  130. package/node_modules/@oscharko-dev/keiko-cli/dist/lifecycle-browser-activity.js +50 -0
  131. package/node_modules/@oscharko-dev/keiko-cli/dist/lifecycle.d.ts +4 -1
  132. package/node_modules/@oscharko-dev/keiko-cli/dist/lifecycle.d.ts.map +1 -1
  133. package/node_modules/@oscharko-dev/keiko-cli/dist/lifecycle.js +137 -32
  134. package/node_modules/@oscharko-dev/keiko-cli/dist/state-paths.d.ts +24 -3
  135. package/node_modules/@oscharko-dev/keiko-cli/dist/state-paths.d.ts.map +1 -1
  136. package/node_modules/@oscharko-dev/keiko-cli/dist/state-paths.js +126 -5
  137. package/node_modules/@oscharko-dev/keiko-cli/dist/ui-browser-handoff.d.ts +15 -0
  138. package/node_modules/@oscharko-dev/keiko-cli/dist/ui-browser-handoff.d.ts.map +1 -0
  139. package/node_modules/@oscharko-dev/keiko-cli/dist/ui-browser-handoff.js +91 -0
  140. package/node_modules/@oscharko-dev/keiko-cli/dist/ui.d.ts +2 -0
  141. package/node_modules/@oscharko-dev/keiko-cli/dist/ui.d.ts.map +1 -1
  142. package/node_modules/@oscharko-dev/keiko-cli/dist/ui.js +31 -3
  143. package/node_modules/@oscharko-dev/keiko-cli/package.json +15 -15
  144. package/node_modules/@oscharko-dev/keiko-connectors/dist/version.d.ts +1 -1
  145. package/node_modules/@oscharko-dev/keiko-connectors/dist/version.js +1 -1
  146. package/node_modules/@oscharko-dev/keiko-connectors/package.json +3 -3
  147. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-failure-class-contracts.d.ts +229 -49
  148. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-failure-class-contracts.d.ts.map +1 -1
  149. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-failure-class-contracts.js +313 -24
  150. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-operations.generated.d.ts +2406 -98
  151. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-operations.generated.d.ts.map +1 -1
  152. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-operations.generated.js +2924 -183
  153. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-registry.generated.d.ts +2489 -206
  154. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-registry.generated.d.ts.map +1 -1
  155. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-registry.generated.js +2867 -35
  156. package/node_modules/@oscharko-dev/keiko-contracts/dist/bff-wire.d.ts +35 -5
  157. package/node_modules/@oscharko-dev/keiko-contracts/dist/bff-wire.d.ts.map +1 -1
  158. package/node_modules/@oscharko-dev/keiko-contracts/dist/bff-wire.js +63 -3
  159. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-app-session-pairing.d.ts +37 -0
  160. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-app-session-pairing.d.ts.map +1 -0
  161. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-app-session-pairing.js +67 -0
  162. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-app-session.d.ts +2 -35
  163. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-app-session.d.ts.map +1 -1
  164. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-app-session.js +1 -62
  165. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-repository-search.d.ts +1 -0
  166. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-repository-search.d.ts.map +1 -1
  167. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-repository-search.js +12 -9
  168. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-safe-activity.d.ts +38 -1
  169. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-safe-activity.d.ts.map +1 -1
  170. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-safe-activity.js +94 -2
  171. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-api-validation.d.ts +3 -3
  172. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-api-validation.d.ts.map +1 -1
  173. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-api-validation.js +64 -17
  174. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-api.d.ts +8 -4
  175. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-api.d.ts.map +1 -1
  176. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-api.js +1 -0
  177. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-constants.d.ts +17 -1
  178. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-constants.d.ts.map +1 -1
  179. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-constants.js +13 -0
  180. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime.js +1 -1
  181. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-validation.d.ts.map +1 -1
  182. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-validation.js +27 -3
  183. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench.d.ts +28 -2
  184. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench.d.ts.map +1 -1
  185. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench.js +27 -0
  186. package/node_modules/@oscharko-dev/keiko-contracts/dist/connected-context.d.ts +28 -1
  187. package/node_modules/@oscharko-dev/keiko-contracts/dist/connected-context.d.ts.map +1 -1
  188. package/node_modules/@oscharko-dev/keiko-contracts/dist/connected-context.js +60 -1
  189. package/node_modules/@oscharko-dev/keiko-contracts/dist/contract-validation-primitives.d.ts +3 -0
  190. package/node_modules/@oscharko-dev/keiko-contracts/dist/contract-validation-primitives.d.ts.map +1 -0
  191. package/node_modules/@oscharko-dev/keiko-contracts/dist/contract-validation-primitives.js +12 -0
  192. package/node_modules/@oscharko-dev/keiko-contracts/dist/diagnostics.d.ts +70 -2
  193. package/node_modules/@oscharko-dev/keiko-contracts/dist/diagnostics.d.ts.map +1 -1
  194. package/node_modules/@oscharko-dev/keiko-contracts/dist/diagnostics.js +266 -5
  195. package/node_modules/@oscharko-dev/keiko-contracts/dist/evidence.d.ts +11 -0
  196. package/node_modules/@oscharko-dev/keiko-contracts/dist/evidence.d.ts.map +1 -1
  197. package/node_modules/@oscharko-dev/keiko-contracts/dist/gateway.d.ts +57 -1
  198. package/node_modules/@oscharko-dev/keiko-contracts/dist/gateway.d.ts.map +1 -1
  199. package/node_modules/@oscharko-dev/keiko-contracts/dist/gateway.js +4 -2
  200. package/node_modules/@oscharko-dev/keiko-contracts/dist/governed-tool-catalog.d.ts +1 -1
  201. package/node_modules/@oscharko-dev/keiko-contracts/dist/governed-tool-catalog.d.ts.map +1 -1
  202. package/node_modules/@oscharko-dev/keiko-contracts/dist/grounded-assessment.d.ts +10 -2
  203. package/node_modules/@oscharko-dev/keiko-contracts/dist/grounded-assessment.d.ts.map +1 -1
  204. package/node_modules/@oscharko-dev/keiko-contracts/dist/grounded-assessment.js +52 -12
  205. package/node_modules/@oscharko-dev/keiko-contracts/dist/index.d.ts +5 -5
  206. package/node_modules/@oscharko-dev/keiko-contracts/dist/index.d.ts.map +1 -1
  207. package/node_modules/@oscharko-dev/keiko-contracts/dist/no-evidence-answer.d.ts.map +1 -1
  208. package/node_modules/@oscharko-dev/keiko-contracts/dist/no-evidence-answer.js +29 -0
  209. package/node_modules/@oscharko-dev/keiko-contracts/dist/opencode-service-host.d.ts +42 -0
  210. package/node_modules/@oscharko-dev/keiko-contracts/dist/opencode-service-host.d.ts.map +1 -0
  211. package/node_modules/@oscharko-dev/keiko-contracts/dist/opencode-service-host.js +151 -0
  212. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-report.d.ts +36 -0
  213. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-report.d.ts.map +1 -1
  214. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-report.js +11 -0
  215. package/node_modules/@oscharko-dev/keiko-contracts/dist/tools.d.ts.map +1 -1
  216. package/node_modules/@oscharko-dev/keiko-contracts/dist/version.d.ts +2 -2
  217. package/node_modules/@oscharko-dev/keiko-contracts/dist/version.js +2 -2
  218. package/node_modules/@oscharko-dev/keiko-contracts/dist/workspace.d.ts +41 -0
  219. package/node_modules/@oscharko-dev/keiko-contracts/dist/workspace.d.ts.map +1 -1
  220. package/node_modules/@oscharko-dev/keiko-contracts/dist/workspace.js +18 -0
  221. package/node_modules/@oscharko-dev/keiko-contracts/package.json +9 -1
  222. package/node_modules/@oscharko-dev/keiko-evaluations/package.json +9 -9
  223. package/node_modules/@oscharko-dev/keiko-evidence/dist/connected-context-evidence.d.ts +5 -0
  224. package/node_modules/@oscharko-dev/keiko-evidence/dist/connected-context-evidence.d.ts.map +1 -1
  225. package/node_modules/@oscharko-dev/keiko-evidence/dist/connected-context-evidence.js +23 -3
  226. package/node_modules/@oscharko-dev/keiko-evidence/dist/version.d.ts +1 -1
  227. package/node_modules/@oscharko-dev/keiko-evidence/dist/version.js +1 -1
  228. package/node_modules/@oscharko-dev/keiko-evidence/package.json +4 -4
  229. package/node_modules/@oscharko-dev/keiko-git/dist/version.d.ts +1 -1
  230. package/node_modules/@oscharko-dev/keiko-git/dist/version.js +1 -1
  231. package/node_modules/@oscharko-dev/keiko-git/package.json +1 -1
  232. package/node_modules/@oscharko-dev/keiko-harness/dist/version.d.ts +1 -1
  233. package/node_modules/@oscharko-dev/keiko-harness/dist/version.js +1 -1
  234. package/node_modules/@oscharko-dev/keiko-harness/package.json +7 -7
  235. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/conversation/grounded-answer-runner.d.ts.map +1 -1
  236. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/conversation/grounded-answer-runner.js +3 -0
  237. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/parsers/_internal.d.ts +1 -1
  238. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/parsers/_internal.d.ts.map +1 -1
  239. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/parsers/_internal.js +2 -33
  240. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/parsers/html-parser.js +5 -4
  241. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/retrieval/index.d.ts +2 -0
  242. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/retrieval/index.d.ts.map +1 -1
  243. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/retrieval/index.js +2 -0
  244. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/retrieval/retrieval-runner.d.ts +2 -1
  245. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/retrieval/retrieval-runner.d.ts.map +1 -1
  246. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/retrieval/retrieval-runner.js +1 -0
  247. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/retrieval/scoped-vector-search.d.ts +9 -2
  248. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/retrieval/scoped-vector-search.d.ts.map +1 -1
  249. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/retrieval/scoped-vector-search.js +18 -10
  250. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/version.d.ts +1 -1
  251. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/version.js +1 -1
  252. package/node_modules/@oscharko-dev/keiko-local-knowledge/package.json +5 -5
  253. package/node_modules/@oscharko-dev/keiko-memory-capture/dist/version.d.ts +1 -1
  254. package/node_modules/@oscharko-dev/keiko-memory-capture/dist/version.js +1 -1
  255. package/node_modules/@oscharko-dev/keiko-memory-capture/package.json +3 -3
  256. package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/version.d.ts +1 -1
  257. package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/version.js +1 -1
  258. package/node_modules/@oscharko-dev/keiko-memory-consolidation/package.json +3 -3
  259. package/node_modules/@oscharko-dev/keiko-memory-governance/dist/version.d.ts +1 -1
  260. package/node_modules/@oscharko-dev/keiko-memory-governance/dist/version.js +1 -1
  261. package/node_modules/@oscharko-dev/keiko-memory-governance/package.json +3 -3
  262. package/node_modules/@oscharko-dev/keiko-memory-retrieval/dist/version.d.ts +1 -1
  263. package/node_modules/@oscharko-dev/keiko-memory-retrieval/dist/version.js +1 -1
  264. package/node_modules/@oscharko-dev/keiko-memory-retrieval/package.json +3 -3
  265. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/version.d.ts +1 -1
  266. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/version.js +1 -1
  267. package/node_modules/@oscharko-dev/keiko-memory-vault/package.json +3 -3
  268. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/config.d.ts.map +1 -1
  269. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/config.js +103 -1
  270. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/embedding.d.ts +2 -0
  271. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/embedding.d.ts.map +1 -1
  272. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/embedding.js +2 -0
  273. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway-attempt-admission.d.ts +8 -0
  274. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway-attempt-admission.d.ts.map +1 -0
  275. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway-attempt-admission.js +44 -0
  276. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway.d.ts +89 -1
  277. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway.d.ts.map +1 -1
  278. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway.js +617 -129
  279. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/http.d.ts +4 -0
  280. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/http.d.ts.map +1 -1
  281. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/http.js +28 -3
  282. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/index.d.ts +3 -2
  283. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/index.d.ts.map +1 -1
  284. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/index.js +2 -2
  285. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/model-selection.d.ts +23 -0
  286. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/model-selection.d.ts.map +1 -1
  287. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/model-selection.js +50 -5
  288. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/normalize.d.ts +10 -0
  289. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/normalize.d.ts.map +1 -1
  290. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/normalize.js +54 -2
  291. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/observability.d.ts.map +1 -1
  292. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/observability.js +2 -0
  293. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-adapter.d.ts +11 -3
  294. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-adapter.d.ts.map +1 -1
  295. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-adapter.js +262 -58
  296. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/readiness-probe.d.ts +1 -0
  297. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/readiness-probe.d.ts.map +1 -1
  298. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/readiness-probe.js +1 -0
  299. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/resilience.d.ts +143 -3
  300. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/resilience.d.ts.map +1 -1
  301. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/resilience.js +361 -39
  302. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/toolCatalogBridge.d.ts +9 -1
  303. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/toolCatalogBridge.d.ts.map +1 -1
  304. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/toolCatalogBridge.js +62 -16
  305. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/types.d.ts +15 -0
  306. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/types.d.ts.map +1 -1
  307. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/version.d.ts +1 -1
  308. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/version.js +1 -1
  309. package/node_modules/@oscharko-dev/keiko-model-gateway/package.json +4 -4
  310. package/node_modules/@oscharko-dev/keiko-quality-intelligence/package.json +3 -3
  311. package/node_modules/@oscharko-dev/keiko-sandbox/dist/backends.d.ts +2 -2
  312. package/node_modules/@oscharko-dev/keiko-sandbox/dist/backends.d.ts.map +1 -1
  313. package/node_modules/@oscharko-dev/keiko-sandbox/dist/backends.js +30 -15
  314. package/node_modules/@oscharko-dev/keiko-sandbox/dist/index.d.ts +1 -1
  315. package/node_modules/@oscharko-dev/keiko-sandbox/dist/index.d.ts.map +1 -1
  316. package/node_modules/@oscharko-dev/keiko-sandbox/dist/plan.d.ts.map +1 -1
  317. package/node_modules/@oscharko-dev/keiko-sandbox/dist/plan.js +24 -3
  318. package/node_modules/@oscharko-dev/keiko-sandbox/dist/runtime-gateway.d.ts +3 -0
  319. package/node_modules/@oscharko-dev/keiko-sandbox/dist/runtime-gateway.d.ts.map +1 -1
  320. package/node_modules/@oscharko-dev/keiko-sandbox/dist/runtime-gateway.js +31 -6
  321. package/node_modules/@oscharko-dev/keiko-sandbox/dist/seatbelt-execution-root.d.ts +11 -0
  322. package/node_modules/@oscharko-dev/keiko-sandbox/dist/seatbelt-execution-root.d.ts.map +1 -0
  323. package/node_modules/@oscharko-dev/keiko-sandbox/dist/seatbelt-execution-root.js +141 -0
  324. package/node_modules/@oscharko-dev/keiko-sandbox/dist/select.d.ts.map +1 -1
  325. package/node_modules/@oscharko-dev/keiko-sandbox/dist/select.js +2 -0
  326. package/node_modules/@oscharko-dev/keiko-sandbox/dist/types.d.ts +8 -0
  327. package/node_modules/@oscharko-dev/keiko-sandbox/dist/types.d.ts.map +1 -1
  328. package/node_modules/@oscharko-dev/keiko-sandbox/package.json +2 -2
  329. package/node_modules/@oscharko-dev/keiko-sdk/package.json +9 -9
  330. package/node_modules/@oscharko-dev/keiko-security/dist/errors/gateway.d.ts +10 -1
  331. package/node_modules/@oscharko-dev/keiko-security/dist/errors/gateway.d.ts.map +1 -1
  332. package/node_modules/@oscharko-dev/keiko-security/dist/errors/gateway.js +25 -2
  333. package/node_modules/@oscharko-dev/keiko-security/dist/index.d.ts +1 -1
  334. package/node_modules/@oscharko-dev/keiko-security/dist/index.d.ts.map +1 -1
  335. package/node_modules/@oscharko-dev/keiko-security/dist/index.js +1 -1
  336. package/node_modules/@oscharko-dev/keiko-security/dist/portable-tree-attestation.d.ts +14 -0
  337. package/node_modules/@oscharko-dev/keiko-security/dist/portable-tree-attestation.d.ts.map +1 -1
  338. package/node_modules/@oscharko-dev/keiko-security/dist/portable-tree-attestation.js +183 -25
  339. package/node_modules/@oscharko-dev/keiko-security/dist/redaction.d.ts +9 -0
  340. package/node_modules/@oscharko-dev/keiko-security/dist/redaction.d.ts.map +1 -1
  341. package/node_modules/@oscharko-dev/keiko-security/dist/redaction.js +16 -1
  342. package/node_modules/@oscharko-dev/keiko-security/dist/version.d.ts +1 -1
  343. package/node_modules/@oscharko-dev/keiko-security/dist/version.js +1 -1
  344. package/node_modules/@oscharko-dev/keiko-security/package.json +2 -2
  345. package/node_modules/@oscharko-dev/keiko-server/dist/chat-activity.d.ts +9 -2
  346. package/node_modules/@oscharko-dev/keiko-server/dist/chat-activity.d.ts.map +1 -1
  347. package/node_modules/@oscharko-dev/keiko-server/dist/chat-activity.js +47 -2
  348. package/node_modules/@oscharko-dev/keiko-server/dist/chat-handlers.d.ts.map +1 -1
  349. package/node_modules/@oscharko-dev/keiko-server/dist/chat-handlers.js +2 -0
  350. package/node_modules/@oscharko-dev/keiko-server/dist/chat-stream-handlers.d.ts.map +1 -1
  351. package/node_modules/@oscharko-dev/keiko-server/dist/chat-stream-handlers.js +4 -0
  352. package/node_modules/@oscharko-dev/keiko-server/dist/client-diagnostics-routes.d.ts.map +1 -1
  353. package/node_modules/@oscharko-dev/keiko-server/dist/client-diagnostics-routes.js +274 -7
  354. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/ciRepairPromptReservation.d.ts +11 -1
  355. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/ciRepairPromptReservation.d.ts.map +1 -1
  356. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/ciRepairPromptReservation.js +21 -7
  357. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeActivityOperations.d.ts +50 -2
  358. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeActivityOperations.d.ts.map +1 -1
  359. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeActivityOperations.js +25 -0
  360. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeCiRepairController.d.ts +14 -7
  361. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeCiRepairController.d.ts.map +1 -1
  362. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeCiRepairController.js +33 -26
  363. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeControlPlane.d.ts +46 -0
  364. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeControlPlane.d.ts.map +1 -1
  365. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeControlPlane.js +33 -0
  366. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeEventHub.d.ts +51 -3
  367. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeEventHub.d.ts.map +1 -1
  368. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeEventHub.js +97 -5
  369. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeManager.d.ts +8 -2
  370. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeManager.d.ts.map +1 -1
  371. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeManager.js +265 -29
  372. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestrator.d.ts +37 -1
  373. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestrator.d.ts.map +1 -1
  374. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestrator.js +416 -34
  375. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestratorState.d.ts +5 -3
  376. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestratorState.d.ts.map +1 -1
  377. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestratorState.js +14 -7
  378. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestratorTypes.d.ts +21 -0
  379. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestratorTypes.d.ts.map +1 -1
  380. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeRefusalEscalation.d.ts +79 -0
  381. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeRefusalEscalation.d.ts.map +1 -0
  382. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeRefusalEscalation.js +305 -0
  383. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeRepositoryInstructions.d.ts +100 -0
  384. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeRepositoryInstructions.d.ts.map +1 -0
  385. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeRepositoryInstructions.js +363 -0
  386. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeRoutes.d.ts.map +1 -1
  387. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeRoutes.js +13 -0
  388. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeRunEffort.d.ts +71 -0
  389. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeRunEffort.d.ts.map +1 -0
  390. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeRunEffort.js +294 -0
  391. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeTerminalCause.d.ts +47 -0
  392. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeTerminalCause.d.ts.map +1 -0
  393. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeTerminalCause.js +65 -0
  394. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeVerificationContinuation.d.ts +7 -0
  395. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeVerificationContinuation.d.ts.map +1 -0
  396. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeVerificationContinuation.js +79 -0
  397. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingSafeActivityProjection.d.ts +18 -0
  398. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingSafeActivityProjection.d.ts.map +1 -1
  399. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingSafeActivityProjection.js +201 -42
  400. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolAuthorityPort.d.ts +6 -1
  401. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolAuthorityPort.d.ts.map +1 -1
  402. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolAuthorityPort.js +733 -17
  403. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolFacade.d.ts +5 -1
  404. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolFacade.d.ts.map +1 -1
  405. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolFacade.js +262 -57
  406. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolFacadePorts.d.ts +185 -2
  407. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolFacadePorts.d.ts.map +1 -1
  408. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolFacadePorts.js +57 -1
  409. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolGovernedDelegate.d.ts +3 -1
  410. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolGovernedDelegate.d.ts.map +1 -1
  411. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolGovernedDelegate.js +14 -2
  412. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolInvocationRegistry.d.ts +4 -0
  413. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolInvocationRegistry.d.ts.map +1 -1
  414. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolInvocationRegistry.js +50 -1
  415. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolIpc.d.ts +21 -3
  416. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolIpc.d.ts.map +1 -1
  417. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolIpc.js +143 -8
  418. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolReadEditPorts.d.ts +63 -1
  419. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolReadEditPorts.d.ts.map +1 -1
  420. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolReadEditPorts.js +710 -170
  421. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolReplacementEdits.d.ts +108 -0
  422. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolReplacementEdits.d.ts.map +1 -0
  423. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolReplacementEdits.js +477 -0
  424. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/devLanePortableCodingRuntime.d.ts +2 -4
  425. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/devLanePortableCodingRuntime.d.ts.map +1 -1
  426. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/devLanePortableCodingRuntime.js +53 -46
  427. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/devLaneRuntimeProcessBackend.d.ts +4 -1
  428. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/devLaneRuntimeProcessBackend.d.ts.map +1 -1
  429. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/devLaneRuntimeProcessBackend.js +51 -52
  430. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/governedToolModelContent.d.ts +48 -0
  431. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/governedToolModelContent.d.ts.map +1 -0
  432. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/governedToolModelContent.js +179 -0
  433. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/materializedPatchRegistry.d.ts +60 -0
  434. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/materializedPatchRegistry.d.ts.map +1 -0
  435. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/materializedPatchRegistry.js +61 -0
  436. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/nativeRuntimeProcessBackend.d.ts +7 -7
  437. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/nativeRuntimeProcessBackend.d.ts.map +1 -1
  438. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/nativeRuntimeProcessBackend.js +48 -15
  439. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/nativeRuntimeProcessPaths.d.ts +3 -0
  440. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/nativeRuntimeProcessPaths.d.ts.map +1 -1
  441. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/nativeRuntimeProcessPaths.js +14 -0
  442. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/nativeRuntimeProcessProtocol.d.ts.map +1 -1
  443. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/nativeRuntimeProcessProtocol.js +11 -4
  444. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/npmLaneRuntimeApprovals.d.ts +2 -0
  445. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/npmLaneRuntimeApprovals.d.ts.map +1 -1
  446. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/npmLaneRuntimeApprovals.js +28 -14
  447. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeFunctionalHarness/_governedTools.d.ts +3 -0
  448. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeFunctionalHarness/_governedTools.d.ts.map +1 -1
  449. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeFunctionalHarness/_governedTools.js +48 -20
  450. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeLaunchProfile.d.ts +5 -4
  451. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeLaunchProfile.d.ts.map +1 -1
  452. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeLaunchProfile.js +11 -12
  453. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeNativeContext.d.ts +10 -0
  454. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeNativeContext.d.ts.map +1 -0
  455. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeNativeContext.js +27 -0
  456. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeReconciler.d.ts +6 -3
  457. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeReconciler.d.ts.map +1 -1
  458. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeReconciler.js +15 -15
  459. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeAdapter.d.ts +17 -3
  460. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeAdapter.d.ts.map +1 -1
  461. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeAdapter.js +198 -43
  462. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeComposition.d.ts +97 -5
  463. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeComposition.d.ts.map +1 -1
  464. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeComposition.js +1334 -103
  465. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeServiceHostArtifact.d.ts +79 -0
  466. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeServiceHostArtifact.d.ts.map +1 -0
  467. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeServiceHostArtifact.js +176 -0
  468. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeToolSchemas.d.ts +177 -25
  469. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeToolSchemas.d.ts.map +1 -1
  470. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeToolSchemas.js +131 -38
  471. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2History.d.ts +18 -0
  472. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2History.d.ts.map +1 -1
  473. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2History.js +298 -32
  474. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2HttpClient.d.ts +6 -0
  475. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2HttpClient.d.ts.map +1 -1
  476. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2HttpClient.js +14 -3
  477. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2LiveText.d.ts +33 -0
  478. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2LiveText.d.ts.map +1 -0
  479. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2LiveText.js +213 -0
  480. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionAuxiliaryPorts.d.ts +1 -1
  481. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionAuxiliaryPorts.d.ts.map +1 -1
  482. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionAuxiliaryPorts.js +2 -8
  483. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionCiRepairRuntime.js +15 -5
  484. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionCodingRuntimeHost.js +5 -0
  485. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionCodingRuntimeResolver.d.ts +25 -3
  486. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionCodingRuntimeResolver.d.ts.map +1 -1
  487. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionCodingRuntimeResolver.js +227 -40
  488. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionManagedWorktreeTools.d.ts +20 -1
  489. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionManagedWorktreeTools.d.ts.map +1 -1
  490. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionManagedWorktreeTools.js +217 -12
  491. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeActivation.d.ts +3 -1
  492. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeActivation.d.ts.map +1 -1
  493. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeActivation.js +20 -5
  494. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeBackend.d.ts +8 -1
  495. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeBackend.d.ts.map +1 -1
  496. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeBackend.functional/repositorySearchProof.d.ts.map +1 -1
  497. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeBackend.functional/repositorySearchProof.js +2 -1
  498. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeBackend.functional/skillDiscoveryProof.d.ts.map +1 -1
  499. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeBackend.functional/skillDiscoveryProof.js +2 -1
  500. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeBackend.js +262 -60
  501. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionRuntimeWorkspaceAuthority.d.ts +18 -0
  502. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionRuntimeWorkspaceAuthority.d.ts.map +1 -1
  503. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionRuntimeWorkspaceAuthority.js +43 -6
  504. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/runtimeAuthorityService.d.ts +38 -0
  505. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/runtimeAuthorityService.d.ts.map +1 -1
  506. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/runtimeAuthorityService.js +115 -16
  507. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/runtimeGatewayProcessSandbox.d.ts +20 -0
  508. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/runtimeGatewayProcessSandbox.d.ts.map +1 -0
  509. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/runtimeGatewayProcessSandbox.js +48 -0
  510. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/runtimeProcessSupervisor.d.ts +5 -0
  511. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/runtimeProcessSupervisor.d.ts.map +1 -1
  512. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/runtimeProcessSupervisor.js +5 -1
  513. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextRead.d.ts +100 -4
  514. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextRead.d.ts.map +1 -1
  515. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextRead.js +435 -25
  516. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextReadAbsence.d.ts +61 -0
  517. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextReadAbsence.d.ts.map +1 -0
  518. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextReadAbsence.js +123 -0
  519. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextReadArtifact.d.ts +7 -0
  520. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextReadArtifact.d.ts.map +1 -1
  521. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextReadArtifact.js +26 -3
  522. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextReadNodeProcess.d.ts.map +1 -1
  523. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextReadNodeProcess.js +10 -0
  524. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextReadProcess.d.ts +2 -0
  525. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextReadProcess.d.ts.map +1 -1
  526. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextReadProcess.js +17 -2
  527. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextReadProtocol.d.ts +69 -2
  528. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextReadProtocol.d.ts.map +1 -1
  529. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/secureWorkspaceTextReadProtocol.js +266 -7
  530. package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-gateway.d.ts +14 -3
  531. package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-gateway.d.ts.map +1 -1
  532. package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-gateway.js +761 -122
  533. package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-tool-facade.d.ts +2 -2
  534. package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-tool-facade.d.ts.map +1 -1
  535. package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-tool-facade.js +139 -0
  536. package/node_modules/@oscharko-dev/keiko-server/dist/command-runner.d.ts +2 -0
  537. package/node_modules/@oscharko-dev/keiko-server/dist/command-runner.d.ts.map +1 -1
  538. package/node_modules/@oscharko-dev/keiko-server/dist/command-runner.js +176 -19
  539. package/node_modules/@oscharko-dev/keiko-server/dist/conversation-readiness-admission.d.ts.map +1 -1
  540. package/node_modules/@oscharko-dev/keiko-server/dist/conversation-readiness-admission.js +72 -13
  541. package/node_modules/@oscharko-dev/keiko-server/dist/conversation-readiness-log.d.ts +3 -0
  542. package/node_modules/@oscharko-dev/keiko-server/dist/conversation-readiness-log.d.ts.map +1 -0
  543. package/node_modules/@oscharko-dev/keiko-server/dist/conversation-readiness-log.js +48 -0
  544. package/node_modules/@oscharko-dev/keiko-server/dist/correlation.d.ts.map +1 -1
  545. package/node_modules/@oscharko-dev/keiko-server/dist/correlation.js +8 -5
  546. package/node_modules/@oscharko-dev/keiko-server/dist/credentialVault.d.ts.map +1 -1
  547. package/node_modules/@oscharko-dev/keiko-server/dist/credentialVault.js +5 -0
  548. package/node_modules/@oscharko-dev/keiko-server/dist/deps.d.ts +39 -8
  549. package/node_modules/@oscharko-dev/keiko-server/dist/deps.d.ts.map +1 -1
  550. package/node_modules/@oscharko-dev/keiko-server/dist/deps.js +234 -77
  551. package/node_modules/@oscharko-dev/keiko-server/dist/diagnostics-log.d.ts +1 -1
  552. package/node_modules/@oscharko-dev/keiko-server/dist/diagnostics-log.d.ts.map +1 -1
  553. package/node_modules/@oscharko-dev/keiko-server/dist/diagnostics-log.js +6 -0
  554. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentAuthorityRegistry.d.ts +8 -0
  555. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentAuthorityRegistry.d.ts.map +1 -1
  556. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentAuthorityRegistry.js +16 -0
  557. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentRootBoundary.d.ts +5 -1
  558. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentRootBoundary.d.ts.map +1 -1
  559. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentRootBoundary.js +60 -12
  560. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentRoutes.d.ts +13 -2
  561. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentRoutes.d.ts.map +1 -1
  562. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentRoutes.js +131 -18
  563. package/node_modules/@oscharko-dev/keiko-server/dist/editor/bufferSafetyTargets.d.ts +5 -0
  564. package/node_modules/@oscharko-dev/keiko-server/dist/editor/bufferSafetyTargets.d.ts.map +1 -0
  565. package/node_modules/@oscharko-dev/keiko-server/dist/editor/bufferSafetyTargets.js +44 -0
  566. package/node_modules/@oscharko-dev/keiko-server/dist/editor/changesetLineBreakProvenance.d.ts +26 -0
  567. package/node_modules/@oscharko-dev/keiko-server/dist/editor/changesetLineBreakProvenance.d.ts.map +1 -0
  568. package/node_modules/@oscharko-dev/keiko-server/dist/editor/changesetLineBreakProvenance.js +87 -0
  569. package/node_modules/@oscharko-dev/keiko-server/dist/editor/codingContextProviders.d.ts.map +1 -1
  570. package/node_modules/@oscharko-dev/keiko-server/dist/editor/codingContextProviders.js +0 -3
  571. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationExecution.d.ts +4 -1
  572. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationExecution.d.ts.map +1 -1
  573. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationExecution.js +62 -5
  574. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationExecutionLog.d.ts +128 -0
  575. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationExecutionLog.d.ts.map +1 -0
  576. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationExecutionLog.js +213 -0
  577. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationRunner.d.ts.map +1 -1
  578. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationRunner.js +68 -24
  579. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationRuntimeTarget.d.ts +13 -0
  580. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationRuntimeTarget.d.ts.map +1 -0
  581. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationRuntimeTarget.js +121 -0
  582. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-readiness.d.ts +10 -10
  583. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-readiness.d.ts.map +1 -1
  584. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-readiness.js +280 -88
  585. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-route-deadline.d.ts +1 -1
  586. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-route-deadline.d.ts.map +1 -1
  587. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-route-deadline.js +11 -5
  588. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-setup.d.ts +15 -2
  589. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-setup.d.ts.map +1 -1
  590. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-setup.js +445 -45
  591. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-startup-activity.d.ts +31 -0
  592. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-startup-activity.d.ts.map +1 -0
  593. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-startup-activity.js +74 -0
  594. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-startup.d.ts +7 -0
  595. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-startup.d.ts.map +1 -0
  596. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-startup.js +282 -0
  597. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-tool-calling-probe.d.ts.map +1 -1
  598. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-tool-calling-probe.js +7 -3
  599. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/commitRoutes.d.ts.map +1 -1
  600. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/commitRoutes.js +7 -3
  601. package/node_modules/@oscharko-dev/keiko-server/dist/gitPorcelainStatus.d.ts +5 -0
  602. package/node_modules/@oscharko-dev/keiko-server/dist/gitPorcelainStatus.d.ts.map +1 -1
  603. package/node_modules/@oscharko-dev/keiko-server/dist/gitPorcelainStatus.js +46 -0
  604. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer-activity.d.ts +19 -0
  605. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer-activity.d.ts.map +1 -0
  606. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer-activity.js +177 -0
  607. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer-assessment.d.ts +7 -0
  608. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer-assessment.d.ts.map +1 -0
  609. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer-assessment.js +69 -0
  610. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer-evidence.d.ts +11 -0
  611. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer-evidence.d.ts.map +1 -0
  612. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer-evidence.js +53 -0
  613. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer-repair.d.ts +25 -0
  614. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer-repair.d.ts.map +1 -0
  615. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer-repair.js +120 -0
  616. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer.d.ts +56 -2
  617. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer.d.ts.map +1 -1
  618. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-answer.js +194 -0
  619. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-assistant-referents.d.ts +16 -0
  620. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-assistant-referents.d.ts.map +1 -0
  621. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-assistant-referents.js +133 -0
  622. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-candidate-ordering.d.ts +16 -0
  623. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-candidate-ordering.d.ts.map +1 -0
  624. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-candidate-ordering.js +103 -0
  625. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-citation-capability.d.ts +7 -0
  626. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-citation-capability.d.ts.map +1 -0
  627. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-citation-capability.js +79 -0
  628. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-citation-log.d.ts +22 -4
  629. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-citation-log.d.ts.map +1 -1
  630. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-citation-log.js +112 -11
  631. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-citation-repair.d.ts +4 -0
  632. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-citation-repair.d.ts.map +1 -0
  633. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-citation-repair.js +117 -0
  634. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-context-pack-reranker.d.ts.map +1 -1
  635. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-context-pack-reranker.js +4 -0
  636. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-contextual-fallback.d.ts +10 -0
  637. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-contextual-fallback.d.ts.map +1 -0
  638. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-contextual-fallback.js +41 -0
  639. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-conversation-continuity.d.ts +6 -0
  640. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-conversation-continuity.d.ts.map +1 -1
  641. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-conversation-continuity.js +54 -5
  642. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-diagnostic-references.d.ts +42 -0
  643. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-diagnostic-references.d.ts.map +1 -0
  644. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-diagnostic-references.js +91 -0
  645. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-document-evidence.d.ts +6 -2
  646. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-document-evidence.d.ts.map +1 -1
  647. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-document-evidence.js +61 -8
  648. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-eval-support.d.ts +28 -1
  649. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-eval-support.d.ts.map +1 -1
  650. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-eval-support.js +140 -0
  651. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-evidence-selection.d.ts +9 -1
  652. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-evidence-selection.d.ts.map +1 -1
  653. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-evidence-selection.js +40 -3
  654. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-explicit-paths.d.ts +44 -0
  655. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-explicit-paths.d.ts.map +1 -0
  656. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-explicit-paths.js +385 -0
  657. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-faithfulness-eval.d.ts +5 -2
  658. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-faithfulness-eval.d.ts.map +1 -1
  659. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-faithfulness-eval.js +91 -39
  660. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-faithfulness.d.ts +43 -4
  661. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-faithfulness.d.ts.map +1 -1
  662. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-faithfulness.js +247 -34
  663. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-follow-up.d.ts +27 -0
  664. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-follow-up.d.ts.map +1 -0
  665. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-follow-up.js +198 -0
  666. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-latency-eval.d.ts +16 -2
  667. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-latency-eval.d.ts.map +1 -1
  668. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-latency-eval.js +69 -1
  669. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-orchestrator.d.ts +106 -7
  670. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-orchestrator.d.ts.map +1 -1
  671. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-orchestrator.js +2618 -376
  672. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-plural-synthesis.d.ts +27 -0
  673. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-plural-synthesis.d.ts.map +1 -0
  674. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-plural-synthesis.js +74 -0
  675. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-preselection-reranker.d.ts +25 -0
  676. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-preselection-reranker.d.ts.map +1 -0
  677. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-preselection-reranker.js +93 -0
  678. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-prompt-context.d.ts +1 -0
  679. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-prompt-context.d.ts.map +1 -1
  680. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-prompt.d.ts +7 -0
  681. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-prompt.d.ts.map +1 -1
  682. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-prompt.js +26 -13
  683. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-hybrid.d.ts +23 -9
  684. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-hybrid.d.ts.map +1 -1
  685. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-hybrid.js +403 -90
  686. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-multi-source.d.ts +31 -8
  687. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-multi-source.d.ts.map +1 -1
  688. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-multi-source.js +485 -99
  689. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa.d.ts +24 -8
  690. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa.d.ts.map +1 -1
  691. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa.js +395 -90
  692. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-repo-semantic-search.d.ts +32 -2
  693. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-repo-semantic-search.d.ts.map +1 -1
  694. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-repo-semantic-search.js +370 -48
  695. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-rerank-facade.d.ts +2 -0
  696. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-rerank-facade.d.ts.map +1 -1
  697. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-rerank-facade.js +22 -1
  698. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-rerank.d.ts +2 -0
  699. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-rerank.d.ts.map +1 -1
  700. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-rerank.js +5 -1
  701. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-retrieval-eval.d.ts +1 -1
  702. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-retrieval-eval.d.ts.map +1 -1
  703. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-retrieval-eval.js +25 -7
  704. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-selection-quality.d.ts +19 -0
  705. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-selection-quality.d.ts.map +1 -0
  706. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-selection-quality.js +55 -0
  707. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-semantic-request.d.ts +31 -0
  708. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-semantic-request.d.ts.map +1 -0
  709. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-semantic-request.js +55 -0
  710. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-symbol-trace-cycles.d.ts +3 -0
  711. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-symbol-trace-cycles.d.ts.map +1 -0
  712. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-symbol-trace-cycles.js +90 -0
  713. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-symbol-trace.d.ts +44 -2
  714. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-symbol-trace.d.ts.map +1 -1
  715. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-symbol-trace.js +1053 -83
  716. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-worktree-recency.d.ts +34 -0
  717. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-worktree-recency.d.ts.map +1 -0
  718. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-worktree-recency.js +190 -0
  719. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-worktree-request.d.ts +5 -0
  720. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-worktree-request.d.ts.map +1 -0
  721. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-worktree-request.js +19 -0
  722. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-grounded-qa.d.ts.map +1 -1
  723. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-grounded-qa.js +4 -0
  724. package/node_modules/@oscharko-dev/keiko-server/dist/read-handlers.d.ts +1 -1
  725. package/node_modules/@oscharko-dev/keiko-server/dist/read-handlers.d.ts.map +1 -1
  726. package/node_modules/@oscharko-dev/keiko-server/dist/read-handlers.js +3 -1
  727. package/node_modules/@oscharko-dev/keiko-server/dist/server.d.ts.map +1 -1
  728. package/node_modules/@oscharko-dev/keiko-server/dist/server.js +7 -0
  729. package/node_modules/@oscharko-dev/keiko-server/dist/store/chats.d.ts.map +1 -1
  730. package/node_modules/@oscharko-dev/keiko-server/dist/store/chats.js +3 -1
  731. package/node_modules/@oscharko-dev/keiko-server/dist/store/legacySchemaTestFixture.js +2 -2
  732. package/node_modules/@oscharko-dev/keiko-server/dist/store/schema.d.ts +1 -1
  733. package/node_modules/@oscharko-dev/keiko-server/dist/store/schema.d.ts.map +1 -1
  734. package/node_modules/@oscharko-dev/keiko-server/dist/store/schema.js +159 -1
  735. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-routes.d.ts.map +1 -1
  736. package/node_modules/@oscharko-dev/keiko-server/dist/support-report-routes.js +4 -7
  737. package/node_modules/@oscharko-dev/keiko-server/dist/task-workspace/routes.js +3 -3
  738. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolDispatch.d.ts.map +1 -1
  739. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolDispatch.js +2 -2
  740. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolFacadeBridge.d.ts +20 -4
  741. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolFacadeBridge.d.ts.map +1 -1
  742. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolFacadeBridge.js +96 -20
  743. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolPorts.d.ts +2 -0
  744. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolPorts.d.ts.map +1 -1
  745. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolRuntimeAuthority.d.ts +2 -2
  746. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolRuntimeAuthority.d.ts.map +1 -1
  747. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolRuntimeAuthority.js +47 -3
  748. package/node_modules/@oscharko-dev/keiko-server/dist/update-portable-sidecar-staging-verification.d.ts +3 -0
  749. package/node_modules/@oscharko-dev/keiko-server/dist/update-portable-sidecar-staging-verification.d.ts.map +1 -1
  750. package/node_modules/@oscharko-dev/keiko-server/dist/update-portable-sidecar-staging-verification.js +23 -7
  751. package/node_modules/@oscharko-dev/keiko-server/dist/update-portable-sidecar-verification.d.ts +3 -0
  752. package/node_modules/@oscharko-dev/keiko-server/dist/update-portable-sidecar-verification.d.ts.map +1 -1
  753. package/node_modules/@oscharko-dev/keiko-server/dist/update-portable-sidecar-verification.js +12 -0
  754. package/node_modules/@oscharko-dev/keiko-server/dist/workspace-index-provider.js +4 -4
  755. package/node_modules/@oscharko-dev/keiko-server/package.json +23 -23
  756. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/index.d.ts +1 -1
  757. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/index.d.ts.map +1 -1
  758. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/index.js +1 -1
  759. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/opencode.d.ts +9 -25
  760. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/opencode.d.ts.map +1 -1
  761. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/opencode.js +207 -112
  762. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/profile.d.ts.map +1 -1
  763. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/profile.js +15 -2
  764. package/node_modules/@oscharko-dev/keiko-tool-catalog/package.json +3 -3
  765. package/node_modules/@oscharko-dev/keiko-tools/dist/exec.d.ts.map +1 -1
  766. package/node_modules/@oscharko-dev/keiko-tools/dist/exec.js +44 -5
  767. package/node_modules/@oscharko-dev/keiko-tools/dist/index.d.ts +1 -1
  768. package/node_modules/@oscharko-dev/keiko-tools/dist/index.d.ts.map +1 -1
  769. package/node_modules/@oscharko-dev/keiko-tools/dist/patch-content.d.ts.map +1 -1
  770. package/node_modules/@oscharko-dev/keiko-tools/dist/patch-content.js +142 -49
  771. package/node_modules/@oscharko-dev/keiko-tools/dist/patch-parse.d.ts.map +1 -1
  772. package/node_modules/@oscharko-dev/keiko-tools/dist/patch-parse.js +14 -3
  773. package/node_modules/@oscharko-dev/keiko-tools/dist/patch.d.ts +15 -0
  774. package/node_modules/@oscharko-dev/keiko-tools/dist/patch.d.ts.map +1 -1
  775. package/node_modules/@oscharko-dev/keiko-tools/dist/patch.js +24 -9
  776. package/node_modules/@oscharko-dev/keiko-tools/dist/version.d.ts +1 -1
  777. package/node_modules/@oscharko-dev/keiko-tools/dist/version.js +1 -1
  778. package/node_modules/@oscharko-dev/keiko-tools/package.json +7 -7
  779. package/node_modules/@oscharko-dev/keiko-verification/dist/dependencies.d.ts +16 -4
  780. package/node_modules/@oscharko-dev/keiko-verification/dist/dependencies.d.ts.map +1 -1
  781. package/node_modules/@oscharko-dev/keiko-verification/dist/dependencies.js +198 -25
  782. package/node_modules/@oscharko-dev/keiko-verification/dist/failure-location.d.ts +1 -1
  783. package/node_modules/@oscharko-dev/keiko-verification/dist/failure-location.d.ts.map +1 -1
  784. package/node_modules/@oscharko-dev/keiko-verification/dist/failure-location.js +34 -17
  785. package/node_modules/@oscharko-dev/keiko-verification/dist/orchestrator.d.ts +4 -1
  786. package/node_modules/@oscharko-dev/keiko-verification/dist/orchestrator.d.ts.map +1 -1
  787. package/node_modules/@oscharko-dev/keiko-verification/dist/orchestrator.js +32 -2
  788. package/node_modules/@oscharko-dev/keiko-verification/dist/plan.d.ts.map +1 -1
  789. package/node_modules/@oscharko-dev/keiko-verification/dist/plan.js +25 -16
  790. package/node_modules/@oscharko-dev/keiko-verification/dist/targeted-project.d.ts +7 -0
  791. package/node_modules/@oscharko-dev/keiko-verification/dist/targeted-project.d.ts.map +1 -0
  792. package/node_modules/@oscharko-dev/keiko-verification/dist/targeted-project.js +37 -0
  793. package/node_modules/@oscharko-dev/keiko-verification/package.json +5 -5
  794. package/node_modules/@oscharko-dev/keiko-workflows/dist/bug-investigation/failure-parse.d.ts +10 -1
  795. package/node_modules/@oscharko-dev/keiko-workflows/dist/bug-investigation/failure-parse.d.ts.map +1 -1
  796. package/node_modules/@oscharko-dev/keiko-workflows/dist/bug-investigation/failure-parse.js +93 -15
  797. package/node_modules/@oscharko-dev/keiko-workflows/dist/bug-investigation/index.d.ts +1 -1
  798. package/node_modules/@oscharko-dev/keiko-workflows/dist/bug-investigation/index.d.ts.map +1 -1
  799. package/node_modules/@oscharko-dev/keiko-workflows/dist/bug-investigation/index.js +1 -1
  800. package/node_modules/@oscharko-dev/keiko-workflows/dist/contextpack/assemble.d.ts.map +1 -1
  801. package/node_modules/@oscharko-dev/keiko-workflows/dist/contextpack/assemble.js +16 -16
  802. package/node_modules/@oscharko-dev/keiko-workflows/dist/contextpack/reranker.d.ts +3 -0
  803. package/node_modules/@oscharko-dev/keiko-workflows/dist/contextpack/reranker.d.ts.map +1 -1
  804. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/anchors.d.ts +4 -1
  805. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/anchors.d.ts.map +1 -1
  806. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/anchors.js +296 -15
  807. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/governor.d.ts.map +1 -1
  808. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/index.d.ts +3 -1
  809. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/index.d.ts.map +1 -1
  810. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/index.js +1 -0
  811. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/intent.d.ts +7 -2
  812. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/intent.d.ts.map +1 -1
  813. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/intent.js +85 -5
  814. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/plan.d.ts +11 -0
  815. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/plan.d.ts.map +1 -1
  816. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/plan.js +507 -32
  817. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/references.d.ts +19 -0
  818. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/references.d.ts.map +1 -0
  819. package/node_modules/@oscharko-dev/keiko-workflows/dist/planner/references.js +159 -0
  820. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/filter.d.ts +1 -0
  821. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/filter.d.ts.map +1 -1
  822. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/filter.js +13 -16
  823. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/index.d.ts +2 -2
  824. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/index.d.ts.map +1 -1
  825. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/index.js +2 -2
  826. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/rank.d.ts.map +1 -1
  827. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/rank.js +21 -4
  828. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/scoring.d.ts +6 -0
  829. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/scoring.d.ts.map +1 -1
  830. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/scoring.js +44 -29
  831. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/signals.d.ts +5 -2
  832. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/signals.d.ts.map +1 -1
  833. package/node_modules/@oscharko-dev/keiko-workflows/dist/ranking/signals.js +141 -45
  834. package/node_modules/@oscharko-dev/keiko-workflows/package.json +10 -10
  835. package/node_modules/@oscharko-dev/keiko-workspace/dist/binaryDetect.d.ts.map +1 -1
  836. package/node_modules/@oscharko-dev/keiko-workspace/dist/binaryDetect.js +91 -15
  837. package/node_modules/@oscharko-dev/keiko-workspace/dist/codeIntelligence.d.ts +22 -1
  838. package/node_modules/@oscharko-dev/keiko-workspace/dist/codeIntelligence.d.ts.map +1 -1
  839. package/node_modules/@oscharko-dev/keiko-workspace/dist/codeIntelligence.js +661 -106
  840. package/node_modules/@oscharko-dev/keiko-workspace/dist/codeIntelligenceSurface.d.ts +3 -1
  841. package/node_modules/@oscharko-dev/keiko-workspace/dist/codeIntelligenceSurface.d.ts.map +1 -1
  842. package/node_modules/@oscharko-dev/keiko-workspace/dist/codeIntelligenceSurface.js +3 -1
  843. package/node_modules/@oscharko-dev/keiko-workspace/dist/discovery.d.ts +24 -4
  844. package/node_modules/@oscharko-dev/keiko-workspace/dist/discovery.d.ts.map +1 -1
  845. package/node_modules/@oscharko-dev/keiko-workspace/dist/discovery.js +89 -26
  846. package/node_modules/@oscharko-dev/keiko-workspace/dist/endpointContractAdapter.d.ts.map +1 -1
  847. package/node_modules/@oscharko-dev/keiko-workspace/dist/endpointContractAdapter.js +31 -9
  848. package/node_modules/@oscharko-dev/keiko-workspace/dist/endpointContractGraph.d.ts +3 -2
  849. package/node_modules/@oscharko-dev/keiko-workspace/dist/endpointContractGraph.d.ts.map +1 -1
  850. package/node_modules/@oscharko-dev/keiko-workspace/dist/endpointContractGraph.js +35 -5
  851. package/node_modules/@oscharko-dev/keiko-workspace/dist/endpointContractSource.d.ts +7 -1
  852. package/node_modules/@oscharko-dev/keiko-workspace/dist/endpointContractSource.d.ts.map +1 -1
  853. package/node_modules/@oscharko-dev/keiko-workspace/dist/endpointContractSource.js +40 -7
  854. package/node_modules/@oscharko-dev/keiko-workspace/dist/endpointContractTypes.d.ts +1 -1
  855. package/node_modules/@oscharko-dev/keiko-workspace/dist/endpointContractTypes.d.ts.map +1 -1
  856. package/node_modules/@oscharko-dev/keiko-workspace/dist/importGraphEdges.d.ts.map +1 -1
  857. package/node_modules/@oscharko-dev/keiko-workspace/dist/importGraphEdges.js +11 -5
  858. package/node_modules/@oscharko-dev/keiko-workspace/dist/index.d.ts +8 -3
  859. package/node_modules/@oscharko-dev/keiko-workspace/dist/index.d.ts.map +1 -1
  860. package/node_modules/@oscharko-dev/keiko-workspace/dist/index.js +7 -2
  861. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearch.d.ts +26 -5
  862. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearch.d.ts.map +1 -1
  863. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearch.js +418 -35
  864. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchHtml.d.ts +5 -0
  865. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchHtml.d.ts.map +1 -0
  866. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchHtml.js +21 -0
  867. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchLineSelection.d.ts +2 -1
  868. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchLineSelection.d.ts.map +1 -1
  869. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchLineSelection.js +5 -3
  870. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchMatchers.d.ts +10 -0
  871. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchMatchers.d.ts.map +1 -1
  872. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchMatchers.js +32 -4
  873. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchPolicy.d.ts +5 -1
  874. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchPolicy.d.ts.map +1 -1
  875. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchPolicy.js +41 -22
  876. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchQueryTerms.d.ts +14 -0
  877. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchQueryTerms.d.ts.map +1 -1
  878. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchQueryTerms.js +97 -0
  879. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchRoutes.d.ts +11 -0
  880. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchRoutes.d.ts.map +1 -1
  881. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchRoutes.js +154 -18
  882. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchScan.d.ts +6 -5
  883. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchScan.d.ts.map +1 -1
  884. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchScan.js +88 -24
  885. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchStream.d.ts.map +1 -1
  886. package/node_modules/@oscharko-dev/keiko-workspace/dist/repoSearchStream.js +21 -14
  887. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralAdapterRequestContext.d.ts +4 -1
  888. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralAdapterRequestContext.d.ts.map +1 -1
  889. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralAdapterRequestContext.js +205 -14
  890. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralAdapters.d.ts +1 -0
  891. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralAdapters.d.ts.map +1 -1
  892. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralAdapters.js +17 -13
  893. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralExecution.d.ts +1 -0
  894. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralExecution.d.ts.map +1 -1
  895. package/node_modules/@oscharko-dev/keiko-workspace/dist/structuralExecution.js +1 -1
  896. package/node_modules/@oscharko-dev/keiko-workspace/dist/symbolGraphLexing.d.ts.map +1 -1
  897. package/node_modules/@oscharko-dev/keiko-workspace/dist/symbolGraphLexing.js +13 -7
  898. package/node_modules/@oscharko-dev/keiko-workspace/dist/testSourcePairing.js +1 -1
  899. package/node_modules/@oscharko-dev/keiko-workspace/dist/types.d.ts +2 -2
  900. package/node_modules/@oscharko-dev/keiko-workspace/dist/types.d.ts.map +1 -1
  901. package/node_modules/@oscharko-dev/keiko-workspace/dist/types.js +1 -1
  902. package/node_modules/@oscharko-dev/keiko-workspace/dist/version.d.ts +1 -1
  903. package/node_modules/@oscharko-dev/keiko-workspace/dist/version.js +1 -1
  904. package/node_modules/@oscharko-dev/keiko-workspace/dist/workspaceIndex.d.ts +13 -5
  905. package/node_modules/@oscharko-dev/keiko-workspace/dist/workspaceIndex.d.ts.map +1 -1
  906. package/node_modules/@oscharko-dev/keiko-workspace/dist/workspaceIndex.js +112 -42
  907. package/node_modules/@oscharko-dev/keiko-workspace/dist/workspaceIndexQueryMatch.d.ts +11 -0
  908. package/node_modules/@oscharko-dev/keiko-workspace/dist/workspaceIndexQueryMatch.d.ts.map +1 -0
  909. package/node_modules/@oscharko-dev/keiko-workspace/dist/workspaceIndexQueryMatch.js +71 -0
  910. package/node_modules/@oscharko-dev/keiko-workspace/dist/workspaceIndexStreaming.d.ts +47 -0
  911. package/node_modules/@oscharko-dev/keiko-workspace/dist/workspaceIndexStreaming.d.ts.map +1 -0
  912. package/node_modules/@oscharko-dev/keiko-workspace/dist/workspaceIndexStreaming.js +231 -0
  913. package/node_modules/@oscharko-dev/keiko-workspace/dist/workspacePathDiscovery.d.ts +8 -0
  914. package/node_modules/@oscharko-dev/keiko-workspace/dist/workspacePathDiscovery.d.ts.map +1 -0
  915. package/node_modules/@oscharko-dev/keiko-workspace/dist/workspacePathDiscovery.js +178 -0
  916. package/node_modules/@oscharko-dev/keiko-workspace/dist/xmlEntities.d.ts +2 -0
  917. package/node_modules/@oscharko-dev/keiko-workspace/dist/xmlEntities.d.ts.map +1 -0
  918. package/node_modules/@oscharko-dev/keiko-workspace/dist/xmlEntities.js +34 -0
  919. package/node_modules/@oscharko-dev/keiko-workspace/package.json +4 -3
  920. package/package.json +28 -27
  921. package/release-impact.catalog.json +100 -0
  922. package/vendor/oscharko-dev-keiko-activity-log-1.2.1.tgz +0 -0
  923. package/vendor/oscharko-dev-keiko-cli-1.2.1.tgz +0 -0
  924. package/vendor/{oscharko-dev-keiko-connectors-1.2.0.tgz → oscharko-dev-keiko-connectors-1.2.1.tgz} +0 -0
  925. package/vendor/oscharko-dev-keiko-contracts-1.2.1.tgz +0 -0
  926. package/vendor/{oscharko-dev-keiko-evaluations-1.2.0.tgz → oscharko-dev-keiko-evaluations-1.2.1.tgz} +0 -0
  927. package/vendor/oscharko-dev-keiko-evidence-1.2.1.tgz +0 -0
  928. package/vendor/{oscharko-dev-keiko-git-1.2.0.tgz → oscharko-dev-keiko-git-1.2.1.tgz} +0 -0
  929. package/vendor/{oscharko-dev-keiko-harness-1.2.0.tgz → oscharko-dev-keiko-harness-1.2.1.tgz} +0 -0
  930. package/vendor/oscharko-dev-keiko-local-knowledge-1.2.1.tgz +0 -0
  931. package/vendor/{oscharko-dev-keiko-memory-capture-1.2.0.tgz → oscharko-dev-keiko-memory-capture-1.2.1.tgz} +0 -0
  932. package/vendor/{oscharko-dev-keiko-memory-consolidation-1.2.0.tgz → oscharko-dev-keiko-memory-consolidation-1.2.1.tgz} +0 -0
  933. package/vendor/{oscharko-dev-keiko-memory-governance-1.2.0.tgz → oscharko-dev-keiko-memory-governance-1.2.1.tgz} +0 -0
  934. package/vendor/{oscharko-dev-keiko-memory-retrieval-1.2.0.tgz → oscharko-dev-keiko-memory-retrieval-1.2.1.tgz} +0 -0
  935. package/vendor/{oscharko-dev-keiko-memory-vault-1.2.0.tgz → oscharko-dev-keiko-memory-vault-1.2.1.tgz} +0 -0
  936. package/vendor/oscharko-dev-keiko-model-gateway-1.2.1.tgz +0 -0
  937. package/vendor/{oscharko-dev-keiko-quality-intelligence-1.2.0.tgz → oscharko-dev-keiko-quality-intelligence-1.2.1.tgz} +0 -0
  938. package/vendor/oscharko-dev-keiko-sandbox-1.2.1.tgz +0 -0
  939. package/vendor/{oscharko-dev-keiko-sdk-1.2.0.tgz → oscharko-dev-keiko-sdk-1.2.1.tgz} +0 -0
  940. package/vendor/oscharko-dev-keiko-security-1.2.1.tgz +0 -0
  941. package/vendor/oscharko-dev-keiko-server-1.2.1.tgz +0 -0
  942. package/vendor/oscharko-dev-keiko-tool-catalog-1.2.1.tgz +0 -0
  943. package/vendor/oscharko-dev-keiko-tools-1.2.1.tgz +0 -0
  944. package/vendor/oscharko-dev-keiko-verification-1.2.1.tgz +0 -0
  945. package/vendor/oscharko-dev-keiko-workflows-1.2.1.tgz +0 -0
  946. package/vendor/oscharko-dev-keiko-workspace-1.2.1.tgz +0 -0
  947. package/dist/ui/static/_next/static/chunks/07skh7tlpfo1v.js +0 -1
  948. package/dist/ui/static/_next/static/chunks/09i_8713x46yr.js +0 -1
  949. package/dist/ui/static/_next/static/chunks/0a6ri2ug5xf10.js +0 -1
  950. package/dist/ui/static/_next/static/chunks/0bbrrvuzilpy5.js +0 -1
  951. package/dist/ui/static/_next/static/chunks/0bg7uh6tq8-dx.js +0 -1
  952. package/dist/ui/static/_next/static/chunks/0cwy6mtvshbuo.js +0 -1
  953. package/dist/ui/static/_next/static/chunks/0fpbvpzg-omn0.js +0 -1
  954. package/dist/ui/static/_next/static/chunks/0fz9qig_5p73f.js +0 -1
  955. package/dist/ui/static/_next/static/chunks/0hvxxuef1gw9p.js +0 -1
  956. package/dist/ui/static/_next/static/chunks/0ktvc8fs3spkb.js +0 -1
  957. package/dist/ui/static/_next/static/chunks/0kvy_ru-kodgv.js +0 -1
  958. package/dist/ui/static/_next/static/chunks/0parm4c86umwk.js +0 -1
  959. package/dist/ui/static/_next/static/chunks/0q_08tk2d3m2n.js +0 -1
  960. package/dist/ui/static/_next/static/chunks/0r2lwkgws6jm8.js +0 -1
  961. package/dist/ui/static/_next/static/chunks/0t73kckx3olud.js +0 -1
  962. package/dist/ui/static/_next/static/chunks/0u7vyqk91gjb8.js +0 -1
  963. package/dist/ui/static/_next/static/chunks/0weojtwxo6qw7.js +0 -1
  964. package/dist/ui/static/_next/static/chunks/0x-r45yl06rdn.js +0 -1
  965. package/dist/ui/static/_next/static/chunks/0zlw46qz0crxg.css +0 -1
  966. package/dist/ui/static/_next/static/chunks/0zuaq_9l5pma_.js +0 -1
  967. package/dist/ui/static/_next/static/chunks/10kb8j7vggfwk.js +0 -1
  968. package/dist/ui/static/_next/static/chunks/14qdwomthzucj.js +0 -1
  969. package/dist/ui/static/_next/static/chunks/1a7ko-_7t4wjo.js +0 -1
  970. package/dist/ui/static/_next/static/chunks/1czgn62g6km38.js +0 -3
  971. package/dist/ui/static/_next/static/chunks/1juiifi_xnx68.js +0 -1
  972. package/dist/ui/static/_next/static/chunks/1wg1s3jm779ro.js +0 -3
  973. package/dist/ui/static/_next/static/chunks/224bbe_3ksnlw.js +0 -1
  974. package/dist/ui/static/_next/static/chunks/263_uck8el32f.js +0 -1
  975. package/dist/ui/static/_next/static/chunks/26gmn1z4oegqh.js +0 -1
  976. package/dist/ui/static/_next/static/chunks/28ylcw-leje_k.js +0 -1
  977. package/dist/ui/static/_next/static/chunks/2937s9os9u2tn.js +0 -1
  978. package/dist/ui/static/_next/static/chunks/29rlw6dih8owf.js +0 -1
  979. package/dist/ui/static/_next/static/chunks/2hq0zlnvfqol9.js +0 -1
  980. package/dist/ui/static/_next/static/chunks/2o584howfzzak.js +0 -3
  981. package/dist/ui/static/_next/static/chunks/2p66e_a0j23r8.js +0 -1
  982. package/dist/ui/static/_next/static/chunks/2r4vn_6anv2cw.js +0 -5
  983. package/dist/ui/static/_next/static/chunks/2ribv7pn1hr-l.js +0 -1
  984. package/dist/ui/static/_next/static/chunks/2tb2nt2wvu643.js +0 -1
  985. package/dist/ui/static/_next/static/chunks/2yot6vshhc19p.css +0 -1
  986. package/dist/ui/static/_next/static/chunks/30j8jo5v60ga1.js +0 -2
  987. package/dist/ui/static/_next/static/chunks/30q9b_aw8driv.js +0 -1
  988. package/dist/ui/static/_next/static/chunks/387k5c-bf1b2e.js +0 -1
  989. package/dist/ui/static/_next/static/chunks/3_alxp77ewgk_.js +0 -1
  990. package/dist/ui/static/_next/static/chunks/3_ycy0h8pq58a.js +0 -1
  991. package/dist/ui/static/_next/static/chunks/3ho1f5n8lir4r.js +0 -1
  992. package/dist/ui/static/_next/static/chunks/3kgc_j74tblcn.js +0 -1
  993. package/dist/ui/static/_next/static/chunks/3mxpjroefk8ou.js +0 -1
  994. package/dist/ui/static/_next/static/chunks/3q5jidle0lb3-.js +0 -1
  995. package/dist/ui/static/_next/static/chunks/3ua7si017r4dg.js +0 -1
  996. package/dist/ui/static/_next/static/chunks/3v2iluxqnsug9.css +0 -15
  997. package/dist/ui/static/_next/static/chunks/3z5f2s7yd35cu.js +0 -1
  998. package/dist/ui/static/_next/static/chunks/40co1uetczqcs.js +0 -1
  999. package/vendor/oscharko-dev-keiko-activity-log-1.2.0.tgz +0 -0
  1000. package/vendor/oscharko-dev-keiko-cli-1.2.0.tgz +0 -0
  1001. package/vendor/oscharko-dev-keiko-contracts-1.2.0.tgz +0 -0
  1002. package/vendor/oscharko-dev-keiko-evidence-1.2.0.tgz +0 -0
  1003. package/vendor/oscharko-dev-keiko-local-knowledge-1.2.0.tgz +0 -0
  1004. package/vendor/oscharko-dev-keiko-model-gateway-1.2.0.tgz +0 -0
  1005. package/vendor/oscharko-dev-keiko-sandbox-1.2.0.tgz +0 -0
  1006. package/vendor/oscharko-dev-keiko-security-1.2.0.tgz +0 -0
  1007. package/vendor/oscharko-dev-keiko-server-1.2.0.tgz +0 -0
  1008. package/vendor/oscharko-dev-keiko-tool-catalog-1.2.0.tgz +0 -0
  1009. package/vendor/oscharko-dev-keiko-tools-1.2.0.tgz +0 -0
  1010. package/vendor/oscharko-dev-keiko-verification-1.2.0.tgz +0 -0
  1011. package/vendor/oscharko-dev-keiko-workflows-1.2.0.tgz +0 -0
  1012. package/vendor/oscharko-dev-keiko-workspace-1.2.0.tgz +0 -0
  1013. /package/dist/ui/static/_next/static/{LNCY1B2FJBOe2AHFXpzB- → FS1LLJ_p3joZhfRkXBRhf}/_buildManifest.js +0 -0
  1014. /package/dist/ui/static/_next/static/{LNCY1B2FJBOe2AHFXpzB- → FS1LLJ_p3joZhfRkXBRhf}/_clientMiddlewareManifest.js +0 -0
  1015. /package/dist/ui/static/_next/static/{LNCY1B2FJBOe2AHFXpzB- → FS1LLJ_p3joZhfRkXBRhf}/_ssgManifest.js +0 -0
@@ -1,3 +1,20 @@
1
+ import { hasRecursiveTraversalQuery, CANONICAL_MANIFEST_BASENAMES, DEFAULT_SEARCH_LIMITS, FileTooLargeError, PathDeniedError, PathEscapeError, RepoSearchUnsupportedFileError, WorkspaceNotFoundError, WorkspaceReadError, candidateBucketForPath, detectWorkspaceAt, decodeTextFileBytes, endpointContractAdapter, findFiles, gitHistoryAdapter, isCanonicalMetadataFile, isEcosystemSourceFile, isGeneratedArtifactPath, isDenied, readExcerpt, resolveWithinWorkspace, searchText, symbolGraphAdapter, containedRealPathInfo, evidenceAtomStableId, } from "@oscharko-dev/keiko-workspace";
2
+ import { groundedSemanticFreshnessSummary, staleSemanticMarker, } from "./grounded-semantic-request.js";
3
+ import { observeWorktreeRecency } from "./grounded-worktree-recency.js";
4
+ import { createWorktreeRecencySnapshot, } from "./grounded-worktree-request.js";
5
+ import { logGroundedAnswerActivity, } from "./grounded-answer-activity.js";
6
+ import { followUpGroundedAnswer, } from "./grounded-follow-up.js";
7
+ import { admissibleDeclaredScopePath, isOrdinaryFolderDocumentPath, } from "./grounded-explicit-paths.js";
8
+ import { declaredInsufficiencyPaths, connectedSearchNoEvidenceAnswer, buildPackCitationIndex, incompleteAnswerMarker, missingCitationMarkerFor, noEvidenceMarker, packHasUsableEvidence, unsupportedCitationMarker, } from "./grounded-faithfulness.js";
9
+ import { splitOwnAssessmentForPolicy, } from "@oscharko-dev/keiko-contracts/runtime/grounded-assessment";
10
+ import { normalizeGroundedAnswerAssessment, isGroundedAssessmentOnly, } from "./grounded-answer-assessment.js";
11
+ import { repairGroundedAnswer, observeGroundedCitationBehaviour, } from "./grounded-answer-repair.js";
12
+ import { singleSentEvidencePack, validateSingleAnswerEvidence, withSentSelectionDiagnostics, } from "./grounded-answer-evidence.js";
13
+ import { rerankGroundedCandidates, } from "./grounded-preselection-reranker.js";
14
+ import { selectionQuality, lowConfidenceSelectionMarker, withContextualHintConfidence, } from "./grounded-selection-quality.js";
15
+ import { captureContextualFallbackCandidates, currentContextualFallbackOrder, } from "./grounded-contextual-fallback.js";
16
+ import { orderDistinctEvidenceCandidates, } from "./grounded-candidate-ordering.js";
17
+ import { admitDiagnosticReferences, } from "./grounded-diagnostic-references.js";
1
18
  // Grounded repository Q&A orchestrator (Epic #177, Issue #185). Composes the connected-context
2
19
  // layers — #181 exploration planner, #179 lexical search facade, #180 structural adapters,
3
20
  // #182 candidate ranker, and #183 context-pack assembler — into a single linear pipeline that
@@ -9,16 +26,15 @@
9
26
  // package's already-bounded WorkspaceFs port. Path validation is enforced by every composed
10
27
  // layer at its own boundary, so this file does not re-validate scope paths.
11
28
  import { directoryCleanupTracker, observeDirectoryIteration, } from "./grounded-directory-iteration.js";
12
- import { reconcileAndLogInlineCitations } from "./grounded-citation-log.js";
29
+ import { logAnswerAssessment, reconcileAndLogInlineCitations, } from "./grounded-citation-log.js";
13
30
  import { createSymbolReadFailureObserver, } from "./grounded-symbol-diagnostics.js";
14
31
  import { mergeOverviewListing } from "./grounded-overview-fallback.js";
15
32
  import { Buffer } from "node:buffer";
16
33
  import { createHash } from "node:crypto";
17
- import { resolve } from "node:path";
34
+ import { dirname as parentDirectory, resolve } from "node:path";
18
35
  import { connectedContextOmittedCount, connectedContextOmittedCounts, CONNECTED_CONTEXT_SCHEMA_VERSION, DEFAULT_EXPLORATION_BUDGET, MAX_OMITTED_CONTEXT_ENTRIES, isValidScopePath, } from "@oscharko-dev/keiko-contracts/connected-context";
19
36
  import { activityLogErrorKindOr, activityLogEvent, classifyErrorKind, defineActivityLogOperation, } from "@oscharko-dev/keiko-contracts/runtime/observability";
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";
37
+ import { advanceRing, applyUsage, assembleContextPack, canContinue, classifyRetrievalIntent, complete, contextPackIndexKey, extractAnchors, DEFAULT_FILTER_OPTIONS, absoluteRelevanceFloor, weightsForIntent, filterCandidates, planAndGovern, rankCandidates, isDirectEvidenceLookup, isGeneratedRankingPath, requiresRelationshipOrHistoryRings, resolveQueryTargetDecision, extractRetrievalChannels, searchReferenceAnchors, } from "@oscharko-dev/keiko-workflows";
22
38
  import { isAllowedContainedPathParent, isCanonicalAllowedContainedPath, } from "@oscharko-dev/keiko-workspace/internal/realpath-policy";
23
39
  import { createStructuralAdapterRequestContext, createEcosystemStructureAdapters, importGraphAdapter, runStructuralAdapters, repositorySourceLines, structuralLineLooksLikeSymbolDefinition, testSourcePairingAdapter, } from "@oscharko-dev/keiko-workspace/code-intelligence";
24
40
  import { CancelledError, ERROR_CODES } from "@oscharko-dev/keiko-model-gateway";
@@ -28,11 +44,10 @@ import { compareStrings } from "@oscharko-dev/keiko-contracts/runtime/comparator
28
44
  import { isWorkspacePathSnapshotCurrent, nodeWorkspaceFs, } from "@oscharko-dev/keiko-workspace/internal/fs";
29
45
  import { preserveOwnedRootAuthority } from "@oscharko-dev/keiko-workspace/internal/owned-root-preserve";
30
46
  import { normalizeGroundedAnswerPayload, } from "./grounded-answer.js";
31
- import { connectedSearchNoEvidenceAnswer, buildPackCitationIndex, incompleteAnswerMarker, missingCitationMarkerFor, noEvidenceMarker, packHasUsableEvidence, unsupportedCitationMarker, } from "./grounded-faithfulness.js";
32
- import { collectDiscoveredSymbolTraceEvidence, collectFollowSymbolTraceEvidence, GROUNDED_TRACE_SEARCH_LIMITS, } from "./grounded-symbol-trace.js";
47
+ import { collectDiscoveredSymbolTraceEvidence, collectFollowSymbolTraceEvidence, contextualDiscoveredSymbolTraceRequested, GROUNDED_TRACE_SEARCH_LIMITS, } from "./grounded-symbol-trace.js";
33
48
  import { defaultGitFileHistoryEvidenceProvider, } from "./grounded-git-history-evidence.js";
34
- import { collectConnectedDocumentEvidence, isConnectedDocumentPath, } from "./grounded-document-evidence.js";
35
- import { certifiedContentPaths, selectGroundedCandidateFiles, pathOnlyEvidencePaths, selectGroundedEvidenceAtoms, tracePriority, } from "./grounded-evidence-selection.js";
49
+ import { collectConnectedDocumentEvidence, isConnectedDocumentPath, isExtractableConnectedDocumentPath, documentProjectionUsage, } from "./grounded-document-evidence.js";
50
+ import { certifiedContentPaths, selectGroundedCandidateFiles, ordinaryRelativeFloor, pathOnlyEvidencePaths, selectGroundedEvidenceAtoms, tracePriority, } from "./grounded-evidence-selection.js";
36
51
  import { directDefinitionSymbol } from "./grounded-query-shape.js";
37
52
  import { KnownFitScopeContext } from "./grounded-scope-context.js";
38
53
  import { attachContextBudgetDiagnostics, deriveGroundedContextAssembly, } from "./grounded-context-diagnostics.js";
@@ -118,6 +133,7 @@ const SEARCH_CONNECTED_CONTEXT_COMPLETED_OPERATION = defineActivityLogOperation(
118
133
  "repository-overview",
119
134
  "targeted-code-search",
120
135
  "diagnostic-search",
136
+ "conversational-follow-up",
121
137
  "clarification-needed",
122
138
  ],
123
139
  },
@@ -168,22 +184,10 @@ const SEARCH_CONNECTED_CONTEXT_COMPLETED_OPERATION = defineActivityLogOperation(
168
184
  "literal-absence",
169
185
  "complete-exact-lookup",
170
186
  "verified-target-context",
187
+ "explicit-target-unavailable",
171
188
  ],
172
189
  },
173
190
  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
- },
187
191
  usageSearchCalls: { type: "integer", dataClass: "count", required: false },
188
192
  usageFilesRead: { type: "integer", dataClass: "count", required: false },
189
193
  usageExcerptBytes: { type: "integer", dataClass: "count", required: false },
@@ -266,6 +270,21 @@ const SEARCH_CONNECTED_CONTEXT_COMPLETION_DETAILS_OPERATION = defineActivityLogO
266
270
  fields: {
267
271
  scopeIdentitySha256: { type: "string", dataClass: "digest", required: true, maxLength: 64 },
268
272
  queryIdentitySha256: { type: "string", dataClass: "digest", required: true, maxLength: 64 },
273
+ metadataRetentionLimit: { type: "integer", dataClass: "count", required: false },
274
+ augmentationSkipReason: {
275
+ type: "string",
276
+ dataClass: "closed-enum",
277
+ required: false,
278
+ values: [
279
+ "no-git-metadata",
280
+ "ordinary-document",
281
+ "literal-absence",
282
+ "complete-exact-lookup",
283
+ "verified-target-context",
284
+ "budget-exhausted",
285
+ "explicit-target-unavailable",
286
+ ],
287
+ },
269
288
  activityDetailStatus: {
270
289
  type: "string",
271
290
  dataClass: "closed-enum",
@@ -275,6 +294,7 @@ const SEARCH_CONNECTED_CONTEXT_COMPLETION_DETAILS_OPERATION = defineActivityLogO
275
294
  excerptOmittedRangeCount: { type: "integer", dataClass: "count", required: false },
276
295
  excerptTruncatedWindowCount: { type: "integer", dataClass: "count", required: false },
277
296
  excerptUnreadFileCount: { type: "integer", dataClass: "count", required: false },
297
+ excerptServedQueryFacetCount: { type: "integer", dataClass: "count", required: false },
278
298
  excerptStopReasons: {
279
299
  type: "string-array",
280
300
  dataClass: "closed-enum",
@@ -345,6 +365,7 @@ const SEARCH_CONNECTED_CONTEXT_COMPLETION_DETAILS_OPERATION = defineActivityLogO
345
365
  indexReusedRecords: { type: "integer", dataClass: "count", required: false },
346
366
  indexStaleRecords: { type: "integer", dataClass: "count", required: false },
347
367
  indexSearchCount: { type: "integer", dataClass: "count", required: false },
368
+ searchCitationDirectiveClauseCount: { type: "integer", dataClass: "count", required: false },
348
369
  indexReportCount: { type: "integer", dataClass: "count", required: false },
349
370
  indexFallbackSearchCount: { type: "integer", dataClass: "count", required: false },
350
371
  indexBypassedSearchCount: { type: "integer", dataClass: "count", required: false },
@@ -368,6 +389,125 @@ const SEARCH_CONNECTED_CONTEXT_COMPLETION_DETAILS_OPERATION = defineActivityLogO
368
389
  proofIds: ["search.connected-context.completion-details.line"],
369
390
  releaseImpact: "patch",
370
391
  });
392
+ const SEARCH_CONNECTED_CONTEXT_SELECTION_DETAILS_OPERATION = defineActivityLogOperation({
393
+ contractKind: "activity-log-operation",
394
+ schemaVersion: 1,
395
+ op: "search.connected-context.selection-details",
396
+ category: "search",
397
+ owner: "keiko-server",
398
+ emitter: "grounded-orchestrator.createConnectedContextActivity.selectionDetails",
399
+ fields: {
400
+ scopeIdentitySha256: { type: "string", dataClass: "digest", required: true, maxLength: 64 },
401
+ queryIdentitySha256: { type: "string", dataClass: "digest", required: true, maxLength: 64 },
402
+ worktreeStatusDisposition: {
403
+ type: "string",
404
+ dataClass: "closed-enum",
405
+ required: false,
406
+ values: ["not-git", "unavailable", "applied", "skipped-budget"],
407
+ },
408
+ worktreeStatusDurationMs: { type: "integer", dataClass: "count", required: false },
409
+ semanticStaleFallbackCount: { type: "integer", dataClass: "count", required: false },
410
+ semanticRefreshedFileCount: { type: "integer", dataClass: "count", required: false },
411
+ semanticRefreshEmbeddingCallCount: { type: "integer", dataClass: "count", required: false },
412
+ semanticRefreshReadFileCount: { type: "integer", dataClass: "count", required: false },
413
+ semanticRefreshReadBytesUpperBound: { type: "integer", dataClass: "count", required: false },
414
+ semanticRefreshInputTokenUpperBound: { type: "integer", dataClass: "count", required: false },
415
+ recentPathHintCount: { type: "integer", dataClass: "count", required: false },
416
+ recentPathHitCount: { type: "integer", dataClass: "count", required: false },
417
+ worktreeObservedFileCount: { type: "integer", dataClass: "count", required: false },
418
+ worktreeDeletedFileCount: { type: "integer", dataClass: "count", required: false },
419
+ basenameCollisionGroupCount: { type: "integer", dataClass: "count", required: false },
420
+ basenameDedupDemotedCount: { type: "integer", dataClass: "count", required: false },
421
+ addressedBasenameDedupDemotedCount: { type: "integer", dataClass: "count", required: false },
422
+ exactPathSignalPresentCount: { type: "integer", dataClass: "count", required: false },
423
+ pathSegmentSignalPresentCount: { type: "integer", dataClass: "count", required: false },
424
+ directoryProximityTieBreakCount: { type: "integer", dataClass: "count", required: false },
425
+ floorReferenceKind: {
426
+ type: "string",
427
+ dataClass: "closed-enum",
428
+ required: false,
429
+ values: ["ordinary-p75", "no-ordinary", "files-scope"],
430
+ },
431
+ relativeFloorPermille: { type: "integer", dataClass: "count", required: false },
432
+ strongestOrdinaryScorePermille: { type: "integer", dataClass: "count", required: false },
433
+ absoluteFloorPermille: { type: "integer", dataClass: "count", required: false },
434
+ keepOneFallbackApplied: { type: "boolean", dataClass: "closed-enum", required: false },
435
+ fallbackRankingSource: {
436
+ type: "string",
437
+ dataClass: "closed-enum",
438
+ required: false,
439
+ values: ["candidate-score", "lexical-producer"],
440
+ },
441
+ selectionConfidence: {
442
+ type: "string",
443
+ dataClass: "closed-enum",
444
+ required: false,
445
+ values: ["high", "low"],
446
+ },
447
+ rerankerDisposition: {
448
+ type: "string",
449
+ dataClass: "closed-enum",
450
+ required: false,
451
+ values: ["unconfigured", "applied", "failed", "skipped-budget", "skipped-literal"],
452
+ },
453
+ reranked: { type: "boolean", dataClass: "closed-enum", required: false },
454
+ rerankFailedCalls: { type: "integer", dataClass: "count", required: false },
455
+ rerankerCandidateCount: { type: "integer", dataClass: "count", required: false },
456
+ rerankerDocumentCount: { type: "integer", dataClass: "count", required: false },
457
+ failureKind: { type: "string", dataClass: "error-kind", required: false, maxLength: 64 },
458
+ frames: {
459
+ type: "string-array",
460
+ dataClass: "safe-platform-class",
461
+ required: false,
462
+ maxLength: 512,
463
+ maxItems: 8,
464
+ },
465
+ causeChain: {
466
+ type: "string-array",
467
+ dataClass: "error-kind",
468
+ required: false,
469
+ maxLength: 128,
470
+ maxItems: 5,
471
+ },
472
+ stackTraceFrameCount: { type: "integer", dataClass: "count", required: false },
473
+ stackTraceExternalFrameCount: { type: "integer", dataClass: "count", required: false },
474
+ continuityReferentSource: {
475
+ type: "string",
476
+ dataClass: "closed-enum",
477
+ required: false,
478
+ values: [
479
+ "none",
480
+ "previous-user-question",
481
+ "assistant-paths",
482
+ "assistant-declaration",
483
+ "assistant-paths-and-declaration",
484
+ ],
485
+ },
486
+ continuityReferentCount: { type: "integer", dataClass: "count", required: false },
487
+ continuityAdmittedCount: { type: "integer", dataClass: "count", required: false },
488
+ continuityRejectedCount: { type: "integer", dataClass: "count", required: false },
489
+ excerptOrdinaryRangeCount: { type: "integer", dataClass: "count", required: false },
490
+ excerptOrdinaryServedRangeCount: { type: "integer", dataClass: "count", required: false },
491
+ excerptDeferredDefinitionRangeCount: { type: "integer", dataClass: "count", required: false },
492
+ requestedStaticCallCycleCount: { type: "integer", dataClass: "count", required: false },
493
+ plannedStaticCallCycleCount: { type: "integer", dataClass: "count", required: false },
494
+ contextualDefinitionSeedCount: { type: "integer", dataClass: "count", required: false },
495
+ completeness: { type: "string", dataClass: "completeness-state", required: true },
496
+ loss: { type: "string", dataClass: "loss-state", required: true },
497
+ },
498
+ diagnosticWhen: [{ field: "rerankerDisposition", values: ["failed"] }],
499
+ causal: "correlation",
500
+ lifecycle: "state",
501
+ analyzerProjection: "timeline",
502
+ failureClasses: ["connected-context-retrieval"],
503
+ proofIds: [
504
+ "search.connected-context.selection-details.line",
505
+ "search.connected-context.path-ranking.line",
506
+ "search.connected-context.selection-quality.line",
507
+ "search.connected-context.continuity.line",
508
+ ],
509
+ releaseImpact: "patch",
510
+ });
371
511
  const SEARCH_CONNECTED_CONTEXT_SOURCE_DETAILS_OPERATION = defineActivityLogOperation({
372
512
  contractKind: "activity-log-operation",
373
513
  schemaVersion: 1,
@@ -385,6 +525,40 @@ const SEARCH_CONNECTED_CONTEXT_SOURCE_DETAILS_OPERATION = defineActivityLogOpera
385
525
  values: ["complete", "unavailable"],
386
526
  },
387
527
  directEvidenceLookup: { type: "boolean", dataClass: "closed-enum", required: false },
528
+ explicitSelectionAtomCount: { type: "integer", dataClass: "count", required: false },
529
+ stackTraceDetected: { type: "boolean", dataClass: "closed-enum", required: false },
530
+ stackTraceInScopeFrameCount: { type: "integer", dataClass: "count", required: false },
531
+ stackTraceAdmittedPathCount: { type: "integer", dataClass: "count", required: false },
532
+ testSourcePairCount: { type: "integer", dataClass: "count", required: false },
533
+ referenceChannelCount: { type: "integer", dataClass: "count", required: false },
534
+ metadataInjectionReason: {
535
+ type: "string",
536
+ dataClass: "closed-enum",
537
+ required: false,
538
+ values: ["intent", "pattern", "none"],
539
+ },
540
+ explicitPathAnchorCount: { type: "integer", dataClass: "count", required: false },
541
+ explicitPathAdmittedCount: { type: "integer", dataClass: "count", required: false },
542
+ explicitPathRejectedCount: { type: "integer", dataClass: "count", required: false },
543
+ explicitPathRejectionReasons: {
544
+ type: "string-array",
545
+ dataClass: "closed-enum",
546
+ required: false,
547
+ maxItems: 8,
548
+ values: [
549
+ "outside-scope",
550
+ "denied",
551
+ "missing",
552
+ "ignored",
553
+ "generated",
554
+ "binary",
555
+ "size-exceeded",
556
+ "unsupported-format",
557
+ ],
558
+ },
559
+ explicitLineHintCount: { type: "integer", dataClass: "count", required: false },
560
+ basenameDiscoveryTermCount: { type: "integer", dataClass: "count", required: false },
561
+ basenameDiscoveryMatchCount: { type: "integer", dataClass: "count", required: false },
388
562
  unrepresentablePathCount: { type: "integer", dataClass: "count", required: false },
389
563
  reusedEvidenceAtomCount: { type: "integer", dataClass: "count", required: false },
390
564
  semanticProviderDisposition: {
@@ -407,7 +581,6 @@ const SEARCH_CONNECTED_CONTEXT_SOURCE_DETAILS_OPERATION = defineActivityLogOpera
407
581
  metadataRetainedCount: { type: "integer", dataClass: "count", required: false },
408
582
  metadataDiscardedCount: { type: "integer", dataClass: "count", required: false },
409
583
  metadataOmittedDetailCount: { type: "integer", dataClass: "count", required: false },
410
- metadataRetentionLimit: { type: "integer", dataClass: "count", required: false },
411
584
  omittedDetailRetainedCount: { type: "integer", dataClass: "count", required: false },
412
585
  omittedDetailsClipped: { type: "boolean", dataClass: "closed-enum", required: false },
413
586
  omittedOutsideScopeCount: { type: "integer", dataClass: "count", required: false },
@@ -437,7 +610,11 @@ const SEARCH_CONNECTED_CONTEXT_SOURCE_DETAILS_OPERATION = defineActivityLogOpera
437
610
  lifecycle: "state",
438
611
  analyzerProjection: "timeline",
439
612
  failureClasses: ["connected-context-retrieval"],
440
- proofIds: ["search.connected-context.source-details.line"],
613
+ proofIds: [
614
+ "search.connected-context.source-details.line",
615
+ "search.connected-context.explicit-admission.line",
616
+ "search.connected-context.diagnostic-references.line",
617
+ ],
441
618
  releaseImpact: "patch",
442
619
  });
443
620
  const SEARCH_METADATA_UNAVAILABLE_OPERATION = defineActivityLogOperation({
@@ -515,6 +692,7 @@ const SEARCH_CONNECTED_CONTEXT_CLARIFICATION_OPERATION = defineActivityLogOperat
515
692
  "repository-overview",
516
693
  "targeted-code-search",
517
694
  "diagnostic-search",
695
+ "conversational-follow-up",
518
696
  "clarification-needed",
519
697
  ],
520
698
  },
@@ -739,6 +917,7 @@ function sumContextDiagnostics(contexts) {
739
917
  }
740
918
  function emptyWorkspaceIndexActivityCounters() {
741
919
  return {
920
+ citationDirectiveClauseCount: 0,
742
921
  discoveredEntries: 0,
743
922
  retainedEntries: 0,
744
923
  indexedRecords: 0,
@@ -769,6 +948,7 @@ function stoppedBeforeWorkspaceScan(result) {
769
948
  }
770
949
  function addWorkspaceIndexResult(counters, result) {
771
950
  counters.searchCount += 1;
951
+ counters.citationDirectiveClauseCount += result.diagnostics?.citationDirectiveClauseCount ?? 0;
772
952
  const report = result.workspaceIndex;
773
953
  if (report === undefined) {
774
954
  if (stoppedBeforeWorkspaceScan(result))
@@ -799,6 +979,10 @@ function unindexedWorkspaceSearchMode(counters) {
799
979
  return "live-fallback";
800
980
  return counters.bypassedSearchCount > 0 ? "live-scan" : "unused";
801
981
  }
982
+ function failedUnusedWorkspaceIndex(counters) {
983
+ return (counters.loadFailures + counters.saveFailures > 0 &&
984
+ counters.retainedEntries + counters.indexedRecords + counters.reusedRecords === 0);
985
+ }
802
986
  function workspaceIndexSearchMode(providerStatus, counters) {
803
987
  if (providerStatus === "not-evaluated")
804
988
  return "not-evaluated";
@@ -806,6 +990,8 @@ function workspaceIndexSearchMode(providerStatus, counters) {
806
990
  return "unused";
807
991
  if (counters.reportCount === 0)
808
992
  return unindexedWorkspaceSearchMode(counters);
993
+ if (failedUnusedWorkspaceIndex(counters))
994
+ return "live-fallback";
809
995
  const reconciled = counters.staleRecords + counters.deletedEntries + counters.droppedRecords > 0;
810
996
  const persistent = workspaceIndexPersistenceSucceeded(providerStatus, counters);
811
997
  if (reconciled)
@@ -845,10 +1031,10 @@ function workspaceIndexActivityDiagnostics(providerStatus, counters) {
845
1031
  }
846
1032
  function observedWorkspaceIndex(source, counters) {
847
1033
  return {
848
- loadSnapshot: async (scopeKey) => {
1034
+ loadSnapshot: async (scopeKey, isActive) => {
849
1035
  counters.loadAttempts += 1;
850
1036
  try {
851
- const snapshot = await source.loadSnapshot(scopeKey);
1037
+ const snapshot = await source.loadSnapshot(scopeKey, isActive);
852
1038
  if (snapshot === undefined)
853
1039
  counters.loadMisses += 1;
854
1040
  else
@@ -860,10 +1046,10 @@ function observedWorkspaceIndex(source, counters) {
860
1046
  throw error;
861
1047
  }
862
1048
  },
863
- saveSnapshot: async (scopeKey, snapshot) => {
1049
+ saveSnapshot: async (scopeKey, snapshot, isActive) => {
864
1050
  counters.saveAttempts += 1;
865
1051
  try {
866
- await source.saveSnapshot(scopeKey, snapshot);
1052
+ await source.saveSnapshot(scopeKey, snapshot, isActive);
867
1053
  counters.saveSuccesses += 1;
868
1054
  }
869
1055
  catch (error) {
@@ -891,6 +1077,7 @@ function observedStructuralContext(context, activity) {
891
1077
  skippedSymbolicLinks: context.skippedSymbolicLinks.bind(context),
892
1078
  candidateLimitReached: context.candidateLimitReached.bind(context),
893
1079
  codeIntelligenceIndex: context.codeIntelligenceIndex.bind(context),
1080
+ isCodeIntelligenceSourceCurrent: context.isCodeIntelligenceSourceCurrent.bind(context),
894
1081
  symbolGraph: context.symbolGraph.bind(context),
895
1082
  importGraph: context.importGraph.bind(context),
896
1083
  endpointContractGraph: context.endpointContractGraph.bind(context),
@@ -904,18 +1091,27 @@ function observedStructuralContext(context, activity) {
904
1091
  diagnostics: context.diagnostics.bind(context),
905
1092
  };
906
1093
  }
907
- function createStructuralRequestContextPool(scope, fs, nowMs, deadlineAtMs, workspaceIndexActivity, signal) {
1094
+ function createStructuralRequestContextPool(scope, fs, nowMs, deadlineAtMs, workspaceIndexActivity, signal, isCandidateAllowed) {
908
1095
  const contexts = new Map();
1096
+ const preferredSourcePaths = [];
909
1097
  return {
1098
+ preferCodeIntelligenceSources: (paths) => {
1099
+ for (const path of paths) {
1100
+ if (!preferredSourcePaths.includes(path))
1101
+ preferredSourcePaths.push(path);
1102
+ }
1103
+ },
910
1104
  forLimits: (limits) => {
911
1105
  const key = searchLimitsKey(limits);
912
1106
  const existing = contexts.get(key);
913
1107
  if (existing !== undefined)
914
1108
  return existing;
915
1109
  const created = observedStructuralContext(createStructuralAdapterRequestContext(scope, limits, fs, {
1110
+ preferredCodeIntelligenceSourcePaths: preferredSourcePaths,
916
1111
  nowMs,
917
1112
  deadlineAtMs,
918
1113
  ...(signal === undefined ? {} : { signal }),
1114
+ ...(isCandidateAllowed === undefined ? {} : { isCandidateAllowed }),
919
1115
  }), workspaceIndexActivity);
920
1116
  contexts.set(key, created);
921
1117
  return created;
@@ -1174,7 +1370,8 @@ function structuralQueriesForRing(ring, inputs) {
1174
1370
  if (anchorKind !== "path" && anchorKind !== "identifier" && anchorKind !== "quoted") {
1175
1371
  continue;
1176
1372
  }
1177
- const query = queryForStructuralAnchor(term, anchorKind, inputs.query);
1373
+ const sourceTerm = inputs.anchors.find((anchor) => anchor.term === term)?.sourceTerm ?? term;
1374
+ const query = queryForStructuralAnchor(sourceTerm, anchorKind, inputs.query);
1178
1375
  const key = `${query.kind}:${query.text}`;
1179
1376
  if (seen.has(key)) {
1180
1377
  continue;
@@ -1402,9 +1599,31 @@ function certifiedLexicalContent(result, inputs) {
1402
1599
  queryFingerprint: atom.provenance.queryFingerprint,
1403
1600
  }));
1404
1601
  }
1602
+ function endpointLexicalContent(result, inputs) {
1603
+ if (!queryTargetsRouteImplementation(inputs.query.text))
1604
+ return [];
1605
+ const ranked = new Set((result.diagnostics?.rankedCandidates ?? [])
1606
+ .filter((candidate) => candidate.bucket === "source")
1607
+ .map((candidate) => candidate.scopePath));
1608
+ const identities = [];
1609
+ for (const atom of result.atoms) {
1610
+ if (atom.provenance.kind !== "lexical-search" ||
1611
+ atom.provenance.tool !== "repo.searchText" ||
1612
+ atom.lineRange === undefined ||
1613
+ !ranked.delete(atom.scopePath))
1614
+ continue;
1615
+ identities.push({
1616
+ stableId: atom.stableId,
1617
+ queryFingerprint: atom.provenance.queryFingerprint,
1618
+ });
1619
+ if (ranked.size === 0)
1620
+ break;
1621
+ }
1622
+ return identities;
1623
+ }
1405
1624
  function primaryRankingAnchors(input, plan) {
1406
1625
  const anchors = [
1407
- ...new Map([...plan.anchors, ...(plan.targetDecision?.targets ?? [])].map((anchor) => [
1626
+ ...new Map([...planSearchAnchors(plan), ...(plan.targetDecision?.targets ?? [])].map((anchor) => [
1408
1627
  `${anchor.kind}:${anchor.term}`,
1409
1628
  anchor,
1410
1629
  ])).values(),
@@ -1414,23 +1633,43 @@ function primaryRankingAnchors(input, plan) {
1414
1633
  ? anchors
1415
1634
  : anchors.filter((anchor) => targets.has(anchor.term) || anchor.kind !== "literal" || !/^\d+$/u.test(anchor.term));
1416
1635
  }
1417
- function lexicalSemanticProvider(inputs) {
1636
+ function effectiveRetrievalIntent(plan) {
1637
+ const intent = plan.effectiveRetrievalIntent ?? plan.retrievalIntent;
1638
+ return intent === "conversational-follow-up" ? "targeted-code-search" : intent;
1639
+ }
1640
+ function planSearchAnchors(plan) {
1641
+ return [...plan.anchors, ...searchReferenceAnchors(plan.references ?? [])];
1642
+ }
1643
+ function semanticProviderAllowed(inputs) {
1418
1644
  if (inputs.targetDecision.kind === "contextual")
1419
- return inputs.repoSemanticSearchProvider;
1645
+ return true;
1420
1646
  if (inputs.targetDecision.kind === "literal-search" ||
1421
1647
  inputs.targetDecision.definitionSymbol !== undefined ||
1422
1648
  isDirectEvidenceLookup(inputs.query, inputs.anchors, inputs.targetDecision))
1649
+ return false;
1650
+ return !inputs.targetDecision.targets.some((anchor) => anchor.kind === "quoted");
1651
+ }
1652
+ function lexicalSemanticProvider(inputs) {
1653
+ if (!semanticProviderAllowed(inputs))
1423
1654
  return undefined;
1424
- return inputs.targetDecision.targets.some((anchor) => anchor.kind === "quoted")
1425
- ? undefined
1426
- : inputs.repoSemanticSearchProvider;
1655
+ return inputs.resolveRepoSemanticSearchProvider === undefined
1656
+ ? inputs.repoSemanticSearchProvider
1657
+ : inputs.resolveRepoSemanticSearchProvider();
1427
1658
  }
1428
1659
  function lexicalSearchOptions(inputs) {
1660
+ const rejectedPaths = inputs.rejectedPaths;
1429
1661
  return {
1430
1662
  fs: inputs.fs,
1431
1663
  nowMs: inputs.nowMs,
1432
1664
  deadlineAtMs: inputs.deadlineAtMs,
1433
- searchHints: { retrievalIntent: inputs.retrievalIntent, allowSourceInspection: true },
1665
+ ...(rejectedPaths === undefined || rejectedPaths.length === 0
1666
+ ? {}
1667
+ : { candidatePathGlobs: { include: [], exclude: [], excludeLiteralPaths: rejectedPaths } }),
1668
+ searchHints: {
1669
+ retrievalIntent: inputs.retrievalIntent,
1670
+ allowSourceInspection: true,
1671
+ recentPaths: inputs.recentPaths,
1672
+ },
1434
1673
  ...(inputs.signal === undefined ? {} : { signal: inputs.signal }),
1435
1674
  };
1436
1675
  }
@@ -1440,15 +1679,29 @@ function lexicalQuery(inputs, terms, symbol) {
1440
1679
  return {
1441
1680
  ...inputs.query,
1442
1681
  text: terms.length === 0 || inputs.targetDecision.kind === "contextual"
1443
- ? inputs.query.text
1682
+ ? lexicalQuestionText(inputs)
1444
1683
  : terms.join(" "),
1445
1684
  };
1446
1685
  }
1686
+ function lexicalQuestionText(inputs) {
1687
+ const query = inputs.query;
1688
+ if (query.kind !== "natural-language")
1689
+ return query.text;
1690
+ const channels = extractRetrievalChannels(query.text, 8);
1691
+ if (!channels.stackTraceDetected)
1692
+ return query.text;
1693
+ // A source-only diagnostic paste has no independent prose. Only freshly admitted references
1694
+ // may supply its lexical query; a raw-frame fallback would restore external runtime noise.
1695
+ return channels.questionText.trim().length > 0
1696
+ ? channels.questionText
1697
+ : (inputs.admittedPaths ?? []).join(" ");
1698
+ }
1447
1699
  function observedLexicalSemanticProvider(inputs, observation) {
1448
1700
  const provider = lexicalSemanticProvider(inputs);
1449
1701
  if (provider === undefined) {
1450
- observation.semanticProviderDisposition =
1451
- inputs.repoSemanticSearchProvider === undefined ? "unavailable" : "suppressed";
1702
+ observation.semanticProviderDisposition = semanticProviderUnavailable(inputs)
1703
+ ? "unavailable"
1704
+ : "suppressed";
1452
1705
  return undefined;
1453
1706
  }
1454
1707
  return {
@@ -1494,13 +1747,7 @@ function allowsReadableScopeContext(coverage) {
1494
1747
  coverage.reasons.every((reason) => reason === "io-error" || reason === "match-cap")));
1495
1748
  }
1496
1749
  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
- };
1750
+ const observation = context?.observation() ?? gateRefusedScopeContext(inputs.scopeContextBytesMax);
1504
1751
  inputs.observeScopeContext?.({
1505
1752
  ...observation,
1506
1753
  ...(!readable && context !== undefined && observation.state !== "overflow"
@@ -1508,6 +1755,15 @@ function recordScopeContextObservation(inputs, context, readable) {
1508
1755
  : {}),
1509
1756
  });
1510
1757
  }
1758
+ function gateRefusedScopeContext(capacityBytes) {
1759
+ return {
1760
+ state: "gate-refused",
1761
+ observedFileCount: 0,
1762
+ retainedFileCount: 0,
1763
+ chargedBytes: 0,
1764
+ capacityBytes,
1765
+ };
1766
+ }
1511
1767
  function isKnownFitSourceAnchor(anchor) {
1512
1768
  if (anchor.kind === "path" || anchor.kind === "quoted")
1513
1769
  return true;
@@ -1522,6 +1778,8 @@ function isKnownFitSourceAnchor(anchor) {
1522
1778
  return true;
1523
1779
  }
1524
1780
  function hasKnownFitSourceTarget(inputs) {
1781
+ if (inputs.anchors.some((anchor) => anchor.kind === "path"))
1782
+ return true;
1525
1783
  if (inputs.targetDecision.definitionRequested && inputs.targetDecision.kind !== "contextual")
1526
1784
  return true;
1527
1785
  // Preserve source spelling: plain technical routing hints are not independently selected
@@ -1594,8 +1852,14 @@ function withoutNamedSemanticSubstitution(result, inputs) {
1594
1852
  };
1595
1853
  }
1596
1854
  async function runLexicalRing(ring, inputs) {
1855
+ if (lexicalQuestionText(inputs).trim().length === 0) {
1856
+ inputs.observeSourceDecision(emptySourceDecision("suppressed"));
1857
+ return { atoms: [], omitted: [], uncertainty: [], usage: usageDelta({ elapsedMs: 0 }) };
1858
+ }
1597
1859
  const result = withoutNamedSemanticSubstitution(await lexicalRingSearch(ring, inputs), inputs);
1860
+ const diagnostics = toPackDiagnostics(result);
1598
1861
  const primaryContentIdentities = certifiedLexicalContent(result, inputs);
1862
+ const endpointContentIdentities = endpointLexicalContent(result, inputs);
1599
1863
  const sourceDecision = result.sourceDecision ?? emptySourceDecision("not-evaluated");
1600
1864
  sourceDecision.primaryContentPathCount = certifiedContentPaths(result.atoms, primaryContentIdentities).size;
1601
1865
  inputs.observeSourceDecision(sourceDecision);
@@ -1604,7 +1868,11 @@ async function runLexicalRing(ring, inputs) {
1604
1868
  // It does NOT consume the excerpt budget; excerpt reads are charged later by the assembler.
1605
1869
  return {
1606
1870
  knownFitFileBytes: result.knownFitFileBytes,
1871
+ contextualFallbackCandidates: inputs.query.kind === "natural-language" && inputs.targetDecision.kind === "contextual"
1872
+ ? captureContextualFallbackCandidates(result.atoms, diagnostics)
1873
+ : [],
1607
1874
  atoms: result.atoms,
1875
+ endpointContentIdentities,
1608
1876
  primaryContentIdentities,
1609
1877
  omitted: omittedFromSearchCandidates(result.candidates, inputs.nowMs()),
1610
1878
  uncertainty: [
@@ -1615,7 +1883,7 @@ async function runLexicalRing(ring, inputs) {
1615
1883
  : []),
1616
1884
  ],
1617
1885
  usage: usageDelta({ elapsedMs: result.elapsedMs }),
1618
- diagnostics: toPackDiagnostics(result),
1886
+ diagnostics,
1619
1887
  };
1620
1888
  }
1621
1889
  function missingPrimaryContextMarker(result, inputs) {
@@ -1659,6 +1927,7 @@ async function runAdapterQueries(registry, ring, queries, inputs, requestContext
1659
1927
  nowMs: inputs.nowMs,
1660
1928
  deadlineAtMs: inputs.deadlineAtMs,
1661
1929
  signal,
1930
+ endpointPreferredSourcePaths: inputs.endpointPreferredSourcePaths,
1662
1931
  ...(requestContext === undefined ? {} : { requestContext }),
1663
1932
  }));
1664
1933
  return settleParallelStage(Promise.all(pending), pending, controller);
@@ -1834,7 +2103,6 @@ function elapsedDeadlineStop(governor, inputs) {
1834
2103
  marker: budgetClipped("budget-exhausted on elapsedMs", inputs.nowMs()),
1835
2104
  };
1836
2105
  }
1837
- const DOCUMENT_EVIDENCE_PATH_RE = /\.(?:html?|txt|rst|adoc|xml)$/iu;
1838
2106
  function isCompleteExactLiteralLookup(query, diagnostics, decision) {
1839
2107
  const coverage = diagnostics?.coverage;
1840
2108
  return (decision.kind === "literal-search" &&
@@ -1848,7 +2116,7 @@ function isOrdinaryDocumentLookup(query, hasGitMetadata, diagnostics) {
1848
2116
  return (!hasGitMetadata &&
1849
2117
  !requiresRelationshipOrHistoryRings(query) &&
1850
2118
  candidates.length > 0 &&
1851
- candidates.every((candidate) => DOCUMENT_EVIDENCE_PATH_RE.test(candidate.scopePath)));
2119
+ candidates.every((candidate) => isOrdinaryFolderDocumentPath(candidate.scopePath, false)));
1852
2120
  }
1853
2121
  function isOrdinaryLiteralAbsence(query, hasGitMetadata, anchors, diagnostics) {
1854
2122
  const coverage = diagnostics?.coverage;
@@ -1872,6 +2140,8 @@ function lookupAugmentationSkipReason(query, anchors, hasGitMetadata, diagnostic
1872
2140
  return undefined;
1873
2141
  }
1874
2142
  function optionalRingSkipReason(ring, inputs, evidence) {
2143
+ if (ring.kind === "git-history" && !inputs.hasGitMetadata)
2144
+ return "no-git-metadata";
1875
2145
  if (requiresRelationshipOrHistoryRings(inputs.query) || ring.kind === "lexical")
1876
2146
  return undefined;
1877
2147
  if (evidence.verifiedDefinitionContext === true)
@@ -1882,7 +2152,7 @@ function optionalRingSkipReason(ring, inputs, evidence) {
1882
2152
  isCompleteExactLiteralLookup(inputs.query, evidence.diagnostics, inputs.targetDecision))
1883
2153
  return "complete-exact-lookup";
1884
2154
  if (ring.kind === "git-history")
1885
- return inputs.hasGitMetadata ? undefined : "no-git-metadata";
2155
+ return undefined;
1886
2156
  return lookupAugmentationSkipReason(inputs.query, inputs.anchors, inputs.hasGitMetadata, evidence.diagnostics, inputs.targetDecision);
1887
2157
  }
1888
2158
  function hasVerifiedTargetContext(query, decision, intent, evidence) {
@@ -1913,6 +2183,8 @@ function skipPlannedRing(ring, inputs, evidence, decisions) {
1913
2183
  decisions.skippedRingKinds.push(ring.kind);
1914
2184
  if (!decisions.ringSkipReasons.includes(reason))
1915
2185
  decisions.ringSkipReasons.push(reason);
2186
+ if (reason === "no-git-metadata" && requiresRelationshipOrHistoryRings(inputs.query))
2187
+ evidence.uncertainty.push(toolUnavailable("git-history unavailable: selected scope has no Git metadata", inputs.nowMs()));
1916
2188
  return true;
1917
2189
  }
1918
2190
  async function runReservedRing(ring, inputs, current, decisions) {
@@ -1920,9 +2192,20 @@ async function runReservedRing(ring, inputs, current, decisions) {
1920
2192
  if (reservation.marker !== undefined)
1921
2193
  return { governor: reservation.governor, marker: reservation.marker };
1922
2194
  let governor = reservation.governor;
2195
+ const grant = (delta) => {
2196
+ throwIfCancelled(inputs.signal);
2197
+ if (inputs.nowMs() >= inputs.deadlineAtMs)
2198
+ return false;
2199
+ const next = applyUsage(governor, usageDelta(delta));
2200
+ if (next.status === "budget-exhausted")
2201
+ return false;
2202
+ governor = next;
2203
+ return true;
2204
+ };
1923
2205
  decisions.executedRingKinds.push(ring.kind);
1924
2206
  const result = await runRing(ring, {
1925
2207
  ...inputs,
2208
+ resolveRepoSemanticSearchProvider: semanticProviderResolver(inputs, grant),
1926
2209
  tryReserveAdditionalSearchCall: () => {
1927
2210
  if (governor.usage.searchCalls >= governor.plan.budget.searchCallsMax)
1928
2211
  return false;
@@ -1938,12 +2221,18 @@ function newRingEvidence() {
1938
2221
  omitted: [],
1939
2222
  uncertainty: [],
1940
2223
  diagnostics: undefined,
2224
+ endpointContentIdentities: [],
1941
2225
  primaryContentIdentities: [],
1942
2226
  };
1943
2227
  }
1944
2228
  function appendRingEvidence(evidence, result) {
1945
2229
  evidence.knownFitFileBytes ??= result.knownFitFileBytes;
1946
- evidence.diagnostics ??= result.diagnostics;
2230
+ evidence.endpointContentIdentities =
2231
+ result.endpointContentIdentities ?? evidence.endpointContentIdentities;
2232
+ if (evidence.diagnostics === undefined) {
2233
+ evidence.diagnostics = result.diagnostics;
2234
+ evidence.contextualFallbackCandidates = result.contextualFallbackCandidates;
2235
+ }
1947
2236
  evidence.primaryContentIdentities = lexicalContentIdentities(result, evidence.primaryContentIdentities);
1948
2237
  for (const atom of result.atoms)
1949
2238
  evidence.atoms.push(atom);
@@ -2001,7 +2290,7 @@ async function runAllRings(rings, inputs, initialGovernor) {
2001
2290
  if (!canContinue(governor)) {
2002
2291
  break;
2003
2292
  }
2004
- const execution = await runReservedRing(ring, inputs, governor, decisions);
2293
+ const execution = await runReservedRing(ring, endpointPriorityInputs(ring, diagnosticHistoryInputs(ring, inputs, evidence), evidence), governor, decisions);
2005
2294
  governor = execution.governor;
2006
2295
  if (execution.marker !== undefined) {
2007
2296
  evidence.uncertainty.push(execution.marker);
@@ -2024,6 +2313,32 @@ async function runAllRings(rings, inputs, initialGovernor) {
2024
2313
  recordStoppedRings(rings, decisions);
2025
2314
  return { ...evidence, governor, decisions };
2026
2315
  }
2316
+ function endpointPriorityInputs(ring, inputs, evidence) {
2317
+ if (ring.kind !== "structural" || !queryTargetsRouteImplementation(inputs.query.text))
2318
+ return inputs;
2319
+ const admitted = certifiedContentPaths(evidence.atoms, evidence.endpointContentIdentities);
2320
+ const paths = (evidence.diagnostics?.rankedCandidates ?? [])
2321
+ .filter((candidate) => candidate.bucket === "source" && admitted.has(candidate.scopePath))
2322
+ .map((candidate) => candidate.scopePath);
2323
+ return { ...inputs, endpointPreferredSourcePaths: paths };
2324
+ }
2325
+ function diagnosticHistoryInputs(ring, inputs, evidence) {
2326
+ if (ring.kind !== "git-history" ||
2327
+ inputs.retrievalIntent !== "diagnostic-search" ||
2328
+ requiresRelationshipOrHistoryRings({
2329
+ ...inputs.query,
2330
+ text: extractRetrievalChannels(inputs.query.text, 8).questionText,
2331
+ }))
2332
+ return inputs;
2333
+ const paths = [
2334
+ ...new Set([...(inputs.admittedPaths ?? []), ...evidence.atoms.map((atom) => atom.scopePath)]),
2335
+ ].filter((path) => isAdmittedMetadataPath(path, inputs.searchScope, undefined));
2336
+ if (paths.length === 0)
2337
+ return inputs;
2338
+ // History enriches already admitted/discovered diagnostic candidates. A shared commit is not
2339
+ // evidence that another file is relevant to this failure; explicit history requests stay broad.
2340
+ return { ...inputs, searchScope: { ...inputs.searchScope, relativePaths: paths } };
2341
+ }
2027
2342
  async function discoverRequiredDefinitionsForRing(ring, inputs, evidence, governor) {
2028
2343
  if (ring.kind === "lexical" || !shouldDiscoverDefinitionsBeforeGraphs(inputs, evidence))
2029
2344
  return governor;
@@ -2045,47 +2360,6 @@ const DEFAULT_EXCERPT_WINDOW = { startLine: 1, endLine: 200 };
2045
2360
  const MAX_EXCERPT_WINDOW_BYTES = 8192;
2046
2361
  const SINGLE_LINE_EXCERPT_CONTEXT_LINES = 3;
2047
2362
  const DISCOVERED_DEFINITION_CONTEXT_AFTER = 24;
2048
- const PROJECT_METADATA_QUERY_TERMS = [
2049
- "abhängigkeit",
2050
- "abhängigkeiten",
2051
- "abhaengigkeit",
2052
- "abhaengigkeiten",
2053
- "build",
2054
- "cypress",
2055
- "dependenc",
2056
- "dependencies",
2057
- "devdependencies",
2058
- "framework",
2059
- "java-script",
2060
- "javascript",
2061
- "jest",
2062
- "node",
2063
- "node.js",
2064
- "npm",
2065
- "package",
2066
- "package.json",
2067
- "package-manager",
2068
- "paketmanager",
2069
- "playwright",
2070
- "pnpm",
2071
- "react",
2072
- "script",
2073
- "stack",
2074
- "tech-stack",
2075
- "techstack",
2076
- "test",
2077
- "test-runner",
2078
- "testing",
2079
- "testumgebung",
2080
- "type script",
2081
- "type-script",
2082
- "typescript",
2083
- "version",
2084
- "versionen",
2085
- "vite",
2086
- "vitest",
2087
- "yarn",
2088
- ];
2089
2363
  // Dependency lockfiles surfaced for project-metadata questions (unchanged behaviour). The manifest
2090
2364
  // basenames themselves now come from the shared ecosystem registry (CANONICAL_MANIFEST_BASENAMES),
2091
2365
  // which is a superset of the prior JS/TS-only list and additionally covers Maven/Gradle/Go/Rust/
@@ -2215,16 +2489,12 @@ function selectedFileQueryFingerprint(query) {
2215
2489
  .digest("hex")
2216
2490
  .slice(0, 16);
2217
2491
  }
2218
- function normalizedQueryText(queryText) {
2219
- return queryText.normalize("NFKD").replace(/\p{M}/gu, "").toLowerCase();
2220
- }
2221
2492
  function wantsProjectMetadata(input, intent) {
2222
2493
  if (intent === "project-metadata" || intent === "repository-overview") {
2223
2494
  return true;
2224
2495
  }
2225
- const lowered = input.query.text.toLowerCase();
2226
- const normalized = normalizedQueryText(input.query.text);
2227
- return PROJECT_METADATA_QUERY_TERMS.some((term) => lowered.includes(term) || normalized.includes(term));
2496
+ const question = extractRetrievalChannels(input.query.text, 8).questionText;
2497
+ return classifyRetrievalIntent(question).intent === "project-metadata";
2228
2498
  }
2229
2499
  function wantsRepositoryOverview(intent) {
2230
2500
  return intent === "repository-overview";
@@ -2999,7 +3269,7 @@ async function collectFilenameMatches(inputs, requestContext) {
2999
3269
  const targets = filenameSearchTargets(inputs);
3000
3270
  const results = await requestContext.findFilesBatch(targets.map((target) => target.request), {
3001
3271
  signal: inputs.signal,
3002
- searchHints: { retrievalIntent: inputs.plan.retrievalIntent },
3272
+ searchHints: { retrievalIntent: effectiveRetrievalIntent(inputs.plan) },
3003
3273
  });
3004
3274
  let symbols = { terms: [], matches: [], uncertainty: [] };
3005
3275
  let documents = { atoms: [], uncertainty: [] };
@@ -3242,19 +3512,20 @@ async function discoverDefinitionsBeforeGraphs(args) {
3242
3512
  }, structuralContexts.forLimits(SYMBOL_FILE_SEARCH_LIMITS));
3243
3513
  return finishDefinitionDiscovery(args, evidence, budget.finish(rings.governor));
3244
3514
  }
3245
- function selectedFileAtom(scope, scopePath, queryFingerprint, nowMs) {
3515
+ function selectedFileAtom(scope, scopePath, queryFingerprint, nowMs, line) {
3516
+ const lineRange = line === undefined ? undefined : { startLine: line, endLine: line };
3246
3517
  return {
3247
3518
  schemaVersion: scope.schemaVersion,
3248
3519
  stableId: evidenceAtomStableId({
3249
3520
  scopeId: scope.scopeId,
3250
3521
  scopePath,
3251
- lineRange: undefined,
3522
+ lineRange,
3252
3523
  provenanceKind: "file-listing",
3253
3524
  provenanceTool: "repo.selectedFile",
3254
3525
  queryFingerprint,
3255
3526
  }),
3256
3527
  scopePath,
3257
- lineRange: undefined,
3528
+ lineRange,
3258
3529
  score: 1,
3259
3530
  provenance: {
3260
3531
  kind: "file-listing",
@@ -3558,7 +3829,7 @@ async function collectParallelDeterministicEvidence(inputs, fileSearchContext, t
3558
3829
  : availableStructuralEvidence({ ...inputs, signal }, () => collectFollowSymbolTraceEvidence({
3559
3830
  scope: input.scope,
3560
3831
  query: input.query,
3561
- anchors: plan.anchors,
3832
+ anchors: planSearchAnchors(plan),
3562
3833
  retrievalIntent: plan.retrievalIntent,
3563
3834
  searchScope,
3564
3835
  fs,
@@ -3660,30 +3931,7 @@ function explicitlyTargetsLockfile(scopePath, queryText, anchors) {
3660
3931
  const name = basename(scopePath).toLowerCase();
3661
3932
  return queryTerms(queryText, anchors).some((term) => path.includes(term) || name === term);
3662
3933
  }
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
- }
3686
- function refineCandidateOrdering(kept, omitted, query, anchors, diagnostics, nowMs) {
3934
+ function refineCandidateOrdering(kept, omitted, query, anchors, diagnostics, nowMs, addressedPaths) {
3687
3935
  const queryText = query.text;
3688
3936
  const preferred = [];
3689
3937
  const lockfiles = [];
@@ -3710,11 +3958,10 @@ function refineCandidateOrdering(kept, omitted, query, anchors, diagnostics, now
3710
3958
  const orderedPreferred = useSearchOrder
3711
3959
  ? orderPreferredCandidates(preferred, diagnostics, priorityPaths)
3712
3960
  : preferred;
3961
+ const distinct = orderDistinctEvidenceCandidates(orderedPreferred, anchors, priorityPaths, addressedPaths);
3713
3962
  return {
3714
- kept: [
3715
- ...orderForDistinctEvidencePaths(orderedPreferred, anchors, priorityPaths),
3716
- ...lockfiles,
3717
- ],
3963
+ rankingObservation: distinct.observation,
3964
+ kept: [...distinct.kept, ...lockfiles],
3718
3965
  omitted: nextOmitted,
3719
3966
  priorityPaths,
3720
3967
  };
@@ -3770,6 +4017,24 @@ function groupEvidenceAtomsByPath(atoms) {
3770
4017
  }
3771
4018
  return grouped;
3772
4019
  }
4020
+ function referenceTargetMatchesRange(atom, edge) {
4021
+ const range = atom.lineRange;
4022
+ return (range !== undefined &&
4023
+ edge.target.scopePath === atom.scopePath &&
4024
+ edge.target.lineRange?.startLine === range.startLine &&
4025
+ edge.target.lineRange.endLine === range.endLine &&
4026
+ edge.target.symbol !== undefined &&
4027
+ edge.source.lineRange !== undefined);
4028
+ }
4029
+ function exactReferenceDefinitionRange(atom) {
4030
+ return (atom.provenance.tool === "discovered-symbol-definition" &&
4031
+ atom.edge?.kind === "reference" &&
4032
+ atom.edge.confidence === "resolved" &&
4033
+ referenceTargetMatchesRange(atom, atom.edge));
4034
+ }
4035
+ function discoveredDefinitionContextAfter(atom) {
4036
+ return exactReferenceDefinitionRange(atom) ? 0 : DISCOVERED_DEFINITION_CONTEXT_AFTER;
4037
+ }
3773
4038
  function lineWindowForAtom(atom) {
3774
4039
  const range = atom.lineRange;
3775
4040
  if (range === undefined) {
@@ -3783,7 +4048,7 @@ function lineWindowForAtom(atom) {
3783
4048
  let contextAfter;
3784
4049
  if (isDiscoveredDefinition) {
3785
4050
  contextBefore = 0;
3786
- contextAfter = DISCOVERED_DEFINITION_CONTEXT_AFTER;
4051
+ contextAfter = discoveredDefinitionContextAfter(atom);
3787
4052
  }
3788
4053
  else {
3789
4054
  const surroundingContext = addSingleLineContext ? SINGLE_LINE_EXCERPT_CONTEXT_LINES : 0;
@@ -3815,10 +4080,24 @@ function windowContainsAtom(window, atom) {
3815
4080
  const range = atom.lineRange;
3816
4081
  return (range === undefined || (window.startLine <= range.startLine && window.endLine >= range.endLine));
3817
4082
  }
4083
+ function mergedPriorityWindows(atoms) {
4084
+ const surrounding = mergeLineWindows(atoms.map(lineWindowForAtom));
4085
+ const registrations = atoms.flatMap((atom) => {
4086
+ const range = atom.lineRange;
4087
+ return atom.provenance.kind === "structural" &&
4088
+ atom.provenance.tool === "endpoint-contract-server-route" &&
4089
+ range !== undefined
4090
+ ? [range, lineWindowForAtom(atom)]
4091
+ : [];
4092
+ });
4093
+ if (registrations.length === 0)
4094
+ return surrounding;
4095
+ return [...atomicCoverageWindows(surrounding, registrations, atoms)].sort((a, b) => a.startLine - b.startLine);
4096
+ }
3818
4097
  function mergeWindowsByTracePriority(atomsForPath) {
3819
4098
  let selected = [];
3820
4099
  for (const priority of [2, 1, 0]) {
3821
- const windows = mergeLineWindows(atomsForPath.filter((atom) => tracePriority(atom) === priority).map(lineWindowForAtom));
4100
+ const windows = mergedPriorityWindows(atomsForPath.filter((atom) => tracePriority(atom) === priority));
3822
4101
  selected = selected
3823
4102
  .concat(nonOverlappingExcerptWindows(windows, selected))
3824
4103
  .sort((a, b) => a.startLine - b.startLine);
@@ -3831,12 +4110,30 @@ function nonOverlappingExcerptWindows(windows, selected) {
3831
4110
  for (const window of windows) {
3832
4111
  while ((selected[index]?.endLine ?? Infinity) < window.startLine)
3833
4112
  index += 1;
3834
- if ((selected[index]?.startLine ?? Infinity) > window.endLine)
3835
- retained.push(window);
4113
+ retained.push(...uncoveredExcerptSegments(window, selected, index));
3836
4114
  }
3837
4115
  return retained;
3838
4116
  }
4117
+ function uncoveredExcerptSegments(window, selected, firstOverlap) {
4118
+ const retained = [];
4119
+ let startLine = window.startLine;
4120
+ for (let index = firstOverlap; index < selected.length; index += 1) {
4121
+ const covered = selected[index];
4122
+ if (covered === undefined || covered.startLine > window.endLine)
4123
+ break;
4124
+ if (covered.startLine > startLine)
4125
+ retained.push({ startLine, endLine: covered.startLine - 1 });
4126
+ startLine = Math.max(startLine, covered.endLine + 1);
4127
+ if (startLine > window.endLine)
4128
+ return retained;
4129
+ }
4130
+ if (startLine <= window.endLine)
4131
+ retained.push({ startLine, endLine: window.endLine });
4132
+ return retained;
4133
+ }
3839
4134
  function strongerExcerptWindow(candidate, current) {
4135
+ if (current === undefined)
4136
+ return candidate;
3840
4137
  if (candidate.tracePriority !== current.tracePriority) {
3841
4138
  return candidate.tracePriority > current.tracePriority ? candidate : current;
3842
4139
  }
@@ -3854,9 +4151,19 @@ function windowIndexContainingLine(windows, line) {
3854
4151
  }
3855
4152
  return low - 1;
3856
4153
  }
4154
+ function retainOverlappingWindowStrength(windows, strengths, range, strength) {
4155
+ const first = Math.max(0, windowIndexContainingLine(windows, range.startLine));
4156
+ for (let index = first; index < windows.length; index += 1) {
4157
+ const window = windows[index];
4158
+ if (window === undefined || window.startLine > range.endLine)
4159
+ break;
4160
+ if (window.endLine >= range.startLine)
4161
+ strengths[index] = strongerExcerptWindow(strength, strengths[index]);
4162
+ }
4163
+ }
3857
4164
  function rankedExcerptWindows(windows, atoms) {
3858
4165
  const sorted = [...windows].sort((a, b) => a.startLine - b.startLine);
3859
- const strengths = sorted.map(() => ({ tracePriority: 0, score: 0 }));
4166
+ const strengths = sorted.map(() => undefined);
3860
4167
  let unlocated = { tracePriority: 0, score: 0 };
3861
4168
  for (const atom of atoms) {
3862
4169
  const strength = { tracePriority: tracePriority(atom), score: atom.score };
@@ -3865,120 +4172,1100 @@ function rankedExcerptWindows(windows, atoms) {
3865
4172
  unlocated = strongerExcerptWindow(strength, unlocated);
3866
4173
  continue;
3867
4174
  }
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);
4175
+ retainOverlappingWindowStrength(sorted, strengths, range, strength);
3873
4176
  }
3874
4177
  return sorted
3875
4178
  .map((window, index) => ({
3876
4179
  window,
3877
- strength: strongerExcerptWindow(strengths[index] ?? unlocated, unlocated),
4180
+ strength: strengths[index] ?? unlocated,
3878
4181
  }))
3879
4182
  .sort((a, b) => b.strength.tracePriority - a.strength.tracePriority ||
3880
4183
  b.strength.score - a.strength.score ||
3881
4184
  a.window.startLine - b.window.startLine)
3882
4185
  .map(({ window }) => window);
3883
4186
  }
3884
- function excerptLineWindows(atomsForPath) {
3885
- if (atomsForPath === undefined || atomsForPath.length === 0) {
3886
- return { windows: [DEFAULT_EXCERPT_WINDOW], omittedWindowCount: 0 };
4187
+ function sameCoverageLocation(candidate, certified) {
4188
+ return (candidate.stableId === certified.stableId &&
4189
+ candidate.scopePath === certified.scopePath &&
4190
+ candidate.provenance.queryFingerprint === certified.provenance.queryFingerprint &&
4191
+ candidate.provenance.tool === certified.provenance.tool &&
4192
+ candidate.lineRange?.startLine === certified.lineRange?.startLine &&
4193
+ candidate.lineRange?.endLine === certified.lineRange?.endLine);
4194
+ }
4195
+ function selectedCoverageEntries(inputs) {
4196
+ const coverage = inputs.routeCoverage;
4197
+ if (coverage?.matches(inputs.searchScope, inputs.fs) !== true)
4198
+ return [];
4199
+ const selected = new Map([...inputs.atomsByPath.values()].flatMap((atoms) => atoms.map((atom) => [atom.stableId, atom])));
4200
+ return coverage.entries.filter((entry) => {
4201
+ const atom = selected.get(entry.atom.stableId);
4202
+ if (atom === undefined || !sameCoverageLocation(atom, entry.atom))
4203
+ return false;
4204
+ return coverage.isCurrent(entry.atom);
4205
+ });
4206
+ }
4207
+ function connectedCoverageChain(entry, byIdentity) {
4208
+ const chain = [];
4209
+ const seen = new Set();
4210
+ let current = entry;
4211
+ while (current !== undefined && !seen.has(current.definitionIdentity)) {
4212
+ seen.add(current.definitionIdentity);
4213
+ chain.push(current);
4214
+ if (current.parentIdentity === undefined)
4215
+ return chain.reverse();
4216
+ current = byIdentity.get(current.parentIdentity);
4217
+ }
4218
+ return [];
4219
+ }
4220
+ function fairCoverageEntries(entries, totalBytes, inputs) {
4221
+ const byIdentity = new Map(entries.map((entry) => [entry.definitionIdentity, entry]));
4222
+ const targets = relevantCoverageTargets(entries, byIdentity);
4223
+ const opportunities = coverageQueueOpportunities(entries, byIdentity, totalBytes);
4224
+ const state = { windows: new Map(), bytes: 0, targets: new Set() };
4225
+ for (const entry of targets) {
4226
+ const opportunity = opportunities.get(entry.definitionIdentity);
4227
+ if (opportunity === undefined)
4228
+ continue;
4229
+ const previousBytes = state.bytes;
4230
+ if (admitCoverageTarget(entry, byIdentity, state, totalBytes, inputs, opportunity.remainingBytes)) {
4231
+ opportunity.remainingBytes -= state.bytes - previousBytes;
4232
+ }
3887
4233
  }
3888
- const merged = mergeWindowsByTracePriority(atomsForPath);
3889
- const selected = rankedExcerptWindows(merged, atomsForPath);
3890
- return {
3891
- windows: selected,
3892
- omittedWindowCount: Math.max(0, merged.length - selected.length),
3893
- };
4234
+ const baseline = copyCoverageAdmission(state);
4235
+ admitSharedCoverageEntries(entries, targets, byIdentity, baseline, totalBytes, inputs);
4236
+ const cycles = requestedCoverageCycles(inputs, byIdentity);
4237
+ if (cycles.every((cycle) => retainedCoverageCycle(cycle, baseline)))
4238
+ return [...baseline.windows.values()].flat();
4239
+ admitRequestedCoverageCycles(cycles, byIdentity, state, totalBytes, inputs);
4240
+ if (!improvesCoverageCycles(cycles, baseline, state))
4241
+ return [...baseline.windows.values()].flat();
4242
+ admitSharedCoverageEntries(entries, targets, byIdentity, state, totalBytes, inputs);
4243
+ return [...state.windows.values()].flat();
4244
+ }
4245
+ function requestedCoverageCycles(inputs, byIdentity) {
4246
+ const query = inputs.query;
4247
+ if (query?.kind !== "natural-language" || !hasRecursiveTraversalQuery(query.text))
4248
+ return [];
4249
+ return (inputs.routeCoverage?.ownedCycles ?? []).filter((cycle) => cycle.length > 0 && cycle.every((identity) => byIdentity.has(identity)));
3894
4250
  }
3895
- function exhaustedDimensions(remainingFiles, remainingBytes) {
3896
- return [
3897
- ...(remainingFiles <= 0 ? ["filesRead"] : []),
3898
- ...(remainingBytes <= 0 ? ["excerptBytes"] : []),
3899
- ].join(", ");
4251
+ function retainedCoverageCycle(cycle, state) {
4252
+ return cycle.every((identity) => state.targets.has(identity));
3900
4253
  }
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)
4254
+ function improvesCoverageCycles(cycles, baseline, proposal) {
4255
+ return (cycles.every((cycle) => !retainedCoverageCycle(cycle, baseline) || retainedCoverageCycle(cycle, proposal)) &&
4256
+ cycles.some((cycle) => !retainedCoverageCycle(cycle, baseline) && retainedCoverageCycle(cycle, proposal)));
4257
+ }
4258
+ function admitRequestedCoverageCycles(cycles, byIdentity, state, totalBytes, inputs) {
4259
+ for (const cycle of cycles) {
4260
+ const proposal = copyCoverageAdmission(state);
4261
+ const admitted = cycle.every((identity) => {
4262
+ const entry = byIdentity.get(identity);
4263
+ return (entry !== undefined && admitCoverageTarget(entry, byIdentity, proposal, totalBytes, inputs));
4264
+ });
4265
+ if (admitted)
4266
+ publishCoverageAdmission(state, proposal);
4267
+ }
4268
+ }
4269
+ function admitSharedCoverageEntries(entries, targets, byIdentity, state, totalBytes, inputs) {
4270
+ const ranked = sharedCoverageTargets(entries, byIdentity);
4271
+ const byPath = new Map(coverageTargetsByPath(connectedCoverageOrder(entries)).flatMap((queue) => {
4272
+ const path = queue[0]?.atom.scopePath;
4273
+ return path === undefined ? [] : [[path, queue]];
4274
+ }));
4275
+ const ownedChildren = ownedCoverageChildren(entries, byIdentity);
4276
+ const admission = {
4277
+ byIdentity,
4278
+ byPath,
4279
+ rankedTargets: ranked,
4280
+ fairTargets: targets,
4281
+ ownedChildren,
4282
+ state,
4283
+ totalBytes,
4284
+ inputs,
4285
+ };
4286
+ for (const entry of ranked)
4287
+ admitSharedCoveragePrefix(entry, targets, admission);
4288
+ for (const entry of targets) {
4289
+ if (!state.targets.has(entry.definitionIdentity))
4290
+ admitSharedCoveragePrefix(undefined, [entry], admission);
4291
+ }
4292
+ }
4293
+ function copyCoverageAdmission(state) {
4294
+ return { windows: new Map(state.windows), bytes: state.bytes, targets: new Set(state.targets) };
4295
+ }
4296
+ function ownedCoverageChildren(entries, byIdentity) {
4297
+ const children = new Map();
4298
+ for (const entry of connectedCoverageOrder(entries)) {
4299
+ const witness = entry.parentWitness;
4300
+ if (witness?.ownedSourceCall !== true ||
4301
+ witness.parentIdentity !== entry.parentIdentity ||
4302
+ witness.targetIdentity !== entry.definitionIdentity ||
4303
+ !byIdentity.has(witness.parentIdentity))
3909
4304
  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))
4305
+ const targets = children.get(witness.parentIdentity) ?? [];
4306
+ targets.push(entry);
4307
+ children.set(witness.parentIdentity, targets);
4308
+ }
4309
+ return children;
4310
+ }
4311
+ function coverageAdmissionWithOwnedContinuation(state, entry, admission, minimumScore, ranked) {
4312
+ let selected = state;
4313
+ let parent = entry;
4314
+ let ownedProgress = false;
4315
+ const seen = new Set([entry.definitionIdentity]);
4316
+ let threshold = ownedCoverageInitialThreshold(entry, admission, minimumScore, state);
4317
+ let requireBranch = true;
4318
+ for (;;) {
4319
+ const next = nextOwnedCoverageContinuation(selected, parent, seen, admission, threshold, requireBranch);
4320
+ if (next === undefined)
4321
+ return { state: selected, ownedProgress };
4322
+ if (next.entry.atom.score < minimumScore) {
4323
+ const competing = coverageAdmissionWithCompetingCoverageTarget(selected, ranked, admission, minimumScore);
4324
+ if (competing !== undefined)
4325
+ return { state: competing, ownedProgress };
4326
+ }
4327
+ selected = next.state;
4328
+ ownedProgress = true;
4329
+ parent = next.entry;
4330
+ threshold = undefined;
4331
+ requireBranch = false;
4332
+ }
4333
+ }
4334
+ function coverageAdmissionWithCompetingCoverageTarget(state, ranked, admission, minimumScore) {
4335
+ if (ranked === undefined)
4336
+ return undefined;
4337
+ for (const entry of admission.rankedTargets) {
4338
+ if (entry.atom.score < minimumScore || state.targets.has(entry.definitionIdentity))
3919
4339
  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);
4340
+ const candidate = coverageAdmissionWithTarget(state, entry, admission);
4341
+ if (candidate === undefined)
4342
+ continue;
4343
+ return coverageAdmissionWithCompetingTargetOpportunity(state, candidate, entry, ranked, admission, minimumScore);
3929
4344
  }
3930
- return { bytes, truncated, anchored };
4345
+ return undefined;
3931
4346
  }
3932
- function excerptWindowKey(window) {
3933
- return JSON.stringify([window.startLine, window.endLine, window.identity ?? null]);
4347
+ function coverageAdmissionWithCompetingTargetOpportunity(state, candidate, entry, ranked, admission, minimumScore) {
4348
+ const canonical = coverageAdmissionWithCompetingCoveragePrefix(candidate, entry, admission);
4349
+ const joint = coverageAdmissionWithPendingFairTarget(canonical, ranked, admission, entry.atom.score, entry) ??
4350
+ coverageAdmissionWithPendingFairTarget(canonical, ranked, admission, minimumScore, entry);
4351
+ if (joint !== undefined)
4352
+ return joint;
4353
+ const head = admission.byPath.get(entry.atom.scopePath)?.[0];
4354
+ if (head !== undefined && admission.state.targets.has(head.definitionIdentity)) {
4355
+ const pending = coverageAdmissionWithPendingFairTarget(state, ranked, admission, minimumScore);
4356
+ if (pending !== undefined)
4357
+ return pending;
4358
+ }
4359
+ return canonical;
3934
4360
  }
3935
- function remainingExcerptWindowBytes(scopePath, availableBytes, inputs) {
3936
- return Math.min(inputs.knownFitFileBytes?.get(scopePath) ?? MAX_EXCERPT_WINDOW_BYTES, availableBytes);
4361
+ function coverageAdmissionWithPendingFairTarget(state, ranked, admission, minimumScore, canonical) {
4362
+ for (const entry of sharedCoverageFairTargets(ranked, admission.fairTargets, admission)) {
4363
+ if (entry.atom.score < minimumScore)
4364
+ continue;
4365
+ if (state.targets.has(entry.definitionIdentity)) {
4366
+ if (entry.atom.scopePath === canonical?.atom.scopePath)
4367
+ continue;
4368
+ const continuation = coverageAdmissionWithLiveFullFairTarget(state, entry, admission);
4369
+ if (continuation !== undefined)
4370
+ return continuation;
4371
+ continue;
4372
+ }
4373
+ const candidate = coverageAdmissionWithFreshPendingFairTarget(state, entry, admission, canonical);
4374
+ if (candidate !== undefined)
4375
+ return candidate;
4376
+ }
4377
+ return undefined;
3937
4378
  }
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)));
4379
+ function coverageAdmissionWithFreshPendingFairTarget(state, entry, admission, canonical) {
4380
+ const head = admission.byPath.get(entry.atom.scopePath)?.[0];
4381
+ if (canonical !== undefined &&
4382
+ (entry.atom.scopePath === canonical.atom.scopePath ||
4383
+ (head !== undefined && state.targets.has(head.definitionIdentity))))
4384
+ return undefined;
4385
+ const candidate = coverageAdmissionWithTarget(state, entry, admission);
4386
+ return candidate === undefined
4387
+ ? undefined
4388
+ : coverageAdmissionWithCompetingCoveragePrefix(candidate, entry, admission);
3945
4389
  }
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);
4390
+ function coverageAdmissionWithLiveFullFairTarget(state, entry, admission) {
4391
+ if (!admission.state.targets.has(entry.definitionIdentity))
4392
+ return undefined;
4393
+ const continuation = coverageAdmissionWithOwnedContinuation(state, entry, admission, coverageFileHeadScore(entry, admission));
4394
+ return continuation.ownedProgress ? continuation.state : undefined;
4395
+ }
4396
+ function coverageAdmissionWithCompetingCoveragePrefix(state, entry, admission) {
4397
+ let selected = state;
4398
+ for (const target of sharedCoveragePrefix(entry, admission)) {
4399
+ if (selected.targets.has(target.definitionIdentity))
4400
+ continue;
4401
+ selected = coverageAdmissionWithTarget(selected, target, admission) ?? selected;
4402
+ }
4403
+ return selected;
4404
+ }
4405
+ function ownedCoverageInitialThreshold(entry, admission, minimumScore, state = admission.state) {
4406
+ return state.targets.has(entry.definitionIdentity) &&
4407
+ canStartOwnedCoverageContinuation(entry, minimumScore, admission)
4408
+ ? undefined
4409
+ : minimumScore;
4410
+ }
4411
+ function nextOwnedCoverageContinuation(state, parent, seen, admission, minimumScore, requireBranch) {
4412
+ const pending = ownedCoverageContinuationChildren(parent, minimumScore, admission).reverse();
4413
+ while (pending.length > 0) {
4414
+ const next = pending.pop();
4415
+ if (next === undefined)
4416
+ continue;
4417
+ const { entry, minimumScore: threshold } = next;
4418
+ if (seen.has(entry.definitionIdentity))
4419
+ continue;
4420
+ seen.add(entry.definitionIdentity);
4421
+ if (state.targets.has(entry.definitionIdentity)) {
4422
+ const nextThreshold = canStartOwnedCoverageContinuation(entry, threshold, admission)
4423
+ ? undefined
4424
+ : threshold;
4425
+ pending.push(...ownedCoverageContinuationChildren(entry, nextThreshold, admission).reverse());
4426
+ continue;
4427
+ }
4428
+ if (!canStartOwnedCoverageContinuation(entry, threshold, admission, requireBranch))
4429
+ continue;
4430
+ const candidate = coverageAdmissionWithTarget(state, entry, admission);
4431
+ if (candidate !== undefined)
4432
+ return { state: candidate, entry };
4433
+ }
4434
+ return undefined;
4435
+ }
4436
+ function ownedCoverageContinuationChildren(parent, minimumScore, admission) {
4437
+ return (admission.ownedChildren.get(parent.definitionIdentity) ?? []).map((entry) => ({
4438
+ entry,
4439
+ minimumScore,
4440
+ }));
4441
+ }
4442
+ function canStartOwnedCoverageContinuation(entry, minimumScore, admission, requireBranch = true) {
4443
+ return ((minimumScore === undefined || entry.atom.score >= minimumScore) &&
4444
+ (!requireBranch || (admission.ownedChildren.get(entry.definitionIdentity)?.length ?? 0) > 0));
4445
+ }
4446
+ function coverageAdmissionWithTarget(state, entry, admission) {
4447
+ const candidate = copyCoverageAdmission(state);
4448
+ if (entry !== undefined &&
4449
+ !admitCoverageTarget(entry, admission.byIdentity, candidate, admission.totalBytes, admission.inputs))
4450
+ return undefined;
4451
+ return candidate;
4452
+ }
4453
+ function sharedCoveragePrefix(ranked, admission) {
4454
+ if (ranked === undefined)
4455
+ return [];
4456
+ return (admission.byPath.get(ranked.atom.scopePath) ?? []).filter((entry) => entry.atom.score >= ranked.atom.score);
4457
+ }
4458
+ function coverageAdmissionWithFairTarget(state, targets, admission, ranked, pendingFileEligible = true) {
4459
+ for (const entry of targets) {
4460
+ if (state.targets.has(entry.definitionIdentity)) {
4461
+ const continuation = coverageAdmissionWithOwnedContinuation(state, entry, admission, coverageFileHeadScore(entry, admission));
4462
+ if (continuation.state.targets.size > state.targets.size)
4463
+ return {
4464
+ state: continuation.state,
4465
+ pendingFileRetained: false,
4466
+ pendingFileEligible: pendingFileEligible && !continuation.ownedProgress,
4467
+ sourceTurnRetained: continuation.ownedProgress,
4468
+ };
4469
+ continue;
4470
+ }
4471
+ const candidate = coverageAdmissionWithCompetingFairTarget(state, ranked, entry, targets, admission, pendingFileEligible);
4472
+ if (candidate !== undefined)
4473
+ return candidate;
4474
+ }
4475
+ return undefined;
4476
+ }
4477
+ function coverageAdmissionWithOwnedOpportunity(state, fair, targets, admission, ranked) {
4478
+ const threshold = coverageFileHeadScore(fair, admission);
4479
+ const own = coverageAdmissionWithOwnedContinuation(state, fair, admission, threshold, ranked);
4480
+ if (own.state.targets.size > state.targets.size)
4481
+ return own;
4482
+ const parents = ranked === undefined
4483
+ ? targets
4484
+ : [
4485
+ ...targets,
4486
+ ...(admission.byPath.get(ranked.atom.scopePath) ?? []).filter((entry) => admission.state.targets.has(entry.definitionIdentity)),
4487
+ ];
4488
+ for (const parent of parents) {
4489
+ if (!state.targets.has(parent.definitionIdentity) ||
4490
+ coverageFileHeadScore(parent, admission) < threshold)
4491
+ continue;
4492
+ const candidate = coverageAdmissionWithOwnedContinuation(state, parent, admission, threshold, ranked);
4493
+ if (candidate.state.targets.size > state.targets.size)
4494
+ return candidate;
4495
+ }
4496
+ return { state, ownedProgress: false };
4497
+ }
4498
+ function coverageAdmissionWithCompetingFairTarget(state, ranked, fair, fairTargets, admission, pendingFileEligible) {
4499
+ if (ranked === undefined)
4500
+ return coverageFairAdmission(coverageAdmissionWithGuardedFairTarget(state, ranked, fair, fairTargets, admission));
4501
+ const targets = admission.byPath.get(ranked.atom.scopePath) ?? [];
4502
+ const head = targets[0];
4503
+ if (head === undefined || !admission.state.targets.has(head.definitionIdentity))
4504
+ return coverageFairAdmission(coverageAdmissionWithGuardedFairTarget(state, ranked, fair, fairTargets, admission));
4505
+ return coverageAdmissionWithTwoPendingFairTargets(state, ranked, fair, fairTargets, admission, pendingFileEligible);
4506
+ }
4507
+ function coverageAdmissionWithGuardedFairTarget(state, ranked, fair, targets, admission) {
4508
+ const joint = coverageAdmissionWithTarget(state, fair, admission);
4509
+ return joint === undefined
4510
+ ? undefined
4511
+ : coverageAdmissionWithOwnedOpportunity(joint, fair, targets, admission, ranked).state;
4512
+ }
4513
+ function coverageAdmissionWithPaidFairCheckpoint(joint, ranked, fair, targets, admission, pendingFileEligible) {
4514
+ if (!pendingFileEligible)
4515
+ return { state: joint, pendingFileRetained: false, pendingFileEligible: false };
4516
+ const threshold = coverageFileHeadScore(fair, admission);
4517
+ const owned = coverageAdmissionWithOwnedOpportunity(joint, fair, targets, admission, ranked);
4518
+ const tied = coverageAdmissionWithTiedFairPrefix(owned.state, ranked, admission, threshold);
4519
+ if (owned.ownedProgress || tied !== owned.state)
4520
+ return {
4521
+ state: owned.state,
4522
+ pendingFileRetained: false,
4523
+ pendingFileEligible: false,
4524
+ firstFairJoint: joint,
4525
+ };
4526
+ const second = coverageAdmissionWithPendingFairTarget(tied, ranked, admission, threshold, fair);
4527
+ return {
4528
+ state: second ?? tied,
4529
+ pendingFileRetained: second !== undefined,
4530
+ pendingFileEligible: true,
4531
+ };
4532
+ }
4533
+ function coverageAdmissionWithTiedFairPrefix(state, ranked, admission, minimumScore) {
4534
+ let selected = state;
4535
+ const family = ownedCoverageFamily(ranked, admission);
4536
+ for (const entry of admission.byPath.get(ranked.atom.scopePath) ?? []) {
4537
+ if (entry.atom.score !== minimumScore ||
4538
+ !family.has(entry.definitionIdentity) ||
4539
+ selected.targets.has(entry.definitionIdentity))
4540
+ continue;
4541
+ selected = coverageAdmissionWithTarget(selected, entry, admission) ?? selected;
4542
+ }
4543
+ return selected;
4544
+ }
4545
+ function ownedCoverageFamily(ranked, admission) {
4546
+ const children = admission.ownedChildren.get(ranked.definitionIdentity) ?? [];
4547
+ const siblings = ranked.parentIdentity === undefined
4548
+ ? []
4549
+ : (admission.ownedChildren.get(ranked.parentIdentity) ?? []);
4550
+ const family = siblings.some((entry) => entry.definitionIdentity === ranked.definitionIdentity)
4551
+ ? [...children, ...siblings]
4552
+ : children;
4553
+ return new Set(family.map((entry) => entry.definitionIdentity));
4554
+ }
4555
+ function coverageAdmissionWithTwoPendingFairTargets(state, ranked, fair, fairTargets, admission, pendingFileEligible) {
4556
+ const threshold = coverageFileHeadScore(fair, admission);
4557
+ let proposal = copyCoverageAdmission(state);
4558
+ let joint = coverageAdmissionWithTarget(proposal, fair, admission);
4559
+ let checkpoint = initialFairCheckpoint(joint, ranked, fair, fairTargets, admission, pendingFileEligible);
4560
+ proposal = sourceCoverageProposal(checkpoint, proposal);
4561
+ for (const entry of admission.byPath.get(ranked.atom.scopePath) ?? []) {
4562
+ if (entry.atom.score < threshold)
4563
+ break;
4564
+ if (proposal.targets.has(entry.definitionIdentity))
4565
+ continue;
4566
+ if (!admitSharedCoverageTarget(entry, proposal, admission))
4567
+ continue;
4568
+ const source = grownSourceFairCheckpoint(checkpoint, proposal);
4569
+ if (source !== undefined) {
4570
+ checkpoint = source;
4571
+ continue;
4572
+ }
4573
+ const nextJoint = coverageAdmissionWithTarget(proposal, fair, admission);
4574
+ if (nextJoint === undefined)
4575
+ continue;
4576
+ joint = nextJoint;
4577
+ if (checkpoint?.pendingFileEligible === false)
4578
+ continue;
4579
+ const next = coverageAdmissionWithPaidFairCheckpoint(nextJoint, ranked, fair, fairTargets, admission, pendingFileEligible);
4580
+ checkpoint = retainedFairCheckpoint(checkpoint, next);
4581
+ }
4582
+ return completedFairCheckpoint(joint, checkpoint, ranked, fair, fairTargets, admission);
4583
+ }
4584
+ function admitSharedCoverageTarget(entry, proposal, admission) {
4585
+ return admitCoverageTarget(entry, admission.byIdentity, proposal, admission.totalBytes, admission.inputs);
4586
+ }
4587
+ function initialFairCheckpoint(joint, ranked, fair, targets, admission, pendingFileEligible) {
4588
+ return (guardedSourceFairCheckpoint(joint, fair, admission) ??
4589
+ optionalPaidFairCheckpoint(joint, ranked, fair, targets, admission, pendingFileEligible));
4590
+ }
4591
+ function grownSourceFairCheckpoint(checkpoint, proposal) {
4592
+ return checkpoint?.sourceTurnRetained === true
4593
+ ? { ...checkpoint, state: copyCoverageAdmission(proposal) }
4594
+ : undefined;
4595
+ }
4596
+ function sourceCoverageProposal(checkpoint, proposal) {
4597
+ return checkpoint?.sourceTurnRetained === true
4598
+ ? copyCoverageAdmission(checkpoint.state)
4599
+ : proposal;
4600
+ }
4601
+ function guardedSourceFairCheckpoint(joint, fair, admission) {
4602
+ if (joint === undefined ||
4603
+ admission.state.targets.has(fair.definitionIdentity) ||
4604
+ (admission.ownedChildren.get(fair.definitionIdentity)?.length ?? 0) === 0)
4605
+ return undefined;
4606
+ const continuation = coverageAdmissionWithOwnedContinuation(joint, fair, admission, coverageFileHeadScore(fair, admission));
4607
+ return {
4608
+ state: continuation.state,
4609
+ pendingFileRetained: false,
4610
+ pendingFileEligible: true,
4611
+ sourceTurnRetained: true,
4612
+ };
4613
+ }
4614
+ function optionalPaidFairCheckpoint(joint, ranked, fair, targets, admission, pendingFileEligible) {
4615
+ return joint === undefined
4616
+ ? undefined
4617
+ : coverageAdmissionWithPaidFairCheckpoint(joint, ranked, fair, targets, admission, pendingFileEligible);
4618
+ }
4619
+ function retainedFairCheckpoint(previous, next) {
4620
+ return !next.pendingFileEligible || next.pendingFileRetained ? next : (previous ?? next);
4621
+ }
4622
+ function completedFairCheckpoint(joint, checkpoint, ranked, fair, targets, admission) {
4623
+ if (checkpoint?.sourceTurnRetained === true)
4624
+ return checkpoint;
4625
+ if (joint === undefined)
4626
+ return undefined;
4627
+ if (checkpoint?.pendingFileEligible === false) {
4628
+ const selected = joint === checkpoint.firstFairJoint
4629
+ ? checkpoint.state
4630
+ : coverageAdmissionWithOwnedOpportunity(joint, fair, targets, admission, ranked).state;
4631
+ return coverageFairAdmission(selected, false, false);
4632
+ }
4633
+ return checkpoint?.pendingFileRetained === true ? checkpoint : coverageFairAdmission(joint);
4634
+ }
4635
+ function coverageFairAdmission(state, pendingFileRetained = false, pendingFileEligible = true) {
4636
+ return state === undefined ? undefined : { state, pendingFileRetained, pendingFileEligible };
4637
+ }
4638
+ function sharedCoverageFairTargets(ranked, fair, admission) {
4639
+ if (ranked === undefined)
4640
+ return fair;
4641
+ const fundedPaths = new Set([...admission.byPath].flatMap(([path, targets]) => {
4642
+ const head = targets[0];
4643
+ return head !== undefined && admission.state.targets.has(head.definitionIdentity)
4644
+ ? [path]
4645
+ : [];
4646
+ }));
4647
+ const minimumScore = fair.reduce((score, entry) => fundedPaths.has(entry.atom.scopePath)
4648
+ ? score
4649
+ : Math.min(score, coverageFileHeadScore(entry, admission)), coverageFileHeadScore(ranked, admission));
4650
+ const pending = fair
4651
+ .filter((entry) => isPendingCoverageFairTarget(entry, ranked, fundedPaths, admission, minimumScore))
4652
+ .sort((left, right) => coverageFileHeadScore(right, admission) - coverageFileHeadScore(left, admission) ||
4653
+ Number(fundedPaths.has(left.atom.scopePath)) -
4654
+ Number(fundedPaths.has(right.atom.scopePath)) ||
4655
+ pendingCoverageSourcePriority(right, fundedPaths, admission) -
4656
+ pendingCoverageSourcePriority(left, fundedPaths, admission));
4657
+ return [
4658
+ ...pending.filter((entry) => coverageFileHeadScore(entry, admission) < ranked.atom.score),
4659
+ ...pending.filter((entry) => coverageFileHeadScore(entry, admission) >= ranked.atom.score),
4660
+ ];
4661
+ }
4662
+ function pendingCoverageSourcePriority(entry, fundedPaths, admission) {
4663
+ return Number(!fundedPaths.has(entry.atom.scopePath) &&
4664
+ canStartOwnedCoverageContinuation(entry, coverageFileHeadScore(entry, admission), admission));
4665
+ }
4666
+ function isPendingCoverageFairTarget(entry, ranked, fundedPaths, admission, minimumScore) {
4667
+ return (entry.atom.scopePath !== ranked.atom.scopePath &&
4668
+ (!fundedPaths.has(entry.atom.scopePath) ||
4669
+ (admission.state.targets.has(entry.definitionIdentity) &&
4670
+ hasPendingOwnedCoverageContinuation(entry, admission, minimumScore))));
4671
+ }
4672
+ function hasPendingOwnedCoverageContinuation(entry, admission, minimumScore) {
4673
+ const threshold = ownedCoverageInitialThreshold(entry, admission, minimumScore);
4674
+ const pending = ownedCoverageContinuationChildren(entry, threshold, admission);
4675
+ const seen = new Set([entry.definitionIdentity]);
4676
+ while (pending.length > 0) {
4677
+ const next = pending.pop();
4678
+ if (next === undefined || seen.has(next.entry.definitionIdentity))
4679
+ continue;
4680
+ const { entry: child, minimumScore: threshold } = next;
4681
+ seen.add(child.definitionIdentity);
4682
+ if (!admission.state.targets.has(child.definitionIdentity)) {
4683
+ if (canStartOwnedCoverageContinuation(child, threshold, admission))
4684
+ return true;
4685
+ continue;
4686
+ }
4687
+ const nextThreshold = canStartOwnedCoverageContinuation(child, threshold, admission)
4688
+ ? undefined
4689
+ : threshold;
4690
+ pending.push(...ownedCoverageContinuationChildren(child, nextThreshold, admission));
4691
+ }
4692
+ return false;
4693
+ }
4694
+ function coverageFileHeadScore(entry, admission) {
4695
+ return admission.byPath.get(entry.atom.scopePath)?.[0]?.atom.score ?? entry.atom.score;
4696
+ }
4697
+ function admitSharedCoveragePrefix(ranked, fair, admission) {
4698
+ const prefix = sharedCoveragePrefix(ranked, admission);
4699
+ let fairTargets;
4700
+ let proposal = copyCoverageAdmission(admission.state);
4701
+ let joint;
4702
+ let pendingJoint;
4703
+ let pendingFileEligible = true;
4704
+ let admitted = false;
4705
+ for (const entry of prefix) {
4706
+ if (proposal.targets.has(entry.definitionIdentity))
4707
+ continue;
4708
+ if (!admitCoverageTarget(entry, admission.byIdentity, proposal, admission.totalBytes, admission.inputs))
4709
+ continue;
4710
+ admitted = true;
4711
+ const source = grownSourceFairCheckpoint(joint, proposal);
4712
+ if (source !== undefined) {
4713
+ joint = source;
4714
+ continue;
4715
+ }
4716
+ fairTargets ??= sharedCoverageFairTargets(ranked, fair, admission);
4717
+ joint =
4718
+ coverageAdmissionWithFairTarget(proposal, fairTargets, admission, ranked, pendingFileEligible) ?? joint;
4719
+ pendingFileEligible = eligiblePendingCoverageTurn(pendingFileEligible, joint);
4720
+ pendingJoint = retainedPendingCoverageState(joint, pendingJoint);
4721
+ proposal = sourceCoverageProposal(joint, proposal);
4722
+ }
4723
+ if (!admitted && ranked !== undefined)
4724
+ return;
4725
+ if (!admitted)
4726
+ joint = coverageAdmissionWithFairTarget(proposal, fair, admission);
4727
+ publishSharedCoverageAdmission(admission.state, proposal, joint, pendingJoint);
4728
+ }
4729
+ function eligiblePendingCoverageTurn(previous, joint) {
4730
+ return previous && joint?.pendingFileEligible !== false;
4731
+ }
4732
+ function retainedPendingCoverageState(joint, previous) {
4733
+ if (joint?.sourceTurnRetained === true || joint?.pendingFileEligible === false)
4734
+ return undefined;
4735
+ return joint?.pendingFileRetained === true ? joint.state : previous;
4736
+ }
4737
+ function publishSharedCoverageAdmission(state, proposal, joint, pendingJoint) {
4738
+ publishCoverageAdmission(state, pendingJoint ?? joint?.state ?? proposal);
4739
+ }
4740
+ function publishCoverageAdmission(state, selected) {
4741
+ state.windows = selected.windows;
4742
+ state.bytes = selected.bytes;
4743
+ for (const identity of selected.targets)
4744
+ state.targets.add(identity);
4745
+ }
4746
+ function admitCoverageTarget(entry, byIdentity, state, totalBytes, inputs, marginalBytes = totalBytes) {
4747
+ if (state.targets.has(entry.definitionIdentity))
4748
+ return true;
4749
+ const chain = connectedCoverageChain(entry, byIdentity);
4750
+ if (chain.length === 0)
4751
+ return false;
4752
+ const candidate = proposedCoverageWindows(chain, state.windows);
4753
+ const windows = [...candidate.values()].flat();
4754
+ const costs = coverageWindowCosts(windows);
4755
+ const bytes = [...costs.values()].reduce((sum, cost) => sum + cost, 0);
4756
+ if (bytes > totalBytes || bytes - state.bytes > marginalBytes)
4757
+ return false;
4758
+ if (windows.some((window) => (coverageWindowCosts([window]).get(window.entry.atom.scopePath) ?? 0) >
4759
+ remainingExcerptWindowBytes(window.entry.atom.scopePath, totalBytes, inputs)))
4760
+ return false;
4761
+ state.windows = candidate;
4762
+ state.bytes = bytes;
4763
+ state.targets.add(entry.definitionIdentity);
4764
+ return true;
4765
+ }
4766
+ function coverageQueueOpportunities(entries, byIdentity, totalBytes) {
4767
+ const roots = coverageRootTargets(entries, byIdentity);
4768
+ const rootGrants = distributeByteBudget(totalBytes, roots.length);
4769
+ const opportunities = new Map();
4770
+ for (const [index, root] of roots.entries()) {
4771
+ const files = coverageTargetsByPath(root);
4772
+ const fileGrants = distributeByteBudget(rootGrants[index] ?? 0, files.length);
4773
+ for (const [fileIndex, targets] of files.entries()) {
4774
+ const opportunity = { remainingBytes: fileGrants[fileIndex] ?? 0 };
4775
+ for (const target of targets)
4776
+ opportunities.set(target.definitionIdentity, opportunity);
4777
+ }
4778
+ }
4779
+ return opportunities;
4780
+ }
4781
+ function proposedCoverageWindows(chain, retained) {
4782
+ const candidate = new Map(retained);
4783
+ for (let index = chain.length - 1; index >= 0; index -= 1) {
4784
+ const entry = chain[index];
4785
+ if (entry === undefined)
4786
+ continue;
4787
+ const previous = candidate.get(entry.definitionIdentity) ?? [];
4788
+ if (previous.some((window) => window.fullBody))
4789
+ continue;
4790
+ const window = coverageBranchWindow(entry, chain[index + 1]);
4791
+ if (window === undefined)
4792
+ continue;
4793
+ candidate.set(entry.definitionIdentity, window.fullBody ? [window] : [...previous, window]);
4794
+ }
4795
+ return candidate;
4796
+ }
4797
+ function certifiedCoverageParentWitness(entry, child) {
4798
+ const witness = child?.parentWitness;
4799
+ const certified = witness?.parentIdentity === entry.definitionIdentity &&
4800
+ witness.targetIdentity === child?.definitionIdentity;
4801
+ return certified ? witness : undefined;
4802
+ }
4803
+ function coverageBranchWindow(entry, child) {
4804
+ const compact = certifiedCoverageParentWitness(entry, child);
4805
+ const lineRange = compact?.lineRange ?? entry.atom.lineRange;
4806
+ if (lineRange === undefined)
4807
+ return undefined;
4808
+ return {
4809
+ entry,
4810
+ lineRange,
4811
+ fullBody: compact === undefined,
4812
+ observedLines: compact ?? entry.observedLines,
4813
+ observedBytes: compact === undefined
4814
+ ? entry.observedBytes
4815
+ : compact.lineBytes.reduce((sum, bytes) => sum + bytes, compact.lineBytes.length - 1),
4816
+ };
4817
+ }
4818
+ function coverageWindowCosts(windows) {
4819
+ const paths = new Map();
4820
+ for (const window of windows) {
4821
+ const costs = paths.get(window.entry.atom.scopePath) ?? new Map();
4822
+ const lines = window.observedLines;
4823
+ if (lines === undefined)
4824
+ costs.set(window.entry.definitionIdentity, window.observedBytes);
4825
+ else
4826
+ for (const [index, bytes] of lines.lineBytes.entries()) {
4827
+ const line = String(lines.startLine + index);
4828
+ costs.set(line, Math.max(costs.get(line) ?? 0, bytes));
4829
+ if (index < lines.lineBytes.length - 1)
4830
+ costs.set(`LF:${line}`, 1);
4831
+ }
4832
+ paths.set(window.entry.atom.scopePath, costs);
4833
+ }
4834
+ return new Map([...paths].map(([path, costs]) => [
4835
+ path,
4836
+ [...costs.values()].reduce((sum, bytes) => sum + bytes, 0),
4837
+ ]));
4838
+ }
4839
+ function coverageRootTargets(entries, byIdentity) {
4840
+ const roots = new Map();
4841
+ for (const entry of connectedCoverageOrder(entries)) {
4842
+ const root = connectedCoverageChain(entry, byIdentity)[0];
4843
+ if (root === undefined)
4844
+ continue;
4845
+ const branch = roots.get(root.definitionIdentity) ?? [];
4846
+ branch.push(entry);
4847
+ roots.set(root.definitionIdentity, branch);
4848
+ }
4849
+ return [...roots.values()];
4850
+ }
4851
+ function relevantCoverageTargets(entries, byIdentity) {
4852
+ return interleavedCoverageTargets(coverageRootTargets(entries, byIdentity).map((root) => interleavedCoverageTargets(coverageTargetsByPath(root))));
4853
+ }
4854
+ function sharedCoverageTargets(entries, byIdentity) {
4855
+ return interleavedCoverageTargets(coverageRootTargets(entries, byIdentity).map((root) => [...root].sort((a, b) => b.atom.score - a.atom.score)));
4856
+ }
4857
+ function coverageTargetsByPath(entries) {
4858
+ const files = new Map();
4859
+ for (const entry of entries) {
4860
+ const queue = files.get(entry.atom.scopePath) ?? [];
4861
+ queue.push(entry);
4862
+ files.set(entry.atom.scopePath, queue);
4863
+ }
4864
+ return [...files.values()].map((queue) => {
4865
+ queue.sort((a, b) => b.atom.score - a.atom.score);
4866
+ return queue;
4867
+ });
4868
+ }
4869
+ function interleavedCoverageTargets(queues) {
4870
+ const targets = [];
4871
+ for (let index = 0; queues.some((queue) => index < queue.length); index += 1)
4872
+ for (const queue of queues) {
4873
+ const entry = queue[index];
4874
+ if (entry !== undefined)
4875
+ targets.push(entry);
4876
+ }
4877
+ return targets;
4878
+ }
4879
+ function connectedCoverageOrder(entries) {
4880
+ const children = new Map();
4881
+ const roots = [];
4882
+ for (const entry of entries) {
4883
+ if (entry.parentIdentity === undefined)
4884
+ roots.push([entry]);
4885
+ else
4886
+ children.set(entry.parentIdentity, [...(children.get(entry.parentIdentity) ?? []), entry]);
4887
+ }
4888
+ const seen = new Set();
4889
+ const ordered = [];
4890
+ while (roots.some((stack) => stack.length > 0)) {
4891
+ for (const stack of roots) {
4892
+ const entry = stack.pop();
4893
+ if (entry === undefined || seen.has(entry.definitionIdentity))
4894
+ continue;
4895
+ seen.add(entry.definitionIdentity);
4896
+ ordered.push(entry);
4897
+ stack.push(...[...(children.get(entry.definitionIdentity) ?? [])].reverse());
4898
+ }
4899
+ }
4900
+ return ordered;
4901
+ }
4902
+ function explicitExcerptPaths(paths, inputs) {
4903
+ return paths.filter((path) => (inputs.atomsByPath.get(path) ?? []).some((atom) => atom.provenance.tool === "repo.selectedFile"));
4904
+ }
4905
+ function interleavedReadPaths(ordinary, connected) {
4906
+ const paths = new Set();
4907
+ for (let index = 0; index < Math.max(ordinary.length, connected.length); index += 1) {
4908
+ const normal = ordinary[index];
4909
+ const traced = connected[index];
4910
+ if (normal !== undefined)
4911
+ paths.add(normal);
4912
+ if (traced !== undefined)
4913
+ paths.add(traced);
4914
+ }
4915
+ return [...paths];
4916
+ }
4917
+ function connectedCoverageReserves(entries, totalBytes) {
4918
+ const reserves = new Map();
4919
+ let remaining = totalBytes;
4920
+ for (const [path, bytes] of coverageWindowCosts(entries)) {
4921
+ const reserve = Math.min(remaining, bytes);
4922
+ if (reserve <= 0)
4923
+ break;
4924
+ reserves.set(path, reserve);
4925
+ remaining -= reserve;
4926
+ }
4927
+ return reserves;
4928
+ }
4929
+ function routeCoverageReadPlan(paths, inputs) {
4930
+ const allowed = new Set(paths);
4931
+ const selected = selectedCoverageEntries(inputs).filter((entry) => allowed.has(entry.atom.scopePath));
4932
+ const share = distributeByteBudget(remainingExcerptCapacity(inputs).bytes, 2)[1] ?? 0;
4933
+ const entries = fairCoverageEntries(selected, share, inputs);
4934
+ const byIdentity = new Map(selected.map((entry) => [entry.definitionIdentity, entry]));
4935
+ const eligiblePaths = new Set(selected
4936
+ .filter((entry) => connectedCoverageChain(entry, byIdentity).length > 0)
4937
+ .map((entry) => entry.atom.scopePath));
4938
+ if (eligiblePaths.size === 0)
4939
+ return undefined;
4940
+ const grouped = new Map();
4941
+ for (const entry of entries) {
4942
+ const path = entry.entry.atom.scopePath;
4943
+ const existing = grouped.get(path) ?? [];
4944
+ grouped.set(path, [...existing, entry]);
4945
+ }
4946
+ const priorities = paths.filter((path) => inputs.priorityPaths?.has(path) === true);
4947
+ return {
4948
+ ...coverageCycleObservation(inputs, byIdentity, entries),
4949
+ paths: [
4950
+ ...new Set([
4951
+ ...explicitExcerptPaths(paths, inputs),
4952
+ ...priorities,
4953
+ ...interleavedReadPaths(paths, [...grouped.keys()]),
4954
+ ]),
4955
+ ],
4956
+ entries: grouped,
4957
+ eligiblePaths,
4958
+ reserves: connectedCoverageReserves(entries, share),
4959
+ };
4960
+ }
4961
+ function coverageCycleObservation(inputs, byIdentity, windows) {
4962
+ const cycles = requestedCoverageCycles(inputs, byIdentity);
4963
+ const whole = new Set(windows.filter((window) => window.fullBody).map((window) => window.entry.definitionIdentity));
4964
+ return {
4965
+ requestedStaticCallCycleCount: cycles.length,
4966
+ plannedStaticCallCycleCount: cycles.filter((cycle) => cycle.every((id) => whole.has(id)))
4967
+ .length,
4968
+ };
4969
+ }
4970
+ function currentCoverageEntries(path, inputs) {
4971
+ const entries = inputs.coveragePlan?.entries.get(path);
4972
+ if (entries?.every((entry) => inputs.routeCoverage?.isCurrent(entry.entry.atom) === true) !== true)
4973
+ return undefined;
4974
+ return entries;
4975
+ }
4976
+ function prioritizedExcerptWindows(ordered, explicit) {
4977
+ let windows = [...explicit];
4978
+ for (const window of ordered) {
4979
+ const covered = [...windows].sort((a, b) => a.startLine - b.startLine);
4980
+ windows = [...windows, ...uncoveredExcerptSegments(window, covered, 0)];
4981
+ }
4982
+ return windows;
4983
+ }
4984
+ function atomicCoverageWindows(ordinary, connected, atoms) {
4985
+ const boundaries = connected.flatMap((range) => [range.startLine, range.endLine + 1]);
4986
+ const segments = ordinary.flatMap((window) => {
4987
+ const starts = [
4988
+ ...new Set([
4989
+ window.startLine,
4990
+ ...boundaries.filter((line) => line > window.startLine && line <= window.endLine),
4991
+ window.endLine + 1,
4992
+ ]),
4993
+ ].sort((a, b) => a - b);
4994
+ return starts.slice(0, -1).map((startLine, index) => ({
4995
+ startLine,
4996
+ endLine: (starts[index + 1] ?? window.endLine + 1) - 1,
4997
+ }));
4998
+ });
4999
+ return rankedExcerptWindows(segments, atoms);
5000
+ }
5001
+ function independentOrdinaryWindows(atoms) {
5002
+ const ordinary = atoms.filter((atom) => atom.provenance.tool !== "discovered-symbol-definition");
5003
+ return ordinary.length === 0 ? [] : excerptLineWindows(ordinary).windows;
5004
+ }
5005
+ function overlappingLineWindows(left, right) {
5006
+ return left.startLine <= right.endLine && right.startLine <= left.endLine;
5007
+ }
5008
+ function scheduledCoverageWindows(selection, atoms, ranges) {
5009
+ const explicit = atoms.filter((atom) => atom.provenance.tool === "repo.selectedFile");
5010
+ const funded = prioritizedExcerptWindows(ranges, explicit.length === 0 ? [] : excerptLineWindows(explicit).windows);
5011
+ const ordinary = prioritizedExcerptWindows(independentOrdinaryWindows(atoms), funded).slice(funded.length);
5012
+ const protectedWindows = [...funded, ...ordinary];
5013
+ const definitions = atoms.filter((atom) => atom.provenance.tool === "discovered-symbol-definition" && atom.lineRange !== undefined);
5014
+ const definitionWindows = prioritizedExcerptWindows(atomicCoverageWindows(selection.windows, ranges, atoms), funded)
5015
+ .slice(funded.length)
5016
+ .filter((window) => definitions.some((atom) => atom.lineRange !== undefined && overlappingLineWindows(window, atom.lineRange)));
5017
+ const deferred = prioritizedExcerptWindows(atomicCoverageWindows(selection.windows, ranges, atoms), protectedWindows).slice(protectedWindows.length);
5018
+ return {
5019
+ ...selection,
5020
+ coverageApplied: true,
5021
+ ordinaryWindows: ordinary,
5022
+ fundedWindows: funded,
5023
+ definitionWindows,
5024
+ deferredDefinitionRangeCount: definitionWindows.length,
5025
+ windows: [...protectedWindows, ...deferred],
5026
+ };
5027
+ }
5028
+ function coverageExcerptLineWindows(path, inputs) {
5029
+ const atoms = inputs.atomsByPath.get(path) ?? [];
5030
+ const selection = excerptLineWindows(atoms);
5031
+ const entries = currentCoverageEntries(path, inputs);
5032
+ if (entries === undefined) {
5033
+ return ordinaryExcerptLineWindows(selection, atoms);
5034
+ }
5035
+ return scheduledCoverageWindows(selection, atoms, entries.map((entry) => entry.lineRange));
5036
+ }
5037
+ function ordinaryExcerptLineWindows(selection, atoms) {
5038
+ const ordinary = atoms.filter((atom) => atom.provenance.tool !== "discovered-symbol-definition");
5039
+ if (ordinary.length === 0)
5040
+ return selection;
5041
+ const anchors = atoms.filter((atom) => atom.provenance.tool === "discovered-symbol-definition" &&
5042
+ atom.lineRange !== undefined &&
5043
+ (atom.edge === undefined ||
5044
+ ordinary.some((candidate) => candidate.lineRange !== undefined &&
5045
+ overlappingLineWindows(lineWindowForAtom(atom), candidate.lineRange))));
5046
+ const explicit = ordinary.filter((atom) => atom.provenance.tool === "repo.selectedFile" && atom.lineRange !== undefined);
5047
+ const prefix = prioritizedExcerptWindows(anchors.length === 0 ? [] : excerptLineWindows(anchors).windows, explicit.length === 0 ? [] : excerptLineWindows(explicit).windows);
5048
+ return {
5049
+ ...selection,
5050
+ windows: prioritizedExcerptWindows([...excerptLineWindows(ordinary).windows, ...selection.windows], prefix),
5051
+ };
5052
+ }
5053
+ function staleCoverageRead(path, inputs, selection, result) {
5054
+ if (selection.coverageApplied !== true || currentCoverageEntries(path, inputs) !== undefined)
5055
+ return undefined;
5056
+ const bytesConsumed = result.windows === undefined
5057
+ ? Buffer.byteLength(result.content)
5058
+ : result.windows.reduce((bytes, window) => bytes + Buffer.byteLength(window.content), 0);
5059
+ return { ...unreadExcerptWindows(selection, false), bytesConsumed, invalidatesPrevious: true };
5060
+ }
5061
+ function excerptLineWindows(atomsForPath) {
5062
+ if (atomsForPath === undefined || atomsForPath.length === 0) {
5063
+ return { windows: [DEFAULT_EXCERPT_WINDOW], omittedWindowCount: 0 };
5064
+ }
5065
+ const merged = mergeWindowsByTracePriority(atomsForPath);
5066
+ const selected = rankedExcerptWindows(merged, atomsForPath);
5067
+ return {
5068
+ windows: selected,
5069
+ omittedWindowCount: Math.max(0, merged.length - selected.length),
5070
+ };
5071
+ }
5072
+ function exhaustedDimensions(remainingFiles, remainingBytes) {
5073
+ return [
5074
+ ...(remainingFiles <= 0 ? ["filesRead"] : []),
5075
+ ...(remainingBytes <= 0 ? ["excerptBytes"] : []),
5076
+ ].join(", ");
5077
+ }
5078
+ function appendReadExcerptWindows(result, windows, preserveWindowIdentity = false) {
5079
+ let bytes = 0;
5080
+ let truncated = 0;
5081
+ let anchored = 0;
5082
+ const seen = new Set(windows.map(excerptWindowKey));
5083
+ for (const read of result.windows ?? [result]) {
5084
+ const range = read.atom.lineRange;
5085
+ if (range === undefined)
5086
+ continue;
5087
+ const identity = read.truncated || preserveWindowIdentity
5088
+ ? connectedContextActivityDigest("keiko.excerpt-window.v1", [
5089
+ String(range.startLine),
5090
+ String(range.endLine),
5091
+ read.content,
5092
+ ])
5093
+ : undefined;
5094
+ const key = excerptWindowKey({ ...range, content: "", identity });
5095
+ if (seen.has(key))
5096
+ continue;
5097
+ seen.add(key);
5098
+ windows.push({
5099
+ ...range,
5100
+ content: read.content,
5101
+ ...(identity === undefined ? {} : { identity }),
5102
+ });
5103
+ bytes += utf8ByteLength(read.content);
5104
+ truncated += Number(read.truncated);
5105
+ anchored += Number(read.anchoredWindowApplied === true);
5106
+ }
5107
+ return { bytes, truncated, anchored };
5108
+ }
5109
+ function excerptWindowKey(window) {
5110
+ return JSON.stringify([window.startLine, window.endLine, window.identity ?? null]);
5111
+ }
5112
+ function remainingExcerptWindowBytes(scopePath, availableBytes, inputs) {
5113
+ return Math.min(inputs.knownFitFileBytes?.get(scopePath) ?? MAX_EXCERPT_WINDOW_BYTES, availableBytes);
5114
+ }
5115
+ function qualifiedWholeFileRanges(scopePath, windows, inputs) {
5116
+ if (inputs.knownFitFileBytes?.has(scopePath) !== true)
5117
+ return false;
5118
+ const wholeFile = (inputs.atomsByPath.get(scopePath) ?? []).find((atom) => atom.provenance.kind === "file-listing" &&
5119
+ atom.provenance.tool === "repo.findFiles" &&
5120
+ atom.lineRange !== undefined);
5121
+ return (wholeFile !== undefined && windows.every((window) => windowContainsAtom(window, wholeFile)));
5122
+ }
5123
+ function hasExplicitExcerptSelection(scopePath, inputs) {
5124
+ return (inputs.atomsByPath.get(scopePath) ?? []).some((atom) => atom.provenance.tool === "repo.selectedFile");
5125
+ }
5126
+ function previousExcerptCoverageInvalidated(scopePath, inputs, selection) {
5127
+ return (inputs.previousExcerptResults?.get(scopePath)?.coverageApplied === true &&
5128
+ selection.coverageApplied !== true);
5129
+ }
5130
+ async function readPathExcerptWindows(scopePath, inputs, remainingBytes) {
5131
+ const selection = coverageExcerptLineWindows(scopePath, inputs);
5132
+ if (previousExcerptCoverageInvalidated(scopePath, inputs, selection))
5133
+ return { ...unreadExcerptWindows(selection, false), invalidatesPrevious: true };
5134
+ throwIfCancelled(inputs.signal);
3951
5135
  if (inputs.nowMs() >= inputs.deadlineAtMs || remainingBytes <= 0)
3952
5136
  return unreadExcerptWindows(selection, inputs.nowMs() >= inputs.deadlineAtMs);
3953
- const result = await readExcerpt(inputs.searchScope, {
5137
+ const completed = completedPathExcerptRead(scopePath, inputs, selection);
5138
+ if (completed !== undefined)
5139
+ return completed;
5140
+ const result = await readExplicitExcerpt(inputs.searchScope, pathExcerptRequest(scopePath, inputs, remainingBytes, selection), {
5141
+ fs: inputs.fs,
5142
+ nowMs: inputs.nowMs,
5143
+ deadlineAtMs: inputs.deadlineAtMs,
5144
+ ...(inputs.signal === undefined ? {} : { signal: inputs.signal }),
5145
+ }, hasExplicitExcerptSelection(scopePath, inputs));
5146
+ throwIfCancelled(inputs.signal);
5147
+ if (inputs.nowMs() >= inputs.deadlineAtMs)
5148
+ return {
5149
+ ...unreadExcerptWindows(selection, true),
5150
+ bytesConsumed: returnedExcerptBytes(result),
5151
+ invalidatesPrevious: true,
5152
+ };
5153
+ const stale = staleCoverageRead(scopePath, inputs, selection, result);
5154
+ if (stale !== undefined)
5155
+ return stale;
5156
+ return readPathExcerptResult(scopePath, inputs, selection, result);
5157
+ }
5158
+ function pathExcerptRequest(scopePath, inputs, remainingBytes, selection) {
5159
+ const previous = inputs.previousExcerptResults?.get(scopePath);
5160
+ return {
3954
5161
  scopePath,
3955
- ...containingRange,
3956
- ranges: selection.windows,
5162
+ query: ordinaryExcerptFacetQuery(scopePath, inputs, selection),
5163
+ ...containingExcerptRange(selection.windows),
5164
+ ranges: selection.fundedWindows ?? [],
5165
+ rangeQueues: selection.coverageApplied === true
5166
+ ? [selection.ordinaryWindows ?? [], selection.definitionWindows ?? []]
5167
+ : [selection.windows],
5168
+ firstRoundOnly: inputs.firstExcerptRound === true,
5169
+ processedRanges: previous?.processedRanges,
5170
+ completedRanges: previous?.completedRanges,
5171
+ expectedSourceFingerprint: previous?.sourceFingerprint,
3957
5172
  maxBytes: remainingExcerptWindowBytes(scopePath, remainingBytes, inputs),
5173
+ preferCompleteDocument: preferCompleteDocumentExcerpt(scopePath, inputs, selection),
3958
5174
  anchors: qualifiedWholeFileRanges(scopePath, selection.windows, inputs)
3959
5175
  ? undefined
3960
5176
  : inputs.anchors,
3961
5177
  maxTotalBytes: remainingBytes,
3962
5178
  maxWindows: Math.max(1, remainingBytes),
3963
- }, {
3964
- fs: inputs.fs,
3965
- nowMs: inputs.nowMs,
3966
- deadlineAtMs: inputs.deadlineAtMs,
3967
- ...(inputs.signal === undefined ? {} : { signal: inputs.signal }),
3968
- });
3969
- throwIfCancelled(inputs.signal);
3970
- if (inputs.nowMs() >= inputs.deadlineAtMs)
3971
- return unreadExcerptWindows(selection, true);
3972
- const appended = appendReadExcerptWindows(result, windows);
5179
+ };
5180
+ }
5181
+ function ordinaryExcerptFacetQuery(scopePath, inputs, selection) {
5182
+ if (inputs.query?.kind !== "natural-language" ||
5183
+ selection.coverageApplied === true ||
5184
+ (inputs.atomsByPath.get(scopePath) ?? []).some((atom) => (atom.provenance.tool === "repo.selectedFile" && atom.lineRange !== undefined) ||
5185
+ (atom.provenance.kind === "structural" &&
5186
+ atom.provenance.tool === "endpoint-contract-server-route") ||
5187
+ (atom.provenance.tool !== "repo.selectedFile" && tracePriority(atom) > 0)))
5188
+ return undefined;
5189
+ return inputs.query;
5190
+ }
5191
+ function preferCompleteDocumentExcerpt(scopePath, inputs, selection) {
5192
+ if (inputs.query?.kind !== "natural-language" ||
5193
+ selection.coverageApplied === true ||
5194
+ hasExplicitExcerptSelection(scopePath, inputs))
5195
+ return false;
5196
+ const bucket = candidateBucketForPath(scopePath);
5197
+ return bucket === "docs" || bucket === "overview-doc";
5198
+ }
5199
+ function readPathExcerptResult(scopePath, inputs, selection, result) {
5200
+ const windows = [];
5201
+ const appended = appendReadExcerptWindows(result, windows, true);
3973
5202
  return {
3974
5203
  windows,
5204
+ queryFacetObservation: result.queryFacetObservation,
5205
+ processedRanges: result.processedRanges,
5206
+ completedRanges: result.completedRanges,
5207
+ sourceFingerprint: result.sourceFingerprint,
5208
+ unavailableRangeCount: result.unavailableRangeCount,
5209
+ coverageApplied: selection.coverageApplied === true,
5210
+ ordinaryWindows: selection.ordinaryWindows,
5211
+ ...excerptQueueObservation(selection, windows),
3975
5212
  bytesConsumed: appended.bytes,
3976
5213
  truncatedWindowCount: appended.truncated,
3977
- anchoredWindowCount: appended.anchored,
5214
+ anchoredWindowCount: Math.max(appended.anchored, explicitLineAnchoredWindowCount(windows, inputs.atomsByPath.get(scopePath))),
3978
5215
  deadlineReached: false,
3979
5216
  omittedWindowCount: selection.omittedWindowCount + (result.omittedRangeCount ?? 0),
3980
5217
  };
3981
5218
  }
5219
+ function completedPathExcerptRead(path, inputs, selection) {
5220
+ const previous = inputs.previousExcerptResults?.get(path);
5221
+ if (previous === undefined)
5222
+ return undefined;
5223
+ const processed = new Set((previous.processedRanges ?? []).map((range) => JSON.stringify(range)));
5224
+ const ranges = selection.coverageApplied === true
5225
+ ? [
5226
+ ...(selection.fundedWindows ?? []),
5227
+ ...(selection.ordinaryWindows ?? []),
5228
+ ...(selection.definitionWindows ?? []),
5229
+ ]
5230
+ : selection.windows;
5231
+ if (!ranges.every((range) => processed.has(JSON.stringify(range))))
5232
+ return undefined;
5233
+ return {
5234
+ ...unreadExcerptWindows(selection, false),
5235
+ omittedWindowCount: selection.omittedWindowCount,
5236
+ completedRanges: previous.completedRanges,
5237
+ sourceFingerprint: previous.sourceFingerprint,
5238
+ coverageApplied: selection.coverageApplied === true,
5239
+ ordinaryWindows: selection.ordinaryWindows,
5240
+ };
5241
+ }
5242
+ function returnedExcerptBytes(result) {
5243
+ return (result.windows ?? [result]).reduce((bytes, view) => bytes + utf8ByteLength(view.content), 0);
5244
+ }
5245
+ async function readExplicitExcerpt(scope, request, deps, hasExplicitSelection) {
5246
+ try {
5247
+ return await readExcerpt(scope, request, deps);
5248
+ }
5249
+ catch (error) {
5250
+ if (!hasExplicitSelection ||
5251
+ !(error instanceof RepoSearchUnsupportedFileError) ||
5252
+ error.reason !== "outside-range")
5253
+ throw error;
5254
+ return readExcerpt(scope, {
5255
+ ...request,
5256
+ ...DEFAULT_EXCERPT_WINDOW,
5257
+ ranges: [DEFAULT_EXCERPT_WINDOW],
5258
+ rangeQueues: request.rangeQueues === undefined ? undefined : [[]],
5259
+ firstRoundOnly: undefined,
5260
+ }, deps);
5261
+ }
5262
+ }
5263
+ function explicitLineAnchoredWindowCount(windows, atoms) {
5264
+ const lines = (atoms ?? [])
5265
+ .filter((atom) => atom.provenance.tool === "repo.selectedFile" && atom.lineRange !== undefined)
5266
+ .flatMap((atom) => (atom.lineRange === undefined ? [] : [atom.lineRange.startLine]));
5267
+ return windows.filter((window) => lines.some((line) => line >= window.startLine && line <= window.endLine)).length;
5268
+ }
3982
5269
  function containingExcerptRange(windows) {
3983
5270
  let startLine = Infinity;
3984
5271
  let endLine = 1;
@@ -3991,6 +5278,7 @@ function containingExcerptRange(windows) {
3991
5278
  function unreadExcerptWindows(selection, deadlineReached) {
3992
5279
  return {
3993
5280
  windows: [],
5281
+ ...excerptQueueObservation(selection, []),
3994
5282
  bytesConsumed: 0,
3995
5283
  truncatedWindowCount: 0,
3996
5284
  anchoredWindowCount: 0,
@@ -3998,6 +5286,15 @@ function unreadExcerptWindows(selection, deadlineReached) {
3998
5286
  deadlineReached,
3999
5287
  };
4000
5288
  }
5289
+ function excerptQueueObservation(selection, windows) {
5290
+ if (selection.ordinaryWindows === undefined)
5291
+ return {};
5292
+ return {
5293
+ ordinaryRangeCount: selection.ordinaryWindows.length,
5294
+ ordinaryServedRangeCount: selection.ordinaryWindows.filter((requested) => windows.some((returned) => returned.content.length > 0 && overlappingLineWindows(requested, returned))).length,
5295
+ deferredDefinitionRangeCount: selection.deferredDefinitionRangeCount ?? 0,
5296
+ };
5297
+ }
4001
5298
  function excerptReadLossSummary(state, nowMs) {
4002
5299
  if (state.omittedWindowCount === 0 &&
4003
5300
  state.truncatedWindowCount === 0 &&
@@ -4044,7 +5341,17 @@ async function readPathExcerptTask(scopePath, inputs, byteBudget) {
4044
5341
  // degrade to a skipped excerpt, never crash the whole grounded answer. Other kept files and
4045
5342
  // the rest of the pipeline continue; the file simply contributes no excerpt content.
4046
5343
  if (error instanceof FileTooLargeError) {
4047
- return { scopePath, skippedReason: "too-large", omissionReason: "size-exceeded" };
5344
+ return {
5345
+ scopePath,
5346
+ skippedReason: "too-large",
5347
+ omissionReason: "size-exceeded",
5348
+ result: inputs.previousExcerptResults?.has(scopePath) === true
5349
+ ? {
5350
+ ...unreadExcerptWindows(coverageExcerptLineWindows(scopePath, inputs), false),
5351
+ invalidatesPrevious: true,
5352
+ }
5353
+ : undefined,
5354
+ };
4048
5355
  }
4049
5356
  if (error instanceof RepoSearchUnsupportedFileError) {
4050
5357
  // Preserve the stop reason (#3347 P1): the excerpt facade reports an elapsed-budget stop as
@@ -4053,6 +5360,12 @@ async function readPathExcerptTask(scopePath, inputs, byteBudget) {
4053
5360
  // the completion status reported an unblocked elapsed budget.
4054
5361
  return {
4055
5362
  scopePath,
5363
+ result: inputs.previousExcerptResults?.has(scopePath) === true
5364
+ ? {
5365
+ ...unreadExcerptWindows(coverageExcerptLineWindows(scopePath, inputs), error.reason === "timeout"),
5366
+ invalidatesPrevious: true,
5367
+ }
5368
+ : undefined,
4056
5369
  skippedReason: error.reason === "timeout" ? "timeout" : "unsupported",
4057
5370
  omissionReason: excerptOmissionReason(error.reason),
4058
5371
  };
@@ -4091,6 +5404,7 @@ function stoppedExcerptReads(inputs, remainingFiles, remainingBytes) {
4091
5404
  return undefined;
4092
5405
  }
4093
5406
  async function readKeptExcerpts(keptPaths, inputs) {
5407
+ throwIfCancelled(inputs.signal);
4094
5408
  const excerpts = new Map();
4095
5409
  const uncertainty = [];
4096
5410
  const { files: remainingFiles, bytes: remainingBytes } = remainingExcerptCapacity(inputs);
@@ -4101,27 +5415,74 @@ async function readKeptExcerpts(keptPaths, inputs) {
4101
5415
  omitted: budgetExcerptOmissions(keptPaths, inputs.nowMs()),
4102
5416
  observation: excerptReadObservation(keptPaths.length, 0, 0, remainingFiles <= 0, remainingBytes <= 0, stopped.elapsedBudgetBlocked),
4103
5417
  };
4104
- const readablePaths = keptPaths.slice(0, remainingFiles);
5418
+ const coveragePlan = routeCoverageReadPlan(keptPaths, inputs);
5419
+ const readablePaths = (coveragePlan?.paths ?? keptPaths).slice(0, remainingFiles);
5420
+ const readInputs = { ...inputs, coveragePlan };
4105
5421
  if (readablePaths.length < keptPaths.length) {
4106
5422
  uncertainty.push(budgetClipped("budget-exhausted on filesRead", inputs.nowMs()));
4107
5423
  }
4108
- const state = {
5424
+ const state = initialExcerptWaveState(excerpts, uncertainty, remainingBytes, readInputs, readablePaths);
5425
+ await readPreparedExcerptWaves(readablePaths, readInputs, state);
5426
+ uncertainty.push(...excerptReadLossSummary(state, inputs.nowMs));
5427
+ if (state.elapsedBudgetBlocked) {
5428
+ uncertainty.push(budgetClipped("budget-exhausted on elapsedMs", inputs.nowMs()));
5429
+ }
5430
+ return withCycleReadObservation(completedExcerptSummary(keptPaths, readablePaths, state, inputs.nowMs), coveragePlan);
5431
+ }
5432
+ function withCycleReadObservation(summary, plan) {
5433
+ if (plan === undefined || summary.observation === undefined)
5434
+ return summary;
5435
+ return {
5436
+ ...summary,
5437
+ observation: {
5438
+ ...summary.observation,
5439
+ requestedStaticCallCycleCount: plan.requestedStaticCallCycleCount,
5440
+ plannedStaticCallCycleCount: plan.plannedStaticCallCycleCount,
5441
+ },
5442
+ };
5443
+ }
5444
+ async function readPreparedExcerptWaves(paths, inputs, state) {
5445
+ if (!requiresBoundedExcerptOpportunities(inputs)) {
5446
+ await readExcerptWaves(paths, inputs, state);
5447
+ return;
5448
+ }
5449
+ reserveInitialExcerptOpportunities(paths, inputs, state);
5450
+ await readExcerptWaves(paths, { ...inputs, firstExcerptRound: true }, state);
5451
+ state.coverageReserves.clear();
5452
+ await readExcerptExpansionWaves(paths, inputs, state);
5453
+ }
5454
+ function requiresBoundedExcerptOpportunities(inputs) {
5455
+ if (inputs.coveragePlan !== undefined)
5456
+ return true;
5457
+ return [...inputs.atomsByPath.values()].some((atoms) => atoms.some((atom) => tracePriority(atom) > 0 && atom.provenance.tool !== "repo.selectedFile"));
5458
+ }
5459
+ async function readExcerptExpansionWaves(paths, inputs, state) {
5460
+ const unavailablePaths = new Set(state.omitted.map((entry) => entry.scopePath));
5461
+ const retryablePaths = paths.filter((path) => !unavailablePaths.has(path));
5462
+ const servedPaths = new Set(retryablePaths.filter((path) => state.excerpts.get(path)?.some((view) => view.content.length > 0)));
5463
+ const expansionInputs = { ...inputs, previousExcerptResults: state.pathResults };
5464
+ for (const alreadyServed of [false, true]) {
5465
+ if (state.elapsedBudgetBlocked || state.remainingBytes <= 0)
5466
+ return;
5467
+ await readExcerptWaves(retryablePaths.filter((path) => servedPaths.has(path) === alreadyServed), expansionInputs, state);
5468
+ }
5469
+ }
5470
+ function initialExcerptWaveState(excerpts, uncertainty, remainingBytes, inputs, readablePaths) {
5471
+ return {
4109
5472
  excerpts,
4110
5473
  uncertainty,
4111
5474
  remainingBytes,
5475
+ bytesConsumed: 0,
5476
+ readPaths: new Set(),
4112
5477
  anchoredWindowCount: 0,
4113
5478
  elapsedBudgetBlocked: false,
4114
5479
  byteBudgetOmittedPaths: undefined,
4115
5480
  omitted: [],
4116
5481
  omittedWindowCount: 0,
4117
5482
  truncatedWindowCount: 0,
5483
+ pathResults: new Map(),
5484
+ coverageReserves: new Map([...(inputs.coveragePlan?.reserves ?? [])].filter(([path]) => readablePaths.includes(path))),
4118
5485
  };
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
5486
  }
4126
5487
  function excerptReadObservation(unreadFileCount, omittedRangeCount, truncatedWindowCount, fileGrantBlocked, byteGrantBlocked, deadlineBlocked) {
4127
5488
  const stopReasons = [];
@@ -4151,10 +5512,16 @@ function completedExcerptSummary(keptPaths, readablePaths, state, nowMs) {
4151
5512
  const stoppedPaths = keptPaths.filter((path) => !accounted.has(path) && (state.elapsedBudgetBlocked || !readable.has(path)));
4152
5513
  return {
4153
5514
  excerpts: state.excerpts,
5515
+ bytesConsumed: state.bytesConsumed,
5516
+ filesRead: state.readPaths.size,
4154
5517
  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),
5518
+ observation: {
5519
+ ...excerptReadObservation(keptPaths.length - state.excerpts.size, state.omittedWindowCount, state.truncatedWindowCount, readablePaths.length < keptPaths.length, (state.byteBudgetOmittedPaths?.length ?? 0) > 0 ||
5520
+ (state.remainingBytes <= 0 &&
5521
+ (state.omittedWindowCount > 0 || state.truncatedWindowCount > 0)), state.elapsedBudgetBlocked),
5522
+ ...excerptQueueObservationSummary(state),
5523
+ ...queryFacetObservationSummary(state.pathResults),
5524
+ },
4158
5525
  omitted: [
4159
5526
  ...state.omitted,
4160
5527
  ...(stoppedPaths.length === 0 ? [] : budgetExcerptOmissions(stoppedPaths, nowMs())),
@@ -4167,22 +5534,126 @@ function completedExcerptSummary(keptPaths, readablePaths, state, nowMs) {
4167
5534
  : { byteBudgetOmittedPaths: state.byteBudgetOmittedPaths }),
4168
5535
  };
4169
5536
  }
5537
+ function excerptQueueObservationSummary(state) {
5538
+ if (state.ordinaryRangeCount === undefined)
5539
+ return {};
5540
+ return {
5541
+ ordinaryRangeCount: state.ordinaryRangeCount,
5542
+ ordinaryServedRangeCount: state.ordinaryServedRangeCount ?? 0,
5543
+ deferredDefinitionRangeCount: state.deferredDefinitionRangeCount ?? 0,
5544
+ };
5545
+ }
5546
+ function queryFacetObservationSummary(paths) {
5547
+ const observations = [...paths.values()].flatMap((result) => result.queryFacetObservation === undefined ? [] : [result.queryFacetObservation]);
5548
+ if (observations.length === 0)
5549
+ return {};
5550
+ return {
5551
+ plannedQueryFacetCount: observations.reduce((sum, observed) => sum + observed.plannedGroups.length, 0),
5552
+ servedQueryFacetCount: observations.reduce((sum, observed) => sum + observed.servedGroups.length, 0),
5553
+ };
5554
+ }
5555
+ function appendExcerptQueueObservation(result, state) {
5556
+ if (result?.ordinaryRangeCount === undefined)
5557
+ return;
5558
+ state.ordinaryRangeCount = (state.ordinaryRangeCount ?? 0) + result.ordinaryRangeCount;
5559
+ state.ordinaryServedRangeCount =
5560
+ (state.ordinaryServedRangeCount ?? 0) + (result.ordinaryServedRangeCount ?? 0);
5561
+ state.deferredDefinitionRangeCount =
5562
+ (state.deferredDefinitionRangeCount ?? 0) + (result.deferredDefinitionRangeCount ?? 0);
5563
+ }
4170
5564
  function appendExcerptWave(results, inputs, state) {
4171
5565
  for (const task of results) {
4172
5566
  throwIfCancelled(inputs.signal);
4173
- const { scopePath, result } = task;
4174
- state.elapsedBudgetBlocked ||= excerptTaskStoppedByDeadline(task);
4175
- if (result === undefined || result.windows.length === 0) {
4176
- if (task.omissionReason !== undefined)
4177
- state.omitted.push({ scopePath, reason: task.omissionReason, omittedAtMs: inputs.nowMs() });
4178
- continue;
4179
- }
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;
5567
+ appendExcerptTask(task, inputs, state);
5568
+ }
5569
+ }
5570
+ function appendExcerptTask(task, inputs, state) {
5571
+ const { scopePath, result } = task;
5572
+ const previous = state.pathResults.get(scopePath);
5573
+ if (previous !== undefined)
5574
+ subtractExcerptResultObservation(previous, state);
5575
+ state.coverageReserves.delete(scopePath);
5576
+ state.elapsedBudgetBlocked ||= excerptTaskStoppedByDeadline(task);
5577
+ consumeExcerptTaskBytes(scopePath, result, state);
5578
+ const merged = mergeExcerptResult(previous, result);
5579
+ retainExcerptResultObservation(scopePath, merged, state);
5580
+ if (result === undefined || result.windows.length === 0) {
5581
+ if (task.omissionReason !== undefined)
5582
+ state.omitted.push({ scopePath, reason: task.omissionReason, omittedAtMs: inputs.nowMs() });
5583
+ return;
4185
5584
  }
5585
+ state.anchoredWindowCount += result.anchoredWindowCount;
5586
+ state.excerpts.set(scopePath, merged?.windows ?? result.windows);
5587
+ }
5588
+ function consumeExcerptTaskBytes(scopePath, result, state) {
5589
+ const bytesConsumed = result?.bytesConsumed ?? 0;
5590
+ state.remainingBytes -= bytesConsumed;
5591
+ state.bytesConsumed += bytesConsumed;
5592
+ if (bytesConsumed > 0)
5593
+ state.readPaths.add(scopePath);
5594
+ if (result?.invalidatesPrevious === true)
5595
+ state.excerpts.delete(scopePath);
5596
+ }
5597
+ function retainExcerptResultObservation(scopePath, merged, state) {
5598
+ if (merged === undefined)
5599
+ return;
5600
+ state.pathResults.set(scopePath, merged);
5601
+ appendExcerptQueueObservation(merged, state);
5602
+ state.omittedWindowCount += observedExcerptOmissionCount(merged);
5603
+ state.truncatedWindowCount += merged.truncatedWindowCount;
5604
+ }
5605
+ function reserveInitialExcerptOpportunities(paths, inputs, state) {
5606
+ const reserved = [...state.coverageReserves.values()].reduce((sum, bytes) => sum + bytes, 0);
5607
+ const portions = excerptWaveGrants(paths, Math.max(0, state.remainingBytes - reserved), inputs);
5608
+ for (const [index, path] of paths.entries())
5609
+ state.coverageReserves.set(path, (state.coverageReserves.get(path) ?? 0) + (portions[index] ?? 0));
5610
+ }
5611
+ function subtractExcerptResultObservation(result, state) {
5612
+ state.omittedWindowCount -= observedExcerptOmissionCount(result);
5613
+ state.truncatedWindowCount -= result.truncatedWindowCount;
5614
+ if (result.ordinaryRangeCount === undefined)
5615
+ return;
5616
+ state.ordinaryRangeCount = (state.ordinaryRangeCount ?? 0) - result.ordinaryRangeCount;
5617
+ state.ordinaryServedRangeCount =
5618
+ (state.ordinaryServedRangeCount ?? 0) - (result.ordinaryServedRangeCount ?? 0);
5619
+ state.deferredDefinitionRangeCount =
5620
+ (state.deferredDefinitionRangeCount ?? 0) - (result.deferredDefinitionRangeCount ?? 0);
5621
+ }
5622
+ function observedExcerptOmissionCount(result) {
5623
+ return result.windows.length > 0
5624
+ ? result.omittedWindowCount
5625
+ : (result.unavailableRangeCount ?? 0);
5626
+ }
5627
+ function servedOrdinaryExcerptRanges(result, windows) {
5628
+ return result.ordinaryWindows?.filter((range) => windows.some((view) => view.content.length > 0 && overlappingLineWindows(range, view))).length;
5629
+ }
5630
+ function mergeExcerptResult(previous, result) {
5631
+ if (previous === undefined || result?.invalidatesPrevious === true)
5632
+ return result;
5633
+ if (result === undefined)
5634
+ return previous;
5635
+ const unique = new Map([...previous.windows, ...result.windows].map((view) => [excerptWindowKey(view), view]));
5636
+ const windows = [...unique.values()];
5637
+ return {
5638
+ ...result,
5639
+ windows,
5640
+ processedRanges: [...(previous.processedRanges ?? []), ...(result.processedRanges ?? [])],
5641
+ completedRanges: result.completedRanges,
5642
+ truncatedWindowCount: previous.truncatedWindowCount + result.truncatedWindowCount,
5643
+ omittedWindowCount: result.omittedWindowCount + (previous.unavailableRangeCount ?? 0),
5644
+ unavailableRangeCount: (previous.unavailableRangeCount ?? 0) + (result.unavailableRangeCount ?? 0),
5645
+ ordinaryServedRangeCount: servedOrdinaryExcerptRanges(result, windows),
5646
+ queryFacetObservation: mergeQueryFacetObservation(previous, result),
5647
+ };
5648
+ }
5649
+ function mergeQueryFacetObservation(previous, result) {
5650
+ const observations = [previous.queryFacetObservation, result.queryFacetObservation].filter((observation) => observation !== undefined);
5651
+ if (observations.length === 0)
5652
+ return undefined;
5653
+ return {
5654
+ plannedGroups: [...new Set(observations.flatMap((observation) => observation.plannedGroups))],
5655
+ servedGroups: [...new Set(observations.flatMap((observation) => observation.servedGroups))],
5656
+ };
4186
5657
  }
4187
5658
  // The next wave depends on the bytes and deadline left after the preceding reads settle.
4188
5659
  // A lazy iterator retains one wave and lets the asynchronous consumer apply backpressure.
@@ -4200,13 +5671,15 @@ function* pendingExcerptWaves(paths, inputs, state) {
4200
5671
  next += wave.length;
4201
5672
  }
4202
5673
  if (next < paths.length && state.remainingBytes <= 0) {
4203
- state.byteBudgetOmittedPaths = paths.slice(next);
5674
+ state.byteBudgetOmittedPaths = paths
5675
+ .slice(next)
5676
+ .filter((path) => !state.excerpts.get(path)?.some((view) => view.content.length > 0));
4204
5677
  state.uncertainty.push(budgetClipped("budget-exhausted on excerptBytes", inputs.nowMs()));
4205
5678
  }
4206
5679
  }
4207
5680
  async function readExcerptWaves(paths, inputs, state) {
4208
5681
  for await (const results of iterateSequentialResults(pendingExcerptWaves(paths, inputs, state), (wave) => {
4209
- const grants = excerptWaveGrants(wave, state.remainingBytes, inputs);
5682
+ const grants = coverageExcerptWaveGrants(wave, state, inputs);
4210
5683
  return mapWithConcurrency(wave, 8, (scopePath, index) => {
4211
5684
  throwIfCancelled(inputs.signal);
4212
5685
  return readPathExcerptTask(scopePath, inputs, grants[index] ?? 0);
@@ -4214,6 +5687,19 @@ async function readExcerptWaves(paths, inputs, state) {
4214
5687
  }))
4215
5688
  appendExcerptWave(results, inputs, state);
4216
5689
  }
5690
+ function coverageExcerptWaveGrants(paths, state, inputs) {
5691
+ const wave = new Set(paths);
5692
+ let reserved = 0;
5693
+ let future = 0;
5694
+ for (const [path, bytes] of state.coverageReserves) {
5695
+ if (wave.has(path))
5696
+ reserved += bytes;
5697
+ else
5698
+ future += bytes;
5699
+ }
5700
+ const extra = excerptWaveGrants(paths, Math.max(0, state.remainingBytes - reserved - future), inputs);
5701
+ return paths.map((path, index) => (state.coverageReserves.get(path) ?? 0) + (extra[index] ?? 0));
5702
+ }
4217
5703
  function excerptWaveGrants(paths, totalBytes, inputs) {
4218
5704
  const known = paths.map((path) => inputs.knownFitFileBytes?.get(path));
4219
5705
  const knownBytes = known.reduce((sum, bytes) => sum + (bytes ?? 0), 0);
@@ -4305,13 +5791,25 @@ async function groundedSchedulingYield(signal) {
4305
5791
  await new Promise((resolve) => setImmediate(resolve));
4306
5792
  throwIfCancelled(signal);
4307
5793
  }
4308
- function createReadyGovernedPlan(input, nowMs, progress) {
4309
- const planned = planAndGovern(input.budget === undefined
4310
- ? { scope: input.scope, query: input.query }
4311
- : { scope: input.scope, query: input.query, budget: input.budget }, { nowMs });
5794
+ function canAnswerUnanchoredAssessment(plan, policy) {
5795
+ return (policy === "allowed" &&
5796
+ (plan.clarification?.reason === "no-anchors" || plan.clarification?.reason === "too-generic"));
5797
+ }
5798
+ function createGovernedRetrievalPlan(input, nowMs, progress, ownAssessmentPolicy) {
5799
+ const planned = planAndGovern({
5800
+ scope: input.scope,
5801
+ query: input.query,
5802
+ ...(input.budget === undefined ? {} : { budget: input.budget }),
5803
+ ...(input.assistantReferents === undefined ? {} : { references: input.assistantReferents }),
5804
+ ...(input.previousRetrievalIntent === undefined
5805
+ ? {}
5806
+ : { previousRetrievalIntent: input.previousRetrievalIntent }),
5807
+ }, { nowMs });
4312
5808
  const { plan } = planned;
4313
5809
  progress.plan = plan;
4314
5810
  if (plan.state !== "ready") {
5811
+ if (canAnswerUnanchoredAssessment(plan, ownAssessmentPolicy))
5812
+ return { plan, governor: undefined };
4315
5813
  if (plan.clarification !== undefined) {
4316
5814
  throw new ClarificationNeededError(plan.clarification);
4317
5815
  }
@@ -4344,49 +5842,14 @@ function deadlineBoundMicroIndex(index, nowMs, deadlineAtMs) {
4344
5842
  size: index.size.bind(index),
4345
5843
  };
4346
5844
  }
4347
- async function raceRerankerToDeadline(operation, nowMs, deadlineAtMs, callerSignal) {
4348
- try {
4349
- return await raceAbortDeadline(operation, {
4350
- deadlineAtMs,
4351
- nowMs,
4352
- ...(callerSignal === undefined ? {} : { signal: callerSignal }),
4353
- });
4354
- }
4355
- catch (error) {
4356
- if (error instanceof AbortDeadlineRaceError) {
4357
- if (error.reason === "aborted") {
4358
- throw new CancelledError("grounded repository request cancelled");
4359
- }
4360
- return undefined;
4361
- }
4362
- throw error;
4363
- }
4364
- }
4365
- function deadlineBoundReranker(reranker, nowMs, deadlineAtMs, callerSignal) {
4366
- return {
4367
- name: reranker.name,
4368
- isAvailable: async () => {
4369
- const availability = await raceRerankerToDeadline((context) => reranker.isAvailable(context), nowMs, deadlineAtMs, callerSignal);
4370
- return availability ?? { available: false, reason: "elapsed-budget-exhausted" };
4371
- },
4372
- rerank: async (candidates, atomsByPath, topK) => {
4373
- const reordered = await raceRerankerToDeadline((context) => reranker.rerank(candidates, atomsByPath, topK, context), nowMs, deadlineAtMs, callerSignal);
4374
- return reordered ?? candidates;
4375
- },
4376
- };
4377
- }
4378
- function assembleOptionsFor(deps, nowMs, includeMicroIndex, includeReranker = true, deadlineAtMs) {
5845
+ function assembleOptionsFor(deps, nowMs, includeMicroIndex, deadlineAtMs) {
4379
5846
  const microIndex = deps.microIndex === undefined || deadlineAtMs === undefined
4380
5847
  ? deps.microIndex
4381
5848
  : deadlineBoundMicroIndex(deps.microIndex, nowMs, deadlineAtMs);
4382
- const reranker = deps.contextPackReranker === undefined || deadlineAtMs === undefined
4383
- ? deps.contextPackReranker
4384
- : deadlineBoundReranker(deps.contextPackReranker, nowMs, deadlineAtMs, deps.signal);
4385
5849
  return {
4386
5850
  nowMs,
4387
5851
  includeSurroundingContext: true,
4388
5852
  ...(includeMicroIndex && microIndex !== undefined ? { microIndex } : {}),
4389
- ...(includeReranker && reranker !== undefined ? { reranker } : {}),
4390
5853
  };
4391
5854
  }
4392
5855
  // Document paths are disjoint from code excerpt paths (documents are excluded from the code-first
@@ -4404,7 +5867,7 @@ function mergeExcerptSources(base, documents) {
4404
5867
  async function assembleEmptyGroundedPack({ input, deps, plan, governor, nowMs, stopReason, }) {
4405
5868
  // An empty pack has nothing to rerank or cache. Keeping both seams out also ensures a request
4406
5869
  // stopped before workspace IO cannot start unrelated external work during empty-pack assembly.
4407
- const assembleOptions = assembleOptionsFor(deps, nowMs, false, false);
5870
+ const assembleOptions = assembleOptionsFor(deps, nowMs, false);
4408
5871
  const assemble = await assembleContextPack({
4409
5872
  scope: input.scope,
4410
5873
  query: input.query,
@@ -4442,7 +5905,7 @@ function selectPackAtoms(atoms, selectedPaths, input, plan) {
4442
5905
  return selectGroundedEvidenceAtoms(atoms, selectedPaths, input.scope.scopeId, targetDecision.definitionRequested);
4443
5906
  }
4444
5907
  function primaryCandidateFilter(rings) {
4445
- const certifiedPaths = primaryContentPaths(rings);
5908
+ const certifiedPaths = new Set([...primaryContentPaths(rings), ...explicitSelectionPaths(rings)]);
4446
5909
  return {
4447
5910
  ...DEFAULT_FILTER_OPTIONS,
4448
5911
  minScoreExemptPaths: certifiedPaths,
@@ -4450,15 +5913,26 @@ function primaryCandidateFilter(rings) {
4450
5913
  maxKept: new Set(rings.atoms.map((atom) => atom.scopePath)).size,
4451
5914
  };
4452
5915
  }
4453
- function codeEvidenceAtoms(atoms, scope) {
5916
+ function explicitSelectionPaths(rings) {
5917
+ return new Set(rings.atoms
5918
+ .filter((atom) => atom.provenance.tool === "repo.selectedFile")
5919
+ .map((atom) => atom.scopePath));
5920
+ }
5921
+ function codeEvidenceAtoms(atoms, scope, admission) {
4454
5922
  // Explicit documents belong to extraction, including its unsupported diagnostics. Keep them
4455
5923
  // 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;
5924
+ const paths = new Set([
5925
+ ...(scope.explicitConnection && scope.kind === "files"
5926
+ ? scope.relativePaths.filter(isConnectedDocumentPath)
5927
+ : []),
5928
+ ...(admission?.selections
5929
+ .map((selection) => selection.path)
5930
+ .filter(isExtractableConnectedDocumentPath) ?? []),
5931
+ ]);
5932
+ return atoms.filter((atom) => !paths.has(atom.scopePath));
4459
5933
  }
4460
5934
  function selectionEvidencePaths(input, plan, rings) {
4461
- const paths = new Set(primaryContentPaths(rings));
5935
+ const paths = new Set([...primaryContentPaths(rings), ...explicitSelectionPaths(rings)]);
4462
5936
  const decision = plan.targetDecision ?? resolveQueryTargetDecision(input.query, plan.anchors);
4463
5937
  if (decision.kind === "contextual") {
4464
5938
  for (const atom of rings.atoms) {
@@ -4470,8 +5944,8 @@ function selectionEvidencePaths(input, plan, rings) {
4470
5944
  // context remains secondary and cannot certify literal presence or declaration discovery.
4471
5945
  return paths;
4472
5946
  }
4473
- function rankingEvidence(rings, scope) {
4474
- const sourceAtoms = codeEvidenceAtoms(rings.atoms, scope);
5947
+ function rankingEvidence(input, rings) {
5948
+ const sourceAtoms = codeEvidenceAtoms(rings.atoms, input.scope, rings.explicitAdmission);
4475
5949
  const atoms = [];
4476
5950
  const seen = new Set();
4477
5951
  for (const atom of sourceAtoms)
@@ -4481,44 +5955,99 @@ function rankingEvidence(rings, scope) {
4481
5955
  reusedEvidenceAtomCount: (rings.reusedEvidenceAtomCount ?? 0) + sourceAtoms.length - atoms.length,
4482
5956
  };
4483
5957
  }
4484
- function preparePackAssembly(input, plan, rings, nowMs, hasGitMetadata) {
4485
- const { atoms, reusedEvidenceAtomCount } = rankingEvidence(rings, input.scope);
4486
- const initialUsage = clampUsageToBudget(rings.governor.usage, plan.budget);
4487
- // M4: pass the classified retrieval intent so ranking can apply intent-conditioned signals
4488
- // (canonical-metadata, structural-edge). Non-boosted intents (e.g. clarification) and the
4489
- // no-context default are byte-identical — see weightsForIntent / isIntentBoosted.
4490
- const ranking = rankCandidates({
5958
+ function rankEligibleEvidencePool(input, plan, rings, atoms, nowMs, hasGitMetadata, recentPaths) {
5959
+ return rankCandidates({
4491
5960
  atoms,
4492
5961
  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
- });
4501
- const refined = refineCandidateOrdering(ranking.kept, ranking.omitted, input.query, plan.anchors, rings.diagnostics, nowMs());
4502
- const ordered = selectGroundedCandidateFiles({
5962
+ ...(plan.references === undefined ? {} : { references: plan.references }),
5963
+ context: { retrievalIntent: effectiveRetrievalIntent(plan) },
5964
+ hints: { recentPaths, ...(hasGitMetadata ? {} : { generatedPathPatterns: [] }) },
5965
+ }, { nowMs, filter: { ...primaryCandidateFilter(rings), minScore: 0 } });
5966
+ }
5967
+ function finalCandidateFilter(args, rings, atoms, reranker) {
5968
+ return {
5969
+ ...primaryCandidateFilter(rings),
5970
+ minScore: args.input.scope.kind === "files"
5971
+ ? 0
5972
+ : absoluteRelevanceFloor(weightsForIntent(effectiveRetrievalIntent(args.plan))),
5973
+ nowMs: args.nowMs,
5974
+ fallbackOrder: reranker.reranked
5975
+ ? []
5976
+ : currentContextualFallbackOrder(rings.contextualFallbackCandidates ?? [], atoms),
5977
+ };
5978
+ }
5979
+ function selectRankedEvidencePool(args, rings, atoms, ranking, reranker) {
5980
+ const { input, plan, nowMs } = args;
5981
+ const options = finalCandidateFilter(args, rings, atoms, reranker);
5982
+ const filtered = filterCandidates(reranker.candidates.map((candidate) => ({ candidate, generatedHint: false, duplicate: false })), options);
5983
+ const refined = refineCandidateOrdering(filtered.kept, [...ranking.omitted, ...filtered.omitted], input.query, planSearchAnchors(plan), rings.diagnostics, nowMs(), explicitSelectionPaths(rings));
5984
+ const selectionInput = {
4503
5985
  ...refined,
5986
+ priorityPaths: mergedSelectionPriorities(refined, rings),
4504
5987
  scopeKind: input.scope.kind,
4505
5988
  protectedContentPaths: selectionEvidencePaths(input, plan, rings),
4506
5989
  pathOnlyPaths: pathOnlyEvidencePaths(atoms),
4507
5990
  filesReadMax: plan.budget.filesReadMax,
4508
5991
  nowMs: nowMs(),
5992
+ };
5993
+ const ordered = selectGroundedCandidateFiles(selectionInput);
5994
+ return {
5995
+ ordered: { ...ordered, rankingObservation: refined.rankingObservation },
5996
+ priorityPaths: selectionInput.priorityPaths,
5997
+ selection: selectionQuality({
5998
+ candidates: reranker.candidates,
5999
+ selected: ordered.kept,
6000
+ absoluteFloor: options.minScore,
6001
+ fallbackOrder: options.fallbackOrder,
6002
+ minScoreExemptPaths: options.minScoreExemptPaths ?? new Set(),
6003
+ scopeKind: input.scope.kind,
6004
+ relative: ordinaryRelativeFloor(selectionInput),
6005
+ reranker,
6006
+ }),
6007
+ };
6008
+ }
6009
+ function rerankPreparedEvidence(args, rings, atoms, ranking) {
6010
+ const { plan, deps, nowMs, deadlineAtMs } = args;
6011
+ return rerankGroundedCandidates({
6012
+ reranker: deps.contextPackReranker,
6013
+ candidates: ranking.kept,
6014
+ atomsByPath: groupEvidenceAtomsByPath(atoms),
6015
+ budget: plan.budget,
6016
+ usage: clampUsageToBudget(rings.governor.usage, plan.budget),
6017
+ nowMs,
6018
+ deadlineAtMs,
6019
+ signal: deps.signal,
6020
+ literal: plan.targetDecision?.kind === "literal-search",
4509
6021
  });
6022
+ }
6023
+ async function preparePackAssembly(args, rings) {
6024
+ const { input, plan, nowMs } = args;
6025
+ const { atoms, reusedEvidenceAtomCount } = rankingEvidence(input, rings);
6026
+ const ranking = rankEligibleEvidencePool(input, plan, rings, atoms, nowMs, args.hasGitMetadata, args.worktreeRecency?.paths.map((path) => path.path) ?? []);
6027
+ const reranker = await rerankPreparedEvidence(args, rings, atoms, ranking);
6028
+ const { ordered, selection, priorityPaths } = selectRankedEvidencePool(args, rings, atoms, ranking, reranker);
4510
6029
  const selectedPaths = new Set(ordered.kept.map((candidate) => candidate.scopePath));
4511
6030
  const selectedAtoms = selectPackAtoms(atoms, selectedPaths, input, plan);
4512
6031
  return {
4513
6032
  atoms: selectedAtoms,
4514
6033
  reusedEvidenceAtomCount,
4515
- initialUsage,
6034
+ initialUsage: clampUsageToBudget(reranker.usage, plan.budget),
4516
6035
  ordered,
6036
+ selection,
6037
+ priorityPaths,
6038
+ rerankerDiagnostics: reranker.diagnostics,
6039
+ rerankFailure: reranker.failure,
4517
6040
  atomsByPath: groupEvidenceAtomsByPath(selectedAtoms),
4518
- evidenceUncertainty: selectedAtoms.length === 0 || ordered.kept.length === 0 ? [noEvidence(nowMs())] : [],
4519
- keptPaths: ordered.kept.map((c) => c.scopePath),
6041
+ evidenceUncertainty: [
6042
+ ...(selectedAtoms.length === 0 || ordered.kept.length === 0 ? [noEvidence(nowMs())] : []),
6043
+ ...(selection.selectionConfidence === "low" ? [lowConfidenceSelectionMarker(nowMs())] : []),
6044
+ ],
6045
+ keptPaths: ordered.kept.map((candidate) => candidate.scopePath),
4520
6046
  };
4521
6047
  }
6048
+ function mergedSelectionPriorities(refined, rings) {
6049
+ return new Set([...(refined.priorityPaths ?? []), ...explicitSelectionPaths(rings)]);
6050
+ }
4522
6051
  function afterExcerptReadOmissions(ordered, reads, nowMs) {
4523
6052
  const entries = [
4524
6053
  ...(reads.omitted ?? []),
@@ -4544,17 +6073,21 @@ async function assemblePackFromReads(inputs) {
4544
6073
  // surface as document evidence or as a precise document diagnostic. The code-first lexical scan
4545
6074
  // also sees them as binary candidates, so strip any document-path omission it produced to avoid a
4546
6075
  // path that is both a selected file and an omitted entry (which the pack validator rejects).
4547
- const codeOmitted = [...rings.omitted, ...ordered.omitted].filter((entry) => !isConnectedDocumentPath(entry.scopePath));
6076
+ const codeOmitted = [...rings.omitted, ...ordered.omitted].filter((entry) => !documentEvidence.candidates.some((candidate) => candidate.scopePath === entry.scopePath) &&
6077
+ !documentEvidence.omitted.some((omitted) => omitted.scopePath === entry.scopePath));
4548
6078
  const assemble = await assembleContextPack({
4549
6079
  scope: input.scope,
4550
6080
  query: input.query,
4551
6081
  budget: plan.budget,
4552
- atoms: [...prepared.atoms, ...documentEvidence.atoms],
6082
+ atoms: [
6083
+ ...atomsForCurrentReadWindows(prepared.atoms, excerptReads, input.scope.scopeId),
6084
+ ...documentEvidence.atoms,
6085
+ ],
4553
6086
  ranked: [...ordered.kept, ...documentEvidence.candidates],
4554
6087
  omittedFromRanking: [...codeOmitted, ...documentEvidence.omitted],
4555
6088
  excerpts,
4556
6089
  initialUsage: prepared.initialUsage,
4557
- diagnostics: rings.diagnostics,
6090
+ diagnostics: { rankedCandidates: [], ...rings.diagnostics, selection: prepared.selection },
4558
6091
  initialUncertainty: [
4559
6092
  ...rings.uncertainty,
4560
6093
  ...excerptReads.uncertainty,
@@ -4563,8 +6096,44 @@ async function assemblePackFromReads(inputs) {
4563
6096
  ...missingExcerptEvidence(prepared, excerpts.size, assembleOptions.nowMs()),
4564
6097
  ],
4565
6098
  }, withoutMicroIndex(knownFitAssembleOptions(assembleOptions, rings)));
4566
- cacheAssembledGroundedPack(inputs, assemble.pack);
4567
- return assemble.pack;
6099
+ const pack = withRetrievalSourceDiagnostics(withExcerptReadUsage(assemble.pack, prepared.initialUsage, excerptReads, documentEvidence), inputs.sourceProgress, assembleOptions.nowMs());
6100
+ cacheAssembledGroundedPack(inputs, pack);
6101
+ return pack;
6102
+ }
6103
+ function withExcerptReadUsage(pack, initialUsage, reads, documentEvidence) {
6104
+ const documents = documentProjectionUsage(documentEvidence.excerpts);
6105
+ return {
6106
+ ...pack,
6107
+ usage: {
6108
+ ...pack.usage,
6109
+ filesRead: Math.max(pack.usage.filesRead, initialUsage.filesRead + (reads.filesRead ?? 0) + documents.filesRead),
6110
+ excerptBytes: Math.max(pack.usage.excerptBytes, initialUsage.excerptBytes + (reads.bytesConsumed ?? 0) + documents.excerptBytes),
6111
+ },
6112
+ };
6113
+ }
6114
+ function atomsForCurrentReadWindows(atoms, reads, scopeId) {
6115
+ return atoms.map((atom) => {
6116
+ const windows = reads.excerpts.get(atom.scopePath);
6117
+ if (atom.provenance.tool !== "repo.selectedFile" ||
6118
+ atom.lineRange === undefined ||
6119
+ !windows?.length ||
6120
+ windows.some((window) => windowContainsAtom(window, atom)))
6121
+ return atom;
6122
+ // The selected path was freshly read, but its old location no longer exists. Preserve only
6123
+ // its unlocated navigation hint; the assembler authenticates the actual returned windows.
6124
+ return {
6125
+ ...atom,
6126
+ lineRange: undefined,
6127
+ stableId: evidenceAtomStableId({
6128
+ scopeId,
6129
+ scopePath: atom.scopePath,
6130
+ lineRange: undefined,
6131
+ provenanceKind: atom.provenance.kind,
6132
+ provenanceTool: atom.provenance.tool,
6133
+ queryFingerprint: atom.provenance.queryFingerprint,
6134
+ }),
6135
+ };
6136
+ });
4568
6137
  }
4569
6138
  function missingExcerptEvidence(prepared, count, nowMs) {
4570
6139
  return count === 0 &&
@@ -4596,10 +6165,21 @@ function finishAugmentationBudget(rings, budget) {
4596
6165
  ]),
4597
6166
  };
4598
6167
  }
6168
+ function discoveredTraceGraphContext(args) {
6169
+ let graphSearchLimits = GROUNDED_TRACE_SEARCH_LIMITS;
6170
+ if (contextualDiscoveredSymbolTraceRequested(args.input.query, planSearchAnchors(args.plan))) {
6171
+ graphSearchLimits =
6172
+ args.plan.rings.find((ring) => ring.kind === "structural")?.searchLimits ?? graphSearchLimits;
6173
+ }
6174
+ return {
6175
+ requestContext: args.structuralContexts.forLimits(graphSearchLimits),
6176
+ graphSearchLimits,
6177
+ };
6178
+ }
4599
6179
  async function discoveredTraceForAugmentation(args, rings, budget) {
4600
- if (!budget.canContinue())
6180
+ if (!budget.canContinue() || rings.verifiedDefinitionContext === true)
4601
6181
  return { atoms: [], uncertainty: [] };
4602
- const { input, deps, plan, searchScope, fs, nowMs, structuralContexts, workspaceIndex, deadlineAtMs, } = args;
6182
+ const { input, deps, plan, searchScope, fs, nowMs, workspaceIndex, deadlineAtMs } = args;
4603
6183
  return availableStructuralEvidence({
4604
6184
  ...deterministicEvidenceObservers(args),
4605
6185
  searchScope,
@@ -4610,7 +6190,7 @@ async function discoveredTraceForAugmentation(args, rings, budget) {
4610
6190
  }, () => collectDiscoveredSymbolTraceEvidence({
4611
6191
  scope: input.scope,
4612
6192
  query: input.query,
4613
- anchors: plan.anchors,
6193
+ anchors: planSearchAnchors(plan),
4614
6194
  retrievalIntent: plan.retrievalIntent,
4615
6195
  searchScope,
4616
6196
  fs,
@@ -4618,7 +6198,7 @@ async function discoveredTraceForAugmentation(args, rings, budget) {
4618
6198
  atoms: rings.atoms,
4619
6199
  signal: deps.signal,
4620
6200
  workspaceIndex,
4621
- requestContext: structuralContexts.forLimits(GROUNDED_TRACE_SEARCH_LIMITS),
6201
+ ...discoveredTraceGraphContext(args),
4622
6202
  deadlineAtMs,
4623
6203
  tryReserveSearchCall: budget.tryReserveSearchCall,
4624
6204
  }));
@@ -4635,12 +6215,16 @@ function markAugmentationUsed(rings) {
4635
6215
  rings.decisions.augmentationDisposition = "used";
4636
6216
  }
4637
6217
  function recordAugmentationSkip(args, rings) {
6218
+ if (rings.decisions?.ringSkipReasons.includes("explicit-target-unavailable")) {
6219
+ markAugmentationSkipped(rings, "explicit-target-unavailable");
6220
+ return true;
6221
+ }
4638
6222
  const decision = args.plan.targetDecision ?? resolveQueryTargetDecision(args.input.query, args.plan.anchors);
4639
6223
  if (hasVerifiedTargetContext(args.input.query, decision, args.plan.retrievalIntent, rings)) {
4640
6224
  markAugmentationSkipped(rings, "verified-target-context");
4641
6225
  return true;
4642
6226
  }
4643
- const reason = lookupAugmentationSkipReason(args.input.query, args.plan.anchors, args.hasGitMetadata, rings.diagnostics, decision);
6227
+ const reason = lookupAugmentationSkipReason(args.input.query, planSearchAnchors(args.plan), args.hasGitMetadata, rings.diagnostics, decision);
4644
6228
  if (reason === undefined)
4645
6229
  return false;
4646
6230
  markAugmentationSkipped(rings, reason);
@@ -4684,6 +6268,8 @@ async function augmentRingsWithDeterministicAtoms(args) {
4684
6268
  return finishAugmentationBudget({
4685
6269
  ...deterministicRings,
4686
6270
  atoms: [...deterministicRings.atoms, ...discoveredTrace.atoms],
6271
+ routeCoverage: discoveredTrace.routeCoverage,
6272
+ contextualDefinitionSeedCount: discoveredTrace.contextualDefinitionSeedCount,
4687
6273
  uncertainty: [...deterministicRings.uncertainty, ...discoveredTrace.uncertainty],
4688
6274
  }, budget);
4689
6275
  }
@@ -4696,13 +6282,15 @@ async function prepareGroundedAssembly(args, augmentedRings, prepared) {
4696
6282
  // Bounded small-document extraction for explicit `files` scopes (Issue #1285). Returns empty
4697
6283
  // evidence for every other scope kind, leaving the code-first path byte-identical.
4698
6284
  const documentEvidence = await collectConnectedDocumentEvidence({
4699
- scope: input.scope,
6285
+ scope: documentSelectionScope(input.scope, augmentedRings.explicitAdmission),
4700
6286
  query: input.query,
4701
6287
  searchScope,
4702
6288
  fs,
4703
6289
  nowMs,
4704
6290
  signal: deps.signal,
4705
6291
  deadlineAtMs,
6292
+ budget: plan.budget,
6293
+ initialUsage: prepared.initialUsage,
4706
6294
  });
4707
6295
  const hasDocumentEvidence = documentEvidence.atoms.length > 0 || documentEvidence.omitted.length > 0;
4708
6296
  const withinDeadline = nowMs() < deadlineAtMs;
@@ -4710,7 +6298,7 @@ async function prepareGroundedAssembly(args, augmentedRings, prepared) {
4710
6298
  ? undefined
4711
6299
  : await assemblyFileStateCacheIdentity(args, prepared.keptPaths);
4712
6300
  const canStartAssemblySeams = nowMs() < deadlineAtMs;
4713
- const assembleOptions = assembleOptionsFor(deps, nowMs, !hasDocumentEvidence && canStartAssemblySeams, canStartAssemblySeams, deadlineAtMs);
6301
+ const assembleOptions = assembleOptionsFor(deps, nowMs, !hasDocumentEvidence && canStartAssemblySeams, deadlineAtMs);
4714
6302
  // The micro-index cache key does not model request-local document evidence, so a scope that
4715
6303
  // carried documents this run must not be served from (or written to) the shared cache.
4716
6304
  const cacheKey = hasDocumentEvidence
@@ -4728,6 +6316,19 @@ async function prepareGroundedAssembly(args, augmentedRings, prepared) {
4728
6316
  const cached = cacheKey === undefined ? undefined : assembleOptions.microIndex?.get(cacheKey);
4729
6317
  return { documentEvidence, cached, cacheIdentity, cacheKey, assembleOptions };
4730
6318
  }
6319
+ function documentSelectionScope(scope, admission) {
6320
+ const paths = admission?.selections
6321
+ .map((selection) => selection.path)
6322
+ .filter(isExtractableConnectedDocumentPath) ?? [];
6323
+ if (paths.length === 0)
6324
+ return scope;
6325
+ return {
6326
+ ...scope,
6327
+ kind: "files",
6328
+ relativePaths: [...new Set([...(scope.kind === "files" ? scope.relativePaths : []), ...paths])],
6329
+ explicitConnection: true,
6330
+ };
6331
+ }
4731
6332
  // PR4-W1 (ADR-0055 D1): conditional diagnostics observer. When a ContextProfile is threaded
4732
6333
  // through OrchestratorDeps, the fully assembled pack is enriched with an additive
4733
6334
  // `diagnostics.contextBudget?`. The observer is pure and touches no field a prompt builder reads,
@@ -4758,32 +6359,49 @@ async function excerptBoundCacheIdentity(args, keptPaths, captured) {
4758
6359
  return undefined;
4759
6360
  return current.every((entry, index) => entry === captured[index]) ? captured : undefined;
4760
6361
  }
4761
- async function assembleGroundedPack(args) {
6362
+ function excerptCapacityWithDocuments(initialUsage, documents) {
6363
+ if (documents.excerpts.size === 0)
6364
+ return initialUsage;
6365
+ const usage = documentProjectionUsage(documents.excerpts);
6366
+ return {
6367
+ ...initialUsage,
6368
+ filesRead: initialUsage.filesRead + usage.filesRead,
6369
+ excerptBytes: initialUsage.excerptBytes + usage.excerptBytes,
6370
+ };
6371
+ }
6372
+ function groundedExcerptInputs(args, augmentedRings, prepared, documentEvidence) {
4762
6373
  const { input, deps, plan, searchScope, fs, nowMs, deadlineAtMs } = args;
4763
- const augmentedRings = await augmentRingsWithDeterministicAtoms(args);
4764
- const prepared = preparePackAssembly(input, plan, augmentedRings, nowMs, args.hasGitMetadata);
4765
- const ctx = await prepareGroundedAssembly(args, augmentedRings, prepared);
4766
- if (ctx.cached !== undefined) {
4767
- return {
4768
- pack: withGroundedContextDiagnostics(ctx.cached, deps),
4769
- reusedEvidenceAtomCount: prepared.reusedEvidenceAtomCount,
4770
- metadataRetention: augmentedRings.metadataRetention,
4771
- elapsedBudgetBlocked: false,
4772
- };
4773
- }
4774
- const excerptReads = await readKeptExcerpts(prepared.keptPaths, {
6374
+ return {
6375
+ query: input.query,
6376
+ routeCoverage: augmentedRings.routeCoverage,
6377
+ priorityPaths: prepared.priorityPaths,
4775
6378
  knownFitFileBytes: augmentedRings.knownFitFileBytes,
4776
6379
  searchScope,
4777
6380
  fs,
4778
6381
  budget: plan.budget,
4779
- initialUsage: prepared.initialUsage,
6382
+ initialUsage: excerptCapacityWithDocuments(prepared.initialUsage, documentEvidence),
4780
6383
  atomsByPath: prepared.atomsByPath,
4781
6384
  anchors: plan.anchors.filter((anchor) => anchor.kind !== "path").map((anchor) => anchor.term),
4782
6385
  nowMs,
4783
6386
  signal: deps.signal,
4784
6387
  deadlineAtMs,
4785
- });
6388
+ };
6389
+ }
6390
+ async function assembleGroundedPack(args) {
6391
+ const assembly = await assembleGroundedPackEvidence(args);
6392
+ const pack = withContextualHintConfidence(assembly.pack, args.plan.anchors, args.nowMs());
6393
+ return { ...assembly, pack, selectionObservation: pack.diagnostics?.selection };
6394
+ }
6395
+ async function assembleGroundedPackEvidence(args) {
6396
+ const { input, deps, plan, nowMs } = args;
6397
+ const augmentedRings = filterRejectedExplicitPaths(await augmentRingsWithDeterministicAtoms(args), input.scope, nowMs(), args.hasGitMetadata);
6398
+ const prepared = await preparePackAssembly(args, augmentedRings);
6399
+ const ctx = await prepareGroundedAssembly(args, augmentedRings, prepared);
6400
+ if (ctx.cached !== undefined)
6401
+ return cachedGroundedAssembly(ctx.cached, args, prepared, augmentedRings);
6402
+ const excerptReads = await readKeptExcerpts(prepared.keptPaths, groundedExcerptInputs(args, augmentedRings, prepared, ctx.documentEvidence));
4786
6403
  const pack = await assemblePackFromReads({
6404
+ sourceProgress: args.sourceProgress,
4787
6405
  input,
4788
6406
  plan,
4789
6407
  rings: augmentedRings,
@@ -4797,14 +6415,44 @@ async function assembleGroundedPack(args) {
4797
6415
  });
4798
6416
  return {
4799
6417
  pack: withGroundedContextDiagnostics(pack, deps),
4800
- reusedEvidenceAtomCount: prepared.reusedEvidenceAtomCount,
4801
- metadataRetention: augmentedRings.metadataRetention,
6418
+ ...groundedAssemblyDetails(prepared, augmentedRings),
4802
6419
  excerptObservation: excerptReads.observation,
4803
6420
  elapsedBudgetBlocked: excerptReads.elapsedBudgetBlocked,
4804
6421
  anchoredWindowCount: excerptReads.anchoredWindowCount,
4805
6422
  readWindowCount: excerptReads.readWindowCount,
4806
6423
  };
4807
6424
  }
6425
+ function groundedAssemblyDetails(prepared, rings) {
6426
+ return {
6427
+ ...explicitAssemblyDetails(rings),
6428
+ selectionObservation: prepared.selection,
6429
+ rerankFailure: prepared.rerankFailure,
6430
+ rankingObservation: prepared.ordered.rankingObservation,
6431
+ reusedEvidenceAtomCount: prepared.reusedEvidenceAtomCount,
6432
+ metadataRetention: rings.metadataRetention,
6433
+ contextualDefinitionSeedCount: rings.contextualDefinitionSeedCount,
6434
+ };
6435
+ }
6436
+ function cachedGroundedAssembly(pack, args, prepared, rings) {
6437
+ const selected = JSON.stringify(pack.diagnostics?.selection) === JSON.stringify(prepared.selection)
6438
+ ? pack
6439
+ : {
6440
+ ...pack,
6441
+ diagnostics: { rankedCandidates: [], ...pack.diagnostics, selection: prepared.selection },
6442
+ };
6443
+ return {
6444
+ pack: withGroundedContextDiagnostics(withRetrievalSourceDiagnostics(selected, args.sourceProgress, args.nowMs()), args.deps),
6445
+ ...groundedAssemblyDetails(prepared, rings),
6446
+ elapsedBudgetBlocked: false,
6447
+ };
6448
+ }
6449
+ function explicitAssemblyDetails(rings) {
6450
+ return {
6451
+ explicitObservation: rings.explicitAdmission?.observation,
6452
+ referenceObservation: rings.referenceObservation,
6453
+ explicitSelectionAtomCount: rings.atoms.filter((atom) => atom.provenance.tool === "repo.selectedFile").length,
6454
+ };
6455
+ }
4808
6456
  const EMPTY_STRUCTURAL_DIAGNOSTICS = {
4809
6457
  contextCount: 0,
4810
6458
  candidateInventoryBuildCount: 0,
@@ -4823,10 +6471,17 @@ const NOT_EVALUATED_WORKSPACE_INDEX_DIAGNOSTICS = workspaceIndexActivityDiagnost
4823
6471
  // claiming an unblocked elapsed budget, contradicting the elapsed-budget marker on its own pack.
4824
6472
  function liveRetrievalCompletion(workspaceIndexProviderStatus, assembled, decisions) {
4825
6473
  return {
6474
+ explicitObservation: assembled.explicitObservation,
6475
+ selectionObservation: assembled.selectionObservation,
6476
+ rerankFailure: assembled.rerankFailure,
6477
+ rankingObservation: assembled.rankingObservation,
6478
+ referenceObservation: assembled.referenceObservation,
6479
+ explicitSelectionAtomCount: assembled.explicitSelectionAtomCount,
4826
6480
  anchoredExcerptWindowCount: assembled.anchoredWindowCount,
4827
6481
  excerptReadWindowCount: assembled.readWindowCount,
4828
6482
  excerptObservation: assembled.excerptObservation,
4829
6483
  metadataRetention: assembled.metadataRetention,
6484
+ contextualDefinitionSeedCount: assembled.contextualDefinitionSeedCount,
4830
6485
  reusedEvidenceAtomCount: assembled.reusedEvidenceAtomCount,
4831
6486
  decisions,
4832
6487
  readBudgetBlocked: assembled.excerptObservation?.readBudgetBlocked ?? false,
@@ -5010,8 +6665,10 @@ function uncertaintyActivityExtra(markers) {
5010
6665
  "budget-clipped": 0,
5011
6666
  "tool-unavailable": 0,
5012
6667
  "low-confidence": 0,
6668
+ "low-confidence-selection": 0,
5013
6669
  "unsupported-citation": 0,
5014
6670
  "uncited-answer": 0,
6671
+ "uncited-memory-context": 0,
5015
6672
  "incomplete-answer": 0,
5016
6673
  "unsupported-claim": 0,
5017
6674
  "entailment-unavailable": 0,
@@ -5106,6 +6763,11 @@ function retrievalLossActivityExtra(status) {
5106
6763
  excerptTruncatedWindowCount: excerpt.truncatedWindowCount,
5107
6764
  excerptUnreadFileCount: excerpt.unreadFileCount,
5108
6765
  excerptStopReasons: excerpt.stopReasons,
6766
+ ...(excerpt.plannedQueryFacetCount === undefined
6767
+ ? {}
6768
+ : {
6769
+ excerptServedQueryFacetCount: excerpt.servedQueryFacetCount ?? 0,
6770
+ }),
5109
6771
  }),
5110
6772
  };
5111
6773
  }
@@ -5119,7 +6781,6 @@ function metadataRetentionActivityExtra(status) {
5119
6781
  metadataRetainedCount: metadata.retainedCount,
5120
6782
  metadataDiscardedCount: metadata.discardedCount,
5121
6783
  metadataOmittedDetailCount: metadata.omittedDetailCount,
5122
- metadataRetentionLimit: metadata.limit,
5123
6784
  }),
5124
6785
  };
5125
6786
  }
@@ -5149,7 +6810,7 @@ function completionActivityExtra(identity, execution) {
5149
6810
  retrievalTargetCount: plan.targetDecision.targets.length,
5150
6811
  }),
5151
6812
  retrievalAnchorCount: plan.anchors.length,
5152
- ...execution.status.decisions,
6813
+ ...completedRingDecisions(execution.status.decisions),
5153
6814
  usageSearchCalls: pack.usage.searchCalls,
5154
6815
  usageFilesRead: pack.usage.filesRead,
5155
6816
  usageExcerptBytes: pack.usage.excerptBytes,
@@ -5175,6 +6836,10 @@ function completionActivityExtra(identity, execution) {
5175
6836
  loss: "none",
5176
6837
  };
5177
6838
  }
6839
+ function completedRingDecisions(decisions) {
6840
+ const { augmentationSkipReason: _reason, ...completed } = decisions ?? {};
6841
+ return completed;
6842
+ }
5178
6843
  function omissionTotalsActivityExtra(pack) {
5179
6844
  const counts = connectedContextOmittedCounts(pack);
5180
6845
  return {
@@ -5201,6 +6866,13 @@ function completionDetailsActivityExtra(identity, execution) {
5201
6866
  scopeIdentitySha256: identity.scopeIdentitySha256,
5202
6867
  queryIdentitySha256: identity.queryIdentitySha256,
5203
6868
  activityDetailStatus: "complete",
6869
+ ...(execution.status.decisions?.augmentationSkipReason === undefined
6870
+ ? {}
6871
+ : { augmentationSkipReason: execution.status.decisions.augmentationSkipReason }),
6872
+ ...(execution.status.metadataRetention === undefined
6873
+ ? {}
6874
+ : { metadataRetentionLimit: execution.status.metadataRetention.limit }),
6875
+ searchCitationDirectiveClauseCount: execution.workspaceIndex.citationDirectiveClauseCount,
5204
6876
  ...retrievalLossActivityExtra(execution.status),
5205
6877
  ...structuralActivityExtra(execution.structural),
5206
6878
  ...workspaceIndexActivityExtra(execution.workspaceIndex),
@@ -5209,6 +6881,12 @@ function completionDetailsActivityExtra(identity, execution) {
5209
6881
  loss: "none",
5210
6882
  };
5211
6883
  }
6884
+ function sourceReferenceActivityExtra(observation) {
6885
+ if (observation === undefined)
6886
+ return {};
6887
+ const { stackTraceFrameCount: _all, stackTraceExternalFrameCount: _external, continuityReferentSource: _source, continuityReferentCount: _referents, continuityAdmittedCount: _admitted, continuityRejectedCount: _rejected, ...fields } = observation;
6888
+ return fields;
6889
+ }
5212
6890
  function sourceDetailsActivityExtra(identity, execution, correlationId) {
5213
6891
  const shared = {
5214
6892
  scopeIdentitySha256: identity.scopeIdentitySha256,
@@ -5221,6 +6899,9 @@ function sourceDetailsActivityExtra(identity, execution, correlationId) {
5221
6899
  ...shared,
5222
6900
  activityDetailStatus: "complete",
5223
6901
  directEvidenceLookup: execution.output.plan.directEvidenceLookup,
6902
+ explicitSelectionAtomCount: execution.status.explicitSelectionAtomCount ?? 0,
6903
+ ...execution.status.explicitObservation,
6904
+ ...sourceReferenceActivityExtra(execution.status.referenceObservation),
5224
6905
  reusedEvidenceAtomCount: execution.status.reusedEvidenceAtomCount ?? 0,
5225
6906
  unrepresentablePathCount: execution.output.pack.diagnostics?.coverage?.unrepresentablePathsByDiscovery ?? 0,
5226
6907
  ...(execution.status.sourceDecision ?? emptySourceDecision("not-evaluated")),
@@ -5384,12 +7065,76 @@ function safeFailureActivityExtra(identity, error, progress, cancelled, correlat
5384
7065
  return unavailableFailureActivityExtra(identity, progress, cancelled);
5385
7066
  }
5386
7067
  }
7068
+ function selectionQualityActivityExtra(status) {
7069
+ const selection = status.selectionObservation;
7070
+ if (selection === undefined)
7071
+ return {};
7072
+ const { reranker, ...observation } = selection;
7073
+ const frames = status.rerankFailure === undefined ? [] : keikoStackFrames(status.rerankFailure);
7074
+ const chain = status.rerankFailure === undefined ? [] : causeChain(status.rerankFailure);
7075
+ return {
7076
+ ...observation,
7077
+ ...(reranker === undefined
7078
+ ? {}
7079
+ : {
7080
+ rerankerCandidateCount: reranker.candidateCount,
7081
+ rerankerDocumentCount: reranker.documentCount,
7082
+ }),
7083
+ ...(status.rerankFailure === undefined
7084
+ ? {}
7085
+ : { failureKind: connectedContextFailureKind(status.rerankFailure) }),
7086
+ ...(frames.length === 0 ? {} : { frames }),
7087
+ ...(chain.length === 0 ? {} : { causeChain: chain }),
7088
+ };
7089
+ }
7090
+ function selectionDetailsActivityExtra(identity, status) {
7091
+ return {
7092
+ scopeIdentitySha256: identity.scopeIdentitySha256,
7093
+ queryIdentitySha256: identity.queryIdentitySha256,
7094
+ ...(status.contextualDefinitionSeedCount === undefined
7095
+ ? {}
7096
+ : { contextualDefinitionSeedCount: status.contextualDefinitionSeedCount }),
7097
+ ...status.rankingObservation,
7098
+ ...worktreeActivityExtra(status),
7099
+ ...status.semanticFreshness,
7100
+ ...selectionQualityActivityExtra(status),
7101
+ ...excerptSchedulingActivityExtra(status.excerptObservation),
7102
+ ...(status.referenceObservation === undefined
7103
+ ? {}
7104
+ : {
7105
+ stackTraceFrameCount: status.referenceObservation.stackTraceFrameCount,
7106
+ stackTraceExternalFrameCount: status.referenceObservation.stackTraceExternalFrameCount,
7107
+ continuityReferentSource: status.referenceObservation.continuityReferentSource,
7108
+ continuityReferentCount: status.referenceObservation.continuityReferentCount,
7109
+ continuityAdmittedCount: status.referenceObservation.continuityAdmittedCount,
7110
+ continuityRejectedCount: status.referenceObservation.continuityRejectedCount,
7111
+ }),
7112
+ completeness: "complete",
7113
+ loss: "none",
7114
+ };
7115
+ }
7116
+ function excerptSchedulingActivityExtra(observation) {
7117
+ if (observation === undefined)
7118
+ return {};
7119
+ return {
7120
+ requestedStaticCallCycleCount: observation.requestedStaticCallCycleCount ?? 0,
7121
+ plannedStaticCallCycleCount: observation.plannedStaticCallCycleCount ?? 0,
7122
+ ...(observation.ordinaryRangeCount === undefined
7123
+ ? {}
7124
+ : {
7125
+ excerptOrdinaryRangeCount: observation.ordinaryRangeCount,
7126
+ excerptOrdinaryServedRangeCount: observation.ordinaryServedRangeCount ?? 0,
7127
+ excerptDeferredDefinitionRangeCount: observation.deferredDefinitionRangeCount ?? 0,
7128
+ }),
7129
+ };
7130
+ }
5387
7131
  function logConnectedContextCompletion(logger, identity, execution, correlationId, durationMs, metadataUnavailableInspectionCount) {
5388
7132
  logger.info(() => activityLogEvent(SEARCH_CONNECTED_CONTEXT_COMPLETION_DETAILS_OPERATION, { correlationId }, safeCompletionDetailsActivityExtra(identity, execution, correlationId)));
5389
7133
  logger.info(() => activityLogEvent(SEARCH_CONNECTED_CONTEXT_SOURCE_DETAILS_OPERATION, { correlationId }, {
5390
7134
  ...sourceDetailsActivityExtra(identity, execution, correlationId),
5391
7135
  metadataUnavailableInspectionCount,
5392
7136
  }));
7137
+ logger.info(() => activityLogEvent(SEARCH_CONNECTED_CONTEXT_SELECTION_DETAILS_OPERATION, { correlationId }, selectionDetailsActivityExtra(identity, execution.status)));
5393
7138
  logger.info(() => activityLogEvent(SEARCH_CONNECTED_CONTEXT_COMPLETED_OPERATION, { correlationId, durationMs }, safeCompletionActivityExtra(identity, execution, correlationId)));
5394
7139
  }
5395
7140
  function logConnectedContextClarification(logger, identity, plan, correlationId, durationMs) {
@@ -5415,8 +7160,9 @@ function logConnectedContextFailure(logger, identity, error, progress, correlati
5415
7160
  logger.error(event);
5416
7161
  }
5417
7162
  function createConnectedContextActivity(input, deps, nowMs, logicalStartMs) {
7163
+ const sink = deps.activityLog ?? processServerLogSink();
5418
7164
  const logger = createServerLogger({
5419
- sink: deps.activityLog ?? processServerLogSink(),
7165
+ sink,
5420
7166
  level: "debug",
5421
7167
  });
5422
7168
  const correlationId = correlationIdOrUnknown(deps.correlationId);
@@ -5424,6 +7170,7 @@ function createConnectedContextActivity(input, deps, nowMs, logicalStartMs) {
5424
7170
  const logElapsed = startLogTimer();
5425
7171
  let metadataUnavailableInspectionCount = 0;
5426
7172
  return {
7173
+ sink,
5427
7174
  symbolReadFailure: createSymbolReadFailureObserver(logger, correlationId),
5428
7175
  elapsedMs: () => Math.max(0, nowMs() - logicalStartMs),
5429
7176
  started: () => {
@@ -5493,23 +7240,78 @@ function connectedContextSearchInputs(input, deps, plan, runtime, context) {
5493
7240
  runtime.progress.scopeContextObservation = observation;
5494
7241
  },
5495
7242
  hasGitMetadata: context.hasGitMetadata,
7243
+ recentPaths: context.worktreeRecency?.paths.map((path) => path.path),
5496
7244
  searchScope: context.searchScope,
7245
+ rejectedPaths: [...runtime.rejectedExplicitPaths],
5497
7246
  query: input.query,
5498
7247
  targetDecision: plan.targetDecision ?? resolveQueryTargetDecision(input.query, plan.anchors),
5499
- anchors: plan.anchors,
5500
- retrievalIntent: plan.retrievalIntent,
7248
+ anchors: planSearchAnchors(plan),
7249
+ retrievalIntent: effectiveRetrievalIntent(plan),
5501
7250
  fs: context.ringFs,
5502
7251
  nowMs: runtime.nowMs,
5503
7252
  signal: deps.signal,
5504
7253
  ...(workspaceIndex === undefined ? {} : { workspaceIndex }),
5505
7254
  workspaceIndexActivity: context.workspaceIndexActivity,
5506
7255
  repoSemanticSearchProvider: deps.repoSemanticSearchProvider ?? deps.semanticSearchProvider,
7256
+ repoSemanticSearchProviderFor: groundedSemanticProviderFactory(deps, runtime, context),
5507
7257
  gitFileHistoryEvidence: deps.gitFileHistoryEvidence ?? defaultGitFileHistoryEvidenceProvider,
5508
7258
  correlationId: deps.correlationId,
5509
7259
  structuralContexts: context.structuralContexts,
5510
7260
  deadlineAtMs: context.deadlineAtMs,
5511
7261
  };
5512
7262
  }
7263
+ function eligibleFocusedFileReferences(references) {
7264
+ return references.length > 0 && references.every((reference) => reference.path.includes("/"));
7265
+ }
7266
+ function focusedTargetsMatchReferences(plan, references) {
7267
+ return (plan.targetDecision?.namedFileOnly === true &&
7268
+ plan.targetDecision.targets.every((target) => references.some((reference) => reference.path.toLowerCase() === target.term)));
7269
+ }
7270
+ function permitsFocusedFileQuery(input, plan) {
7271
+ return (input.query.kind === "natural-language" &&
7272
+ plan.targetDecision?.kind !== "literal-search" &&
7273
+ effectiveRetrievalIntent(plan) !== "diagnostic-search" &&
7274
+ !requiresRelationshipOrHistoryRings(input.query));
7275
+ }
7276
+ function isFocusedFileQuery(input, plan) {
7277
+ const references = plan.references?.filter((reference) => reference.origin === "query") ?? [];
7278
+ return (permitsFocusedFileQuery(input, plan) &&
7279
+ plan.targetDecision?.definitionRequested === false &&
7280
+ eligibleFocusedFileReferences(references) &&
7281
+ focusedTargetsMatchReferences(plan, references));
7282
+ }
7283
+ function unavailableFileTargetSummary(input, plan, admission, governor) {
7284
+ if (!isFocusedFileQuery(input, plan) || admission.selections.length !== 0)
7285
+ return undefined;
7286
+ const { explicitPathRejectedCount, explicitPathAnchorCount } = admission.observation;
7287
+ if (explicitPathRejectedCount === 0 || explicitPathRejectedCount !== explicitPathAnchorCount)
7288
+ return undefined;
7289
+ return {
7290
+ ...newRingEvidence(),
7291
+ governor: complete(governor),
7292
+ decisions: {
7293
+ ...newRingDecisions(),
7294
+ skippedRingKinds: plan.rings.map((ring) => ring.kind),
7295
+ ringSkipReasons: ["explicit-target-unavailable"],
7296
+ },
7297
+ };
7298
+ }
7299
+ function focusedFileContext(input, deps, runtime, context, plan, admission) {
7300
+ const selections = admission.selections;
7301
+ if (!isFocusedFileQuery(input, plan) ||
7302
+ selections.length === 0 ||
7303
+ !selections.every((selection) => selection.path.includes("/") && selection.origin === "query"))
7304
+ return context;
7305
+ // Admission has already established canonical selected-scope membership. Focus discovery on
7306
+ // the named files; unrelated lexical vocabulary cannot broaden this bounded factual lookup.
7307
+ const searchScope = {
7308
+ ...context.searchScope,
7309
+ relativePaths: [...new Set(selections.map((selection) => selection.path))],
7310
+ };
7311
+ const structuralContexts = liveStructuralContexts(searchScope, context.ringFs, runtime, context.deadlineAtMs, context.workspaceIndexActivity, deps.signal);
7312
+ runtime.progress.structuralContexts = structuralContexts;
7313
+ return { ...context, searchScope, structuralContexts };
7314
+ }
5513
7315
  function emptyWorkspaceIoActivityDiagnostics() {
5514
7316
  return {
5515
7317
  readDirCalls: 0,
@@ -5797,7 +7599,7 @@ export function _ringDiscoveryFsForTests(fs) {
5797
7599
  }
5798
7600
  export const _RING_DISCOVERY_SENTINEL_ENTRIES_FOR_TESTS = RING_DISCOVERY_SENTINEL_ENTRIES;
5799
7601
  function liveStructuralContexts(searchScope, fs, runtime, deadlineAtMs, workspaceIndexActivity, signal) {
5800
- return createStructuralRequestContextPool(searchScope, fs, runtime.nowMs, deadlineAtMs, workspaceIndexActivity, signal);
7602
+ return createStructuralRequestContextPool(searchScope, fs, runtime.nowMs, deadlineAtMs, workspaceIndexActivity, signal, (scopePath) => !runtime.rejectedExplicitPaths.has(scopePath));
5801
7603
  }
5802
7604
  function detectConnectedContextWorkspace(root, fs) {
5803
7605
  return detectWorkspaceAt(root, fs, { scanSourceFilesForLanguages: false });
@@ -5829,6 +7631,21 @@ function explorationDeadlineAtMs(startedAtMs, budget) {
5829
7631
  ? Number.POSITIVE_INFINITY
5830
7632
  : startedAtMs + Math.max(0, budget.elapsedMsMax);
5831
7633
  }
7634
+ // Metadata only: the existing hardened Git membership resolver still validates ownership in the
7635
+ // selected cwd. Finding an ancestor marker never changes the selected evidence root or scope.
7636
+ // The original metadata deadline/abort guard bounds each probe; filesystem-root termination keeps
7637
+ // legitimate deeply nested selections discoverable without an arbitrary ancestor-depth cutoff.
7638
+ function hasConnectedGitMetadata(root, fs) {
7639
+ let current = root;
7640
+ for (;;) {
7641
+ if (fs.exists(resolve(current, ".git")))
7642
+ return true;
7643
+ const parent = parentDirectory(current);
7644
+ if (parent === current)
7645
+ return false;
7646
+ current = parent;
7647
+ }
7648
+ }
5832
7649
  function prepareLiveRetrievalContext(input, deps, plan, runtime) {
5833
7650
  const deadlineAtMs = explorationDeadlineAtMs(runtime.requestStartedAtMs, plan.budget);
5834
7651
  runtime.progress.phase = "workspace-detection";
@@ -5838,7 +7655,7 @@ function prepareLiveRetrievalContext(input, deps, plan, runtime) {
5838
7655
  deadlineAtMs,
5839
7656
  };
5840
7657
  const workspace = runtime.detect(runtime.workspaceRoot, detectionGuardedFs(runtime.fs, detectionControl));
5841
- const hasGitMetadata = detectionGuardedFs(runtime.fs, detectionControl).exists(resolve(workspace.root, ".git"));
7658
+ const hasGitMetadata = hasConnectedGitMetadata(workspace.root, detectionGuardedFs(runtime.fs, detectionControl));
5842
7659
  const searchScope = buildSearchScope(input.scope, workspace);
5843
7660
  const workspaceIndexSource = runtime.nowMs() < deadlineAtMs ? deps.workspaceIndexForRoot?.(workspace.root) : undefined;
5844
7661
  const workspaceIndexActivity = createWorkspaceIndexActivity(workspaceIndexSource);
@@ -5858,6 +7675,8 @@ function prepareLiveRetrievalContext(input, deps, plan, runtime) {
5858
7675
  }
5859
7676
  function liveGroundedPackInputs(input, deps, plan, runtime, context, rings) {
5860
7677
  return {
7678
+ sourceProgress: runtime.progress,
7679
+ worktreeRecency: context.worktreeRecency,
5861
7680
  recordMetadataUnavailable: runtime.activity.metadataUnavailable,
5862
7681
  recordSymbolReadFailure: runtime.activity.symbolReadFailure,
5863
7682
  input,
@@ -5874,19 +7693,172 @@ function liveGroundedPackInputs(input, deps, plan, runtime, context, rings) {
5874
7693
  hasGitMetadata: context.hasGitMetadata,
5875
7694
  };
5876
7695
  }
7696
+ async function retrieveAdmittedLiveRings(input, deps, plan, governor, runtime, context) {
7697
+ const admitted = await liveExplicitPathAdmission(input, deps, plan, governor, runtime, context);
7698
+ const focused = focusedFileContext(input, deps, runtime, context, plan, admitted.admission);
7699
+ focused.structuralContexts.preferCodeIntelligenceSources(admitted.admission.selections.map((selection) => selection.path));
7700
+ const unavailable = unavailableFileTargetSummary(input, plan, admitted.admission, admitted.governor);
7701
+ if (unavailable !== undefined)
7702
+ runtime.progress.scopeContextObservation = gateRefusedScopeContext(plan.budget.excerptBytesMax);
7703
+ const discovered = unavailable ??
7704
+ (await runAllRings(plan.rings, {
7705
+ ...connectedContextSearchInputs(input, deps, plan, runtime, focused),
7706
+ admittedPaths: admitted.admission.selections.map((selection) => selection.path),
7707
+ }, admitted.governor));
7708
+ const rings = withAdmittedExplicitPaths({ ...discovered, referenceObservation: admitted.observation }, admitted.admission, input, runtime.nowMs, context.hasGitMetadata);
7709
+ return { context: focused, rings };
7710
+ }
5877
7711
  async function retrieveLiveConnectedContext(input, deps, plan, governor, runtime, context) {
5878
7712
  runtime.progress.phase = "ring-retrieval";
5879
- const rings = await runAllRings(plan.rings, connectedContextSearchInputs(input, deps, plan, runtime, context), governor);
7713
+ const { context: focused, rings } = await retrieveAdmittedLiveRings(input, deps, plan, governor, runtime, context);
5880
7714
  throwIfCancelled(deps.signal);
5881
7715
  runtime.progress.phase = "pack-assembly";
5882
- const assembled = await assembleGroundedPack(liveGroundedPackInputs(input, deps, plan, runtime, context, rings));
7716
+ const assembled = await assembleGroundedPack(liveGroundedPackInputs(input, deps, plan, runtime, focused, rings));
5883
7717
  throwIfCancelled(deps.signal);
5884
7718
  const workspaceIndex = context.workspaceIndexActivity.diagnostics();
5885
- return connectedContextExecution(assembled.pack, plan, runtime.activity, {
7719
+ const execution = connectedContextExecution(assembled.pack, plan, runtime.activity, {
5886
7720
  ...liveRetrievalCompletion(workspaceIndex.providerStatus, assembled, rings.decisions),
7721
+ ...liveWorktreeCompletion(context, assembled.pack),
7722
+ semanticFreshness: groundedSemanticFreshnessSummary(runtime.progress.semanticFreshness ?? [], assembled.pack),
5887
7723
  scopeContextObservation: runtime.progress.scopeContextObservation,
5888
7724
  sourceDecision: runtime.progress.sourceDecision,
5889
7725
  }, context.structuralContexts.diagnostics(), workspaceIndex, runtime.workspaceIoActivity.diagnostics());
7726
+ return withDeclarationScopeResolver(execution, input, deps, runtime, context);
7727
+ }
7728
+ function withDeclarationScopeResolver(execution, input, deps, runtime, context) {
7729
+ return {
7730
+ ...execution,
7731
+ output: {
7732
+ ...execution.output,
7733
+ declarationScopeIndexFor: (paths) => declarationScopeIndex(paths, input, deps, runtime, context),
7734
+ },
7735
+ };
7736
+ }
7737
+ function declarationScopeIndex(paths, input, deps, runtime, context) {
7738
+ const verified = new Map();
7739
+ for (const path of paths.slice(0, 3)) {
7740
+ throwIfCancelled(deps.declarationVerificationSignal ?? deps.signal);
7741
+ if (runtime.nowMs() >= context.deadlineAtMs)
7742
+ break;
7743
+ if (admissibleDeclaredScopePath(path, {
7744
+ scope: input.scope,
7745
+ searchScope: context.searchScope,
7746
+ fs: runtime.fs,
7747
+ hasGitMetadata: context.hasGitMetadata,
7748
+ }))
7749
+ verified.set(path, "unread-in-scope");
7750
+ }
7751
+ return verified;
7752
+ }
7753
+ function withRetrievalSourceDiagnostics(pack, progress, nowMs) {
7754
+ const observedScopeState = progress.scopeContextObservation?.state;
7755
+ const scopeState = observedScopeState === "empty" ? undefined : observedScopeState;
7756
+ const semanticState = progress.sourceDecision?.semanticProviderDisposition;
7757
+ const staleMarkers = staleSemanticMarker(groundedSemanticFreshnessSummary(progress.semanticFreshness ?? [], pack), nowMs);
7758
+ const sourceDiagnostics = {
7759
+ scopeContextState: scopeState,
7760
+ semanticProviderDisposition: semanticState,
7761
+ };
7762
+ if (sameRetrievalSourceDiagnostics(pack, sourceDiagnostics, staleMarkers))
7763
+ return pack;
7764
+ return {
7765
+ ...pack,
7766
+ uncertainty: [
7767
+ ...pack.uncertainty.filter((marker) => !isRetrievalSemanticStaleMarker(marker)),
7768
+ ...staleMarkers,
7769
+ ],
7770
+ diagnostics: {
7771
+ rankedCandidates: [],
7772
+ ...pack.diagnostics,
7773
+ ...sourceDiagnostics,
7774
+ },
7775
+ };
7776
+ }
7777
+ function sameRetrievalSourceDiagnostics(pack, diagnostics, staleMarkers) {
7778
+ const priorStale = pack.uncertainty.filter(isRetrievalSemanticStaleMarker);
7779
+ return (pack.diagnostics?.scopeContextState === diagnostics.scopeContextState &&
7780
+ pack.diagnostics?.semanticProviderDisposition === diagnostics.semanticProviderDisposition &&
7781
+ priorStale.length === staleMarkers.length &&
7782
+ priorStale.every((marker, index) => marker.claim === staleMarkers[index]?.claim));
7783
+ }
7784
+ function isRetrievalSemanticStaleMarker(marker) {
7785
+ return marker.kind === "stale-evidence" && marker.claim.startsWith("stale-semantic: ");
7786
+ }
7787
+ function metadataInjectionReason(input, plan) {
7788
+ const intent = effectiveRetrievalIntent(plan);
7789
+ if (intent === "project-metadata" || intent === "repository-overview")
7790
+ return "intent";
7791
+ return wantsProjectMetadata(input, intent) ? "pattern" : "none";
7792
+ }
7793
+ async function liveExplicitPathAdmission(input, deps, plan, governor, runtime, context) {
7794
+ const budget = createAugmentationBudgetMeter(plan, governor, runtime.nowMs, context.deadlineAtMs);
7795
+ const result = await admitDiagnosticReferences({
7796
+ hasGitMetadata: context.hasGitMetadata,
7797
+ plan,
7798
+ assistantReferents: input.assistantReferents,
7799
+ continuityReferentSource: input.continuityReferentSource,
7800
+ structuralFs: context.ringFs,
7801
+ requestContext: (preferredPaths) => {
7802
+ context.structuralContexts.preferCodeIntelligenceSources(preferredPaths);
7803
+ return context.structuralContexts.forLimits(GROUNDED_TRACE_SEARCH_LIMITS);
7804
+ },
7805
+ metadataInjectionReason: metadataInjectionReason(input, plan),
7806
+ scope: input.scope,
7807
+ query: input.query,
7808
+ searchScope: context.searchScope,
7809
+ fs: runtime.fs,
7810
+ nowMs: runtime.nowMs,
7811
+ deadlineAtMs: context.deadlineAtMs,
7812
+ signal: deps.signal,
7813
+ tryReserveSearchCall: budget.tryReserveSearchCall,
7814
+ onPathRejected: (scopePath) => {
7815
+ runtime.rejectedExplicitPaths.add(scopePath);
7816
+ },
7817
+ });
7818
+ return { ...result, governor: budget.finish(governor).governor };
7819
+ }
7820
+ function withAdmittedExplicitPaths(rings, admission, input, nowMs, hasGitMetadata) {
7821
+ const fingerprint = selectedFileQueryFingerprint(input.query);
7822
+ return filterRejectedExplicitPaths({
7823
+ ...rings,
7824
+ explicitAdmission: admission,
7825
+ atoms: [
7826
+ ...admission.selections
7827
+ .filter((selection) => !isExtractableConnectedDocumentPath(selection.path))
7828
+ .map((selection) => selectedFileAtom(input.scope, selection.path, fingerprint, nowMs, selection.line)),
7829
+ ...rings.atoms,
7830
+ ],
7831
+ omitted: [...rings.omitted, ...admission.omitted],
7832
+ }, input.scope, nowMs(), hasGitMetadata);
7833
+ }
7834
+ function filterRejectedExplicitPaths(rings, scope, nowMs, hasGitMetadata) {
7835
+ const admission = rings.explicitAdmission;
7836
+ if (admission === undefined || admission.observation.explicitPathAnchorCount === 0)
7837
+ return rings;
7838
+ const humanPaths = new Set(scope.kind === "files" ? scope.relativePaths : []);
7839
+ const generated = new Set(rings.atoms
7840
+ .filter((atom) => !humanPaths.has(atom.scopePath) &&
7841
+ !isOrdinaryFolderDocumentPath(atom.scopePath, hasGitMetadata) &&
7842
+ (isGeneratedArtifactPath(atom.scopePath) || isGeneratedRankingPath(atom.scopePath)))
7843
+ .map((atom) => atom.scopePath));
7844
+ const omitted = new Set(rings.omitted.map((entry) => entry.scopePath));
7845
+ const retainedOmissions = rings.omitted.filter((entry) => !humanPaths.has(entry.scopePath) ||
7846
+ (entry.reason !== "ignored" && entry.reason !== "generated"));
7847
+ return {
7848
+ ...rings,
7849
+ atoms: rings.atoms.filter((atom) => humanPaths.has(atom.scopePath) ||
7850
+ (!admission.rejectedPaths.has(atom.scopePath) && !generated.has(atom.scopePath))),
7851
+ omitted: [
7852
+ ...retainedOmissions,
7853
+ ...[...generated]
7854
+ .filter((path) => !omitted.has(path))
7855
+ .map((scopePath) => ({
7856
+ scopePath,
7857
+ reason: "generated",
7858
+ omittedAtMs: nowMs,
7859
+ })),
7860
+ ],
7861
+ };
5890
7862
  }
5891
7863
  async function emptyBudgetExhaustedRetrieval(input, deps, plan, governor, runtime, stop) {
5892
7864
  runtime.progress.phase = "empty-pack-assembly";
@@ -5926,12 +7898,30 @@ async function retrieveLiveOrDeadlineExhausted(input, deps, plan, governor, runt
5926
7898
  elapsedBudgetBlocked: true,
5927
7899
  });
5928
7900
  }
5929
- return retrieveLiveConnectedContext(input, deps, plan, governor, runtime, liveContext);
7901
+ const observedContext = await withLiveWorktreeRecency(input, deps, plan, runtime, liveContext);
7902
+ throwIfCancelled(deps.signal);
7903
+ const observedGovernor = applyUsage(governor, usageDelta({ elapsedMs: observedContext.worktreeStatusDurationMs ?? 0 }));
7904
+ return retrieveLiveConnectedContext(input, deps, plan, observedGovernor, runtime, observedContext);
7905
+ }
7906
+ /** No source lookup is runnable; the accepted assessment uses the same validated empty assembler. */
7907
+ async function unanchoredAssessmentRetrieval(input, deps, plan, runtime) {
7908
+ runtime.progress.phase = "empty-pack-assembly";
7909
+ const { pack } = await assembleContextPack({
7910
+ scope: input.scope,
7911
+ query: input.query,
7912
+ budget: plan.budget,
7913
+ atoms: [],
7914
+ ranked: [],
7915
+ omittedFromRanking: [],
7916
+ excerpts: new Map(),
7917
+ }, assembleOptionsFor(deps, runtime.nowMs, false));
7918
+ throwIfCancelled(deps.signal);
7919
+ return connectedContextExecution(pack, plan, runtime.activity, stoppedRetrievalCompletion(false, false, plan.rings), EMPTY_STRUCTURAL_DIAGNOSTICS, NOT_EVALUATED_WORKSPACE_INDEX_DIAGNOSTICS, runtime.workspaceIoActivity.diagnostics());
5930
7920
  }
5931
7921
  async function executeConnectedContextRetrieval(input, deps, runtime) {
5932
7922
  throwIfCancelled(deps.signal);
5933
7923
  runtime.progress.phase = "planning";
5934
- const { plan, governor } = createReadyGovernedPlan(input, runtime.nowMs, runtime.progress);
7924
+ const { plan, governor } = createGovernedRetrievalPlan(input, runtime.nowMs, runtime.progress, deps.ownAssessmentPolicy);
5935
7925
  runtime.progress.plannedRingCount = plan.rings.length;
5936
7926
  deps.recordPlan?.(plan);
5937
7927
  throwIfCancelled(deps.signal);
@@ -5940,6 +7930,8 @@ async function executeConnectedContextRetrieval(input, deps, runtime) {
5940
7930
  ...runtime,
5941
7931
  workspaceRoot: assertGroundedWorkspaceRootAllowed(runtime.fs, input.workspaceRoot, deps),
5942
7932
  };
7933
+ if (governor === undefined)
7934
+ return unanchoredAssessmentRetrieval(input, deps, plan, admittedRuntime);
5943
7935
  runtime.progress.phase = "budget-evaluation";
5944
7936
  const readBudgetBlock = readBudgetStopReason(plan.budget);
5945
7937
  const deadlineAtMs = explorationDeadlineAtMs(runtime.requestStartedAtMs, plan.budget);
@@ -6006,6 +7998,7 @@ export async function retrieveConnectedContextPack(input, deps) {
6006
7998
  progress,
6007
7999
  workspaceIoActivity,
6008
8000
  requestStartedAtMs,
8001
+ rejectedExplicitPaths: new Set(),
6009
8002
  });
6010
8003
  activity.completed(execution);
6011
8004
  return execution.output;
@@ -6022,17 +8015,20 @@ export async function retrieveConnectedContextPack(input, deps) {
6022
8015
  async function entailmentMarkersFor(deps, answerContent, pack, nowMs) {
6023
8016
  return (await deps.entailmentStage?.evaluate(answerContent, [pack], nowMs)) ?? [];
6024
8017
  }
6025
- function citationCoverageMarkerFor(answerContent, pack, nowMs, correlationId) {
6026
- const reconciliation = reconcileAndLogInlineCitations(answerContent, buildPackCitationIndex([pack]), correlationId);
8018
+ function citationCoverageMarkerFor(answerContent, pack, nowMs, correlationId, metadata) {
8019
+ const reconciliation = reconcileAndLogInlineCitations(answerContent, buildPackCitationIndex([pack]), correlationId, metadata);
6027
8020
  const unsupported = unsupportedCitationMarker(reconciliation.unsupported, nowMs);
6028
8021
  if (unsupported !== undefined || reconciliation.citedScopePaths.size > 0)
6029
8022
  return unsupported;
6030
- return missingCitationMarkerFor(answerContent, nowMs);
8023
+ return missingCitationMarkerFor(answerContent, nowMs, metadata.answerKind);
6031
8024
  }
6032
8025
  function exhaustedAnswerBudgetDimensions(answer, pack, elapsedMs) {
6033
8026
  return [
6034
- ...(answer.usage.promptTokens > pack.budget.modelInputTokensMax ? ["modelInputTokens"] : []),
6035
- ...(answer.usage.completionTokens > pack.budget.modelOutputTokensMax
8027
+ ...(pack.usage.modelInputTokens + answer.usage.promptTokens > pack.budget.modelInputTokensMax
8028
+ ? ["modelInputTokens"]
8029
+ : []),
8030
+ ...(pack.usage.modelOutputTokens + answer.usage.completionTokens >
8031
+ pack.budget.modelOutputTokensMax
6036
8032
  ? ["modelOutputTokens"]
6037
8033
  : []),
6038
8034
  ...(pack.budget.elapsedMsMax !== null && elapsedMs > pack.budget.elapsedMsMax
@@ -6040,52 +8036,176 @@ function exhaustedAnswerBudgetDimensions(answer, pack, elapsedMs) {
6040
8036
  : []),
6041
8037
  ];
6042
8038
  }
6043
- async function answerWithAvailableContext(input, deps, pack, plan, sourceEvidenceAvailable, start, nowMs) {
6044
- const answer = normalizeGroundedAnswerPayload(await deps.answerer.answer(input.answerQuestion ?? input.query.text, pack));
6045
- const elapsedMs = Math.max(0, nowMs() - start);
8039
+ async function groundedAnswerForPack(input, deps, pack, declarationScopeIndexFor, deadlineAtMs, requiredEvidencePaths, conversationOnly = false) {
8040
+ const payload = await deps.answerer.answer(input.answerQuestion ?? input.query.text, pack, {
8041
+ modelInputTokensMax: Math.max(0, pack.budget.modelInputTokensMax - pack.usage.modelInputTokens),
8042
+ modelOutputTokensMax: Math.max(0, pack.budget.modelOutputTokensMax - pack.usage.modelOutputTokens),
8043
+ answerOnlyContextAvailable: input.answerOnlyContextAvailable,
8044
+ currentQuestion: input.currentQuestion ?? input.query.text,
8045
+ signal: deps.signal,
8046
+ deadlineAtMs,
8047
+ requiredEvidencePaths,
8048
+ });
8049
+ const normalized = normalizeGroundedAnswerPayload(payload);
8050
+ const answer = normalizeGroundedAnswerAssessment(normalized, deps.ownAssessmentPolicy ?? "disabled", deps.correlationId, input.currentQuestion ?? input.query.text, { ...connectedContextActivityIdentity(input), phase: "candidate" }, conversationOnly && !packHasUsableEvidence(singleSentEvidencePack(normalized, pack)));
8051
+ return validateSingleAnswerEvidence(answer, pack, input.currentQuestion ?? input.query.text, declarationScopeIndexFor?.(declaredInsufficiencyPaths(answer.content)));
8052
+ }
8053
+ function answeredContextPack(pack, answer, elapsedMs, markers, nowMs) {
8054
+ const observed = withSentSelectionDiagnostics(pack, answer.sentEvidencePacks, nowMs);
6046
8055
  const exhausted = exhaustedAnswerBudgetDimensions(answer, pack, elapsedMs);
6047
- const unsupportedMarker = citationCoverageMarkerFor(answer.content, pack, nowMs(), deps.correlationId);
6048
- const entailmentMarkers = await entailmentMarkersFor(deps, answer.content, pack, nowMs());
6049
- const groundedPack = {
6050
- ...pack,
8056
+ return {
8057
+ ...observed,
6051
8058
  usage: {
6052
8059
  ...pack.usage,
6053
- modelInputTokens: Math.min(answer.usage.promptTokens, pack.budget.modelInputTokensMax),
6054
- modelOutputTokens: Math.min(answer.usage.completionTokens, pack.budget.modelOutputTokensMax),
8060
+ modelInputTokens: Math.min(pack.usage.modelInputTokens + answer.usage.promptTokens, pack.budget.modelInputTokensMax),
8061
+ modelOutputTokens: Math.min(pack.usage.modelOutputTokens + answer.usage.completionTokens, pack.budget.modelOutputTokensMax),
6055
8062
  elapsedMs: Math.min(Math.max(pack.usage.elapsedMs, elapsedMs), pack.budget.elapsedMsMax ?? Number.POSITIVE_INFINITY),
6056
8063
  },
6057
8064
  uncertainty: [
6058
- ...pack.uncertainty,
6059
- ...(exhausted.length === 0 ? [] : [answerBudgetClipped(exhausted, nowMs())]),
6060
- ...(unsupportedMarker === undefined ? [] : [unsupportedMarker]),
6061
- ...(answer.finishReason === "length" ? [incompleteAnswerMarker(nowMs())] : []),
6062
- ...entailmentMarkers,
8065
+ ...answerApplicableUncertainty(observed.uncertainty, answer),
8066
+ ...(answer.noEvidence === true && !isGroundedAssessmentOnly(answer.content)
8067
+ ? [noEvidenceMarker(nowMs)]
8068
+ : []),
8069
+ ...(exhausted.length === 0 ? [] : [answerBudgetClipped(exhausted, nowMs)]),
8070
+ ...(answer.finishReason === "length" ? [incompleteAnswerMarker(nowMs)] : []),
8071
+ ...markers,
6063
8072
  ],
6064
8073
  };
8074
+ }
8075
+ function answerApplicableUncertainty(markers, answer) {
8076
+ if (!isGroundedAssessmentOnly(answer.content))
8077
+ return markers;
8078
+ return markers.filter((marker) => marker.kind !== "no-evidence" && marker.kind !== "low-confidence-selection");
8079
+ }
8080
+ /** Plural callers reuse the exact retrieval identity of each actual folder pack. */
8081
+ export function logGroundedAnswerForPack(pack, answer, repairDisposition, correlationId, failure, ownAssessmentPolicy) {
8082
+ const identity = connectedContextActivityIdentity({
8083
+ scope: pack.scope,
8084
+ query: pack.query,
8085
+ workspaceRoot: pack.scope.workspaceRoot,
8086
+ });
8087
+ logAcceptedGroundedAssessment(answer, ownAssessmentPolicy, correlationId, identity);
8088
+ logGroundedAnswerActivity(correlationId, {
8089
+ ...identity,
8090
+ answer,
8091
+ repairDisposition,
8092
+ failure,
8093
+ followUp: {
8094
+ passCount: 0,
8095
+ admittedPathCount: 0,
8096
+ trigger: "none",
8097
+ outcome: "not-needed",
8098
+ firstDeclarations: [],
8099
+ },
8100
+ });
8101
+ }
8102
+ function logAcceptedGroundedAssessment(answer, policy, correlationId, identity) {
8103
+ if (policy === undefined)
8104
+ return;
8105
+ const { grounded, assessment, neutralized } = splitOwnAssessmentForPolicy(answer.content, policy);
8106
+ logAnswerAssessment({ policy, sourceBacked: grounded, assessment, neutralized }, correlationId, {
8107
+ ...identity,
8108
+ phase: "accepted-final",
8109
+ });
8110
+ }
8111
+ async function refinedGroundedAnswer(input, deps, pack, start, nowMs, declarationScopeIndexFor, conversationOnly = false) {
8112
+ const deadlineAtMs = explorationDeadlineAtMs(start, pack.budget);
8113
+ const initial = await groundedAnswerForPack(input, deps, pack, declarationScopeIndexFor, deadlineAtMs, undefined, conversationOnly);
8114
+ if (initial.answerKind === "insufficiency")
8115
+ citationCoverageMarkerFor(initial.content, singleSentEvidencePack(initial, pack), nowMs(), deps.correlationId, citationObservation(input, initial));
8116
+ const followUp = await followUpAnswerForPack(input, deps, pack, initial, deadlineAtMs, nowMs);
8117
+ const repairContext = {
8118
+ answer: followUp.answer,
8119
+ pack: followUp.pack,
8120
+ deps,
8121
+ nowMs,
8122
+ question: input.answerQuestion ?? input.query.text,
8123
+ deadlineAtMs,
8124
+ };
8125
+ const repair = followUp.observation.passCount === 1
8126
+ ? { answer: followUp.answer, disposition: "not-needed" }
8127
+ : await repairGroundedAnswer(repairContext);
8128
+ return {
8129
+ ...repair,
8130
+ ...(followUp.failure === undefined ? {} : { failure: followUp.failure }),
8131
+ pack: followUp.pack,
8132
+ followUp: followUp.observation,
8133
+ answer: observeGroundedCitationBehaviour({ ...repairContext, answer: repair.answer }),
8134
+ };
8135
+ }
8136
+ function followUpAnswerForPack(input, deps, pack, initial, deadlineAtMs, nowMs) {
8137
+ return followUpGroundedAnswer({
8138
+ input,
8139
+ deps,
8140
+ pack,
8141
+ initial,
8142
+ deadlineAtMs,
8143
+ nowMs,
8144
+ retrieve: (next) => retrieveConnectedContextPack(next, deps),
8145
+ answer: (next, retrieved, requiredEvidencePaths) => groundedAnswerForPack(next, deps, retrieved.pack, retrieved.declarationScopeIndexFor, deadlineAtMs, requiredEvidencePaths),
8146
+ });
8147
+ }
8148
+ async function answerWithAvailableContext(input, deps, pack, plan, start, nowMs, declarationScopeIndexFor) {
8149
+ const repair = await refinedGroundedAnswer(input, deps, pack, start, nowMs, declarationScopeIndexFor, plan?.targetDecision?.conversationOnly === true);
8150
+ const answer = {
8151
+ ...repair.answer,
8152
+ noEvidence: !packHasUsableEvidence(singleSentEvidencePack(repair.answer, repair.pack)),
8153
+ };
8154
+ logAcceptedGroundedAssessment(answer, deps.ownAssessmentPolicy, deps.correlationId, connectedContextActivityIdentity(input));
8155
+ logGroundedAnswerActivity(deps.correlationId, {
8156
+ ...connectedContextActivityIdentity(input),
8157
+ answer,
8158
+ followUp: repair.followUp,
8159
+ repairDisposition: repair.disposition,
8160
+ configuration: deps.followUpConfigurationDisposition,
8161
+ failure: repair.failure,
8162
+ });
8163
+ const elapsedMs = Math.max(0, nowMs() - start);
8164
+ const markers = await refinementMarkers(input, deps, repair, nowMs);
6065
8165
  return {
6066
- pack: groundedPack,
8166
+ pack: answeredContextPack(repair.pack, answer, elapsedMs, markers, nowMs()),
6067
8167
  assistantContent: answer.content,
6068
8168
  elapsedMs,
6069
- modelInvoked: true,
6070
- ...(answer.promptContext === undefined ? {} : { promptContext: answer.promptContext }),
8169
+ modelInvoked: answer.modelInvoked ?? true,
8170
+ ...answerEvidenceFields(answer),
8171
+ citationRepairDisposition: repair.disposition,
8172
+ followUp: repair.followUp,
6071
8173
  ...(plan === undefined ? {} : { plan }),
6072
- ...(!sourceEvidenceAvailable ? { noEvidence: true } : {}),
6073
8174
  };
6074
8175
  }
8176
+ async function refinementMarkers(input, deps, repair, nowMs) {
8177
+ const answer = repair.answer;
8178
+ const sentPack = singleSentEvidencePack(answer, repair.pack);
8179
+ const unsupportedMarker = citationCoverageMarkerFor(answer.content, sentPack, nowMs(), deps.correlationId, {
8180
+ ...citationObservation(input, answer),
8181
+ followUpPass: repair.followUp.passCount,
8182
+ citationRepairDisposition: repair.disposition,
8183
+ });
8184
+ const entailmentMarkers = answer.modelInvoked === false
8185
+ ? []
8186
+ : await entailmentMarkersFor(deps, answer.content, sentPack, nowMs());
8187
+ return [...(unsupportedMarker === undefined ? [] : [unsupportedMarker]), ...entailmentMarkers];
8188
+ }
6075
8189
  export async function runGroundedExploration(input, deps) {
6076
8190
  // AC5 (#532): the single-source path measures its OWN total wall time (retrieval + answer) so the
6077
8191
  // observable elapsedMs is byte-identical to before this split. The retrieval-only elapsed returned
6078
8192
  // by retrieveConnectedContextPack is deliberately discarded here.
6079
8193
  const nowMs = deps.nowMs ?? Date.now;
6080
8194
  const start = nowMs();
6081
- const { pack, plan } = await retrieveConnectedContextPack(input, deps);
8195
+ const requestDeps = {
8196
+ ...deps,
8197
+ worktreeRecencySnapshot: deps.worktreeRecencySnapshot ?? createWorktreeRecencySnapshot(),
8198
+ };
8199
+ const { pack, plan, declarationScopeIndexFor } = await retrieveConnectedContextPack(input, requestDeps);
6082
8200
  // GEN-AI-GROUNDING-002/-003 (RB-4): abstain BEFORE the model call when the assembled pack carries
6083
8201
  // no usable evidence. The local-knowledge and hybrid paths already short-circuit here; the folder
6084
8202
  // path must too, so the model is never asked to answer confidently over zero evidence and no
6085
8203
  // hallucinated answer is persisted as grounded. The `no-evidence` uncertainty marker is already on
6086
8204
  // the pack (assemblePackFromReads adds it when excerpts are empty).
6087
8205
  const sourceEvidenceAvailable = packHasUsableEvidence(pack);
6088
- if (!sourceEvidenceAvailable && input.answerOnlyContextAvailable !== true) {
8206
+ if (!sourceEvidenceAvailable &&
8207
+ input.answerOnlyContextAvailable !== true &&
8208
+ deps.ownAssessmentPolicy !== "allowed") {
6089
8209
  const elapsedMs = Math.max(0, nowMs() - start);
6090
8210
  return {
6091
8211
  pack,
@@ -6095,8 +8215,130 @@ export async function runGroundedExploration(input, deps) {
6095
8215
  noEvidence: true,
6096
8216
  };
6097
8217
  }
6098
- return answerWithAvailableContext(input, deps, pack, plan, sourceEvidenceAvailable, start, nowMs);
8218
+ return answerWithAvailableContext(input, requestDeps, pack, plan, start, nowMs, declarationScopeIndexFor);
6099
8219
  }
6100
8220
  // Re-export DEFAULT_SEARCH_LIMITS for parity with #179 callers that import limits via the
6101
8221
  // orchestrator. Keeps `grounded-qa.ts` from needing a second workspace import path.
6102
8222
  export { DEFAULT_SEARCH_LIMITS };
8223
+ function answerEvidenceFields(answer) {
8224
+ return {
8225
+ ...(answer.citationBehaviour === undefined
8226
+ ? {}
8227
+ : { citationBehaviour: answer.citationBehaviour }),
8228
+ ...(answer.promptContext === undefined ? {} : { promptContext: answer.promptContext }),
8229
+ ...(answer.noEvidence === true ? { noEvidence: true } : {}),
8230
+ ...(answer.answerKind === undefined ? {} : { answerKind: answer.answerKind }),
8231
+ ...(answer.insufficiencyDeclarations === undefined
8232
+ ? {}
8233
+ : { insufficiencyDeclarations: answer.insufficiencyDeclarations }),
8234
+ ...(answer.insufficiencyObservation === undefined
8235
+ ? {}
8236
+ : { insufficiencyObservation: answer.insufficiencyObservation }),
8237
+ ...(answer.sentEvidencePacks === undefined
8238
+ ? {}
8239
+ : { sentEvidencePacks: answer.sentEvidencePacks }),
8240
+ ...(answer.filesInPrompt === undefined ? {} : { filesInPrompt: answer.filesInPrompt }),
8241
+ ...(answer.completedSynthesisCallCount === undefined
8242
+ ? {}
8243
+ : { completedSynthesisCallCount: answer.completedSynthesisCallCount }),
8244
+ };
8245
+ }
8246
+ function citationObservation(input, answer) {
8247
+ const identity = connectedContextActivityIdentity(input);
8248
+ const observation = answer.insufficiencyObservation;
8249
+ return {
8250
+ scopeIdentitySha256: identity.scopeIdentitySha256,
8251
+ queryIdentitySha256: identity.queryIdentitySha256,
8252
+ answerKind: answer.answerKind,
8253
+ followUpPass: 0,
8254
+ insufficiencyDeclaredCount: observation?.declaredCount ?? 0,
8255
+ declaredInScopeCount: observation?.inScopeCount ?? 0,
8256
+ declaredUnreadInScopeCount: observation?.unreadInScopeCount ?? 0,
8257
+ declaredNotInScopeCount: observation?.notInScopeCount ?? 0,
8258
+ };
8259
+ }
8260
+ async function withLiveWorktreeRecency(input, deps, plan, runtime, context) {
8261
+ const startedAtMs = runtime.nowMs();
8262
+ const observe = deps.worktreeRecencySnapshot ?? observeWorktreeRecency;
8263
+ const worktreeRecency = await observe({
8264
+ scope: input.scope,
8265
+ searchScope: context.searchScope,
8266
+ workspaceKind: context.hasGitMetadata ? "git-repository" : "directory",
8267
+ fs: runtime.fs,
8268
+ nowMs: runtime.nowMs,
8269
+ deadlineAtMs: context.deadlineAtMs,
8270
+ observationAllowed: plan.budget.searchCallsMax > 0,
8271
+ signal: deps.signal,
8272
+ gitRunner: deps.worktreeGitRunner,
8273
+ // Activity setup already captured this port safely. Re-reading a hostile dependency getter
8274
+ // would turn a recorded logging failure into a retrieval failure.
8275
+ activityLog: runtime.activity.sink,
8276
+ diagnostics: deps.diagnostics,
8277
+ correlationId: deps.correlationId,
8278
+ });
8279
+ return {
8280
+ ...context,
8281
+ worktreeRecency,
8282
+ worktreeStatusDurationMs: Math.max(0, Math.floor(runtime.nowMs() - startedAtMs)),
8283
+ };
8284
+ }
8285
+ function worktreeActivityExtra(status) {
8286
+ const recency = status.worktreeRecency;
8287
+ if (recency === undefined)
8288
+ return {};
8289
+ return {
8290
+ worktreeStatusDisposition: recency.observation.worktreeStatusDisposition,
8291
+ worktreeStatusDurationMs: status.worktreeStatusDurationMs ?? 0,
8292
+ recentPathHintCount: recency.paths.length,
8293
+ recentPathHitCount: status.recentPathHitCount ?? 0,
8294
+ worktreeObservedFileCount: recency.observation.worktreeObservedFileCount,
8295
+ worktreeDeletedFileCount: recency.observation.worktreeDeletedFileCount,
8296
+ };
8297
+ }
8298
+ function liveWorktreeCompletion(context, pack) {
8299
+ const paths = new Set(context.worktreeRecency?.paths.map((path) => path.path));
8300
+ return {
8301
+ worktreeRecency: context.worktreeRecency,
8302
+ worktreeStatusDurationMs: context.worktreeStatusDurationMs,
8303
+ recentPathHitCount: pack.files.filter((file) => paths.has(file.scopePath)).length,
8304
+ };
8305
+ }
8306
+ function semanticProviderResolver(inputs, grant) {
8307
+ let resolved = false;
8308
+ let provider;
8309
+ return () => {
8310
+ if (!resolved) {
8311
+ provider =
8312
+ inputs.repoSemanticSearchProviderFor === undefined
8313
+ ? inputs.repoSemanticSearchProvider
8314
+ : inputs.repoSemanticSearchProviderFor(grant);
8315
+ resolved = true;
8316
+ }
8317
+ return provider;
8318
+ };
8319
+ }
8320
+ function groundedSemanticProviderFactory(deps, runtime, context) {
8321
+ const factory = deps.repoSemanticSearchProviderFor;
8322
+ if (factory === undefined)
8323
+ return undefined;
8324
+ return (tryReserveRefreshUsage) => {
8325
+ const request = {
8326
+ fs: context.ringFs,
8327
+ nowMs: runtime.nowMs,
8328
+ deadlineAtMs: context.deadlineAtMs,
8329
+ signal: deps.signal,
8330
+ correlationId: deps.correlationId,
8331
+ tryReserveRefreshUsage,
8332
+ observeSemanticFreshness: (observation) => {
8333
+ runtime.progress.semanticFreshness ??= [];
8334
+ runtime.progress.semanticFreshness.push(observation);
8335
+ },
8336
+ };
8337
+ return factory(request);
8338
+ };
8339
+ }
8340
+ function semanticProviderUnavailable(inputs) {
8341
+ return (semanticProviderAllowed(inputs) ||
8342
+ (inputs.repoSemanticSearchProvider === undefined &&
8343
+ inputs.repoSemanticSearchProviderFor === undefined));
8344
+ }