@remnic/core 9.27.0 → 9.28.0
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 +13 -10
- package/dist/access-admin-ops-surface.js +43 -38
- package/dist/access-audit.js +2 -2
- package/dist/access-authorization-probe.d.ts +13 -10
- package/dist/access-authorization-probe.js +44 -39
- package/dist/access-boundary.d.ts +13 -10
- package/dist/access-boundary.js +43 -38
- package/dist/access-cli.js +100 -94
- package/dist/access-cli.js.map +1 -1
- package/dist/access-health-types.d.ts +10 -1
- package/dist/access-http-lcm-compaction.d.ts +13 -10
- package/dist/access-http.d.ts +13 -10
- package/dist/access-http.js +53 -48
- package/dist/access-identity-continuity-surface.d.ts +9 -8
- package/dist/access-identity-continuity-surface.js +43 -38
- package/dist/access-lcm-surface.d.ts +13 -10
- package/dist/access-lcm-surface.js +43 -38
- package/dist/access-mcp.d.ts +13 -10
- package/dist/access-mcp.js +48 -43
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-wRSZEO5V.d.ts → access-namespace-preflight-BiQ_-iUJ.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +43 -38
- package/dist/access-observe-write-surface.d.ts +13 -10
- package/dist/access-observe-write-surface.js +43 -38
- package/dist/access-operations-batch.js +45 -40
- package/dist/access-operations.d.ts +16 -13
- package/dist/access-operations.js +47 -42
- package/dist/access-recall-concurrency.d.ts +13 -10
- package/dist/access-recall-concurrency.js +43 -38
- package/dist/access-recall-response.d.ts +13 -10
- package/dist/access-recall-response.js +43 -38
- package/dist/access-recall-surface.d.ts +13 -10
- package/dist/access-recall-surface.js +43 -38
- package/dist/access-schema.d.ts +80 -80
- package/dist/access-schema.js +4 -4
- package/dist/{access-service-B4-Fu9x2.d.ts → access-service-CXkIgcGh.d.ts} +12 -8
- package/dist/access-service.d.ts +13 -10
- package/dist/access-service.js +43 -38
- package/dist/access-surface-catalog.d.ts +13 -10
- package/dist/access-wearables-meetings-surface.d.ts +4 -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 +4 -2
- package/dist/active-recall.js.map +1 -1
- package/dist/adapters/index.js +7 -7
- package/dist/adapters/registry.js +3 -3
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +9 -8
- package/dist/briefing.d.ts +3 -2
- package/dist/briefing.js +12 -10
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer.d.ts +3 -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/{capsule-crypto-YO5QJ6L3.js → capsule-crypto-7FJQINUR.js} +2 -2
- package/dist/{catalog-BLLxZ5L5.d.ts → catalog-Bouj8Gfg.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +13 -11
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/{chunk-7RZJWZ46.js → chunk-227UFSEQ.js} +5 -5
- package/dist/{chunk-UT3OQPFA.js → chunk-2BEJ4XCF.js} +2 -2
- package/dist/{chunk-EOLC6EXV.js → chunk-2FYNLDKJ.js} +24 -3
- package/dist/chunk-2FYNLDKJ.js.map +1 -0
- package/dist/{chunk-BXLOS5AJ.js → chunk-2NLLXCJG.js} +2 -2
- package/dist/{chunk-6NNNURLK.js → chunk-2PHX3I5C.js} +8 -8
- package/dist/{chunk-HORJVJ6K.js → chunk-2TQ2UFKH.js} +65 -60
- package/dist/chunk-2TQ2UFKH.js.map +1 -0
- package/dist/{chunk-RPA2RX5P.js → chunk-3BSJBIZ3.js} +2 -2
- package/dist/{chunk-JCVQV6QX.js → chunk-3UOSVTFR.js} +11 -11
- package/dist/{chunk-AJ7QCSIS.js → chunk-7CPOZH6Y.js} +2 -2
- package/dist/{chunk-MEBQFQ26.js → chunk-AHFZXUZM.js} +7 -5
- package/dist/chunk-AHFZXUZM.js.map +1 -0
- package/dist/{chunk-U3TH5Q2Q.js → chunk-ALTP3MFS.js} +2 -2
- package/dist/{chunk-77CNV7DY.js → chunk-BLAKS3CP.js} +4 -4
- package/dist/{chunk-XQ4EH6DI.js → chunk-BR4UFMLO.js} +2 -2
- package/dist/chunk-CVILPI77.js +432 -0
- package/dist/chunk-CVILPI77.js.map +1 -0
- package/dist/{chunk-WEAO45M4.js → chunk-DKQM5Q6Q.js} +2 -2
- package/dist/{chunk-CSXHRAJJ.js → chunk-EG64LXKL.js} +3 -3
- package/dist/{chunk-PTN6UAUA.js → chunk-ES36HTSC.js} +4 -4
- package/dist/{chunk-5BRT4Z2I.js → chunk-EZWWCN7I.js} +2 -2
- package/dist/{chunk-XKGPIWGI.js → chunk-FBZTWUK5.js} +5 -5
- package/dist/{chunk-GJJBPI6I.js → chunk-FOCEI3TN.js} +6 -3
- package/dist/chunk-FOCEI3TN.js.map +1 -0
- package/dist/{chunk-FRVTCCGD.js → chunk-GJPCP5CA.js} +2 -2
- package/dist/{chunk-CI26JDZA.js → chunk-GQSMYXKL.js} +6 -4
- package/dist/{chunk-CI26JDZA.js.map → chunk-GQSMYXKL.js.map} +1 -1
- package/dist/{chunk-TGQ2NTWH.js → chunk-IJ6WHMFB.js} +16 -2
- package/dist/{chunk-TGQ2NTWH.js.map → chunk-IJ6WHMFB.js.map} +1 -1
- package/dist/{chunk-VDX2J7OX.js → chunk-IPLYGWQF.js} +6 -6
- package/dist/{chunk-YSGBD3QN.js → chunk-IYT632D5.js} +3 -3
- package/dist/{chunk-2QSZNTDO.js → chunk-JBPKEARU.js} +7 -7
- package/dist/{chunk-RSYJV25N.js → chunk-JIF3VRKQ.js} +8 -8
- package/dist/{chunk-V25OWXAC.js → chunk-JQ7T5VDC.js} +1 -1
- package/dist/chunk-JQ7T5VDC.js.map +1 -0
- package/dist/{chunk-EUSLKI4X.js → chunk-KKBTBUVT.js} +2 -2
- package/dist/{chunk-RNY3BO35.js → chunk-LIHC3T43.js} +2 -2
- package/dist/{chunk-RGJBM7Z3.js → chunk-MJPV4LBH.js} +79 -79
- package/dist/{chunk-RGJBM7Z3.js.map → chunk-MJPV4LBH.js.map} +1 -1
- package/dist/{chunk-UGH6VPPO.js → chunk-MWTMTW2T.js} +2 -2
- package/dist/{chunk-MG6MNSP4.js → chunk-MXJ3VP6S.js} +6 -6
- package/dist/{chunk-XKO7BM2C.js → chunk-NBNDVNJ2.js} +186 -25
- package/dist/chunk-NBNDVNJ2.js.map +1 -0
- package/dist/{chunk-M5EPMNS4.js → chunk-P2CLYN6H.js} +2 -2
- package/dist/{chunk-BNGPHGVZ.js → chunk-PXQM2HOG.js} +13 -6
- package/dist/{chunk-BNGPHGVZ.js.map → chunk-PXQM2HOG.js.map} +1 -1
- package/dist/{chunk-CIQXI47W.js → chunk-Q5VJUNXA.js} +1192 -268
- package/dist/chunk-Q5VJUNXA.js.map +1 -0
- package/dist/{chunk-KGTD2KZJ.js → chunk-Q6YJW6KE.js} +2 -2
- package/dist/{chunk-X3SQYAPP.js → chunk-R372P2EH.js} +2 -2
- package/dist/{chunk-4MJZTF42.js → chunk-RKXZ7P4V.js} +3 -3
- package/dist/chunk-RMMVQQA6.js +70 -0
- package/dist/chunk-RMMVQQA6.js.map +1 -0
- package/dist/{chunk-2RAC4JIG.js → chunk-S24E4MBQ.js} +14 -14
- package/dist/chunk-S24E4MBQ.js.map +1 -0
- package/dist/{chunk-RYHWZ52A.js → chunk-S2BBISHU.js} +4 -4
- package/dist/{chunk-LLISELSY.js → chunk-TBMRQZDY.js} +2 -2
- package/dist/{chunk-FMLKOL2Z.js → chunk-TC3VNKGX.js} +4 -4
- package/dist/{chunk-7K5Q6COX.js → chunk-TVVEYCNW.js} +4 -4
- package/dist/{chunk-NUWMZIYZ.js → chunk-UR5SIN7H.js} +53 -35
- package/dist/chunk-UR5SIN7H.js.map +1 -0
- package/dist/{chunk-JDOJZTFF.js → chunk-VFNI3RPT.js} +2 -2
- package/dist/chunk-VNA7W7QF.js +134 -0
- package/dist/chunk-VNA7W7QF.js.map +1 -0
- package/dist/{chunk-EYJSW2RV.js → chunk-VYYNBJXH.js} +5 -5
- package/dist/chunk-WNIUPHWV.js +152 -0
- package/dist/chunk-WNIUPHWV.js.map +1 -0
- package/dist/chunk-WRJVB3C2.js +118 -0
- package/dist/chunk-WRJVB3C2.js.map +1 -0
- package/dist/{chunk-BHLN7L7M.js → chunk-WVVK2RFM.js} +6 -6
- package/dist/{chunk-DQEMWVMT.js → chunk-X7Y7WX73.js} +1 -1
- package/dist/{chunk-HEXSNYJD.js → chunk-YOBNCD3Z.js} +6 -6
- package/dist/chunk-YXZG5TVN.js +40 -0
- package/dist/chunk-YXZG5TVN.js.map +1 -0
- package/dist/{chunk-4DJQYKMN.js → chunk-ZIKENA2C.js} +2 -2
- package/dist/chunk-ZIKENA2C.js.map +1 -0
- package/dist/{chunk-SK3EYPKC.js → chunk-ZN4UZWMT.js} +2 -2
- package/dist/{cli-Bz7X7dGx.d.ts → cli-DJbkaZBU.d.ts} +5 -5
- package/dist/cli.d.ts +14 -12
- package/dist/cli.js +79 -74
- package/dist/compounding/engine.d.ts +3 -2
- package/dist/compounding/engine.js +12 -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 +4 -2
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +12 -10
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +12 -10
- package/dist/consolidation-provenance-check.d.ts +3 -2
- package/dist/consolidation-undo.d.ts +3 -2
- package/dist/contradiction/index.d.ts +3 -2
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/backend.js +2 -2
- 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 +15 -2
- package/dist/corpus-watermark.js +25 -21
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/entity-id-normalization.d.ts +4 -0
- package/dist/entity-id-normalization.js +10 -0
- package/dist/entity-id-normalization.js.map +1 -0
- package/dist/entity-retrieval-boundaries.d.ts +3 -0
- package/dist/entity-retrieval-boundaries.js +8 -0
- package/dist/entity-retrieval-boundaries.js.map +1 -0
- package/dist/entity-retrieval.d.ts +3 -2
- package/dist/entity-retrieval.js +13 -10
- package/dist/entity-schema.d.ts +1 -1
- package/dist/entity-schema.js +1 -1
- package/dist/explicit-capture.d.ts +9 -8
- 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.d.ts +1 -1
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/{first-start-migration-LEXL3XYL.js → first-start-migration-BKNGOFED.js} +4 -4
- 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-snapshot.d.ts +1 -1
- package/dist/graph.d.ts +1 -1
- 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 +409 -407
- package/dist/index.js +147 -141
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/engine.js +3 -3
- 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 +12 -10
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +3 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +12 -10
- package/dist/maintenance/rebuild-memory-projection.d.ts +3 -2
- package/dist/maintenance/rebuild-memory-projection.js +13 -11
- package/dist/{maintenance-DgnD2z8S.d.ts → maintenance-DveW6azo.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +13 -10
- 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-mutations.d.ts +4 -0
- package/dist/memory-projection-mutations.js +15 -0
- package/dist/memory-projection-mutations.js.map +1 -0
- package/dist/memory-projection-store.d.ts +1 -1
- package/dist/memory-provenance.d.ts +1 -1
- package/dist/memory-worth-outcomes.d.ts +3 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +4 -3
- package/dist/namespaces/migrate.js +22 -20
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +9 -9
- package/dist/namespaces/storage.d.ts +4 -3
- package/dist/namespaces/storage.js +12 -10
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/offline-sync-impression-drain.js +3 -3
- package/dist/operator-doctor-corpus.d.ts +22 -3
- package/dist/operator-doctor-corpus.js +32 -22
- package/dist/operator-doctor-replica.d.ts +52 -0
- package/dist/operator-doctor-replica.js +15 -0
- package/dist/operator-doctor-replica.js.map +1 -0
- package/dist/operator-toolkit.d.ts +7 -3
- package/dist/operator-toolkit.js +33 -27
- package/dist/orchestration/compression-guideline-coordinator.d.ts +3 -2
- package/dist/orchestration/maintenance.d.ts +5 -4
- package/dist/orchestration/maintenance.js +17 -15
- package/dist/{orchestrator-rIHmHpv1.d.ts → orchestrator-Cvlgpe6I.d.ts} +7 -7
- package/dist/orchestrator.d.ts +9 -8
- package/dist/orchestrator.js +99 -93
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-Bq5zU6Bp.d.ts → pipeline-BveYVaz7.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/proactive-contention.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/{qmd-3ILJkC70.d.ts → qmd-CLWDsbYR.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-state.d.ts +1 -1
- package/dist/recall-state.js +2 -2
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.d.ts +1 -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/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 +279 -0
- package/dist/replica-divergence.js +28 -0
- package/dist/replica-divergence.js.map +1 -0
- package/dist/replica-peers-config.d.ts +5 -0
- package/dist/replica-peers-config.js +13 -0
- package/dist/replica-peers-config.js.map +1 -0
- package/dist/resolve-auth-token.d.ts +21 -2
- package/dist/resolve-auth-token.js +5 -1
- package/dist/resume-bundles.js +5 -3
- 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/schemas.d.ts +76 -76
- package/dist/{scope-profiles-D0-ff4xT.d.ts → scope-profiles-BVf3DZ7z.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 +8 -8
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +13 -13
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/lancedb-backend.js +2 -2
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.js +2 -2
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- package/dist/search/orama-backend.js +2 -2
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-4Tfh7c1g.d.ts → semantic-consolidation-DXLV47y2.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +13 -11
- package/dist/semantic-rule-promotion.js +12 -10
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +12 -10
- package/dist/{service-cTvil7D_.d.ts → service-DbgPTeMJ.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 +9 -9
- package/dist/signal.d.ts +1 -1
- package/dist/{storage-C9ibpTme.d.ts → storage-DOzTm8wG.d.ts} +13 -19
- package/dist/storage.d.ts +3 -2
- package/dist/storage.js +13 -10
- package/dist/summarizer.d.ts +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/temporal-supersession.d.ts +3 -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 +3 -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/autodetect.js +1 -1
- package/dist/transfer/backup.js +2 -2
- package/dist/transfer/capsule-export.js +3 -3
- package/dist/transfer/capsule-import.js +2 -2
- package/dist/transfer/types.d.ts +66 -66
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-DHBxIF0s.d.ts → types-BA7W-_xy.d.ts} +53 -4
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +12 -10
- package/dist/write-envelope.d.ts +1 -1
- package/package.json +2 -2
- package/src/access-health-types.ts +8 -0
- package/src/access-http.test.ts +4 -0
- package/src/access-service-health.test.ts +23 -0
- package/src/access-service.ts +27 -4
- package/src/cli.ts +9 -7
- package/src/config.ts +2 -1
- package/src/corpus-watermark.test.ts +21 -0
- package/src/corpus-watermark.ts +25 -3
- package/src/entity-id-normalization.ts +55 -0
- package/src/entity-retrieval-boundaries.ts +134 -0
- package/src/entity-retrieval.ts +253 -27
- package/src/entity-schema.ts +2 -1
- package/src/memory-projection-mutations.ts +132 -0
- package/src/namespaces/storage.ts +5 -3
- package/src/operator-doctor-corpus.ts +41 -0
- package/src/operator-doctor-replica.test.ts +261 -0
- package/src/operator-doctor-replica.ts +129 -0
- package/src/operator-toolkit.ts +5 -4
- package/src/orchestration/orchestrator-init.ts +2 -2
- package/src/replica-divergence.test.ts +1475 -0
- package/src/replica-divergence.ts +910 -0
- package/src/replica-peers-config.ts +250 -0
- package/src/resolve-auth-token.ts +38 -0
- package/src/storage/entity-canonical-id-migration-adapter.ts +72 -0
- package/src/storage/entity-canonical-id-migration-runner.ts +68 -0
- package/src/storage/entity-canonical-id-migration.ts +904 -0
- package/src/storage/entity-store.ts +44 -0
- package/src/storage/memory-frontmatter-metadata.ts +17 -0
- package/src/storage/memory-migration-serialization.ts +37 -0
- package/src/storage/memory-read-store.ts +3 -2
- package/src/storage/profile-header.ts +8 -7
- package/src/storage-profile-timestamp.test.ts +68 -0
- package/src/storage.ts +68 -69
- package/src/types.ts +3 -3
- package/dist/chunk-2RAC4JIG.js.map +0 -1
- package/dist/chunk-4DJQYKMN.js.map +0 -1
- package/dist/chunk-CIQXI47W.js.map +0 -1
- package/dist/chunk-EOLC6EXV.js.map +0 -1
- package/dist/chunk-GJJBPI6I.js.map +0 -1
- package/dist/chunk-HORJVJ6K.js.map +0 -1
- package/dist/chunk-MEBQFQ26.js.map +0 -1
- package/dist/chunk-NUWMZIYZ.js.map +0 -1
- package/dist/chunk-V25OWXAC.js.map +0 -1
- package/dist/chunk-XKO7BM2C.js.map +0 -1
- /package/dist/{capsule-crypto-YO5QJ6L3.js.map → capsule-crypto-7FJQINUR.js.map} +0 -0
- /package/dist/{chunk-7RZJWZ46.js.map → chunk-227UFSEQ.js.map} +0 -0
- /package/dist/{chunk-UT3OQPFA.js.map → chunk-2BEJ4XCF.js.map} +0 -0
- /package/dist/{chunk-BXLOS5AJ.js.map → chunk-2NLLXCJG.js.map} +0 -0
- /package/dist/{chunk-6NNNURLK.js.map → chunk-2PHX3I5C.js.map} +0 -0
- /package/dist/{chunk-RPA2RX5P.js.map → chunk-3BSJBIZ3.js.map} +0 -0
- /package/dist/{chunk-JCVQV6QX.js.map → chunk-3UOSVTFR.js.map} +0 -0
- /package/dist/{chunk-AJ7QCSIS.js.map → chunk-7CPOZH6Y.js.map} +0 -0
- /package/dist/{chunk-U3TH5Q2Q.js.map → chunk-ALTP3MFS.js.map} +0 -0
- /package/dist/{chunk-77CNV7DY.js.map → chunk-BLAKS3CP.js.map} +0 -0
- /package/dist/{chunk-XQ4EH6DI.js.map → chunk-BR4UFMLO.js.map} +0 -0
- /package/dist/{chunk-WEAO45M4.js.map → chunk-DKQM5Q6Q.js.map} +0 -0
- /package/dist/{chunk-CSXHRAJJ.js.map → chunk-EG64LXKL.js.map} +0 -0
- /package/dist/{chunk-PTN6UAUA.js.map → chunk-ES36HTSC.js.map} +0 -0
- /package/dist/{chunk-5BRT4Z2I.js.map → chunk-EZWWCN7I.js.map} +0 -0
- /package/dist/{chunk-XKGPIWGI.js.map → chunk-FBZTWUK5.js.map} +0 -0
- /package/dist/{chunk-FRVTCCGD.js.map → chunk-GJPCP5CA.js.map} +0 -0
- /package/dist/{chunk-VDX2J7OX.js.map → chunk-IPLYGWQF.js.map} +0 -0
- /package/dist/{chunk-YSGBD3QN.js.map → chunk-IYT632D5.js.map} +0 -0
- /package/dist/{chunk-2QSZNTDO.js.map → chunk-JBPKEARU.js.map} +0 -0
- /package/dist/{chunk-RSYJV25N.js.map → chunk-JIF3VRKQ.js.map} +0 -0
- /package/dist/{chunk-EUSLKI4X.js.map → chunk-KKBTBUVT.js.map} +0 -0
- /package/dist/{chunk-RNY3BO35.js.map → chunk-LIHC3T43.js.map} +0 -0
- /package/dist/{chunk-UGH6VPPO.js.map → chunk-MWTMTW2T.js.map} +0 -0
- /package/dist/{chunk-MG6MNSP4.js.map → chunk-MXJ3VP6S.js.map} +0 -0
- /package/dist/{chunk-M5EPMNS4.js.map → chunk-P2CLYN6H.js.map} +0 -0
- /package/dist/{chunk-KGTD2KZJ.js.map → chunk-Q6YJW6KE.js.map} +0 -0
- /package/dist/{chunk-X3SQYAPP.js.map → chunk-R372P2EH.js.map} +0 -0
- /package/dist/{chunk-4MJZTF42.js.map → chunk-RKXZ7P4V.js.map} +0 -0
- /package/dist/{chunk-RYHWZ52A.js.map → chunk-S2BBISHU.js.map} +0 -0
- /package/dist/{chunk-LLISELSY.js.map → chunk-TBMRQZDY.js.map} +0 -0
- /package/dist/{chunk-FMLKOL2Z.js.map → chunk-TC3VNKGX.js.map} +0 -0
- /package/dist/{chunk-7K5Q6COX.js.map → chunk-TVVEYCNW.js.map} +0 -0
- /package/dist/{chunk-JDOJZTFF.js.map → chunk-VFNI3RPT.js.map} +0 -0
- /package/dist/{chunk-EYJSW2RV.js.map → chunk-VYYNBJXH.js.map} +0 -0
- /package/dist/{chunk-BHLN7L7M.js.map → chunk-WVVK2RFM.js.map} +0 -0
- /package/dist/{chunk-DQEMWVMT.js.map → chunk-X7Y7WX73.js.map} +0 -0
- /package/dist/{chunk-HEXSNYJD.js.map → chunk-YOBNCD3Z.js.map} +0 -0
- /package/dist/{chunk-SK3EYPKC.js.map → chunk-ZN4UZWMT.js.map} +0 -0
- /package/dist/{first-start-migration-LEXL3XYL.js.map → first-start-migration-BKNGOFED.js.map} +0 -0
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { readdir, unlink } from "node:fs/promises";
|
|
14
14
|
import path from "node:path";
|
|
15
15
|
import { normalizeEntityStructuredSection, sortStructuredSectionsBySchema } from "../entity-schema.js";
|
|
16
|
+
import { withEntityCanonicalMutationLock } from "./entity-canonical-id-migration.js";
|
|
16
17
|
import { log } from "../logger.js";
|
|
17
18
|
import { getCachedEntities, setCachedEntities } from "../memory-cache.js";
|
|
18
19
|
import type { VersionTrigger } from "../page-versioning.js";
|
|
@@ -78,6 +79,24 @@ export class EntityStore {
|
|
|
78
79
|
} = {},
|
|
79
80
|
): Promise<string> {
|
|
80
81
|
await this.deps.ensureDirectories();
|
|
82
|
+
return withEntityCanonicalMutationLock(
|
|
83
|
+
path.join(this.deps.baseDir, "state"),
|
|
84
|
+
() => this.writeEntityUnlocked(name, type, facts, options),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private async writeEntityUnlocked(
|
|
89
|
+
name: string,
|
|
90
|
+
type: string,
|
|
91
|
+
facts: string[],
|
|
92
|
+
options: {
|
|
93
|
+
timestamp?: string;
|
|
94
|
+
source?: string;
|
|
95
|
+
sessionKey?: string;
|
|
96
|
+
principal?: string;
|
|
97
|
+
structuredSections?: EntityStructuredSection[];
|
|
98
|
+
} = {},
|
|
99
|
+
): Promise<string> {
|
|
81
100
|
if (typeof name !== "string" || !name.trim() || typeof type !== "string" || !type.trim()) {
|
|
82
101
|
log.warn("writeEntity: invalid entity payload, skipping", {
|
|
83
102
|
nameType: typeof name,
|
|
@@ -238,6 +257,24 @@ export class EntityStore {
|
|
|
238
257
|
updatedAt?: string;
|
|
239
258
|
incrementVersion?: boolean;
|
|
240
259
|
} = {},
|
|
260
|
+
): Promise<void> {
|
|
261
|
+
return withEntityCanonicalMutationLock(
|
|
262
|
+
path.join(this.deps.baseDir, "state"),
|
|
263
|
+
() => this.updateEntitySynthesisUnlocked(name, synthesis, options),
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
private async updateEntitySynthesisUnlocked(
|
|
268
|
+
name: string,
|
|
269
|
+
synthesis: string,
|
|
270
|
+
options: {
|
|
271
|
+
entityUpdatedAt?: string;
|
|
272
|
+
synthesisStructuredFactCount?: number;
|
|
273
|
+
synthesisStructuredFactDigest?: string;
|
|
274
|
+
synthesisTimelineCount?: number;
|
|
275
|
+
updatedAt?: string;
|
|
276
|
+
incrementVersion?: boolean;
|
|
277
|
+
} = {},
|
|
241
278
|
): Promise<void> {
|
|
242
279
|
const filePath = path.join(this.deps.entitiesDir, `${name}.md`);
|
|
243
280
|
let entity: EntityFile;
|
|
@@ -407,6 +444,13 @@ export class EntityStore {
|
|
|
407
444
|
* Returns count of files merged.
|
|
408
445
|
*/
|
|
409
446
|
async mergeFragmentedEntities(): Promise<number> {
|
|
447
|
+
return withEntityCanonicalMutationLock(
|
|
448
|
+
path.join(this.deps.baseDir, "state"),
|
|
449
|
+
() => this.mergeFragmentedEntitiesUnlocked(),
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
private async mergeFragmentedEntitiesUnlocked(): Promise<number> {
|
|
410
454
|
let merged = 0;
|
|
411
455
|
try {
|
|
412
456
|
const entries = await readdir(this.deps.entitiesDir);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type RawFrontmatterOwner = object;
|
|
2
|
+
|
|
3
|
+
const rawFrontmatterByMemory = new WeakMap<RawFrontmatterOwner, string>();
|
|
4
|
+
|
|
5
|
+
export function extractRawFrontmatter(raw: string): string | null {
|
|
6
|
+
return raw.match(/^---\n([\s\S]*?)\n---\n?/)?.[1] ?? null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function rememberRawFrontmatter<T extends RawFrontmatterOwner>(owner: T, raw: string): T {
|
|
10
|
+
const frontmatter = extractRawFrontmatter(raw);
|
|
11
|
+
if (frontmatter !== null) rawFrontmatterByMemory.set(owner, frontmatter);
|
|
12
|
+
return owner;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function readRawFrontmatter(owner: RawFrontmatterOwner): string | undefined {
|
|
16
|
+
return rawFrontmatterByMemory.get(owner);
|
|
17
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { MemoryFile, MemoryFrontmatter } from "../types.js";
|
|
2
|
+
import { readRawFrontmatter } from "./memory-frontmatter-metadata.js";
|
|
3
|
+
|
|
4
|
+
export type MemoryEntityRefSerializer = (memory: MemoryFile, entityRef: string) => string;
|
|
5
|
+
|
|
6
|
+
export function serializeMemoryWithEntityRef(
|
|
7
|
+
memory: MemoryFile,
|
|
8
|
+
entityRef: string,
|
|
9
|
+
fallback: MemoryEntityRefSerializer,
|
|
10
|
+
): string {
|
|
11
|
+
const rawFrontmatter = readRawFrontmatter(memory);
|
|
12
|
+
if (rawFrontmatter === undefined) return fallback(memory, entityRef);
|
|
13
|
+
const lines = rawFrontmatter.split("\n");
|
|
14
|
+
let entityRefLine = -1;
|
|
15
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
16
|
+
if (/^\s*entityRef\s*:/.test(lines[index] ?? "")) entityRefLine = index;
|
|
17
|
+
}
|
|
18
|
+
if (entityRefLine >= 0) {
|
|
19
|
+
const indent = lines[entityRefLine]!.match(/^\s*/)?.[0] ?? "";
|
|
20
|
+
lines[entityRefLine] = `${indent}entityRef: ${entityRef}`;
|
|
21
|
+
} else {
|
|
22
|
+
lines.push(`entityRef: ${entityRef}`);
|
|
23
|
+
}
|
|
24
|
+
return `---\n${lines.join("\n")}\n---\n\n${memory.content}\n`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function createMemoryEntityRefSerializer(
|
|
28
|
+
serializeFrontmatter: (frontmatter: MemoryFrontmatter) => string,
|
|
29
|
+
): MemoryEntityRefSerializer {
|
|
30
|
+
return (memory, entityRef) =>
|
|
31
|
+
serializeMemoryWithEntityRef(
|
|
32
|
+
memory,
|
|
33
|
+
entityRef,
|
|
34
|
+
(fallbackMemory, fallbackEntityRef) =>
|
|
35
|
+
`${serializeFrontmatter({ ...fallbackMemory.frontmatter, entityRef: fallbackEntityRef })}\n\n${fallbackMemory.content}\n`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
parseFrontmatter,
|
|
27
27
|
StorageManager,
|
|
28
28
|
} from "../storage.js";
|
|
29
|
+
import { rememberRawFrontmatter } from "./memory-frontmatter-metadata.js";
|
|
29
30
|
|
|
30
31
|
export interface MemoryReadStoreDeps {
|
|
31
32
|
/** Live class object of the host instance — shared static caches (see storage.ts storageManagerClass). */
|
|
@@ -495,7 +496,7 @@ export class MemoryReadStore {
|
|
|
495
496
|
// but SecureStoreLockedError must propagate — see re-throw below.
|
|
496
497
|
const parsed = parseFrontmatter(raw);
|
|
497
498
|
if (parsed) {
|
|
498
|
-
return {
|
|
499
|
+
return rememberRawFrontmatter({
|
|
499
500
|
path: filePath,
|
|
500
501
|
frontmatter: normalizeFrontmatterForPath(
|
|
501
502
|
parsed.frontmatter,
|
|
@@ -503,7 +504,7 @@ export class MemoryReadStore {
|
|
|
503
504
|
parsed.content,
|
|
504
505
|
),
|
|
505
506
|
content: parsed.content,
|
|
506
|
-
};
|
|
507
|
+
}, raw);
|
|
507
508
|
}
|
|
508
509
|
|
|
509
510
|
// Entity files use a `# Name` + `**Type:** ...` markdown format rather than
|
|
@@ -7,12 +7,12 @@ const MARKDOWN_THEMATIC_BREAK = /^(?:(?:\*[ \t]*){3,}|(?:-[ \t]*){3,}|(?:_[ \t]*
|
|
|
7
7
|
const MARKDOWN_SETEXT_UNDERLINE = /^(?:=+|-+)$/;
|
|
8
8
|
const MARKDOWN_BLOCK_QUOTE = /^>/;
|
|
9
9
|
const MARKDOWN_LINK_REFERENCE =
|
|
10
|
-
/^\[(?:\\.|[^\\\[\]])+\]
|
|
11
|
-
const MARKDOWN_LINK_REFERENCE_LABEL = /^\[(?:\\.|[^\\\[\]])+\]
|
|
10
|
+
/^\[(?:\\.|[^\\\[\]])+\]:[ \t]*(?:<[^>\n]*>|([^\s]+))(?:[ \t]+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?$/;
|
|
11
|
+
const MARKDOWN_LINK_REFERENCE_LABEL = /^\[(?:\\.|[^\\\[\]])+\]:[ \t]*$/;
|
|
12
12
|
const MARKDOWN_LINK_REFERENCE_CONTINUATION =
|
|
13
13
|
/^ {1,3}(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\))$/;
|
|
14
14
|
const MARKDOWN_LINK_REFERENCE_DESTINATION_CONTINUATION =
|
|
15
|
-
/^ {1,3}(?:<[^>\n]*>|(?!["'(])[^\s]+(
|
|
15
|
+
/^ {1,3}(?:<[^>\n]*>|(?!["'(])[^\s]+(?:[ \t]+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?)$/;
|
|
16
16
|
const UTF8_BOM = "\uFEFF";
|
|
17
17
|
|
|
18
18
|
type FenceMarker = {
|
|
@@ -440,10 +440,11 @@ function canStartGenericHtmlBlock(
|
|
|
440
440
|
const previousLine = lines[index - 1]?.content.trim() ?? "";
|
|
441
441
|
if (previousLine === "") return true;
|
|
442
442
|
return (
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
443
|
+
isCompletedIndentedCodeBlock(lines, index) ||
|
|
444
|
+
(isMetadataBoundary(previousLine, previousHtmlTerminator) &&
|
|
445
|
+
!isLastUpdatedHeader(previousLine) &&
|
|
446
|
+
!MARKDOWN_LIST_ITEM.test(previousLine) &&
|
|
447
|
+
!MARKDOWN_BLOCK_QUOTE.test(previousLine))
|
|
447
448
|
);
|
|
448
449
|
}
|
|
449
450
|
|
|
@@ -819,6 +819,38 @@ test("writeProfile recognizes a completed indented code block before metadata",
|
|
|
819
819
|
t.mock.timers.reset();
|
|
820
820
|
}
|
|
821
821
|
});
|
|
822
|
+
test("writeProfile treats generic HTML after completed indented code as opaque", async (t) => {
|
|
823
|
+
t.mock.timers.enable({ apis: ["Date"], now: Date.parse(WRITE_TIME) });
|
|
824
|
+
try {
|
|
825
|
+
await withMemoryDir(async (dir) => {
|
|
826
|
+
const storage = new StorageManager(dir);
|
|
827
|
+
const profile = [
|
|
828
|
+
"# Behavioral Profile",
|
|
829
|
+
"",
|
|
830
|
+
" code example",
|
|
831
|
+
"<custom>",
|
|
832
|
+
"# Embedded heading",
|
|
833
|
+
"",
|
|
834
|
+
"*Last updated: literal inside HTML*",
|
|
835
|
+
"</custom>",
|
|
836
|
+
"",
|
|
837
|
+
STALE_HEADER,
|
|
838
|
+
"",
|
|
839
|
+
"- Keeps metadata after generic HTML.",
|
|
840
|
+
"",
|
|
841
|
+
].join("\n");
|
|
842
|
+
|
|
843
|
+
await storage.writeProfile(profile);
|
|
844
|
+
|
|
845
|
+
assert.equal(
|
|
846
|
+
await storage.readProfile(),
|
|
847
|
+
profile.replace(STALE_HEADER, FRESH_HEADER),
|
|
848
|
+
);
|
|
849
|
+
});
|
|
850
|
+
} finally {
|
|
851
|
+
t.mock.timers.reset();
|
|
852
|
+
}
|
|
853
|
+
});
|
|
822
854
|
test("writeProfile recognizes standalone headers with Markdown indentation", async (t) => {
|
|
823
855
|
t.mock.timers.enable({ apis: ["Date"], now: Date.parse(WRITE_TIME) });
|
|
824
856
|
try {
|
|
@@ -1264,6 +1296,42 @@ test("writeProfile recognizes link reference definitions as metadata boundaries"
|
|
|
1264
1296
|
t.mock.timers.reset();
|
|
1265
1297
|
}
|
|
1266
1298
|
});
|
|
1299
|
+
test("writeProfile ignores non-breaking spaces as link-reference separators", async (t) => {
|
|
1300
|
+
t.mock.timers.enable({ apis: ["Date"], now: Date.parse(WRITE_TIME) });
|
|
1301
|
+
try {
|
|
1302
|
+
await withMemoryDir(async (dir) => {
|
|
1303
|
+
const storage = new StorageManager(dir);
|
|
1304
|
+
const profile = [
|
|
1305
|
+
"# Behavioral Profile",
|
|
1306
|
+
"",
|
|
1307
|
+
"[docs]:\u00a0/url",
|
|
1308
|
+
STALE_HEADER,
|
|
1309
|
+
"",
|
|
1310
|
+
"- Keeps ordinary paragraph content.",
|
|
1311
|
+
"",
|
|
1312
|
+
].join("\n");
|
|
1313
|
+
|
|
1314
|
+
await storage.writeProfile(profile);
|
|
1315
|
+
|
|
1316
|
+
assert.equal(
|
|
1317
|
+
await storage.readProfile(),
|
|
1318
|
+
[
|
|
1319
|
+
"# Behavioral Profile",
|
|
1320
|
+
"",
|
|
1321
|
+
FRESH_HEADER,
|
|
1322
|
+
"",
|
|
1323
|
+
"[docs]:\u00a0/url",
|
|
1324
|
+
STALE_HEADER,
|
|
1325
|
+
"",
|
|
1326
|
+
"- Keeps ordinary paragraph content.",
|
|
1327
|
+
"",
|
|
1328
|
+
].join("\n"),
|
|
1329
|
+
);
|
|
1330
|
+
});
|
|
1331
|
+
} finally {
|
|
1332
|
+
t.mock.timers.reset();
|
|
1333
|
+
}
|
|
1334
|
+
});
|
|
1267
1335
|
|
|
1268
1336
|
test("writeProfile stops nested-list context at an intervening document paragraph", async (t) => {
|
|
1269
1337
|
t.mock.timers.enable({ apis: ["Date"], now: Date.parse(WRITE_TIME) });
|
package/src/storage.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { readProjectionRebuiltAt } from "./maintenance/projection-support.js";
|
|
2
2
|
import {
|
|
3
|
-
access,
|
|
4
3
|
lstat,
|
|
5
4
|
readdir,
|
|
6
5
|
readFile,
|
|
@@ -9,7 +8,6 @@ import {
|
|
|
9
8
|
writeFile,
|
|
10
9
|
mkdir,
|
|
11
10
|
unlink,
|
|
12
|
-
rename,
|
|
13
11
|
appendFile,
|
|
14
12
|
open,
|
|
15
13
|
} from "node:fs/promises";
|
|
@@ -35,10 +33,17 @@ import {
|
|
|
35
33
|
import { selfDeps } from "./orchestration/self-deps.js";
|
|
36
34
|
import { EntityStore } from "./storage/entity-store.js";
|
|
37
35
|
import { IdentityContinuityStore } from "./storage/identity-continuity-store.js";
|
|
36
|
+
import * as entityMigration from "./storage/entity-canonical-id-migration.js";
|
|
37
|
+
import {
|
|
38
|
+
runLegacyEntityCanonicalIdMigration,
|
|
39
|
+
type EntityCanonicalIdMigrationHost,
|
|
40
|
+
} from "./storage/entity-canonical-id-migration-adapter.js";
|
|
41
|
+
import { EntityCanonicalIdMigrationRunner } from "./storage/entity-canonical-id-migration-runner.js";
|
|
42
|
+
import { rememberRawFrontmatter } from "./storage/memory-frontmatter-metadata.js";
|
|
43
|
+
import { createMemoryEntityRefSerializer } from "./storage/memory-migration-serialization.js";
|
|
44
|
+
export { normalizeEntityName } from "./entity-id-normalization.js";
|
|
38
45
|
import { isErrnoCode } from "./utils/errno.js";
|
|
39
|
-
import {
|
|
40
|
-
import { RECALL_FALLBACK_DIRS, getCategoryDir, categoryDirName } from "./utils/category-dir.js";
|
|
41
|
-
import { assertPathInsideRoot } from "./utils/path-containment.js";
|
|
46
|
+
import { getCategoryDir, categoryDirName } from "./utils/category-dir.js";
|
|
42
47
|
import { decodeYamlScalar } from "./utils/yaml-scalar.js";
|
|
43
48
|
import {
|
|
44
49
|
qmdCollectionPathParts,
|
|
@@ -1095,52 +1100,6 @@ function inferCurrentStateStatus(
|
|
|
1095
1100
|
return inferMemoryStatus(frontmatter, pathRel, fallbackStatus);
|
|
1096
1101
|
}
|
|
1097
1102
|
|
|
1098
|
-
/** Built-in aliases for common structural normalizations (no personal data) */
|
|
1099
|
-
const BUILTIN_ALIASES: Record<string, string> = {
|
|
1100
|
-
openclaw: "openclaw",
|
|
1101
|
-
"open-claw": "openclaw",
|
|
1102
|
-
};
|
|
1103
|
-
|
|
1104
|
-
/**
|
|
1105
|
-
* Normalize an entity name to a canonical form.
|
|
1106
|
-
* Strips non-alphanumeric chars, collapses hyphens, removes type prefix duplication.
|
|
1107
|
-
* e.g. "My Project" → "my-project"
|
|
1108
|
-
*
|
|
1109
|
-
* Checks caller-provided user aliases first, then built-in aliases. Alias
|
|
1110
|
-
* tables are instance state on StorageManager (issue #1534) — use
|
|
1111
|
-
* `storageManager.normalizeEntityName(raw, type)` when normalizing within a
|
|
1112
|
-
* store, or pass `storageManager.entityAliases` explicitly. Without an
|
|
1113
|
-
* aliases argument only the built-in structural aliases apply.
|
|
1114
|
-
*/
|
|
1115
|
-
export function normalizeEntityName(raw: string, type: string, aliases?: Readonly<Record<string, string>>): string {
|
|
1116
|
-
// Strip type prefix if present (e.g. name="person-jane-doe", type="person")
|
|
1117
|
-
const rawStr = typeof raw === "string" ? raw : "";
|
|
1118
|
-
const typeStr = typeof type === "string" && type.trim().length > 0 ? type : "entity";
|
|
1119
|
-
|
|
1120
|
-
let name = rawStr.toLowerCase().trim();
|
|
1121
|
-
const typePrefix = `${typeStr.toLowerCase()}-`;
|
|
1122
|
-
if (name.startsWith(typePrefix)) {
|
|
1123
|
-
name = name.slice(typePrefix.length);
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
// Replace non-alphanumeric with hyphens, collapse multiples, trim edges
|
|
1127
|
-
let normalized = name
|
|
1128
|
-
.replace(/[^a-z0-9]+/g, "-")
|
|
1129
|
-
.replace(/-+/g, "-")
|
|
1130
|
-
.replace(/^-|-$/g, "");
|
|
1131
|
-
|
|
1132
|
-
// Check caller-provided user aliases first, then built-in. Own-property and
|
|
1133
|
-
// string guards keep inherited object keys (e.g. an entity literally named
|
|
1134
|
-
// "constructor") and malformed alias values from corrupting canonical ids.
|
|
1135
|
-
const userAlias = aliases !== undefined && Object.hasOwn(aliases, normalized) ? aliases[normalized] : undefined;
|
|
1136
|
-
if (typeof userAlias === "string" && userAlias.length > 0) {
|
|
1137
|
-
normalized = userAlias;
|
|
1138
|
-
} else if (Object.hasOwn(BUILTIN_ALIASES, normalized)) {
|
|
1139
|
-
normalized = BUILTIN_ALIASES[normalized];
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
return `${typeStr.toLowerCase()}-${normalized}`;
|
|
1143
|
-
}
|
|
1144
1103
|
|
|
1145
1104
|
/**
|
|
1146
1105
|
* Simple Levenshtein distance between two strings.
|
|
@@ -2135,24 +2094,39 @@ export class StorageManager {
|
|
|
2135
2094
|
* Set or clear the at-rest encryption key.
|
|
2136
2095
|
*
|
|
2137
2096
|
* Pass a 32-byte Buffer to enable encryption; pass null to clear
|
|
2138
|
-
* (lock) the store.
|
|
2097
|
+
* (lock) the store. The caller is responsible for key lifecycle —
|
|
2139
2098
|
* this method does not zero the buffer on replacement; the keyring
|
|
2140
|
-
* module (`keyring.ts`) owns zeroization.
|
|
2099
|
+
* module (`keyring.ts`) owns zeroization. The setter remains synchronous
|
|
2100
|
+
* for existing consumers; call `setSecureStoreKeyAndWait` when unlock must
|
|
2101
|
+
* await migration.
|
|
2141
2102
|
*/
|
|
2142
2103
|
setSecureStoreKey(key: Buffer | null, encryptOnWrite = true): void {
|
|
2104
|
+
if (!this.applySecureStoreKey(key, encryptOnWrite) || key === null) return;
|
|
2105
|
+
void this.entityCanonicalIdMigration.triggerAfterUnlock().catch((error: unknown) => {
|
|
2106
|
+
log.warn(
|
|
2107
|
+
`secure-store unlock migration failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
2108
|
+
);
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
public async setSecureStoreKeyAndWait(key: Buffer | null, encryptOnWrite = true): Promise<void> {
|
|
2113
|
+
if (!this.applySecureStoreKey(key, encryptOnWrite) || key === null) return;
|
|
2114
|
+
await this.entityCanonicalIdMigration.triggerAfterUnlock();
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
private applySecureStoreKey(key: Buffer | null, encryptOnWrite: boolean): boolean {
|
|
2118
|
+
const sameKey =
|
|
2119
|
+
this._secureStoreKey === key ||
|
|
2120
|
+
(this._secureStoreKey !== null && key !== null && this._secureStoreKey.equals(key));
|
|
2121
|
+
if (sameKey && this._secureStoreEncryptOnWrite === encryptOnWrite) return false;
|
|
2122
|
+
|
|
2143
2123
|
this._secureStoreKey = key;
|
|
2144
2124
|
this._secureStoreEncryptOnWrite = encryptOnWrite;
|
|
2145
|
-
// Route through the invalidation chokepoint (issue #1535): a key change
|
|
2146
|
-
// (or store lock) must evict every cache layer that may hold content
|
|
2147
|
-
// decrypted under the previous key, not just the entity layer.
|
|
2148
2125
|
invalidateAllForDir(this.baseDir);
|
|
2149
2126
|
this.invalidateKnowledgeIndexCache();
|
|
2150
|
-
// A key change flips resolveWriteKey(), so a file's plain/encrypted class on
|
|
2151
|
-
// the next full rewrite may differ from what was cached (issue #1909).
|
|
2152
2127
|
this.secureFileEncryptionSniffCache.clear();
|
|
2153
|
-
// Same rationale for the behavior-signals dedup key cache (issue #1909):
|
|
2154
|
-
// drop it on a key change so a re-encrypted/re-decrypted ledger is reloaded.
|
|
2155
2128
|
this.behaviorSignalsKeyCache = null;
|
|
2129
|
+
return true;
|
|
2156
2130
|
}
|
|
2157
2131
|
|
|
2158
2132
|
private getEntityCacheSecureStoreKey(): string {
|
|
@@ -2340,6 +2314,7 @@ export class StorageManager {
|
|
|
2340
2314
|
// loadAliases() explicitly — every creation path must still get the
|
|
2341
2315
|
// store's own aliases, never an empty or foreign table.
|
|
2342
2316
|
this.loadAliasesSync();
|
|
2317
|
+
this.loadHistoricalEntityCanonicalIdsSync();
|
|
2343
2318
|
}
|
|
2344
2319
|
|
|
2345
2320
|
/** Set the process-wide hot-memories cache default (issue #1902). The
|
|
@@ -3597,9 +3572,17 @@ export class StorageManager {
|
|
|
3597
3572
|
* store loaded last rewrite every other store's canonical entity ids.
|
|
3598
3573
|
*/
|
|
3599
3574
|
private userAliases: Record<string, string> = {};
|
|
3600
|
-
|
|
3575
|
+
private historicalEntityCanonicalIds: Readonly<Record<string, string>> = {};
|
|
3576
|
+
private readonly entityCanonicalIdMigration = new EntityCanonicalIdMigrationRunner(
|
|
3577
|
+
() => !(this._secureStoreRequired && !this.isSecureStoreUnlocked()),
|
|
3578
|
+
() => this.runLegacyEntityCanonicalIdMigration(),
|
|
3579
|
+
() => entityMigration.getFingerprint(this.baseDir, this.entitiesDir, () => this.getCorpusScanVersion()),
|
|
3580
|
+
);
|
|
3601
3581
|
normalizeEntityName(raw: string, type: string): string {
|
|
3602
|
-
return
|
|
3582
|
+
return entityMigration.resolveHistoricalEntityCanonicalId(
|
|
3583
|
+
this.entityStore.normalizeEntityName(raw, type),
|
|
3584
|
+
this.historicalEntityCanonicalIds,
|
|
3585
|
+
);
|
|
3603
3586
|
}
|
|
3604
3587
|
|
|
3605
3588
|
/**
|
|
@@ -3646,8 +3629,24 @@ export class StorageManager {
|
|
|
3646
3629
|
log.debug("no config/aliases.json found — using built-in aliases only");
|
|
3647
3630
|
}
|
|
3648
3631
|
}
|
|
3632
|
+
private loadHistoricalEntityCanonicalIdsSync(): void {
|
|
3633
|
+
this.historicalEntityCanonicalIds = entityMigration.loadHistoricalEntityCanonicalIds(this.stateDir);
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
private async runLegacyEntityCanonicalIdMigration(): Promise<string> {
|
|
3637
|
+
const completionFingerprint = await runLegacyEntityCanonicalIdMigration(
|
|
3638
|
+
this as unknown as EntityCanonicalIdMigrationHost,
|
|
3639
|
+
(content) => parseEntityFile(content, this.entitySchemas),
|
|
3640
|
+
(entity) => serializeEntityFile(entity, this.entitySchemas),
|
|
3641
|
+
createMemoryEntityRefSerializer(serializeFrontmatter),
|
|
3642
|
+
);
|
|
3643
|
+
this.loadHistoricalEntityCanonicalIdsSync();
|
|
3644
|
+
return completionFingerprint;
|
|
3645
|
+
}
|
|
3649
3646
|
|
|
3650
3647
|
async ensureDirectories(): Promise<void> {
|
|
3648
|
+
await mkdir(this.baseDir, { recursive: true });
|
|
3649
|
+
await entityMigration.validateRoots(this.baseDir, this.entitiesDir, this.stateDir, this.archiveDir);
|
|
3651
3650
|
const today = new Date().toISOString().slice(0, 10);
|
|
3652
3651
|
await mkdir(path.join(this.factsDir, today), { recursive: true });
|
|
3653
3652
|
await mkdir(path.join(this.proceduresDir, today), { recursive: true });
|
|
@@ -3662,6 +3661,7 @@ export class StorageManager {
|
|
|
3662
3661
|
await mkdir(this.identityAuditsWeeklyDir, { recursive: true });
|
|
3663
3662
|
await mkdir(this.identityAuditsMonthlyDir, { recursive: true });
|
|
3664
3663
|
await mkdir(path.join(this.baseDir, "config"), { recursive: true });
|
|
3664
|
+
await this.entityCanonicalIdMigration.ensure();
|
|
3665
3665
|
// Activate the corpus sentinel at setup (issue #1902, Cursor Medium): an
|
|
3666
3666
|
// existing corpus predating this feature has a size-0/absent sentinel, which
|
|
3667
3667
|
// getCachedMemories treats as a miss — so a read-heavy workload would never
|
|
@@ -3675,6 +3675,7 @@ export class StorageManager {
|
|
|
3675
3675
|
if (this.hotMemoriesCacheEnabled && this.getMemoryCorpusVersion() === 0) {
|
|
3676
3676
|
this.bumpMemoryCorpusVersion();
|
|
3677
3677
|
}
|
|
3678
|
+
await this.entityCanonicalIdMigration.markDirectoriesInitialized();
|
|
3678
3679
|
}
|
|
3679
3680
|
|
|
3680
3681
|
/**
|
|
@@ -4682,7 +4683,7 @@ export class StorageManager {
|
|
|
4682
4683
|
const raw = await readMaybeEncryptedFile(fullPath, this._secureStoreKey, this.baseDir);
|
|
4683
4684
|
const parsed = parseFrontmatter(raw);
|
|
4684
4685
|
if (!parsed) return null;
|
|
4685
|
-
return {
|
|
4686
|
+
return rememberRawFrontmatter({
|
|
4686
4687
|
path: fullPath,
|
|
4687
4688
|
frontmatter: normalizeFrontmatterForPath(
|
|
4688
4689
|
parsed.frontmatter,
|
|
@@ -4690,7 +4691,7 @@ export class StorageManager {
|
|
|
4690
4691
|
parsed.content
|
|
4691
4692
|
),
|
|
4692
4693
|
content: parsed.content,
|
|
4693
|
-
} satisfies MemoryFile;
|
|
4694
|
+
} satisfies MemoryFile, raw);
|
|
4694
4695
|
} catch (err) {
|
|
4695
4696
|
// Re-throw store-locked errors so a locked encrypted store fails
|
|
4696
4697
|
// loudly rather than appearing as an empty memory corpus (Cursor
|
|
@@ -4841,7 +4842,7 @@ export class StorageManager {
|
|
|
4841
4842
|
const raw = await readMaybeEncryptedFile(fullPath, this._secureStoreKey, this.baseDir);
|
|
4842
4843
|
const parsed = parseFrontmatter(raw);
|
|
4843
4844
|
if (parsed) {
|
|
4844
|
-
memories.push({
|
|
4845
|
+
memories.push(rememberRawFrontmatter({
|
|
4845
4846
|
path: fullPath,
|
|
4846
4847
|
frontmatter: normalizeFrontmatterForPath(
|
|
4847
4848
|
parsed.frontmatter,
|
|
@@ -4849,7 +4850,7 @@ export class StorageManager {
|
|
|
4849
4850
|
parsed.content
|
|
4850
4851
|
),
|
|
4851
4852
|
content: parsed.content,
|
|
4852
|
-
});
|
|
4853
|
+
}, raw));
|
|
4853
4854
|
}
|
|
4854
4855
|
} catch (err) {
|
|
4855
4856
|
// Re-throw store-locked errors — a locked encrypted store
|
|
@@ -6133,9 +6134,6 @@ export class StorageManager {
|
|
|
6133
6134
|
this.invalidateKnowledgeIndexCache();
|
|
6134
6135
|
}
|
|
6135
6136
|
|
|
6136
|
-
/**
|
|
6137
|
-
* Add an alias to an entity file. Deduplicates.
|
|
6138
|
-
*/
|
|
6139
6137
|
async addEntityAlias(name: string, alias: string): Promise<void> {
|
|
6140
6138
|
const filePath = path.join(this.entitiesDir, `${name}.md`);
|
|
6141
6139
|
let entity: EntityFile;
|
|
@@ -6154,6 +6152,7 @@ export class StorageManager {
|
|
|
6154
6152
|
entity.updated = new Date().toISOString();
|
|
6155
6153
|
await this.writeStorageSecureFile(filePath, serializeEntityFile(entity, this.entitySchemas));
|
|
6156
6154
|
this.invalidateKnowledgeIndexCache();
|
|
6155
|
+
this.bumpMemoryStatusVersion();
|
|
6157
6156
|
}
|
|
6158
6157
|
|
|
6159
6158
|
async updateEntitySynthesis(
|
package/src/types.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { MeetingsConfig } from "./meetings/types.js";
|
|
|
3
3
|
import type { ActivityConfig } from "./activity/types.js";
|
|
4
4
|
import type { WearablesConfig } from "./wearables/types.js";
|
|
5
5
|
import type { ExtractionLivenessConfig } from "./extraction-liveness.js";
|
|
6
|
+
import type { ReplicaPeersConfig } from "./replica-peers-config.js";
|
|
6
7
|
|
|
7
8
|
export type ReasoningEffort = "none" | "low" | "medium" | "high";
|
|
8
9
|
export type TriggerMode = "smart" | "every_n" | "time_based";
|
|
@@ -1208,9 +1209,8 @@ export interface PluginConfig extends BoundedJsonlStateConfig {
|
|
|
1208
1209
|
dreamsPhases: DreamsPhasesConfig;
|
|
1209
1210
|
procedural: ProceduralConfig;
|
|
1210
1211
|
extractionLiveness: ExtractionLivenessConfig;
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
*/
|
|
1212
|
+
replicaPeers: ReplicaPeersConfig;
|
|
1213
|
+
/** Claim-level provenance spans (#1575); see `ProvenanceConfig` for defaults. */
|
|
1214
1214
|
provenance: ProvenanceConfig;
|
|
1215
1215
|
/**
|
|
1216
1216
|
* Wearable transcript ingestion (Limitless / Bee / Omi connectors).
|