@remnic/core 9.30.1 → 9.32.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 +55 -44
- package/dist/access-authorization-probe.d.ts +10 -10
- package/dist/access-authorization-probe.js +56 -45
- package/dist/access-boundary.d.ts +13 -11
- package/dist/access-boundary.js +55 -44
- package/dist/access-cli.js +170 -126
- package/dist/access-cli.js.map +1 -1
- package/dist/access-extraction-force-flush.d.ts +119 -0
- package/dist/access-extraction-force-flush.js +171 -0
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +47 -13
- package/dist/access-http-lcm-compaction.js +7 -3
- package/dist/access-http-lifecycle-flush.d.ts +132 -0
- package/dist/access-http-lifecycle-flush.js +9 -0
- package/dist/access-http-lifecycle-flush.js.map +1 -0
- package/dist/access-http.d.ts +11 -10
- package/dist/access-http.js +71 -59
- package/dist/access-identity-continuity-surface.d.ts +8 -8
- package/dist/access-identity-continuity-surface.js +55 -44
- package/dist/access-lcm-surface.d.ts +10 -10
- package/dist/access-lcm-surface.js +55 -44
- package/dist/access-mcp-output-schemas.js +1 -1
- package/dist/access-mcp.d.ts +16 -10
- package/dist/access-mcp.js +63 -52
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-VfXssvoI.d.ts → access-namespace-preflight-COhbXBqS.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +55 -44
- package/dist/access-observe-helpers.d.ts +22 -0
- package/dist/access-observe-helpers.js +10 -0
- package/dist/access-observe-helpers.js.map +1 -0
- package/dist/access-observe-write-surface.d.ts +51 -47
- package/dist/access-observe-write-surface.js +55 -44
- package/dist/access-operations-batch.js +58 -47
- package/dist/access-operations.d.ts +11 -11
- package/dist/access-operations.js +60 -49
- package/dist/access-recall-concurrency.d.ts +10 -10
- package/dist/access-recall-concurrency.js +55 -44
- package/dist/access-recall-response.d.ts +10 -10
- package/dist/access-recall-response.js +55 -44
- package/dist/access-recall-surface.d.ts +10 -10
- package/dist/access-recall-surface.js +55 -44
- package/dist/access-schema.d.ts +37 -7
- package/dist/access-schema.js +5 -3
- package/dist/{access-service-B5RwVsTV.d.ts → access-service-BmBTtEKO.d.ts} +44 -20
- package/dist/access-service-helpers.d.ts +113 -0
- package/dist/access-service-helpers.js +8 -0
- package/dist/access-service-helpers.js.map +1 -0
- package/dist/access-service.d.ts +10 -10
- package/dist/access-service.js +55 -44
- package/dist/access-surface-catalog.d.ts +10 -10
- package/dist/access-surface-catalog.js +2 -0
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/access-wearables-meetings-surface.d.ts +3 -3
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +2 -2
- package/dist/adapters/index.js +7 -7
- package/dist/adapters/registry.js +3 -3
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +8 -8
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +14 -14
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer-turn-helpers.d.ts +5 -0
- package/dist/buffer-turn-helpers.js +24 -0
- package/dist/buffer-turn-helpers.js.map +1 -0
- package/dist/buffer.d.ts +17 -4
- package/dist/buffer.js +21 -1
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{capsule-crypto-GWVG7LGC.js → capsule-crypto-7FJQINUR.js} +2 -2
- package/dist/capsule-crypto-7FJQINUR.js.map +1 -0
- package/dist/{capsule-merge-5KKJQBWQ.js → capsule-merge-2H2IUTBT.js} +4 -4
- package/dist/{catalog-V7inUQdp.d.ts → catalog-Dm-DvNBY.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 +21 -22
- package/dist/causal-consolidation.js.map +1 -1
- 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-LEPOP46W.js → chunk-227UFSEQ.js} +4 -4
- package/dist/{chunk-I5NLEENJ.js → chunk-27HHNYSQ.js} +3 -3
- package/dist/{chunk-2SA56WMI.js → chunk-2LTDWSR6.js} +4 -4
- package/dist/{chunk-OWHERGF2.js → chunk-2NLLXCJG.js} +2 -2
- package/dist/{chunk-SPJXKAVF.js → chunk-2NTGBZLZ.js} +14 -13
- package/dist/chunk-2NTGBZLZ.js.map +1 -0
- package/dist/{chunk-P5PXWTW7.js → chunk-2Q4JJ3FZ.js} +3 -3
- package/dist/{chunk-G5R3D5UP.js → chunk-2QIMTVEJ.js} +6 -5
- package/dist/chunk-2QIMTVEJ.js.map +1 -0
- package/dist/{chunk-H5CPS5JP.js → chunk-35IVNNRK.js} +3 -3
- package/dist/{chunk-LBOD4U5B.js → chunk-3EQ2XB3W.js} +6 -6
- package/dist/{chunk-YTSNAUXN.js → chunk-3F2LKUMU.js} +22 -8
- package/dist/chunk-3F2LKUMU.js.map +1 -0
- package/dist/chunk-3QL24R5Y.js +9 -0
- package/dist/chunk-3QL24R5Y.js.map +1 -0
- package/dist/chunk-4RNZMRAV.js +60 -0
- package/dist/chunk-4RNZMRAV.js.map +1 -0
- package/dist/chunk-5IVLTFOV.js +65 -0
- package/dist/chunk-5IVLTFOV.js.map +1 -0
- package/dist/{chunk-2EUVEDF5.js → chunk-5WZVQRHV.js} +2 -2
- package/dist/{chunk-ALSGMEJR.js → chunk-65ZPVYTA.js} +7 -7
- package/dist/{chunk-GIBMDSJ2.js → chunk-6P7MTSU5.js} +2 -2
- package/dist/{chunk-5VQJBH2G.js → chunk-6TAUHL33.js} +2 -2
- package/dist/{chunk-WVO4G37W.js → chunk-7TEZUUGM.js} +3 -3
- package/dist/{chunk-MJCGLM25.js → chunk-7VUAG236.js} +5 -5
- package/dist/{chunk-CZRYLSSW.js → chunk-AJL6NNX6.js} +2 -2
- package/dist/{chunk-LGHKJABJ.js → chunk-AQEJE3WO.js} +40 -18
- package/dist/chunk-AQEJE3WO.js.map +1 -0
- package/dist/{chunk-66772WBP.js → chunk-AQWVJURR.js} +5 -5
- package/dist/{chunk-RKNJBZ55.js → chunk-AU7Q3LSC.js} +7 -7
- package/dist/{chunk-IYZ5K7MU.js → chunk-BUE5E2HL.js} +4 -187
- package/dist/chunk-BUE5E2HL.js.map +1 -0
- package/dist/{chunk-NHWB6HG2.js → chunk-CE5355TT.js} +21 -5
- package/dist/chunk-CE5355TT.js.map +1 -0
- package/dist/{chunk-M3C2V3PV.js → chunk-CJDNT45S.js} +12 -12
- package/dist/{chunk-D2ANTDGO.js → chunk-E6BMSH7U.js} +2 -2
- package/dist/{chunk-CKMO4RDY.js → chunk-EMDLM3LW.js} +4 -4
- package/dist/chunk-ER7W6H4T.js +112 -0
- package/dist/chunk-ER7W6H4T.js.map +1 -0
- package/dist/{chunk-RGIWINDN.js → chunk-FHBITMRY.js} +30 -30
- package/dist/{chunk-6FUPCJUL.js → chunk-FMFLGS5Z.js} +54 -54
- package/dist/chunk-FMFLGS5Z.js.map +1 -0
- package/dist/{chunk-FDAMS4PK.js → chunk-G2YQ57YO.js} +4 -4
- package/dist/{chunk-6U7F52DE.js → chunk-HFQQWAMS.js} +62 -62
- package/dist/{chunk-5W4ZLBEZ.js → chunk-HKPJPOW7.js} +2 -2
- package/dist/{chunk-JCBWCYEJ.js → chunk-IGWFKW4B.js} +2 -2
- package/dist/{chunk-AITCS2RC.js → chunk-IJ7HK452.js} +4 -4
- package/dist/{chunk-4WKA6I65.js → chunk-J3ZGPYXB.js} +1135 -311
- package/dist/chunk-J3ZGPYXB.js.map +1 -0
- package/dist/{chunk-D3LMYTBV.js → chunk-J7WZUL2K.js} +9 -9
- package/dist/{chunk-5W7CTZ2E.js → chunk-KQAFEZQX.js} +4 -4
- package/dist/{chunk-YNQBRLC5.js → chunk-LUQ443JP.js} +520 -2011
- package/dist/chunk-LUQ443JP.js.map +1 -0
- package/dist/{chunk-Z54EM5YZ.js → chunk-MAXVH44E.js} +7 -7
- package/dist/{chunk-WZFAPHIK.js → chunk-MU7ZHSZE.js} +2 -2
- package/dist/chunk-N5Z4EVOR.js +123 -0
- package/dist/chunk-N5Z4EVOR.js.map +1 -0
- package/dist/{chunk-AZ5BTEKX.js → chunk-NQUF7XKR.js} +2 -2
- package/dist/{chunk-W4FBGYGK.js → chunk-NRV4Y3PM.js} +1 -1
- package/dist/{chunk-62U4J2GN.js → chunk-ODGOP7P2.js} +2 -2
- package/dist/{chunk-QJAQNXWI.js → chunk-ONHRRJZM.js} +6 -6
- package/dist/{chunk-ACXPX4AG.js → chunk-OPBTPRGY.js} +2 -2
- package/dist/{chunk-XOZ4ALGB.js → chunk-QDTZ2HF7.js} +3 -3
- package/dist/{chunk-GBJ4RDFR.js → chunk-QIHIHZYC.js} +66 -91
- package/dist/chunk-QIHIHZYC.js.map +1 -0
- package/dist/{chunk-ZPSVBSOF.js → chunk-QMWFQBIL.js} +3 -3
- package/dist/{chunk-W5EG6LE3.js → chunk-THCPRMRF.js} +3 -3
- package/dist/{chunk-4A6YGWQN.js → chunk-TL4TO3EA.js} +115 -120
- package/dist/chunk-TL4TO3EA.js.map +1 -0
- package/dist/{chunk-VI2JQPNQ.js → chunk-U7QYBSQJ.js} +2 -2
- package/dist/chunk-ULARSG5Z.js +203 -0
- package/dist/chunk-ULARSG5Z.js.map +1 -0
- package/dist/{chunk-TH2LSRMG.js → chunk-UORKJ34C.js} +2 -2
- package/dist/{chunk-4Z4XNEWZ.js → chunk-VCD4PSK2.js} +56 -12
- package/dist/chunk-VCD4PSK2.js.map +1 -0
- package/dist/{chunk-K5GB36ME.js → chunk-VMZ56EE3.js} +2 -2
- package/dist/{chunk-HUHX2OCX.js → chunk-VVDPPDDF.js} +1 -1
- package/dist/chunk-VVDPPDDF.js.map +1 -0
- package/dist/{chunk-RMMVQQA6.js → chunk-WDISJRMG.js} +2 -2
- package/dist/{chunk-B6JDYXL7.js → chunk-WWUVONGW.js} +7 -1
- package/dist/chunk-WWUVONGW.js.map +1 -0
- package/dist/{chunk-UVYI6VIX.js → chunk-X7Y7WX73.js} +1 -1
- package/dist/{chunk-CVILPI77.js → chunk-XOQSEF7X.js} +6 -6
- package/dist/{chunk-RPW2NOU6.js → chunk-YIAA2X3D.js} +41 -1
- package/dist/chunk-YIAA2X3D.js.map +1 -0
- package/dist/chunk-YPC7W6GA.js +1604 -0
- package/dist/chunk-YPC7W6GA.js.map +1 -0
- package/dist/{chunk-YTQNQ4KB.js → chunk-YX5LN6JR.js} +3 -3
- package/dist/{chunk-IC6CBHCA.js → chunk-Z7XKUWYS.js} +2 -2
- package/dist/{chunk-PHWUFPCO.js → chunk-ZCPP5OW6.js} +61 -53
- package/dist/chunk-ZCPP5OW6.js.map +1 -0
- package/dist/{cli-C4GbETPC.d.ts → cli-DRJLv1Xt.d.ts} +5 -5
- package/dist/cli.d.ts +12 -12
- package/dist/cli.js +96 -86
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +14 -14
- package/dist/compounding/preference-consolidator.d.ts +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +2 -2
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +14 -15
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +3 -2
- package/dist/connectors/index.js +24 -23
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-provenance-check.js +5 -5
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/consolidation-undo.js +3 -3
- package/dist/contradiction/index.d.ts +2 -2
- package/dist/contradiction/index.js +4 -4
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/backend.js +2 -2
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/corpus-watermark.d.ts +1 -1
- package/dist/corpus-watermark.js +26 -26
- 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 +14 -14
- 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 +15 -2
- package/dist/extraction-source-grounding.js +10 -1
- package/dist/extraction.d.ts +2 -15
- package/dist/extraction.js +5 -4
- 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 +253 -246
- 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 +6 -6
- 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-helpers.d.ts +7 -0
- package/dist/local-llm-helpers.js +16 -0
- package/dist/local-llm-helpers.js.map +1 -0
- package/dist/local-llm.d.ts +3 -6
- package/dist/local-llm.js +2 -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 +14 -14
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +14 -14
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +15 -15
- package/dist/{maintenance-CL30NWtc.d.ts → maintenance-C6Pffz30.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-corpus-version.js +2 -2
- 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 +24 -24
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +9 -9
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +14 -14
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/offline-sync-impression-drain.js +6 -5
- package/dist/operator-doctor-corpus.d.ts +1 -1
- package/dist/operator-doctor-corpus.js +29 -29
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-doctor-replica.js +3 -3
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +39 -38
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +4 -4
- package/dist/orchestration/maintenance.js +22 -21
- package/dist/{orchestrator-CKTCRwWV.d.ts → orchestrator-eQlmasno.d.ts} +72 -34
- package/dist/orchestrator.d.ts +8 -8
- package/dist/orchestrator.js +169 -162
- package/dist/page-versioning.js +3 -3
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-B7wj4rRZ.d.ts → pipeline-CZGmAMQ2.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-q9tg4dHp.d.ts → qmd-DBj4MF8T.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/replica-divergence.d.ts +1 -1
- package/dist/replica-divergence.js +2 -2
- 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-CWDyglPM.d.ts → scope-profiles-S85lrsUn.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/factory.js +8 -8
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +12 -12
- 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-BUE3deLn.d.ts → semantic-consolidation-DVzDcV6x.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +17 -18
- package/dist/semantic-rule-promotion.js +14 -14
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +14 -14
- package/dist/{service-CXgM0bQG.d.ts → service-C2M-wD4W.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/{storage-DysJq-XH.d.ts → storage-dyBC3Q84.d.ts} +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +13 -13
- package/dist/summarizer.d.ts +1 -1
- package/dist/summarizer.js +3 -2
- 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/tokens.js +2 -2
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transfer/backup.js +2 -2
- package/dist/transfer/capsule-export.js +2 -2
- package/dist/transfer/capsule-import.js +5 -5
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-aPPzhnjT.d.ts → types-D63ZI--P.d.ts} +23 -2
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +14 -14
- package/dist/write-envelope.d.ts +1 -1
- package/package.json +2 -2
- package/src/access-boundary.ts +3 -0
- package/src/access-cli.test.ts +93 -0
- package/src/access-cli.ts +56 -2
- package/src/access-extraction-force-flush.ts +177 -0
- package/src/access-http-extraction-force-flush.test.ts +132 -0
- package/src/access-http-lcm-compaction.ts +99 -22
- package/src/access-http-lifecycle-flush.ts +81 -0
- package/src/access-http.test.ts +227 -0
- package/src/access-http.ts +33 -40
- package/src/access-mcp-output-schemas.ts +6 -0
- package/src/access-mcp.test.ts +40 -0
- package/src/access-mcp.ts +32 -1
- package/src/access-observe-helpers.ts +180 -0
- package/src/access-observe-write-surface.ts +78 -19
- package/src/access-operations-batch.ts +2 -1
- package/src/access-schema-pi.test.ts +17 -0
- package/src/access-schema.ts +28 -11
- package/src/access-service-helpers.ts +46 -0
- package/src/access-service-observe-lcm-parity.test.ts +781 -31
- package/src/access-service-observe-scope.test.ts +88 -0
- package/src/access-service.ts +46 -128
- package/src/access-surface-catalog.test.ts +32 -0
- package/src/access-surface-catalog.ts +2 -0
- package/src/buffer-session.test.ts +148 -0
- package/src/buffer-turn-helpers.ts +152 -0
- package/src/buffer.ts +126 -201
- package/src/connectors/index.ts +1 -1
- package/src/connectors/label.ts +18 -0
- package/src/correction/correction-access-wiring.ts +79 -27
- package/src/correction/correction-executor.test.ts +542 -1
- package/src/correction/correction-executor.ts +309 -89
- package/src/correction/correction-planner.test.ts +35 -1
- package/src/correction/correction-planner.ts +50 -3
- package/src/correction/correction-service.ts +12 -7
- package/src/correction/correction-storage-integration.test.ts +172 -1
- package/src/correction/passive-capture.test.ts +35 -0
- package/src/correction/passive-capture.ts +17 -3
- package/src/extraction-source-grounding.ts +55 -1
- package/src/extraction-timeout.test.ts +51 -0
- package/src/extraction.ts +64 -90
- package/src/local-llm-headers-timeout.test.ts +48 -0
- package/src/local-llm-helpers.ts +58 -0
- package/src/local-llm.ts +62 -58
- package/src/orchestration/extraction-run-helpers.ts +309 -0
- package/src/orchestration/extraction-run.test.ts +350 -7
- package/src/orchestration/extraction-run.ts +327 -250
- package/src/orchestration/recall-result-formatter.ts +21 -2
- package/src/orchestration/recall-search-pipeline.test.ts +34 -0
- package/src/orchestration/recall-search-pipeline.ts +9 -1
- package/src/orchestration/session-context.ts +193 -18
- package/src/orchestration/turn-ingestion.ts +61 -11
- package/src/orchestrator-flush.test.ts +511 -5
- package/src/orchestrator.ts +8 -6
- package/src/recall-source-connector-label.test.ts +300 -0
- package/src/types.ts +3 -3
- package/dist/chunk-3UXOZBHV.js +0 -20
- package/dist/chunk-3UXOZBHV.js.map +0 -1
- package/dist/chunk-4A6YGWQN.js.map +0 -1
- package/dist/chunk-4WKA6I65.js.map +0 -1
- package/dist/chunk-4Z4XNEWZ.js.map +0 -1
- package/dist/chunk-6FUPCJUL.js.map +0 -1
- package/dist/chunk-B6JDYXL7.js.map +0 -1
- package/dist/chunk-G5R3D5UP.js.map +0 -1
- package/dist/chunk-GBJ4RDFR.js.map +0 -1
- package/dist/chunk-HUHX2OCX.js.map +0 -1
- package/dist/chunk-IYZ5K7MU.js.map +0 -1
- package/dist/chunk-LGHKJABJ.js.map +0 -1
- package/dist/chunk-NHWB6HG2.js.map +0 -1
- package/dist/chunk-PHWUFPCO.js.map +0 -1
- package/dist/chunk-RPW2NOU6.js.map +0 -1
- package/dist/chunk-SPJXKAVF.js.map +0 -1
- package/dist/chunk-YNQBRLC5.js.map +0 -1
- package/dist/chunk-YTSNAUXN.js.map +0 -1
- /package/dist/{capsule-crypto-GWVG7LGC.js.map → access-extraction-force-flush.js.map} +0 -0
- /package/dist/{capsule-merge-5KKJQBWQ.js.map → capsule-merge-2H2IUTBT.js.map} +0 -0
- /package/dist/{chunk-LEPOP46W.js.map → chunk-227UFSEQ.js.map} +0 -0
- /package/dist/{chunk-I5NLEENJ.js.map → chunk-27HHNYSQ.js.map} +0 -0
- /package/dist/{chunk-2SA56WMI.js.map → chunk-2LTDWSR6.js.map} +0 -0
- /package/dist/{chunk-OWHERGF2.js.map → chunk-2NLLXCJG.js.map} +0 -0
- /package/dist/{chunk-P5PXWTW7.js.map → chunk-2Q4JJ3FZ.js.map} +0 -0
- /package/dist/{chunk-H5CPS5JP.js.map → chunk-35IVNNRK.js.map} +0 -0
- /package/dist/{chunk-LBOD4U5B.js.map → chunk-3EQ2XB3W.js.map} +0 -0
- /package/dist/{chunk-2EUVEDF5.js.map → chunk-5WZVQRHV.js.map} +0 -0
- /package/dist/{chunk-ALSGMEJR.js.map → chunk-65ZPVYTA.js.map} +0 -0
- /package/dist/{chunk-GIBMDSJ2.js.map → chunk-6P7MTSU5.js.map} +0 -0
- /package/dist/{chunk-5VQJBH2G.js.map → chunk-6TAUHL33.js.map} +0 -0
- /package/dist/{chunk-WVO4G37W.js.map → chunk-7TEZUUGM.js.map} +0 -0
- /package/dist/{chunk-MJCGLM25.js.map → chunk-7VUAG236.js.map} +0 -0
- /package/dist/{chunk-CZRYLSSW.js.map → chunk-AJL6NNX6.js.map} +0 -0
- /package/dist/{chunk-66772WBP.js.map → chunk-AQWVJURR.js.map} +0 -0
- /package/dist/{chunk-RKNJBZ55.js.map → chunk-AU7Q3LSC.js.map} +0 -0
- /package/dist/{chunk-M3C2V3PV.js.map → chunk-CJDNT45S.js.map} +0 -0
- /package/dist/{chunk-D2ANTDGO.js.map → chunk-E6BMSH7U.js.map} +0 -0
- /package/dist/{chunk-CKMO4RDY.js.map → chunk-EMDLM3LW.js.map} +0 -0
- /package/dist/{chunk-RGIWINDN.js.map → chunk-FHBITMRY.js.map} +0 -0
- /package/dist/{chunk-FDAMS4PK.js.map → chunk-G2YQ57YO.js.map} +0 -0
- /package/dist/{chunk-6U7F52DE.js.map → chunk-HFQQWAMS.js.map} +0 -0
- /package/dist/{chunk-5W4ZLBEZ.js.map → chunk-HKPJPOW7.js.map} +0 -0
- /package/dist/{chunk-JCBWCYEJ.js.map → chunk-IGWFKW4B.js.map} +0 -0
- /package/dist/{chunk-AITCS2RC.js.map → chunk-IJ7HK452.js.map} +0 -0
- /package/dist/{chunk-D3LMYTBV.js.map → chunk-J7WZUL2K.js.map} +0 -0
- /package/dist/{chunk-5W7CTZ2E.js.map → chunk-KQAFEZQX.js.map} +0 -0
- /package/dist/{chunk-Z54EM5YZ.js.map → chunk-MAXVH44E.js.map} +0 -0
- /package/dist/{chunk-WZFAPHIK.js.map → chunk-MU7ZHSZE.js.map} +0 -0
- /package/dist/{chunk-AZ5BTEKX.js.map → chunk-NQUF7XKR.js.map} +0 -0
- /package/dist/{chunk-W4FBGYGK.js.map → chunk-NRV4Y3PM.js.map} +0 -0
- /package/dist/{chunk-62U4J2GN.js.map → chunk-ODGOP7P2.js.map} +0 -0
- /package/dist/{chunk-QJAQNXWI.js.map → chunk-ONHRRJZM.js.map} +0 -0
- /package/dist/{chunk-ACXPX4AG.js.map → chunk-OPBTPRGY.js.map} +0 -0
- /package/dist/{chunk-XOZ4ALGB.js.map → chunk-QDTZ2HF7.js.map} +0 -0
- /package/dist/{chunk-ZPSVBSOF.js.map → chunk-QMWFQBIL.js.map} +0 -0
- /package/dist/{chunk-W5EG6LE3.js.map → chunk-THCPRMRF.js.map} +0 -0
- /package/dist/{chunk-VI2JQPNQ.js.map → chunk-U7QYBSQJ.js.map} +0 -0
- /package/dist/{chunk-TH2LSRMG.js.map → chunk-UORKJ34C.js.map} +0 -0
- /package/dist/{chunk-K5GB36ME.js.map → chunk-VMZ56EE3.js.map} +0 -0
- /package/dist/{chunk-RMMVQQA6.js.map → chunk-WDISJRMG.js.map} +0 -0
- /package/dist/{chunk-UVYI6VIX.js.map → chunk-X7Y7WX73.js.map} +0 -0
- /package/dist/{chunk-CVILPI77.js.map → chunk-XOQSEF7X.js.map} +0 -0
- /package/dist/{chunk-YTQNQ4KB.js.map → chunk-YX5LN6JR.js.map} +0 -0
- /package/dist/{chunk-IC6CBHCA.js.map → chunk-Z7XKUWYS.js.map} +0 -0
|
@@ -24,17 +24,19 @@
|
|
|
24
24
|
* (`markConsumed`) under `serializeMutations` keyed by plan id (rule 40).
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
+
import { throwIfAborted } from "../abort-error.js";
|
|
28
|
+
import { log } from "../logger.js";
|
|
27
29
|
import { serializeMutations } from "../utils/serialize-mutations.js";
|
|
28
|
-
import type { CorrectionPlanner } from "./correction-planner.js";
|
|
29
30
|
import {
|
|
30
|
-
CorrectionContractError,
|
|
31
|
-
validateCorrectionAction,
|
|
32
|
-
validateRedactionPattern,
|
|
33
31
|
type CorrectionAction,
|
|
34
32
|
type CorrectionActionResult,
|
|
33
|
+
CorrectionContractError,
|
|
35
34
|
type CorrectionOutcome,
|
|
36
35
|
type CorrectionPlan,
|
|
36
|
+
validateCorrectionAction,
|
|
37
|
+
validateRedactionPattern,
|
|
37
38
|
} from "./correction-contract.js";
|
|
39
|
+
import type { CorrectionPlanner } from "./correction-planner.js";
|
|
38
40
|
|
|
39
41
|
// ---------------------------------------------------------------------------
|
|
40
42
|
// Injected collaborators
|
|
@@ -69,8 +71,7 @@ export interface ExecutorMemory {
|
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
export interface ExecutorDeps {
|
|
72
|
-
|
|
73
|
-
getMemory(namespace: string, memoryId: string): Promise<ExecutorMemory | null>;
|
|
74
|
+
getMemory(namespace: string, memoryId: string, abortSignal?: AbortSignal): Promise<ExecutorMemory | null>;
|
|
74
75
|
/**
|
|
75
76
|
* Persist a NEW memory through the orchestrator's normal write pipeline
|
|
76
77
|
* (catalog/reindex/dedup fire — rule 43). Returns the new memory id.
|
|
@@ -89,17 +90,14 @@ export interface ExecutorDeps {
|
|
|
89
90
|
structuredAttributes?: Record<string, string>;
|
|
90
91
|
supersedes?: string;
|
|
91
92
|
},
|
|
93
|
+
abortSignal?: AbortSignal
|
|
92
94
|
): Promise<string>;
|
|
93
95
|
/**
|
|
94
96
|
* Apply a versioned edit to an existing memory (page-versioning — every
|
|
95
97
|
* change revertable). Returns the memory id. The patch is the NEW full
|
|
96
98
|
* content; the implementation snapshots the prior version.
|
|
97
99
|
*/
|
|
98
|
-
applyEdit(
|
|
99
|
-
namespace: string,
|
|
100
|
-
memoryId: string,
|
|
101
|
-
patch: string,
|
|
102
|
-
): Promise<string>;
|
|
100
|
+
applyEdit(namespace: string, memoryId: string, patch: string, abortSignal?: AbortSignal): Promise<string>;
|
|
103
101
|
/**
|
|
104
102
|
* Flip a memory's status to superseded/retracted and stamp `validUntil`
|
|
105
103
|
* when bi-temporal is gated on (#1578). Idempotent.
|
|
@@ -112,13 +110,14 @@ export interface ExecutorDeps {
|
|
|
112
110
|
supersededBy?: string;
|
|
113
111
|
validUntil?: string;
|
|
114
112
|
},
|
|
113
|
+
abortSignal?: AbortSignal
|
|
115
114
|
): Promise<void>;
|
|
116
115
|
/**
|
|
117
116
|
* Move a memory to a different namespace (rescope). The destination
|
|
118
117
|
* namespace is re-authorized by the service before the executor runs; the
|
|
119
118
|
* implementation performs the move atomically (write-then-unlink).
|
|
120
119
|
*/
|
|
121
|
-
rescopeMemory(namespace: string, memoryId: string, toNamespace: string): Promise<string>;
|
|
120
|
+
rescopeMemory(namespace: string, memoryId: string, toNamespace: string, abortSignal?: AbortSignal): Promise<string>;
|
|
122
121
|
/**
|
|
123
122
|
* Append a tombstone (#1579) for a retired memory. Returns the tombstone
|
|
124
123
|
* id, or null if tombstones are disabled (off = pre-feature behavior).
|
|
@@ -141,12 +140,13 @@ export interface ExecutorDeps {
|
|
|
141
140
|
/** Canonical contentHash from the retired memory's frontmatter (#1672 item 4). */
|
|
142
141
|
contentHash?: string;
|
|
143
142
|
},
|
|
143
|
+
abortSignal?: AbortSignal
|
|
144
144
|
): Promise<string | null>;
|
|
145
145
|
/**
|
|
146
146
|
* Persist a redaction rule so extraction consults it the same way tombstones
|
|
147
147
|
* are consulted (route through the same chokepoint check). Idempotent.
|
|
148
148
|
*/
|
|
149
|
-
registerRedactionRule(namespace: string, pattern: string): Promise<void>;
|
|
149
|
+
registerRedactionRule(namespace: string, pattern: string, abortSignal?: AbortSignal): Promise<void>;
|
|
150
150
|
/**
|
|
151
151
|
* Append an audit record under `corrections/` (existing storage category)
|
|
152
152
|
* capturing plan + outcome. Returns the audit memory id.
|
|
@@ -159,6 +159,7 @@ export interface ExecutorDeps {
|
|
|
159
159
|
outcome: CorrectionOutcome;
|
|
160
160
|
requestText: string;
|
|
161
161
|
},
|
|
162
|
+
abortSignal?: AbortSignal
|
|
162
163
|
): Promise<string>;
|
|
163
164
|
/**
|
|
164
165
|
* Post-write propagation: QMD reindex for touched files (checklist §31),
|
|
@@ -166,7 +167,7 @@ export interface ExecutorDeps {
|
|
|
166
167
|
* here is recorded as a warning, never as a failed action (propagation is
|
|
167
168
|
* not part of the §14 non-destructive-order guarantee; it runs after).
|
|
168
169
|
*/
|
|
169
|
-
propagate(namespace: string, touchedMemoryIds: readonly string[]): Promise<void>;
|
|
170
|
+
propagate(namespace: string, touchedMemoryIds: readonly string[], abortSignal?: AbortSignal): Promise<void>;
|
|
170
171
|
/** Whether the bi-temporal gate (#1578) is on. When off, validUntil is omitted. */
|
|
171
172
|
readonly biTemporalEnabled: boolean;
|
|
172
173
|
/** Injected clock for deterministic tests. */
|
|
@@ -180,7 +181,7 @@ export interface ExecutorDeps {
|
|
|
180
181
|
export class CorrectionExecutor {
|
|
181
182
|
constructor(
|
|
182
183
|
private readonly deps: ExecutorDeps,
|
|
183
|
-
private readonly planner: CorrectionPlanner
|
|
184
|
+
private readonly planner: CorrectionPlanner
|
|
184
185
|
) {}
|
|
185
186
|
|
|
186
187
|
/**
|
|
@@ -192,6 +193,7 @@ export class CorrectionExecutor {
|
|
|
192
193
|
planId: string,
|
|
193
194
|
opts: {
|
|
194
195
|
confirm: boolean;
|
|
196
|
+
abortSignal?: AbortSignal;
|
|
195
197
|
/**
|
|
196
198
|
* Authorize a rescope destination namespace. Bound per-request by the
|
|
197
199
|
* service from the namespace policy + principal so a plan can never
|
|
@@ -200,34 +202,42 @@ export class CorrectionExecutor {
|
|
|
200
202
|
* source namespace already resolves to a writable scope (single-tenant).
|
|
201
203
|
*/
|
|
202
204
|
canWriteDestination?: (namespace: string) => Promise<boolean>;
|
|
203
|
-
}
|
|
205
|
+
}
|
|
204
206
|
): Promise<CorrectionOutcome> {
|
|
207
|
+
throwIfAborted(opts.abortSignal, "correction apply aborted");
|
|
205
208
|
if (!opts.confirm) {
|
|
206
209
|
throw new CorrectionContractError(
|
|
207
|
-
"Correction apply requires explicit confirmation (correction.applyRequiresConfirm)."
|
|
210
|
+
"Correction apply requires explicit confirmation (correction.applyRequiresConfirm)."
|
|
208
211
|
);
|
|
209
212
|
}
|
|
210
213
|
// serializeMutations on the plan id so two concurrent applies of the SAME
|
|
211
214
|
// plan serialize — the second observes the consumed status and rejects.
|
|
212
215
|
return serializeMutations(`correction-apply:${namespace}:${planId}`, () =>
|
|
213
|
-
this.applyInternal(namespace, planId, opts.canWriteDestination)
|
|
216
|
+
this.applyInternal(namespace, planId, opts.canWriteDestination, opts.abortSignal)
|
|
214
217
|
);
|
|
215
218
|
}
|
|
216
219
|
|
|
217
|
-
private async applyInternal(
|
|
220
|
+
private async applyInternal(
|
|
221
|
+
namespace: string,
|
|
222
|
+
planId: string,
|
|
223
|
+
canWriteDestination?: (namespace: string) => Promise<boolean>,
|
|
224
|
+
abortSignal?: AbortSignal
|
|
225
|
+
): Promise<CorrectionOutcome> {
|
|
226
|
+
throwIfAborted(abortSignal, "correction apply aborted");
|
|
218
227
|
const plan = await this.planner.loadPlan(namespace, planId);
|
|
228
|
+
throwIfAborted(abortSignal, "correction apply aborted");
|
|
219
229
|
if (!plan) {
|
|
220
230
|
throw new CorrectionContractError(`Correction plan not found: ${planId}`);
|
|
221
231
|
}
|
|
222
232
|
if (plan.namespace !== namespace) {
|
|
223
233
|
// Cross-namespace foreign-id guard (rule 42 / checklist §16).
|
|
224
234
|
throw new CorrectionContractError(
|
|
225
|
-
`Correction plan ${planId} belongs to namespace '${plan.namespace}', not '${namespace}'
|
|
235
|
+
`Correction plan ${planId} belongs to namespace '${plan.namespace}', not '${namespace}'.`
|
|
226
236
|
);
|
|
227
237
|
}
|
|
228
238
|
if (plan.status === "applied" || plan.status === "partial" || plan.status === "applying") {
|
|
229
239
|
throw new CorrectionContractError(
|
|
230
|
-
`Correction plan ${planId} has already been applied or is in progress (status=${plan.status})
|
|
240
|
+
`Correction plan ${planId} has already been applied or is in progress (status=${plan.status}).`
|
|
231
241
|
);
|
|
232
242
|
}
|
|
233
243
|
if (plan.status === "discarded") {
|
|
@@ -237,7 +247,7 @@ export class CorrectionExecutor {
|
|
|
237
247
|
if (this.deps.now().getTime() > new Date(plan.expiresAt).getTime()) {
|
|
238
248
|
await this.planner.markConsumed(namespace, planId, "discarded");
|
|
239
249
|
throw new CorrectionContractError(
|
|
240
|
-
`Correction plan ${planId} expired at ${plan.expiresAt} and has been discarded
|
|
250
|
+
`Correction plan ${planId} expired at ${plan.expiresAt} and has been discarded.`
|
|
241
251
|
);
|
|
242
252
|
}
|
|
243
253
|
|
|
@@ -252,36 +262,109 @@ export class CorrectionExecutor {
|
|
|
252
262
|
// Optimistically mark the plan `applying` BEFORE any mutation (review
|
|
253
263
|
// thread OgIqt). If the process dies mid-apply — or the final
|
|
254
264
|
// markConsumed("applied"|"partial") fails — the plan stays `applying`
|
|
255
|
-
// and is NOT silently retryable.
|
|
256
|
-
//
|
|
257
|
-
//
|
|
258
|
-
//
|
|
259
|
-
// inside the serializeMutations lock so concurrent applies serialize.
|
|
265
|
+
// and is NOT silently retryable. If cancellation arrives before the
|
|
266
|
+
// first mutation, reset the plan to `pending` so it remains actionable.
|
|
267
|
+
// A partially-applied plan must never be re-applied wholesale: re-running
|
|
268
|
+
// succeeded actions would duplicate replacements, tombstones, and audits.
|
|
269
|
+
// This mark runs inside the serializeMutations lock so concurrent applies serialize.
|
|
270
|
+
throwIfAborted(abortSignal, "correction apply aborted");
|
|
260
271
|
try {
|
|
261
272
|
await this.planner.markConsumed(namespace, planId, "applying");
|
|
262
273
|
} catch {
|
|
263
274
|
// If we cannot even mark the plan in-progress, the filesystem is
|
|
264
275
|
// likely unwritable and mutations would fail too — fail closed now.
|
|
265
276
|
throw new CorrectionContractError(
|
|
266
|
-
`Correction plan ${planId}: cannot mark in-progress (filesystem unwritable?) — aborting before any mutation
|
|
277
|
+
`Correction plan ${planId}: cannot mark in-progress (filesystem unwritable?) — aborting before any mutation.`
|
|
267
278
|
);
|
|
268
279
|
}
|
|
269
280
|
|
|
281
|
+
const resetApplying = async (): Promise<void> => {
|
|
282
|
+
try {
|
|
283
|
+
await this.planner.resetApplying(namespace, planId);
|
|
284
|
+
} catch (resetError) {
|
|
285
|
+
log.warn(
|
|
286
|
+
`Correction plan ${planId}: cancellation reset failed; leaving plan applying: ${
|
|
287
|
+
resetError instanceof Error ? resetError.message : String(resetError)
|
|
288
|
+
}`
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
try {
|
|
293
|
+
throwIfAborted(abortSignal, "correction apply aborted");
|
|
294
|
+
} catch (error) {
|
|
295
|
+
await resetApplying();
|
|
296
|
+
throw error;
|
|
297
|
+
}
|
|
298
|
+
|
|
270
299
|
const results: CorrectionActionResult[] = [];
|
|
271
300
|
const appliedTouched: string[] = [];
|
|
301
|
+
const retiredReplacementActions = new Set<CorrectionAction>();
|
|
302
|
+
const removeFailedResultsFor = (action: CorrectionAction): void => {
|
|
303
|
+
for (let i = results.length - 1; i >= 0; i -= 1) {
|
|
304
|
+
if (results[i]?.action === action && results[i]?.status === "failed") {
|
|
305
|
+
results.splice(i, 1);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
let mutationCommitted = false;
|
|
310
|
+
let cancellationSafeAfterCommit = false;
|
|
311
|
+
let cancellationRequestedAfterCommit = false;
|
|
312
|
+
const throwIfAbortedBeforeCommit = (): void => {
|
|
313
|
+
if (!mutationCommitted || !cancellationSafeAfterCommit) {
|
|
314
|
+
throwIfAborted(abortSignal, "correction apply aborted");
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
const stopBeforeNewAction = async (): Promise<boolean> => {
|
|
318
|
+
if (!abortSignal?.aborted) return false;
|
|
319
|
+
if (!mutationCommitted) {
|
|
320
|
+
try {
|
|
321
|
+
throwIfAborted(abortSignal, "correction apply aborted");
|
|
322
|
+
} catch (error) {
|
|
323
|
+
await resetApplying();
|
|
324
|
+
throw error;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
cancellationRequestedAfterCommit = true;
|
|
328
|
+
return true;
|
|
329
|
+
};
|
|
330
|
+
const throwIfAbortedBeforeCommitAndReset = async (): Promise<void> => {
|
|
331
|
+
try {
|
|
332
|
+
throwIfAbortedBeforeCommit();
|
|
333
|
+
} catch (error) {
|
|
334
|
+
if (!mutationCommitted) await resetApplying();
|
|
335
|
+
const reason = abortSignal?.reason;
|
|
336
|
+
if (reason instanceof Error && reason.name !== "AbortError") throw reason;
|
|
337
|
+
throw error;
|
|
338
|
+
}
|
|
339
|
+
};
|
|
272
340
|
|
|
273
341
|
// ── Phase 1: replacement / edit writes (new state first) ───────────────
|
|
274
342
|
// For each supersede with a replacement, write the replacement FIRST. If
|
|
275
343
|
// the write fails, the loser is NOT superseded (§14: never destroy old
|
|
276
344
|
// state for an action whose replacement write failed).
|
|
277
345
|
for (const action of plan.actions) {
|
|
346
|
+
if (await stopBeforeNewAction()) break;
|
|
347
|
+
|
|
278
348
|
if (action.kind === "supersede" && action.replacement) {
|
|
279
349
|
// Preflight the loser BEFORE writing the replacement (review thread
|
|
280
350
|
// Of0pz): if the loser was deleted between plan and apply, writing a
|
|
281
351
|
// replacement creates an orphan fact that supersedes nothing. Phase 2
|
|
282
352
|
// (retireAndTombstone) re-checks via getMemory, so verifying here
|
|
283
353
|
// keeps the two phases in agreement and avoids the orphan write.
|
|
284
|
-
|
|
354
|
+
let loser: ExecutorMemory | null;
|
|
355
|
+
try {
|
|
356
|
+
loser = await this.deps.getMemory(namespace, action.loserId, abortSignal);
|
|
357
|
+
} catch (error) {
|
|
358
|
+
if (abortSignal?.aborted) {
|
|
359
|
+
if (!mutationCommitted) {
|
|
360
|
+
await resetApplying();
|
|
361
|
+
throwIfAborted(abortSignal, "correction apply aborted");
|
|
362
|
+
}
|
|
363
|
+
cancellationRequestedAfterCommit = true;
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
throw error;
|
|
367
|
+
}
|
|
285
368
|
if (!loser) {
|
|
286
369
|
results.push({
|
|
287
370
|
action,
|
|
@@ -291,22 +374,52 @@ export class CorrectionExecutor {
|
|
|
291
374
|
continue;
|
|
292
375
|
}
|
|
293
376
|
try {
|
|
294
|
-
const newId = await this.deps.writeReplacement(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
? {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
377
|
+
const newId = await this.deps.writeReplacement(
|
|
378
|
+
namespace,
|
|
379
|
+
{
|
|
380
|
+
content: action.replacement.content,
|
|
381
|
+
...(action.replacement.category ? { category: action.replacement.category } : {}),
|
|
382
|
+
...(action.replacement.confidence !== undefined ? { confidence: action.replacement.confidence } : {}),
|
|
383
|
+
...(action.replacement.tags ? { tags: action.replacement.tags } : {}),
|
|
384
|
+
...(action.replacement.entityRef ? { entityRef: action.replacement.entityRef } : {}),
|
|
385
|
+
...(action.replacement.validAt ? { validAt: action.replacement.validAt } : {}),
|
|
386
|
+
...(action.replacement.observedAt ? { observedAt: action.replacement.observedAt } : {}),
|
|
387
|
+
...(action.replacement.structuredAttributes
|
|
388
|
+
? { structuredAttributes: action.replacement.structuredAttributes }
|
|
389
|
+
: {}),
|
|
390
|
+
supersedes: action.loserId,
|
|
391
|
+
},
|
|
392
|
+
abortSignal
|
|
393
|
+
);
|
|
394
|
+
mutationCommitted = true;
|
|
307
395
|
results.push({ action, status: "applied", memoryId: newId });
|
|
308
396
|
appliedTouched.push(newId);
|
|
397
|
+
// A replacement and retirement form one non-destructive transaction.
|
|
398
|
+
// Once the replacement is durable, cancellation cannot interrupt the
|
|
399
|
+
// retirement half and leave both memories active. This remains inside
|
|
400
|
+
// the apply plan's serializeMutations lock.
|
|
401
|
+
const retirementResultBeforePhase2 = results.at(-1);
|
|
402
|
+
await this.retireAndTombstone(namespace, action, "supersession", results, appliedTouched, {
|
|
403
|
+
supersededBy: newId,
|
|
404
|
+
});
|
|
405
|
+
const retirementResult = results.at(-1);
|
|
406
|
+
if (
|
|
407
|
+
retirementResult !== retirementResultBeforePhase2 &&
|
|
408
|
+
retirementResult?.action === action &&
|
|
409
|
+
retirementResult.status === "applied"
|
|
410
|
+
) {
|
|
411
|
+
retiredReplacementActions.add(action);
|
|
412
|
+
cancellationSafeAfterCommit = true;
|
|
413
|
+
}
|
|
309
414
|
} catch (err) {
|
|
415
|
+
if (abortSignal?.aborted) {
|
|
416
|
+
if (!mutationCommitted) {
|
|
417
|
+
await resetApplying();
|
|
418
|
+
throw err;
|
|
419
|
+
}
|
|
420
|
+
cancellationRequestedAfterCommit = true;
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
310
423
|
results.push({
|
|
311
424
|
action,
|
|
312
425
|
status: "failed",
|
|
@@ -315,17 +428,46 @@ export class CorrectionExecutor {
|
|
|
315
428
|
}
|
|
316
429
|
} else if (action.kind === "edit") {
|
|
317
430
|
try {
|
|
318
|
-
const editedId = await this.deps.applyEdit(
|
|
431
|
+
const editedId = await this.deps.applyEdit(
|
|
432
|
+
namespace,
|
|
433
|
+
action.memoryId,
|
|
434
|
+
action.patch,
|
|
435
|
+
abortSignal
|
|
436
|
+
);
|
|
437
|
+
mutationCommitted = true;
|
|
438
|
+
cancellationSafeAfterCommit = true;
|
|
319
439
|
results.push({ action, status: "applied", memoryId: editedId });
|
|
320
440
|
appliedTouched.push(editedId);
|
|
321
441
|
} catch (err) {
|
|
442
|
+
if (abortSignal?.aborted) {
|
|
443
|
+
if (!mutationCommitted) {
|
|
444
|
+
await resetApplying();
|
|
445
|
+
throw err;
|
|
446
|
+
}
|
|
447
|
+
cancellationRequestedAfterCommit = true;
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
322
450
|
results.push({ action, status: "failed", error: errMsg(err) });
|
|
323
451
|
}
|
|
324
452
|
} else if (action.kind === "redaction_rule") {
|
|
325
453
|
try {
|
|
326
|
-
await this.deps.registerRedactionRule(
|
|
454
|
+
await this.deps.registerRedactionRule(
|
|
455
|
+
namespace,
|
|
456
|
+
action.pattern,
|
|
457
|
+
abortSignal
|
|
458
|
+
);
|
|
459
|
+
mutationCommitted = true;
|
|
460
|
+
cancellationSafeAfterCommit = true;
|
|
327
461
|
results.push({ action, status: "applied" });
|
|
328
462
|
} catch (err) {
|
|
463
|
+
if (abortSignal?.aborted) {
|
|
464
|
+
if (!mutationCommitted) {
|
|
465
|
+
await resetApplying();
|
|
466
|
+
throw err;
|
|
467
|
+
}
|
|
468
|
+
cancellationRequestedAfterCommit = true;
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
329
471
|
results.push({ action, status: "failed", error: errMsg(err) });
|
|
330
472
|
}
|
|
331
473
|
}
|
|
@@ -335,19 +477,52 @@ export class CorrectionExecutor {
|
|
|
335
477
|
// Only run for supersede/retract actions whose replacement write (if any)
|
|
336
478
|
// succeeded. A supersede WITHOUT a replacement is a pure retract.
|
|
337
479
|
for (const action of plan.actions) {
|
|
480
|
+
const needsPhase2Work =
|
|
481
|
+
action.kind === "retract" ||
|
|
482
|
+
action.kind === "rescope" ||
|
|
483
|
+
(action.kind === "supersede" && !retiredReplacementActions.has(action));
|
|
484
|
+
if (needsPhase2Work && (await stopBeforeNewAction())) break;
|
|
485
|
+
try {
|
|
486
|
+
if (action.kind === "supersede" && retiredReplacementActions.has(action)) continue;
|
|
338
487
|
if (action.kind === "supersede") {
|
|
339
|
-
const replacementResult = results.find(
|
|
340
|
-
(r) => r.action === action && r.status === "applied",
|
|
341
|
-
);
|
|
488
|
+
const replacementResult = results.find((r) => r.action === action && r.status === "applied");
|
|
342
489
|
// If the replacement write failed, skip retirement (§14).
|
|
343
490
|
if (action.replacement && !replacementResult) {
|
|
344
491
|
continue;
|
|
345
492
|
}
|
|
346
|
-
await this.retireAndTombstone(
|
|
347
|
-
|
|
348
|
-
|
|
493
|
+
await this.retireAndTombstone(
|
|
494
|
+
namespace,
|
|
495
|
+
action,
|
|
496
|
+
"supersession",
|
|
497
|
+
results,
|
|
498
|
+
appliedTouched,
|
|
499
|
+
{ supersededBy: replacementResult?.memoryId },
|
|
500
|
+
abortSignal
|
|
501
|
+
);
|
|
502
|
+
if (results.at(-1)?.status === "applied") {
|
|
503
|
+
mutationCommitted = true;
|
|
504
|
+
cancellationSafeAfterCommit = true;
|
|
505
|
+
}
|
|
506
|
+
if (results.at(-1)?.action === action && results.at(-1)?.status === "applied") {
|
|
507
|
+
removeFailedResultsFor(action);
|
|
508
|
+
}
|
|
349
509
|
} else if (action.kind === "retract") {
|
|
350
|
-
await this.retireAndTombstone(
|
|
510
|
+
await this.retireAndTombstone(
|
|
511
|
+
namespace,
|
|
512
|
+
action,
|
|
513
|
+
"retraction",
|
|
514
|
+
results,
|
|
515
|
+
appliedTouched,
|
|
516
|
+
{},
|
|
517
|
+
abortSignal
|
|
518
|
+
);
|
|
519
|
+
if (results.at(-1)?.status === "applied") {
|
|
520
|
+
mutationCommitted = true;
|
|
521
|
+
cancellationSafeAfterCommit = true;
|
|
522
|
+
}
|
|
523
|
+
if (results.at(-1)?.action === action && results.at(-1)?.status === "applied") {
|
|
524
|
+
removeFailedResultsFor(action);
|
|
525
|
+
}
|
|
351
526
|
} else if (action.kind === "rescope") {
|
|
352
527
|
try {
|
|
353
528
|
// Authorize the destination namespace BEFORE the move — the plan's
|
|
@@ -364,7 +539,14 @@ export class CorrectionExecutor {
|
|
|
364
539
|
});
|
|
365
540
|
continue;
|
|
366
541
|
}
|
|
367
|
-
const destId = await this.deps.rescopeMemory(
|
|
542
|
+
const destId = await this.deps.rescopeMemory(
|
|
543
|
+
namespace,
|
|
544
|
+
action.memoryId,
|
|
545
|
+
action.toNamespace,
|
|
546
|
+
abortSignal
|
|
547
|
+
);
|
|
548
|
+
mutationCommitted = true;
|
|
549
|
+
cancellationSafeAfterCommit = true;
|
|
368
550
|
// #1678 (thread OiiV6): report the DESTINATION memory id, not the
|
|
369
551
|
// source. The source is archived by the move; callers that re-fetch
|
|
370
552
|
// the reported id need the live (destination) memory, otherwise they
|
|
@@ -374,15 +556,32 @@ export class CorrectionExecutor {
|
|
|
374
556
|
// Propagate the destination memory in its namespace too (review
|
|
375
557
|
// thread: propagate-rescoped-destination) — best-effort.
|
|
376
558
|
try {
|
|
377
|
-
await this.deps.propagate(action.toNamespace, [destId]);
|
|
559
|
+
await this.deps.propagate(action.toNamespace, [destId], undefined);
|
|
378
560
|
} catch {
|
|
379
561
|
// non-fatal — the source propagation still fires.
|
|
380
562
|
}
|
|
381
563
|
} catch (err) {
|
|
564
|
+
if (abortSignal?.aborted) {
|
|
565
|
+
if (!mutationCommitted) throw err;
|
|
566
|
+
cancellationRequestedAfterCommit = true;
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
382
569
|
results.push({ action, status: "failed", error: errMsg(err) });
|
|
383
570
|
}
|
|
384
571
|
}
|
|
572
|
+
} catch (err) {
|
|
573
|
+
if (abortSignal?.aborted) {
|
|
574
|
+
if (!mutationCommitted) {
|
|
575
|
+
await resetApplying();
|
|
576
|
+
throw err;
|
|
577
|
+
}
|
|
578
|
+
cancellationRequestedAfterCommit = true;
|
|
579
|
+
break;
|
|
580
|
+
}
|
|
581
|
+
throw err;
|
|
582
|
+
}
|
|
385
583
|
}
|
|
584
|
+
await throwIfAbortedBeforeCommitAndReset();
|
|
386
585
|
|
|
387
586
|
// ── Phase 3: propagation (post-write reindex + graph) ─────────────────
|
|
388
587
|
// Best-effort: a propagation failure is recorded as a warning on the
|
|
@@ -390,15 +589,18 @@ export class CorrectionExecutor {
|
|
|
390
589
|
const propagationWarnings: string[] = [];
|
|
391
590
|
if (appliedTouched.length > 0) {
|
|
392
591
|
try {
|
|
393
|
-
await this.deps.propagate(namespace, appliedTouched);
|
|
592
|
+
await this.deps.propagate(namespace, appliedTouched, cancellationSafeAfterCommit ? undefined : abortSignal);
|
|
394
593
|
} catch (err) {
|
|
594
|
+
if ((!mutationCommitted || !cancellationSafeAfterCommit) && abortSignal?.aborted) throw err;
|
|
395
595
|
propagationWarnings.push(`propagation failed (non-fatal): ${errMsg(err)}`);
|
|
396
596
|
}
|
|
397
597
|
}
|
|
398
598
|
|
|
599
|
+
await throwIfAbortedBeforeCommitAndReset();
|
|
399
600
|
// ── Phase 4: audit record ─────────────────────────────────────────────
|
|
400
601
|
const anyFailed = results.some((r) => r.status === "failed");
|
|
401
|
-
const status: CorrectionOutcome["status"] =
|
|
602
|
+
const status: CorrectionOutcome["status"] =
|
|
603
|
+
anyFailed || cancellationRequestedAfterCommit ? "partial" : "applied";
|
|
402
604
|
const appliedAt = this.deps.now().toISOString();
|
|
403
605
|
const outcome: CorrectionOutcome = {
|
|
404
606
|
planId,
|
|
@@ -411,21 +613,28 @@ export class CorrectionExecutor {
|
|
|
411
613
|
(outcome as CorrectionOutcome & { warnings?: string[] }).warnings = propagationWarnings;
|
|
412
614
|
}
|
|
413
615
|
try {
|
|
414
|
-
const auditId = await this.deps.appendAuditRecord(
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
616
|
+
const auditId = await this.deps.appendAuditRecord(
|
|
617
|
+
namespace,
|
|
618
|
+
{
|
|
619
|
+
planId,
|
|
620
|
+
classification: plan.classification,
|
|
621
|
+
outcome,
|
|
622
|
+
requestText: plan.request.text,
|
|
623
|
+
},
|
|
624
|
+
cancellationSafeAfterCommit ? undefined : abortSignal
|
|
625
|
+
);
|
|
420
626
|
outcome.auditMemoryId = auditId;
|
|
421
627
|
} catch (err) {
|
|
628
|
+
if ((!mutationCommitted || !cancellationSafeAfterCommit) && abortSignal?.aborted) throw err;
|
|
422
629
|
// The audit record is part of the contract but a failure to write it
|
|
423
|
-
// must NOT
|
|
630
|
+
// must NOT propagate — applied corrections are already durable. Record
|
|
631
|
+
// as a warning instead.
|
|
424
632
|
(outcome as CorrectionOutcome & { warnings?: string[] }).warnings = [
|
|
425
633
|
...propagationWarnings,
|
|
426
634
|
`audit record write failed (non-fatal): ${errMsg(err)}`,
|
|
427
635
|
];
|
|
428
636
|
}
|
|
637
|
+
await throwIfAbortedBeforeCommitAndReset();
|
|
429
638
|
|
|
430
639
|
// ── Phase 5: mark plan consumed ───────────────────────────────────────
|
|
431
640
|
// Corrections are already applied (phases 1-4 succeeded). A markConsumed
|
|
@@ -448,12 +657,12 @@ export class CorrectionExecutor {
|
|
|
448
657
|
results: CorrectionActionResult[],
|
|
449
658
|
appliedTouched: string[],
|
|
450
659
|
opts: { supersededBy?: string } = {},
|
|
660
|
+
abortSignal?: AbortSignal
|
|
451
661
|
): Promise<void> {
|
|
452
|
-
const memoryId =
|
|
453
|
-
action.kind === "supersede" ? action.loserId : action.kind === "retract" ? action.memoryId : null;
|
|
662
|
+
const memoryId = action.kind === "supersede" ? action.loserId : action.kind === "retract" ? action.memoryId : null;
|
|
454
663
|
if (!memoryId) return;
|
|
455
664
|
try {
|
|
456
|
-
const memory = await this.deps.getMemory(namespace, memoryId);
|
|
665
|
+
const memory = await this.deps.getMemory(namespace, memoryId, abortSignal);
|
|
457
666
|
if (!memory) {
|
|
458
667
|
results.push({
|
|
459
668
|
action,
|
|
@@ -469,27 +678,39 @@ export class CorrectionExecutor {
|
|
|
469
678
|
// operates on un-mutated state with no resurrection window. A tombstone
|
|
470
679
|
// for a still-active memory (if retire later fails) is benign — it only
|
|
471
680
|
// blocks re-ingestion of the same content, which is exactly the intent.
|
|
472
|
-
const tombstoneId = await this.deps.appendTombstone(
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
? {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
681
|
+
const tombstoneId = await this.deps.appendTombstone(
|
|
682
|
+
namespace,
|
|
683
|
+
{
|
|
684
|
+
reason,
|
|
685
|
+
sourceMemoryId: memoryId,
|
|
686
|
+
rawContent: memory.rawContent,
|
|
687
|
+
...(memory.entityRef ? { entityRef: memory.entityRef } : {}),
|
|
688
|
+
...(memory.supersessionKey ? { supersessionKey: memory.supersessionKey } : {}),
|
|
689
|
+
// #1672 item 4: carry the canonical contentHash (exact tier) and the
|
|
690
|
+
// full supersession-key set (keyed tier) so paraphrased re-observations
|
|
691
|
+
// of the same supersession identity are blocked, not just the literal
|
|
692
|
+
// body. Without these the tombstone projected from a structured fact
|
|
693
|
+
// dropped both fields and the fact could resurrect.
|
|
694
|
+
...(memory.contentHash ? { contentHash: memory.contentHash } : {}),
|
|
695
|
+
...(memory.supersessionKeys && memory.supersessionKeys.length > 0
|
|
696
|
+
? { supersessionKeys: memory.supersessionKeys }
|
|
697
|
+
: {}),
|
|
698
|
+
},
|
|
699
|
+
abortSignal
|
|
700
|
+
);
|
|
701
|
+
// A committed tombstone and source retirement form one transaction from
|
|
702
|
+
// the caller's point of view. Once append succeeds, cancellation must
|
|
703
|
+
// not prevent retirement and leave an active source behind the block.
|
|
704
|
+
await this.deps.retireMemory(
|
|
705
|
+
namespace,
|
|
706
|
+
memoryId,
|
|
707
|
+
{
|
|
708
|
+
status: reason === "supersession" ? "superseded" : "retracted",
|
|
709
|
+
...(opts.supersededBy ? { supersededBy: opts.supersededBy } : {}),
|
|
710
|
+
...(validUntil ? { validUntil } : {}),
|
|
711
|
+
},
|
|
712
|
+
tombstoneId === null ? abortSignal : undefined
|
|
713
|
+
);
|
|
493
714
|
results.push({
|
|
494
715
|
action,
|
|
495
716
|
status: "applied",
|
|
@@ -498,6 +719,7 @@ export class CorrectionExecutor {
|
|
|
498
719
|
});
|
|
499
720
|
appliedTouched.push(memoryId);
|
|
500
721
|
} catch (err) {
|
|
722
|
+
if (abortSignal?.aborted) throw err;
|
|
501
723
|
results.push({ action, status: "failed", error: errMsg(err) });
|
|
502
724
|
}
|
|
503
725
|
}
|
|
@@ -522,9 +744,7 @@ export function sanitizeErrorMessage(raw: string): string {
|
|
|
522
744
|
.replace(/(^|[\s:'"(])\/(?:[^\s'">)\\]+\/)+[^\s'">)\\]*/g, "$1<path>")
|
|
523
745
|
.replace(/(^|[\s:'"(])[A-Za-z]:\\[^\s'">)\\]+(?:\\[^\s'">) ]*)*/g, "$1<path>");
|
|
524
746
|
const trimmed = stripped.trim();
|
|
525
|
-
return trimmed.length > CORRECTION_ERROR_MAX
|
|
526
|
-
? `${trimmed.slice(0, CORRECTION_ERROR_MAX)}…`
|
|
527
|
-
: trimmed;
|
|
747
|
+
return trimmed.length > CORRECTION_ERROR_MAX ? `${trimmed.slice(0, CORRECTION_ERROR_MAX)}…` : trimmed;
|
|
528
748
|
}
|
|
529
749
|
|
|
530
750
|
function errMsg(err: unknown): string {
|