@remnic/core 9.62.1 → 9.62.2
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.
- package/dist/access-admin-ops-surface.d.ts +11 -11
- package/dist/access-admin-ops-surface.js +26 -26
- package/dist/access-audit.js +2 -2
- package/dist/access-authorization-probe.d.ts +11 -11
- package/dist/access-authorization-probe.js +27 -27
- package/dist/access-boundary.d.ts +11 -11
- package/dist/access-boundary.js +26 -26
- package/dist/access-cli.js +88 -86
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.d.ts +1 -1
- package/dist/access-extraction-force-flush.d.ts +11 -11
- package/dist/access-extraction-force-flush.js +26 -26
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +11 -11
- package/dist/access-http-lifecycle-flush.d.ts +11 -11
- package/dist/access-http-offline-stream.d.ts +11 -11
- package/dist/access-http-query.js +26 -26
- package/dist/access-http.d.ts +12 -12
- package/dist/access-http.js +36 -36
- package/dist/access-identity-continuity-surface.d.ts +9 -9
- package/dist/access-identity-continuity-surface.js +26 -26
- package/dist/access-lcm-surface.d.ts +11 -11
- package/dist/access-lcm-surface.js +26 -26
- package/dist/access-mcp.d.ts +11 -11
- package/dist/access-mcp.js +31 -31
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-EMvicnrb.d.ts → access-namespace-preflight-yO4LMGFH.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +26 -26
- package/dist/access-observe-write-surface.d.ts +11 -11
- package/dist/access-observe-write-surface.js +26 -26
- package/dist/access-offline-manifest.d.ts +9 -9
- package/dist/access-offline-manifest.js +2 -2
- package/dist/access-operations-batch.js +27 -27
- package/dist/access-operations.d.ts +11 -11
- package/dist/access-operations.js +30 -30
- package/dist/access-recall-concurrency.d.ts +11 -11
- package/dist/access-recall-concurrency.js +26 -26
- package/dist/access-recall-response.d.ts +11 -11
- package/dist/access-recall-response.js +26 -26
- package/dist/access-recall-surface.d.ts +11 -11
- package/dist/access-recall-surface.js +26 -26
- package/dist/{access-service-BeDYQQ62.d.ts → access-service-M4LgO141.d.ts} +7 -7
- package/dist/access-service-helpers.d.ts +11 -11
- package/dist/access-service.d.ts +11 -11
- package/dist/access-service.js +26 -26
- package/dist/access-surface-catalog.d.ts +11 -11
- package/dist/access-surface-catalog.js +28 -28
- package/dist/access-wearables-meetings-surface.d.ts +3 -3
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +1 -1
- package/dist/ambient-provenance.d.ts +1 -1
- package/dist/artifact-search.d.ts +1 -1
- package/dist/{auto-sync-FMWQQB3J.js → auto-sync-Z52VWMNC.js} +3 -3
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-learner.js +2 -2
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +9 -9
- package/dist/briefing-window.d.ts +2 -2
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +11 -10
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer-turn-helpers.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{catalog-B2SxZ6LU.d.ts → catalog-CyYTf_ok.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-behavior.js +3 -3
- package/dist/causal-chain.js +3 -3
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +14 -14
- package/dist/causal-retrieval.js +3 -3
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/causal-trajectory.js +2 -2
- package/dist/{chunk-B2QHVLJO.js → chunk-256FBCVX.js} +22 -10
- package/dist/chunk-256FBCVX.js.map +1 -0
- package/dist/{chunk-QP2IZTUR.js → chunk-2TYIAKU5.js} +2 -2
- package/dist/{chunk-QNMNNFKD.js → chunk-347ZR6D4.js} +2 -2
- package/dist/{chunk-76YNCJ5H.js → chunk-3F3CVVDS.js} +2 -2
- package/dist/{chunk-KCFZOSR6.js → chunk-3MA7JVXN.js} +4 -4
- package/dist/{chunk-KHQ57QLJ.js → chunk-46WM6JX2.js} +7 -3
- package/dist/chunk-46WM6JX2.js.map +1 -0
- package/dist/chunk-47DU4SGJ.js +92 -0
- package/dist/chunk-47DU4SGJ.js.map +1 -0
- package/dist/{chunk-HKYNBEL4.js → chunk-4FFROSFG.js} +37 -14
- package/dist/{chunk-HKYNBEL4.js.map → chunk-4FFROSFG.js.map} +1 -1
- package/dist/{chunk-TLUSSS2F.js → chunk-4HO3542O.js} +2 -2
- package/dist/{chunk-4E67XCT2.js → chunk-4IZ2IT7D.js} +3 -3
- package/dist/{chunk-33JBK2XP.js → chunk-5F6HMNMZ.js} +2 -2
- package/dist/{chunk-5WQMORU5.js → chunk-5PFGMO33.js} +2 -2
- package/dist/{chunk-6HEM6HTQ.js → chunk-6GGTATZF.js} +2 -2
- package/dist/{chunk-UIRU3MIJ.js → chunk-7BJYTX6Q.js} +2 -2
- package/dist/{chunk-2GRLJMKJ.js → chunk-7DRSWPUV.js} +3 -3
- package/dist/{chunk-TVVEYCNW.js → chunk-7K5Q6COX.js} +4 -4
- package/dist/{chunk-HXXGZ4KV.js → chunk-ALNZEWGN.js} +2 -2
- package/dist/{chunk-5WVUO6QT.js → chunk-AR253JBM.js} +1 -1
- package/dist/chunk-AR253JBM.js.map +1 -0
- package/dist/{chunk-67MKNKJQ.js → chunk-AYIHDC5S.js} +2 -2
- package/dist/{chunk-IXJ5U6ZL.js → chunk-BBHFAVMP.js} +8 -8
- package/dist/{chunk-IIRK5V5Z.js → chunk-BHO6RHE5.js} +3 -3
- package/dist/{chunk-WANOCU3K.js → chunk-BP6WMYLP.js} +3 -3
- package/dist/{chunk-ZJKLGS76.js → chunk-CALURYWR.js} +283 -248
- package/dist/chunk-CALURYWR.js.map +1 -0
- package/dist/{chunk-JLMH5YMU.js → chunk-CH627RRV.js} +2 -2
- package/dist/{chunk-XIABRKF6.js → chunk-CLJ5QS6J.js} +239 -47
- package/dist/chunk-CLJ5QS6J.js.map +1 -0
- package/dist/{chunk-YLHM5BQQ.js → chunk-DCUMFQYM.js} +171 -8
- package/dist/chunk-DCUMFQYM.js.map +1 -0
- package/dist/{chunk-ZBJMUXZH.js → chunk-DJ7HMNSL.js} +15 -8
- package/dist/chunk-DJ7HMNSL.js.map +1 -0
- package/dist/{chunk-WTMG5GAK.js → chunk-DROAPP6N.js} +3 -3
- package/dist/{chunk-PBH2Z2NY.js → chunk-DTLF2SLZ.js} +2 -2
- package/dist/{chunk-7JAXC526.js → chunk-EFWHCTYJ.js} +2 -2
- package/dist/{chunk-3XG4QEA2.js → chunk-FF6E6HOT.js} +39 -39
- package/dist/{chunk-NP7FLVZW.js → chunk-G2FCSILA.js} +2 -2
- package/dist/{chunk-7PVTOZR4.js → chunk-H23GIXJC.js} +2 -2
- package/dist/{chunk-WT6UL3UA.js → chunk-H7PRHUBD.js} +2 -2
- package/dist/{chunk-ETCVSZLG.js → chunk-HSBQJRV2.js} +2 -2
- package/dist/{chunk-GZRDOVQN.js → chunk-HVKMJAEF.js} +2 -2
- package/dist/{chunk-CSOYVTRX.js → chunk-IIPJKCZB.js} +3 -3
- package/dist/{chunk-E57E5SCS.js → chunk-IRLH4NM2.js} +3 -3
- package/dist/{chunk-4G45LJJP.js → chunk-IZRNVNPV.js} +2 -2
- package/dist/{chunk-YSUSUZR4.js → chunk-JCJGYNIS.js} +3 -3
- package/dist/{chunk-EU74U4GT.js → chunk-JDI7G6EA.js} +2 -2
- package/dist/{chunk-QWPAQLYV.js → chunk-JFLKSD5V.js} +2 -2
- package/dist/{chunk-KQS72GCR.js → chunk-LJOIZPJH.js} +2 -2
- package/dist/{chunk-U27G4E5G.js → chunk-LLGDVG52.js} +3 -3
- package/dist/{chunk-7N7DB4L5.js → chunk-LTJTP5YQ.js} +10 -9
- package/dist/chunk-LTJTP5YQ.js.map +1 -0
- package/dist/{chunk-XL3TATMJ.js → chunk-OQIRBGUU.js} +21 -12
- package/dist/chunk-OQIRBGUU.js.map +1 -0
- package/dist/{chunk-JGW2EUCQ.js → chunk-PMRUMGK6.js} +2 -2
- package/dist/{chunk-3G6YU5YD.js → chunk-PSNN25DW.js} +2 -2
- package/dist/{chunk-LRGSLV7M.js → chunk-PYHOAXTI.js} +4 -4
- package/dist/{chunk-75U2FR7U.js → chunk-QCI73Z7C.js} +2 -2
- package/dist/{chunk-EHMMRZOZ.js → chunk-QICOU4RY.js} +2 -2
- package/dist/{chunk-K4WIUTNH.js → chunk-RFH7U5LT.js} +2 -2
- package/dist/{chunk-4SGDYYWV.js → chunk-RPKJHYVE.js} +2 -2
- package/dist/{chunk-BHO3IVAN.js → chunk-RYST72N5.js} +12 -1
- package/dist/chunk-RYST72N5.js.map +1 -0
- package/dist/chunk-T3GIETKV.js +152 -0
- package/dist/chunk-T3GIETKV.js.map +1 -0
- package/dist/{chunk-DYDACAK2.js → chunk-TGSMU3F2.js} +3 -3
- package/dist/{chunk-MJFDJTDC.js → chunk-TIRJV2LW.js} +2 -2
- package/dist/{chunk-QRA3XVJX.js → chunk-UDTME32W.js} +2 -2
- package/dist/{chunk-LAM6UDFV.js → chunk-WMOJIOIG.js} +2 -2
- package/dist/{chunk-LLLY5IBK.js → chunk-WR2YKUIW.js} +2 -2
- package/dist/{chunk-KYI3CM42.js → chunk-X6E7TT3A.js} +2 -2
- package/dist/{chunk-QN7XQEIT.js → chunk-YIIC5IDU.js} +2 -2
- package/dist/{chunk-JDJOAL4B.js → chunk-YSR3DXGC.js} +2 -2
- package/dist/{chunk-LBJBNWS2.js → chunk-YTHQHH5U.js} +2 -2
- package/dist/{chunk-JF6YSHJM.js → chunk-ZPGHA7EO.js} +12 -12
- package/dist/{chunk-VUDALPI5.js → chunk-ZQKXRKMR.js} +19 -5
- package/dist/chunk-ZQKXRKMR.js.map +1 -0
- package/dist/{chunk-YG56A6XY.js → chunk-ZS4JADYY.js} +3 -3
- package/dist/{cli-DB_uakTc.d.ts → cli-Bw9z-KqX.d.ts} +5 -5
- package/dist/cli.d.ts +13 -13
- package/dist/cli.js +60 -60
- package/dist/coding/pre-action-gate.d.ts +1 -1
- package/dist/coding/pre-action-gate.js +3 -3
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +11 -10
- package/dist/compounding/preference-consolidator.d.ts +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +11 -10
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +11 -10
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/contradiction/index.d.ts +2 -2
- package/dist/converge-config.d.ts +1 -1
- package/dist/convergence-refresh.d.ts +2 -2
- package/dist/convergence-refresh.js +13 -12
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/corpus-watermark.d.ts +1 -1
- package/dist/corpus-watermark.js +13 -12
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/dependency-propagation-config.d.ts +1 -1
- package/dist/{dependency-propagation-delivery-DcOVpK3y.d.ts → dependency-propagation-delivery-BxhvAppj.d.ts} +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer-wiring.js +3 -3
- package/dist/direct-answer.d.ts +1 -1
- package/dist/direct-answer.js +2 -2
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/entity-origin-fields.d.ts +1 -1
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +11 -10
- package/dist/entity-schema.d.ts +1 -1
- package/dist/episodic-context.d.ts +92 -0
- package/dist/episodic-context.js +16 -0
- package/dist/episodic-context.js.map +1 -0
- package/dist/explicit-capture.d.ts +9 -9
- package/dist/external-wiki-access.d.ts +11 -11
- package/dist/external-wiki-access.js +27 -27
- package/dist/external-wiki-collection-registration.d.ts +1 -1
- package/dist/external-wiki-collection.d.ts +1 -1
- package/dist/external-wiki-mcp-tools.d.ts +11 -11
- package/dist/extraction-error-classification.d.ts +1 -1
- package/dist/extraction-faithfulness.d.ts +1 -1
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction-liveness.d.ts +1 -1
- package/dist/extraction-normalization.d.ts +1 -1
- package/dist/extraction-normalization.js +2 -2
- package/dist/extraction-prompt.d.ts +1 -1
- package/dist/extraction-source-grounding-rules.d.ts +1 -1
- package/dist/extraction-source-grounding.d.ts +1 -1
- package/dist/extraction.d.ts +1 -1
- package/dist/extraction.js +14 -14
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/{forget-5TWK7CZT.js → forget-SZ2BXDGF.js} +2 -2
- package/dist/graph-dashboard-diff.d.ts +1 -1
- package/dist/graph-dashboard-key.d.ts +1 -1
- package/dist/graph-dashboard-parser.d.ts +1 -1
- package/dist/graph-edge-reinforcement.d.ts +1 -1
- package/dist/graph-path-reconstruction.d.ts +1 -1
- package/dist/graph-path-scoring.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph.d.ts +1 -1
- package/dist/harmonic-construction.js +2 -2
- package/dist/harmonic-retrieval.js +2 -2
- package/dist/importance.d.ts +1 -1
- package/dist/importers/index.d.ts +1 -1
- package/dist/in-flight-reads.d.ts +1 -1
- package/dist/index.d.ts +21 -21
- package/dist/index.js +100 -98
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +8 -2
- package/dist/lcm/engine.js +4 -4
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +9 -9
- package/dist/lcm/tools.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +1 -1
- package/dist/local-model-endpoint.d.ts +1 -1
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +11 -10
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +11 -10
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +12 -11
- package/dist/{maintenance-5c1olVtB.d.ts → maintenance-uJb74j64.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +11 -11
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
- package/dist/memory-projection-store.d.ts +1 -1
- package/dist/memory-provenance.d.ts +1 -1
- package/dist/memory-snapshot.d.ts +1 -1
- package/dist/memory-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +3 -3
- package/dist/namespaces/migrate.js +12 -11
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +6 -5
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +11 -10
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/operator-doctor-corpus.d.ts +1 -1
- package/dist/operator-doctor-corpus.js +14 -13
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +19 -18
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +4 -4
- package/dist/orchestration/maintenance.js +16 -15
- package/dist/{orchestrator-HPuY6I4i.d.ts → orchestrator-CFi-5JSR.d.ts} +23 -8
- package/dist/orchestrator.d.ts +9 -9
- package/dist/orchestrator.js +88 -86
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-CvVe1Q2_.d.ts → pipeline-BdF3ferY.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/policy-runtime.js +3 -3
- package/dist/proactive-contention.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/{public-http-D0JKFkyf.d.ts → public-http-DK-QwaBu.d.ts} +1 -1
- package/dist/{qmd-Bd0Tp76_.d.ts → qmd-D_62bYNl.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +2 -2
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +1 -1
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-query-policy.js +2 -2
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.d.ts +1 -1
- package/dist/recall-tokenization.d.ts +3 -1
- package/dist/recall-tokenization.js +5 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +1 -1
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/cursor.d.ts +1 -1
- package/dist/reconcile/manifest.d.ts +10 -1
- package/dist/reconcile/manifest.js +1 -1
- package/dist/reconcile/plan.d.ts +1 -1
- package/dist/replay/normalizers/chatgpt.d.ts +1 -1
- package/dist/replay/normalizers/claude.d.ts +1 -1
- package/dist/replay/normalizers/openclaw.d.ts +1 -1
- package/dist/replay/normalizers/shared.d.ts +1 -1
- package/dist/replay/runner.d.ts +1 -1
- package/dist/replay/types.d.ts +1 -1
- package/dist/replica-divergence.d.ts +1 -1
- package/dist/replica-peers-config.d.ts +1 -1
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +4 -4
- package/dist/retrieval-agents.d.ts +2 -2
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/routing/engine.d.ts +1 -1
- package/dist/routing/store.d.ts +1 -1
- package/dist/salvage-envelope.d.ts +1 -1
- package/dist/{scope-profiles-ClLtm9gK.d.ts → scope-profiles-CeMv7pP0.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/factory.js +5 -4
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +9 -8
- package/dist/search/lancedb-backend.d.ts +14 -1
- package/dist/search/lancedb-backend.js +1 -1
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +22 -1
- package/dist/search/orama-backend.js +2 -1
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-B1EkeEDj.d.ts → semantic-consolidation-B-85brYj.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +12 -12
- package/dist/semantic-rule-promotion.js +11 -10
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +11 -11
- package/dist/{service-Cf3ANQj9.d.ts → service-CoO0HA2E.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +1 -1
- package/dist/signal.d.ts +1 -1
- package/dist/source-agent-qualifier.d.ts +1 -1
- package/dist/source-agent-qualifier.js +11 -10
- package/dist/{storage-DS2O_6Qt.d.ts → storage-BVAVitkO.d.ts} +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +10 -9
- package/dist/summarizer.d.ts +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/support-passport/index.d.ts +14 -14
- package/dist/support-passport/index.js +29 -29
- package/dist/temporal-supersession.d.ts +2 -2
- package/dist/temporal-timeline-recall.d.ts +1 -1
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +2 -2
- package/dist/tier-routing.d.ts +1 -1
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transfer/import-sqlite.js +2 -2
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/trust-zones.js +2 -2
- package/dist/{types-BOANGhCJ.d.ts → types-DWHOxlZP.d.ts} +3 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/user-message-cleaning.d.ts +23 -0
- package/dist/user-message-cleaning.js +10 -0
- package/dist/user-message-cleaning.js.map +1 -0
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +11 -11
- package/dist/work-product-ledger.js +2 -2
- package/dist/write-envelope.d.ts +1 -1
- package/package.json +12 -2
- package/src/access-service-offline-file-content.test.ts +1 -0
- package/src/config.ts +11 -0
- package/src/episodic-context-recall.integration.test.ts +169 -0
- package/src/episodic-context.test.ts +266 -0
- package/src/episodic-context.ts +274 -0
- package/src/lcm/engine.ts +18 -1
- package/src/lifecycle/tombstones.test.ts +134 -0
- package/src/lifecycle/tombstones.ts +29 -2
- package/src/orchestration/episodic-context-section.ts +255 -0
- package/src/orchestration/recall-internal-deps.ts +2 -0
- package/src/orchestration/recall-internal.ts +40 -25
- package/src/orchestration/recall-result-formatter.ts +37 -0
- package/src/recall-tokenization.ts +14 -8
- package/src/reconcile/manifest.test.ts +133 -4
- package/src/reconcile/manifest.ts +43 -7
- package/src/search/factory.ts +1 -0
- package/src/search/lancedb-backend.ts +24 -16
- package/src/search/orama-backend.test.ts +208 -1
- package/src/search/orama-backend.ts +133 -18
- package/src/search/orama-cjk-tokenizer.test.ts +108 -0
- package/src/search/orama-cjk-tokenizer.ts +143 -0
- package/src/storage/tombstone-migration-sources.test.ts +116 -0
- package/src/storage/tombstone-migration-sources.ts +90 -0
- package/src/storage.ts +13 -34
- package/src/types.ts +3 -3
- package/src/user-message-cleaning.ts +139 -0
- package/dist/chunk-5WVUO6QT.js.map +0 -1
- package/dist/chunk-7N7DB4L5.js.map +0 -1
- package/dist/chunk-B2QHVLJO.js.map +0 -1
- package/dist/chunk-BHO3IVAN.js.map +0 -1
- package/dist/chunk-KHQ57QLJ.js.map +0 -1
- package/dist/chunk-VUDALPI5.js.map +0 -1
- package/dist/chunk-XIABRKF6.js.map +0 -1
- package/dist/chunk-XL3TATMJ.js.map +0 -1
- package/dist/chunk-YLHM5BQQ.js.map +0 -1
- package/dist/chunk-ZBJMUXZH.js.map +0 -1
- package/dist/chunk-ZJKLGS76.js.map +0 -1
- /package/dist/{auto-sync-FMWQQB3J.js.map → auto-sync-Z52VWMNC.js.map} +0 -0
- /package/dist/{chunk-QP2IZTUR.js.map → chunk-2TYIAKU5.js.map} +0 -0
- /package/dist/{chunk-QNMNNFKD.js.map → chunk-347ZR6D4.js.map} +0 -0
- /package/dist/{chunk-76YNCJ5H.js.map → chunk-3F3CVVDS.js.map} +0 -0
- /package/dist/{chunk-KCFZOSR6.js.map → chunk-3MA7JVXN.js.map} +0 -0
- /package/dist/{chunk-TLUSSS2F.js.map → chunk-4HO3542O.js.map} +0 -0
- /package/dist/{chunk-4E67XCT2.js.map → chunk-4IZ2IT7D.js.map} +0 -0
- /package/dist/{chunk-33JBK2XP.js.map → chunk-5F6HMNMZ.js.map} +0 -0
- /package/dist/{chunk-5WQMORU5.js.map → chunk-5PFGMO33.js.map} +0 -0
- /package/dist/{chunk-6HEM6HTQ.js.map → chunk-6GGTATZF.js.map} +0 -0
- /package/dist/{chunk-UIRU3MIJ.js.map → chunk-7BJYTX6Q.js.map} +0 -0
- /package/dist/{chunk-2GRLJMKJ.js.map → chunk-7DRSWPUV.js.map} +0 -0
- /package/dist/{chunk-TVVEYCNW.js.map → chunk-7K5Q6COX.js.map} +0 -0
- /package/dist/{chunk-HXXGZ4KV.js.map → chunk-ALNZEWGN.js.map} +0 -0
- /package/dist/{chunk-67MKNKJQ.js.map → chunk-AYIHDC5S.js.map} +0 -0
- /package/dist/{chunk-IXJ5U6ZL.js.map → chunk-BBHFAVMP.js.map} +0 -0
- /package/dist/{chunk-IIRK5V5Z.js.map → chunk-BHO6RHE5.js.map} +0 -0
- /package/dist/{chunk-WANOCU3K.js.map → chunk-BP6WMYLP.js.map} +0 -0
- /package/dist/{chunk-JLMH5YMU.js.map → chunk-CH627RRV.js.map} +0 -0
- /package/dist/{chunk-WTMG5GAK.js.map → chunk-DROAPP6N.js.map} +0 -0
- /package/dist/{chunk-PBH2Z2NY.js.map → chunk-DTLF2SLZ.js.map} +0 -0
- /package/dist/{chunk-7JAXC526.js.map → chunk-EFWHCTYJ.js.map} +0 -0
- /package/dist/{chunk-3XG4QEA2.js.map → chunk-FF6E6HOT.js.map} +0 -0
- /package/dist/{chunk-NP7FLVZW.js.map → chunk-G2FCSILA.js.map} +0 -0
- /package/dist/{chunk-7PVTOZR4.js.map → chunk-H23GIXJC.js.map} +0 -0
- /package/dist/{chunk-WT6UL3UA.js.map → chunk-H7PRHUBD.js.map} +0 -0
- /package/dist/{chunk-ETCVSZLG.js.map → chunk-HSBQJRV2.js.map} +0 -0
- /package/dist/{chunk-GZRDOVQN.js.map → chunk-HVKMJAEF.js.map} +0 -0
- /package/dist/{chunk-CSOYVTRX.js.map → chunk-IIPJKCZB.js.map} +0 -0
- /package/dist/{chunk-E57E5SCS.js.map → chunk-IRLH4NM2.js.map} +0 -0
- /package/dist/{chunk-4G45LJJP.js.map → chunk-IZRNVNPV.js.map} +0 -0
- /package/dist/{chunk-YSUSUZR4.js.map → chunk-JCJGYNIS.js.map} +0 -0
- /package/dist/{chunk-EU74U4GT.js.map → chunk-JDI7G6EA.js.map} +0 -0
- /package/dist/{chunk-QWPAQLYV.js.map → chunk-JFLKSD5V.js.map} +0 -0
- /package/dist/{chunk-KQS72GCR.js.map → chunk-LJOIZPJH.js.map} +0 -0
- /package/dist/{chunk-U27G4E5G.js.map → chunk-LLGDVG52.js.map} +0 -0
- /package/dist/{chunk-JGW2EUCQ.js.map → chunk-PMRUMGK6.js.map} +0 -0
- /package/dist/{chunk-3G6YU5YD.js.map → chunk-PSNN25DW.js.map} +0 -0
- /package/dist/{chunk-LRGSLV7M.js.map → chunk-PYHOAXTI.js.map} +0 -0
- /package/dist/{chunk-75U2FR7U.js.map → chunk-QCI73Z7C.js.map} +0 -0
- /package/dist/{chunk-EHMMRZOZ.js.map → chunk-QICOU4RY.js.map} +0 -0
- /package/dist/{chunk-K4WIUTNH.js.map → chunk-RFH7U5LT.js.map} +0 -0
- /package/dist/{chunk-4SGDYYWV.js.map → chunk-RPKJHYVE.js.map} +0 -0
- /package/dist/{chunk-DYDACAK2.js.map → chunk-TGSMU3F2.js.map} +0 -0
- /package/dist/{chunk-MJFDJTDC.js.map → chunk-TIRJV2LW.js.map} +0 -0
- /package/dist/{chunk-QRA3XVJX.js.map → chunk-UDTME32W.js.map} +0 -0
- /package/dist/{chunk-LAM6UDFV.js.map → chunk-WMOJIOIG.js.map} +0 -0
- /package/dist/{chunk-LLLY5IBK.js.map → chunk-WR2YKUIW.js.map} +0 -0
- /package/dist/{chunk-KYI3CM42.js.map → chunk-X6E7TT3A.js.map} +0 -0
- /package/dist/{chunk-QN7XQEIT.js.map → chunk-YIIC5IDU.js.map} +0 -0
- /package/dist/{chunk-JDJOAL4B.js.map → chunk-YSR3DXGC.js.map} +0 -0
- /package/dist/{chunk-LBJBNWS2.js.map → chunk-YTHQHH5U.js.map} +0 -0
- /package/dist/{chunk-JF6YSHJM.js.map → chunk-ZPGHA7EO.js.map} +0 -0
- /package/dist/{chunk-YG56A6XY.js.map → chunk-ZS4JADYY.js.map} +0 -0
- /package/dist/{forget-5TWK7CZT.js.map → forget-SZ2BXDGF.js.map} +0 -0
|
@@ -14,17 +14,17 @@ import {
|
|
|
14
14
|
applyTombstoneResurrectionGate,
|
|
15
15
|
buildRetiredFactTombstoneInputs,
|
|
16
16
|
collectRetiredMemoriesForRebuild
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-46WM6JX2.js";
|
|
18
18
|
import {
|
|
19
19
|
normalizeQmdResultPath
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-JFLKSD5V.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-
|
|
27
|
+
} from "./chunk-AR253JBM.js";
|
|
28
28
|
import {
|
|
29
29
|
createMemorySnapshot
|
|
30
30
|
} from "./chunk-S2HLHAZ4.js";
|
|
@@ -36,9 +36,6 @@ import {
|
|
|
36
36
|
rewriteProjectedEntityReferences,
|
|
37
37
|
rewriteProjectedMemoryEntityReference
|
|
38
38
|
} from "./chunk-PO7NXBG2.js";
|
|
39
|
-
import {
|
|
40
|
-
rotateMarkdownFileToArchive
|
|
41
|
-
} from "./chunk-DM2T26WE.js";
|
|
42
39
|
import {
|
|
43
40
|
closeContinuityIncidentRecord,
|
|
44
41
|
createContinuityIncidentRecord,
|
|
@@ -48,6 +45,9 @@ import {
|
|
|
48
45
|
serializeContinuityIncident,
|
|
49
46
|
upsertContinuityLoopInMarkdown
|
|
50
47
|
} from "./chunk-LDXUBPMO.js";
|
|
48
|
+
import {
|
|
49
|
+
rotateMarkdownFileToArchive
|
|
50
|
+
} from "./chunk-DM2T26WE.js";
|
|
51
51
|
import {
|
|
52
52
|
parseFaithfulnessField,
|
|
53
53
|
serializeFaithfulnessFields
|
|
@@ -257,13 +257,72 @@ import {
|
|
|
257
257
|
appendFile,
|
|
258
258
|
open
|
|
259
259
|
} from "fs/promises";
|
|
260
|
-
import { appendFileSync, createReadStream, mkdirSync, statSync } from "fs";
|
|
260
|
+
import { appendFileSync, createReadStream, mkdirSync, statSync as statSync2 } from "fs";
|
|
261
261
|
import { createHash as createHash6 } from "crypto";
|
|
262
|
-
import
|
|
262
|
+
import path12 from "path";
|
|
263
|
+
|
|
264
|
+
// src/storage/tombstone-migration-sources.ts
|
|
265
|
+
import { statSync } from "fs";
|
|
266
|
+
import path from "path";
|
|
267
|
+
function createTombstoneMigrationSourceContents(deps) {
|
|
268
|
+
let sourcePathsPromise;
|
|
269
|
+
let sourceContentsByIdPromise;
|
|
270
|
+
let ledgerMtimeMs = null;
|
|
271
|
+
const dropCachesIfLedgerChanged = () => {
|
|
272
|
+
let mtimeMs;
|
|
273
|
+
try {
|
|
274
|
+
mtimeMs = Math.floor(statSync(deps.tombstonesPath()).mtimeMs);
|
|
275
|
+
} catch {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (mtimeMs === ledgerMtimeMs) return;
|
|
279
|
+
ledgerMtimeMs = mtimeMs;
|
|
280
|
+
sourcePathsPromise = void 0;
|
|
281
|
+
sourceContentsByIdPromise = void 0;
|
|
282
|
+
};
|
|
283
|
+
return async (sourceMemoryIds) => {
|
|
284
|
+
for (; ; ) {
|
|
285
|
+
dropCachesIfLedgerChanged();
|
|
286
|
+
const revision = ledgerMtimeMs;
|
|
287
|
+
const requested = new Set(sourceMemoryIds);
|
|
288
|
+
const sourcePaths = await (sourcePathsPromise ??= deps.collectTombstoneMigrationPaths());
|
|
289
|
+
if (ledgerMtimeMs !== revision) continue;
|
|
290
|
+
const directPaths = sourcePaths.filter(
|
|
291
|
+
(filePath) => requested.has(path.basename(filePath, ".md"))
|
|
292
|
+
);
|
|
293
|
+
const contents = /* @__PURE__ */ new Map();
|
|
294
|
+
for (const memory of await deps.readParsedMemoriesFromPaths(directPaths, 50)) {
|
|
295
|
+
const id = memory.frontmatter.id;
|
|
296
|
+
if (requested.has(id) && !contents.has(id)) {
|
|
297
|
+
contents.set(id, deps.storedContentIdentityCandidates(memory.content));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (ledgerMtimeMs !== revision) continue;
|
|
301
|
+
if (contents.size === requested.size) return contents;
|
|
302
|
+
const fill = sourceContentsByIdPromise ??= (async () => {
|
|
303
|
+
const allContents2 = /* @__PURE__ */ new Map();
|
|
304
|
+
for (const memory of await deps.readParsedMemoriesFromPaths(sourcePaths, 50)) {
|
|
305
|
+
const id = memory.frontmatter.id;
|
|
306
|
+
if (!allContents2.has(id)) {
|
|
307
|
+
allContents2.set(id, deps.storedContentIdentityCandidates(memory.content));
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return allContents2;
|
|
311
|
+
})();
|
|
312
|
+
const allContents = await fill;
|
|
313
|
+
if (ledgerMtimeMs !== revision) continue;
|
|
314
|
+
for (const id of requested) {
|
|
315
|
+
const content = allContents.get(id);
|
|
316
|
+
if (content !== void 0) contents.set(id, content);
|
|
317
|
+
}
|
|
318
|
+
return contents;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
}
|
|
263
322
|
|
|
264
323
|
// src/storage/memory-read-store.ts
|
|
265
324
|
import { lstat, readdir, realpath, stat as stat2 } from "fs/promises";
|
|
266
|
-
import
|
|
325
|
+
import path3 from "path";
|
|
267
326
|
|
|
268
327
|
// src/storage/memory-frontmatter-metadata.ts
|
|
269
328
|
var rawDocumentByMemory = /* @__PURE__ */ new WeakMap();
|
|
@@ -277,7 +336,7 @@ function readRawMemoryDocument(owner) {
|
|
|
277
336
|
|
|
278
337
|
// src/storage/windowed-memory-read.ts
|
|
279
338
|
import { stat } from "fs/promises";
|
|
280
|
-
import
|
|
339
|
+
import path2 from "path";
|
|
281
340
|
async function readWindowedMemories(store, options, hotCache, rememberMemorySnapshots) {
|
|
282
341
|
if (options.updatedAfter !== void 0 && (!(options.updatedAfter instanceof Date) || !Number.isFinite(options.updatedAfter.getTime()))) {
|
|
283
342
|
throw new TypeError("updatedAfter must be a valid Date");
|
|
@@ -315,9 +374,9 @@ async function readWindowTimestamp(memory) {
|
|
|
315
374
|
}
|
|
316
375
|
}
|
|
317
376
|
function orderWindowMemories(memories, baseDir) {
|
|
318
|
-
const correctionsRoot =
|
|
319
|
-
const corrections = memories.filter((memory) => memory.path === correctionsRoot || memory.path.startsWith(`${correctionsRoot}${
|
|
320
|
-
const facts = memories.filter((memory) => memory.path !== correctionsRoot && !memory.path.startsWith(`${correctionsRoot}${
|
|
377
|
+
const correctionsRoot = path2.join(baseDir, "corrections");
|
|
378
|
+
const corrections = memories.filter((memory) => memory.path === correctionsRoot || memory.path.startsWith(`${correctionsRoot}${path2.sep}`)).sort((left, right) => right.path.localeCompare(left.path));
|
|
379
|
+
const facts = memories.filter((memory) => memory.path !== correctionsRoot && !memory.path.startsWith(`${correctionsRoot}${path2.sep}`)).sort((left, right) => right.path.localeCompare(left.path));
|
|
321
380
|
const ordered = [];
|
|
322
381
|
for (let index = 0; index < Math.max(corrections.length, facts.length); index += 1) {
|
|
323
382
|
const correction = corrections[index];
|
|
@@ -360,7 +419,7 @@ var MemoryReadStore = class {
|
|
|
360
419
|
if (!/^[a-z][a-z0-9-]{0,63}$/.test(source)) continue;
|
|
361
420
|
let entries;
|
|
362
421
|
try {
|
|
363
|
-
entries = await readdir(
|
|
422
|
+
entries = await readdir(path3.join(this.deps.wearablesDir, source));
|
|
364
423
|
} catch (err) {
|
|
365
424
|
if (err.code === "ENOENT") continue;
|
|
366
425
|
throw err;
|
|
@@ -393,7 +452,7 @@ var MemoryReadStore = class {
|
|
|
393
452
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
394
453
|
for (const entry of entries) {
|
|
395
454
|
checkCorpusReadAbort(options);
|
|
396
|
-
const fullPath =
|
|
455
|
+
const fullPath = path3.join(dir, entry.name);
|
|
397
456
|
if (entry.isDirectory()) {
|
|
398
457
|
await readDir(fullPath);
|
|
399
458
|
continue;
|
|
@@ -472,7 +531,7 @@ var MemoryReadStore = class {
|
|
|
472
531
|
for (const entry of entries) {
|
|
473
532
|
checkCorpusReadAbort(options);
|
|
474
533
|
if (entry.isSymbolicLink()) continue;
|
|
475
|
-
const fullPath =
|
|
534
|
+
const fullPath = path3.join(dir, entry.name);
|
|
476
535
|
if (entry.isDirectory()) {
|
|
477
536
|
subdirs.push(fullPath);
|
|
478
537
|
} else if (entry.name.endsWith(".md")) {
|
|
@@ -496,7 +555,7 @@ var MemoryReadStore = class {
|
|
|
496
555
|
}
|
|
497
556
|
async collectActiveMemoryPaths(options) {
|
|
498
557
|
return this.collectContainedMarkdownPaths(
|
|
499
|
-
RECALL_FALLBACK_DIRS.map((dir) =>
|
|
558
|
+
RECALL_FALLBACK_DIRS.map((dir) => path3.join(this.deps.baseDir, dir)),
|
|
500
559
|
options?.propagateReadErrors ?? false,
|
|
501
560
|
options
|
|
502
561
|
);
|
|
@@ -521,7 +580,7 @@ var MemoryReadStore = class {
|
|
|
521
580
|
const tiers = await Promise.all([
|
|
522
581
|
this.collectActiveMemoryPaths(),
|
|
523
582
|
this.collectColdMemoryPaths(),
|
|
524
|
-
this.collectContainedMarkdownPaths([
|
|
583
|
+
this.collectContainedMarkdownPaths([path3.join(this.deps.baseDir, "archive")])
|
|
525
584
|
]);
|
|
526
585
|
return tiers.flat();
|
|
527
586
|
}
|
|
@@ -601,7 +660,7 @@ var MemoryReadStore = class {
|
|
|
601
660
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
602
661
|
const subdirs = [];
|
|
603
662
|
for (const entry of entries) {
|
|
604
|
-
const fullPath =
|
|
663
|
+
const fullPath = path3.join(dir, entry.name);
|
|
605
664
|
if (entry.isDirectory()) {
|
|
606
665
|
subdirs.push(fullPath);
|
|
607
666
|
} else if (entry.name.endsWith(".md")) {
|
|
@@ -635,11 +694,11 @@ var MemoryReadStore = class {
|
|
|
635
694
|
content: parsed.content
|
|
636
695
|
}, raw);
|
|
637
696
|
}
|
|
638
|
-
const normalizedPath = filePath.split(
|
|
697
|
+
const normalizedPath = filePath.split(path3.sep).join("/");
|
|
639
698
|
if (normalizedPath.includes("/entities/") && filePath.endsWith(".md")) {
|
|
640
699
|
const entity = parseEntityFile(raw, this.deps.entitySchemas);
|
|
641
700
|
if (!entity.name) return null;
|
|
642
|
-
const nameWithoutExt =
|
|
701
|
+
const nameWithoutExt = path3.basename(filePath, ".md");
|
|
643
702
|
const fileMtime = entity.updated || await stat2(filePath).then((s) => s.mtime.toISOString()).catch(() => (/* @__PURE__ */ new Date(0)).toISOString());
|
|
644
703
|
return {
|
|
645
704
|
path: filePath,
|
|
@@ -823,7 +882,7 @@ var MemoryReadStore = class {
|
|
|
823
882
|
const questions = [];
|
|
824
883
|
for (const file of files) {
|
|
825
884
|
if (!file.endsWith(".md")) continue;
|
|
826
|
-
const filePath =
|
|
885
|
+
const filePath = path3.join(this.deps.questionsDir, file);
|
|
827
886
|
const raw = await readMaybeEncryptedFile(filePath, this.deps._secureStoreKey, this.deps.baseDir);
|
|
828
887
|
const parsed = this.deps.parseQuestionFile(raw, filePath);
|
|
829
888
|
if (parsed) {
|
|
@@ -1550,7 +1609,7 @@ function selfDeps(self) {
|
|
|
1550
1609
|
|
|
1551
1610
|
// src/storage/entity-store.ts
|
|
1552
1611
|
import { readdir as readdir2, unlink } from "fs/promises";
|
|
1553
|
-
import
|
|
1612
|
+
import path4 from "path";
|
|
1554
1613
|
var EntityStore = class {
|
|
1555
1614
|
constructor(deps) {
|
|
1556
1615
|
this.deps = deps;
|
|
@@ -1570,7 +1629,7 @@ var EntityStore = class {
|
|
|
1570
1629
|
async readEntityForMutation(name, method, historicalIds) {
|
|
1571
1630
|
const canonical = resolveHistoricalEntityCanonicalId(name, historicalIds);
|
|
1572
1631
|
for (const candidate of canonical === name ? [name] : [canonical, name]) {
|
|
1573
|
-
const filePath =
|
|
1632
|
+
const filePath = path4.join(this.deps.entitiesDir, `${candidate}.md`);
|
|
1574
1633
|
try {
|
|
1575
1634
|
const entity = parseEntityFile(await this.deps.readStorageSecureFile(filePath), this.deps.entitySchemas);
|
|
1576
1635
|
return { filePath, entity };
|
|
@@ -1595,7 +1654,7 @@ var EntityStore = class {
|
|
|
1595
1654
|
* `mutate` returns false to skip the write. Resolves true when written.
|
|
1596
1655
|
*/
|
|
1597
1656
|
async mutateEntityFile(name, method, mutate) {
|
|
1598
|
-
const stateDir =
|
|
1657
|
+
const stateDir = path4.join(this.deps.baseDir, "state");
|
|
1599
1658
|
return withEntityCanonicalMutationLock(stateDir, async () => {
|
|
1600
1659
|
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
1601
1660
|
const idsAtResolve = this.deps.currentHistoricalIds();
|
|
@@ -1650,7 +1709,7 @@ var EntityStore = class {
|
|
|
1650
1709
|
async writeEntity(name, type, facts, options = {}) {
|
|
1651
1710
|
await this.deps.ensureDirectories();
|
|
1652
1711
|
return withEntityCanonicalMutationLock(
|
|
1653
|
-
|
|
1712
|
+
path4.join(this.deps.baseDir, "state"),
|
|
1654
1713
|
() => this.writeEntityUnlocked(name, type, facts, options)
|
|
1655
1714
|
);
|
|
1656
1715
|
}
|
|
@@ -1671,7 +1730,7 @@ var EntityStore = class {
|
|
|
1671
1730
|
log.debug(`fuzzy match: "${normalized}" \u2192 existing "${match}"`);
|
|
1672
1731
|
normalized = match;
|
|
1673
1732
|
}
|
|
1674
|
-
const filePath =
|
|
1733
|
+
const filePath = path4.join(this.deps.entitiesDir, `${normalized}.md`);
|
|
1675
1734
|
let entity = {
|
|
1676
1735
|
name,
|
|
1677
1736
|
type,
|
|
@@ -1792,7 +1851,7 @@ var EntityStore = class {
|
|
|
1792
1851
|
/** Re-serialize every entity file into the compiled-truth timeline shape. */
|
|
1793
1852
|
async migrateEntityFilesToCompiledTruthTimeline() {
|
|
1794
1853
|
const entityNames = await this.listEntityNames();
|
|
1795
|
-
const stateDir =
|
|
1854
|
+
const stateDir = path4.join(this.deps.baseDir, "state");
|
|
1796
1855
|
let migrated = 0;
|
|
1797
1856
|
for (const entityName of entityNames) {
|
|
1798
1857
|
const wrote = await withEntityCanonicalMutationLock(stateDir, async () => {
|
|
@@ -1819,12 +1878,12 @@ var EntityStore = class {
|
|
|
1819
1878
|
*/
|
|
1820
1879
|
async updateEntitySynthesis(name, synthesis, options = {}) {
|
|
1821
1880
|
return withEntityCanonicalMutationLock(
|
|
1822
|
-
|
|
1881
|
+
path4.join(this.deps.baseDir, "state"),
|
|
1823
1882
|
() => this.updateEntitySynthesisUnlocked(name, synthesis, options)
|
|
1824
1883
|
);
|
|
1825
1884
|
}
|
|
1826
1885
|
async updateEntitySynthesisUnlocked(name, synthesis, options = {}) {
|
|
1827
|
-
const filePath =
|
|
1886
|
+
const filePath = path4.join(this.deps.entitiesDir, `${name}.md`);
|
|
1828
1887
|
let entity;
|
|
1829
1888
|
try {
|
|
1830
1889
|
const content = await this.deps.readStorageSecureFile(filePath);
|
|
@@ -1882,7 +1941,7 @@ var EntityStore = class {
|
|
|
1882
1941
|
const results = await Promise.all(
|
|
1883
1942
|
batch.map(async (entry) => {
|
|
1884
1943
|
try {
|
|
1885
|
-
return await this.deps.readStorageSecureFile(
|
|
1944
|
+
return await this.deps.readStorageSecureFile(path4.join(this.deps.entitiesDir, entry));
|
|
1886
1945
|
} catch (err) {
|
|
1887
1946
|
if (err instanceof SecureStoreLockedError) throw err;
|
|
1888
1947
|
if (!isErrnoCode(err, "ENOENT")) throw err;
|
|
@@ -1957,7 +2016,7 @@ ${rows.join("\n")}
|
|
|
1957
2016
|
*/
|
|
1958
2017
|
async mergeFragmentedEntities() {
|
|
1959
2018
|
return withEntityCanonicalMutationLock(
|
|
1960
|
-
|
|
2019
|
+
path4.join(this.deps.baseDir, "state"),
|
|
1961
2020
|
() => this.mergeFragmentedEntitiesUnlocked()
|
|
1962
2021
|
);
|
|
1963
2022
|
}
|
|
@@ -2002,7 +2061,7 @@ ${rows.join("\n")}
|
|
|
2002
2061
|
extraSections: []
|
|
2003
2062
|
};
|
|
2004
2063
|
for (const file of files) {
|
|
2005
|
-
const filePath =
|
|
2064
|
+
const filePath = path4.join(this.deps.entitiesDir, file);
|
|
2006
2065
|
try {
|
|
2007
2066
|
const content = await this.deps.readStorageSecureFile(filePath);
|
|
2008
2067
|
const parsed = parseEntityFile(content, this.deps.entitySchemas);
|
|
@@ -2155,11 +2214,11 @@ ${rows.join("\n")}
|
|
|
2155
2214
|
}
|
|
2156
2215
|
mergedEntity.created = mergedEntity.created || mergedEntity.updated || (/* @__PURE__ */ new Date()).toISOString();
|
|
2157
2216
|
mergedEntity.updated = mergedEntity.updated || (/* @__PURE__ */ new Date()).toISOString();
|
|
2158
|
-
const canonicalPath =
|
|
2217
|
+
const canonicalPath = path4.join(this.deps.entitiesDir, `${canonical}.md`);
|
|
2159
2218
|
await this.deps.writeStorageSecureFile(canonicalPath, serializeEntityFile(mergedEntity, this.deps.entitySchemas));
|
|
2160
2219
|
this.deps.bumpEntityMutationVersion();
|
|
2161
2220
|
for (const file of files) {
|
|
2162
|
-
const filePath =
|
|
2221
|
+
const filePath = path4.join(this.deps.entitiesDir, file);
|
|
2163
2222
|
if (filePath !== canonicalPath) {
|
|
2164
2223
|
try {
|
|
2165
2224
|
await unlink(filePath);
|
|
@@ -2179,7 +2238,7 @@ ${rows.join("\n")}
|
|
|
2179
2238
|
|
|
2180
2239
|
// src/storage/identity-continuity-store.ts
|
|
2181
2240
|
import { readdir as readdir3 } from "fs/promises";
|
|
2182
|
-
import
|
|
2241
|
+
import path5 from "path";
|
|
2183
2242
|
var IdentityContinuityStore = class {
|
|
2184
2243
|
constructor(deps) {
|
|
2185
2244
|
this.deps = deps;
|
|
@@ -2204,7 +2263,7 @@ var IdentityContinuityStore = class {
|
|
|
2204
2263
|
const date = nowIso.slice(0, 10);
|
|
2205
2264
|
const id = this.deps.generateId("incident");
|
|
2206
2265
|
const incident = createContinuityIncidentRecord(id, input, nowIso);
|
|
2207
|
-
const filePath =
|
|
2266
|
+
const filePath = path5.join(this.deps.identityIncidentsDir, `${date}-${id}.md`);
|
|
2208
2267
|
await this.deps.writeStorageSecureFile(filePath, serializeContinuityIncident(incident));
|
|
2209
2268
|
return { ...incident, filePath };
|
|
2210
2269
|
}
|
|
@@ -2217,7 +2276,7 @@ var IdentityContinuityStore = class {
|
|
|
2217
2276
|
const incidents = [];
|
|
2218
2277
|
for (const file of candidates) {
|
|
2219
2278
|
if (incidents.length >= cappedLimit) break;
|
|
2220
|
-
const filePath =
|
|
2279
|
+
const filePath = path5.join(this.deps.identityIncidentsDir, file);
|
|
2221
2280
|
try {
|
|
2222
2281
|
const raw = await this.deps.readStorageSecureFile(filePath);
|
|
2223
2282
|
const parsed = parseContinuityIncident(raw);
|
|
@@ -2248,7 +2307,7 @@ var IdentityContinuityStore = class {
|
|
|
2248
2307
|
await this.deps.ensureDirectories();
|
|
2249
2308
|
const safeKey = this.sanitizeIdentityAuditKey(key);
|
|
2250
2309
|
const dir = period === "weekly" ? this.deps.identityAuditsWeeklyDir : this.deps.identityAuditsMonthlyDir;
|
|
2251
|
-
const filePath =
|
|
2310
|
+
const filePath = path5.join(dir, `${safeKey}.md`);
|
|
2252
2311
|
await this.deps.writeStorageSecureFile(filePath, content);
|
|
2253
2312
|
return filePath;
|
|
2254
2313
|
}
|
|
@@ -2256,7 +2315,7 @@ var IdentityContinuityStore = class {
|
|
|
2256
2315
|
try {
|
|
2257
2316
|
const safeKey = this.sanitizeIdentityAuditKey(key);
|
|
2258
2317
|
const dir = period === "weekly" ? this.deps.identityAuditsWeeklyDir : this.deps.identityAuditsMonthlyDir;
|
|
2259
|
-
return await this.deps.readStorageSecureFile(
|
|
2318
|
+
return await this.deps.readStorageSecureFile(path5.join(dir, `${safeKey}.md`));
|
|
2260
2319
|
} catch (err) {
|
|
2261
2320
|
if (err instanceof Error && err.message === "Invalid identity audit key") return null;
|
|
2262
2321
|
if (!isErrnoCode(err, "ENOENT")) throw err;
|
|
@@ -2312,12 +2371,12 @@ var IdentityContinuityStore = class {
|
|
|
2312
2371
|
const fileNames = await this.readContinuityIncidentFileNames();
|
|
2313
2372
|
const directMatch = fileNames.find((name) => name.endsWith(`-${id}.md`));
|
|
2314
2373
|
if (directMatch) {
|
|
2315
|
-
const directPath =
|
|
2374
|
+
const directPath = path5.join(this.deps.identityIncidentsDir, directMatch);
|
|
2316
2375
|
const parsed = await this.readContinuityIncidentFile(directPath);
|
|
2317
2376
|
if (parsed?.id === id) return directPath;
|
|
2318
2377
|
}
|
|
2319
2378
|
for (const fileName of fileNames) {
|
|
2320
|
-
const filePath =
|
|
2379
|
+
const filePath = path5.join(this.deps.identityIncidentsDir, fileName);
|
|
2321
2380
|
const parsed = await this.readContinuityIncidentFile(filePath);
|
|
2322
2381
|
if (parsed?.id === id) return filePath;
|
|
2323
2382
|
}
|
|
@@ -2345,7 +2404,7 @@ import {
|
|
|
2345
2404
|
unlink as unlink2,
|
|
2346
2405
|
writeFile
|
|
2347
2406
|
} from "fs/promises";
|
|
2348
|
-
import
|
|
2407
|
+
import path6 from "path";
|
|
2349
2408
|
import { z } from "zod";
|
|
2350
2409
|
var ENTITY_CANONICAL_ID_MIGRATION_VERSION = 1;
|
|
2351
2410
|
var ENTITY_CANONICAL_ID_MIGRATION_LOCK_STALE_MS = 6e4;
|
|
@@ -2379,7 +2438,7 @@ async function fingerprintPath(filePath) {
|
|
|
2379
2438
|
async function fingerprintEntityEntries(entitiesDir) {
|
|
2380
2439
|
let names;
|
|
2381
2440
|
try {
|
|
2382
|
-
names = (await readdir4(entitiesDir)).filter((name) =>
|
|
2441
|
+
names = (await readdir4(entitiesDir)).filter((name) => path6.extname(name) === ".md").sort();
|
|
2383
2442
|
} catch (error) {
|
|
2384
2443
|
if (isErrnoCode(error, "ENOENT")) return "missing";
|
|
2385
2444
|
throw error;
|
|
@@ -2388,7 +2447,7 @@ async function fingerprintEntityEntries(entitiesDir) {
|
|
|
2388
2447
|
for (const name of names) {
|
|
2389
2448
|
hash.update(`${name.length}:${name}:`);
|
|
2390
2449
|
try {
|
|
2391
|
-
const entry = await lstat2(
|
|
2450
|
+
const entry = await lstat2(path6.join(entitiesDir, name), { bigint: true });
|
|
2392
2451
|
hash.update(`${entry.dev}:${entry.ino}:${entry.size}:${entry.mtimeNs}:${entry.ctimeNs}`);
|
|
2393
2452
|
} catch (error) {
|
|
2394
2453
|
if (!isErrnoCode(error, "ENOENT")) throw error;
|
|
@@ -2408,9 +2467,9 @@ async function getFingerprint(baseDir, entitiesDir, getEntityMutationVersion) {
|
|
|
2408
2467
|
] = await Promise.all([
|
|
2409
2468
|
fingerprintPath(entitiesDir),
|
|
2410
2469
|
fingerprintEntityEntries(entitiesDir),
|
|
2411
|
-
fingerprintPath(
|
|
2412
|
-
fingerprintPath(
|
|
2413
|
-
fingerprintPath(
|
|
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))
|
|
2414
2473
|
]);
|
|
2415
2474
|
return [
|
|
2416
2475
|
entityDirectoryFingerprint,
|
|
@@ -2436,8 +2495,8 @@ async function validateRoots(baseDir, entitiesDir, stateDir, archiveDir) {
|
|
|
2436
2495
|
const roots = [
|
|
2437
2496
|
entitiesDir,
|
|
2438
2497
|
stateDir,
|
|
2439
|
-
...RECALL_FALLBACK_DIRS.map((directory) =>
|
|
2440
|
-
|
|
2498
|
+
...RECALL_FALLBACK_DIRS.map((directory) => path6.join(baseDir, directory)),
|
|
2499
|
+
path6.join(baseDir, "cold"),
|
|
2441
2500
|
archiveDir
|
|
2442
2501
|
];
|
|
2443
2502
|
for (const root of roots) {
|
|
@@ -2455,7 +2514,7 @@ async function validateRoots(baseDir, entitiesDir, stateDir, archiveDir) {
|
|
|
2455
2514
|
}
|
|
2456
2515
|
}
|
|
2457
2516
|
function statePath(deps) {
|
|
2458
|
-
return
|
|
2517
|
+
return path6.join(deps.stateDir, ENTITY_CANONICAL_ID_MIGRATION_FILE);
|
|
2459
2518
|
}
|
|
2460
2519
|
async function assertSafeMigrationStateFile(deps) {
|
|
2461
2520
|
const migrationStatePath = statePath(deps);
|
|
@@ -2498,7 +2557,7 @@ async function assertSafeTombstoneFile(deps, tombstonePath) {
|
|
|
2498
2557
|
return true;
|
|
2499
2558
|
}
|
|
2500
2559
|
function lockPath(deps) {
|
|
2501
|
-
return
|
|
2560
|
+
return path6.join(deps.stateDir, "entity-canonical-id-migration.lock");
|
|
2502
2561
|
}
|
|
2503
2562
|
async function readState(deps) {
|
|
2504
2563
|
await assertSafeMigrationStateFile(deps);
|
|
@@ -2596,7 +2655,7 @@ async function readSafeEntityEntries(entitiesDir) {
|
|
|
2596
2655
|
}
|
|
2597
2656
|
const entries = await readdir4(entitiesDir);
|
|
2598
2657
|
for (const entry of entries) {
|
|
2599
|
-
await assertNotSymlink(
|
|
2658
|
+
await assertNotSymlink(path6.join(entitiesDir, entry), entry);
|
|
2600
2659
|
}
|
|
2601
2660
|
return entries;
|
|
2602
2661
|
}
|
|
@@ -2658,7 +2717,7 @@ async function rewriteReferences(deps, mappings, refreshLock) {
|
|
|
2658
2717
|
const seenPaths = /* @__PURE__ */ new Set();
|
|
2659
2718
|
let rewroteAny = false;
|
|
2660
2719
|
for (const memory of [...hotMemories, ...coldMemories, ...archivedMemories]) {
|
|
2661
|
-
const memoryPath =
|
|
2720
|
+
const memoryPath = path6.resolve(memory.path);
|
|
2662
2721
|
if (seenPaths.has(memoryPath)) continue;
|
|
2663
2722
|
seenPaths.add(memoryPath);
|
|
2664
2723
|
const previousEntityRef = memory.frontmatter.entityRef;
|
|
@@ -2690,7 +2749,7 @@ async function rewriteReferences(deps, mappings, refreshLock) {
|
|
|
2690
2749
|
latestCanonicalId
|
|
2691
2750
|
);
|
|
2692
2751
|
rewroteAny = true;
|
|
2693
|
-
rewroteColdMemory ||= latestMemory.path.includes(`${
|
|
2752
|
+
rewroteColdMemory ||= latestMemory.path.includes(`${path6.sep}cold${path6.sep}`);
|
|
2694
2753
|
}
|
|
2695
2754
|
if (!rewroteAny) return { rewroteColdMemory };
|
|
2696
2755
|
}
|
|
@@ -2729,7 +2788,7 @@ function rewriteTombstoneLine(line, mappings, normalizedMappings) {
|
|
|
2729
2788
|
return changed ? JSON.stringify(tombstone) : line;
|
|
2730
2789
|
}
|
|
2731
2790
|
async function rewriteTombstoneReferences(deps, mappings, refreshLock) {
|
|
2732
|
-
const tombstonePath =
|
|
2791
|
+
const tombstonePath = path6.join(deps.stateDir, "tombstones.jsonl");
|
|
2733
2792
|
const normalizedMappings = /* @__PURE__ */ new Map();
|
|
2734
2793
|
for (const [legacyId, canonicalId] of Object.entries(mappings)) {
|
|
2735
2794
|
const normalizedLegacyId = normalizeSupersessionKey(legacyId);
|
|
@@ -2738,7 +2797,7 @@ async function rewriteTombstoneReferences(deps, mappings, refreshLock) {
|
|
|
2738
2797
|
}
|
|
2739
2798
|
}
|
|
2740
2799
|
await withHeldFileLock(
|
|
2741
|
-
|
|
2800
|
+
path6.join(deps.stateDir, "tombstones.lock"),
|
|
2742
2801
|
{
|
|
2743
2802
|
staleMs: TOMBSTONE_LOCK_STALE_MS,
|
|
2744
2803
|
maxWaitMs: TOMBSTONE_LOCK_MAX_WAIT_MS
|
|
@@ -2977,8 +3036,8 @@ async function migrateLegacyEntityCanonicalIds(deps) {
|
|
|
2977
3036
|
if (!acquired) throw new Error("Timed out waiting for active entity canonical-id migration.");
|
|
2978
3037
|
await deps.validateMemoryScanRoots?.();
|
|
2979
3038
|
await readSafeEntityEntries(deps.entitiesDir);
|
|
2980
|
-
const reconcileMarkerPath =
|
|
2981
|
-
const consumingMarkerPath =
|
|
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);
|
|
2982
3041
|
let reconcileRequested = await fileExists(consumingMarkerPath);
|
|
2983
3042
|
if (await fileExists(reconcileMarkerPath)) {
|
|
2984
3043
|
try {
|
|
@@ -3374,7 +3433,7 @@ import {
|
|
|
3374
3433
|
readFileSync,
|
|
3375
3434
|
realpathSync
|
|
3376
3435
|
} from "fs";
|
|
3377
|
-
import
|
|
3436
|
+
import path7 from "path";
|
|
3378
3437
|
function resolveSafeAliasRoots(baseDir, configDir) {
|
|
3379
3438
|
let baseStat;
|
|
3380
3439
|
try {
|
|
@@ -3401,8 +3460,8 @@ function resolveSafeAliasRoots(baseDir, configDir) {
|
|
|
3401
3460
|
return memoryRoot;
|
|
3402
3461
|
}
|
|
3403
3462
|
function readEntityAliasConfigSync(baseDir) {
|
|
3404
|
-
const configDir =
|
|
3405
|
-
const aliasPath =
|
|
3463
|
+
const configDir = path7.join(baseDir, "config");
|
|
3464
|
+
const aliasPath = path7.join(configDir, "aliases.json");
|
|
3406
3465
|
let memoryRoot = resolveSafeAliasRoots(baseDir, configDir);
|
|
3407
3466
|
if (memoryRoot === void 0) return void 0;
|
|
3408
3467
|
let aliasPreflight;
|
|
@@ -3463,7 +3522,7 @@ function decodeYamlScalar(value) {
|
|
|
3463
3522
|
}
|
|
3464
3523
|
|
|
3465
3524
|
// src/orchestration/qmd-result-resolver.ts
|
|
3466
|
-
import
|
|
3525
|
+
import path8 from "path";
|
|
3467
3526
|
var INTERNAL_QMD_ROOTS = /* @__PURE__ */ new Set([
|
|
3468
3527
|
...ALL_CATEGORY_DIRS,
|
|
3469
3528
|
"activity",
|
|
@@ -3484,7 +3543,7 @@ var INTERNAL_QMD_ROOTS = /* @__PURE__ */ new Set([
|
|
|
3484
3543
|
]);
|
|
3485
3544
|
var PRIVATE_RESULT_RESOLUTION_CONCURRENCY = 16;
|
|
3486
3545
|
function qmdCollectionPathParts(resultPath) {
|
|
3487
|
-
if (!resultPath ||
|
|
3546
|
+
if (!resultPath || path8.isAbsolute(resultPath)) return null;
|
|
3488
3547
|
if (resultPath.trim().startsWith("qmd://")) {
|
|
3489
3548
|
try {
|
|
3490
3549
|
const parsed = new URL(resultPath.trim());
|
|
@@ -3509,9 +3568,9 @@ function qmdCollectionPathParts(resultPath) {
|
|
|
3509
3568
|
}
|
|
3510
3569
|
function qmdResultPathCandidates(storageDir, resultPath) {
|
|
3511
3570
|
const candidates = /* @__PURE__ */ new Set();
|
|
3512
|
-
const storageRoot =
|
|
3571
|
+
const storageRoot = path8.resolve(storageDir);
|
|
3513
3572
|
const addCandidate = (candidate) => {
|
|
3514
|
-
const resolved =
|
|
3573
|
+
const resolved = path8.resolve(candidate);
|
|
3515
3574
|
if (isPathInsideStorageRoot(storageRoot, resolved)) {
|
|
3516
3575
|
candidates.add(resolved);
|
|
3517
3576
|
}
|
|
@@ -3519,18 +3578,18 @@ function qmdResultPathCandidates(storageDir, resultPath) {
|
|
|
3519
3578
|
const addRelativeCandidates = (relativePath) => {
|
|
3520
3579
|
const normalized = relativePath.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
3521
3580
|
if (!normalized) return;
|
|
3522
|
-
addCandidate(
|
|
3581
|
+
addCandidate(path8.join(storageRoot, normalized));
|
|
3523
3582
|
if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
|
|
3524
|
-
addCandidate(
|
|
3583
|
+
addCandidate(path8.join(storageRoot, "facts", normalized));
|
|
3525
3584
|
}
|
|
3526
3585
|
};
|
|
3527
|
-
if (
|
|
3586
|
+
if (path8.isAbsolute(resultPath)) {
|
|
3528
3587
|
addCandidate(resultPath);
|
|
3529
|
-
const relative2 =
|
|
3530
|
-
if (relative2 && !relative2.startsWith("..") && !
|
|
3531
|
-
const normalized = relative2.split(
|
|
3588
|
+
const relative2 = path8.relative(storageRoot, path8.resolve(resultPath));
|
|
3589
|
+
if (relative2 && !relative2.startsWith("..") && !path8.isAbsolute(relative2)) {
|
|
3590
|
+
const normalized = relative2.split(path8.sep).join("/");
|
|
3532
3591
|
if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
|
|
3533
|
-
addCandidate(
|
|
3592
|
+
addCandidate(path8.join(storageRoot, "facts", normalized));
|
|
3534
3593
|
}
|
|
3535
3594
|
}
|
|
3536
3595
|
} else {
|
|
@@ -3566,7 +3625,7 @@ var QmdResultResolver = class {
|
|
|
3566
3625
|
const seenStorageDirs = /* @__PURE__ */ new Set();
|
|
3567
3626
|
const addStorage = (storage) => {
|
|
3568
3627
|
const storageDir = storageDirOrNull(storage);
|
|
3569
|
-
const storageKey = storageDir ?
|
|
3628
|
+
const storageKey = storageDir ? path8.resolve(storageDir) : `storage-without-dir-${storages.length}`;
|
|
3570
3629
|
if (seenStorageDirs.has(storageKey)) return;
|
|
3571
3630
|
seenStorageDirs.add(storageKey);
|
|
3572
3631
|
storages.push(storage);
|
|
@@ -3596,7 +3655,7 @@ var QmdResultResolver = class {
|
|
|
3596
3655
|
continue;
|
|
3597
3656
|
}
|
|
3598
3657
|
try {
|
|
3599
|
-
const coldRoot =
|
|
3658
|
+
const coldRoot = path8.join(storageDir, "cold");
|
|
3600
3659
|
for (const candidate of qmdResultPathCandidates(coldRoot, parts.relativePath)) {
|
|
3601
3660
|
const memory = await storage.readMemoryByPath(candidate);
|
|
3602
3661
|
if (memory) return memory;
|
|
@@ -3646,9 +3705,9 @@ var QmdResultResolver = class {
|
|
|
3646
3705
|
error: err.message
|
|
3647
3706
|
});
|
|
3648
3707
|
}
|
|
3649
|
-
if (!
|
|
3708
|
+
if (!path8.isAbsolute(fallbackResultPath)) return null;
|
|
3650
3709
|
}
|
|
3651
|
-
if (
|
|
3710
|
+
if (path8.isAbsolute(fallbackResultPath)) {
|
|
3652
3711
|
if (!fallbackStorageDir) {
|
|
3653
3712
|
return await fallbackStorage.readMemoryByPath(fallbackResultPath);
|
|
3654
3713
|
}
|
|
@@ -3705,17 +3764,17 @@ var QmdResultResolver = class {
|
|
|
3705
3764
|
if (!memory && parts && !collectionIsKnownInternal && !collectionIsConfigured) {
|
|
3706
3765
|
memory = await this.readQmdResultMemory(parts.relativePath, fallbackStorage, namespaces, result.namespace);
|
|
3707
3766
|
}
|
|
3708
|
-
const absoluteInsideMemoryRoot =
|
|
3767
|
+
const absoluteInsideMemoryRoot = path8.isAbsolute(result.path) && isPathInsideStorageRoot(path8.resolve(config.memoryDir), path8.resolve(result.path));
|
|
3709
3768
|
const hasExplicitQmdCollection = result.path.trim().startsWith("qmd://");
|
|
3710
3769
|
const unresolvedInternalPath = !memory && (absoluteInsideMemoryRoot || collectionIsKnownInternal && (!preserveUnresolved || hasExplicitQmdCollection) || hasExplicitQmdCollection && collectionIsConfigured);
|
|
3711
|
-
const unresolvedExternalCollection = !memory && (parts !== null && !collectionIsKnownInternal && !collectionIsConfigured ||
|
|
3770
|
+
const unresolvedExternalCollection = !memory && (parts !== null && !collectionIsKnownInternal && !collectionIsConfigured || path8.isAbsolute(result.path) && !isPathInsideStorageRoot(path8.resolve(config.memoryDir), path8.resolve(result.path)));
|
|
3712
3771
|
return memory !== null && !isSupportPassportPrivateMemory(memory) || !memory && !unresolvedInternalPath && (preserveUnresolved || unresolvedExternalCollection);
|
|
3713
3772
|
}
|
|
3714
3773
|
async resolveColdQmdResultForRecall(result, fallbackStorage, recallNamespaces = []) {
|
|
3715
3774
|
const memory = await this.readQmdResultMemory(result.path, fallbackStorage, recallNamespaces, result.namespace);
|
|
3716
3775
|
if (!memory) return null;
|
|
3717
3776
|
let ownerNamespace = null;
|
|
3718
|
-
if (
|
|
3777
|
+
if (path8.isAbsolute(memory.path)) {
|
|
3719
3778
|
const ownerStorage = await this.storageForAbsoluteQmdResultPath(memory.path, fallbackStorage, recallNamespaces);
|
|
3720
3779
|
ownerNamespace = ownerStorage?.namespace ?? null;
|
|
3721
3780
|
if (!ownerNamespace && resolveNamespaceCapabilities(this.getConfig()).namespaces) return null;
|
|
@@ -3736,17 +3795,17 @@ var QmdResultResolver = class {
|
|
|
3736
3795
|
};
|
|
3737
3796
|
}
|
|
3738
3797
|
async storageForAbsoluteQmdResultPath(resultPath, fallbackStorage, recallNamespaces = []) {
|
|
3739
|
-
const resolvedPath =
|
|
3798
|
+
const resolvedPath = path8.resolve(resultPath);
|
|
3740
3799
|
const config = this.getConfig();
|
|
3741
|
-
const memoryRoot =
|
|
3742
|
-
const namespacesRoot =
|
|
3800
|
+
const memoryRoot = path8.resolve(config.memoryDir);
|
|
3801
|
+
const namespacesRoot = path8.join(memoryRoot, "namespaces");
|
|
3743
3802
|
const fallbackStorageDir = storageDirOrNull(fallbackStorage);
|
|
3744
3803
|
const matches = [];
|
|
3745
3804
|
const seenDirs = /* @__PURE__ */ new Set();
|
|
3746
3805
|
const maybeAddStorage = (storage, namespace) => {
|
|
3747
3806
|
const storageDir = storageDirOrNull(storage);
|
|
3748
3807
|
if (!storageDir) return;
|
|
3749
|
-
const candidateRoot =
|
|
3808
|
+
const candidateRoot = path8.resolve(storageDir);
|
|
3750
3809
|
if (seenDirs.has(candidateRoot)) return;
|
|
3751
3810
|
if (!isPathInsideStorageRoot(candidateRoot, resolvedPath)) return;
|
|
3752
3811
|
if (candidateRoot === memoryRoot && isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
|
|
@@ -3764,7 +3823,7 @@ var QmdResultResolver = class {
|
|
|
3764
3823
|
candidateNamespaces.add(ns);
|
|
3765
3824
|
}
|
|
3766
3825
|
if (isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
|
|
3767
|
-
const relativeToNamespaces =
|
|
3826
|
+
const relativeToNamespaces = path8.relative(namespacesRoot, resolvedPath);
|
|
3768
3827
|
const [namespaceSegment] = relativeToNamespaces.split(/[\\/]/);
|
|
3769
3828
|
if (namespaceSegment) {
|
|
3770
3829
|
candidateNamespaces.add(namespaceIdentityFromToken(namespaceSegment) ?? namespaceSegment);
|
|
@@ -4410,7 +4469,7 @@ function fuseDay(date, inputs, options = {}) {
|
|
|
4410
4469
|
|
|
4411
4470
|
// src/wearables/fusion/store.ts
|
|
4412
4471
|
import { createHash as createHash3 } from "crypto";
|
|
4413
|
-
import * as
|
|
4472
|
+
import * as path9 from "path";
|
|
4414
4473
|
var FUSION_KIND = "wearable-fusion";
|
|
4415
4474
|
function hashFusionBody(conversations) {
|
|
4416
4475
|
return createHash3("sha256").update(JSON.stringify(conversations), "utf-8").digest("hex");
|
|
@@ -4597,7 +4656,7 @@ var FusionArtifactStore = class {
|
|
|
4597
4656
|
`invalid wearable fusion date '${String(date)}' \u2014 expected YYYY-MM-DD`
|
|
4598
4657
|
);
|
|
4599
4658
|
}
|
|
4600
|
-
return
|
|
4659
|
+
return path9.join(this.wearablesDir, FUSION_DIR_NAME, `${date}.md`);
|
|
4601
4660
|
}
|
|
4602
4661
|
async writeFusedDay(date, serialized) {
|
|
4603
4662
|
const filePath = this.fusedDayPath(date);
|
|
@@ -4634,7 +4693,7 @@ var FusionArtifactStore = class {
|
|
|
4634
4693
|
}
|
|
4635
4694
|
/** List dates with stored fused artifacts, newest first. */
|
|
4636
4695
|
async listFusedDays() {
|
|
4637
|
-
const fusionDir =
|
|
4696
|
+
const fusionDir = path9.join(this.wearablesDir, FUSION_DIR_NAME);
|
|
4638
4697
|
await this.assertPathContained(fusionDir);
|
|
4639
4698
|
let entries;
|
|
4640
4699
|
try {
|
|
@@ -4678,10 +4737,10 @@ var FusionArtifactStore = class {
|
|
|
4678
4737
|
try {
|
|
4679
4738
|
rootReal = await this.io.realpath(this.memoryDir);
|
|
4680
4739
|
} catch {
|
|
4681
|
-
rootReal =
|
|
4740
|
+
rootReal = path9.resolve(this.memoryDir);
|
|
4682
4741
|
}
|
|
4683
4742
|
await this.assertNoEscape(rootReal, this.wearablesDir);
|
|
4684
|
-
await this.assertNoEscape(rootReal,
|
|
4743
|
+
await this.assertNoEscape(rootReal, path9.dirname(targetPath));
|
|
4685
4744
|
await this.assertNoEscape(rootReal, targetPath);
|
|
4686
4745
|
await this.assertFusionDirNotSymlinked();
|
|
4687
4746
|
}
|
|
@@ -4695,7 +4754,7 @@ var FusionArtifactStore = class {
|
|
|
4695
4754
|
* (a fresh write creates a real directory lexically under the root).
|
|
4696
4755
|
*/
|
|
4697
4756
|
async assertFusionDirNotSymlinked() {
|
|
4698
|
-
const fusionDir =
|
|
4757
|
+
const fusionDir = path9.join(this.wearablesDir, FUSION_DIR_NAME);
|
|
4699
4758
|
let stat4;
|
|
4700
4759
|
try {
|
|
4701
4760
|
stat4 = await this.io.lstat(fusionDir);
|
|
@@ -4831,7 +4890,7 @@ function reconstructFusionInputs(date, dayTranscripts) {
|
|
|
4831
4890
|
|
|
4832
4891
|
// src/meetings/store.ts
|
|
4833
4892
|
import { createHash as createHash4 } from "crypto";
|
|
4834
|
-
import * as
|
|
4893
|
+
import * as path10 from "path";
|
|
4835
4894
|
var MEETINGS_DIR_NAME = "meetings";
|
|
4836
4895
|
var MEETING_KIND = "meeting";
|
|
4837
4896
|
var MEETING_FORMAT_VERSION = 1;
|
|
@@ -5000,7 +5059,7 @@ var MeetingRecordStore = class {
|
|
|
5000
5059
|
constructor(memoryDir, io) {
|
|
5001
5060
|
this.memoryDir = memoryDir;
|
|
5002
5061
|
this.io = io;
|
|
5003
|
-
this.meetingsDir =
|
|
5062
|
+
this.meetingsDir = path10.join(memoryDir, MEETINGS_DIR_NAME);
|
|
5004
5063
|
}
|
|
5005
5064
|
memoryDir;
|
|
5006
5065
|
io;
|
|
@@ -5016,7 +5075,7 @@ var MeetingRecordStore = class {
|
|
|
5016
5075
|
if (idDate !== date) {
|
|
5017
5076
|
throw new Error(`meeting id '${id}' does not belong to date '${date}'`);
|
|
5018
5077
|
}
|
|
5019
|
-
return
|
|
5078
|
+
return path10.join(this.meetingsDir, date, `${id}.md`);
|
|
5020
5079
|
}
|
|
5021
5080
|
/** Idempotently persist a record: skip the write when contentHash is unchanged. */
|
|
5022
5081
|
async saveMeetingRecord(record) {
|
|
@@ -5047,7 +5106,7 @@ var MeetingRecordStore = class {
|
|
|
5047
5106
|
if (!isValidTranscriptDate(date)) {
|
|
5048
5107
|
throw new Error(`invalid meeting date '${String(date)}' \u2014 expected YYYY-MM-DD`);
|
|
5049
5108
|
}
|
|
5050
|
-
const dayDir =
|
|
5109
|
+
const dayDir = path10.join(this.meetingsDir, date);
|
|
5051
5110
|
await this.assertPathContained(dayDir);
|
|
5052
5111
|
let entries;
|
|
5053
5112
|
try {
|
|
@@ -5115,10 +5174,10 @@ var MeetingRecordStore = class {
|
|
|
5115
5174
|
try {
|
|
5116
5175
|
rootReal = await this.io.realpath(this.memoryDir);
|
|
5117
5176
|
} catch {
|
|
5118
|
-
rootReal =
|
|
5177
|
+
rootReal = path10.resolve(this.memoryDir);
|
|
5119
5178
|
}
|
|
5120
5179
|
await this.assertNoEscape(rootReal, this.meetingsDir);
|
|
5121
|
-
await this.assertNoEscape(rootReal,
|
|
5180
|
+
await this.assertNoEscape(rootReal, path10.dirname(targetPath));
|
|
5122
5181
|
await this.assertNoEscape(rootReal, targetPath);
|
|
5123
5182
|
await this.assertNotSymlink(this.meetingsDir, "directory");
|
|
5124
5183
|
const dayDir = this.dayDirWithin(targetPath);
|
|
@@ -5128,11 +5187,11 @@ var MeetingRecordStore = class {
|
|
|
5128
5187
|
/** The `<meetings>/<date>` directory on the path to `targetPath`, or null when
|
|
5129
5188
|
* `targetPath` is the meetings root itself. */
|
|
5130
5189
|
dayDirWithin(targetPath) {
|
|
5131
|
-
const rel =
|
|
5132
|
-
if (rel === "" || rel.startsWith("..") ||
|
|
5133
|
-
const first = rel.split(
|
|
5190
|
+
const rel = path10.relative(this.meetingsDir, targetPath);
|
|
5191
|
+
if (rel === "" || rel.startsWith("..") || path10.isAbsolute(rel)) return null;
|
|
5192
|
+
const first = rel.split(path10.sep)[0];
|
|
5134
5193
|
if (first === void 0 || first.length === 0) return null;
|
|
5135
|
-
return
|
|
5194
|
+
return path10.join(this.meetingsDir, first);
|
|
5136
5195
|
}
|
|
5137
5196
|
async assertNotSymlink(target, kind) {
|
|
5138
5197
|
let stat4;
|
|
@@ -5143,7 +5202,7 @@ var MeetingRecordStore = class {
|
|
|
5143
5202
|
throw err;
|
|
5144
5203
|
}
|
|
5145
5204
|
if (stat4.isSymbolicLink) {
|
|
5146
|
-
const label =
|
|
5205
|
+
const label = path10.relative(this.memoryDir, target) || MEETINGS_DIR_NAME;
|
|
5147
5206
|
throw new Error(
|
|
5148
5207
|
`meetings ${kind} '${label}' is a symbolic link \u2014 refusing to follow it even when it resolves inside the memory dir (AGENTS.md pattern #3)`
|
|
5149
5208
|
);
|
|
@@ -5167,7 +5226,7 @@ var SORT_STR = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
|
5167
5226
|
|
|
5168
5227
|
// src/storage/supersession-audit.ts
|
|
5169
5228
|
import { readdir as readdir5 } from "fs/promises";
|
|
5170
|
-
import
|
|
5229
|
+
import path11 from "path";
|
|
5171
5230
|
async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody, structuredAttributes) {
|
|
5172
5231
|
let entries;
|
|
5173
5232
|
try {
|
|
@@ -5178,7 +5237,7 @@ async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody,
|
|
|
5178
5237
|
}
|
|
5179
5238
|
for (const entry of entries) {
|
|
5180
5239
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
5181
|
-
const memory = await lookup.readMemoryByPath(
|
|
5240
|
+
const memory = await lookup.readMemoryByPath(path11.join(lookup.correctionsDir, entry.name));
|
|
5182
5241
|
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(
|
|
5183
5242
|
([key, value]) => memory.frontmatter.structuredAttributes?.[key] === value
|
|
5184
5243
|
))) {
|
|
@@ -6259,17 +6318,17 @@ function inferEntityTypeFromContent(content) {
|
|
|
6259
6318
|
}
|
|
6260
6319
|
var KNOWN_ENTITY_FILENAME_PREFIXES = /* @__PURE__ */ new Set(["company", "other", "person", "place", "project", "tool", "topic"]);
|
|
6261
6320
|
function inferEntityTypeFromFilename(pathRel) {
|
|
6262
|
-
const basename =
|
|
6321
|
+
const basename = path12.basename(pathRel, ".md").toLowerCase();
|
|
6263
6322
|
const separator = basename.indexOf("-");
|
|
6264
6323
|
if (separator <= 0) return void 0;
|
|
6265
6324
|
const candidate = basename.slice(0, separator);
|
|
6266
6325
|
return KNOWN_ENTITY_FILENAME_PREFIXES.has(candidate) ? candidate : void 0;
|
|
6267
6326
|
}
|
|
6268
6327
|
function normalizeFrontmatterForPath(frontmatter, pathRel, content = "") {
|
|
6269
|
-
const normalizedPath = pathRel.split(
|
|
6328
|
+
const normalizedPath = pathRel.split(path12.sep).join("/");
|
|
6270
6329
|
let normalizedFrontmatter = frontmatter;
|
|
6271
6330
|
if (normalizedPath === "entities" || normalizedPath.startsWith("entities/") || normalizedPath.includes("/entities/")) {
|
|
6272
|
-
const basename =
|
|
6331
|
+
const basename = path12.basename(pathRel, ".md");
|
|
6273
6332
|
const inferredType = inferEntityTypeFromContent(content) || inferEntityTypeFromFilename(pathRel) || "entity";
|
|
6274
6333
|
const existingTags = Array.isArray(frontmatter.tags) ? frontmatter.tags : [];
|
|
6275
6334
|
normalizedFrontmatter = {
|
|
@@ -6740,9 +6799,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
6740
6799
|
this.entitySchemas = entitySchemas;
|
|
6741
6800
|
this.deletionRevisionStore = new DeletionRevisionStore({
|
|
6742
6801
|
baseDir,
|
|
6743
|
-
deletionRevisionMetadataPath:
|
|
6744
|
-
invalidationCommitMetadataPath:
|
|
6745
|
-
deletionRevisionLockPath:
|
|
6802
|
+
deletionRevisionMetadataPath: path12.join(baseDir, ".offline-sync", "deletion-revisions.v1.json"),
|
|
6803
|
+
invalidationCommitMetadataPath: path12.join(baseDir, ".offline-sync", "invalidation-commits.v1.json"),
|
|
6804
|
+
deletionRevisionLockPath: path12.join(baseDir, ".offline-sync", "deletion-revisions.v1.json.lock"),
|
|
6746
6805
|
assertManagedStoragePath: (filePath, method) => this.assertManagedStoragePath(filePath, method)
|
|
6747
6806
|
});
|
|
6748
6807
|
this.hotMemoriesCacheEnabled = hotMemoriesCacheEnabledOverride ?? _StorageManager.hotMemoriesCacheDefaultByDir.get(baseDir) ?? _StorageManager.hotMemoriesCacheDefault;
|
|
@@ -6930,8 +6989,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
6930
6989
|
}
|
|
6931
6990
|
/** Whether `filePath` resolves to `stateDir` itself or a path contained in it. */
|
|
6932
6991
|
isStateFilePath(filePath) {
|
|
6933
|
-
const rel =
|
|
6934
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
6992
|
+
const rel = path12.relative(this.stateDir, path12.resolve(filePath));
|
|
6993
|
+
return rel === "" || !rel.startsWith("..") && !path12.isAbsolute(rel);
|
|
6935
6994
|
}
|
|
6936
6995
|
// ── Tombstone store (issue #1579) ───────────────────────────────────────
|
|
6937
6996
|
// Instance-scoped (rule 11) + namespace-scoped (rule 42) tombstone index.
|
|
@@ -7046,8 +7105,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7046
7105
|
* /srv/cold/remnic), skipping the patch and stranding a stale hot entry.
|
|
7047
7106
|
*/
|
|
7048
7107
|
isColdOrArchiveTierPath(p) {
|
|
7049
|
-
const rel =
|
|
7050
|
-
return rel === "cold" || rel === "archive" || rel.startsWith(`cold${
|
|
7108
|
+
const rel = path12.relative(this.baseDir, p);
|
|
7109
|
+
return rel === "cold" || rel === "archive" || rel.startsWith(`cold${path12.sep}`) || rel.startsWith(`archive${path12.sep}`);
|
|
7051
7110
|
}
|
|
7052
7111
|
/**
|
|
7053
7112
|
* Mark the secure-store as required for this storage instance.
|
|
@@ -7134,7 +7193,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7134
7193
|
void 0,
|
|
7135
7194
|
this.baseDir
|
|
7136
7195
|
);
|
|
7137
|
-
const rel =
|
|
7196
|
+
const rel = path12.relative(this.baseDir, filePath).split(path12.sep).join("/");
|
|
7138
7197
|
return `${rel}:${version.versionId}`;
|
|
7139
7198
|
} catch (err) {
|
|
7140
7199
|
log.warn(
|
|
@@ -7214,19 +7273,19 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7214
7273
|
}
|
|
7215
7274
|
identityFilePath(workspaceDir, namespace) {
|
|
7216
7275
|
const rawNamespace = typeof namespace === "string" ? namespace.trim() : "";
|
|
7217
|
-
if (!rawNamespace) return
|
|
7276
|
+
if (!rawNamespace) return path12.join(workspaceDir, "IDENTITY.md");
|
|
7218
7277
|
const safeNamespace = rawNamespace.replace(/[^a-zA-Z0-9._-]/g, "-");
|
|
7219
|
-
return
|
|
7278
|
+
return path12.join(workspaceDir, `IDENTITY.${safeNamespace}.md`);
|
|
7220
7279
|
}
|
|
7221
7280
|
versionFilePath(kind) {
|
|
7222
|
-
return
|
|
7281
|
+
return path12.join(this.stateDir, `.${kind}-version.log`);
|
|
7223
7282
|
}
|
|
7224
7283
|
bumpSharedVersion(kind, fallbackMap) {
|
|
7225
7284
|
const filePath = this.versionFilePath(kind);
|
|
7226
7285
|
try {
|
|
7227
7286
|
mkdirSync(this.stateDir, { recursive: true });
|
|
7228
7287
|
appendFileSync(filePath, "x");
|
|
7229
|
-
const next =
|
|
7288
|
+
const next = statSync2(filePath).size;
|
|
7230
7289
|
fallbackMap.set(this.baseDir, next);
|
|
7231
7290
|
return next;
|
|
7232
7291
|
} catch {
|
|
@@ -7238,7 +7297,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7238
7297
|
readSharedVersion(kind, fallbackMap) {
|
|
7239
7298
|
const filePath = this.versionFilePath(kind);
|
|
7240
7299
|
try {
|
|
7241
|
-
return
|
|
7300
|
+
return statSync2(filePath).size;
|
|
7242
7301
|
} catch {
|
|
7243
7302
|
return fallbackMap.get(this.baseDir) ?? 0;
|
|
7244
7303
|
}
|
|
@@ -7293,12 +7352,12 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7293
7352
|
mkdirSync(this.stateDir, { recursive: true });
|
|
7294
7353
|
let before = 0;
|
|
7295
7354
|
try {
|
|
7296
|
-
before =
|
|
7355
|
+
before = statSync2(filePath).size;
|
|
7297
7356
|
} catch {
|
|
7298
7357
|
before = 0;
|
|
7299
7358
|
}
|
|
7300
7359
|
appendFileSync(filePath, "x");
|
|
7301
|
-
const produced =
|
|
7360
|
+
const produced = statSync2(filePath).size;
|
|
7302
7361
|
_StorageManager.memoryCorpusVersionByDir.set(this.baseDir, produced);
|
|
7303
7362
|
return { produced, exclusive: produced === before + 1 };
|
|
7304
7363
|
} catch {
|
|
@@ -7323,7 +7382,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7323
7382
|
// memories.
|
|
7324
7383
|
// -------------------------------------------------------------------------
|
|
7325
7384
|
get wearablesDir() {
|
|
7326
|
-
return
|
|
7385
|
+
return path12.join(this.baseDir, WEARABLES_DIR_NAME);
|
|
7327
7386
|
}
|
|
7328
7387
|
/**
|
|
7329
7388
|
* Resolve the on-disk path for a source/day transcript. Throws on
|
|
@@ -7339,7 +7398,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7339
7398
|
if (!isValidTranscriptDate(date)) {
|
|
7340
7399
|
throw new Error(`invalid wearable transcript date '${String(date)}' \u2014 expected YYYY-MM-DD`);
|
|
7341
7400
|
}
|
|
7342
|
-
return
|
|
7401
|
+
return path12.join(this.wearablesDir, sourceId, `${date}.md`);
|
|
7343
7402
|
}
|
|
7344
7403
|
async writeWearableDayTranscript(sourceId, date, serialized) {
|
|
7345
7404
|
const targetPath = this.wearableTranscriptPath(sourceId, date);
|
|
@@ -7455,25 +7514,25 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7455
7514
|
});
|
|
7456
7515
|
}
|
|
7457
7516
|
get factsDir() {
|
|
7458
|
-
return
|
|
7517
|
+
return path12.join(this.baseDir, "facts");
|
|
7459
7518
|
}
|
|
7460
7519
|
get correctionsDir() {
|
|
7461
|
-
return
|
|
7520
|
+
return path12.join(this.baseDir, "corrections");
|
|
7462
7521
|
}
|
|
7463
7522
|
get proceduresDir() {
|
|
7464
|
-
return
|
|
7523
|
+
return path12.join(this.baseDir, "procedures");
|
|
7465
7524
|
}
|
|
7466
7525
|
get reasoningTracesDir() {
|
|
7467
|
-
return
|
|
7526
|
+
return path12.join(this.baseDir, "reasoning-traces");
|
|
7468
7527
|
}
|
|
7469
7528
|
get entitiesDir() {
|
|
7470
|
-
return
|
|
7529
|
+
return path12.join(this.baseDir, "entities");
|
|
7471
7530
|
}
|
|
7472
7531
|
resolveEntityFilePath(name) {
|
|
7473
7532
|
if (typeof name !== "string") return null;
|
|
7474
|
-
const filePath =
|
|
7475
|
-
const relative2 =
|
|
7476
|
-
if (relative2 === "" || relative2.startsWith("..") ||
|
|
7533
|
+
const filePath = path12.resolve(this.entitiesDir, `${name}.md`);
|
|
7534
|
+
const relative2 = path12.relative(this.entitiesDir, filePath);
|
|
7535
|
+
if (relative2 === "" || relative2.startsWith("..") || path12.isAbsolute(relative2)) {
|
|
7477
7536
|
return null;
|
|
7478
7537
|
}
|
|
7479
7538
|
return filePath;
|
|
@@ -7484,7 +7543,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7484
7543
|
async readDependencyPropagationQueueFile(filePath) {
|
|
7485
7544
|
const target = await resolveSafeStoragePath(
|
|
7486
7545
|
this.baseDir,
|
|
7487
|
-
|
|
7546
|
+
path12.relative(
|
|
7488
7547
|
this.baseDir,
|
|
7489
7548
|
this.assertManagedStoragePath(filePath, "storage.readDependencyPropagationQueueFile")
|
|
7490
7549
|
)
|
|
@@ -7494,7 +7553,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7494
7553
|
async writeDependencyPropagationQueueFile(filePath, content) {
|
|
7495
7554
|
const target = await resolveSafeStoragePath(
|
|
7496
7555
|
this.baseDir,
|
|
7497
|
-
|
|
7556
|
+
path12.relative(
|
|
7498
7557
|
this.baseDir,
|
|
7499
7558
|
this.assertManagedStoragePath(filePath, "storage.writeDependencyPropagationQueueFile")
|
|
7500
7559
|
)
|
|
@@ -7508,10 +7567,10 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7508
7567
|
});
|
|
7509
7568
|
}
|
|
7510
7569
|
assertManagedStoragePath(filePath, method) {
|
|
7511
|
-
const resolved =
|
|
7512
|
-
const base =
|
|
7513
|
-
const rel =
|
|
7514
|
-
if (rel === "" || rel === ".." || rel.startsWith(`..${
|
|
7570
|
+
const resolved = path12.resolve(filePath);
|
|
7571
|
+
const base = path12.resolve(this.baseDir);
|
|
7572
|
+
const rel = path12.relative(base, resolved);
|
|
7573
|
+
if (rel === "" || rel === ".." || rel.startsWith(`..${path12.sep}`) || path12.isAbsolute(rel)) {
|
|
7515
7574
|
throw new Error(`${method}: file path escapes memory dir`);
|
|
7516
7575
|
}
|
|
7517
7576
|
return resolved;
|
|
@@ -7544,7 +7603,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7544
7603
|
async digestOfflineSyncFile(filePath) {
|
|
7545
7604
|
const target = this.assertManagedStoragePath(filePath, "storage.digestOfflineSyncFile");
|
|
7546
7605
|
const st = await stat3(target);
|
|
7547
|
-
const relPath =
|
|
7606
|
+
const relPath = path12.relative(this.baseDir, target).split(path12.sep).join("/");
|
|
7548
7607
|
const cache = await this.loadOfflineSyncDigestCache();
|
|
7549
7608
|
const cached = cache.get(relPath);
|
|
7550
7609
|
if (cached && cached.statBytes === st.size && cached.mtimeMs === st.mtimeMs && cached.ctimeMs === st.ctimeMs && !cached.encrypted) {
|
|
@@ -7605,7 +7664,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7605
7664
|
const bytes = typeof record.bytes === "number" ? record.bytes : NaN;
|
|
7606
7665
|
const sha256 = typeof record.sha256 === "string" ? record.sha256 : "";
|
|
7607
7666
|
const encrypted = record.encrypted === true;
|
|
7608
|
-
if (cachePath.length === 0 || cachePath === ".." || cachePath.startsWith("../") ||
|
|
7667
|
+
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)) {
|
|
7609
7668
|
continue;
|
|
7610
7669
|
}
|
|
7611
7670
|
cache.set(cachePath, { statBytes, mtimeMs, ctimeMs, encrypted, sha256, bytes });
|
|
@@ -7647,7 +7706,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7647
7706
|
const cache = this.offlineSyncDigestCache;
|
|
7648
7707
|
if (!cache) return;
|
|
7649
7708
|
const entries = [...cache.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([entryPath, entry]) => ({ path: entryPath, ...entry }));
|
|
7650
|
-
await mkdir(
|
|
7709
|
+
await mkdir(path12.dirname(this.offlineSyncDigestCachePath), { recursive: true });
|
|
7651
7710
|
await writeFile2(this.offlineSyncDigestCachePath, `${JSON.stringify({ version: 1, entries })}
|
|
7652
7711
|
`, "utf-8");
|
|
7653
7712
|
}).catch((err) => {
|
|
@@ -7736,7 +7795,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7736
7795
|
}
|
|
7737
7796
|
async appendStorageSecureFileUnlocked(filePath, content) {
|
|
7738
7797
|
const writeKey = this.resolveWriteKey();
|
|
7739
|
-
await mkdir(
|
|
7798
|
+
await mkdir(path12.dirname(filePath), { recursive: true });
|
|
7740
7799
|
if (writeKey === null) {
|
|
7741
7800
|
try {
|
|
7742
7801
|
if (await this.isEncryptedFileHeader(filePath)) {
|
|
@@ -7762,13 +7821,13 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7762
7821
|
this.notifyCatalogWriteForPath(filePath);
|
|
7763
7822
|
}
|
|
7764
7823
|
get stateDir() {
|
|
7765
|
-
return
|
|
7824
|
+
return path12.join(this.baseDir, "state");
|
|
7766
7825
|
}
|
|
7767
7826
|
get offlineSyncDigestCachePath() {
|
|
7768
|
-
return
|
|
7827
|
+
return path12.join(this.baseDir, ".offline-sync", "digest-cache.v1.json");
|
|
7769
7828
|
}
|
|
7770
7829
|
get entitySynthesisQueuePath() {
|
|
7771
|
-
return
|
|
7830
|
+
return path12.join(this.stateDir, "entity-synthesis-queue.json");
|
|
7772
7831
|
}
|
|
7773
7832
|
// ── Tombstone store access (issue #1579) ─────────────────────────────────
|
|
7774
7833
|
/**
|
|
@@ -7778,7 +7837,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7778
7837
|
* helpers are injected into the store).
|
|
7779
7838
|
*/
|
|
7780
7839
|
get tombstonesPath() {
|
|
7781
|
-
return
|
|
7840
|
+
return path12.join(this.stateDir, "tombstones.jsonl");
|
|
7782
7841
|
}
|
|
7783
7842
|
/**
|
|
7784
7843
|
* Configure the tombstone invariant for this storage instance. Installed
|
|
@@ -7796,51 +7855,27 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7796
7855
|
}
|
|
7797
7856
|
}
|
|
7798
7857
|
buildTombstoneStore() {
|
|
7799
|
-
let sourcePathsPromise;
|
|
7800
|
-
let sourceContentsByIdPromise;
|
|
7801
7858
|
const options = {
|
|
7802
7859
|
enabled: this.tombstonesConfig.enabled,
|
|
7803
7860
|
semanticMatch: this.tombstonesConfig.semanticMatch,
|
|
7804
7861
|
semanticThreshold: this.tombstonesConfig.semanticThreshold,
|
|
7805
7862
|
hashContent: ContentHashIndex.computeHash,
|
|
7806
7863
|
normalizeText: ContentHashIndex.normalizeContent,
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
)
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
if (requested.has(id) && !contents.has(id)) {
|
|
7817
|
-
contents.set(id, this.storedContentIdentityCandidates(memory.content));
|
|
7818
|
-
}
|
|
7819
|
-
}
|
|
7820
|
-
if (contents.size === requested.size) return contents;
|
|
7821
|
-
sourceContentsByIdPromise ??= (async () => {
|
|
7822
|
-
const allContents2 = /* @__PURE__ */ new Map();
|
|
7823
|
-
for (const memory of await this.readParsedMemoriesFromPaths(sourcePaths, 50)) {
|
|
7824
|
-
const id = memory.frontmatter.id;
|
|
7825
|
-
if (!allContents2.has(id)) {
|
|
7826
|
-
allContents2.set(id, this.storedContentIdentityCandidates(memory.content));
|
|
7827
|
-
}
|
|
7828
|
-
}
|
|
7829
|
-
return allContents2;
|
|
7830
|
-
})();
|
|
7831
|
-
const allContents = await sourceContentsByIdPromise;
|
|
7832
|
-
for (const id of requested) {
|
|
7833
|
-
const content = allContents.get(id);
|
|
7834
|
-
if (content !== void 0) contents.set(id, content);
|
|
7835
|
-
}
|
|
7836
|
-
return contents;
|
|
7837
|
-
}
|
|
7864
|
+
// Corpus-path + source-content caches are scoped to one ledger revision
|
|
7865
|
+
// so a peer-appended legacy row is verified on the next staleness reload
|
|
7866
|
+
// (issue #2367). Implementation lives in storage/tombstone-migration-sources.ts.
|
|
7867
|
+
sourceContentsForMemoryIds: createTombstoneMigrationSourceContents({
|
|
7868
|
+
tombstonesPath: () => this.tombstonesPath,
|
|
7869
|
+
collectTombstoneMigrationPaths: () => this.memoryReadStore.collectTombstoneMigrationPaths(),
|
|
7870
|
+
readParsedMemoriesFromPaths: (filePaths, batchSize) => this.readParsedMemoriesFromPaths(filePaths, batchSize),
|
|
7871
|
+
storedContentIdentityCandidates: (content) => this.storedContentIdentityCandidates(content)
|
|
7872
|
+
})
|
|
7838
7873
|
};
|
|
7839
7874
|
const io = {
|
|
7840
7875
|
read: (filePath) => this.readStorageSecureFile(filePath),
|
|
7841
7876
|
append: (filePath, content) => this.appendStorageSecureFile(filePath, content),
|
|
7842
7877
|
write: (filePath, content) => this.writeStorageSecureFile(filePath, content),
|
|
7843
|
-
stat: (filePath) =>
|
|
7878
|
+
stat: (filePath) => statSync2(filePath)
|
|
7844
7879
|
};
|
|
7845
7880
|
return new TombstoneStore(this.tombstonesPath, this.tombstonesConfig.namespace, options, io);
|
|
7846
7881
|
}
|
|
@@ -8102,55 +8137,55 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8102
8137
|
return legacyMatches.length > 0 ? [...new Set(legacyMatches.map((content) => ContentHashIndex.computeHash(content)))] : [persistedHash];
|
|
8103
8138
|
}
|
|
8104
8139
|
get questionsDir() {
|
|
8105
|
-
return
|
|
8140
|
+
return path12.join(this.baseDir, "questions");
|
|
8106
8141
|
}
|
|
8107
8142
|
get artifactsDir() {
|
|
8108
|
-
return
|
|
8143
|
+
return path12.join(this.baseDir, "artifacts");
|
|
8109
8144
|
}
|
|
8110
8145
|
get identityDir() {
|
|
8111
|
-
return
|
|
8146
|
+
return path12.join(this.baseDir, "identity");
|
|
8112
8147
|
}
|
|
8113
8148
|
get identityAnchorPath() {
|
|
8114
|
-
return
|
|
8149
|
+
return path12.join(this.identityDir, "identity-anchor.md");
|
|
8115
8150
|
}
|
|
8116
8151
|
get identityIncidentsDir() {
|
|
8117
|
-
return
|
|
8152
|
+
return path12.join(this.identityDir, "incidents");
|
|
8118
8153
|
}
|
|
8119
8154
|
get identityAuditsWeeklyDir() {
|
|
8120
|
-
return
|
|
8155
|
+
return path12.join(this.identityDir, "audits", "weekly");
|
|
8121
8156
|
}
|
|
8122
8157
|
get identityAuditsMonthlyDir() {
|
|
8123
|
-
return
|
|
8158
|
+
return path12.join(this.identityDir, "audits", "monthly");
|
|
8124
8159
|
}
|
|
8125
8160
|
get identityImprovementLoopsPath() {
|
|
8126
|
-
return
|
|
8161
|
+
return path12.join(this.identityDir, "improvement-loops.md");
|
|
8127
8162
|
}
|
|
8128
8163
|
get identityReflectionsPath() {
|
|
8129
|
-
return
|
|
8164
|
+
return path12.join(this.identityDir, "reflections.md");
|
|
8130
8165
|
}
|
|
8131
8166
|
get profilePath() {
|
|
8132
|
-
return
|
|
8167
|
+
return path12.join(this.baseDir, "profile.md");
|
|
8133
8168
|
}
|
|
8134
8169
|
get memoryActionsPath() {
|
|
8135
|
-
return
|
|
8170
|
+
return path12.join(this.stateDir, "memory-actions.jsonl");
|
|
8136
8171
|
}
|
|
8137
8172
|
get memoryLifecycleLedgerPath() {
|
|
8138
|
-
return
|
|
8173
|
+
return path12.join(this.stateDir, "memory-lifecycle-ledger.jsonl");
|
|
8139
8174
|
}
|
|
8140
8175
|
get compressionGuidelinesPath() {
|
|
8141
|
-
return
|
|
8176
|
+
return path12.join(this.stateDir, "compression-guidelines.md");
|
|
8142
8177
|
}
|
|
8143
8178
|
get compressionGuidelineDraftPath() {
|
|
8144
|
-
return
|
|
8179
|
+
return path12.join(this.stateDir, "compression-guidelines.draft.md");
|
|
8145
8180
|
}
|
|
8146
8181
|
get compressionGuidelineStatePath() {
|
|
8147
|
-
return
|
|
8182
|
+
return path12.join(this.stateDir, "compression-guideline-state.json");
|
|
8148
8183
|
}
|
|
8149
8184
|
get compressionGuidelineDraftStatePath() {
|
|
8150
|
-
return
|
|
8185
|
+
return path12.join(this.stateDir, "compression-guideline-draft-state.json");
|
|
8151
8186
|
}
|
|
8152
8187
|
get behaviorSignalsPath() {
|
|
8153
|
-
return
|
|
8188
|
+
return path12.join(this.stateDir, "behavior-signals.jsonl");
|
|
8154
8189
|
}
|
|
8155
8190
|
/**
|
|
8156
8191
|
* In-memory dedup key set for behavior-signals appends (issue #1909),
|
|
@@ -8182,7 +8217,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8182
8217
|
* governance sweeps can treat it uniformly.
|
|
8183
8218
|
*/
|
|
8184
8219
|
get bufferSurpriseLedgerPath() {
|
|
8185
|
-
return
|
|
8220
|
+
return path12.join(this.stateDir, "buffer-surprise-ledger.jsonl");
|
|
8186
8221
|
}
|
|
8187
8222
|
/**
|
|
8188
8223
|
* Entity alias table loaded from THIS store's config/aliases.json.
|
|
@@ -8243,7 +8278,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8243
8278
|
this.loadAliasesSync();
|
|
8244
8279
|
}
|
|
8245
8280
|
loadAliasesSync() {
|
|
8246
|
-
const aliasPath =
|
|
8281
|
+
const aliasPath = path12.join(this.baseDir, "config", "aliases.json");
|
|
8247
8282
|
this.userAliases = {};
|
|
8248
8283
|
const raw = readEntityAliasConfigSync(this.baseDir);
|
|
8249
8284
|
if (raw === void 0) return;
|
|
@@ -8281,9 +8316,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8281
8316
|
await mkdir(this.baseDir, { recursive: true });
|
|
8282
8317
|
await validateRoots(this.baseDir, this.entitiesDir, this.stateDir, this.archiveDir);
|
|
8283
8318
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
8284
|
-
await mkdir(
|
|
8285
|
-
await mkdir(
|
|
8286
|
-
await mkdir(
|
|
8319
|
+
await mkdir(path12.join(this.factsDir, today), { recursive: true });
|
|
8320
|
+
await mkdir(path12.join(this.proceduresDir, today), { recursive: true });
|
|
8321
|
+
await mkdir(path12.join(this.reasoningTracesDir, today), { recursive: true });
|
|
8287
8322
|
await mkdir(this.correctionsDir, { recursive: true });
|
|
8288
8323
|
await mkdir(this.entitiesDir, { recursive: true });
|
|
8289
8324
|
await mkdir(this.stateDir, { recursive: true });
|
|
@@ -8293,7 +8328,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8293
8328
|
await mkdir(this.identityIncidentsDir, { recursive: true });
|
|
8294
8329
|
await mkdir(this.identityAuditsWeeklyDir, { recursive: true });
|
|
8295
8330
|
await mkdir(this.identityAuditsMonthlyDir, { recursive: true });
|
|
8296
|
-
await mkdir(
|
|
8331
|
+
await mkdir(path12.join(this.baseDir, "config"), { recursive: true });
|
|
8297
8332
|
await this.entityCanonicalIdMigration.ensure();
|
|
8298
8333
|
if (this.hotMemoriesCacheEnabled && this.getMemoryCorpusVersion() === 0) {
|
|
8299
8334
|
this.bumpMemoryCorpusVersion();
|
|
@@ -8315,11 +8350,11 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8315
8350
|
async resolveCategoryWritePath(category, id, today) {
|
|
8316
8351
|
if (category === "correction") {
|
|
8317
8352
|
await mkdir(this.correctionsDir, { recursive: true });
|
|
8318
|
-
return
|
|
8353
|
+
return path12.join(this.correctionsDir, `${id}.md`);
|
|
8319
8354
|
}
|
|
8320
|
-
const datedDir =
|
|
8355
|
+
const datedDir = path12.join(getCategoryDir(this.baseDir, category), today);
|
|
8321
8356
|
await mkdir(datedDir, { recursive: true });
|
|
8322
|
-
return
|
|
8357
|
+
return path12.join(datedDir, `${id}.md`);
|
|
8323
8358
|
}
|
|
8324
8359
|
async findExistingTombstoneBlockedMemory(content, category, sourceConnector) {
|
|
8325
8360
|
const identity = buildExplicitCaptureDedupKey(content, category, sourceConnector);
|
|
@@ -8685,7 +8720,7 @@ ${sanitized.text}
|
|
|
8685
8720
|
await this.ensureDirectories();
|
|
8686
8721
|
const now = /* @__PURE__ */ new Date();
|
|
8687
8722
|
const day = now.toISOString().slice(0, 10);
|
|
8688
|
-
const dir =
|
|
8723
|
+
const dir = path12.join(this.artifactsDir, day);
|
|
8689
8724
|
await mkdir(dir, { recursive: true });
|
|
8690
8725
|
const id = `artifact-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
8691
8726
|
const fm = {
|
|
@@ -8712,7 +8747,7 @@ ${sanitized.text}
|
|
|
8712
8747
|
log.warn(`artifact content rejected for ${id}; violations=${sanitized.violations.join(", ")}`);
|
|
8713
8748
|
return "";
|
|
8714
8749
|
}
|
|
8715
|
-
const filePath =
|
|
8750
|
+
const filePath = path12.join(dir, `${id}.md`);
|
|
8716
8751
|
await this.writeStorageSecureFile(filePath, `${serializeFrontmatter(fm)}
|
|
8717
8752
|
|
|
8718
8753
|
${sanitized.text}
|
|
@@ -9000,7 +9035,7 @@ ${sanitized.text}
|
|
|
9000
9035
|
* per-process in-memory cache safe across process boundaries.
|
|
9001
9036
|
*/
|
|
9002
9037
|
invalidateColdMemoriesCache() {
|
|
9003
|
-
const coldRoot =
|
|
9038
|
+
const coldRoot = path12.join(this.baseDir, "cold");
|
|
9004
9039
|
_StorageManager.coldMemoriesCache.delete(coldRoot);
|
|
9005
9040
|
this.bumpColdWriteVersion();
|
|
9006
9041
|
invalidateAllForDir(this.baseDir);
|
|
@@ -9120,7 +9155,7 @@ ${sanitized.text}
|
|
|
9120
9155
|
const correctionPaths = [];
|
|
9121
9156
|
const factPaths = [];
|
|
9122
9157
|
for (const filePath of filePaths) {
|
|
9123
|
-
if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${
|
|
9158
|
+
if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${path12.sep}`)) {
|
|
9124
9159
|
correctionPaths.push(filePath);
|
|
9125
9160
|
} else {
|
|
9126
9161
|
factPaths.push(filePath);
|
|
@@ -9183,7 +9218,7 @@ ${sanitized.text}
|
|
|
9183
9218
|
try {
|
|
9184
9219
|
const entries = await readdir6(dir, { withFileTypes: true });
|
|
9185
9220
|
for (const entry of entries) {
|
|
9186
|
-
const fullPath =
|
|
9221
|
+
const fullPath = path12.join(dir, entry.name);
|
|
9187
9222
|
if (entry.isDirectory()) {
|
|
9188
9223
|
await readDir(fullPath);
|
|
9189
9224
|
} else if (entry.name.endsWith(".md")) {
|
|
@@ -9226,7 +9261,7 @@ ${sanitized.text}
|
|
|
9226
9261
|
return this.rememberMemorySnapshot(await this.memoryReadStore.readMemoryByPath(filePath));
|
|
9227
9262
|
}
|
|
9228
9263
|
resolveTierRootDir(tier) {
|
|
9229
|
-
return tier === "cold" ?
|
|
9264
|
+
return tier === "cold" ? path12.join(this.baseDir, "cold") : this.baseDir;
|
|
9230
9265
|
}
|
|
9231
9266
|
resolveMemoryDateDir(memory) {
|
|
9232
9267
|
const preferred = memory.frontmatter.created || memory.frontmatter.updated;
|
|
@@ -9241,13 +9276,13 @@ ${sanitized.text}
|
|
|
9241
9276
|
buildTierMemoryPath(memory, tier) {
|
|
9242
9277
|
const root = this.resolveTierRootDir(tier);
|
|
9243
9278
|
if (this.isArtifactMemory(memory)) {
|
|
9244
|
-
return
|
|
9279
|
+
return path12.join(root, "artifacts", this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
|
|
9245
9280
|
}
|
|
9246
9281
|
if (memory.frontmatter.category === "correction") {
|
|
9247
|
-
return
|
|
9282
|
+
return path12.join(root, "corrections", `${memory.frontmatter.id}.md`);
|
|
9248
9283
|
}
|
|
9249
9284
|
const dir = categoryDirName(memory.frontmatter.category);
|
|
9250
|
-
return
|
|
9285
|
+
return path12.join(root, dir, this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
|
|
9251
9286
|
}
|
|
9252
9287
|
async writeMemoryFileAtomic(targetPath, memory) {
|
|
9253
9288
|
const refIdsAtWrite = this.currentHistoricalIds();
|
|
@@ -9325,8 +9360,8 @@ ${memory.content}
|
|
|
9325
9360
|
memory.frontmatter.entityRef = current.frontmatter.entityRef;
|
|
9326
9361
|
}
|
|
9327
9362
|
durable = true;
|
|
9328
|
-
const sourcePath =
|
|
9329
|
-
const destPath =
|
|
9363
|
+
const sourcePath = path12.resolve(current.path);
|
|
9364
|
+
const destPath = path12.resolve(targetPath);
|
|
9330
9365
|
if (sourcePath !== destPath) {
|
|
9331
9366
|
await recordArchiveDelete2(this.baseDir, current.path, () => this.deleteManagedStorageFile(current.path));
|
|
9332
9367
|
this.invalidateAllMemoriesCache();
|
|
@@ -9350,8 +9385,8 @@ ${memory.content}
|
|
|
9350
9385
|
}
|
|
9351
9386
|
async migrateMemoryToTier(memory, targetTier) {
|
|
9352
9387
|
const targetPath = this.buildTierMemoryPath(memory, targetTier);
|
|
9353
|
-
const sourcePath =
|
|
9354
|
-
const destPath =
|
|
9388
|
+
const sourcePath = path12.resolve(memory.path);
|
|
9389
|
+
const destPath = path12.resolve(targetPath);
|
|
9355
9390
|
if (sourcePath === destPath) {
|
|
9356
9391
|
return { changed: false, targetPath };
|
|
9357
9392
|
}
|
|
@@ -9361,7 +9396,7 @@ ${memory.content}
|
|
|
9361
9396
|
return { changed, targetPath };
|
|
9362
9397
|
}
|
|
9363
9398
|
get archiveDir() {
|
|
9364
|
-
return
|
|
9399
|
+
return path12.join(this.baseDir, "archive");
|
|
9365
9400
|
}
|
|
9366
9401
|
/**
|
|
9367
9402
|
* Archive a memory by moving it from facts/ to archive/YYYY-MM-DD/.
|
|
@@ -9374,7 +9409,7 @@ ${memory.content}
|
|
|
9374
9409
|
try {
|
|
9375
9410
|
const now = lifecycle?.at ?? /* @__PURE__ */ new Date();
|
|
9376
9411
|
const today = now.toISOString().slice(0, 10);
|
|
9377
|
-
const destDir =
|
|
9412
|
+
const destDir = path12.join(this.archiveDir, today);
|
|
9378
9413
|
await mkdir(destDir, { recursive: true });
|
|
9379
9414
|
const refIdsAtWrite = this.currentHistoricalIds();
|
|
9380
9415
|
const updatedFm = canonicalizeEntityRefOption(
|
|
@@ -9390,7 +9425,7 @@ ${memory.content}
|
|
|
9390
9425
|
|
|
9391
9426
|
${current.content}
|
|
9392
9427
|
`;
|
|
9393
|
-
const destPath =
|
|
9428
|
+
const destPath = path12.join(destDir, path12.basename(current.path));
|
|
9394
9429
|
const priorDest = await this.readStorageSecureFile(destPath).catch(() => null);
|
|
9395
9430
|
await recordArchiveWrite(this.baseDir, destPath, () => this.writeStorageSecureFile(destPath, fileContent));
|
|
9396
9431
|
if (typeof current.frontmatter.entityRef === "string") {
|
|
@@ -9623,7 +9658,7 @@ ${memory.content}
|
|
|
9623
9658
|
`;
|
|
9624
9659
|
await this.writeTombstoneBlockedFrontmatter(memory, fileContent, updated, async () => {
|
|
9625
9660
|
this.invalidateAllMemoriesCache();
|
|
9626
|
-
if (memory.path.includes(`${
|
|
9661
|
+
if (memory.path.includes(`${path12.sep}cold${path12.sep}`)) {
|
|
9627
9662
|
this.invalidateColdMemoriesCache();
|
|
9628
9663
|
}
|
|
9629
9664
|
});
|
|
@@ -9634,7 +9669,7 @@ ${memory.content}
|
|
|
9634
9669
|
});
|
|
9635
9670
|
}
|
|
9636
9671
|
await this.patchHotMemoriesCache({ addedPath: memory.path });
|
|
9637
|
-
if (memory.path.includes(`${
|
|
9672
|
+
if (memory.path.includes(`${path12.sep}cold${path12.sep}`)) {
|
|
9638
9673
|
this.invalidateColdMemoriesCache();
|
|
9639
9674
|
}
|
|
9640
9675
|
try {
|
|
@@ -9715,7 +9750,7 @@ ${memory.content}
|
|
|
9715
9750
|
return deleted;
|
|
9716
9751
|
}
|
|
9717
9752
|
async loadBuffer() {
|
|
9718
|
-
const bufferPath =
|
|
9753
|
+
const bufferPath = path12.join(this.stateDir, "buffer.json");
|
|
9719
9754
|
try {
|
|
9720
9755
|
const raw = await this.readStorageSecureFile(bufferPath);
|
|
9721
9756
|
return JSON.parse(raw);
|
|
@@ -9727,11 +9762,11 @@ ${memory.content}
|
|
|
9727
9762
|
}
|
|
9728
9763
|
async saveBuffer(state) {
|
|
9729
9764
|
await this.ensureDirectories();
|
|
9730
|
-
const bufferPath =
|
|
9765
|
+
const bufferPath = path12.join(this.stateDir, "buffer.json");
|
|
9731
9766
|
await this.writeStorageSecureFile(bufferPath, JSON.stringify(state, null, 2));
|
|
9732
9767
|
}
|
|
9733
9768
|
async loadMeta() {
|
|
9734
|
-
const metaPath =
|
|
9769
|
+
const metaPath = path12.join(this.stateDir, "meta.json");
|
|
9735
9770
|
try {
|
|
9736
9771
|
const raw = await this.readStorageSecureFile(metaPath);
|
|
9737
9772
|
const parsed = JSON.parse(raw);
|
|
@@ -9764,7 +9799,7 @@ ${memory.content}
|
|
|
9764
9799
|
}
|
|
9765
9800
|
async saveMeta(state) {
|
|
9766
9801
|
await this.ensureDirectories();
|
|
9767
|
-
const metaPath =
|
|
9802
|
+
const metaPath = path12.join(this.stateDir, "meta.json");
|
|
9768
9803
|
await this.writeStorageSecureFile(metaPath, JSON.stringify(state, null, 2));
|
|
9769
9804
|
}
|
|
9770
9805
|
async appendMemoryActionEvents(events) {
|
|
@@ -9828,7 +9863,7 @@ ${memory.content}
|
|
|
9828
9863
|
},
|
|
9829
9864
|
(payload) => this.appendStorageSecureFile(target, payload),
|
|
9830
9865
|
async () => {
|
|
9831
|
-
await mkdir(
|
|
9866
|
+
await mkdir(path12.dirname(target), { recursive: true });
|
|
9832
9867
|
}
|
|
9833
9868
|
);
|
|
9834
9869
|
}
|
|
@@ -9926,7 +9961,7 @@ ${memory.content}
|
|
|
9926
9961
|
async appendReextractJobs(events) {
|
|
9927
9962
|
if (events.length === 0) return 0;
|
|
9928
9963
|
await this.ensureDirectories();
|
|
9929
|
-
const filePath =
|
|
9964
|
+
const filePath = path12.join(this.stateDir, "reextract-jobs.jsonl");
|
|
9930
9965
|
const lines = events.map((event) => JSON.stringify(event)).join("\n") + "\n";
|
|
9931
9966
|
try {
|
|
9932
9967
|
await this.appendStorageSecureFile(filePath, lines);
|
|
@@ -9939,7 +9974,7 @@ ${memory.content}
|
|
|
9939
9974
|
}
|
|
9940
9975
|
async readReextractJobs(limit = 200) {
|
|
9941
9976
|
const safeLimit = Number.isFinite(limit) ? Math.max(1, Math.min(1e3, Math.floor(limit))) : 200;
|
|
9942
|
-
const filePath =
|
|
9977
|
+
const filePath = path12.join(this.stateDir, "reextract-jobs.jsonl");
|
|
9943
9978
|
try {
|
|
9944
9979
|
const raw = await this.readStorageSecureFile(filePath);
|
|
9945
9980
|
const lines = raw.split("\n").filter((line) => line.trim().length > 0);
|
|
@@ -10166,7 +10201,7 @@ ${question}
|
|
|
10166
10201
|
|
|
10167
10202
|
**Context:** ${context}
|
|
10168
10203
|
`;
|
|
10169
|
-
const filePath =
|
|
10204
|
+
const filePath = path12.join(this.questionsDir, `${id}.md`);
|
|
10170
10205
|
await this.writeStorageSecureFile(filePath, content);
|
|
10171
10206
|
log.debug(`wrote question ${id} to ${filePath}`);
|
|
10172
10207
|
this.invalidateQuestionsCache();
|
|
@@ -10184,7 +10219,7 @@ ${question}
|
|
|
10184
10219
|
if (!match) return null;
|
|
10185
10220
|
const frontmatterStr = match[1];
|
|
10186
10221
|
const body = match[2].trim();
|
|
10187
|
-
const id = this.extractFrontmatterValue(frontmatterStr, "id") ??
|
|
10222
|
+
const id = this.extractFrontmatterValue(frontmatterStr, "id") ?? path12.basename(filePath, ".md");
|
|
10188
10223
|
const created = this.extractFrontmatterValue(frontmatterStr, "created") ?? "";
|
|
10189
10224
|
const priority = parseFloat(this.extractFrontmatterValue(frontmatterStr, "priority") ?? "0.5");
|
|
10190
10225
|
const resolved = this.extractFrontmatterValue(frontmatterStr, "resolved") === "true";
|
|
@@ -10240,11 +10275,11 @@ ${question}
|
|
|
10240
10275
|
} catch {
|
|
10241
10276
|
}
|
|
10242
10277
|
const hygiene = opts?.hygiene;
|
|
10243
|
-
const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(
|
|
10278
|
+
const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(path12.basename(identityPath));
|
|
10244
10279
|
if (rotateEnabled) {
|
|
10245
10280
|
const maxBytes = hygiene.rotateMaxBytes;
|
|
10246
10281
|
if (existing.length > maxBytes) {
|
|
10247
|
-
const archiveDir =
|
|
10282
|
+
const archiveDir = path12.join(workspaceDir, hygiene.archiveDir);
|
|
10248
10283
|
const { newContent } = await rotateMarkdownFileToArchive({
|
|
10249
10284
|
filePath: identityPath,
|
|
10250
10285
|
archiveDir,
|
|
@@ -10504,14 +10539,14 @@ ${reflection}
|
|
|
10504
10539
|
if (entries.length === 0) return 0;
|
|
10505
10540
|
const memories = await this.readAllMemories();
|
|
10506
10541
|
const memoryMap = new Map(memories.map((m) => [m.frontmatter.id, m]));
|
|
10507
|
-
const memoryPathMap = new Map(memories.map((m) => [
|
|
10542
|
+
const memoryPathMap = new Map(memories.map((m) => [path12.resolve(m.path), m]));
|
|
10508
10543
|
let updated = 0;
|
|
10509
10544
|
const prevVersion = this.getMemoryCorpusVersion();
|
|
10510
10545
|
const keyId = this.hotCacheKeyId();
|
|
10511
10546
|
const warm = this.hotMemoriesCacheEnabled && getCachedMemories(this.baseDir, prevVersion, keyId, this.hotCacheTtlMs()) !== null;
|
|
10512
10547
|
const appliedPatches = /* @__PURE__ */ new Map();
|
|
10513
10548
|
for (const entry of entries) {
|
|
10514
|
-
const memory = entry.memoryPath ? memoryPathMap.get(
|
|
10549
|
+
const memory = entry.memoryPath ? memoryPathMap.get(path12.resolve(entry.memoryPath)) : memoryMap.get(entry.memoryId);
|
|
10515
10550
|
if (!memory) continue;
|
|
10516
10551
|
try {
|
|
10517
10552
|
const applied = await this.withTombstoneBlockedMemoryPathLock(memory.path, async (current) => {
|
|
@@ -10542,7 +10577,7 @@ ${current.content}
|
|
|
10542
10577
|
if (warm) {
|
|
10543
10578
|
updateCacheOnWrite(this.baseDir, { ...applied.current, frontmatter: applied.newFm }, keyId);
|
|
10544
10579
|
}
|
|
10545
|
-
appliedPatches.set(
|
|
10580
|
+
appliedPatches.set(path12.resolve(memory.path), {
|
|
10546
10581
|
accessCount: entry.newCount,
|
|
10547
10582
|
lastAccessed: entry.lastAccessed
|
|
10548
10583
|
});
|
|
@@ -10558,7 +10593,7 @@ ${current.content}
|
|
|
10558
10593
|
const cur = getCachedMemories(this.baseDir, prevVersion, keyId);
|
|
10559
10594
|
if (cur) {
|
|
10560
10595
|
const reapplied = cur.map((m) => {
|
|
10561
|
-
const patch = appliedPatches.get(
|
|
10596
|
+
const patch = appliedPatches.get(path12.resolve(m.path));
|
|
10562
10597
|
return patch ? {
|
|
10563
10598
|
...m,
|
|
10564
10599
|
frontmatter: { ...m.frontmatter, accessCount: patch.accessCount, lastAccessed: patch.lastAccessed }
|
|
@@ -10588,7 +10623,7 @@ ${current.content}
|
|
|
10588
10623
|
const pathsById = /* @__PURE__ */ new Map();
|
|
10589
10624
|
const filePathsById = /* @__PURE__ */ new Map();
|
|
10590
10625
|
for (const filePath of filePaths) {
|
|
10591
|
-
const memoryId =
|
|
10626
|
+
const memoryId = path12.basename(filePath, ".md");
|
|
10592
10627
|
if (!wantedIds.has(memoryId)) continue;
|
|
10593
10628
|
const paths = filePathsById.get(memoryId) ?? [];
|
|
10594
10629
|
paths.push(filePath);
|
|
@@ -10600,7 +10635,7 @@ ${current.content}
|
|
|
10600
10635
|
const preferredMatches = [];
|
|
10601
10636
|
for (const preferredPath of preferred) {
|
|
10602
10637
|
const directCandidates = new Set(qmdResultPathCandidates(this.baseDir, preferredPath));
|
|
10603
|
-
const directMatch = existingPaths.find((filePath) => directCandidates.has(
|
|
10638
|
+
const directMatch = existingPaths.find((filePath) => directCandidates.has(path12.resolve(filePath)));
|
|
10604
10639
|
if (directMatch) {
|
|
10605
10640
|
preferredMatches.push(directMatch);
|
|
10606
10641
|
continue;
|
|
@@ -10612,7 +10647,7 @@ ${current.content}
|
|
|
10612
10647
|
candidates.add(candidate);
|
|
10613
10648
|
}
|
|
10614
10649
|
}
|
|
10615
|
-
const match = existingPaths.find((filePath) => candidates.has(
|
|
10650
|
+
const match = existingPaths.find((filePath) => candidates.has(path12.resolve(filePath)));
|
|
10616
10651
|
if (match) preferredMatches.push(match);
|
|
10617
10652
|
}
|
|
10618
10653
|
if (preferredMatches.length > 0) {
|
|
@@ -10932,11 +10967,11 @@ ${current.content}
|
|
|
10932
10967
|
}
|
|
10933
10968
|
}
|
|
10934
10969
|
get summariesDir() {
|
|
10935
|
-
return
|
|
10970
|
+
return path12.join(this.baseDir, "summaries");
|
|
10936
10971
|
}
|
|
10937
10972
|
async writeSummary(summary) {
|
|
10938
10973
|
await mkdir(this.summariesDir, { recursive: true });
|
|
10939
|
-
const filePath =
|
|
10974
|
+
const filePath = path12.join(this.summariesDir, `${summary.id}.json`);
|
|
10940
10975
|
await this.writeStorageSecureFile(filePath, JSON.stringify(summary, null, 2));
|
|
10941
10976
|
log.debug(`wrote summary ${summary.id}`);
|
|
10942
10977
|
}
|
|
@@ -10946,7 +10981,7 @@ ${current.content}
|
|
|
10946
10981
|
const summaries = [];
|
|
10947
10982
|
for (const file of files) {
|
|
10948
10983
|
if (!file.endsWith(".json")) continue;
|
|
10949
|
-
const filePath =
|
|
10984
|
+
const filePath = path12.join(this.summariesDir, file);
|
|
10950
10985
|
const raw = await this.readStorageSecureFile(filePath);
|
|
10951
10986
|
summaries.push(JSON.parse(raw));
|
|
10952
10987
|
}
|
|
@@ -11016,7 +11051,7 @@ ${current.content}
|
|
|
11016
11051
|
return archived;
|
|
11017
11052
|
}
|
|
11018
11053
|
async saveTopics(topics) {
|
|
11019
|
-
const metaPath =
|
|
11054
|
+
const metaPath = path12.join(this.stateDir, "topics.json");
|
|
11020
11055
|
await mkdir(this.stateDir, { recursive: true });
|
|
11021
11056
|
await this.writeStorageSecureFile(
|
|
11022
11057
|
metaPath,
|
|
@@ -11025,7 +11060,7 @@ ${current.content}
|
|
|
11025
11060
|
log.debug(`saved ${topics.length} topic scores`);
|
|
11026
11061
|
}
|
|
11027
11062
|
async loadTopics() {
|
|
11028
|
-
const metaPath =
|
|
11063
|
+
const metaPath = path12.join(this.stateDir, "topics.json");
|
|
11029
11064
|
try {
|
|
11030
11065
|
const raw = await this.readStorageSecureFile(metaPath);
|
|
11031
11066
|
return JSON.parse(raw);
|
|
@@ -11141,4 +11176,4 @@ export {
|
|
|
11141
11176
|
isValidBufferSurpriseEvent,
|
|
11142
11177
|
StorageManager3 as StorageManager
|
|
11143
11178
|
};
|
|
11144
|
-
//# sourceMappingURL=chunk-
|
|
11179
|
+
//# sourceMappingURL=chunk-CALURYWR.js.map
|