@remnic/core 1.1.1 → 1.1.3
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/abort-error.js +1 -0
- package/dist/abstraction-nodes.js +1 -0
- package/dist/access-audit.js +1 -0
- package/dist/access-cli.js +76 -51
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.d.ts +50 -5
- package/dist/access-http.js +38 -16
- package/dist/access-idempotency.js +1 -0
- package/dist/access-mcp.d.ts +10 -5
- package/dist/access-mcp.js +37 -14
- package/dist/access-schema.d.ts +133 -13
- package/dist/access-schema.js +20 -1
- package/dist/access-service-_AEUMVyX.d.ts +1981 -0
- package/dist/access-service.d.ts +11 -6
- package/dist/access-service.js +39 -14
- package/dist/active-memory-bridge.js +1 -0
- package/dist/active-recall.js +1 -0
- package/dist/active-recall.js.map +1 -1
- package/dist/behavior-learner.js +1 -0
- package/dist/behavior-learner.js.map +1 -1
- package/dist/behavior-signals.js +1 -0
- package/dist/bootstrap.d.ts +6 -4
- package/dist/bootstrap.js +1 -0
- package/dist/boxes.js +1 -0
- package/dist/briefing.d.ts +9 -5
- package/dist/briefing.js +10 -6
- package/dist/buffer-surprise-report.js +1 -0
- package/dist/buffer-surprise.js +1 -0
- package/dist/buffer.d.ts +1 -1
- package/dist/buffer.js +1 -0
- package/dist/calibration.d.ts +8 -1
- package/dist/calibration.js +10 -2
- package/dist/calibration.js.map +1 -1
- package/dist/capsule-cli.d.ts +137 -0
- package/dist/capsule-cli.js +34 -0
- package/dist/capsule-crypto-5CYAGVC5.js +18 -0
- package/dist/capsule-export-NZQPOTQ4.js +17 -0
- package/dist/capsule-export-NZQPOTQ4.js.map +1 -0
- package/dist/capsule-import-SDCUXLEV.js +16 -0
- package/dist/capsule-import-SDCUXLEV.js.map +1 -0
- package/dist/capsule-merge-DI7PNQ2H.js +189 -0
- package/dist/capsule-merge-DI7PNQ2H.js.map +1 -0
- package/dist/causal-behavior.js +1 -0
- package/dist/causal-behavior.js.map +1 -1
- package/dist/causal-chain.js +1 -0
- package/dist/causal-consolidation.js +12 -9
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/causal-retrieval.js +2 -1
- package/dist/causal-retrieval.js.map +1 -1
- package/dist/causal-trajectory-graph.js +4 -1
- package/dist/causal-trajectory-graph.js.map +1 -1
- package/dist/causal-trajectory.js +2 -1
- package/dist/chunk-2LSZVONP.js +67 -0
- package/dist/chunk-2LSZVONP.js.map +1 -0
- package/dist/chunk-32KD5IHZ.js +245 -0
- package/dist/chunk-32KD5IHZ.js.map +1 -0
- package/dist/{chunk-VDX363PS.js → chunk-34F3PLWZ.js} +10 -3
- package/dist/chunk-34F3PLWZ.js.map +1 -0
- package/dist/chunk-3KIS4VGT.js +228 -0
- package/dist/chunk-3KIS4VGT.js.map +1 -0
- package/dist/chunk-3LCWFNVS.js +350 -0
- package/dist/chunk-3LCWFNVS.js.map +1 -0
- package/dist/chunk-43EKP2UK.js +26 -0
- package/dist/chunk-43EKP2UK.js.map +1 -0
- package/dist/chunk-457A4P3L.js +119 -0
- package/dist/chunk-457A4P3L.js.map +1 -0
- package/dist/{chunk-KUB6JU6H.js → chunk-47WOM4YW.js} +2 -2
- package/dist/{chunk-HK3FGIEW.js → chunk-4PLGJRBV.js} +656 -20
- package/dist/chunk-4PLGJRBV.js.map +1 -0
- package/dist/{chunk-BGJGXLZ7.js → chunk-55FXRRSJ.js} +11 -8
- package/dist/chunk-55FXRRSJ.js.map +1 -0
- package/dist/{chunk-ULYOGL6R.js → chunk-5HRY2WRF.js} +7 -3
- package/dist/chunk-5HRY2WRF.js.map +1 -0
- package/dist/chunk-6TBWYBJ3.js +236 -0
- package/dist/chunk-6TBWYBJ3.js.map +1 -0
- package/dist/chunk-74EMIVE4.js +329 -0
- package/dist/chunk-74EMIVE4.js.map +1 -0
- package/dist/chunk-74WWN7ZW.js +82 -0
- package/dist/chunk-74WWN7ZW.js.map +1 -0
- package/dist/{chunk-B5WXLVDY.js → chunk-7GCMLT7J.js} +245 -25
- package/dist/chunk-7GCMLT7J.js.map +1 -0
- package/dist/chunk-A6XUJE5D.js +126 -0
- package/dist/chunk-A6XUJE5D.js.map +1 -0
- package/dist/chunk-AJA46VX5.js +393 -0
- package/dist/chunk-AJA46VX5.js.map +1 -0
- package/dist/{chunk-DFTTJYSO.js → chunk-AKUCB2OG.js} +525 -24
- package/dist/chunk-AKUCB2OG.js.map +1 -0
- package/dist/chunk-ASIQZXYO.js +277 -0
- package/dist/chunk-ASIQZXYO.js.map +1 -0
- package/dist/{chunk-ZEM3OK2K.js → chunk-B2TL6GA2.js} +3 -3
- package/dist/chunk-BJMBJZ2Y.js +290 -0
- package/dist/chunk-BJMBJZ2Y.js.map +1 -0
- package/dist/chunk-BT7NVCML.js +79 -0
- package/dist/chunk-BT7NVCML.js.map +1 -0
- package/dist/chunk-CK5NTM2S.js +454 -0
- package/dist/chunk-CK5NTM2S.js.map +1 -0
- package/dist/{chunk-3GXCSUXR.js → chunk-CRU27Q4J.js} +2 -2
- package/dist/{chunk-F5VP6YCB.js → chunk-DCE6SQLA.js} +572 -155
- package/dist/chunk-DCE6SQLA.js.map +1 -0
- package/dist/{chunk-CUPFXL3J.js → chunk-DHRQHX36.js} +4 -4
- package/dist/chunk-DHRQHX36.js.map +1 -0
- package/dist/{chunk-GKFXUTJ2.js → chunk-DR7MCMPS.js} +981 -61
- package/dist/chunk-DR7MCMPS.js.map +1 -0
- package/dist/chunk-FP2373TW.js +149 -0
- package/dist/chunk-FP2373TW.js.map +1 -0
- package/dist/{chunk-RBBWYEFJ.js → chunk-G2WADRQ3.js} +1 -1
- package/dist/chunk-G7D6GZ5J.js +48 -0
- package/dist/chunk-G7D6GZ5J.js.map +1 -0
- package/dist/chunk-H7XKCNR6.js +60 -0
- package/dist/chunk-H7XKCNR6.js.map +1 -0
- package/dist/{chunk-VYM3VWOF.js → chunk-IM3JSE73.js} +966 -329
- package/dist/chunk-IM3JSE73.js.map +1 -0
- package/dist/chunk-IXEJRKCZ.js +18 -0
- package/dist/chunk-IXEJRKCZ.js.map +1 -0
- package/dist/chunk-IYY4MCPG.js +275 -0
- package/dist/chunk-IYY4MCPG.js.map +1 -0
- package/dist/{chunk-BK2EFTE2.js → chunk-JWSENLQI.js} +508 -28
- package/dist/chunk-JWSENLQI.js.map +1 -0
- package/dist/chunk-KNKUID7G.js +183 -0
- package/dist/chunk-KNKUID7G.js.map +1 -0
- package/dist/chunk-L2IO2QPY.js +2036 -0
- package/dist/chunk-L2IO2QPY.js.map +1 -0
- package/dist/{chunk-SPI27QT6.js → chunk-L5IIGA5V.js} +9 -4
- package/dist/chunk-L5IIGA5V.js.map +1 -0
- package/dist/{chunk-RGLL5SPU.js → chunk-LVYGDT5V.js} +56 -82
- package/dist/chunk-LVYGDT5V.js.map +1 -0
- package/dist/{chunk-ZAIM4TUE.js → chunk-LW2NMHDW.js} +46 -1
- package/dist/chunk-LW2NMHDW.js.map +1 -0
- package/dist/{chunk-3OGMS3PE.js → chunk-LZRYQK6L.js} +3 -2
- package/dist/chunk-LZRYQK6L.js.map +1 -0
- package/dist/chunk-MDYG7VI7.js +48 -0
- package/dist/chunk-MDYG7VI7.js.map +1 -0
- package/dist/chunk-MXC3AP5I.js +74 -0
- package/dist/chunk-MXC3AP5I.js.map +1 -0
- package/dist/{chunk-S3EEFKNY.js → chunk-N7X62G74.js} +26 -11
- package/dist/chunk-N7X62G74.js.map +1 -0
- package/dist/chunk-NN3TS5BM.js +147 -0
- package/dist/chunk-NN3TS5BM.js.map +1 -0
- package/dist/chunk-OA3L7BFR.js +183 -0
- package/dist/chunk-OA3L7BFR.js.map +1 -0
- package/dist/{chunk-LK6SGL53.js → chunk-OR64ZGRZ.js} +3 -2
- package/dist/chunk-OR64ZGRZ.js.map +1 -0
- package/dist/chunk-OZHRDTDX.js +240 -0
- package/dist/chunk-OZHRDTDX.js.map +1 -0
- package/dist/chunk-PCUKNJAZ.js +165 -0
- package/dist/chunk-PCUKNJAZ.js.map +1 -0
- package/dist/{chunk-6PFRXT4K.js → chunk-PFV5C235.js} +11 -6
- package/dist/chunk-PFV5C235.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/{chunk-XZ2TIKGC.js → chunk-Q7FJ5ZHM.js} +30 -10
- package/dist/chunk-Q7FJ5ZHM.js.map +1 -0
- package/dist/{chunk-7I7FKFZH.js → chunk-R2L7SUX2.js} +6 -6
- package/dist/{chunk-JL2PU6AI.js → chunk-R2XRID2N.js} +2 -2
- package/dist/{chunk-WCLICCGB.js → chunk-RILIVK4O.js} +91 -4
- package/dist/chunk-RILIVK4O.js.map +1 -0
- package/dist/{chunk-C2EFFULQ.js → chunk-RK2Y4XOM.js} +163 -20
- package/dist/chunk-RK2Y4XOM.js.map +1 -0
- package/dist/{chunk-TP4FZJIZ.js → chunk-RULE4VG5.js} +5 -1
- package/dist/chunk-RULE4VG5.js.map +1 -0
- package/dist/{chunk-PVPWZSSI.js → chunk-SMA4IMHV.js} +19 -3
- package/dist/chunk-SMA4IMHV.js.map +1 -0
- package/dist/{chunk-WVVA7F5A.js → chunk-SS253RXF.js} +30 -16
- package/dist/chunk-SS253RXF.js.map +1 -0
- package/dist/chunk-TUFG6VXY.js +875 -0
- package/dist/chunk-TUFG6VXY.js.map +1 -0
- package/dist/chunk-TYEOAFH3.js +251 -0
- package/dist/chunk-TYEOAFH3.js.map +1 -0
- package/dist/chunk-UKJAGEXH.js +260 -0
- package/dist/chunk-UKJAGEXH.js.map +1 -0
- package/dist/{chunk-KVBLZUKV.js → chunk-USFPPRAF.js} +93 -3
- package/dist/chunk-USFPPRAF.js.map +1 -0
- package/dist/{chunk-EPQJM2GC.js → chunk-VTJVUHRK.js} +22 -36
- package/dist/chunk-VTJVUHRK.js.map +1 -0
- package/dist/{chunk-O5ETUNBT.js → chunk-VTU2B4VF.js} +7 -3
- package/dist/chunk-VTU2B4VF.js.map +1 -0
- package/dist/chunk-WIICJPET.js +45 -0
- package/dist/chunk-WIICJPET.js.map +1 -0
- package/dist/{chunk-VBVG2M5G.js → chunk-WPGJYVUH.js} +6 -2
- package/dist/chunk-WPGJYVUH.js.map +1 -0
- package/dist/{chunk-YNQKWQT4.js → chunk-WSZIHQBK.js} +31 -11
- package/dist/{chunk-YNQKWQT4.js.map → chunk-WSZIHQBK.js.map} +1 -1
- package/dist/{chunk-NZLQTHS5.js → chunk-WW3QQF4H.js} +4 -1
- package/dist/chunk-WW3QQF4H.js.map +1 -0
- package/dist/{chunk-FVA6TGI3.js → chunk-Y3WQ4ZWK.js} +42 -2
- package/dist/chunk-Y3WQ4ZWK.js.map +1 -0
- package/dist/chunk-YNJHCGDT.js +309 -0
- package/dist/chunk-YNJHCGDT.js.map +1 -0
- package/dist/{chunk-ALXMCZEU.js → chunk-Z2E7VW55.js} +6 -3
- package/dist/chunk-Z2E7VW55.js.map +1 -0
- package/dist/{chunk-INXV5JBT.js → chunk-ZGXSCMQN.js} +1992 -410
- package/dist/chunk-ZGXSCMQN.js.map +1 -0
- package/dist/{chunk-W6SL7OFG.js → chunk-ZTSE2ZJ6.js} +12 -2
- package/dist/{chunk-W6SL7OFG.js.map → chunk-ZTSE2ZJ6.js.map} +1 -1
- package/dist/chunking.js +1 -0
- package/dist/cipher-GVE2GQ5H.js +28 -0
- package/dist/cipher-GVE2GQ5H.js.map +1 -0
- package/dist/citations.js +1 -0
- package/dist/{cli-BkeRaYfk.d.ts → cli-x2APT9a6.d.ts} +26 -7
- package/dist/cli.d.ts +11 -6
- package/dist/cli.js +68 -34
- package/dist/codex-thread-key.js +1 -0
- package/dist/commitment-ledger.js +1 -0
- package/dist/compression-optimizer.js +1 -0
- package/dist/config.d.ts +2 -1
- package/dist/config.js +5 -2
- package/dist/connectors-cli-DFGtY2DB.d.ts +257 -0
- package/dist/connectors-cli.d.ts +2 -0
- package/dist/connectors-cli.js +22 -0
- package/dist/connectors-cli.js.map +1 -0
- package/dist/consolidation-operator.d.ts +65 -5
- package/dist/consolidation-operator.js +6 -1
- package/dist/consolidation-provenance-check.d.ts +1 -1
- package/dist/consolidation-provenance-check.js +3 -2
- package/dist/consolidation-undo.d.ts +1 -1
- package/dist/consolidation-undo.js +1 -0
- package/dist/consolidation-undo.js.map +1 -1
- package/dist/{contradiction-review-WIUBAR52.js → contradiction-review-5LTTVDQV.js} +2 -1
- package/dist/contradiction-review-5LTTVDQV.js.map +1 -0
- package/dist/{contradiction-scan-E3GJTI4F.js → contradiction-scan-3Z6YW7YA.js} +2 -1
- package/dist/{contradiction-scan-E3GJTI4F.js.map → contradiction-scan-3Z6YW7YA.js.map} +1 -1
- package/dist/cross-namespace-budget.js +1 -0
- package/dist/cue-anchors.js +1 -0
- package/dist/dashboard-runtime.js +1 -0
- package/dist/day-summary.js +1 -0
- package/dist/delinearize.js +1 -0
- package/dist/direct-answer-wiring.js +1 -0
- package/dist/direct-answer.js +1 -0
- package/dist/dreams-ledger-LR2NBAZE.js +286 -0
- package/dist/dreams-ledger-LR2NBAZE.js.map +1 -0
- package/dist/embedding-fallback.js +3 -1
- package/dist/{engine-F3GOXGE5.js → engine-ICC2DSQF.js} +10 -7
- package/dist/engine-ICC2DSQF.js.map +1 -0
- package/dist/entity-retrieval.d.ts +1 -1
- package/dist/entity-retrieval.js +9 -6
- package/dist/entity-schema.js +1 -0
- package/dist/evals.js +1 -0
- package/dist/evidence-pack.d.ts +16 -0
- package/dist/evidence-pack.js +8 -0
- package/dist/evidence-pack.js.map +1 -0
- package/dist/explicit-capture.d.ts +6 -4
- package/dist/explicit-capture.js +1 -0
- package/dist/extraction-judge-telemetry.js +1 -0
- package/dist/extraction-judge-training.js +1 -0
- package/dist/extraction-judge.js +1 -0
- package/dist/extraction.js +9 -8
- package/dist/fallback-llm.js +3 -2
- package/dist/first-start-migration-4MHQEOSD.js +263 -0
- package/dist/first-start-migration-4MHQEOSD.js.map +1 -0
- package/dist/forget-PLR6J5DN.js +69 -0
- package/dist/forget-PLR6J5DN.js.map +1 -0
- package/dist/framework-CyHYDcri.d.ts +153 -0
- package/dist/fs-utils-IRVUFB6G.js +30 -0
- package/dist/fs-utils-IRVUFB6G.js.map +1 -0
- package/dist/graph-dashboard-diff.js +1 -0
- package/dist/graph-dashboard-key.js +1 -0
- package/dist/graph-dashboard-parser.js +1 -0
- package/dist/graph-edge-decay-PWB63GRE.js +207 -0
- package/dist/graph-edge-decay-PWB63GRE.js.map +1 -0
- package/dist/graph-edge-reinforcement.d.ts +81 -0
- package/dist/graph-edge-reinforcement.js +24 -0
- package/dist/graph-edge-reinforcement.js.map +1 -0
- package/dist/graph-events.d.ts +87 -0
- package/dist/graph-events.js +14 -0
- package/dist/graph-events.js.map +1 -0
- package/dist/graph-recall.js +1 -0
- package/dist/graph-retrieval.js +1 -0
- package/dist/graph-snapshot.d.ts +112 -0
- package/dist/graph-snapshot.js +19 -0
- package/dist/graph-snapshot.js.map +1 -0
- package/dist/graph.d.ts +105 -7
- package/dist/graph.js +20 -3
- package/dist/harmonic-retrieval.js +1 -0
- package/dist/himem.js +1 -0
- package/dist/hygiene.js +1 -0
- package/dist/identity-continuity.js +1 -0
- package/dist/importance.js +1 -0
- package/dist/index.d.ts +562 -13
- package/dist/index.js +365 -96
- package/dist/index.js.map +1 -1
- package/dist/intent.js +1 -0
- package/dist/json-extract.js +1 -0
- package/dist/json-store.js +1 -0
- package/dist/kdf-7S6RWKLZ.js +26 -0
- package/dist/kdf-7S6RWKLZ.js.map +1 -0
- package/dist/legacy-hook-compat.js +1 -0
- package/dist/legacy-hook-compat.js.map +1 -1
- package/dist/lifecycle.js +1 -0
- package/dist/live-connectors-runner.d.ts +48 -0
- package/dist/live-connectors-runner.js +17 -0
- package/dist/live-connectors-runner.js.map +1 -0
- package/dist/local-llm.js +3 -2
- package/dist/logger.js +1 -0
- package/dist/memory-action-policy.js +1 -0
- package/dist/memory-cache.d.ts +2 -1
- package/dist/memory-cache.js +4 -1
- package/dist/memory-governance-KG52RITE.js +37 -0
- package/dist/memory-governance-KG52RITE.js.map +1 -0
- package/dist/memory-lifecycle-ledger-utils.d.ts +2 -1
- package/dist/memory-lifecycle-ledger-utils.js +4 -1
- package/dist/memory-projection-format.js +1 -0
- package/dist/{memory-projection-store-DeSXPh1j.d.ts → memory-projection-store-D3vBHS4J.d.ts} +1 -0
- package/dist/memory-projection-store.d.ts +1 -1
- package/dist/memory-projection-store.js +1 -0
- package/dist/memory-worth-bench.js +1 -0
- package/dist/memory-worth-bench.js.map +1 -1
- package/dist/memory-worth-filter.js +1 -0
- package/dist/memory-worth-outcomes.d.ts +1 -1
- package/dist/memory-worth-outcomes.js +1 -0
- package/dist/memory-worth.js +1 -0
- package/dist/metadata-FC3XPDRQ.js +21 -0
- package/dist/metadata-FC3XPDRQ.js.map +1 -0
- package/dist/migrate-from-identity-anchor-TTEDEJGX.js +8 -0
- package/dist/migrate-from-identity-anchor-TTEDEJGX.js.map +1 -0
- package/dist/model-registry.js +1 -0
- package/dist/models-json.js +1 -0
- package/dist/native-knowledge.js +1 -0
- package/dist/negative.js +1 -0
- package/dist/objective-state-writers.js +1 -0
- package/dist/objective-state-writers.js.map +1 -1
- package/dist/objective-state.js +1 -0
- package/dist/openai-chat-compat.js +1 -0
- package/dist/operator-toolkit.d.ts +46 -2
- package/dist/operator-toolkit.js +29 -17
- package/dist/opik-exporter.js +1 -0
- package/dist/opik-exporter.js.map +1 -1
- package/dist/{orchestrator-CmJ-NTdJ.d.ts → orchestrator-ChkesB8U.d.ts} +177 -13
- package/dist/orchestrator.d.ts +6 -4
- package/dist/orchestrator.js +58 -42
- package/dist/page-versioning.js +1 -0
- package/dist/path-RMTY5Y5A.js +9 -0
- package/dist/path-RMTY5Y5A.js.map +1 -0
- package/dist/patterns-cli.d.ts +160 -0
- package/dist/patterns-cli.js +29 -0
- package/dist/patterns-cli.js.map +1 -0
- package/dist/peers-6OSQ3NK6.js +44 -0
- package/dist/peers-6OSQ3NK6.js.map +1 -0
- package/dist/plugin-id.js +1 -0
- package/dist/policy-runtime.js +1 -0
- package/dist/{port-BADbLZU5.d.ts → port-hqGnoStS.d.ts} +6 -0
- package/dist/profiling.js +1 -0
- package/dist/purge-6ATBGT77.js +205 -0
- package/dist/purge-6ATBGT77.js.map +1 -0
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd-recall-cache.js +1 -0
- package/dist/qmd.d.ts +2 -1
- package/dist/qmd.js +4 -3
- package/dist/reasoning-trace-recall.js +1 -0
- package/dist/reasoning-trace-types.js +1 -0
- package/dist/recall-audit-anomaly.js +1 -0
- package/dist/recall-audit.js +1 -0
- package/dist/recall-disclosure-escalation.d.ts +84 -0
- package/dist/recall-disclosure-escalation.js +14 -0
- package/dist/recall-disclosure-escalation.js.map +1 -0
- package/dist/recall-explain-renderer.js +4 -1
- package/dist/recall-mmr.js +1 -0
- package/dist/recall-qos.js +1 -0
- package/dist/recall-query-policy.js +1 -0
- package/dist/recall-state.d.ts +7 -0
- package/dist/recall-state.js +2 -1
- package/dist/recall-tag-filter.d.ts +56 -0
- package/dist/recall-tag-filter.js +14 -0
- package/dist/recall-tag-filter.js.map +1 -0
- package/dist/recall-tokenization.js +1 -0
- package/dist/recall-xray-cli.d.ts +9 -2
- package/dist/recall-xray-cli.js +9 -4
- package/dist/recall-xray-renderer.js +4 -1
- package/dist/recall-xray.d.ts +116 -2
- package/dist/recall-xray.js +9 -3
- package/dist/reconstruct.js +1 -0
- package/dist/release-changelog.js +2 -0
- package/dist/release-changelog.js.map +1 -1
- package/dist/relevance.js +1 -0
- package/dist/rerank.js +1 -0
- package/dist/{resolution-QBTDHTG7.js → resolution-YGIBORXI.js} +2 -1
- package/dist/{resolution-QBTDHTG7.js.map → resolution-YGIBORXI.js.map} +1 -1
- package/dist/resolve-auth-token.d.ts +51 -0
- package/dist/resolve-auth-token.js +12 -0
- package/dist/resolve-auth-token.js.map +1 -0
- package/dist/resolve-provider-secret.d.ts +13 -1
- package/dist/resolve-provider-secret.js +6 -1
- package/dist/resume-bundles.js +5 -4
- package/dist/retrieval-agents.d.ts +1 -1
- package/dist/retrieval-agents.js +1 -0
- package/dist/retrieval-tiers.js +1 -0
- package/dist/retrieval.js +1 -0
- package/dist/sanitize.js +1 -0
- package/dist/schemas.d.ts +15 -2
- package/dist/schemas.js +2 -1
- package/dist/sdk-compat.js +1 -0
- package/dist/sdk-compat.js.map +1 -1
- package/dist/secure-store-4R2GSO7S.js +156 -0
- package/dist/secure-store-4R2GSO7S.js.map +1 -0
- package/dist/semantic-chunking.js +1 -0
- package/dist/{semantic-consolidation-CxJU6MJk.d.ts → semantic-consolidation-ByBXb-sf.d.ts} +3 -3
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +12 -6
- package/dist/semantic-rule-promotion.d.ts +1 -1
- package/dist/semantic-rule-promotion.js +9 -6
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +9 -6
- package/dist/session-integrity.js +1 -0
- package/dist/session-observer-bands.js +1 -0
- package/dist/session-observer-state.js +1 -0
- package/dist/session-toggles.js +2 -0
- package/dist/session-toggles.js.map +1 -1
- package/dist/signal.js +1 -0
- package/dist/skills-registry.js +2 -0
- package/dist/skills-registry.js.map +1 -1
- package/dist/source-attribution.js +1 -0
- package/dist/state-NCHQ4TRG.js +8 -0
- package/dist/state-NCHQ4TRG.js.map +1 -0
- package/dist/state-store-3EH7HYIN.js +16 -0
- package/dist/state-store-3EH7HYIN.js.map +1 -0
- package/dist/storage.d.ts +76 -2
- package/dist/storage.js +8 -5
- package/dist/store-contract.js +1 -0
- package/dist/summarizer.js +6 -5
- package/dist/summary-snapshot.js +1 -0
- package/dist/temporal-index.js +1 -0
- package/dist/temporal-supersession.d.ts +1 -1
- package/dist/temporal-supersession.js +2 -1
- package/dist/temporal-validity.d.ts +52 -0
- package/dist/temporal-validity.js +14 -0
- package/dist/temporal-validity.js.map +1 -0
- package/dist/threading.js +1 -0
- package/dist/tier-migration.d.ts +2 -2
- package/dist/tier-migration.js +1 -0
- package/dist/tier-routing.js +1 -0
- package/dist/tier-stats-62ZVDFKS.js +152 -0
- package/dist/tier-stats-62ZVDFKS.js.map +1 -0
- package/dist/tmt.js +1 -0
- package/dist/tokens.js +3 -1
- package/dist/topics.js +1 -0
- package/dist/trace-C5ETWBEF.js +290 -0
- package/dist/trace-C5ETWBEF.js.map +1 -0
- package/dist/transcript.js +1 -0
- package/dist/trust-zones.js +1 -0
- package/dist/tui-RI7P6PBS.js +13 -0
- package/dist/tui-RI7P6PBS.js.map +1 -0
- package/dist/types-V3FJ26TF.js +30 -0
- package/dist/types-V3FJ26TF.js.map +1 -0
- package/dist/types.d.ts +634 -9
- package/dist/types.js +10 -3
- package/dist/utility-learner.js +1 -0
- package/dist/utility-runtime.js +1 -0
- package/dist/utility-telemetry.js +1 -0
- package/dist/verified-recall.js +9 -6
- package/dist/version-utils.js +1 -0
- package/dist/whitespace.js +1 -0
- package/dist/work-product-ledger.js +1 -0
- package/package.json +2 -1
- package/dist/access-service-Br8ZydTK.d.ts +0 -827
- package/dist/chunk-3OGMS3PE.js.map +0 -1
- package/dist/chunk-6PFRXT4K.js.map +0 -1
- package/dist/chunk-ALXMCZEU.js.map +0 -1
- package/dist/chunk-B5WXLVDY.js.map +0 -1
- package/dist/chunk-BGJGXLZ7.js.map +0 -1
- package/dist/chunk-BK2EFTE2.js.map +0 -1
- package/dist/chunk-C2EFFULQ.js.map +0 -1
- package/dist/chunk-CUPFXL3J.js.map +0 -1
- package/dist/chunk-DFTTJYSO.js.map +0 -1
- package/dist/chunk-EPQJM2GC.js.map +0 -1
- package/dist/chunk-F5VP6YCB.js.map +0 -1
- package/dist/chunk-FVA6TGI3.js.map +0 -1
- package/dist/chunk-GKFXUTJ2.js.map +0 -1
- package/dist/chunk-HK3FGIEW.js.map +0 -1
- package/dist/chunk-INXV5JBT.js.map +0 -1
- package/dist/chunk-KVBLZUKV.js.map +0 -1
- package/dist/chunk-LK6SGL53.js.map +0 -1
- package/dist/chunk-LTCGGW2D.js +0 -14
- package/dist/chunk-LTCGGW2D.js.map +0 -1
- package/dist/chunk-NZLQTHS5.js.map +0 -1
- package/dist/chunk-O5ETUNBT.js.map +0 -1
- package/dist/chunk-PVPWZSSI.js.map +0 -1
- package/dist/chunk-RGLL5SPU.js.map +0 -1
- package/dist/chunk-S3EEFKNY.js.map +0 -1
- package/dist/chunk-SPI27QT6.js.map +0 -1
- package/dist/chunk-TP4FZJIZ.js.map +0 -1
- package/dist/chunk-ULYOGL6R.js.map +0 -1
- package/dist/chunk-VBVG2M5G.js.map +0 -1
- package/dist/chunk-VDX363PS.js.map +0 -1
- package/dist/chunk-VYM3VWOF.js.map +0 -1
- package/dist/chunk-WCLICCGB.js.map +0 -1
- package/dist/chunk-WVVA7F5A.js.map +0 -1
- package/dist/chunk-X6GF3FX2.js +0 -26
- package/dist/chunk-X6GF3FX2.js.map +0 -1
- package/dist/chunk-XZ2TIKGC.js.map +0 -1
- package/dist/chunk-ZAIM4TUE.js.map +0 -1
- /package/dist/{contradiction-review-WIUBAR52.js.map → capsule-cli.js.map} +0 -0
- /package/dist/{engine-F3GOXGE5.js.map → capsule-crypto-5CYAGVC5.js.map} +0 -0
- /package/dist/{chunk-KUB6JU6H.js.map → chunk-47WOM4YW.js.map} +0 -0
- /package/dist/{chunk-ZEM3OK2K.js.map → chunk-B2TL6GA2.js.map} +0 -0
- /package/dist/{chunk-3GXCSUXR.js.map → chunk-CRU27Q4J.js.map} +0 -0
- /package/dist/{chunk-RBBWYEFJ.js.map → chunk-G2WADRQ3.js.map} +0 -0
- /package/dist/{chunk-7I7FKFZH.js.map → chunk-R2L7SUX2.js.map} +0 -0
- /package/dist/{chunk-JL2PU6AI.js.map → chunk-R2XRID2N.js.map} +0 -0
|
@@ -2,20 +2,12 @@ import {
|
|
|
2
2
|
CompoundingEngine,
|
|
3
3
|
SharedContextManager,
|
|
4
4
|
defaultTierMigrationCycleBudget
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import {
|
|
7
|
-
extractTopics
|
|
8
|
-
} from "./chunk-UHGBNIOS.js";
|
|
5
|
+
} from "./chunk-LVYGDT5V.js";
|
|
9
6
|
import {
|
|
10
7
|
applyUtilityPromotionRuntimePolicy,
|
|
11
8
|
applyUtilityRankingRuntimeDelta,
|
|
12
9
|
loadUtilityRuntimeValues
|
|
13
10
|
} from "./chunk-FSFEQI74.js";
|
|
14
|
-
import {
|
|
15
|
-
applyTemporalSupersession,
|
|
16
|
-
normalizeSupersessionKey,
|
|
17
|
-
shouldFilterSupersededFromRecall
|
|
18
|
-
} from "./chunk-W6SL7OFG.js";
|
|
19
11
|
import {
|
|
20
12
|
TierMigrationExecutor
|
|
21
13
|
} from "./chunk-Z5AAYHUC.js";
|
|
@@ -25,12 +17,29 @@ import {
|
|
|
25
17
|
import {
|
|
26
18
|
TmtBuilder
|
|
27
19
|
} from "./chunk-TPB3I2AC.js";
|
|
20
|
+
import {
|
|
21
|
+
extractTopics
|
|
22
|
+
} from "./chunk-UHGBNIOS.js";
|
|
23
|
+
import {
|
|
24
|
+
HourlySummarizer
|
|
25
|
+
} from "./chunk-B2TL6GA2.js";
|
|
26
|
+
import {
|
|
27
|
+
applyTemporalSupersession,
|
|
28
|
+
normalizeSupersessionKey,
|
|
29
|
+
shouldFilterSupersededFromRecall
|
|
30
|
+
} from "./chunk-ZTSE2ZJ6.js";
|
|
31
|
+
import {
|
|
32
|
+
isValidAsOf
|
|
33
|
+
} from "./chunk-MDYG7VI7.js";
|
|
28
34
|
import {
|
|
29
35
|
SessionObserverState
|
|
30
36
|
} from "./chunk-JR4ZC3G4.js";
|
|
31
37
|
import {
|
|
32
|
-
|
|
33
|
-
} from "./chunk-
|
|
38
|
+
applyRuntimeRetrievalPolicy
|
|
39
|
+
} from "./chunk-5IZL4DCV.js";
|
|
40
|
+
import {
|
|
41
|
+
findUnresolvedEntityRefs
|
|
42
|
+
} from "./chunk-X7XN6YU4.js";
|
|
34
43
|
import {
|
|
35
44
|
RelevanceStore
|
|
36
45
|
} from "./chunk-5NPGSAVB.js";
|
|
@@ -57,28 +66,19 @@ import {
|
|
|
57
66
|
resolvePromptTagPrefilterAsync
|
|
58
67
|
} from "./chunk-V3RXWQIE.js";
|
|
59
68
|
import {
|
|
60
|
-
|
|
61
|
-
} from "./chunk-
|
|
69
|
+
createRecallSectionMetricRecorder
|
|
70
|
+
} from "./chunk-7DHTMOND.js";
|
|
62
71
|
import {
|
|
63
72
|
LastRecallStore,
|
|
64
73
|
TierMigrationStatusStore,
|
|
65
74
|
clampGraphRecallExpandedEntries
|
|
66
|
-
} from "./chunk-
|
|
67
|
-
import {
|
|
68
|
-
buildXraySnapshot
|
|
69
|
-
} from "./chunk-KVBLZUKV.js";
|
|
70
|
-
import {
|
|
71
|
-
findUnresolvedEntityRefs
|
|
72
|
-
} from "./chunk-X7XN6YU4.js";
|
|
75
|
+
} from "./chunk-WPGJYVUH.js";
|
|
73
76
|
import {
|
|
74
77
|
applyReasoningTraceBoost
|
|
75
78
|
} from "./chunk-ZZTOURJI.js";
|
|
76
79
|
import {
|
|
77
80
|
reorderRecallResultsWithMmr
|
|
78
81
|
} from "./chunk-YDBIWGNI.js";
|
|
79
|
-
import {
|
|
80
|
-
createRecallSectionMetricRecorder
|
|
81
|
-
} from "./chunk-7DHTMOND.js";
|
|
82
82
|
import {
|
|
83
83
|
buildQmdRecallCacheKey,
|
|
84
84
|
getCachedQmdRecall,
|
|
@@ -87,13 +87,19 @@ import {
|
|
|
87
87
|
import {
|
|
88
88
|
NegativeExampleStore
|
|
89
89
|
} from "./chunk-D654IBA6.js";
|
|
90
|
-
import {
|
|
91
|
-
evaluateMemoryActionPolicy
|
|
92
|
-
} from "./chunk-H63EDPFJ.js";
|
|
93
90
|
import {
|
|
94
91
|
applyMemoryWorthFilter,
|
|
95
92
|
buildMemoryWorthCounterMap
|
|
96
93
|
} from "./chunk-3GPTTA4J.js";
|
|
94
|
+
import {
|
|
95
|
+
runLiveConnectorsOnce
|
|
96
|
+
} from "./chunk-ASIQZXYO.js";
|
|
97
|
+
import {
|
|
98
|
+
evaluateMemoryActionPolicy
|
|
99
|
+
} from "./chunk-H63EDPFJ.js";
|
|
100
|
+
import {
|
|
101
|
+
classifyMemoryKind
|
|
102
|
+
} from "./chunk-YAZNBMNF.js";
|
|
97
103
|
import {
|
|
98
104
|
hasBroadGraphIntent,
|
|
99
105
|
inferIntentFromText,
|
|
@@ -101,13 +107,6 @@ import {
|
|
|
101
107
|
isTaskInitiationIntent,
|
|
102
108
|
planRecallMode
|
|
103
109
|
} from "./chunk-GGD5W7TB.js";
|
|
104
|
-
import {
|
|
105
|
-
classifyMemoryKind
|
|
106
|
-
} from "./chunk-YAZNBMNF.js";
|
|
107
|
-
import {
|
|
108
|
-
EXTRACTION_JUDGE_VERDICT_CATEGORY,
|
|
109
|
-
recordJudgeVerdict
|
|
110
|
-
} from "./chunk-AJU4PJGY.js";
|
|
111
110
|
import {
|
|
112
111
|
recordJudgeTrainingPair
|
|
113
112
|
} from "./chunk-DF3RVK3X.js";
|
|
@@ -120,10 +119,10 @@ import {
|
|
|
120
119
|
} from "./chunk-C4SQJZAF.js";
|
|
121
120
|
import {
|
|
122
121
|
ExtractionEngine
|
|
123
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-N7X62G74.js";
|
|
124
123
|
import {
|
|
125
124
|
parseMemoryActionEligibilityContext
|
|
126
|
-
} from "./chunk-
|
|
125
|
+
} from "./chunk-WW3QQF4H.js";
|
|
127
126
|
import {
|
|
128
127
|
ProfilingCollector
|
|
129
128
|
} from "./chunk-NBNN5GOB.js";
|
|
@@ -132,41 +131,52 @@ import {
|
|
|
132
131
|
} from "./chunk-FEMOX5AD.js";
|
|
133
132
|
import {
|
|
134
133
|
LocalLlmClient
|
|
135
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-R2XRID2N.js";
|
|
135
|
+
import {
|
|
136
|
+
formatDaySummaryMemories
|
|
137
|
+
} from "./chunk-GZCUW5IC.js";
|
|
136
138
|
import {
|
|
137
139
|
tryDirectAnswer
|
|
138
140
|
} from "./chunk-6AUUAZEX.js";
|
|
139
141
|
import {
|
|
140
142
|
EmbeddingFallback
|
|
141
|
-
} from "./chunk-
|
|
143
|
+
} from "./chunk-Z2E7VW55.js";
|
|
142
144
|
import {
|
|
143
145
|
buildEntityRecallSection,
|
|
144
146
|
entityRecentTranscriptLookbackHours,
|
|
145
147
|
readRecentEntityTranscriptEntries
|
|
146
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-Y3WQ4ZWK.js";
|
|
147
149
|
import {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
buildCompressionGuidelinesMarkdown,
|
|
151
|
+
computeCompressionGuidelineCandidate,
|
|
152
|
+
refineCompressionGuidelineCandidateSemantically,
|
|
153
|
+
renderCompressionGuidelinesMarkdown
|
|
154
|
+
} from "./chunk-2NMMFZ5T.js";
|
|
150
155
|
import {
|
|
151
156
|
RoutingRulesStore,
|
|
152
|
-
expandTildePath,
|
|
153
157
|
normalizeReplaySessionKey
|
|
154
|
-
} from "./chunk-
|
|
158
|
+
} from "./chunk-VTJVUHRK.js";
|
|
155
159
|
import {
|
|
156
160
|
searchVerifiedEpisodes
|
|
157
|
-
} from "./chunk-
|
|
161
|
+
} from "./chunk-DHRQHX36.js";
|
|
158
162
|
import {
|
|
159
163
|
ThreadingManager
|
|
160
164
|
} from "./chunk-JRNQ3RNA.js";
|
|
161
165
|
import {
|
|
162
166
|
searchVerifiedSemanticRules
|
|
163
|
-
} from "./chunk-
|
|
167
|
+
} from "./chunk-L5IIGA5V.js";
|
|
164
168
|
import {
|
|
165
169
|
searchWorkProductLedgerEntries
|
|
166
170
|
} from "./chunk-CULXMQJH.js";
|
|
167
171
|
import {
|
|
168
172
|
TranscriptManager
|
|
169
173
|
} from "./chunk-E6K4NIEU.js";
|
|
174
|
+
import {
|
|
175
|
+
PolicyRuntimeManager
|
|
176
|
+
} from "./chunk-EABGC2TL.js";
|
|
177
|
+
import {
|
|
178
|
+
searchObjectiveStateSnapshots
|
|
179
|
+
} from "./chunk-LOBRX7VD.js";
|
|
170
180
|
import {
|
|
171
181
|
NamespaceSearchRouter,
|
|
172
182
|
NamespaceStorageRouter,
|
|
@@ -174,16 +184,10 @@ import {
|
|
|
174
184
|
createConversationIndexRuntime,
|
|
175
185
|
createSearchBackend,
|
|
176
186
|
writeConversationChunks
|
|
177
|
-
} from "./chunk-
|
|
187
|
+
} from "./chunk-R2L7SUX2.js";
|
|
178
188
|
import {
|
|
179
189
|
parseQmdExplain
|
|
180
|
-
} from "./chunk-
|
|
181
|
-
import {
|
|
182
|
-
PolicyRuntimeManager
|
|
183
|
-
} from "./chunk-EABGC2TL.js";
|
|
184
|
-
import {
|
|
185
|
-
searchObjectiveStateSnapshots
|
|
186
|
-
} from "./chunk-LOBRX7VD.js";
|
|
190
|
+
} from "./chunk-WSZIHQBK.js";
|
|
187
191
|
import {
|
|
188
192
|
searchHarmonicRetrieval
|
|
189
193
|
} from "./chunk-HMDCOMYU.js";
|
|
@@ -192,31 +196,23 @@ import {
|
|
|
192
196
|
scoreImportance
|
|
193
197
|
} from "./chunk-JXS5PDQ7.js";
|
|
194
198
|
import {
|
|
195
|
-
|
|
196
|
-
} from "./chunk-
|
|
199
|
+
recordEvalShadowRecall
|
|
200
|
+
} from "./chunk-K6WK37A6.js";
|
|
201
|
+
import {
|
|
202
|
+
EXTRACTION_JUDGE_VERDICT_CATEGORY,
|
|
203
|
+
recordJudgeVerdict
|
|
204
|
+
} from "./chunk-AJU4PJGY.js";
|
|
197
205
|
import {
|
|
198
206
|
collectNativeKnowledgeChunks,
|
|
199
207
|
formatNativeKnowledgeSection,
|
|
200
208
|
searchNativeKnowledge
|
|
201
209
|
} from "./chunk-7SEAZFFB.js";
|
|
202
|
-
import {
|
|
203
|
-
recordEvalShadowRecall
|
|
204
|
-
} from "./chunk-K6WK37A6.js";
|
|
205
|
-
import {
|
|
206
|
-
GraphIndex
|
|
207
|
-
} from "./chunk-C2EFFULQ.js";
|
|
208
210
|
import {
|
|
209
211
|
CODEX_THREAD_KEY_PREFIX
|
|
210
212
|
} from "./chunk-3PG3H5TD.js";
|
|
211
213
|
import {
|
|
212
214
|
applyCommitmentLedgerLifecycle
|
|
213
215
|
} from "./chunk-FYIYMQ5N.js";
|
|
214
|
-
import {
|
|
215
|
-
buildCompressionGuidelinesMarkdown,
|
|
216
|
-
computeCompressionGuidelineCandidate,
|
|
217
|
-
refineCompressionGuidelineCandidateSemantically,
|
|
218
|
-
renderCompressionGuidelinesMarkdown
|
|
219
|
-
} from "./chunk-2NMMFZ5T.js";
|
|
220
216
|
import {
|
|
221
217
|
semanticChunkContent
|
|
222
218
|
} from "./chunk-KVE7R4CG.js";
|
|
@@ -235,10 +231,10 @@ import {
|
|
|
235
231
|
materializeAfterSemanticConsolidation,
|
|
236
232
|
parseConsolidationResponse,
|
|
237
233
|
parseOperatorAwareConsolidationResponse
|
|
238
|
-
} from "./chunk-
|
|
234
|
+
} from "./chunk-55FXRRSJ.js";
|
|
239
235
|
import {
|
|
240
236
|
FallbackLlmClient
|
|
241
|
-
} from "./chunk-
|
|
237
|
+
} from "./chunk-CRU27Q4J.js";
|
|
242
238
|
import {
|
|
243
239
|
buildRecallQueryPolicy
|
|
244
240
|
} from "./chunk-6HZ6AO2P.js";
|
|
@@ -261,24 +257,34 @@ import {
|
|
|
261
257
|
throwIfAborted
|
|
262
258
|
} from "./chunk-PVGDJXVK.js";
|
|
263
259
|
import {
|
|
264
|
-
|
|
265
|
-
|
|
260
|
+
clusterByKey,
|
|
261
|
+
stableHash
|
|
262
|
+
} from "./chunk-NN3TS5BM.js";
|
|
266
263
|
import {
|
|
267
264
|
listTrustZoneRecords,
|
|
268
265
|
searchTrustZoneRecords
|
|
269
266
|
} from "./chunk-EQINRHYR.js";
|
|
270
267
|
import {
|
|
271
|
-
|
|
272
|
-
} from "./chunk-
|
|
268
|
+
buildXraySnapshot
|
|
269
|
+
} from "./chunk-USFPPRAF.js";
|
|
273
270
|
import {
|
|
274
271
|
shouldSkipImplicitExtraction
|
|
275
272
|
} from "./chunk-3FPTCC3Z.js";
|
|
276
273
|
import {
|
|
277
274
|
selectRouteRule
|
|
278
275
|
} from "./chunk-2LGMW3DJ.js";
|
|
276
|
+
import {
|
|
277
|
+
launchProcessSync
|
|
278
|
+
} from "./chunk-OR64ZGRZ.js";
|
|
279
|
+
import {
|
|
280
|
+
buildProcedurePersistBody
|
|
281
|
+
} from "./chunk-QDW3E4RD.js";
|
|
282
|
+
import {
|
|
283
|
+
GraphIndex
|
|
284
|
+
} from "./chunk-RK2Y4XOM.js";
|
|
279
285
|
import {
|
|
280
286
|
searchCausalTrajectories
|
|
281
|
-
} from "./chunk-
|
|
287
|
+
} from "./chunk-G2WADRQ3.js";
|
|
282
288
|
import {
|
|
283
289
|
canReadNamespace,
|
|
284
290
|
defaultNamespaceForPrincipal,
|
|
@@ -297,15 +303,18 @@ import {
|
|
|
297
303
|
normalizeAttributePairs,
|
|
298
304
|
normalizeEntityName,
|
|
299
305
|
parseEntityFile
|
|
300
|
-
} from "./chunk-
|
|
301
|
-
import {
|
|
302
|
-
confidenceTier
|
|
303
|
-
} from "./chunk-LTCGGW2D.js";
|
|
306
|
+
} from "./chunk-DCE6SQLA.js";
|
|
304
307
|
import {
|
|
305
308
|
attachCitation,
|
|
306
309
|
hasCitationForTemplate,
|
|
307
310
|
stripCitationForTemplate
|
|
308
311
|
} from "./chunk-4KAN3GZ3.js";
|
|
312
|
+
import {
|
|
313
|
+
confidenceTier
|
|
314
|
+
} from "./chunk-43EKP2UK.js";
|
|
315
|
+
import {
|
|
316
|
+
isActiveMemoryStatus
|
|
317
|
+
} from "./chunk-RULE4VG5.js";
|
|
309
318
|
import {
|
|
310
319
|
openBetterSqlite3
|
|
311
320
|
} from "./chunk-BOUYNNYD.js";
|
|
@@ -316,12 +325,19 @@ import {
|
|
|
316
325
|
import {
|
|
317
326
|
sanitizeMemoryContent
|
|
318
327
|
} from "./chunk-M62O4P4T.js";
|
|
328
|
+
import {
|
|
329
|
+
resolveHomeDir
|
|
330
|
+
} from "./chunk-MARWOCVP.js";
|
|
319
331
|
import {
|
|
320
332
|
log
|
|
321
333
|
} from "./chunk-2ODBA7MQ.js";
|
|
334
|
+
import {
|
|
335
|
+
keyring_exports,
|
|
336
|
+
secureStoreDir
|
|
337
|
+
} from "./chunk-BJMBJZ2Y.js";
|
|
322
338
|
|
|
323
339
|
// src/orchestrator.ts
|
|
324
|
-
import
|
|
340
|
+
import path6 from "path";
|
|
325
341
|
import os from "os";
|
|
326
342
|
import { createHash as createHash2, randomBytes } from "crypto";
|
|
327
343
|
import { existsSync as existsSync2 } from "fs";
|
|
@@ -335,7 +351,6 @@ import {
|
|
|
335
351
|
} from "fs/promises";
|
|
336
352
|
|
|
337
353
|
// src/migrate/from-engram.ts
|
|
338
|
-
import { execFileSync } from "child_process";
|
|
339
354
|
import { createHash } from "crypto";
|
|
340
355
|
import path from "path";
|
|
341
356
|
import {
|
|
@@ -371,7 +386,14 @@ function resolveLogger(options) {
|
|
|
371
386
|
}
|
|
372
387
|
function resolveExec(options) {
|
|
373
388
|
return options?.execCommand ?? ((command, args) => {
|
|
374
|
-
|
|
389
|
+
const result = launchProcessSync(command, args, { stdio: "ignore" });
|
|
390
|
+
if (result.error) {
|
|
391
|
+
throw result.error;
|
|
392
|
+
}
|
|
393
|
+
if (result.status !== 0) {
|
|
394
|
+
const reason = result.status === null ? `signal ${result.signal ?? "unknown"}` : `exit code ${result.status}`;
|
|
395
|
+
throw new Error(`migration command failed: ${command} ${args.join(" ")} (${reason})`);
|
|
396
|
+
}
|
|
375
397
|
});
|
|
376
398
|
}
|
|
377
399
|
function remnicRoot(homeDir) {
|
|
@@ -913,7 +935,7 @@ async function buildProcedureRecallSection(storage, prompt, config) {
|
|
|
913
935
|
);
|
|
914
936
|
const all = await storage.readAllMemories();
|
|
915
937
|
const scored = all.filter(
|
|
916
|
-
(m) => m.frontmatter.category === "procedure" && m.frontmatter.status
|
|
938
|
+
(m) => m.frontmatter.category === "procedure" && isActiveMemoryStatus(m.frontmatter.status)
|
|
917
939
|
).map((m) => ({ m, score: scoreProcedureForPrompt(m, trimmed, queryIntent) })).filter((x) => x.score > 0.04).sort((a, b) => b.score - a.score).slice(0, maxN);
|
|
918
940
|
if (scored.length === 0) return null;
|
|
919
941
|
const blocks = scored.map(({ m, score }) => {
|
|
@@ -937,6 +959,8 @@ var DAY_SUMMARY_CRON_ID = "engram-day-summary";
|
|
|
937
959
|
var GOVERNANCE_CRON_ID = "engram-nightly-governance";
|
|
938
960
|
var PROCEDURAL_MINING_CRON_ID = "engram-procedural-mining";
|
|
939
961
|
var CONTRADICTION_SCAN_CRON_ID = "engram-contradiction-scan";
|
|
962
|
+
var PATTERN_REINFORCEMENT_CRON_ID = "engram-pattern-reinforcement";
|
|
963
|
+
var GRAPH_EDGE_DECAY_CRON_ID = "engram-graph-edge-decay";
|
|
940
964
|
async function acquireCronJobsLock(jobsPath) {
|
|
941
965
|
const lockPath2 = `${jobsPath}.lock`;
|
|
942
966
|
const start = Date.now();
|
|
@@ -1097,6 +1121,202 @@ async function ensureContradictionScanCron(jobsPath, options) {
|
|
|
1097
1121
|
delivery: { mode: "none" }
|
|
1098
1122
|
}));
|
|
1099
1123
|
}
|
|
1124
|
+
async function ensurePatternReinforcementCron(jobsPath, options) {
|
|
1125
|
+
const scheduleExpr = typeof options.scheduleExpr === "string" && options.scheduleExpr.trim().length > 0 ? options.scheduleExpr.trim() : "53 4 * * 0";
|
|
1126
|
+
const agentId = typeof options.agentId === "string" && options.agentId.trim().length > 0 ? options.agentId.trim() : "main";
|
|
1127
|
+
return ensureCronJob(jobsPath, PATTERN_REINFORCEMENT_CRON_ID, () => ({
|
|
1128
|
+
id: PATTERN_REINFORCEMENT_CRON_ID,
|
|
1129
|
+
agentId,
|
|
1130
|
+
name: "Remnic Pattern Reinforcement (weekly)",
|
|
1131
|
+
enabled: true,
|
|
1132
|
+
schedule: {
|
|
1133
|
+
kind: "cron",
|
|
1134
|
+
expr: scheduleExpr,
|
|
1135
|
+
tz: options.timezone
|
|
1136
|
+
},
|
|
1137
|
+
sessionTarget: "isolated",
|
|
1138
|
+
wakeMode: "now",
|
|
1139
|
+
payload: {
|
|
1140
|
+
kind: "agentTurn",
|
|
1141
|
+
timeoutSeconds: 900,
|
|
1142
|
+
thinking: "off",
|
|
1143
|
+
message: "You are OpenClaw automation. Call tool `engram.pattern_reinforcement_run` with empty params. If successful output exactly NO_REPLY. On error output one concise line. Do NOT use message tool."
|
|
1144
|
+
},
|
|
1145
|
+
delivery: { mode: "none" }
|
|
1146
|
+
}));
|
|
1147
|
+
}
|
|
1148
|
+
async function ensureGraphEdgeDecayCron(jobsPath, options) {
|
|
1149
|
+
const scheduleExpr = typeof options.scheduleExpr === "string" && options.scheduleExpr.trim().length > 0 ? options.scheduleExpr.trim() : "13 4 * * 0";
|
|
1150
|
+
const agentId = typeof options.agentId === "string" && options.agentId.trim().length > 0 ? options.agentId.trim() : "main";
|
|
1151
|
+
const scheduleLabel = graphEdgeDecayScheduleLabel(scheduleExpr);
|
|
1152
|
+
return ensureCronJob(jobsPath, GRAPH_EDGE_DECAY_CRON_ID, () => ({
|
|
1153
|
+
id: GRAPH_EDGE_DECAY_CRON_ID,
|
|
1154
|
+
agentId,
|
|
1155
|
+
// Schedule label reflects the actual cron expression (`daily` /
|
|
1156
|
+
// `weekly` / `custom`) so cron dashboards do not show "weekly"
|
|
1157
|
+
// when the schedule is in fact daily — Cursor review on PR #729.
|
|
1158
|
+
name: `Remnic Graph Edge Decay (${scheduleLabel})`,
|
|
1159
|
+
enabled: true,
|
|
1160
|
+
schedule: {
|
|
1161
|
+
kind: "cron",
|
|
1162
|
+
expr: scheduleExpr,
|
|
1163
|
+
tz: options.timezone
|
|
1164
|
+
},
|
|
1165
|
+
sessionTarget: "isolated",
|
|
1166
|
+
wakeMode: "now",
|
|
1167
|
+
payload: {
|
|
1168
|
+
kind: "agentTurn",
|
|
1169
|
+
timeoutSeconds: 900,
|
|
1170
|
+
thinking: "off",
|
|
1171
|
+
message: "You are OpenClaw automation. Call tool `engram.graph_edge_decay_run` with empty params. If successful output exactly NO_REPLY. On error output one concise line. Do NOT use message tool."
|
|
1172
|
+
},
|
|
1173
|
+
delivery: { mode: "none" }
|
|
1174
|
+
}));
|
|
1175
|
+
}
|
|
1176
|
+
function graphEdgeDecayCadenceToCronExpr(cadenceMs) {
|
|
1177
|
+
if (!Number.isFinite(cadenceMs) || cadenceMs <= 0) {
|
|
1178
|
+
return "13 4 * * 0";
|
|
1179
|
+
}
|
|
1180
|
+
const day = 24 * 60 * 60 * 1e3;
|
|
1181
|
+
if (cadenceMs < 7 * day) return "13 4 * * *";
|
|
1182
|
+
return "13 4 * * 0";
|
|
1183
|
+
}
|
|
1184
|
+
function graphEdgeDecayScheduleLabel(scheduleExpr) {
|
|
1185
|
+
if (scheduleExpr === "13 4 * * *") return "daily";
|
|
1186
|
+
if (scheduleExpr === "13 4 * * 0") return "weekly";
|
|
1187
|
+
return "custom";
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
// src/maintenance/pattern-reinforcement.ts
|
|
1191
|
+
function patternReinforcementKey(content) {
|
|
1192
|
+
return content.trim().toLowerCase().replace(/\s+/g, " ").slice(0, 200);
|
|
1193
|
+
}
|
|
1194
|
+
function patternReinforcementClusterKey(category, content) {
|
|
1195
|
+
return `${category}::${patternReinforcementKey(content)}`;
|
|
1196
|
+
}
|
|
1197
|
+
function pickCanonical(memories) {
|
|
1198
|
+
let best = memories[0];
|
|
1199
|
+
let bestInstant = memoryInstant(best);
|
|
1200
|
+
let bestStamp = memoryStamp(best);
|
|
1201
|
+
for (let i = 1; i < memories.length; i += 1) {
|
|
1202
|
+
const candidate = memories[i];
|
|
1203
|
+
const instant = memoryInstant(candidate);
|
|
1204
|
+
const stamp = memoryStamp(candidate);
|
|
1205
|
+
let cmp;
|
|
1206
|
+
if (instant !== null && bestInstant !== null) {
|
|
1207
|
+
cmp = instant - bestInstant;
|
|
1208
|
+
} else {
|
|
1209
|
+
cmp = stamp.localeCompare(bestStamp);
|
|
1210
|
+
}
|
|
1211
|
+
if (cmp > 0 || cmp === 0 && candidate.frontmatter.id > best.frontmatter.id) {
|
|
1212
|
+
best = candidate;
|
|
1213
|
+
bestInstant = instant;
|
|
1214
|
+
bestStamp = stamp;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
return best;
|
|
1218
|
+
}
|
|
1219
|
+
function memoryStamp(memory) {
|
|
1220
|
+
return memory.frontmatter.updated || memory.frontmatter.created || "";
|
|
1221
|
+
}
|
|
1222
|
+
function memoryInstant(memory) {
|
|
1223
|
+
const stamp = memoryStamp(memory);
|
|
1224
|
+
if (stamp.length === 0) return null;
|
|
1225
|
+
const parsed = Date.parse(stamp);
|
|
1226
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
1227
|
+
}
|
|
1228
|
+
var ACTIVE_STATUS = "active";
|
|
1229
|
+
async function runPatternReinforcement(storage, options) {
|
|
1230
|
+
const minCount = Math.max(2, Math.floor(options.minCount));
|
|
1231
|
+
const targetCategories = new Set(options.categories);
|
|
1232
|
+
const now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
1233
|
+
const nowIso = now().toISOString();
|
|
1234
|
+
if (targetCategories.size === 0) {
|
|
1235
|
+
return emptyResult();
|
|
1236
|
+
}
|
|
1237
|
+
const memories = await storage.readAllMemories();
|
|
1238
|
+
const eligible = memories.filter((m) => {
|
|
1239
|
+
if (!targetCategories.has(m.frontmatter.category)) return false;
|
|
1240
|
+
const status = m.frontmatter.status ?? ACTIVE_STATUS;
|
|
1241
|
+
return status === ACTIVE_STATUS || status === "superseded";
|
|
1242
|
+
});
|
|
1243
|
+
if (eligible.length === 0) return emptyResult();
|
|
1244
|
+
const clusters = clusterByKey(
|
|
1245
|
+
eligible,
|
|
1246
|
+
(m) => patternReinforcementClusterKey(m.frontmatter.category, m.content)
|
|
1247
|
+
);
|
|
1248
|
+
const result = {
|
|
1249
|
+
clustersFound: 0,
|
|
1250
|
+
canonicalsUpdated: 0,
|
|
1251
|
+
duplicatesSuperseded: 0,
|
|
1252
|
+
clusters: []
|
|
1253
|
+
};
|
|
1254
|
+
for (const cluster of clusters.values()) {
|
|
1255
|
+
if (cluster.length < minCount) continue;
|
|
1256
|
+
const activeMembers = cluster.filter((m) => {
|
|
1257
|
+
const status = m.frontmatter.status ?? ACTIVE_STATUS;
|
|
1258
|
+
return status === ACTIVE_STATUS;
|
|
1259
|
+
});
|
|
1260
|
+
if (activeMembers.length === 0) continue;
|
|
1261
|
+
result.clustersFound += 1;
|
|
1262
|
+
const canonical = pickCanonical(activeMembers);
|
|
1263
|
+
const activeDuplicates = activeMembers.filter((m) => m !== canonical);
|
|
1264
|
+
const sourceIds = [...cluster].map((m) => m.frontmatter.id).filter((id) => typeof id === "string" && id.length > 0).sort();
|
|
1265
|
+
const previousCount = canonical.frontmatter.reinforcement_count ?? 0;
|
|
1266
|
+
const newCount = sourceIds.length;
|
|
1267
|
+
const reinforcementBumped = newCount > previousCount;
|
|
1268
|
+
const previousDerivedFrom = Array.isArray(canonical.frontmatter.derived_from) ? [...canonical.frontmatter.derived_from].sort() : [];
|
|
1269
|
+
const sortedSourceIds = [...sourceIds].sort();
|
|
1270
|
+
const membershipChanged = previousDerivedFrom.length !== sortedSourceIds.length || previousDerivedFrom.some((id, i) => id !== sortedSourceIds[i]);
|
|
1271
|
+
const previousVia = canonical.frontmatter.derived_via;
|
|
1272
|
+
const viaChanged = previousVia !== "pattern-reinforcement";
|
|
1273
|
+
const canonicalNeedsRefresh = reinforcementBumped || membershipChanged || viaChanged;
|
|
1274
|
+
if (canonicalNeedsRefresh) {
|
|
1275
|
+
const patch = {
|
|
1276
|
+
derived_from: sourceIds,
|
|
1277
|
+
derived_via: "pattern-reinforcement",
|
|
1278
|
+
updated: nowIso
|
|
1279
|
+
};
|
|
1280
|
+
if (reinforcementBumped) {
|
|
1281
|
+
patch.reinforcement_count = newCount;
|
|
1282
|
+
patch.last_reinforced_at = nowIso;
|
|
1283
|
+
} else {
|
|
1284
|
+
patch.reinforcement_count = canonical.frontmatter.reinforcement_count ?? newCount;
|
|
1285
|
+
patch.last_reinforced_at = canonical.frontmatter.last_reinforced_at ?? nowIso;
|
|
1286
|
+
}
|
|
1287
|
+
await storage.writeMemoryFrontmatter(canonical, patch);
|
|
1288
|
+
result.canonicalsUpdated += 1;
|
|
1289
|
+
}
|
|
1290
|
+
const supersededIds = [];
|
|
1291
|
+
for (const dup of activeDuplicates) {
|
|
1292
|
+
const patch = {
|
|
1293
|
+
status: "superseded",
|
|
1294
|
+
supersededBy: canonical.frontmatter.id,
|
|
1295
|
+
supersededAt: nowIso,
|
|
1296
|
+
updated: nowIso
|
|
1297
|
+
};
|
|
1298
|
+
await storage.writeMemoryFrontmatter(dup, patch);
|
|
1299
|
+
supersededIds.push(dup.frontmatter.id);
|
|
1300
|
+
result.duplicatesSuperseded += 1;
|
|
1301
|
+
}
|
|
1302
|
+
result.clusters.push({
|
|
1303
|
+
canonicalId: canonical.frontmatter.id,
|
|
1304
|
+
count: newCount,
|
|
1305
|
+
sourceIds,
|
|
1306
|
+
supersededIds,
|
|
1307
|
+
reinforcementBumped
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
return result;
|
|
1311
|
+
}
|
|
1312
|
+
function emptyResult() {
|
|
1313
|
+
return {
|
|
1314
|
+
clustersFound: 0,
|
|
1315
|
+
canonicalsUpdated: 0,
|
|
1316
|
+
duplicatesSuperseded: 0,
|
|
1317
|
+
clusters: []
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1100
1320
|
|
|
1101
1321
|
// src/dedup/semantic.ts
|
|
1102
1322
|
async function decideSemanticDedup(content, lookup, options) {
|
|
@@ -2700,119 +2920,6 @@ async function cleanupConversationChunks(rootDir, retentionDays) {
|
|
|
2700
2920
|
}
|
|
2701
2921
|
}
|
|
2702
2922
|
|
|
2703
|
-
// src/coding/git-context.ts
|
|
2704
|
-
import path6 from "path";
|
|
2705
|
-
var DEFAULT_GIT_TIMEOUT_MS = 2e3;
|
|
2706
|
-
function defaultGitInvoker() {
|
|
2707
|
-
return (cwd, args) => {
|
|
2708
|
-
const result = launchProcessSync("git", args, {
|
|
2709
|
-
cwd,
|
|
2710
|
-
encoding: "utf-8",
|
|
2711
|
-
timeout: DEFAULT_GIT_TIMEOUT_MS,
|
|
2712
|
-
shell: false
|
|
2713
|
-
});
|
|
2714
|
-
if (result.error) {
|
|
2715
|
-
return { stdout: "", exitCode: 127 };
|
|
2716
|
-
}
|
|
2717
|
-
return {
|
|
2718
|
-
stdout: typeof result.stdout === "string" ? result.stdout : "",
|
|
2719
|
-
exitCode: typeof result.status === "number" ? result.status : 1
|
|
2720
|
-
};
|
|
2721
|
-
};
|
|
2722
|
-
}
|
|
2723
|
-
function stableHash(input) {
|
|
2724
|
-
let hash = 2166136261;
|
|
2725
|
-
for (let i = 0; i < input.length; i++) {
|
|
2726
|
-
hash ^= input.charCodeAt(i);
|
|
2727
|
-
hash = Math.imul(hash, 16777619) >>> 0;
|
|
2728
|
-
}
|
|
2729
|
-
return hash.toString(16).padStart(8, "0");
|
|
2730
|
-
}
|
|
2731
|
-
function normalizeOriginUrl(rawUrl) {
|
|
2732
|
-
let url = rawUrl.trim();
|
|
2733
|
-
if (!url) return "";
|
|
2734
|
-
if (/\.git$/i.test(url)) url = url.slice(0, -4);
|
|
2735
|
-
if (/^[A-Za-z]:[\\/]/.test(url)) {
|
|
2736
|
-
return url.toLowerCase();
|
|
2737
|
-
}
|
|
2738
|
-
const protoMatch = /^[a-z][a-z0-9+.-]*:\/\/(?:[^@/]+@)?(\[[^\]]+\]|[^/:]*)(?::(\d+))?(\/.*)?$/i.exec(url);
|
|
2739
|
-
if (protoMatch) {
|
|
2740
|
-
let host = protoMatch[1] ?? "";
|
|
2741
|
-
const wasBracketed = host.startsWith("[") && host.endsWith("]");
|
|
2742
|
-
if (wasBracketed) host = host.slice(1, -1);
|
|
2743
|
-
const port = protoMatch[2];
|
|
2744
|
-
const repoPath = (protoMatch[3] ?? "").replace(/^\/+/, "");
|
|
2745
|
-
const hostPort = port ? wasBracketed ? `[${host}]:${port}` : `${host}:${port}` : host;
|
|
2746
|
-
const prefix = hostPort.length > 0 ? hostPort : "localhost";
|
|
2747
|
-
return `${prefix}/${repoPath}`.toLowerCase();
|
|
2748
|
-
}
|
|
2749
|
-
const scpMatch = /^(?:([^@\s/]+)@)?(\[[^\]]+\]|[^:@\s/]+):(.+)$/.exec(url);
|
|
2750
|
-
if (scpMatch) {
|
|
2751
|
-
let host = scpMatch[2] ?? "";
|
|
2752
|
-
if (host.startsWith("[") && host.endsWith("]")) host = host.slice(1, -1);
|
|
2753
|
-
const repoPath = scpMatch[3] ?? "";
|
|
2754
|
-
if (repoPath.startsWith("//")) {
|
|
2755
|
-
return url.toLowerCase();
|
|
2756
|
-
}
|
|
2757
|
-
return `${host}/${repoPath.replace(/^\/+/, "")}`.toLowerCase();
|
|
2758
|
-
}
|
|
2759
|
-
return url.toLowerCase();
|
|
2760
|
-
}
|
|
2761
|
-
async function resolveGitContext(cwd, options = {}) {
|
|
2762
|
-
try {
|
|
2763
|
-
if (typeof cwd !== "string" || cwd.length === 0) return null;
|
|
2764
|
-
const expanded = expandTildePath(cwd);
|
|
2765
|
-
if (!path6.isAbsolute(expanded)) return null;
|
|
2766
|
-
const invoker = options.invoker ?? defaultGitInvoker();
|
|
2767
|
-
const topLevel = invoker(expanded, ["rev-parse", "--show-toplevel"]);
|
|
2768
|
-
if (topLevel.exitCode !== 0) return null;
|
|
2769
|
-
const rootPath = topLevel.stdout.trim();
|
|
2770
|
-
if (!rootPath) return null;
|
|
2771
|
-
const branchResult = invoker(rootPath, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
2772
|
-
let branch = null;
|
|
2773
|
-
if (branchResult.exitCode === 0) {
|
|
2774
|
-
const raw = branchResult.stdout.trim();
|
|
2775
|
-
branch = raw && raw !== "HEAD" ? raw : null;
|
|
2776
|
-
} else {
|
|
2777
|
-
const unbornRef = invoker(rootPath, ["symbolic-ref", "--quiet", "HEAD"]);
|
|
2778
|
-
if (unbornRef.exitCode === 0) {
|
|
2779
|
-
const raw = unbornRef.stdout.trim();
|
|
2780
|
-
const prefix = "refs/heads/";
|
|
2781
|
-
if (raw.startsWith(prefix)) {
|
|
2782
|
-
const candidate = raw.slice(prefix.length);
|
|
2783
|
-
if (candidate) branch = candidate;
|
|
2784
|
-
}
|
|
2785
|
-
}
|
|
2786
|
-
}
|
|
2787
|
-
const originResult = invoker(rootPath, ["remote", "get-url", "origin"]);
|
|
2788
|
-
let projectId;
|
|
2789
|
-
if (originResult.exitCode === 0) {
|
|
2790
|
-
const normalized = normalizeOriginUrl(originResult.stdout);
|
|
2791
|
-
projectId = normalized ? `origin:${stableHash(normalized)}` : `root:${stableHash(rootPath)}`;
|
|
2792
|
-
} else {
|
|
2793
|
-
projectId = `root:${stableHash(rootPath)}`;
|
|
2794
|
-
}
|
|
2795
|
-
const headRef = invoker(rootPath, ["symbolic-ref", "--quiet", "refs/remotes/origin/HEAD"]);
|
|
2796
|
-
let defaultBranch = null;
|
|
2797
|
-
if (headRef.exitCode === 0) {
|
|
2798
|
-
const raw = headRef.stdout.trim();
|
|
2799
|
-
const prefix = "refs/remotes/origin/";
|
|
2800
|
-
if (raw.startsWith(prefix)) {
|
|
2801
|
-
const candidate = raw.slice(prefix.length);
|
|
2802
|
-
if (candidate) defaultBranch = candidate;
|
|
2803
|
-
}
|
|
2804
|
-
}
|
|
2805
|
-
return {
|
|
2806
|
-
projectId,
|
|
2807
|
-
branch,
|
|
2808
|
-
rootPath,
|
|
2809
|
-
defaultBranch
|
|
2810
|
-
};
|
|
2811
|
-
} catch {
|
|
2812
|
-
return null;
|
|
2813
|
-
}
|
|
2814
|
-
}
|
|
2815
|
-
|
|
2816
2923
|
// src/coding/coding-namespace.ts
|
|
2817
2924
|
function sanitizeFragment(input) {
|
|
2818
2925
|
if (typeof input !== "string") return "";
|
|
@@ -2883,27 +2990,30 @@ function branchNamespaceName(projectId, branch) {
|
|
|
2883
2990
|
const suffixed = disambig ? `${base}-${stableHash(trimmedBranch)}` : base;
|
|
2884
2991
|
return capLength(suffixed);
|
|
2885
2992
|
}
|
|
2886
|
-
function resolveCodingNamespaceOverlay(codingContext, config) {
|
|
2993
|
+
function resolveCodingNamespaceOverlay(codingContext, config, defaultNamespace) {
|
|
2887
2994
|
if (!codingContext) return null;
|
|
2888
2995
|
if (!config.projectScope) return null;
|
|
2889
2996
|
const projectId = typeof codingContext.projectId === "string" ? codingContext.projectId.trim() : "";
|
|
2890
2997
|
if (!projectId) return null;
|
|
2891
2998
|
const projectNs = projectNamespaceName(projectId);
|
|
2999
|
+
const includeRoot = config.globalFallback === true;
|
|
2892
3000
|
if (config.branchScope && typeof codingContext.branch === "string" && codingContext.branch.length > 0) {
|
|
2893
3001
|
const branchNs = branchNamespaceName(projectId, codingContext.branch);
|
|
3002
|
+
const fallbacks = [projectNs];
|
|
3003
|
+
if (includeRoot) fallbacks.push("");
|
|
2894
3004
|
return {
|
|
2895
3005
|
namespace: branchNs,
|
|
2896
|
-
readFallbacks:
|
|
3006
|
+
readFallbacks: fallbacks,
|
|
2897
3007
|
scope: "branch"
|
|
2898
3008
|
};
|
|
2899
3009
|
}
|
|
2900
3010
|
return {
|
|
2901
3011
|
namespace: projectNs,
|
|
2902
|
-
readFallbacks: [],
|
|
3012
|
+
readFallbacks: includeRoot ? [""] : [],
|
|
2903
3013
|
scope: "project"
|
|
2904
3014
|
};
|
|
2905
3015
|
}
|
|
2906
|
-
function describeCodingScope(codingContext, config) {
|
|
3016
|
+
function describeCodingScope(codingContext, config, defaultNamespace) {
|
|
2907
3017
|
const projectId = codingContext?.projectId ?? null;
|
|
2908
3018
|
const branch = codingContext?.branch ?? null;
|
|
2909
3019
|
if (!codingContext) {
|
|
@@ -2937,7 +3047,7 @@ function describeCodingScope(codingContext, config) {
|
|
|
2937
3047
|
disabledReason: "empty-project"
|
|
2938
3048
|
};
|
|
2939
3049
|
}
|
|
2940
|
-
const overlay = resolveCodingNamespaceOverlay(codingContext, config);
|
|
3050
|
+
const overlay = resolveCodingNamespaceOverlay(codingContext, config, defaultNamespace);
|
|
2941
3051
|
if (!overlay) {
|
|
2942
3052
|
return {
|
|
2943
3053
|
scope: "none",
|
|
@@ -3058,7 +3168,7 @@ async function raceRecallAbort(promise, signal, message = "recall aborted") {
|
|
|
3058
3168
|
}
|
|
3059
3169
|
var COMPACTION_SIGNAL_MAX_AGE_MS = 60 * 60 * 1e3;
|
|
3060
3170
|
function defaultWorkspaceDir() {
|
|
3061
|
-
return
|
|
3171
|
+
return path6.join(os.homedir(), ".openclaw", "workspace");
|
|
3062
3172
|
}
|
|
3063
3173
|
function sanitizeSessionKeyForFilename(sessionKey) {
|
|
3064
3174
|
const readable = sessionKey.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
@@ -3226,11 +3336,11 @@ function mergeGraphExpandedResults(primary, expanded) {
|
|
|
3226
3336
|
return Array.from(mergedByPath.values());
|
|
3227
3337
|
}
|
|
3228
3338
|
function graphPathRelativeToStorage(storageDir, candidatePath) {
|
|
3229
|
-
const absolutePath =
|
|
3230
|
-
const rel =
|
|
3339
|
+
const absolutePath = path6.isAbsolute(candidatePath) ? candidatePath : path6.resolve(storageDir, candidatePath);
|
|
3340
|
+
const rel = path6.relative(storageDir, absolutePath);
|
|
3231
3341
|
if (!rel || rel === ".") return null;
|
|
3232
3342
|
if (rel.startsWith("..")) return null;
|
|
3233
|
-
return rel.split(
|
|
3343
|
+
return rel.split(path6.sep).join("/");
|
|
3234
3344
|
}
|
|
3235
3345
|
function normalizeGraphActivationScore(score) {
|
|
3236
3346
|
const bounded = Number.isFinite(score) && score > 0 ? score : 0;
|
|
@@ -3372,7 +3482,7 @@ function buildMemoryPathById(allMemsForGraph, storageDir) {
|
|
|
3372
3482
|
for (const mem of allMemsForGraph ?? []) {
|
|
3373
3483
|
const id = mem.frontmatter.id;
|
|
3374
3484
|
if (!id) continue;
|
|
3375
|
-
pathById.set(id,
|
|
3485
|
+
pathById.set(id, path6.relative(storageDir, mem.path));
|
|
3376
3486
|
}
|
|
3377
3487
|
return pathById;
|
|
3378
3488
|
}
|
|
@@ -3380,7 +3490,7 @@ function appendMemoryToGraphContext(options) {
|
|
|
3380
3490
|
if (!Array.isArray(options.allMemsForGraph)) return;
|
|
3381
3491
|
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
3382
3492
|
options.allMemsForGraph.push({
|
|
3383
|
-
path:
|
|
3493
|
+
path: path6.join(options.storageDir, options.memoryRelPath),
|
|
3384
3494
|
content: options.content,
|
|
3385
3495
|
frontmatter: {
|
|
3386
3496
|
id: options.memoryId,
|
|
@@ -3400,16 +3510,16 @@ function resolvePersistedMemoryRelativePath(options) {
|
|
|
3400
3510
|
const persisted = options.pathById.get(options.memoryId);
|
|
3401
3511
|
if (persisted) return persisted;
|
|
3402
3512
|
if (options.category === "correction") {
|
|
3403
|
-
return
|
|
3513
|
+
return path6.join("corrections", `${options.memoryId}.md`);
|
|
3404
3514
|
}
|
|
3405
3515
|
const subtree = options.category === "procedure" ? "procedures" : options.category === "reasoning_trace" ? "reasoning-traces" : "facts";
|
|
3406
3516
|
const idParts = options.memoryId.split("-");
|
|
3407
3517
|
const maybeTimestamp = Number(idParts[1]);
|
|
3408
3518
|
if (Number.isFinite(maybeTimestamp) && maybeTimestamp > 0) {
|
|
3409
3519
|
const day = new Date(maybeTimestamp).toISOString().slice(0, 10);
|
|
3410
|
-
return
|
|
3520
|
+
return path6.join(subtree, day, `${options.memoryId}.md`);
|
|
3411
3521
|
}
|
|
3412
|
-
return
|
|
3522
|
+
return path6.join(subtree, `${options.memoryId}.md`);
|
|
3413
3523
|
}
|
|
3414
3524
|
var Orchestrator = class _Orchestrator {
|
|
3415
3525
|
storage;
|
|
@@ -3501,6 +3611,15 @@ var Orchestrator = class _Orchestrator {
|
|
|
3501
3611
|
* through the same namespace layer).
|
|
3502
3612
|
*/
|
|
3503
3613
|
_codingContextBySession = /* @__PURE__ */ new Map();
|
|
3614
|
+
/**
|
|
3615
|
+
* Per-session peer ID registry (issue #679 PR 3/5).
|
|
3616
|
+
* Set by connectors / hooks via `setPeerIdForSession` so `recallInternal`
|
|
3617
|
+
* can inject the peer's profile into recall context when
|
|
3618
|
+
* `peerProfileRecallEnabled` is true. Cleared when the session ends.
|
|
3619
|
+
* Keyed by sessionKey so concurrent sessions don't clobber each other
|
|
3620
|
+
* (rule 11 — scope globals per plugin ID / session).
|
|
3621
|
+
*/
|
|
3622
|
+
_peerIdBySession = /* @__PURE__ */ new Map();
|
|
3504
3623
|
routingRulesStore = null;
|
|
3505
3624
|
contentHashIndex = null;
|
|
3506
3625
|
artifactSourceStatusCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -3527,6 +3646,13 @@ var Orchestrator = class _Orchestrator {
|
|
|
3527
3646
|
lastTierMigrationRunAtMs = 0;
|
|
3528
3647
|
conversationIndexLastUpdateAtMs = /* @__PURE__ */ new Map();
|
|
3529
3648
|
lastFileHygieneRunAtMs = 0;
|
|
3649
|
+
// Pattern-reinforcement cadence gate (issue #687 PR 2/4). Tracks the
|
|
3650
|
+
// last successful run so `runPatternReinforcement` can short-circuit
|
|
3651
|
+
// when the configured cadence has not elapsed. Keyed by namespace
|
|
3652
|
+
// so MCP-triggered runs in tenant A don't suppress runs in tenant B
|
|
3653
|
+
// (PR #730 review feedback, Codex P2). The default-tenant path
|
|
3654
|
+
// uses the empty-string key.
|
|
3655
|
+
lastPatternReinforcementAtByNs = /* @__PURE__ */ new Map();
|
|
3530
3656
|
lastRecallFailureLogAtMs = 0;
|
|
3531
3657
|
lastRecallFailureAtMs = 0;
|
|
3532
3658
|
suppressedRecallFailures = 0;
|
|
@@ -3654,14 +3780,58 @@ var Orchestrator = class _Orchestrator {
|
|
|
3654
3780
|
applyCodingNamespaceOverlay(sessionKey, baseNamespace) {
|
|
3655
3781
|
if (!this.config.namespacesEnabled) return baseNamespace;
|
|
3656
3782
|
const codingContext = this.getCodingContextForSession(sessionKey);
|
|
3657
|
-
const overlay = resolveCodingNamespaceOverlay(codingContext, this.config.codingMode);
|
|
3783
|
+
const overlay = resolveCodingNamespaceOverlay(codingContext, this.config.codingMode, this.config.defaultNamespace);
|
|
3658
3784
|
if (!overlay) return baseNamespace;
|
|
3659
3785
|
return combineNamespaces(baseNamespace, overlay.namespace);
|
|
3660
3786
|
}
|
|
3787
|
+
/**
|
|
3788
|
+
* Register a peer ID for a session so recall can inject the peer's
|
|
3789
|
+
* profile into context (issue #679 PR 3/5). Pass `null` to clear.
|
|
3790
|
+
*
|
|
3791
|
+
* Connectors and the `before_agent_start` hook call this when the
|
|
3792
|
+
* session's counter-party is known. The ID is validated against
|
|
3793
|
+
* `PEER_ID_PATTERN` before storing.
|
|
3794
|
+
*
|
|
3795
|
+
* Fail-closed (Codex P1 review): an invalid peerId clears any
|
|
3796
|
+
* previously registered mapping for the session rather than silently
|
|
3797
|
+
* keeping stale data. This prevents a malformed metadata update from
|
|
3798
|
+
* mixing one peer's profile context into another session.
|
|
3799
|
+
*
|
|
3800
|
+
* Defensive init (Cursor review + rule 16): `Object.create(
|
|
3801
|
+
* Orchestrator.prototype)` stubs in legacy tests skip class-field
|
|
3802
|
+
* initializers, so `_peerIdBySession` may be undefined. Mirror the
|
|
3803
|
+
* same guard used by `setCodingContextForSession`.
|
|
3804
|
+
*/
|
|
3805
|
+
setPeerIdForSession(sessionKey, peerId) {
|
|
3806
|
+
if (typeof sessionKey !== "string" || sessionKey.length === 0) return;
|
|
3807
|
+
if (!this._peerIdBySession) {
|
|
3808
|
+
this._peerIdBySession = /* @__PURE__ */ new Map();
|
|
3809
|
+
}
|
|
3810
|
+
if (peerId === null) {
|
|
3811
|
+
this._peerIdBySession.delete(sessionKey);
|
|
3812
|
+
return;
|
|
3813
|
+
}
|
|
3814
|
+
if (typeof peerId !== "string" || peerId.length === 0 || peerId.length > 64 || !/^[A-Za-z0-9]+(?:[._-][A-Za-z0-9]+)*$/.test(peerId)) {
|
|
3815
|
+
log.warn(`setPeerIdForSession: invalid peerId \u2014 clearing session mapping`);
|
|
3816
|
+
this._peerIdBySession.delete(sessionKey);
|
|
3817
|
+
return;
|
|
3818
|
+
}
|
|
3819
|
+
this._peerIdBySession.set(sessionKey, peerId);
|
|
3820
|
+
}
|
|
3821
|
+
/**
|
|
3822
|
+
* Return the peer ID registered for a session, or `null` when none
|
|
3823
|
+
* is set. Used by `recallInternal` to inject the peer profile section.
|
|
3824
|
+
* Defensive `_peerIdBySession` lookup — legacy orchestrator-flush tests
|
|
3825
|
+
* use `Object.create(Orchestrator.prototype)` which skips class-field
|
|
3826
|
+
* initializers, so the Map may be undefined on stubs.
|
|
3827
|
+
*/
|
|
3828
|
+
getPeerIdForSession(sessionKey) {
|
|
3829
|
+
if (typeof sessionKey !== "string" || sessionKey.length === 0) return null;
|
|
3830
|
+
return this._peerIdBySession?.get(sessionKey) ?? null;
|
|
3831
|
+
}
|
|
3661
3832
|
/**
|
|
3662
3833
|
* Read-side overlay: returns the list of namespaces a session should read
|
|
3663
|
-
* from, including any read fallbacks (branch → project
|
|
3664
|
-
* PR 3; PR 2 returns an empty fallbacks list).
|
|
3834
|
+
* from, including any read fallbacks (branch → project, global root).
|
|
3665
3835
|
*
|
|
3666
3836
|
* Returns `null` when:
|
|
3667
3837
|
* - `namespacesEnabled` is false (overlay would create false isolation)
|
|
@@ -3678,7 +3848,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
3678
3848
|
applyCodingRecallOverlay(sessionKey) {
|
|
3679
3849
|
if (!this.config.namespacesEnabled) return null;
|
|
3680
3850
|
const codingContext = this.getCodingContextForSession(sessionKey);
|
|
3681
|
-
const overlay = resolveCodingNamespaceOverlay(codingContext, this.config.codingMode);
|
|
3851
|
+
const overlay = resolveCodingNamespaceOverlay(codingContext, this.config.codingMode, this.config.defaultNamespace);
|
|
3682
3852
|
if (!overlay) return null;
|
|
3683
3853
|
return { namespace: overlay.namespace, readFallbacks: overlay.readFallbacks };
|
|
3684
3854
|
}
|
|
@@ -3761,11 +3931,14 @@ var Orchestrator = class _Orchestrator {
|
|
|
3761
3931
|
if (this.config.namespacesEnabled) return true;
|
|
3762
3932
|
return this.qmd.isAvailable();
|
|
3763
3933
|
}
|
|
3934
|
+
invalidateLiveContentHashIndex() {
|
|
3935
|
+
this.contentHashIndex = null;
|
|
3936
|
+
}
|
|
3764
3937
|
constructor(config) {
|
|
3765
3938
|
this.config = config;
|
|
3766
3939
|
this.profiler = new ProfilingCollector({
|
|
3767
3940
|
enabled: config.profilingEnabled,
|
|
3768
|
-
storageDir: config.profilingStorageDir ||
|
|
3941
|
+
storageDir: config.profilingStorageDir || path6.join(config.memoryDir, "profiling"),
|
|
3769
3942
|
maxTraces: config.profilingMaxTraces
|
|
3770
3943
|
});
|
|
3771
3944
|
this.storageRouter = new NamespaceStorageRouter(config);
|
|
@@ -3780,6 +3953,14 @@ var Orchestrator = class _Orchestrator {
|
|
|
3780
3953
|
maxVersionsPerPage: config.versioningMaxPerPage,
|
|
3781
3954
|
sidecarDir: config.versioningSidecarDir
|
|
3782
3955
|
});
|
|
3956
|
+
if (config.secureStoreEnabled) {
|
|
3957
|
+
this.storage.setSecureStoreRequired(true);
|
|
3958
|
+
const storeId = secureStoreDir(config.memoryDir);
|
|
3959
|
+
const existingKey = keyring_exports.getKey(storeId);
|
|
3960
|
+
if (existingKey) {
|
|
3961
|
+
this.storage.setSecureStoreKey(existingKey, config.secureStoreEncryptOnWrite);
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3783
3964
|
this.qmd = createSearchBackend(config);
|
|
3784
3965
|
const conversationIndexRuntime = createConversationIndexRuntime(config, {
|
|
3785
3966
|
getQmd: () => this.conversationQmd,
|
|
@@ -3789,10 +3970,10 @@ var Orchestrator = class _Orchestrator {
|
|
|
3789
3970
|
this.conversationFaiss = conversationIndexRuntime.faiss;
|
|
3790
3971
|
this.conversationIndexBackend = conversationIndexRuntime.backend;
|
|
3791
3972
|
this.sharedContext = config.sharedContextEnabled ? new SharedContextManager(config) : void 0;
|
|
3792
|
-
this.compounding = config.compoundingEnabled ? new CompoundingEngine(config) : void 0;
|
|
3973
|
+
this.compounding = config.compoundingEnabled ? new CompoundingEngine(config, this.storage) : void 0;
|
|
3793
3974
|
this.buffer = new SmartBuffer(config, this.storage);
|
|
3794
3975
|
this.transcript = new TranscriptManager(config);
|
|
3795
|
-
this.conversationIndexDir =
|
|
3976
|
+
this.conversationIndexDir = path6.join(
|
|
3796
3977
|
config.memoryDir,
|
|
3797
3978
|
"conversation-index",
|
|
3798
3979
|
"chunks"
|
|
@@ -3846,7 +4027,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
3846
4027
|
this.modelRegistry
|
|
3847
4028
|
);
|
|
3848
4029
|
this.threading = new ThreadingManager(
|
|
3849
|
-
|
|
4030
|
+
path6.join(config.memoryDir, "threads"),
|
|
3850
4031
|
config.threadingGapMinutes
|
|
3851
4032
|
);
|
|
3852
4033
|
this.tmtBuilder = new TmtBuilder(config.memoryDir, {
|
|
@@ -4091,8 +4272,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
4091
4272
|
promotionByOutcomeEnabled: this.config.promotionByOutcomeEnabled
|
|
4092
4273
|
});
|
|
4093
4274
|
if (this.config.factDeduplicationEnabled) {
|
|
4094
|
-
|
|
4095
|
-
this.contentHashIndex = new ContentHashIndex(stateDir);
|
|
4275
|
+
this.contentHashIndex = this.storage.createContentHashIndex();
|
|
4096
4276
|
await this.contentHashIndex.load();
|
|
4097
4277
|
log.info(
|
|
4098
4278
|
`content-hash dedup: loaded ${this.contentHashIndex.size} hashes`
|
|
@@ -4120,7 +4300,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
4120
4300
|
const files = await readdir3(wsDir).catch(() => []);
|
|
4121
4301
|
for (const f of files) {
|
|
4122
4302
|
if (!f.startsWith(".compaction-reset-signal-")) continue;
|
|
4123
|
-
const fp =
|
|
4303
|
+
const fp = path6.join(wsDir, f);
|
|
4124
4304
|
const s = await stat3(fp).catch(() => null);
|
|
4125
4305
|
if (s && Date.now() - s.mtimeMs >= COMPACTION_SIGNAL_MAX_AGE_MS) {
|
|
4126
4306
|
await unlink2(fp).catch(() => {
|
|
@@ -4328,6 +4508,43 @@ var Orchestrator = class _Orchestrator {
|
|
|
4328
4508
|
log.debug(`contradiction scan cron auto-register failed (non-fatal): ${err}`);
|
|
4329
4509
|
}
|
|
4330
4510
|
}
|
|
4511
|
+
if (this.config.patternReinforcementEnabled) {
|
|
4512
|
+
try {
|
|
4513
|
+
await this.autoRegisterPatternReinforcementCron();
|
|
4514
|
+
} catch (err) {
|
|
4515
|
+
log.debug(`pattern reinforcement cron auto-register failed (non-fatal): ${err}`);
|
|
4516
|
+
}
|
|
4517
|
+
}
|
|
4518
|
+
if (this.config.graphEdgeDecayEnabled) {
|
|
4519
|
+
try {
|
|
4520
|
+
await this.autoRegisterGraphEdgeDecayCron();
|
|
4521
|
+
} catch (err) {
|
|
4522
|
+
log.debug(`graph edge decay cron auto-register failed (non-fatal): ${err}`);
|
|
4523
|
+
}
|
|
4524
|
+
}
|
|
4525
|
+
if (signal.aborted) return;
|
|
4526
|
+
if (this.config.lifecyclePolicyEnabled && this.config.qmdTierMigrationEnabled) {
|
|
4527
|
+
try {
|
|
4528
|
+
const { runFirstStartMigration } = await import("./first-start-migration-4MHQEOSD.js");
|
|
4529
|
+
const result = await runFirstStartMigration({
|
|
4530
|
+
storage: this.storage,
|
|
4531
|
+
config: this.config,
|
|
4532
|
+
qmd: this.qmd,
|
|
4533
|
+
hotCollection: this.config.qmdCollection,
|
|
4534
|
+
coldCollection: this.config.qmdColdCollection,
|
|
4535
|
+
signal
|
|
4536
|
+
});
|
|
4537
|
+
if (!result.skipped) {
|
|
4538
|
+
log.info(
|
|
4539
|
+
`first-start lifecycle migration: demoted ${result.demotedCount} of ${result.candidateCount} candidates (cap=${result.cappedAt})`
|
|
4540
|
+
);
|
|
4541
|
+
} else {
|
|
4542
|
+
log.debug(`first-start lifecycle migration skipped: ${result.skipReason}`);
|
|
4543
|
+
}
|
|
4544
|
+
} catch (err) {
|
|
4545
|
+
log.warn(`first-start lifecycle migration failed (non-fatal): ${err}`);
|
|
4546
|
+
}
|
|
4547
|
+
}
|
|
4331
4548
|
log.info("orchestrator initialized (full \u2014 deferred steps complete)");
|
|
4332
4549
|
}
|
|
4333
4550
|
/**
|
|
@@ -4435,7 +4652,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
4435
4652
|
*/
|
|
4436
4653
|
async autoRegisterDaySummaryCron() {
|
|
4437
4654
|
const home = resolveHomeDir();
|
|
4438
|
-
const jobsPath =
|
|
4655
|
+
const jobsPath = path6.join(home, ".openclaw", "cron", "jobs.json");
|
|
4439
4656
|
try {
|
|
4440
4657
|
if (!existsSync2(jobsPath)) {
|
|
4441
4658
|
log.debug(
|
|
@@ -4458,8 +4675,8 @@ var Orchestrator = class _Orchestrator {
|
|
|
4458
4675
|
}
|
|
4459
4676
|
}
|
|
4460
4677
|
async autoRegisterNightlyGovernanceCron() {
|
|
4461
|
-
const home =
|
|
4462
|
-
const jobsPath =
|
|
4678
|
+
const home = resolveHomeDir();
|
|
4679
|
+
const jobsPath = path6.join(home, ".openclaw", "cron", "jobs.json");
|
|
4463
4680
|
try {
|
|
4464
4681
|
if (!existsSync2(jobsPath)) {
|
|
4465
4682
|
log.debug("nightly governance cron: jobs.json not found, skipping auto-register");
|
|
@@ -4481,7 +4698,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
4481
4698
|
}
|
|
4482
4699
|
async autoRegisterProceduralMiningCron() {
|
|
4483
4700
|
const home = resolveHomeDir();
|
|
4484
|
-
const jobsPath =
|
|
4701
|
+
const jobsPath = path6.join(home, ".openclaw", "cron", "jobs.json");
|
|
4485
4702
|
try {
|
|
4486
4703
|
if (!existsSync2(jobsPath)) {
|
|
4487
4704
|
log.debug("procedural mining cron: jobs.json not found, skipping auto-register");
|
|
@@ -4501,7 +4718,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
4501
4718
|
}
|
|
4502
4719
|
async autoRegisterContradictionScanCron() {
|
|
4503
4720
|
const home = resolveHomeDir();
|
|
4504
|
-
const jobsPath =
|
|
4721
|
+
const jobsPath = path6.join(home, ".openclaw", "cron", "jobs.json");
|
|
4505
4722
|
try {
|
|
4506
4723
|
if (!existsSync2(jobsPath)) {
|
|
4507
4724
|
log.debug("contradiction scan cron: jobs.json not found, skipping auto-register");
|
|
@@ -4519,6 +4736,109 @@ var Orchestrator = class _Orchestrator {
|
|
|
4519
4736
|
log.debug(`contradiction scan cron auto-register error: ${err}`);
|
|
4520
4737
|
}
|
|
4521
4738
|
}
|
|
4739
|
+
async autoRegisterPatternReinforcementCron() {
|
|
4740
|
+
const home = resolveHomeDir();
|
|
4741
|
+
const jobsPath = path6.join(home, ".openclaw", "cron", "jobs.json");
|
|
4742
|
+
try {
|
|
4743
|
+
if (!existsSync2(jobsPath)) {
|
|
4744
|
+
log.debug("pattern reinforcement cron: jobs.json not found, skipping auto-register");
|
|
4745
|
+
return;
|
|
4746
|
+
}
|
|
4747
|
+
const created = await ensurePatternReinforcementCron(jobsPath, {
|
|
4748
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
4749
|
+
});
|
|
4750
|
+
if (created.created) {
|
|
4751
|
+
log.info(`pattern reinforcement cron auto-registered (${created.jobId})`);
|
|
4752
|
+
} else {
|
|
4753
|
+
log.debug("pattern reinforcement cron already exists, skipping auto-register");
|
|
4754
|
+
}
|
|
4755
|
+
} catch (err) {
|
|
4756
|
+
log.debug(`pattern reinforcement cron auto-register error: ${err}`);
|
|
4757
|
+
}
|
|
4758
|
+
}
|
|
4759
|
+
/**
|
|
4760
|
+
* Run the pattern-reinforcement maintenance job (issue #687 PR 2/4).
|
|
4761
|
+
*
|
|
4762
|
+
* Cadence-gated on `patternReinforcementCadenceMs` so every caller
|
|
4763
|
+
* (orchestrator cron path, MCP tool, CLI) shares a single floor —
|
|
4764
|
+
* none can call this on a hot loop and burn the corpus. When the
|
|
4765
|
+
* feature is disabled or the cadence has not elapsed, returns a
|
|
4766
|
+
* synthetic "skipped" result rather than throwing.
|
|
4767
|
+
*
|
|
4768
|
+
* Cadence tracking is per-namespace so a tenant-scoped MCP run in
|
|
4769
|
+
* one namespace does not silence a cron run in another (PR #730
|
|
4770
|
+
* review feedback, Codex P2). Pass `force: true` for ad-hoc
|
|
4771
|
+
* operator runs that must bypass the cadence floor — mirrors the
|
|
4772
|
+
* pattern used by other maintenance MCP tools.
|
|
4773
|
+
*
|
|
4774
|
+
* `force` deliberately does NOT bypass the master
|
|
4775
|
+
* `patternReinforcementEnabled` flag (PR #730 review feedback,
|
|
4776
|
+
* Cursor Medium). Operators who have explicitly disabled the
|
|
4777
|
+
* feature must not have their corpus mutated by an MCP tool call —
|
|
4778
|
+
* the only way to run the job is to enable the feature in config.
|
|
4779
|
+
*/
|
|
4780
|
+
async runPatternReinforcement(options = {}) {
|
|
4781
|
+
const cadenceKey = options.namespace ?? "";
|
|
4782
|
+
if (!this.config.patternReinforcementEnabled) {
|
|
4783
|
+
return { ran: false, skippedReason: "disabled", namespace: cadenceKey };
|
|
4784
|
+
}
|
|
4785
|
+
const cadence = this.config.patternReinforcementCadenceMs;
|
|
4786
|
+
const lastAt = this.lastPatternReinforcementAtByNs.get(cadenceKey);
|
|
4787
|
+
if (!options.force && cadence > 0 && lastAt !== void 0 && Date.now() - lastAt < cadence) {
|
|
4788
|
+
return { ran: false, skippedReason: "cadence", namespace: cadenceKey };
|
|
4789
|
+
}
|
|
4790
|
+
const storage = options.namespace ? await this.getStorage(options.namespace) : this.storage;
|
|
4791
|
+
const result = await runPatternReinforcement(storage, {
|
|
4792
|
+
categories: this.config.patternReinforcementCategories,
|
|
4793
|
+
minCount: this.config.patternReinforcementMinCount
|
|
4794
|
+
});
|
|
4795
|
+
this.lastPatternReinforcementAtByNs.set(cadenceKey, Date.now());
|
|
4796
|
+
log.debug(
|
|
4797
|
+
`pattern reinforcement [ns=${cadenceKey || "(default)"}]: clusters=${result.clustersFound} canonicalsUpdated=${result.canonicalsUpdated} duplicatesSuperseded=${result.duplicatesSuperseded}`
|
|
4798
|
+
);
|
|
4799
|
+
return { ran: true, result, namespace: cadenceKey };
|
|
4800
|
+
}
|
|
4801
|
+
async autoRegisterGraphEdgeDecayCron() {
|
|
4802
|
+
const home = resolveHomeDir();
|
|
4803
|
+
const jobsPath = path6.join(home, ".openclaw", "cron", "jobs.json");
|
|
4804
|
+
try {
|
|
4805
|
+
if (!existsSync2(jobsPath)) {
|
|
4806
|
+
log.debug("graph edge decay cron: jobs.json not found, skipping auto-register");
|
|
4807
|
+
return;
|
|
4808
|
+
}
|
|
4809
|
+
const scheduleExpr = graphEdgeDecayCadenceToCronExpr(this.config.graphEdgeDecayCadenceMs);
|
|
4810
|
+
const created = await ensureGraphEdgeDecayCron(jobsPath, {
|
|
4811
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
4812
|
+
scheduleExpr
|
|
4813
|
+
});
|
|
4814
|
+
if (created.created) {
|
|
4815
|
+
log.info(`graph edge decay cron auto-registered (${created.jobId}, ${scheduleExpr})`);
|
|
4816
|
+
} else {
|
|
4817
|
+
log.debug("graph edge decay cron already exists, skipping auto-register");
|
|
4818
|
+
}
|
|
4819
|
+
} catch (err) {
|
|
4820
|
+
log.debug(`graph edge decay cron auto-register error: ${err}`);
|
|
4821
|
+
}
|
|
4822
|
+
}
|
|
4823
|
+
async runLiveConnectors(options = {}) {
|
|
4824
|
+
return runLiveConnectorsOnce({
|
|
4825
|
+
memoryDir: this.config.memoryDir,
|
|
4826
|
+
connectors: this.config.connectors,
|
|
4827
|
+
force: options.force === true,
|
|
4828
|
+
abortSignal: options.abortSignal,
|
|
4829
|
+
ingestDocuments: async (docs) => {
|
|
4830
|
+
const fetchedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
4831
|
+
const turns = docs.map((doc) => ({
|
|
4832
|
+
role: "assistant",
|
|
4833
|
+
content: doc.title ? `# ${doc.title}
|
|
4834
|
+
|
|
4835
|
+
${doc.content}` : doc.content,
|
|
4836
|
+
timestamp: fetchedAt
|
|
4837
|
+
}));
|
|
4838
|
+
await this.ingestBulkImportBatch(turns);
|
|
4839
|
+
}
|
|
4840
|
+
});
|
|
4841
|
+
}
|
|
4522
4842
|
async applyBehaviorRuntimePolicy(state) {
|
|
4523
4843
|
const result = await this.policyRuntime.applyFromBehaviorState(state);
|
|
4524
4844
|
this.runtimePolicyValues = await this.policyRuntime.loadRuntimeValues();
|
|
@@ -4537,15 +4857,15 @@ var Orchestrator = class _Orchestrator {
|
|
|
4537
4857
|
this.lastFileHygieneRunAtMs = now;
|
|
4538
4858
|
if (hygiene.rotateEnabled) {
|
|
4539
4859
|
for (const rel of hygiene.rotatePaths) {
|
|
4540
|
-
const abs =
|
|
4860
|
+
const abs = path6.isAbsolute(rel) ? rel : path6.join(this.config.workspaceDir, rel);
|
|
4541
4861
|
try {
|
|
4542
4862
|
const raw = await readFile4(abs, "utf-8");
|
|
4543
4863
|
if (raw.length > hygiene.rotateMaxBytes) {
|
|
4544
|
-
const archiveDir =
|
|
4864
|
+
const archiveDir = path6.join(
|
|
4545
4865
|
this.config.workspaceDir,
|
|
4546
4866
|
hygiene.archiveDir
|
|
4547
4867
|
);
|
|
4548
|
-
const base =
|
|
4868
|
+
const base = path6.basename(abs);
|
|
4549
4869
|
const prefix = base.toUpperCase().replace(/\.MD$/i, "").replace(/[^A-Z0-9]+/g, "-") || "FILE";
|
|
4550
4870
|
const { newContent } = await rotateMarkdownFileToArchive({
|
|
4551
4871
|
filePath: abs,
|
|
@@ -4570,8 +4890,8 @@ var Orchestrator = class _Orchestrator {
|
|
|
4570
4890
|
log.warn(w.message);
|
|
4571
4891
|
}
|
|
4572
4892
|
if (hygiene.warningsLogEnabled && warnings.length > 0) {
|
|
4573
|
-
const fp =
|
|
4574
|
-
await mkdir5(
|
|
4893
|
+
const fp = path6.join(this.config.memoryDir, hygiene.warningsLogPath);
|
|
4894
|
+
await mkdir5(path6.dirname(fp), { recursive: true });
|
|
4575
4895
|
const stamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
4576
4896
|
const block = `
|
|
4577
4897
|
|
|
@@ -4608,7 +4928,28 @@ var Orchestrator = class _Orchestrator {
|
|
|
4608
4928
|
async runSemanticConsolidationNow(options) {
|
|
4609
4929
|
return this.runSemanticConsolidation({ ...options, force: true });
|
|
4610
4930
|
}
|
|
4931
|
+
async runDeepSleepGovernanceNow(options) {
|
|
4932
|
+
const targetStorage = options?.storage ?? this.storage;
|
|
4933
|
+
const { runMemoryGovernance } = await import("./memory-governance-KG52RITE.js");
|
|
4934
|
+
const { summarizeGovernanceResultForDreams } = await import("./dreams-ledger-LR2NBAZE.js");
|
|
4935
|
+
const govResult = await runMemoryGovernance({
|
|
4936
|
+
memoryDir: targetStorage.dir,
|
|
4937
|
+
mode: options?.dryRun === true ? "shadow" : "apply"
|
|
4938
|
+
});
|
|
4939
|
+
if (options?.dryRun !== true) {
|
|
4940
|
+
try {
|
|
4941
|
+
await this.processEntitySynthesisQueue(
|
|
4942
|
+
this.namespaceFromStorageDir(targetStorage.dir),
|
|
4943
|
+
5
|
|
4944
|
+
);
|
|
4945
|
+
} catch (error) {
|
|
4946
|
+
log.debug(`deep-sleep governance: entity synthesis refresh failed after apply: ${error}`);
|
|
4947
|
+
}
|
|
4948
|
+
}
|
|
4949
|
+
return summarizeGovernanceResultForDreams(govResult, options?.dryRun === true);
|
|
4950
|
+
}
|
|
4611
4951
|
async runSemanticConsolidation(options) {
|
|
4952
|
+
const targetStorage = options?.storage ?? this.storage;
|
|
4612
4953
|
const result = {
|
|
4613
4954
|
clustersFound: 0,
|
|
4614
4955
|
memoriesConsolidated: 0,
|
|
@@ -4621,7 +4962,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
4621
4962
|
return result;
|
|
4622
4963
|
}
|
|
4623
4964
|
log.info("[semantic-consolidation] starting run");
|
|
4624
|
-
const allMemories = await
|
|
4965
|
+
const allMemories = await targetStorage.readAllMemories();
|
|
4625
4966
|
if (allMemories.length < 10) {
|
|
4626
4967
|
log.debug("[semantic-consolidation] too few memories, skipping");
|
|
4627
4968
|
return result;
|
|
@@ -4724,10 +5065,10 @@ var Orchestrator = class _Orchestrator {
|
|
|
4724
5065
|
const derivedFromEntries = [];
|
|
4725
5066
|
for (const m of cluster.memories) {
|
|
4726
5067
|
if (!m.path) continue;
|
|
4727
|
-
const entry = await
|
|
5068
|
+
const entry = await targetStorage.snapshotForProvenance(m.path);
|
|
4728
5069
|
if (entry) derivedFromEntries.push(entry);
|
|
4729
5070
|
}
|
|
4730
|
-
const canonicalId = await
|
|
5071
|
+
const canonicalId = await targetStorage.writeMemory(
|
|
4731
5072
|
newest.frontmatter.category,
|
|
4732
5073
|
canonicalContent,
|
|
4733
5074
|
{
|
|
@@ -4746,7 +5087,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
4746
5087
|
);
|
|
4747
5088
|
result.memoriesConsolidated++;
|
|
4748
5089
|
for (const m of cluster.memories) {
|
|
4749
|
-
const archiveResult = await
|
|
5090
|
+
const archiveResult = await targetStorage.archiveMemory(m, {
|
|
4750
5091
|
actor: "semantic-consolidation",
|
|
4751
5092
|
reasonCode: "semantic-consolidation",
|
|
4752
5093
|
relatedMemoryIds: [canonicalId]
|
|
@@ -4765,7 +5106,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
4765
5106
|
await this.embeddingFallback.removeFromIndex(m.frontmatter.id);
|
|
4766
5107
|
if (this.config.queryAwareIndexingEnabled && m.path && m.frontmatter?.created) {
|
|
4767
5108
|
deindexMemory(
|
|
4768
|
-
|
|
5109
|
+
targetStorage.dir,
|
|
4769
5110
|
m.path,
|
|
4770
5111
|
m.frontmatter.created,
|
|
4771
5112
|
m.frontmatter.tags ?? []
|
|
@@ -4797,13 +5138,39 @@ var Orchestrator = class _Orchestrator {
|
|
|
4797
5138
|
try {
|
|
4798
5139
|
await materializeAfterSemanticConsolidation({
|
|
4799
5140
|
config: this.config,
|
|
4800
|
-
memoryDir:
|
|
5141
|
+
memoryDir: targetStorage.dir
|
|
4801
5142
|
});
|
|
4802
5143
|
} catch (err) {
|
|
4803
5144
|
log.warn(
|
|
4804
5145
|
`[semantic-consolidation] Codex materialize post-hook failed (non-fatal): ${err instanceof Error ? err.message : String(err)}`
|
|
4805
5146
|
);
|
|
4806
5147
|
}
|
|
5148
|
+
if (this.config.peerProfileReasonerEnabled) {
|
|
5149
|
+
try {
|
|
5150
|
+
const { runPeerProfileReasoner } = await import("./peers-6OSQ3NK6.js");
|
|
5151
|
+
const llm2 = new FallbackLlmClient2(this.config.gatewayConfig);
|
|
5152
|
+
const peerResult = await runPeerProfileReasoner({
|
|
5153
|
+
memoryDir: targetStorage.dir,
|
|
5154
|
+
enabled: true,
|
|
5155
|
+
llm: llm2,
|
|
5156
|
+
model: this.config.peerProfileReasonerModel,
|
|
5157
|
+
minInteractions: this.config.peerProfileReasonerMinInteractions,
|
|
5158
|
+
maxFieldsPerRun: this.config.peerProfileReasonerMaxFieldsPerRun,
|
|
5159
|
+
log: {
|
|
5160
|
+
debug: (msg) => log.debug(msg),
|
|
5161
|
+
info: (msg) => log.info(msg),
|
|
5162
|
+
warn: (msg) => log.warn(msg)
|
|
5163
|
+
}
|
|
5164
|
+
});
|
|
5165
|
+
log.info(
|
|
5166
|
+
`[peer-profile-reasoner] complete: peers=${peerResult.peersConsidered}, processed=${peerResult.peersProcessed}, fields=${peerResult.fieldsApplied}`
|
|
5167
|
+
);
|
|
5168
|
+
} catch (err) {
|
|
5169
|
+
log.warn(
|
|
5170
|
+
`[peer-profile-reasoner] post-consolidation hook failed (non-fatal): ${err instanceof Error ? err.message : String(err)}`
|
|
5171
|
+
);
|
|
5172
|
+
}
|
|
5173
|
+
}
|
|
4807
5174
|
return result;
|
|
4808
5175
|
}
|
|
4809
5176
|
async waitForExtractionIdle(timeoutMs = 6e4) {
|
|
@@ -4983,16 +5350,16 @@ ${evidenceText}`
|
|
|
4983
5350
|
const datesToScan = [yesterday, utcToday].filter(
|
|
4984
5351
|
(v, i, a) => a.indexOf(v) === i
|
|
4985
5352
|
);
|
|
4986
|
-
const factsBaseDir =
|
|
5353
|
+
const factsBaseDir = path6.join(storage.dir, "facts");
|
|
4987
5354
|
const MAX_CHARS = 1e5;
|
|
4988
5355
|
const facts = [];
|
|
4989
5356
|
for (const date of datesToScan) {
|
|
4990
|
-
const factsDir =
|
|
5357
|
+
const factsDir = path6.join(factsBaseDir, date);
|
|
4991
5358
|
try {
|
|
4992
5359
|
const entries = await readdir3(factsDir, { withFileTypes: true });
|
|
4993
5360
|
for (const entry of entries) {
|
|
4994
5361
|
if (!entry.name.endsWith(".md")) continue;
|
|
4995
|
-
const fullPath =
|
|
5362
|
+
const fullPath = path6.join(factsDir, entry.name);
|
|
4996
5363
|
try {
|
|
4997
5364
|
const raw = await readFile4(fullPath, "utf-8");
|
|
4998
5365
|
const fmMatch = raw.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
@@ -5008,7 +5375,7 @@ ${evidenceText}`
|
|
|
5008
5375
|
facts.push({
|
|
5009
5376
|
path: fullPath,
|
|
5010
5377
|
frontmatter: {
|
|
5011
|
-
id: fm.id ||
|
|
5378
|
+
id: fm.id || path6.basename(entry.name, ".md"),
|
|
5012
5379
|
category: fm.category || "fact",
|
|
5013
5380
|
created: fm.created || "unknown",
|
|
5014
5381
|
updated: fm.updated || fm.created || "unknown",
|
|
@@ -5029,13 +5396,13 @@ ${evidenceText}`
|
|
|
5029
5396
|
(a, b) => a.frontmatter.created < b.frontmatter.created ? -1 : 1
|
|
5030
5397
|
);
|
|
5031
5398
|
const hourlySummaries = [];
|
|
5032
|
-
const hourlyBaseDir =
|
|
5399
|
+
const hourlyBaseDir = path6.join(storage.dir, "summaries", "hourly");
|
|
5033
5400
|
try {
|
|
5034
5401
|
const sessionKeys = await readdir3(hourlyBaseDir, { withFileTypes: true });
|
|
5035
5402
|
for (const sk of sessionKeys) {
|
|
5036
5403
|
if (!sk.isDirectory()) continue;
|
|
5037
5404
|
for (const date of datesToScan) {
|
|
5038
|
-
const summaryFile =
|
|
5405
|
+
const summaryFile = path6.join(hourlyBaseDir, sk.name, `${date}.md`);
|
|
5039
5406
|
try {
|
|
5040
5407
|
const raw = await readFile4(summaryFile, "utf-8");
|
|
5041
5408
|
if (raw.trim().length > 0) {
|
|
@@ -5133,7 +5500,7 @@ ${evidenceText}`
|
|
|
5133
5500
|
}
|
|
5134
5501
|
async getLastGraphRecallSnapshot(namespace) {
|
|
5135
5502
|
const storage = await this.getStorage(namespace);
|
|
5136
|
-
const snapshotPath =
|
|
5503
|
+
const snapshotPath = path6.join(
|
|
5137
5504
|
storage.dir,
|
|
5138
5505
|
"state",
|
|
5139
5506
|
"last_graph_recall.json"
|
|
@@ -5172,7 +5539,7 @@ ${evidenceText}`
|
|
|
5172
5539
|
}
|
|
5173
5540
|
async getLastIntentSnapshot(namespace) {
|
|
5174
5541
|
const storage = await this.getStorage(namespace);
|
|
5175
|
-
const snapshotPath =
|
|
5542
|
+
const snapshotPath = path6.join(storage.dir, "state", "last_intent.json");
|
|
5176
5543
|
try {
|
|
5177
5544
|
const raw = await readFile4(snapshotPath, "utf-8");
|
|
5178
5545
|
const parsed = JSON.parse(raw);
|
|
@@ -5205,7 +5572,7 @@ ${evidenceText}`
|
|
|
5205
5572
|
}
|
|
5206
5573
|
async getLastQmdRecallSnapshot(namespace) {
|
|
5207
5574
|
const storage = await this.getStorage(namespace);
|
|
5208
|
-
const snapshotPath =
|
|
5575
|
+
const snapshotPath = path6.join(
|
|
5209
5576
|
storage.dir,
|
|
5210
5577
|
"state",
|
|
5211
5578
|
"last_qmd_recall.json"
|
|
@@ -5266,9 +5633,10 @@ ${evidenceText}`
|
|
|
5266
5633
|
`Seed paths (${snapshot.seedCount}):`,
|
|
5267
5634
|
...snapshot.seeds.map((p) => `- ${p}`),
|
|
5268
5635
|
`Expanded paths (${snapshot.expandedCount}, showing ${expanded.length}):`,
|
|
5269
|
-
...expanded.map(
|
|
5270
|
-
|
|
5271
|
-
|
|
5636
|
+
...expanded.map((e) => {
|
|
5637
|
+
const confLabel = typeof e.edgeConfidence === "number" && Number.isFinite(e.edgeConfidence) ? e.edgeConfidence.toFixed(2) : "n/a";
|
|
5638
|
+
return `- ${e.path} (score=${e.score.toFixed(3)}, ns=${e.namespace}, seed=${e.seed || "unknown"}, hop=${e.hopDepth}, w=${e.decayedWeight.toFixed(3)}, type=${e.graphType}, conf=${confLabel})`;
|
|
5639
|
+
}),
|
|
5272
5640
|
`Final ranked results (${snapshot.finalResults?.length ?? 0}, showing ${finalResults.length}):`,
|
|
5273
5641
|
...finalResults.map(
|
|
5274
5642
|
(entry) => `- ${entry.path} (score=${entry.score.toFixed(3)}, sources=${entry.sourceLabels.join(",") || "baseline"})`
|
|
@@ -5357,7 +5725,7 @@ ${r.snippet.trim()}
|
|
|
5357
5725
|
const entries = await readdir3(dir, { withFileTypes: true });
|
|
5358
5726
|
let total = 0;
|
|
5359
5727
|
for (const entry of entries) {
|
|
5360
|
-
const fullPath =
|
|
5728
|
+
const fullPath = path6.join(dir, entry.name);
|
|
5361
5729
|
if (entry.isDirectory()) {
|
|
5362
5730
|
total += await this.countConversationChunkDocs(fullPath);
|
|
5363
5731
|
continue;
|
|
@@ -5612,6 +5980,11 @@ ${r.snippet.trim()}
|
|
|
5612
5980
|
log.warn("recall: init gate timed out \u2014 proceeding without full init");
|
|
5613
5981
|
}
|
|
5614
5982
|
}
|
|
5983
|
+
if (this.config.secureStoreEnabled && !this.storage.isSecureStoreUnlocked()) {
|
|
5984
|
+
const lockedMsg = "[secure-store locked] Memory store is encrypted and locked. Run `remnic secure-store unlock` then restart the daemon to decrypt.";
|
|
5985
|
+
log.warn("recall blocked: secure-store is locked");
|
|
5986
|
+
return lockedMsg;
|
|
5987
|
+
}
|
|
5615
5988
|
try {
|
|
5616
5989
|
const recallPromise = this.recallInternal(prompt, sessionKey, {
|
|
5617
5990
|
...options,
|
|
@@ -6234,17 +6607,18 @@ ${r.snippet.trim()}
|
|
|
6234
6607
|
0
|
|
6235
6608
|
);
|
|
6236
6609
|
seedPaths.push(
|
|
6237
|
-
...seedRelativePaths.map((rel) =>
|
|
6610
|
+
...seedRelativePaths.map((rel) => path6.join(storage.dir, rel))
|
|
6238
6611
|
);
|
|
6239
6612
|
const seedSet = new Set(seedRelativePaths);
|
|
6240
6613
|
const expanded = await this.graphIndexFor(storage).spreadingActivation(
|
|
6241
6614
|
seedRelativePaths,
|
|
6242
|
-
this.config.maxGraphTraversalSteps
|
|
6615
|
+
this.config.maxGraphTraversalSteps,
|
|
6616
|
+
options.includeLowConfidence === true ? { includeLowConfidence: true } : void 0
|
|
6243
6617
|
);
|
|
6244
6618
|
if (expanded.length === 0) continue;
|
|
6245
6619
|
for (const candidate of expanded.slice(0, perNamespaceExpandedCap)) {
|
|
6246
6620
|
if (seedSet.has(candidate.path)) continue;
|
|
6247
|
-
const memoryPath =
|
|
6621
|
+
const memoryPath = path6.resolve(storage.dir, candidate.path);
|
|
6248
6622
|
const memory = await storage.readMemoryByPath(memoryPath);
|
|
6249
6623
|
if (!memory) continue;
|
|
6250
6624
|
if (isArtifactMemoryPath(memory.path)) continue;
|
|
@@ -6268,10 +6642,15 @@ ${r.snippet.trim()}
|
|
|
6268
6642
|
path: memory.path,
|
|
6269
6643
|
score,
|
|
6270
6644
|
namespace,
|
|
6271
|
-
seed:
|
|
6645
|
+
seed: path6.resolve(storage.dir, candidate.seed),
|
|
6272
6646
|
hopDepth: candidate.hopDepth,
|
|
6273
6647
|
decayedWeight: candidate.decayedWeight,
|
|
6274
|
-
graphType: candidate.graphType
|
|
6648
|
+
graphType: candidate.graphType,
|
|
6649
|
+
// Issue #681 PR 3/3 — surface the per-edge confidence used for
|
|
6650
|
+
// PageRank weighting / floor pruning so downstream observability
|
|
6651
|
+
// (recall_xray, memory_graph_explain) can attribute ranking and
|
|
6652
|
+
// pruning decisions to specific edges.
|
|
6653
|
+
edgeConfidence: candidate.edgeConfidence
|
|
6275
6654
|
});
|
|
6276
6655
|
}
|
|
6277
6656
|
}
|
|
@@ -6284,12 +6663,12 @@ ${r.snippet.trim()}
|
|
|
6284
6663
|
}
|
|
6285
6664
|
async recordLastGraphRecallSnapshot(options) {
|
|
6286
6665
|
try {
|
|
6287
|
-
const snapshotPath =
|
|
6666
|
+
const snapshotPath = path6.join(
|
|
6288
6667
|
options.storage.dir,
|
|
6289
6668
|
"state",
|
|
6290
6669
|
"last_graph_recall.json"
|
|
6291
6670
|
);
|
|
6292
|
-
await mkdir5(
|
|
6671
|
+
await mkdir5(path6.dirname(snapshotPath), { recursive: true });
|
|
6293
6672
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
6294
6673
|
const totalSeedCount = options.seedPaths.length;
|
|
6295
6674
|
const totalExpandedCount = options.expandedPaths.length;
|
|
@@ -6323,12 +6702,12 @@ ${r.snippet.trim()}
|
|
|
6323
6702
|
}
|
|
6324
6703
|
async recordLastIntentSnapshot(options) {
|
|
6325
6704
|
try {
|
|
6326
|
-
const snapshotPath =
|
|
6705
|
+
const snapshotPath = path6.join(
|
|
6327
6706
|
options.storage.dir,
|
|
6328
6707
|
"state",
|
|
6329
6708
|
"last_intent.json"
|
|
6330
6709
|
);
|
|
6331
|
-
await mkdir5(
|
|
6710
|
+
await mkdir5(path6.dirname(snapshotPath), { recursive: true });
|
|
6332
6711
|
await writeFile4(
|
|
6333
6712
|
snapshotPath,
|
|
6334
6713
|
JSON.stringify(options.snapshot, null, 2),
|
|
@@ -6340,12 +6719,12 @@ ${r.snippet.trim()}
|
|
|
6340
6719
|
}
|
|
6341
6720
|
async recordLastQmdRecallSnapshot(options) {
|
|
6342
6721
|
try {
|
|
6343
|
-
const snapshotPath =
|
|
6722
|
+
const snapshotPath = path6.join(
|
|
6344
6723
|
options.storage.dir,
|
|
6345
6724
|
"state",
|
|
6346
6725
|
"last_qmd_recall.json"
|
|
6347
6726
|
);
|
|
6348
|
-
await mkdir5(
|
|
6727
|
+
await mkdir5(path6.dirname(snapshotPath), { recursive: true });
|
|
6349
6728
|
await writeFile4(
|
|
6350
6729
|
snapshotPath,
|
|
6351
6730
|
JSON.stringify(options.snapshot, null, 2),
|
|
@@ -6360,8 +6739,8 @@ ${r.snippet.trim()}
|
|
|
6360
6739
|
const stateDir = await this.resolveStateDirForNamespace(
|
|
6361
6740
|
options.namespace
|
|
6362
6741
|
);
|
|
6363
|
-
const snapshotPath =
|
|
6364
|
-
await mkdir5(
|
|
6742
|
+
const snapshotPath = path6.join(stateDir, "last_intent.json");
|
|
6743
|
+
await mkdir5(path6.dirname(snapshotPath), { recursive: true });
|
|
6365
6744
|
await writeFile4(
|
|
6366
6745
|
snapshotPath,
|
|
6367
6746
|
JSON.stringify(options.snapshot, null, 2),
|
|
@@ -6373,12 +6752,12 @@ ${r.snippet.trim()}
|
|
|
6373
6752
|
}
|
|
6374
6753
|
async resolveStateDirForNamespace(namespace) {
|
|
6375
6754
|
if (!this.config.namespacesEnabled) {
|
|
6376
|
-
return
|
|
6755
|
+
return path6.join(this.config.memoryDir, "state");
|
|
6377
6756
|
}
|
|
6378
6757
|
if (namespace !== this.config.defaultNamespace) {
|
|
6379
|
-
return
|
|
6758
|
+
return path6.join(this.config.memoryDir, "namespaces", namespace, "state");
|
|
6380
6759
|
}
|
|
6381
|
-
const candidate =
|
|
6760
|
+
const candidate = path6.join(
|
|
6382
6761
|
this.config.memoryDir,
|
|
6383
6762
|
"namespaces",
|
|
6384
6763
|
this.config.defaultNamespace
|
|
@@ -6386,11 +6765,11 @@ ${r.snippet.trim()}
|
|
|
6386
6765
|
try {
|
|
6387
6766
|
const candidateStat = await stat3(candidate);
|
|
6388
6767
|
if (candidateStat.isDirectory()) {
|
|
6389
|
-
return
|
|
6768
|
+
return path6.join(candidate, "state");
|
|
6390
6769
|
}
|
|
6391
6770
|
} catch {
|
|
6392
6771
|
}
|
|
6393
|
-
return
|
|
6772
|
+
return path6.join(this.config.memoryDir, "state");
|
|
6394
6773
|
}
|
|
6395
6774
|
buildGraphRecallRankedResults(results, sourceLabelResolver, limit = 64) {
|
|
6396
6775
|
return results.slice(0, limit).map((result) => ({
|
|
@@ -6424,12 +6803,12 @@ ${r.snippet.trim()}
|
|
|
6424
6803
|
return Math.max(0, Math.floor(value));
|
|
6425
6804
|
}
|
|
6426
6805
|
appendRecallSection(sectionBuckets, sectionId, content) {
|
|
6427
|
-
if (!this.isRecallSectionEnabled(sectionId)) return;
|
|
6806
|
+
if (!this.isRecallSectionEnabled(sectionId)) return false;
|
|
6428
6807
|
const trimmed = content.trim();
|
|
6429
|
-
if (trimmed.length === 0) return;
|
|
6808
|
+
if (trimmed.length === 0) return false;
|
|
6430
6809
|
const maxChars = this.getRecallSectionMaxChars(sectionId);
|
|
6431
6810
|
let finalContent = trimmed;
|
|
6432
|
-
if (maxChars === 0) return;
|
|
6811
|
+
if (maxChars === 0) return false;
|
|
6433
6812
|
if (typeof maxChars === "number" && finalContent.length > maxChars) {
|
|
6434
6813
|
finalContent = `${finalContent.slice(0, maxChars)}
|
|
6435
6814
|
|
|
@@ -6439,6 +6818,7 @@ ${r.snippet.trim()}
|
|
|
6439
6818
|
const existing = sectionBuckets.get(sectionId) ?? [];
|
|
6440
6819
|
existing.push(finalContent);
|
|
6441
6820
|
sectionBuckets.set(sectionId, existing);
|
|
6821
|
+
return true;
|
|
6442
6822
|
}
|
|
6443
6823
|
truncateRecallSectionToBudget(content, maxChars) {
|
|
6444
6824
|
if (maxChars <= 0) return "";
|
|
@@ -6564,6 +6944,11 @@ ${r.snippet.trim()}
|
|
|
6564
6944
|
}
|
|
6565
6945
|
async recallInternal(prompt, sessionKey, options = {}) {
|
|
6566
6946
|
const recallStart = Date.now();
|
|
6947
|
+
let asOfMs;
|
|
6948
|
+
if (typeof options.asOf === "string" && options.asOf.length > 0) {
|
|
6949
|
+
const parsed = Date.parse(options.asOf);
|
|
6950
|
+
if (Number.isFinite(parsed)) asOfMs = parsed;
|
|
6951
|
+
}
|
|
6567
6952
|
const timings = {};
|
|
6568
6953
|
const profileTraceId = this.profiler.startTrace("recall", sessionKey, {
|
|
6569
6954
|
qmdEnabled: this.config.qmdEnabled,
|
|
@@ -6638,6 +7023,7 @@ ${r.snippet.trim()}
|
|
|
6638
7023
|
let recalledMemoryCount = 0;
|
|
6639
7024
|
let recalledMemoryIds = [];
|
|
6640
7025
|
let recalledMemoryPaths = [];
|
|
7026
|
+
let xrayRecalledResults = [];
|
|
6641
7027
|
const xrayBranchPoolSize = {
|
|
6642
7028
|
hot_qmd: 0,
|
|
6643
7029
|
hot_embedding: 0,
|
|
@@ -6750,7 +7136,7 @@ ${r.snippet.trim()}
|
|
|
6750
7136
|
const graphExpandedResultPaths = /* @__PURE__ */ new Set();
|
|
6751
7137
|
const graphSourceLabelsForPath = (resultPath) => {
|
|
6752
7138
|
const labels = [];
|
|
6753
|
-
const normalizedPath = resultPath.split(
|
|
7139
|
+
const normalizedPath = resultPath.split(path6.sep).join("/");
|
|
6754
7140
|
const isEntityPath = normalizedPath.startsWith("entities/") || normalizedPath.includes("/entities/");
|
|
6755
7141
|
if (graphBaselinePaths.has(resultPath)) labels.push("baseline");
|
|
6756
7142
|
if (graphExpandedResultPaths.has(resultPath))
|
|
@@ -6974,6 +7360,71 @@ ${trimmedBody}`;
|
|
|
6974
7360
|
});
|
|
6975
7361
|
return profile2 || null;
|
|
6976
7362
|
})();
|
|
7363
|
+
let peerProfileXrayAnnotation = void 0;
|
|
7364
|
+
const peerProfileRecallPromise = (async () => {
|
|
7365
|
+
if (!this.config.peerProfileRecallEnabled) return null;
|
|
7366
|
+
if (this.config.peerProfileRecallMaxFields <= 0) return null;
|
|
7367
|
+
const peerId = this.getPeerIdForSession(sessionKey);
|
|
7368
|
+
if (!peerId) return null;
|
|
7369
|
+
const t0 = Date.now();
|
|
7370
|
+
try {
|
|
7371
|
+
const { readPeerProfile: _readPeerProfile } = await import("./peers-6OSQ3NK6.js");
|
|
7372
|
+
const peerProfile = await _readPeerProfile(this.config.memoryDir, peerId);
|
|
7373
|
+
recordRecallSectionMetric({
|
|
7374
|
+
section: "peerProfile",
|
|
7375
|
+
priority: "core",
|
|
7376
|
+
durationMs: Date.now() - t0,
|
|
7377
|
+
deadlineMs: recallSectionDeadlineMs,
|
|
7378
|
+
source: "fresh",
|
|
7379
|
+
success: true
|
|
7380
|
+
});
|
|
7381
|
+
if (!peerProfile) {
|
|
7382
|
+
peerProfileXrayAnnotation = null;
|
|
7383
|
+
return null;
|
|
7384
|
+
}
|
|
7385
|
+
const allFields = Object.entries(peerProfile.fields);
|
|
7386
|
+
if (allFields.length === 0) {
|
|
7387
|
+
peerProfileXrayAnnotation = null;
|
|
7388
|
+
return null;
|
|
7389
|
+
}
|
|
7390
|
+
const fieldsByRecency = allFields.map(([key, value]) => {
|
|
7391
|
+
const prov = peerProfile.provenance[key];
|
|
7392
|
+
let latestMs = 0;
|
|
7393
|
+
if (Array.isArray(prov) && prov.length > 0) {
|
|
7394
|
+
for (const p of prov) {
|
|
7395
|
+
if (typeof p.observedAt === "string") {
|
|
7396
|
+
const parsed = Date.parse(p.observedAt);
|
|
7397
|
+
if (Number.isFinite(parsed) && parsed > latestMs) {
|
|
7398
|
+
latestMs = parsed;
|
|
7399
|
+
}
|
|
7400
|
+
}
|
|
7401
|
+
}
|
|
7402
|
+
}
|
|
7403
|
+
return { key, value, latestMs };
|
|
7404
|
+
}).sort((a, b) => {
|
|
7405
|
+
if (b.latestMs !== a.latestMs) return b.latestMs - a.latestMs;
|
|
7406
|
+
return a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
|
|
7407
|
+
});
|
|
7408
|
+
const capped = fieldsByRecency.slice(0, this.config.peerProfileRecallMaxFields);
|
|
7409
|
+
const lines = capped.map(({ key, value }) => `**${key}**: ${value}`);
|
|
7410
|
+
peerProfileXrayAnnotation = { peerId, fieldsInjected: capped.length };
|
|
7411
|
+
return `## Peer Profile
|
|
7412
|
+
|
|
7413
|
+
${lines.join("\n\n")}`;
|
|
7414
|
+
} catch (err) {
|
|
7415
|
+
recordRecallSectionMetric({
|
|
7416
|
+
section: "peerProfile",
|
|
7417
|
+
priority: "core",
|
|
7418
|
+
durationMs: Date.now() - t0,
|
|
7419
|
+
deadlineMs: recallSectionDeadlineMs,
|
|
7420
|
+
source: "fresh",
|
|
7421
|
+
success: false,
|
|
7422
|
+
timing: `error(${err instanceof Error ? err.message : String(err)})`
|
|
7423
|
+
});
|
|
7424
|
+
log.debug(`peer profile recall injection failed (non-fatal): ${err}`);
|
|
7425
|
+
return null;
|
|
7426
|
+
}
|
|
7427
|
+
})();
|
|
6977
7428
|
const identityContinuityPromise = (async () => {
|
|
6978
7429
|
if (!this.isRecallSectionEnabled(
|
|
6979
7430
|
"identity-continuity",
|
|
@@ -7963,11 +8414,11 @@ ${formatted}`;
|
|
|
7963
8414
|
if (!this.config.compactionResetEnabled) return null;
|
|
7964
8415
|
const workspaceDir = compactionWorkspaceDir || this.config.workspaceDir || defaultWorkspaceDir();
|
|
7965
8416
|
const safeSessionKey = sanitizeSessionKeyForFilename(effectiveSessionKey);
|
|
7966
|
-
const signalPath =
|
|
8417
|
+
const signalPath = path6.join(
|
|
7967
8418
|
workspaceDir,
|
|
7968
8419
|
`.compaction-reset-signal-${safeSessionKey}`
|
|
7969
8420
|
);
|
|
7970
|
-
const bootPath =
|
|
8421
|
+
const bootPath = path6.join(workspaceDir, "BOOT.md");
|
|
7971
8422
|
try {
|
|
7972
8423
|
const signalStat = await stat3(signalPath).catch(() => null);
|
|
7973
8424
|
if (!signalStat) return null;
|
|
@@ -8269,7 +8720,8 @@ ${formatted}`;
|
|
|
8269
8720
|
transcriptSection,
|
|
8270
8721
|
compactionSection,
|
|
8271
8722
|
summariesSection,
|
|
8272
|
-
conversationRecallSection
|
|
8723
|
+
conversationRecallSection,
|
|
8724
|
+
peerProfileSection
|
|
8273
8725
|
] = await raceRecallAbort(
|
|
8274
8726
|
Promise.all(
|
|
8275
8727
|
[
|
|
@@ -8291,7 +8743,8 @@ ${formatted}`;
|
|
|
8291
8743
|
["transcript", transcriptPromise],
|
|
8292
8744
|
["compaction", compactionPromise],
|
|
8293
8745
|
["summaries", summariesPromise],
|
|
8294
|
-
["convRecall", conversationRecallPromise]
|
|
8746
|
+
["convRecall", conversationRecallPromise],
|
|
8747
|
+
["peerProfile", peerProfileRecallPromise]
|
|
8295
8748
|
].map(
|
|
8296
8749
|
([name, p]) => p.then((v) => {
|
|
8297
8750
|
log.debug(
|
|
@@ -8382,6 +8835,16 @@ ${formatted}`;
|
|
|
8382
8835
|
|
|
8383
8836
|
${profile}`
|
|
8384
8837
|
);
|
|
8838
|
+
if (peerProfileSection) {
|
|
8839
|
+
const peerSectionAppended = this.appendRecallSection(
|
|
8840
|
+
sectionBuckets,
|
|
8841
|
+
"peer-profile",
|
|
8842
|
+
peerProfileSection
|
|
8843
|
+
);
|
|
8844
|
+
if (!peerSectionAppended) {
|
|
8845
|
+
peerProfileXrayAnnotation = null;
|
|
8846
|
+
}
|
|
8847
|
+
}
|
|
8385
8848
|
if (calibrationSection) {
|
|
8386
8849
|
this.appendRecallSection(
|
|
8387
8850
|
sectionBuckets,
|
|
@@ -8609,7 +9072,8 @@ ${tmtNode.summary}`
|
|
|
8609
9072
|
} = await this.expandResultsViaGraph({
|
|
8610
9073
|
memoryResults,
|
|
8611
9074
|
recallNamespaces,
|
|
8612
|
-
recallResultLimit
|
|
9075
|
+
recallResultLimit,
|
|
9076
|
+
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
8613
9077
|
});
|
|
8614
9078
|
graphSnapshotStatus = "completed";
|
|
8615
9079
|
graphDecisionStatus = "completed";
|
|
@@ -8663,7 +9127,9 @@ ${tmtNode.summary}`
|
|
|
8663
9127
|
memoryResults = await this.boostSearchResults(
|
|
8664
9128
|
memoryResults,
|
|
8665
9129
|
recallNamespaces,
|
|
8666
|
-
retrievalQuery
|
|
9130
|
+
retrievalQuery,
|
|
9131
|
+
void 0,
|
|
9132
|
+
{ asOfMs }
|
|
8667
9133
|
);
|
|
8668
9134
|
if (this.config.rerankEnabled && this.config.rerankProvider === "local") {
|
|
8669
9135
|
const ranked = await rerankLocalOrNoop({
|
|
@@ -8785,6 +9251,7 @@ ${tmtNode.summary}`
|
|
|
8785
9251
|
});
|
|
8786
9252
|
recalledMemoryIds = this.extractMemoryIdsFromResults(memoryResults);
|
|
8787
9253
|
recalledMemoryPaths = memoryResults.map((result) => result.path).filter(Boolean);
|
|
9254
|
+
xrayRecalledResults = memoryResults;
|
|
8788
9255
|
impressionRecorded = true;
|
|
8789
9256
|
} else if (!confidenceGateRejected) {
|
|
8790
9257
|
const queryAwarePrefilter = await queryAwarePrefilterPromise;
|
|
@@ -8808,7 +9275,9 @@ ${tmtNode.summary}`
|
|
|
8808
9275
|
const boostedScoped = await this.boostSearchResults(
|
|
8809
9276
|
scopedCandidates,
|
|
8810
9277
|
recallNamespaces,
|
|
8811
|
-
retrievalQuery
|
|
9278
|
+
retrievalQuery,
|
|
9279
|
+
void 0,
|
|
9280
|
+
{ asOfMs }
|
|
8812
9281
|
);
|
|
8813
9282
|
xrayBranchPoolSize.hot_embedding = Math.max(
|
|
8814
9283
|
xrayBranchPoolSize.hot_embedding,
|
|
@@ -8843,6 +9312,7 @@ ${tmtNode.summary}`
|
|
|
8843
9312
|
});
|
|
8844
9313
|
recalledMemoryIds = this.extractMemoryIdsFromResults(scoped);
|
|
8845
9314
|
recalledMemoryPaths = scoped.map((result) => result.path).filter(Boolean);
|
|
9315
|
+
xrayRecalledResults = scoped;
|
|
8846
9316
|
impressionRecorded = true;
|
|
8847
9317
|
} else {
|
|
8848
9318
|
const longTerm = await this.applyColdFallbackPipeline({
|
|
@@ -8852,7 +9322,9 @@ ${tmtNode.summary}`
|
|
|
8852
9322
|
recallMode,
|
|
8853
9323
|
queryAwarePrefilter,
|
|
8854
9324
|
abortSignal: options.abortSignal,
|
|
8855
|
-
xrayPoolSizeSink: xrayColdPoolSink
|
|
9325
|
+
xrayPoolSizeSink: xrayColdPoolSink,
|
|
9326
|
+
asOfMs,
|
|
9327
|
+
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
8856
9328
|
});
|
|
8857
9329
|
if (longTerm.length > 0) {
|
|
8858
9330
|
if (shouldPersistGraphSnapshot) {
|
|
@@ -8877,6 +9349,7 @@ ${tmtNode.summary}`
|
|
|
8877
9349
|
});
|
|
8878
9350
|
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
8879
9351
|
recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
|
|
9352
|
+
xrayRecalledResults = longTerm;
|
|
8880
9353
|
impressionRecorded = true;
|
|
8881
9354
|
}
|
|
8882
9355
|
}
|
|
@@ -8934,7 +9407,9 @@ ${tmtNode.summary}`
|
|
|
8934
9407
|
const boostedScoped = await this.boostSearchResults(
|
|
8935
9408
|
scopedCandidates,
|
|
8936
9409
|
recallNamespaces,
|
|
8937
|
-
retrievalQuery
|
|
9410
|
+
retrievalQuery,
|
|
9411
|
+
void 0,
|
|
9412
|
+
{ asOfMs }
|
|
8938
9413
|
);
|
|
8939
9414
|
xrayBranchPoolSize.hot_embedding = Math.max(
|
|
8940
9415
|
xrayBranchPoolSize.hot_embedding,
|
|
@@ -8969,6 +9444,7 @@ ${tmtNode.summary}`
|
|
|
8969
9444
|
});
|
|
8970
9445
|
recalledMemoryIds = this.extractMemoryIdsFromResults(scoped);
|
|
8971
9446
|
recalledMemoryPaths = scoped.map((result) => result.path).filter(Boolean);
|
|
9447
|
+
xrayRecalledResults = scoped;
|
|
8972
9448
|
impressionRecorded = true;
|
|
8973
9449
|
} else {
|
|
8974
9450
|
const memories = await this.readAllMemoriesForNamespaces(recallNamespaces);
|
|
@@ -8977,12 +9453,14 @@ ${tmtNode.summary}`
|
|
|
8977
9453
|
enabled: this.config.temporalSupersessionEnabled,
|
|
8978
9454
|
includeInRecall: this.config.temporalSupersessionIncludeInRecall
|
|
8979
9455
|
};
|
|
9456
|
+
const asOfActive = typeof asOfMs === "number" && Number.isFinite(asOfMs);
|
|
8980
9457
|
const activeMemories = memories.filter(
|
|
8981
9458
|
(m) => {
|
|
8982
9459
|
if (isArtifactMemoryPath(m.path)) return false;
|
|
8983
9460
|
const status = m.frontmatter.status;
|
|
8984
9461
|
if (!status || status === "active") return true;
|
|
8985
9462
|
if (status === "superseded") {
|
|
9463
|
+
if (asOfActive) return true;
|
|
8986
9464
|
return !shouldFilterSupersededFromRecall(m.frontmatter, supersessionOptions);
|
|
8987
9465
|
}
|
|
8988
9466
|
return false;
|
|
@@ -8999,7 +9477,9 @@ ${tmtNode.summary}`
|
|
|
8999
9477
|
recallMode,
|
|
9000
9478
|
queryAwarePrefilter,
|
|
9001
9479
|
abortSignal: options.abortSignal,
|
|
9002
|
-
xrayPoolSizeSink: xrayColdPoolSink
|
|
9480
|
+
xrayPoolSizeSink: xrayColdPoolSink,
|
|
9481
|
+
asOfMs,
|
|
9482
|
+
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
9003
9483
|
});
|
|
9004
9484
|
if (longTerm.length > 0) {
|
|
9005
9485
|
recallSource = "cold_fallback";
|
|
@@ -9018,6 +9498,7 @@ ${tmtNode.summary}`
|
|
|
9018
9498
|
});
|
|
9019
9499
|
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
9020
9500
|
recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
|
|
9501
|
+
xrayRecalledResults = longTerm;
|
|
9021
9502
|
impressionRecorded = true;
|
|
9022
9503
|
}
|
|
9023
9504
|
} else {
|
|
@@ -9039,7 +9520,8 @@ ${tmtNode.summary}`
|
|
|
9039
9520
|
recentAsResults,
|
|
9040
9521
|
recallNamespaces,
|
|
9041
9522
|
retrievalQuery,
|
|
9042
|
-
preloadedMap
|
|
9523
|
+
preloadedMap,
|
|
9524
|
+
{ asOfMs }
|
|
9043
9525
|
)).sort((a, b) => b.score - a.score);
|
|
9044
9526
|
xrayBranchPoolSize.recent_scan = Math.max(
|
|
9045
9527
|
xrayBranchPoolSize.recent_scan,
|
|
@@ -9074,6 +9556,7 @@ ${tmtNode.summary}`
|
|
|
9074
9556
|
});
|
|
9075
9557
|
recalledMemoryIds = this.extractMemoryIdsFromResults(recent);
|
|
9076
9558
|
recalledMemoryPaths = recent.map((result) => result.path).filter(Boolean);
|
|
9559
|
+
xrayRecalledResults = recent;
|
|
9077
9560
|
impressionRecorded = true;
|
|
9078
9561
|
} else {
|
|
9079
9562
|
const longTerm = await this.applyColdFallbackPipeline({
|
|
@@ -9083,7 +9566,9 @@ ${tmtNode.summary}`
|
|
|
9083
9566
|
recallMode,
|
|
9084
9567
|
queryAwarePrefilter,
|
|
9085
9568
|
abortSignal: options.abortSignal,
|
|
9086
|
-
xrayPoolSizeSink: xrayColdPoolSink
|
|
9569
|
+
xrayPoolSizeSink: xrayColdPoolSink,
|
|
9570
|
+
asOfMs,
|
|
9571
|
+
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
9087
9572
|
});
|
|
9088
9573
|
if (longTerm.length > 0) {
|
|
9089
9574
|
if (shouldPersistGraphSnapshot) {
|
|
@@ -9108,6 +9593,7 @@ ${tmtNode.summary}`
|
|
|
9108
9593
|
});
|
|
9109
9594
|
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
9110
9595
|
recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
|
|
9596
|
+
xrayRecalledResults = longTerm;
|
|
9111
9597
|
impressionRecorded = true;
|
|
9112
9598
|
}
|
|
9113
9599
|
}
|
|
@@ -9120,7 +9606,9 @@ ${tmtNode.summary}`
|
|
|
9120
9606
|
recallMode,
|
|
9121
9607
|
queryAwarePrefilter,
|
|
9122
9608
|
abortSignal: options.abortSignal,
|
|
9123
|
-
xrayPoolSizeSink: xrayColdPoolSink
|
|
9609
|
+
xrayPoolSizeSink: xrayColdPoolSink,
|
|
9610
|
+
asOfMs,
|
|
9611
|
+
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
9124
9612
|
});
|
|
9125
9613
|
if (longTerm.length > 0) {
|
|
9126
9614
|
if (shouldPersistGraphSnapshot) {
|
|
@@ -9145,6 +9633,7 @@ ${tmtNode.summary}`
|
|
|
9145
9633
|
});
|
|
9146
9634
|
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
9147
9635
|
recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
|
|
9636
|
+
xrayRecalledResults = longTerm;
|
|
9148
9637
|
impressionRecorded = true;
|
|
9149
9638
|
}
|
|
9150
9639
|
}
|
|
@@ -9305,15 +9794,25 @@ _Context: ${topQuestion.context}_`
|
|
|
9305
9794
|
const match = p.match(/([^/]+)\.md$/);
|
|
9306
9795
|
return match ? match[1] ?? null : null;
|
|
9307
9796
|
};
|
|
9797
|
+
const xrayResultByPath = new Map(
|
|
9798
|
+
xrayRecalledResults.map((xr) => [xr.path, xr])
|
|
9799
|
+
);
|
|
9308
9800
|
const results = [];
|
|
9309
9801
|
for (const recalledPath of recalledMemoryPaths) {
|
|
9310
9802
|
const derivedId = idFromPath(recalledPath);
|
|
9311
9803
|
if (!derivedId) continue;
|
|
9804
|
+
const xrayResult = xrayResultByPath.get(recalledPath);
|
|
9805
|
+
const scoreDecomposition = {
|
|
9806
|
+
final: xrayResult?.score ?? 0
|
|
9807
|
+
};
|
|
9808
|
+
if (xrayResult?.explain?.reinforcementBoost !== void 0 && xrayResult.explain.reinforcementBoost > 0) {
|
|
9809
|
+
scoreDecomposition.reinforcementBoost = xrayResult.explain.reinforcementBoost;
|
|
9810
|
+
}
|
|
9312
9811
|
results.push({
|
|
9313
9812
|
memoryId: derivedId,
|
|
9314
9813
|
path: recalledPath,
|
|
9315
9814
|
servedBy,
|
|
9316
|
-
scoreDecomposition
|
|
9815
|
+
scoreDecomposition,
|
|
9317
9816
|
admittedBy: []
|
|
9318
9817
|
});
|
|
9319
9818
|
}
|
|
@@ -9359,7 +9858,14 @@ _Context: ${topQuestion.context}_`
|
|
|
9359
9858
|
},
|
|
9360
9859
|
sessionKey,
|
|
9361
9860
|
namespace: selfNamespace,
|
|
9362
|
-
traceId
|
|
9861
|
+
traceId,
|
|
9862
|
+
// Issue #679 completion: record peer-profile injection in the
|
|
9863
|
+
// xray snapshot. peerProfileXrayAnnotation is set inside
|
|
9864
|
+
// peerProfileRecallPromise when injection actually occurred,
|
|
9865
|
+
// and stays null otherwise. By the time xray capture runs,
|
|
9866
|
+
// phase-1 parallel work is complete so the annotation is
|
|
9867
|
+
// guaranteed to be populated.
|
|
9868
|
+
peerProfileInjection: peerProfileXrayAnnotation
|
|
9363
9869
|
});
|
|
9364
9870
|
} catch (err) {
|
|
9365
9871
|
log.debug(`x-ray capture failed: ${err}`);
|
|
@@ -10087,7 +10593,7 @@ ${normalized}`).digest("hex");
|
|
|
10087
10593
|
);
|
|
10088
10594
|
this.tierMigrationInFlight = true;
|
|
10089
10595
|
try {
|
|
10090
|
-
const coldStorage = new StorageManager(
|
|
10596
|
+
const coldStorage = new StorageManager(path6.join(storage.dir, "cold"));
|
|
10091
10597
|
const [hotMemories, coldMemories] = await Promise.all([
|
|
10092
10598
|
storage.readAllMemories(),
|
|
10093
10599
|
coldStorage.readAllMemories()
|
|
@@ -10653,6 +11159,7 @@ ${normalized}`).digest("hex");
|
|
|
10653
11159
|
let writeCategory = fact.category;
|
|
10654
11160
|
let targetStorage = storage;
|
|
10655
11161
|
let routedRuleId;
|
|
11162
|
+
let routedNamespaceExplicit = false;
|
|
10656
11163
|
if (routeRules.length > 0) {
|
|
10657
11164
|
try {
|
|
10658
11165
|
const routeText = `${fact.category} ${fact.tags.join(" ")} ${fact.content}`;
|
|
@@ -10663,6 +11170,7 @@ ${normalized}`).digest("hex");
|
|
|
10663
11170
|
writeCategory = selected.target.category;
|
|
10664
11171
|
}
|
|
10665
11172
|
if (selected.target.namespace) {
|
|
11173
|
+
routedNamespaceExplicit = true;
|
|
10666
11174
|
targetStorage = await this.storageRouter.storageFor(
|
|
10667
11175
|
selected.target.namespace
|
|
10668
11176
|
);
|
|
@@ -10674,6 +11182,23 @@ ${normalized}`).digest("hex");
|
|
|
10674
11182
|
);
|
|
10675
11183
|
}
|
|
10676
11184
|
}
|
|
11185
|
+
if (this.config.extractionScopeClassificationEnabled && this.config.namespacesEnabled && fact.scope === "global" && !routedNamespaceExplicit) {
|
|
11186
|
+
const currentNs = this.namespaceFromStorageDir(targetStorage.dir);
|
|
11187
|
+
if (currentNs !== this.config.sharedNamespace) {
|
|
11188
|
+
try {
|
|
11189
|
+
targetStorage = await this.storageRouter.storageFor(
|
|
11190
|
+
this.config.sharedNamespace
|
|
11191
|
+
);
|
|
11192
|
+
log.debug(
|
|
11193
|
+
`scope-routing: fact "${fact.content.slice(0, 60)}\u2026" routed to shared namespace (scope=global)`
|
|
11194
|
+
);
|
|
11195
|
+
} catch (scopeRouteErr) {
|
|
11196
|
+
log.warn(
|
|
11197
|
+
`scope-routing: failed to resolve shared namespace storage; writing to session namespace (fail-open): ${scopeRouteErr}`
|
|
11198
|
+
);
|
|
11199
|
+
}
|
|
11200
|
+
}
|
|
11201
|
+
}
|
|
10677
11202
|
const canonicalContentForHash = citationEnabled && hasCitationForTemplate(fact.content, citationTemplate) ? stripCitationForTemplate(fact.content, citationTemplate) : fact.content;
|
|
10678
11203
|
const contentHashDedupKey = writeCategory === "procedure" ? buildProcedurePersistBody(fact.content, fact.procedureSteps) : canonicalContentForHash;
|
|
10679
11204
|
if (this.contentHashIndex && this.contentHashIndex.has(contentHashDedupKey)) {
|
|
@@ -11260,7 +11785,7 @@ ${normalized}`).digest("hex");
|
|
|
11260
11785
|
const allMems = allMemsForGraph ?? [];
|
|
11261
11786
|
for (const m of allMems) {
|
|
11262
11787
|
if (m.frontmatter.entityRef === entityRef) {
|
|
11263
|
-
const rel =
|
|
11788
|
+
const rel = path6.relative(storage.dir, m.path);
|
|
11264
11789
|
if (rel !== memoryRelPath) entitySiblings.push(rel);
|
|
11265
11790
|
}
|
|
11266
11791
|
}
|
|
@@ -11327,8 +11852,7 @@ ${normalized}`).digest("hex");
|
|
|
11327
11852
|
])
|
|
11328
11853
|
)
|
|
11329
11854
|
) : await storage.readAllMemories();
|
|
11330
|
-
const
|
|
11331
|
-
const pool = needsFullRebuild ? allMemories.filter(isActive) : (() => {
|
|
11855
|
+
const pool = needsFullRebuild ? allMemories.filter((m) => isActiveMemoryStatus(m.frontmatter.status)) : (() => {
|
|
11332
11856
|
const idSet = new Set(persistedIds);
|
|
11333
11857
|
return allMemories.filter((m) => idSet.has(m.frontmatter.id));
|
|
11334
11858
|
})();
|
|
@@ -11514,24 +12038,54 @@ ${normalized}`).digest("hex");
|
|
|
11514
12038
|
}
|
|
11515
12039
|
if (this.config.lifecyclePolicyEnabled) {
|
|
11516
12040
|
try {
|
|
12041
|
+
const lightSleepStartedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
11517
12042
|
const lifecycleCorpus = await this.storage.readAllMemories();
|
|
11518
12043
|
await this.runLifecyclePolicyPass(lifecycleCorpus);
|
|
12044
|
+
await this.recordScheduledDreamsPhaseRun(
|
|
12045
|
+
"lightSleep",
|
|
12046
|
+
lifecycleCorpus.length,
|
|
12047
|
+
`scheduled lifecycle policy pass assessed ${lifecycleCorpus.length} memories`,
|
|
12048
|
+
{
|
|
12049
|
+
startedAt: lightSleepStartedAt,
|
|
12050
|
+
completedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
12051
|
+
}
|
|
12052
|
+
);
|
|
11519
12053
|
} catch (err) {
|
|
11520
12054
|
log.warn(`lifecycle policy pass failed (ignored): ${err}`);
|
|
11521
12055
|
}
|
|
11522
12056
|
}
|
|
11523
12057
|
await this.runCompressionGuidelineLearningPass();
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
-
if (
|
|
11529
|
-
|
|
12058
|
+
try {
|
|
12059
|
+
const deepSleepStartedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
12060
|
+
await this.runTierMigrationCycle(this.storage, "maintenance");
|
|
12061
|
+
allMemories = await this.storage.readAllMemories();
|
|
12062
|
+
if (this.config.factArchivalEnabled) {
|
|
12063
|
+
const archived = await this.runFactArchival(allMemories);
|
|
12064
|
+
if (archived > 0) {
|
|
12065
|
+
log.info(`archived ${archived} old low-importance facts`);
|
|
12066
|
+
}
|
|
12067
|
+
}
|
|
12068
|
+
await this.recordScheduledDreamsPhaseRun(
|
|
12069
|
+
"deepSleep",
|
|
12070
|
+
allMemories.length,
|
|
12071
|
+
`scheduled deep-sleep maintenance assessed ${allMemories.length} memories`,
|
|
12072
|
+
{
|
|
12073
|
+
startedAt: deepSleepStartedAt,
|
|
12074
|
+
completedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
12075
|
+
}
|
|
12076
|
+
);
|
|
12077
|
+
} catch (err) {
|
|
12078
|
+
log.warn(`deep-sleep maintenance pass failed (ignored): ${err}`);
|
|
12079
|
+
try {
|
|
12080
|
+
allMemories = await this.storage.readAllMemories();
|
|
12081
|
+
} catch (readErr) {
|
|
12082
|
+
log.warn(`deep-sleep maintenance recovery read failed: ${readErr}`);
|
|
12083
|
+
throw err;
|
|
11530
12084
|
}
|
|
11531
12085
|
}
|
|
11532
12086
|
if (this.config.semanticConsolidationEnabled) {
|
|
11533
12087
|
try {
|
|
11534
|
-
const stateFilePath =
|
|
12088
|
+
const stateFilePath = path6.join(
|
|
11535
12089
|
this.config.memoryDir,
|
|
11536
12090
|
"state",
|
|
11537
12091
|
"semantic-consolidation-last-run.json"
|
|
@@ -11553,15 +12107,33 @@ ${normalized}`).digest("hex");
|
|
|
11553
12107
|
} catch {
|
|
11554
12108
|
}
|
|
11555
12109
|
if (shouldRun) {
|
|
12110
|
+
const remStartedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
11556
12111
|
const semResult = await this.runSemanticConsolidation();
|
|
12112
|
+
let remItemsProcessed = allMemories.length;
|
|
12113
|
+
try {
|
|
12114
|
+
allMemories = await this.storage.readAllMemories();
|
|
12115
|
+
remItemsProcessed = allMemories.length;
|
|
12116
|
+
} catch (err) {
|
|
12117
|
+
log.warn(
|
|
12118
|
+
`[semantic-consolidation] post-run telemetry refresh failed (non-fatal): ${err}`
|
|
12119
|
+
);
|
|
12120
|
+
}
|
|
12121
|
+
await this.recordScheduledDreamsPhaseRun(
|
|
12122
|
+
"rem",
|
|
12123
|
+
remItemsProcessed,
|
|
12124
|
+
`scheduled REM consolidation found ${semResult.clustersFound} clusters`,
|
|
12125
|
+
{
|
|
12126
|
+
startedAt: remStartedAt,
|
|
12127
|
+
completedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
12128
|
+
}
|
|
12129
|
+
);
|
|
11557
12130
|
if (semResult.memoriesArchived > 0) {
|
|
11558
12131
|
log.info(
|
|
11559
12132
|
`[semantic-consolidation] archived ${semResult.memoriesArchived} memories during maintenance`
|
|
11560
12133
|
);
|
|
11561
|
-
allMemories = await this.storage.readAllMemories();
|
|
11562
12134
|
}
|
|
11563
12135
|
if (semResult.errors === 0 || semResult.memoriesArchived > 0) {
|
|
11564
|
-
const stateDir =
|
|
12136
|
+
const stateDir = path6.join(this.config.memoryDir, "state");
|
|
11565
12137
|
await mkdir5(stateDir, { recursive: true });
|
|
11566
12138
|
await writeFile4(
|
|
11567
12139
|
stateFilePath,
|
|
@@ -11612,7 +12184,7 @@ ${normalized}`).digest("hex");
|
|
|
11612
12184
|
if (this.config.temporalMemoryTreeEnabled) {
|
|
11613
12185
|
try {
|
|
11614
12186
|
const tmtEntries = allMemories.filter(
|
|
11615
|
-
(m) => m.frontmatter.status !== "superseded" && m.frontmatter.status !== "archived"
|
|
12187
|
+
(m) => m.frontmatter.status !== "superseded" && m.frontmatter.status !== "archived" && m.frontmatter.status !== "forgotten"
|
|
11616
12188
|
).map((m) => ({
|
|
11617
12189
|
path: m.path,
|
|
11618
12190
|
id: m.frontmatter.id,
|
|
@@ -11927,8 +12499,8 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
|
|
|
11927
12499
|
return 0;
|
|
11928
12500
|
}
|
|
11929
12501
|
}
|
|
11930
|
-
async buildLifecycleActionPriors() {
|
|
11931
|
-
const events = await
|
|
12502
|
+
async buildLifecycleActionPriors(storage = this.storage) {
|
|
12503
|
+
const events = await storage.readMemoryActionEvents(1200);
|
|
11932
12504
|
if (events.length === 0) return /* @__PURE__ */ new Map();
|
|
11933
12505
|
const nowMs = Date.now();
|
|
11934
12506
|
const windowMs = 14 * 24 * 60 * 60 * 1e3;
|
|
@@ -11965,7 +12537,28 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
|
|
|
11965
12537
|
}
|
|
11966
12538
|
return out;
|
|
11967
12539
|
}
|
|
11968
|
-
async
|
|
12540
|
+
async recordScheduledDreamsPhaseRun(phase, itemsProcessed, notes, timing = {}) {
|
|
12541
|
+
try {
|
|
12542
|
+
const { recordDreamsPhaseRun } = await import("./dreams-ledger-LR2NBAZE.js");
|
|
12543
|
+
await recordDreamsPhaseRun({
|
|
12544
|
+
memoryDir: this.storage.dir,
|
|
12545
|
+
phase,
|
|
12546
|
+
trigger: "scheduled",
|
|
12547
|
+
itemsProcessed,
|
|
12548
|
+
notes,
|
|
12549
|
+
startedAt: timing.startedAt,
|
|
12550
|
+
completedAt: timing.completedAt
|
|
12551
|
+
});
|
|
12552
|
+
} catch (error) {
|
|
12553
|
+
log.debug(`dreams ledger scheduled ${phase} write failed (non-fatal): ${error}`);
|
|
12554
|
+
}
|
|
12555
|
+
}
|
|
12556
|
+
async runLifecyclePolicyNow(storage = this.storage) {
|
|
12557
|
+
const lifecycleCorpus = await storage.readAllMemories();
|
|
12558
|
+
await this.runLifecyclePolicyPass(lifecycleCorpus, storage);
|
|
12559
|
+
return { memoriesAssessed: lifecycleCorpus.length };
|
|
12560
|
+
}
|
|
12561
|
+
async runLifecyclePolicyPass(allMemories, storage = this.storage) {
|
|
11969
12562
|
const now = /* @__PURE__ */ new Date();
|
|
11970
12563
|
const nowIso = now.toISOString();
|
|
11971
12564
|
const countsByState = {
|
|
@@ -11986,9 +12579,9 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
|
|
|
11986
12579
|
archiveDecayThreshold: thresholds.archiveDecayThreshold,
|
|
11987
12580
|
protectedCategories: this.config.lifecycleProtectedCategories
|
|
11988
12581
|
};
|
|
11989
|
-
const actionPriors = await this.buildLifecycleActionPriors();
|
|
12582
|
+
const actionPriors = await this.buildLifecycleActionPriors(storage);
|
|
11990
12583
|
for (const memory of allMemories) {
|
|
11991
|
-
if (memory.frontmatter.status === "superseded") {
|
|
12584
|
+
if (memory.frontmatter.status === "superseded" || memory.frontmatter.status === "forgotten") {
|
|
11992
12585
|
continue;
|
|
11993
12586
|
}
|
|
11994
12587
|
evaluatedCount += 1;
|
|
@@ -12010,7 +12603,7 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
|
|
|
12010
12603
|
const scoreDelta = Math.abs((prevHeat ?? -1) - decision.heatScore) + Math.abs((prevDecay ?? -1) - decision.decayScore);
|
|
12011
12604
|
const shouldPersist = memory.frontmatter.lifecycleState !== nextState || memory.frontmatter.heatScore === void 0 || memory.frontmatter.decayScore === void 0 || memory.frontmatter.lastValidatedAt === void 0 || scoreDelta >= 0.01;
|
|
12012
12605
|
if (!shouldPersist) continue;
|
|
12013
|
-
const wrote = await
|
|
12606
|
+
const wrote = await storage.writeMemoryFrontmatter(memory, {
|
|
12014
12607
|
lifecycleState: nextState,
|
|
12015
12608
|
heatScore: decision.heatScore,
|
|
12016
12609
|
decayScore: decision.decayScore,
|
|
@@ -12035,12 +12628,12 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
|
|
|
12035
12628
|
protectedCategories: this.config.lifecycleProtectedCategories
|
|
12036
12629
|
}
|
|
12037
12630
|
};
|
|
12038
|
-
const metricsPath =
|
|
12039
|
-
|
|
12631
|
+
const metricsPath = path6.join(
|
|
12632
|
+
storage.dir,
|
|
12040
12633
|
"state",
|
|
12041
12634
|
"lifecycle-metrics.json"
|
|
12042
12635
|
);
|
|
12043
|
-
await mkdir5(
|
|
12636
|
+
await mkdir5(path6.dirname(metricsPath), { recursive: true });
|
|
12044
12637
|
await writeFile4(metricsPath, JSON.stringify(metrics, null, 2), "utf-8");
|
|
12045
12638
|
}
|
|
12046
12639
|
/**
|
|
@@ -12102,7 +12695,7 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
|
|
|
12102
12695
|
*/
|
|
12103
12696
|
async runSummarization(allMemories) {
|
|
12104
12697
|
const activeMemories = allMemories.filter(
|
|
12105
|
-
(m) =>
|
|
12698
|
+
(m) => isActiveMemoryStatus(m.frontmatter.status)
|
|
12106
12699
|
);
|
|
12107
12700
|
if (activeMemories.length < this.config.summarizationTriggerCount) {
|
|
12108
12701
|
return;
|
|
@@ -12167,7 +12760,7 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
|
|
|
12167
12760
|
*/
|
|
12168
12761
|
async runTopicExtraction(allMemories) {
|
|
12169
12762
|
const activeMemories = allMemories.filter(
|
|
12170
|
-
(m) =>
|
|
12763
|
+
(m) => isActiveMemoryStatus(m.frontmatter.status)
|
|
12171
12764
|
);
|
|
12172
12765
|
if (activeMemories.length === 0) return;
|
|
12173
12766
|
const topics = extractTopics(
|
|
@@ -12567,7 +13160,7 @@ ${lines.join("\n\n")}`;
|
|
|
12567
13160
|
nsMap = buildMemoryWorthCounterMap(memories);
|
|
12568
13161
|
this.memoryWorthCounterCache.set(ns, { at: nowMs, counters: nsMap });
|
|
12569
13162
|
}
|
|
12570
|
-
for (const [
|
|
13163
|
+
for (const [path7, c] of nsMap) counters.set(path7, c);
|
|
12571
13164
|
} catch (err) {
|
|
12572
13165
|
log.debug("memory-worth: failed to read namespace, skipping", {
|
|
12573
13166
|
namespace: ns,
|
|
@@ -12738,12 +13331,12 @@ ${lines.join("\n\n")}`;
|
|
|
12738
13331
|
*/
|
|
12739
13332
|
semanticDedupScopeFor(targetStorage) {
|
|
12740
13333
|
if (!this.config.namespacesEnabled) return {};
|
|
12741
|
-
const memoryDir =
|
|
12742
|
-
const storageDir =
|
|
13334
|
+
const memoryDir = path6.resolve(this.config.memoryDir);
|
|
13335
|
+
const storageDir = path6.resolve(targetStorage.dir);
|
|
12743
13336
|
if (storageDir === memoryDir) {
|
|
12744
13337
|
return { pathExcludePrefixes: ["namespaces/"] };
|
|
12745
13338
|
}
|
|
12746
|
-
let rel =
|
|
13339
|
+
let rel = path6.relative(memoryDir, storageDir);
|
|
12747
13340
|
if (!rel || rel.startsWith("..")) {
|
|
12748
13341
|
log.debug(
|
|
12749
13342
|
`semantic dedup: target storage dir ${storageDir} is outside memoryDir ${memoryDir}; scoping lookup to absolute path prefix`
|
|
@@ -12762,7 +13355,7 @@ ${lines.join("\n\n")}`;
|
|
|
12762
13355
|
if (hits.length === 0) return [];
|
|
12763
13356
|
const results = [];
|
|
12764
13357
|
for (const hit of hits) {
|
|
12765
|
-
const fullPath =
|
|
13358
|
+
const fullPath = path6.isAbsolute(hit.path) ? hit.path : path6.join(this.config.memoryDir, hit.path);
|
|
12766
13359
|
const memory = await this.storage.readMemoryByPath(fullPath);
|
|
12767
13360
|
if (!memory) continue;
|
|
12768
13361
|
results.push({
|
|
@@ -12894,7 +13487,8 @@ ${lines.join("\n\n")}`;
|
|
|
12894
13487
|
const { merged } = await this.expandResultsViaGraph({
|
|
12895
13488
|
memoryResults: results,
|
|
12896
13489
|
recallNamespaces: options.recallNamespaces,
|
|
12897
|
-
recallResultLimit: options.recallResultLimit
|
|
13490
|
+
recallResultLimit: options.recallResultLimit,
|
|
13491
|
+
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
12898
13492
|
});
|
|
12899
13493
|
results = merged;
|
|
12900
13494
|
}
|
|
@@ -12903,7 +13497,7 @@ ${lines.join("\n\n")}`;
|
|
|
12903
13497
|
options.recallNamespaces,
|
|
12904
13498
|
options.prompt,
|
|
12905
13499
|
void 0,
|
|
12906
|
-
{ allowLifecycleFiltered: true }
|
|
13500
|
+
{ allowLifecycleFiltered: true, asOfMs: options.asOfMs }
|
|
12907
13501
|
);
|
|
12908
13502
|
if (this.config.rerankEnabled && this.config.rerankProvider === "local") {
|
|
12909
13503
|
const ranked = await rerankLocalOrNoop({
|
|
@@ -13077,12 +13671,17 @@ ${lines.join("\n\n")}`;
|
|
|
13077
13671
|
let lifecycleFilteredCount = 0;
|
|
13078
13672
|
let temporalSupersededFilteredCount = 0;
|
|
13079
13673
|
let dedicatedSurfaceFilteredCount = 0;
|
|
13674
|
+
let forgottenFilteredCount = 0;
|
|
13080
13675
|
const boosted = [];
|
|
13081
13676
|
const recencyWeight = this.effectiveRecencyWeight();
|
|
13082
13677
|
for (const r of results) {
|
|
13083
13678
|
const memory = memoryByPath.get(r.path);
|
|
13084
13679
|
let score = r.score;
|
|
13085
13680
|
if (memory) {
|
|
13681
|
+
if (memory.frontmatter.status === "forgotten") {
|
|
13682
|
+
forgottenFilteredCount += 1;
|
|
13683
|
+
continue;
|
|
13684
|
+
}
|
|
13086
13685
|
if (options?.allowLifecycleFiltered !== true && shouldFilterLifecycleRecallCandidate(memory.frontmatter, {
|
|
13087
13686
|
lifecyclePolicyEnabled: this.config.lifecyclePolicyEnabled,
|
|
13088
13687
|
lifecycleFilterStaleEnabled: this.config.lifecycleFilterStaleEnabled
|
|
@@ -13090,10 +13689,28 @@ ${lines.join("\n\n")}`;
|
|
|
13090
13689
|
lifecycleFilteredCount += 1;
|
|
13091
13690
|
continue;
|
|
13092
13691
|
}
|
|
13093
|
-
|
|
13094
|
-
|
|
13095
|
-
|
|
13096
|
-
|
|
13692
|
+
const asOfActive = typeof options?.asOfMs === "number" && Number.isFinite(options.asOfMs);
|
|
13693
|
+
if (asOfActive) {
|
|
13694
|
+
if (!isValidAsOf(memory.frontmatter, options.asOfMs)) {
|
|
13695
|
+
temporalSupersededFilteredCount += 1;
|
|
13696
|
+
continue;
|
|
13697
|
+
}
|
|
13698
|
+
} else if (
|
|
13699
|
+
// Temporal supersession filter (issue #375): drop memories that
|
|
13700
|
+
// a newer fact has retired, unless the caller opted in to history.
|
|
13701
|
+
// NOTE: This check is intentionally independent of
|
|
13702
|
+
// allowLifecycleFiltered (Finding A fix) — cold fallback sets
|
|
13703
|
+
// allowLifecycleFiltered=true to include archived/retired
|
|
13704
|
+
// candidates, but superseded memories must still be filtered
|
|
13705
|
+
// unless temporalSupersessionIncludeInRecall is set.
|
|
13706
|
+
// Skipped entirely when `as_of` is active (above branch); the
|
|
13707
|
+
// half-open `[valid_at, invalid_at)` evaluation in isValidAsOf
|
|
13708
|
+
// is the authoritative gate for historical recall.
|
|
13709
|
+
shouldFilterSupersededFromRecall(memory.frontmatter, {
|
|
13710
|
+
enabled: this.config.temporalSupersessionEnabled,
|
|
13711
|
+
includeInRecall: this.config.temporalSupersessionIncludeInRecall
|
|
13712
|
+
})
|
|
13713
|
+
) {
|
|
13097
13714
|
temporalSupersededFilteredCount += 1;
|
|
13098
13715
|
continue;
|
|
13099
13716
|
}
|
|
@@ -13192,6 +13809,22 @@ ${lines.join("\n\n")}`;
|
|
|
13192
13809
|
this.utilityRuntimeValues,
|
|
13193
13810
|
lifecycleDelta >= 0 ? "boost" : "suppress"
|
|
13194
13811
|
);
|
|
13812
|
+
let reinforcementBoost = 0;
|
|
13813
|
+
if (this.config.reinforcementRecallBoostEnabled && typeof memory.frontmatter.reinforcement_count === "number" && memory.frontmatter.reinforcement_count > 0) {
|
|
13814
|
+
reinforcementBoost = Math.min(
|
|
13815
|
+
memory.frontmatter.reinforcement_count * this.config.reinforcementRecallBoostWeight,
|
|
13816
|
+
this.config.reinforcementRecallBoostMax
|
|
13817
|
+
);
|
|
13818
|
+
score += reinforcementBoost;
|
|
13819
|
+
}
|
|
13820
|
+
if (reinforcementBoost > 0) {
|
|
13821
|
+
boosted.push({
|
|
13822
|
+
...r,
|
|
13823
|
+
score,
|
|
13824
|
+
explain: { ...r.explain ?? {}, reinforcementBoost }
|
|
13825
|
+
});
|
|
13826
|
+
continue;
|
|
13827
|
+
}
|
|
13195
13828
|
}
|
|
13196
13829
|
boosted.push({ ...r, score });
|
|
13197
13830
|
}
|
|
@@ -13210,6 +13843,11 @@ ${lines.join("\n\n")}`;
|
|
|
13210
13843
|
`dedicated surface filter removed ${dedicatedSurfaceFilteredCount} dream/procedural candidates from generic recall`
|
|
13211
13844
|
);
|
|
13212
13845
|
}
|
|
13846
|
+
if (forgottenFilteredCount > 0) {
|
|
13847
|
+
log.debug(
|
|
13848
|
+
`forgotten status filter removed ${forgottenFilteredCount} candidates from recall`
|
|
13849
|
+
);
|
|
13850
|
+
}
|
|
13213
13851
|
return boosted.sort((a, b) => b.score - a.score);
|
|
13214
13852
|
}
|
|
13215
13853
|
/**
|
|
@@ -13260,7 +13898,9 @@ ${lines.join("\n\n")}`;
|
|
|
13260
13898
|
const resultStorage = await this.storageRouter.storageFor(resultNamespace);
|
|
13261
13899
|
const existingMemory = await resultStorage.getMemoryById(memoryId);
|
|
13262
13900
|
if (!existingMemory) continue;
|
|
13263
|
-
if (existingMemory.frontmatter.status === "superseded")
|
|
13901
|
+
if (existingMemory.frontmatter.status === "superseded" || existingMemory.frontmatter.status === "forgotten") {
|
|
13902
|
+
continue;
|
|
13903
|
+
}
|
|
13264
13904
|
const verification = await this.extraction.verifyContradiction(
|
|
13265
13905
|
{ content, category },
|
|
13266
13906
|
{
|
|
@@ -13324,7 +13964,7 @@ ${lines.join("\n\n")}`;
|
|
|
13324
13964
|
if (resultNamespace !== namespaceScope) continue;
|
|
13325
13965
|
const resultStorage = await this.storageRouter.storageFor(resultNamespace);
|
|
13326
13966
|
const memory = await resultStorage.getMemoryById(memoryId);
|
|
13327
|
-
if (memory && memory.frontmatter.status !== "superseded") {
|
|
13967
|
+
if (memory && memory.frontmatter.status !== "superseded" && memory.frontmatter.status !== "forgotten") {
|
|
13328
13968
|
candidates.push({
|
|
13329
13969
|
id: memory.frontmatter.id,
|
|
13330
13970
|
content: memory.content,
|
|
@@ -13352,8 +13992,8 @@ ${lines.join("\n\n")}`;
|
|
|
13352
13992
|
}
|
|
13353
13993
|
namespaceFromStorageDir(storageDir) {
|
|
13354
13994
|
if (!this.config.namespacesEnabled) return this.config.defaultNamespace;
|
|
13355
|
-
const resolvedStorageDir =
|
|
13356
|
-
const resolvedMemoryDir =
|
|
13995
|
+
const resolvedStorageDir = path6.resolve(storageDir);
|
|
13996
|
+
const resolvedMemoryDir = path6.resolve(this.config.memoryDir);
|
|
13357
13997
|
if (resolvedStorageDir === resolvedMemoryDir)
|
|
13358
13998
|
return this.config.defaultNamespace;
|
|
13359
13999
|
const m = resolvedStorageDir.match(/[\\/]namespaces[\\/]([^\\/]+)$/);
|
|
@@ -13394,9 +14034,6 @@ export {
|
|
|
13394
14034
|
saveTaxonomy,
|
|
13395
14035
|
getTaxonomyDir,
|
|
13396
14036
|
getTaxonomyFilePath,
|
|
13397
|
-
stableHash,
|
|
13398
|
-
normalizeOriginUrl,
|
|
13399
|
-
resolveGitContext,
|
|
13400
14037
|
projectNamespaceName,
|
|
13401
14038
|
branchNamespaceName,
|
|
13402
14039
|
resolveCodingNamespaceOverlay,
|
|
@@ -13429,4 +14066,4 @@ export {
|
|
|
13429
14066
|
resolvePersistedMemoryRelativePath,
|
|
13430
14067
|
Orchestrator
|
|
13431
14068
|
};
|
|
13432
|
-
//# sourceMappingURL=chunk-
|
|
14069
|
+
//# sourceMappingURL=chunk-IM3JSE73.js.map
|