@remnic/core 1.0.3 → 1.1.1
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.d.ts +32 -0
- package/dist/abort-error.js +11 -0
- package/dist/access-audit.d.ts +56 -0
- package/dist/access-audit.js +9 -0
- package/dist/access-audit.js.map +1 -0
- package/dist/access-cli.js +72 -54
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.d.ts +16 -8
- package/dist/access-http.js +25 -17
- package/dist/access-mcp.d.ts +16 -8
- package/dist/access-mcp.js +28 -6
- package/dist/access-schema.d.ts +130 -39
- package/dist/access-schema.js +5 -1
- package/dist/access-service-Br8ZydTK.d.ts +827 -0
- package/dist/access-service.d.ts +20 -660
- package/dist/access-service.js +22 -14
- package/dist/bootstrap.d.ts +6 -3
- package/dist/briefing.d.ts +1 -0
- package/dist/briefing.js +6 -5
- package/dist/buffer-surprise-report.d.ts +70 -0
- package/dist/buffer-surprise-report.js +7 -0
- package/dist/buffer-surprise-report.js.map +1 -0
- package/dist/buffer-surprise.d.ts +98 -0
- package/dist/buffer-surprise.js +11 -0
- package/dist/buffer-surprise.js.map +1 -0
- package/dist/buffer.d.ts +100 -2
- package/dist/buffer.js +1 -1
- package/dist/calibration.js +5 -5
- package/dist/causal-behavior.js +4 -4
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.js +17 -16
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/causal-retrieval.js +4 -4
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-QNJMBKFK.js → chunk-2LGMW3DJ.js} +3 -2
- package/dist/chunk-2LGMW3DJ.js.map +1 -0
- package/dist/{chunk-QDYXG4CS.js → chunk-3FPTCC3Z.js} +4 -3
- package/dist/chunk-3FPTCC3Z.js.map +1 -0
- package/dist/chunk-3GPTTA4J.js +57 -0
- package/dist/chunk-3GPTTA4J.js.map +1 -0
- package/dist/{chunk-QKAH5B6E.js → chunk-3GXCSUXR.js} +94 -6
- package/dist/chunk-3GXCSUXR.js.map +1 -0
- package/dist/{chunk-POBPGDWI.js → chunk-3OGMS3PE.js} +2 -2
- package/dist/chunk-54V4BZWP.js +139 -0
- package/dist/chunk-54V4BZWP.js.map +1 -0
- package/dist/chunk-5JRF2PZA.js +67 -0
- package/dist/chunk-5JRF2PZA.js.map +1 -0
- package/dist/chunk-64NJRYU2.js +332 -0
- package/dist/chunk-64NJRYU2.js.map +1 -0
- package/dist/chunk-6AUUAZEX.js +150 -0
- package/dist/chunk-6AUUAZEX.js.map +1 -0
- package/dist/{chunk-HITJFT7E.js → chunk-7I7FKFZH.js} +28 -21
- package/dist/chunk-7I7FKFZH.js.map +1 -0
- package/dist/chunk-AJU4PJGY.js +126 -0
- package/dist/chunk-AJU4PJGY.js.map +1 -0
- package/dist/chunk-ASAITVLA.js +64 -0
- package/dist/chunk-ASAITVLA.js.map +1 -0
- package/dist/{chunk-X4WESCKA.js → chunk-B5WXLVDY.js} +187 -6
- package/dist/chunk-B5WXLVDY.js.map +1 -0
- package/dist/{chunk-RCICHSHL.js → chunk-BGJGXLZ7.js} +111 -2
- package/dist/{chunk-RCICHSHL.js.map → chunk-BGJGXLZ7.js.map} +1 -1
- package/dist/{chunk-OJFGVJS6.js → chunk-BK2EFTE2.js} +319 -18
- package/dist/chunk-BK2EFTE2.js.map +1 -0
- package/dist/chunk-C4SQJZAF.js +486 -0
- package/dist/chunk-C4SQJZAF.js.map +1 -0
- package/dist/{chunk-GJQPH5G3.js → chunk-CUPFXL3J.js} +2 -2
- package/dist/chunk-DF3RVK3X.js +119 -0
- package/dist/chunk-DF3RVK3X.js.map +1 -0
- package/dist/{chunk-PMB3WGDL.js → chunk-DFTTJYSO.js} +167 -7
- package/dist/chunk-DFTTJYSO.js.map +1 -0
- package/dist/chunk-DGVM5SFL.js +69 -0
- package/dist/chunk-DGVM5SFL.js.map +1 -0
- package/dist/chunk-EIR5VLIH.js +90 -0
- package/dist/chunk-EIR5VLIH.js.map +1 -0
- package/dist/{chunk-PAORGQRI.js → chunk-EPQJM2GC.js} +37 -23
- package/dist/chunk-EPQJM2GC.js.map +1 -0
- package/dist/{chunk-POMSFKTB.js → chunk-F5VP6YCB.js} +368 -10
- package/dist/chunk-F5VP6YCB.js.map +1 -0
- package/dist/{chunk-6ZH4TU6I.js → chunk-FAAFWE4G.js} +2 -1
- package/dist/chunk-FAAFWE4G.js.map +1 -0
- package/dist/{chunk-74JR4N5J.js → chunk-FVA6TGI3.js} +2 -2
- package/dist/chunk-GDFS42HT.js +206 -0
- package/dist/chunk-GDFS42HT.js.map +1 -0
- package/dist/{chunk-BKQJBXXX.js → chunk-GGD5W7TB.js} +2 -2
- package/dist/chunk-GGD5W7TB.js.map +1 -0
- package/dist/{chunk-V7XCAHIB.js → chunk-GKFXUTJ2.js} +508 -26
- package/dist/chunk-GKFXUTJ2.js.map +1 -0
- package/dist/{chunk-NSB3WSYS.js → chunk-HK3FGIEW.js} +278 -3
- package/dist/chunk-HK3FGIEW.js.map +1 -0
- package/dist/{chunk-AAI7JARD.js → chunk-HMDCOMYU.js} +8 -11
- package/dist/chunk-HMDCOMYU.js.map +1 -0
- package/dist/chunk-IISBCCWR.js +52 -0
- package/dist/chunk-IISBCCWR.js.map +1 -0
- package/dist/{chunk-YFYL2SIJ.js → chunk-INXV5JBT.js} +290 -46
- package/dist/chunk-INXV5JBT.js.map +1 -0
- package/dist/chunk-JBMSGZEQ.js +441 -0
- package/dist/chunk-JBMSGZEQ.js.map +1 -0
- package/dist/{chunk-UPMD5XND.js → chunk-JL2PU6AI.js} +16 -5
- package/dist/chunk-JL2PU6AI.js.map +1 -0
- package/dist/{chunk-J4IYOZZ5.js → chunk-JXS5PDQ7.js} +3 -1
- package/dist/chunk-JXS5PDQ7.js.map +1 -0
- package/dist/{chunk-AYPYCLR7.js → chunk-KUB6JU6H.js} +4 -4
- package/dist/chunk-KVBLZUKV.js +173 -0
- package/dist/chunk-KVBLZUKV.js.map +1 -0
- package/dist/chunk-LBLXEFWK.js +51 -0
- package/dist/chunk-LBLXEFWK.js.map +1 -0
- package/dist/{chunk-U2IQTSBY.js → chunk-LTCGGW2D.js} +1 -1
- package/dist/chunk-LTCGGW2D.js.map +1 -0
- package/dist/{chunk-UEYA6UC7.js → chunk-NZLQTHS5.js} +25 -2
- package/dist/chunk-NZLQTHS5.js.map +1 -0
- package/dist/chunk-PVGDJXVK.js +21 -0
- package/dist/chunk-PVGDJXVK.js.map +1 -0
- package/dist/chunk-PVPWZSSI.js +37 -0
- package/dist/chunk-PVPWZSSI.js.map +1 -0
- package/dist/{chunk-4NRAJUDS.js → chunk-RBBWYEFJ.js} +1 -1
- package/dist/chunk-RFYAYKTD.js +146 -0
- package/dist/chunk-RFYAYKTD.js.map +1 -0
- package/dist/{chunk-JROGC36Y.js → chunk-RGLL5SPU.js} +2 -2
- package/dist/{chunk-2VFW5K5U.js → chunk-S3EEFKNY.js} +103 -65
- package/dist/chunk-S3EEFKNY.js.map +1 -0
- package/dist/chunk-SOBJ6NEY.js +18 -0
- package/dist/chunk-SOBJ6NEY.js.map +1 -0
- package/dist/{chunk-MYQWXITD.js → chunk-SPI27QT6.js} +2 -2
- package/dist/chunk-TVVEYCNW.js +65 -0
- package/dist/chunk-TVVEYCNW.js.map +1 -0
- package/dist/chunk-ULYOGL6R.js +322 -0
- package/dist/chunk-ULYOGL6R.js.map +1 -0
- package/dist/{chunk-S4LX5EBI.js → chunk-VBVG2M5G.js} +64 -10
- package/dist/chunk-VBVG2M5G.js.map +1 -0
- package/dist/{chunk-KWP7T3DP.js → chunk-VDX363PS.js} +2 -2
- package/dist/{chunk-XMGSSBFX.js → chunk-VYM3VWOF.js} +1560 -244
- package/dist/chunk-VYM3VWOF.js.map +1 -0
- package/dist/{chunk-MTLYEMJB.js → chunk-WCLICCGB.js} +18 -3
- package/dist/chunk-WCLICCGB.js.map +1 -0
- package/dist/{chunk-ECKDIK5F.js → chunk-WVVA7F5A.js} +2 -2
- package/dist/chunk-X6GF3FX2.js +26 -0
- package/dist/chunk-X6GF3FX2.js.map +1 -0
- package/dist/{chunk-3QFQGRHO.js → chunk-XMHBH5H6.js} +4 -4
- package/dist/{chunk-KEG4GNGI.js → chunk-XZ2TIKGC.js} +38 -8
- package/dist/chunk-XZ2TIKGC.js.map +1 -0
- package/dist/chunk-Y4FHOFJ2.js +140 -0
- package/dist/chunk-Y4FHOFJ2.js.map +1 -0
- package/dist/chunk-YNB73F22.js +137 -0
- package/dist/chunk-YNB73F22.js.map +1 -0
- package/dist/{chunk-7PA4OZEU.js → chunk-YNQKWQT4.js} +55 -30
- package/dist/chunk-YNQKWQT4.js.map +1 -0
- package/dist/chunk-ZAIM4TUE.js +488 -0
- package/dist/chunk-ZAIM4TUE.js.map +1 -0
- package/dist/{chunk-BTY5RRRF.js → chunk-ZEM3OK2K.js} +5 -5
- package/dist/chunk-ZZTOURJI.js +91 -0
- package/dist/chunk-ZZTOURJI.js.map +1 -0
- package/dist/{cli-DwIBnp2g.d.ts → cli-BkeRaYfk.d.ts} +2 -2
- package/dist/cli.d.ts +13 -5
- package/dist/cli.js +45 -33
- package/dist/config.js +1 -1
- package/dist/consolidation-operator.d.ts +41 -0
- package/dist/consolidation-operator.js +11 -0
- package/dist/consolidation-operator.js.map +1 -0
- package/dist/consolidation-provenance-check.d.ts +68 -0
- package/dist/consolidation-provenance-check.js +9 -0
- package/dist/consolidation-provenance-check.js.map +1 -0
- package/dist/consolidation-undo.d.ts +123 -0
- package/dist/consolidation-undo.js +426 -0
- package/dist/consolidation-undo.js.map +1 -0
- package/dist/contradiction-review-WIUBAR52.js +21 -0
- package/dist/contradiction-review-WIUBAR52.js.map +1 -0
- package/dist/contradiction-scan-E3GJTI4F.js +412 -0
- package/dist/contradiction-scan-E3GJTI4F.js.map +1 -0
- package/dist/cross-namespace-budget.d.ts +133 -0
- package/dist/cross-namespace-budget.js +9 -0
- package/dist/cross-namespace-budget.js.map +1 -0
- package/dist/direct-answer-wiring.d.ts +77 -0
- package/dist/direct-answer-wiring.js +10 -0
- package/dist/direct-answer-wiring.js.map +1 -0
- package/dist/direct-answer.d.ts +106 -0
- package/dist/direct-answer.js +10 -0
- package/dist/direct-answer.js.map +1 -0
- package/dist/{engine-X7X3AAG3.js → engine-F3GOXGE5.js} +7 -6
- package/dist/engine-F3GOXGE5.js.map +1 -0
- package/dist/entity-retrieval.d.ts +1 -0
- package/dist/entity-retrieval.js +6 -5
- package/dist/explicit-capture.d.ts +6 -3
- package/dist/explicit-capture.js +2 -2
- package/dist/extraction-judge-telemetry.d.ts +113 -0
- package/dist/extraction-judge-telemetry.js +14 -0
- package/dist/extraction-judge-telemetry.js.map +1 -0
- package/dist/extraction-judge-training.d.ts +85 -0
- package/dist/extraction-judge-training.js +16 -0
- package/dist/extraction-judge-training.js.map +1 -0
- package/dist/extraction-judge.d.ts +124 -2
- package/dist/extraction-judge.js +11 -1
- package/dist/extraction.js +7 -6
- package/dist/fallback-llm.d.ts +11 -2
- package/dist/fallback-llm.js +2 -2
- package/dist/graph-recall.d.ts +100 -0
- package/dist/graph-recall.js +8 -0
- package/dist/graph-recall.js.map +1 -0
- package/dist/graph-retrieval.d.ts +271 -0
- package/dist/graph-retrieval.js +21 -0
- package/dist/graph-retrieval.js.map +1 -0
- package/dist/harmonic-retrieval.js +2 -1
- package/dist/importance.js +1 -1
- package/dist/index.d.ts +589 -138
- package/dist/index.js +531 -403
- package/dist/index.js.map +1 -1
- package/dist/intent.js +1 -1
- package/dist/local-llm.d.ts +10 -3
- package/dist/local-llm.js +1 -1
- package/dist/memory-worth-bench.d.ts +51 -0
- package/dist/memory-worth-bench.js +131 -0
- package/dist/memory-worth-bench.js.map +1 -0
- package/dist/memory-worth-filter.d.ts +128 -0
- package/dist/memory-worth-filter.js +10 -0
- package/dist/memory-worth-filter.js.map +1 -0
- package/dist/memory-worth-outcomes.d.ts +118 -0
- package/dist/memory-worth-outcomes.js +9 -0
- package/dist/memory-worth-outcomes.js.map +1 -0
- package/dist/memory-worth.d.ts +102 -0
- package/dist/memory-worth.js +7 -0
- package/dist/memory-worth.js.map +1 -0
- package/dist/operator-toolkit.d.ts +40 -1
- package/dist/operator-toolkit.js +24 -14
- package/dist/{orchestrator-B9kwlCep.d.ts → orchestrator-CmJ-NTdJ.d.ts} +254 -10
- package/dist/orchestrator.d.ts +6 -3
- package/dist/orchestrator.js +59 -48
- package/dist/page-versioning.d.ts +12 -1
- package/dist/page-versioning.js +5 -3
- package/dist/{port-C1GZFv8h.d.ts → port-BADbLZU5.d.ts} +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +5 -3
- package/dist/qmd.js +2 -1
- package/dist/reasoning-trace-recall.d.ts +90 -0
- package/dist/reasoning-trace-recall.js +13 -0
- package/dist/reasoning-trace-recall.js.map +1 -0
- package/dist/reasoning-trace-types.d.ts +54 -0
- package/dist/reasoning-trace-types.js +17 -0
- package/dist/reasoning-trace-types.js.map +1 -0
- package/dist/recall-audit-anomaly.d.ts +112 -0
- package/dist/recall-audit-anomaly.js +11 -0
- package/dist/recall-audit-anomaly.js.map +1 -0
- package/dist/recall-audit.js +5 -44
- package/dist/recall-audit.js.map +1 -1
- package/dist/recall-explain-renderer.d.ts +49 -0
- package/dist/recall-explain-renderer.js +18 -0
- package/dist/recall-explain-renderer.js.map +1 -0
- package/dist/recall-state.d.ts +39 -1
- package/dist/recall-state.js +1 -1
- package/dist/recall-xray-cli.d.ts +40 -0
- package/dist/recall-xray-cli.js +11 -0
- package/dist/recall-xray-cli.js.map +1 -0
- package/dist/recall-xray-renderer.d.ts +44 -0
- package/dist/recall-xray-renderer.js +18 -0
- package/dist/recall-xray-renderer.js.map +1 -0
- package/dist/recall-xray.d.ts +179 -0
- package/dist/recall-xray.js +13 -0
- package/dist/recall-xray.js.map +1 -0
- package/dist/resolution-QBTDHTG7.js +100 -0
- package/dist/resolution-QBTDHTG7.js.map +1 -0
- package/dist/resolve-provider-secret.d.ts +24 -1
- package/dist/resolve-provider-secret.js +3 -1
- package/dist/resume-bundles.js +6 -6
- package/dist/retrieval-agents.d.ts +1 -1
- package/dist/retrieval-tiers.d.ts +17 -0
- package/dist/retrieval-tiers.js +9 -0
- package/dist/retrieval-tiers.js.map +1 -0
- package/dist/schemas.d.ts +301 -45
- package/dist/schemas.js +1 -1
- package/dist/{semantic-consolidation-DrvSYRdB.d.ts → semantic-consolidation-CxJU6MJk.d.ts} +62 -1
- package/dist/semantic-consolidation.d.ts +2 -1
- package/dist/semantic-consolidation.js +20 -6
- package/dist/semantic-rule-promotion.js +6 -5
- package/dist/semantic-rule-verifier.js +6 -5
- package/dist/storage.d.ts +82 -1
- package/dist/storage.js +5 -4
- package/dist/summarizer.js +4 -4
- package/dist/temporal-supersession.d.ts +1 -0
- package/dist/tier-migration.d.ts +2 -1
- package/dist/types-DJhqDJUV.d.ts +50 -0
- package/dist/types.d.ts +309 -3
- package/dist/types.js +1 -1
- package/dist/verified-recall.js +6 -5
- package/package.json +1 -1
- package/dist/chunk-2VFW5K5U.js.map +0 -1
- package/dist/chunk-6ZH4TU6I.js.map +0 -1
- package/dist/chunk-7PA4OZEU.js.map +0 -1
- package/dist/chunk-AAI7JARD.js.map +0 -1
- package/dist/chunk-BKQJBXXX.js.map +0 -1
- package/dist/chunk-HITJFT7E.js.map +0 -1
- package/dist/chunk-J4IYOZZ5.js.map +0 -1
- package/dist/chunk-KEG4GNGI.js.map +0 -1
- package/dist/chunk-LAYN4LDC.js +0 -267
- package/dist/chunk-LAYN4LDC.js.map +0 -1
- package/dist/chunk-MTLYEMJB.js.map +0 -1
- package/dist/chunk-NSB3WSYS.js.map +0 -1
- package/dist/chunk-OJFGVJS6.js.map +0 -1
- package/dist/chunk-PAORGQRI.js.map +0 -1
- package/dist/chunk-PMB3WGDL.js.map +0 -1
- package/dist/chunk-POMSFKTB.js.map +0 -1
- package/dist/chunk-QDYXG4CS.js.map +0 -1
- package/dist/chunk-QKAH5B6E.js.map +0 -1
- package/dist/chunk-QNJMBKFK.js.map +0 -1
- package/dist/chunk-S4LX5EBI.js.map +0 -1
- package/dist/chunk-U2IQTSBY.js.map +0 -1
- package/dist/chunk-UEYA6UC7.js.map +0 -1
- package/dist/chunk-UPMD5XND.js.map +0 -1
- package/dist/chunk-UVJFDP7P.js +0 -202
- package/dist/chunk-UVJFDP7P.js.map +0 -1
- package/dist/chunk-V7XCAHIB.js.map +0 -1
- package/dist/chunk-X4WESCKA.js.map +0 -1
- package/dist/chunk-XMGSSBFX.js.map +0 -1
- package/dist/chunk-YFYL2SIJ.js.map +0 -1
- /package/dist/{engine-X7X3AAG3.js.map → abort-error.js.map} +0 -0
- /package/dist/{chunk-POBPGDWI.js.map → chunk-3OGMS3PE.js.map} +0 -0
- /package/dist/{chunk-GJQPH5G3.js.map → chunk-CUPFXL3J.js.map} +0 -0
- /package/dist/{chunk-74JR4N5J.js.map → chunk-FVA6TGI3.js.map} +0 -0
- /package/dist/{chunk-AYPYCLR7.js.map → chunk-KUB6JU6H.js.map} +0 -0
- /package/dist/{chunk-4NRAJUDS.js.map → chunk-RBBWYEFJ.js.map} +0 -0
- /package/dist/{chunk-JROGC36Y.js.map → chunk-RGLL5SPU.js.map} +0 -0
- /package/dist/{chunk-MYQWXITD.js.map → chunk-SPI27QT6.js.map} +0 -0
- /package/dist/{chunk-KWP7T3DP.js.map → chunk-VDX363PS.js.map} +0 -0
- /package/dist/{chunk-ECKDIK5F.js.map → chunk-WVVA7F5A.js.map} +0 -0
- /package/dist/{chunk-3QFQGRHO.js.map → chunk-XMHBH5H6.js.map} +0 -0
- /package/dist/{chunk-BTY5RRRF.js.map → chunk-ZEM3OK2K.js.map} +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { LastRecallSnapshot } from './recall-state.js';
|
|
2
|
+
import { RecallTierExplain } from './types.js';
|
|
3
|
+
import { RecallXraySnapshot } from './recall-xray.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Renderers for RecallTierExplain (issue #518).
|
|
7
|
+
*
|
|
8
|
+
* Pure functions that format a `LastRecallSnapshot` and its
|
|
9
|
+
* optional `tierExplain` field for human text and machine JSON
|
|
10
|
+
* consumption. CLI / HTTP / MCP surfaces consume these — they do
|
|
11
|
+
* not format explain output themselves, so rendering is tested in
|
|
12
|
+
* one place.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `text` and `json` are the original formats (backwards-compatible
|
|
17
|
+
* since issue #518). `markdown` was added in issue #570 PR 7 and
|
|
18
|
+
* delegates to the shared X-ray renderer so the three observability
|
|
19
|
+
* surfaces stay in lock-step (CLAUDE.md rule 22).
|
|
20
|
+
*/
|
|
21
|
+
type RecallExplainFormat = "text" | "json" | "markdown";
|
|
22
|
+
interface RecallExplainJsonPayload {
|
|
23
|
+
hasExplain: boolean;
|
|
24
|
+
snapshotFound: boolean;
|
|
25
|
+
sessionKey: string | null;
|
|
26
|
+
recordedAt: string | null;
|
|
27
|
+
namespace: string | null;
|
|
28
|
+
memoryIds: string[];
|
|
29
|
+
source: string | null;
|
|
30
|
+
sourcesUsed: string[] | null;
|
|
31
|
+
latencyMs: number | null;
|
|
32
|
+
tierExplain: RecallTierExplain | null;
|
|
33
|
+
}
|
|
34
|
+
declare function toRecallExplainJson(snapshot: LastRecallSnapshot | null): RecallExplainJsonPayload;
|
|
35
|
+
/**
|
|
36
|
+
* Render the shared "--- tier explain ---" text block used by both the
|
|
37
|
+
* recall-explain surface and the Recall X-ray surface. Callers provide
|
|
38
|
+
* the normalized `RecallTierExplain` (or `null` for the
|
|
39
|
+
* not-populated/disabled case) so the block stays character-for-character
|
|
40
|
+
* identical across surfaces (CLAUDE.md rule 22). The returned strings do
|
|
41
|
+
* NOT include leading blank lines or headers — callers own that framing.
|
|
42
|
+
*/
|
|
43
|
+
declare function renderTierExplainTextLines(tierExplain: RecallTierExplain | null): string[];
|
|
44
|
+
declare function toRecallExplainText(snapshot: LastRecallSnapshot | null): string;
|
|
45
|
+
declare function toRecallXraySnapshotFromLegacy(snapshot: LastRecallSnapshot | null): RecallXraySnapshot | null;
|
|
46
|
+
declare function renderRecallExplain(snapshot: LastRecallSnapshot | null, format: RecallExplainFormat): string;
|
|
47
|
+
declare function parseRecallExplainFormat(value: unknown): RecallExplainFormat;
|
|
48
|
+
|
|
49
|
+
export { type RecallExplainFormat, type RecallExplainJsonPayload, parseRecallExplainFormat, renderRecallExplain, renderTierExplainTextLines, toRecallExplainJson, toRecallExplainText, toRecallXraySnapshotFromLegacy };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseRecallExplainFormat,
|
|
3
|
+
renderRecallExplain,
|
|
4
|
+
renderTierExplainTextLines,
|
|
5
|
+
toRecallExplainJson,
|
|
6
|
+
toRecallExplainText,
|
|
7
|
+
toRecallXraySnapshotFromLegacy
|
|
8
|
+
} from "./chunk-ZAIM4TUE.js";
|
|
9
|
+
import "./chunk-SOBJ6NEY.js";
|
|
10
|
+
export {
|
|
11
|
+
parseRecallExplainFormat,
|
|
12
|
+
renderRecallExplain,
|
|
13
|
+
renderTierExplainTextLines,
|
|
14
|
+
toRecallExplainJson,
|
|
15
|
+
toRecallExplainText,
|
|
16
|
+
toRecallXraySnapshotFromLegacy
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=recall-explain-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/recall-state.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RecallPlanMode, IdentityInjectionMode } from './types.js';
|
|
1
|
+
import { RecallPlanMode, IdentityInjectionMode, RecallTierExplain } from './types.js';
|
|
2
2
|
|
|
3
3
|
interface LastRecallBudgetSummary {
|
|
4
4
|
requestedTopK?: number;
|
|
@@ -32,6 +32,22 @@ interface LastRecallSnapshot {
|
|
|
32
32
|
identityInjectionMode?: IdentityInjectionMode | "none";
|
|
33
33
|
identityInjectedChars?: number;
|
|
34
34
|
identityInjectionTruncated?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Collision-safe write nonce. Random UUID set on every `record()`
|
|
37
|
+
* call so the observation-mode direct-answer hook can detect stale
|
|
38
|
+
* snapshots and avoid annotating a snapshot that a subsequent recall
|
|
39
|
+
* already replaced (issue #518).
|
|
40
|
+
*/
|
|
41
|
+
writeNonce?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Optional tier-level explanation of how recall was served
|
|
44
|
+
* (issue #518). Populated by orchestrator call sites that can
|
|
45
|
+
* identify a concrete tier; surfaces expose the block via
|
|
46
|
+
* `engram query --explain`, the `?explain=1` HTTP flag, and the
|
|
47
|
+
* `remnic_recall_explain` MCP tool. Orthogonal to the existing
|
|
48
|
+
* graph-path `recallExplain` operation.
|
|
49
|
+
*/
|
|
50
|
+
tierExplain?: RecallTierExplain;
|
|
35
51
|
}
|
|
36
52
|
interface GraphRecallExpandedEntry {
|
|
37
53
|
path: string;
|
|
@@ -99,6 +115,28 @@ declare class LastRecallStore {
|
|
|
99
115
|
injectedChars: number;
|
|
100
116
|
truncated: boolean;
|
|
101
117
|
};
|
|
118
|
+
/**
|
|
119
|
+
* Per-tier explain annotation (issue #518). When supplied, the
|
|
120
|
+
* snapshot carries it so downstream surfaces (CLI / HTTP / MCP)
|
|
121
|
+
* can render which retrieval tier served the query.
|
|
122
|
+
*/
|
|
123
|
+
tierExplain?: RecallTierExplain;
|
|
124
|
+
}): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Attach a RecallTierExplain block to the existing snapshot for a
|
|
127
|
+
* session without rewriting the entire snapshot. Used by the
|
|
128
|
+
* post-recall direct-answer annotation path (issue #518 slice 3c):
|
|
129
|
+
* recallInternal records the snapshot first, then the orchestrator
|
|
130
|
+
* fires the direct-answer tier in observation mode and annotates
|
|
131
|
+
* the stored snapshot with whichever tier served the query.
|
|
132
|
+
*
|
|
133
|
+
* No-op when no snapshot exists for the given session; callers do
|
|
134
|
+
* not need to guard on existence.
|
|
135
|
+
*/
|
|
136
|
+
annotateTierExplain(sessionKey: string, tierExplain: RecallTierExplain, expected?: {
|
|
137
|
+
writeNonce?: string;
|
|
138
|
+
traceId?: string;
|
|
139
|
+
recordedAt?: string;
|
|
102
140
|
}): Promise<void>;
|
|
103
141
|
}
|
|
104
142
|
declare class TierMigrationStatusStore {
|
package/dist/recall-state.js
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { RecallXrayFormat } from './recall-xray-renderer.js';
|
|
2
|
+
import './recall-xray.js';
|
|
3
|
+
import './types.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Input-validation helpers for the `remnic xray` CLI command (issue
|
|
7
|
+
* #570, PR 3).
|
|
8
|
+
*
|
|
9
|
+
* Pulled out of `cli.ts` so the validation paths can be unit-tested in
|
|
10
|
+
* isolation — the full CLI handler is hard to exercise without booting
|
|
11
|
+
* an orchestrator. CLAUDE.md rules 14 + 51 require that `--format`,
|
|
12
|
+
* `--budget`, `--namespace`, and `--out` reject missing-value /
|
|
13
|
+
* unknown / non-positive arguments with a listed-options error, rather
|
|
14
|
+
* than silently defaulting.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
interface ParsedXrayCliOptions {
|
|
18
|
+
format: RecallXrayFormat;
|
|
19
|
+
/** Positive integer override, or undefined when not specified. */
|
|
20
|
+
budget?: number;
|
|
21
|
+
/** Trimmed namespace, or undefined when not specified. */
|
|
22
|
+
namespace?: string;
|
|
23
|
+
/** Trimmed, tilde-unexpanded output path, or undefined when stdout. */
|
|
24
|
+
outPath?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validate and coerce `--budget <chars>`. Must be a positive integer;
|
|
28
|
+
* throws a listed-options error otherwise.
|
|
29
|
+
*/
|
|
30
|
+
declare function parseXrayBudgetFlag(value: unknown): number | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Parse and validate the full option bag for `remnic xray`. Extracted
|
|
33
|
+
* so the CLI handler in `cli.ts` can stay thin and the validation can
|
|
34
|
+
* be unit-tested without booting an orchestrator.
|
|
35
|
+
*/
|
|
36
|
+
declare function parseXrayCliOptions(rawQuery: unknown, options: Record<string, unknown>): {
|
|
37
|
+
query: string;
|
|
38
|
+
} & ParsedXrayCliOptions;
|
|
39
|
+
|
|
40
|
+
export { type ParsedXrayCliOptions, parseXrayBudgetFlag, parseXrayCliOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { RecallXraySnapshot } from './recall-xray.js';
|
|
2
|
+
import './types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Unified Recall X-ray renderer (issue #570, PR 2).
|
|
6
|
+
*
|
|
7
|
+
* Pure functions that format a `RecallXraySnapshot` for human text,
|
|
8
|
+
* GitHub-flavored markdown, and machine JSON consumption. CLI / HTTP
|
|
9
|
+
* / MCP surfaces all call into this module — they do NOT format X-ray
|
|
10
|
+
* output themselves, so rendering is tested in one place (CLAUDE.md
|
|
11
|
+
* rule 22).
|
|
12
|
+
*
|
|
13
|
+
* Scope for PR 2 (this slice):
|
|
14
|
+
* - Pure rendering. No IO, no transport, no capture.
|
|
15
|
+
* - `renderXray(snapshot, format)` with format ∈
|
|
16
|
+
* `{"json", "text", "markdown"}`.
|
|
17
|
+
* - `parseXrayFormat(value)` — input validator that rejects unknown
|
|
18
|
+
* formats with a listed-options error (CLAUDE.md rule 51).
|
|
19
|
+
* - Golden-file-style tests in `recall-xray-renderer.test.ts`.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
type RecallXrayFormat = "json" | "text" | "markdown";
|
|
23
|
+
declare const RECALL_XRAY_FORMATS: readonly RecallXrayFormat[];
|
|
24
|
+
/**
|
|
25
|
+
* Validate and coerce a user-provided `--format` / `format` argument to
|
|
26
|
+
* `RecallXrayFormat`. Unknown values throw an error listing valid
|
|
27
|
+
* options (CLAUDE.md rule 51). `undefined`/`null` defaults to `"text"`.
|
|
28
|
+
*/
|
|
29
|
+
declare function parseXrayFormat(value: unknown): RecallXrayFormat;
|
|
30
|
+
/**
|
|
31
|
+
* Top-level dispatcher. CLI / HTTP / MCP callers should always route
|
|
32
|
+
* through this function so the three formats stay in lock-step.
|
|
33
|
+
*/
|
|
34
|
+
declare function renderXray(snapshot: RecallXraySnapshot | null, format: RecallXrayFormat): string;
|
|
35
|
+
/**
|
|
36
|
+
* Deterministic JSON encoding of an X-ray snapshot. Returns a stable
|
|
37
|
+
* v1 envelope when the snapshot is absent so consumers can pattern-match
|
|
38
|
+
* on `snapshotFound` rather than distinguishing `null` vs `{}`.
|
|
39
|
+
*/
|
|
40
|
+
declare function renderXrayJson(snapshot: RecallXraySnapshot | null): string;
|
|
41
|
+
declare function renderXrayText(snapshot: RecallXraySnapshot | null): string;
|
|
42
|
+
declare function renderXrayMarkdown(snapshot: RecallXraySnapshot | null): string;
|
|
43
|
+
|
|
44
|
+
export { RECALL_XRAY_FORMATS, type RecallXrayFormat, parseXrayFormat, renderXray, renderXrayJson, renderXrayMarkdown, renderXrayText };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RECALL_XRAY_FORMATS,
|
|
3
|
+
parseXrayFormat,
|
|
4
|
+
renderXray,
|
|
5
|
+
renderXrayJson,
|
|
6
|
+
renderXrayMarkdown,
|
|
7
|
+
renderXrayText
|
|
8
|
+
} from "./chunk-ZAIM4TUE.js";
|
|
9
|
+
import "./chunk-SOBJ6NEY.js";
|
|
10
|
+
export {
|
|
11
|
+
RECALL_XRAY_FORMATS,
|
|
12
|
+
parseXrayFormat,
|
|
13
|
+
renderXray,
|
|
14
|
+
renderXrayJson,
|
|
15
|
+
renderXrayMarkdown,
|
|
16
|
+
renderXrayText
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=recall-xray-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { RecallTierExplain } from './types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Recall X-ray snapshot schema (issue #570, PR 1).
|
|
5
|
+
*
|
|
6
|
+
* The X-ray surface is the unified, per-result attribution document that
|
|
7
|
+
* merges the tier that served each memory, its score decomposition, any
|
|
8
|
+
* graph path, an audit entry id, and the exact filter/eligibility ladder
|
|
9
|
+
* that either admitted or rejected each candidate. This file defines the
|
|
10
|
+
* schema and an in-memory builder + builder-state helper.
|
|
11
|
+
*
|
|
12
|
+
* Scope for PR 1 (this slice):
|
|
13
|
+
* - Types only + pure builder functions (no IO, no rendering).
|
|
14
|
+
* - Orchestrator plumbing captures a snapshot when the caller passes
|
|
15
|
+
* `xrayCapture: true`. No behavior change when the flag is absent.
|
|
16
|
+
* - NO new public surfaces here — CLI/HTTP/MCP land in later slices.
|
|
17
|
+
*
|
|
18
|
+
* The shared renderer lands in PR 2 at `recall-xray-renderer.ts`. Do not
|
|
19
|
+
* fork formatting logic into other surfaces; extend the renderer.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Which retrieval source produced a given result. This is the X-ray
|
|
24
|
+
* tier ladder called out in issue #570 and is *distinct* from the
|
|
25
|
+
* `RetrievalTier` enum (which describes issue #518's tier-explain
|
|
26
|
+
* block). Keeping the sets separate lets the two observability
|
|
27
|
+
* surfaces evolve without conflating their vocabularies:
|
|
28
|
+
*
|
|
29
|
+
* - `RetrievalTier` — direct-answer eligibility ladder.
|
|
30
|
+
* - `RecallXrayServedBy` — which source materialized each result.
|
|
31
|
+
*/
|
|
32
|
+
type RecallXrayServedBy = "direct-answer" | "hybrid" | "graph" | "recent-scan" | "procedural" | "review-context";
|
|
33
|
+
declare const RECALL_XRAY_SERVED_BY_VALUES: readonly RecallXrayServedBy[];
|
|
34
|
+
declare function isRecallXrayServedBy(value: unknown): value is RecallXrayServedBy;
|
|
35
|
+
/**
|
|
36
|
+
* Score decomposition for a single X-ray result.
|
|
37
|
+
*
|
|
38
|
+
* All fields are optional because different tiers populate different
|
|
39
|
+
* terms: `hybrid` reports vector + bm25 + mmr penalty, `direct-answer`
|
|
40
|
+
* reports importance + tier prior, etc. The only guaranteed field is
|
|
41
|
+
* `final`, which is the post-combination score used for ordering.
|
|
42
|
+
*/
|
|
43
|
+
interface RecallXrayScoreDecomposition {
|
|
44
|
+
vector?: number;
|
|
45
|
+
bm25?: number;
|
|
46
|
+
importance?: number;
|
|
47
|
+
mmrPenalty?: number;
|
|
48
|
+
tierPrior?: number;
|
|
49
|
+
final: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Per-result breakdown inside an X-ray snapshot.
|
|
53
|
+
*/
|
|
54
|
+
interface RecallXrayResult {
|
|
55
|
+
memoryId: string;
|
|
56
|
+
path: string;
|
|
57
|
+
servedBy: RecallXrayServedBy;
|
|
58
|
+
scoreDecomposition: RecallXrayScoreDecomposition;
|
|
59
|
+
graphPath?: string[];
|
|
60
|
+
auditEntryId?: string;
|
|
61
|
+
/** Human-readable list of filters the candidate *passed*. */
|
|
62
|
+
admittedBy: string[];
|
|
63
|
+
/**
|
|
64
|
+
* First filter that *would have* rejected the candidate, or undefined
|
|
65
|
+
* when the candidate was admitted without a rejection trace. When
|
|
66
|
+
* present, `admittedBy` may still contain filters the candidate passed
|
|
67
|
+
* before the rejecting gate; consumers should render both.
|
|
68
|
+
*/
|
|
69
|
+
rejectedBy?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Trace entry for a filter the orchestrator evaluated during recall.
|
|
73
|
+
* Captures the name of the filter, how many candidates it saw, and how
|
|
74
|
+
* many it let through. Used by X-ray consumers to render the filter
|
|
75
|
+
* ladder above the per-result breakdown.
|
|
76
|
+
*/
|
|
77
|
+
interface RecallFilterTrace {
|
|
78
|
+
name: string;
|
|
79
|
+
considered: number;
|
|
80
|
+
admitted: number;
|
|
81
|
+
/** Optional human-readable reason for any rejections. */
|
|
82
|
+
reason?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The unified X-ray snapshot. CLI, HTTP, and MCP surfaces all render
|
|
86
|
+
* this same shape through the shared renderer (CLAUDE.md rule 22).
|
|
87
|
+
*/
|
|
88
|
+
interface RecallXraySnapshot {
|
|
89
|
+
/** Stable v1 tag so downstream consumers can version-gate their parsers. */
|
|
90
|
+
schemaVersion: "1";
|
|
91
|
+
query: string;
|
|
92
|
+
/** UUID minted per capture; unique across snapshots within a process. */
|
|
93
|
+
snapshotId: string;
|
|
94
|
+
/** Epoch milliseconds the snapshot was captured. */
|
|
95
|
+
capturedAt: number;
|
|
96
|
+
/**
|
|
97
|
+
* Tier-explain block from issue #518, carried verbatim when present.
|
|
98
|
+
* `null` means direct-answer tier did not run (disabled, or another
|
|
99
|
+
* tier served the query).
|
|
100
|
+
*/
|
|
101
|
+
tierExplain: RecallTierExplain | null;
|
|
102
|
+
results: RecallXrayResult[];
|
|
103
|
+
filters: RecallFilterTrace[];
|
|
104
|
+
/**
|
|
105
|
+
* Character budget accounting for the final assembled recall payload.
|
|
106
|
+
* `used` is the rendered-context length; `chars` is the cap. Both are
|
|
107
|
+
* non-negative integers in `[0, 2**31)`.
|
|
108
|
+
*/
|
|
109
|
+
budget: {
|
|
110
|
+
chars: number;
|
|
111
|
+
used: number;
|
|
112
|
+
};
|
|
113
|
+
/** Optional session-scope fields carried for downstream filtering. */
|
|
114
|
+
sessionKey?: string;
|
|
115
|
+
namespace?: string;
|
|
116
|
+
traceId?: string;
|
|
117
|
+
}
|
|
118
|
+
interface BuildXraySnapshotInput {
|
|
119
|
+
query: string;
|
|
120
|
+
tierExplain?: RecallTierExplain | null;
|
|
121
|
+
results?: RecallXrayResult[];
|
|
122
|
+
filters?: RecallFilterTrace[];
|
|
123
|
+
budget?: {
|
|
124
|
+
chars?: number;
|
|
125
|
+
used?: number;
|
|
126
|
+
};
|
|
127
|
+
sessionKey?: string;
|
|
128
|
+
namespace?: string;
|
|
129
|
+
traceId?: string;
|
|
130
|
+
/** Optional injected timestamp for deterministic tests. */
|
|
131
|
+
now?: () => number;
|
|
132
|
+
/** Optional injected id generator for deterministic tests. */
|
|
133
|
+
snapshotIdGenerator?: () => string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Build a `RecallXraySnapshot` from explicit input fields. Pure
|
|
137
|
+
* function; safe to call from anywhere. All array/object inputs are
|
|
138
|
+
* shallow-copied so caller mutation after build cannot tear the
|
|
139
|
+
* returned snapshot.
|
|
140
|
+
*/
|
|
141
|
+
declare function buildXraySnapshot(input: BuildXraySnapshotInput): RecallXraySnapshot;
|
|
142
|
+
/**
|
|
143
|
+
* Mutable builder used by the orchestrator to accumulate X-ray fields
|
|
144
|
+
* as recall progresses. Call `build()` to get the finalized
|
|
145
|
+
* immutable-ish snapshot. All inputs are validated at insert time so
|
|
146
|
+
* a malformed entry cannot poison the snapshot later.
|
|
147
|
+
*/
|
|
148
|
+
declare class RecallXrayBuilder {
|
|
149
|
+
private readonly query;
|
|
150
|
+
private readonly sessionKey;
|
|
151
|
+
private namespace;
|
|
152
|
+
private traceId;
|
|
153
|
+
private tierExplain;
|
|
154
|
+
private readonly results;
|
|
155
|
+
private readonly filters;
|
|
156
|
+
private budgetChars;
|
|
157
|
+
private budgetUsed;
|
|
158
|
+
constructor(opts: {
|
|
159
|
+
query: string;
|
|
160
|
+
sessionKey?: string;
|
|
161
|
+
namespace?: string;
|
|
162
|
+
traceId?: string;
|
|
163
|
+
});
|
|
164
|
+
setNamespace(namespace: string | undefined): void;
|
|
165
|
+
setTraceId(traceId: string | undefined): void;
|
|
166
|
+
setTierExplain(tierExplain: RecallTierExplain | null | undefined): void;
|
|
167
|
+
setBudget(budget: {
|
|
168
|
+
chars?: number;
|
|
169
|
+
used?: number;
|
|
170
|
+
}): void;
|
|
171
|
+
recordResult(result: RecallXrayResult): void;
|
|
172
|
+
recordFilter(filter: RecallFilterTrace): void;
|
|
173
|
+
build(opts?: {
|
|
174
|
+
now?: () => number;
|
|
175
|
+
snapshotIdGenerator?: () => string;
|
|
176
|
+
}): RecallXraySnapshot;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export { type BuildXraySnapshotInput, RECALL_XRAY_SERVED_BY_VALUES, type RecallFilterTrace, RecallXrayBuilder, type RecallXrayResult, type RecallXrayScoreDecomposition, type RecallXrayServedBy, type RecallXraySnapshot, buildXraySnapshot, isRecallXrayServedBy };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RECALL_XRAY_SERVED_BY_VALUES,
|
|
3
|
+
RecallXrayBuilder,
|
|
4
|
+
buildXraySnapshot,
|
|
5
|
+
isRecallXrayServedBy
|
|
6
|
+
} from "./chunk-KVBLZUKV.js";
|
|
7
|
+
export {
|
|
8
|
+
RECALL_XRAY_SERVED_BY_VALUES,
|
|
9
|
+
RecallXrayBuilder,
|
|
10
|
+
buildXraySnapshot,
|
|
11
|
+
isRecallXrayServedBy
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=recall-xray.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readPair,
|
|
3
|
+
resolvePair
|
|
4
|
+
} from "./chunk-YNB73F22.js";
|
|
5
|
+
import {
|
|
6
|
+
log
|
|
7
|
+
} from "./chunk-2ODBA7MQ.js";
|
|
8
|
+
|
|
9
|
+
// src/contradiction/resolution.ts
|
|
10
|
+
var VALID_VERBS = ["keep-a", "keep-b", "merge", "both-valid", "needs-more-context"];
|
|
11
|
+
function isValidResolutionVerb(value) {
|
|
12
|
+
return VALID_VERBS.includes(value);
|
|
13
|
+
}
|
|
14
|
+
async function executeResolution(memoryDir, storage, pairId, verb) {
|
|
15
|
+
const pair = readPair(memoryDir, pairId);
|
|
16
|
+
if (!pair) {
|
|
17
|
+
return { pairId, verb, affectedIds: [], message: `Pair ${pairId} not found` };
|
|
18
|
+
}
|
|
19
|
+
if (pair.resolution) {
|
|
20
|
+
return { pairId, verb, affectedIds: [], message: `Pair already resolved with verb "${pair.resolution}"` };
|
|
21
|
+
}
|
|
22
|
+
const [idA, idB] = pair.memoryIds;
|
|
23
|
+
const affectedIds = [];
|
|
24
|
+
let message = "";
|
|
25
|
+
let supersedeFailed = false;
|
|
26
|
+
switch (verb) {
|
|
27
|
+
case "keep-a": {
|
|
28
|
+
const ok = await supersedeSafe(storage, idB, idA, "contradiction-resolution:keep-a");
|
|
29
|
+
if (ok) {
|
|
30
|
+
affectedIds.push(idB);
|
|
31
|
+
message = `Kept ${idA}, superseded ${idB}`;
|
|
32
|
+
} else {
|
|
33
|
+
supersedeFailed = true;
|
|
34
|
+
message = `Supersede failed for ${idB}; not resolving`;
|
|
35
|
+
}
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
case "keep-b": {
|
|
39
|
+
const ok = await supersedeSafe(storage, idA, idB, "contradiction-resolution:keep-b");
|
|
40
|
+
if (ok) {
|
|
41
|
+
affectedIds.push(idA);
|
|
42
|
+
message = `Kept ${idB}, superseded ${idA}`;
|
|
43
|
+
} else {
|
|
44
|
+
supersedeFailed = true;
|
|
45
|
+
message = `Supersede failed for ${idA}; not resolving`;
|
|
46
|
+
}
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case "merge": {
|
|
50
|
+
const mergedId = `merged-${pairId}`;
|
|
51
|
+
const okA = await supersedeSafe(storage, idA, mergedId, "contradiction-resolution:merge");
|
|
52
|
+
const okB = await supersedeSafe(storage, idB, mergedId, "contradiction-resolution:merge");
|
|
53
|
+
if (okA) affectedIds.push(idA);
|
|
54
|
+
if (okB) affectedIds.push(idB);
|
|
55
|
+
if (!okA || !okB) {
|
|
56
|
+
supersedeFailed = true;
|
|
57
|
+
message = `Merge incomplete: ${affectedIds.length}/2 superseded; not resolving to allow retry`;
|
|
58
|
+
} else {
|
|
59
|
+
message = `Both memories superseded by merged ${mergedId}`;
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
case "both-valid": {
|
|
64
|
+
message = "Pair marked as both-valid; cooldown applied";
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
case "needs-more-context": {
|
|
68
|
+
message = "Deferred; no action taken, short cooldown applied";
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (!supersedeFailed) {
|
|
73
|
+
resolvePair(memoryDir, pairId, verb);
|
|
74
|
+
}
|
|
75
|
+
log.info("[contradiction-resolution] pair=%s verb=%s affected=%d", pairId, verb, affectedIds.length);
|
|
76
|
+
return { pairId, verb, affectedIds, message };
|
|
77
|
+
}
|
|
78
|
+
async function supersedeSafe(storage, oldId, newId, reason) {
|
|
79
|
+
try {
|
|
80
|
+
const result = await storage.supersedeMemory(oldId, newId, reason);
|
|
81
|
+
if (result === false) {
|
|
82
|
+
log.warn("[contradiction-resolution] supersede returned false for %s \u2192 %s", oldId, newId);
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
} catch (err) {
|
|
87
|
+
log.warn(
|
|
88
|
+
"[contradiction-resolution] supersede failed %s \u2192 %s: %s",
|
|
89
|
+
oldId,
|
|
90
|
+
newId,
|
|
91
|
+
err instanceof Error ? err.message : err
|
|
92
|
+
);
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
executeResolution,
|
|
98
|
+
isValidResolutionVerb
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=resolution-QBTDHTG7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/contradiction/resolution.ts"],"sourcesContent":["/**\n * Resolution Verbs — executes user-chosen resolution actions on contradiction pairs (issue #520).\n *\n * All resolution paths delegate to StorageManager.supersedeMemory. Do not\n * reimplement supersession logic here (rule 22: deduplicate resolution).\n */\n\nimport type { StorageManager } from \"../storage.js\";\nimport type { ResolutionVerb } from \"./contradiction-review.js\";\nimport { resolvePair, readPair } from \"./contradiction-review.js\";\nimport { log } from \"../logger.js\";\n\nexport interface ResolutionResult {\n pairId: string;\n verb: ResolutionVerb;\n /** Memory IDs affected by the resolution. */\n affectedIds: string[];\n /** Human-readable status. */\n message: string;\n}\n\nconst VALID_VERBS: ResolutionVerb[] = [\"keep-a\", \"keep-b\", \"merge\", \"both-valid\", \"needs-more-context\"];\n\nexport function isValidResolutionVerb(value: string): value is ResolutionVerb {\n return VALID_VERBS.includes(value as ResolutionVerb);\n}\n\n/**\n * Execute a resolution verb on a contradiction pair.\n *\n * - `keep-a`: Supersede B, keep A active.\n * - `keep-b`: Supersede A, keep B active.\n * - `merge`: Mark both as superseded by a synthetic merged ID.\n * - `both-valid`: Mark pair as reviewed; no memories are superseded.\n * - `needs-more-context`: Defer; no action, short cooldown.\n */\nexport async function executeResolution(\n memoryDir: string,\n storage: StorageManager,\n pairId: string,\n verb: ResolutionVerb,\n): Promise<ResolutionResult> {\n const pair = readPair(memoryDir, pairId);\n if (!pair) {\n return { pairId, verb, affectedIds: [], message: `Pair ${pairId} not found` };\n }\n\n if (pair.resolution) {\n return { pairId, verb, affectedIds: [], message: `Pair already resolved with verb \"${pair.resolution}\"` };\n }\n\n const [idA, idB] = pair.memoryIds;\n const affectedIds: string[] = [];\n let message = \"\";\n let supersedeFailed = false;\n\n switch (verb) {\n case \"keep-a\": {\n const ok = await supersedeSafe(storage, idB, idA, \"contradiction-resolution:keep-a\");\n if (ok) { affectedIds.push(idB); message = `Kept ${idA}, superseded ${idB}`; }\n else { supersedeFailed = true; message = `Supersede failed for ${idB}; not resolving`; }\n break;\n }\n case \"keep-b\": {\n const ok = await supersedeSafe(storage, idA, idB, \"contradiction-resolution:keep-b\");\n if (ok) { affectedIds.push(idA); message = `Kept ${idB}, superseded ${idA}`; }\n else { supersedeFailed = true; message = `Supersede failed for ${idA}; not resolving`; }\n break;\n }\n case \"merge\": {\n const mergedId = `merged-${pairId}`;\n const okA = await supersedeSafe(storage, idA, mergedId, \"contradiction-resolution:merge\");\n const okB = await supersedeSafe(storage, idB, mergedId, \"contradiction-resolution:merge\");\n if (okA) affectedIds.push(idA);\n if (okB) affectedIds.push(idB);\n if (!okA || !okB) {\n supersedeFailed = true;\n message = `Merge incomplete: ${affectedIds.length}/2 superseded; not resolving to allow retry`;\n } else {\n message = `Both memories superseded by merged ${mergedId}`;\n }\n break;\n }\n case \"both-valid\": {\n message = \"Pair marked as both-valid; cooldown applied\";\n break;\n }\n case \"needs-more-context\": {\n message = \"Deferred; no action taken, short cooldown applied\";\n break;\n }\n }\n\n if (!supersedeFailed) {\n resolvePair(memoryDir, pairId, verb);\n }\n log.info(\"[contradiction-resolution] pair=%s verb=%s affected=%d\", pairId, verb, affectedIds.length);\n return { pairId, verb, affectedIds, message };\n}\n\nasync function supersedeSafe(\n storage: StorageManager,\n oldId: string,\n newId: string,\n reason: string,\n): Promise<boolean> {\n try {\n const result = await storage.supersedeMemory(oldId, newId, reason);\n if (result === false) {\n log.warn(\"[contradiction-resolution] supersede returned false for %s → %s\", oldId, newId);\n return false;\n }\n return true;\n } catch (err) {\n log.warn(\n \"[contradiction-resolution] supersede failed %s → %s: %s\",\n oldId,\n newId,\n err instanceof Error ? err.message : err,\n );\n return false;\n }\n}\n"],"mappings":";;;;;;;;;AAqBA,IAAM,cAAgC,CAAC,UAAU,UAAU,SAAS,cAAc,oBAAoB;AAE/F,SAAS,sBAAsB,OAAwC;AAC5E,SAAO,YAAY,SAAS,KAAuB;AACrD;AAWA,eAAsB,kBACpB,WACA,SACA,QACA,MAC2B;AAC3B,QAAM,OAAO,SAAS,WAAW,MAAM;AACvC,MAAI,CAAC,MAAM;AACT,WAAO,EAAE,QAAQ,MAAM,aAAa,CAAC,GAAG,SAAS,QAAQ,MAAM,aAAa;AAAA,EAC9E;AAEA,MAAI,KAAK,YAAY;AACnB,WAAO,EAAE,QAAQ,MAAM,aAAa,CAAC,GAAG,SAAS,oCAAoC,KAAK,UAAU,IAAI;AAAA,EAC1G;AAEA,QAAM,CAAC,KAAK,GAAG,IAAI,KAAK;AACxB,QAAM,cAAwB,CAAC;AAC/B,MAAI,UAAU;AACd,MAAI,kBAAkB;AAEtB,UAAQ,MAAM;AAAA,IACZ,KAAK,UAAU;AACb,YAAM,KAAK,MAAM,cAAc,SAAS,KAAK,KAAK,iCAAiC;AACnF,UAAI,IAAI;AAAE,oBAAY,KAAK,GAAG;AAAG,kBAAU,QAAQ,GAAG,gBAAgB,GAAG;AAAA,MAAI,OACxE;AAAE,0BAAkB;AAAM,kBAAU,wBAAwB,GAAG;AAAA,MAAmB;AACvF;AAAA,IACF;AAAA,IACA,KAAK,UAAU;AACb,YAAM,KAAK,MAAM,cAAc,SAAS,KAAK,KAAK,iCAAiC;AACnF,UAAI,IAAI;AAAE,oBAAY,KAAK,GAAG;AAAG,kBAAU,QAAQ,GAAG,gBAAgB,GAAG;AAAA,MAAI,OACxE;AAAE,0BAAkB;AAAM,kBAAU,wBAAwB,GAAG;AAAA,MAAmB;AACvF;AAAA,IACF;AAAA,IACA,KAAK,SAAS;AACZ,YAAM,WAAW,UAAU,MAAM;AACjC,YAAM,MAAM,MAAM,cAAc,SAAS,KAAK,UAAU,gCAAgC;AACxF,YAAM,MAAM,MAAM,cAAc,SAAS,KAAK,UAAU,gCAAgC;AACxF,UAAI,IAAK,aAAY,KAAK,GAAG;AAC7B,UAAI,IAAK,aAAY,KAAK,GAAG;AAC7B,UAAI,CAAC,OAAO,CAAC,KAAK;AAChB,0BAAkB;AAClB,kBAAU,qBAAqB,YAAY,MAAM;AAAA,MACnD,OAAO;AACL,kBAAU,sCAAsC,QAAQ;AAAA,MAC1D;AACA;AAAA,IACF;AAAA,IACA,KAAK,cAAc;AACjB,gBAAU;AACV;AAAA,IACF;AAAA,IACA,KAAK,sBAAsB;AACzB,gBAAU;AACV;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,iBAAiB;AACpB,gBAAY,WAAW,QAAQ,IAAI;AAAA,EACrC;AACA,MAAI,KAAK,0DAA0D,QAAQ,MAAM,YAAY,MAAM;AACnG,SAAO,EAAE,QAAQ,MAAM,aAAa,QAAQ;AAC9C;AAEA,eAAe,cACb,SACA,OACA,OACA,QACkB;AAClB,MAAI;AACF,UAAM,SAAS,MAAM,QAAQ,gBAAgB,OAAO,OAAO,MAAM;AACjE,QAAI,WAAW,OAAO;AACpB,UAAI,KAAK,wEAAmE,OAAO,KAAK;AACxF,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT,SAAS,KAAK;AACZ,QAAI;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAe,QAAQ,IAAI,UAAU;AAAA,IACvC;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a provider API key using OpenClaw's own auth resolution system.
|
|
3
|
+
*
|
|
4
|
+
* This module delegates to the gateway's `resolveApiKeyForProvider()` function,
|
|
5
|
+
* which handles all secret reference formats (SecretRef objects, auth profiles,
|
|
6
|
+
* "secretref-managed" markers, environment variables, etc.) using the same
|
|
7
|
+
* codepath the gateway uses for its own agent sessions.
|
|
8
|
+
*
|
|
9
|
+
* For plain-text API keys, a fast path returns them directly without
|
|
10
|
+
* involving the gateway auth system.
|
|
11
|
+
*
|
|
12
|
+
* Results are cached per provider for the gateway process lifetime.
|
|
13
|
+
*/
|
|
14
|
+
type ResolveApiKeyFn = (params: {
|
|
15
|
+
provider: string;
|
|
16
|
+
cfg?: unknown;
|
|
17
|
+
agentDir?: string;
|
|
18
|
+
}) => Promise<{
|
|
19
|
+
apiKey?: string;
|
|
20
|
+
source?: string;
|
|
21
|
+
mode?: string;
|
|
22
|
+
} | null>;
|
|
1
23
|
/**
|
|
2
24
|
* Resolve request-ready auth for a model, including provider-owned transforms
|
|
3
25
|
* (e.g., OAuth token exchange, base URL override for openai-codex).
|
|
@@ -40,5 +62,6 @@ declare function getGatewayRuntimeAuthForModel(): Promise<GetRuntimeAuthForModel
|
|
|
40
62
|
* Clear the resolution cache (useful for testing or key rotation).
|
|
41
63
|
*/
|
|
42
64
|
declare function clearSecretCache(): void;
|
|
65
|
+
declare function __setGatewayResolverForTest(resolver: ResolveApiKeyFn | null): void;
|
|
43
66
|
|
|
44
|
-
export { type GetRuntimeAuthForModelFn, clearSecretCache, getGatewayRuntimeAuthForModel, resolveProviderApiKey };
|
|
67
|
+
export { type GetRuntimeAuthForModelFn, __setGatewayResolverForTest, clearSecretCache, getGatewayRuntimeAuthForModel, resolveProviderApiKey };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
__setGatewayResolverForTest,
|
|
2
3
|
clearSecretCache,
|
|
3
4
|
getGatewayRuntimeAuthForModel,
|
|
4
5
|
resolveProviderApiKey
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-XZ2TIKGC.js";
|
|
6
7
|
import "./chunk-MARWOCVP.js";
|
|
7
8
|
import "./chunk-2ODBA7MQ.js";
|
|
8
9
|
export {
|
|
10
|
+
__setGatewayResolverForTest,
|
|
9
11
|
clearSecretCache,
|
|
10
12
|
getGatewayRuntimeAuthForModel,
|
|
11
13
|
resolveProviderApiKey
|
package/dist/resume-bundles.js
CHANGED
|
@@ -4,20 +4,20 @@ import {
|
|
|
4
4
|
recordResumeBundle,
|
|
5
5
|
resolveResumeBundleDir,
|
|
6
6
|
validateResumeBundle
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-KUB6JU6H.js";
|
|
8
8
|
import "./chunk-CULXMQJH.js";
|
|
9
9
|
import "./chunk-E6K4NIEU.js";
|
|
10
|
-
import "./chunk-LOBRX7VD.js";
|
|
11
10
|
import "./chunk-YRMVARQP.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-LOBRX7VD.js";
|
|
12
|
+
import "./chunk-BK2EFTE2.js";
|
|
14
13
|
import "./chunk-Z5LAYHGJ.js";
|
|
14
|
+
import "./chunk-FYIYMQ5N.js";
|
|
15
15
|
import "./chunk-MARWOCVP.js";
|
|
16
16
|
import "./chunk-DT5TVLJE.js";
|
|
17
|
-
import "./chunk-DGXUHMOV.js";
|
|
18
|
-
import "./chunk-LPSF4OQH.js";
|
|
19
17
|
import "./chunk-4DJQYKMN.js";
|
|
20
18
|
import "./chunk-2ODBA7MQ.js";
|
|
19
|
+
import "./chunk-DGXUHMOV.js";
|
|
20
|
+
import "./chunk-LPSF4OQH.js";
|
|
21
21
|
export {
|
|
22
22
|
buildResumeBundleFromState,
|
|
23
23
|
getResumeBundleStatus,
|