@remnic/core 9.22.0 → 9.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-admin-ops-surface.d.ts +15 -12
- package/dist/access-admin-ops-surface.js +25 -24
- package/dist/access-audit.js +2 -2
- package/dist/access-boundary.d.ts +13 -10
- package/dist/access-boundary.js +25 -24
- package/dist/access-cli.js +84 -82
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.d.ts +16 -9
- package/dist/access-http.js +33 -32
- package/dist/access-identity-continuity-surface.d.ts +9 -7
- package/dist/access-identity-continuity-surface.js +25 -24
- package/dist/access-lcm-surface.d.ts +12 -9
- package/dist/access-lcm-surface.js +25 -24
- package/dist/access-mcp-output-schemas.js +1 -1
- package/dist/access-mcp.d.ts +22 -10
- package/dist/access-mcp.js +31 -30
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-tmwQgCT6.d.ts → access-namespace-preflight-CmErR03h.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +25 -24
- package/dist/access-observe-write-surface.d.ts +12 -9
- package/dist/access-observe-write-surface.js +25 -24
- package/dist/access-operations-batch.js +27 -26
- package/dist/access-operations.d.ts +16 -13
- package/dist/access-operations.js +28 -27
- package/dist/access-recall-concurrency.d.ts +12 -9
- package/dist/access-recall-concurrency.js +25 -24
- package/dist/access-recall-response.d.ts +12 -9
- package/dist/access-recall-response.js +25 -24
- package/dist/access-recall-surface.d.ts +14 -11
- package/dist/access-recall-surface.js +25 -24
- package/dist/access-schema.d.ts +76 -76
- package/dist/{access-service-BtxW52vv.d.ts → access-service-CKEROeFP.d.ts} +22 -11
- package/dist/access-service.d.ts +13 -10
- package/dist/access-service.js +25 -24
- package/dist/access-surface-catalog.d.ts +12 -9
- package/dist/access-surface-catalog.js +6 -0
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/access-wearables-meetings-surface.d.ts +78 -0
- package/dist/access-wearables-meetings-surface.js +22 -0
- package/dist/access-wearables-meetings-surface.js.map +1 -0
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +2 -2
- package/dist/{auto-sync-UPTUVE4X.js → auto-sync-5OE5QOZB.js} +3 -3
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +9 -7
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +5 -5
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{catalog-iWvWz61I.d.ts → catalog-BFTVo2Ez.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-behavior.js +2 -2
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +9 -9
- package/dist/causal-retrieval.js +2 -2
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-GF22HWS2.js → chunk-2PHX3I5C.js} +7 -7
- package/dist/{chunk-JFDEYXF7.js → chunk-3NAHZQU3.js} +2 -2
- package/dist/{chunk-XBRPEGXF.js → chunk-3UOSVTFR.js} +5 -5
- package/dist/{chunk-TTKWTT72.js → chunk-3ZW6ZQO6.js} +3 -3
- package/dist/{chunk-UV72DEZD.js → chunk-4B77XSG5.js} +5 -5
- package/dist/{chunk-IC2TCZJ2.js → chunk-57QKLRBV.js} +3 -1
- package/dist/chunk-57QKLRBV.js.map +1 -0
- package/dist/{chunk-LMHDFOVV.js → chunk-5CPI2QWG.js} +3 -3
- package/dist/{chunk-P72WZMWQ.js → chunk-5FZQ74K5.js} +2 -2
- package/dist/{chunk-BRT7KEXU.js → chunk-6TWXQ4E2.js} +5 -5
- package/dist/{chunk-CV6ZYXK3.js → chunk-7I7AYIUQ.js} +3 -3
- package/dist/{chunk-TVVEYCNW.js → chunk-7K5Q6COX.js} +4 -4
- package/dist/{chunk-MONWCSVL.js → chunk-7RAJ3GXO.js} +2 -1
- package/dist/chunk-7RAJ3GXO.js.map +1 -0
- package/dist/{chunk-SQEDDWAM.js → chunk-A2RFKL3V.js} +5 -34
- package/dist/chunk-A2RFKL3V.js.map +1 -0
- package/dist/{chunk-JN57HZCD.js → chunk-ATEAL5EI.js} +6 -6
- package/dist/{chunk-4PYLBXX6.js → chunk-AYAROCWD.js} +2 -2
- package/dist/chunk-BLDBT6HZ.js +39 -0
- package/dist/chunk-BLDBT6HZ.js.map +1 -0
- package/dist/{chunk-NB2P47N7.js → chunk-CUUY5CC4.js} +6 -6
- package/dist/{chunk-KL5Y6PEV.js → chunk-E3ZMFFQZ.js} +2 -2
- package/dist/{chunk-55FDQYPS.js → chunk-ES5IHQ6M.js} +2 -2
- package/dist/{chunk-N47ZWQBO.js → chunk-G2NSSQES.js} +2 -2
- package/dist/{chunk-GSWPU5CR.js → chunk-GD3QOBMB.js} +2 -2
- package/dist/{chunk-6ANPNUVL.js → chunk-IIXLB5E7.js} +58 -36
- package/dist/chunk-IIXLB5E7.js.map +1 -0
- package/dist/{chunk-SACPRJ7F.js → chunk-JNIJBXVK.js} +2 -2
- package/dist/{chunk-W3XT32W7.js → chunk-JVGUY2AU.js} +23 -13
- package/dist/chunk-JVGUY2AU.js.map +1 -0
- package/dist/{chunk-DGLON3AL.js → chunk-KNRG6ZGJ.js} +6 -6
- package/dist/{chunk-GEUDRENF.js → chunk-MMTG3SCJ.js} +2 -2
- package/dist/{chunk-WZFAPHIK.js → chunk-MU7ZHSZE.js} +2 -2
- package/dist/{chunk-W4FBGYGK.js → chunk-NRV4Y3PM.js} +1 -1
- package/dist/{chunk-QTO2FGBT.js → chunk-OUW4PAY4.js} +191 -117
- package/dist/chunk-OUW4PAY4.js.map +1 -0
- package/dist/{chunk-KQ2XCQYN.js → chunk-P2BLHUL2.js} +2 -2
- package/dist/{chunk-ACGGTPU4.js → chunk-QCKQEBIY.js} +17 -9
- package/dist/chunk-QCKQEBIY.js.map +1 -0
- package/dist/{chunk-6L775BUB.js → chunk-QE63OHLB.js} +2 -2
- package/dist/{chunk-ONHRRJZM.js → chunk-QJAQNXWI.js} +6 -6
- package/dist/{chunk-EQYBHXRR.js → chunk-ROUL7RZU.js} +385 -59
- package/dist/chunk-ROUL7RZU.js.map +1 -0
- package/dist/{chunk-N6M7MRVN.js → chunk-RT4TSR2C.js} +9034 -8726
- package/dist/chunk-RT4TSR2C.js.map +1 -0
- package/dist/{chunk-6NZ7U4R4.js → chunk-SCOT5DTA.js} +1 -1
- package/dist/chunk-SCOT5DTA.js.map +1 -0
- package/dist/{chunk-6RYWNBSA.js → chunk-SVZGA2MK.js} +2 -2
- package/dist/chunk-SYOIVK7K.js +63 -0
- package/dist/chunk-SYOIVK7K.js.map +1 -0
- package/dist/{chunk-DM5A4ZFL.js → chunk-TWCOYET2.js} +11 -1
- package/dist/chunk-TWCOYET2.js.map +1 -0
- package/dist/{chunk-7S5OMI76.js → chunk-WS32QRLO.js} +109 -44
- package/dist/chunk-WS32QRLO.js.map +1 -0
- package/dist/{chunk-OCMLGND7.js → chunk-WWZ35GWW.js} +5 -5
- package/dist/{chunk-QMGIQUBG.js → chunk-XWPFZX6S.js} +503 -139
- package/dist/chunk-XWPFZX6S.js.map +1 -0
- package/dist/{chunk-A5N6ISRK.js → chunk-ZN4UZWMT.js} +2 -2
- package/dist/{chunk-7M6APKJL.js → chunk-ZYU7ZFLT.js} +2 -2
- package/dist/{cli-D9vXgWwM.d.ts → cli-BrwT9YMD.d.ts} +5 -5
- package/dist/cli.d.ts +14 -11
- package/dist/cli.js +57 -56
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +5 -5
- 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 -2
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +5 -5
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +5 -5
- 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/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +5 -5
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +9 -7
- package/dist/extraction-error-classification.d.ts +22 -0
- package/dist/extraction-error-classification.js +11 -0
- package/dist/extraction-error-classification.js.map +1 -0
- package/dist/extraction-faithfulness.d.ts +1 -1
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction.d.ts +3 -17
- package/dist/extraction.js +5 -3
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/{first-start-migration-LEXL3XYL.js → first-start-migration-BKNGOFED.js} +4 -4
- package/dist/graph-dashboard-diff.d.ts +1 -1
- package/dist/graph-dashboard-key.d.ts +1 -1
- package/dist/graph-dashboard-parser.d.ts +1 -1
- package/dist/graph-edge-reinforcement.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph.d.ts +1 -1
- package/dist/importance.d.ts +1 -1
- package/dist/importers/index.d.ts +1 -1
- package/dist/in-flight-reads.d.ts +1 -1
- package/dist/index.d.ts +713 -923
- package/dist/index.js +176 -140
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/engine.js +3 -3
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +11 -11
- package/dist/lcm/tools.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +1 -1
- package/dist/local-model-endpoint.d.ts +1 -1
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +6 -6
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +5 -5
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +7 -7
- package/dist/maintenance-C98njYb8.d.ts +366 -0
- package/dist/mcp-memory-inspector-app.d.ts +12 -9
- 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-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +3 -3
- package/dist/namespaces/migrate.js +12 -12
- 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 +5 -5
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +2 -2
- package/dist/operator-toolkit.js +18 -18
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +6 -223
- package/dist/orchestration/maintenance.js +12 -12
- package/dist/{orchestrator-DB93S48I.d.ts → orchestrator-C9ZVppNh.d.ts} +12 -481
- package/dist/orchestrator.d.ts +10 -8
- package/dist/orchestrator.js +84 -82
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-DmGc-H66.d.ts → pipeline-id_-sqYm.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/proactive-contention.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/{qmd-cJT0crkF.d.ts → qmd-R6XaQOZK.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/qmd.js +4 -4
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +1 -1
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +1 -1
- package/dist/recall-xray.js +2 -2
- package/dist/replay/normalizers/chatgpt.d.ts +1 -1
- package/dist/replay/normalizers/claude.d.ts +1 -1
- package/dist/replay/normalizers/openclaw.d.ts +1 -1
- package/dist/replay/normalizers/shared.d.ts +1 -1
- package/dist/replay/runner.d.ts +1 -1
- package/dist/replay/types.d.ts +1 -1
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +4 -4
- package/dist/retrieval-agents.d.ts +2 -2
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/routing/engine.d.ts +1 -1
- package/dist/routing/store.d.ts +1 -1
- package/dist/salvage-envelope.d.ts +1 -1
- package/dist/schemas.d.ts +76 -76
- package/dist/{scope-profiles-KG2nODX7.d.ts → scope-profiles-EhyuAKkd.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-BaZlg0D8.d.ts → semantic-consolidation-B2xo26UQ.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +7 -7
- package/dist/semantic-rule-promotion.js +5 -5
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +6 -6
- package/dist/service-DgFWlZ-r.d.ts +835 -0
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +9 -9
- package/dist/signal.d.ts +1 -1
- package/dist/{storage-BKhHHnRo.d.ts → storage-XGawwqXE.d.ts} +131 -2
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +4 -4
- package/dist/summarizer.d.ts +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/temporal-supersession.d.ts +2 -2
- package/dist/temporal-timeline-recall.d.ts +1 -1
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +2 -2
- package/dist/tier-routing.d.ts +1 -1
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transfer/types.d.ts +66 -66
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-GBQZuT7l.d.ts → types-Bbs0qz6b.d.ts} +2 -3
- 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 +6 -6
- package/dist/write-envelope.d.ts +1 -1
- package/package.json +2 -2
- package/src/access-boundary.ts +3 -0
- package/src/access-http.test.ts +63 -0
- package/src/access-http.ts +26 -37
- package/src/access-mcp-output-schemas.ts +10 -0
- package/src/access-mcp.ts +4 -121
- package/src/access-operations-batch.ts +10 -5
- package/src/access-service.ts +43 -46
- package/src/access-surface-catalog.ts +6 -0
- package/src/access-wearables-meetings-surface.ts +139 -0
- package/src/activity/digest.ts +1 -1
- package/src/activity/runner.test.ts +37 -0
- package/src/activity/runner.ts +12 -0
- package/src/activity/scheduler.test.ts +1 -0
- package/src/activity/sync-registration.ts +13 -0
- package/src/cli/meetings-commands.ts +70 -0
- package/src/cli.ts +7 -6
- package/src/extraction-error-classification.ts +52 -0
- package/src/extraction.ts +2 -50
- package/src/mcp-read-only-tools.ts +2 -0
- package/src/meetings/build-memory.test.ts +364 -0
- package/src/meetings/build-scheduler.test.ts +55 -0
- package/src/meetings/build-scheduler.ts +96 -0
- package/src/meetings/day-source.test.ts +275 -0
- package/src/meetings/day-source.ts +352 -0
- package/src/meetings/http-glue.ts +126 -0
- package/src/meetings/index.ts +5 -4
- package/src/meetings/manual-sync-flush.test.ts +72 -0
- package/src/meetings/mcp-tools.ts +65 -0
- package/src/meetings/memory-gen.test.ts +498 -0
- package/src/meetings/memory-gen.ts +549 -0
- package/src/meetings/memory-generator.ts +5 -0
- package/src/meetings/namespace-isolation.test.ts +159 -0
- package/src/meetings/service.test.ts +195 -0
- package/src/meetings/service.ts +157 -0
- package/src/meetings/summary-extractor.test.ts +287 -0
- package/src/meetings/summary-extractor.ts +264 -0
- package/src/orchestration/maintenance.ts +8 -0
- package/src/orchestration/orchestrator-init.ts +6 -1
- package/src/orchestration/workspace-ops.ts +172 -8
- package/src/orchestrator.ts +12 -13
- package/src/storage.ts +21 -0
- package/src/testing/subjects/meetings-namespace-harness.ts +159 -0
- package/src/testing/subjects/meetings-namespace.test.ts +93 -0
- package/src/types.ts +1 -2
- package/src/wearables/cli.ts +2 -1
- package/src/wearables/index.ts +1 -0
- package/src/wearables/mcp-tools.ts +143 -0
- package/src/wearables/registry.test.ts +11 -0
- package/src/wearables/registry.ts +13 -0
- package/src/wearables/service.test.ts +62 -1
- package/src/wearables/service.ts +30 -2
- package/src/wearables/transcript-search-namespace-isolation.test.ts +98 -0
- package/dist/chunk-6ANPNUVL.js.map +0 -1
- package/dist/chunk-6NZ7U4R4.js.map +0 -1
- package/dist/chunk-7S5OMI76.js.map +0 -1
- package/dist/chunk-ACGGTPU4.js.map +0 -1
- package/dist/chunk-DM5A4ZFL.js.map +0 -1
- package/dist/chunk-EQYBHXRR.js.map +0 -1
- package/dist/chunk-IC2TCZJ2.js.map +0 -1
- package/dist/chunk-MONWCSVL.js.map +0 -1
- package/dist/chunk-N6M7MRVN.js.map +0 -1
- package/dist/chunk-QMGIQUBG.js.map +0 -1
- package/dist/chunk-QTO2FGBT.js.map +0 -1
- package/dist/chunk-SQEDDWAM.js.map +0 -1
- package/dist/chunk-W3XT32W7.js.map +0 -1
- /package/dist/{auto-sync-UPTUVE4X.js.map → auto-sync-5OE5QOZB.js.map} +0 -0
- /package/dist/{chunk-GF22HWS2.js.map → chunk-2PHX3I5C.js.map} +0 -0
- /package/dist/{chunk-JFDEYXF7.js.map → chunk-3NAHZQU3.js.map} +0 -0
- /package/dist/{chunk-XBRPEGXF.js.map → chunk-3UOSVTFR.js.map} +0 -0
- /package/dist/{chunk-TTKWTT72.js.map → chunk-3ZW6ZQO6.js.map} +0 -0
- /package/dist/{chunk-UV72DEZD.js.map → chunk-4B77XSG5.js.map} +0 -0
- /package/dist/{chunk-LMHDFOVV.js.map → chunk-5CPI2QWG.js.map} +0 -0
- /package/dist/{chunk-P72WZMWQ.js.map → chunk-5FZQ74K5.js.map} +0 -0
- /package/dist/{chunk-BRT7KEXU.js.map → chunk-6TWXQ4E2.js.map} +0 -0
- /package/dist/{chunk-CV6ZYXK3.js.map → chunk-7I7AYIUQ.js.map} +0 -0
- /package/dist/{chunk-TVVEYCNW.js.map → chunk-7K5Q6COX.js.map} +0 -0
- /package/dist/{chunk-JN57HZCD.js.map → chunk-ATEAL5EI.js.map} +0 -0
- /package/dist/{chunk-4PYLBXX6.js.map → chunk-AYAROCWD.js.map} +0 -0
- /package/dist/{chunk-NB2P47N7.js.map → chunk-CUUY5CC4.js.map} +0 -0
- /package/dist/{chunk-KL5Y6PEV.js.map → chunk-E3ZMFFQZ.js.map} +0 -0
- /package/dist/{chunk-55FDQYPS.js.map → chunk-ES5IHQ6M.js.map} +0 -0
- /package/dist/{chunk-N47ZWQBO.js.map → chunk-G2NSSQES.js.map} +0 -0
- /package/dist/{chunk-GSWPU5CR.js.map → chunk-GD3QOBMB.js.map} +0 -0
- /package/dist/{chunk-SACPRJ7F.js.map → chunk-JNIJBXVK.js.map} +0 -0
- /package/dist/{chunk-DGLON3AL.js.map → chunk-KNRG6ZGJ.js.map} +0 -0
- /package/dist/{chunk-GEUDRENF.js.map → chunk-MMTG3SCJ.js.map} +0 -0
- /package/dist/{chunk-WZFAPHIK.js.map → chunk-MU7ZHSZE.js.map} +0 -0
- /package/dist/{chunk-W4FBGYGK.js.map → chunk-NRV4Y3PM.js.map} +0 -0
- /package/dist/{chunk-KQ2XCQYN.js.map → chunk-P2BLHUL2.js.map} +0 -0
- /package/dist/{chunk-6L775BUB.js.map → chunk-QE63OHLB.js.map} +0 -0
- /package/dist/{chunk-ONHRRJZM.js.map → chunk-QJAQNXWI.js.map} +0 -0
- /package/dist/{chunk-6RYWNBSA.js.map → chunk-SVZGA2MK.js.map} +0 -0
- /package/dist/{chunk-OCMLGND7.js.map → chunk-WWZ35GWW.js.map} +0 -0
- /package/dist/{chunk-A5N6ISRK.js.map → chunk-ZN4UZWMT.js.map} +0 -0
- /package/dist/{chunk-7M6APKJL.js.map → chunk-ZYU7ZFLT.js.map} +0 -0
- /package/dist/{first-start-migration-LEXL3XYL.js.map → first-start-migration-BKNGOFED.js.map} +0 -0
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TombstoneStore,
|
|
3
|
+
buildRetiredFactTombstoneInputs,
|
|
4
|
+
collectRetiredMemoriesForRebuild
|
|
5
|
+
} from "./chunk-2QMKMVHH.js";
|
|
1
6
|
import {
|
|
2
7
|
WEARABLES_DIR_NAME,
|
|
8
|
+
escapeSegmentText,
|
|
9
|
+
escapeSpeakerLabel,
|
|
3
10
|
hasSelfMarker,
|
|
4
11
|
isValidTranscriptDate,
|
|
5
12
|
parseTranscriptSegmentLine,
|
|
@@ -7,11 +14,6 @@ import {
|
|
|
7
14
|
unescapeSegmentText,
|
|
8
15
|
unescapeSpeakerLabel
|
|
9
16
|
} from "./chunk-UHVXE24Y.js";
|
|
10
|
-
import {
|
|
11
|
-
TombstoneStore,
|
|
12
|
-
buildRetiredFactTombstoneInputs,
|
|
13
|
-
collectRetiredMemoriesForRebuild
|
|
14
|
-
} from "./chunk-2QMKMVHH.js";
|
|
15
17
|
import {
|
|
16
18
|
supersessionKeysForFact
|
|
17
19
|
} from "./chunk-DNHVPZOD.js";
|
|
@@ -27,7 +29,7 @@ import {
|
|
|
27
29
|
import {
|
|
28
30
|
SPECULATIVE_TTL_DAYS,
|
|
29
31
|
confidenceTier
|
|
30
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-SCOT5DTA.js";
|
|
31
33
|
import {
|
|
32
34
|
appendLifecycleEventsSerialized,
|
|
33
35
|
drainPendingLifecycleLedgerForSync,
|
|
@@ -67,9 +69,6 @@ import {
|
|
|
67
69
|
readProjectedMemoryTimeline,
|
|
68
70
|
updateProjectedMemoryPath
|
|
69
71
|
} from "./chunk-3CSX3ETE.js";
|
|
70
|
-
import {
|
|
71
|
-
rotateMarkdownFileToArchive
|
|
72
|
-
} from "./chunk-DM2T26WE.js";
|
|
73
72
|
import {
|
|
74
73
|
closeContinuityIncidentRecord,
|
|
75
74
|
createContinuityIncidentRecord,
|
|
@@ -79,6 +78,9 @@ import {
|
|
|
79
78
|
serializeContinuityIncident,
|
|
80
79
|
upsertContinuityLoopInMarkdown
|
|
81
80
|
} from "./chunk-LDXUBPMO.js";
|
|
81
|
+
import {
|
|
82
|
+
rotateMarkdownFileToArchive
|
|
83
|
+
} from "./chunk-DM2T26WE.js";
|
|
82
84
|
import {
|
|
83
85
|
parseFaithfulnessField,
|
|
84
86
|
serializeFaithfulnessFields
|
|
@@ -205,8 +207,8 @@ import {
|
|
|
205
207
|
open
|
|
206
208
|
} from "fs/promises";
|
|
207
209
|
import { appendFileSync, createReadStream, mkdirSync, readFileSync, statSync } from "fs";
|
|
208
|
-
import { createHash as
|
|
209
|
-
import
|
|
210
|
+
import { createHash as createHash5 } from "crypto";
|
|
211
|
+
import path9 from "path";
|
|
210
212
|
|
|
211
213
|
// src/storage/memory-read-store.ts
|
|
212
214
|
import { lstat, readdir, realpath, stat } from "fs/promises";
|
|
@@ -1334,9 +1336,9 @@ function qmdResultPathCandidates(storageDir, resultPath) {
|
|
|
1334
1336
|
};
|
|
1335
1337
|
if (path5.isAbsolute(resultPath)) {
|
|
1336
1338
|
addCandidate(resultPath);
|
|
1337
|
-
const
|
|
1338
|
-
if (
|
|
1339
|
-
const normalized =
|
|
1339
|
+
const relative2 = path5.relative(storageRoot, path5.resolve(resultPath));
|
|
1340
|
+
if (relative2 && !relative2.startsWith("..") && !path5.isAbsolute(relative2)) {
|
|
1341
|
+
const normalized = relative2.split(path5.sep).join("/");
|
|
1340
1342
|
if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
|
|
1341
1343
|
addCandidate(path5.join(storageRoot, "facts", normalized));
|
|
1342
1344
|
}
|
|
@@ -2624,8 +2626,344 @@ function reconstructFusionInputs(date, dayTranscripts) {
|
|
|
2624
2626
|
return inputs;
|
|
2625
2627
|
}
|
|
2626
2628
|
|
|
2627
|
-
// src/
|
|
2629
|
+
// src/meetings/store.ts
|
|
2628
2630
|
import { createHash as createHash3 } from "crypto";
|
|
2631
|
+
import * as path7 from "path";
|
|
2632
|
+
var MEETINGS_DIR_NAME = "meetings";
|
|
2633
|
+
var MEETING_KIND = "meeting";
|
|
2634
|
+
var MEETING_FORMAT_VERSION = 1;
|
|
2635
|
+
var MEETING_ID_PATTERN = /^mtg-(\d{4}-\d{2}-\d{2})-[0-9a-f]{8}$/;
|
|
2636
|
+
function meetingIdDate(id) {
|
|
2637
|
+
const match = MEETING_ID_PATTERN.exec(id);
|
|
2638
|
+
return match === null ? null : match[1];
|
|
2639
|
+
}
|
|
2640
|
+
function canonicalContent(base, fused) {
|
|
2641
|
+
return JSON.stringify({
|
|
2642
|
+
formatVersion: MEETING_FORMAT_VERSION,
|
|
2643
|
+
id: base.id,
|
|
2644
|
+
date: base.date,
|
|
2645
|
+
startUtc: base.startUtc,
|
|
2646
|
+
endUtc: base.endUtc,
|
|
2647
|
+
app: base.app ?? null,
|
|
2648
|
+
detectionSource: base.detectionSource,
|
|
2649
|
+
title: base.title ?? null,
|
|
2650
|
+
attendees: fused.attendees,
|
|
2651
|
+
sources: fused.sources,
|
|
2652
|
+
corroboratedBy: fused.corroboratedBy,
|
|
2653
|
+
screenContext: fused.screenContext,
|
|
2654
|
+
contextExcerpts: fused.contextExcerpts,
|
|
2655
|
+
transcript: fused.transcript,
|
|
2656
|
+
speakers: fused.speakers,
|
|
2657
|
+
snapshotCount: fused.snapshotCount
|
|
2658
|
+
});
|
|
2659
|
+
}
|
|
2660
|
+
function composeMeetingRecord(base, fused) {
|
|
2661
|
+
const contentHash = createHash3("sha256").update(canonicalContent(base, fused), "utf-8").digest("hex");
|
|
2662
|
+
return {
|
|
2663
|
+
...base,
|
|
2664
|
+
...fused,
|
|
2665
|
+
contentHash,
|
|
2666
|
+
formatVersion: MEETING_FORMAT_VERSION
|
|
2667
|
+
};
|
|
2668
|
+
}
|
|
2669
|
+
function formatClockUtc(iso) {
|
|
2670
|
+
const ms = Date.parse(iso);
|
|
2671
|
+
if (Number.isNaN(ms)) return "--:--";
|
|
2672
|
+
return new Date(ms).toISOString().slice(11, 16);
|
|
2673
|
+
}
|
|
2674
|
+
function renderTranscriptLine(segment) {
|
|
2675
|
+
const clock = formatClockUtc(segment.startIso ?? "");
|
|
2676
|
+
return `**${escapeSpeakerLabel(segment.speaker)}** [${clock}]: ${escapeSegmentText(segment.text)}`;
|
|
2677
|
+
}
|
|
2678
|
+
function frontmatterList(key, values) {
|
|
2679
|
+
if (values.length === 0) return [`${key}: []`];
|
|
2680
|
+
const lines = [`${key}:`];
|
|
2681
|
+
for (const value of values) lines.push(` - ${JSON.stringify(value)}`);
|
|
2682
|
+
return lines;
|
|
2683
|
+
}
|
|
2684
|
+
function serializeMeetingRecord(record) {
|
|
2685
|
+
const lines = ["---"];
|
|
2686
|
+
lines.push(`kind: ${MEETING_KIND}`);
|
|
2687
|
+
lines.push(`formatVersion: ${record.formatVersion}`);
|
|
2688
|
+
lines.push(`id: ${JSON.stringify(record.id)}`);
|
|
2689
|
+
lines.push(`date: ${JSON.stringify(record.date)}`);
|
|
2690
|
+
lines.push(`startUtc: ${JSON.stringify(record.startUtc)}`);
|
|
2691
|
+
lines.push(`endUtc: ${JSON.stringify(record.endUtc)}`);
|
|
2692
|
+
if (record.app !== void 0) lines.push(`app: ${JSON.stringify(record.app)}`);
|
|
2693
|
+
lines.push(`detectionSource: ${JSON.stringify(record.detectionSource)}`);
|
|
2694
|
+
if (record.title !== void 0) lines.push(`title: ${JSON.stringify(record.title)}`);
|
|
2695
|
+
lines.push(...frontmatterList("attendees", record.attendees));
|
|
2696
|
+
lines.push(...frontmatterList("sources", record.sources));
|
|
2697
|
+
lines.push(...frontmatterList("corroboratedBy", record.corroboratedBy));
|
|
2698
|
+
lines.push(`snapshotCount: ${record.snapshotCount}`);
|
|
2699
|
+
lines.push(`contentHash: ${JSON.stringify(record.contentHash)}`);
|
|
2700
|
+
lines.push("---");
|
|
2701
|
+
lines.push("");
|
|
2702
|
+
const heading = record.title !== void 0 && record.title.length > 0 ? ` \xB7 ${record.title}` : "";
|
|
2703
|
+
lines.push(`# Meeting ${record.id}${heading}`);
|
|
2704
|
+
lines.push("");
|
|
2705
|
+
lines.push("## Attendees");
|
|
2706
|
+
lines.push("");
|
|
2707
|
+
if (record.attendees.length === 0) {
|
|
2708
|
+
lines.push("_None resolved._");
|
|
2709
|
+
} else {
|
|
2710
|
+
for (const attendee of record.attendees) lines.push(`- ${attendee}`);
|
|
2711
|
+
}
|
|
2712
|
+
lines.push("");
|
|
2713
|
+
if (record.screenContext.length > 0 || record.contextExcerpts.length > 0) {
|
|
2714
|
+
lines.push("## Screen context");
|
|
2715
|
+
lines.push("");
|
|
2716
|
+
for (const event of record.screenContext) {
|
|
2717
|
+
lines.push(`- [${event.clock}] ${event.label}`);
|
|
2718
|
+
}
|
|
2719
|
+
if (record.contextExcerpts.length > 0) {
|
|
2720
|
+
if (record.screenContext.length > 0) lines.push("");
|
|
2721
|
+
lines.push("Notable excerpts:");
|
|
2722
|
+
lines.push("");
|
|
2723
|
+
for (const excerpt of record.contextExcerpts) lines.push(`> ${excerpt.replace(/\n/g, " ")}`);
|
|
2724
|
+
}
|
|
2725
|
+
lines.push("");
|
|
2726
|
+
}
|
|
2727
|
+
lines.push("## Transcript");
|
|
2728
|
+
lines.push("");
|
|
2729
|
+
if (record.transcript.length === 0) {
|
|
2730
|
+
lines.push("_No transcript segments in this window._");
|
|
2731
|
+
} else {
|
|
2732
|
+
for (const segment of record.transcript) lines.push(renderTranscriptLine(segment));
|
|
2733
|
+
}
|
|
2734
|
+
lines.push("");
|
|
2735
|
+
return `${lines.join("\n")}`;
|
|
2736
|
+
}
|
|
2737
|
+
function parseScalar2(value) {
|
|
2738
|
+
const trimmed = value.trim();
|
|
2739
|
+
if (trimmed.startsWith('"')) {
|
|
2740
|
+
try {
|
|
2741
|
+
return JSON.parse(trimmed);
|
|
2742
|
+
} catch {
|
|
2743
|
+
return trimmed;
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
return trimmed;
|
|
2747
|
+
}
|
|
2748
|
+
function parseMeetingRecordSummary(raw) {
|
|
2749
|
+
if (!raw.startsWith("---\n")) return null;
|
|
2750
|
+
const closeIndex = raw.indexOf("\n---\n", 4);
|
|
2751
|
+
if (closeIndex === -1) return null;
|
|
2752
|
+
const frontmatter = raw.slice(4, closeIndex).split("\n");
|
|
2753
|
+
const scalars = {};
|
|
2754
|
+
const lists = {};
|
|
2755
|
+
let currentList = null;
|
|
2756
|
+
for (const line of frontmatter) {
|
|
2757
|
+
const listItem = /^ {2}- (.*)$/.exec(line);
|
|
2758
|
+
if (listItem !== null && currentList !== null) {
|
|
2759
|
+
lists[currentList].push(parseScalar2(listItem[1]));
|
|
2760
|
+
continue;
|
|
2761
|
+
}
|
|
2762
|
+
const kv = /^([A-Za-z][A-Za-z0-9]*):\s*(.*)$/.exec(line);
|
|
2763
|
+
if (kv === null) continue;
|
|
2764
|
+
const key = kv[1];
|
|
2765
|
+
const value = kv[2];
|
|
2766
|
+
if (value === "") {
|
|
2767
|
+
currentList = key;
|
|
2768
|
+
lists[key] = [];
|
|
2769
|
+
} else if (value === "[]") {
|
|
2770
|
+
currentList = null;
|
|
2771
|
+
lists[key] = [];
|
|
2772
|
+
} else {
|
|
2773
|
+
currentList = null;
|
|
2774
|
+
scalars[key] = value;
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
if (scalars.kind !== void 0 && parseScalar2(scalars.kind) !== MEETING_KIND) return null;
|
|
2778
|
+
const id = scalars.id !== void 0 ? parseScalar2(scalars.id) : void 0;
|
|
2779
|
+
const contentHash = scalars.contentHash !== void 0 ? parseScalar2(scalars.contentHash) : void 0;
|
|
2780
|
+
if (id === void 0 || contentHash === void 0) return null;
|
|
2781
|
+
return {
|
|
2782
|
+
id,
|
|
2783
|
+
date: scalars.date !== void 0 ? parseScalar2(scalars.date) : "",
|
|
2784
|
+
startUtc: scalars.startUtc !== void 0 ? parseScalar2(scalars.startUtc) : "",
|
|
2785
|
+
endUtc: scalars.endUtc !== void 0 ? parseScalar2(scalars.endUtc) : "",
|
|
2786
|
+
...scalars.app !== void 0 ? { app: parseScalar2(scalars.app) } : {},
|
|
2787
|
+
detectionSource: scalars.detectionSource !== void 0 ? parseScalar2(scalars.detectionSource) : "",
|
|
2788
|
+
...scalars.title !== void 0 ? { title: parseScalar2(scalars.title) } : {},
|
|
2789
|
+
attendees: lists.attendees ?? [],
|
|
2790
|
+
sources: lists.sources ?? [],
|
|
2791
|
+
corroboratedBy: lists.corroboratedBy ?? [],
|
|
2792
|
+
snapshotCount: scalars.snapshotCount !== void 0 ? Number(scalars.snapshotCount) || 0 : 0,
|
|
2793
|
+
contentHash
|
|
2794
|
+
};
|
|
2795
|
+
}
|
|
2796
|
+
var MeetingRecordStore = class {
|
|
2797
|
+
constructor(memoryDir, io) {
|
|
2798
|
+
this.memoryDir = memoryDir;
|
|
2799
|
+
this.io = io;
|
|
2800
|
+
this.meetingsDir = path7.join(memoryDir, MEETINGS_DIR_NAME);
|
|
2801
|
+
}
|
|
2802
|
+
memoryDir;
|
|
2803
|
+
io;
|
|
2804
|
+
meetingsDir;
|
|
2805
|
+
recordPath(date, id) {
|
|
2806
|
+
if (!isValidTranscriptDate(date)) {
|
|
2807
|
+
throw new Error(`invalid meeting date '${String(date)}' \u2014 expected YYYY-MM-DD`);
|
|
2808
|
+
}
|
|
2809
|
+
const idDate = meetingIdDate(id);
|
|
2810
|
+
if (idDate === null) {
|
|
2811
|
+
throw new Error(`invalid meeting id '${String(id)}' \u2014 expected mtg-YYYY-MM-DD-<hash>`);
|
|
2812
|
+
}
|
|
2813
|
+
if (idDate !== date) {
|
|
2814
|
+
throw new Error(`meeting id '${id}' does not belong to date '${date}'`);
|
|
2815
|
+
}
|
|
2816
|
+
return path7.join(this.meetingsDir, date, `${id}.md`);
|
|
2817
|
+
}
|
|
2818
|
+
/** Idempotently persist a record: skip the write when contentHash is unchanged. */
|
|
2819
|
+
async saveMeetingRecord(record) {
|
|
2820
|
+
const filePath = this.recordPath(record.date, record.id);
|
|
2821
|
+
await this.assertPathContained(filePath);
|
|
2822
|
+
const existing = await this.readRaw(filePath);
|
|
2823
|
+
if (existing !== null) {
|
|
2824
|
+
const summary = parseMeetingRecordSummary(existing);
|
|
2825
|
+
if (summary !== null && summary.contentHash === record.contentHash) {
|
|
2826
|
+
return { path: filePath, written: false, contentHash: record.contentHash };
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
await this.io.writeFile(filePath, serializeMeetingRecord(record));
|
|
2830
|
+
return { path: filePath, written: true, contentHash: record.contentHash };
|
|
2831
|
+
}
|
|
2832
|
+
/** Read a stored record's raw markdown; null when absent. */
|
|
2833
|
+
async readMeetingRecord(date, id) {
|
|
2834
|
+
const filePath = this.recordPath(date, id);
|
|
2835
|
+
await this.assertPathContained(filePath);
|
|
2836
|
+
return this.readRaw(filePath);
|
|
2837
|
+
}
|
|
2838
|
+
/**
|
|
2839
|
+
* Read + parse every stored record for a day exactly ONCE, sorted by start
|
|
2840
|
+
* time (ascending, id tiebreak). The single day-read path both `listMeetingIds`
|
|
2841
|
+
* and `listMeetingSummaries` derive from — no record is read twice.
|
|
2842
|
+
*/
|
|
2843
|
+
async readDaySummaries(date) {
|
|
2844
|
+
if (!isValidTranscriptDate(date)) {
|
|
2845
|
+
throw new Error(`invalid meeting date '${String(date)}' \u2014 expected YYYY-MM-DD`);
|
|
2846
|
+
}
|
|
2847
|
+
const dayDir = path7.join(this.meetingsDir, date);
|
|
2848
|
+
await this.assertPathContained(dayDir);
|
|
2849
|
+
let entries;
|
|
2850
|
+
try {
|
|
2851
|
+
entries = await this.io.readDir(dayDir);
|
|
2852
|
+
} catch (err) {
|
|
2853
|
+
if (err.code === "ENOENT") return [];
|
|
2854
|
+
throw err;
|
|
2855
|
+
}
|
|
2856
|
+
const summaries = [];
|
|
2857
|
+
for (const entry of entries) {
|
|
2858
|
+
if (!entry.endsWith(".md")) continue;
|
|
2859
|
+
const id = entry.slice(0, -3);
|
|
2860
|
+
if (meetingIdDate(id) !== date) continue;
|
|
2861
|
+
const raw = await this.readMeetingRecord(date, id);
|
|
2862
|
+
if (raw === null) continue;
|
|
2863
|
+
const summary = parseMeetingRecordSummary(raw);
|
|
2864
|
+
if (summary !== null) summaries.push(summary);
|
|
2865
|
+
}
|
|
2866
|
+
summaries.sort((a, b) => a.startUtc < b.startUtc ? -1 : a.startUtc > b.startUtc ? 1 : SORT_STR(a.id, b.id));
|
|
2867
|
+
return summaries;
|
|
2868
|
+
}
|
|
2869
|
+
/** List meeting ids stored for a day, sorted by start time (ascending). */
|
|
2870
|
+
async listMeetingIds(date) {
|
|
2871
|
+
return (await this.readDaySummaries(date)).map((summary) => summary.id);
|
|
2872
|
+
}
|
|
2873
|
+
/** Read parsed summaries for a day, sorted by start time. */
|
|
2874
|
+
async listMeetingSummaries(date) {
|
|
2875
|
+
return this.readDaySummaries(date);
|
|
2876
|
+
}
|
|
2877
|
+
/** List dates that have at least one stored meeting record, newest first. */
|
|
2878
|
+
async listMeetingDates() {
|
|
2879
|
+
await this.assertPathContained(this.meetingsDir);
|
|
2880
|
+
let entries;
|
|
2881
|
+
try {
|
|
2882
|
+
entries = await this.io.readDir(this.meetingsDir);
|
|
2883
|
+
} catch (err) {
|
|
2884
|
+
if (err.code === "ENOENT") return [];
|
|
2885
|
+
throw err;
|
|
2886
|
+
}
|
|
2887
|
+
const dates = entries.filter((entry) => isValidTranscriptDate(entry));
|
|
2888
|
+
dates.sort((a, b) => a > b ? -1 : a < b ? 1 : 0);
|
|
2889
|
+
return dates;
|
|
2890
|
+
}
|
|
2891
|
+
/** Remove a stored record. Idempotent: a no-op when already absent. */
|
|
2892
|
+
async deleteMeetingRecord(date, id) {
|
|
2893
|
+
const filePath = this.recordPath(date, id);
|
|
2894
|
+
await this.assertPathContained(filePath);
|
|
2895
|
+
try {
|
|
2896
|
+
await this.io.deleteFile(filePath);
|
|
2897
|
+
} catch (err) {
|
|
2898
|
+
if (err.code === "ENOENT") return;
|
|
2899
|
+
throw err;
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
async readRaw(filePath) {
|
|
2903
|
+
try {
|
|
2904
|
+
return await this.io.readFile(filePath);
|
|
2905
|
+
} catch (err) {
|
|
2906
|
+
if (err.code === "ENOENT") return null;
|
|
2907
|
+
throw err;
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
async assertPathContained(targetPath) {
|
|
2911
|
+
let rootReal;
|
|
2912
|
+
try {
|
|
2913
|
+
rootReal = await this.io.realpath(this.memoryDir);
|
|
2914
|
+
} catch {
|
|
2915
|
+
rootReal = path7.resolve(this.memoryDir);
|
|
2916
|
+
}
|
|
2917
|
+
await this.assertNoEscape(rootReal, this.meetingsDir);
|
|
2918
|
+
await this.assertNoEscape(rootReal, path7.dirname(targetPath));
|
|
2919
|
+
await this.assertNoEscape(rootReal, targetPath);
|
|
2920
|
+
await this.assertNotSymlink(this.meetingsDir, "directory");
|
|
2921
|
+
const dayDir = this.dayDirWithin(targetPath);
|
|
2922
|
+
if (dayDir !== null) await this.assertNotSymlink(dayDir, "directory");
|
|
2923
|
+
if (targetPath.endsWith(".md")) await this.assertNotSymlink(targetPath, "record file");
|
|
2924
|
+
}
|
|
2925
|
+
/** The `<meetings>/<date>` directory on the path to `targetPath`, or null when
|
|
2926
|
+
* `targetPath` is the meetings root itself. */
|
|
2927
|
+
dayDirWithin(targetPath) {
|
|
2928
|
+
const rel = path7.relative(this.meetingsDir, targetPath);
|
|
2929
|
+
if (rel === "" || rel.startsWith("..") || path7.isAbsolute(rel)) return null;
|
|
2930
|
+
const first = rel.split(path7.sep)[0];
|
|
2931
|
+
if (first === void 0 || first.length === 0) return null;
|
|
2932
|
+
return path7.join(this.meetingsDir, first);
|
|
2933
|
+
}
|
|
2934
|
+
async assertNotSymlink(target, kind) {
|
|
2935
|
+
let stat4;
|
|
2936
|
+
try {
|
|
2937
|
+
stat4 = await this.io.lstat(target);
|
|
2938
|
+
} catch (err) {
|
|
2939
|
+
if (err.code === "ENOENT") return;
|
|
2940
|
+
throw err;
|
|
2941
|
+
}
|
|
2942
|
+
if (stat4.isSymbolicLink) {
|
|
2943
|
+
const label = path7.relative(this.memoryDir, target) || MEETINGS_DIR_NAME;
|
|
2944
|
+
throw new Error(
|
|
2945
|
+
`meetings ${kind} '${label}' is a symbolic link \u2014 refusing to follow it even when it resolves inside the memory dir (AGENTS.md pattern #3)`
|
|
2946
|
+
);
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
async assertNoEscape(rootReal, candidate) {
|
|
2950
|
+
let candidateReal;
|
|
2951
|
+
try {
|
|
2952
|
+
candidateReal = await this.io.realpath(candidate);
|
|
2953
|
+
} catch {
|
|
2954
|
+
return;
|
|
2955
|
+
}
|
|
2956
|
+
if (!pathIsInside(rootReal, candidateReal)) {
|
|
2957
|
+
throw new Error(
|
|
2958
|
+
"meeting record path resolves outside the memory dir \u2014 refusing to follow a symlink/traversal (AGENTS.md pattern #3)"
|
|
2959
|
+
);
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
};
|
|
2963
|
+
var SORT_STR = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
2964
|
+
|
|
2965
|
+
// src/storage/entity-timeline.ts
|
|
2966
|
+
import { createHash as createHash4 } from "crypto";
|
|
2629
2967
|
function parseEntityTimelineBullet(bullet, fallbackTimestamp) {
|
|
2630
2968
|
const trimmed = bullet.trim();
|
|
2631
2969
|
if (!trimmed) return null;
|
|
@@ -2997,7 +3335,7 @@ function fingerprintEntityStructuredFacts(entity) {
|
|
|
2997
3335
|
(left, right) => left.key.localeCompare(right.key) || left.title.localeCompare(right.title) || left.facts.join("\n").localeCompare(right.facts.join("\n"))
|
|
2998
3336
|
);
|
|
2999
3337
|
if (normalizedSections.length === 0) return void 0;
|
|
3000
|
-
return
|
|
3338
|
+
return createHash4("sha256").update(JSON.stringify(normalizedSections)).digest("hex");
|
|
3001
3339
|
}
|
|
3002
3340
|
function isEntitySynthesisStale(entity) {
|
|
3003
3341
|
const structuredFactCount = countEntityStructuredFacts(entity);
|
|
@@ -3020,7 +3358,7 @@ function isEntitySynthesisStale(entity) {
|
|
|
3020
3358
|
|
|
3021
3359
|
// src/storage/content-hash-index.ts
|
|
3022
3360
|
import { mkdir, stat as stat2 } from "fs/promises";
|
|
3023
|
-
import
|
|
3361
|
+
import path8 from "path";
|
|
3024
3362
|
var CONTENT_HASH_INDEX_LOCK_STALE_MS = 3e4;
|
|
3025
3363
|
var CONTENT_HASH_INDEX_RETRY_MAX_ATTEMPTS = 5;
|
|
3026
3364
|
var CONTENT_HASH_INDEX_RETRY_BASE_MS = 500;
|
|
@@ -3080,8 +3418,8 @@ var ContentHashIndex = class _ContentHashIndex {
|
|
|
3080
3418
|
* re-read on the hot path.
|
|
3081
3419
|
*/
|
|
3082
3420
|
lastSyncedFingerprint = null;
|
|
3083
|
-
constructor(stateDir, secureStoreKeyProvider = () => null, secureStoreWriteKeyProvider = secureStoreKeyProvider, memoryDir =
|
|
3084
|
-
this.filePath =
|
|
3421
|
+
constructor(stateDir, secureStoreKeyProvider = () => null, secureStoreWriteKeyProvider = secureStoreKeyProvider, memoryDir = path8.dirname(stateDir), lockOptions = {}) {
|
|
3422
|
+
this.filePath = path8.join(stateDir, "fact-hashes.txt");
|
|
3085
3423
|
this.secureStoreKeyProvider = secureStoreKeyProvider;
|
|
3086
3424
|
this.secureStoreWriteKeyProvider = secureStoreWriteKeyProvider;
|
|
3087
3425
|
this.memoryDir = memoryDir;
|
|
@@ -3173,7 +3511,7 @@ var ContentHashIndex = class _ContentHashIndex {
|
|
|
3173
3511
|
/** Persist index to disk if changed (plain whole-file overwrite). */
|
|
3174
3512
|
async save() {
|
|
3175
3513
|
if (!this.dirty) return;
|
|
3176
|
-
await mkdir(
|
|
3514
|
+
await mkdir(path8.dirname(this.filePath), { recursive: true });
|
|
3177
3515
|
const publishedAdded = new Set(this.added);
|
|
3178
3516
|
const publishedRemoved = new Set(this.removed);
|
|
3179
3517
|
const serialized = [...this.hashes].join("\n") + "\n";
|
|
@@ -3220,7 +3558,7 @@ var ContentHashIndex = class _ContentHashIndex {
|
|
|
3220
3558
|
*/
|
|
3221
3559
|
async saveMergingWithDisk() {
|
|
3222
3560
|
if (!this.dirty) return;
|
|
3223
|
-
await mkdir(
|
|
3561
|
+
await mkdir(path8.dirname(this.filePath), { recursive: true });
|
|
3224
3562
|
const publish = async () => {
|
|
3225
3563
|
const publishedAdded = new Set(this.added);
|
|
3226
3564
|
const publishedRemoved = new Set(this.removed);
|
|
@@ -3239,7 +3577,7 @@ var ContentHashIndex = class _ContentHashIndex {
|
|
|
3239
3577
|
if (err instanceof SecureStoreLockedError) throw err;
|
|
3240
3578
|
if (!isErrnoCode(err, "ENOENT")) throw err;
|
|
3241
3579
|
}
|
|
3242
|
-
await mkdir(
|
|
3580
|
+
await mkdir(path8.dirname(this.filePath), { recursive: true });
|
|
3243
3581
|
await writeMaybeEncryptedFile(
|
|
3244
3582
|
this.filePath,
|
|
3245
3583
|
[...merged].join("\n") + "\n",
|
|
@@ -3306,7 +3644,7 @@ var ContentHashIndex = class _ContentHashIndex {
|
|
|
3306
3644
|
* fired retry) simply yields `acquired=false` after the bounded wait.
|
|
3307
3645
|
*/
|
|
3308
3646
|
async rebuildUnderLock(populate) {
|
|
3309
|
-
await mkdir(
|
|
3647
|
+
await mkdir(path8.dirname(this.filePath), { recursive: true });
|
|
3310
3648
|
let published = false;
|
|
3311
3649
|
await withHeldFileLock(
|
|
3312
3650
|
`${this.filePath}.lock`,
|
|
@@ -3373,7 +3711,7 @@ var ContentHashIndex = class _ContentHashIndex {
|
|
|
3373
3711
|
if (!this.dirty) break;
|
|
3374
3712
|
if (attempt < maxAttempts - 1) {
|
|
3375
3713
|
const wait = Math.min(baseMs * 2 ** attempt, CONTENT_HASH_INDEX_RETRY_MAX_DELAY_MS);
|
|
3376
|
-
await new Promise((
|
|
3714
|
+
await new Promise((resolve3) => setTimeout(resolve3, wait));
|
|
3377
3715
|
}
|
|
3378
3716
|
}
|
|
3379
3717
|
if (this.reconcileRetryTimer) {
|
|
@@ -3403,8 +3741,8 @@ var ContentHashIndex = class _ContentHashIndex {
|
|
|
3403
3741
|
return;
|
|
3404
3742
|
}
|
|
3405
3743
|
if (!this.reconcileRetryBarrier) {
|
|
3406
|
-
this.reconcileRetryBarrier = new Promise((
|
|
3407
|
-
this.reconcileRetryResolve =
|
|
3744
|
+
this.reconcileRetryBarrier = new Promise((resolve3) => {
|
|
3745
|
+
this.reconcileRetryResolve = resolve3;
|
|
3408
3746
|
});
|
|
3409
3747
|
}
|
|
3410
3748
|
const attempt = this.reconcileRetryAttempts + 1;
|
|
@@ -3432,10 +3770,10 @@ var ContentHashIndex = class _ContentHashIndex {
|
|
|
3432
3770
|
}
|
|
3433
3771
|
/** Resolve and clear the retry barrier if one is outstanding. */
|
|
3434
3772
|
settleReconcileRetry() {
|
|
3435
|
-
const
|
|
3773
|
+
const resolve3 = this.reconcileRetryResolve;
|
|
3436
3774
|
this.reconcileRetryBarrier = null;
|
|
3437
3775
|
this.reconcileRetryResolve = null;
|
|
3438
|
-
|
|
3776
|
+
resolve3?.();
|
|
3439
3777
|
}
|
|
3440
3778
|
/** Remove a hash from the index (used when archiving/deleting). */
|
|
3441
3779
|
remove(content) {
|
|
@@ -4107,17 +4445,17 @@ function inferEntityTypeFromContent(content) {
|
|
|
4107
4445
|
}
|
|
4108
4446
|
var KNOWN_ENTITY_FILENAME_PREFIXES = /* @__PURE__ */ new Set(["company", "other", "person", "place", "project", "tool", "topic"]);
|
|
4109
4447
|
function inferEntityTypeFromFilename(pathRel) {
|
|
4110
|
-
const basename =
|
|
4448
|
+
const basename = path9.basename(pathRel, ".md").toLowerCase();
|
|
4111
4449
|
const separator = basename.indexOf("-");
|
|
4112
4450
|
if (separator <= 0) return void 0;
|
|
4113
4451
|
const candidate = basename.slice(0, separator);
|
|
4114
4452
|
return KNOWN_ENTITY_FILENAME_PREFIXES.has(candidate) ? candidate : void 0;
|
|
4115
4453
|
}
|
|
4116
4454
|
function normalizeFrontmatterForPath(frontmatter, pathRel, content = "") {
|
|
4117
|
-
const normalizedPath = pathRel.split(
|
|
4455
|
+
const normalizedPath = pathRel.split(path9.sep).join("/");
|
|
4118
4456
|
let normalizedFrontmatter = frontmatter;
|
|
4119
4457
|
if (normalizedPath === "entities" || normalizedPath.startsWith("entities/") || normalizedPath.includes("/entities/")) {
|
|
4120
|
-
const basename =
|
|
4458
|
+
const basename = path9.basename(pathRel, ".md");
|
|
4121
4459
|
const inferredType = inferEntityTypeFromContent(content) || inferEntityTypeFromFilename(pathRel) || "entity";
|
|
4122
4460
|
const existingTags = Array.isArray(frontmatter.tags) ? frontmatter.tags : [];
|
|
4123
4461
|
normalizedFrontmatter = {
|
|
@@ -4783,8 +5121,8 @@ var StorageManager3 = class _StorageManager {
|
|
|
4783
5121
|
}
|
|
4784
5122
|
/** Whether `filePath` resolves to `stateDir` itself or a path contained in it. */
|
|
4785
5123
|
isStateFilePath(filePath) {
|
|
4786
|
-
const rel =
|
|
4787
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
5124
|
+
const rel = path9.relative(this.stateDir, path9.resolve(filePath));
|
|
5125
|
+
return rel === "" || !rel.startsWith("..") && !path9.isAbsolute(rel);
|
|
4788
5126
|
}
|
|
4789
5127
|
// ── Tombstone store (issue #1579) ───────────────────────────────────────
|
|
4790
5128
|
// Instance-scoped (rule 11) + namespace-scoped (rule 42) tombstone index.
|
|
@@ -4884,8 +5222,8 @@ var StorageManager3 = class _StorageManager {
|
|
|
4884
5222
|
* /srv/cold/remnic), skipping the patch and stranding a stale hot entry.
|
|
4885
5223
|
*/
|
|
4886
5224
|
isColdOrArchiveTierPath(p) {
|
|
4887
|
-
const rel =
|
|
4888
|
-
return rel === "cold" || rel === "archive" || rel.startsWith(`cold${
|
|
5225
|
+
const rel = path9.relative(this.baseDir, p);
|
|
5226
|
+
return rel === "cold" || rel === "archive" || rel.startsWith(`cold${path9.sep}`) || rel.startsWith(`archive${path9.sep}`);
|
|
4889
5227
|
}
|
|
4890
5228
|
/**
|
|
4891
5229
|
* Mark the secure-store as required for this storage instance.
|
|
@@ -4972,7 +5310,7 @@ var StorageManager3 = class _StorageManager {
|
|
|
4972
5310
|
void 0,
|
|
4973
5311
|
this.baseDir
|
|
4974
5312
|
);
|
|
4975
|
-
const rel =
|
|
5313
|
+
const rel = path9.relative(this.baseDir, filePath).split(path9.sep).join("/");
|
|
4976
5314
|
return `${rel}:${version.versionId}`;
|
|
4977
5315
|
} catch (err) {
|
|
4978
5316
|
log.warn(
|
|
@@ -5052,13 +5390,13 @@ var StorageManager3 = class _StorageManager {
|
|
|
5052
5390
|
}
|
|
5053
5391
|
identityFilePath(workspaceDir, namespace) {
|
|
5054
5392
|
const rawNamespace = typeof namespace === "string" ? namespace.trim() : "";
|
|
5055
|
-
if (!rawNamespace) return
|
|
5393
|
+
if (!rawNamespace) return path9.join(workspaceDir, "IDENTITY.md");
|
|
5056
5394
|
const safeNamespace = rawNamespace.replace(/[^a-zA-Z0-9._-]/g, "-");
|
|
5057
|
-
return
|
|
5395
|
+
return path9.join(workspaceDir, `IDENTITY.${safeNamespace}.md`);
|
|
5058
5396
|
}
|
|
5059
5397
|
versionFilePath(kind) {
|
|
5060
5398
|
const fileName = kind === "memory-status" ? ".memory-status-version.log" : kind === "artifact-write" ? ".artifact-write-version.log" : kind === "cold-write" ? ".cold-write-version.log" : ".memory-corpus-version.log";
|
|
5061
|
-
return
|
|
5399
|
+
return path9.join(this.stateDir, fileName);
|
|
5062
5400
|
}
|
|
5063
5401
|
bumpSharedVersion(kind, fallbackMap) {
|
|
5064
5402
|
const filePath = this.versionFilePath(kind);
|
|
@@ -5150,7 +5488,7 @@ var StorageManager3 = class _StorageManager {
|
|
|
5150
5488
|
// memories.
|
|
5151
5489
|
// -------------------------------------------------------------------------
|
|
5152
5490
|
get wearablesDir() {
|
|
5153
|
-
return
|
|
5491
|
+
return path9.join(this.baseDir, WEARABLES_DIR_NAME);
|
|
5154
5492
|
}
|
|
5155
5493
|
/**
|
|
5156
5494
|
* Resolve the on-disk path for a source/day transcript. Throws on
|
|
@@ -5166,7 +5504,7 @@ var StorageManager3 = class _StorageManager {
|
|
|
5166
5504
|
if (!isValidTranscriptDate(date)) {
|
|
5167
5505
|
throw new Error(`invalid wearable transcript date '${String(date)}' \u2014 expected YYYY-MM-DD`);
|
|
5168
5506
|
}
|
|
5169
|
-
return
|
|
5507
|
+
return path9.join(this.wearablesDir, sourceId, `${date}.md`);
|
|
5170
5508
|
}
|
|
5171
5509
|
async writeWearableDayTranscript(sourceId, date, serialized) {
|
|
5172
5510
|
const targetPath = this.wearableTranscriptPath(sourceId, date);
|
|
@@ -5198,6 +5536,24 @@ var StorageManager3 = class _StorageManager {
|
|
|
5198
5536
|
lstat: (p) => lstat2(p).then((st) => ({ isSymbolicLink: st.isSymbolicLink() }))
|
|
5199
5537
|
});
|
|
5200
5538
|
}
|
|
5539
|
+
_meetingRecordStore;
|
|
5540
|
+
/**
|
|
5541
|
+
* Meeting record IO (issue #1900). Records live under `<baseDir>/meetings/`
|
|
5542
|
+
* — inside the QMD collection root (full-text searchable) but outside the
|
|
5543
|
+
* memory scan roots — and inherit the same encrypted-at-rest + atomic-write +
|
|
5544
|
+
* symlink-containment semantics as memories via the shared secure IO port.
|
|
5545
|
+
*/
|
|
5546
|
+
meetingRecordStore() {
|
|
5547
|
+
if (this._meetingRecordStore) return this._meetingRecordStore;
|
|
5548
|
+
return this._meetingRecordStore = new MeetingRecordStore(this.baseDir, {
|
|
5549
|
+
writeFile: (p, c) => this.writeStorageSecureFile(p, c),
|
|
5550
|
+
readFile: (p) => readMaybeEncryptedFile(p, this._secureStoreKey, this.baseDir),
|
|
5551
|
+
readDir: (d) => readdir4(d),
|
|
5552
|
+
deleteFile: (p) => unlink2(p),
|
|
5553
|
+
realpath: (p) => realpath2(p),
|
|
5554
|
+
lstat: (p) => lstat2(p).then((st) => ({ isSymbolicLink: st.isSymbolicLink() }))
|
|
5555
|
+
});
|
|
5556
|
+
}
|
|
5201
5557
|
/**
|
|
5202
5558
|
* Locate a wearable-sourced memory by exact (trimmed) content,
|
|
5203
5559
|
* ignoring the "[Attributes: ...]" suffix writeMemory appends for
|
|
@@ -5264,25 +5620,25 @@ var StorageManager3 = class _StorageManager {
|
|
|
5264
5620
|
});
|
|
5265
5621
|
}
|
|
5266
5622
|
get factsDir() {
|
|
5267
|
-
return
|
|
5623
|
+
return path9.join(this.baseDir, "facts");
|
|
5268
5624
|
}
|
|
5269
5625
|
get correctionsDir() {
|
|
5270
|
-
return
|
|
5626
|
+
return path9.join(this.baseDir, "corrections");
|
|
5271
5627
|
}
|
|
5272
5628
|
get proceduresDir() {
|
|
5273
|
-
return
|
|
5629
|
+
return path9.join(this.baseDir, "procedures");
|
|
5274
5630
|
}
|
|
5275
5631
|
get reasoningTracesDir() {
|
|
5276
|
-
return
|
|
5632
|
+
return path9.join(this.baseDir, "reasoning-traces");
|
|
5277
5633
|
}
|
|
5278
5634
|
get entitiesDir() {
|
|
5279
|
-
return
|
|
5635
|
+
return path9.join(this.baseDir, "entities");
|
|
5280
5636
|
}
|
|
5281
5637
|
resolveEntityFilePath(name) {
|
|
5282
5638
|
if (typeof name !== "string") return null;
|
|
5283
|
-
const filePath =
|
|
5284
|
-
const
|
|
5285
|
-
if (
|
|
5639
|
+
const filePath = path9.resolve(this.entitiesDir, `${name}.md`);
|
|
5640
|
+
const relative2 = path9.relative(this.entitiesDir, filePath);
|
|
5641
|
+
if (relative2 === "" || relative2.startsWith("..") || path9.isAbsolute(relative2)) {
|
|
5286
5642
|
return null;
|
|
5287
5643
|
}
|
|
5288
5644
|
return filePath;
|
|
@@ -5303,10 +5659,10 @@ var StorageManager3 = class _StorageManager {
|
|
|
5303
5659
|
});
|
|
5304
5660
|
}
|
|
5305
5661
|
assertManagedStoragePath(filePath, method) {
|
|
5306
|
-
const resolved =
|
|
5307
|
-
const base =
|
|
5308
|
-
const rel =
|
|
5309
|
-
if (rel === "" || rel === ".." || rel.startsWith(`..${
|
|
5662
|
+
const resolved = path9.resolve(filePath);
|
|
5663
|
+
const base = path9.resolve(this.baseDir);
|
|
5664
|
+
const rel = path9.relative(base, resolved);
|
|
5665
|
+
if (rel === "" || rel === ".." || rel.startsWith(`..${path9.sep}`) || path9.isAbsolute(rel)) {
|
|
5310
5666
|
throw new Error(`${method}: file path escapes memory dir`);
|
|
5311
5667
|
}
|
|
5312
5668
|
return resolved;
|
|
@@ -5318,7 +5674,7 @@ var StorageManager3 = class _StorageManager {
|
|
|
5318
5674
|
async digestOfflineSyncFile(filePath) {
|
|
5319
5675
|
const target = this.assertManagedStoragePath(filePath, "storage.digestOfflineSyncFile");
|
|
5320
5676
|
const st = await stat3(target);
|
|
5321
|
-
const relPath =
|
|
5677
|
+
const relPath = path9.relative(this.baseDir, target).split(path9.sep).join("/");
|
|
5322
5678
|
const cache = await this.loadOfflineSyncDigestCache();
|
|
5323
5679
|
const cached = cache.get(relPath);
|
|
5324
5680
|
if (cached && cached.statBytes === st.size && cached.mtimeMs === st.mtimeMs && cached.ctimeMs === st.ctimeMs && !cached.encrypted) {
|
|
@@ -5332,11 +5688,11 @@ var StorageManager3 = class _StorageManager {
|
|
|
5332
5688
|
if (encrypted) {
|
|
5333
5689
|
const content = await readMaybeEncryptedFileBuffer(target, this._secureStoreKey, this.baseDir);
|
|
5334
5690
|
digest = {
|
|
5335
|
-
sha256:
|
|
5691
|
+
sha256: createHash5("sha256").update(content).digest("hex"),
|
|
5336
5692
|
bytes: content.byteLength
|
|
5337
5693
|
};
|
|
5338
5694
|
} else {
|
|
5339
|
-
const hash =
|
|
5695
|
+
const hash = createHash5("sha256");
|
|
5340
5696
|
let bytes = 0;
|
|
5341
5697
|
for await (const rawChunk of createReadStream(target)) {
|
|
5342
5698
|
const chunk = Buffer.isBuffer(rawChunk) ? rawChunk : Buffer.from(rawChunk);
|
|
@@ -5379,7 +5735,7 @@ var StorageManager3 = class _StorageManager {
|
|
|
5379
5735
|
const bytes = typeof record.bytes === "number" ? record.bytes : NaN;
|
|
5380
5736
|
const sha256 = typeof record.sha256 === "string" ? record.sha256 : "";
|
|
5381
5737
|
const encrypted = record.encrypted === true;
|
|
5382
|
-
if (cachePath.length === 0 || cachePath === ".." || cachePath.startsWith("../") ||
|
|
5738
|
+
if (cachePath.length === 0 || cachePath === ".." || cachePath.startsWith("../") || path9.isAbsolute(cachePath) || !Number.isFinite(statBytes) || !Number.isFinite(mtimeMs) || !Number.isFinite(ctimeMs) || !Number.isFinite(bytes) || !/^[a-f0-9]{64}$/i.test(sha256)) {
|
|
5383
5739
|
continue;
|
|
5384
5740
|
}
|
|
5385
5741
|
cache.set(cachePath, { statBytes, mtimeMs, ctimeMs, encrypted, sha256, bytes });
|
|
@@ -5421,7 +5777,7 @@ var StorageManager3 = class _StorageManager {
|
|
|
5421
5777
|
const cache = this.offlineSyncDigestCache;
|
|
5422
5778
|
if (!cache) return;
|
|
5423
5779
|
const entries = [...cache.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([entryPath, entry]) => ({ path: entryPath, ...entry }));
|
|
5424
|
-
await mkdir2(
|
|
5780
|
+
await mkdir2(path9.dirname(this.offlineSyncDigestCachePath), { recursive: true });
|
|
5425
5781
|
await writeFile(this.offlineSyncDigestCachePath, `${JSON.stringify({ version: 1, entries })}
|
|
5426
5782
|
`, "utf-8");
|
|
5427
5783
|
}).catch((err) => {
|
|
@@ -5466,10 +5822,10 @@ var StorageManager3 = class _StorageManager {
|
|
|
5466
5822
|
this.invalidateAllMemoriesCache();
|
|
5467
5823
|
this.invalidateKnowledgeIndexCache();
|
|
5468
5824
|
this.factHashIndexAuthoritative = false;
|
|
5469
|
-
if (filePath.includes(`${
|
|
5825
|
+
if (filePath.includes(`${path9.sep}cold${path9.sep}`)) {
|
|
5470
5826
|
this.invalidateColdMemoriesCache();
|
|
5471
5827
|
}
|
|
5472
|
-
if (filePath.includes(`${
|
|
5828
|
+
if (filePath.includes(`${path9.sep}artifacts${path9.sep}`)) {
|
|
5473
5829
|
this.bumpArtifactWriteVersion();
|
|
5474
5830
|
}
|
|
5475
5831
|
this.bumpMemoryStatusVersion();
|
|
@@ -5540,7 +5896,7 @@ var StorageManager3 = class _StorageManager {
|
|
|
5540
5896
|
}
|
|
5541
5897
|
async appendStorageSecureFileUnlocked(filePath, content) {
|
|
5542
5898
|
const writeKey = this.resolveWriteKey();
|
|
5543
|
-
await mkdir2(
|
|
5899
|
+
await mkdir2(path9.dirname(filePath), { recursive: true });
|
|
5544
5900
|
if (writeKey === null) {
|
|
5545
5901
|
try {
|
|
5546
5902
|
if (await this.isEncryptedFileHeader(filePath)) {
|
|
@@ -5566,13 +5922,13 @@ var StorageManager3 = class _StorageManager {
|
|
|
5566
5922
|
this.notifyCatalogWriteForPath(filePath);
|
|
5567
5923
|
}
|
|
5568
5924
|
get stateDir() {
|
|
5569
|
-
return
|
|
5925
|
+
return path9.join(this.baseDir, "state");
|
|
5570
5926
|
}
|
|
5571
5927
|
get offlineSyncDigestCachePath() {
|
|
5572
|
-
return
|
|
5928
|
+
return path9.join(this.baseDir, ".offline-sync", "digest-cache.v1.json");
|
|
5573
5929
|
}
|
|
5574
5930
|
get entitySynthesisQueuePath() {
|
|
5575
|
-
return
|
|
5931
|
+
return path9.join(this.stateDir, "entity-synthesis-queue.json");
|
|
5576
5932
|
}
|
|
5577
5933
|
// ── Tombstone store access (issue #1579) ─────────────────────────────────
|
|
5578
5934
|
/**
|
|
@@ -5582,7 +5938,7 @@ var StorageManager3 = class _StorageManager {
|
|
|
5582
5938
|
* helpers are injected into the store).
|
|
5583
5939
|
*/
|
|
5584
5940
|
get tombstonesPath() {
|
|
5585
|
-
return
|
|
5941
|
+
return path9.join(this.stateDir, "tombstones.jsonl");
|
|
5586
5942
|
}
|
|
5587
5943
|
/**
|
|
5588
5944
|
* Configure the tombstone invariant for this storage instance. Installed
|
|
@@ -5777,7 +6133,7 @@ var StorageManager3 = class _StorageManager {
|
|
|
5777
6133
|
);
|
|
5778
6134
|
if (published || attempt === maxAttempts - 1) break;
|
|
5779
6135
|
const wait = Math.min(baseMs * 2 ** attempt, CONTENT_HASH_INDEX_RETRY_MAX_DELAY_MS);
|
|
5780
|
-
await new Promise((
|
|
6136
|
+
await new Promise((resolve3) => setTimeout(resolve3, wait));
|
|
5781
6137
|
}
|
|
5782
6138
|
this.factHashIndexAuthoritative = published;
|
|
5783
6139
|
if (!published) {
|
|
@@ -5855,55 +6211,55 @@ var StorageManager3 = class _StorageManager {
|
|
|
5855
6211
|
return null;
|
|
5856
6212
|
}
|
|
5857
6213
|
get questionsDir() {
|
|
5858
|
-
return
|
|
6214
|
+
return path9.join(this.baseDir, "questions");
|
|
5859
6215
|
}
|
|
5860
6216
|
get artifactsDir() {
|
|
5861
|
-
return
|
|
6217
|
+
return path9.join(this.baseDir, "artifacts");
|
|
5862
6218
|
}
|
|
5863
6219
|
get identityDir() {
|
|
5864
|
-
return
|
|
6220
|
+
return path9.join(this.baseDir, "identity");
|
|
5865
6221
|
}
|
|
5866
6222
|
get identityAnchorPath() {
|
|
5867
|
-
return
|
|
6223
|
+
return path9.join(this.identityDir, "identity-anchor.md");
|
|
5868
6224
|
}
|
|
5869
6225
|
get identityIncidentsDir() {
|
|
5870
|
-
return
|
|
6226
|
+
return path9.join(this.identityDir, "incidents");
|
|
5871
6227
|
}
|
|
5872
6228
|
get identityAuditsWeeklyDir() {
|
|
5873
|
-
return
|
|
6229
|
+
return path9.join(this.identityDir, "audits", "weekly");
|
|
5874
6230
|
}
|
|
5875
6231
|
get identityAuditsMonthlyDir() {
|
|
5876
|
-
return
|
|
6232
|
+
return path9.join(this.identityDir, "audits", "monthly");
|
|
5877
6233
|
}
|
|
5878
6234
|
get identityImprovementLoopsPath() {
|
|
5879
|
-
return
|
|
6235
|
+
return path9.join(this.identityDir, "improvement-loops.md");
|
|
5880
6236
|
}
|
|
5881
6237
|
get identityReflectionsPath() {
|
|
5882
|
-
return
|
|
6238
|
+
return path9.join(this.identityDir, "reflections.md");
|
|
5883
6239
|
}
|
|
5884
6240
|
get profilePath() {
|
|
5885
|
-
return
|
|
6241
|
+
return path9.join(this.baseDir, "profile.md");
|
|
5886
6242
|
}
|
|
5887
6243
|
get memoryActionsPath() {
|
|
5888
|
-
return
|
|
6244
|
+
return path9.join(this.stateDir, "memory-actions.jsonl");
|
|
5889
6245
|
}
|
|
5890
6246
|
get memoryLifecycleLedgerPath() {
|
|
5891
|
-
return
|
|
6247
|
+
return path9.join(this.stateDir, "memory-lifecycle-ledger.jsonl");
|
|
5892
6248
|
}
|
|
5893
6249
|
get compressionGuidelinesPath() {
|
|
5894
|
-
return
|
|
6250
|
+
return path9.join(this.stateDir, "compression-guidelines.md");
|
|
5895
6251
|
}
|
|
5896
6252
|
get compressionGuidelineDraftPath() {
|
|
5897
|
-
return
|
|
6253
|
+
return path9.join(this.stateDir, "compression-guidelines.draft.md");
|
|
5898
6254
|
}
|
|
5899
6255
|
get compressionGuidelineStatePath() {
|
|
5900
|
-
return
|
|
6256
|
+
return path9.join(this.stateDir, "compression-guideline-state.json");
|
|
5901
6257
|
}
|
|
5902
6258
|
get compressionGuidelineDraftStatePath() {
|
|
5903
|
-
return
|
|
6259
|
+
return path9.join(this.stateDir, "compression-guideline-draft-state.json");
|
|
5904
6260
|
}
|
|
5905
6261
|
get behaviorSignalsPath() {
|
|
5906
|
-
return
|
|
6262
|
+
return path9.join(this.stateDir, "behavior-signals.jsonl");
|
|
5907
6263
|
}
|
|
5908
6264
|
/**
|
|
5909
6265
|
* In-memory dedup key set for behavior-signals appends (issue #1909),
|
|
@@ -5935,7 +6291,7 @@ var StorageManager3 = class _StorageManager {
|
|
|
5935
6291
|
* governance sweeps can treat it uniformly.
|
|
5936
6292
|
*/
|
|
5937
6293
|
get bufferSurpriseLedgerPath() {
|
|
5938
|
-
return
|
|
6294
|
+
return path9.join(this.stateDir, "buffer-surprise-ledger.jsonl");
|
|
5939
6295
|
}
|
|
5940
6296
|
/**
|
|
5941
6297
|
* Entity alias table loaded from THIS store's config/aliases.json.
|
|
@@ -5966,7 +6322,7 @@ var StorageManager3 = class _StorageManager {
|
|
|
5966
6322
|
this.loadAliasesSync();
|
|
5967
6323
|
}
|
|
5968
6324
|
loadAliasesSync() {
|
|
5969
|
-
const aliasPath =
|
|
6325
|
+
const aliasPath = path9.join(this.baseDir, "config", "aliases.json");
|
|
5970
6326
|
this.userAliases = {};
|
|
5971
6327
|
try {
|
|
5972
6328
|
const raw = readFileSync(aliasPath, "utf-8");
|
|
@@ -5989,9 +6345,9 @@ var StorageManager3 = class _StorageManager {
|
|
|
5989
6345
|
}
|
|
5990
6346
|
async ensureDirectories() {
|
|
5991
6347
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
5992
|
-
await mkdir2(
|
|
5993
|
-
await mkdir2(
|
|
5994
|
-
await mkdir2(
|
|
6348
|
+
await mkdir2(path9.join(this.factsDir, today), { recursive: true });
|
|
6349
|
+
await mkdir2(path9.join(this.proceduresDir, today), { recursive: true });
|
|
6350
|
+
await mkdir2(path9.join(this.reasoningTracesDir, today), { recursive: true });
|
|
5995
6351
|
await mkdir2(this.correctionsDir, { recursive: true });
|
|
5996
6352
|
await mkdir2(this.entitiesDir, { recursive: true });
|
|
5997
6353
|
await mkdir2(this.stateDir, { recursive: true });
|
|
@@ -6001,7 +6357,7 @@ var StorageManager3 = class _StorageManager {
|
|
|
6001
6357
|
await mkdir2(this.identityIncidentsDir, { recursive: true });
|
|
6002
6358
|
await mkdir2(this.identityAuditsWeeklyDir, { recursive: true });
|
|
6003
6359
|
await mkdir2(this.identityAuditsMonthlyDir, { recursive: true });
|
|
6004
|
-
await mkdir2(
|
|
6360
|
+
await mkdir2(path9.join(this.baseDir, "config"), { recursive: true });
|
|
6005
6361
|
if (this.hotMemoriesCacheEnabled && this.getMemoryCorpusVersion() === 0) {
|
|
6006
6362
|
this.bumpMemoryCorpusVersion();
|
|
6007
6363
|
}
|
|
@@ -6021,11 +6377,11 @@ var StorageManager3 = class _StorageManager {
|
|
|
6021
6377
|
async resolveCategoryWritePath(category, id, today) {
|
|
6022
6378
|
if (category === "correction") {
|
|
6023
6379
|
await mkdir2(this.correctionsDir, { recursive: true });
|
|
6024
|
-
return
|
|
6380
|
+
return path9.join(this.correctionsDir, `${id}.md`);
|
|
6025
6381
|
}
|
|
6026
|
-
const datedDir =
|
|
6382
|
+
const datedDir = path9.join(getCategoryDir(this.baseDir, category), today);
|
|
6027
6383
|
await mkdir2(datedDir, { recursive: true });
|
|
6028
|
-
return
|
|
6384
|
+
return path9.join(datedDir, `${id}.md`);
|
|
6029
6385
|
}
|
|
6030
6386
|
async writeMemory(category, content, options = {}) {
|
|
6031
6387
|
await this.ensureDirectories();
|
|
@@ -6330,7 +6686,7 @@ ${sanitized.text}
|
|
|
6330
6686
|
await this.ensureDirectories();
|
|
6331
6687
|
const now = /* @__PURE__ */ new Date();
|
|
6332
6688
|
const day = now.toISOString().slice(0, 10);
|
|
6333
|
-
const dir =
|
|
6689
|
+
const dir = path9.join(this.artifactsDir, day);
|
|
6334
6690
|
await mkdir2(dir, { recursive: true });
|
|
6335
6691
|
const id = `artifact-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
6336
6692
|
const fm = {
|
|
@@ -6355,7 +6711,7 @@ ${sanitized.text}
|
|
|
6355
6711
|
log.warn(`artifact content rejected for ${id}; violations=${sanitized.violations.join(", ")}`);
|
|
6356
6712
|
return "";
|
|
6357
6713
|
}
|
|
6358
|
-
const filePath =
|
|
6714
|
+
const filePath = path9.join(dir, `${id}.md`);
|
|
6359
6715
|
await this.writeStorageSecureFile(filePath, `${serializeFrontmatter(fm)}
|
|
6360
6716
|
|
|
6361
6717
|
${sanitized.text}
|
|
@@ -6631,7 +6987,7 @@ ${sanitized.text}
|
|
|
6631
6987
|
* per-process in-memory cache safe across process boundaries.
|
|
6632
6988
|
*/
|
|
6633
6989
|
invalidateColdMemoriesCache() {
|
|
6634
|
-
const coldRoot =
|
|
6990
|
+
const coldRoot = path9.join(this.baseDir, "cold");
|
|
6635
6991
|
_StorageManager.coldMemoriesCache.delete(coldRoot);
|
|
6636
6992
|
this.bumpColdWriteVersion();
|
|
6637
6993
|
invalidateAllForDir(this.baseDir);
|
|
@@ -6723,7 +7079,7 @@ ${sanitized.text}
|
|
|
6723
7079
|
const correctionPaths = [];
|
|
6724
7080
|
const factPaths = [];
|
|
6725
7081
|
for (const filePath of filePaths) {
|
|
6726
|
-
if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${
|
|
7082
|
+
if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${path9.sep}`)) {
|
|
6727
7083
|
correctionPaths.push(filePath);
|
|
6728
7084
|
} else {
|
|
6729
7085
|
factPaths.push(filePath);
|
|
@@ -6786,7 +7142,7 @@ ${sanitized.text}
|
|
|
6786
7142
|
try {
|
|
6787
7143
|
const entries = await readdir4(dir, { withFileTypes: true });
|
|
6788
7144
|
for (const entry of entries) {
|
|
6789
|
-
const fullPath =
|
|
7145
|
+
const fullPath = path9.join(dir, entry.name);
|
|
6790
7146
|
if (entry.isDirectory()) {
|
|
6791
7147
|
await readDir(fullPath);
|
|
6792
7148
|
} else if (entry.name.endsWith(".md")) {
|
|
@@ -6819,7 +7175,7 @@ ${sanitized.text}
|
|
|
6819
7175
|
return this.memoryReadStore.readMemoryByPath(filePath);
|
|
6820
7176
|
}
|
|
6821
7177
|
resolveTierRootDir(tier) {
|
|
6822
|
-
return tier === "cold" ?
|
|
7178
|
+
return tier === "cold" ? path9.join(this.baseDir, "cold") : this.baseDir;
|
|
6823
7179
|
}
|
|
6824
7180
|
resolveMemoryDateDir(memory) {
|
|
6825
7181
|
const preferred = memory.frontmatter.created || memory.frontmatter.updated;
|
|
@@ -6834,13 +7190,13 @@ ${sanitized.text}
|
|
|
6834
7190
|
buildTierMemoryPath(memory, tier) {
|
|
6835
7191
|
const root = this.resolveTierRootDir(tier);
|
|
6836
7192
|
if (this.isArtifactMemory(memory)) {
|
|
6837
|
-
return
|
|
7193
|
+
return path9.join(root, "artifacts", this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
|
|
6838
7194
|
}
|
|
6839
7195
|
if (memory.frontmatter.category === "correction") {
|
|
6840
|
-
return
|
|
7196
|
+
return path9.join(root, "corrections", `${memory.frontmatter.id}.md`);
|
|
6841
7197
|
}
|
|
6842
7198
|
const dir = categoryDirName(memory.frontmatter.category);
|
|
6843
|
-
return
|
|
7199
|
+
return path9.join(root, dir, this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
|
|
6844
7200
|
}
|
|
6845
7201
|
async writeMemoryFileAtomic(targetPath, memory) {
|
|
6846
7202
|
const fileContent = `${serializeFrontmatter(memory.frontmatter)}
|
|
@@ -6853,8 +7209,8 @@ ${memory.content}
|
|
|
6853
7209
|
}
|
|
6854
7210
|
async moveMemoryToPath(memory, targetPath) {
|
|
6855
7211
|
await this.writeMemoryFileAtomic(targetPath, memory);
|
|
6856
|
-
const sourcePath =
|
|
6857
|
-
const destPath =
|
|
7212
|
+
const sourcePath = path9.resolve(memory.path);
|
|
7213
|
+
const destPath = path9.resolve(targetPath);
|
|
6858
7214
|
if (sourcePath !== destPath) {
|
|
6859
7215
|
try {
|
|
6860
7216
|
await unlink2(memory.path);
|
|
@@ -6870,8 +7226,8 @@ ${memory.content}
|
|
|
6870
7226
|
}
|
|
6871
7227
|
async migrateMemoryToTier(memory, targetTier) {
|
|
6872
7228
|
const targetPath = this.buildTierMemoryPath(memory, targetTier);
|
|
6873
|
-
const sourcePath =
|
|
6874
|
-
const destPath =
|
|
7229
|
+
const sourcePath = path9.resolve(memory.path);
|
|
7230
|
+
const destPath = path9.resolve(targetPath);
|
|
6875
7231
|
if (sourcePath === destPath) {
|
|
6876
7232
|
return { changed: false, targetPath };
|
|
6877
7233
|
}
|
|
@@ -6898,7 +7254,7 @@ ${memory.content}
|
|
|
6898
7254
|
return { changed: true, targetPath };
|
|
6899
7255
|
}
|
|
6900
7256
|
get archiveDir() {
|
|
6901
|
-
return
|
|
7257
|
+
return path9.join(this.baseDir, "archive");
|
|
6902
7258
|
}
|
|
6903
7259
|
/**
|
|
6904
7260
|
* Archive a memory by moving it from facts/ to archive/YYYY-MM-DD/.
|
|
@@ -6909,7 +7265,7 @@ ${memory.content}
|
|
|
6909
7265
|
try {
|
|
6910
7266
|
const now = lifecycle?.at ?? /* @__PURE__ */ new Date();
|
|
6911
7267
|
const today = now.toISOString().slice(0, 10);
|
|
6912
|
-
const destDir =
|
|
7268
|
+
const destDir = path9.join(this.archiveDir, today);
|
|
6913
7269
|
await mkdir2(destDir, { recursive: true });
|
|
6914
7270
|
const updatedFm = {
|
|
6915
7271
|
...memory.frontmatter,
|
|
@@ -6921,7 +7277,7 @@ ${memory.content}
|
|
|
6921
7277
|
|
|
6922
7278
|
${memory.content}
|
|
6923
7279
|
`;
|
|
6924
|
-
const destPath =
|
|
7280
|
+
const destPath = path9.join(destDir, path9.basename(memory.path));
|
|
6925
7281
|
await this.writeStorageSecureFile(destPath, fileContent);
|
|
6926
7282
|
await unlink2(memory.path);
|
|
6927
7283
|
markProjectedMemoryPathInvalid(this.baseDir, memory.frontmatter.id);
|
|
@@ -7069,7 +7425,7 @@ ${memory.content}
|
|
|
7069
7425
|
`;
|
|
7070
7426
|
await this.writeStorageSecureFile(memory.path, fileContent);
|
|
7071
7427
|
await this.patchHotMemoriesCache({ addedPath: memory.path });
|
|
7072
|
-
if (memory.path.includes(`${
|
|
7428
|
+
if (memory.path.includes(`${path9.sep}cold${path9.sep}`)) {
|
|
7073
7429
|
this.invalidateColdMemoriesCache();
|
|
7074
7430
|
}
|
|
7075
7431
|
try {
|
|
@@ -7140,7 +7496,7 @@ ${memory.content}
|
|
|
7140
7496
|
return deleted;
|
|
7141
7497
|
}
|
|
7142
7498
|
async loadBuffer() {
|
|
7143
|
-
const bufferPath =
|
|
7499
|
+
const bufferPath = path9.join(this.stateDir, "buffer.json");
|
|
7144
7500
|
try {
|
|
7145
7501
|
const raw = await this.readStorageSecureFile(bufferPath);
|
|
7146
7502
|
return JSON.parse(raw);
|
|
@@ -7152,11 +7508,11 @@ ${memory.content}
|
|
|
7152
7508
|
}
|
|
7153
7509
|
async saveBuffer(state) {
|
|
7154
7510
|
await this.ensureDirectories();
|
|
7155
|
-
const bufferPath =
|
|
7511
|
+
const bufferPath = path9.join(this.stateDir, "buffer.json");
|
|
7156
7512
|
await this.writeStorageSecureFile(bufferPath, JSON.stringify(state, null, 2));
|
|
7157
7513
|
}
|
|
7158
7514
|
async loadMeta() {
|
|
7159
|
-
const metaPath =
|
|
7515
|
+
const metaPath = path9.join(this.stateDir, "meta.json");
|
|
7160
7516
|
try {
|
|
7161
7517
|
const raw = await this.readStorageSecureFile(metaPath);
|
|
7162
7518
|
const parsed = JSON.parse(raw);
|
|
@@ -7189,7 +7545,7 @@ ${memory.content}
|
|
|
7189
7545
|
}
|
|
7190
7546
|
async saveMeta(state) {
|
|
7191
7547
|
await this.ensureDirectories();
|
|
7192
|
-
const metaPath =
|
|
7548
|
+
const metaPath = path9.join(this.stateDir, "meta.json");
|
|
7193
7549
|
await this.writeStorageSecureFile(metaPath, JSON.stringify(state, null, 2));
|
|
7194
7550
|
}
|
|
7195
7551
|
async appendMemoryActionEvents(events) {
|
|
@@ -7256,7 +7612,7 @@ ${memory.content}
|
|
|
7256
7612
|
},
|
|
7257
7613
|
(payload) => this.appendStorageSecureFile(target, payload),
|
|
7258
7614
|
async () => {
|
|
7259
|
-
await mkdir2(
|
|
7615
|
+
await mkdir2(path9.dirname(target), { recursive: true });
|
|
7260
7616
|
}
|
|
7261
7617
|
);
|
|
7262
7618
|
}
|
|
@@ -7354,7 +7710,7 @@ ${memory.content}
|
|
|
7354
7710
|
async appendReextractJobs(events) {
|
|
7355
7711
|
if (events.length === 0) return 0;
|
|
7356
7712
|
await this.ensureDirectories();
|
|
7357
|
-
const filePath =
|
|
7713
|
+
const filePath = path9.join(this.stateDir, "reextract-jobs.jsonl");
|
|
7358
7714
|
const lines = events.map((event) => JSON.stringify(event)).join("\n") + "\n";
|
|
7359
7715
|
try {
|
|
7360
7716
|
await this.appendStorageSecureFile(filePath, lines);
|
|
@@ -7367,7 +7723,7 @@ ${memory.content}
|
|
|
7367
7723
|
}
|
|
7368
7724
|
async readReextractJobs(limit = 200) {
|
|
7369
7725
|
const safeLimit = Number.isFinite(limit) ? Math.max(1, Math.min(1e3, Math.floor(limit))) : 200;
|
|
7370
|
-
const filePath =
|
|
7726
|
+
const filePath = path9.join(this.stateDir, "reextract-jobs.jsonl");
|
|
7371
7727
|
try {
|
|
7372
7728
|
const raw = await this.readStorageSecureFile(filePath);
|
|
7373
7729
|
const lines = raw.split("\n").filter((line) => line.trim().length > 0);
|
|
@@ -7519,7 +7875,7 @@ ${memory.content}
|
|
|
7519
7875
|
return false;
|
|
7520
7876
|
}
|
|
7521
7877
|
if (draftState.contentHash) {
|
|
7522
|
-
const contentHash =
|
|
7878
|
+
const contentHash = createHash5("sha256").update(draftContent).digest("hex");
|
|
7523
7879
|
if (contentHash !== draftState.contentHash) return false;
|
|
7524
7880
|
}
|
|
7525
7881
|
await this.writeCompressionGuidelines(draftContent);
|
|
@@ -7597,7 +7953,7 @@ ${question}
|
|
|
7597
7953
|
|
|
7598
7954
|
**Context:** ${context}
|
|
7599
7955
|
`;
|
|
7600
|
-
const filePath =
|
|
7956
|
+
const filePath = path9.join(this.questionsDir, `${id}.md`);
|
|
7601
7957
|
await this.writeStorageSecureFile(filePath, content);
|
|
7602
7958
|
log.debug(`wrote question ${id} to ${filePath}`);
|
|
7603
7959
|
this.invalidateQuestionsCache();
|
|
@@ -7615,7 +7971,7 @@ ${question}
|
|
|
7615
7971
|
if (!match) return null;
|
|
7616
7972
|
const frontmatterStr = match[1];
|
|
7617
7973
|
const body = match[2].trim();
|
|
7618
|
-
const id = this.extractFrontmatterValue(frontmatterStr, "id") ??
|
|
7974
|
+
const id = this.extractFrontmatterValue(frontmatterStr, "id") ?? path9.basename(filePath, ".md");
|
|
7619
7975
|
const created = this.extractFrontmatterValue(frontmatterStr, "created") ?? "";
|
|
7620
7976
|
const priority = parseFloat(this.extractFrontmatterValue(frontmatterStr, "priority") ?? "0.5");
|
|
7621
7977
|
const resolved = this.extractFrontmatterValue(frontmatterStr, "resolved") === "true";
|
|
@@ -7671,11 +8027,11 @@ ${question}
|
|
|
7671
8027
|
} catch {
|
|
7672
8028
|
}
|
|
7673
8029
|
const hygiene = opts?.hygiene;
|
|
7674
|
-
const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(
|
|
8030
|
+
const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(path9.basename(identityPath));
|
|
7675
8031
|
if (rotateEnabled) {
|
|
7676
8032
|
const maxBytes = hygiene.rotateMaxBytes;
|
|
7677
8033
|
if (existing.length > maxBytes) {
|
|
7678
|
-
const archiveDir =
|
|
8034
|
+
const archiveDir = path9.join(workspaceDir, hygiene.archiveDir);
|
|
7679
8035
|
const { newContent } = await rotateMarkdownFileToArchive({
|
|
7680
8036
|
filePath: identityPath,
|
|
7681
8037
|
archiveDir,
|
|
@@ -7771,7 +8127,7 @@ ${reflection}
|
|
|
7771
8127
|
* Deduplicates by target+label.
|
|
7772
8128
|
*/
|
|
7773
8129
|
async addEntityRelationship(name, rel) {
|
|
7774
|
-
const filePath =
|
|
8130
|
+
const filePath = path9.join(this.entitiesDir, `${name}.md`);
|
|
7775
8131
|
let entity;
|
|
7776
8132
|
try {
|
|
7777
8133
|
const content = await this.readStorageSecureFile(filePath);
|
|
@@ -7794,7 +8150,7 @@ ${reflection}
|
|
|
7794
8150
|
* Prepends to the beginning, prunes oldest entries beyond maxEntries.
|
|
7795
8151
|
*/
|
|
7796
8152
|
async addEntityActivity(name, entry, maxEntries) {
|
|
7797
|
-
const filePath =
|
|
8153
|
+
const filePath = path9.join(this.entitiesDir, `${name}.md`);
|
|
7798
8154
|
let entity;
|
|
7799
8155
|
try {
|
|
7800
8156
|
const content = await this.readStorageSecureFile(filePath);
|
|
@@ -7817,7 +8173,7 @@ ${reflection}
|
|
|
7817
8173
|
* Add an alias to an entity file. Deduplicates.
|
|
7818
8174
|
*/
|
|
7819
8175
|
async addEntityAlias(name, alias) {
|
|
7820
|
-
const filePath =
|
|
8176
|
+
const filePath = path9.join(this.entitiesDir, `${name}.md`);
|
|
7821
8177
|
let entity;
|
|
7822
8178
|
try {
|
|
7823
8179
|
const content = await this.readStorageSecureFile(filePath);
|
|
@@ -7844,7 +8200,7 @@ ${reflection}
|
|
|
7844
8200
|
const updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7845
8201
|
let synthesisTimelineCount;
|
|
7846
8202
|
try {
|
|
7847
|
-
const filePath =
|
|
8203
|
+
const filePath = path9.join(this.entitiesDir, `${name}.md`);
|
|
7848
8204
|
const content = await this.readStorageSecureFile(filePath);
|
|
7849
8205
|
synthesisTimelineCount = parseEntityFile(content, this.entitySchemas).timeline.length;
|
|
7850
8206
|
} catch (err) {
|
|
@@ -7927,7 +8283,7 @@ ${reflection}
|
|
|
7927
8283
|
if (!raw) continue;
|
|
7928
8284
|
const serialized = serializeEntityFile(parseEntityFile(raw, this.entitySchemas), this.entitySchemas);
|
|
7929
8285
|
if (raw.trimEnd() === serialized.trimEnd()) continue;
|
|
7930
|
-
await this.writeStorageSecureFile(
|
|
8286
|
+
await this.writeStorageSecureFile(path9.join(this.entitiesDir, `${entityName}.md`), serialized);
|
|
7931
8287
|
migrated += 1;
|
|
7932
8288
|
}
|
|
7933
8289
|
if (migrated > 0) {
|
|
@@ -8020,14 +8376,14 @@ ${reflection}
|
|
|
8020
8376
|
if (entries.length === 0) return 0;
|
|
8021
8377
|
const memories = await this.readAllMemories();
|
|
8022
8378
|
const memoryMap = new Map(memories.map((m) => [m.frontmatter.id, m]));
|
|
8023
|
-
const memoryPathMap = new Map(memories.map((m) => [
|
|
8379
|
+
const memoryPathMap = new Map(memories.map((m) => [path9.resolve(m.path), m]));
|
|
8024
8380
|
let updated = 0;
|
|
8025
8381
|
const prevVersion = this.getMemoryCorpusVersion();
|
|
8026
8382
|
const keyId = this.hotCacheKeyId();
|
|
8027
8383
|
const warm = this.hotMemoriesCacheEnabled && getCachedMemories(this.baseDir, prevVersion, keyId, this.hotCacheTtlMs()) !== null;
|
|
8028
8384
|
const appliedPatches = /* @__PURE__ */ new Map();
|
|
8029
8385
|
for (const entry of entries) {
|
|
8030
|
-
const memory = entry.memoryPath ? memoryPathMap.get(
|
|
8386
|
+
const memory = entry.memoryPath ? memoryPathMap.get(path9.resolve(entry.memoryPath)) : memoryMap.get(entry.memoryId);
|
|
8031
8387
|
if (!memory) continue;
|
|
8032
8388
|
const newFm = {
|
|
8033
8389
|
...memory.frontmatter,
|
|
@@ -8043,7 +8399,7 @@ ${memory.content}
|
|
|
8043
8399
|
if (warm) {
|
|
8044
8400
|
updateCacheOnWrite(this.baseDir, { ...memory, frontmatter: newFm }, keyId);
|
|
8045
8401
|
}
|
|
8046
|
-
appliedPatches.set(
|
|
8402
|
+
appliedPatches.set(path9.resolve(memory.path), {
|
|
8047
8403
|
accessCount: entry.newCount,
|
|
8048
8404
|
lastAccessed: entry.lastAccessed
|
|
8049
8405
|
});
|
|
@@ -8059,7 +8415,7 @@ ${memory.content}
|
|
|
8059
8415
|
const cur = getCachedMemories(this.baseDir, prevVersion, keyId);
|
|
8060
8416
|
if (cur) {
|
|
8061
8417
|
const reapplied = cur.map((m) => {
|
|
8062
|
-
const patch = appliedPatches.get(
|
|
8418
|
+
const patch = appliedPatches.get(path9.resolve(m.path));
|
|
8063
8419
|
return patch ? { ...m, frontmatter: { ...m.frontmatter, accessCount: patch.accessCount, lastAccessed: patch.lastAccessed } } : m;
|
|
8064
8420
|
});
|
|
8065
8421
|
setCachedMemories(this.baseDir, reapplied, produced, keyId, this.hotCacheTtlMs());
|
|
@@ -8091,7 +8447,7 @@ ${memory.content}
|
|
|
8091
8447
|
const pathsById = /* @__PURE__ */ new Map();
|
|
8092
8448
|
const filePathsById = /* @__PURE__ */ new Map();
|
|
8093
8449
|
for (const filePath of filePaths) {
|
|
8094
|
-
const memoryId =
|
|
8450
|
+
const memoryId = path9.basename(filePath, ".md");
|
|
8095
8451
|
if (!wantedIds.has(memoryId)) continue;
|
|
8096
8452
|
const paths = filePathsById.get(memoryId) ?? [];
|
|
8097
8453
|
paths.push(filePath);
|
|
@@ -8106,7 +8462,7 @@ ${memory.content}
|
|
|
8106
8462
|
qmdResultPathCandidates(this.baseDir, preferredPath)
|
|
8107
8463
|
);
|
|
8108
8464
|
const directMatch = existingPaths.find(
|
|
8109
|
-
(filePath) => directCandidates.has(
|
|
8465
|
+
(filePath) => directCandidates.has(path9.resolve(filePath))
|
|
8110
8466
|
);
|
|
8111
8467
|
if (directMatch) {
|
|
8112
8468
|
preferredMatches.push(directMatch);
|
|
@@ -8119,7 +8475,7 @@ ${memory.content}
|
|
|
8119
8475
|
candidates.add(candidate);
|
|
8120
8476
|
}
|
|
8121
8477
|
}
|
|
8122
|
-
const match = existingPaths.find((filePath) => candidates.has(
|
|
8478
|
+
const match = existingPaths.find((filePath) => candidates.has(path9.resolve(filePath)));
|
|
8123
8479
|
if (match) preferredMatches.push(match);
|
|
8124
8480
|
}
|
|
8125
8481
|
if (preferredMatches.length > 0) {
|
|
@@ -8338,14 +8694,14 @@ Reason: ${reason}`;
|
|
|
8338
8694
|
// Memory Summarization (Phase 4A)
|
|
8339
8695
|
// ---------------------------------------------------------------------------
|
|
8340
8696
|
get summariesDir() {
|
|
8341
|
-
return
|
|
8697
|
+
return path9.join(this.baseDir, "summaries");
|
|
8342
8698
|
}
|
|
8343
8699
|
/**
|
|
8344
8700
|
* Write a memory summary.
|
|
8345
8701
|
*/
|
|
8346
8702
|
async writeSummary(summary) {
|
|
8347
8703
|
await mkdir2(this.summariesDir, { recursive: true });
|
|
8348
|
-
const filePath =
|
|
8704
|
+
const filePath = path9.join(this.summariesDir, `${summary.id}.json`);
|
|
8349
8705
|
await this.writeStorageSecureFile(filePath, JSON.stringify(summary, null, 2));
|
|
8350
8706
|
log.debug(`wrote summary ${summary.id}`);
|
|
8351
8707
|
}
|
|
@@ -8358,7 +8714,7 @@ Reason: ${reason}`;
|
|
|
8358
8714
|
const summaries = [];
|
|
8359
8715
|
for (const file of files) {
|
|
8360
8716
|
if (!file.endsWith(".json")) continue;
|
|
8361
|
-
const filePath =
|
|
8717
|
+
const filePath = path9.join(this.summariesDir, file);
|
|
8362
8718
|
const raw = await this.readStorageSecureFile(filePath);
|
|
8363
8719
|
summaries.push(JSON.parse(raw));
|
|
8364
8720
|
}
|
|
@@ -8420,7 +8776,7 @@ ${memory.content}
|
|
|
8420
8776
|
* Save topic scores to meta.json.
|
|
8421
8777
|
*/
|
|
8422
8778
|
async saveTopics(topics) {
|
|
8423
|
-
const metaPath =
|
|
8779
|
+
const metaPath = path9.join(this.stateDir, "topics.json");
|
|
8424
8780
|
await mkdir2(this.stateDir, { recursive: true });
|
|
8425
8781
|
await this.writeStorageSecureFile(
|
|
8426
8782
|
metaPath,
|
|
@@ -8432,7 +8788,7 @@ ${memory.content}
|
|
|
8432
8788
|
* Load topic scores from meta.json.
|
|
8433
8789
|
*/
|
|
8434
8790
|
async loadTopics() {
|
|
8435
|
-
const metaPath =
|
|
8791
|
+
const metaPath = path9.join(this.stateDir, "topics.json");
|
|
8436
8792
|
try {
|
|
8437
8793
|
const raw = await this.readStorageSecureFile(metaPath);
|
|
8438
8794
|
return JSON.parse(raw);
|
|
@@ -8529,6 +8885,14 @@ export {
|
|
|
8529
8885
|
serializeFusionDay,
|
|
8530
8886
|
parseFusionDay,
|
|
8531
8887
|
reconstructFusionInputs,
|
|
8888
|
+
MEETINGS_DIR_NAME,
|
|
8889
|
+
MEETING_KIND,
|
|
8890
|
+
MEETING_FORMAT_VERSION,
|
|
8891
|
+
meetingIdDate,
|
|
8892
|
+
composeMeetingRecord,
|
|
8893
|
+
serializeMeetingRecord,
|
|
8894
|
+
parseMeetingRecordSummary,
|
|
8895
|
+
MeetingRecordStore,
|
|
8532
8896
|
normalizeStructuredSectionFacts,
|
|
8533
8897
|
compileEntityFacts,
|
|
8534
8898
|
compareEntityTimestamps,
|
|
@@ -8547,4 +8911,4 @@ export {
|
|
|
8547
8911
|
isValidBufferSurpriseEvent,
|
|
8548
8912
|
StorageManager3 as StorageManager
|
|
8549
8913
|
};
|
|
8550
|
-
//# sourceMappingURL=chunk-
|
|
8914
|
+
//# sourceMappingURL=chunk-XWPFZX6S.js.map
|