@remnic/core 9.64.1 → 9.64.3

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 (462) hide show
  1. package/dist/access-admin-ops-surface.d.ts +12 -11
  2. package/dist/access-admin-ops-surface.js +23 -22
  3. package/dist/access-authorization-probe.d.ts +12 -11
  4. package/dist/access-authorization-probe.js +24 -23
  5. package/dist/access-boundary.d.ts +13 -12
  6. package/dist/access-boundary.js +23 -22
  7. package/dist/access-cli.js +70 -68
  8. package/dist/access-cli.js.map +1 -1
  9. package/dist/access-coding-context-resolution.d.ts +1 -1
  10. package/dist/access-extraction-force-flush.d.ts +12 -11
  11. package/dist/access-extraction-force-flush.js +23 -22
  12. package/dist/access-health-types.d.ts +1 -1
  13. package/dist/access-http-lcm-compaction.d.ts +12 -11
  14. package/dist/access-http-lifecycle-flush.d.ts +12 -11
  15. package/dist/access-http-offline-stream.d.ts +12 -11
  16. package/dist/access-http-query.d.ts +2 -2
  17. package/dist/access-http-query.js +25 -24
  18. package/dist/access-http.d.ts +13 -12
  19. package/dist/access-http.js +40 -39
  20. package/dist/access-identity-continuity-surface.d.ts +9 -9
  21. package/dist/access-identity-continuity-surface.js +23 -22
  22. package/dist/access-lcm-surface.d.ts +12 -11
  23. package/dist/access-lcm-surface.js +23 -22
  24. package/dist/access-mcp-output-schemas.js +1 -1
  25. package/dist/access-mcp.d.ts +12 -186
  26. package/dist/access-mcp.js +32 -31
  27. package/dist/access-memory-search-fanout.d.ts +2 -2
  28. package/dist/{access-namespace-preflight-Dj9uR4Cq.d.ts → access-namespace-preflight-CYeI1R2_.d.ts} +1 -1
  29. package/dist/access-namespace-preflight.d.ts +3 -3
  30. package/dist/access-namespace-preflight.js +23 -22
  31. package/dist/access-observe-write-surface.d.ts +12 -11
  32. package/dist/access-observe-write-surface.js +23 -22
  33. package/dist/access-offline-manifest.d.ts +9 -9
  34. package/dist/access-operations-batch.js +26 -25
  35. package/dist/access-operations.d.ts +16 -15
  36. package/dist/access-operations.js +29 -28
  37. package/dist/access-recall-concurrency.d.ts +12 -11
  38. package/dist/access-recall-concurrency.js +23 -22
  39. package/dist/access-recall-response.d.ts +12 -11
  40. package/dist/access-recall-response.js +23 -22
  41. package/dist/access-recall-surface.d.ts +12 -11
  42. package/dist/access-recall-surface.js +23 -22
  43. package/dist/access-schema.d.ts +88 -88
  44. package/dist/access-schema.js +3 -3
  45. package/dist/{access-service-Bd0lzaHp.d.ts → access-service-BKtdXnyk.d.ts} +358 -76
  46. package/dist/access-service-helpers.d.ts +12 -11
  47. package/dist/access-service.d.ts +12 -11
  48. package/dist/access-service.js +23 -22
  49. package/dist/access-surface-catalog.d.ts +12 -11
  50. package/dist/access-surface-catalog.js +27 -24
  51. package/dist/access-surface-catalog.js.map +1 -1
  52. package/dist/access-wearables-meetings-surface.d.ts +3 -3
  53. package/dist/action-confidence.d.ts +1 -1
  54. package/dist/active-memory-bridge.d.ts +1 -1
  55. package/dist/active-recall.d.ts +1 -1
  56. package/dist/active-recall.js +1 -1
  57. package/dist/adapters/index.js +4 -4
  58. package/dist/adapters/registry.js +2 -2
  59. package/dist/ambient-provenance.d.ts +1 -1
  60. package/dist/artifact-search.d.ts +1 -1
  61. package/dist/behavior-learner.d.ts +1 -1
  62. package/dist/behavior-signals.d.ts +1 -1
  63. package/dist/bootstrap.d.ts +9 -9
  64. package/dist/briefing-window.d.ts +2 -2
  65. package/dist/briefing.d.ts +2 -2
  66. package/dist/briefing.js +10 -10
  67. package/dist/buffer-surprise-report.d.ts +1 -1
  68. package/dist/buffer-turn-helpers.d.ts +1 -1
  69. package/dist/buffer.d.ts +2 -2
  70. package/dist/bulk-import/index.d.ts +3 -3
  71. package/dist/calibration.d.ts +1 -1
  72. package/dist/capabilities.d.ts +1 -1
  73. package/dist/{capsule-crypto-GWVG7LGC.js → capsule-crypto-7FJQINUR.js} +2 -2
  74. package/dist/{catalog-rKYbN7zF.d.ts → catalog-CLAqQO2L.d.ts} +1 -1
  75. package/dist/causal-behavior.d.ts +1 -1
  76. package/dist/causal-consolidation.d.ts +1 -1
  77. package/dist/causal-consolidation.js +11 -11
  78. package/dist/causal-trajectory-graph.d.ts +1 -1
  79. package/dist/{chunk-D267K4V5.js → chunk-246HFJVG.js} +2 -2
  80. package/dist/{chunk-OWHERGF2.js → chunk-2NLLXCJG.js} +2 -2
  81. package/dist/{chunk-2RZCOG63.js → chunk-2QI2JBLQ.js} +359 -238
  82. package/dist/chunk-2QI2JBLQ.js.map +1 -0
  83. package/dist/{chunk-WNO5W2TP.js → chunk-3A46U7XG.js} +2 -2
  84. package/dist/{chunk-XFAWGUNX.js → chunk-3LOQN3TO.js} +10 -5
  85. package/dist/chunk-3LOQN3TO.js.map +1 -0
  86. package/dist/{chunk-5Q5BEWJ3.js → chunk-44DSGZFF.js} +2 -2
  87. package/dist/{chunk-VENMDW4U.js → chunk-55SJFHVD.js} +6 -6
  88. package/dist/{chunk-VCBG52MM.js → chunk-5HERQ5FX.js} +7 -7
  89. package/dist/{chunk-IRXMJLTW.js → chunk-5HK3CJAR.js} +2 -2
  90. package/dist/{chunk-VSKA2ATE.js → chunk-6LTCUN3T.js} +2 -2
  91. package/dist/{chunk-IHPYTG6F.js → chunk-7BVO64UC.js} +2 -2
  92. package/dist/{chunk-ZUIVJ3BB.js → chunk-7V3AZWWZ.js} +4 -4
  93. package/dist/{chunk-Y5ZIQFWH.js → chunk-A2IBK3TG.js} +2 -2
  94. package/dist/{chunk-6I6IOMKS.js → chunk-C6AKYOFO.js} +2 -2
  95. package/dist/{chunk-ZGGTIBWN.js → chunk-CKZHKFY3.js} +3 -3
  96. package/dist/{chunk-FMGTFMT3.js → chunk-DA2O3F5V.js} +25 -11
  97. package/dist/chunk-DA2O3F5V.js.map +1 -0
  98. package/dist/{chunk-GSQDPL45.js → chunk-DC4FJY2G.js} +22 -7
  99. package/dist/{chunk-GSQDPL45.js.map → chunk-DC4FJY2G.js.map} +1 -1
  100. package/dist/{chunk-JE3AKPOO.js → chunk-DG6MJD7W.js} +2 -2
  101. package/dist/{chunk-P4SD7BSA.js → chunk-DHKV6E4A.js} +2 -2
  102. package/dist/{chunk-KOE3RLNN.js → chunk-EJDLQRUO.js} +2 -2
  103. package/dist/{chunk-VD2OT77P.js → chunk-GEULB2VI.js} +2 -1
  104. package/dist/chunk-GEULB2VI.js.map +1 -0
  105. package/dist/{chunk-DRS3OX77.js → chunk-GVRLED7R.js} +2 -2
  106. package/dist/{chunk-EAWJSY2Z.js → chunk-H5CGAD7L.js} +1 -1
  107. package/dist/{chunk-DLZBOEJY.js → chunk-IFK3PVM7.js} +2 -2
  108. package/dist/{chunk-E7MYSCSL.js → chunk-IJXECCUV.js} +2 -2
  109. package/dist/{chunk-RKNJBZ55.js → chunk-JBPKEARU.js} +4 -4
  110. package/dist/{chunk-NMQXUGTU.js → chunk-JCSUNXYJ.js} +3 -3
  111. package/dist/{chunk-5W7CTZ2E.js → chunk-KQAFEZQX.js} +4 -4
  112. package/dist/{chunk-YY63AMGP.js → chunk-KRPE7ANR.js} +2 -2
  113. package/dist/{chunk-AGC3Q53R.js → chunk-LOETWOEB.js} +2 -2
  114. package/dist/{chunk-7X35RPN3.js → chunk-LZKCMK3U.js} +2 -2
  115. package/dist/{chunk-4KKVDOCD.js → chunk-MJRVF7SF.js} +26 -25
  116. package/dist/chunk-MJRVF7SF.js.map +1 -0
  117. package/dist/{chunk-K547KS3X.js → chunk-ML3U4KPR.js} +4 -4
  118. package/dist/{chunk-HIEWDJ2O.js → chunk-MSTNSVXI.js} +2 -1
  119. package/dist/chunk-MSTNSVXI.js.map +1 -0
  120. package/dist/{chunk-CI6YIT5S.js → chunk-NO7B6DRB.js} +2 -2
  121. package/dist/{chunk-Q3IRE6E4.js → chunk-ON2P3SHG.js} +2 -2
  122. package/dist/{chunk-2Q4UAPLD.js → chunk-OQIRBGUU.js} +4 -4
  123. package/dist/{chunk-WDFXRHOZ.js → chunk-PE76XIDM.js} +3 -3
  124. package/dist/{chunk-MVIYRRVJ.js → chunk-PMVPCZJZ.js} +5 -5
  125. package/dist/{chunk-VCNGVU62.js → chunk-PVIXAMWM.js} +2 -2
  126. package/dist/{chunk-QHNO6AND.js → chunk-RWLRKMZK.js} +2 -2
  127. package/dist/{chunk-UWSETW6O.js → chunk-SB6YBB2V.js} +2 -2
  128. package/dist/{chunk-DTQ3OB7O.js → chunk-SHQFYZTD.js} +2 -2
  129. package/dist/chunk-TKI2WOL5.js +256 -0
  130. package/dist/chunk-TKI2WOL5.js.map +1 -0
  131. package/dist/chunk-TY35YQ6E.js +77 -0
  132. package/dist/chunk-TY35YQ6E.js.map +1 -0
  133. package/dist/{chunk-AL43367I.js → chunk-UMDZXW5J.js} +23 -1
  134. package/dist/chunk-UMDZXW5J.js.map +1 -0
  135. package/dist/{chunk-G5OB4XZX.js → chunk-VANZKHTN.js} +4 -4
  136. package/dist/{chunk-IPUUMLSM.js → chunk-VLES5S4K.js} +271 -62
  137. package/dist/chunk-VLES5S4K.js.map +1 -0
  138. package/dist/{chunk-DPPTG6VJ.js → chunk-VRYEXPRX.js} +1 -1
  139. package/dist/chunk-VRYEXPRX.js.map +1 -0
  140. package/dist/{chunk-3CYVTO6A.js → chunk-VUP47UJI.js} +3 -3
  141. package/dist/{chunk-OTVHRZZD.js → chunk-WBM5NR4E.js} +2 -2
  142. package/dist/{chunk-UVYI6VIX.js → chunk-X7Y7WX73.js} +1 -1
  143. package/dist/{chunk-7D3TTGHY.js → chunk-XACYILRA.js} +38 -12
  144. package/dist/chunk-XACYILRA.js.map +1 -0
  145. package/dist/{chunk-B2GICNOJ.js → chunk-XH4IQVTN.js} +2 -2
  146. package/dist/{chunk-OWAYQK5V.js → chunk-XZUCNVGE.js} +8 -8
  147. package/dist/{chunk-4FSCGYTQ.js → chunk-YFQTDE7N.js} +2 -2
  148. package/dist/{chunk-RMB22Q3R.js → chunk-YXGU3MDQ.js} +2 -2
  149. package/dist/{chunk-XSPRZZEX.js → chunk-Z6CJLYXT.js} +4 -4
  150. package/dist/{chunk-DZ2AVS2H.js → chunk-ZSYE2QVJ.js} +2 -2
  151. package/dist/{cli-0dDmOsJ8.d.ts → cli-CLvBewKf.d.ts} +5 -5
  152. package/dist/cli.d.ts +13 -13
  153. package/dist/cli.js +56 -55
  154. package/dist/coding/pre-action-gate.d.ts +1 -1
  155. package/dist/compounding/engine.d.ts +2 -2
  156. package/dist/compounding/engine.js +10 -10
  157. package/dist/compounding/preference-consolidator.d.ts +1 -1
  158. package/dist/compression-optimizer.d.ts +1 -1
  159. package/dist/config.d.ts +1 -1
  160. package/dist/config.js +1 -1
  161. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  162. package/dist/connectors/codex-materialize-runner.js +10 -10
  163. package/dist/connectors/codex-materialize.d.ts +1 -1
  164. package/dist/connectors/index.d.ts +1 -1
  165. package/dist/connectors/index.js +10 -10
  166. package/dist/consolidation-provenance-check.d.ts +2 -2
  167. package/dist/consolidation-undo.d.ts +2 -2
  168. package/dist/contradiction/index.d.ts +2 -2
  169. package/dist/contradiction/index.js +4 -4
  170. package/dist/converge-config.d.ts +1 -1
  171. package/dist/convergence-refresh.d.ts +2 -2
  172. package/dist/convergence-refresh.js +12 -12
  173. package/dist/conversation-index/backend.d.ts +1 -1
  174. package/dist/conversation-index/chunker.d.ts +1 -1
  175. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  176. package/dist/conversation-index/indexer.d.ts +1 -1
  177. package/dist/conversation-index/search.d.ts +1 -1
  178. package/dist/corpus-watermark.d.ts +1 -1
  179. package/dist/corpus-watermark.js +12 -12
  180. package/dist/day-summary.d.ts +1 -1
  181. package/dist/delinearize.d.ts +1 -1
  182. package/dist/dependency-propagation-config.d.ts +1 -1
  183. package/dist/{dependency-propagation-delivery-Cr8u-XwC.d.ts → dependency-propagation-delivery-DMqIw9Zh.d.ts} +1 -1
  184. package/dist/direct-answer-wiring.d.ts +1 -1
  185. package/dist/direct-answer.d.ts +1 -1
  186. package/dist/embedding-fallback.d.ts +1 -1
  187. package/dist/enrichment/index.d.ts +1 -1
  188. package/dist/entity-origin-fields.d.ts +1 -1
  189. package/dist/entity-retrieval.d.ts +2 -2
  190. package/dist/entity-retrieval.js +10 -10
  191. package/dist/entity-schema.d.ts +1 -1
  192. package/dist/episodic-context.d.ts +1 -1
  193. package/dist/explicit-capture.d.ts +9 -9
  194. package/dist/external-wiki-access.d.ts +12 -11
  195. package/dist/external-wiki-access.js +24 -23
  196. package/dist/external-wiki-collection-registration.d.ts +1 -1
  197. package/dist/external-wiki-collection.d.ts +1 -1
  198. package/dist/external-wiki-mcp-tools.d.ts +12 -13
  199. package/dist/extraction-error-classification.d.ts +1 -1
  200. package/dist/extraction-faithfulness.d.ts +1 -1
  201. package/dist/extraction-judge-telemetry.d.ts +1 -1
  202. package/dist/extraction-judge-training.d.ts +1 -1
  203. package/dist/extraction-judge.d.ts +1 -1
  204. package/dist/extraction-liveness.d.ts +1 -1
  205. package/dist/extraction-normalization.d.ts +1 -1
  206. package/dist/extraction-prompt.d.ts +1 -1
  207. package/dist/extraction-source-grounding-rules.d.ts +1 -1
  208. package/dist/extraction-source-grounding.d.ts +1 -1
  209. package/dist/extraction.d.ts +1 -1
  210. package/dist/extraction.js +10 -10
  211. package/dist/fallback-llm.d.ts +1 -1
  212. package/dist/graph-dashboard-diff.d.ts +1 -1
  213. package/dist/graph-dashboard-key.d.ts +1 -1
  214. package/dist/graph-dashboard-parser.d.ts +1 -1
  215. package/dist/graph-edge-reinforcement.d.ts +1 -1
  216. package/dist/graph-path-reconstruction.d.ts +1 -1
  217. package/dist/graph-path-scoring.d.ts +1 -1
  218. package/dist/graph-snapshot.d.ts +1 -1
  219. package/dist/graph.d.ts +1 -1
  220. package/dist/harmonic-retrieval.js +1 -1
  221. package/dist/importance.d.ts +1 -1
  222. package/dist/importers/index.d.ts +1 -1
  223. package/dist/in-flight-reads.d.ts +1 -1
  224. package/dist/index.d.ts +709 -700
  225. package/dist/index.js +116 -80
  226. package/dist/intent.d.ts +1 -1
  227. package/dist/lcm/engine.d.ts +1 -1
  228. package/dist/lcm/engine.js +3 -3
  229. package/dist/lcm/index.d.ts +1 -1
  230. package/dist/lcm/index.js +11 -11
  231. package/dist/lcm/tools.d.ts +1 -1
  232. package/dist/lifecycle.d.ts +1 -1
  233. package/dist/live-connectors-runner.d.ts +1 -1
  234. package/dist/local-llm.d.ts +1 -1
  235. package/dist/local-model-endpoint.d.ts +1 -1
  236. package/dist/maintenance/memory-governance.d.ts +1 -1
  237. package/dist/maintenance/memory-governance.js +10 -10
  238. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
  239. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +10 -10
  240. package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
  241. package/dist/maintenance/rebuild-memory-projection.js +11 -11
  242. package/dist/{maintenance-BpNjuZk4.d.ts → maintenance-DITiehFX.d.ts} +3 -3
  243. package/dist/mcp-memory-inspector-app.d.ts +12 -11
  244. package/dist/mcp-read-only-tools.js +1 -1
  245. package/dist/memory-action-policy.d.ts +1 -1
  246. package/dist/memory-cache.d.ts +1 -1
  247. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  248. package/dist/memory-projection-store.d.ts +1 -1
  249. package/dist/memory-provenance.d.ts +1 -1
  250. package/dist/memory-snapshot.d.ts +1 -1
  251. package/dist/memory-worth-outcomes.d.ts +2 -2
  252. package/dist/models-json.d.ts +1 -1
  253. package/dist/namespaces/migrate.d.ts +3 -3
  254. package/dist/namespaces/migrate.js +11 -11
  255. package/dist/namespaces/principal.d.ts +1 -1
  256. package/dist/namespaces/search.d.ts +1 -1
  257. package/dist/namespaces/search.js +7 -7
  258. package/dist/namespaces/storage.d.ts +3 -3
  259. package/dist/namespaces/storage.js +10 -10
  260. package/dist/native-knowledge.d.ts +1 -1
  261. package/dist/offline-sync-impression-drain.d.ts +1 -1
  262. package/dist/operator-doctor-corpus.d.ts +1 -1
  263. package/dist/operator-doctor-corpus.js +13 -13
  264. package/dist/operator-doctor-replica.d.ts +1 -1
  265. package/dist/operator-toolkit.d.ts +3 -3
  266. package/dist/operator-toolkit.js +19 -19
  267. package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
  268. package/dist/orchestration/maintenance.d.ts +4 -4
  269. package/dist/orchestration/maintenance.js +16 -16
  270. package/dist/{orchestrator-B3ZQ8CTJ.d.ts → orchestrator-6fPa2l9x.d.ts} +8 -8
  271. package/dist/orchestrator.d.ts +9 -9
  272. package/dist/orchestrator.js +70 -68
  273. package/dist/patterns-cli.d.ts +1 -1
  274. package/dist/{pipeline-q5emoXD6.d.ts → pipeline-DHpYtfM3.d.ts} +1 -1
  275. package/dist/policy-runtime.d.ts +1 -1
  276. package/dist/proactive-contention.d.ts +1 -1
  277. package/dist/provenance.d.ts +1 -1
  278. package/dist/{public-http-CQN-i7Ai.d.ts → public-http-BT36aBb-.d.ts} +1 -1
  279. package/dist/{qmd-YC6YGphs.d.ts → qmd-BaX31tM0.d.ts} +1 -1
  280. package/dist/qmd-preflight.d.ts +2 -2
  281. package/dist/qmd-recall-cache.d.ts +1 -1
  282. package/dist/qmd.d.ts +2 -2
  283. package/dist/recall-concurrency-config.d.ts +1 -1
  284. package/dist/recall-disclosure-escalation.d.ts +1 -1
  285. package/dist/recall-explain-renderer.d.ts +1 -1
  286. package/dist/recall-explain-renderer.js +3 -3
  287. package/dist/recall-memory-map.d.ts +1 -1
  288. package/dist/recall-planner-llm.d.ts +1 -1
  289. package/dist/recall-state.d.ts +1 -1
  290. package/dist/recall-tag-filter.d.ts +1 -1
  291. package/dist/recall-timings.d.ts +1 -1
  292. package/dist/recall-xray-cli.d.ts +1 -1
  293. package/dist/recall-xray-cli.js +4 -4
  294. package/dist/recall-xray-renderer.d.ts +1 -1
  295. package/dist/recall-xray-renderer.js +3 -3
  296. package/dist/recall-xray.d.ts +1 -1
  297. package/dist/recall-xray.js +2 -2
  298. package/dist/reconcile/cursor.d.ts +1 -1
  299. package/dist/reconcile/manifest.d.ts +1 -1
  300. package/dist/reconcile/plan.d.ts +1 -1
  301. package/dist/replay/normalizers/chatgpt.d.ts +1 -1
  302. package/dist/replay/normalizers/claude.d.ts +1 -1
  303. package/dist/replay/normalizers/openclaw.d.ts +1 -1
  304. package/dist/replay/normalizers/shared.d.ts +1 -1
  305. package/dist/replay/runner.d.ts +1 -1
  306. package/dist/replay/types.d.ts +1 -1
  307. package/dist/replica-divergence.d.ts +1 -1
  308. package/dist/replica-peers-config.d.ts +1 -1
  309. package/dist/resolve-auth-token.d.ts +1 -1
  310. package/dist/resume-bundles.js +2 -2
  311. package/dist/retrieval-agents.d.ts +2 -2
  312. package/dist/retrieval-tiers.d.ts +1 -1
  313. package/dist/routing/engine.d.ts +1 -1
  314. package/dist/routing/store.d.ts +1 -1
  315. package/dist/salvage-envelope.d.ts +1 -1
  316. package/dist/schemas.d.ts +108 -108
  317. package/dist/{scope-profiles-De8F7YQ6.d.ts → scope-profiles-1hYWJ9bM.d.ts} +1 -1
  318. package/dist/search/embed-helper.d.ts +1 -1
  319. package/dist/search/factory.d.ts +1 -1
  320. package/dist/search/factory.js +6 -6
  321. package/dist/search/index.d.ts +1 -1
  322. package/dist/search/index.js +10 -10
  323. package/dist/search/lancedb-backend.d.ts +1 -1
  324. package/dist/search/lancedb-backend.js +2 -2
  325. package/dist/search/meilisearch-backend.d.ts +1 -1
  326. package/dist/search/meilisearch-backend.js +2 -2
  327. package/dist/search/noop-backend.d.ts +1 -1
  328. package/dist/search/orama-backend.d.ts +1 -1
  329. package/dist/search/orama-backend.js +2 -2
  330. package/dist/search/port.d.ts +1 -1
  331. package/dist/search/remote-backend.d.ts +1 -1
  332. package/dist/{semantic-consolidation-Bf-hm2LQ.d.ts → semantic-consolidation-Chmddvcg.d.ts} +1 -1
  333. package/dist/semantic-consolidation.d.ts +2 -2
  334. package/dist/semantic-consolidation.js +11 -11
  335. package/dist/semantic-rule-promotion.js +10 -10
  336. package/dist/semantic-rule-verifier.d.ts +1 -1
  337. package/dist/semantic-rule-verifier.js +10 -10
  338. package/dist/{service-D83osSRn.d.ts → service-DMs_dCCg.d.ts} +2 -2
  339. package/dist/session-observer-bands.d.ts +1 -1
  340. package/dist/session-observer-state.d.ts +1 -1
  341. package/dist/shared-context/manager.d.ts +9 -9
  342. package/dist/signal.d.ts +1 -1
  343. package/dist/source-agent-qualifier.d.ts +1 -1
  344. package/dist/source-agent-qualifier.js +10 -10
  345. package/dist/{storage-BHWbpbhj.d.ts → storage-CzorrpcN.d.ts} +12 -3
  346. package/dist/storage.d.ts +2 -2
  347. package/dist/storage.js +9 -9
  348. package/dist/summarizer.d.ts +1 -1
  349. package/dist/summary-snapshot.d.ts +1 -1
  350. package/dist/support-passport/index.d.ts +15 -14
  351. package/dist/support-passport/index.js +26 -25
  352. package/dist/temporal-supersession.d.ts +2 -2
  353. package/dist/temporal-timeline-recall.d.ts +1 -1
  354. package/dist/temporal-validity.d.ts +1 -1
  355. package/dist/threading.d.ts +1 -1
  356. package/dist/tier-migration.d.ts +2 -2
  357. package/dist/tier-routing.d.ts +1 -1
  358. package/dist/topics.d.ts +1 -1
  359. package/dist/transcript.d.ts +1 -1
  360. package/dist/transfer/backup.js +2 -2
  361. package/dist/transfer/capsule-export.js +2 -2
  362. package/dist/transfer/capsule-import.js +2 -2
  363. package/dist/transfer/types.d.ts +66 -66
  364. package/dist/trust-score-stage.d.ts +1 -1
  365. package/dist/trust-score.d.ts +1 -1
  366. package/dist/{types-CpgsN-Gb.d.ts → types-BP5MC8UU.d.ts} +10 -5
  367. package/dist/types.d.ts +1 -1
  368. package/dist/types.js +1 -1
  369. package/dist/utility-runtime.d.ts +1 -1
  370. package/dist/verified-recall.js +10 -10
  371. package/dist/who-knows-cli.d.ts +155 -0
  372. package/dist/who-knows-cli.js +109 -0
  373. package/dist/who-knows-cli.js.map +1 -0
  374. package/dist/who-knows.d.ts +127 -0
  375. package/dist/who-knows.js +118 -0
  376. package/dist/who-knows.js.map +1 -0
  377. package/dist/write-envelope.d.ts +1 -1
  378. package/package.json +2 -2
  379. package/src/access-boundary.ts +1 -0
  380. package/src/access-http.ts +15 -0
  381. package/src/access-mcp-output-schemas.ts +1 -0
  382. package/src/access-mcp.ts +3 -2
  383. package/src/access-operations-batch.ts +8 -0
  384. package/src/access-service.ts +26 -0
  385. package/src/access-surface-catalog.ts +2 -0
  386. package/src/cli/okf-commands.ts +23 -0
  387. package/src/cli.ts +2 -1
  388. package/src/config.ts +2 -1
  389. package/src/index.ts +3 -0
  390. package/src/mcp-read-only-tools.ts +1 -0
  391. package/src/okf/cli.ts +42 -0
  392. package/src/okf/config.ts +34 -0
  393. package/src/okf/lint.ts +110 -0
  394. package/src/okf/sweep.ts +63 -0
  395. package/src/okf/type-mapping.test.ts +207 -0
  396. package/src/okf/type-mapping.ts +79 -0
  397. package/src/orchestrator.ts +2 -0
  398. package/src/storage/entity-store.ts +9 -5
  399. package/src/storage/profile-header.ts +33 -9
  400. package/src/storage/questions-file.ts +50 -0
  401. package/src/storage.ts +76 -63
  402. package/src/types.ts +4 -5
  403. package/src/who-knows-cli.ts +96 -0
  404. package/src/who-knows.test.ts +257 -0
  405. package/src/who-knows.ts +364 -0
  406. package/dist/chunk-2RZCOG63.js.map +0 -1
  407. package/dist/chunk-4KKVDOCD.js.map +0 -1
  408. package/dist/chunk-7D3TTGHY.js.map +0 -1
  409. package/dist/chunk-AL43367I.js.map +0 -1
  410. package/dist/chunk-DPPTG6VJ.js.map +0 -1
  411. package/dist/chunk-FMGTFMT3.js.map +0 -1
  412. package/dist/chunk-HIEWDJ2O.js.map +0 -1
  413. package/dist/chunk-IPUUMLSM.js.map +0 -1
  414. package/dist/chunk-VD2OT77P.js.map +0 -1
  415. package/dist/chunk-XFAWGUNX.js.map +0 -1
  416. /package/dist/{capsule-crypto-GWVG7LGC.js.map → capsule-crypto-7FJQINUR.js.map} +0 -0
  417. /package/dist/{chunk-D267K4V5.js.map → chunk-246HFJVG.js.map} +0 -0
  418. /package/dist/{chunk-OWHERGF2.js.map → chunk-2NLLXCJG.js.map} +0 -0
  419. /package/dist/{chunk-WNO5W2TP.js.map → chunk-3A46U7XG.js.map} +0 -0
  420. /package/dist/{chunk-5Q5BEWJ3.js.map → chunk-44DSGZFF.js.map} +0 -0
  421. /package/dist/{chunk-VENMDW4U.js.map → chunk-55SJFHVD.js.map} +0 -0
  422. /package/dist/{chunk-VCBG52MM.js.map → chunk-5HERQ5FX.js.map} +0 -0
  423. /package/dist/{chunk-IRXMJLTW.js.map → chunk-5HK3CJAR.js.map} +0 -0
  424. /package/dist/{chunk-VSKA2ATE.js.map → chunk-6LTCUN3T.js.map} +0 -0
  425. /package/dist/{chunk-IHPYTG6F.js.map → chunk-7BVO64UC.js.map} +0 -0
  426. /package/dist/{chunk-ZUIVJ3BB.js.map → chunk-7V3AZWWZ.js.map} +0 -0
  427. /package/dist/{chunk-Y5ZIQFWH.js.map → chunk-A2IBK3TG.js.map} +0 -0
  428. /package/dist/{chunk-6I6IOMKS.js.map → chunk-C6AKYOFO.js.map} +0 -0
  429. /package/dist/{chunk-ZGGTIBWN.js.map → chunk-CKZHKFY3.js.map} +0 -0
  430. /package/dist/{chunk-JE3AKPOO.js.map → chunk-DG6MJD7W.js.map} +0 -0
  431. /package/dist/{chunk-P4SD7BSA.js.map → chunk-DHKV6E4A.js.map} +0 -0
  432. /package/dist/{chunk-KOE3RLNN.js.map → chunk-EJDLQRUO.js.map} +0 -0
  433. /package/dist/{chunk-DRS3OX77.js.map → chunk-GVRLED7R.js.map} +0 -0
  434. /package/dist/{chunk-EAWJSY2Z.js.map → chunk-H5CGAD7L.js.map} +0 -0
  435. /package/dist/{chunk-DLZBOEJY.js.map → chunk-IFK3PVM7.js.map} +0 -0
  436. /package/dist/{chunk-E7MYSCSL.js.map → chunk-IJXECCUV.js.map} +0 -0
  437. /package/dist/{chunk-RKNJBZ55.js.map → chunk-JBPKEARU.js.map} +0 -0
  438. /package/dist/{chunk-NMQXUGTU.js.map → chunk-JCSUNXYJ.js.map} +0 -0
  439. /package/dist/{chunk-5W7CTZ2E.js.map → chunk-KQAFEZQX.js.map} +0 -0
  440. /package/dist/{chunk-YY63AMGP.js.map → chunk-KRPE7ANR.js.map} +0 -0
  441. /package/dist/{chunk-AGC3Q53R.js.map → chunk-LOETWOEB.js.map} +0 -0
  442. /package/dist/{chunk-7X35RPN3.js.map → chunk-LZKCMK3U.js.map} +0 -0
  443. /package/dist/{chunk-K547KS3X.js.map → chunk-ML3U4KPR.js.map} +0 -0
  444. /package/dist/{chunk-CI6YIT5S.js.map → chunk-NO7B6DRB.js.map} +0 -0
  445. /package/dist/{chunk-Q3IRE6E4.js.map → chunk-ON2P3SHG.js.map} +0 -0
  446. /package/dist/{chunk-2Q4UAPLD.js.map → chunk-OQIRBGUU.js.map} +0 -0
  447. /package/dist/{chunk-WDFXRHOZ.js.map → chunk-PE76XIDM.js.map} +0 -0
  448. /package/dist/{chunk-MVIYRRVJ.js.map → chunk-PMVPCZJZ.js.map} +0 -0
  449. /package/dist/{chunk-VCNGVU62.js.map → chunk-PVIXAMWM.js.map} +0 -0
  450. /package/dist/{chunk-QHNO6AND.js.map → chunk-RWLRKMZK.js.map} +0 -0
  451. /package/dist/{chunk-UWSETW6O.js.map → chunk-SB6YBB2V.js.map} +0 -0
  452. /package/dist/{chunk-DTQ3OB7O.js.map → chunk-SHQFYZTD.js.map} +0 -0
  453. /package/dist/{chunk-G5OB4XZX.js.map → chunk-VANZKHTN.js.map} +0 -0
  454. /package/dist/{chunk-3CYVTO6A.js.map → chunk-VUP47UJI.js.map} +0 -0
  455. /package/dist/{chunk-OTVHRZZD.js.map → chunk-WBM5NR4E.js.map} +0 -0
  456. /package/dist/{chunk-UVYI6VIX.js.map → chunk-X7Y7WX73.js.map} +0 -0
  457. /package/dist/{chunk-B2GICNOJ.js.map → chunk-XH4IQVTN.js.map} +0 -0
  458. /package/dist/{chunk-OWAYQK5V.js.map → chunk-XZUCNVGE.js.map} +0 -0
  459. /package/dist/{chunk-4FSCGYTQ.js.map → chunk-YFQTDE7N.js.map} +0 -0
  460. /package/dist/{chunk-RMB22Q3R.js.map → chunk-YXGU3MDQ.js.map} +0 -0
  461. /package/dist/{chunk-XSPRZZEX.js.map → chunk-Z6CJLYXT.js.map} +0 -0
  462. /package/dist/{chunk-DZ2AVS2H.js.map → chunk-ZSYE2QVJ.js.map} +0 -0
@@ -17,14 +17,14 @@ import {
17
17
  } from "./chunk-46WM6JX2.js";
18
18
  import {
19
19
  normalizeQmdResultPath
20
- } from "./chunk-E7MYSCSL.js";
20
+ } from "./chunk-IJXECCUV.js";
21
21
  import {
22
22
  withholdToolScopedFromSharedNamespace
23
23
  } from "./chunk-S2V7RUCL.js";
24
24
  import {
25
25
  SPECULATIVE_TTL_DAYS,
26
26
  confidenceTier
27
- } from "./chunk-DPPTG6VJ.js";
27
+ } from "./chunk-VRYEXPRX.js";
28
28
  import {
29
29
  normalizeProjectionPreview,
30
30
  normalizeProjectionTags
@@ -259,7 +259,7 @@ import {
259
259
  } from "fs/promises";
260
260
  import { appendFileSync, createReadStream, mkdirSync, statSync as statSync2 } from "fs";
261
261
  import { createHash as createHash6 } from "crypto";
262
- import path12 from "path";
262
+ import path14 from "path";
263
263
 
264
264
  // src/storage/tombstone-migration-sources.ts
265
265
  import { statSync } from "fs";
@@ -1587,6 +1587,107 @@ function renderProfileWithLastUpdated(content, updatedAt) {
1587
1587
  insertHeaderAfter(lines, titleIndex, header);
1588
1588
  return renderProfileLines(lines);
1589
1589
  }
1590
+ function withOkfProfileFrontmatter(content, timestamp, enabled) {
1591
+ if (!enabled || stripOkfProfileFrontmatter(content) !== content) return content;
1592
+ return `---
1593
+ type: Profile
1594
+ title: User Profile
1595
+ timestamp: ${timestamp}
1596
+ ---
1597
+ ${content}`;
1598
+ }
1599
+ function stripOkfProfileFrontmatter(content) {
1600
+ if (!content.startsWith("---\n") && !content.startsWith("---\r\n")) return content;
1601
+ const lines = content.split("\n");
1602
+ for (let index = 1; index < lines.length; index += 1) {
1603
+ const line = lines[index];
1604
+ if (line === "---" || line === "---\r") {
1605
+ return lines.slice(1, index).some((l) => l.startsWith("type: Profile")) ? lines.slice(index + 1).join("\n") : content;
1606
+ }
1607
+ if (line === "" || line === "\r" || line === "...") return content;
1608
+ }
1609
+ return content;
1610
+ }
1611
+
1612
+ // src/storage/questions-file.ts
1613
+ import path4 from "path";
1614
+ function parseQuestionFile(raw, filePath) {
1615
+ if (!raw.startsWith("---\n")) return null;
1616
+ const close = raw.indexOf("\n---\n\n", 4);
1617
+ if (close === -1) return null;
1618
+ const frontmatterStr = raw.slice(4, close);
1619
+ const body = raw.slice(close + 6).trim();
1620
+ const id = extractFrontmatterValue(frontmatterStr, "id") ?? path4.basename(filePath, ".md");
1621
+ const created = extractFrontmatterValue(frontmatterStr, "created") ?? "";
1622
+ const priority = parseFloat(extractFrontmatterValue(frontmatterStr, "priority") ?? "0.5");
1623
+ const resolved = extractFrontmatterValue(frontmatterStr, "resolved") === "true";
1624
+ const contextMarker = "**Context:**";
1625
+ const contextAt = body.indexOf(contextMarker);
1626
+ const question = contextAt === -1 ? body : body.slice(0, contextAt).trim();
1627
+ const context = contextAt === -1 ? "" : body.slice(contextAt + contextMarker.length).trim();
1628
+ return { id, question, context, priority, resolved, created, filePath };
1629
+ }
1630
+ function extractFrontmatterValue(frontmatter, key) {
1631
+ const prefix = `${key}:`;
1632
+ for (const line of frontmatter.split("\n")) {
1633
+ if (!line.startsWith(prefix)) continue;
1634
+ let value = line.slice(prefix.length).trim();
1635
+ if (value.startsWith('"') && value.endsWith('"') && value.length >= 2) {
1636
+ value = value.slice(1, -1);
1637
+ }
1638
+ return value;
1639
+ }
1640
+ return null;
1641
+ }
1642
+
1643
+ // src/okf/type-mapping.ts
1644
+ import path5 from "path";
1645
+ var OKF_TYPE_BY_CATEGORY = Object.freeze({
1646
+ fact: "Memory Fact",
1647
+ decision: "Decision",
1648
+ preference: "Preference",
1649
+ commitment: "Commitment",
1650
+ relationship: "Relationship",
1651
+ principle: "Principle",
1652
+ moment: "Moment",
1653
+ skill: "Skill",
1654
+ correction: "Correction",
1655
+ rule: "Rule"
1656
+ });
1657
+ var OKF_TYPE_FALLBACK = "Memory";
1658
+ function okfTypeForCategory(category) {
1659
+ return OKF_TYPE_BY_CATEGORY[category] ?? OKF_TYPE_FALLBACK;
1660
+ }
1661
+ function okfTypeForMemory(fm) {
1662
+ return fm.artifactType ? "Artifact" : okfTypeForCategory(fm.category);
1663
+ }
1664
+ var OKF_TYPE_BY_ENTITY_KIND = Object.freeze({
1665
+ person: "Person",
1666
+ company: "Company",
1667
+ organization: "Organization",
1668
+ project: "Project",
1669
+ topic: "Topic",
1670
+ technology: "Technology",
1671
+ place: "Place",
1672
+ event: "Event"
1673
+ });
1674
+ function okfTypeForEntityKind(kind) {
1675
+ const normalized = kind?.trim().toLowerCase();
1676
+ return normalized !== void 0 && OKF_TYPE_BY_ENTITY_KIND[normalized] || "Entity";
1677
+ }
1678
+ var OKF_QUESTION_TYPE = "Question";
1679
+ var OKF_RESERVED_BASENAMES = Object.freeze({
1680
+ "index.md": true,
1681
+ "log.md": true
1682
+ });
1683
+ function assertNotOkfReservedBasename(filePath) {
1684
+ const basename = path5.basename(filePath);
1685
+ if (OKF_RESERVED_BASENAMES[basename] === true) {
1686
+ throw new Error(
1687
+ `OKF reserved basename '${basename}' is not a valid memory file target (${filePath}); OKF \xA76/\xA77 reserves it for bundle-level files.`
1688
+ );
1689
+ }
1690
+ }
1590
1691
 
1591
1692
  // src/orchestration/self-deps.ts
1592
1693
  function selfDeps(self) {
@@ -1609,7 +1710,7 @@ function selfDeps(self) {
1609
1710
 
1610
1711
  // src/storage/entity-store.ts
1611
1712
  import { readdir as readdir2, unlink } from "fs/promises";
1612
- import path4 from "path";
1713
+ import path6 from "path";
1613
1714
  var EntityStore = class {
1614
1715
  constructor(deps) {
1615
1716
  this.deps = deps;
@@ -1629,7 +1730,7 @@ var EntityStore = class {
1629
1730
  async readEntityForMutation(name, method, historicalIds) {
1630
1731
  const canonical = resolveHistoricalEntityCanonicalId(name, historicalIds);
1631
1732
  for (const candidate of canonical === name ? [name] : [canonical, name]) {
1632
- const filePath = path4.join(this.deps.entitiesDir, `${candidate}.md`);
1733
+ const filePath = path6.join(this.deps.entitiesDir, `${candidate}.md`);
1633
1734
  try {
1634
1735
  const entity = parseEntityFile(await this.deps.readStorageSecureFile(filePath), this.deps.entitySchemas);
1635
1736
  return { filePath, entity };
@@ -1654,7 +1755,7 @@ var EntityStore = class {
1654
1755
  * `mutate` returns false to skip the write. Resolves true when written.
1655
1756
  */
1656
1757
  async mutateEntityFile(name, method, mutate) {
1657
- const stateDir = path4.join(this.deps.baseDir, "state");
1758
+ const stateDir = path6.join(this.deps.baseDir, "state");
1658
1759
  return withEntityCanonicalMutationLock(stateDir, async () => {
1659
1760
  for (let attempt = 0; attempt < 3; attempt += 1) {
1660
1761
  const idsAtResolve = this.deps.currentHistoricalIds();
@@ -1665,7 +1766,7 @@ var EntityStore = class {
1665
1766
  located.entity.updated = (/* @__PURE__ */ new Date()).toISOString();
1666
1767
  await this.deps.writeStorageSecureFile(
1667
1768
  located.filePath,
1668
- serializeEntityFile(located.entity, this.deps.entitySchemas)
1769
+ serializeEntityFile(located.entity, this.deps.entitySchemas, this.deps.okfConformanceEnabled())
1669
1770
  );
1670
1771
  reconcileIfJournalMovedSync(stateDir, idsAtResolve, this.deps.currentHistoricalIds());
1671
1772
  this.deps.invalidateKnowledgeIndexCache();
@@ -1709,7 +1810,7 @@ var EntityStore = class {
1709
1810
  async writeEntity(name, type, facts, options = {}) {
1710
1811
  await this.deps.ensureDirectories();
1711
1812
  return withEntityCanonicalMutationLock(
1712
- path4.join(this.deps.baseDir, "state"),
1813
+ path6.join(this.deps.baseDir, "state"),
1713
1814
  () => this.writeEntityUnlocked(name, type, facts, options)
1714
1815
  );
1715
1816
  }
@@ -1730,7 +1831,7 @@ var EntityStore = class {
1730
1831
  log.debug(`fuzzy match: "${normalized}" \u2192 existing "${match}"`);
1731
1832
  normalized = match;
1732
1833
  }
1733
- const filePath = path4.join(this.deps.entitiesDir, `${normalized}.md`);
1834
+ const filePath = path6.join(this.deps.entitiesDir, `${normalized}.md`);
1734
1835
  let entity = {
1735
1836
  name,
1736
1837
  type,
@@ -1819,7 +1920,7 @@ var EntityStore = class {
1819
1920
  entity.created = entity.created || timestamp;
1820
1921
  entity.updated = (/* @__PURE__ */ new Date()).toISOString();
1821
1922
  await this.deps.snapshotBeforeWrite(filePath, "write");
1822
- await this.deps.writeStorageSecureFile(filePath, serializeEntityFile(entity, this.deps.entitySchemas));
1923
+ await this.deps.writeStorageSecureFile(filePath, serializeEntityFile(entity, this.deps.entitySchemas, this.deps.okfConformanceEnabled()));
1823
1924
  this.deps.invalidateKnowledgeIndexCache();
1824
1925
  this.deps.bumpMemoryStatusVersion();
1825
1926
  this.deps.bumpEntityMutationVersion();
@@ -1851,13 +1952,13 @@ var EntityStore = class {
1851
1952
  /** Re-serialize every entity file into the compiled-truth timeline shape. */
1852
1953
  async migrateEntityFilesToCompiledTruthTimeline() {
1853
1954
  const entityNames = await this.listEntityNames();
1854
- const stateDir = path4.join(this.deps.baseDir, "state");
1955
+ const stateDir = path6.join(this.deps.baseDir, "state");
1855
1956
  let migrated = 0;
1856
1957
  for (const entityName of entityNames) {
1857
1958
  const wrote = await withEntityCanonicalMutationLock(stateDir, async () => {
1858
1959
  const raw = await this.readEntity(entityName);
1859
1960
  if (!raw) return false;
1860
- const serialized = serializeEntityFile(parseEntityFile(raw, this.deps.entitySchemas), this.deps.entitySchemas);
1961
+ const serialized = serializeEntityFile(parseEntityFile(raw, this.deps.entitySchemas), this.deps.entitySchemas, this.deps.okfConformanceEnabled());
1861
1962
  if (raw.trimEnd() === serialized.trimEnd()) return false;
1862
1963
  const filePath = this.deps.resolveEntityFilePath(entityName);
1863
1964
  if (filePath === null) return false;
@@ -1878,12 +1979,12 @@ var EntityStore = class {
1878
1979
  */
1879
1980
  async updateEntitySynthesis(name, synthesis, options = {}) {
1880
1981
  return withEntityCanonicalMutationLock(
1881
- path4.join(this.deps.baseDir, "state"),
1982
+ path6.join(this.deps.baseDir, "state"),
1882
1983
  () => this.updateEntitySynthesisUnlocked(name, synthesis, options)
1883
1984
  );
1884
1985
  }
1885
1986
  async updateEntitySynthesisUnlocked(name, synthesis, options = {}) {
1886
- const filePath = path4.join(this.deps.entitiesDir, `${name}.md`);
1987
+ const filePath = path6.join(this.deps.entitiesDir, `${name}.md`);
1887
1988
  let entity;
1888
1989
  try {
1889
1990
  const content = await this.deps.readStorageSecureFile(filePath);
@@ -1907,7 +2008,7 @@ var EntityStore = class {
1907
2008
  entity.synthesisStructuredFactDigest = synthesisStructuredFactDigest;
1908
2009
  entity.synthesisVersion = Math.max(0, entity.synthesisVersion ?? 0) + (options.incrementVersion === false ? 0 : 1);
1909
2010
  entity.updated = entityUpdatedAt;
1910
- await this.deps.writeStorageSecureFile(filePath, serializeEntityFile(entity, this.deps.entitySchemas));
2011
+ await this.deps.writeStorageSecureFile(filePath, serializeEntityFile(entity, this.deps.entitySchemas, this.deps.okfConformanceEnabled()));
1911
2012
  await this.deps.removeEntitySynthesisQueueEntries([
1912
2013
  .../* @__PURE__ */ new Set([name, this.deps.normalizeEntityName(entity.name, entity.type)])
1913
2014
  ]);
@@ -1941,7 +2042,7 @@ var EntityStore = class {
1941
2042
  const results = await Promise.all(
1942
2043
  batch.map(async (entry) => {
1943
2044
  try {
1944
- return await this.deps.readStorageSecureFile(path4.join(this.deps.entitiesDir, entry));
2045
+ return await this.deps.readStorageSecureFile(path6.join(this.deps.entitiesDir, entry));
1945
2046
  } catch (err) {
1946
2047
  if (err instanceof SecureStoreLockedError) throw err;
1947
2048
  if (!isErrnoCode(err, "ENOENT")) throw err;
@@ -2016,7 +2117,7 @@ ${rows.join("\n")}
2016
2117
  */
2017
2118
  async mergeFragmentedEntities() {
2018
2119
  return withEntityCanonicalMutationLock(
2019
- path4.join(this.deps.baseDir, "state"),
2120
+ path6.join(this.deps.baseDir, "state"),
2020
2121
  () => this.mergeFragmentedEntitiesUnlocked()
2021
2122
  );
2022
2123
  }
@@ -2061,7 +2162,7 @@ ${rows.join("\n")}
2061
2162
  extraSections: []
2062
2163
  };
2063
2164
  for (const file of files) {
2064
- const filePath = path4.join(this.deps.entitiesDir, file);
2165
+ const filePath = path6.join(this.deps.entitiesDir, file);
2065
2166
  try {
2066
2167
  const content = await this.deps.readStorageSecureFile(filePath);
2067
2168
  const parsed = parseEntityFile(content, this.deps.entitySchemas);
@@ -2214,11 +2315,11 @@ ${rows.join("\n")}
2214
2315
  }
2215
2316
  mergedEntity.created = mergedEntity.created || mergedEntity.updated || (/* @__PURE__ */ new Date()).toISOString();
2216
2317
  mergedEntity.updated = mergedEntity.updated || (/* @__PURE__ */ new Date()).toISOString();
2217
- const canonicalPath = path4.join(this.deps.entitiesDir, `${canonical}.md`);
2218
- await this.deps.writeStorageSecureFile(canonicalPath, serializeEntityFile(mergedEntity, this.deps.entitySchemas));
2318
+ const canonicalPath = path6.join(this.deps.entitiesDir, `${canonical}.md`);
2319
+ await this.deps.writeStorageSecureFile(canonicalPath, serializeEntityFile(mergedEntity, this.deps.entitySchemas, this.deps.okfConformanceEnabled()));
2219
2320
  this.deps.bumpEntityMutationVersion();
2220
2321
  for (const file of files) {
2221
- const filePath = path4.join(this.deps.entitiesDir, file);
2322
+ const filePath = path6.join(this.deps.entitiesDir, file);
2222
2323
  if (filePath !== canonicalPath) {
2223
2324
  try {
2224
2325
  await unlink(filePath);
@@ -2238,7 +2339,7 @@ ${rows.join("\n")}
2238
2339
 
2239
2340
  // src/storage/identity-continuity-store.ts
2240
2341
  import { readdir as readdir3 } from "fs/promises";
2241
- import path5 from "path";
2342
+ import path7 from "path";
2242
2343
  var IdentityContinuityStore = class {
2243
2344
  constructor(deps) {
2244
2345
  this.deps = deps;
@@ -2263,7 +2364,7 @@ var IdentityContinuityStore = class {
2263
2364
  const date = nowIso.slice(0, 10);
2264
2365
  const id = this.deps.generateId("incident");
2265
2366
  const incident = createContinuityIncidentRecord(id, input, nowIso);
2266
- const filePath = path5.join(this.deps.identityIncidentsDir, `${date}-${id}.md`);
2367
+ const filePath = path7.join(this.deps.identityIncidentsDir, `${date}-${id}.md`);
2267
2368
  await this.deps.writeStorageSecureFile(filePath, serializeContinuityIncident(incident));
2268
2369
  return { ...incident, filePath };
2269
2370
  }
@@ -2276,7 +2377,7 @@ var IdentityContinuityStore = class {
2276
2377
  const incidents = [];
2277
2378
  for (const file of candidates) {
2278
2379
  if (incidents.length >= cappedLimit) break;
2279
- const filePath = path5.join(this.deps.identityIncidentsDir, file);
2380
+ const filePath = path7.join(this.deps.identityIncidentsDir, file);
2280
2381
  try {
2281
2382
  const raw = await this.deps.readStorageSecureFile(filePath);
2282
2383
  const parsed = parseContinuityIncident(raw);
@@ -2307,7 +2408,7 @@ var IdentityContinuityStore = class {
2307
2408
  await this.deps.ensureDirectories();
2308
2409
  const safeKey = this.sanitizeIdentityAuditKey(key);
2309
2410
  const dir = period === "weekly" ? this.deps.identityAuditsWeeklyDir : this.deps.identityAuditsMonthlyDir;
2310
- const filePath = path5.join(dir, `${safeKey}.md`);
2411
+ const filePath = path7.join(dir, `${safeKey}.md`);
2311
2412
  await this.deps.writeStorageSecureFile(filePath, content);
2312
2413
  return filePath;
2313
2414
  }
@@ -2315,7 +2416,7 @@ var IdentityContinuityStore = class {
2315
2416
  try {
2316
2417
  const safeKey = this.sanitizeIdentityAuditKey(key);
2317
2418
  const dir = period === "weekly" ? this.deps.identityAuditsWeeklyDir : this.deps.identityAuditsMonthlyDir;
2318
- return await this.deps.readStorageSecureFile(path5.join(dir, `${safeKey}.md`));
2419
+ return await this.deps.readStorageSecureFile(path7.join(dir, `${safeKey}.md`));
2319
2420
  } catch (err) {
2320
2421
  if (err instanceof Error && err.message === "Invalid identity audit key") return null;
2321
2422
  if (!isErrnoCode(err, "ENOENT")) throw err;
@@ -2371,12 +2472,12 @@ var IdentityContinuityStore = class {
2371
2472
  const fileNames = await this.readContinuityIncidentFileNames();
2372
2473
  const directMatch = fileNames.find((name) => name.endsWith(`-${id}.md`));
2373
2474
  if (directMatch) {
2374
- const directPath = path5.join(this.deps.identityIncidentsDir, directMatch);
2475
+ const directPath = path7.join(this.deps.identityIncidentsDir, directMatch);
2375
2476
  const parsed = await this.readContinuityIncidentFile(directPath);
2376
2477
  if (parsed?.id === id) return directPath;
2377
2478
  }
2378
2479
  for (const fileName of fileNames) {
2379
- const filePath = path5.join(this.deps.identityIncidentsDir, fileName);
2480
+ const filePath = path7.join(this.deps.identityIncidentsDir, fileName);
2380
2481
  const parsed = await this.readContinuityIncidentFile(filePath);
2381
2482
  if (parsed?.id === id) return filePath;
2382
2483
  }
@@ -2404,7 +2505,7 @@ import {
2404
2505
  unlink as unlink2,
2405
2506
  writeFile
2406
2507
  } from "fs/promises";
2407
- import path6 from "path";
2508
+ import path8 from "path";
2408
2509
  import { z } from "zod";
2409
2510
  var ENTITY_CANONICAL_ID_MIGRATION_VERSION = 1;
2410
2511
  var ENTITY_CANONICAL_ID_MIGRATION_LOCK_STALE_MS = 6e4;
@@ -2438,7 +2539,7 @@ async function fingerprintPath(filePath) {
2438
2539
  async function fingerprintEntityEntries(entitiesDir) {
2439
2540
  let names;
2440
2541
  try {
2441
- names = (await readdir4(entitiesDir)).filter((name) => path6.extname(name) === ".md").sort();
2542
+ names = (await readdir4(entitiesDir)).filter((name) => path8.extname(name) === ".md").sort();
2442
2543
  } catch (error) {
2443
2544
  if (isErrnoCode(error, "ENOENT")) return "missing";
2444
2545
  throw error;
@@ -2447,7 +2548,7 @@ async function fingerprintEntityEntries(entitiesDir) {
2447
2548
  for (const name of names) {
2448
2549
  hash.update(`${name.length}:${name}:`);
2449
2550
  try {
2450
- const entry = await lstat2(path6.join(entitiesDir, name), { bigint: true });
2551
+ const entry = await lstat2(path8.join(entitiesDir, name), { bigint: true });
2451
2552
  hash.update(`${entry.dev}:${entry.ino}:${entry.size}:${entry.mtimeNs}:${entry.ctimeNs}`);
2452
2553
  } catch (error) {
2453
2554
  if (!isErrnoCode(error, "ENOENT")) throw error;
@@ -2467,9 +2568,9 @@ async function getFingerprint(baseDir, entitiesDir, getEntityMutationVersion) {
2467
2568
  ] = await Promise.all([
2468
2569
  fingerprintPath(entitiesDir),
2469
2570
  fingerprintEntityEntries(entitiesDir),
2470
- fingerprintPath(path6.join(baseDir, "config", "aliases.json")),
2471
- fingerprintPath(path6.join(baseDir, "state", ENTITY_CANONICAL_ID_RECONCILE_MARKER)),
2472
- fingerprintPath(path6.join(baseDir, "state", ENTITY_CANONICAL_ID_RECONCILE_CONSUMING_MARKER))
2571
+ fingerprintPath(path8.join(baseDir, "config", "aliases.json")),
2572
+ fingerprintPath(path8.join(baseDir, "state", ENTITY_CANONICAL_ID_RECONCILE_MARKER)),
2573
+ fingerprintPath(path8.join(baseDir, "state", ENTITY_CANONICAL_ID_RECONCILE_CONSUMING_MARKER))
2473
2574
  ]);
2474
2575
  return [
2475
2576
  entityDirectoryFingerprint,
@@ -2495,8 +2596,8 @@ async function validateRoots(baseDir, entitiesDir, stateDir, archiveDir) {
2495
2596
  const roots = [
2496
2597
  entitiesDir,
2497
2598
  stateDir,
2498
- ...RECALL_FALLBACK_DIRS.map((directory) => path6.join(baseDir, directory)),
2499
- path6.join(baseDir, "cold"),
2599
+ ...RECALL_FALLBACK_DIRS.map((directory) => path8.join(baseDir, directory)),
2600
+ path8.join(baseDir, "cold"),
2500
2601
  archiveDir
2501
2602
  ];
2502
2603
  for (const root of roots) {
@@ -2514,7 +2615,7 @@ async function validateRoots(baseDir, entitiesDir, stateDir, archiveDir) {
2514
2615
  }
2515
2616
  }
2516
2617
  function statePath(deps) {
2517
- return path6.join(deps.stateDir, ENTITY_CANONICAL_ID_MIGRATION_FILE);
2618
+ return path8.join(deps.stateDir, ENTITY_CANONICAL_ID_MIGRATION_FILE);
2518
2619
  }
2519
2620
  async function assertSafeMigrationStateFile(deps) {
2520
2621
  const migrationStatePath = statePath(deps);
@@ -2557,7 +2658,7 @@ async function assertSafeTombstoneFile(deps, tombstonePath) {
2557
2658
  return true;
2558
2659
  }
2559
2660
  function lockPath(deps) {
2560
- return path6.join(deps.stateDir, "entity-canonical-id-migration.lock");
2661
+ return path8.join(deps.stateDir, "entity-canonical-id-migration.lock");
2561
2662
  }
2562
2663
  async function readState(deps) {
2563
2664
  await assertSafeMigrationStateFile(deps);
@@ -2655,7 +2756,7 @@ async function readSafeEntityEntries(entitiesDir) {
2655
2756
  }
2656
2757
  const entries = await readdir4(entitiesDir);
2657
2758
  for (const entry of entries) {
2658
- await assertNotSymlink(path6.join(entitiesDir, entry), entry);
2759
+ await assertNotSymlink(path8.join(entitiesDir, entry), entry);
2659
2760
  }
2660
2761
  return entries;
2661
2762
  }
@@ -2717,7 +2818,7 @@ async function rewriteReferences(deps, mappings, refreshLock) {
2717
2818
  const seenPaths = /* @__PURE__ */ new Set();
2718
2819
  let rewroteAny = false;
2719
2820
  for (const memory of [...hotMemories, ...coldMemories, ...archivedMemories]) {
2720
- const memoryPath = path6.resolve(memory.path);
2821
+ const memoryPath = path8.resolve(memory.path);
2721
2822
  if (seenPaths.has(memoryPath)) continue;
2722
2823
  seenPaths.add(memoryPath);
2723
2824
  const previousEntityRef = memory.frontmatter.entityRef;
@@ -2749,7 +2850,7 @@ async function rewriteReferences(deps, mappings, refreshLock) {
2749
2850
  latestCanonicalId
2750
2851
  );
2751
2852
  rewroteAny = true;
2752
- rewroteColdMemory ||= latestMemory.path.includes(`${path6.sep}cold${path6.sep}`);
2853
+ rewroteColdMemory ||= latestMemory.path.includes(`${path8.sep}cold${path8.sep}`);
2753
2854
  }
2754
2855
  if (!rewroteAny) return { rewroteColdMemory };
2755
2856
  }
@@ -2788,7 +2889,7 @@ function rewriteTombstoneLine(line, mappings, normalizedMappings) {
2788
2889
  return changed ? JSON.stringify(tombstone) : line;
2789
2890
  }
2790
2891
  async function rewriteTombstoneReferences(deps, mappings, refreshLock) {
2791
- const tombstonePath = path6.join(deps.stateDir, "tombstones.jsonl");
2892
+ const tombstonePath = path8.join(deps.stateDir, "tombstones.jsonl");
2792
2893
  const normalizedMappings = /* @__PURE__ */ new Map();
2793
2894
  for (const [legacyId, canonicalId] of Object.entries(mappings)) {
2794
2895
  const normalizedLegacyId = normalizeSupersessionKey(legacyId);
@@ -2797,7 +2898,7 @@ async function rewriteTombstoneReferences(deps, mappings, refreshLock) {
2797
2898
  }
2798
2899
  }
2799
2900
  await withHeldFileLock(
2800
- path6.join(deps.stateDir, "tombstones.lock"),
2901
+ path8.join(deps.stateDir, "tombstones.lock"),
2801
2902
  {
2802
2903
  staleMs: TOMBSTONE_LOCK_STALE_MS,
2803
2904
  maxWaitMs: TOMBSTONE_LOCK_MAX_WAIT_MS
@@ -3036,8 +3137,8 @@ async function migrateLegacyEntityCanonicalIds(deps) {
3036
3137
  if (!acquired) throw new Error("Timed out waiting for active entity canonical-id migration.");
3037
3138
  await deps.validateMemoryScanRoots?.();
3038
3139
  await readSafeEntityEntries(deps.entitiesDir);
3039
- const reconcileMarkerPath = path6.join(deps.stateDir, ENTITY_CANONICAL_ID_RECONCILE_MARKER);
3040
- const consumingMarkerPath = path6.join(deps.stateDir, ENTITY_CANONICAL_ID_RECONCILE_CONSUMING_MARKER);
3140
+ const reconcileMarkerPath = path8.join(deps.stateDir, ENTITY_CANONICAL_ID_RECONCILE_MARKER);
3141
+ const consumingMarkerPath = path8.join(deps.stateDir, ENTITY_CANONICAL_ID_RECONCILE_CONSUMING_MARKER);
3041
3142
  let reconcileRequested = await fileExists(consumingMarkerPath);
3042
3143
  if (await fileExists(reconcileMarkerPath)) {
3043
3144
  try {
@@ -3433,7 +3534,7 @@ import {
3433
3534
  readFileSync,
3434
3535
  realpathSync
3435
3536
  } from "fs";
3436
- import path7 from "path";
3537
+ import path9 from "path";
3437
3538
  function resolveSafeAliasRoots(baseDir, configDir) {
3438
3539
  let baseStat;
3439
3540
  try {
@@ -3460,8 +3561,8 @@ function resolveSafeAliasRoots(baseDir, configDir) {
3460
3561
  return memoryRoot;
3461
3562
  }
3462
3563
  function readEntityAliasConfigSync(baseDir) {
3463
- const configDir = path7.join(baseDir, "config");
3464
- const aliasPath = path7.join(configDir, "aliases.json");
3564
+ const configDir = path9.join(baseDir, "config");
3565
+ const aliasPath = path9.join(configDir, "aliases.json");
3465
3566
  let memoryRoot = resolveSafeAliasRoots(baseDir, configDir);
3466
3567
  if (memoryRoot === void 0) return void 0;
3467
3568
  let aliasPreflight;
@@ -3522,7 +3623,7 @@ function decodeYamlScalar(value) {
3522
3623
  }
3523
3624
 
3524
3625
  // src/orchestration/qmd-result-resolver.ts
3525
- import path8 from "path";
3626
+ import path10 from "path";
3526
3627
  var INTERNAL_QMD_ROOTS = /* @__PURE__ */ new Set([
3527
3628
  ...ALL_CATEGORY_DIRS,
3528
3629
  "activity",
@@ -3544,7 +3645,7 @@ var INTERNAL_QMD_ROOTS = /* @__PURE__ */ new Set([
3544
3645
  ]);
3545
3646
  var PRIVATE_RESULT_RESOLUTION_CONCURRENCY = 16;
3546
3647
  function qmdCollectionPathParts(resultPath) {
3547
- if (!resultPath || path8.isAbsolute(resultPath)) return null;
3648
+ if (!resultPath || path10.isAbsolute(resultPath)) return null;
3548
3649
  if (resultPath.trim().startsWith("qmd://")) {
3549
3650
  try {
3550
3651
  const parsed = new URL(resultPath.trim());
@@ -3569,9 +3670,9 @@ function qmdCollectionPathParts(resultPath) {
3569
3670
  }
3570
3671
  function qmdResultPathCandidates(storageDir, resultPath) {
3571
3672
  const candidates = /* @__PURE__ */ new Set();
3572
- const storageRoot = path8.resolve(storageDir);
3673
+ const storageRoot = path10.resolve(storageDir);
3573
3674
  const addCandidate = (candidate) => {
3574
- const resolved = path8.resolve(candidate);
3675
+ const resolved = path10.resolve(candidate);
3575
3676
  if (isPathInsideStorageRoot(storageRoot, resolved)) {
3576
3677
  candidates.add(resolved);
3577
3678
  }
@@ -3579,18 +3680,18 @@ function qmdResultPathCandidates(storageDir, resultPath) {
3579
3680
  const addRelativeCandidates = (relativePath) => {
3580
3681
  const normalized = relativePath.replace(/\\/g, "/").replace(/^\/+/, "");
3581
3682
  if (!normalized) return;
3582
- addCandidate(path8.join(storageRoot, normalized));
3683
+ addCandidate(path10.join(storageRoot, normalized));
3583
3684
  if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
3584
- addCandidate(path8.join(storageRoot, "facts", normalized));
3685
+ addCandidate(path10.join(storageRoot, "facts", normalized));
3585
3686
  }
3586
3687
  };
3587
- if (path8.isAbsolute(resultPath)) {
3688
+ if (path10.isAbsolute(resultPath)) {
3588
3689
  addCandidate(resultPath);
3589
- const relative2 = path8.relative(storageRoot, path8.resolve(resultPath));
3590
- if (relative2 && !relative2.startsWith("..") && !path8.isAbsolute(relative2)) {
3591
- const normalized = relative2.split(path8.sep).join("/");
3690
+ const relative2 = path10.relative(storageRoot, path10.resolve(resultPath));
3691
+ if (relative2 && !relative2.startsWith("..") && !path10.isAbsolute(relative2)) {
3692
+ const normalized = relative2.split(path10.sep).join("/");
3592
3693
  if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
3593
- addCandidate(path8.join(storageRoot, "facts", normalized));
3694
+ addCandidate(path10.join(storageRoot, "facts", normalized));
3594
3695
  }
3595
3696
  }
3596
3697
  } else {
@@ -3626,7 +3727,7 @@ var QmdResultResolver = class {
3626
3727
  const seenStorageDirs = /* @__PURE__ */ new Set();
3627
3728
  const addStorage = (storage) => {
3628
3729
  const storageDir = storageDirOrNull(storage);
3629
- const storageKey = storageDir ? path8.resolve(storageDir) : `storage-without-dir-${storages.length}`;
3730
+ const storageKey = storageDir ? path10.resolve(storageDir) : `storage-without-dir-${storages.length}`;
3630
3731
  if (seenStorageDirs.has(storageKey)) return;
3631
3732
  seenStorageDirs.add(storageKey);
3632
3733
  storages.push(storage);
@@ -3656,7 +3757,7 @@ var QmdResultResolver = class {
3656
3757
  continue;
3657
3758
  }
3658
3759
  try {
3659
- const coldRoot = path8.join(storageDir, "cold");
3760
+ const coldRoot = path10.join(storageDir, "cold");
3660
3761
  for (const candidate of qmdResultPathCandidates(coldRoot, parts.relativePath)) {
3661
3762
  const memory = await storage.readMemoryByPath(candidate);
3662
3763
  if (memory) return memory;
@@ -3706,9 +3807,9 @@ var QmdResultResolver = class {
3706
3807
  error: err.message
3707
3808
  });
3708
3809
  }
3709
- if (!path8.isAbsolute(fallbackResultPath)) return null;
3810
+ if (!path10.isAbsolute(fallbackResultPath)) return null;
3710
3811
  }
3711
- if (path8.isAbsolute(fallbackResultPath)) {
3812
+ if (path10.isAbsolute(fallbackResultPath)) {
3712
3813
  if (!fallbackStorageDir) {
3713
3814
  return await fallbackStorage.readMemoryByPath(fallbackResultPath);
3714
3815
  }
@@ -3765,17 +3866,17 @@ var QmdResultResolver = class {
3765
3866
  if (!memory && parts && !collectionIsKnownInternal && !collectionIsConfigured) {
3766
3867
  memory = await this.readQmdResultMemory(parts.relativePath, fallbackStorage, namespaces, result.namespace);
3767
3868
  }
3768
- const absoluteInsideMemoryRoot = path8.isAbsolute(result.path) && isPathInsideStorageRoot(path8.resolve(config.memoryDir), path8.resolve(result.path));
3869
+ const absoluteInsideMemoryRoot = path10.isAbsolute(result.path) && isPathInsideStorageRoot(path10.resolve(config.memoryDir), path10.resolve(result.path));
3769
3870
  const hasExplicitQmdCollection = result.path.trim().startsWith("qmd://");
3770
3871
  const unresolvedInternalPath = !memory && (absoluteInsideMemoryRoot || collectionIsKnownInternal && (!preserveUnresolved || hasExplicitQmdCollection) || hasExplicitQmdCollection && collectionIsConfigured);
3771
- const unresolvedExternalCollection = !memory && (parts !== null && !collectionIsKnownInternal && !collectionIsConfigured || path8.isAbsolute(result.path) && !isPathInsideStorageRoot(path8.resolve(config.memoryDir), path8.resolve(result.path)));
3872
+ const unresolvedExternalCollection = !memory && (parts !== null && !collectionIsKnownInternal && !collectionIsConfigured || path10.isAbsolute(result.path) && !isPathInsideStorageRoot(path10.resolve(config.memoryDir), path10.resolve(result.path)));
3772
3873
  return memory !== null && !isSupportPassportPrivateMemory(memory) || !memory && !unresolvedInternalPath && (preserveUnresolved || unresolvedExternalCollection);
3773
3874
  }
3774
3875
  async resolveColdQmdResultForRecall(result, fallbackStorage, recallNamespaces = []) {
3775
3876
  const memory = await this.readQmdResultMemory(result.path, fallbackStorage, recallNamespaces, result.namespace);
3776
3877
  if (!memory) return null;
3777
3878
  let ownerNamespace = null;
3778
- if (path8.isAbsolute(memory.path)) {
3879
+ if (path10.isAbsolute(memory.path)) {
3779
3880
  const ownerStorage = await this.storageForAbsoluteQmdResultPath(memory.path, fallbackStorage, recallNamespaces);
3780
3881
  ownerNamespace = ownerStorage?.namespace ?? null;
3781
3882
  if (!ownerNamespace && resolveNamespaceCapabilities(this.getConfig()).namespaces) return null;
@@ -3796,17 +3897,17 @@ var QmdResultResolver = class {
3796
3897
  };
3797
3898
  }
3798
3899
  async storageForAbsoluteQmdResultPath(resultPath, fallbackStorage, recallNamespaces = []) {
3799
- const resolvedPath = path8.resolve(resultPath);
3900
+ const resolvedPath = path10.resolve(resultPath);
3800
3901
  const config = this.getConfig();
3801
- const memoryRoot = path8.resolve(config.memoryDir);
3802
- const namespacesRoot = path8.join(memoryRoot, "namespaces");
3902
+ const memoryRoot = path10.resolve(config.memoryDir);
3903
+ const namespacesRoot = path10.join(memoryRoot, "namespaces");
3803
3904
  const fallbackStorageDir = storageDirOrNull(fallbackStorage);
3804
3905
  const matches = [];
3805
3906
  const seenDirs = /* @__PURE__ */ new Set();
3806
3907
  const maybeAddStorage = (storage, namespace) => {
3807
3908
  const storageDir = storageDirOrNull(storage);
3808
3909
  if (!storageDir) return;
3809
- const candidateRoot = path8.resolve(storageDir);
3910
+ const candidateRoot = path10.resolve(storageDir);
3810
3911
  if (seenDirs.has(candidateRoot)) return;
3811
3912
  if (!isPathInsideStorageRoot(candidateRoot, resolvedPath)) return;
3812
3913
  if (candidateRoot === memoryRoot && isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
@@ -3824,7 +3925,7 @@ var QmdResultResolver = class {
3824
3925
  candidateNamespaces.add(ns);
3825
3926
  }
3826
3927
  if (isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
3827
- const relativeToNamespaces = path8.relative(namespacesRoot, resolvedPath);
3928
+ const relativeToNamespaces = path10.relative(namespacesRoot, resolvedPath);
3828
3929
  const [namespaceSegment] = relativeToNamespaces.split(/[\\/]/);
3829
3930
  if (namespaceSegment) {
3830
3931
  candidateNamespaces.add(namespaceIdentityFromToken(namespaceSegment) ?? namespaceSegment);
@@ -4470,7 +4571,7 @@ function fuseDay(date, inputs, options = {}) {
4470
4571
 
4471
4572
  // src/wearables/fusion/store.ts
4472
4573
  import { createHash as createHash3 } from "crypto";
4473
- import * as path9 from "path";
4574
+ import * as path11 from "path";
4474
4575
  var FUSION_KIND = "wearable-fusion";
4475
4576
  function hashFusionBody(conversations) {
4476
4577
  return createHash3("sha256").update(JSON.stringify(conversations), "utf-8").digest("hex");
@@ -4657,7 +4758,7 @@ var FusionArtifactStore = class {
4657
4758
  `invalid wearable fusion date '${String(date)}' \u2014 expected YYYY-MM-DD`
4658
4759
  );
4659
4760
  }
4660
- return path9.join(this.wearablesDir, FUSION_DIR_NAME, `${date}.md`);
4761
+ return path11.join(this.wearablesDir, FUSION_DIR_NAME, `${date}.md`);
4661
4762
  }
4662
4763
  async writeFusedDay(date, serialized) {
4663
4764
  const filePath = this.fusedDayPath(date);
@@ -4694,7 +4795,7 @@ var FusionArtifactStore = class {
4694
4795
  }
4695
4796
  /** List dates with stored fused artifacts, newest first. */
4696
4797
  async listFusedDays() {
4697
- const fusionDir = path9.join(this.wearablesDir, FUSION_DIR_NAME);
4798
+ const fusionDir = path11.join(this.wearablesDir, FUSION_DIR_NAME);
4698
4799
  await this.assertPathContained(fusionDir);
4699
4800
  let entries;
4700
4801
  try {
@@ -4738,10 +4839,10 @@ var FusionArtifactStore = class {
4738
4839
  try {
4739
4840
  rootReal = await this.io.realpath(this.memoryDir);
4740
4841
  } catch {
4741
- rootReal = path9.resolve(this.memoryDir);
4842
+ rootReal = path11.resolve(this.memoryDir);
4742
4843
  }
4743
4844
  await this.assertNoEscape(rootReal, this.wearablesDir);
4744
- await this.assertNoEscape(rootReal, path9.dirname(targetPath));
4845
+ await this.assertNoEscape(rootReal, path11.dirname(targetPath));
4745
4846
  await this.assertNoEscape(rootReal, targetPath);
4746
4847
  await this.assertFusionDirNotSymlinked();
4747
4848
  }
@@ -4755,7 +4856,7 @@ var FusionArtifactStore = class {
4755
4856
  * (a fresh write creates a real directory lexically under the root).
4756
4857
  */
4757
4858
  async assertFusionDirNotSymlinked() {
4758
- const fusionDir = path9.join(this.wearablesDir, FUSION_DIR_NAME);
4859
+ const fusionDir = path11.join(this.wearablesDir, FUSION_DIR_NAME);
4759
4860
  let stat4;
4760
4861
  try {
4761
4862
  stat4 = await this.io.lstat(fusionDir);
@@ -4891,7 +4992,7 @@ function reconstructFusionInputs(date, dayTranscripts) {
4891
4992
 
4892
4993
  // src/meetings/store.ts
4893
4994
  import { createHash as createHash4 } from "crypto";
4894
- import * as path10 from "path";
4995
+ import * as path12 from "path";
4895
4996
  var MEETINGS_DIR_NAME = "meetings";
4896
4997
  var MEETING_KIND = "meeting";
4897
4998
  var MEETING_FORMAT_VERSION = 1;
@@ -5060,7 +5161,7 @@ var MeetingRecordStore = class {
5060
5161
  constructor(memoryDir, io) {
5061
5162
  this.memoryDir = memoryDir;
5062
5163
  this.io = io;
5063
- this.meetingsDir = path10.join(memoryDir, MEETINGS_DIR_NAME);
5164
+ this.meetingsDir = path12.join(memoryDir, MEETINGS_DIR_NAME);
5064
5165
  }
5065
5166
  memoryDir;
5066
5167
  io;
@@ -5076,7 +5177,7 @@ var MeetingRecordStore = class {
5076
5177
  if (idDate !== date) {
5077
5178
  throw new Error(`meeting id '${id}' does not belong to date '${date}'`);
5078
5179
  }
5079
- return path10.join(this.meetingsDir, date, `${id}.md`);
5180
+ return path12.join(this.meetingsDir, date, `${id}.md`);
5080
5181
  }
5081
5182
  /** Idempotently persist a record: skip the write when contentHash is unchanged. */
5082
5183
  async saveMeetingRecord(record) {
@@ -5107,7 +5208,7 @@ var MeetingRecordStore = class {
5107
5208
  if (!isValidTranscriptDate(date)) {
5108
5209
  throw new Error(`invalid meeting date '${String(date)}' \u2014 expected YYYY-MM-DD`);
5109
5210
  }
5110
- const dayDir = path10.join(this.meetingsDir, date);
5211
+ const dayDir = path12.join(this.meetingsDir, date);
5111
5212
  await this.assertPathContained(dayDir);
5112
5213
  let entries;
5113
5214
  try {
@@ -5175,10 +5276,10 @@ var MeetingRecordStore = class {
5175
5276
  try {
5176
5277
  rootReal = await this.io.realpath(this.memoryDir);
5177
5278
  } catch {
5178
- rootReal = path10.resolve(this.memoryDir);
5279
+ rootReal = path12.resolve(this.memoryDir);
5179
5280
  }
5180
5281
  await this.assertNoEscape(rootReal, this.meetingsDir);
5181
- await this.assertNoEscape(rootReal, path10.dirname(targetPath));
5282
+ await this.assertNoEscape(rootReal, path12.dirname(targetPath));
5182
5283
  await this.assertNoEscape(rootReal, targetPath);
5183
5284
  await this.assertNotSymlink(this.meetingsDir, "directory");
5184
5285
  const dayDir = this.dayDirWithin(targetPath);
@@ -5188,11 +5289,11 @@ var MeetingRecordStore = class {
5188
5289
  /** The `<meetings>/<date>` directory on the path to `targetPath`, or null when
5189
5290
  * `targetPath` is the meetings root itself. */
5190
5291
  dayDirWithin(targetPath) {
5191
- const rel = path10.relative(this.meetingsDir, targetPath);
5192
- if (rel === "" || rel.startsWith("..") || path10.isAbsolute(rel)) return null;
5193
- const first = rel.split(path10.sep)[0];
5292
+ const rel = path12.relative(this.meetingsDir, targetPath);
5293
+ if (rel === "" || rel.startsWith("..") || path12.isAbsolute(rel)) return null;
5294
+ const first = rel.split(path12.sep)[0];
5194
5295
  if (first === void 0 || first.length === 0) return null;
5195
- return path10.join(this.meetingsDir, first);
5296
+ return path12.join(this.meetingsDir, first);
5196
5297
  }
5197
5298
  async assertNotSymlink(target, kind) {
5198
5299
  let stat4;
@@ -5203,7 +5304,7 @@ var MeetingRecordStore = class {
5203
5304
  throw err;
5204
5305
  }
5205
5306
  if (stat4.isSymbolicLink) {
5206
- const label = path10.relative(this.memoryDir, target) || MEETINGS_DIR_NAME;
5307
+ const label = path12.relative(this.memoryDir, target) || MEETINGS_DIR_NAME;
5207
5308
  throw new Error(
5208
5309
  `meetings ${kind} '${label}' is a symbolic link \u2014 refusing to follow it even when it resolves inside the memory dir (AGENTS.md pattern #3)`
5209
5310
  );
@@ -5227,7 +5328,7 @@ var SORT_STR = (a, b) => a < b ? -1 : a > b ? 1 : 0;
5227
5328
 
5228
5329
  // src/storage/supersession-audit.ts
5229
5330
  import { readdir as readdir5 } from "fs/promises";
5230
- import path11 from "path";
5331
+ import path13 from "path";
5231
5332
  async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody, structuredAttributes) {
5232
5333
  let entries;
5233
5334
  try {
@@ -5238,7 +5339,7 @@ async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody,
5238
5339
  }
5239
5340
  for (const entry of entries) {
5240
5341
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
5241
- const memory = await lookup.readMemoryByPath(path11.join(lookup.correctionsDir, entry.name));
5342
+ const memory = await lookup.readMemoryByPath(path13.join(lookup.correctionsDir, entry.name));
5242
5343
  if (memory?.frontmatter.category === "correction" && (memory.frontmatter.sourceMemoryId === oldMemoryId || memory.frontmatter.sourceMemoryId === void 0 && memory.frontmatter.lineage?.includes(oldMemoryId)) && memory.frontmatter.lineage?.includes(newMemoryId) && stripAttributesSuffix(memory.content) === auditBody && (structuredAttributes === void 0 || Object.entries(structuredAttributes).every(
5243
5344
  ([key, value]) => memory.frontmatter.structuredAttributes?.[key] === value
5244
5345
  ))) {
@@ -5828,6 +5929,7 @@ function serializeFrontmatter(fm) {
5828
5929
  `confidenceTier: ${fm.confidenceTier}`,
5829
5930
  `tags: [${fm.tags.map((t) => `"${t}"`).join(", ")}]`
5830
5931
  ];
5932
+ if (fm.type !== void 0) lines.push(`type: ${fm.type}`);
5831
5933
  if (fm.origin) lines.push(`origin: ${/^[A-Za-z0-9:_.*-]+$/.test(fm.origin) ? fm.origin : JSON.stringify(fm.origin)}`);
5832
5934
  if (fm.entityRef) lines.push(`entityRef: ${fm.entityRef}`);
5833
5935
  if (fm.sourceConnector) {
@@ -6219,6 +6321,7 @@ function parseFrontmatter(raw) {
6219
6321
  frontmatter: {
6220
6322
  id: fm.id ?? "",
6221
6323
  category: fm.category ?? "fact",
6324
+ type: parseFrontmatterStringValue(fm.type),
6222
6325
  created: fm.created ?? (/* @__PURE__ */ new Date()).toISOString(),
6223
6326
  updated: fm.updated ?? (/* @__PURE__ */ new Date()).toISOString(),
6224
6327
  source: fm.source ?? "unknown",
@@ -6319,17 +6422,17 @@ function inferEntityTypeFromContent(content) {
6319
6422
  }
6320
6423
  var KNOWN_ENTITY_FILENAME_PREFIXES = /* @__PURE__ */ new Set(["company", "other", "person", "place", "project", "tool", "topic"]);
6321
6424
  function inferEntityTypeFromFilename(pathRel) {
6322
- const basename = path12.basename(pathRel, ".md").toLowerCase();
6425
+ const basename = path14.basename(pathRel, ".md").toLowerCase();
6323
6426
  const separator = basename.indexOf("-");
6324
6427
  if (separator <= 0) return void 0;
6325
6428
  const candidate = basename.slice(0, separator);
6326
6429
  return KNOWN_ENTITY_FILENAME_PREFIXES.has(candidate) ? candidate : void 0;
6327
6430
  }
6328
6431
  function normalizeFrontmatterForPath(frontmatter, pathRel, content = "") {
6329
- const normalizedPath = pathRel.split(path12.sep).join("/");
6432
+ const normalizedPath = pathRel.split(path14.sep).join("/");
6330
6433
  let normalizedFrontmatter = frontmatter;
6331
6434
  if (normalizedPath === "entities" || normalizedPath.startsWith("entities/") || normalizedPath.includes("/entities/")) {
6332
- const basename = path12.basename(pathRel, ".md");
6435
+ const basename = path14.basename(pathRel, ".md");
6333
6436
  const inferredType = inferEntityTypeFromContent(content) || inferEntityTypeFromFilename(pathRel) || "entity";
6334
6437
  const existingTags = Array.isArray(frontmatter.tags) ? frontmatter.tags : [];
6335
6438
  normalizedFrontmatter = {
@@ -6377,15 +6480,16 @@ function parseEntityFrontmatter(raw) {
6377
6480
  }
6378
6481
  const values = {};
6379
6482
  const extraLines = [];
6380
- const recognizedKeys = /* @__PURE__ */ new Set([
6381
- "created",
6382
- "updated",
6383
- "synthesis_updated_at",
6384
- "synthesis_timeline_count",
6385
- "synthesis_structured_fact_count",
6386
- "synthesis_structured_fact_digest",
6387
- "synthesis_version"
6388
- ]);
6483
+ const recognizedKeys = {
6484
+ created: true,
6485
+ updated: true,
6486
+ type: true,
6487
+ synthesis_updated_at: true,
6488
+ synthesis_timeline_count: true,
6489
+ synthesis_structured_fact_count: true,
6490
+ synthesis_structured_fact_digest: true,
6491
+ synthesis_version: true
6492
+ };
6389
6493
  for (const line of match[1].split(/\r?\n/)) {
6390
6494
  if (/^\s/.test(line)) {
6391
6495
  extraLines.push(line);
@@ -6397,7 +6501,7 @@ function parseEntityFrontmatter(raw) {
6397
6501
  continue;
6398
6502
  }
6399
6503
  const key = line.slice(0, colonIdx).trim();
6400
- if (!recognizedKeys.has(key)) {
6504
+ if (recognizedKeys[key] !== true) {
6401
6505
  extraLines.push(line);
6402
6506
  continue;
6403
6507
  }
@@ -6626,7 +6730,7 @@ function parseEntityFile(content, entitySchemas) {
6626
6730
  extraSections: remainingExtraSections
6627
6731
  };
6628
6732
  }
6629
- function serializeEntityFile(entity, entitySchemas) {
6733
+ function serializeEntityFile(entity, entitySchemas, okfType) {
6630
6734
  const synthesis = entity.synthesis || entity.summary || "";
6631
6735
  const created = entity.created?.trim() || entity.updated || (/* @__PURE__ */ new Date()).toISOString();
6632
6736
  const updated = entity.updated || created;
@@ -6661,7 +6765,8 @@ function serializeEntityFile(entity, entitySchemas) {
6661
6765
  ...synthesisStructuredFactCount === void 0 ? [] : [`synthesis_structured_fact_count: ${synthesisStructuredFactCount}`],
6662
6766
  ...synthesisStructuredFactDigest ? [`synthesis_structured_fact_digest: "${synthesisStructuredFactDigest}"`] : [],
6663
6767
  `synthesis_version: ${synthesisVersion}`,
6664
- ...entity.extraFrontmatterLines ?? [],
6768
+ ...okfType === false ? [] : [`type: ${okfTypeForEntityKind(entity.type)}`],
6769
+ ...okfType === false ? entity.extraFrontmatterLines ?? [] : (entity.extraFrontmatterLines ?? []).filter((line) => !line.startsWith("type:")),
6665
6770
  "---",
6666
6771
  "",
6667
6772
  `# ${entity.name}`,
@@ -6800,9 +6905,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
6800
6905
  this.entitySchemas = entitySchemas;
6801
6906
  this.deletionRevisionStore = new DeletionRevisionStore({
6802
6907
  baseDir,
6803
- deletionRevisionMetadataPath: path12.join(baseDir, ".offline-sync", "deletion-revisions.v1.json"),
6804
- invalidationCommitMetadataPath: path12.join(baseDir, ".offline-sync", "invalidation-commits.v1.json"),
6805
- deletionRevisionLockPath: path12.join(baseDir, ".offline-sync", "deletion-revisions.v1.json.lock"),
6908
+ deletionRevisionMetadataPath: path14.join(baseDir, ".offline-sync", "deletion-revisions.v1.json"),
6909
+ invalidationCommitMetadataPath: path14.join(baseDir, ".offline-sync", "invalidation-commits.v1.json"),
6910
+ deletionRevisionLockPath: path14.join(baseDir, ".offline-sync", "deletion-revisions.v1.json.lock"),
6806
6911
  assertManagedStoragePath: (filePath, method) => this.assertManagedStoragePath(filePath, method)
6807
6912
  });
6808
6913
  this.hotMemoriesCacheEnabled = hotMemoriesCacheEnabledOverride ?? _StorageManager.hotMemoriesCacheDefaultByDir.get(baseDir) ?? _StorageManager.hotMemoriesCacheDefault;
@@ -6986,8 +7091,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
6986
7091
  }
6987
7092
  /** Whether `filePath` resolves to `stateDir` itself or a path contained in it. */
6988
7093
  isStateFilePath(filePath) {
6989
- const rel = path12.relative(this.stateDir, path12.resolve(filePath));
6990
- return rel === "" || !rel.startsWith("..") && !path12.isAbsolute(rel);
7094
+ const rel = path14.relative(this.stateDir, path14.resolve(filePath));
7095
+ return rel === "" || !rel.startsWith("..") && !path14.isAbsolute(rel);
6991
7096
  }
6992
7097
  // ── Tombstone store (issue #1579) ───────────────────────────────────────
6993
7098
  // Instance-scoped (rule 11) + namespace-scoped (rule 42) tombstone index.
@@ -7102,8 +7207,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7102
7207
  * /srv/cold/remnic), skipping the patch and stranding a stale hot entry.
7103
7208
  */
7104
7209
  isColdOrArchiveTierPath(p) {
7105
- const rel = path12.relative(this.baseDir, p);
7106
- return rel === "cold" || rel === "archive" || rel.startsWith(`cold${path12.sep}`) || rel.startsWith(`archive${path12.sep}`);
7210
+ const rel = path14.relative(this.baseDir, p);
7211
+ return rel === "cold" || rel === "archive" || rel.startsWith(`cold${path14.sep}`) || rel.startsWith(`archive${path14.sep}`);
7107
7212
  }
7108
7213
  /**
7109
7214
  * Mark the secure-store as required for this storage instance.
@@ -7190,7 +7295,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7190
7295
  void 0,
7191
7296
  this.baseDir
7192
7297
  );
7193
- const rel = path12.relative(this.baseDir, filePath).split(path12.sep).join("/");
7298
+ const rel = path14.relative(this.baseDir, filePath).split(path14.sep).join("/");
7194
7299
  return `${rel}:${version.versionId}`;
7195
7300
  } catch (err) {
7196
7301
  log.warn(
@@ -7226,6 +7331,21 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7226
7331
  static setScopedCacheInvalidationDefault(memoryDir, enabled) {
7227
7332
  _StorageManager.scopedCacheInvalidationByDir.set(memoryDir, enabled !== false);
7228
7333
  }
7334
+ /** OKF `type` emission gate registrations per memory dir (issue #1946). */
7335
+ static okfConformanceByDir = /* @__PURE__ */ new Map();
7336
+ /** Register the OKF conformance gate for a memory dir. Unregistered dirs default to
7337
+ * conformance-on; namespace child dirs (<memoryDir>/namespaces/<tok>) inherit the
7338
+ * nearest registered ancestor. Only an explicit `false` disables. */
7339
+ static setOkfConformanceDefault(memoryDir, enabled) {
7340
+ _StorageManager.okfConformanceByDir.set(memoryDir, enabled !== false);
7341
+ }
7342
+ okfConformanceEnabled() {
7343
+ for (let dir = this.baseDir; ; dir = path14.dirname(dir)) {
7344
+ const registered = _StorageManager.okfConformanceByDir.get(dir);
7345
+ if (registered !== void 0) return registered;
7346
+ if (dir === path14.dirname(dir)) return true;
7347
+ }
7348
+ }
7229
7349
  /**
7230
7350
  * The LIVE class object of this instance (issue #1809 review of the
7231
7351
  * storage decomposition): extracted store modules must read/write the
@@ -7270,12 +7390,12 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7270
7390
  }
7271
7391
  identityFilePath(workspaceDir, namespace) {
7272
7392
  const rawNamespace = typeof namespace === "string" ? namespace.trim() : "";
7273
- if (!rawNamespace) return path12.join(workspaceDir, "IDENTITY.md");
7393
+ if (!rawNamespace) return path14.join(workspaceDir, "IDENTITY.md");
7274
7394
  const safeNamespace = rawNamespace.replace(/[^a-zA-Z0-9._-]/g, "-");
7275
- return path12.join(workspaceDir, `IDENTITY.${safeNamespace}.md`);
7395
+ return path14.join(workspaceDir, `IDENTITY.${safeNamespace}.md`);
7276
7396
  }
7277
7397
  versionFilePath(kind) {
7278
- return path12.join(this.stateDir, `.${kind}-version.log`);
7398
+ return path14.join(this.stateDir, `.${kind}-version.log`);
7279
7399
  }
7280
7400
  bumpSharedVersion(kind, fallbackMap) {
7281
7401
  const filePath = this.versionFilePath(kind);
@@ -7379,7 +7499,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7379
7499
  // memories.
7380
7500
  // -------------------------------------------------------------------------
7381
7501
  get wearablesDir() {
7382
- return path12.join(this.baseDir, WEARABLES_DIR_NAME);
7502
+ return path14.join(this.baseDir, WEARABLES_DIR_NAME);
7383
7503
  }
7384
7504
  /**
7385
7505
  * Resolve the on-disk path for a source/day transcript. Throws on
@@ -7395,7 +7515,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7395
7515
  if (!isValidTranscriptDate(date)) {
7396
7516
  throw new Error(`invalid wearable transcript date '${String(date)}' \u2014 expected YYYY-MM-DD`);
7397
7517
  }
7398
- return path12.join(this.wearablesDir, sourceId, `${date}.md`);
7518
+ return path14.join(this.wearablesDir, sourceId, `${date}.md`);
7399
7519
  }
7400
7520
  async writeWearableDayTranscript(sourceId, date, serialized) {
7401
7521
  const targetPath = this.wearableTranscriptPath(sourceId, date);
@@ -7511,25 +7631,25 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7511
7631
  });
7512
7632
  }
7513
7633
  get factsDir() {
7514
- return path12.join(this.baseDir, "facts");
7634
+ return path14.join(this.baseDir, "facts");
7515
7635
  }
7516
7636
  get correctionsDir() {
7517
- return path12.join(this.baseDir, "corrections");
7637
+ return path14.join(this.baseDir, "corrections");
7518
7638
  }
7519
7639
  get proceduresDir() {
7520
- return path12.join(this.baseDir, "procedures");
7640
+ return path14.join(this.baseDir, "procedures");
7521
7641
  }
7522
7642
  get reasoningTracesDir() {
7523
- return path12.join(this.baseDir, "reasoning-traces");
7643
+ return path14.join(this.baseDir, "reasoning-traces");
7524
7644
  }
7525
7645
  get entitiesDir() {
7526
- return path12.join(this.baseDir, "entities");
7646
+ return path14.join(this.baseDir, "entities");
7527
7647
  }
7528
7648
  resolveEntityFilePath(name) {
7529
7649
  if (typeof name !== "string") return null;
7530
- const filePath = path12.resolve(this.entitiesDir, `${name}.md`);
7531
- const relative2 = path12.relative(this.entitiesDir, filePath);
7532
- if (relative2 === "" || relative2.startsWith("..") || path12.isAbsolute(relative2)) {
7650
+ const filePath = path14.resolve(this.entitiesDir, `${name}.md`);
7651
+ const relative2 = path14.relative(this.entitiesDir, filePath);
7652
+ if (relative2 === "" || relative2.startsWith("..") || path14.isAbsolute(relative2)) {
7533
7653
  return null;
7534
7654
  }
7535
7655
  return filePath;
@@ -7540,7 +7660,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7540
7660
  async readDependencyPropagationQueueFile(filePath) {
7541
7661
  const target = await resolveSafeStoragePath(
7542
7662
  this.baseDir,
7543
- path12.relative(
7663
+ path14.relative(
7544
7664
  this.baseDir,
7545
7665
  this.assertManagedStoragePath(filePath, "storage.readDependencyPropagationQueueFile")
7546
7666
  )
@@ -7550,7 +7670,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7550
7670
  async writeDependencyPropagationQueueFile(filePath, content) {
7551
7671
  const target = await resolveSafeStoragePath(
7552
7672
  this.baseDir,
7553
- path12.relative(
7673
+ path14.relative(
7554
7674
  this.baseDir,
7555
7675
  this.assertManagedStoragePath(filePath, "storage.writeDependencyPropagationQueueFile")
7556
7676
  )
@@ -7558,16 +7678,17 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7558
7678
  return this.writeStorageSecureFile(target, content);
7559
7679
  }
7560
7680
  writeStorageSecureFile(filePath, content, forceEncrypt = false) {
7681
+ assertNotOkfReservedBasename(filePath);
7561
7682
  const writeKey = this.resolveWriteKey(forceEncrypt);
7562
7683
  return writeMaybeEncryptedFile(filePath, content, writeKey, {}, this.baseDir).then(() => {
7563
7684
  this.notifyCatalogWriteForPath(filePath);
7564
7685
  });
7565
7686
  }
7566
7687
  assertManagedStoragePath(filePath, method) {
7567
- const resolved = path12.resolve(filePath);
7568
- const base = path12.resolve(this.baseDir);
7569
- const rel = path12.relative(base, resolved);
7570
- if (rel === "" || rel === ".." || rel.startsWith(`..${path12.sep}`) || path12.isAbsolute(rel)) {
7688
+ const resolved = path14.resolve(filePath);
7689
+ const base = path14.resolve(this.baseDir);
7690
+ const rel = path14.relative(base, resolved);
7691
+ if (rel === "" || rel === ".." || rel.startsWith(`..${path14.sep}`) || path14.isAbsolute(rel)) {
7571
7692
  throw new Error(`${method}: file path escapes memory dir`);
7572
7693
  }
7573
7694
  return resolved;
@@ -7600,7 +7721,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7600
7721
  async digestOfflineSyncFile(filePath) {
7601
7722
  const target = this.assertManagedStoragePath(filePath, "storage.digestOfflineSyncFile");
7602
7723
  const st = await stat3(target);
7603
- const relPath = path12.relative(this.baseDir, target).split(path12.sep).join("/");
7724
+ const relPath = path14.relative(this.baseDir, target).split(path14.sep).join("/");
7604
7725
  const cache = await this.loadOfflineSyncDigestCache();
7605
7726
  const cached = cache.get(relPath);
7606
7727
  if (cached && cached.statBytes === st.size && cached.mtimeMs === st.mtimeMs && cached.ctimeMs === st.ctimeMs && !cached.encrypted) {
@@ -7661,7 +7782,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7661
7782
  const bytes = typeof record.bytes === "number" ? record.bytes : NaN;
7662
7783
  const sha256 = typeof record.sha256 === "string" ? record.sha256 : "";
7663
7784
  const encrypted = record.encrypted === true;
7664
- if (cachePath.length === 0 || cachePath === ".." || cachePath.startsWith("../") || path12.isAbsolute(cachePath) || !Number.isFinite(statBytes) || !Number.isFinite(mtimeMs) || !Number.isFinite(ctimeMs) || !Number.isFinite(bytes) || !/^[a-f0-9]{64}$/i.test(sha256)) {
7785
+ if (cachePath.length === 0 || cachePath === ".." || cachePath.startsWith("../") || path14.isAbsolute(cachePath) || !Number.isFinite(statBytes) || !Number.isFinite(mtimeMs) || !Number.isFinite(ctimeMs) || !Number.isFinite(bytes) || !/^[a-f0-9]{64}$/i.test(sha256)) {
7665
7786
  continue;
7666
7787
  }
7667
7788
  cache.set(cachePath, { statBytes, mtimeMs, ctimeMs, encrypted, sha256, bytes });
@@ -7703,7 +7824,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7703
7824
  const cache = this.offlineSyncDigestCache;
7704
7825
  if (!cache) return;
7705
7826
  const entries = [...cache.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([entryPath, entry]) => ({ path: entryPath, ...entry }));
7706
- await mkdir(path12.dirname(this.offlineSyncDigestCachePath), { recursive: true });
7827
+ await mkdir(path14.dirname(this.offlineSyncDigestCachePath), { recursive: true });
7707
7828
  await writeFile2(this.offlineSyncDigestCachePath, `${JSON.stringify({ version: 1, entries })}
7708
7829
  `, "utf-8");
7709
7830
  }).catch((err) => {
@@ -7792,7 +7913,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7792
7913
  }
7793
7914
  async appendStorageSecureFileUnlocked(filePath, content) {
7794
7915
  const writeKey = this.resolveWriteKey();
7795
- await mkdir(path12.dirname(filePath), { recursive: true });
7916
+ await mkdir(path14.dirname(filePath), { recursive: true });
7796
7917
  if (writeKey === null) {
7797
7918
  try {
7798
7919
  if (await this.isEncryptedFileHeader(filePath)) {
@@ -7818,13 +7939,13 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7818
7939
  this.notifyCatalogWriteForPath(filePath);
7819
7940
  }
7820
7941
  get stateDir() {
7821
- return path12.join(this.baseDir, "state");
7942
+ return path14.join(this.baseDir, "state");
7822
7943
  }
7823
7944
  get offlineSyncDigestCachePath() {
7824
- return path12.join(this.baseDir, ".offline-sync", "digest-cache.v1.json");
7945
+ return path14.join(this.baseDir, ".offline-sync", "digest-cache.v1.json");
7825
7946
  }
7826
7947
  get entitySynthesisQueuePath() {
7827
- return path12.join(this.stateDir, "entity-synthesis-queue.json");
7948
+ return path14.join(this.stateDir, "entity-synthesis-queue.json");
7828
7949
  }
7829
7950
  // ── Tombstone store access (issue #1579) ─────────────────────────────────
7830
7951
  /**
@@ -7834,7 +7955,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7834
7955
  * helpers are injected into the store).
7835
7956
  */
7836
7957
  get tombstonesPath() {
7837
- return path12.join(this.stateDir, "tombstones.jsonl");
7958
+ return path14.join(this.stateDir, "tombstones.jsonl");
7838
7959
  }
7839
7960
  /**
7840
7961
  * Configure the tombstone invariant for this storage instance. Installed
@@ -8136,55 +8257,55 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
8136
8257
  return legacyMatches.length > 0 ? [...new Set(legacyMatches.map((content) => ContentHashIndex.computeHash(content)))] : [persistedHash];
8137
8258
  }
8138
8259
  get questionsDir() {
8139
- return path12.join(this.baseDir, "questions");
8260
+ return path14.join(this.baseDir, "questions");
8140
8261
  }
8141
8262
  get artifactsDir() {
8142
- return path12.join(this.baseDir, "artifacts");
8263
+ return path14.join(this.baseDir, "artifacts");
8143
8264
  }
8144
8265
  get identityDir() {
8145
- return path12.join(this.baseDir, "identity");
8266
+ return path14.join(this.baseDir, "identity");
8146
8267
  }
8147
8268
  get identityAnchorPath() {
8148
- return path12.join(this.identityDir, "identity-anchor.md");
8269
+ return path14.join(this.identityDir, "identity-anchor.md");
8149
8270
  }
8150
8271
  get identityIncidentsDir() {
8151
- return path12.join(this.identityDir, "incidents");
8272
+ return path14.join(this.identityDir, "incidents");
8152
8273
  }
8153
8274
  get identityAuditsWeeklyDir() {
8154
- return path12.join(this.identityDir, "audits", "weekly");
8275
+ return path14.join(this.identityDir, "audits", "weekly");
8155
8276
  }
8156
8277
  get identityAuditsMonthlyDir() {
8157
- return path12.join(this.identityDir, "audits", "monthly");
8278
+ return path14.join(this.identityDir, "audits", "monthly");
8158
8279
  }
8159
8280
  get identityImprovementLoopsPath() {
8160
- return path12.join(this.identityDir, "improvement-loops.md");
8281
+ return path14.join(this.identityDir, "improvement-loops.md");
8161
8282
  }
8162
8283
  get identityReflectionsPath() {
8163
- return path12.join(this.identityDir, "reflections.md");
8284
+ return path14.join(this.identityDir, "reflections.md");
8164
8285
  }
8165
8286
  get profilePath() {
8166
- return path12.join(this.baseDir, "profile.md");
8287
+ return path14.join(this.baseDir, "profile.md");
8167
8288
  }
8168
8289
  get memoryActionsPath() {
8169
- return path12.join(this.stateDir, "memory-actions.jsonl");
8290
+ return path14.join(this.stateDir, "memory-actions.jsonl");
8170
8291
  }
8171
8292
  get memoryLifecycleLedgerPath() {
8172
- return path12.join(this.stateDir, "memory-lifecycle-ledger.jsonl");
8293
+ return path14.join(this.stateDir, "memory-lifecycle-ledger.jsonl");
8173
8294
  }
8174
8295
  get compressionGuidelinesPath() {
8175
- return path12.join(this.stateDir, "compression-guidelines.md");
8296
+ return path14.join(this.stateDir, "compression-guidelines.md");
8176
8297
  }
8177
8298
  get compressionGuidelineDraftPath() {
8178
- return path12.join(this.stateDir, "compression-guidelines.draft.md");
8299
+ return path14.join(this.stateDir, "compression-guidelines.draft.md");
8179
8300
  }
8180
8301
  get compressionGuidelineStatePath() {
8181
- return path12.join(this.stateDir, "compression-guideline-state.json");
8302
+ return path14.join(this.stateDir, "compression-guideline-state.json");
8182
8303
  }
8183
8304
  get compressionGuidelineDraftStatePath() {
8184
- return path12.join(this.stateDir, "compression-guideline-draft-state.json");
8305
+ return path14.join(this.stateDir, "compression-guideline-draft-state.json");
8185
8306
  }
8186
8307
  get behaviorSignalsPath() {
8187
- return path12.join(this.stateDir, "behavior-signals.jsonl");
8308
+ return path14.join(this.stateDir, "behavior-signals.jsonl");
8188
8309
  }
8189
8310
  /**
8190
8311
  * In-memory dedup key set for behavior-signals appends (issue #1909),
@@ -8216,7 +8337,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
8216
8337
  * governance sweeps can treat it uniformly.
8217
8338
  */
8218
8339
  get bufferSurpriseLedgerPath() {
8219
- return path12.join(this.stateDir, "buffer-surprise-ledger.jsonl");
8340
+ return path14.join(this.stateDir, "buffer-surprise-ledger.jsonl");
8220
8341
  }
8221
8342
  /**
8222
8343
  * Entity alias table loaded from THIS store's config/aliases.json.
@@ -8277,7 +8398,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
8277
8398
  this.loadAliasesSync();
8278
8399
  }
8279
8400
  loadAliasesSync() {
8280
- const aliasPath = path12.join(this.baseDir, "config", "aliases.json");
8401
+ const aliasPath = path14.join(this.baseDir, "config", "aliases.json");
8281
8402
  this.userAliases = {};
8282
8403
  const raw = readEntityAliasConfigSync(this.baseDir);
8283
8404
  if (raw === void 0) return;
@@ -8306,7 +8427,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
8306
8427
  const completionFingerprint = await runLegacyEntityCanonicalIdMigration(
8307
8428
  this,
8308
8429
  (content) => parseEntityFile(content, this.entitySchemas),
8309
- (entity) => serializeEntityFile(entity, this.entitySchemas),
8430
+ (entity) => serializeEntityFile(entity, this.entitySchemas, this.okfConformanceEnabled()),
8310
8431
  createMemoryEntityRefSerializer(serializeFrontmatter)
8311
8432
  );
8312
8433
  return completionFingerprint;
@@ -8315,9 +8436,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
8315
8436
  await mkdir(this.baseDir, { recursive: true });
8316
8437
  await validateRoots(this.baseDir, this.entitiesDir, this.stateDir, this.archiveDir);
8317
8438
  const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
8318
- await mkdir(path12.join(this.factsDir, today), { recursive: true });
8319
- await mkdir(path12.join(this.proceduresDir, today), { recursive: true });
8320
- await mkdir(path12.join(this.reasoningTracesDir, today), { recursive: true });
8439
+ await mkdir(path14.join(this.factsDir, today), { recursive: true });
8440
+ await mkdir(path14.join(this.proceduresDir, today), { recursive: true });
8441
+ await mkdir(path14.join(this.reasoningTracesDir, today), { recursive: true });
8321
8442
  await mkdir(this.correctionsDir, { recursive: true });
8322
8443
  await mkdir(this.entitiesDir, { recursive: true });
8323
8444
  await mkdir(this.stateDir, { recursive: true });
@@ -8327,7 +8448,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
8327
8448
  await mkdir(this.identityIncidentsDir, { recursive: true });
8328
8449
  await mkdir(this.identityAuditsWeeklyDir, { recursive: true });
8329
8450
  await mkdir(this.identityAuditsMonthlyDir, { recursive: true });
8330
- await mkdir(path12.join(this.baseDir, "config"), { recursive: true });
8451
+ await mkdir(path14.join(this.baseDir, "config"), { recursive: true });
8331
8452
  await this.entityCanonicalIdMigration.ensure();
8332
8453
  if (this.hotMemoriesCacheEnabled && this.getMemoryCorpusVersion() === 0) {
8333
8454
  this.bumpMemoryCorpusVersion();
@@ -8349,11 +8470,11 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
8349
8470
  async resolveCategoryWritePath(category, id, today) {
8350
8471
  if (category === "correction") {
8351
8472
  await mkdir(this.correctionsDir, { recursive: true });
8352
- return path12.join(this.correctionsDir, `${id}.md`);
8473
+ return path14.join(this.correctionsDir, `${id}.md`);
8353
8474
  }
8354
- const datedDir = path12.join(getCategoryDir(this.baseDir, category), today);
8475
+ const datedDir = path14.join(getCategoryDir(this.baseDir, category), today);
8355
8476
  await mkdir(datedDir, { recursive: true });
8356
- return path12.join(datedDir, `${id}.md`);
8477
+ return path14.join(datedDir, `${id}.md`);
8357
8478
  }
8358
8479
  async findExistingTombstoneBlockedMemory(content, category, sourceConnector) {
8359
8480
  const identity = buildExplicitCaptureDedupKey(content, category, sourceConnector);
@@ -8367,6 +8488,12 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
8367
8488
  ) === identity;
8368
8489
  }) ?? null;
8369
8490
  }
8491
+ /** Derive the inert OKF `type` at the serialization choke point when conformance is on
8492
+ * and the parsed frontmatter carried none (issue #1946). Never touches `category`. */
8493
+ withOkfType(fm) {
8494
+ if (this.okfConformanceEnabled() && fm.type === void 0) fm.type = okfTypeForMemory(fm);
8495
+ return fm;
8496
+ }
8370
8497
  async writeMemory(category, content, options = {}) {
8371
8498
  await this.ensureDirectories();
8372
8499
  const rawEntityRef = options.entityRef;
@@ -8477,7 +8604,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
8477
8604
  }
8478
8605
  };
8479
8606
  await applyTombstoneGate();
8480
- const fileContent = `${serializeFrontmatter(fm)}
8607
+ const fileContent = `${serializeFrontmatter(this.withOkfType(fm))}
8481
8608
 
8482
8609
  ${sanitized.text}
8483
8610
  `;
@@ -8504,7 +8631,7 @@ ${sanitized.text}
8504
8631
  await applyTombstoneGate();
8505
8632
  await this.writeTombstoneBlockedMemory(
8506
8633
  filePath,
8507
- `${serializeFrontmatter(fm)}
8634
+ `${serializeFrontmatter(this.withOkfType(fm))}
8508
8635
 
8509
8636
  ${sanitized.text}
8510
8637
  `,
@@ -8720,7 +8847,7 @@ ${sanitized.text}
8720
8847
  await this.ensureDirectories();
8721
8848
  const now = /* @__PURE__ */ new Date();
8722
8849
  const day = now.toISOString().slice(0, 10);
8723
- const dir = path12.join(this.artifactsDir, day);
8850
+ const dir = path14.join(this.artifactsDir, day);
8724
8851
  await mkdir(dir, { recursive: true });
8725
8852
  const id = `artifact-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
8726
8853
  const fm = {
@@ -8747,8 +8874,8 @@ ${sanitized.text}
8747
8874
  log.warn(`artifact content rejected for ${id}; violations=${sanitized.violations.join(", ")}`);
8748
8875
  return "";
8749
8876
  }
8750
- const filePath = path12.join(dir, `${id}.md`);
8751
- await this.writeStorageSecureFile(filePath, `${serializeFrontmatter(fm)}
8877
+ const filePath = path14.join(dir, `${id}.md`);
8878
+ await this.writeStorageSecureFile(filePath, `${serializeFrontmatter(this.withOkfType(fm))}
8752
8879
 
8753
8880
  ${sanitized.text}
8754
8881
  `);
@@ -8781,7 +8908,7 @@ ${sanitized.text}
8781
8908
  }
8782
8909
  async readProfile() {
8783
8910
  try {
8784
- return await readMaybeEncryptedFile(this.profilePath, this._secureStoreKey, this.baseDir);
8911
+ return stripOkfProfileFrontmatter(await readMaybeEncryptedFile(this.profilePath, this._secureStoreKey, this.baseDir));
8785
8912
  } catch (error) {
8786
8913
  if (error instanceof SecureStoreLockedError) {
8787
8914
  throw error;
@@ -8791,7 +8918,12 @@ ${sanitized.text}
8791
8918
  }
8792
8919
  }
8793
8920
  async writeProfile(content) {
8794
- const stampedContent = renderProfileWithLastUpdated(content, (/* @__PURE__ */ new Date()).toISOString());
8921
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
8922
+ const stampedContent = withOkfProfileFrontmatter(
8923
+ renderProfileWithLastUpdated(content, timestamp),
8924
+ timestamp,
8925
+ this.okfConformanceEnabled()
8926
+ );
8795
8927
  await this.ensureDirectories();
8796
8928
  await this.snapshotBeforeWrite(this.profilePath, "consolidation");
8797
8929
  await this.writeStorageSecureFile(this.profilePath, stampedContent);
@@ -9035,7 +9167,7 @@ ${sanitized.text}
9035
9167
  * per-process in-memory cache safe across process boundaries.
9036
9168
  */
9037
9169
  invalidateColdMemoriesCache() {
9038
- const coldRoot = path12.join(this.baseDir, "cold");
9170
+ const coldRoot = path14.join(this.baseDir, "cold");
9039
9171
  _StorageManager.coldMemoriesCache.delete(coldRoot);
9040
9172
  this.bumpColdWriteVersion();
9041
9173
  invalidateAllForDir(this.baseDir);
@@ -9155,7 +9287,7 @@ ${sanitized.text}
9155
9287
  const correctionPaths = [];
9156
9288
  const factPaths = [];
9157
9289
  for (const filePath of filePaths) {
9158
- if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${path12.sep}`)) {
9290
+ if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${path14.sep}`)) {
9159
9291
  correctionPaths.push(filePath);
9160
9292
  } else {
9161
9293
  factPaths.push(filePath);
@@ -9218,7 +9350,7 @@ ${sanitized.text}
9218
9350
  try {
9219
9351
  const entries = await readdir6(dir, { withFileTypes: true });
9220
9352
  for (const entry of entries) {
9221
- const fullPath = path12.join(dir, entry.name);
9353
+ const fullPath = path14.join(dir, entry.name);
9222
9354
  if (entry.isDirectory()) {
9223
9355
  await readDir(fullPath);
9224
9356
  } else if (entry.name.endsWith(".md")) {
@@ -9261,7 +9393,7 @@ ${sanitized.text}
9261
9393
  return this.rememberMemorySnapshot(await this.memoryReadStore.readMemoryByPath(filePath));
9262
9394
  }
9263
9395
  resolveTierRootDir(tier) {
9264
- return tier === "cold" ? path12.join(this.baseDir, "cold") : this.baseDir;
9396
+ return tier === "cold" ? path14.join(this.baseDir, "cold") : this.baseDir;
9265
9397
  }
9266
9398
  resolveMemoryDateDir(memory) {
9267
9399
  const preferred = memory.frontmatter.created || memory.frontmatter.updated;
@@ -9276,21 +9408,22 @@ ${sanitized.text}
9276
9408
  buildTierMemoryPath(memory, tier) {
9277
9409
  const root = this.resolveTierRootDir(tier);
9278
9410
  if (this.isArtifactMemory(memory)) {
9279
- return path12.join(root, "artifacts", this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
9411
+ return path14.join(root, "artifacts", this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
9280
9412
  }
9281
9413
  if (memory.frontmatter.category === "correction") {
9282
- return path12.join(root, "corrections", `${memory.frontmatter.id}.md`);
9414
+ return path14.join(root, "corrections", `${memory.frontmatter.id}.md`);
9283
9415
  }
9284
9416
  const dir = categoryDirName(memory.frontmatter.category);
9285
- return path12.join(root, dir, this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
9417
+ return path14.join(root, dir, this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
9286
9418
  }
9287
9419
  async writeMemoryFileAtomic(targetPath, memory) {
9420
+ assertNotOkfReservedBasename(targetPath);
9288
9421
  const refIdsAtWrite = this.currentHistoricalIds();
9289
9422
  const rawRef = memory.frontmatter.entityRef;
9290
9423
  const frontmatter = canonicalizeEntityRefOption(memory.frontmatter, refIdsAtWrite);
9291
9424
  const persist = () => writeMaybeEncryptedFile(
9292
9425
  targetPath,
9293
- `${serializeFrontmatter(frontmatter)}
9426
+ `${serializeFrontmatter(this.withOkfType(frontmatter))}
9294
9427
 
9295
9428
  ${memory.content}
9296
9429
  `,
@@ -9360,8 +9493,8 @@ ${memory.content}
9360
9493
  memory.frontmatter.entityRef = current.frontmatter.entityRef;
9361
9494
  }
9362
9495
  durable = true;
9363
- const sourcePath = path12.resolve(current.path);
9364
- const destPath = path12.resolve(targetPath);
9496
+ const sourcePath = path14.resolve(current.path);
9497
+ const destPath = path14.resolve(targetPath);
9365
9498
  if (sourcePath !== destPath) {
9366
9499
  await recordArchiveDelete2(this.baseDir, current.path, () => this.deleteManagedStorageFile(current.path));
9367
9500
  this.invalidateAllMemoriesCache();
@@ -9385,8 +9518,8 @@ ${memory.content}
9385
9518
  }
9386
9519
  async migrateMemoryToTier(memory, targetTier) {
9387
9520
  const targetPath = this.buildTierMemoryPath(memory, targetTier);
9388
- const sourcePath = path12.resolve(memory.path);
9389
- const destPath = path12.resolve(targetPath);
9521
+ const sourcePath = path14.resolve(memory.path);
9522
+ const destPath = path14.resolve(targetPath);
9390
9523
  if (sourcePath === destPath) {
9391
9524
  return { changed: false, targetPath };
9392
9525
  }
@@ -9396,7 +9529,7 @@ ${memory.content}
9396
9529
  return { changed, targetPath };
9397
9530
  }
9398
9531
  get archiveDir() {
9399
- return path12.join(this.baseDir, "archive");
9532
+ return path14.join(this.baseDir, "archive");
9400
9533
  }
9401
9534
  /**
9402
9535
  * Archive a memory by moving it from facts/ to archive/YYYY-MM-DD/.
@@ -9409,7 +9542,7 @@ ${memory.content}
9409
9542
  try {
9410
9543
  const now = lifecycle?.at ?? /* @__PURE__ */ new Date();
9411
9544
  const today = now.toISOString().slice(0, 10);
9412
- const destDir = path12.join(this.archiveDir, today);
9545
+ const destDir = path14.join(this.archiveDir, today);
9413
9546
  await mkdir(destDir, { recursive: true });
9414
9547
  const refIdsAtWrite = this.currentHistoricalIds();
9415
9548
  const updatedFm = canonicalizeEntityRefOption(
@@ -9421,11 +9554,11 @@ ${memory.content}
9421
9554
  },
9422
9555
  refIdsAtWrite
9423
9556
  );
9424
- const fileContent = `${serializeFrontmatter(updatedFm)}
9557
+ const fileContent = `${serializeFrontmatter(this.withOkfType(updatedFm))}
9425
9558
 
9426
9559
  ${current.content}
9427
9560
  `;
9428
- const destPath = path12.join(destDir, path12.basename(current.path));
9561
+ const destPath = path14.join(destDir, path14.basename(current.path));
9429
9562
  const priorDest = await this.readStorageSecureFile(destPath).catch(() => null);
9430
9563
  await recordArchiveWrite(this.baseDir, destPath, () => this.writeStorageSecureFile(destPath, fileContent));
9431
9564
  if (typeof current.frontmatter.entityRef === "string") {
@@ -9578,7 +9711,7 @@ ${current.content}
9578
9711
  if (!sanitized.clean) {
9579
9712
  log.warn(`updated memory content sanitized for ${memory.frontmatter.id}; violations=${sanitized.violations.join(", ")}`);
9580
9713
  }
9581
- const fileContent = `${serializeFrontmatter(updated)}
9714
+ const fileContent = `${serializeFrontmatter(this.withOkfType(updated))}
9582
9715
 
9583
9716
  ${sanitized.text}
9584
9717
  `;
@@ -9652,13 +9785,13 @@ ${sanitized.text}
9652
9785
  );
9653
9786
  const refIds = typeof updated.entityRef === "string" ? resolveIds : null;
9654
9787
  const afterStatus = updated.status ?? "active";
9655
- const fileContent = `${serializeFrontmatter(updated)}
9788
+ const fileContent = `${serializeFrontmatter(this.withOkfType(updated))}
9656
9789
 
9657
9790
  ${memory.content}
9658
9791
  `;
9659
9792
  await this.writeTombstoneBlockedFrontmatter(memory, fileContent, updated, async () => {
9660
9793
  this.invalidateAllMemoriesCache();
9661
- if (memory.path.includes(`${path12.sep}cold${path12.sep}`)) {
9794
+ if (memory.path.includes(`${path14.sep}cold${path14.sep}`)) {
9662
9795
  this.invalidateColdMemoriesCache();
9663
9796
  }
9664
9797
  });
@@ -9669,7 +9802,7 @@ ${memory.content}
9669
9802
  });
9670
9803
  }
9671
9804
  await this.patchHotMemoriesCache({ addedPath: memory.path });
9672
- if (memory.path.includes(`${path12.sep}cold${path12.sep}`)) {
9805
+ if (memory.path.includes(`${path14.sep}cold${path14.sep}`)) {
9673
9806
  this.invalidateColdMemoriesCache();
9674
9807
  }
9675
9808
  try {
@@ -9750,7 +9883,7 @@ ${memory.content}
9750
9883
  return deleted;
9751
9884
  }
9752
9885
  async loadBuffer() {
9753
- const bufferPath = path12.join(this.stateDir, "buffer.json");
9886
+ const bufferPath = path14.join(this.stateDir, "buffer.json");
9754
9887
  try {
9755
9888
  const raw = await this.readStorageSecureFile(bufferPath);
9756
9889
  return JSON.parse(raw);
@@ -9762,11 +9895,11 @@ ${memory.content}
9762
9895
  }
9763
9896
  async saveBuffer(state) {
9764
9897
  await this.ensureDirectories();
9765
- const bufferPath = path12.join(this.stateDir, "buffer.json");
9898
+ const bufferPath = path14.join(this.stateDir, "buffer.json");
9766
9899
  await this.writeStorageSecureFile(bufferPath, JSON.stringify(state, null, 2));
9767
9900
  }
9768
9901
  async loadMeta() {
9769
- const metaPath = path12.join(this.stateDir, "meta.json");
9902
+ const metaPath = path14.join(this.stateDir, "meta.json");
9770
9903
  try {
9771
9904
  const raw = await this.readStorageSecureFile(metaPath);
9772
9905
  const parsed = JSON.parse(raw);
@@ -9799,7 +9932,7 @@ ${memory.content}
9799
9932
  }
9800
9933
  async saveMeta(state) {
9801
9934
  await this.ensureDirectories();
9802
- const metaPath = path12.join(this.stateDir, "meta.json");
9935
+ const metaPath = path14.join(this.stateDir, "meta.json");
9803
9936
  await this.writeStorageSecureFile(metaPath, JSON.stringify(state, null, 2));
9804
9937
  }
9805
9938
  async appendMemoryActionEvents(events) {
@@ -9863,7 +9996,7 @@ ${memory.content}
9863
9996
  },
9864
9997
  (payload) => this.appendStorageSecureFile(target, payload),
9865
9998
  async () => {
9866
- await mkdir(path12.dirname(target), { recursive: true });
9999
+ await mkdir(path14.dirname(target), { recursive: true });
9867
10000
  }
9868
10001
  );
9869
10002
  }
@@ -9961,7 +10094,7 @@ ${memory.content}
9961
10094
  async appendReextractJobs(events) {
9962
10095
  if (events.length === 0) return 0;
9963
10096
  await this.ensureDirectories();
9964
- const filePath = path12.join(this.stateDir, "reextract-jobs.jsonl");
10097
+ const filePath = path14.join(this.stateDir, "reextract-jobs.jsonl");
9965
10098
  const lines = events.map((event) => JSON.stringify(event)).join("\n") + "\n";
9966
10099
  try {
9967
10100
  await this.appendStorageSecureFile(filePath, lines);
@@ -9974,7 +10107,7 @@ ${memory.content}
9974
10107
  }
9975
10108
  async readReextractJobs(limit = 200) {
9976
10109
  const safeLimit = Number.isFinite(limit) ? Math.max(1, Math.min(1e3, Math.floor(limit))) : 200;
9977
- const filePath = path12.join(this.stateDir, "reextract-jobs.jsonl");
10110
+ const filePath = path14.join(this.stateDir, "reextract-jobs.jsonl");
9978
10111
  try {
9979
10112
  const raw = await this.readStorageSecureFile(filePath);
9980
10113
  const lines = raw.split("\n").filter((line) => line.trim().length > 0);
@@ -10191,7 +10324,8 @@ ${memory.content}
10191
10324
  id,
10192
10325
  created: (/* @__PURE__ */ new Date()).toISOString(),
10193
10326
  priority,
10194
- resolved: false
10327
+ resolved: false,
10328
+ ...this.okfConformanceEnabled() ? { type: OKF_QUESTION_TYPE } : {}
10195
10329
  };
10196
10330
  const content = `---
10197
10331
  ${Object.entries(frontmatter).map(([k, v]) => `${k}: ${JSON.stringify(v)}`).join("\n")}
@@ -10201,7 +10335,7 @@ ${question}
10201
10335
 
10202
10336
  **Context:** ${context}
10203
10337
  `;
10204
- const filePath = path12.join(this.questionsDir, `${id}.md`);
10338
+ const filePath = path14.join(this.questionsDir, `${id}.md`);
10205
10339
  await this.writeStorageSecureFile(filePath, content);
10206
10340
  log.debug(`wrote question ${id} to ${filePath}`);
10207
10341
  this.invalidateQuestionsCache();
@@ -10215,22 +10349,7 @@ ${question}
10215
10349
  _StorageManager.questionsCache.delete(this.questionsDir);
10216
10350
  }
10217
10351
  parseQuestionFile(raw, filePath) {
10218
- const match = raw.match(/^---\n([\s\S]*?)\n---\n\n([\s\S]*)$/);
10219
- if (!match) return null;
10220
- const frontmatterStr = match[1];
10221
- const body = match[2].trim();
10222
- const id = this.extractFrontmatterValue(frontmatterStr, "id") ?? path12.basename(filePath, ".md");
10223
- const created = this.extractFrontmatterValue(frontmatterStr, "created") ?? "";
10224
- const priority = parseFloat(this.extractFrontmatterValue(frontmatterStr, "priority") ?? "0.5");
10225
- const resolved = this.extractFrontmatterValue(frontmatterStr, "resolved") === "true";
10226
- const contextMatch = body.match(/\*\*Context:\*\*\s*(.*)/);
10227
- const question = contextMatch ? body.slice(0, contextMatch.index).trim() : body;
10228
- const context = contextMatch ? contextMatch[1].trim() : "";
10229
- return { id, question, context, priority, resolved, created, filePath };
10230
- }
10231
- extractFrontmatterValue(frontmatter, key) {
10232
- const match = frontmatter.match(new RegExp(`^${key}:\\s*"?([^"\\n]*)"?`, "m"));
10233
- return match ? match[1] : null;
10352
+ return parseQuestionFile(raw, filePath);
10234
10353
  }
10235
10354
  async resolveQuestion(id) {
10236
10355
  const questions = await this.readQuestions();
@@ -10275,11 +10394,11 @@ ${question}
10275
10394
  } catch {
10276
10395
  }
10277
10396
  const hygiene = opts?.hygiene;
10278
- const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(path12.basename(identityPath));
10397
+ const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(path14.basename(identityPath));
10279
10398
  if (rotateEnabled) {
10280
10399
  const maxBytes = hygiene.rotateMaxBytes;
10281
10400
  if (existing.length > maxBytes) {
10282
- const archiveDir = path12.join(workspaceDir, hygiene.archiveDir);
10401
+ const archiveDir = path14.join(workspaceDir, hygiene.archiveDir);
10283
10402
  const { newContent } = await rotateMarkdownFileToArchive({
10284
10403
  filePath: identityPath,
10285
10404
  archiveDir,
@@ -10539,14 +10658,14 @@ ${reflection}
10539
10658
  if (entries.length === 0) return 0;
10540
10659
  const memories = await this.readAllMemories();
10541
10660
  const memoryMap = new Map(memories.map((m) => [m.frontmatter.id, m]));
10542
- const memoryPathMap = new Map(memories.map((m) => [path12.resolve(m.path), m]));
10661
+ const memoryPathMap = new Map(memories.map((m) => [path14.resolve(m.path), m]));
10543
10662
  let updated = 0;
10544
10663
  const prevVersion = this.getMemoryCorpusVersion();
10545
10664
  const keyId = this.hotCacheKeyId();
10546
10665
  const warm = this.hotMemoriesCacheEnabled && getCachedMemories(this.baseDir, prevVersion, keyId, this.hotCacheTtlMs()) !== null;
10547
10666
  const appliedPatches = /* @__PURE__ */ new Map();
10548
10667
  for (const entry of entries) {
10549
- const memory = entry.memoryPath ? memoryPathMap.get(path12.resolve(entry.memoryPath)) : memoryMap.get(entry.memoryId);
10668
+ const memory = entry.memoryPath ? memoryPathMap.get(path14.resolve(entry.memoryPath)) : memoryMap.get(entry.memoryId);
10550
10669
  if (!memory) continue;
10551
10670
  try {
10552
10671
  const applied = await this.withTombstoneBlockedMemoryPathLock(memory.path, async (current) => {
@@ -10556,7 +10675,7 @@ ${reflection}
10556
10675
  { ...current.frontmatter, accessCount: entry.newCount, lastAccessed: entry.lastAccessed },
10557
10676
  rowIds
10558
10677
  );
10559
- const fileContent = `${serializeFrontmatter(newFm)}
10678
+ const fileContent = `${serializeFrontmatter(this.withOkfType(newFm))}
10560
10679
 
10561
10680
  ${current.content}
10562
10681
  `;
@@ -10577,7 +10696,7 @@ ${current.content}
10577
10696
  if (warm) {
10578
10697
  updateCacheOnWrite(this.baseDir, { ...applied.current, frontmatter: applied.newFm }, keyId);
10579
10698
  }
10580
- appliedPatches.set(path12.resolve(memory.path), {
10699
+ appliedPatches.set(path14.resolve(memory.path), {
10581
10700
  accessCount: entry.newCount,
10582
10701
  lastAccessed: entry.lastAccessed
10583
10702
  });
@@ -10593,7 +10712,7 @@ ${current.content}
10593
10712
  const cur = getCachedMemories(this.baseDir, prevVersion, keyId);
10594
10713
  if (cur) {
10595
10714
  const reapplied = cur.map((m) => {
10596
- const patch = appliedPatches.get(path12.resolve(m.path));
10715
+ const patch = appliedPatches.get(path14.resolve(m.path));
10597
10716
  return patch ? {
10598
10717
  ...m,
10599
10718
  frontmatter: { ...m.frontmatter, accessCount: patch.accessCount, lastAccessed: patch.lastAccessed }
@@ -10623,7 +10742,7 @@ ${current.content}
10623
10742
  const pathsById = /* @__PURE__ */ new Map();
10624
10743
  const filePathsById = /* @__PURE__ */ new Map();
10625
10744
  for (const filePath of filePaths) {
10626
- const memoryId = path12.basename(filePath, ".md");
10745
+ const memoryId = path14.basename(filePath, ".md");
10627
10746
  if (!wantedIds.has(memoryId)) continue;
10628
10747
  const paths = filePathsById.get(memoryId) ?? [];
10629
10748
  paths.push(filePath);
@@ -10635,7 +10754,7 @@ ${current.content}
10635
10754
  const preferredMatches = [];
10636
10755
  for (const preferredPath of preferred) {
10637
10756
  const directCandidates = new Set(qmdResultPathCandidates(this.baseDir, preferredPath));
10638
- const directMatch = existingPaths.find((filePath) => directCandidates.has(path12.resolve(filePath)));
10757
+ const directMatch = existingPaths.find((filePath) => directCandidates.has(path14.resolve(filePath)));
10639
10758
  if (directMatch) {
10640
10759
  preferredMatches.push(directMatch);
10641
10760
  continue;
@@ -10647,7 +10766,7 @@ ${current.content}
10647
10766
  candidates.add(candidate);
10648
10767
  }
10649
10768
  }
10650
- const match = existingPaths.find((filePath) => candidates.has(path12.resolve(filePath)));
10769
+ const match = existingPaths.find((filePath) => candidates.has(path14.resolve(filePath)));
10651
10770
  if (match) preferredMatches.push(match);
10652
10771
  }
10653
10772
  if (preferredMatches.length > 0) {
@@ -10778,7 +10897,7 @@ ${current.content}
10778
10897
  }) ? { toolScoped: true } : {}
10779
10898
  };
10780
10899
  const filePath = await this.resolveCategoryWritePath(category, id, today);
10781
- const fileContent = `${serializeFrontmatter(fm)}
10900
+ const fileContent = `${serializeFrontmatter(this.withOkfType(fm))}
10782
10901
 
10783
10902
  ${sanitized.text}
10784
10903
  `;
@@ -10877,7 +10996,7 @@ ${sanitized.text}
10877
10996
  },
10878
10997
  refIdsAtWrite
10879
10998
  );
10880
- const fileContent = `${serializeFrontmatter(updatedFm)}
10999
+ const fileContent = `${serializeFrontmatter(this.withOkfType(updatedFm))}
10881
11000
 
10882
11001
  ${current.content}
10883
11002
  `;
@@ -10967,11 +11086,11 @@ ${current.content}
10967
11086
  }
10968
11087
  }
10969
11088
  get summariesDir() {
10970
- return path12.join(this.baseDir, "summaries");
11089
+ return path14.join(this.baseDir, "summaries");
10971
11090
  }
10972
11091
  async writeSummary(summary) {
10973
11092
  await mkdir(this.summariesDir, { recursive: true });
10974
- const filePath = path12.join(this.summariesDir, `${summary.id}.json`);
11093
+ const filePath = path14.join(this.summariesDir, `${summary.id}.json`);
10975
11094
  await this.writeStorageSecureFile(filePath, JSON.stringify(summary, null, 2));
10976
11095
  log.debug(`wrote summary ${summary.id}`);
10977
11096
  }
@@ -10981,7 +11100,7 @@ ${current.content}
10981
11100
  const summaries = [];
10982
11101
  for (const file of files) {
10983
11102
  if (!file.endsWith(".json")) continue;
10984
- const filePath = path12.join(this.summariesDir, file);
11103
+ const filePath = path14.join(this.summariesDir, file);
10985
11104
  const raw = await this.readStorageSecureFile(filePath);
10986
11105
  summaries.push(JSON.parse(raw));
10987
11106
  }
@@ -11011,7 +11130,7 @@ ${current.content}
11011
11130
  { ...current.frontmatter, status: "archived", archivedAt: now, updated: now },
11012
11131
  rowIds
11013
11132
  );
11014
- const fileContent = `${serializeFrontmatter(updatedFm)}
11133
+ const fileContent = `${serializeFrontmatter(this.withOkfType(updatedFm))}
11015
11134
 
11016
11135
  ${current.content}
11017
11136
  `;
@@ -11051,7 +11170,7 @@ ${current.content}
11051
11170
  return archived;
11052
11171
  }
11053
11172
  async saveTopics(topics) {
11054
- const metaPath = path12.join(this.stateDir, "topics.json");
11173
+ const metaPath = path14.join(this.stateDir, "topics.json");
11055
11174
  await mkdir(this.stateDir, { recursive: true });
11056
11175
  await this.writeStorageSecureFile(
11057
11176
  metaPath,
@@ -11060,7 +11179,7 @@ ${current.content}
11060
11179
  log.debug(`saved ${topics.length} topic scores`);
11061
11180
  }
11062
11181
  async loadTopics() {
11063
- const metaPath = path12.join(this.stateDir, "topics.json");
11182
+ const metaPath = path14.join(this.stateDir, "topics.json");
11064
11183
  try {
11065
11184
  const raw = await this.readStorageSecureFile(metaPath);
11066
11185
  return JSON.parse(raw);
@@ -11135,6 +11254,8 @@ ${current.content}
11135
11254
  };
11136
11255
 
11137
11256
  export {
11257
+ okfTypeForCategory,
11258
+ OKF_RESERVED_BASENAMES,
11138
11259
  selfDeps,
11139
11260
  qmdCollectionPathParts,
11140
11261
  qmdResultPathCandidates,
@@ -11176,4 +11297,4 @@ export {
11176
11297
  isValidBufferSurpriseEvent,
11177
11298
  StorageManager3 as StorageManager
11178
11299
  };
11179
- //# sourceMappingURL=chunk-2RZCOG63.js.map
11300
+ //# sourceMappingURL=chunk-2QI2JBLQ.js.map