@remnic/core 9.54.5 → 9.54.7
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 +24 -24
- package/dist/access-admin-ops-surface.js +32 -29
- package/dist/access-authorization-probe.d.ts +25 -23
- package/dist/access-authorization-probe.js +35 -30
- package/dist/access-boundary.d.ts +26 -24
- package/dist/access-boundary.js +36 -31
- package/dist/access-cli.js +86 -80
- 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 +19 -19
- package/dist/access-extraction-force-flush.js +32 -29
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +22 -22
- package/dist/access-http-lifecycle-flush.d.ts +22 -22
- package/dist/access-http-offline-stream.d.ts +18 -18
- package/dist/access-http-query.js +32 -29
- package/dist/access-http.d.ts +55 -37
- package/dist/access-http.js +52 -43
- package/dist/access-identity-continuity-surface.d.ts +9 -9
- package/dist/access-identity-continuity-surface.js +32 -29
- package/dist/access-lcm-surface.d.ts +21 -21
- package/dist/access-lcm-surface.js +32 -29
- package/dist/access-mcp.d.ts +22 -22
- package/dist/access-mcp.js +40 -36
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-BdHlGd_T.d.ts → access-namespace-preflight-CCNn_6NE.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +32 -29
- package/dist/access-observe-write-surface.d.ts +22 -22
- package/dist/access-observe-write-surface.js +32 -29
- package/dist/access-offline-manifest.d.ts +9 -9
- package/dist/access-offline-manifest.js +2 -2
- package/dist/access-operations-batch.js +34 -31
- package/dist/access-operations.d.ts +23 -23
- package/dist/access-operations.js +38 -34
- package/dist/access-recall-concurrency.d.ts +21 -21
- package/dist/access-recall-concurrency.js +32 -29
- package/dist/access-recall-response.d.ts +19 -19
- package/dist/access-recall-response.js +32 -29
- package/dist/access-recall-surface.d.ts +19 -19
- package/dist/access-recall-surface.js +32 -29
- package/dist/access-schema.js +3 -3
- package/dist/{access-service-DL7X9hrg.d.ts → access-service-DK82xdNi.d.ts} +1314 -83
- package/dist/access-service-helpers.d.ts +22 -22
- package/dist/access-service.d.ts +31 -31
- package/dist/access-service.js +32 -29
- package/dist/access-surface-catalog.d.ts +22 -22
- package/dist/access-surface-catalog.js +209 -2
- package/dist/access-surface-catalog.js.map +1 -1
- 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 +6 -5
- package/dist/active-memory-bridge.js +2 -2
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +2 -1
- package/dist/active-recall.js.map +1 -1
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/registry.js +2 -2
- package/dist/admin-console/public/what-helps-me/app.js +1594 -0
- package/dist/admin-console/public/what-helps-me/index.html +339 -0
- package/dist/admin-console/public/what-helps-me/model.js +685 -0
- package/dist/admin-console/public/what-helps-me/what-helps-me.css +1296 -0
- package/dist/ambient-provenance.d.ts +1 -1
- package/dist/artifact-search.d.ts +1 -1
- package/dist/{auto-sync-TDHLZPVP.js → auto-sync-NR3GPCOA.js} +4 -4
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +9 -9
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +14 -14
- 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/buffer.js +2 -2
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/calibration.js +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{catalog-B90is4d8.d.ts → catalog-DGFf8mD9.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 +15 -15
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/{chunk-CSY44OKU.js → chunk-26ZXBTYN.js} +4 -4
- package/dist/chunk-26ZXBTYN.js.map +1 -0
- package/dist/{chunk-LLJMAULE.js → chunk-2FKEIPIT.js} +5 -5
- package/dist/{chunk-AU7Q3LSC.js → chunk-2QSZNTDO.js} +4 -4
- package/dist/chunk-37DZZFFM.js +502 -0
- package/dist/chunk-37DZZFFM.js.map +1 -0
- package/dist/chunk-3HSRWJTC.js +9 -0
- package/dist/chunk-3HSRWJTC.js.map +1 -0
- package/dist/{chunk-TKFGFDPJ.js → chunk-3TIZPSJC.js} +4 -4
- package/dist/{chunk-B4T3FQMT.js → chunk-43SEBY2M.js} +1 -1
- package/dist/{chunk-LVKYLMSM.js → chunk-46SZBVDS.js} +2 -2
- package/dist/{chunk-YKZLOPTC.js → chunk-5FD7JMTX.js} +2 -2
- package/dist/{chunk-2PNXOQ4P.js → chunk-5NB726GV.js} +3 -7
- package/dist/chunk-5NB726GV.js.map +1 -0
- package/dist/chunk-62OKGIJA.js +39 -0
- package/dist/chunk-62OKGIJA.js.map +1 -0
- package/dist/{chunk-WM5LD6AT.js → chunk-6CYHUWCO.js} +2 -2
- package/dist/{chunk-BIF4SHMD.js → chunk-76JJSXK7.js} +1 -1
- package/dist/chunk-76JJSXK7.js.map +1 -0
- package/dist/{chunk-3SXLD5T3.js → chunk-7BD6O7ZV.js} +189 -4
- package/dist/chunk-7BD6O7ZV.js.map +1 -0
- package/dist/chunk-7TBXNYLO.js +346 -0
- package/dist/chunk-7TBXNYLO.js.map +1 -0
- package/dist/{chunk-YR65W7BV.js → chunk-BRR5EUTF.js} +3 -3
- package/dist/{chunk-JKW663ZN.js → chunk-CIAI24TQ.js} +2 -2
- package/dist/{chunk-3WGI7F4V.js → chunk-D3LBIUWV.js} +9219 -5233
- package/dist/chunk-D3LBIUWV.js.map +1 -0
- package/dist/{chunk-YDWPYDML.js → chunk-EKTP7MNS.js} +4 -4
- package/dist/{chunk-6LEIWWAF.js → chunk-F2JRDPON.js} +2 -2
- package/dist/{chunk-VYQ4URQB.js → chunk-FFRTNF3L.js} +2 -2
- package/dist/{chunk-TY6MKIWP.js → chunk-FONWBCVY.js} +3 -3
- package/dist/{chunk-XSV2YDCJ.js → chunk-FPLM2TKD.js} +2 -2
- package/dist/{chunk-VTU5IEKY.js → chunk-FTPONF6B.js} +2 -2
- package/dist/{chunk-6PZGKGAO.js → chunk-FWX7W5PM.js} +2 -2
- package/dist/{chunk-QPW3PAIH.js → chunk-G6DFSS6A.js} +2 -2
- package/dist/{chunk-2DD6ZHOM.js → chunk-GJ776BC2.js} +3 -3
- package/dist/{chunk-XKAR4RF6.js → chunk-GN3WRFJY.js} +6 -6
- package/dist/{chunk-RG426DJO.js → chunk-H7NAZ3UB.js} +2 -2
- package/dist/{chunk-BSXGTDVJ.js → chunk-HBUFQRIM.js} +2 -2
- package/dist/{chunk-FFEBSFVT.js → chunk-HGJ6NJ4E.js} +2 -2
- package/dist/{chunk-WB7JSQCP.js → chunk-HIEWDJ2O.js} +5 -2
- package/dist/{chunk-WB7JSQCP.js.map → chunk-HIEWDJ2O.js.map} +1 -1
- package/dist/{chunk-QTO6BMQZ.js → chunk-I3MSGFGD.js} +17 -6
- package/dist/chunk-I3MSGFGD.js.map +1 -0
- package/dist/{chunk-5JKUSBMX.js → chunk-IKP5OYQQ.js} +2 -2
- package/dist/{chunk-KQAFEZQX.js → chunk-IPLYGWQF.js} +5 -5
- package/dist/{chunk-DBY26JJJ.js → chunk-IQ4NVWEF.js} +2 -2
- package/dist/{chunk-7Q7JWLQ4.js → chunk-JYG4OLWH.js} +2 -2
- package/dist/{chunk-3OTSVCPK.js → chunk-K26NWEOC.js} +4 -4
- package/dist/{chunk-WZWZRZ2V.js → chunk-K2UGPTYY.js} +484 -43
- package/dist/chunk-K2UGPTYY.js.map +1 -0
- package/dist/{chunk-L6CQ7WIW.js → chunk-KFBOPMF6.js} +11 -11
- package/dist/chunk-KFBOPMF6.js.map +1 -0
- package/dist/{chunk-HOIRB77A.js → chunk-L6Z5OAS4.js} +2 -2
- package/dist/{chunk-7RZJWZ46.js → chunk-LEPOP46W.js} +5 -5
- package/dist/{chunk-QQXWFDRD.js → chunk-M4YHAODQ.js} +270 -684
- package/dist/chunk-M4YHAODQ.js.map +1 -0
- package/dist/{chunk-NGT35IGQ.js → chunk-MIH3CJPN.js} +3 -3
- package/dist/{chunk-QPAQSG3F.js → chunk-MK5VEWCR.js} +2 -2
- package/dist/chunk-NISZQW72.js +140 -0
- package/dist/chunk-NISZQW72.js.map +1 -0
- package/dist/{chunk-L7RTUEDG.js → chunk-OCIP6YMD.js} +2 -2
- package/dist/{chunk-2INWPC6E.js → chunk-PG4QBPVG.js} +20 -10
- package/dist/chunk-PG4QBPVG.js.map +1 -0
- package/dist/{chunk-DDA55IVB.js → chunk-PT54WISF.js} +189 -55
- package/dist/chunk-PT54WISF.js.map +1 -0
- package/dist/{chunk-UWJNKGBA.js → chunk-QZLDRQ4I.js} +5 -5
- package/dist/{chunk-UYOXFFEY.js → chunk-RUNORG2P.js} +3 -3
- package/dist/{chunk-LC3FD4BV.js → chunk-RZQ6W2W4.js} +39 -39
- package/dist/{chunk-MRGJZ75M.js → chunk-SMNYAMJD.js} +3 -3
- package/dist/{chunk-MKQBXQKU.js → chunk-TB6CBZ5V.js} +22 -15
- package/dist/chunk-TB6CBZ5V.js.map +1 -0
- package/dist/{chunk-DN2IDKI5.js → chunk-TO7ZTWJW.js} +2 -2
- package/dist/{chunk-K2TDK7GG.js → chunk-TWTUGCTY.js} +2 -2
- package/dist/{chunk-CUTFSLSD.js → chunk-UCTS3DDH.js} +2 -2
- package/dist/{chunk-JYIJNNN3.js → chunk-UG6VXIOK.js} +2 -2
- package/dist/{chunk-QOQQMVR2.js → chunk-UKYS3NU5.js} +2 -2
- package/dist/{chunk-VZRFGJCH.js → chunk-UPLZNJKN.js} +2 -2
- package/dist/{chunk-C23BYTJV.js → chunk-UW5NPZJ2.js} +40 -12
- package/dist/chunk-UW5NPZJ2.js.map +1 -0
- package/dist/{chunk-DOOWFDWN.js → chunk-V6ERBR7U.js} +2 -2
- package/dist/{chunk-7HG7MGAP.js → chunk-W5ZKPI34.js} +462 -2673
- package/dist/chunk-W5ZKPI34.js.map +1 -0
- package/dist/{chunk-HNDIND7P.js → chunk-XX4HPFFM.js} +54 -15
- package/dist/chunk-XX4HPFFM.js.map +1 -0
- package/dist/{chunk-N7CXQ5TA.js → chunk-XZHE2DEN.js} +1 -1
- package/dist/chunk-YXQEKCZM.js +223 -0
- package/dist/chunk-YXQEKCZM.js.map +1 -0
- package/dist/{chunk-6NNNURLK.js → chunk-Z54EM5YZ.js} +4 -4
- package/dist/{chunk-F2Y6I74C.js → chunk-ZRZVLB7O.js} +2 -2
- package/dist/{chunk-CLKBV3Z3.js → chunk-ZUKIUXHQ.js} +9 -9
- package/dist/{cli-jfuZXixq.d.ts → cli-BPDUXnAl.d.ts} +5 -5
- package/dist/cli.d.ts +22 -22
- package/dist/cli.js +66 -58
- package/dist/coding/pre-action-gate.d.ts +1 -1
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +14 -14
- 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 +2 -1
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +14 -14
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +14 -14
- 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/contradiction/index.js +2 -2
- package/dist/{contradiction-scan-KCADHXPE.js → contradiction-scan-JDTBXRGW.js} +3 -3
- package/dist/converge-config.d.ts +1 -1
- package/dist/convergence-refresh.d.ts +2 -2
- package/dist/convergence-refresh.js +16 -16
- 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 +1 -1
- package/dist/corpus-watermark.js +16 -16
- 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-CTDuAVJc.d.ts → dependency-propagation-delivery-CzEfB31P.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-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +14 -14
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +9 -9
- package/dist/explicit-capture.js +4 -3
- package/dist/external-wiki-access.d.ts +22 -22
- package/dist/external-wiki-access.js +33 -30
- 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 +22 -22
- package/dist/extraction-error-classification.d.ts +1 -1
- package/dist/extraction-faithfulness.d.ts +1 -1
- package/dist/extraction-faithfulness.js +2 -2
- 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-judge.js +2 -2
- package/dist/extraction-liveness.d.ts +1 -1
- package/dist/extraction-normalization.d.ts +1 -1
- 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 +20 -20
- package/dist/fallback-llm.d.ts +14 -1
- package/dist/fallback-llm.js +1 -1
- package/dist/{first-start-migration-LMMZFLKK.js → first-start-migration-CRZCZAJN.js} +5 -5
- 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-retrieval.js +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 +30 -747
- package/dist/index.js +203 -118
- package/dist/inline-script.d.ts +3 -0
- package/dist/inline-script.js +8 -0
- package/dist/inline-script.js.map +1 -0
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/engine.js +2 -2
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +2 -2
- 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 +2 -1
- package/dist/local-llm.js +2 -2
- package/dist/local-model-endpoint.d.ts +1 -1
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +14 -14
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +14 -14
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +15 -15
- package/dist/{maintenance-heMZSq7G.d.ts → maintenance-C8aRWfhq.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +22 -22
- package/dist/mcp-read-only-tools.js +1 -1
- 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 +15 -15
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +6 -6
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +14 -14
- 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 +17 -17
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +23 -22
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +4 -4
- package/dist/orchestration/maintenance.js +19 -19
- package/dist/{orchestrator-BQQPsSjs.d.ts → orchestrator-D85CzDDY.d.ts} +8 -8
- package/dist/orchestrator.d.ts +9 -9
- package/dist/orchestrator.js +86 -80
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-DFfmsnGk.d.ts → pipeline-DPcUifCO.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/public-http-D3GBeII4.d.ts +25 -0
- package/dist/{qmd-BF5bcVRs.d.ts → qmd-dFCHp1r0.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-planner-llm.js +1 -1
- 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-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 +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 +3 -2
- 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-CbUOsE_E.d.ts → scope-profiles-DICK7GtN.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 -5
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +9 -9
- package/dist/search/lancedb-backend.d.ts +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 +1 -1
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-DAB3xdKM.d.ts → semantic-consolidation-BP7NAX0N.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +15 -15
- package/dist/semantic-rule-promotion.js +14 -14
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +14 -14
- package/dist/{service-DGKg2O6r.d.ts → service-DT-pJyda.d.ts} +660 -660
- 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 +16 -16
- package/dist/{storage-CC1jKcWg.d.ts → storage-qOnaJ1Lw.d.ts} +4 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +13 -13
- package/dist/summarizer.d.ts +1 -1
- package/dist/summarizer.js +5 -5
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/support-passport/index.d.ts +518 -0
- package/dist/support-passport/index.js +357 -0
- package/dist/support-passport/index.js.map +1 -0
- 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/tier-routing.js +2 -2
- package/dist/{tier-stats-JDN6HRNT.js → tier-stats-EXYSKSVN.js} +3 -3
- 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 +1 -1
- package/dist/transfer/capsule-export.js +2 -2
- package/dist/transfer/types.d.ts +24 -24
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-BnQza1y8.d.ts → types-ed-SvS2t.d.ts} +7 -1
- 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 +14 -14
- package/dist/write-envelope.d.ts +1 -1
- package/dist/write-rate-limiter.d.ts +11 -5
- package/dist/write-rate-limiter.js +1 -1
- package/package.json +12 -2
- package/scripts/build-with-heap.mjs +11 -1
- package/src/access-authorization-probe.ts +20 -2
- package/src/access-boundary.ts +32 -0
- package/src/access-http.test.ts +1940 -643
- package/src/access-http.ts +81 -74
- package/src/access-mcp.ts +3 -1
- package/src/access-operations.ts +2 -0
- package/src/access-service.ts +612 -845
- package/src/access-surface-catalog.test.ts +40 -10
- package/src/access-surface-catalog.ts +15 -0
- package/src/active-memory-bridge.ts +17 -19
- package/src/config.ts +18 -9
- package/src/fallback-llm.test.ts +54 -0
- package/src/fallback-llm.ts +54 -9
- package/src/inline-script.ts +6 -0
- package/src/local-llm-headers-timeout.test.ts +42 -0
- package/src/local-llm.ts +8 -8
- package/src/mcp-read-only-tools.ts +3 -0
- package/src/relay/mission-access.test.ts +11 -11
- package/src/relay/mission-ui.test.ts +3 -1
- package/src/storage/tombstone-blocked-capture-sync.ts +31 -0
- package/src/storage-contract/failure-semantics.test.ts +102 -0
- package/src/support-passport/access-http-base.ts +143 -0
- package/src/support-passport/access-http.ts +172 -0
- package/src/support-passport/access-operations.ts +272 -0
- package/src/support-passport/access-service-base.test.ts +193 -0
- package/src/support-passport/access-service-base.ts +176 -0
- package/src/support-passport/access-surface.test.ts +283 -0
- package/src/support-passport/access-surface.ts +286 -0
- package/src/support-passport/card-projection.test.ts +8 -0
- package/src/support-passport/card-projection.ts +77 -16
- package/src/support-passport/card-replacement.ts +126 -0
- package/src/support-passport/card-service-commit-forwarding.test.ts +160 -0
- package/src/support-passport/card-service.test.ts +533 -31
- package/src/support-passport/card-service.ts +506 -364
- package/src/support-passport/card-state.ts +158 -0
- package/src/support-passport/config-model-routing.test.ts +37 -0
- package/src/support-passport/config.test.ts +34 -0
- package/src/support-passport/config.ts +41 -0
- package/src/support-passport/contracts.test.ts +15 -2
- package/src/support-passport/contracts.ts +13 -0
- package/src/support-passport/errors.ts +6 -0
- package/src/support-passport/generated-batch.test.ts +185 -0
- package/src/support-passport/generated-batch.ts +338 -0
- package/src/support-passport/grant-contracts.ts +45 -1
- package/src/support-passport/grant-generated-batch-scope.test.ts +201 -0
- package/src/support-passport/grant-service-cache.test.ts +2 -2
- package/src/support-passport/grant-service-cancellation.test.ts +2 -0
- package/src/support-passport/grant-service-marker-cache.test.ts +62 -0
- package/src/support-passport/grant-service.test.ts +853 -239
- package/src/support-passport/grant-service.ts +206 -57
- package/src/support-passport/grant-store.ts +7 -3
- package/src/support-passport/index.ts +10 -0
- package/src/support-passport/mcp-tools.test.ts +222 -0
- package/src/support-passport/mcp-tools.ts +187 -0
- package/src/support-passport/model-adapter.test.ts +840 -0
- package/src/support-passport/model-adapter.ts +602 -0
- package/src/support-passport/model-audit-pinned-write.test.ts +59 -0
- package/src/support-passport/model-audit.ts +152 -0
- package/src/support-passport/model-bridge.test.ts +456 -0
- package/src/support-passport/model-bridge.ts +439 -0
- package/src/support-passport/model-contracts.ts +124 -0
- package/src/support-passport/model-service.test.ts +1731 -0
- package/src/support-passport/model-service.ts +399 -0
- package/src/support-passport/owner-http.test.ts +671 -0
- package/src/support-passport/owner-lock.ts +26 -9
- package/src/support-passport/private-file.test.ts +99 -0
- package/src/support-passport/private-file.ts +139 -12
- package/src/support-passport/public-http.test.ts +476 -0
- package/src/support-passport/public-http.ts +601 -0
- package/src/support-passport/ui.test.ts +181 -0
- package/src/types.ts +7 -0
- package/src/write-rate-limiter.test.ts +30 -6
- package/src/write-rate-limiter.ts +29 -18
- package/dist/chunk-2INWPC6E.js.map +0 -1
- package/dist/chunk-2PNXOQ4P.js.map +0 -1
- package/dist/chunk-3SXLD5T3.js.map +0 -1
- package/dist/chunk-3WGI7F4V.js.map +0 -1
- package/dist/chunk-7HG7MGAP.js.map +0 -1
- package/dist/chunk-BIF4SHMD.js.map +0 -1
- package/dist/chunk-C23BYTJV.js.map +0 -1
- package/dist/chunk-CSY44OKU.js.map +0 -1
- package/dist/chunk-DDA55IVB.js.map +0 -1
- package/dist/chunk-HNDIND7P.js.map +0 -1
- package/dist/chunk-L6CQ7WIW.js.map +0 -1
- package/dist/chunk-MKQBXQKU.js.map +0 -1
- package/dist/chunk-QQXWFDRD.js.map +0 -1
- package/dist/chunk-QTO6BMQZ.js.map +0 -1
- package/dist/chunk-WZWZRZ2V.js.map +0 -1
- /package/dist/{auto-sync-TDHLZPVP.js.map → auto-sync-NR3GPCOA.js.map} +0 -0
- /package/dist/{chunk-LLJMAULE.js.map → chunk-2FKEIPIT.js.map} +0 -0
- /package/dist/{chunk-AU7Q3LSC.js.map → chunk-2QSZNTDO.js.map} +0 -0
- /package/dist/{chunk-TKFGFDPJ.js.map → chunk-3TIZPSJC.js.map} +0 -0
- /package/dist/{chunk-B4T3FQMT.js.map → chunk-43SEBY2M.js.map} +0 -0
- /package/dist/{chunk-LVKYLMSM.js.map → chunk-46SZBVDS.js.map} +0 -0
- /package/dist/{chunk-YKZLOPTC.js.map → chunk-5FD7JMTX.js.map} +0 -0
- /package/dist/{chunk-WM5LD6AT.js.map → chunk-6CYHUWCO.js.map} +0 -0
- /package/dist/{chunk-YR65W7BV.js.map → chunk-BRR5EUTF.js.map} +0 -0
- /package/dist/{chunk-JKW663ZN.js.map → chunk-CIAI24TQ.js.map} +0 -0
- /package/dist/{chunk-YDWPYDML.js.map → chunk-EKTP7MNS.js.map} +0 -0
- /package/dist/{chunk-6LEIWWAF.js.map → chunk-F2JRDPON.js.map} +0 -0
- /package/dist/{chunk-VYQ4URQB.js.map → chunk-FFRTNF3L.js.map} +0 -0
- /package/dist/{chunk-TY6MKIWP.js.map → chunk-FONWBCVY.js.map} +0 -0
- /package/dist/{chunk-XSV2YDCJ.js.map → chunk-FPLM2TKD.js.map} +0 -0
- /package/dist/{chunk-VTU5IEKY.js.map → chunk-FTPONF6B.js.map} +0 -0
- /package/dist/{chunk-6PZGKGAO.js.map → chunk-FWX7W5PM.js.map} +0 -0
- /package/dist/{chunk-QPW3PAIH.js.map → chunk-G6DFSS6A.js.map} +0 -0
- /package/dist/{chunk-2DD6ZHOM.js.map → chunk-GJ776BC2.js.map} +0 -0
- /package/dist/{chunk-XKAR4RF6.js.map → chunk-GN3WRFJY.js.map} +0 -0
- /package/dist/{chunk-RG426DJO.js.map → chunk-H7NAZ3UB.js.map} +0 -0
- /package/dist/{chunk-BSXGTDVJ.js.map → chunk-HBUFQRIM.js.map} +0 -0
- /package/dist/{chunk-FFEBSFVT.js.map → chunk-HGJ6NJ4E.js.map} +0 -0
- /package/dist/{chunk-5JKUSBMX.js.map → chunk-IKP5OYQQ.js.map} +0 -0
- /package/dist/{chunk-KQAFEZQX.js.map → chunk-IPLYGWQF.js.map} +0 -0
- /package/dist/{chunk-DBY26JJJ.js.map → chunk-IQ4NVWEF.js.map} +0 -0
- /package/dist/{chunk-7Q7JWLQ4.js.map → chunk-JYG4OLWH.js.map} +0 -0
- /package/dist/{chunk-3OTSVCPK.js.map → chunk-K26NWEOC.js.map} +0 -0
- /package/dist/{chunk-HOIRB77A.js.map → chunk-L6Z5OAS4.js.map} +0 -0
- /package/dist/{chunk-7RZJWZ46.js.map → chunk-LEPOP46W.js.map} +0 -0
- /package/dist/{chunk-NGT35IGQ.js.map → chunk-MIH3CJPN.js.map} +0 -0
- /package/dist/{chunk-QPAQSG3F.js.map → chunk-MK5VEWCR.js.map} +0 -0
- /package/dist/{chunk-L7RTUEDG.js.map → chunk-OCIP6YMD.js.map} +0 -0
- /package/dist/{chunk-UWJNKGBA.js.map → chunk-QZLDRQ4I.js.map} +0 -0
- /package/dist/{chunk-UYOXFFEY.js.map → chunk-RUNORG2P.js.map} +0 -0
- /package/dist/{chunk-LC3FD4BV.js.map → chunk-RZQ6W2W4.js.map} +0 -0
- /package/dist/{chunk-MRGJZ75M.js.map → chunk-SMNYAMJD.js.map} +0 -0
- /package/dist/{chunk-DN2IDKI5.js.map → chunk-TO7ZTWJW.js.map} +0 -0
- /package/dist/{chunk-K2TDK7GG.js.map → chunk-TWTUGCTY.js.map} +0 -0
- /package/dist/{chunk-CUTFSLSD.js.map → chunk-UCTS3DDH.js.map} +0 -0
- /package/dist/{chunk-JYIJNNN3.js.map → chunk-UG6VXIOK.js.map} +0 -0
- /package/dist/{chunk-QOQQMVR2.js.map → chunk-UKYS3NU5.js.map} +0 -0
- /package/dist/{chunk-VZRFGJCH.js.map → chunk-UPLZNJKN.js.map} +0 -0
- /package/dist/{chunk-DOOWFDWN.js.map → chunk-V6ERBR7U.js.map} +0 -0
- /package/dist/{chunk-N7CXQ5TA.js.map → chunk-XZHE2DEN.js.map} +0 -0
- /package/dist/{chunk-6NNNURLK.js.map → chunk-Z54EM5YZ.js.map} +0 -0
- /package/dist/{chunk-F2Y6I74C.js.map → chunk-ZRZVLB7O.js.map} +0 -0
- /package/dist/{chunk-CLKBV3Z3.js.map → chunk-ZUKIUXHQ.js.map} +0 -0
- /package/dist/{contradiction-scan-KCADHXPE.js.map → contradiction-scan-JDTBXRGW.js.map} +0 -0
- /package/dist/{first-start-migration-LMMZFLKK.js.map → first-start-migration-CRZCZAJN.js.map} +0 -0
- /package/dist/{tier-stats-JDN6HRNT.js.map → tier-stats-EXYSKSVN.js.map} +0 -0
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TombstoneStore,
|
|
3
|
+
applyTombstoneResurrectionGate,
|
|
4
|
+
buildRetiredFactTombstoneInputs,
|
|
5
|
+
collectRetiredMemoriesForRebuild
|
|
6
|
+
} from "./chunk-MLPTFODV.js";
|
|
1
7
|
import {
|
|
2
8
|
WEARABLES_DIR_NAME,
|
|
3
9
|
escapeSegmentText,
|
|
@@ -9,22 +15,16 @@ import {
|
|
|
9
15
|
unescapeSegmentText,
|
|
10
16
|
unescapeSpeakerLabel
|
|
11
17
|
} from "./chunk-UHVXE24Y.js";
|
|
12
|
-
import {
|
|
13
|
-
TombstoneStore,
|
|
14
|
-
applyTombstoneResurrectionGate,
|
|
15
|
-
buildRetiredFactTombstoneInputs,
|
|
16
|
-
collectRetiredMemoriesForRebuild
|
|
17
|
-
} from "./chunk-MLPTFODV.js";
|
|
18
18
|
import {
|
|
19
19
|
normalizeQmdResultPath
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-TO7ZTWJW.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-76JJSXK7.js";
|
|
28
28
|
import {
|
|
29
29
|
normalizeProjectionPreview,
|
|
30
30
|
normalizeProjectionTags
|
|
@@ -51,15 +51,17 @@ import {
|
|
|
51
51
|
import {
|
|
52
52
|
parseFaithfulnessField,
|
|
53
53
|
serializeFaithfulnessFields
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-UG6VXIOK.js";
|
|
55
55
|
import {
|
|
56
|
+
DeletionRevisionStore,
|
|
56
57
|
TombstoneBlockedCaptureIndexHost,
|
|
57
58
|
buildCapturePathLockIdentity,
|
|
58
59
|
buildExplicitCaptureDedupKey,
|
|
60
|
+
invalidationCommitFingerprint,
|
|
59
61
|
isQueuedReviewMemory,
|
|
60
62
|
parseTombstoneBlockedOfflineSyncMemory,
|
|
61
63
|
tombstoneBlocked
|
|
62
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-K2UGPTYY.js";
|
|
63
65
|
import {
|
|
64
66
|
composeMemoryEnvelope,
|
|
65
67
|
isSealedMemoryEnvelope,
|
|
@@ -191,7 +193,7 @@ import {
|
|
|
191
193
|
} from "./chunk-5FVVY2EB.js";
|
|
192
194
|
import {
|
|
193
195
|
isSupportPassportPrivateMemory
|
|
194
|
-
} from "./chunk-
|
|
196
|
+
} from "./chunk-XX4HPFFM.js";
|
|
195
197
|
import {
|
|
196
198
|
namespaceIdentityFromToken
|
|
197
199
|
} from "./chunk-EGGE52UU.js";
|
|
@@ -241,20 +243,20 @@ import {
|
|
|
241
243
|
|
|
242
244
|
// src/storage.ts
|
|
243
245
|
import {
|
|
244
|
-
lstat as
|
|
246
|
+
lstat as lstat3,
|
|
245
247
|
readdir as readdir6,
|
|
246
|
-
readFile as
|
|
248
|
+
readFile as readFile2,
|
|
247
249
|
realpath as realpath3,
|
|
248
250
|
stat as stat2,
|
|
249
251
|
writeFile as writeFile2,
|
|
250
|
-
mkdir
|
|
251
|
-
unlink as
|
|
252
|
+
mkdir,
|
|
253
|
+
unlink as unlink4,
|
|
252
254
|
appendFile,
|
|
253
|
-
open
|
|
255
|
+
open
|
|
254
256
|
} from "fs/promises";
|
|
255
257
|
import { appendFileSync, createReadStream, mkdirSync, statSync } from "fs";
|
|
256
|
-
import { createHash as
|
|
257
|
-
import
|
|
258
|
+
import { createHash as createHash6 } from "crypto";
|
|
259
|
+
import path10 from "path";
|
|
258
260
|
|
|
259
261
|
// src/storage/memory-read-store.ts
|
|
260
262
|
import { lstat, readdir, realpath, stat } from "fs/promises";
|
|
@@ -2087,425 +2089,9 @@ ${rows.join("\n")}
|
|
|
2087
2089
|
}
|
|
2088
2090
|
};
|
|
2089
2091
|
|
|
2090
|
-
// src/storage/deletion-revision-store.ts
|
|
2091
|
-
import { createHash, randomUUID } from "crypto";
|
|
2092
|
-
import { lstat as lstat2, mkdir, open, readFile, rename, unlink as unlink2 } from "fs/promises";
|
|
2093
|
-
import path3 from "path";
|
|
2094
|
-
var DELETION_REVISION_MAX_MTIME_MS = 864e13;
|
|
2095
|
-
var DELETION_REVISION_LOCK_STALE_MS = 6e4;
|
|
2096
|
-
var DELETION_REVISION_LOCK_MAX_WAIT_MS = 12e4;
|
|
2097
|
-
var INVALIDATION_COMMIT_MAX_TIMESTAMP_MS = 864e13;
|
|
2098
|
-
var INVALIDATION_PROOF_QUARANTINE_MAX_IDS = 1024;
|
|
2099
|
-
function canonicalizeInvalidationEvidence(value) {
|
|
2100
|
-
if (Array.isArray(value)) return value.map((item) => canonicalizeInvalidationEvidence(item));
|
|
2101
|
-
if (value && typeof value === "object") {
|
|
2102
|
-
const result = {};
|
|
2103
|
-
for (const key of Object.keys(value).sort()) {
|
|
2104
|
-
result[key] = canonicalizeInvalidationEvidence(value[key]);
|
|
2105
|
-
}
|
|
2106
|
-
return result;
|
|
2107
|
-
}
|
|
2108
|
-
return value;
|
|
2109
|
-
}
|
|
2110
|
-
function invalidationCommitFingerprint(memory) {
|
|
2111
|
-
const frontmatter = { ...memory.frontmatter };
|
|
2112
|
-
delete frontmatter.accessCount;
|
|
2113
|
-
delete frontmatter.lastAccessed;
|
|
2114
|
-
return createHash("sha256").update(
|
|
2115
|
-
JSON.stringify(
|
|
2116
|
-
canonicalizeInvalidationEvidence({
|
|
2117
|
-
content: memory.content,
|
|
2118
|
-
frontmatter
|
|
2119
|
-
})
|
|
2120
|
-
)
|
|
2121
|
-
).digest("hex");
|
|
2122
|
-
}
|
|
2123
|
-
function isValidInvalidationCommitTimestamp(value) {
|
|
2124
|
-
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= INVALIDATION_COMMIT_MAX_TIMESTAMP_MS;
|
|
2125
|
-
}
|
|
2126
|
-
function isValidInvalidationCommitFingerprint(value) {
|
|
2127
|
-
return typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
|
|
2128
|
-
}
|
|
2129
|
-
function isValidMemoryId(value) {
|
|
2130
|
-
return typeof value === "string" && value.length > 0 && !value.includes("\0");
|
|
2131
|
-
}
|
|
2132
|
-
function isValidDeletionRevisionPath(value) {
|
|
2133
|
-
return typeof value === "string" && value.length > 0 && !value.includes("\\") && !value.includes("\0") && !path3.posix.isAbsolute(value) && path3.posix.normalize(value) === value && value !== "." && value !== ".." && !value.startsWith("../");
|
|
2134
|
-
}
|
|
2135
|
-
function deletionRevisionPathIdentity(value) {
|
|
2136
|
-
return value.normalize("NFC").toUpperCase().toLowerCase();
|
|
2137
|
-
}
|
|
2138
|
-
var DeletionRevisionStore = class {
|
|
2139
|
-
options;
|
|
2140
|
-
invalidationProofQuarantine = /* @__PURE__ */ new Set();
|
|
2141
|
-
invalidationProofQuarantineFull = false;
|
|
2142
|
-
invalidationProofQuarantineFullAt = null;
|
|
2143
|
-
constructor(options) {
|
|
2144
|
-
this.options = options;
|
|
2145
|
-
}
|
|
2146
|
-
quarantineInvalidationProof(memoryId) {
|
|
2147
|
-
if (this.invalidationProofQuarantineFull) {
|
|
2148
|
-
const nextBoundary = Date.now() + 1;
|
|
2149
|
-
this.invalidationProofQuarantineFullAt = Math.max(
|
|
2150
|
-
this.invalidationProofQuarantineFullAt ?? 0,
|
|
2151
|
-
nextBoundary
|
|
2152
|
-
);
|
|
2153
|
-
return;
|
|
2154
|
-
}
|
|
2155
|
-
if (this.invalidationProofQuarantine.has(memoryId)) return;
|
|
2156
|
-
if (this.invalidationProofQuarantine.size >= INVALIDATION_PROOF_QUARANTINE_MAX_IDS) {
|
|
2157
|
-
this.invalidationProofQuarantineFull = true;
|
|
2158
|
-
this.invalidationProofQuarantineFullAt = Date.now() + 1;
|
|
2159
|
-
return;
|
|
2160
|
-
}
|
|
2161
|
-
this.invalidationProofQuarantine.add(memoryId);
|
|
2162
|
-
}
|
|
2163
|
-
async resolveConfiguredStoragePath(targetPath) {
|
|
2164
|
-
const baseDir = path3.resolve(this.options.baseDir);
|
|
2165
|
-
const relativePath = path3.relative(baseDir, path3.resolve(targetPath));
|
|
2166
|
-
return resolveSafeStoragePath(baseDir, relativePath);
|
|
2167
|
-
}
|
|
2168
|
-
async resolveManagedStoragePath(filePath, method) {
|
|
2169
|
-
const assertedPath = this.options.assertManagedStoragePath(filePath, method);
|
|
2170
|
-
const target = await this.resolveConfiguredStoragePath(assertedPath);
|
|
2171
|
-
const relativePath = path3.relative(path3.resolve(this.options.baseDir), target).split(path3.sep).join("/");
|
|
2172
|
-
return { target, relativePath };
|
|
2173
|
-
}
|
|
2174
|
-
parseDeletionRevisionMetadata(raw) {
|
|
2175
|
-
let parsed;
|
|
2176
|
-
try {
|
|
2177
|
-
parsed = JSON.parse(raw);
|
|
2178
|
-
} catch {
|
|
2179
|
-
throw new Error("Deletion revision metadata is invalid.");
|
|
2180
|
-
}
|
|
2181
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
2182
|
-
throw new Error("Deletion revision metadata is invalid.");
|
|
2183
|
-
}
|
|
2184
|
-
const root = parsed;
|
|
2185
|
-
if (Object.keys(root).sort().join(",") !== "deletions,version" || root.version !== 1 || !Array.isArray(root.deletions)) {
|
|
2186
|
-
throw new Error("Deletion revision metadata is invalid.");
|
|
2187
|
-
}
|
|
2188
|
-
const revisions = /* @__PURE__ */ new Map();
|
|
2189
|
-
const pathByIdentity = /* @__PURE__ */ new Map();
|
|
2190
|
-
for (const rawEntry of root.deletions) {
|
|
2191
|
-
if (!rawEntry || typeof rawEntry !== "object" || Array.isArray(rawEntry)) {
|
|
2192
|
-
throw new Error("Deletion revision metadata is invalid.");
|
|
2193
|
-
}
|
|
2194
|
-
const entry = rawEntry;
|
|
2195
|
-
if (Object.keys(entry).sort().join(",") !== "mtimeMs,path" || !isValidDeletionRevisionPath(entry.path) || typeof entry.mtimeMs !== "number" || !Number.isFinite(entry.mtimeMs) || entry.mtimeMs < 0 || entry.mtimeMs > DELETION_REVISION_MAX_MTIME_MS || revisions.has(entry.path)) {
|
|
2196
|
-
throw new Error("Deletion revision metadata is invalid.");
|
|
2197
|
-
}
|
|
2198
|
-
const identity = deletionRevisionPathIdentity(entry.path);
|
|
2199
|
-
if (pathByIdentity.has(identity)) {
|
|
2200
|
-
throw new Error("Deletion revision metadata is invalid.");
|
|
2201
|
-
}
|
|
2202
|
-
pathByIdentity.set(identity, entry.path);
|
|
2203
|
-
revisions.set(entry.path, entry.mtimeMs);
|
|
2204
|
-
}
|
|
2205
|
-
return new Map([...revisions.entries()].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0));
|
|
2206
|
-
}
|
|
2207
|
-
async readDeletionRevisionMetadata() {
|
|
2208
|
-
const metadataPath = await this.resolveConfiguredStoragePath(this.options.deletionRevisionMetadataPath);
|
|
2209
|
-
let raw;
|
|
2210
|
-
try {
|
|
2211
|
-
raw = await readFile(metadataPath, "utf8");
|
|
2212
|
-
} catch (error) {
|
|
2213
|
-
if (isErrnoCode(error, "ENOENT")) return /* @__PURE__ */ new Map();
|
|
2214
|
-
throw new Error("Deletion revision metadata is unavailable.");
|
|
2215
|
-
}
|
|
2216
|
-
return this.parseDeletionRevisionMetadata(raw);
|
|
2217
|
-
}
|
|
2218
|
-
async writeDeletionRevisionMetadata(revisions, lock) {
|
|
2219
|
-
const metadataPath = await this.resolveConfiguredStoragePath(this.options.deletionRevisionMetadataPath);
|
|
2220
|
-
const deletions = [...revisions.entries()].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([entryPath, mtimeMs]) => ({ path: entryPath, mtimeMs }));
|
|
2221
|
-
const metadata = { version: 1, deletions };
|
|
2222
|
-
const temporaryPath = await this.resolveConfiguredStoragePath(
|
|
2223
|
-
`${metadataPath}.${process.pid}.${randomUUID()}.tmp`
|
|
2224
|
-
);
|
|
2225
|
-
let handle = null;
|
|
2226
|
-
try {
|
|
2227
|
-
handle = await open(temporaryPath, "wx", 384);
|
|
2228
|
-
await handle.writeFile(`${JSON.stringify(metadata)}
|
|
2229
|
-
`, "utf8");
|
|
2230
|
-
await handle.sync();
|
|
2231
|
-
await handle.close();
|
|
2232
|
-
handle = null;
|
|
2233
|
-
if (!await lock.refresh()) {
|
|
2234
|
-
throw new Error("Deletion revision metadata lock was lost.");
|
|
2235
|
-
}
|
|
2236
|
-
const renameTarget = await this.resolveConfiguredStoragePath(this.options.deletionRevisionMetadataPath);
|
|
2237
|
-
await rename(temporaryPath, renameTarget);
|
|
2238
|
-
} finally {
|
|
2239
|
-
if (handle !== null) {
|
|
2240
|
-
await handle.close().catch((error) => {
|
|
2241
|
-
log.warn("failed to close deletion revision metadata temporary file", error);
|
|
2242
|
-
});
|
|
2243
|
-
}
|
|
2244
|
-
const cleanupPath = await this.resolveConfiguredStoragePath(temporaryPath).catch((error) => {
|
|
2245
|
-
log.warn("failed to resolve deletion revision metadata temporary file for cleanup", error);
|
|
2246
|
-
return null;
|
|
2247
|
-
});
|
|
2248
|
-
if (cleanupPath !== null) {
|
|
2249
|
-
await unlink2(cleanupPath).catch((error) => {
|
|
2250
|
-
if (!isErrnoCode(error, "ENOENT")) {
|
|
2251
|
-
log.warn("failed to clean up deletion revision metadata temporary file", error);
|
|
2252
|
-
}
|
|
2253
|
-
});
|
|
2254
|
-
}
|
|
2255
|
-
}
|
|
2256
|
-
}
|
|
2257
|
-
async withDeletionRevisionLock(task) {
|
|
2258
|
-
const lockPath2 = await this.resolveConfiguredStoragePath(this.options.deletionRevisionLockPath);
|
|
2259
|
-
return withHeldFileLock(
|
|
2260
|
-
lockPath2,
|
|
2261
|
-
{
|
|
2262
|
-
staleMs: DELETION_REVISION_LOCK_STALE_MS,
|
|
2263
|
-
maxWaitMs: DELETION_REVISION_LOCK_MAX_WAIT_MS
|
|
2264
|
-
},
|
|
2265
|
-
async (acquired, lock) => {
|
|
2266
|
-
if (!acquired) throw new Error("Deletion revision metadata lock is unavailable.");
|
|
2267
|
-
return task(lock);
|
|
2268
|
-
}
|
|
2269
|
-
);
|
|
2270
|
-
}
|
|
2271
|
-
async readDeletionRevisions() {
|
|
2272
|
-
return this.withDeletionRevisionLock(async () => this.readDeletionRevisionMetadata());
|
|
2273
|
-
}
|
|
2274
|
-
parseInvalidationCommitMetadata(raw) {
|
|
2275
|
-
let parsed;
|
|
2276
|
-
try {
|
|
2277
|
-
parsed = JSON.parse(raw);
|
|
2278
|
-
} catch {
|
|
2279
|
-
throw new Error("Invalidation commit metadata is invalid.");
|
|
2280
|
-
}
|
|
2281
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
2282
|
-
throw new Error("Invalidation commit metadata is invalid.");
|
|
2283
|
-
}
|
|
2284
|
-
const root = parsed;
|
|
2285
|
-
if (Object.keys(root).sort().join(",") !== "commits,version" || root.version !== 1 || !Array.isArray(root.commits)) {
|
|
2286
|
-
throw new Error("Invalidation commit metadata is invalid.");
|
|
2287
|
-
}
|
|
2288
|
-
const commits = /* @__PURE__ */ new Map();
|
|
2289
|
-
for (const rawEntry of root.commits) {
|
|
2290
|
-
if (!rawEntry || typeof rawEntry !== "object" || Array.isArray(rawEntry)) {
|
|
2291
|
-
throw new Error("Invalidation commit metadata is invalid.");
|
|
2292
|
-
}
|
|
2293
|
-
const entry = rawEntry;
|
|
2294
|
-
if (Object.keys(entry).sort().join(",") !== "committedAt,fingerprint,memoryId" || !isValidMemoryId(entry.memoryId) || !isValidInvalidationCommitFingerprint(entry.fingerprint) || !isValidInvalidationCommitTimestamp(entry.committedAt) || commits.has(entry.memoryId)) {
|
|
2295
|
-
throw new Error("Invalidation commit metadata is invalid.");
|
|
2296
|
-
}
|
|
2297
|
-
commits.set(entry.memoryId, {
|
|
2298
|
-
fingerprint: entry.fingerprint,
|
|
2299
|
-
committedAt: entry.committedAt
|
|
2300
|
-
});
|
|
2301
|
-
}
|
|
2302
|
-
return commits;
|
|
2303
|
-
}
|
|
2304
|
-
async readInvalidationCommitMetadata() {
|
|
2305
|
-
const metadataPath = await this.resolveConfiguredStoragePath(this.options.invalidationCommitMetadataPath);
|
|
2306
|
-
let raw;
|
|
2307
|
-
try {
|
|
2308
|
-
raw = await readFile(metadataPath, "utf8");
|
|
2309
|
-
} catch (error) {
|
|
2310
|
-
if (isErrnoCode(error, "ENOENT")) return /* @__PURE__ */ new Map();
|
|
2311
|
-
throw new Error("Invalidation commit metadata is unavailable.");
|
|
2312
|
-
}
|
|
2313
|
-
return this.parseInvalidationCommitMetadata(raw);
|
|
2314
|
-
}
|
|
2315
|
-
async writeInvalidationCommitMetadata(commits, lock) {
|
|
2316
|
-
const metadataPath = await this.resolveConfiguredStoragePath(this.options.invalidationCommitMetadataPath);
|
|
2317
|
-
const entries = [...commits.entries()].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([memoryId, value]) => ({
|
|
2318
|
-
memoryId,
|
|
2319
|
-
fingerprint: value.fingerprint,
|
|
2320
|
-
committedAt: value.committedAt
|
|
2321
|
-
}));
|
|
2322
|
-
const metadata = { version: 1, commits: entries };
|
|
2323
|
-
const temporaryPath = await this.resolveConfiguredStoragePath(
|
|
2324
|
-
`${metadataPath}.${process.pid}.${randomUUID()}.tmp`
|
|
2325
|
-
);
|
|
2326
|
-
const metadataDir = await this.resolveConfiguredStoragePath(path3.dirname(metadataPath));
|
|
2327
|
-
let handle = null;
|
|
2328
|
-
let renamed = false;
|
|
2329
|
-
try {
|
|
2330
|
-
await mkdir(metadataDir, { recursive: true });
|
|
2331
|
-
handle = await open(temporaryPath, "wx", 384);
|
|
2332
|
-
await handle.writeFile(`${JSON.stringify(metadata)}
|
|
2333
|
-
`, "utf8");
|
|
2334
|
-
await handle.sync();
|
|
2335
|
-
await handle.close();
|
|
2336
|
-
handle = null;
|
|
2337
|
-
if (!await lock.refresh()) {
|
|
2338
|
-
throw new Error("Invalidation commit metadata lock was lost.");
|
|
2339
|
-
}
|
|
2340
|
-
const renameTarget = await this.resolveConfiguredStoragePath(this.options.invalidationCommitMetadataPath);
|
|
2341
|
-
await rename(temporaryPath, renameTarget);
|
|
2342
|
-
renamed = true;
|
|
2343
|
-
} finally {
|
|
2344
|
-
if (handle !== null) {
|
|
2345
|
-
await handle.close().catch((error) => {
|
|
2346
|
-
log.warn("failed to close invalidation commit metadata temporary file", error);
|
|
2347
|
-
});
|
|
2348
|
-
}
|
|
2349
|
-
const cleanupPath = await this.resolveConfiguredStoragePath(temporaryPath).catch((error) => {
|
|
2350
|
-
log.warn("failed to resolve invalidation commit metadata temporary file for cleanup", error);
|
|
2351
|
-
return null;
|
|
2352
|
-
});
|
|
2353
|
-
if (cleanupPath !== null) {
|
|
2354
|
-
await unlink2(cleanupPath).catch((error) => {
|
|
2355
|
-
if (!isErrnoCode(error, "ENOENT")) {
|
|
2356
|
-
log.warn(
|
|
2357
|
-
`failed to clean up invalidation commit metadata temporary file after ${renamed ? "commit" : "failure"}`,
|
|
2358
|
-
error
|
|
2359
|
-
);
|
|
2360
|
-
}
|
|
2361
|
-
});
|
|
2362
|
-
}
|
|
2363
|
-
}
|
|
2364
|
-
}
|
|
2365
|
-
async hasCommittedInvalidation(memory) {
|
|
2366
|
-
const memoryId = memory.frontmatter.id;
|
|
2367
|
-
const fingerprint = invalidationCommitFingerprint(memory);
|
|
2368
|
-
return this.withDeletionRevisionLock(async () => {
|
|
2369
|
-
const entry = (await this.readInvalidationCommitMetadata()).get(memoryId);
|
|
2370
|
-
if (entry?.fingerprint !== fingerprint) return false;
|
|
2371
|
-
if (this.invalidationProofQuarantine.has(memoryId)) return false;
|
|
2372
|
-
if (!this.invalidationProofQuarantineFull) return true;
|
|
2373
|
-
const fullAt = this.invalidationProofQuarantineFullAt;
|
|
2374
|
-
return fullAt !== null && entry.committedAt >= fullAt;
|
|
2375
|
-
});
|
|
2376
|
-
}
|
|
2377
|
-
async recordCommittedInvalidation(memory) {
|
|
2378
|
-
const fingerprint = invalidationCommitFingerprint(memory);
|
|
2379
|
-
await this.withDeletionRevisionLock(async (lock) => {
|
|
2380
|
-
const fullAt = this.invalidationProofQuarantineFullAt;
|
|
2381
|
-
const committedAt = fullAt === null ? Date.now() : Math.max(Date.now(), fullAt + 1);
|
|
2382
|
-
const commits = await this.readInvalidationCommitMetadata();
|
|
2383
|
-
commits.set(memory.frontmatter.id, {
|
|
2384
|
-
fingerprint,
|
|
2385
|
-
committedAt
|
|
2386
|
-
});
|
|
2387
|
-
await this.writeInvalidationCommitMetadata(commits, lock);
|
|
2388
|
-
this.invalidationProofQuarantine.delete(memory.frontmatter.id);
|
|
2389
|
-
});
|
|
2390
|
-
}
|
|
2391
|
-
async clearCommittedInvalidation(memory) {
|
|
2392
|
-
const memoryId = memory.frontmatter.id;
|
|
2393
|
-
this.quarantineInvalidationProof(memoryId);
|
|
2394
|
-
const fingerprint = invalidationCommitFingerprint(memory);
|
|
2395
|
-
let cleared = false;
|
|
2396
|
-
try {
|
|
2397
|
-
await this.withDeletionRevisionLock(async (lock) => {
|
|
2398
|
-
const commits = await this.readInvalidationCommitMetadata();
|
|
2399
|
-
const current = commits.get(memoryId);
|
|
2400
|
-
if (current?.fingerprint !== fingerprint) return;
|
|
2401
|
-
commits.delete(memoryId);
|
|
2402
|
-
await this.writeInvalidationCommitMetadata(commits, lock);
|
|
2403
|
-
});
|
|
2404
|
-
cleared = true;
|
|
2405
|
-
} finally {
|
|
2406
|
-
if (cleared) this.invalidationProofQuarantine.delete(memoryId);
|
|
2407
|
-
}
|
|
2408
|
-
}
|
|
2409
|
-
async recordReplicatedDeletionRevision(filePath, mtimeMs) {
|
|
2410
|
-
const { relativePath } = await this.resolveManagedStoragePath(
|
|
2411
|
-
filePath,
|
|
2412
|
-
"storage.recordReplicatedDeletionRevision"
|
|
2413
|
-
);
|
|
2414
|
-
if (typeof mtimeMs !== "number" || !Number.isFinite(mtimeMs) || mtimeMs < 0 || mtimeMs > DELETION_REVISION_MAX_MTIME_MS) {
|
|
2415
|
-
throw new Error("Deletion revision timestamp is invalid.");
|
|
2416
|
-
}
|
|
2417
|
-
if (!isValidDeletionRevisionPath(relativePath)) {
|
|
2418
|
-
throw new Error("Deletion revision path is invalid.");
|
|
2419
|
-
}
|
|
2420
|
-
await this.withDeletionRevisionLock(async (lock) => {
|
|
2421
|
-
const revisions = await this.readDeletionRevisionMetadata();
|
|
2422
|
-
const identity = deletionRevisionPathIdentity(relativePath);
|
|
2423
|
-
let existingPath;
|
|
2424
|
-
for (const candidatePath of revisions.keys()) {
|
|
2425
|
-
if (deletionRevisionPathIdentity(candidatePath) === identity) {
|
|
2426
|
-
existingPath = candidatePath;
|
|
2427
|
-
break;
|
|
2428
|
-
}
|
|
2429
|
-
}
|
|
2430
|
-
const existingMtimeMs = existingPath === void 0 ? void 0 : revisions.get(existingPath);
|
|
2431
|
-
if (existingMtimeMs !== void 0 && existingMtimeMs >= mtimeMs) return;
|
|
2432
|
-
const updated = new Map(revisions);
|
|
2433
|
-
if (existingPath !== void 0) updated.delete(existingPath);
|
|
2434
|
-
updated.set(relativePath, mtimeMs);
|
|
2435
|
-
await this.writeDeletionRevisionMetadata(updated, lock);
|
|
2436
|
-
});
|
|
2437
|
-
}
|
|
2438
|
-
async writeManagedStorageFile(filePath, write) {
|
|
2439
|
-
const { relativePath } = await this.resolveManagedStoragePath(filePath, "storage.writeManagedStorageFile");
|
|
2440
|
-
if (!isValidDeletionRevisionPath(relativePath)) {
|
|
2441
|
-
throw new Error("Deletion revision path is invalid.");
|
|
2442
|
-
}
|
|
2443
|
-
await this.withDeletionRevisionLock(async (lock) => {
|
|
2444
|
-
const before = await this.readDeletionRevisionMetadata();
|
|
2445
|
-
const identity = deletionRevisionPathIdentity(relativePath);
|
|
2446
|
-
const existingPath = [...before.keys()].find(
|
|
2447
|
-
(candidatePath) => deletionRevisionPathIdentity(candidatePath) === identity
|
|
2448
|
-
);
|
|
2449
|
-
await write();
|
|
2450
|
-
if (existingPath === void 0) return;
|
|
2451
|
-
const updated = new Map(before);
|
|
2452
|
-
updated.delete(existingPath);
|
|
2453
|
-
await this.writeDeletionRevisionMetadata(updated, lock);
|
|
2454
|
-
});
|
|
2455
|
-
}
|
|
2456
|
-
async deleteManagedStorageFile(filePath, deletionMtimeMs) {
|
|
2457
|
-
const { target, relativePath } = await this.resolveManagedStoragePath(
|
|
2458
|
-
filePath,
|
|
2459
|
-
"storage.deleteManagedStorageFile"
|
|
2460
|
-
);
|
|
2461
|
-
if (deletionMtimeMs !== void 0 && deletionMtimeMs !== null && (typeof deletionMtimeMs !== "number" || !Number.isFinite(deletionMtimeMs) || deletionMtimeMs < 0 || deletionMtimeMs > DELETION_REVISION_MAX_MTIME_MS)) {
|
|
2462
|
-
throw new Error("Deletion revision timestamp is invalid.");
|
|
2463
|
-
}
|
|
2464
|
-
return this.withDeletionRevisionLock(async (lock) => {
|
|
2465
|
-
const safeTarget = await this.resolveConfiguredStoragePath(target);
|
|
2466
|
-
try {
|
|
2467
|
-
await lstat2(safeTarget);
|
|
2468
|
-
} catch (error) {
|
|
2469
|
-
if (isErrnoCode(error, "ENOENT")) return false;
|
|
2470
|
-
throw error;
|
|
2471
|
-
}
|
|
2472
|
-
if (!isValidDeletionRevisionPath(relativePath)) {
|
|
2473
|
-
throw new Error("Deletion revision path is invalid.");
|
|
2474
|
-
}
|
|
2475
|
-
const revision = deletionMtimeMs === null ? void 0 : deletionMtimeMs ?? Date.now();
|
|
2476
|
-
const before = await this.readDeletionRevisionMetadata();
|
|
2477
|
-
const identity = deletionRevisionPathIdentity(relativePath);
|
|
2478
|
-
let existingPath;
|
|
2479
|
-
for (const candidatePath of before.keys()) {
|
|
2480
|
-
if (deletionRevisionPathIdentity(candidatePath) === identity) {
|
|
2481
|
-
existingPath = candidatePath;
|
|
2482
|
-
break;
|
|
2483
|
-
}
|
|
2484
|
-
}
|
|
2485
|
-
const existing = existingPath === void 0 ? void 0 : before.get(existingPath);
|
|
2486
|
-
const changed = existingPath !== void 0 && existingPath !== relativePath || (revision === void 0 ? existing !== void 0 : existing !== revision);
|
|
2487
|
-
if (changed) {
|
|
2488
|
-
const updated = new Map(before);
|
|
2489
|
-
if (existingPath !== void 0) updated.delete(existingPath);
|
|
2490
|
-
if (revision !== void 0) updated.set(relativePath, revision);
|
|
2491
|
-
await this.writeDeletionRevisionMetadata(updated, lock);
|
|
2492
|
-
}
|
|
2493
|
-
try {
|
|
2494
|
-
const unlinkTarget = await this.resolveConfiguredStoragePath(target);
|
|
2495
|
-
await unlink2(unlinkTarget);
|
|
2496
|
-
return true;
|
|
2497
|
-
} catch (error) {
|
|
2498
|
-
if (changed) await this.writeDeletionRevisionMetadata(before, lock);
|
|
2499
|
-
if (isErrnoCode(error, "ENOENT")) return false;
|
|
2500
|
-
throw error;
|
|
2501
|
-
}
|
|
2502
|
-
});
|
|
2503
|
-
}
|
|
2504
|
-
};
|
|
2505
|
-
|
|
2506
2092
|
// src/storage/identity-continuity-store.ts
|
|
2507
2093
|
import { readdir as readdir3 } from "fs/promises";
|
|
2508
|
-
import
|
|
2094
|
+
import path3 from "path";
|
|
2509
2095
|
var IdentityContinuityStore = class {
|
|
2510
2096
|
constructor(deps) {
|
|
2511
2097
|
this.deps = deps;
|
|
@@ -2530,7 +2116,7 @@ var IdentityContinuityStore = class {
|
|
|
2530
2116
|
const date = nowIso.slice(0, 10);
|
|
2531
2117
|
const id = this.deps.generateId("incident");
|
|
2532
2118
|
const incident = createContinuityIncidentRecord(id, input, nowIso);
|
|
2533
|
-
const filePath =
|
|
2119
|
+
const filePath = path3.join(this.deps.identityIncidentsDir, `${date}-${id}.md`);
|
|
2534
2120
|
await this.deps.writeStorageSecureFile(filePath, serializeContinuityIncident(incident));
|
|
2535
2121
|
return { ...incident, filePath };
|
|
2536
2122
|
}
|
|
@@ -2543,7 +2129,7 @@ var IdentityContinuityStore = class {
|
|
|
2543
2129
|
const incidents = [];
|
|
2544
2130
|
for (const file of candidates) {
|
|
2545
2131
|
if (incidents.length >= cappedLimit) break;
|
|
2546
|
-
const filePath =
|
|
2132
|
+
const filePath = path3.join(this.deps.identityIncidentsDir, file);
|
|
2547
2133
|
try {
|
|
2548
2134
|
const raw = await this.deps.readStorageSecureFile(filePath);
|
|
2549
2135
|
const parsed = parseContinuityIncident(raw);
|
|
@@ -2574,7 +2160,7 @@ var IdentityContinuityStore = class {
|
|
|
2574
2160
|
await this.deps.ensureDirectories();
|
|
2575
2161
|
const safeKey = this.sanitizeIdentityAuditKey(key);
|
|
2576
2162
|
const dir = period === "weekly" ? this.deps.identityAuditsWeeklyDir : this.deps.identityAuditsMonthlyDir;
|
|
2577
|
-
const filePath =
|
|
2163
|
+
const filePath = path3.join(dir, `${safeKey}.md`);
|
|
2578
2164
|
await this.deps.writeStorageSecureFile(filePath, content);
|
|
2579
2165
|
return filePath;
|
|
2580
2166
|
}
|
|
@@ -2582,7 +2168,7 @@ var IdentityContinuityStore = class {
|
|
|
2582
2168
|
try {
|
|
2583
2169
|
const safeKey = this.sanitizeIdentityAuditKey(key);
|
|
2584
2170
|
const dir = period === "weekly" ? this.deps.identityAuditsWeeklyDir : this.deps.identityAuditsMonthlyDir;
|
|
2585
|
-
return await this.deps.readStorageSecureFile(
|
|
2171
|
+
return await this.deps.readStorageSecureFile(path3.join(dir, `${safeKey}.md`));
|
|
2586
2172
|
} catch (err) {
|
|
2587
2173
|
if (err instanceof Error && err.message === "Invalid identity audit key") return null;
|
|
2588
2174
|
if (!isErrnoCode(err, "ENOENT")) throw err;
|
|
@@ -2638,12 +2224,12 @@ var IdentityContinuityStore = class {
|
|
|
2638
2224
|
const fileNames = await this.readContinuityIncidentFileNames();
|
|
2639
2225
|
const directMatch = fileNames.find((name) => name.endsWith(`-${id}.md`));
|
|
2640
2226
|
if (directMatch) {
|
|
2641
|
-
const directPath =
|
|
2227
|
+
const directPath = path3.join(this.deps.identityIncidentsDir, directMatch);
|
|
2642
2228
|
const parsed = await this.readContinuityIncidentFile(directPath);
|
|
2643
2229
|
if (parsed?.id === id) return directPath;
|
|
2644
2230
|
}
|
|
2645
2231
|
for (const fileName of fileNames) {
|
|
2646
|
-
const filePath =
|
|
2232
|
+
const filePath = path3.join(this.deps.identityIncidentsDir, fileName);
|
|
2647
2233
|
const parsed = await this.readContinuityIncidentFile(filePath);
|
|
2648
2234
|
if (parsed?.id === id) return filePath;
|
|
2649
2235
|
}
|
|
@@ -2659,19 +2245,19 @@ var IdentityContinuityStore = class {
|
|
|
2659
2245
|
};
|
|
2660
2246
|
|
|
2661
2247
|
// src/storage/entity-canonical-id-migration.ts
|
|
2662
|
-
import { createHash
|
|
2248
|
+
import { createHash, randomUUID } from "crypto";
|
|
2663
2249
|
import {
|
|
2664
2250
|
access,
|
|
2665
|
-
lstat as
|
|
2666
|
-
readFile
|
|
2251
|
+
lstat as lstat2,
|
|
2252
|
+
readFile,
|
|
2667
2253
|
readdir as readdir4,
|
|
2668
2254
|
realpath as realpath2,
|
|
2669
|
-
rename
|
|
2255
|
+
rename,
|
|
2670
2256
|
stat as statFile,
|
|
2671
|
-
unlink as
|
|
2257
|
+
unlink as unlink2,
|
|
2672
2258
|
writeFile
|
|
2673
2259
|
} from "fs/promises";
|
|
2674
|
-
import
|
|
2260
|
+
import path4 from "path";
|
|
2675
2261
|
import { z } from "zod";
|
|
2676
2262
|
var ENTITY_CANONICAL_ID_MIGRATION_VERSION = 1;
|
|
2677
2263
|
var ENTITY_CANONICAL_ID_MIGRATION_LOCK_STALE_MS = 6e4;
|
|
@@ -2696,7 +2282,7 @@ var EntityCanonicalIdMigrationStateSchema = z.object({
|
|
|
2696
2282
|
async function fingerprintPath(filePath) {
|
|
2697
2283
|
let fileStat;
|
|
2698
2284
|
try {
|
|
2699
|
-
fileStat = await
|
|
2285
|
+
fileStat = await lstat2(filePath);
|
|
2700
2286
|
} catch (error) {
|
|
2701
2287
|
if (!isErrnoCode(error, "ENOENT")) throw error;
|
|
2702
2288
|
}
|
|
@@ -2705,16 +2291,16 @@ async function fingerprintPath(filePath) {
|
|
|
2705
2291
|
async function fingerprintEntityEntries(entitiesDir) {
|
|
2706
2292
|
let names;
|
|
2707
2293
|
try {
|
|
2708
|
-
names = (await readdir4(entitiesDir)).filter((name) =>
|
|
2294
|
+
names = (await readdir4(entitiesDir)).filter((name) => path4.extname(name) === ".md").sort();
|
|
2709
2295
|
} catch (error) {
|
|
2710
2296
|
if (isErrnoCode(error, "ENOENT")) return "missing";
|
|
2711
2297
|
throw error;
|
|
2712
2298
|
}
|
|
2713
|
-
const hash =
|
|
2299
|
+
const hash = createHash("sha256");
|
|
2714
2300
|
for (const name of names) {
|
|
2715
2301
|
hash.update(`${name.length}:${name}:`);
|
|
2716
2302
|
try {
|
|
2717
|
-
const entry = await
|
|
2303
|
+
const entry = await lstat2(path4.join(entitiesDir, name), { bigint: true });
|
|
2718
2304
|
hash.update(`${entry.dev}:${entry.ino}:${entry.size}:${entry.mtimeNs}:${entry.ctimeNs}`);
|
|
2719
2305
|
} catch (error) {
|
|
2720
2306
|
if (!isErrnoCode(error, "ENOENT")) throw error;
|
|
@@ -2734,9 +2320,9 @@ async function getFingerprint(baseDir, entitiesDir, getEntityMutationVersion) {
|
|
|
2734
2320
|
] = await Promise.all([
|
|
2735
2321
|
fingerprintPath(entitiesDir),
|
|
2736
2322
|
fingerprintEntityEntries(entitiesDir),
|
|
2737
|
-
fingerprintPath(
|
|
2738
|
-
fingerprintPath(
|
|
2739
|
-
fingerprintPath(
|
|
2323
|
+
fingerprintPath(path4.join(baseDir, "config", "aliases.json")),
|
|
2324
|
+
fingerprintPath(path4.join(baseDir, "state", ENTITY_CANONICAL_ID_RECONCILE_MARKER)),
|
|
2325
|
+
fingerprintPath(path4.join(baseDir, "state", ENTITY_CANONICAL_ID_RECONCILE_CONSUMING_MARKER))
|
|
2740
2326
|
]);
|
|
2741
2327
|
return [
|
|
2742
2328
|
entityDirectoryFingerprint,
|
|
@@ -2750,7 +2336,7 @@ async function getFingerprint(baseDir, entitiesDir, getEntityMutationVersion) {
|
|
|
2750
2336
|
async function validateRoots(baseDir, entitiesDir, stateDir, archiveDir) {
|
|
2751
2337
|
let baseStat;
|
|
2752
2338
|
try {
|
|
2753
|
-
baseStat = await
|
|
2339
|
+
baseStat = await lstat2(baseDir);
|
|
2754
2340
|
} catch (error) {
|
|
2755
2341
|
if (isErrnoCode(error, "ENOENT")) return;
|
|
2756
2342
|
throw error;
|
|
@@ -2762,14 +2348,14 @@ async function validateRoots(baseDir, entitiesDir, stateDir, archiveDir) {
|
|
|
2762
2348
|
const roots = [
|
|
2763
2349
|
entitiesDir,
|
|
2764
2350
|
stateDir,
|
|
2765
|
-
...RECALL_FALLBACK_DIRS.map((directory) =>
|
|
2766
|
-
|
|
2351
|
+
...RECALL_FALLBACK_DIRS.map((directory) => path4.join(baseDir, directory)),
|
|
2352
|
+
path4.join(baseDir, "cold"),
|
|
2767
2353
|
archiveDir
|
|
2768
2354
|
];
|
|
2769
2355
|
for (const root of roots) {
|
|
2770
2356
|
let rootStat;
|
|
2771
2357
|
try {
|
|
2772
|
-
rootStat = await
|
|
2358
|
+
rootStat = await lstat2(root);
|
|
2773
2359
|
} catch (error) {
|
|
2774
2360
|
if (isErrnoCode(error, "ENOENT")) continue;
|
|
2775
2361
|
throw error;
|
|
@@ -2781,13 +2367,13 @@ async function validateRoots(baseDir, entitiesDir, stateDir, archiveDir) {
|
|
|
2781
2367
|
}
|
|
2782
2368
|
}
|
|
2783
2369
|
function statePath(deps) {
|
|
2784
|
-
return
|
|
2370
|
+
return path4.join(deps.stateDir, ENTITY_CANONICAL_ID_MIGRATION_FILE);
|
|
2785
2371
|
}
|
|
2786
2372
|
async function assertSafeMigrationStateFile(deps) {
|
|
2787
2373
|
const migrationStatePath = statePath(deps);
|
|
2788
2374
|
let fileStat;
|
|
2789
2375
|
try {
|
|
2790
|
-
fileStat = await
|
|
2376
|
+
fileStat = await lstat2(migrationStatePath);
|
|
2791
2377
|
} catch (error) {
|
|
2792
2378
|
if (isErrnoCode(error, "ENOENT")) return;
|
|
2793
2379
|
throw error;
|
|
@@ -2806,7 +2392,7 @@ async function assertSafeMigrationStateFile(deps) {
|
|
|
2806
2392
|
async function assertSafeTombstoneFile(deps, tombstonePath) {
|
|
2807
2393
|
let fileStat;
|
|
2808
2394
|
try {
|
|
2809
|
-
fileStat = await
|
|
2395
|
+
fileStat = await lstat2(tombstonePath);
|
|
2810
2396
|
} catch (error) {
|
|
2811
2397
|
if (isErrnoCode(error, "ENOENT")) return false;
|
|
2812
2398
|
throw error;
|
|
@@ -2824,13 +2410,13 @@ async function assertSafeTombstoneFile(deps, tombstonePath) {
|
|
|
2824
2410
|
return true;
|
|
2825
2411
|
}
|
|
2826
2412
|
function lockPath(deps) {
|
|
2827
|
-
return
|
|
2413
|
+
return path4.join(deps.stateDir, "entity-canonical-id-migration.lock");
|
|
2828
2414
|
}
|
|
2829
2415
|
async function readState(deps) {
|
|
2830
2416
|
await assertSafeMigrationStateFile(deps);
|
|
2831
2417
|
let raw;
|
|
2832
2418
|
try {
|
|
2833
|
-
raw = await
|
|
2419
|
+
raw = await readFile(statePath(deps), "utf-8");
|
|
2834
2420
|
} catch (error) {
|
|
2835
2421
|
if (isErrnoCode(error, "ENOENT")) return null;
|
|
2836
2422
|
throw error;
|
|
@@ -2853,13 +2439,13 @@ async function readState(deps) {
|
|
|
2853
2439
|
}
|
|
2854
2440
|
async function writeState(deps, state) {
|
|
2855
2441
|
const destination = statePath(deps);
|
|
2856
|
-
const temporary = `${destination}.${process.pid}.${
|
|
2442
|
+
const temporary = `${destination}.${process.pid}.${randomUUID()}.tmp`;
|
|
2857
2443
|
try {
|
|
2858
2444
|
await writeFile(temporary, `${JSON.stringify(state, null, 2)}
|
|
2859
2445
|
`, "utf-8");
|
|
2860
|
-
await
|
|
2446
|
+
await rename(temporary, destination);
|
|
2861
2447
|
} finally {
|
|
2862
|
-
await
|
|
2448
|
+
await unlink2(temporary).catch(() => void 0);
|
|
2863
2449
|
}
|
|
2864
2450
|
}
|
|
2865
2451
|
async function publishState(deps, state) {
|
|
@@ -2888,7 +2474,7 @@ async function sameFileIdentity(leftPath, rightPath) {
|
|
|
2888
2474
|
async function assertNotSymlink(filePath, label) {
|
|
2889
2475
|
let stat3;
|
|
2890
2476
|
try {
|
|
2891
|
-
stat3 = await
|
|
2477
|
+
stat3 = await lstat2(filePath);
|
|
2892
2478
|
} catch (error) {
|
|
2893
2479
|
if (isErrnoCode(error, "ENOENT")) return;
|
|
2894
2480
|
throw error;
|
|
@@ -2900,7 +2486,7 @@ async function assertNotSymlink(filePath, label) {
|
|
|
2900
2486
|
async function assertNotMemorySymlink(filePath) {
|
|
2901
2487
|
let stat3;
|
|
2902
2488
|
try {
|
|
2903
|
-
stat3 = await
|
|
2489
|
+
stat3 = await lstat2(filePath);
|
|
2904
2490
|
} catch (error) {
|
|
2905
2491
|
if (isErrnoCode(error, "ENOENT")) return;
|
|
2906
2492
|
throw error;
|
|
@@ -2916,13 +2502,13 @@ async function assertEntityContentUnchanged(deps, filePath, expectedContent, leg
|
|
|
2916
2502
|
}
|
|
2917
2503
|
}
|
|
2918
2504
|
async function readSafeEntityEntries(entitiesDir) {
|
|
2919
|
-
const rootStat = await
|
|
2505
|
+
const rootStat = await lstat2(entitiesDir);
|
|
2920
2506
|
if (rootStat.isSymbolicLink() || !rootStat.isDirectory()) {
|
|
2921
2507
|
throw new Error("Refusing entity canonical-id migration through a symlinked or non-directory entities root.");
|
|
2922
2508
|
}
|
|
2923
2509
|
const entries = await readdir4(entitiesDir);
|
|
2924
2510
|
for (const entry of entries) {
|
|
2925
|
-
await assertNotSymlink(
|
|
2511
|
+
await assertNotSymlink(path4.join(entitiesDir, entry), entry);
|
|
2926
2512
|
}
|
|
2927
2513
|
return entries;
|
|
2928
2514
|
}
|
|
@@ -2984,7 +2570,7 @@ async function rewriteReferences(deps, mappings, refreshLock) {
|
|
|
2984
2570
|
const seenPaths = /* @__PURE__ */ new Set();
|
|
2985
2571
|
let rewroteAny = false;
|
|
2986
2572
|
for (const memory of [...hotMemories, ...coldMemories, ...archivedMemories]) {
|
|
2987
|
-
const memoryPath =
|
|
2573
|
+
const memoryPath = path4.resolve(memory.path);
|
|
2988
2574
|
if (seenPaths.has(memoryPath)) continue;
|
|
2989
2575
|
seenPaths.add(memoryPath);
|
|
2990
2576
|
const previousEntityRef = memory.frontmatter.entityRef;
|
|
@@ -3016,7 +2602,7 @@ async function rewriteReferences(deps, mappings, refreshLock) {
|
|
|
3016
2602
|
latestCanonicalId
|
|
3017
2603
|
);
|
|
3018
2604
|
rewroteAny = true;
|
|
3019
|
-
rewroteColdMemory ||= latestMemory.path.includes(`${
|
|
2605
|
+
rewroteColdMemory ||= latestMemory.path.includes(`${path4.sep}cold${path4.sep}`);
|
|
3020
2606
|
}
|
|
3021
2607
|
if (!rewroteAny) return { rewroteColdMemory };
|
|
3022
2608
|
}
|
|
@@ -3055,7 +2641,7 @@ function rewriteTombstoneLine(line, mappings, normalizedMappings) {
|
|
|
3055
2641
|
return changed ? JSON.stringify(tombstone) : line;
|
|
3056
2642
|
}
|
|
3057
2643
|
async function rewriteTombstoneReferences(deps, mappings, refreshLock) {
|
|
3058
|
-
const tombstonePath =
|
|
2644
|
+
const tombstonePath = path4.join(deps.stateDir, "tombstones.jsonl");
|
|
3059
2645
|
const normalizedMappings = /* @__PURE__ */ new Map();
|
|
3060
2646
|
for (const [legacyId, canonicalId] of Object.entries(mappings)) {
|
|
3061
2647
|
const normalizedLegacyId = normalizeSupersessionKey(legacyId);
|
|
@@ -3064,7 +2650,7 @@ async function rewriteTombstoneReferences(deps, mappings, refreshLock) {
|
|
|
3064
2650
|
}
|
|
3065
2651
|
}
|
|
3066
2652
|
await withHeldFileLock(
|
|
3067
|
-
|
|
2653
|
+
path4.join(deps.stateDir, "tombstones.lock"),
|
|
3068
2654
|
{
|
|
3069
2655
|
staleMs: TOMBSTONE_LOCK_STALE_MS,
|
|
3070
2656
|
maxWaitMs: TOMBSTONE_LOCK_MAX_WAIT_MS
|
|
@@ -3252,7 +2838,7 @@ async function migrateEntityFilePair(deps, legacyId, canonicalId, refreshMigrati
|
|
|
3252
2838
|
await deps.snapshotBeforeWrite(legacyPath, "write");
|
|
3253
2839
|
await assertNotSymlink(legacyPath, legacyId);
|
|
3254
2840
|
await assertEntityContentUnchanged(deps, legacyPath, legacyContent, legacyId);
|
|
3255
|
-
await
|
|
2841
|
+
await unlink2(legacyPath);
|
|
3256
2842
|
return { deferred: false, progressed: true };
|
|
3257
2843
|
}
|
|
3258
2844
|
if (!legacyExists) return { deferred: false, progressed: false };
|
|
@@ -3276,13 +2862,13 @@ async function migrateEntityFilePair(deps, legacyId, canonicalId, refreshMigrati
|
|
|
3276
2862
|
await deps.snapshotBeforeWrite(legacyPath, "write");
|
|
3277
2863
|
await assertNotSymlink(legacyPath, legacyId);
|
|
3278
2864
|
await assertEntityContentUnchanged(deps, legacyPath, entityContent, legacyId);
|
|
3279
|
-
await
|
|
2865
|
+
await unlink2(legacyPath);
|
|
3280
2866
|
} catch (error) {
|
|
3281
2867
|
if (!canonicalExists && canonicalFingerprintAfterWrite !== null) {
|
|
3282
2868
|
try {
|
|
3283
2869
|
if (await fingerprintPath(canonicalPath) === canonicalFingerprintAfterWrite) {
|
|
3284
2870
|
await assertNotSymlink(canonicalPath, canonicalId);
|
|
3285
|
-
await
|
|
2871
|
+
await unlink2(canonicalPath);
|
|
3286
2872
|
}
|
|
3287
2873
|
} catch {
|
|
3288
2874
|
}
|
|
@@ -3303,12 +2889,12 @@ async function migrateLegacyEntityCanonicalIds(deps) {
|
|
|
3303
2889
|
if (!acquired) throw new Error("Timed out waiting for active entity canonical-id migration.");
|
|
3304
2890
|
await deps.validateMemoryScanRoots?.();
|
|
3305
2891
|
await readSafeEntityEntries(deps.entitiesDir);
|
|
3306
|
-
const reconcileMarkerPath =
|
|
3307
|
-
const consumingMarkerPath =
|
|
2892
|
+
const reconcileMarkerPath = path4.join(deps.stateDir, ENTITY_CANONICAL_ID_RECONCILE_MARKER);
|
|
2893
|
+
const consumingMarkerPath = path4.join(deps.stateDir, ENTITY_CANONICAL_ID_RECONCILE_CONSUMING_MARKER);
|
|
3308
2894
|
let reconcileRequested = await fileExists(consumingMarkerPath);
|
|
3309
2895
|
if (await fileExists(reconcileMarkerPath)) {
|
|
3310
2896
|
try {
|
|
3311
|
-
await
|
|
2897
|
+
await rename(reconcileMarkerPath, consumingMarkerPath);
|
|
3312
2898
|
reconcileRequested = true;
|
|
3313
2899
|
} catch (error) {
|
|
3314
2900
|
if (!isErrnoCode(error, "ENOENT")) throw error;
|
|
@@ -3331,7 +2917,7 @@ async function migrateLegacyEntityCanonicalIds(deps) {
|
|
|
3331
2917
|
);
|
|
3332
2918
|
}
|
|
3333
2919
|
if (reconcileRequested) {
|
|
3334
|
-
await
|
|
2920
|
+
await unlink2(consumingMarkerPath).catch((error) => {
|
|
3335
2921
|
if (!isErrnoCode(error, "ENOENT")) throw error;
|
|
3336
2922
|
});
|
|
3337
2923
|
}
|
|
@@ -3477,7 +3063,7 @@ async function migrateLegacyEntityCanonicalIds(deps) {
|
|
|
3477
3063
|
}
|
|
3478
3064
|
|
|
3479
3065
|
// src/storage/entity-ref-repair.ts
|
|
3480
|
-
import { unlink as
|
|
3066
|
+
import { unlink as unlink3 } from "fs/promises";
|
|
3481
3067
|
var EntityRefRepair = class {
|
|
3482
3068
|
constructor(deps) {
|
|
3483
3069
|
this.deps = deps;
|
|
@@ -3539,7 +3125,7 @@ ${body}
|
|
|
3539
3125
|
if (opts.onFailRestore) {
|
|
3540
3126
|
await this.restore(opts.onFailRestore);
|
|
3541
3127
|
} else if (opts.onFailRemove) {
|
|
3542
|
-
await
|
|
3128
|
+
await unlink3(opts.onFailRemove).catch(() => void 0);
|
|
3543
3129
|
this.deps.invalidateAllMemoriesCache();
|
|
3544
3130
|
}
|
|
3545
3131
|
throw err;
|
|
@@ -3700,7 +3286,7 @@ import {
|
|
|
3700
3286
|
readFileSync,
|
|
3701
3287
|
realpathSync
|
|
3702
3288
|
} from "fs";
|
|
3703
|
-
import
|
|
3289
|
+
import path5 from "path";
|
|
3704
3290
|
function resolveSafeAliasRoots(baseDir, configDir) {
|
|
3705
3291
|
let baseStat;
|
|
3706
3292
|
try {
|
|
@@ -3727,8 +3313,8 @@ function resolveSafeAliasRoots(baseDir, configDir) {
|
|
|
3727
3313
|
return memoryRoot;
|
|
3728
3314
|
}
|
|
3729
3315
|
function readEntityAliasConfigSync(baseDir) {
|
|
3730
|
-
const configDir =
|
|
3731
|
-
const aliasPath =
|
|
3316
|
+
const configDir = path5.join(baseDir, "config");
|
|
3317
|
+
const aliasPath = path5.join(configDir, "aliases.json");
|
|
3732
3318
|
let memoryRoot = resolveSafeAliasRoots(baseDir, configDir);
|
|
3733
3319
|
if (memoryRoot === void 0) return void 0;
|
|
3734
3320
|
let aliasPreflight;
|
|
@@ -3789,7 +3375,7 @@ function decodeYamlScalar(value) {
|
|
|
3789
3375
|
}
|
|
3790
3376
|
|
|
3791
3377
|
// src/orchestration/qmd-result-resolver.ts
|
|
3792
|
-
import
|
|
3378
|
+
import path6 from "path";
|
|
3793
3379
|
var INTERNAL_QMD_ROOTS = /* @__PURE__ */ new Set([
|
|
3794
3380
|
...ALL_CATEGORY_DIRS,
|
|
3795
3381
|
"activity",
|
|
@@ -3810,7 +3396,7 @@ var INTERNAL_QMD_ROOTS = /* @__PURE__ */ new Set([
|
|
|
3810
3396
|
]);
|
|
3811
3397
|
var PRIVATE_RESULT_RESOLUTION_CONCURRENCY = 16;
|
|
3812
3398
|
function qmdCollectionPathParts(resultPath) {
|
|
3813
|
-
if (!resultPath ||
|
|
3399
|
+
if (!resultPath || path6.isAbsolute(resultPath)) return null;
|
|
3814
3400
|
if (resultPath.trim().startsWith("qmd://")) {
|
|
3815
3401
|
try {
|
|
3816
3402
|
const parsed = new URL(resultPath.trim());
|
|
@@ -3835,9 +3421,9 @@ function qmdCollectionPathParts(resultPath) {
|
|
|
3835
3421
|
}
|
|
3836
3422
|
function qmdResultPathCandidates(storageDir, resultPath) {
|
|
3837
3423
|
const candidates = /* @__PURE__ */ new Set();
|
|
3838
|
-
const storageRoot =
|
|
3424
|
+
const storageRoot = path6.resolve(storageDir);
|
|
3839
3425
|
const addCandidate = (candidate) => {
|
|
3840
|
-
const resolved =
|
|
3426
|
+
const resolved = path6.resolve(candidate);
|
|
3841
3427
|
if (isPathInsideStorageRoot(storageRoot, resolved)) {
|
|
3842
3428
|
candidates.add(resolved);
|
|
3843
3429
|
}
|
|
@@ -3845,18 +3431,18 @@ function qmdResultPathCandidates(storageDir, resultPath) {
|
|
|
3845
3431
|
const addRelativeCandidates = (relativePath) => {
|
|
3846
3432
|
const normalized = relativePath.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
3847
3433
|
if (!normalized) return;
|
|
3848
|
-
addCandidate(
|
|
3434
|
+
addCandidate(path6.join(storageRoot, normalized));
|
|
3849
3435
|
if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
|
|
3850
|
-
addCandidate(
|
|
3436
|
+
addCandidate(path6.join(storageRoot, "facts", normalized));
|
|
3851
3437
|
}
|
|
3852
3438
|
};
|
|
3853
|
-
if (
|
|
3439
|
+
if (path6.isAbsolute(resultPath)) {
|
|
3854
3440
|
addCandidate(resultPath);
|
|
3855
|
-
const relative2 =
|
|
3856
|
-
if (relative2 && !relative2.startsWith("..") && !
|
|
3857
|
-
const normalized = relative2.split(
|
|
3441
|
+
const relative2 = path6.relative(storageRoot, path6.resolve(resultPath));
|
|
3442
|
+
if (relative2 && !relative2.startsWith("..") && !path6.isAbsolute(relative2)) {
|
|
3443
|
+
const normalized = relative2.split(path6.sep).join("/");
|
|
3858
3444
|
if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
|
|
3859
|
-
addCandidate(
|
|
3445
|
+
addCandidate(path6.join(storageRoot, "facts", normalized));
|
|
3860
3446
|
}
|
|
3861
3447
|
}
|
|
3862
3448
|
} else {
|
|
@@ -3892,7 +3478,7 @@ var QmdResultResolver = class {
|
|
|
3892
3478
|
const seenStorageDirs = /* @__PURE__ */ new Set();
|
|
3893
3479
|
const addStorage = (storage) => {
|
|
3894
3480
|
const storageDir = storageDirOrNull(storage);
|
|
3895
|
-
const storageKey = storageDir ?
|
|
3481
|
+
const storageKey = storageDir ? path6.resolve(storageDir) : `storage-without-dir-${storages.length}`;
|
|
3896
3482
|
if (seenStorageDirs.has(storageKey)) return;
|
|
3897
3483
|
seenStorageDirs.add(storageKey);
|
|
3898
3484
|
storages.push(storage);
|
|
@@ -3922,7 +3508,7 @@ var QmdResultResolver = class {
|
|
|
3922
3508
|
continue;
|
|
3923
3509
|
}
|
|
3924
3510
|
try {
|
|
3925
|
-
const coldRoot =
|
|
3511
|
+
const coldRoot = path6.join(storageDir, "cold");
|
|
3926
3512
|
for (const candidate of qmdResultPathCandidates(coldRoot, parts.relativePath)) {
|
|
3927
3513
|
const memory = await storage.readMemoryByPath(candidate);
|
|
3928
3514
|
if (memory) return memory;
|
|
@@ -3972,9 +3558,9 @@ var QmdResultResolver = class {
|
|
|
3972
3558
|
error: err.message
|
|
3973
3559
|
});
|
|
3974
3560
|
}
|
|
3975
|
-
if (!
|
|
3561
|
+
if (!path6.isAbsolute(fallbackResultPath)) return null;
|
|
3976
3562
|
}
|
|
3977
|
-
if (
|
|
3563
|
+
if (path6.isAbsolute(fallbackResultPath)) {
|
|
3978
3564
|
if (!fallbackStorageDir) {
|
|
3979
3565
|
return await fallbackStorage.readMemoryByPath(fallbackResultPath);
|
|
3980
3566
|
}
|
|
@@ -4031,17 +3617,17 @@ var QmdResultResolver = class {
|
|
|
4031
3617
|
if (!memory && parts && !collectionIsKnownInternal && !collectionIsConfigured) {
|
|
4032
3618
|
memory = await this.readQmdResultMemory(parts.relativePath, fallbackStorage, namespaces, result.namespace);
|
|
4033
3619
|
}
|
|
4034
|
-
const absoluteInsideMemoryRoot =
|
|
3620
|
+
const absoluteInsideMemoryRoot = path6.isAbsolute(result.path) && isPathInsideStorageRoot(path6.resolve(config.memoryDir), path6.resolve(result.path));
|
|
4035
3621
|
const hasExplicitQmdCollection = result.path.trim().startsWith("qmd://");
|
|
4036
3622
|
const unresolvedInternalPath = !memory && (absoluteInsideMemoryRoot || collectionIsKnownInternal && (!preserveUnresolved || hasExplicitQmdCollection) || hasExplicitQmdCollection && collectionIsConfigured);
|
|
4037
|
-
const unresolvedExternalCollection = !memory && (parts !== null && !collectionIsKnownInternal && !collectionIsConfigured ||
|
|
3623
|
+
const unresolvedExternalCollection = !memory && (parts !== null && !collectionIsKnownInternal && !collectionIsConfigured || path6.isAbsolute(result.path) && !isPathInsideStorageRoot(path6.resolve(config.memoryDir), path6.resolve(result.path)));
|
|
4038
3624
|
return memory !== null && !isSupportPassportPrivateMemory(memory) || !memory && !unresolvedInternalPath && (preserveUnresolved || unresolvedExternalCollection);
|
|
4039
3625
|
}
|
|
4040
3626
|
async resolveColdQmdResultForRecall(result, fallbackStorage, recallNamespaces = []) {
|
|
4041
3627
|
const memory = await this.readQmdResultMemory(result.path, fallbackStorage, recallNamespaces, result.namespace);
|
|
4042
3628
|
if (!memory) return null;
|
|
4043
3629
|
let ownerNamespace = null;
|
|
4044
|
-
if (
|
|
3630
|
+
if (path6.isAbsolute(memory.path)) {
|
|
4045
3631
|
const ownerStorage = await this.storageForAbsoluteQmdResultPath(memory.path, fallbackStorage, recallNamespaces);
|
|
4046
3632
|
ownerNamespace = ownerStorage?.namespace ?? null;
|
|
4047
3633
|
if (!ownerNamespace && resolveNamespaceCapabilities(this.getConfig()).namespaces) return null;
|
|
@@ -4061,17 +3647,17 @@ var QmdResultResolver = class {
|
|
|
4061
3647
|
};
|
|
4062
3648
|
}
|
|
4063
3649
|
async storageForAbsoluteQmdResultPath(resultPath, fallbackStorage, recallNamespaces = []) {
|
|
4064
|
-
const resolvedPath =
|
|
3650
|
+
const resolvedPath = path6.resolve(resultPath);
|
|
4065
3651
|
const config = this.getConfig();
|
|
4066
|
-
const memoryRoot =
|
|
4067
|
-
const namespacesRoot =
|
|
3652
|
+
const memoryRoot = path6.resolve(config.memoryDir);
|
|
3653
|
+
const namespacesRoot = path6.join(memoryRoot, "namespaces");
|
|
4068
3654
|
const fallbackStorageDir = storageDirOrNull(fallbackStorage);
|
|
4069
3655
|
const matches = [];
|
|
4070
3656
|
const seenDirs = /* @__PURE__ */ new Set();
|
|
4071
3657
|
const maybeAddStorage = (storage, namespace) => {
|
|
4072
3658
|
const storageDir = storageDirOrNull(storage);
|
|
4073
3659
|
if (!storageDir) return;
|
|
4074
|
-
const candidateRoot =
|
|
3660
|
+
const candidateRoot = path6.resolve(storageDir);
|
|
4075
3661
|
if (seenDirs.has(candidateRoot)) return;
|
|
4076
3662
|
if (!isPathInsideStorageRoot(candidateRoot, resolvedPath)) return;
|
|
4077
3663
|
if (candidateRoot === memoryRoot && isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
|
|
@@ -4089,7 +3675,7 @@ var QmdResultResolver = class {
|
|
|
4089
3675
|
candidateNamespaces.add(ns);
|
|
4090
3676
|
}
|
|
4091
3677
|
if (isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
|
|
4092
|
-
const relativeToNamespaces =
|
|
3678
|
+
const relativeToNamespaces = path6.relative(namespacesRoot, resolvedPath);
|
|
4093
3679
|
const [namespaceSegment] = relativeToNamespaces.split(/[\\/]/);
|
|
4094
3680
|
if (namespaceSegment) {
|
|
4095
3681
|
candidateNamespaces.add(namespaceIdentityFromToken(namespaceSegment) ?? namespaceSegment);
|
|
@@ -4630,7 +4216,7 @@ function collectSpeakers(tagged) {
|
|
|
4630
4216
|
}
|
|
4631
4217
|
|
|
4632
4218
|
// src/wearables/fusion/fuse.ts
|
|
4633
|
-
import { createHash as
|
|
4219
|
+
import { createHash as createHash2 } from "crypto";
|
|
4634
4220
|
var FUSION_ID_PREFIX = "fusion";
|
|
4635
4221
|
var FUSION_ALGO_VERSION = "2026-07-12-1";
|
|
4636
4222
|
function canonicalInputsKey(date, inputs) {
|
|
@@ -4659,7 +4245,7 @@ function canonicalInputsKey(date, inputs) {
|
|
|
4659
4245
|
])
|
|
4660
4246
|
])
|
|
4661
4247
|
];
|
|
4662
|
-
return
|
|
4248
|
+
return createHash2("sha256").update(JSON.stringify(record), "utf-8").digest("hex");
|
|
4663
4249
|
}
|
|
4664
4250
|
function configFingerprint(options, sources) {
|
|
4665
4251
|
const proximityGapMs = options.proximityGapMs ?? DEFAULT_PROXIMITY_GAP_MS;
|
|
@@ -4674,7 +4260,7 @@ function canonicalDayKey(date, inputs, options, algoVersion = FUSION_ALGO_VERSIO
|
|
|
4674
4260
|
options,
|
|
4675
4261
|
inputs.map((conv) => conv.source)
|
|
4676
4262
|
);
|
|
4677
|
-
return
|
|
4263
|
+
return createHash2("sha256").update(inputsKey).update("\n").update(fingerprint).update("\n").update(algoVersion).digest("hex");
|
|
4678
4264
|
}
|
|
4679
4265
|
function buildProvenance(cluster, proximityGapMs, windowToleranceMs) {
|
|
4680
4266
|
return {
|
|
@@ -4734,11 +4320,11 @@ function fuseDay(date, inputs, options = {}) {
|
|
|
4734
4320
|
}
|
|
4735
4321
|
|
|
4736
4322
|
// src/wearables/fusion/store.ts
|
|
4737
|
-
import { createHash as
|
|
4738
|
-
import * as
|
|
4323
|
+
import { createHash as createHash3 } from "crypto";
|
|
4324
|
+
import * as path7 from "path";
|
|
4739
4325
|
var FUSION_KIND = "wearable-fusion";
|
|
4740
4326
|
function hashFusionBody(conversations) {
|
|
4741
|
-
return
|
|
4327
|
+
return createHash3("sha256").update(JSON.stringify(conversations), "utf-8").digest("hex");
|
|
4742
4328
|
}
|
|
4743
4329
|
function composeFusionDayMeta(date, conversations, sources, contentHash, fusedAt) {
|
|
4744
4330
|
return {
|
|
@@ -4922,7 +4508,7 @@ var FusionArtifactStore = class {
|
|
|
4922
4508
|
`invalid wearable fusion date '${String(date)}' \u2014 expected YYYY-MM-DD`
|
|
4923
4509
|
);
|
|
4924
4510
|
}
|
|
4925
|
-
return
|
|
4511
|
+
return path7.join(this.wearablesDir, FUSION_DIR_NAME, `${date}.md`);
|
|
4926
4512
|
}
|
|
4927
4513
|
async writeFusedDay(date, serialized) {
|
|
4928
4514
|
const filePath = this.fusedDayPath(date);
|
|
@@ -4959,7 +4545,7 @@ var FusionArtifactStore = class {
|
|
|
4959
4545
|
}
|
|
4960
4546
|
/** List dates with stored fused artifacts, newest first. */
|
|
4961
4547
|
async listFusedDays() {
|
|
4962
|
-
const fusionDir =
|
|
4548
|
+
const fusionDir = path7.join(this.wearablesDir, FUSION_DIR_NAME);
|
|
4963
4549
|
await this.assertPathContained(fusionDir);
|
|
4964
4550
|
let entries;
|
|
4965
4551
|
try {
|
|
@@ -5003,10 +4589,10 @@ var FusionArtifactStore = class {
|
|
|
5003
4589
|
try {
|
|
5004
4590
|
rootReal = await this.io.realpath(this.memoryDir);
|
|
5005
4591
|
} catch {
|
|
5006
|
-
rootReal =
|
|
4592
|
+
rootReal = path7.resolve(this.memoryDir);
|
|
5007
4593
|
}
|
|
5008
4594
|
await this.assertNoEscape(rootReal, this.wearablesDir);
|
|
5009
|
-
await this.assertNoEscape(rootReal,
|
|
4595
|
+
await this.assertNoEscape(rootReal, path7.dirname(targetPath));
|
|
5010
4596
|
await this.assertNoEscape(rootReal, targetPath);
|
|
5011
4597
|
await this.assertFusionDirNotSymlinked();
|
|
5012
4598
|
}
|
|
@@ -5020,7 +4606,7 @@ var FusionArtifactStore = class {
|
|
|
5020
4606
|
* (a fresh write creates a real directory lexically under the root).
|
|
5021
4607
|
*/
|
|
5022
4608
|
async assertFusionDirNotSymlinked() {
|
|
5023
|
-
const fusionDir =
|
|
4609
|
+
const fusionDir = path7.join(this.wearablesDir, FUSION_DIR_NAME);
|
|
5024
4610
|
let stat3;
|
|
5025
4611
|
try {
|
|
5026
4612
|
stat3 = await this.io.lstat(fusionDir);
|
|
@@ -5155,8 +4741,8 @@ function reconstructFusionInputs(date, dayTranscripts) {
|
|
|
5155
4741
|
}
|
|
5156
4742
|
|
|
5157
4743
|
// src/meetings/store.ts
|
|
5158
|
-
import { createHash as
|
|
5159
|
-
import * as
|
|
4744
|
+
import { createHash as createHash4 } from "crypto";
|
|
4745
|
+
import * as path8 from "path";
|
|
5160
4746
|
var MEETINGS_DIR_NAME = "meetings";
|
|
5161
4747
|
var MEETING_KIND = "meeting";
|
|
5162
4748
|
var MEETING_FORMAT_VERSION = 1;
|
|
@@ -5186,7 +4772,7 @@ function canonicalContent(base, fused) {
|
|
|
5186
4772
|
});
|
|
5187
4773
|
}
|
|
5188
4774
|
function composeMeetingRecord(base, fused) {
|
|
5189
|
-
const contentHash =
|
|
4775
|
+
const contentHash = createHash4("sha256").update(canonicalContent(base, fused), "utf-8").digest("hex");
|
|
5190
4776
|
return {
|
|
5191
4777
|
...base,
|
|
5192
4778
|
...fused,
|
|
@@ -5325,7 +4911,7 @@ var MeetingRecordStore = class {
|
|
|
5325
4911
|
constructor(memoryDir, io) {
|
|
5326
4912
|
this.memoryDir = memoryDir;
|
|
5327
4913
|
this.io = io;
|
|
5328
|
-
this.meetingsDir =
|
|
4914
|
+
this.meetingsDir = path8.join(memoryDir, MEETINGS_DIR_NAME);
|
|
5329
4915
|
}
|
|
5330
4916
|
memoryDir;
|
|
5331
4917
|
io;
|
|
@@ -5341,7 +4927,7 @@ var MeetingRecordStore = class {
|
|
|
5341
4927
|
if (idDate !== date) {
|
|
5342
4928
|
throw new Error(`meeting id '${id}' does not belong to date '${date}'`);
|
|
5343
4929
|
}
|
|
5344
|
-
return
|
|
4930
|
+
return path8.join(this.meetingsDir, date, `${id}.md`);
|
|
5345
4931
|
}
|
|
5346
4932
|
/** Idempotently persist a record: skip the write when contentHash is unchanged. */
|
|
5347
4933
|
async saveMeetingRecord(record) {
|
|
@@ -5372,7 +4958,7 @@ var MeetingRecordStore = class {
|
|
|
5372
4958
|
if (!isValidTranscriptDate(date)) {
|
|
5373
4959
|
throw new Error(`invalid meeting date '${String(date)}' \u2014 expected YYYY-MM-DD`);
|
|
5374
4960
|
}
|
|
5375
|
-
const dayDir =
|
|
4961
|
+
const dayDir = path8.join(this.meetingsDir, date);
|
|
5376
4962
|
await this.assertPathContained(dayDir);
|
|
5377
4963
|
let entries;
|
|
5378
4964
|
try {
|
|
@@ -5440,10 +5026,10 @@ var MeetingRecordStore = class {
|
|
|
5440
5026
|
try {
|
|
5441
5027
|
rootReal = await this.io.realpath(this.memoryDir);
|
|
5442
5028
|
} catch {
|
|
5443
|
-
rootReal =
|
|
5029
|
+
rootReal = path8.resolve(this.memoryDir);
|
|
5444
5030
|
}
|
|
5445
5031
|
await this.assertNoEscape(rootReal, this.meetingsDir);
|
|
5446
|
-
await this.assertNoEscape(rootReal,
|
|
5032
|
+
await this.assertNoEscape(rootReal, path8.dirname(targetPath));
|
|
5447
5033
|
await this.assertNoEscape(rootReal, targetPath);
|
|
5448
5034
|
await this.assertNotSymlink(this.meetingsDir, "directory");
|
|
5449
5035
|
const dayDir = this.dayDirWithin(targetPath);
|
|
@@ -5453,11 +5039,11 @@ var MeetingRecordStore = class {
|
|
|
5453
5039
|
/** The `<meetings>/<date>` directory on the path to `targetPath`, or null when
|
|
5454
5040
|
* `targetPath` is the meetings root itself. */
|
|
5455
5041
|
dayDirWithin(targetPath) {
|
|
5456
|
-
const rel =
|
|
5457
|
-
if (rel === "" || rel.startsWith("..") ||
|
|
5458
|
-
const first = rel.split(
|
|
5042
|
+
const rel = path8.relative(this.meetingsDir, targetPath);
|
|
5043
|
+
if (rel === "" || rel.startsWith("..") || path8.isAbsolute(rel)) return null;
|
|
5044
|
+
const first = rel.split(path8.sep)[0];
|
|
5459
5045
|
if (first === void 0 || first.length === 0) return null;
|
|
5460
|
-
return
|
|
5046
|
+
return path8.join(this.meetingsDir, first);
|
|
5461
5047
|
}
|
|
5462
5048
|
async assertNotSymlink(target, kind) {
|
|
5463
5049
|
let stat3;
|
|
@@ -5468,7 +5054,7 @@ var MeetingRecordStore = class {
|
|
|
5468
5054
|
throw err;
|
|
5469
5055
|
}
|
|
5470
5056
|
if (stat3.isSymbolicLink) {
|
|
5471
|
-
const label =
|
|
5057
|
+
const label = path8.relative(this.memoryDir, target) || MEETINGS_DIR_NAME;
|
|
5472
5058
|
throw new Error(
|
|
5473
5059
|
`meetings ${kind} '${label}' is a symbolic link \u2014 refusing to follow it even when it resolves inside the memory dir (AGENTS.md pattern #3)`
|
|
5474
5060
|
);
|
|
@@ -5492,7 +5078,7 @@ var SORT_STR = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
|
5492
5078
|
|
|
5493
5079
|
// src/storage/supersession-audit.ts
|
|
5494
5080
|
import { readdir as readdir5 } from "fs/promises";
|
|
5495
|
-
import
|
|
5081
|
+
import path9 from "path";
|
|
5496
5082
|
async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody, structuredAttributes) {
|
|
5497
5083
|
let entries;
|
|
5498
5084
|
try {
|
|
@@ -5503,7 +5089,7 @@ async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody,
|
|
|
5503
5089
|
}
|
|
5504
5090
|
for (const entry of entries) {
|
|
5505
5091
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
5506
|
-
const memory = await lookup.readMemoryByPath(
|
|
5092
|
+
const memory = await lookup.readMemoryByPath(path9.join(lookup.correctionsDir, entry.name));
|
|
5507
5093
|
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(
|
|
5508
5094
|
([key, value]) => memory.frontmatter.structuredAttributes?.[key] === value
|
|
5509
5095
|
))) {
|
|
@@ -5593,7 +5179,7 @@ Reason: ${reason}`;
|
|
|
5593
5179
|
}
|
|
5594
5180
|
|
|
5595
5181
|
// src/storage/entity-timeline.ts
|
|
5596
|
-
import { createHash as
|
|
5182
|
+
import { createHash as createHash5 } from "crypto";
|
|
5597
5183
|
function parseEntityTimelineBullet(bullet, fallbackTimestamp) {
|
|
5598
5184
|
const trimmed = bullet.trim();
|
|
5599
5185
|
if (!trimmed) return null;
|
|
@@ -5965,7 +5551,7 @@ function fingerprintEntityStructuredFacts(entity) {
|
|
|
5965
5551
|
(left, right) => left.key.localeCompare(right.key) || left.title.localeCompare(right.title) || left.facts.join("\n").localeCompare(right.facts.join("\n"))
|
|
5966
5552
|
);
|
|
5967
5553
|
if (normalizedSections.length === 0) return void 0;
|
|
5968
|
-
return
|
|
5554
|
+
return createHash5("sha256").update(JSON.stringify(normalizedSections)).digest("hex");
|
|
5969
5555
|
}
|
|
5970
5556
|
function isEntitySynthesisStale(entity) {
|
|
5971
5557
|
const structuredFactCount = countEntityStructuredFacts(entity);
|
|
@@ -6512,17 +6098,17 @@ function inferEntityTypeFromContent(content) {
|
|
|
6512
6098
|
}
|
|
6513
6099
|
var KNOWN_ENTITY_FILENAME_PREFIXES = /* @__PURE__ */ new Set(["company", "other", "person", "place", "project", "tool", "topic"]);
|
|
6514
6100
|
function inferEntityTypeFromFilename(pathRel) {
|
|
6515
|
-
const basename =
|
|
6101
|
+
const basename = path10.basename(pathRel, ".md").toLowerCase();
|
|
6516
6102
|
const separator = basename.indexOf("-");
|
|
6517
6103
|
if (separator <= 0) return void 0;
|
|
6518
6104
|
const candidate = basename.slice(0, separator);
|
|
6519
6105
|
return KNOWN_ENTITY_FILENAME_PREFIXES.has(candidate) ? candidate : void 0;
|
|
6520
6106
|
}
|
|
6521
6107
|
function normalizeFrontmatterForPath(frontmatter, pathRel, content = "") {
|
|
6522
|
-
const normalizedPath = pathRel.split(
|
|
6108
|
+
const normalizedPath = pathRel.split(path10.sep).join("/");
|
|
6523
6109
|
let normalizedFrontmatter = frontmatter;
|
|
6524
6110
|
if (normalizedPath === "entities" || normalizedPath.startsWith("entities/") || normalizedPath.includes("/entities/")) {
|
|
6525
|
-
const basename =
|
|
6111
|
+
const basename = path10.basename(pathRel, ".md");
|
|
6526
6112
|
const inferredType = inferEntityTypeFromContent(content) || inferEntityTypeFromFilename(pathRel) || "entity";
|
|
6527
6113
|
const existingTags = Array.isArray(frontmatter.tags) ? frontmatter.tags : [];
|
|
6528
6114
|
normalizedFrontmatter = {
|
|
@@ -6989,9 +6575,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
6989
6575
|
this.entitySchemas = entitySchemas;
|
|
6990
6576
|
this.deletionRevisionStore = new DeletionRevisionStore({
|
|
6991
6577
|
baseDir,
|
|
6992
|
-
deletionRevisionMetadataPath:
|
|
6993
|
-
invalidationCommitMetadataPath:
|
|
6994
|
-
deletionRevisionLockPath:
|
|
6578
|
+
deletionRevisionMetadataPath: path10.join(baseDir, ".offline-sync", "deletion-revisions.v1.json"),
|
|
6579
|
+
invalidationCommitMetadataPath: path10.join(baseDir, ".offline-sync", "invalidation-commits.v1.json"),
|
|
6580
|
+
deletionRevisionLockPath: path10.join(baseDir, ".offline-sync", "deletion-revisions.v1.json.lock"),
|
|
6995
6581
|
assertManagedStoragePath: (filePath, method) => this.assertManagedStoragePath(filePath, method)
|
|
6996
6582
|
});
|
|
6997
6583
|
this.hotMemoriesCacheEnabled = hotMemoriesCacheEnabledOverride ?? _StorageManager.hotMemoriesCacheDefaultByDir.get(baseDir) ?? _StorageManager.hotMemoriesCacheDefault;
|
|
@@ -7179,8 +6765,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7179
6765
|
}
|
|
7180
6766
|
/** Whether `filePath` resolves to `stateDir` itself or a path contained in it. */
|
|
7181
6767
|
isStateFilePath(filePath) {
|
|
7182
|
-
const rel =
|
|
7183
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
6768
|
+
const rel = path10.relative(this.stateDir, path10.resolve(filePath));
|
|
6769
|
+
return rel === "" || !rel.startsWith("..") && !path10.isAbsolute(rel);
|
|
7184
6770
|
}
|
|
7185
6771
|
// ── Tombstone store (issue #1579) ───────────────────────────────────────
|
|
7186
6772
|
// Instance-scoped (rule 11) + namespace-scoped (rule 42) tombstone index.
|
|
@@ -7295,8 +6881,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7295
6881
|
* /srv/cold/remnic), skipping the patch and stranding a stale hot entry.
|
|
7296
6882
|
*/
|
|
7297
6883
|
isColdOrArchiveTierPath(p) {
|
|
7298
|
-
const rel =
|
|
7299
|
-
return rel === "cold" || rel === "archive" || rel.startsWith(`cold${
|
|
6884
|
+
const rel = path10.relative(this.baseDir, p);
|
|
6885
|
+
return rel === "cold" || rel === "archive" || rel.startsWith(`cold${path10.sep}`) || rel.startsWith(`archive${path10.sep}`);
|
|
7300
6886
|
}
|
|
7301
6887
|
/**
|
|
7302
6888
|
* Mark the secure-store as required for this storage instance.
|
|
@@ -7383,7 +6969,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7383
6969
|
void 0,
|
|
7384
6970
|
this.baseDir
|
|
7385
6971
|
);
|
|
7386
|
-
const rel =
|
|
6972
|
+
const rel = path10.relative(this.baseDir, filePath).split(path10.sep).join("/");
|
|
7387
6973
|
return `${rel}:${version.versionId}`;
|
|
7388
6974
|
} catch (err) {
|
|
7389
6975
|
log.warn(
|
|
@@ -7463,12 +7049,12 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7463
7049
|
}
|
|
7464
7050
|
identityFilePath(workspaceDir, namespace) {
|
|
7465
7051
|
const rawNamespace = typeof namespace === "string" ? namespace.trim() : "";
|
|
7466
|
-
if (!rawNamespace) return
|
|
7052
|
+
if (!rawNamespace) return path10.join(workspaceDir, "IDENTITY.md");
|
|
7467
7053
|
const safeNamespace = rawNamespace.replace(/[^a-zA-Z0-9._-]/g, "-");
|
|
7468
|
-
return
|
|
7054
|
+
return path10.join(workspaceDir, `IDENTITY.${safeNamespace}.md`);
|
|
7469
7055
|
}
|
|
7470
7056
|
versionFilePath(kind) {
|
|
7471
|
-
return
|
|
7057
|
+
return path10.join(this.stateDir, `.${kind}-version.log`);
|
|
7472
7058
|
}
|
|
7473
7059
|
bumpSharedVersion(kind, fallbackMap) {
|
|
7474
7060
|
const filePath = this.versionFilePath(kind);
|
|
@@ -7572,7 +7158,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7572
7158
|
// memories.
|
|
7573
7159
|
// -------------------------------------------------------------------------
|
|
7574
7160
|
get wearablesDir() {
|
|
7575
|
-
return
|
|
7161
|
+
return path10.join(this.baseDir, WEARABLES_DIR_NAME);
|
|
7576
7162
|
}
|
|
7577
7163
|
/**
|
|
7578
7164
|
* Resolve the on-disk path for a source/day transcript. Throws on
|
|
@@ -7588,7 +7174,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7588
7174
|
if (!isValidTranscriptDate(date)) {
|
|
7589
7175
|
throw new Error(`invalid wearable transcript date '${String(date)}' \u2014 expected YYYY-MM-DD`);
|
|
7590
7176
|
}
|
|
7591
|
-
return
|
|
7177
|
+
return path10.join(this.wearablesDir, sourceId, `${date}.md`);
|
|
7592
7178
|
}
|
|
7593
7179
|
async writeWearableDayTranscript(sourceId, date, serialized) {
|
|
7594
7180
|
const targetPath = this.wearableTranscriptPath(sourceId, date);
|
|
@@ -7615,9 +7201,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7615
7201
|
writeFile: (p, c) => this.writeStorageSecureFile(p, c),
|
|
7616
7202
|
readFile: (p) => readMaybeEncryptedFile(p, this._secureStoreKey, this.baseDir),
|
|
7617
7203
|
readDir: (d) => readdir6(d),
|
|
7618
|
-
deleteFile: (p) =>
|
|
7204
|
+
deleteFile: (p) => unlink4(p),
|
|
7619
7205
|
realpath: (p) => realpath3(p),
|
|
7620
|
-
lstat: (p) =>
|
|
7206
|
+
lstat: (p) => lstat3(p).then((st) => ({ isSymbolicLink: st.isSymbolicLink() }))
|
|
7621
7207
|
});
|
|
7622
7208
|
}
|
|
7623
7209
|
_meetingRecordStore;
|
|
@@ -7633,9 +7219,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7633
7219
|
writeFile: (p, c) => this.writeStorageSecureFile(p, c),
|
|
7634
7220
|
readFile: (p) => readMaybeEncryptedFile(p, this._secureStoreKey, this.baseDir),
|
|
7635
7221
|
readDir: (d) => readdir6(d),
|
|
7636
|
-
deleteFile: (p) =>
|
|
7222
|
+
deleteFile: (p) => unlink4(p),
|
|
7637
7223
|
realpath: (p) => realpath3(p),
|
|
7638
|
-
lstat: (p) =>
|
|
7224
|
+
lstat: (p) => lstat3(p).then((st) => ({ isSymbolicLink: st.isSymbolicLink() }))
|
|
7639
7225
|
});
|
|
7640
7226
|
}
|
|
7641
7227
|
/**
|
|
@@ -7704,25 +7290,25 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7704
7290
|
});
|
|
7705
7291
|
}
|
|
7706
7292
|
get factsDir() {
|
|
7707
|
-
return
|
|
7293
|
+
return path10.join(this.baseDir, "facts");
|
|
7708
7294
|
}
|
|
7709
7295
|
get correctionsDir() {
|
|
7710
|
-
return
|
|
7296
|
+
return path10.join(this.baseDir, "corrections");
|
|
7711
7297
|
}
|
|
7712
7298
|
get proceduresDir() {
|
|
7713
|
-
return
|
|
7299
|
+
return path10.join(this.baseDir, "procedures");
|
|
7714
7300
|
}
|
|
7715
7301
|
get reasoningTracesDir() {
|
|
7716
|
-
return
|
|
7302
|
+
return path10.join(this.baseDir, "reasoning-traces");
|
|
7717
7303
|
}
|
|
7718
7304
|
get entitiesDir() {
|
|
7719
|
-
return
|
|
7305
|
+
return path10.join(this.baseDir, "entities");
|
|
7720
7306
|
}
|
|
7721
7307
|
resolveEntityFilePath(name) {
|
|
7722
7308
|
if (typeof name !== "string") return null;
|
|
7723
|
-
const filePath =
|
|
7724
|
-
const relative2 =
|
|
7725
|
-
if (relative2 === "" || relative2.startsWith("..") ||
|
|
7309
|
+
const filePath = path10.resolve(this.entitiesDir, `${name}.md`);
|
|
7310
|
+
const relative2 = path10.relative(this.entitiesDir, filePath);
|
|
7311
|
+
if (relative2 === "" || relative2.startsWith("..") || path10.isAbsolute(relative2)) {
|
|
7726
7312
|
return null;
|
|
7727
7313
|
}
|
|
7728
7314
|
return filePath;
|
|
@@ -7733,7 +7319,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7733
7319
|
async readDependencyPropagationQueueFile(filePath) {
|
|
7734
7320
|
const target = await resolveSafeStoragePath(
|
|
7735
7321
|
this.baseDir,
|
|
7736
|
-
|
|
7322
|
+
path10.relative(
|
|
7737
7323
|
this.baseDir,
|
|
7738
7324
|
this.assertManagedStoragePath(filePath, "storage.readDependencyPropagationQueueFile")
|
|
7739
7325
|
)
|
|
@@ -7743,7 +7329,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7743
7329
|
async writeDependencyPropagationQueueFile(filePath, content) {
|
|
7744
7330
|
const target = await resolveSafeStoragePath(
|
|
7745
7331
|
this.baseDir,
|
|
7746
|
-
|
|
7332
|
+
path10.relative(
|
|
7747
7333
|
this.baseDir,
|
|
7748
7334
|
this.assertManagedStoragePath(filePath, "storage.writeDependencyPropagationQueueFile")
|
|
7749
7335
|
)
|
|
@@ -7757,10 +7343,10 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7757
7343
|
});
|
|
7758
7344
|
}
|
|
7759
7345
|
assertManagedStoragePath(filePath, method) {
|
|
7760
|
-
const resolved =
|
|
7761
|
-
const base =
|
|
7762
|
-
const rel =
|
|
7763
|
-
if (rel === "" || rel === ".." || rel.startsWith(`..${
|
|
7346
|
+
const resolved = path10.resolve(filePath);
|
|
7347
|
+
const base = path10.resolve(this.baseDir);
|
|
7348
|
+
const rel = path10.relative(base, resolved);
|
|
7349
|
+
if (rel === "" || rel === ".." || rel.startsWith(`..${path10.sep}`) || path10.isAbsolute(rel)) {
|
|
7764
7350
|
throw new Error(`${method}: file path escapes memory dir`);
|
|
7765
7351
|
}
|
|
7766
7352
|
return resolved;
|
|
@@ -7793,7 +7379,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7793
7379
|
async digestOfflineSyncFile(filePath) {
|
|
7794
7380
|
const target = this.assertManagedStoragePath(filePath, "storage.digestOfflineSyncFile");
|
|
7795
7381
|
const st = await stat2(target);
|
|
7796
|
-
const relPath =
|
|
7382
|
+
const relPath = path10.relative(this.baseDir, target).split(path10.sep).join("/");
|
|
7797
7383
|
const cache = await this.loadOfflineSyncDigestCache();
|
|
7798
7384
|
const cached = cache.get(relPath);
|
|
7799
7385
|
if (cached && cached.statBytes === st.size && cached.mtimeMs === st.mtimeMs && cached.ctimeMs === st.ctimeMs && !cached.encrypted) {
|
|
@@ -7807,11 +7393,11 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7807
7393
|
if (encrypted) {
|
|
7808
7394
|
const content = await readMaybeEncryptedFileBuffer(target, this._secureStoreKey, this.baseDir);
|
|
7809
7395
|
digest = {
|
|
7810
|
-
sha256:
|
|
7396
|
+
sha256: createHash6("sha256").update(content).digest("hex"),
|
|
7811
7397
|
bytes: content.byteLength
|
|
7812
7398
|
};
|
|
7813
7399
|
} else {
|
|
7814
|
-
const hash =
|
|
7400
|
+
const hash = createHash6("sha256");
|
|
7815
7401
|
let bytes = 0;
|
|
7816
7402
|
for await (const rawChunk of createReadStream(target)) {
|
|
7817
7403
|
const chunk = Buffer.isBuffer(rawChunk) ? rawChunk : Buffer.from(rawChunk);
|
|
@@ -7839,7 +7425,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7839
7425
|
async readOfflineSyncDigestCache() {
|
|
7840
7426
|
const cache = /* @__PURE__ */ new Map();
|
|
7841
7427
|
try {
|
|
7842
|
-
const raw = await
|
|
7428
|
+
const raw = await readFile2(this.offlineSyncDigestCachePath, "utf-8");
|
|
7843
7429
|
const parsed = JSON.parse(raw);
|
|
7844
7430
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return cache;
|
|
7845
7431
|
const entries = parsed.entries;
|
|
@@ -7854,7 +7440,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7854
7440
|
const bytes = typeof record.bytes === "number" ? record.bytes : NaN;
|
|
7855
7441
|
const sha256 = typeof record.sha256 === "string" ? record.sha256 : "";
|
|
7856
7442
|
const encrypted = record.encrypted === true;
|
|
7857
|
-
if (cachePath.length === 0 || cachePath === ".." || cachePath.startsWith("../") ||
|
|
7443
|
+
if (cachePath.length === 0 || cachePath === ".." || cachePath.startsWith("../") || path10.isAbsolute(cachePath) || !Number.isFinite(statBytes) || !Number.isFinite(mtimeMs) || !Number.isFinite(ctimeMs) || !Number.isFinite(bytes) || !/^[a-f0-9]{64}$/i.test(sha256)) {
|
|
7858
7444
|
continue;
|
|
7859
7445
|
}
|
|
7860
7446
|
cache.set(cachePath, { statBytes, mtimeMs, ctimeMs, encrypted, sha256, bytes });
|
|
@@ -7896,7 +7482,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7896
7482
|
const cache = this.offlineSyncDigestCache;
|
|
7897
7483
|
if (!cache) return;
|
|
7898
7484
|
const entries = [...cache.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([entryPath, entry]) => ({ path: entryPath, ...entry }));
|
|
7899
|
-
await
|
|
7485
|
+
await mkdir(path10.dirname(this.offlineSyncDigestCachePath), { recursive: true });
|
|
7900
7486
|
await writeFile2(this.offlineSyncDigestCachePath, `${JSON.stringify({ version: 1, entries })}
|
|
7901
7487
|
`, "utf-8");
|
|
7902
7488
|
}).catch((err) => {
|
|
@@ -7906,7 +7492,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7906
7492
|
});
|
|
7907
7493
|
}
|
|
7908
7494
|
async offlineSyncFileIsEncrypted(filePath) {
|
|
7909
|
-
const handle = await
|
|
7495
|
+
const handle = await open(filePath, "r");
|
|
7910
7496
|
try {
|
|
7911
7497
|
const header = Buffer.alloc(MAGIC_HEADER_SIZE);
|
|
7912
7498
|
const { bytesRead } = await handle.read(header, 0, header.length, 0);
|
|
@@ -7965,7 +7551,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7965
7551
|
}
|
|
7966
7552
|
let handle;
|
|
7967
7553
|
try {
|
|
7968
|
-
handle = await
|
|
7554
|
+
handle = await open(filePath, "r");
|
|
7969
7555
|
} catch (err) {
|
|
7970
7556
|
if (isErrnoCode(err, "ENOENT")) return false;
|
|
7971
7557
|
throw err;
|
|
@@ -7985,7 +7571,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7985
7571
|
}
|
|
7986
7572
|
async appendStorageSecureFileUnlocked(filePath, content) {
|
|
7987
7573
|
const writeKey = this.resolveWriteKey();
|
|
7988
|
-
await
|
|
7574
|
+
await mkdir(path10.dirname(filePath), { recursive: true });
|
|
7989
7575
|
if (writeKey === null) {
|
|
7990
7576
|
try {
|
|
7991
7577
|
if (await this.isEncryptedFileHeader(filePath)) {
|
|
@@ -8011,13 +7597,13 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8011
7597
|
this.notifyCatalogWriteForPath(filePath);
|
|
8012
7598
|
}
|
|
8013
7599
|
get stateDir() {
|
|
8014
|
-
return
|
|
7600
|
+
return path10.join(this.baseDir, "state");
|
|
8015
7601
|
}
|
|
8016
7602
|
get offlineSyncDigestCachePath() {
|
|
8017
|
-
return
|
|
7603
|
+
return path10.join(this.baseDir, ".offline-sync", "digest-cache.v1.json");
|
|
8018
7604
|
}
|
|
8019
7605
|
get entitySynthesisQueuePath() {
|
|
8020
|
-
return
|
|
7606
|
+
return path10.join(this.stateDir, "entity-synthesis-queue.json");
|
|
8021
7607
|
}
|
|
8022
7608
|
// ── Tombstone store access (issue #1579) ─────────────────────────────────
|
|
8023
7609
|
/**
|
|
@@ -8027,7 +7613,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8027
7613
|
* helpers are injected into the store).
|
|
8028
7614
|
*/
|
|
8029
7615
|
get tombstonesPath() {
|
|
8030
|
-
return
|
|
7616
|
+
return path10.join(this.stateDir, "tombstones.jsonl");
|
|
8031
7617
|
}
|
|
8032
7618
|
/**
|
|
8033
7619
|
* Configure the tombstone invariant for this storage instance. Installed
|
|
@@ -8057,7 +7643,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8057
7643
|
const requested = new Set(sourceMemoryIds);
|
|
8058
7644
|
const sourcePaths = await (sourcePathsPromise ??= this.memoryReadStore.collectTombstoneMigrationPaths());
|
|
8059
7645
|
const directPaths = sourcePaths.filter(
|
|
8060
|
-
(filePath) => requested.has(
|
|
7646
|
+
(filePath) => requested.has(path10.basename(filePath, ".md"))
|
|
8061
7647
|
);
|
|
8062
7648
|
const contents = /* @__PURE__ */ new Map();
|
|
8063
7649
|
for (const memory of await this.readParsedMemoriesFromPaths(directPaths, 50)) {
|
|
@@ -8351,55 +7937,55 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8351
7937
|
return legacyMatches.length > 0 ? [...new Set(legacyMatches.map((content) => ContentHashIndex.computeHash(content)))] : [persistedHash];
|
|
8352
7938
|
}
|
|
8353
7939
|
get questionsDir() {
|
|
8354
|
-
return
|
|
7940
|
+
return path10.join(this.baseDir, "questions");
|
|
8355
7941
|
}
|
|
8356
7942
|
get artifactsDir() {
|
|
8357
|
-
return
|
|
7943
|
+
return path10.join(this.baseDir, "artifacts");
|
|
8358
7944
|
}
|
|
8359
7945
|
get identityDir() {
|
|
8360
|
-
return
|
|
7946
|
+
return path10.join(this.baseDir, "identity");
|
|
8361
7947
|
}
|
|
8362
7948
|
get identityAnchorPath() {
|
|
8363
|
-
return
|
|
7949
|
+
return path10.join(this.identityDir, "identity-anchor.md");
|
|
8364
7950
|
}
|
|
8365
7951
|
get identityIncidentsDir() {
|
|
8366
|
-
return
|
|
7952
|
+
return path10.join(this.identityDir, "incidents");
|
|
8367
7953
|
}
|
|
8368
7954
|
get identityAuditsWeeklyDir() {
|
|
8369
|
-
return
|
|
7955
|
+
return path10.join(this.identityDir, "audits", "weekly");
|
|
8370
7956
|
}
|
|
8371
7957
|
get identityAuditsMonthlyDir() {
|
|
8372
|
-
return
|
|
7958
|
+
return path10.join(this.identityDir, "audits", "monthly");
|
|
8373
7959
|
}
|
|
8374
7960
|
get identityImprovementLoopsPath() {
|
|
8375
|
-
return
|
|
7961
|
+
return path10.join(this.identityDir, "improvement-loops.md");
|
|
8376
7962
|
}
|
|
8377
7963
|
get identityReflectionsPath() {
|
|
8378
|
-
return
|
|
7964
|
+
return path10.join(this.identityDir, "reflections.md");
|
|
8379
7965
|
}
|
|
8380
7966
|
get profilePath() {
|
|
8381
|
-
return
|
|
7967
|
+
return path10.join(this.baseDir, "profile.md");
|
|
8382
7968
|
}
|
|
8383
7969
|
get memoryActionsPath() {
|
|
8384
|
-
return
|
|
7970
|
+
return path10.join(this.stateDir, "memory-actions.jsonl");
|
|
8385
7971
|
}
|
|
8386
7972
|
get memoryLifecycleLedgerPath() {
|
|
8387
|
-
return
|
|
7973
|
+
return path10.join(this.stateDir, "memory-lifecycle-ledger.jsonl");
|
|
8388
7974
|
}
|
|
8389
7975
|
get compressionGuidelinesPath() {
|
|
8390
|
-
return
|
|
7976
|
+
return path10.join(this.stateDir, "compression-guidelines.md");
|
|
8391
7977
|
}
|
|
8392
7978
|
get compressionGuidelineDraftPath() {
|
|
8393
|
-
return
|
|
7979
|
+
return path10.join(this.stateDir, "compression-guidelines.draft.md");
|
|
8394
7980
|
}
|
|
8395
7981
|
get compressionGuidelineStatePath() {
|
|
8396
|
-
return
|
|
7982
|
+
return path10.join(this.stateDir, "compression-guideline-state.json");
|
|
8397
7983
|
}
|
|
8398
7984
|
get compressionGuidelineDraftStatePath() {
|
|
8399
|
-
return
|
|
7985
|
+
return path10.join(this.stateDir, "compression-guideline-draft-state.json");
|
|
8400
7986
|
}
|
|
8401
7987
|
get behaviorSignalsPath() {
|
|
8402
|
-
return
|
|
7988
|
+
return path10.join(this.stateDir, "behavior-signals.jsonl");
|
|
8403
7989
|
}
|
|
8404
7990
|
/**
|
|
8405
7991
|
* In-memory dedup key set for behavior-signals appends (issue #1909),
|
|
@@ -8431,7 +8017,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8431
8017
|
* governance sweeps can treat it uniformly.
|
|
8432
8018
|
*/
|
|
8433
8019
|
get bufferSurpriseLedgerPath() {
|
|
8434
|
-
return
|
|
8020
|
+
return path10.join(this.stateDir, "buffer-surprise-ledger.jsonl");
|
|
8435
8021
|
}
|
|
8436
8022
|
/**
|
|
8437
8023
|
* Entity alias table loaded from THIS store's config/aliases.json.
|
|
@@ -8492,7 +8078,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8492
8078
|
this.loadAliasesSync();
|
|
8493
8079
|
}
|
|
8494
8080
|
loadAliasesSync() {
|
|
8495
|
-
const aliasPath =
|
|
8081
|
+
const aliasPath = path10.join(this.baseDir, "config", "aliases.json");
|
|
8496
8082
|
this.userAliases = {};
|
|
8497
8083
|
const raw = readEntityAliasConfigSync(this.baseDir);
|
|
8498
8084
|
if (raw === void 0) return;
|
|
@@ -8527,22 +8113,22 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8527
8113
|
return completionFingerprint;
|
|
8528
8114
|
}
|
|
8529
8115
|
async ensureDirectories() {
|
|
8530
|
-
await
|
|
8116
|
+
await mkdir(this.baseDir, { recursive: true });
|
|
8531
8117
|
await validateRoots(this.baseDir, this.entitiesDir, this.stateDir, this.archiveDir);
|
|
8532
8118
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
8533
|
-
await
|
|
8534
|
-
await
|
|
8535
|
-
await
|
|
8536
|
-
await
|
|
8537
|
-
await
|
|
8538
|
-
await
|
|
8539
|
-
await
|
|
8540
|
-
await
|
|
8541
|
-
await
|
|
8542
|
-
await
|
|
8543
|
-
await
|
|
8544
|
-
await
|
|
8545
|
-
await
|
|
8119
|
+
await mkdir(path10.join(this.factsDir, today), { recursive: true });
|
|
8120
|
+
await mkdir(path10.join(this.proceduresDir, today), { recursive: true });
|
|
8121
|
+
await mkdir(path10.join(this.reasoningTracesDir, today), { recursive: true });
|
|
8122
|
+
await mkdir(this.correctionsDir, { recursive: true });
|
|
8123
|
+
await mkdir(this.entitiesDir, { recursive: true });
|
|
8124
|
+
await mkdir(this.stateDir, { recursive: true });
|
|
8125
|
+
await mkdir(this.questionsDir, { recursive: true });
|
|
8126
|
+
await mkdir(this.artifactsDir, { recursive: true });
|
|
8127
|
+
await mkdir(this.identityDir, { recursive: true });
|
|
8128
|
+
await mkdir(this.identityIncidentsDir, { recursive: true });
|
|
8129
|
+
await mkdir(this.identityAuditsWeeklyDir, { recursive: true });
|
|
8130
|
+
await mkdir(this.identityAuditsMonthlyDir, { recursive: true });
|
|
8131
|
+
await mkdir(path10.join(this.baseDir, "config"), { recursive: true });
|
|
8546
8132
|
await this.entityCanonicalIdMigration.ensure();
|
|
8547
8133
|
if (this.hotMemoriesCacheEnabled && this.getMemoryCorpusVersion() === 0) {
|
|
8548
8134
|
this.bumpMemoryCorpusVersion();
|
|
@@ -8563,12 +8149,12 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8563
8149
|
*/
|
|
8564
8150
|
async resolveCategoryWritePath(category, id, today) {
|
|
8565
8151
|
if (category === "correction") {
|
|
8566
|
-
await
|
|
8567
|
-
return
|
|
8152
|
+
await mkdir(this.correctionsDir, { recursive: true });
|
|
8153
|
+
return path10.join(this.correctionsDir, `${id}.md`);
|
|
8568
8154
|
}
|
|
8569
|
-
const datedDir =
|
|
8570
|
-
await
|
|
8571
|
-
return
|
|
8155
|
+
const datedDir = path10.join(getCategoryDir(this.baseDir, category), today);
|
|
8156
|
+
await mkdir(datedDir, { recursive: true });
|
|
8157
|
+
return path10.join(datedDir, `${id}.md`);
|
|
8572
8158
|
}
|
|
8573
8159
|
async findExistingTombstoneBlockedMemory(content, category, sourceConnector) {
|
|
8574
8160
|
const identity = buildExplicitCaptureDedupKey(content, category, sourceConnector);
|
|
@@ -8730,7 +8316,7 @@ ${sanitized.text}
|
|
|
8730
8316
|
}
|
|
8731
8317
|
});
|
|
8732
8318
|
} catch (err) {
|
|
8733
|
-
await
|
|
8319
|
+
await unlink4(filePath).catch(() => void 0);
|
|
8734
8320
|
this.invalidateAllMemoriesCache();
|
|
8735
8321
|
await this.rebuildTombstoneBlockedCaptureAfterInvalidationForPath(filePath);
|
|
8736
8322
|
throw err;
|
|
@@ -8933,8 +8519,8 @@ ${sanitized.text}
|
|
|
8933
8519
|
await this.ensureDirectories();
|
|
8934
8520
|
const now = /* @__PURE__ */ new Date();
|
|
8935
8521
|
const day = now.toISOString().slice(0, 10);
|
|
8936
|
-
const dir =
|
|
8937
|
-
await
|
|
8522
|
+
const dir = path10.join(this.artifactsDir, day);
|
|
8523
|
+
await mkdir(dir, { recursive: true });
|
|
8938
8524
|
const id = `artifact-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
8939
8525
|
const fm = {
|
|
8940
8526
|
id,
|
|
@@ -8959,7 +8545,7 @@ ${sanitized.text}
|
|
|
8959
8545
|
log.warn(`artifact content rejected for ${id}; violations=${sanitized.violations.join(", ")}`);
|
|
8960
8546
|
return "";
|
|
8961
8547
|
}
|
|
8962
|
-
const filePath =
|
|
8548
|
+
const filePath = path10.join(dir, `${id}.md`);
|
|
8963
8549
|
await this.writeStorageSecureFile(filePath, `${serializeFrontmatter(fm)}
|
|
8964
8550
|
|
|
8965
8551
|
${sanitized.text}
|
|
@@ -9247,7 +8833,7 @@ ${sanitized.text}
|
|
|
9247
8833
|
* per-process in-memory cache safe across process boundaries.
|
|
9248
8834
|
*/
|
|
9249
8835
|
invalidateColdMemoriesCache() {
|
|
9250
|
-
const coldRoot =
|
|
8836
|
+
const coldRoot = path10.join(this.baseDir, "cold");
|
|
9251
8837
|
_StorageManager.coldMemoriesCache.delete(coldRoot);
|
|
9252
8838
|
this.bumpColdWriteVersion();
|
|
9253
8839
|
invalidateAllForDir(this.baseDir);
|
|
@@ -9367,7 +8953,7 @@ ${sanitized.text}
|
|
|
9367
8953
|
const correctionPaths = [];
|
|
9368
8954
|
const factPaths = [];
|
|
9369
8955
|
for (const filePath of filePaths) {
|
|
9370
|
-
if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${
|
|
8956
|
+
if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${path10.sep}`)) {
|
|
9371
8957
|
correctionPaths.push(filePath);
|
|
9372
8958
|
} else {
|
|
9373
8959
|
factPaths.push(filePath);
|
|
@@ -9430,7 +9016,7 @@ ${sanitized.text}
|
|
|
9430
9016
|
try {
|
|
9431
9017
|
const entries = await readdir6(dir, { withFileTypes: true });
|
|
9432
9018
|
for (const entry of entries) {
|
|
9433
|
-
const fullPath =
|
|
9019
|
+
const fullPath = path10.join(dir, entry.name);
|
|
9434
9020
|
if (entry.isDirectory()) {
|
|
9435
9021
|
await readDir(fullPath);
|
|
9436
9022
|
} else if (entry.name.endsWith(".md")) {
|
|
@@ -9473,7 +9059,7 @@ ${sanitized.text}
|
|
|
9473
9059
|
return this.rememberMemorySnapshot(await this.memoryReadStore.readMemoryByPath(filePath));
|
|
9474
9060
|
}
|
|
9475
9061
|
resolveTierRootDir(tier) {
|
|
9476
|
-
return tier === "cold" ?
|
|
9062
|
+
return tier === "cold" ? path10.join(this.baseDir, "cold") : this.baseDir;
|
|
9477
9063
|
}
|
|
9478
9064
|
resolveMemoryDateDir(memory) {
|
|
9479
9065
|
const preferred = memory.frontmatter.created || memory.frontmatter.updated;
|
|
@@ -9488,13 +9074,13 @@ ${sanitized.text}
|
|
|
9488
9074
|
buildTierMemoryPath(memory, tier) {
|
|
9489
9075
|
const root = this.resolveTierRootDir(tier);
|
|
9490
9076
|
if (this.isArtifactMemory(memory)) {
|
|
9491
|
-
return
|
|
9077
|
+
return path10.join(root, "artifacts", this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
|
|
9492
9078
|
}
|
|
9493
9079
|
if (memory.frontmatter.category === "correction") {
|
|
9494
|
-
return
|
|
9080
|
+
return path10.join(root, "corrections", `${memory.frontmatter.id}.md`);
|
|
9495
9081
|
}
|
|
9496
9082
|
const dir = categoryDirName(memory.frontmatter.category);
|
|
9497
|
-
return
|
|
9083
|
+
return path10.join(root, dir, this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
|
|
9498
9084
|
}
|
|
9499
9085
|
async writeMemoryFileAtomic(targetPath, memory) {
|
|
9500
9086
|
const refIdsAtWrite = this.currentHistoricalIds();
|
|
@@ -9510,7 +9096,7 @@ ${memory.content}
|
|
|
9510
9096
|
{},
|
|
9511
9097
|
this.baseDir
|
|
9512
9098
|
);
|
|
9513
|
-
const priorDest = await
|
|
9099
|
+
const priorDest = await readFile2(targetPath).catch(() => null);
|
|
9514
9100
|
await persist();
|
|
9515
9101
|
if (typeof rawRef === "string") {
|
|
9516
9102
|
const refBeforeRepair = frontmatter.entityRef;
|
|
@@ -9525,7 +9111,7 @@ ${memory.content}
|
|
|
9525
9111
|
});
|
|
9526
9112
|
} catch (err) {
|
|
9527
9113
|
if (priorDest === null) {
|
|
9528
|
-
await
|
|
9114
|
+
await unlink4(targetPath).catch(() => void 0);
|
|
9529
9115
|
} else {
|
|
9530
9116
|
await writeFile2(targetPath, priorDest).catch(() => void 0);
|
|
9531
9117
|
}
|
|
@@ -9572,8 +9158,8 @@ ${memory.content}
|
|
|
9572
9158
|
memory.frontmatter.entityRef = current.frontmatter.entityRef;
|
|
9573
9159
|
}
|
|
9574
9160
|
durable = true;
|
|
9575
|
-
const sourcePath =
|
|
9576
|
-
const destPath =
|
|
9161
|
+
const sourcePath = path10.resolve(current.path);
|
|
9162
|
+
const destPath = path10.resolve(targetPath);
|
|
9577
9163
|
if (sourcePath !== destPath) {
|
|
9578
9164
|
await recordArchiveDelete2(this.baseDir, current.path, () => this.deleteManagedStorageFile(current.path));
|
|
9579
9165
|
this.invalidateAllMemoriesCache();
|
|
@@ -9597,8 +9183,8 @@ ${memory.content}
|
|
|
9597
9183
|
}
|
|
9598
9184
|
async migrateMemoryToTier(memory, targetTier) {
|
|
9599
9185
|
const targetPath = this.buildTierMemoryPath(memory, targetTier);
|
|
9600
|
-
const sourcePath =
|
|
9601
|
-
const destPath =
|
|
9186
|
+
const sourcePath = path10.resolve(memory.path);
|
|
9187
|
+
const destPath = path10.resolve(targetPath);
|
|
9602
9188
|
if (sourcePath === destPath) {
|
|
9603
9189
|
return { changed: false, targetPath };
|
|
9604
9190
|
}
|
|
@@ -9608,7 +9194,7 @@ ${memory.content}
|
|
|
9608
9194
|
return { changed, targetPath };
|
|
9609
9195
|
}
|
|
9610
9196
|
get archiveDir() {
|
|
9611
|
-
return
|
|
9197
|
+
return path10.join(this.baseDir, "archive");
|
|
9612
9198
|
}
|
|
9613
9199
|
/**
|
|
9614
9200
|
* Archive a memory by moving it from facts/ to archive/YYYY-MM-DD/.
|
|
@@ -9621,8 +9207,8 @@ ${memory.content}
|
|
|
9621
9207
|
try {
|
|
9622
9208
|
const now = lifecycle?.at ?? /* @__PURE__ */ new Date();
|
|
9623
9209
|
const today = now.toISOString().slice(0, 10);
|
|
9624
|
-
const destDir =
|
|
9625
|
-
await
|
|
9210
|
+
const destDir = path10.join(this.archiveDir, today);
|
|
9211
|
+
await mkdir(destDir, { recursive: true });
|
|
9626
9212
|
const refIdsAtWrite = this.currentHistoricalIds();
|
|
9627
9213
|
const updatedFm = canonicalizeEntityRefOption(
|
|
9628
9214
|
{
|
|
@@ -9637,7 +9223,7 @@ ${memory.content}
|
|
|
9637
9223
|
|
|
9638
9224
|
${current.content}
|
|
9639
9225
|
`;
|
|
9640
|
-
const destPath =
|
|
9226
|
+
const destPath = path10.join(destDir, path10.basename(current.path));
|
|
9641
9227
|
const priorDest = await this.readStorageSecureFile(destPath).catch(() => null);
|
|
9642
9228
|
await recordArchiveWrite(this.baseDir, destPath, () => this.writeStorageSecureFile(destPath, fileContent));
|
|
9643
9229
|
if (typeof current.frontmatter.entityRef === "string") {
|
|
@@ -9654,7 +9240,7 @@ ${current.content}
|
|
|
9654
9240
|
await recordArchiveDelete2(
|
|
9655
9241
|
this.baseDir,
|
|
9656
9242
|
destPath,
|
|
9657
|
-
() =>
|
|
9243
|
+
() => unlink4(destPath).then(
|
|
9658
9244
|
() => true,
|
|
9659
9245
|
() => false
|
|
9660
9246
|
)
|
|
@@ -9870,7 +9456,7 @@ ${memory.content}
|
|
|
9870
9456
|
`;
|
|
9871
9457
|
await this.writeTombstoneBlockedFrontmatter(memory, fileContent, updated, async () => {
|
|
9872
9458
|
this.invalidateAllMemoriesCache();
|
|
9873
|
-
if (memory.path.includes(`${
|
|
9459
|
+
if (memory.path.includes(`${path10.sep}cold${path10.sep}`)) {
|
|
9874
9460
|
this.invalidateColdMemoriesCache();
|
|
9875
9461
|
}
|
|
9876
9462
|
});
|
|
@@ -9881,7 +9467,7 @@ ${memory.content}
|
|
|
9881
9467
|
});
|
|
9882
9468
|
}
|
|
9883
9469
|
await this.patchHotMemoriesCache({ addedPath: memory.path });
|
|
9884
|
-
if (memory.path.includes(`${
|
|
9470
|
+
if (memory.path.includes(`${path10.sep}cold${path10.sep}`)) {
|
|
9885
9471
|
this.invalidateColdMemoriesCache();
|
|
9886
9472
|
}
|
|
9887
9473
|
try {
|
|
@@ -9962,7 +9548,7 @@ ${memory.content}
|
|
|
9962
9548
|
return deleted;
|
|
9963
9549
|
}
|
|
9964
9550
|
async loadBuffer() {
|
|
9965
|
-
const bufferPath =
|
|
9551
|
+
const bufferPath = path10.join(this.stateDir, "buffer.json");
|
|
9966
9552
|
try {
|
|
9967
9553
|
const raw = await this.readStorageSecureFile(bufferPath);
|
|
9968
9554
|
return JSON.parse(raw);
|
|
@@ -9974,11 +9560,11 @@ ${memory.content}
|
|
|
9974
9560
|
}
|
|
9975
9561
|
async saveBuffer(state) {
|
|
9976
9562
|
await this.ensureDirectories();
|
|
9977
|
-
const bufferPath =
|
|
9563
|
+
const bufferPath = path10.join(this.stateDir, "buffer.json");
|
|
9978
9564
|
await this.writeStorageSecureFile(bufferPath, JSON.stringify(state, null, 2));
|
|
9979
9565
|
}
|
|
9980
9566
|
async loadMeta() {
|
|
9981
|
-
const metaPath =
|
|
9567
|
+
const metaPath = path10.join(this.stateDir, "meta.json");
|
|
9982
9568
|
try {
|
|
9983
9569
|
const raw = await this.readStorageSecureFile(metaPath);
|
|
9984
9570
|
const parsed = JSON.parse(raw);
|
|
@@ -10011,7 +9597,7 @@ ${memory.content}
|
|
|
10011
9597
|
}
|
|
10012
9598
|
async saveMeta(state) {
|
|
10013
9599
|
await this.ensureDirectories();
|
|
10014
|
-
const metaPath =
|
|
9600
|
+
const metaPath = path10.join(this.stateDir, "meta.json");
|
|
10015
9601
|
await this.writeStorageSecureFile(metaPath, JSON.stringify(state, null, 2));
|
|
10016
9602
|
}
|
|
10017
9603
|
async appendMemoryActionEvents(events) {
|
|
@@ -10075,7 +9661,7 @@ ${memory.content}
|
|
|
10075
9661
|
},
|
|
10076
9662
|
(payload) => this.appendStorageSecureFile(target, payload),
|
|
10077
9663
|
async () => {
|
|
10078
|
-
await
|
|
9664
|
+
await mkdir(path10.dirname(target), { recursive: true });
|
|
10079
9665
|
}
|
|
10080
9666
|
);
|
|
10081
9667
|
}
|
|
@@ -10173,7 +9759,7 @@ ${memory.content}
|
|
|
10173
9759
|
async appendReextractJobs(events) {
|
|
10174
9760
|
if (events.length === 0) return 0;
|
|
10175
9761
|
await this.ensureDirectories();
|
|
10176
|
-
const filePath =
|
|
9762
|
+
const filePath = path10.join(this.stateDir, "reextract-jobs.jsonl");
|
|
10177
9763
|
const lines = events.map((event) => JSON.stringify(event)).join("\n") + "\n";
|
|
10178
9764
|
try {
|
|
10179
9765
|
await this.appendStorageSecureFile(filePath, lines);
|
|
@@ -10186,7 +9772,7 @@ ${memory.content}
|
|
|
10186
9772
|
}
|
|
10187
9773
|
async readReextractJobs(limit = 200) {
|
|
10188
9774
|
const safeLimit = Number.isFinite(limit) ? Math.max(1, Math.min(1e3, Math.floor(limit))) : 200;
|
|
10189
|
-
const filePath =
|
|
9775
|
+
const filePath = path10.join(this.stateDir, "reextract-jobs.jsonl");
|
|
10190
9776
|
try {
|
|
10191
9777
|
const raw = await this.readStorageSecureFile(filePath);
|
|
10192
9778
|
const lines = raw.split("\n").filter((line) => line.trim().length > 0);
|
|
@@ -10335,7 +9921,7 @@ ${memory.content}
|
|
|
10335
9921
|
return false;
|
|
10336
9922
|
}
|
|
10337
9923
|
if (draftState.contentHash) {
|
|
10338
|
-
const contentHash =
|
|
9924
|
+
const contentHash = createHash6("sha256").update(draftContent).digest("hex");
|
|
10339
9925
|
if (contentHash !== draftState.contentHash) return false;
|
|
10340
9926
|
}
|
|
10341
9927
|
await this.writeCompressionGuidelines(draftContent);
|
|
@@ -10344,8 +9930,8 @@ ${memory.content}
|
|
|
10344
9930
|
activationState: "active"
|
|
10345
9931
|
});
|
|
10346
9932
|
await Promise.all([
|
|
10347
|
-
|
|
10348
|
-
|
|
9933
|
+
unlink4(this.compressionGuidelineDraftPath).catch(() => void 0),
|
|
9934
|
+
unlink4(this.compressionGuidelineDraftStatePath).catch(() => void 0)
|
|
10349
9935
|
]);
|
|
10350
9936
|
return true;
|
|
10351
9937
|
}
|
|
@@ -10397,7 +9983,7 @@ ${memory.content}
|
|
|
10397
9983
|
return `${prefix}-${ts}-${rand}`;
|
|
10398
9984
|
}
|
|
10399
9985
|
async writeQuestion(question, context, priority) {
|
|
10400
|
-
await
|
|
9986
|
+
await mkdir(this.questionsDir, { recursive: true });
|
|
10401
9987
|
const id = this.generateId("q");
|
|
10402
9988
|
const frontmatter = {
|
|
10403
9989
|
id,
|
|
@@ -10413,7 +9999,7 @@ ${question}
|
|
|
10413
9999
|
|
|
10414
10000
|
**Context:** ${context}
|
|
10415
10001
|
`;
|
|
10416
|
-
const filePath =
|
|
10002
|
+
const filePath = path10.join(this.questionsDir, `${id}.md`);
|
|
10417
10003
|
await this.writeStorageSecureFile(filePath, content);
|
|
10418
10004
|
log.debug(`wrote question ${id} to ${filePath}`);
|
|
10419
10005
|
this.invalidateQuestionsCache();
|
|
@@ -10431,7 +10017,7 @@ ${question}
|
|
|
10431
10017
|
if (!match) return null;
|
|
10432
10018
|
const frontmatterStr = match[1];
|
|
10433
10019
|
const body = match[2].trim();
|
|
10434
|
-
const id = this.extractFrontmatterValue(frontmatterStr, "id") ??
|
|
10020
|
+
const id = this.extractFrontmatterValue(frontmatterStr, "id") ?? path10.basename(filePath, ".md");
|
|
10435
10021
|
const created = this.extractFrontmatterValue(frontmatterStr, "created") ?? "";
|
|
10436
10022
|
const priority = parseFloat(this.extractFrontmatterValue(frontmatterStr, "priority") ?? "0.5");
|
|
10437
10023
|
const resolved = this.extractFrontmatterValue(frontmatterStr, "resolved") === "true";
|
|
@@ -10465,7 +10051,7 @@ ${question}
|
|
|
10465
10051
|
async readIdentity(workspaceDir, namespace) {
|
|
10466
10052
|
const identityPath = this.identityFilePath(workspaceDir, namespace);
|
|
10467
10053
|
try {
|
|
10468
|
-
return await
|
|
10054
|
+
return await readFile2(identityPath, "utf-8");
|
|
10469
10055
|
} catch {
|
|
10470
10056
|
return "";
|
|
10471
10057
|
}
|
|
@@ -10483,15 +10069,15 @@ ${question}
|
|
|
10483
10069
|
const identityPath = this.identityFilePath(workspaceDir, opts?.namespace);
|
|
10484
10070
|
let existing = "";
|
|
10485
10071
|
try {
|
|
10486
|
-
existing = await
|
|
10072
|
+
existing = await readFile2(identityPath, "utf-8");
|
|
10487
10073
|
} catch {
|
|
10488
10074
|
}
|
|
10489
10075
|
const hygiene = opts?.hygiene;
|
|
10490
|
-
const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(
|
|
10076
|
+
const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(path10.basename(identityPath));
|
|
10491
10077
|
if (rotateEnabled) {
|
|
10492
10078
|
const maxBytes = hygiene.rotateMaxBytes;
|
|
10493
10079
|
if (existing.length > maxBytes) {
|
|
10494
|
-
const archiveDir =
|
|
10080
|
+
const archiveDir = path10.join(workspaceDir, hygiene.archiveDir);
|
|
10495
10081
|
const { newContent } = await rotateMarkdownFileToArchive({
|
|
10496
10082
|
filePath: identityPath,
|
|
10497
10083
|
archiveDir,
|
|
@@ -10543,7 +10129,7 @@ ${reflection}
|
|
|
10543
10129
|
}
|
|
10544
10130
|
}
|
|
10545
10131
|
async writeIdentityReflections(content) {
|
|
10546
|
-
await
|
|
10132
|
+
await mkdir(this.identityDir, { recursive: true });
|
|
10547
10133
|
await this.writeStorageSecureFile(this.identityReflectionsPath, content);
|
|
10548
10134
|
}
|
|
10549
10135
|
async appendIdentityReflection(reflection) {
|
|
@@ -10575,7 +10161,7 @@ ${reflection}
|
|
|
10575
10161
|
|
|
10576
10162
|
${reflection}
|
|
10577
10163
|
`;
|
|
10578
|
-
await
|
|
10164
|
+
await mkdir(this.identityDir, { recursive: true });
|
|
10579
10165
|
await this.writeStorageSecureFile(this.identityReflectionsPath, `${existing.trimEnd()}${section}`);
|
|
10580
10166
|
log.debug(`appended namespace-local reflection to ${this.identityReflectionsPath}`);
|
|
10581
10167
|
}
|
|
@@ -10631,7 +10217,7 @@ ${reflection}
|
|
|
10631
10217
|
const rightTs = latestEntityTimelineTimestamp(right.entity) ?? "";
|
|
10632
10218
|
return compareEntityTimestamps(rightTs, leftTs);
|
|
10633
10219
|
}).map(({ entityName }) => entityName);
|
|
10634
|
-
await
|
|
10220
|
+
await mkdir(this.stateDir, { recursive: true });
|
|
10635
10221
|
await this.writeStorageSecureFile(
|
|
10636
10222
|
this.entitySynthesisQueuePath,
|
|
10637
10223
|
JSON.stringify(
|
|
@@ -10651,7 +10237,7 @@ ${reflection}
|
|
|
10651
10237
|
if (queue.length === 0) return;
|
|
10652
10238
|
const removals = new Set(entityNames);
|
|
10653
10239
|
const nextQueue = queue.filter((name) => !removals.has(name));
|
|
10654
|
-
await
|
|
10240
|
+
await mkdir(this.stateDir, { recursive: true });
|
|
10655
10241
|
await this.writeStorageSecureFile(
|
|
10656
10242
|
this.entitySynthesisQueuePath,
|
|
10657
10243
|
JSON.stringify(
|
|
@@ -10751,14 +10337,14 @@ ${reflection}
|
|
|
10751
10337
|
if (entries.length === 0) return 0;
|
|
10752
10338
|
const memories = await this.readAllMemories();
|
|
10753
10339
|
const memoryMap = new Map(memories.map((m) => [m.frontmatter.id, m]));
|
|
10754
|
-
const memoryPathMap = new Map(memories.map((m) => [
|
|
10340
|
+
const memoryPathMap = new Map(memories.map((m) => [path10.resolve(m.path), m]));
|
|
10755
10341
|
let updated = 0;
|
|
10756
10342
|
const prevVersion = this.getMemoryCorpusVersion();
|
|
10757
10343
|
const keyId = this.hotCacheKeyId();
|
|
10758
10344
|
const warm = this.hotMemoriesCacheEnabled && getCachedMemories(this.baseDir, prevVersion, keyId, this.hotCacheTtlMs()) !== null;
|
|
10759
10345
|
const appliedPatches = /* @__PURE__ */ new Map();
|
|
10760
10346
|
for (const entry of entries) {
|
|
10761
|
-
const memory = entry.memoryPath ? memoryPathMap.get(
|
|
10347
|
+
const memory = entry.memoryPath ? memoryPathMap.get(path10.resolve(entry.memoryPath)) : memoryMap.get(entry.memoryId);
|
|
10762
10348
|
if (!memory) continue;
|
|
10763
10349
|
try {
|
|
10764
10350
|
const applied = await this.withTombstoneBlockedMemoryPathLock(memory.path, async (current) => {
|
|
@@ -10789,7 +10375,7 @@ ${current.content}
|
|
|
10789
10375
|
if (warm) {
|
|
10790
10376
|
updateCacheOnWrite(this.baseDir, { ...applied.current, frontmatter: applied.newFm }, keyId);
|
|
10791
10377
|
}
|
|
10792
|
-
appliedPatches.set(
|
|
10378
|
+
appliedPatches.set(path10.resolve(memory.path), {
|
|
10793
10379
|
accessCount: entry.newCount,
|
|
10794
10380
|
lastAccessed: entry.lastAccessed
|
|
10795
10381
|
});
|
|
@@ -10805,7 +10391,7 @@ ${current.content}
|
|
|
10805
10391
|
const cur = getCachedMemories(this.baseDir, prevVersion, keyId);
|
|
10806
10392
|
if (cur) {
|
|
10807
10393
|
const reapplied = cur.map((m) => {
|
|
10808
|
-
const patch = appliedPatches.get(
|
|
10394
|
+
const patch = appliedPatches.get(path10.resolve(m.path));
|
|
10809
10395
|
return patch ? {
|
|
10810
10396
|
...m,
|
|
10811
10397
|
frontmatter: { ...m.frontmatter, accessCount: patch.accessCount, lastAccessed: patch.lastAccessed }
|
|
@@ -10835,7 +10421,7 @@ ${current.content}
|
|
|
10835
10421
|
const pathsById = /* @__PURE__ */ new Map();
|
|
10836
10422
|
const filePathsById = /* @__PURE__ */ new Map();
|
|
10837
10423
|
for (const filePath of filePaths) {
|
|
10838
|
-
const memoryId =
|
|
10424
|
+
const memoryId = path10.basename(filePath, ".md");
|
|
10839
10425
|
if (!wantedIds.has(memoryId)) continue;
|
|
10840
10426
|
const paths = filePathsById.get(memoryId) ?? [];
|
|
10841
10427
|
paths.push(filePath);
|
|
@@ -10847,7 +10433,7 @@ ${current.content}
|
|
|
10847
10433
|
const preferredMatches = [];
|
|
10848
10434
|
for (const preferredPath of preferred) {
|
|
10849
10435
|
const directCandidates = new Set(qmdResultPathCandidates(this.baseDir, preferredPath));
|
|
10850
|
-
const directMatch = existingPaths.find((filePath) => directCandidates.has(
|
|
10436
|
+
const directMatch = existingPaths.find((filePath) => directCandidates.has(path10.resolve(filePath)));
|
|
10851
10437
|
if (directMatch) {
|
|
10852
10438
|
preferredMatches.push(directMatch);
|
|
10853
10439
|
continue;
|
|
@@ -10859,7 +10445,7 @@ ${current.content}
|
|
|
10859
10445
|
candidates.add(candidate);
|
|
10860
10446
|
}
|
|
10861
10447
|
}
|
|
10862
|
-
const match = existingPaths.find((filePath) => candidates.has(
|
|
10448
|
+
const match = existingPaths.find((filePath) => candidates.has(path10.resolve(filePath)));
|
|
10863
10449
|
if (match) preferredMatches.push(match);
|
|
10864
10450
|
}
|
|
10865
10451
|
if (preferredMatches.length > 0) {
|
|
@@ -11049,7 +10635,7 @@ ${sanitized.text}
|
|
|
11049
10635
|
}
|
|
11050
10636
|
if (!oldMemory) return false;
|
|
11051
10637
|
const requireActiveAtWrite = options.requireActive === true || inferMemoryStatus(oldMemory.frontmatter, toMemoryPathRel(this.baseDir, oldMemory.path)) === "active";
|
|
11052
|
-
const operationId =
|
|
10638
|
+
const operationId = createHash6("sha256").update(
|
|
11053
10639
|
JSON.stringify({
|
|
11054
10640
|
oldMemoryId,
|
|
11055
10641
|
newMemoryId,
|
|
@@ -11178,11 +10764,11 @@ ${current.content}
|
|
|
11178
10764
|
}
|
|
11179
10765
|
}
|
|
11180
10766
|
get summariesDir() {
|
|
11181
|
-
return
|
|
10767
|
+
return path10.join(this.baseDir, "summaries");
|
|
11182
10768
|
}
|
|
11183
10769
|
async writeSummary(summary) {
|
|
11184
|
-
await
|
|
11185
|
-
const filePath =
|
|
10770
|
+
await mkdir(this.summariesDir, { recursive: true });
|
|
10771
|
+
const filePath = path10.join(this.summariesDir, `${summary.id}.json`);
|
|
11186
10772
|
await this.writeStorageSecureFile(filePath, JSON.stringify(summary, null, 2));
|
|
11187
10773
|
log.debug(`wrote summary ${summary.id}`);
|
|
11188
10774
|
}
|
|
@@ -11192,7 +10778,7 @@ ${current.content}
|
|
|
11192
10778
|
const summaries = [];
|
|
11193
10779
|
for (const file of files) {
|
|
11194
10780
|
if (!file.endsWith(".json")) continue;
|
|
11195
|
-
const filePath =
|
|
10781
|
+
const filePath = path10.join(this.summariesDir, file);
|
|
11196
10782
|
const raw = await this.readStorageSecureFile(filePath);
|
|
11197
10783
|
summaries.push(JSON.parse(raw));
|
|
11198
10784
|
}
|
|
@@ -11262,8 +10848,8 @@ ${current.content}
|
|
|
11262
10848
|
return archived;
|
|
11263
10849
|
}
|
|
11264
10850
|
async saveTopics(topics) {
|
|
11265
|
-
const metaPath =
|
|
11266
|
-
await
|
|
10851
|
+
const metaPath = path10.join(this.stateDir, "topics.json");
|
|
10852
|
+
await mkdir(this.stateDir, { recursive: true });
|
|
11267
10853
|
await this.writeStorageSecureFile(
|
|
11268
10854
|
metaPath,
|
|
11269
10855
|
JSON.stringify({ topics, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2)
|
|
@@ -11271,7 +10857,7 @@ ${current.content}
|
|
|
11271
10857
|
log.debug(`saved ${topics.length} topic scores`);
|
|
11272
10858
|
}
|
|
11273
10859
|
async loadTopics() {
|
|
11274
|
-
const metaPath =
|
|
10860
|
+
const metaPath = path10.join(this.stateDir, "topics.json");
|
|
11275
10861
|
try {
|
|
11276
10862
|
const raw = await this.readStorageSecureFile(metaPath);
|
|
11277
10863
|
return JSON.parse(raw);
|
|
@@ -11386,4 +10972,4 @@ export {
|
|
|
11386
10972
|
isValidBufferSurpriseEvent,
|
|
11387
10973
|
StorageManager3 as StorageManager
|
|
11388
10974
|
};
|
|
11389
|
-
//# sourceMappingURL=chunk-
|
|
10975
|
+
//# sourceMappingURL=chunk-M4YHAODQ.js.map
|