@remnic/core 10.0.165 → 10.0.167

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 (430) hide show
  1. package/dist/access-admin-ops-surface.js +129 -128
  2. package/dist/access-authorization-probe.js +4 -4
  3. package/dist/access-boundary.js +3 -3
  4. package/dist/access-cli.d.ts.map +1 -1
  5. package/dist/access-cli.js +145 -138
  6. package/dist/access-cli.js.map +1 -1
  7. package/dist/access-coding-context-resolution.d.ts +37 -0
  8. package/dist/access-coding-context-resolution.d.ts.map +1 -1
  9. package/dist/access-coding-context-resolution.js +48 -4
  10. package/dist/access-errors.d.ts +5 -0
  11. package/dist/access-errors.d.ts.map +1 -1
  12. package/dist/access-errors.js +3 -1
  13. package/dist/access-extraction-force-flush-preempt.js +129 -128
  14. package/dist/access-extraction-force-flush.js +129 -128
  15. package/dist/access-http-briefing.js +129 -128
  16. package/dist/access-http-query.js +129 -128
  17. package/dist/access-http.d.ts.map +1 -1
  18. package/dist/access-http.js +129 -128
  19. package/dist/access-identity-continuity-surface.js +129 -128
  20. package/dist/access-lcm-surface.js +129 -128
  21. package/dist/access-mcp.js +129 -128
  22. package/dist/access-memory-search-fanout.js +2 -2
  23. package/dist/access-namespace-preflight.js +4 -4
  24. package/dist/access-observe-transcript.js +3 -2
  25. package/dist/access-observe-write-category.js +9 -9
  26. package/dist/access-observe-write-surface.d.ts +1 -0
  27. package/dist/access-observe-write-surface.d.ts.map +1 -1
  28. package/dist/access-observe-write-surface.js +129 -128
  29. package/dist/access-offline-manifest.js +9 -8
  30. package/dist/access-operations-batch.js +129 -128
  31. package/dist/access-operations.d.ts +1 -1
  32. package/dist/access-operations.js +129 -128
  33. package/dist/access-recall-concurrency.d.ts +3 -16
  34. package/dist/access-recall-concurrency.d.ts.map +1 -1
  35. package/dist/access-recall-concurrency.js +129 -128
  36. package/dist/access-recall-corpus-versions.d.ts +4 -1
  37. package/dist/access-recall-corpus-versions.d.ts.map +1 -1
  38. package/dist/access-recall-corpus-versions.js +4 -1
  39. package/dist/access-recall-diagnostics.js +3 -3
  40. package/dist/access-recall-response.d.ts.map +1 -1
  41. package/dist/access-recall-response.js +129 -128
  42. package/dist/access-recall-surface.d.ts +1 -0
  43. package/dist/access-recall-surface.d.ts.map +1 -1
  44. package/dist/access-recall-surface.js +129 -128
  45. package/dist/access-schema.d.ts +1 -0
  46. package/dist/access-schema.d.ts.map +1 -1
  47. package/dist/access-schema.js +2 -2
  48. package/dist/access-service.d.ts +3 -15
  49. package/dist/access-service.d.ts.map +1 -1
  50. package/dist/access-service.js +131 -128
  51. package/dist/access-surface-catalog.js +5 -5
  52. package/dist/access-token-capabilities.js +2 -2
  53. package/dist/active-recall.js +21 -21
  54. package/dist/artifact-search.js +2 -2
  55. package/dist/auto-sync-L3M4RKJD.js +1 -1
  56. package/dist/briefing.js +19 -19
  57. package/dist/buffer-add-turns-bounded.js +2 -2
  58. package/dist/buffer-turn-helpers.d.ts.map +1 -1
  59. package/dist/buffer-turn-helpers.js +1 -1
  60. package/dist/buffer.js +11 -10
  61. package/dist/calibration.js +2 -2
  62. package/dist/capsule-import-gate.js +2 -2
  63. package/dist/causal-consolidation.js +20 -20
  64. package/dist/{chunk-5V3IBSVB.js → chunk-22V3CMIW.js} +4 -4
  65. package/dist/{chunk-7IWRLYFJ.js → chunk-2TJSGIKT.js} +2 -2
  66. package/dist/{chunk-V6M6N3EE.js → chunk-333SBFXB.js} +2 -2
  67. package/dist/{chunk-XBW7U7GM.js → chunk-3PNJZTDV.js} +5 -2
  68. package/dist/chunk-3PNJZTDV.js.map +1 -0
  69. package/dist/{chunk-XE4UYWW3.js → chunk-3YOX2BQD.js} +3 -3
  70. package/dist/{chunk-XEBNSY7N.js → chunk-4D2EY4WM.js} +2 -2
  71. package/dist/{chunk-5HFCXTGY.js → chunk-4D77BI3J.js} +29 -189
  72. package/dist/chunk-4D77BI3J.js.map +1 -0
  73. package/dist/{chunk-LPV72KRQ.js → chunk-4IMOGAFF.js} +3 -3
  74. package/dist/{chunk-QBREZ4QL.js → chunk-4L25GAYL.js} +2 -2
  75. package/dist/{chunk-HADD45AR.js → chunk-4WCLZBM2.js} +2 -2
  76. package/dist/{chunk-B3GKQ6DU.js → chunk-5MA6ZQ4Z.js} +2 -2
  77. package/dist/{chunk-V4ASAWRP.js → chunk-5PUZV73Z.js} +3 -3
  78. package/dist/{chunk-3QLAOYBL.js → chunk-5QDTZIGH.js} +3 -3
  79. package/dist/{chunk-WXDTOE6F.js → chunk-5VMRM2X3.js} +2 -2
  80. package/dist/{chunk-VE23DIBH.js → chunk-6QWFZ3X5.js} +2 -2
  81. package/dist/{chunk-SDGD6MYV.js → chunk-7F7HRJI2.js} +2 -2
  82. package/dist/{chunk-QFPNWSVH.js → chunk-7OCKK5M5.js} +6 -6
  83. package/dist/{chunk-WAJL65KW.js → chunk-7VIJUZYW.js} +3 -3
  84. package/dist/{chunk-EI2M2CFJ.js → chunk-A5UOREWD.js} +3 -3
  85. package/dist/{chunk-32CA7B6L.js → chunk-AQZL7JBZ.js} +2 -2
  86. package/dist/{chunk-EDA6CDBT.js → chunk-AVWOULJH.js} +2 -2
  87. package/dist/{chunk-4HKK5HUI.js → chunk-B3M56D2A.js} +2 -2
  88. package/dist/{chunk-YAVIBVCU.js → chunk-BFPQJNFZ.js} +5 -5
  89. package/dist/{chunk-YAVIBVCU.js.map → chunk-BFPQJNFZ.js.map} +1 -1
  90. package/dist/{chunk-SRN5M4LQ.js → chunk-BKTCVXMK.js} +4 -4
  91. package/dist/{chunk-TXVTNDQT.js → chunk-BPCR5DZP.js} +2 -2
  92. package/dist/{chunk-6S4DM53Y.js → chunk-C5QYWM6F.js} +6 -6
  93. package/dist/chunk-CKELO7Q6.js +113 -0
  94. package/dist/chunk-CKELO7Q6.js.map +1 -0
  95. package/dist/{chunk-IEB6XYW6.js → chunk-CKZWLAHN.js} +2 -2
  96. package/dist/{chunk-JVIWVJ2A.js → chunk-CUPILBIP.js} +3 -3
  97. package/dist/{chunk-274UY54Z.js → chunk-DFZYZOLH.js} +3 -3
  98. package/dist/{chunk-FSI45NUK.js → chunk-EZG54YDS.js} +2 -2
  99. package/dist/{chunk-7ZFB4VZS.js → chunk-FFWFFAP3.js} +2 -2
  100. package/dist/{chunk-22VXXA67.js → chunk-FGT7CUYZ.js} +2 -2
  101. package/dist/{chunk-Z3SXC3MP.js → chunk-FOTFLHBN.js} +2 -2
  102. package/dist/{chunk-RH6XWXMA.js → chunk-FRYCXXTB.js} +3 -3
  103. package/dist/{chunk-B377OKUP.js → chunk-G64WYD2S.js} +4 -4
  104. package/dist/{chunk-JJEQRSYU.js → chunk-GBSXTTLP.js} +2 -2
  105. package/dist/{chunk-2YODOG2O.js → chunk-GIL2M2OI.js} +3 -3
  106. package/dist/{chunk-YVRQ5JRA.js → chunk-GYOKVJPB.js} +14 -8
  107. package/dist/chunk-GYOKVJPB.js.map +1 -0
  108. package/dist/{chunk-ARJ3KCX4.js → chunk-HDLNSDLK.js} +2 -2
  109. package/dist/{chunk-VXUO5JZC.js → chunk-HDWISXFH.js} +6 -6
  110. package/dist/{chunk-RNFMFC37.js → chunk-IDYYGOOQ.js} +28 -1
  111. package/dist/chunk-IDYYGOOQ.js.map +1 -0
  112. package/dist/{chunk-IHOKB3L3.js → chunk-IE2ZLO3R.js} +785 -515
  113. package/dist/chunk-IE2ZLO3R.js.map +1 -0
  114. package/dist/{chunk-EZ47HOJ6.js → chunk-IXI6S2VJ.js} +4 -4
  115. package/dist/{chunk-VXMWTRQX.js → chunk-J74YOBB3.js} +4 -4
  116. package/dist/{chunk-AMW3IDCO.js → chunk-JFMMEHVG.js} +2 -2
  117. package/dist/{chunk-XKZBZOKV.js → chunk-JIF22AXI.js} +18 -1
  118. package/dist/chunk-JIF22AXI.js.map +1 -0
  119. package/dist/{chunk-JTSSSR4L.js → chunk-KIUFT2WZ.js} +3 -3
  120. package/dist/{chunk-L6BLTV4D.js → chunk-L7SEYUHS.js} +2 -2
  121. package/dist/{chunk-WRAK5LLB.js → chunk-LPUEBFX2.js} +3 -3
  122. package/dist/{chunk-DBVSU3HE.js → chunk-LVGTH6IQ.js} +9 -9
  123. package/dist/{chunk-33VVVP57.js → chunk-MEVBSF6T.js} +4 -1
  124. package/dist/chunk-MEVBSF6T.js.map +1 -0
  125. package/dist/{chunk-CJCTKL6Y.js → chunk-MGKCKY7X.js} +4 -1
  126. package/dist/chunk-MGKCKY7X.js.map +1 -0
  127. package/dist/{chunk-SOGOHLWN.js → chunk-N7AIFTSH.js} +1 -1
  128. package/dist/chunk-N7AIFTSH.js.map +1 -0
  129. package/dist/chunk-O3XGASU5.js +197 -0
  130. package/dist/chunk-O3XGASU5.js.map +1 -0
  131. package/dist/{chunk-OGBQMY46.js → chunk-O544TUJO.js} +2 -2
  132. package/dist/{chunk-TFNZXOXK.js → chunk-OAQRZ4SV.js} +2 -2
  133. package/dist/{chunk-IEEV27BC.js → chunk-OO2HEUZ4.js} +2 -2
  134. package/dist/{chunk-YMC4AYJK.js → chunk-OWM2VWNX.js} +10 -10
  135. package/dist/{chunk-4LPTSB5V.js → chunk-PFLN6TTW.js} +2 -2
  136. package/dist/{chunk-YOR5QBEU.js → chunk-QFTK6EDM.js} +4 -4
  137. package/dist/{chunk-A2WFUMUN.js → chunk-QKDXO4FD.js} +4 -4
  138. package/dist/{chunk-Y7HLGKKU.js → chunk-QLQUAVVP.js} +4 -4
  139. package/dist/{chunk-MUMQWCE2.js → chunk-QPFM6DHY.js} +2 -2
  140. package/dist/{chunk-YWPCDR3I.js → chunk-QVXEXGIM.js} +3 -3
  141. package/dist/{chunk-UPE7TJWN.js → chunk-QWWHYBPT.js} +2 -2
  142. package/dist/{chunk-NZHZQGLB.js → chunk-QXTKN25V.js} +2 -2
  143. package/dist/{chunk-OAGTKS73.js → chunk-RFLC6PKQ.js} +2 -2
  144. package/dist/{chunk-ZRLTQ2Y7.js → chunk-RO5EGRAI.js} +2 -2
  145. package/dist/{chunk-5D4NBANY.js → chunk-SIONKXLU.js} +2 -2
  146. package/dist/{chunk-6XTUZKCZ.js → chunk-SMDZTJ2D.js} +2 -2
  147. package/dist/{chunk-OFSAKEZB.js → chunk-T4BT4FQN.js} +2 -2
  148. package/dist/{chunk-IC35ZYLM.js → chunk-TAD6QMMD.js} +4 -4
  149. package/dist/{chunk-EAHNSQ7H.js → chunk-TB6VFEHQ.js} +2 -2
  150. package/dist/{chunk-6ARSFTLD.js → chunk-TNRGWJYT.js} +2 -2
  151. package/dist/{chunk-6TPWIPE3.js → chunk-U3BCW7GX.js} +3 -3
  152. package/dist/{chunk-JCAMHTS2.js → chunk-UBG65KEY.js} +7 -5
  153. package/dist/{chunk-JCAMHTS2.js.map → chunk-UBG65KEY.js.map} +1 -1
  154. package/dist/{chunk-CGOPDXLK.js → chunk-UMEUU66X.js} +2 -2
  155. package/dist/{chunk-5LTXYM7D.js → chunk-UYIBNDQE.js} +2 -2
  156. package/dist/{chunk-UGQEJWR3.js → chunk-VHXRLD6S.js} +2 -2
  157. package/dist/{chunk-WJ6S54ES.js → chunk-VOLTQNAP.js} +2 -2
  158. package/dist/{chunk-SBU5GDOT.js → chunk-VRHY7Y5A.js} +7 -7
  159. package/dist/{chunk-E5RJPLNL.js → chunk-W7N7NWG5.js} +3 -3
  160. package/dist/{chunk-UPWOMMVU.js → chunk-WECKZ3KT.js} +7 -7
  161. package/dist/{chunk-PCUDFWX5.js → chunk-WEFFO2MJ.js} +2 -2
  162. package/dist/{chunk-QCP75JGO.js → chunk-WQUGCOKF.js} +5 -5
  163. package/dist/{chunk-FKBGK3NC.js → chunk-WWUQ6CP3.js} +2 -2
  164. package/dist/{chunk-KR6PEAM4.js → chunk-X67XNZ64.js} +8 -8
  165. package/dist/{chunk-UYHDMCY2.js → chunk-XUVCQ4YZ.js} +2 -2
  166. package/dist/{chunk-7IJ2H43M.js → chunk-YY57TRKN.js} +2 -2
  167. package/dist/{chunk-AU6AEUFD.js → chunk-YYXYZM2I.js} +2 -2
  168. package/dist/{chunk-3FBAEPCU.js → chunk-ZDUE44CC.js} +2 -2
  169. package/dist/{chunk-PRE7R3RQ.js → chunk-ZQUOUPP3.js} +12 -3
  170. package/dist/chunk-ZQUOUPP3.js.map +1 -0
  171. package/dist/{chunk-RDO6AMDL.js → chunk-ZWDDY4WF.js} +2 -2
  172. package/dist/{chunk-QASTQVGK.js → chunk-ZX546Y3Y.js} +2 -2
  173. package/dist/chunk-ZX546Y3Y.js.map +1 -0
  174. package/dist/cli.js +129 -128
  175. package/dist/coding/architecture-surfaces.d.ts +0 -24
  176. package/dist/coding/architecture-surfaces.d.ts.map +1 -1
  177. package/dist/coding/codegraph-surfaces.d.ts.map +1 -1
  178. package/dist/coding/export-okf-codegraph.js +51 -24
  179. package/dist/coding/export-okf-codegraph.js.map +1 -1
  180. package/dist/coding/git-context.d.ts +23 -0
  181. package/dist/coding/git-context.d.ts.map +1 -1
  182. package/dist/coding/git-context.js +31 -0
  183. package/dist/coding/git-context.js.map +1 -0
  184. package/dist/coding/session-delta-surfaces.d.ts +0 -23
  185. package/dist/coding/session-delta-surfaces.d.ts.map +1 -1
  186. package/dist/compounding/engine.js +20 -20
  187. package/dist/config.js +21 -21
  188. package/dist/connectors/codex-materialize-runner.js +19 -19
  189. package/dist/connectors/droid-mcp.d.ts +4 -3
  190. package/dist/connectors/droid-mcp.d.ts.map +1 -1
  191. package/dist/connectors/index.js +23 -23
  192. package/dist/convergence-refresh.js +21 -21
  193. package/dist/conversation-index/backend.js +2 -2
  194. package/dist/corpus-watermark.js +23 -23
  195. package/dist/deep-recall-config.js +2 -2
  196. package/dist/deep-recall-http-glue.js +4 -4
  197. package/dist/entity-recall-cancellation.js +2 -2
  198. package/dist/entity-recall-reads.js +3 -3
  199. package/dist/entity-retrieval.js +21 -21
  200. package/dist/explicit-capture.js +129 -128
  201. package/dist/external-wiki-access.js +4 -4
  202. package/dist/extraction-judge.js +1 -1
  203. package/dist/extraction.js +31 -30
  204. package/dist/harmonic-retrieval.js +19 -19
  205. package/dist/index.js +208 -206
  206. package/dist/local-llm.js +2 -2
  207. package/dist/location/index.js +21 -21
  208. package/dist/maintenance/memory-governance.js +19 -19
  209. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +19 -19
  210. package/dist/maintenance/rebuild-memory-projection-runner.js +21 -21
  211. package/dist/maintenance/rebuild-memory-projection.js +20 -20
  212. package/dist/memory-browse-http-glue.js +2 -2
  213. package/dist/memory-browse-operations.js +4 -4
  214. package/dist/memory-browse.js +6 -6
  215. package/dist/memory-controller.d.ts +8 -0
  216. package/dist/memory-controller.d.ts.map +1 -1
  217. package/dist/memory-controller.js +1 -1
  218. package/dist/namespaces/migrate.js +20 -20
  219. package/dist/namespaces/search.js +8 -8
  220. package/dist/namespaces/storage.js +19 -19
  221. package/dist/offline-sync-impression-drain.js +8 -7
  222. package/dist/operator-doctor-corpus.js +26 -26
  223. package/dist/operator-doctor-replica.js +4 -4
  224. package/dist/operator-toolkit.js +35 -34
  225. package/dist/orchestration/backlog-scheduler.js +130 -129
  226. package/dist/orchestration/backlog-scheduler.js.map +1 -1
  227. package/dist/orchestration/buffer-drain-runner.js +130 -129
  228. package/dist/orchestration/episodic-context-section.d.ts +3 -2
  229. package/dist/orchestration/episodic-context-section.d.ts.map +1 -1
  230. package/dist/orchestration/maintenance.js +34 -33
  231. package/dist/orchestration/orchestrator-helpers.d.ts +10 -0
  232. package/dist/orchestration/orchestrator-helpers.d.ts.map +1 -1
  233. package/dist/orchestration/orchestrator-init.d.ts +12 -13
  234. package/dist/orchestration/orchestrator-init.d.ts.map +1 -1
  235. package/dist/orchestration/recall-entry.d.ts.map +1 -1
  236. package/dist/orchestration/recall-internal.d.ts.map +1 -1
  237. package/dist/orchestration/session-context.d.ts +5 -1
  238. package/dist/orchestration/session-context.d.ts.map +1 -1
  239. package/dist/orchestration/startup-search-sync.d.ts +73 -0
  240. package/dist/orchestration/startup-search-sync.d.ts.map +1 -0
  241. package/dist/orchestration/turn-ingestion.d.ts.map +1 -1
  242. package/dist/orchestrator.d.ts +4 -1
  243. package/dist/orchestrator.d.ts.map +1 -1
  244. package/dist/orchestrator.js +129 -128
  245. package/dist/qmd-daemon-session.js +2 -2
  246. package/dist/qmd.js +3 -3
  247. package/dist/recall-explain-renderer.js +3 -3
  248. package/dist/recall-navigate-access.js +2 -2
  249. package/dist/recall-navigate-disclosure.js +2 -2
  250. package/dist/recall-navigate.js +2 -2
  251. package/dist/recall-navigation-http-glue.js +2 -2
  252. package/dist/recall-navigation-operations.js +4 -4
  253. package/dist/recall-navigation.js +129 -128
  254. package/dist/recall-qos.d.ts +26 -0
  255. package/dist/recall-qos.d.ts.map +1 -1
  256. package/dist/recall-qos.js +9 -1
  257. package/dist/recall-state-view-admission.js +6 -6
  258. package/dist/recall-why-service.js +6 -6
  259. package/dist/recall-xray-cli.js +4 -4
  260. package/dist/recall-xray-renderer.js +3 -3
  261. package/dist/recall-xray.js +2 -2
  262. package/dist/relay/mission.d.ts +3 -3
  263. package/dist/replica-divergence.js +3 -3
  264. package/dist/resume-bundles.js +23 -23
  265. package/dist/search/factory.js +7 -7
  266. package/dist/search/index.js +9 -9
  267. package/dist/semantic-consolidation.js +20 -20
  268. package/dist/semantic-rule-promotion.js +19 -19
  269. package/dist/semantic-rule-verifier.js +19 -19
  270. package/dist/source-agent-qualifier.js +29 -28
  271. package/dist/standup/build.js +20 -20
  272. package/dist/storage/buffer-drain-claims.js +2 -2
  273. package/dist/storage/buffer-session-files.js +2 -2
  274. package/dist/storage.js +18 -18
  275. package/dist/summarizer.js +3 -3
  276. package/dist/support-passport/index.js +7 -7
  277. package/dist/tokens.js +3 -3
  278. package/dist/transfer/export-okf.js +19 -19
  279. package/dist/types.d.ts +1 -0
  280. package/dist/types.d.ts.map +1 -1
  281. package/dist/types.js +1 -1
  282. package/dist/verified-recall.js +19 -19
  283. package/dist/who-knows-cli.js +21 -21
  284. package/dist/who-knows.js +20 -20
  285. package/package.json +12 -2
  286. package/src/access-cli.ts +18 -9
  287. package/src/access-coding-context-resolution.ts +138 -0
  288. package/src/access-errors.ts +5 -0
  289. package/src/access-http-admission.test.ts +76 -0
  290. package/src/access-http.test.ts +2 -0
  291. package/src/access-http.ts +4 -0
  292. package/src/access-observe-write-surface.ts +2 -1
  293. package/src/access-operations-batch.ts +2 -2
  294. package/src/access-recall-concurrency.ts +179 -22
  295. package/src/access-recall-corpus-versions.ts +12 -7
  296. package/src/access-recall-response.ts +25 -2
  297. package/src/access-recall-surface.ts +6 -4
  298. package/src/access-schema.ts +9 -0
  299. package/src/access-service-raw-excerpt-read-gate.test.ts +7 -2
  300. package/src/access-service-recall-concurrency.test.ts +242 -0
  301. package/src/access-service-set-coding-context.test.ts +210 -0
  302. package/src/access-service.ts +43 -58
  303. package/src/buffer-turn-helpers.ts +3 -0
  304. package/src/capsule-import-gate.test.ts +106 -0
  305. package/src/coding/access-coding-context.test.ts +3 -0
  306. package/src/coding/architecture-surfaces.ts +2 -1
  307. package/src/coding/codegraph-surfaces.test.ts +34 -0
  308. package/src/coding/codegraph-surfaces.ts +3 -2
  309. package/src/coding/git-context.test.ts +29 -0
  310. package/src/coding/git-context.ts +63 -2
  311. package/src/coding/session-delta-surfaces.ts +2 -1
  312. package/src/connectors/droid-mcp.test.ts +46 -0
  313. package/src/connectors/droid-mcp.ts +5 -5
  314. package/src/harmonic-graph-version.test.ts +63 -0
  315. package/src/memory-controller.test.ts +38 -0
  316. package/src/memory-controller.ts +25 -2
  317. package/src/orchestration/episodic-context-section.ts +6 -7
  318. package/src/orchestration/orchestrator-helpers.ts +10 -0
  319. package/src/orchestration/orchestrator-init.ts +57 -303
  320. package/src/orchestration/recall-entry.ts +59 -4
  321. package/src/orchestration/recall-internal.ts +10 -10
  322. package/src/orchestration/session-context.ts +11 -1
  323. package/src/orchestration/startup-search-sync.ts +492 -0
  324. package/src/orchestration/task-exit.test.ts +45 -0
  325. package/src/orchestration/turn-ingestion-buffered.test.ts +224 -0
  326. package/src/orchestration/turn-ingestion.ts +28 -35
  327. package/src/orchestrator-flush.test.ts +7 -7
  328. package/src/orchestrator-init.test.ts +364 -12
  329. package/src/orchestrator-source-attribution.test.ts +100 -0
  330. package/src/orchestrator-startup-ready-path.test.ts +133 -10
  331. package/src/orchestrator.ts +16 -1
  332. package/src/recall-qos.test.ts +62 -0
  333. package/src/recall-qos.ts +75 -0
  334. package/src/recall-retrieval-failure.test.ts +282 -18
  335. package/src/recall-search-options.test.ts +13 -1
  336. package/src/storage/buffer-drain-handin-memo.test.ts +140 -0
  337. package/src/types.ts +1 -1
  338. package/dist/chunk-33VVVP57.js.map +0 -1
  339. package/dist/chunk-3QNFHI6T.js +0 -38
  340. package/dist/chunk-3QNFHI6T.js.map +0 -1
  341. package/dist/chunk-5HFCXTGY.js.map +0 -1
  342. package/dist/chunk-CJCTKL6Y.js.map +0 -1
  343. package/dist/chunk-IHOKB3L3.js.map +0 -1
  344. package/dist/chunk-PRE7R3RQ.js.map +0 -1
  345. package/dist/chunk-QASTQVGK.js.map +0 -1
  346. package/dist/chunk-RNFMFC37.js.map +0 -1
  347. package/dist/chunk-SOGOHLWN.js.map +0 -1
  348. package/dist/chunk-XBW7U7GM.js.map +0 -1
  349. package/dist/chunk-XKZBZOKV.js.map +0 -1
  350. package/dist/chunk-YVRQ5JRA.js.map +0 -1
  351. /package/dist/{chunk-5V3IBSVB.js.map → chunk-22V3CMIW.js.map} +0 -0
  352. /package/dist/{chunk-7IWRLYFJ.js.map → chunk-2TJSGIKT.js.map} +0 -0
  353. /package/dist/{chunk-V6M6N3EE.js.map → chunk-333SBFXB.js.map} +0 -0
  354. /package/dist/{chunk-XE4UYWW3.js.map → chunk-3YOX2BQD.js.map} +0 -0
  355. /package/dist/{chunk-XEBNSY7N.js.map → chunk-4D2EY4WM.js.map} +0 -0
  356. /package/dist/{chunk-LPV72KRQ.js.map → chunk-4IMOGAFF.js.map} +0 -0
  357. /package/dist/{chunk-QBREZ4QL.js.map → chunk-4L25GAYL.js.map} +0 -0
  358. /package/dist/{chunk-HADD45AR.js.map → chunk-4WCLZBM2.js.map} +0 -0
  359. /package/dist/{chunk-B3GKQ6DU.js.map → chunk-5MA6ZQ4Z.js.map} +0 -0
  360. /package/dist/{chunk-V4ASAWRP.js.map → chunk-5PUZV73Z.js.map} +0 -0
  361. /package/dist/{chunk-3QLAOYBL.js.map → chunk-5QDTZIGH.js.map} +0 -0
  362. /package/dist/{chunk-WXDTOE6F.js.map → chunk-5VMRM2X3.js.map} +0 -0
  363. /package/dist/{chunk-VE23DIBH.js.map → chunk-6QWFZ3X5.js.map} +0 -0
  364. /package/dist/{chunk-SDGD6MYV.js.map → chunk-7F7HRJI2.js.map} +0 -0
  365. /package/dist/{chunk-QFPNWSVH.js.map → chunk-7OCKK5M5.js.map} +0 -0
  366. /package/dist/{chunk-WAJL65KW.js.map → chunk-7VIJUZYW.js.map} +0 -0
  367. /package/dist/{chunk-EI2M2CFJ.js.map → chunk-A5UOREWD.js.map} +0 -0
  368. /package/dist/{chunk-32CA7B6L.js.map → chunk-AQZL7JBZ.js.map} +0 -0
  369. /package/dist/{chunk-EDA6CDBT.js.map → chunk-AVWOULJH.js.map} +0 -0
  370. /package/dist/{chunk-4HKK5HUI.js.map → chunk-B3M56D2A.js.map} +0 -0
  371. /package/dist/{chunk-SRN5M4LQ.js.map → chunk-BKTCVXMK.js.map} +0 -0
  372. /package/dist/{chunk-TXVTNDQT.js.map → chunk-BPCR5DZP.js.map} +0 -0
  373. /package/dist/{chunk-6S4DM53Y.js.map → chunk-C5QYWM6F.js.map} +0 -0
  374. /package/dist/{chunk-IEB6XYW6.js.map → chunk-CKZWLAHN.js.map} +0 -0
  375. /package/dist/{chunk-JVIWVJ2A.js.map → chunk-CUPILBIP.js.map} +0 -0
  376. /package/dist/{chunk-274UY54Z.js.map → chunk-DFZYZOLH.js.map} +0 -0
  377. /package/dist/{chunk-FSI45NUK.js.map → chunk-EZG54YDS.js.map} +0 -0
  378. /package/dist/{chunk-7ZFB4VZS.js.map → chunk-FFWFFAP3.js.map} +0 -0
  379. /package/dist/{chunk-22VXXA67.js.map → chunk-FGT7CUYZ.js.map} +0 -0
  380. /package/dist/{chunk-Z3SXC3MP.js.map → chunk-FOTFLHBN.js.map} +0 -0
  381. /package/dist/{chunk-RH6XWXMA.js.map → chunk-FRYCXXTB.js.map} +0 -0
  382. /package/dist/{chunk-B377OKUP.js.map → chunk-G64WYD2S.js.map} +0 -0
  383. /package/dist/{chunk-JJEQRSYU.js.map → chunk-GBSXTTLP.js.map} +0 -0
  384. /package/dist/{chunk-2YODOG2O.js.map → chunk-GIL2M2OI.js.map} +0 -0
  385. /package/dist/{chunk-ARJ3KCX4.js.map → chunk-HDLNSDLK.js.map} +0 -0
  386. /package/dist/{chunk-VXUO5JZC.js.map → chunk-HDWISXFH.js.map} +0 -0
  387. /package/dist/{chunk-EZ47HOJ6.js.map → chunk-IXI6S2VJ.js.map} +0 -0
  388. /package/dist/{chunk-VXMWTRQX.js.map → chunk-J74YOBB3.js.map} +0 -0
  389. /package/dist/{chunk-AMW3IDCO.js.map → chunk-JFMMEHVG.js.map} +0 -0
  390. /package/dist/{chunk-JTSSSR4L.js.map → chunk-KIUFT2WZ.js.map} +0 -0
  391. /package/dist/{chunk-L6BLTV4D.js.map → chunk-L7SEYUHS.js.map} +0 -0
  392. /package/dist/{chunk-WRAK5LLB.js.map → chunk-LPUEBFX2.js.map} +0 -0
  393. /package/dist/{chunk-DBVSU3HE.js.map → chunk-LVGTH6IQ.js.map} +0 -0
  394. /package/dist/{chunk-OGBQMY46.js.map → chunk-O544TUJO.js.map} +0 -0
  395. /package/dist/{chunk-TFNZXOXK.js.map → chunk-OAQRZ4SV.js.map} +0 -0
  396. /package/dist/{chunk-IEEV27BC.js.map → chunk-OO2HEUZ4.js.map} +0 -0
  397. /package/dist/{chunk-YMC4AYJK.js.map → chunk-OWM2VWNX.js.map} +0 -0
  398. /package/dist/{chunk-4LPTSB5V.js.map → chunk-PFLN6TTW.js.map} +0 -0
  399. /package/dist/{chunk-YOR5QBEU.js.map → chunk-QFTK6EDM.js.map} +0 -0
  400. /package/dist/{chunk-A2WFUMUN.js.map → chunk-QKDXO4FD.js.map} +0 -0
  401. /package/dist/{chunk-Y7HLGKKU.js.map → chunk-QLQUAVVP.js.map} +0 -0
  402. /package/dist/{chunk-MUMQWCE2.js.map → chunk-QPFM6DHY.js.map} +0 -0
  403. /package/dist/{chunk-YWPCDR3I.js.map → chunk-QVXEXGIM.js.map} +0 -0
  404. /package/dist/{chunk-UPE7TJWN.js.map → chunk-QWWHYBPT.js.map} +0 -0
  405. /package/dist/{chunk-NZHZQGLB.js.map → chunk-QXTKN25V.js.map} +0 -0
  406. /package/dist/{chunk-OAGTKS73.js.map → chunk-RFLC6PKQ.js.map} +0 -0
  407. /package/dist/{chunk-ZRLTQ2Y7.js.map → chunk-RO5EGRAI.js.map} +0 -0
  408. /package/dist/{chunk-5D4NBANY.js.map → chunk-SIONKXLU.js.map} +0 -0
  409. /package/dist/{chunk-6XTUZKCZ.js.map → chunk-SMDZTJ2D.js.map} +0 -0
  410. /package/dist/{chunk-OFSAKEZB.js.map → chunk-T4BT4FQN.js.map} +0 -0
  411. /package/dist/{chunk-IC35ZYLM.js.map → chunk-TAD6QMMD.js.map} +0 -0
  412. /package/dist/{chunk-EAHNSQ7H.js.map → chunk-TB6VFEHQ.js.map} +0 -0
  413. /package/dist/{chunk-6ARSFTLD.js.map → chunk-TNRGWJYT.js.map} +0 -0
  414. /package/dist/{chunk-6TPWIPE3.js.map → chunk-U3BCW7GX.js.map} +0 -0
  415. /package/dist/{chunk-CGOPDXLK.js.map → chunk-UMEUU66X.js.map} +0 -0
  416. /package/dist/{chunk-5LTXYM7D.js.map → chunk-UYIBNDQE.js.map} +0 -0
  417. /package/dist/{chunk-UGQEJWR3.js.map → chunk-VHXRLD6S.js.map} +0 -0
  418. /package/dist/{chunk-WJ6S54ES.js.map → chunk-VOLTQNAP.js.map} +0 -0
  419. /package/dist/{chunk-SBU5GDOT.js.map → chunk-VRHY7Y5A.js.map} +0 -0
  420. /package/dist/{chunk-E5RJPLNL.js.map → chunk-W7N7NWG5.js.map} +0 -0
  421. /package/dist/{chunk-UPWOMMVU.js.map → chunk-WECKZ3KT.js.map} +0 -0
  422. /package/dist/{chunk-PCUDFWX5.js.map → chunk-WEFFO2MJ.js.map} +0 -0
  423. /package/dist/{chunk-QCP75JGO.js.map → chunk-WQUGCOKF.js.map} +0 -0
  424. /package/dist/{chunk-FKBGK3NC.js.map → chunk-WWUQ6CP3.js.map} +0 -0
  425. /package/dist/{chunk-KR6PEAM4.js.map → chunk-X67XNZ64.js.map} +0 -0
  426. /package/dist/{chunk-UYHDMCY2.js.map → chunk-XUVCQ4YZ.js.map} +0 -0
  427. /package/dist/{chunk-7IJ2H43M.js.map → chunk-YY57TRKN.js.map} +0 -0
  428. /package/dist/{chunk-AU6AEUFD.js.map → chunk-YYXYZM2I.js.map} +0 -0
  429. /package/dist/{chunk-3FBAEPCU.js.map → chunk-ZDUE44CC.js.map} +0 -0
  430. /package/dist/{chunk-RDO6AMDL.js.map → chunk-ZWDDY4WF.js.map} +0 -0
@@ -0,0 +1,106 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdir, mkdtemp, rm, symlink, writeFile } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import path from "node:path";
5
+ import test from "node:test";
6
+ import { ZodError } from "zod";
7
+
8
+ import { EngramAccessInputError } from "./access-errors.js";
9
+ import { defaultCapsulesDir } from "./capsule-cli.js";
10
+ import { isCapsuleImportArchiveInputError, validateCapsuleImportArchive } from "./capsule-import-gate.js";
11
+
12
+ async function storeFixture(t: test.TestContext): Promise<{ storageDir: string; archivePath: string }> {
13
+ const storageDir = await mkdtemp(path.join(tmpdir(), "remnic-gate-"));
14
+ t.after(() => rm(storageDir, { recursive: true, force: true }));
15
+ const storeDir = defaultCapsulesDir(storageDir);
16
+ await mkdir(storeDir, { recursive: true });
17
+ const archivePath = path.join(storeDir, "capsule.tgz");
18
+ await writeFile(archivePath, "archive-bytes");
19
+ return { storageDir, archivePath };
20
+ }
21
+
22
+ test("capsule import gate: an archive inside the capsule store validates", async (t) => {
23
+ const { storageDir, archivePath } = await storeFixture(t);
24
+ await assert.doesNotReject(validateCapsuleImportArchive(archivePath, storageDir));
25
+ });
26
+
27
+ test("capsule import gate: an archive outside the store is refused with the shared message", async (t) => {
28
+ const { storageDir } = await storeFixture(t);
29
+ const outside = path.join(storageDir, "outside.tgz");
30
+ await writeFile(outside, "bytes");
31
+
32
+ await assert.rejects(
33
+ validateCapsuleImportArchive(outside, storageDir),
34
+ (err: Error) =>
35
+ err instanceof EngramAccessInputError &&
36
+ /existing file inside the namespace capsule store/.test(err.message),
37
+ );
38
+ });
39
+
40
+ test("capsule import gate: a missing path is refused without revealing it is missing", async (t) => {
41
+ const { storageDir } = await storeFixture(t);
42
+ const missing = path.join(defaultCapsulesDir(storageDir), "never.tgz");
43
+
44
+ await assert.rejects(
45
+ validateCapsuleImportArchive(missing, storageDir),
46
+ /existing file inside the namespace capsule store/,
47
+ );
48
+ });
49
+
50
+ test("capsule import gate: .. traversal out of the store is refused", async (t) => {
51
+ const { storageDir, archivePath } = await storeFixture(t);
52
+ const traversed = path.join(defaultCapsulesDir(storageDir), "..", "outside-store.tgz");
53
+ await writeFile(path.resolve(traversed), "bytes");
54
+
55
+ await assert.rejects(
56
+ validateCapsuleImportArchive(traversed, storageDir),
57
+ /existing file inside the namespace capsule store/,
58
+ );
59
+ // The real archive still validates — the refusal is about the traversal, not the store.
60
+ await assert.doesNotReject(validateCapsuleImportArchive(archivePath, storageDir));
61
+ });
62
+
63
+ test("capsule import gate: a store symlink to a file outside the store is refused", async (t) => {
64
+ const { storageDir } = await storeFixture(t);
65
+ const outside = path.join(storageDir, "outside-target.tgz");
66
+ await writeFile(outside, "bytes");
67
+ // The link path itself sits inside the store; only its real path escapes.
68
+ const link = path.join(defaultCapsulesDir(storageDir), "escape.tgz");
69
+ await symlink(outside, link);
70
+
71
+ await assert.rejects(
72
+ validateCapsuleImportArchive(link, storageDir),
73
+ /existing file inside the namespace capsule store/,
74
+ );
75
+ });
76
+
77
+ test("capsule import gate: a directory inside the store is refused as not-a-file", async (t) => {
78
+ const { storageDir } = await storeFixture(t);
79
+ await mkdir(path.join(defaultCapsulesDir(storageDir), "a-dir"), { recursive: true });
80
+
81
+ await assert.rejects(
82
+ validateCapsuleImportArchive(path.join(defaultCapsulesDir(storageDir), "a-dir"), storageDir),
83
+ /must point to a file/,
84
+ );
85
+ });
86
+
87
+ test("capsule import gate: a missing capsule store is refused like any other path", async (t) => {
88
+ const storageDir = await mkdtemp(path.join(tmpdir(), "remnic-gate-nostore-"));
89
+ t.after(() => rm(storageDir, { recursive: true, force: true }));
90
+ const archivePath = path.join(storageDir, "whatever.tgz");
91
+
92
+ await assert.rejects(
93
+ validateCapsuleImportArchive(archivePath, storageDir),
94
+ /existing file inside the namespace capsule store/,
95
+ );
96
+ });
97
+
98
+ test("archive input classifier: zod errors and archive-shape messages are input faults", () => {
99
+ assert.ok(isCapsuleImportArchiveInputError(new ZodError([]), "anything"));
100
+ assert.ok(isCapsuleImportArchiveInputError(Object.assign(new Error("x"), { code: "Z_ANY" }), "anything"));
101
+ assert.ok(isCapsuleImportArchiveInputError(new Error("y"), "importCapsule: archive is truncated"));
102
+ assert.ok(isCapsuleImportArchiveInputError(new Error("y"), "importCapsule: manifest invalid"));
103
+ assert.ok(isCapsuleImportArchiveInputError(new Error("y"), "gunzip failed: incorrect header check"));
104
+ assert.ok(isCapsuleImportArchiveInputError(new Error("y"), "unexpected end of file"));
105
+ assert.ok(!isCapsuleImportArchiveInputError(new Error("db unavailable"), "importCapsule: backend write failed"));
106
+ });
@@ -22,6 +22,9 @@ function makeService(): {
22
22
  } {
23
23
  const calls: Array<{ sessionKey: string; ctx: CodingContext | null }> = [];
24
24
  const stubOrchestrator = {
25
+ // Namespaces off keeps this suite on the permissive validation path; the
26
+ // principal-binding gate is covered in access-service-set-coding-context.test.ts.
27
+ config: { namespacesEnabled: false },
25
28
  setCodingContextForSession(sessionKey: string, ctx: CodingContext | null) {
26
29
  calls.push({ sessionKey, ctx });
27
30
  },
@@ -22,6 +22,7 @@
22
22
  * - `refresh`: build a fresh card from the repo, persist it, and
23
23
  * snapshot the prior version.
24
24
  */
25
+ import { codingContextLocalRoot } from "../access-coding-context-resolution.js";
25
26
  import type {
26
27
  CodingKnowledgeConfig,
27
28
  CodingContext,
@@ -244,7 +245,7 @@ async function architectureRefresh(
244
245
  ctx: ArchitectureSurfaceContext,
245
246
  codingContext: CodingContext,
246
247
  ): Promise<ArchitectureSurfaceResponse> {
247
- const repoRoot = codingContext.rootPath ?? codingContext.projectId;
248
+ const repoRoot = codingContextLocalRoot(codingContext);
248
249
  // Authorize the write + resolve storage BEFORE scanning the repo or
249
250
  // invoking the summariser, so an unauthorized refresh fails fast instead
250
251
  // of doing work (and an LLM call) it cannot persist (codex review: buildCard
@@ -953,3 +953,37 @@ test("LSP wiring: a failed LSP pass is non-fatal — index still reports ok with
953
953
  assert.equal(result.lsp?.error, "lsp_resolution_error", "the degradation code surfaces (never silent)");
954
954
  assert.equal(result.lsp?.message, "server crashed", "the degradation message surfaces");
955
955
  });
956
+
957
+ // ──────────────────────────────────────────────────────────────────────────
958
+ // #3515 review (wAK): a client-supplied rootPath is remote to the daemon —
959
+ // surfaces must never open it as a local path. It degrades to the projectId,
960
+ // which is what a projectTag-derived context already carries.
961
+ // ──────────────────────────────────────────────────────────────────────────
962
+
963
+ test("remote coding-context rootPath is never passed to repo scanning", async () => {
964
+ const remoteCtx: CodingContext = { ...CODING_CONTEXT, remote: true };
965
+ let built = "";
966
+ let indexed = "";
967
+ const ctx = makeEnabledCtx({
968
+ getCodingContext: () => remoteCtx,
969
+ buildArchitectureCard: async (root: string) => {
970
+ built = root;
971
+ return { card: "stub" };
972
+ },
973
+ reportIndexStatus: async (_store: CodegraphStore, repoRoot: string) => {
974
+ indexed = repoRoot;
975
+ return { ok: true, status: { mode: "fresh" } };
976
+ },
977
+ });
978
+ const arch = await handleCodegraphTool({ tool: "get_architecture", sessionKey: "s1" }, ctx);
979
+ assert.notEqual(built, CODING_CONTEXT.rootPath, "remote rootPath must not reach the scanner");
980
+ // projectId is caller-chosen and may itself be path-shaped, so the remote
981
+ // root degrades to the tag form — the same non-path label a
982
+ // projectTag-derived context already carries.
983
+ assert.equal(built, `tag:${remoteCtx.projectId}`, "remote root degrades to the tag label like a projectTag context");
984
+ assert.equal(arch.ok, true);
985
+ const status = await handleCodegraphTool({ tool: "index_status", sessionKey: "s1" }, ctx);
986
+ assert.notEqual(indexed, CODING_CONTEXT.rootPath);
987
+ assert.equal(indexed, `tag:${remoteCtx.projectId}`);
988
+ assert.equal(status.ok, true);
989
+ });
@@ -19,6 +19,7 @@
19
19
  * or architecture-card logic.
20
20
  */
21
21
  import type { PluginConfig, CodingContext } from "../types.js";
22
+ import { codingContextLocalRoot } from "../access-coding-context-resolution.js";
22
23
  import {
23
24
  codegraphRuntimeAvailable,
24
25
  codegraphSurfaceVisible,
@@ -633,7 +634,7 @@ async function handleGetArchitecture(
633
634
  ctx: CodegraphSurfaceContext,
634
635
  ): Promise<CodegraphSurfaceResponse> {
635
636
  const codingContext = resolveCodingContext(request, ctx);
636
- const repoRoot = request.repoRoot ?? codingContext.rootPath;
637
+ const repoRoot = request.repoRoot ?? codingContextLocalRoot(codingContext);
637
638
  // Composition (issue #1554): deterministic architecture card from Track A
638
639
  // (no live graph) + live graph stats from the per-project store. Two
639
640
  // existing sources, one composed response -- no duplicated card logic.
@@ -785,7 +786,7 @@ function resolveRepoRoot(request: CodegraphSurfaceRequest, ctx: CodegraphSurface
785
786
  if (typeof request.repoRoot === "string" && request.repoRoot.trim().length > 0) {
786
787
  return request.repoRoot.trim();
787
788
  }
788
- return resolveCodingContext(request, ctx).rootPath;
789
+ return codingContextLocalRoot(resolveCodingContext(request, ctx));
789
790
  }
790
791
 
791
792
  /**
@@ -822,3 +822,32 @@ test("a non-repo-only cache remembers non-repos but always re-reads repos", asyn
822
822
  await resolveGitContext("/tmp/z", { invoker: notRepo, cache });
823
823
  assert.equal(nonRepoCalls, 1);
824
824
  });
825
+
826
+ test("probeGitContext: dubious-ownership exit 128 is inconclusive, a real non-repo is conclusive", async () => {
827
+ const { probeGitContext } = await import("./git-context.js");
828
+ const dubious: GitInvoker = (cwd, args) =>
829
+ args.includes("--show-toplevel")
830
+ ? { stdout: "", stderr: "fatal: detected dubious ownership in repository at '/repo'", exitCode: 128 }
831
+ : { stdout: "", exitCode: 1 };
832
+ const d = await probeGitContext("/repo", { invoker: dubious });
833
+ assert.equal(d.conclusive, false, "operational git failure must not masquerade as a confirmed non-repo");
834
+
835
+ const notRepo: GitInvoker = (cwd, args) =>
836
+ args.includes("--show-toplevel")
837
+ ? { stdout: "", stderr: "fatal: not a git repository (or any of the parent directories): .git", exitCode: 128 }
838
+ : { stdout: "", exitCode: 1 };
839
+ const n = await probeGitContext("/tmp/x", { invoker: notRepo });
840
+ assert.equal(n.conclusive, true);
841
+ assert.equal(n.context, null);
842
+
843
+ // Inside a confirmed repo, an optional probe failing (no origin) stays conclusive.
844
+ const noOrigin: GitInvoker = (cwd, args) => {
845
+ if (args.includes("--show-toplevel")) return { stdout: "/repo\n", exitCode: 0 };
846
+ if (args[0] === "remote") return { stdout: "", stderr: "error: No such remote 'origin'", exitCode: 2 };
847
+ if (args[1] === "--abbrev-ref") return { stdout: "main\n", exitCode: 0 };
848
+ if (args[0] === "symbolic-ref" || args[0] === "rev-parse") return { stdout: "", stderr: "", exitCode: 1 };
849
+ return { stdout: "", exitCode: 1 };
850
+ };
851
+ const r = await probeGitContext("/repo", { invoker: noOrigin });
852
+ assert.equal(r.conclusive, true, "a missing origin inside a repo is a conclusive result, not a degraded probe");
853
+ });
@@ -74,6 +74,10 @@ export interface GitInvokeOptions {
74
74
  export interface GitInvokeResult {
75
75
  stdout: string;
76
76
  exitCode: number;
77
+ /** Captured when the invoker can supply it; used to tell a confirmed
78
+ * "not a git repository" answer from operational failures (e.g. exit 128
79
+ * for dubious ownership) that must stay inconclusive. */
80
+ stderr?: string;
77
81
  }
78
82
 
79
83
  /**
@@ -99,6 +103,7 @@ export interface SyncGitInvoker {
99
103
  const DEFAULT_GIT_TIMEOUT_MS = 2_000;
100
104
  const GIT_TIMEOUT_EXIT_CODE = 124;
101
105
  const GIT_SPAWN_ERROR_EXIT_CODE = 127;
106
+ const NOT_A_GIT_REPOSITORY = /not a git repository|outside repository|this operation must be run in a work tree/i;
102
107
 
103
108
  export function defaultGitInvokerSync(): SyncGitInvoker {
104
109
  return (cwd: string, args: string[]) => {
@@ -111,6 +116,7 @@ export function defaultGitInvokerSync(): SyncGitInvoker {
111
116
  if (result.error) return { stdout: "", exitCode: GIT_SPAWN_ERROR_EXIT_CODE };
112
117
  return {
113
118
  stdout: typeof result.stdout === "string" ? result.stdout : "",
119
+ stderr: result.stderr ?? "",
114
120
  exitCode: typeof result.status === "number" ? result.status : 1,
115
121
  };
116
122
  };
@@ -128,10 +134,11 @@ export function defaultGitInvoker(): GitInvoker {
128
134
  cwd,
129
135
  encoding: "utf-8",
130
136
  shell: false,
131
- stdio: ["ignore", "pipe", "ignore"],
137
+ stdio: ["ignore", "pipe", "pipe"],
132
138
  });
133
139
  const { promise, resolve, reject } = Promise.withResolvers<GitInvokeResult>();
134
140
  let stdout = "";
141
+ let stderr = "";
135
142
  let settled = false;
136
143
  let timer: NodeJS.Timeout | undefined;
137
144
 
@@ -164,9 +171,13 @@ export function defaultGitInvoker(): GitInvoker {
164
171
  child.stdout?.on("data", (chunk: string | Buffer) => {
165
172
  stdout += chunk.toString();
166
173
  });
174
+ child.stderr?.setEncoding("utf-8");
175
+ child.stderr?.on("data", (chunk: string | Buffer) => {
176
+ stderr += chunk.toString();
177
+ });
167
178
  child.once("error", () => finish({ stdout: "", exitCode: GIT_SPAWN_ERROR_EXIT_CODE }));
168
179
  child.once("close", (exitCode: number | null) => {
169
- finish({ stdout, exitCode: typeof exitCode === "number" ? exitCode : 1 });
180
+ finish({ stdout, stderr, exitCode: exitCode ?? 1 });
170
181
  });
171
182
  options.abortSignal?.addEventListener("abort", onAbort, { once: true });
172
183
 
@@ -573,3 +584,53 @@ export const sharedGitContextCache = new GitContextCache();
573
584
  * read a repo fresh; they only skip repeat probes of non-repo directories.
574
585
  */
575
586
  export const sharedNonRepoGitContextCache = new GitContextCache({ cacheRepos: false });
587
+
588
+ /**
589
+ * A probe verdict: `context` is the resolved context or `null`, and
590
+ * `conclusive` tells the two nulls apart. `conclusive: true` means git
591
+ * answered (a real repo or a confirmed non-repo); `conclusive: false` means
592
+ * the probe itself failed — spawn error, timeout, or an invoker throw —
593
+ * so the null carries no evidence about the directory.
594
+ */
595
+ export interface GitContextProbeResult {
596
+ context: GitContext | null;
597
+ conclusive: boolean;
598
+ }
599
+
600
+ /**
601
+ * `resolveGitContext` with the inconclusive distinction surfaced: the
602
+ * existing cache path already refuses to cache timeout/spawn-failure
603
+ * results, so a cached `null` is conclusive by construction. Callers that
604
+ * clear state on `null` (the plugin's coding-context sync) must only do so
605
+ * on a conclusive verdict.
606
+ */
607
+ export async function probeGitContext(
608
+ cwd: string,
609
+ options: ResolveGitContextOptions = {},
610
+ ): Promise<GitContextProbeResult> {
611
+ let inconclusive = false;
612
+ const inner = options.invoker ?? defaultGitInvoker();
613
+ const invoker: GitInvoker = async (probeCwd, args, invokeOptions) => {
614
+ let result: GitInvokeResult;
615
+ try {
616
+ result = await inner(probeCwd, args, invokeOptions);
617
+ } catch (err) {
618
+ inconclusive = true;
619
+ throw err;
620
+ }
621
+ if (result.exitCode === GIT_TIMEOUT_EXIT_CODE || result.exitCode === GIT_SPAWN_ERROR_EXIT_CODE) {
622
+ inconclusive = true;
623
+ } else if (
624
+ args[0] === "rev-parse" && args.includes("--show-toplevel")
625
+ && result.exitCode !== 0 && result.stderr !== undefined && !NOT_A_GIT_REPOSITORY.test(result.stderr)
626
+ ) {
627
+ // The repo probe's nonzero exit decides "not a repo", but dubious
628
+ // ownership, a corrupt .git or an unreadable cwd exit the same 128 —
629
+ // only git's own "not a repository" answer is conclusive.
630
+ inconclusive = true;
631
+ }
632
+ return result;
633
+ };
634
+ const context = await resolveGitContext(cwd, { ...options, invoker });
635
+ return { context, conclusive: !inconclusive };
636
+ }
@@ -21,6 +21,7 @@
21
21
  * state file is operator-side bookkeeping, not user memory content — the
22
22
  * same way `calibration.ts` writes are uncounted).
23
23
  */
24
+ import { codingContextLocalRoot } from "../access-coding-context-resolution.js";
24
25
  import type {
25
26
  CodingKnowledgeConfig,
26
27
  CodingContext,
@@ -224,7 +225,7 @@ async function deltaGet(
224
225
  // coding context was resolved from; it MUST exist for a delta to make
225
226
  // sense. Fall back to `projectId` only as a path hint — refresh is the
226
227
  // caller's responsibility (the gate already required a context).
227
- const repoRoot = codingContext.rootPath ?? codingContext.projectId;
228
+ const repoRoot = codingContextLocalRoot(codingContext);
228
229
  const sliceResult: ResolveSliceResult = resolveSlice(
229
230
  repoRoot,
230
231
  lastSeen?.head ?? null,
@@ -0,0 +1,46 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import fs from "node:fs";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+
7
+ import { droidInstallStep } from "./droid-mcp.js";
8
+ import type { TokenStore } from "../tokens.js";
9
+
10
+ test("droidInstallStep hands the prior token store to the saver when the mcp.json write fails", () => {
11
+ const home = fs.mkdtempSync(path.join(os.tmpdir(), "remnic-droid-step-"));
12
+ // A file where ~/.factory must be a directory makes the write fail.
13
+ fs.writeFileSync(path.join(home, ".factory"), "not a directory");
14
+ const priorHome = process.env.HOME;
15
+ process.env.HOME = home;
16
+ const prior: TokenStore = { tokens: [] };
17
+ const saved: TokenStore[] = [];
18
+ try {
19
+ const result = droidInstallStep("tok", {}, true, { token: "tok" }, prior, (store) => {
20
+ saved.push(store);
21
+ });
22
+ if (result.ok) assert.fail("the write into a non-directory must fail");
23
+ assert.deepEqual(saved, [prior]);
24
+ assert.match(result.errorMessage, /Token has been rolled back/);
25
+ } finally {
26
+ if (priorHome === undefined) delete process.env.HOME;
27
+ else process.env.HOME = priorHome;
28
+ fs.rmSync(home, { recursive: true, force: true });
29
+ }
30
+ });
31
+
32
+ test("droidInstallStep types its saver as a TokenStore saver (#3538)", () => {
33
+ // Compile-time contract only: tsc fails on an unused @ts-expect-error, so
34
+ // the call below only has to type-check; it never runs.
35
+ const call = () =>
36
+ droidInstallStep(
37
+ undefined,
38
+ {},
39
+ false,
40
+ null,
41
+ null,
42
+ // @ts-expect-error a saver for another shape is not a token-store saver
43
+ (store: { other: number }) => void store,
44
+ );
45
+ void call;
46
+ });
@@ -17,6 +17,7 @@ import os from "node:os";
17
17
 
18
18
  import { readEnvVar } from "../runtime/env.js";
19
19
  import type { ConnectorManifest } from "./index.js";
20
+ import type { TokenStore } from "../tokens.js";
20
21
 
21
22
  // ── Manifest ────────────────────────────────────────────────────────────────
22
23
 
@@ -76,17 +77,16 @@ export type DroidInstallStepResult =
76
77
  /**
77
78
  * Write the remnic MCP entry to ~/.factory/mcp.json, with token rollback on failure.
78
79
  *
79
- * `saveTokenStore` is passed as a callback to avoid a circular dependency
80
- * back into the main connectors module.
80
+ * `saveTokenStoreFn` is the token-store saver (`saveTokenStore` in
81
+ * production), injected so a test can observe or fail the rollback.
81
82
  */
82
83
  export function droidInstallStep(
83
84
  authToken: string | undefined,
84
85
  resolvedConfig: Record<string, unknown>,
85
86
  requiresToken: boolean,
86
87
  tokenEntry: { token: string } | null,
87
- priorTokenStore: unknown,
88
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
- saveTokenStoreFn: (store: any) => void,
88
+ priorTokenStore: TokenStore | null,
89
+ saveTokenStoreFn: (store: TokenStore) => void,
90
90
  ): DroidInstallStepResult {
91
91
  try {
92
92
  const result = writeDroidMcpEntry(authToken, resolvedConfig);
@@ -0,0 +1,63 @@
1
+ import assert from "node:assert/strict";
2
+ import { statSync, writeFileSync } from "node:fs";
3
+ import { mkdtemp, rm } from "node:fs/promises";
4
+ import { tmpdir } from "node:os";
5
+ import path from "node:path";
6
+ import test from "node:test";
7
+
8
+ import {
9
+ bumpHarmonicGraphVersion,
10
+ HARMONIC_GRAPH_VERSION_SENTINEL,
11
+ readHarmonicGraphStamp,
12
+ } from "./harmonic-graph-version.js";
13
+
14
+ test("harmonic version: bump appends one byte to the sentinel, creating it", async (t) => {
15
+ const nodeDir = await mkdtemp(path.join(tmpdir(), "remnic-hgv-"));
16
+ t.after(() => rm(nodeDir, { recursive: true, force: true }));
17
+ const sentinel = path.join(nodeDir, HARMONIC_GRAPH_VERSION_SENTINEL);
18
+
19
+ bumpHarmonicGraphVersion(nodeDir);
20
+ assert.equal(statSync(sentinel).size, 1);
21
+ bumpHarmonicGraphVersion(nodeDir);
22
+ assert.equal(statSync(sentinel).size, 2);
23
+ });
24
+
25
+ test("harmonic version: stamp changes when the harmonic sentinel grows", async (t) => {
26
+ const memoryDir = await mkdtemp(path.join(tmpdir(), "remnic-hgv-mem-"));
27
+ t.after(() => rm(memoryDir, { recursive: true, force: true }));
28
+ const nodeDir = path.join(memoryDir, "abstraction-nodes");
29
+
30
+ const before = readHarmonicGraphStamp(memoryDir, nodeDir);
31
+ assert.equal(before, "0:0:0:0");
32
+
33
+ bumpHarmonicGraphVersion(nodeDir);
34
+ const after = readHarmonicGraphStamp(memoryDir, nodeDir);
35
+ assert.notEqual(after, before);
36
+ assert.equal(after.split(":")[3], "1");
37
+ });
38
+
39
+ test("harmonic version: stamp reflects the corpus sentinel too", async (t) => {
40
+ const memoryDir = await mkdtemp(path.join(tmpdir(), "remnic-hgv-mem2-"));
41
+ const nodeDir = await mkdtemp(path.join(tmpdir(), "remnic-hgv-node2-"));
42
+ t.after(() => rm(memoryDir, { recursive: true, force: true }));
43
+ t.after(() => rm(nodeDir, { recursive: true, force: true }));
44
+
45
+ const { MEMORY_CORPUS_VERSION_SENTINEL } = await import("./memory-corpus-version.js");
46
+ const { mkdirSync } = await import("node:fs");
47
+ const stateDir = path.join(memoryDir, "state");
48
+ mkdirSync(stateDir, { recursive: true });
49
+ writeFileSync(path.join(stateDir, MEMORY_CORPUS_VERSION_SENTINEL), "xxx");
50
+
51
+ const stamp = readHarmonicGraphStamp(memoryDir, nodeDir);
52
+ assert.equal(stamp.split(":")[0], "3");
53
+ });
54
+
55
+ test("harmonic version: a failed bump is fail-open, never throws", async (t) => {
56
+ const base = await mkdtemp(path.join(tmpdir(), "remnic-hgv-ro-"));
57
+ t.after(() => rm(base, { recursive: true, force: true }));
58
+ // A regular file in place of the store dir makes mkdirSync fail; bump swallows it.
59
+ const fileAsDir = path.join(base, "not-a-dir");
60
+ writeFileSync(fileAsDir, "x");
61
+
62
+ assert.doesNotThrow(() => bumpHarmonicGraphVersion(fileAsDir));
63
+ });
@@ -91,6 +91,16 @@ function harness(options?: {
91
91
  events.push(event);
92
92
  },
93
93
  countShadowRecords: async () => options?.shadowRecords ?? 10,
94
+ trailingReceiptFailures: async () => {
95
+ let count = 0;
96
+ for (let i = events.length - 1; i >= 0; i -= 1) {
97
+ const event = events[i];
98
+ if (event.phase !== "outcome") continue;
99
+ if (!event.failureClass || event.failureClass === "record_failed") break;
100
+ count += 1;
101
+ }
102
+ return count;
103
+ },
94
104
  },
95
105
  executors:
96
106
  options?.executors ??
@@ -245,6 +255,34 @@ test("failed receipt forces shadow on the next run", async () => {
245
255
  assert.equal(second.executed, false);
246
256
  });
247
257
 
258
+ test("a restarted coordinator keeps the receipt-failure demotion from recorded outcomes", async () => {
259
+ const h = harness({
260
+ executors: {
261
+ executeRecall: async () => ({ decisionId: "wrong-id", ok: true }),
262
+ },
263
+ });
264
+ const first = await new MemoryControllerCoordinator(h.deps).run({ prompt: RECALL_PROMPT });
265
+ assert.equal(first.executed, false);
266
+
267
+ const restarted = await new MemoryControllerCoordinator(h.deps).run({ prompt: RECALL_PROMPT });
268
+ assert.equal(restarted.effectiveMode, "shadow");
269
+ assert.ok(restarted.demotionReasons.includes("recent_receipt_failures"));
270
+ assert.equal(restarted.executed, false);
271
+ });
272
+
273
+ test("an unreadable receipt-failure history keeps the gate closed", async () => {
274
+ const h = harness();
275
+ h.deps.recorder = {
276
+ ...h.deps.recorder!,
277
+ trailingReceiptFailures: async () => {
278
+ throw new Error("history unavailable");
279
+ },
280
+ };
281
+ const result = await new MemoryControllerCoordinator(h.deps).run({ prompt: RECALL_PROMPT });
282
+ assert.equal(result.effectiveMode, "shadow");
283
+ assert.ok(result.demotionReasons.includes("recent_receipt_failures"));
284
+ });
285
+
248
286
  test("executor error or missing executor records a failure class and demotes next run", async () => {
249
287
  const h = harness({
250
288
  executors: {
@@ -99,6 +99,12 @@ export interface MemoryControllerRecorder {
99
99
  record(event: MemoryControllerEvent): Promise<void>;
100
100
  /** Prior shadow choice records; active promotion requires shadow history. */
101
101
  countShadowRecords(): Promise<number>;
102
+ /**
103
+ * Failed outcomes (executor_error, bad_receipt, no_executor) at the end of
104
+ * the recorded stream, newest first, stopping at the first success. A new
105
+ * coordinator seeds its receipt-failure gate from this count.
106
+ */
107
+ trailingReceiptFailures?(): Promise<number>;
102
108
  }
103
109
 
104
110
  export interface MemoryControllerConfig {
@@ -338,6 +344,7 @@ export class MemoryControllerCoordinator {
338
344
  private readonly deps: MemoryControllerDeps;
339
345
  private readonly clock: () => Date;
340
346
  private consecutiveReceiptFailures = 0;
347
+ private receiptFailuresSeeded = false;
341
348
 
342
349
  constructor(deps: MemoryControllerDeps) {
343
350
  this.deps = deps;
@@ -379,6 +386,7 @@ export class MemoryControllerCoordinator {
379
386
  let demotionReasons: string[] = [];
380
387
  let effectiveMode = requestedMode;
381
388
  if (requestedMode === "active") {
389
+ await this.seedReceiptFailures();
382
390
  demotionReasons = await evaluateActiveGates({
383
391
  config: this.deps.config,
384
392
  reportReader: this.deps.reportReader,
@@ -527,6 +535,23 @@ export class MemoryControllerCoordinator {
527
535
  }
528
536
  }
529
537
 
538
+ private async seedReceiptFailures(): Promise<void> {
539
+ if (this.receiptFailuresSeeded) return;
540
+ this.receiptFailuresSeeded = true;
541
+ const reader = this.deps.recorder?.trailingReceiptFailures;
542
+ if (!reader) return;
543
+ let recorded: number;
544
+ try {
545
+ recorded = await reader.call(this.deps.recorder);
546
+ } catch {
547
+ // Unknown receipt health keeps the gate closed.
548
+ recorded = 1;
549
+ }
550
+ if (Number.isFinite(recorded) && recorded > this.consecutiveReceiptFailures) {
551
+ this.consecutiveReceiptFailures = recorded;
552
+ }
553
+ }
554
+
530
555
  private async recordOutcome(event: MemoryControllerEvent): Promise<void> {
531
556
  if (!this.deps.recorder) return;
532
557
  await this.deps.recorder.record(event);
@@ -543,5 +568,3 @@ function isValidReceipt(receipt: unknown, decisionId: string): boolean {
543
568
  );
544
569
  }
545
570
 
546
- // ponytail: consecutiveReceiptFailures is per-instance, not persisted; persist
547
- // with the recorder if coordinator restarts must carry receipt health forward.
@@ -40,8 +40,9 @@ export async function appendEpisodicContextSection(
40
40
  scopePlan: ScopePlan;
41
41
  namespacesEnabled: boolean;
42
42
  enrichmentSectionDeadlineMs: number;
43
- recallOuterTimeoutMs: number;
44
- recallStart: number;
43
+ /** Absolute deadline for the whole request (already client-clamped),
44
+ * or null when unbounded. */
45
+ outerDeadlineAtMs: number | null;
45
46
  abortSignal?: AbortSignal;
46
47
  recordMetric: (metric: RecallSectionMetric) => void;
47
48
  },
@@ -72,12 +73,10 @@ export async function appendEpisodicContextSection(
72
73
  return;
73
74
  }
74
75
 
75
- const outerDeadlineAtMs =
76
- options.recallOuterTimeoutMs > 0
77
- ? options.recallStart + options.recallOuterTimeoutMs
78
- : null;
79
76
  const remainingOuterMs =
80
- outerDeadlineAtMs === null ? null : outerDeadlineAtMs - deps.recallAssemblyClockMs();
77
+ options.outerDeadlineAtMs === null
78
+ ? null
79
+ : options.outerDeadlineAtMs - deps.recallAssemblyClockMs();
81
80
  const deadlineMs = resolveRecallCoreSectionDeadlineMs({
82
81
  configuredCoreDeadlineMs: options.enrichmentSectionDeadlineMs,
83
82
  remainingOuterMs,
@@ -263,6 +263,16 @@ export interface RecallInvocationOptions {
263
263
  * absent, so existing timing consumers are unaffected.
264
264
  */
265
265
  queueWaitMs?: number;
266
+ /**
267
+ * Client's own deadline for this recall (issue #3499). Epoch-sized
268
+ * values are absolute; smaller values read as a budget from now — the
269
+ * force-flush convention (issue #3140). Caps the request's outer
270
+ * deadline at `min(configured, client)` so a client whose own budget is
271
+ * tighter than `recallOuterTimeoutMs` gets a degraded recall inside what
272
+ * remains instead of an answer it can no longer use. Never a rejection:
273
+ * an already-passed deadline behaves like a 0-remaining budget.
274
+ */
275
+ deadlineMs?: number;
266
276
  onContextComposition?: (composition: RecallContextComposition) => void | PromiseLike<void>;
267
277
  }
268
278