@remnic/core 9.38.3 → 9.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-admin-ops-surface.d.ts +10 -10
- package/dist/access-admin-ops-surface.js +15 -15
- package/dist/access-authorization-probe.d.ts +10 -10
- package/dist/access-authorization-probe.js +16 -16
- package/dist/access-boundary.d.ts +10 -10
- package/dist/access-boundary.js +15 -15
- package/dist/access-cli.js +37 -37
- package/dist/access-extraction-force-flush.d.ts +10 -10
- package/dist/access-extraction-force-flush.js +15 -15
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +10 -10
- package/dist/access-http-lifecycle-flush.d.ts +10 -10
- package/dist/access-http.d.ts +10 -10
- package/dist/access-http.js +20 -20
- package/dist/access-identity-continuity-surface.d.ts +8 -8
- package/dist/access-identity-continuity-surface.js +15 -15
- package/dist/access-lcm-surface.d.ts +10 -10
- package/dist/access-lcm-surface.js +15 -15
- package/dist/access-mcp.d.ts +10 -10
- package/dist/access-mcp.js +18 -18
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-CWyL4Zai.d.ts → access-namespace-preflight-BbDJBq0e.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +15 -15
- package/dist/access-observe-write-surface.d.ts +10 -10
- package/dist/access-observe-write-surface.js +15 -15
- package/dist/access-operations-batch.js +16 -16
- package/dist/access-operations.d.ts +10 -10
- package/dist/access-operations.js +17 -17
- package/dist/access-recall-concurrency.d.ts +10 -10
- package/dist/access-recall-concurrency.js +15 -15
- package/dist/access-recall-response.d.ts +10 -10
- package/dist/access-recall-response.js +15 -15
- package/dist/access-recall-surface.d.ts +10 -10
- package/dist/access-recall-surface.js +15 -15
- package/dist/{access-service-C2WYT1pO.d.ts → access-service-B2h6rITp.d.ts} +7 -7
- package/dist/access-service-helpers.d.ts +10 -10
- package/dist/access-service.d.ts +10 -10
- package/dist/access-service.js +15 -15
- package/dist/access-surface-catalog.d.ts +10 -10
- package/dist/access-wearables-meetings-surface.d.ts +3 -3
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +1 -1
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +8 -8
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +6 -6
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer-turn-helpers.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{catalog-Du4bpZWM.d.ts → catalog-Bz2LxGNb.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 +7 -7
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/{chunk-6TF4M2LB.js → chunk-3C2TGBDB.js} +2 -2
- package/dist/{chunk-T3FVAHM7.js → chunk-4VXGRIH6.js} +286 -7
- package/dist/chunk-4VXGRIH6.js.map +1 -0
- package/dist/{chunk-UBWOCQ3I.js → chunk-5N26WBPQ.js} +2 -2
- package/dist/{chunk-PRP3M5Y3.js → chunk-5TOV3D6U.js} +2 -2
- package/dist/{chunk-DKKZ6SO2.js → chunk-6GIMMNVK.js} +22 -45
- package/dist/chunk-6GIMMNVK.js.map +1 -0
- package/dist/{chunk-ILGC6JH6.js → chunk-7RJUVTVF.js} +16 -1
- package/dist/chunk-7RJUVTVF.js.map +1 -0
- package/dist/{chunk-BGLDKAYY.js → chunk-AXHMCRS3.js} +2 -2
- package/dist/{chunk-AF4HOJMH.js → chunk-AYICY7IE.js} +2 -2
- package/dist/{chunk-6D5D5A4M.js → chunk-BI6RE2ZS.js} +2 -2
- package/dist/{chunk-6BNE62PM.js → chunk-EBWOOJEP.js} +2 -2
- package/dist/{chunk-PYTUBWAS.js → chunk-F2KMAFEB.js} +2 -2
- package/dist/{chunk-DMT2RGAZ.js → chunk-FXGLFGIG.js} +3 -3
- package/dist/{chunk-44SRDUI4.js → chunk-GLBK35BT.js} +20 -20
- package/dist/{chunk-HXDWZFNP.js → chunk-GSL47NPM.js} +1 -1
- package/dist/chunk-GSL47NPM.js.map +1 -0
- package/dist/{chunk-RY2XZTFN.js → chunk-JDXDA5OO.js} +2 -2
- package/dist/{chunk-5ZGHUWTT.js → chunk-KPJQTSRJ.js} +2 -2
- package/dist/{chunk-P2NCTIKE.js → chunk-KW4ZFTUS.js} +8 -7
- package/dist/chunk-KW4ZFTUS.js.map +1 -0
- package/dist/{chunk-POQGCS4H.js → chunk-KYYRJVE6.js} +2 -2
- package/dist/{chunk-IB26HVAJ.js → chunk-MOHZIKZM.js} +2 -2
- package/dist/chunk-MOHZIKZM.js.map +1 -0
- package/dist/{chunk-IJAQCBGV.js → chunk-MSXWUXFE.js} +2 -2
- package/dist/{chunk-WET4M3R6.js → chunk-MVW234LO.js} +2 -2
- package/dist/{chunk-RY7CHVGE.js → chunk-NEO4QCID.js} +2 -2
- package/dist/{chunk-JYLN6KHH.js → chunk-NHRNYJPJ.js} +7 -9
- package/dist/{chunk-JYLN6KHH.js.map → chunk-NHRNYJPJ.js.map} +1 -1
- package/dist/{chunk-4TAD3B56.js → chunk-OEXKYYVH.js} +2 -2
- package/dist/{chunk-RMOSIGGI.js → chunk-Q6QYN56R.js} +2 -2
- package/dist/{chunk-FE7MUX7M.js → chunk-QY66HJ4X.js} +2 -2
- package/dist/{chunk-KWU6MAD4.js → chunk-R4Q7CQGZ.js} +2 -2
- package/dist/{chunk-IMEXE4XS.js → chunk-RK6WMGTX.js} +7 -7
- package/dist/{chunk-C3HUHJ4G.js → chunk-SD4A6IZY.js} +3 -3
- package/dist/{chunk-MYXWPG5O.js → chunk-TXBU7YDV.js} +2 -2
- package/dist/{chunk-YVMVVE4B.js → chunk-UIVRPXRR.js} +2 -2
- package/dist/{chunk-NBAEGFXT.js → chunk-WGCTFGLW.js} +11 -14
- package/dist/chunk-WGCTFGLW.js.map +1 -0
- package/dist/{chunk-XBJC7RTW.js → chunk-XPQ5ZTL6.js} +19 -19
- package/dist/{chunk-XEM77GGX.js → chunk-XYXYEDPL.js} +10 -10
- package/dist/{chunk-HUS2XN3T.js → chunk-YFHMW37V.js} +2 -2
- package/dist/{chunk-HKF5VASQ.js → chunk-ZA53AZND.js} +17 -6
- package/dist/chunk-ZA53AZND.js.map +1 -0
- package/dist/{chunk-Q3CVY7LV.js → chunk-ZERSIPFC.js} +202 -232
- package/dist/chunk-ZERSIPFC.js.map +1 -0
- package/dist/{cli-jkmzdT8P.d.ts → cli-CO8qKPM5.d.ts} +5 -5
- package/dist/cli.d.ts +12 -12
- package/dist/cli.js +32 -32
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +6 -6
- package/dist/compounding/preference-consolidator.d.ts +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +6 -6
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +6 -6
- 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/corpus-watermark.d.ts +1 -1
- package/dist/corpus-watermark.js +8 -8
- 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 +6 -6
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +8 -8
- package/dist/extraction-error-classification.d.ts +1 -1
- package/dist/extraction-faithfulness.d.ts +1 -1
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction-liveness.d.ts +1 -1
- package/dist/extraction-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 +6 -6
- package/dist/fallback-llm.d.ts +1 -1
- 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 +19 -19
- package/dist/index.js +37 -37
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/index.d.ts +1 -1
- 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 +6 -6
- package/dist/maintenance/rebuild-memory-projection.d.ts +18 -11
- package/dist/maintenance/rebuild-memory-projection.js +7 -7
- package/dist/{maintenance-Ha9Dg93M.d.ts → maintenance-D2jkiT9r.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +10 -10
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/memory-lifecycle-ledger-utils.d.ts +9 -2
- package/dist/memory-lifecycle-ledger-utils.js +5 -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 +7 -7
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +6 -6
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/offline-sync-impression-drain.js +5 -3
- package/dist/operator-doctor-corpus.d.ts +1 -1
- package/dist/operator-doctor-corpus.js +9 -9
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +13 -13
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +4 -4
- package/dist/orchestration/maintenance.js +11 -11
- package/dist/{orchestrator-DV_u9bfx.d.ts → orchestrator-SHaRXCUF.d.ts} +7 -7
- package/dist/orchestrator.d.ts +8 -8
- package/dist/orchestrator.js +37 -37
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-DSLWFeHz.d.ts → pipeline-B5_tS1Yc.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-BSDGyr0H.d.ts → qmd-CkEV_SPG.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +2 -2
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +1 -1
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +1 -1
- package/dist/recall-xray.js +2 -2
- package/dist/replay/normalizers/chatgpt.d.ts +1 -1
- package/dist/replay/normalizers/claude.d.ts +1 -1
- package/dist/replay/normalizers/openclaw.d.ts +1 -1
- package/dist/replay/normalizers/shared.d.ts +1 -1
- package/dist/replay/runner.d.ts +1 -1
- package/dist/replay/types.d.ts +1 -1
- package/dist/replica-divergence.d.ts +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 +2 -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-C4zY-a2K.d.ts → scope-profiles-DeAdnocS.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/index.d.ts +1 -1
- 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-ChKRYpRO.d.ts → semantic-consolidation-DR_h-JUD.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 +6 -6
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +6 -6
- package/dist/{service-JxXXY-Eh.d.ts → service-BTb94UPJ.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +1 -1
- package/dist/signal.d.ts +1 -1
- package/dist/source-agent-qualifier.d.ts +1 -1
- package/dist/source-agent-qualifier.js +6 -6
- package/dist/{storage-BbH4HDUS.d.ts → storage-ax2EIsVS.d.ts} +2 -2
- package/dist/storage-guards.d.ts +9 -2
- package/dist/storage-guards.js +3 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +5 -5
- 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/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-5398p7Zm.d.ts → types-CCGL-9NX.d.ts} +1 -7
- 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-http.test.ts +60 -0
- package/src/access-http.ts +2 -1
- package/src/access-surface-catalog.test.ts +1 -0
- package/src/config.test.ts +4 -0
- package/src/config.ts +1 -5
- package/src/maintenance/projection-support.ts +192 -1
- package/src/maintenance/rebuild-memory-lifecycle-ledger.ts +5 -16
- package/src/maintenance/rebuild-memory-projection.ts +28 -60
- package/src/memory-lifecycle-ledger-utils.ts +21 -0
- package/src/orchestration/maintenance.test.ts +30 -0
- package/src/storage/memory-lifecycle-ledger-access.ts +198 -1
- package/src/storage/secure-line-reader.ts +3 -1
- package/src/storage-guards.ts +28 -7
- package/src/storage-memory-lifecycle-ledger.test.ts +291 -1
- package/src/storage.ts +11 -21
- package/src/types.ts +1 -7
- package/dist/chunk-DKKZ6SO2.js.map +0 -1
- package/dist/chunk-HKF5VASQ.js.map +0 -1
- package/dist/chunk-HXDWZFNP.js.map +0 -1
- package/dist/chunk-IB26HVAJ.js.map +0 -1
- package/dist/chunk-ILGC6JH6.js.map +0 -1
- package/dist/chunk-NBAEGFXT.js.map +0 -1
- package/dist/chunk-P2NCTIKE.js.map +0 -1
- package/dist/chunk-Q3CVY7LV.js.map +0 -1
- package/dist/chunk-T3FVAHM7.js.map +0 -1
- /package/dist/{chunk-6TF4M2LB.js.map → chunk-3C2TGBDB.js.map} +0 -0
- /package/dist/{chunk-UBWOCQ3I.js.map → chunk-5N26WBPQ.js.map} +0 -0
- /package/dist/{chunk-PRP3M5Y3.js.map → chunk-5TOV3D6U.js.map} +0 -0
- /package/dist/{chunk-BGLDKAYY.js.map → chunk-AXHMCRS3.js.map} +0 -0
- /package/dist/{chunk-AF4HOJMH.js.map → chunk-AYICY7IE.js.map} +0 -0
- /package/dist/{chunk-6D5D5A4M.js.map → chunk-BI6RE2ZS.js.map} +0 -0
- /package/dist/{chunk-6BNE62PM.js.map → chunk-EBWOOJEP.js.map} +0 -0
- /package/dist/{chunk-PYTUBWAS.js.map → chunk-F2KMAFEB.js.map} +0 -0
- /package/dist/{chunk-DMT2RGAZ.js.map → chunk-FXGLFGIG.js.map} +0 -0
- /package/dist/{chunk-44SRDUI4.js.map → chunk-GLBK35BT.js.map} +0 -0
- /package/dist/{chunk-RY2XZTFN.js.map → chunk-JDXDA5OO.js.map} +0 -0
- /package/dist/{chunk-5ZGHUWTT.js.map → chunk-KPJQTSRJ.js.map} +0 -0
- /package/dist/{chunk-POQGCS4H.js.map → chunk-KYYRJVE6.js.map} +0 -0
- /package/dist/{chunk-IJAQCBGV.js.map → chunk-MSXWUXFE.js.map} +0 -0
- /package/dist/{chunk-WET4M3R6.js.map → chunk-MVW234LO.js.map} +0 -0
- /package/dist/{chunk-RY7CHVGE.js.map → chunk-NEO4QCID.js.map} +0 -0
- /package/dist/{chunk-4TAD3B56.js.map → chunk-OEXKYYVH.js.map} +0 -0
- /package/dist/{chunk-RMOSIGGI.js.map → chunk-Q6QYN56R.js.map} +0 -0
- /package/dist/{chunk-FE7MUX7M.js.map → chunk-QY66HJ4X.js.map} +0 -0
- /package/dist/{chunk-KWU6MAD4.js.map → chunk-R4Q7CQGZ.js.map} +0 -0
- /package/dist/{chunk-IMEXE4XS.js.map → chunk-RK6WMGTX.js.map} +0 -0
- /package/dist/{chunk-C3HUHJ4G.js.map → chunk-SD4A6IZY.js.map} +0 -0
- /package/dist/{chunk-MYXWPG5O.js.map → chunk-TXBU7YDV.js.map} +0 -0
- /package/dist/{chunk-YVMVVE4B.js.map → chunk-UIVRPXRR.js.map} +0 -0
- /package/dist/{chunk-XBJC7RTW.js.map → chunk-XPQ5ZTL6.js.map} +0 -0
- /package/dist/{chunk-XEM77GGX.js.map → chunk-XYXYEDPL.js.map} +0 -0
- /package/dist/{chunk-HUS2XN3T.js.map → chunk-YFHMW37V.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-B7RWBZXW.js";
|
|
4
4
|
import {
|
|
5
5
|
StorageManager
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZERSIPFC.js";
|
|
7
7
|
import {
|
|
8
8
|
getCachedEpisodeMap,
|
|
9
9
|
setCachedEpisodeMap
|
|
@@ -109,4 +109,4 @@ export {
|
|
|
109
109
|
compareVerifiedEpisodeResults,
|
|
110
110
|
searchVerifiedEpisodes
|
|
111
111
|
};
|
|
112
|
-
//# sourceMappingURL=chunk-
|
|
112
|
+
//# sourceMappingURL=chunk-OEXKYYVH.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
DELTA_SUBCOMMANDS,
|
|
8
8
|
defineOperation,
|
|
9
9
|
isCodegraphToolName
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-XYXYEDPL.js";
|
|
11
11
|
import {
|
|
12
12
|
serializeMutations,
|
|
13
13
|
withHeldFileLock
|
|
@@ -1805,4 +1805,4 @@ export {
|
|
|
1805
1805
|
codegraphIngestTracesOperation,
|
|
1806
1806
|
REGISTERED_OPERATIONS
|
|
1807
1807
|
};
|
|
1808
|
-
//# sourceMappingURL=chunk-
|
|
1808
|
+
//# sourceMappingURL=chunk-Q6QYN56R.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./chunk-JLNBQWZ2.js";
|
|
6
6
|
import {
|
|
7
7
|
runPostConsolidationMaterialize
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KPJQTSRJ.js";
|
|
9
9
|
import {
|
|
10
10
|
isSemanticConsolidationLlmOperator
|
|
11
11
|
} from "./chunk-G7D6GZ5J.js";
|
|
@@ -220,4 +220,4 @@ export {
|
|
|
220
220
|
buildExtensionsBlockForConsolidation,
|
|
221
221
|
materializeAfterSemanticConsolidation
|
|
222
222
|
};
|
|
223
|
-
//# sourceMappingURL=chunk-
|
|
223
|
+
//# sourceMappingURL=chunk-QY66HJ4X.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isRecallDisclosure
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GSL47NPM.js";
|
|
4
4
|
import {
|
|
5
5
|
normalizeRetrievedMemoryProvenance
|
|
6
6
|
} from "./chunk-I4WBNM3M.js";
|
|
@@ -292,4 +292,4 @@ export {
|
|
|
292
292
|
RecallXrayBuilder,
|
|
293
293
|
summarizeDisclosureTokens
|
|
294
294
|
};
|
|
295
|
-
//# sourceMappingURL=chunk-
|
|
295
|
+
//# sourceMappingURL=chunk-R4Q7CQGZ.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
readNamespaceMaintenanceLastRanStatuses,
|
|
4
4
|
readNamespaceMaintenanceStatuses,
|
|
5
5
|
runNamespaceMaintenancePlan
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BI6RE2ZS.js";
|
|
7
7
|
import {
|
|
8
8
|
analyzeSessionIntegrity,
|
|
9
9
|
applySessionRepair,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "./chunk-CMTINOFS.js";
|
|
15
15
|
import {
|
|
16
16
|
summarizeCorpusAndReplica
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-UIVRPXRR.js";
|
|
18
18
|
import {
|
|
19
19
|
readJudgeVerdictStats
|
|
20
20
|
} from "./chunk-OZKOPQCM.js";
|
|
@@ -38,20 +38,20 @@ import {
|
|
|
38
38
|
} from "./chunk-YBPYIAA5.js";
|
|
39
39
|
import {
|
|
40
40
|
parseConfig
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-MOHZIKZM.js";
|
|
42
42
|
import {
|
|
43
43
|
listMemoryGovernanceRuns,
|
|
44
44
|
readMemoryGovernanceRunArtifact
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-5N26WBPQ.js";
|
|
46
46
|
import {
|
|
47
47
|
listNamespaces
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-NEO4QCID.js";
|
|
49
49
|
import {
|
|
50
50
|
analyzeGraphHealth
|
|
51
51
|
} from "./chunk-L2DPF4DF.js";
|
|
52
52
|
import {
|
|
53
53
|
StorageManager
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-ZERSIPFC.js";
|
|
55
55
|
import {
|
|
56
56
|
lintWorkspaceFiles
|
|
57
57
|
} from "./chunk-DM2T26WE.js";
|
|
@@ -1679,4 +1679,4 @@ export {
|
|
|
1679
1679
|
runBenchmarkRecall,
|
|
1680
1680
|
runOperatorRepair
|
|
1681
1681
|
};
|
|
1682
|
-
//# sourceMappingURL=chunk-
|
|
1682
|
+
//# sourceMappingURL=chunk-RK6WMGTX.js.map
|
|
@@ -28,13 +28,13 @@ import {
|
|
|
28
28
|
defineOperation,
|
|
29
29
|
parseNamespacePreflightWriteOp,
|
|
30
30
|
resolveAuthorizedNamespaceWritablePreflight
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-XYXYEDPL.js";
|
|
32
32
|
import {
|
|
33
33
|
projectTagProjectId
|
|
34
34
|
} from "./chunk-BUE5E2HL.js";
|
|
35
35
|
import {
|
|
36
36
|
validateBriefingFormat
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-3C2TGBDB.js";
|
|
38
38
|
import {
|
|
39
39
|
enforceNamespaceAllowList,
|
|
40
40
|
tokenCapabilityStore
|
|
@@ -494,4 +494,4 @@ defineOperation({ name: "graph_events", description: "SSE graph events.", schema
|
|
|
494
494
|
defineOperation({ name: "chat_message", description: "Chat message.", schema: strictSchema({ message: S.str, chatSessionId: S.str }), handler: async (_i, _ctx) => ({ result: { ok: true } }) });
|
|
495
495
|
defineOperation({ name: "chat_events", description: "SSE chat events.", schema: strictSchema({}), handler: async (_i, _ctx) => ({ result: { stream: "sse" } }) });
|
|
496
496
|
defineOperation({ name: "adapters_status", description: "Adapter registry metadata (issue #1850 round 5). Marker op: the HTTP transport builds the response from its own adapterRegistry, but the op still must be registered so it appears in listRegisteredOperations and enforceTokenOp can gate it for scoped tokens.", schema: strictSchema({}), handler: async (_i, _ctx) => ({ result: { ok: true } }) });
|
|
497
|
-
//# sourceMappingURL=chunk-
|
|
497
|
+
//# sourceMappingURL=chunk-SD4A6IZY.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-SOBJ6NEY.js";
|
|
4
4
|
import {
|
|
5
5
|
summarizeDisclosureTokens
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-R4Q7CQGZ.js";
|
|
7
7
|
import {
|
|
8
8
|
summarizeRetrievedMemoryProvenance
|
|
9
9
|
} from "./chunk-I4WBNM3M.js";
|
|
@@ -587,4 +587,4 @@ export {
|
|
|
587
587
|
renderRecallExplain,
|
|
588
588
|
parseRecallExplainFormat
|
|
589
589
|
};
|
|
590
|
-
//# sourceMappingURL=chunk-
|
|
590
|
+
//# sourceMappingURL=chunk-TXBU7YDV.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
computeCorpusWatermarks,
|
|
6
6
|
resolveCorpusNamespaceRoots
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-AXHMCRS3.js";
|
|
8
8
|
|
|
9
9
|
// src/operator-doctor-corpus.ts
|
|
10
10
|
var DIGEST_PREFIX_LENGTH = 12;
|
|
@@ -78,4 +78,4 @@ export {
|
|
|
78
78
|
corpusWatermarksFromCheck,
|
|
79
79
|
summarizeCorpusAndReplica
|
|
80
80
|
};
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
81
|
+
//# sourceMappingURL=chunk-UIVRPXRR.js.map
|
|
@@ -6,16 +6,20 @@ import {
|
|
|
6
6
|
writeFileAtomically
|
|
7
7
|
} from "./chunk-R6YJI3HE.js";
|
|
8
8
|
import {
|
|
9
|
-
StorageManager
|
|
9
|
+
StorageManager
|
|
10
|
+
} from "./chunk-ZERSIPFC.js";
|
|
11
|
+
import {
|
|
10
12
|
assertInjectedStorageRooted
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-4VXGRIH6.js";
|
|
12
14
|
import {
|
|
13
15
|
MEMORY_LIFECYCLE_LEDGER_LOCK_STALE_MS,
|
|
14
16
|
buildLifecycleEventsForMemory,
|
|
15
17
|
compareMemoryLifecycleEvents,
|
|
18
|
+
isFrontmatterDerivedLifecycleEventType,
|
|
19
|
+
memoryLifecycleEventProjectionIdentity,
|
|
16
20
|
memoryLifecycleLedgerLockPath,
|
|
17
21
|
sortMemoryLifecycleEvents
|
|
18
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-7RJUVTVF.js";
|
|
19
23
|
import {
|
|
20
24
|
displayErrorDetail
|
|
21
25
|
} from "./chunk-RL6NEVXT.js";
|
|
@@ -32,12 +36,6 @@ import {
|
|
|
32
36
|
// src/maintenance/rebuild-memory-lifecycle-ledger.ts
|
|
33
37
|
import path from "path";
|
|
34
38
|
import { stat } from "fs/promises";
|
|
35
|
-
var FRONTMATTER_DERIVED_EVENT_TYPES = {
|
|
36
|
-
created: true,
|
|
37
|
-
updated: true,
|
|
38
|
-
superseded: true,
|
|
39
|
-
archived: true
|
|
40
|
-
};
|
|
41
39
|
function isNodeError(err) {
|
|
42
40
|
return typeof err === "object" && err !== null && "code" in err;
|
|
43
41
|
}
|
|
@@ -159,16 +157,15 @@ async function rebuildMemoryLifecycleLedger(options) {
|
|
|
159
157
|
`lifecycle ledger rebuild aborted: cannot read existing events to preserve (${displayErrorDetail(err) || "unknown error"})`
|
|
160
158
|
);
|
|
161
159
|
}
|
|
162
|
-
const
|
|
163
|
-
const reconstructedKeys = new Set(events.map(contentKey));
|
|
160
|
+
const reconstructedKeys = new Set(events.map(memoryLifecycleEventProjectionIdentity));
|
|
164
161
|
const racedFrontmatterByKey = /* @__PURE__ */ new Map();
|
|
165
162
|
const appendOnly = [];
|
|
166
163
|
for (const event of existing) {
|
|
167
|
-
if (!
|
|
164
|
+
if (!isFrontmatterDerivedLifecycleEventType(event.eventType)) {
|
|
168
165
|
appendOnly.push(event);
|
|
169
166
|
continue;
|
|
170
167
|
}
|
|
171
|
-
const key =
|
|
168
|
+
const key = memoryLifecycleEventProjectionIdentity(event);
|
|
172
169
|
if (reconstructedKeys.has(key)) continue;
|
|
173
170
|
if (!racedFrontmatterByKey.has(key)) racedFrontmatterByKey.set(key, event);
|
|
174
171
|
}
|
|
@@ -263,4 +260,4 @@ export {
|
|
|
263
260
|
backupExistingLedger,
|
|
264
261
|
rebuildMemoryLifecycleLedger
|
|
265
262
|
};
|
|
266
|
-
//# sourceMappingURL=chunk-
|
|
263
|
+
//# sourceMappingURL=chunk-WGCTFGLW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/maintenance/rebuild-memory-lifecycle-ledger.ts"],"sourcesContent":["import path from \"node:path\";\nimport { stat } from \"node:fs/promises\";\nimport { StorageManager } from \"../storage.js\";\nimport { assertInjectedStorageRooted } from \"./projection-support.js\";\nimport { log } from \"../logger.js\";\nimport { displayErrorDetail } from \"../runtime/better-sqlite.js\";\nimport type { MemoryLifecycleEvent } from \"../types.js\";\nimport { toBackupStamp } from \"./backup-stamp.js\";\nimport { copyExistingFileToBackup, writeFileAtomically } from \"./atomic-file.js\";\nimport {\n buildLifecycleEventsForMemory,\n compareMemoryLifecycleEvents,\n sortMemoryLifecycleEvents,\n isFrontmatterDerivedLifecycleEventType,\n memoryLifecycleEventProjectionIdentity,\n memoryLifecycleLedgerLockPath,\n MEMORY_LIFECYCLE_LEDGER_LOCK_STALE_MS,\n} from \"../memory-lifecycle-ledger-utils.js\";\nimport { withHeldFileLock, type HeldFileLockOptions, type HeldFileLockController } from \"../utils/serialize-mutations.js\";\nimport { probeEncryptedRegularFileHeader } from \"../secure-store/secure-fs.js\";\n\n\nexport interface RebuildMemoryLifecycleLedgerOptions {\n memoryDir: string;\n dryRun?: boolean;\n now?: Date;\n /**\n * Active storage context (issue #1910). When provided, memories are read\n * through it (so encrypted-at-rest memories in a secure-store deployment are\n * decrypted with the live key) and the rebuilt ledger is rewritten through\n * its secure writer (so it stays encrypted at rest). Its `dir` MUST equal\n * `memoryDir`. When omitted, a fresh plaintext `StorageManager` is used and\n * the ledger is written as plaintext — the CLI default.\n */\n storage?: StorageManager;\n /**\n * Preserve append-only lifecycle events that have no frontmatter equivalent\n * (issue #1910). `buildLifecycleEventsForMemory` only reconstructs\n * `created`/`updated`/`superseded`/`archived` from frontmatter, so a bare\n * rebuild silently drops history like `explicit_capture_accepted`,\n * `explicit_capture_queued`, `imported`, `promoted`, `merged`, `restored`,\n * and `rejected`. When true, the existing ledger's non-reconstructable rows\n * are read (via the same secure/permissive `readAllMemoryLifecycleEvents`\n * path), merged with the rebuilt rows, deduplicated by `eventId`, and sorted\n * canonically. Background auto-compaction sets this so it never loses events;\n * the manual/CLI repair rebuild leaves it off (reconstruct purely from\n * frontmatter).\n */\n preserveExistingEvents?: boolean;\n /**\n * Override the ledger-lock acquisition timing (issue #2033). Only\n * `maxWaitMs`/`pollMs` are honored; `staleMs` stays fixed at\n * `MEMORY_LIFECYCLE_LEDGER_LOCK_STALE_MS`. Used by tests to force the\n * lock-acquisition-failure branch (`acquired=false`) deterministically\n * without a multi-second wait.\n */\n lockOptions?: Pick<HeldFileLockOptions, \"maxWaitMs\" | \"pollMs\">;\n /**\n * Upper bound (bytes) on the rewritten ledger when preserving events (issue\n * #2033). A preserving compaction carries over ALL append-only history, which\n * — if the history alone is large — could leave the rewritten ledger over the\n * whole-file read/decrypt cap (STATE_FILE_MAX_DECRYPT_BYTES), the exact\n * unreadable-ledger failure compaction exists to prevent. When set and the\n * preserved payload would exceed it, the OLDEST rows are dropped from the\n * active ledger until it fits; because the full pre-compaction ledger is\n * copied verbatim to the timestamped backup first, those rows are archived,\n * not lost. Ignored when `preserveExistingEvents` is off (a frontmatter-only\n * rebuild is already bounded by the corpus). `0`/undefined disables bounding.\n */\n maxLedgerBytes?: number;\n}\n\nexport interface SkippedLifecycleBlankIdMemory {\n path: string;\n}\n\nexport interface SkippedDuplicateLifecycleEvent {\n eventId: string;\n keptPath: string;\n skippedPath: string;\n}\n\nexport interface RebuildMemoryLifecycleLedgerResult {\n dryRun: boolean;\n scannedMemories: number;\n rebuiltRows: number;\n outputPath: string;\n backupPath?: string;\n skippedBlankIdMemories: SkippedLifecycleBlankIdMemory[];\n skippedDuplicateEvents: SkippedDuplicateLifecycleEvent[];\n /**\n * Count of existing-ledger rows carried over beyond the frontmatter\n * reconstruction (only set when `preserveExistingEvents` is on; issue #1910):\n * append-only history with no frontmatter equivalent, plus any\n * frontmatter-derived row that raced in after the corpus scan and so was not\n * reproduced by the reconstruction (#2033).\n */\n preservedAppendOnlyRows?: number;\n /**\n * Count of oldest rows dropped from the ACTIVE ledger to keep it under\n * `maxLedgerBytes` (issue #2033). They remain in the verbatim timestamped\n * backup, so this is a bound-and-archive, not a loss. Set only when bounding\n * actually trimmed rows.\n */\n archivedOverflowRows?: number;\n /**\n * Whether the active ledger was actually backed up and rewritten (issue #2033\n * thread PRRT_kwDORJXyws6SExst). A preserving write-mode rebuild that would\n * reproduce the current ledger byte-for-byte (same decrypted content AND same\n * at-rest format) skips the backup+rewrite, so callers can distinguish a real\n * compaction from a no-op and avoid re-archiving an unchanged ledger every\n * interval. `true` for every dry run's non-write preview is never set — only\n * write-mode results carry it; defaults to `false` when no rewrite happened.\n */\n rewritten?: boolean;\n}\n\nfunction isNodeError(err: unknown): err is NodeJS.ErrnoException {\n return typeof err === \"object\" && err !== null && \"code\" in err;\n}\n\n/** Serialized on-disk size (bytes, incl. trailing newline) of one ledger row. */\nfunction lifecycleRowBytes(event: MemoryLifecycleEvent): number {\n return Buffer.byteLength(`${JSON.stringify(event)}\\n`, \"utf8\");\n}\n\n/**\n * Keep the NEWEST canonically-ordered events whose serialized payload fits\n * strictly under `cap` bytes (issue #2033). Recency is by `timestamp` (newest\n * first), tie-broken by the canonical comparator, so a large append-only\n * history is trimmed to its most recent rows rather than to a single memoryId\n * group (the ledger's on-disk order is by memoryId then time).\n *\n * A row too large to fit the remaining budget is SKIPPED, and scanning\n * continues to older rows that still fit — one oversized (or future-dated,\n * hence recency-first) row cannot truncate the entire older history. The kept\n * subset is returned in the input's canonical order; the caller relies on the\n * verbatim backup to retain the dropped rows.\n */\nexport function boundLifecycleEventsToByteCap(\n events: MemoryLifecycleEvent[],\n cap: number,\n): { kept: MemoryLifecycleEvent[]; dropped: number } {\n if (!(cap > 0)) return { kept: events, dropped: 0 };\n const sizes = new Map<MemoryLifecycleEvent, number>();\n let total = 0;\n for (const event of events) {\n const bytes = lifecycleRowBytes(event);\n sizes.set(event, bytes);\n total += bytes;\n }\n if (total <= cap) return { kept: events, dropped: 0 };\n const byRecency = [...events].sort((a, b) => {\n if (a.timestamp !== b.timestamp) return b.timestamp.localeCompare(a.timestamp);\n return -compareMemoryLifecycleEvents(a, b);\n });\n const keep = new Set<MemoryLifecycleEvent>();\n let running = 0;\n for (const event of byRecency) {\n const bytes = sizes.get(event)!;\n if (running + bytes > cap) continue; // skip this row, keep scanning older rows that still fit\n running += bytes;\n keep.add(event);\n }\n const kept = events.filter((event) => keep.has(event));\n return { kept, dropped: events.length - kept.length };\n}\n\nexport async function backupExistingLedger(\n memoryDir: string,\n outputPath: string,\n now: Date,\n): Promise<string | undefined> {\n try {\n await stat(outputPath);\n } catch (err) {\n if (isNodeError(err) && err.code === \"ENOENT\") {\n return undefined;\n }\n throw err;\n }\n\n const backupPath = path.join(\n memoryDir,\n \"archive\",\n \"memory-lifecycle-ledger\",\n toBackupStamp(now),\n \"state\",\n \"memory-lifecycle-ledger.jsonl\",\n );\n return backupPath;\n}\n\nexport async function rebuildMemoryLifecycleLedger(\n options: RebuildMemoryLifecycleLedgerOptions,\n): Promise<RebuildMemoryLifecycleLedgerResult> {\n const dryRun = options.dryRun !== false;\n const now = options.now ?? new Date();\n const outputPath = path.join(options.memoryDir, \"state\", \"memory-lifecycle-ledger.jsonl\");\n const storage = assertInjectedStorageRooted(\"rebuildMemoryLifecycleLedger\", options.memoryDir, options.storage) ?? new StorageManager(options.memoryDir);\n const secureRewrite = options.storage !== undefined;\n const tiers = [\n await storage.readAllMemories(),\n await storage.readAllColdMemories(),\n await storage.readArchivedMemories(),\n ];\n const allMemories = tiers.flat();\n const skippedBlankIdMemories: SkippedLifecycleBlankIdMemory[] = [];\n const eventCandidates: Array<{ event: MemoryLifecycleEvent; path: string }> = [];\n for (const tier of tiers) {\n for (const memory of [...tier].sort((left, right) => left.path.localeCompare(right.path))) {\n if (!memory.frontmatter.id.trim()) {\n skippedBlankIdMemories.push({ path: memory.path });\n log.warn(`lifecycle ledger rebuild skipped blank memory id: path=${memory.path}`);\n continue;\n }\n for (const event of buildLifecycleEventsForMemory(memory)) {\n eventCandidates.push({ event, path: memory.path });\n }\n }\n }\n\n const orderedEvents = sortMemoryLifecycleEvents(eventCandidates.map((candidate) => candidate.event));\n const candidateByEvent = new Map(\n eventCandidates.map((candidate) => [candidate.event, candidate]),\n );\n const keptByEventId = new Map<string, { event: MemoryLifecycleEvent; path: string }>();\n const events: MemoryLifecycleEvent[] = [];\n const skippedDuplicateEvents: SkippedDuplicateLifecycleEvent[] = [];\n for (const event of orderedEvents) {\n const candidate = candidateByEvent.get(event)!;\n const kept = keptByEventId.get(event.eventId);\n if (kept) {\n skippedDuplicateEvents.push({\n eventId: event.eventId,\n keptPath: kept.path,\n skippedPath: candidate.path,\n });\n log.warn(\n `lifecycle ledger rebuild skipped duplicate event_id=${event.eventId}: `\n + `kept=${kept.path} skipped=${candidate.path}`,\n );\n continue;\n }\n keptByEventId.set(event.eventId, candidate);\n events.push(event);\n }\n\n let finalEvents = events;\n let preservedAppendOnlyRows: number | undefined;\n let archivedOverflowRows: number | undefined;\n let backupPath: string | undefined;\n let rewritten = false;\n // The preserve-read + whole-file rewrite are serialized against concurrent\n // lifecycle appends ONLY in write mode (issue #1910, codex):\n // appendMemoryLifecycleEvents holds this same cross-process lock, so an event\n // appended after the preserve-read but before the atomic rename waits and\n // lands on the compacted ledger instead of being clobbered by the rename. A\n // DRY RUN takes no lock — it reads the ledger read-only to compute the\n // preserve/merge/byte-cap PREVIEW and never rewrites, so it must not block\n // appends (#2033 Cursor). The corpus scan above stays outside the lock in\n // both modes — frontmatter-derived rows come from the memory files.\n const runLedgerCriticalSection = async (\n acquired: boolean,\n lock: HeldFileLockController | null,\n ): Promise<void> => {\n // A WRITE that read or rewrote the ledger without the lock could race a\n // concurrent append/rewrite and lose data, so REFUSE the unlocked fallback\n // withHeldFileLock takes on acquisition timeout (issue #2033 CodeRabbit\n // Critical / codex). A dry run passes lock=null and acquired=true: it never\n // reaches the rewrite, so the unlocked preview read is safe.\n if (!dryRun && !acquired) {\n throw new Error(\n \"lifecycle ledger rebuild aborted: could not acquire the ledger lock within the \"\n + \"acquisition budget; refusing to read or rewrite unlocked so a concurrent append \"\n + \"or compaction cannot be clobbered (issue #1910).\",\n );\n }\n if (options.preserveExistingEvents) {\n // Merge the frontmatter reconstruction (`events`) with the CURRENT ledger\n // so compaction never deletes a lifecycle row that raced the scan (issue\n // #1910, #2033). Read the existing ledger through the uncapped BUFFER\n // path — it decrypts with the live key when `storage` carries the secure\n // context and bypasses the whole-file string decrypt cap, so an oversize\n // encrypted ledger (the exact file compaction must shrink) is still\n // readable here rather than aborting (#2033 Cursor High).\n // preserveExistingEvents means \"never lose history\": if the current\n // ledger genuinely cannot be read (corruption, or a locked required\n // store), ABORT rather than rewrite from frontmatter only and silently\n // drop that history. An absent ledger reads as [] (ENOENT swallowed\n // downstream), so a throw here is always a real read failure.\n let existing: MemoryLifecycleEvent[];\n try {\n existing = await storage.readAllMemoryLifecycleEventsForCompaction();\n } catch (err) {\n throw new Error(\n `lifecycle ledger rebuild aborted: cannot read existing events to preserve `\n + `(${displayErrorDetail(err) || \"unknown error\"})`,\n );\n }\n // The corpus scan (`events`) runs OUTSIDE the lock and is therefore a\n // stale snapshot; `existing` is read here under the lock and is\n // authoritative for what the ledger holds at rewrite time. A\n // frontmatter-derived row (created/updated/superseded/archived) is safe to\n // collapse into the reconstruction ONLY when the scan actually reproduced\n // the same logical event — same (memoryId, eventType, timestamp), which is\n // exactly what the live append stamps (fm.created/updated/...) and what\n // makeRebuiltMemoryLifecycleEvent emits. A frontmatter-derived row whose\n // content key the reconstruction did NOT produce raced in after the scan\n // (a memory created/updated between the scan and this locked read); the\n // reconstruction has no equivalent, so dropping it by eventType alone\n // would delete it. Preserve it instead, deduped by content key so a\n // retried append of the same logical event still collapses to one. Rows\n // that are not frontmatter-derived are append-only history with no\n // reconstruction — always carried over, deduped by eventId in the merge.\n const reconstructedKeys = new Set(events.map(memoryLifecycleEventProjectionIdentity));\n const racedFrontmatterByKey = new Map<string, MemoryLifecycleEvent>();\n const appendOnly: MemoryLifecycleEvent[] = [];\n for (const event of existing) {\n if (!isFrontmatterDerivedLifecycleEventType(event.eventType)) {\n appendOnly.push(event);\n continue;\n }\n const key = memoryLifecycleEventProjectionIdentity(event);\n if (reconstructedKeys.has(key)) continue; // collapsed into reconstruction\n if (!racedFrontmatterByKey.has(key)) racedFrontmatterByKey.set(key, event);\n }\n const mergedById = new Map<string, MemoryLifecycleEvent>();\n for (const event of sortMemoryLifecycleEvents([\n ...events,\n ...racedFrontmatterByKey.values(),\n ...appendOnly,\n ])) {\n if (!mergedById.has(event.eventId)) mergedById.set(event.eventId, event);\n }\n finalEvents = [...mergedById.values()];\n preservedAppendOnlyRows = finalEvents.length - events.length;\n // Bound the rewritten ledger so a preserving compaction can never leave it\n // over the whole-file read/decrypt cap (#2033). This must run whenever a\n // cap is set — NOT only when `existing.length > 0`: an oversized on-disk\n // ledger whose every row fails validation reads as `existing === []`, yet\n // `finalEvents` (the frontmatter reconstruction) can itself exceed the cap.\n // Overflow (oldest) rows are dropped from the active ledger but survive\n // both in the timestamped backup (a verbatim copy when the ledger is\n // plaintext, re-encrypted under the backup path's own AAD when it is\n // encrypted so it still decrypts there, #2033) and, for frontmatter-derived\n // rows, in the memory files they were reconstructed from — so a later full\n // rebuild regenerates them.\n if (options.maxLedgerBytes && options.maxLedgerBytes > 0) {\n const bounded = boundLifecycleEventsToByteCap(finalEvents, options.maxLedgerBytes);\n if (bounded.dropped > 0) {\n finalEvents = bounded.kept;\n archivedOverflowRows = bounded.dropped;\n log.warn(\n `lifecycle ledger rebuild bounded to ${options.maxLedgerBytes} bytes: `\n + `dropped ${bounded.dropped} oldest row(s) from the active ledger `\n + `(preserved in the backup) to stay under the read/decrypt cap.`,\n );\n }\n }\n }\n\n // Re-assert the lock immediately before the destructive active-ledger\n // rewrite. Everything above (the preserve read, merge, sort, byte-cap\n // bound, and JSON serialize) is CPU-bound and blocks the event loop, so the\n // timer heartbeat inside withHeldFileLock cannot refresh the lock's mtime;\n // a peer that judged the lock stale within the 30s window could have broken\n // it and appended to the current ledger. `lock.refresh()` (a) reports the\n // lock LOST so we ABORT rather than rename our compacted file over that\n // peer's append, and (b) when still held, re-stamps the mtime so the bounded\n // write below cannot itself be judged stale mid-rename (issue #1910/#2033).\n const abortIfLockLost = async (): Promise<void> => {\n if (lock && await lock.refresh()) return;\n throw new Error(\n \"lifecycle ledger rebuild aborted: lost the ledger lock during the compaction \"\n + \"rewrite (a peer stale-broke it while the event loop was blocked by CPU-bound \"\n + \"merge/serialize); refusing to clobber a concurrent append (issue #1910/#2033).\",\n );\n };\n if (!dryRun) {\n const payload = finalEvents.map((event) => JSON.stringify(event)).join(\"\\n\");\n const content = payload.length > 0 ? `${payload}\\n` : \"\";\n // No-op skip (#2033 thread PRRT_kwDORJXyws6SExst): a preserving rebuild\n // bounds the ACTIVE ledger to the read/decrypt cap, so a VALID ledger that\n // sits above the configured compaction trigger but below the cap would\n // otherwise be rewritten to identical content and re-archived on every\n // maintenance interval — unbounded growth of archive/memory-lifecycle-ledger\n // plus pointless disk/CPU churn. Skip the backup+rewrite when it would\n // change neither the logical (decrypted) content NOR the at-rest format.\n // The raw read here doubles as the source for the encrypted verbatim backup\n // below, so the current ledger is read at most once. An absent ledger reads\n // as ENOENT (a create is always a real change) and any other read/probe\n // error propagates rather than masking a needed rewrite.\n let currentEncrypted = false;\n let priorRawBuffer: Buffer | null = null;\n try {\n currentEncrypted = await probeEncryptedRegularFileHeader(outputPath);\n priorRawBuffer = await storage.readMemoryLifecycleLedgerRawBufferForCompaction();\n } catch (err) {\n if (!isNodeError(err) || err.code !== \"ENOENT\") throw err;\n }\n // Preserve encryption at rest (#2033). An already-encrypted ledger (or its\n // encrypted backup) MUST be rewritten encrypted even when the\n // `secureStoreEncryptOnWrite` policy is paused — otherwise the compaction\n // silently DOWNGRADES encrypted state to plaintext. Force encryption\n // whenever the current ledger is encrypted and the store is unlocked (a\n // key is available); reaching this point with an encrypted ledger already\n // implies an unlocked store, since the raw read above decrypts and would\n // have thrown under a locked key. A plaintext ledger keeps the ordinary\n // policy (`willEncryptStateWrites`), so existing plaintext behavior holds.\n const forceEncrypt =\n secureRewrite && currentEncrypted && storage.isSecureStoreUnlocked();\n const replacementEncrypted =\n secureRewrite && (storage.willEncryptStateWrites() || forceEncrypt);\n // Compare as buffers, never decoding the raw ledger to one giant string:\n // a multi-hundred-MB decrypted ledger can exceed V8's max string length,\n // so `priorRawBuffer.equals(...)` (byte compare) must be used, NOT\n // `.toString()` (#2033 giant-string invariant). `content` is the freshly\n // serialized replacement, already a string; Buffer.from() reuses it.\n if (\n priorRawBuffer !== null &&\n currentEncrypted === replacementEncrypted &&\n priorRawBuffer.equals(Buffer.from(content, \"utf8\"))\n ) {\n // Nothing to change: leave the active ledger and archive untouched.\n rewritten = false;\n } else {\n const desiredBackup = await backupExistingLedger(options.memoryDir, outputPath, now);\n if (secureRewrite) {\n // Preserve encrypted-at-rest (issue #1910). The BACKUP needs care under\n // secure-store (#2033): when the existing ledger is encrypted, its bytes\n // are path-bound via AAD, so a byte-for-byte copy to the archive path\n // cannot be decrypted there — it would silently orphan the overflow rows\n // a bounded rewrite claims to preserve. Reuse the RAW decrypted ledger\n // content read above (no event parsing, so malformed/truncated/future\n // rows survive exactly as the plaintext verbatim copy keeps them) and\n // re-encrypt it under the backup path's own AAD, yielding a directly\n // decryptable backup that retains every original byte. A PLAINTEXT\n // existing ledger is already readable, so a verbatim copy is correct.\n // Then rewrite the active ledger through the secure writer.\n if (desiredBackup && currentEncrypted) {\n const rawForBackup =\n priorRawBuffer ?? (await storage.readMemoryLifecycleLedgerRawBufferForCompaction());\n await storage.writeMemoryLifecycleLedgerContent(rawForBackup, desiredBackup, forceEncrypt);\n backupPath = desiredBackup;\n } else {\n backupPath = desiredBackup\n ? await copyExistingFileToBackup(outputPath, desiredBackup)\n : undefined;\n }\n await abortIfLockLost();\n await storage.writeMemoryLifecycleLedgerContent(content, undefined, forceEncrypt);\n } else {\n await abortIfLockLost();\n backupPath = await writeFileAtomically(outputPath, content, desiredBackup);\n }\n rewritten = true;\n }\n }\n };\n // Write mode holds the ledger lock across the preserve-read and atomic\n // rewrite so a concurrent append lands on the compacted ledger instead of\n // being clobbered. A dry run computes the SAME preserve/merge/byte-cap\n // preview but WITHOUT the lock (read-only, no rewrite), so `rebuiltRows`,\n // `preservedAppendOnlyRows`, and `archivedOverflowRows` report what a --write\n // would apply while never blocking concurrent appends (#2033 Cursor). A dry\n // run with nothing to preserve touches nothing at all.\n if (!dryRun) {\n await withHeldFileLock(\n memoryLifecycleLedgerLockPath(outputPath),\n { staleMs: MEMORY_LIFECYCLE_LEDGER_LOCK_STALE_MS, ...options.lockOptions },\n runLedgerCriticalSection,\n );\n } else if (options.preserveExistingEvents) {\n await runLedgerCriticalSection(true, null);\n }\n\n return {\n dryRun,\n scannedMemories: allMemories.length,\n rebuiltRows: finalEvents.length,\n outputPath,\n backupPath,\n skippedBlankIdMemories,\n skippedDuplicateEvents,\n preservedAppendOnlyRows,\n archivedOverflowRows,\n rewritten,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AACjB,SAAS,YAAY;AAoHrB,SAAS,YAAY,KAA4C;AAC/D,SAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,UAAU;AAC9D;AAGA,SAAS,kBAAkB,OAAqC;AAC9D,SAAO,OAAO,WAAW,GAAG,KAAK,UAAU,KAAK,CAAC;AAAA,GAAM,MAAM;AAC/D;AAeO,SAAS,8BACd,Q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nF,YAAI,eAAe;AAYjB,cAAI,iBAAiB,kBAAkB;AACrC,kBAAM,eACJ,kBAAmB,MAAM,QAAQ,gDAAgD;AACnF,kBAAM,QAAQ,kCAAkC,cAAc,eAAe,YAAY;AACzF,yBAAa;AAAA,UACf,OAAO;AACL,yBAAa,gBACT,MAAM,yBAAyB,YAAY,aAAa,IACxD;AAAA,UACN;AACA,gBAAM,gBAAgB;AACtB,gBAAM,QAAQ,kCAAkC,SAAS,QAAW,YAAY;AAAA,QAClF,OAAO;AACL,gBAAM,gBAAgB;AACtB,uBAAa,MAAM,oBAAoB,YAAY,SAAS,aAAa;AAAA,QAC3E;AACA,oBAAY;AAAA,MACd;AAAA,IACF;AAAA,EACF;AAQA,MAAI,CAAC,QAAQ;AACX,UAAM;AAAA,MACJ,8BAA8B,UAAU;AAAA,MACxC,EAAE,SAAS,uCAAuC,GAAG,QAAQ,YAAY;AAAA,MACzE;AAAA,IACF;AAAA,EACF,WAAW,QAAQ,wBAAwB;AACzC,UAAM,yBAAyB,MAAM,IAAI;AAAA,EAC3C;AAEA,SAAO;AAAA,IACL;AAAA,IACA,iBAAiB,YAAY;AAAA,IAC7B,aAAa,YAAY;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
ActivityStore,
|
|
18
18
|
MaintenanceScheduler
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-NHRNYJPJ.js";
|
|
20
20
|
import {
|
|
21
21
|
migrateFromEngram
|
|
22
22
|
} from "./chunk-7HYPN2GC.js";
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
import {
|
|
33
33
|
CompoundingEngine,
|
|
34
34
|
defaultTierMigrationCycleBudget
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-MSXWUXFE.js";
|
|
36
36
|
import {
|
|
37
37
|
SharedContextManager
|
|
38
38
|
} from "./chunk-AS7YMSL6.js";
|
|
@@ -198,7 +198,7 @@ import {
|
|
|
198
198
|
buildEntityRecallSection,
|
|
199
199
|
entityRecentTranscriptLookbackHours,
|
|
200
200
|
readRecentEntityTranscriptEntries
|
|
201
|
-
} from "./chunk-
|
|
201
|
+
} from "./chunk-JDXDA5OO.js";
|
|
202
202
|
import {
|
|
203
203
|
buildEventOrderRecallSection,
|
|
204
204
|
shouldRecallEventOrderEvidence
|
|
@@ -214,7 +214,7 @@ import {
|
|
|
214
214
|
ensureBuiltInWearableConnectors,
|
|
215
215
|
getWearableConnector,
|
|
216
216
|
listWearableConnectors
|
|
217
|
-
} from "./chunk-
|
|
217
|
+
} from "./chunk-GLBK35BT.js";
|
|
218
218
|
import {
|
|
219
219
|
normalizeReplaySessionKey
|
|
220
220
|
} from "./chunk-AJVLDJU6.js";
|
|
@@ -224,14 +224,14 @@ import {
|
|
|
224
224
|
import {
|
|
225
225
|
compareVerifiedEpisodeResults,
|
|
226
226
|
searchVerifiedEpisodes
|
|
227
|
-
} from "./chunk-
|
|
227
|
+
} from "./chunk-OEXKYYVH.js";
|
|
228
228
|
import {
|
|
229
229
|
ThreadingManager
|
|
230
230
|
} from "./chunk-OJP3N7UK.js";
|
|
231
231
|
import {
|
|
232
232
|
compareVerifiedSemanticRuleResults,
|
|
233
233
|
searchVerifiedSemanticRules
|
|
234
|
-
} from "./chunk-
|
|
234
|
+
} from "./chunk-5TOV3D6U.js";
|
|
235
235
|
import {
|
|
236
236
|
searchWorkProductLedgerEntries
|
|
237
237
|
} from "./chunk-ZRWB5D4H.js";
|
|
@@ -244,11 +244,11 @@ import {
|
|
|
244
244
|
import {
|
|
245
245
|
runNamespaceMaintenanceFanout,
|
|
246
246
|
summarizeNamespaceMaintenanceHealth
|
|
247
|
-
} from "./chunk-
|
|
247
|
+
} from "./chunk-RK6WMGTX.js";
|
|
248
248
|
import {
|
|
249
249
|
NamespaceCatalog,
|
|
250
250
|
planNamespaceMaintenance
|
|
251
|
-
} from "./chunk-
|
|
251
|
+
} from "./chunk-BI6RE2ZS.js";
|
|
252
252
|
import {
|
|
253
253
|
isAboveImportanceThreshold,
|
|
254
254
|
scoreImportance
|
|
@@ -283,7 +283,7 @@ import {
|
|
|
283
283
|
materializeAfterSemanticConsolidation,
|
|
284
284
|
parseConsolidationResponse,
|
|
285
285
|
parseOperatorAwareConsolidationResponse
|
|
286
|
-
} from "./chunk-
|
|
286
|
+
} from "./chunk-QY66HJ4X.js";
|
|
287
287
|
import {
|
|
288
288
|
buildBehaviorSignalsForMemory,
|
|
289
289
|
dedupeBehaviorSignalsByMemoryAndHash
|
|
@@ -305,7 +305,7 @@ import {
|
|
|
305
305
|
} from "./chunk-UQ7RN5HK.js";
|
|
306
306
|
import {
|
|
307
307
|
detectMeetings
|
|
308
|
-
} from "./chunk-
|
|
308
|
+
} from "./chunk-MOHZIKZM.js";
|
|
309
309
|
import {
|
|
310
310
|
compileCorrectionRule,
|
|
311
311
|
correctionsFilePath,
|
|
@@ -322,7 +322,7 @@ import {
|
|
|
322
322
|
} from "./chunk-LBJBNWS2.js";
|
|
323
323
|
import {
|
|
324
324
|
MeetingsInputError
|
|
325
|
-
} from "./chunk-
|
|
325
|
+
} from "./chunk-KW4ZFTUS.js";
|
|
326
326
|
import {
|
|
327
327
|
WearablesInputError,
|
|
328
328
|
describeErrorForOperator
|
|
@@ -340,7 +340,7 @@ import {
|
|
|
340
340
|
capturePassiveCorrections,
|
|
341
341
|
clusterByKey,
|
|
342
342
|
detectPassiveCorrections
|
|
343
|
-
} from "./chunk-
|
|
343
|
+
} from "./chunk-XYXYEDPL.js";
|
|
344
344
|
import {
|
|
345
345
|
importCapsule
|
|
346
346
|
} from "./chunk-3CE77VAP.js";
|
|
@@ -360,7 +360,7 @@ import {
|
|
|
360
360
|
} from "./chunk-JGSKJHF7.js";
|
|
361
361
|
import {
|
|
362
362
|
buildXraySnapshot
|
|
363
|
-
} from "./chunk-
|
|
363
|
+
} from "./chunk-R4Q7CQGZ.js";
|
|
364
364
|
import {
|
|
365
365
|
boundRecallContextComposition,
|
|
366
366
|
composeRecallContext,
|
|
@@ -399,7 +399,7 @@ import {
|
|
|
399
399
|
} from "./chunk-CYEPCZN5.js";
|
|
400
400
|
import {
|
|
401
401
|
NamespaceStorageRouter
|
|
402
|
-
} from "./chunk-
|
|
402
|
+
} from "./chunk-F2KMAFEB.js";
|
|
403
403
|
import {
|
|
404
404
|
writeConversationChunks
|
|
405
405
|
} from "./chunk-72A4L5JJ.js";
|
|
@@ -462,7 +462,7 @@ import {
|
|
|
462
462
|
} from "./chunk-NRV4Y3PM.js";
|
|
463
463
|
import {
|
|
464
464
|
buildChainFollowupGenerator
|
|
465
|
-
} from "./chunk-
|
|
465
|
+
} from "./chunk-3C2TGBDB.js";
|
|
466
466
|
import {
|
|
467
467
|
QmdResultResolver,
|
|
468
468
|
StorageManager,
|
|
@@ -481,7 +481,7 @@ import {
|
|
|
481
481
|
reconstructFusionInputs,
|
|
482
482
|
selfDeps,
|
|
483
483
|
serializeFusionDay
|
|
484
|
-
} from "./chunk-
|
|
484
|
+
} from "./chunk-ZERSIPFC.js";
|
|
485
485
|
import {
|
|
486
486
|
bodyIsEscaped,
|
|
487
487
|
decodeTranscriptBody,
|
|
@@ -502,7 +502,7 @@ import {
|
|
|
502
502
|
} from "./chunk-J6A3CX5N.js";
|
|
503
503
|
import {
|
|
504
504
|
confidenceTier
|
|
505
|
-
} from "./chunk-
|
|
505
|
+
} from "./chunk-GSL47NPM.js";
|
|
506
506
|
import {
|
|
507
507
|
namespaceIdentityFromToken,
|
|
508
508
|
namespaceIdentityToken,
|
|
@@ -511,7 +511,7 @@ import {
|
|
|
511
511
|
import {
|
|
512
512
|
inferMemoryStatus,
|
|
513
513
|
isActiveMemoryStatus
|
|
514
|
-
} from "./chunk-
|
|
514
|
+
} from "./chunk-7RJUVTVF.js";
|
|
515
515
|
import {
|
|
516
516
|
assertPathInsideRoot
|
|
517
517
|
} from "./chunk-GCASGYIO.js";
|
|
@@ -23923,4 +23923,4 @@ export {
|
|
|
23923
23923
|
filterRecallCandidates,
|
|
23924
23924
|
Orchestrator
|
|
23925
23925
|
};
|
|
23926
|
-
//# sourceMappingURL=chunk-
|
|
23926
|
+
//# sourceMappingURL=chunk-XPQ5ZTL6.js.map
|
|
@@ -35,10 +35,10 @@ import {
|
|
|
35
35
|
} from "./chunk-H7XKCNR6.js";
|
|
36
36
|
import {
|
|
37
37
|
toRecallExplainJson
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-TXBU7YDV.js";
|
|
39
39
|
import {
|
|
40
40
|
estimateRecallTokens
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-R4Q7CQGZ.js";
|
|
42
42
|
import {
|
|
43
43
|
boundRecallContextComposition,
|
|
44
44
|
composeRecallContext
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
listMemoryGovernanceRuns,
|
|
51
51
|
readMemoryGovernanceRunArtifact,
|
|
52
52
|
runMemoryGovernance
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-5N26WBPQ.js";
|
|
54
54
|
import {
|
|
55
55
|
recordObjectiveStateSnapshotsFromObservedMessages
|
|
56
56
|
} from "./chunk-ICP53SKG.js";
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
} from "./chunk-6HMYUWXR.js";
|
|
60
60
|
import {
|
|
61
61
|
offlineSyncStorageForSnapshot
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-YFHMW37V.js";
|
|
63
63
|
import {
|
|
64
64
|
resolveScopePlan,
|
|
65
65
|
resolveScopedWritableNamespaceValue,
|
|
@@ -101,7 +101,7 @@ import {
|
|
|
101
101
|
import {
|
|
102
102
|
CorpusWatermarkCache,
|
|
103
103
|
computeServiceCorpusCensus
|
|
104
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-AXHMCRS3.js";
|
|
105
105
|
import {
|
|
106
106
|
namespaceCollectionName
|
|
107
107
|
} from "./chunk-IOQFPVGY.js";
|
|
@@ -136,24 +136,24 @@ import {
|
|
|
136
136
|
enqueuePassiveCorrectionNotification,
|
|
137
137
|
parseBriefingFocus,
|
|
138
138
|
parseBriefingWindow
|
|
139
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-3C2TGBDB.js";
|
|
140
140
|
import {
|
|
141
141
|
parseEntityFile,
|
|
142
142
|
qmdCollectionPathParts,
|
|
143
143
|
qmdResultPathCandidates,
|
|
144
144
|
selfDeps
|
|
145
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-ZERSIPFC.js";
|
|
146
146
|
import {
|
|
147
147
|
DEFAULT_RECALL_DISCLOSURE,
|
|
148
148
|
isRecallDisclosure
|
|
149
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-GSL47NPM.js";
|
|
150
150
|
import {
|
|
151
151
|
namespaceIdentityFromToken
|
|
152
152
|
} from "./chunk-EGGE52UU.js";
|
|
153
153
|
import {
|
|
154
154
|
inferMemoryStatus,
|
|
155
155
|
toMemoryPathRel
|
|
156
|
-
} from "./chunk-
|
|
156
|
+
} from "./chunk-7RJUVTVF.js";
|
|
157
157
|
import {
|
|
158
158
|
normalizeProjectionPreview,
|
|
159
159
|
normalizeProjectionTags
|
|
@@ -13323,4 +13323,4 @@ export {
|
|
|
13323
13323
|
EngramAccessService,
|
|
13324
13324
|
AccessAdminOpsSurface
|
|
13325
13325
|
};
|
|
13326
|
-
//# sourceMappingURL=chunk-
|
|
13326
|
+
//# sourceMappingURL=chunk-XYXYEDPL.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
drainPendingLifecycleForSyncOrThrow,
|
|
9
9
|
drainPendingLifecycleLedgerForSync
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-4VXGRIH6.js";
|
|
11
11
|
import {
|
|
12
12
|
namespaceIdentityFromToken
|
|
13
13
|
} from "./chunk-EGGE52UU.js";
|
|
@@ -181,4 +181,4 @@ export {
|
|
|
181
181
|
offlineSyncStorageForSnapshot,
|
|
182
182
|
drainPendingLifecycleForOfflineSync
|
|
183
183
|
};
|
|
184
|
-
//# sourceMappingURL=chunk-
|
|
184
|
+
//# sourceMappingURL=chunk-YFHMW37V.js.map
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// src/storage-guards.ts
|
|
6
6
|
var PROJECTION_FALLBACK_WARN_INTERVAL_MS = 5 * 6e4;
|
|
7
|
+
var PROJECTION_LEDGER_LAG_WARN_THRESHOLD_EVENTS = 100;
|
|
7
8
|
var projectionFallbackWarnedAt = /* @__PURE__ */ new Map();
|
|
8
9
|
function assertMemoryFrontmatterId(fm) {
|
|
9
10
|
if (typeof fm.id !== "string" || fm.id.trim().length === 0) {
|
|
@@ -17,16 +18,25 @@ function assertMemoryFrontmatterId(fm) {
|
|
|
17
18
|
);
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
function warnProjectionFallback(memoryDir, consumer, detail) {
|
|
21
|
+
function warnProjectionFallback(memoryDir, consumer, detail, ledgerLag) {
|
|
22
|
+
const fallback = `storage.${consumer}: memory projection absent or empty; falling back to full corpus`;
|
|
23
|
+
const thresholdEvents = Math.max(
|
|
24
|
+
0,
|
|
25
|
+
Math.floor(ledgerLag?.warnThresholdEvents ?? PROJECTION_LEDGER_LAG_WARN_THRESHOLD_EVENTS)
|
|
26
|
+
);
|
|
27
|
+
const lag = ledgerLag ? `projected_events=${ledgerLag.projectedEvents} current_ledger_events=${ledgerLag.currentLedgerEvents} delta_events=${ledgerLag.deltaEvents} threshold_events=${thresholdEvents} fallback_action=full-ledger-scan` : void 0;
|
|
28
|
+
if (ledgerLag && ledgerLag.deltaEvents <= thresholdEvents) {
|
|
29
|
+
const suffix = [detail?.(), lag].filter(Boolean).join("; ");
|
|
30
|
+
log.debug(`${fallback}${suffix ? ` (${suffix})` : ""}`);
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
21
33
|
const key = `${memoryDir}\0${consumer}`;
|
|
22
34
|
const now = Date.now();
|
|
23
35
|
const warnedAt = projectionFallbackWarnedAt.get(key) ?? 0;
|
|
24
36
|
if (now - warnedAt >= PROJECTION_FALLBACK_WARN_INTERVAL_MS) {
|
|
25
37
|
projectionFallbackWarnedAt.set(key, now);
|
|
26
|
-
const suffix = detail?.();
|
|
27
|
-
log.warn(
|
|
28
|
-
`storage.${consumer}: memory projection absent or empty; falling back to full corpus` + (suffix ? ` (${suffix})` : "")
|
|
29
|
-
);
|
|
38
|
+
const suffix = [detail?.(), lag].filter(Boolean).join("; ");
|
|
39
|
+
log.warn(`${fallback}${suffix ? ` (${suffix})` : ""}`);
|
|
30
40
|
}
|
|
31
41
|
return null;
|
|
32
42
|
}
|
|
@@ -35,8 +45,9 @@ function __resetProjectionFallbackWarnSuppressionForTest() {
|
|
|
35
45
|
}
|
|
36
46
|
|
|
37
47
|
export {
|
|
48
|
+
PROJECTION_LEDGER_LAG_WARN_THRESHOLD_EVENTS,
|
|
38
49
|
assertMemoryFrontmatterId,
|
|
39
50
|
warnProjectionFallback,
|
|
40
51
|
__resetProjectionFallbackWarnSuppressionForTest
|
|
41
52
|
};
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
53
|
+
//# sourceMappingURL=chunk-ZA53AZND.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/storage-guards.ts"],"sourcesContent":["import { log } from \"./logger.js\";\n\nconst PROJECTION_FALLBACK_WARN_INTERVAL_MS = 5 * 60_000;\nexport const PROJECTION_LEDGER_LAG_WARN_THRESHOLD_EVENTS = 100;\nconst projectionFallbackWarnedAt = new Map<string, number>();\n\nexport function assertMemoryFrontmatterId(\n fm: { id: string; category?: string; created?: string; entityRef?: string },\n): void {\n if (typeof fm.id !== \"string\" || fm.id.trim().length === 0) {\n const context = [\n fm.category ? `category=${fm.category}` : null,\n fm.created ? `created=${fm.created}` : null,\n fm.entityRef ? `entityRef=${fm.entityRef}` : null,\n ].filter(Boolean).join(\" \");\n throw new Error(\n `memory frontmatter id must not be blank${context ? ` (${context})` : \"\"}`,\n );\n }\n}\n\nexport interface ProjectionLedgerLagTelemetry {\n projectedEvents: number;\n currentLedgerEvents: number;\n deltaEvents: number;\n warnThresholdEvents?: number;\n}\n\nexport function warnProjectionFallback(\n memoryDir: string,\n consumer: string,\n detail?: () => string | undefined,\n ledgerLag?: ProjectionLedgerLagTelemetry,\n): null {\n const fallback = `storage.${consumer}: memory projection absent or empty; falling back to full corpus`;\n const thresholdEvents = Math.max(\n 0,\n Math.floor(ledgerLag?.warnThresholdEvents ?? PROJECTION_LEDGER_LAG_WARN_THRESHOLD_EVENTS),\n );\n const lag = ledgerLag\n ? `projected_events=${ledgerLag.projectedEvents} current_ledger_events=${ledgerLag.currentLedgerEvents} `\n + `delta_events=${ledgerLag.deltaEvents} threshold_events=${thresholdEvents} `\n + \"fallback_action=full-ledger-scan\"\n : undefined;\n\n if (ledgerLag && ledgerLag.deltaEvents <= thresholdEvents) {\n const suffix = [detail?.(), lag].filter(Boolean).join(\"; \");\n log.debug(`${fallback}${suffix ? ` (${suffix})` : \"\"}`);\n return null;\n }\n\n const key = `${memoryDir}\\0${consumer}`;\n const now = Date.now();\n const warnedAt = projectionFallbackWarnedAt.get(key) ?? 0;\n if (now - warnedAt >= PROJECTION_FALLBACK_WARN_INTERVAL_MS) {\n projectionFallbackWarnedAt.set(key, now);\n const suffix = [detail?.(), lag].filter(Boolean).join(\"; \");\n log.warn(`${fallback}${suffix ? ` (${suffix})` : \"\"}`);\n }\n return null;\n}\n\n/** @internal Test seam (#2119): clear the fallback-warn rate-limit dedup map so\n * a focused test can prove the once-per-interval spam suppression from a clean\n * slate regardless of prior tests in the same process. */\nexport function __resetProjectionFallbackWarnSuppressionForTest(): void {\n projectionFallbackWarnedAt.clear();\n}\n"],"mappings":";;;;;AAEA,IAAM,uCAAuC,IAAI;AAC1C,IA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