@remnic/core 9.65.2 → 9.65.4

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 (492) hide show
  1. package/dist/access-admin-ops-surface.d.ts +44 -44
  2. package/dist/access-admin-ops-surface.js +21 -19
  3. package/dist/access-authorization-probe.d.ts +38 -38
  4. package/dist/access-authorization-probe.js +22 -20
  5. package/dist/access-boundary.d.ts +40 -40
  6. package/dist/access-boundary.js +21 -19
  7. package/dist/access-cli.js +62 -60
  8. package/dist/access-cli.js.map +1 -1
  9. package/dist/access-coding-context-resolution.d.ts +3 -1
  10. package/dist/access-extraction-force-flush.d.ts +25 -25
  11. package/dist/access-extraction-force-flush.js +21 -19
  12. package/dist/access-health-types.d.ts +3 -1
  13. package/dist/access-http-lcm-compaction.d.ts +39 -39
  14. package/dist/access-http-lifecycle-flush.d.ts +39 -39
  15. package/dist/access-http-offline-stream.d.ts +25 -25
  16. package/dist/access-http-query.d.ts +4 -2
  17. package/dist/access-http-query.js +23 -21
  18. package/dist/access-http.d.ts +51 -44
  19. package/dist/access-http.js +37 -35
  20. package/dist/access-identity-continuity-surface.d.ts +12 -12
  21. package/dist/access-identity-continuity-surface.js +21 -19
  22. package/dist/access-lcm-surface.d.ts +27 -27
  23. package/dist/access-lcm-surface.js +21 -19
  24. package/dist/access-mcp-admin-tools.d.ts +9 -1
  25. package/dist/access-mcp-admin-tools.js +3 -1
  26. package/dist/access-mcp-output-schemas.js +1 -1
  27. package/dist/access-mcp.d.ts +39 -39
  28. package/dist/access-mcp.js +31 -29
  29. package/dist/access-memory-search-fanout.d.ts +4 -2
  30. package/dist/{access-namespace-preflight-Dhvcl-T0.d.ts → access-namespace-preflight-D_6mo8ms.d.ts} +1 -1
  31. package/dist/access-namespace-preflight.d.ts +5 -3
  32. package/dist/access-namespace-preflight.js +21 -19
  33. package/dist/access-observe-write-surface.d.ts +39 -39
  34. package/dist/access-observe-write-surface.js +21 -19
  35. package/dist/access-offline-manifest.d.ts +12 -12
  36. package/dist/access-offline-manifest.js +3 -3
  37. package/dist/access-operations-batch.js +25 -23
  38. package/dist/access-operations.d.ts +40 -40
  39. package/dist/access-operations.js +28 -26
  40. package/dist/access-recall-concurrency.d.ts +40 -40
  41. package/dist/access-recall-concurrency.js +21 -19
  42. package/dist/access-recall-response.d.ts +24 -24
  43. package/dist/access-recall-response.js +21 -19
  44. package/dist/access-recall-surface.d.ts +24 -24
  45. package/dist/access-recall-surface.js +21 -19
  46. package/dist/access-schema.d.ts +45 -45
  47. package/dist/{access-service-Bke1alZO.d.ts → access-service-DqPa3hy4.d.ts} +219 -75
  48. package/dist/access-service-helpers.d.ts +40 -40
  49. package/dist/access-service.d.ts +47 -47
  50. package/dist/access-service.js +21 -19
  51. package/dist/access-surface-catalog.d.ts +40 -40
  52. package/dist/access-surface-catalog.js +27 -21
  53. package/dist/access-surface-catalog.js.map +1 -1
  54. package/dist/access-wearables-meetings-surface.d.ts +5 -3
  55. package/dist/action-confidence.d.ts +3 -1
  56. package/dist/active-memory-bridge.d.ts +3 -1
  57. package/dist/active-recall.d.ts +3 -1
  58. package/dist/active-recall.js +10 -1
  59. package/dist/active-recall.js.map +1 -1
  60. package/dist/ambient-provenance.d.ts +3 -1
  61. package/dist/artifact-search.d.ts +3 -1
  62. package/dist/{auto-sync-H64ZCNIR.js → auto-sync-XVMLL2RH.js} +5 -5
  63. package/dist/behavior-learner.d.ts +3 -1
  64. package/dist/behavior-signals.d.ts +3 -1
  65. package/dist/bootstrap.d.ts +12 -12
  66. package/dist/briefing-window.d.ts +4 -2
  67. package/dist/briefing.d.ts +4 -2
  68. package/dist/briefing.js +4 -4
  69. package/dist/buffer-surprise-report.d.ts +3 -1
  70. package/dist/buffer-turn-helpers.d.ts +3 -1
  71. package/dist/buffer.d.ts +4 -2
  72. package/dist/bulk-import/index.d.ts +5 -3
  73. package/dist/calibration.d.ts +3 -1
  74. package/dist/capabilities.d.ts +3 -1
  75. package/dist/{catalog-DV6qnbr7.d.ts → catalog-DO_7zfkv.d.ts} +1 -1
  76. package/dist/causal-behavior.d.ts +1 -1
  77. package/dist/causal-consolidation.d.ts +3 -1
  78. package/dist/causal-consolidation.js +12 -9
  79. package/dist/causal-consolidation.js.map +1 -1
  80. package/dist/causal-trajectory-graph.d.ts +1 -1
  81. package/dist/chunk-236PXYG7.js +232 -0
  82. package/dist/chunk-236PXYG7.js.map +1 -0
  83. package/dist/{chunk-YB42WZCY.js → chunk-2IXQSGCU.js} +2 -2
  84. package/dist/{chunk-PE255F4T.js → chunk-2MVTAIL3.js} +2 -2
  85. package/dist/{chunk-LGO6A7GJ.js → chunk-3JZBPTLD.js} +338 -80
  86. package/dist/chunk-3JZBPTLD.js.map +1 -0
  87. package/dist/{chunk-GDFVPUJ5.js → chunk-3NH3VP3U.js} +2 -2
  88. package/dist/{chunk-TBOJ76ER.js → chunk-AB3A7EFH.js} +18 -2
  89. package/dist/{chunk-TBOJ76ER.js.map → chunk-AB3A7EFH.js.map} +1 -1
  90. package/dist/{chunk-GNCCUR6K.js → chunk-AXGFOFNY.js} +2 -2
  91. package/dist/{chunk-SB7D4BT7.js → chunk-AZLLH6YA.js} +1554 -114
  92. package/dist/chunk-AZLLH6YA.js.map +1 -0
  93. package/dist/{chunk-5YQ63T4B.js → chunk-BK5G2MHO.js} +2 -2
  94. package/dist/{chunk-LZH5FR2W.js → chunk-CQBIN77D.js} +2 -2
  95. package/dist/{chunk-35NN3ZFA.js → chunk-CTVWELNK.js} +21 -3
  96. package/dist/chunk-CTVWELNK.js.map +1 -0
  97. package/dist/{chunk-NKKD4ZAU.js → chunk-DORFF5N5.js} +2 -2
  98. package/dist/{chunk-BWLRUMOG.js → chunk-DPNXADEI.js} +441 -2
  99. package/dist/chunk-DPNXADEI.js.map +1 -0
  100. package/dist/{chunk-SQI57UCJ.js → chunk-DUEDOYZD.js} +2 -2
  101. package/dist/{chunk-5NM4OH4P.js → chunk-DUZARALI.js} +3 -3
  102. package/dist/{chunk-2E36UXVW.js → chunk-ECLJ4LA2.js} +2 -2
  103. package/dist/{chunk-TZNQUNKL.js → chunk-FC7TIRFS.js} +15 -1
  104. package/dist/chunk-FC7TIRFS.js.map +1 -0
  105. package/dist/{chunk-IID2CMUU.js → chunk-GHD2LLG4.js} +2 -2
  106. package/dist/{chunk-ZQHI2BZB.js → chunk-HF5BUTI6.js} +2 -2
  107. package/dist/{chunk-3DVBKTSO.js → chunk-HSZMX3ZJ.js} +4 -4
  108. package/dist/{chunk-S2DPMJXH.js → chunk-I23ZHYSL.js} +2 -2
  109. package/dist/{chunk-ODZG724P.js → chunk-I2HTKOOP.js} +2 -2
  110. package/dist/chunk-I32NKXE2.js +879 -0
  111. package/dist/chunk-I32NKXE2.js.map +1 -0
  112. package/dist/{chunk-NTWN6HB2.js → chunk-IURMJBGP.js} +2 -2
  113. package/dist/{chunk-OCZIYAE5.js → chunk-IWKGOCL6.js} +3 -3
  114. package/dist/{chunk-UXO5IMBK.js → chunk-J3ATBB7M.js} +2 -2
  115. package/dist/{chunk-Y7DK7HHJ.js → chunk-JPAKBNTM.js} +2 -2
  116. package/dist/{chunk-SPUJNJJC.js → chunk-KFIOPZ25.js} +2 -2
  117. package/dist/{chunk-JYYBA7TF.js → chunk-KOO37E4Y.js} +2 -2
  118. package/dist/{chunk-OTHZWLUD.js → chunk-KPB2QHJZ.js} +2 -2
  119. package/dist/{chunk-SBDCZ2AX.js → chunk-LBFFNDFM.js} +1 -1
  120. package/dist/chunk-LBFFNDFM.js.map +1 -0
  121. package/dist/{chunk-CT56C22C.js → chunk-LYBIHM4N.js} +4 -4
  122. package/dist/{chunk-3I7ASZN3.js → chunk-MFOSZUIT.js} +2 -2
  123. package/dist/{chunk-DZUJ46DO.js → chunk-NLEH4RTB.js} +2 -2
  124. package/dist/{chunk-ZO6AXLEH.js → chunk-OCCHUEZB.js} +2 -2
  125. package/dist/{chunk-EILZG5VC.js → chunk-OU34IQXV.js} +2 -2
  126. package/dist/{chunk-2XDWWPTN.js → chunk-OZDFB22S.js} +2 -2
  127. package/dist/{chunk-UIN2BWDD.js → chunk-PTZQYCJ4.js} +2 -2
  128. package/dist/{chunk-7BY7V4YX.js → chunk-Q4WONDMJ.js} +4 -3
  129. package/dist/{chunk-7BY7V4YX.js.map → chunk-Q4WONDMJ.js.map} +1 -1
  130. package/dist/{chunk-Z7PBQPJ4.js → chunk-QJW4MZSW.js} +2 -2
  131. package/dist/{chunk-R7JAM2XF.js → chunk-R2MZCYA6.js} +3 -3
  132. package/dist/{chunk-TF77C7SV.js → chunk-SR5LNI6Q.js} +7 -5
  133. package/dist/chunk-SR5LNI6Q.js.map +1 -0
  134. package/dist/{chunk-LBWQ65SX.js → chunk-T42L3S6A.js} +4 -4
  135. package/dist/{chunk-J275IYMG.js → chunk-THVI4Y7X.js} +34 -7
  136. package/dist/chunk-THVI4Y7X.js.map +1 -0
  137. package/dist/{chunk-QOS5LBZN.js → chunk-TJFI3K2O.js} +15 -3
  138. package/dist/chunk-TJFI3K2O.js.map +1 -0
  139. package/dist/{chunk-2YI72KM3.js → chunk-UCKG36HO.js} +2 -2
  140. package/dist/{chunk-SIHSCCUQ.js → chunk-UFR6HX7A.js} +1 -1
  141. package/dist/{chunk-CDUUDBWJ.js → chunk-VFYRYFLL.js} +2 -2
  142. package/dist/{chunk-XRYZRW54.js → chunk-WDXD6ITO.js} +2 -2
  143. package/dist/{chunk-4KYOLI6M.js → chunk-XGM3VQWG.js} +120 -14
  144. package/dist/chunk-XGM3VQWG.js.map +1 -0
  145. package/dist/{chunk-MN4KB2A4.js → chunk-YDKF4MSJ.js} +3 -3
  146. package/dist/{chunk-YLDXWCZP.js → chunk-YHGCT462.js} +14 -9
  147. package/dist/chunk-YHGCT462.js.map +1 -0
  148. package/dist/{chunk-7YQ4IYS2.js → chunk-YOXVZJFM.js} +2 -2
  149. package/dist/{chunk-ZWXJBFZU.js → chunk-YZJM6CLF.js} +8 -8
  150. package/dist/chunk-ZCUTSMR2.js +61 -0
  151. package/dist/chunk-ZCUTSMR2.js.map +1 -0
  152. package/dist/{chunk-LUNJ3WFO.js → chunk-ZK4BFABK.js} +4 -4
  153. package/dist/{chunk-V3MXUL3D.js → chunk-ZPOHEB5Z.js} +329 -653
  154. package/dist/chunk-ZPOHEB5Z.js.map +1 -0
  155. package/dist/{chunk-RDFF2NAU.js → chunk-ZXBTTMGZ.js} +184 -88
  156. package/dist/chunk-ZXBTTMGZ.js.map +1 -0
  157. package/dist/{cli-cShQ13XG.d.ts → cli-DO3i14pM.d.ts} +5 -5
  158. package/dist/cli.d.ts +25 -25
  159. package/dist/cli.js +51 -48
  160. package/dist/coding/pre-action-gate.d.ts +2 -60
  161. package/dist/compounding/engine.d.ts +4 -2
  162. package/dist/compounding/engine.js +4 -4
  163. package/dist/compounding/preference-consolidator.d.ts +3 -1
  164. package/dist/compression-optimizer.d.ts +3 -1
  165. package/dist/config.d.ts +3 -1
  166. package/dist/config.js +10 -1
  167. package/dist/connectors/codex-materialize-runner.d.ts +3 -1
  168. package/dist/connectors/codex-materialize-runner.js +8 -5
  169. package/dist/connectors/codex-materialize.d.ts +16 -1
  170. package/dist/connectors/codex-materialize.js +10 -1
  171. package/dist/connectors/index.d.ts +3 -1
  172. package/dist/connectors/index.js +8 -5
  173. package/dist/consolidation-provenance-check.d.ts +4 -2
  174. package/dist/consolidation-undo.d.ts +4 -2
  175. package/dist/contradiction/index.d.ts +10 -270
  176. package/dist/contradiction/index.js +12 -7
  177. package/dist/{contradiction-review-QKJH5DKD.js → contradiction-review-WRVLRWHS.js} +6 -2
  178. package/dist/{contradiction-scan-VOTQRRSX.js → contradiction-scan-AKUWPX5N.js} +5 -3
  179. package/dist/converge-config.d.ts +3 -1
  180. package/dist/convergence-refresh.d.ts +4 -2
  181. package/dist/convergence-refresh.js +6 -6
  182. package/dist/conversation-index/backend.d.ts +3 -1
  183. package/dist/conversation-index/chunker.d.ts +3 -1
  184. package/dist/conversation-index/faiss-adapter.d.ts +3 -1
  185. package/dist/conversation-index/indexer.d.ts +3 -1
  186. package/dist/conversation-index/search.d.ts +3 -1
  187. package/dist/corpus-watermark.d.ts +3 -1
  188. package/dist/corpus-watermark.js +6 -6
  189. package/dist/cross-lingual-recall.d.ts +3 -1
  190. package/dist/day-summary.d.ts +3 -1
  191. package/dist/delinearize.d.ts +3 -1
  192. package/dist/dependency-propagation-config.d.ts +3 -1
  193. package/dist/{dependency-propagation-delivery-CsGg-VwS.d.ts → dependency-propagation-delivery-D23_x-s5.d.ts} +1 -1
  194. package/dist/direct-answer-wiring.d.ts +3 -1
  195. package/dist/direct-answer.d.ts +3 -1
  196. package/dist/embedding-fallback.d.ts +3 -1
  197. package/dist/enrichment/index.d.ts +3 -1
  198. package/dist/entity-origin-fields.d.ts +3 -1
  199. package/dist/entity-retrieval.d.ts +4 -2
  200. package/dist/entity-retrieval.js +4 -4
  201. package/dist/entity-schema.d.ts +3 -1
  202. package/dist/episodic-context.d.ts +3 -1
  203. package/dist/explicit-capture.d.ts +12 -12
  204. package/dist/explicit-capture.js +1 -1
  205. package/dist/external-wiki-access.d.ts +40 -40
  206. package/dist/external-wiki-access.js +22 -20
  207. package/dist/external-wiki-collection-registration.d.ts +3 -1
  208. package/dist/external-wiki-collection.d.ts +3 -1
  209. package/dist/external-wiki-mcp-tools.d.ts +40 -40
  210. package/dist/extraction-error-classification.d.ts +3 -1
  211. package/dist/extraction-faithfulness.d.ts +3 -1
  212. package/dist/extraction-judge-telemetry.d.ts +3 -1
  213. package/dist/extraction-judge-training.d.ts +3 -1
  214. package/dist/extraction-judge.d.ts +3 -1
  215. package/dist/extraction-judge.js +2 -2
  216. package/dist/extraction-liveness.d.ts +3 -1
  217. package/dist/extraction-normalization.d.ts +3 -1
  218. package/dist/extraction-prompt.d.ts +3 -1
  219. package/dist/extraction-source-grounding-rules.d.ts +3 -1
  220. package/dist/extraction-source-grounding.d.ts +3 -1
  221. package/dist/extraction.d.ts +3 -1
  222. package/dist/extraction.js +9 -7
  223. package/dist/fallback-llm.d.ts +3 -1
  224. package/dist/graph-dashboard-diff.d.ts +3 -1
  225. package/dist/graph-dashboard-key.d.ts +3 -1
  226. package/dist/graph-dashboard-parser.d.ts +3 -1
  227. package/dist/graph-edge-reinforcement.d.ts +3 -1
  228. package/dist/graph-path-reconstruction.d.ts +3 -1
  229. package/dist/graph-path-scoring.d.ts +3 -1
  230. package/dist/graph-snapshot.d.ts +3 -1
  231. package/dist/graph.d.ts +3 -1
  232. package/dist/harmonic-retrieval.js +1 -1
  233. package/dist/importance.d.ts +3 -1
  234. package/dist/importers/index.d.ts +3 -1
  235. package/dist/in-flight-reads.d.ts +3 -1
  236. package/dist/index--QhGIXF2.d.ts +284 -0
  237. package/dist/index.d.ts +314 -45
  238. package/dist/index.js +163 -88
  239. package/dist/intent.d.ts +3 -1
  240. package/dist/lcm/engine.d.ts +3 -1
  241. package/dist/lcm/index.d.ts +3 -1
  242. package/dist/lcm/tools.d.ts +3 -1
  243. package/dist/lifecycle.d.ts +3 -1
  244. package/dist/live-connectors-runner.d.ts +3 -1
  245. package/dist/local-llm.d.ts +3 -1
  246. package/dist/local-model-endpoint.d.ts +3 -1
  247. package/dist/maintenance/memory-governance.d.ts +3 -1
  248. package/dist/maintenance/memory-governance.js +4 -4
  249. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +4 -2
  250. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +4 -4
  251. package/dist/maintenance/rebuild-memory-projection.d.ts +4 -2
  252. package/dist/maintenance/rebuild-memory-projection.js +5 -5
  253. package/dist/{maintenance-jhMpeGne.d.ts → maintenance-PFvY1Pw_.d.ts} +3 -3
  254. package/dist/mcp-memory-inspector-app.d.ts +37 -37
  255. package/dist/memory-action-policy.d.ts +3 -1
  256. package/dist/memory-cache.d.ts +3 -1
  257. package/dist/memory-lifecycle-ledger-utils.d.ts +3 -1
  258. package/dist/memory-projection-store.d.ts +3 -1
  259. package/dist/memory-provenance.d.ts +3 -1
  260. package/dist/memory-snapshot.d.ts +3 -1
  261. package/dist/memory-subject-cli.d.ts +40 -40
  262. package/dist/memory-subject.d.ts +42 -42
  263. package/dist/memory-worth-outcomes.d.ts +4 -2
  264. package/dist/models-json.d.ts +3 -1
  265. package/dist/namespaces/migrate.d.ts +5 -3
  266. package/dist/namespaces/migrate.js +5 -5
  267. package/dist/namespaces/principal.d.ts +3 -1
  268. package/dist/namespaces/search.d.ts +3 -1
  269. package/dist/namespaces/storage.d.ts +5 -3
  270. package/dist/namespaces/storage.js +4 -4
  271. package/dist/native-knowledge.d.ts +3 -1
  272. package/dist/offline-sync-impression-drain.d.ts +3 -1
  273. package/dist/operator-doctor-corpus.d.ts +3 -1
  274. package/dist/operator-doctor-corpus.js +7 -7
  275. package/dist/operator-doctor-replica.d.ts +3 -1
  276. package/dist/operator-toolkit.d.ts +5 -3
  277. package/dist/operator-toolkit.js +19 -13
  278. package/dist/orchestration/compression-guideline-coordinator.d.ts +4 -2
  279. package/dist/orchestration/maintenance.d.ts +6 -4
  280. package/dist/orchestration/maintenance.js +10 -10
  281. package/dist/{orchestrator-DyGUC7re.d.ts → orchestrator-4wzJrPVm.d.ts} +23 -9
  282. package/dist/orchestrator.d.ts +12 -12
  283. package/dist/orchestrator.js +62 -60
  284. package/dist/patterns-cli.d.ts +3 -1
  285. package/dist/{pipeline-C25Oxtp1.d.ts → pipeline-CgXgdIrF.d.ts} +1 -1
  286. package/dist/policy-runtime.d.ts +3 -1
  287. package/dist/proactive-contention.d.ts +3 -1
  288. package/dist/provenance.d.ts +3 -1
  289. package/dist/{public-http-CMe7NQzj.d.ts → public-http-DhIXYBYI.d.ts} +1 -1
  290. package/dist/{qmd-DkDVCbgF.d.ts → qmd-BppGGxsi.d.ts} +1 -1
  291. package/dist/qmd-preflight.d.ts +4 -2
  292. package/dist/qmd-recall-cache.d.ts +3 -1
  293. package/dist/qmd.d.ts +4 -2
  294. package/dist/recall-concurrency-config.d.ts +3 -1
  295. package/dist/recall-disclosure-escalation.d.ts +3 -1
  296. package/dist/recall-explain-renderer.d.ts +3 -1
  297. package/dist/recall-explain-renderer.js +3 -3
  298. package/dist/recall-memory-map.d.ts +3 -1
  299. package/dist/recall-planner-llm.d.ts +3 -1
  300. package/dist/recall-state.d.ts +3 -1
  301. package/dist/recall-tag-filter.d.ts +3 -1
  302. package/dist/recall-timings.d.ts +3 -1
  303. package/dist/recall-xray-cli.d.ts +3 -1
  304. package/dist/recall-xray-cli.js +4 -4
  305. package/dist/recall-xray-renderer.d.ts +3 -1
  306. package/dist/recall-xray-renderer.js +3 -3
  307. package/dist/recall-xray.d.ts +3 -1
  308. package/dist/recall-xray.js +2 -2
  309. package/dist/reconcile/cursor.d.ts +3 -1
  310. package/dist/reconcile/manifest.d.ts +3 -1
  311. package/dist/reconcile/manifest.js +2 -2
  312. package/dist/reconcile/plan.d.ts +3 -1
  313. package/dist/replay/normalizers/chatgpt.d.ts +3 -1
  314. package/dist/replay/normalizers/claude.d.ts +3 -1
  315. package/dist/replay/normalizers/openclaw.d.ts +3 -1
  316. package/dist/replay/normalizers/shared.d.ts +3 -1
  317. package/dist/replay/runner.d.ts +3 -1
  318. package/dist/replay/types.d.ts +3 -1
  319. package/dist/replica-divergence.d.ts +3 -1
  320. package/dist/replica-peers-config.d.ts +3 -1
  321. package/dist/{resolution-MFY72STR.js → resolution-4552BNRV.js} +14 -4
  322. package/dist/resolve-auth-token.d.ts +3 -1
  323. package/dist/resume-bundles.js +8 -2
  324. package/dist/retrieval-agents.d.ts +4 -2
  325. package/dist/retrieval-tiers.d.ts +3 -1
  326. package/dist/routing/engine.d.ts +3 -1
  327. package/dist/routing/store.d.ts +3 -1
  328. package/dist/salvage-envelope.d.ts +3 -1
  329. package/dist/salvage-envelope.js +1 -1
  330. package/dist/schemas.d.ts +44 -44
  331. package/dist/{scope-profiles-B9xMoFO-.d.ts → scope-profiles-ChZUtxDU.d.ts} +1 -1
  332. package/dist/search/embed-helper.d.ts +3 -1
  333. package/dist/search/factory.d.ts +3 -1
  334. package/dist/search/index.d.ts +3 -1
  335. package/dist/search/lancedb-backend.d.ts +3 -1
  336. package/dist/search/meilisearch-backend.d.ts +3 -1
  337. package/dist/search/noop-backend.d.ts +3 -1
  338. package/dist/search/orama-backend.d.ts +3 -1
  339. package/dist/search/port.d.ts +3 -1
  340. package/dist/search/remote-backend.d.ts +3 -1
  341. package/dist/{semantic-TddhF0y7.d.ts → semantic-BalR6EXU.d.ts} +1 -1
  342. package/dist/{semantic-consolidation-C4uykW84.d.ts → semantic-consolidation-mSPwQSmF.d.ts} +1 -1
  343. package/dist/semantic-consolidation.d.ts +4 -2
  344. package/dist/semantic-consolidation.js +9 -6
  345. package/dist/semantic-rule-promotion.js +4 -4
  346. package/dist/semantic-rule-verifier.d.ts +3 -1
  347. package/dist/semantic-rule-verifier.js +4 -4
  348. package/dist/{service-DCZDZNcV.d.ts → service-BICWLwSP.d.ts} +2 -2
  349. package/dist/session-observer-bands.d.ts +3 -1
  350. package/dist/session-observer-state.d.ts +3 -1
  351. package/dist/shared-context/manager.d.ts +3 -1
  352. package/dist/signal.d.ts +3 -1
  353. package/dist/skills-registry.js +4 -56
  354. package/dist/skills-registry.js.map +1 -1
  355. package/dist/source-agent-qualifier.d.ts +3 -1
  356. package/dist/source-agent-qualifier.js +8 -5
  357. package/dist/{storage-CcKmEjL8.d.ts → storage-B7urx1K3.d.ts} +1 -1
  358. package/dist/storage.d.ts +4 -2
  359. package/dist/storage.js +6 -6
  360. package/dist/subject-config.d.ts +3 -1
  361. package/dist/summarizer.d.ts +3 -1
  362. package/dist/summary-snapshot.d.ts +3 -1
  363. package/dist/support-passport/index.d.ts +43 -43
  364. package/dist/support-passport/index.js +24 -22
  365. package/dist/temporal-supersession.d.ts +4 -2
  366. package/dist/temporal-timeline-recall.d.ts +3 -1
  367. package/dist/temporal-validity.d.ts +3 -1
  368. package/dist/threading.d.ts +3 -1
  369. package/dist/tier-migration.d.ts +4 -2
  370. package/dist/tier-routing.d.ts +3 -1
  371. package/dist/topics.d.ts +3 -1
  372. package/dist/transcript.d.ts +3 -1
  373. package/dist/transfer/types.d.ts +20 -20
  374. package/dist/trust-score-stage.d.ts +3 -1
  375. package/dist/trust-score.d.ts +3 -1
  376. package/dist/{types-Pi0lfaEt.d.ts → types-ETU5N6nB.d.ts} +433 -7
  377. package/dist/types.d.ts +3 -1
  378. package/dist/types.js +1 -1
  379. package/dist/utility-runtime.d.ts +3 -1
  380. package/dist/verified-recall.js +4 -4
  381. package/dist/who-knows-cli.d.ts +40 -40
  382. package/dist/who-knows-cli.js +5 -5
  383. package/dist/who-knows.d.ts +42 -42
  384. package/dist/who-knows.js +4 -4
  385. package/dist/write-envelope.d.ts +3 -1
  386. package/dist/write-envelope.js +1 -1
  387. package/package.json +2 -2
  388. package/src/access-boundary.ts +4 -0
  389. package/src/access-http.ts +6 -5
  390. package/src/access-mcp-admin-tools.ts +24 -0
  391. package/src/access-mcp-output-schemas.ts +14 -0
  392. package/src/access-mcp.ts +2 -2
  393. package/src/access-operations-batch.ts +5 -0
  394. package/src/access-service.ts +27 -0
  395. package/src/access-surface-catalog.test.ts +24 -0
  396. package/src/access-surface-catalog.ts +4 -0
  397. package/src/cli/skills-commands.ts +150 -0
  398. package/src/cli.ts +4 -2
  399. package/src/coding/action-gate.test.ts +341 -0
  400. package/src/coding/action-gate.ts +556 -0
  401. package/src/config.ts +9 -2
  402. package/src/connectors/codex-materialize-runner.ts +16 -0
  403. package/src/connectors/codex-materialize-skills.test.ts +141 -0
  404. package/src/connectors/codex-materialize.ts +58 -40
  405. package/src/connectors/materialize-paths.ts +50 -0
  406. package/src/connectors/materialize-skills.ts +127 -0
  407. package/src/contradiction/contradiction-review.ts +50 -4
  408. package/src/contradiction/contradiction-scan.ts +14 -3
  409. package/src/contradiction/resolution.ts +50 -2
  410. package/src/index.ts +9 -13
  411. package/src/orchestration/recall-rerank-coordinator.ts +123 -4
  412. package/src/orchestration/recall-result-formatter.ts +6 -2
  413. package/src/orchestration/recall-search-pipeline.ts +14 -1
  414. package/src/preferences/drift-config.ts +118 -0
  415. package/src/preferences/drift-recall.ts +133 -0
  416. package/src/preferences/drift-types.ts +87 -0
  417. package/src/preferences/index.ts +12 -0
  418. package/src/preferences/preference-drift.test.ts +690 -0
  419. package/src/preferences/preference-drift.ts +724 -0
  420. package/src/procedural/skill-io.test.ts +190 -0
  421. package/src/procedural/skill-io.ts +220 -0
  422. package/src/procedural/skill-projection.test.ts +214 -0
  423. package/src/procedural/skill-projection.ts +356 -0
  424. package/src/review/review-deck-access.test.ts +325 -0
  425. package/src/review/review-deck-http-base.ts +133 -0
  426. package/src/review/review-deck-mutation.test.ts +417 -0
  427. package/src/review/review-deck-mutation.ts +677 -0
  428. package/src/review/review-deck-snapshot.ts +196 -0
  429. package/src/review/review-deck-surface.ts +117 -0
  430. package/src/review/review-deck.test.ts +347 -0
  431. package/src/review/review-deck.ts +311 -0
  432. package/src/storage.ts +4 -6
  433. package/src/types.ts +9 -6
  434. package/dist/chunk-35NN3ZFA.js.map +0 -1
  435. package/dist/chunk-4KYOLI6M.js.map +0 -1
  436. package/dist/chunk-BWLRUMOG.js.map +0 -1
  437. package/dist/chunk-J275IYMG.js.map +0 -1
  438. package/dist/chunk-LGO6A7GJ.js.map +0 -1
  439. package/dist/chunk-QOS5LBZN.js.map +0 -1
  440. package/dist/chunk-RDFF2NAU.js.map +0 -1
  441. package/dist/chunk-SB7D4BT7.js.map +0 -1
  442. package/dist/chunk-SBDCZ2AX.js.map +0 -1
  443. package/dist/chunk-TF77C7SV.js.map +0 -1
  444. package/dist/chunk-TZNQUNKL.js.map +0 -1
  445. package/dist/chunk-V3MXUL3D.js.map +0 -1
  446. package/dist/chunk-XCTXS7VY.js +0 -402
  447. package/dist/chunk-XCTXS7VY.js.map +0 -1
  448. package/dist/chunk-YLDXWCZP.js.map +0 -1
  449. /package/dist/{auto-sync-H64ZCNIR.js.map → auto-sync-XVMLL2RH.js.map} +0 -0
  450. /package/dist/{chunk-YB42WZCY.js.map → chunk-2IXQSGCU.js.map} +0 -0
  451. /package/dist/{chunk-PE255F4T.js.map → chunk-2MVTAIL3.js.map} +0 -0
  452. /package/dist/{chunk-GDFVPUJ5.js.map → chunk-3NH3VP3U.js.map} +0 -0
  453. /package/dist/{chunk-GNCCUR6K.js.map → chunk-AXGFOFNY.js.map} +0 -0
  454. /package/dist/{chunk-5YQ63T4B.js.map → chunk-BK5G2MHO.js.map} +0 -0
  455. /package/dist/{chunk-LZH5FR2W.js.map → chunk-CQBIN77D.js.map} +0 -0
  456. /package/dist/{chunk-NKKD4ZAU.js.map → chunk-DORFF5N5.js.map} +0 -0
  457. /package/dist/{chunk-SQI57UCJ.js.map → chunk-DUEDOYZD.js.map} +0 -0
  458. /package/dist/{chunk-5NM4OH4P.js.map → chunk-DUZARALI.js.map} +0 -0
  459. /package/dist/{chunk-2E36UXVW.js.map → chunk-ECLJ4LA2.js.map} +0 -0
  460. /package/dist/{chunk-IID2CMUU.js.map → chunk-GHD2LLG4.js.map} +0 -0
  461. /package/dist/{chunk-ZQHI2BZB.js.map → chunk-HF5BUTI6.js.map} +0 -0
  462. /package/dist/{chunk-3DVBKTSO.js.map → chunk-HSZMX3ZJ.js.map} +0 -0
  463. /package/dist/{chunk-S2DPMJXH.js.map → chunk-I23ZHYSL.js.map} +0 -0
  464. /package/dist/{chunk-ODZG724P.js.map → chunk-I2HTKOOP.js.map} +0 -0
  465. /package/dist/{chunk-NTWN6HB2.js.map → chunk-IURMJBGP.js.map} +0 -0
  466. /package/dist/{chunk-OCZIYAE5.js.map → chunk-IWKGOCL6.js.map} +0 -0
  467. /package/dist/{chunk-UXO5IMBK.js.map → chunk-J3ATBB7M.js.map} +0 -0
  468. /package/dist/{chunk-Y7DK7HHJ.js.map → chunk-JPAKBNTM.js.map} +0 -0
  469. /package/dist/{chunk-SPUJNJJC.js.map → chunk-KFIOPZ25.js.map} +0 -0
  470. /package/dist/{chunk-JYYBA7TF.js.map → chunk-KOO37E4Y.js.map} +0 -0
  471. /package/dist/{chunk-OTHZWLUD.js.map → chunk-KPB2QHJZ.js.map} +0 -0
  472. /package/dist/{chunk-CT56C22C.js.map → chunk-LYBIHM4N.js.map} +0 -0
  473. /package/dist/{chunk-3I7ASZN3.js.map → chunk-MFOSZUIT.js.map} +0 -0
  474. /package/dist/{chunk-DZUJ46DO.js.map → chunk-NLEH4RTB.js.map} +0 -0
  475. /package/dist/{chunk-ZO6AXLEH.js.map → chunk-OCCHUEZB.js.map} +0 -0
  476. /package/dist/{chunk-EILZG5VC.js.map → chunk-OU34IQXV.js.map} +0 -0
  477. /package/dist/{chunk-2XDWWPTN.js.map → chunk-OZDFB22S.js.map} +0 -0
  478. /package/dist/{chunk-UIN2BWDD.js.map → chunk-PTZQYCJ4.js.map} +0 -0
  479. /package/dist/{chunk-Z7PBQPJ4.js.map → chunk-QJW4MZSW.js.map} +0 -0
  480. /package/dist/{chunk-R7JAM2XF.js.map → chunk-R2MZCYA6.js.map} +0 -0
  481. /package/dist/{chunk-LBWQ65SX.js.map → chunk-T42L3S6A.js.map} +0 -0
  482. /package/dist/{chunk-2YI72KM3.js.map → chunk-UCKG36HO.js.map} +0 -0
  483. /package/dist/{chunk-SIHSCCUQ.js.map → chunk-UFR6HX7A.js.map} +0 -0
  484. /package/dist/{chunk-CDUUDBWJ.js.map → chunk-VFYRYFLL.js.map} +0 -0
  485. /package/dist/{chunk-XRYZRW54.js.map → chunk-WDXD6ITO.js.map} +0 -0
  486. /package/dist/{chunk-MN4KB2A4.js.map → chunk-YDKF4MSJ.js.map} +0 -0
  487. /package/dist/{chunk-7YQ4IYS2.js.map → chunk-YOXVZJFM.js.map} +0 -0
  488. /package/dist/{chunk-ZWXJBFZU.js.map → chunk-YZJM6CLF.js.map} +0 -0
  489. /package/dist/{chunk-LUNJ3WFO.js.map → chunk-ZK4BFABK.js.map} +0 -0
  490. /package/dist/{contradiction-review-QKJH5DKD.js.map → contradiction-review-WRVLRWHS.js.map} +0 -0
  491. /package/dist/{contradiction-scan-VOTQRRSX.js.map → contradiction-scan-AKUWPX5N.js.map} +0 -0
  492. /package/dist/{resolution-MFY72STR.js.map → resolution-4552BNRV.js.map} +0 -0
@@ -0,0 +1,356 @@
1
+ /**
2
+ * skill-projection.ts — project active `procedure` memories into portable
3
+ * `skills/<slug>/SKILL.md` bundles, and parse hand-authored bundles back into
4
+ * procedure candidates (issue #2369).
5
+ *
6
+ * Pure module: no filesystem, no host coupling. The Codex materializer, the
7
+ * `remnic export skills` CLI, and `remnic import skills` all consume these
8
+ * functions so one slug + format contract serves every surface.
9
+ *
10
+ * Import is INERT by construction: this module only ever returns text and
11
+ * parsed steps. It never resolves, loads, or executes a bundle resource.
12
+ */
13
+
14
+ import { coerceBool, coerceNumber } from "../connectors/coerce.js";
15
+ import { isValidSkillSlug } from "../skills-registry.js";
16
+ import { stripAttributesSuffix } from "../structured-attributes.js";
17
+ import type { MemoryFile, MemoryStatus } from "../types.js";
18
+ import { parseProcedureStepsFromBody, type ProcedureStep } from "./procedure-types.js";
19
+
20
+ /** Provenance frontmatter keys. Namespaced so hosts treat them as opaque. */
21
+ export const SKILL_MEMORY_ID_KEY = "x-remnic-memory-id";
22
+ export const SKILL_UPDATED_KEY = "x-remnic-updated";
23
+ export const SKILL_SOURCE_KEY = "x-remnic-source";
24
+
25
+ /** File name every bundle directory must contain. */
26
+ export const SKILL_FILE_NAME = "SKILL.md";
27
+
28
+ /** Source tag written on imported procedure memories. */
29
+ export const SKILL_IMPORT_SOURCE = "skill-import";
30
+
31
+ /**
32
+ * The ONLY statuses that may be projected (Review Prevention Checklist §41 —
33
+ * define the active set, never an exclusion list). `pending_review`,
34
+ * `rejected`, `quarantined`, `superseded`, `archived`, and `forgotten` are
35
+ * withheld because a projected skill is loaded by a host with no further gate.
36
+ */
37
+ const PROJECTABLE_STATUSES: Partial<Record<MemoryStatus, true>> = { active: true };
38
+
39
+ /** Default projection cap. `0` disables projection entirely. */
40
+ export const DEFAULT_SKILL_PROJECTION_MAX_SKILLS = 20;
41
+
42
+ /** Hard ceiling so a misconfigured cap cannot flood a host skills directory. */
43
+ const MAX_SKILL_PROJECTION_MAX_SKILLS = 500;
44
+
45
+ const MAX_SLUG_LENGTH = 64;
46
+ const MAX_DESCRIPTION_LENGTH = 300;
47
+
48
+ export interface SkillBundleProvenance {
49
+ /** Remnic memory id this bundle was projected from. */
50
+ memoryId: string;
51
+ /** `frontmatter.updated` of the source memory. */
52
+ updated: string;
53
+ /** `frontmatter.source` of the source memory, when present. */
54
+ source?: string;
55
+ }
56
+
57
+ export interface SkillBundle {
58
+ slug: string;
59
+ frontmatter: { name: string; description: string };
60
+ /** Markdown body: the stored procedure body (title line + `## Step N`). */
61
+ body: string;
62
+ provenance: SkillBundleProvenance;
63
+ }
64
+
65
+ export interface ProjectProceduresOptions {
66
+ /** Cap on projected bundles. `0` projects nothing. Default 20. */
67
+ maxSkills?: number;
68
+ /** Slugs a projected bundle must not take (e.g. `BUILTIN_SKILLS` slugs). */
69
+ reservedSlugs?: readonly string[];
70
+ }
71
+
72
+ export interface SkillProjectionConfig {
73
+ enabled: boolean;
74
+ maxSkills: number;
75
+ }
76
+
77
+ /**
78
+ * Parse the `procedural.skillProjection` config block. Mirrors
79
+ * `parseProceduralMaintenanceConfig`: string forms (`"false"`, `"0"`) coerce,
80
+ * unrecognized values throw rather than silently defaulting.
81
+ */
82
+ export function parseSkillProjectionConfig(raw: unknown): SkillProjectionConfig {
83
+ if (raw !== undefined && (raw === null || typeof raw !== "object" || Array.isArray(raw))) {
84
+ throw new Error(
85
+ `procedural.skillProjection must be an object (got ${JSON.stringify(raw)}). Omit the key to keep skill projection disabled (issue #2369).`,
86
+ );
87
+ }
88
+ const block = raw && typeof raw === "object" ? (raw as Record<string, unknown>) : {};
89
+
90
+ let enabled = false;
91
+ if (block.enabled !== undefined) {
92
+ const coerced = coerceBool(block.enabled);
93
+ if (coerced === undefined) {
94
+ throw new Error(
95
+ `procedural.skillProjection.enabled must be a boolean or one of "true"/"false"/"1"/"0"/"yes"/"no"/"on"/"off" (got ${JSON.stringify(block.enabled)}).`,
96
+ );
97
+ }
98
+ enabled = coerced;
99
+ }
100
+
101
+ let maxSkills = DEFAULT_SKILL_PROJECTION_MAX_SKILLS;
102
+ if (block.maxSkills !== undefined) {
103
+ const coerced = coerceNumber(block.maxSkills);
104
+ if (coerced === undefined || !Number.isFinite(coerced)) {
105
+ throw new Error(
106
+ `procedural.skillProjection.maxSkills must be a finite number (got ${JSON.stringify(block.maxSkills)}).`,
107
+ );
108
+ }
109
+ if (!Number.isInteger(coerced)) {
110
+ throw new Error(
111
+ `procedural.skillProjection.maxSkills must be an integer (got ${JSON.stringify(block.maxSkills)}).`,
112
+ );
113
+ }
114
+ if (coerced < 0 || coerced > MAX_SKILL_PROJECTION_MAX_SKILLS) {
115
+ throw new Error(
116
+ `procedural.skillProjection.maxSkills must be between 0 and ${MAX_SKILL_PROJECTION_MAX_SKILLS} (got ${JSON.stringify(block.maxSkills)}). 0 disables projection.`,
117
+ );
118
+ }
119
+ // `0` is a documented disable value (§33) — never clamp it up.
120
+ maxSkills = coerced;
121
+ }
122
+
123
+ return { enabled, maxSkills };
124
+ }
125
+
126
+ /**
127
+ * Sanitize arbitrary text into a slug `isValidSkillSlug` accepts.
128
+ * Deterministic: the same title always yields the same slug.
129
+ */
130
+ export function sanitizeSkillSlug(input: string): string {
131
+ const base = input
132
+ .toLowerCase()
133
+ .replace(/[^a-z0-9]+/g, "-")
134
+ .slice(0, MAX_SLUG_LENGTH);
135
+ const trimmed = trimDashes(base);
136
+ return trimmed.length > 0 && isValidSkillSlug(trimmed) ? trimmed : "procedure";
137
+ }
138
+
139
+ function trimDashes(value: string): string {
140
+ let start = 0;
141
+ let end = value.length;
142
+ while (start < end && value[start] === "-") start += 1;
143
+ while (end > start && value[end - 1] === "-") end -= 1;
144
+ return value.slice(start, end);
145
+ }
146
+
147
+ /** Append a suffix while keeping the slug valid and within the length cap. */
148
+ function withSuffix(base: string, suffix: string): string {
149
+ const room = MAX_SLUG_LENGTH - suffix.length;
150
+ const head = trimDashes(base.slice(0, Math.max(1, room)));
151
+ const candidate = `${head.length > 0 ? head : "procedure"}${suffix}`;
152
+ return isValidSkillSlug(candidate) ? candidate : `procedure${suffix}`;
153
+ }
154
+
155
+ /**
156
+ * Reserve a slug: prefix reserved (built-in) collisions with `user-`, then
157
+ * disambiguate duplicates with a stable `-2`, `-3`, … tiebreak so a batch with
158
+ * repeated titles never writes two bundles to one directory (§37).
159
+ */
160
+ function allocateSlug(base: string, used: Set<string>, reserved: ReadonlySet<string>): string {
161
+ let candidate = reserved.has(base) ? withSuffix(`user-${base}`, "") : base;
162
+ if (!isValidSkillSlug(candidate)) candidate = "procedure";
163
+ if (!used.has(candidate) && !reserved.has(candidate)) {
164
+ used.add(candidate);
165
+ return candidate;
166
+ }
167
+ for (let n = 2; n < 10_000; n++) {
168
+ const next = withSuffix(candidate, `-${n}`);
169
+ if (!used.has(next) && !reserved.has(next)) {
170
+ used.add(next);
171
+ return next;
172
+ }
173
+ }
174
+ // Unreachable in practice (10k distinct suffixes per base slug).
175
+ throw new Error(`skill-projection: could not allocate a unique slug for ${base}`);
176
+ }
177
+
178
+ /** First non-empty line of the body, with a leading markdown heading stripped. */
179
+ export function procedureTitleFromBody(body: string): string {
180
+ for (const line of body.replace(/\r\n/g, "\n").split("\n")) {
181
+ const trimmed = line.trim();
182
+ if (trimmed.length === 0) continue;
183
+ if (/^##\s+Step\s+\d+/i.test(trimmed)) break;
184
+ return trimmed.replace(/^#{1,6}\s*/, "").trim();
185
+ }
186
+ return "";
187
+ }
188
+
189
+ /** Total comparator: newest first, `id` as the stable tiebreak (§12). */
190
+ function compareProcedures(a: MemoryFile, b: MemoryFile): number {
191
+ const aTs = Date.parse(a.frontmatter.updated ?? "");
192
+ const bTs = Date.parse(b.frontmatter.updated ?? "");
193
+ const aVal = Number.isFinite(aTs) ? aTs : 0;
194
+ const bVal = Number.isFinite(bTs) ? bTs : 0;
195
+ if (aVal !== bVal) return bVal - aVal;
196
+ const aId = a.frontmatter.id ?? "";
197
+ const bId = b.frontmatter.id ?? "";
198
+ if (aId < bId) return -1;
199
+ if (aId > bId) return 1;
200
+ return 0;
201
+ }
202
+
203
+ /**
204
+ * Project procedure memories into skill bundles. Filters to `active`
205
+ * procedures, orders deterministically, caps at `maxSkills`, and assigns
206
+ * collision-free slugs.
207
+ */
208
+ export function projectProceduresToSkills(
209
+ memories: readonly MemoryFile[],
210
+ options: ProjectProceduresOptions = {},
211
+ ): SkillBundle[] {
212
+ const maxSkills =
213
+ typeof options.maxSkills === "number" && Number.isInteger(options.maxSkills) && options.maxSkills >= 0
214
+ ? Math.min(MAX_SKILL_PROJECTION_MAX_SKILLS, options.maxSkills)
215
+ : DEFAULT_SKILL_PROJECTION_MAX_SKILLS;
216
+ if (maxSkills === 0) return [];
217
+
218
+ const reserved = new Set((options.reservedSlugs ?? []).map((s) => s.trim().toLowerCase()));
219
+ const candidates = memories
220
+ .filter(
221
+ (m) =>
222
+ m.frontmatter.category === "procedure" &&
223
+ PROJECTABLE_STATUSES[(m.frontmatter.status ?? "active") as MemoryStatus] === true &&
224
+ typeof m.content === "string" &&
225
+ m.content.trim().length > 0,
226
+ )
227
+ .sort(compareProcedures)
228
+ .slice(0, maxSkills);
229
+
230
+ const used = new Set<string>();
231
+ const bundles: SkillBundle[] = [];
232
+ for (const memory of candidates) {
233
+ // Drop the machine "[Attributes: ...]" footer writeMemory appends: a human
234
+ // skill body must not carry it, and leaving it in would let the footer be
235
+ // absorbed into the final step's intent on re-parse.
236
+ const body = stripAttributesSuffix(memory.content.replace(/\r\n/g, "\n")).trim();
237
+ const title = procedureTitleFromBody(body) || memory.frontmatter.id;
238
+ const slug = allocateSlug(sanitizeSkillSlug(title), used, reserved);
239
+ bundles.push({
240
+ slug,
241
+ frontmatter: {
242
+ name: slug,
243
+ description: title.slice(0, MAX_DESCRIPTION_LENGTH),
244
+ },
245
+ body: `${body}\n`,
246
+ provenance: {
247
+ memoryId: memory.frontmatter.id,
248
+ updated: memory.frontmatter.updated,
249
+ ...(memory.frontmatter.source ? { source: memory.frontmatter.source } : {}),
250
+ },
251
+ });
252
+ }
253
+ return bundles;
254
+ }
255
+
256
+ /**
257
+ * Render one bundle as SKILL.md text. Scalars are emitted as YAML
258
+ * double-quoted strings so a title containing `:` or `#` cannot corrupt the
259
+ * frontmatter block.
260
+ */
261
+ export function renderSkillBundle(bundle: SkillBundle): string {
262
+ const lines = [
263
+ "---",
264
+ `name: ${yamlScalar(bundle.frontmatter.name)}`,
265
+ `description: ${yamlScalar(bundle.frontmatter.description)}`,
266
+ `${SKILL_MEMORY_ID_KEY}: ${yamlScalar(bundle.provenance.memoryId)}`,
267
+ `${SKILL_UPDATED_KEY}: ${yamlScalar(bundle.provenance.updated)}`,
268
+ ];
269
+ if (bundle.provenance.source) {
270
+ lines.push(`${SKILL_SOURCE_KEY}: ${yamlScalar(bundle.provenance.source)}`);
271
+ }
272
+ lines.push("---", "");
273
+ return `${lines.join("\n")}\n${bundle.body.trimEnd()}\n`;
274
+ }
275
+
276
+ function yamlScalar(value: string): string {
277
+ return JSON.stringify(value.replace(/\r?\n/g, " ").trim());
278
+ }
279
+
280
+ export interface ParsedSkillBundle {
281
+ /** Directory name the bundle was read from (already sanitized by the caller). */
282
+ slug: string;
283
+ name?: string;
284
+ description?: string;
285
+ /** Markdown body with the frontmatter block removed. */
286
+ body: string;
287
+ /** Parsed `## Step N` sections, or `null` for a step-less body. */
288
+ steps: ProcedureStep[] | null;
289
+ provenance: { memoryId?: string; updated?: string; source?: string };
290
+ }
291
+
292
+ /**
293
+ * Parse SKILL.md text. Frontmatter is optional; unknown keys are ignored.
294
+ * Returns `null` when there is no body to import.
295
+ */
296
+ export function parseSkillBundle(text: string, slug: string): ParsedSkillBundle | null {
297
+ const lines = text.replace(/\r\n/g, "\n").split("\n");
298
+ // Line scan rather than a lazy `[\s\S]*?` fence regex (issue #2439).
299
+ let frontmatter: Record<string, string> = {};
300
+ let bodyLines = lines;
301
+ if (lines[0]?.trim() === "---") {
302
+ const close = lines.findIndex((line, idx) => idx > 0 && line.trim() === "---");
303
+ if (close !== -1) {
304
+ frontmatter = parseFlatFrontmatter(lines.slice(1, close).join("\n"));
305
+ bodyLines = lines.slice(close + 1);
306
+ }
307
+ }
308
+ const body = bodyLines.join("\n").trim();
309
+ if (body.length === 0) return null;
310
+ return {
311
+ slug,
312
+ name: frontmatter.name,
313
+ description: frontmatter.description,
314
+ body,
315
+ steps: parseProcedureStepsFromBody(body),
316
+ provenance: {
317
+ memoryId: frontmatter[SKILL_MEMORY_ID_KEY],
318
+ updated: frontmatter[SKILL_UPDATED_KEY],
319
+ source: frontmatter[SKILL_SOURCE_KEY],
320
+ },
321
+ };
322
+ }
323
+
324
+ /**
325
+ * Minimal flat `key: value` frontmatter reader. Nested blocks and sequences
326
+ * (e.g. `allowed-tools:`) are skipped — the import path only consumes scalars.
327
+ */
328
+ function parseFlatFrontmatter(block: string): Record<string, string> {
329
+ const out: Record<string, string> = {};
330
+ for (const line of block.split("\n")) {
331
+ if (/^\s/.test(line) || line.trim().startsWith("#")) continue;
332
+ const colon = line.indexOf(":");
333
+ if (colon <= 0) continue;
334
+ const key = line.slice(0, colon).trim();
335
+ const raw = line.slice(colon + 1).trim();
336
+ if (key.length === 0 || raw.length === 0) continue;
337
+ out[key] = unquoteScalar(raw);
338
+ }
339
+ return out;
340
+ }
341
+
342
+ function unquoteScalar(raw: string): string {
343
+ if (raw.startsWith('"') && raw.endsWith('"') && raw.length >= 2) {
344
+ try {
345
+ const parsed = JSON.parse(raw) as unknown;
346
+ if (typeof parsed === "string") return parsed;
347
+ } catch {
348
+ // fall through to the literal slice below
349
+ }
350
+ return raw.slice(1, -1);
351
+ }
352
+ if (raw.startsWith("'") && raw.endsWith("'") && raw.length >= 2) {
353
+ return raw.slice(1, -1);
354
+ }
355
+ return raw;
356
+ }
@@ -0,0 +1,325 @@
1
+ import assert from "node:assert/strict";
2
+ import { request as httpRequest } from "node:http";
3
+ import test from "node:test";
4
+
5
+ import { EngramAccessHttpServer } from "../access-http.js";
6
+ import type { EngramAccessService } from "../access-service.js";
7
+ import type {
8
+ ReviewDeckActionReceipt,
9
+ ReviewDeckActionRequest,
10
+ ReviewDeckPage,
11
+ ReviewDeckUndoRequest,
12
+ } from "./review-deck.js";
13
+
14
+ const TOKEN = "test-token";
15
+
16
+ function deferred<T = void>(): {
17
+ promise: Promise<T>;
18
+ resolve: (value: T | PromiseLike<T>) => void;
19
+ reject: (reason?: unknown) => void;
20
+ } {
21
+ let resolve!: (value: T | PromiseLike<T>) => void;
22
+ let reject!: (reason?: unknown) => void;
23
+ const promise = new Promise<T>((resolvePromise, rejectPromise) => {
24
+ resolve = resolvePromise;
25
+ reject = rejectPromise;
26
+ });
27
+ return { promise, resolve, reject };
28
+ }
29
+
30
+ function page(): ReviewDeckPage {
31
+ return { schemaVersion: 1, items: [], total: 0 };
32
+ }
33
+
34
+ function receipt(
35
+ action: ReviewDeckActionReceipt["action"] = "keep",
36
+ ): ReviewDeckActionReceipt {
37
+ return {
38
+ schemaVersion: 1,
39
+ receiptId: "receipt-1",
40
+ itemId: "item-1",
41
+ action,
42
+ outcome: "applied",
43
+ effect: action,
44
+ undoAvailable: action !== "undo",
45
+ };
46
+ }
47
+
48
+ function mockService(overrides: Partial<EngramAccessService> = {}): EngramAccessService {
49
+ return {
50
+ reviewDeckEnabled: true,
51
+ reviewDeckList: async () => page(),
52
+ reviewDeckAction: async () => receipt("keep"),
53
+ reviewDeckUndo: async () => receipt("undo"),
54
+ reviewQueue: async () => ({ found: true, runId: "existing-review" }),
55
+ ...overrides,
56
+ } as unknown as EngramAccessService;
57
+ }
58
+
59
+ async function startServer(
60
+ service: EngramAccessService,
61
+ extras: ConstructorParameters<typeof EngramAccessHttpServer>[0] extends infer T
62
+ ? T extends { service: EngramAccessService }
63
+ ? Omit<T, "service" | "port" | "adminConsoleEnabled">
64
+ : never
65
+ : never = { authToken: TOKEN },
66
+ ): Promise<{ port: number; stop: () => Promise<void> }> {
67
+ const server = new EngramAccessHttpServer({
68
+ service,
69
+ port: 0,
70
+ adminConsoleEnabled: false,
71
+ ...extras,
72
+ });
73
+ const status = await server.start();
74
+ return { port: status.port, stop: () => server.stop() };
75
+ }
76
+
77
+ async function jsonRequest(
78
+ port: number,
79
+ path: string,
80
+ options: {
81
+ method?: string;
82
+ token?: string;
83
+ body?: unknown;
84
+ } = {},
85
+ ): Promise<{ status: number; body: Record<string, unknown> }> {
86
+ const res = await fetch(`http://127.0.0.1:${port}${path}`, {
87
+ method: options.method ?? "GET",
88
+ headers: {
89
+ authorization: `Bearer ${options.token ?? TOKEN}`,
90
+ ...(options.body !== undefined ? { "content-type": "application/json" } : {}),
91
+ },
92
+ body: options.body !== undefined ? JSON.stringify(options.body) : undefined,
93
+ });
94
+ return { status: res.status, body: (await res.json()) as Record<string, unknown> };
95
+ }
96
+
97
+ const keepBody: ReviewDeckActionRequest = {
98
+ schemaVersion: 1,
99
+ itemId: "item-1",
100
+ revision: "rv1:abc",
101
+ action: "keep",
102
+ idempotencyKey: "key-1",
103
+ };
104
+
105
+ const undoBody: ReviewDeckUndoRequest = {
106
+ schemaVersion: 1,
107
+ receiptId: "receipt-1",
108
+ expectedRevision: "rv1:abc",
109
+ idempotencyKey: "key-undo",
110
+ };
111
+
112
+ test("canonical and engram alias list routes return schemaVersion 1", async () => {
113
+ const { port, stop } = await startServer(mockService());
114
+ try {
115
+ for (const prefix of ["/remnic/v1", "/engram/v1"] as const) {
116
+ const listed = await jsonRequest(port, `${prefix}/review/deck?limit=1`);
117
+ assert.equal(listed.status, 200);
118
+ assert.equal(listed.body.schemaVersion, 1);
119
+ const acted = await jsonRequest(port, `${prefix}/review/deck/action`, {
120
+ method: "POST",
121
+ body: keepBody,
122
+ });
123
+ assert.equal(acted.status, 200);
124
+ assert.equal(acted.body.schemaVersion, 1);
125
+ const undone = await jsonRequest(port, `${prefix}/review/deck/undo`, {
126
+ method: "POST",
127
+ body: undoBody,
128
+ });
129
+ assert.equal(undone.status, 200);
130
+ assert.equal(undone.body.schemaVersion, 1);
131
+ }
132
+ } finally {
133
+ await stop();
134
+ }
135
+ });
136
+
137
+ test("invalid cursor, limit, action, revision, and missing idempotency key are client errors", async () => {
138
+ const { port, stop } = await startServer(mockService());
139
+ try {
140
+ const cases: Array<{ path: string; method?: string; body?: unknown; message: RegExp }> = [
141
+ { path: "/engram/v1/review/deck?limit=1&cursor=%%%", message: /cursor is malformed/ },
142
+ { path: "/engram/v1/review/deck", message: /limit is required/ },
143
+ { path: "/engram/v1/review/deck?limit=abc", message: /limit must be an integer/ },
144
+ { path: "/engram/v1/review/deck?limit=0", message: /limit must be an integer from 1 to 100/ },
145
+ { path: "/engram/v1/review/deck?limit=101", message: /limit must be an integer from 1 to 100/ },
146
+ {
147
+ path: "/engram/v1/review/deck/action",
148
+ method: "POST",
149
+ body: { ...keepBody, action: "later" },
150
+ message: /action must be one of/,
151
+ },
152
+ {
153
+ path: "/engram/v1/review/deck/action",
154
+ method: "POST",
155
+ body: { ...keepBody, revision: "" },
156
+ message: /revision is required/,
157
+ },
158
+ {
159
+ path: "/engram/v1/review/deck/action",
160
+ method: "POST",
161
+ body: { ...keepBody, idempotencyKey: undefined },
162
+ message: /idempotencyKey is required/,
163
+ },
164
+ {
165
+ path: "/engram/v1/review/deck/action",
166
+ method: "POST",
167
+ body: { ...keepBody, action: "prepare_fix", correctionText: " " },
168
+ message: /correctionText is required/,
169
+ },
170
+ ];
171
+ for (const item of cases) {
172
+ const result = await jsonRequest(port, item.path, { method: item.method, body: item.body });
173
+ assert.equal(result.status, 400, item.path);
174
+ assert.match(String(result.body.error), item.message);
175
+ }
176
+ } finally {
177
+ await stop();
178
+ }
179
+ });
180
+
181
+ test("POST body principal and namespace are ignored in favor of the boundary", async () => {
182
+ let seen: { namespace?: string; principal?: string } | undefined;
183
+ const { port, stop } = await startServer(
184
+ mockService({
185
+ reviewDeckAction: async (_req, opts) => {
186
+ seen = { namespace: opts.namespace, principal: opts.principal };
187
+ return receipt("keep");
188
+ },
189
+ }),
190
+ { authToken: TOKEN, principal: "boundary-principal" },
191
+ );
192
+ try {
193
+ const result = await jsonRequest(
194
+ port,
195
+ "/engram/v1/review/deck/action?namespace=boundary-ns",
196
+ {
197
+ method: "POST",
198
+ body: {
199
+ ...keepBody,
200
+ namespace: "body-ns",
201
+ principal: "body-principal",
202
+ },
203
+ },
204
+ );
205
+ assert.equal(result.status, 200);
206
+ assert.deepEqual(seen, { namespace: "boundary-ns", principal: "boundary-principal" });
207
+ } finally {
208
+ await stop();
209
+ }
210
+ });
211
+
212
+ test("a read-only token cannot call action or undo", async () => {
213
+ const { port, stop } = await startServer(mockService(), {
214
+ authTokenEntriesGetter: () => [
215
+ { token: "reader", capabilities: { version: 1, ops: ["review_deck_list"] } },
216
+ ],
217
+ });
218
+ try {
219
+ const listed = await jsonRequest(port, "/engram/v1/review/deck?limit=1", { token: "reader" });
220
+ assert.equal(listed.status, 200);
221
+ const acted = await jsonRequest(port, "/engram/v1/review/deck/action", {
222
+ method: "POST",
223
+ token: "reader",
224
+ body: keepBody,
225
+ });
226
+ assert.equal(acted.status, 403);
227
+ const undone = await jsonRequest(port, "/engram/v1/review/deck/undo", {
228
+ method: "POST",
229
+ token: "reader",
230
+ body: undoBody,
231
+ });
232
+ assert.equal(undone.status, 403);
233
+ } finally {
234
+ await stop();
235
+ }
236
+ });
237
+
238
+ test("disabled gate returns 404 for deck routes while review-queue still works", async () => {
239
+ let queueCalled = false;
240
+ let deckCalled = false;
241
+ const { port, stop } = await startServer(
242
+ mockService({
243
+ reviewDeckEnabled: false,
244
+ reviewDeckList: async () => {
245
+ deckCalled = true;
246
+ return page();
247
+ },
248
+ reviewQueue: async () => {
249
+ queueCalled = true;
250
+ return { found: true, runId: "existing-review" };
251
+ },
252
+ }),
253
+ );
254
+ try {
255
+ for (const path of [
256
+ "/engram/v1/review/deck?limit=1",
257
+ "/remnic/v1/review/deck?limit=1",
258
+ "/engram/v1/review/deck/action",
259
+ "/remnic/v1/review/deck/undo",
260
+ ]) {
261
+ const method = path.includes("/action") || path.includes("/undo") ? "POST" : "GET";
262
+ const result = await jsonRequest(port, path, {
263
+ method,
264
+ body: method === "POST" ? keepBody : undefined,
265
+ });
266
+ assert.equal(result.status, 404, path);
267
+ assert.equal(result.body.code, "not_found");
268
+ }
269
+ assert.equal(deckCalled, false);
270
+ const queue = await jsonRequest(port, "/engram/v1/review-queue");
271
+ assert.equal(queue.status, 200);
272
+ assert.equal(queueCalled, true);
273
+ } finally {
274
+ await stop();
275
+ }
276
+ });
277
+
278
+ test("cancellation reaches the deck action executor", async () => {
279
+ const started = deferred<void>();
280
+ const settled = deferred<void>();
281
+ const forceRelease = deferred<void>();
282
+ let observed: AbortSignal | undefined;
283
+ const { port, stop } = await startServer(
284
+ mockService({
285
+ reviewDeckAction: async (_req, opts) => {
286
+ observed = opts.signal;
287
+ started.resolve();
288
+ try {
289
+ await Promise.race([
290
+ forceRelease.promise,
291
+ new Promise<void>((_resolve, reject) => {
292
+ opts.signal?.addEventListener("abort", () => reject(opts.signal?.reason), { once: true });
293
+ }),
294
+ ]);
295
+ } finally {
296
+ settled.resolve();
297
+ }
298
+ if (opts.signal?.aborted) throw opts.signal.reason;
299
+ return receipt("keep");
300
+ },
301
+ }),
302
+ );
303
+ try {
304
+ const client = httpRequest({
305
+ host: "127.0.0.1",
306
+ port,
307
+ path: "/engram/v1/review/deck/action",
308
+ method: "POST",
309
+ headers: {
310
+ authorization: `Bearer ${TOKEN}`,
311
+ "content-type": "application/json",
312
+ },
313
+ });
314
+ client.on("error", () => {});
315
+ client.end(JSON.stringify(keepBody));
316
+ await started.promise;
317
+ assert.ok(observed, "abort signal must reach the executor");
318
+ client.destroy();
319
+ await settled.promise;
320
+ assert.equal(observed.aborted, true);
321
+ } finally {
322
+ forceRelease.resolve();
323
+ await stop();
324
+ }
325
+ });