@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,486 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractJsonCandidates
|
|
3
|
+
} from "./chunk-UZB5KHKX.js";
|
|
4
|
+
import {
|
|
5
|
+
normalizeProcedureSteps
|
|
6
|
+
} from "./chunk-QDW3E4RD.js";
|
|
7
|
+
import {
|
|
8
|
+
log
|
|
9
|
+
} from "./chunk-2ODBA7MQ.js";
|
|
10
|
+
|
|
11
|
+
// src/extraction-judge.ts
|
|
12
|
+
import { createHash } from "crypto";
|
|
13
|
+
function getVerdictKind(verdict) {
|
|
14
|
+
const raw = verdict.kind;
|
|
15
|
+
if (raw === "accept" || raw === "reject" || raw === "defer") {
|
|
16
|
+
return raw;
|
|
17
|
+
}
|
|
18
|
+
return verdict.durable ? "accept" : "reject";
|
|
19
|
+
}
|
|
20
|
+
function isDurableVerdict(verdict) {
|
|
21
|
+
return getVerdictKind(verdict) === "accept";
|
|
22
|
+
}
|
|
23
|
+
function isValidCachedVerdict(value) {
|
|
24
|
+
if (typeof value !== "object" || value === null) return false;
|
|
25
|
+
const v = value;
|
|
26
|
+
if (typeof v.durable !== "boolean") return false;
|
|
27
|
+
if (typeof v.reason !== "string") return false;
|
|
28
|
+
if (v.kind !== void 0) {
|
|
29
|
+
if (v.kind !== "accept" && v.kind !== "reject" && v.kind !== "defer") {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
function normalizeCachedVerdict(value) {
|
|
36
|
+
if (typeof value !== "object" || value === null) return null;
|
|
37
|
+
const v = value;
|
|
38
|
+
if (typeof v.durable !== "boolean") return null;
|
|
39
|
+
if (typeof v.reason !== "string") return null;
|
|
40
|
+
let kind;
|
|
41
|
+
if (v.kind !== void 0) {
|
|
42
|
+
if (typeof v.kind !== "string") return null;
|
|
43
|
+
if (v.kind === "accept" || v.kind === "reject" || v.kind === "defer") {
|
|
44
|
+
kind = v.kind;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const out = { durable: v.durable, reason: v.reason };
|
|
48
|
+
if (kind !== void 0) out.kind = kind;
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
var JUDGE_SYSTEM_PROMPT = `You are a memory curator evaluating whether extracted facts are **durable** \u2014 worth storing for long-term recall across sessions.
|
|
52
|
+
|
|
53
|
+
A fact is **durable** if it will still be useful 30+ days from now and is relevant across multiple sessions, not just the current task.
|
|
54
|
+
|
|
55
|
+
Return one of three verdicts per candidate:
|
|
56
|
+
|
|
57
|
+
ACCEPT \u2014 the fact is durable, persist it:
|
|
58
|
+
- Personal preferences, identities, or relationships
|
|
59
|
+
- Decisions with rationale that affect future work
|
|
60
|
+
- Corrections to previously held beliefs
|
|
61
|
+
- Principles, rules, or constraints the user wants respected
|
|
62
|
+
- Stable facts about projects, tools, or workflows
|
|
63
|
+
- Commitments, deadlines, or obligations
|
|
64
|
+
|
|
65
|
+
REJECT \u2014 the fact is not durable, drop it:
|
|
66
|
+
- Transient task details ("currently debugging line 42")
|
|
67
|
+
- Ephemeral state ("the build is running now")
|
|
68
|
+
- Routine operations ("ran npm install")
|
|
69
|
+
- Conversational filler or acknowledgements
|
|
70
|
+
- Information that will be stale within hours
|
|
71
|
+
- Step-by-step instructions for a one-time task
|
|
72
|
+
|
|
73
|
+
DEFER \u2014 the fact MIGHT be durable but needs more context to decide. The candidate will be re-evaluated on a later extraction pass with fresh context; if it cannot be resolved within a small number of re-evaluations it will be rejected.
|
|
74
|
+
- Ambiguous referents ("he said they'd follow up on it")
|
|
75
|
+
- Partial or in-progress statements that might become durable once completed
|
|
76
|
+
- Future-tense commitments whose subject or timeline is unclear
|
|
77
|
+
- Facts whose durability hinges on context not present in the candidate text
|
|
78
|
+
|
|
79
|
+
Do NOT use defer as a soft reject. Reject facts you are confident are transient. Only defer when another turn of context would genuinely change the verdict.
|
|
80
|
+
|
|
81
|
+
Return a JSON array of objects with these fields:
|
|
82
|
+
- index: number (the candidate index)
|
|
83
|
+
- kind: string \u2014 one of "accept", "reject", "defer"
|
|
84
|
+
- reason: string (brief explanation, under 80 characters)
|
|
85
|
+
|
|
86
|
+
You may also include durable (boolean) for backwards compatibility: true for accept, false for reject or defer. If kind is omitted, durable determines the verdict.
|
|
87
|
+
|
|
88
|
+
Rules:
|
|
89
|
+
1. Return exactly one verdict per input candidate, matched by index.
|
|
90
|
+
2. When in doubt between accept and reject, lean toward accept \u2014 false negatives (losing a useful fact) are worse than false positives (keeping a marginal one).
|
|
91
|
+
3. Use defer only when another turn of context would genuinely change the verdict.
|
|
92
|
+
4. Output valid JSON only. No markdown fences, no commentary.
|
|
93
|
+
|
|
94
|
+
Example output:
|
|
95
|
+
[{"index": 0, "kind": "accept", "durable": true, "reason": "Stable personal preference"}, {"index": 1, "kind": "reject", "durable": false, "reason": "Ephemeral build status"}, {"index": 2, "kind": "defer", "durable": false, "reason": "Ambiguous pronoun"}]`;
|
|
96
|
+
var VERDICT_CACHE_MAX_SIZE = 1e4;
|
|
97
|
+
var defaultVerdictCache = /* @__PURE__ */ new Map();
|
|
98
|
+
var defaultDeferCounts = /* @__PURE__ */ new Map();
|
|
99
|
+
var DEFER_COUNT_MAX_SIZE = 2e4;
|
|
100
|
+
function cacheKey(text, category) {
|
|
101
|
+
return createHash("sha256").update(`${text}\0${category}`).digest("hex");
|
|
102
|
+
}
|
|
103
|
+
function resolveDeferCap(config) {
|
|
104
|
+
const raw = config.extractionJudgeMaxDeferrals;
|
|
105
|
+
if (typeof raw === "number" && Number.isFinite(raw) && raw >= 1) {
|
|
106
|
+
return Math.floor(raw);
|
|
107
|
+
}
|
|
108
|
+
return 2;
|
|
109
|
+
}
|
|
110
|
+
function enforceMaxCacheSize(cache) {
|
|
111
|
+
if (cache.size <= VERDICT_CACHE_MAX_SIZE) return;
|
|
112
|
+
const deleteCount = Math.floor(cache.size / 2);
|
|
113
|
+
let deleted = 0;
|
|
114
|
+
for (const key of cache.keys()) {
|
|
115
|
+
if (deleted >= deleteCount) break;
|
|
116
|
+
cache.delete(key);
|
|
117
|
+
deleted++;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
var AUTO_APPROVE_CATEGORIES = /* @__PURE__ */ new Set(["correction", "principle"]);
|
|
121
|
+
var PROCEDURE_TRIGGER_RE = /(when you|whenever|before you|before running|always\s|first\b.*\bthen|to deploy|to ship|run these steps|follow these steps|how (i|we)\s|recipe for|workflow|each time you)/i;
|
|
122
|
+
function validateProcedureExtraction(input) {
|
|
123
|
+
const steps = normalizeProcedureSteps(input.procedureSteps);
|
|
124
|
+
if (steps.length < 2) {
|
|
125
|
+
return { durable: false, reason: "Procedure requires at least two steps with intents" };
|
|
126
|
+
}
|
|
127
|
+
const combined = [input.content, ...steps.map((s) => s.intent)].join(" ").toLowerCase();
|
|
128
|
+
if (!PROCEDURE_TRIGGER_RE.test(combined)) {
|
|
129
|
+
return { durable: false, reason: "Procedure missing explicit trigger phrasing" };
|
|
130
|
+
}
|
|
131
|
+
return { durable: true, reason: "Procedure structure validated" };
|
|
132
|
+
}
|
|
133
|
+
async function judgeFactDurability(candidates, config, localLlm, fallbackLlm, cache, deferCounts, onVerdict) {
|
|
134
|
+
const startMs = Date.now();
|
|
135
|
+
const verdicts = /* @__PURE__ */ new Map();
|
|
136
|
+
let cached = 0;
|
|
137
|
+
let judged = 0;
|
|
138
|
+
let deferred = 0;
|
|
139
|
+
let deferredCappedToReject = 0;
|
|
140
|
+
const verdictCache = cache ?? defaultVerdictCache;
|
|
141
|
+
const deferCountMap = deferCounts ?? defaultDeferCounts;
|
|
142
|
+
const deferCap = resolveDeferCap(config);
|
|
143
|
+
const emit = (build) => {
|
|
144
|
+
if (!onVerdict) return;
|
|
145
|
+
let observation;
|
|
146
|
+
try {
|
|
147
|
+
observation = build();
|
|
148
|
+
} catch (err) {
|
|
149
|
+
log.debug(
|
|
150
|
+
`extraction-judge: onVerdict builder threw (non-fatal): ${err instanceof Error ? err.message : String(err)}`
|
|
151
|
+
);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
onVerdict(observation);
|
|
156
|
+
} catch (err) {
|
|
157
|
+
log.debug(
|
|
158
|
+
`extraction-judge: onVerdict callback threw (non-fatal): ${err instanceof Error ? err.message : String(err)}`
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
if (candidates.length === 0) {
|
|
163
|
+
return {
|
|
164
|
+
verdicts,
|
|
165
|
+
cached,
|
|
166
|
+
judged,
|
|
167
|
+
elapsed: 0,
|
|
168
|
+
deferred,
|
|
169
|
+
deferredCappedToReject
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const pendingIndices = [];
|
|
173
|
+
for (let i = 0; i < candidates.length; i++) {
|
|
174
|
+
const c = candidates[i];
|
|
175
|
+
if (AUTO_APPROVE_CATEGORIES.has(c.category)) {
|
|
176
|
+
const v = {
|
|
177
|
+
durable: true,
|
|
178
|
+
reason: `Auto-approved: ${c.category} category bypasses judge`
|
|
179
|
+
};
|
|
180
|
+
verdicts.set(i, v);
|
|
181
|
+
emit(() => ({
|
|
182
|
+
verdict: v,
|
|
183
|
+
candidate: c,
|
|
184
|
+
contentHash: cacheKey(c.text, c.category),
|
|
185
|
+
source: "auto-approve",
|
|
186
|
+
priorDeferrals: 0,
|
|
187
|
+
elapsedMs: Date.now() - startMs
|
|
188
|
+
}));
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (c.importanceLevel === "critical") {
|
|
192
|
+
const v = {
|
|
193
|
+
durable: true,
|
|
194
|
+
reason: "Auto-approved: critical importance"
|
|
195
|
+
};
|
|
196
|
+
verdicts.set(i, v);
|
|
197
|
+
emit(() => ({
|
|
198
|
+
verdict: v,
|
|
199
|
+
candidate: c,
|
|
200
|
+
contentHash: cacheKey(c.text, c.category),
|
|
201
|
+
source: "auto-approve",
|
|
202
|
+
priorDeferrals: 0,
|
|
203
|
+
elapsedMs: Date.now() - startMs
|
|
204
|
+
}));
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const key = cacheKey(c.text, c.category);
|
|
208
|
+
const cachedVerdict = verdictCache.get(key);
|
|
209
|
+
if (cachedVerdict) {
|
|
210
|
+
verdicts.set(i, cachedVerdict);
|
|
211
|
+
cached++;
|
|
212
|
+
emit(() => ({
|
|
213
|
+
verdict: cachedVerdict,
|
|
214
|
+
candidate: c,
|
|
215
|
+
contentHash: key,
|
|
216
|
+
source: "cache",
|
|
217
|
+
priorDeferrals: deferCountMap.get(key) ?? 0,
|
|
218
|
+
elapsedMs: Date.now() - startMs
|
|
219
|
+
}));
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
pendingIndices.push(i);
|
|
223
|
+
}
|
|
224
|
+
if (pendingIndices.length === 0) {
|
|
225
|
+
return {
|
|
226
|
+
verdicts,
|
|
227
|
+
cached,
|
|
228
|
+
judged,
|
|
229
|
+
elapsed: Date.now() - startMs,
|
|
230
|
+
deferred,
|
|
231
|
+
deferredCappedToReject
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
const batchSize = config.extractionJudgeBatchSize;
|
|
235
|
+
for (let batchStart = 0; batchStart < pendingIndices.length; batchStart += batchSize) {
|
|
236
|
+
const batchIndices = pendingIndices.slice(batchStart, batchStart + batchSize);
|
|
237
|
+
const batchPayload = batchIndices.map((idx) => ({
|
|
238
|
+
index: idx,
|
|
239
|
+
text: candidates[idx].text,
|
|
240
|
+
category: candidates[idx].category,
|
|
241
|
+
confidence: candidates[idx].confidence
|
|
242
|
+
}));
|
|
243
|
+
const userPrompt = JSON.stringify(batchPayload);
|
|
244
|
+
try {
|
|
245
|
+
const llmResponse = await callJudgeLlm(
|
|
246
|
+
userPrompt,
|
|
247
|
+
config,
|
|
248
|
+
localLlm,
|
|
249
|
+
fallbackLlm
|
|
250
|
+
);
|
|
251
|
+
if (llmResponse) {
|
|
252
|
+
const parsed = parseJudgeResponse(llmResponse, batchIndices);
|
|
253
|
+
const deferredThisBatch = /* @__PURE__ */ new Set();
|
|
254
|
+
for (const [idx, rawVerdict] of parsed.entries()) {
|
|
255
|
+
const c = candidates[idx];
|
|
256
|
+
const key = cacheKey(c.text, c.category);
|
|
257
|
+
let verdict = rawVerdict;
|
|
258
|
+
let source = "llm";
|
|
259
|
+
const priorDefers = deferCountMap.get(key) ?? 0;
|
|
260
|
+
if (getVerdictKind(verdict) === "defer") {
|
|
261
|
+
if (priorDefers >= deferCap) {
|
|
262
|
+
verdict = {
|
|
263
|
+
durable: false,
|
|
264
|
+
reason: `Defer cap reached (${deferCap} prior defers); rejecting`,
|
|
265
|
+
kind: "reject"
|
|
266
|
+
};
|
|
267
|
+
source = "llm-cap-rejected";
|
|
268
|
+
if (!deferredThisBatch.has(key)) {
|
|
269
|
+
deferCountMap.delete(key);
|
|
270
|
+
deferredCappedToReject++;
|
|
271
|
+
deferredThisBatch.add(key);
|
|
272
|
+
}
|
|
273
|
+
} else if (!deferredThisBatch.has(key)) {
|
|
274
|
+
deferCountMap.set(key, priorDefers + 1);
|
|
275
|
+
deferred++;
|
|
276
|
+
deferredThisBatch.add(key);
|
|
277
|
+
if (deferCountMap.size > DEFER_COUNT_MAX_SIZE) {
|
|
278
|
+
const drop = Math.floor(deferCountMap.size / 2);
|
|
279
|
+
let dropped = 0;
|
|
280
|
+
for (const k of deferCountMap.keys()) {
|
|
281
|
+
if (dropped >= drop) break;
|
|
282
|
+
deferCountMap.delete(k);
|
|
283
|
+
dropped++;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
deferCountMap.delete(key);
|
|
289
|
+
}
|
|
290
|
+
verdicts.set(idx, verdict);
|
|
291
|
+
judged++;
|
|
292
|
+
if (getVerdictKind(verdict) !== "defer") {
|
|
293
|
+
verdictCache.set(key, verdict);
|
|
294
|
+
}
|
|
295
|
+
emit(() => ({
|
|
296
|
+
verdict,
|
|
297
|
+
candidate: c,
|
|
298
|
+
contentHash: key,
|
|
299
|
+
source,
|
|
300
|
+
priorDeferrals: priorDefers,
|
|
301
|
+
elapsedMs: Date.now() - startMs
|
|
302
|
+
}));
|
|
303
|
+
}
|
|
304
|
+
enforceMaxCacheSize(verdictCache);
|
|
305
|
+
}
|
|
306
|
+
} catch (err) {
|
|
307
|
+
log.warn(
|
|
308
|
+
`extraction-judge: LLM call failed, approving batch (fail-open): ${err instanceof Error ? err.message : String(err)}`
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
for (const idx of batchIndices) {
|
|
312
|
+
if (!verdicts.has(idx)) {
|
|
313
|
+
const c = candidates[idx];
|
|
314
|
+
const hash = cacheKey(c.text, c.category);
|
|
315
|
+
const priorDefers = deferCountMap.get(hash) ?? 0;
|
|
316
|
+
deferCountMap.delete(hash);
|
|
317
|
+
const v = {
|
|
318
|
+
durable: true,
|
|
319
|
+
reason: "Approved by default (judge unavailable or parse error)"
|
|
320
|
+
};
|
|
321
|
+
verdicts.set(idx, v);
|
|
322
|
+
emit(() => {
|
|
323
|
+
return {
|
|
324
|
+
verdict: v,
|
|
325
|
+
candidate: c,
|
|
326
|
+
contentHash: hash,
|
|
327
|
+
source: "fail-open",
|
|
328
|
+
priorDeferrals: priorDefers,
|
|
329
|
+
elapsedMs: Date.now() - startMs
|
|
330
|
+
};
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return {
|
|
336
|
+
verdicts,
|
|
337
|
+
cached,
|
|
338
|
+
judged,
|
|
339
|
+
elapsed: Date.now() - startMs,
|
|
340
|
+
deferred,
|
|
341
|
+
deferredCappedToReject
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
async function callJudgeLlm(userPrompt, config, localLlm, fallbackLlm) {
|
|
345
|
+
const messages = [
|
|
346
|
+
{ role: "system", content: JUDGE_SYSTEM_PROMPT },
|
|
347
|
+
{ role: "user", content: userPrompt }
|
|
348
|
+
];
|
|
349
|
+
const modelOverride = config.extractionJudgeModel || void 0;
|
|
350
|
+
const skipLocal = config.modelSource === "gateway";
|
|
351
|
+
const agentId = config.modelSource === "gateway" ? config.gatewayAgentId || void 0 : void 0;
|
|
352
|
+
if (localLlm && !skipLocal) {
|
|
353
|
+
try {
|
|
354
|
+
const result = await localLlm.chatCompletion(messages, {
|
|
355
|
+
temperature: 0.1,
|
|
356
|
+
maxTokens: 2048,
|
|
357
|
+
responseFormat: { type: "json_object" },
|
|
358
|
+
timeoutMs: 1500,
|
|
359
|
+
operation: "extraction-judge",
|
|
360
|
+
...modelOverride ? { model: modelOverride } : {}
|
|
361
|
+
});
|
|
362
|
+
if (result?.content) {
|
|
363
|
+
return result.content;
|
|
364
|
+
}
|
|
365
|
+
} catch (err) {
|
|
366
|
+
log.debug(
|
|
367
|
+
`extraction-judge: local LLM failed, trying fallback: ${err instanceof Error ? err.message : String(err)}`
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (fallbackLlm) {
|
|
372
|
+
try {
|
|
373
|
+
const result = await fallbackLlm.chatCompletion(
|
|
374
|
+
messages,
|
|
375
|
+
{
|
|
376
|
+
temperature: 0.1,
|
|
377
|
+
maxTokens: 2048,
|
|
378
|
+
timeoutMs: 1500,
|
|
379
|
+
...modelOverride ? { model: modelOverride } : {},
|
|
380
|
+
...agentId ? { agentId } : {}
|
|
381
|
+
}
|
|
382
|
+
);
|
|
383
|
+
if (result?.content) {
|
|
384
|
+
return result.content;
|
|
385
|
+
}
|
|
386
|
+
} catch (err) {
|
|
387
|
+
log.debug(
|
|
388
|
+
`extraction-judge: fallback LLM failed: ${err instanceof Error ? err.message : String(err)}`
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
394
|
+
function parseJudgeResponse(raw, expectedIndices) {
|
|
395
|
+
const result = /* @__PURE__ */ new Map();
|
|
396
|
+
const expectedSet = new Set(expectedIndices);
|
|
397
|
+
try {
|
|
398
|
+
let parsed;
|
|
399
|
+
try {
|
|
400
|
+
parsed = JSON.parse(raw);
|
|
401
|
+
} catch {
|
|
402
|
+
const candidates = extractJsonCandidates(raw);
|
|
403
|
+
if (candidates.length > 0) {
|
|
404
|
+
parsed = JSON.parse(candidates[0]);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (!Array.isArray(parsed)) {
|
|
408
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
409
|
+
const values = Object.values(parsed);
|
|
410
|
+
for (const v of values) {
|
|
411
|
+
if (Array.isArray(v)) {
|
|
412
|
+
parsed = v;
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (!Array.isArray(parsed)) {
|
|
418
|
+
log.debug("extraction-judge: response is not an array, cannot parse");
|
|
419
|
+
return result;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
for (const item of parsed) {
|
|
423
|
+
if (typeof item !== "object" || item === null || typeof item.index !== "number") {
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
const idx = item.index;
|
|
427
|
+
if (!expectedSet.has(idx)) continue;
|
|
428
|
+
let kind;
|
|
429
|
+
const rawKind = item.kind;
|
|
430
|
+
const rawAction = item.action;
|
|
431
|
+
if (rawKind === "accept" || rawKind === "reject" || rawKind === "defer") {
|
|
432
|
+
kind = rawKind;
|
|
433
|
+
} else if (rawAction === "accept" || rawAction === "reject" || rawAction === "defer") {
|
|
434
|
+
kind = rawAction;
|
|
435
|
+
}
|
|
436
|
+
const hasDurable = typeof item.durable === "boolean";
|
|
437
|
+
const durableFromModel = hasDurable ? item.durable : void 0;
|
|
438
|
+
let durable;
|
|
439
|
+
if (kind === "accept") {
|
|
440
|
+
durable = true;
|
|
441
|
+
} else if (kind === "reject" || kind === "defer") {
|
|
442
|
+
durable = false;
|
|
443
|
+
} else if (durableFromModel !== void 0) {
|
|
444
|
+
durable = durableFromModel;
|
|
445
|
+
} else {
|
|
446
|
+
durable = true;
|
|
447
|
+
}
|
|
448
|
+
const reason = typeof item.reason === "string" ? item.reason.slice(0, 120) : "No reason provided";
|
|
449
|
+
const verdict = { durable, reason };
|
|
450
|
+
if (kind !== void 0) verdict.kind = kind;
|
|
451
|
+
result.set(idx, verdict);
|
|
452
|
+
}
|
|
453
|
+
} catch (err) {
|
|
454
|
+
log.debug(
|
|
455
|
+
`extraction-judge: failed to parse response: ${err instanceof Error ? err.message : String(err)}`
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
return result;
|
|
459
|
+
}
|
|
460
|
+
function clearVerdictCache() {
|
|
461
|
+
defaultVerdictCache.clear();
|
|
462
|
+
defaultDeferCounts.clear();
|
|
463
|
+
}
|
|
464
|
+
function verdictCacheSize() {
|
|
465
|
+
return defaultVerdictCache.size;
|
|
466
|
+
}
|
|
467
|
+
function createVerdictCache() {
|
|
468
|
+
return /* @__PURE__ */ new Map();
|
|
469
|
+
}
|
|
470
|
+
function createDeferCountMap() {
|
|
471
|
+
return /* @__PURE__ */ new Map();
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export {
|
|
475
|
+
getVerdictKind,
|
|
476
|
+
isDurableVerdict,
|
|
477
|
+
isValidCachedVerdict,
|
|
478
|
+
normalizeCachedVerdict,
|
|
479
|
+
validateProcedureExtraction,
|
|
480
|
+
judgeFactDurability,
|
|
481
|
+
clearVerdictCache,
|
|
482
|
+
verdictCacheSize,
|
|
483
|
+
createVerdictCache,
|
|
484
|
+
createDeferCountMap
|
|
485
|
+
};
|
|
486
|
+
//# sourceMappingURL=chunk-C4SQJZAF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/extraction-judge.ts"],"sourcesContent":["/**\n * Extraction Judge — LLM-as-judge fact-worthiness gate (issue #376).\n *\n * Evaluates extracted facts against a durability rubric before they are\n * persisted. Facts that are unlikely to be useful 30+ days from now or\n * across sessions are rejected (or shadow-logged depending on config).\n *\n * Design constraints:\n * - Corrections and principles are auto-approved (safety bypass).\n * - Critical-importance facts are auto-approved.\n * - Batches respect extractionJudgeBatchSize.\n * - Content-hash caching avoids redundant LLM calls.\n * - Performance budget: <= 1.5s per batch.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { log } from \"./logger.js\";\nimport type { PluginConfig, ImportanceLevel } from \"./types.js\";\nimport type { LocalLlmClient } from \"./local-llm.js\";\nimport type { FallbackLlmClient } from \"./fallback-llm.js\";\nimport { extractJsonCandidates } from \"./json-extract.js\";\nimport { normalizeProcedureSteps } from \"./procedural/procedure-types.js\";\n\n// ---------------------------------------------------------------------------\n// Public interfaces\n// ---------------------------------------------------------------------------\n\nexport interface JudgeCandidate {\n text: string;\n category: string;\n confidence: number;\n tags?: string[];\n /** Local importance level, set by caller before judging. */\n importanceLevel?: ImportanceLevel;\n}\n\n/**\n * Verdict kinds (issue #562, PR 1).\n *\n * - `\"accept\"`: fact is durable, persist it.\n * - `\"reject\"`: fact is not durable, drop it.\n * - `\"defer\"`: fact is ambiguous; push it back into the buffer for another\n * pass with fresh context. Inspired by MemReader (arxiv 2604.07877).\n *\n * PR 1 only introduces the type. No emit path produces `\"defer\"` yet — the\n * defer-capable prompt, buffer re-routing, telemetry, and GRPO data\n * collection are landing in PRs 2, 3, and 4 respectively.\n */\nexport type JudgeVerdictKind = \"accept\" | \"reject\" | \"defer\";\n\n/**\n * Judge verdict shape.\n *\n * Back-compat note: `kind` is optional. Verdicts serialized before PR 1\n * (both in-memory cache entries and any persisted caches) only carry\n * `{ durable, reason }`. Downstream consumers must either read `durable`\n * directly, or use {@link getVerdictKind} / {@link isDurableVerdict} which\n * gracefully fall back to the boolean when `kind` is missing, and ignore\n * unknown future `kind` values rather than crashing.\n */\nexport interface JudgeVerdict {\n /**\n * True iff the fact should be persisted. For `\"defer\"` verdicts this is\n * `false` — a deferred fact is not (yet) persisted, so callers that only\n * look at `durable` will treat defer as \"skip this turn\", which matches\n * the pre-PR-1 fail-closed behavior for non-accepted verdicts.\n */\n durable: boolean;\n reason: string;\n /**\n * Optional explicit verdict kind. Added in PR 1 of issue #562. Legacy\n * verdicts (including cache entries produced before this field existed)\n * do not set `kind`; use {@link getVerdictKind} to read this safely.\n */\n kind?: JudgeVerdictKind;\n}\n\n/**\n * Resolve a verdict's effective kind.\n *\n * - If `kind` is explicitly set to one of the known values, return it.\n * - If `kind` is absent, infer from `durable` (back-compat with pre-PR-1\n * cache entries and emit paths that have not been updated yet).\n * - If `kind` is set to an unrecognised value (forward-compat, e.g. a\n * future cache entry loaded by an older build), fall back to `durable`\n * so we never crash on unknown strings.\n */\nexport function getVerdictKind(verdict: JudgeVerdict): JudgeVerdictKind {\n const raw = verdict.kind;\n if (raw === \"accept\" || raw === \"reject\" || raw === \"defer\") {\n return raw;\n }\n return verdict.durable ? \"accept\" : \"reject\";\n}\n\n/**\n * Type guard: returns `true` only for verdicts that should be persisted.\n * Treats both `\"reject\"` and `\"defer\"` as \"not durable\" — defer means the\n * caller should re-evaluate later, not write now.\n */\nexport function isDurableVerdict(verdict: JudgeVerdict): boolean {\n return getVerdictKind(verdict) === \"accept\";\n}\n\n/**\n * Validate a cache entry loaded from persistence / another process.\n *\n * Strict: accepts legacy `{ durable, reason }` entries and new entries\n * whose `kind` is one of the three known `JudgeVerdictKind` values.\n * Rejects structurally wrong types and unknown `kind` strings so the\n * type-guard narrowing is sound — callers that receive\n * `value is JudgeVerdict` can safely treat `kind` as the declared\n * union.\n *\n * Forward-compat is handled by {@link normalizeCachedVerdict}, which\n * drops unknown `kind` strings before validation so a newer build's\n * cache entry still loads instead of being rejected.\n */\nexport function isValidCachedVerdict(value: unknown): value is JudgeVerdict {\n if (typeof value !== \"object\" || value === null) return false;\n const v = value as Record<string, unknown>;\n if (typeof v.durable !== \"boolean\") return false;\n if (typeof v.reason !== \"string\") return false;\n if (v.kind !== undefined) {\n if (v.kind !== \"accept\" && v.kind !== \"reject\" && v.kind !== \"defer\") {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Forward-compatible cache-entry loader.\n *\n * Drops unknown `kind` strings to `undefined` (so `getVerdictKind` can\n * fall back to `durable`), then validates structurally. Non-string\n * `kind` values are still treated as structural violations and rejected.\n * Returns the sanitised verdict, or `null` when the entry is structurally\n * unusable.\n */\nexport function normalizeCachedVerdict(value: unknown): JudgeVerdict | null {\n if (typeof value !== \"object\" || value === null) return null;\n const v = value as Record<string, unknown>;\n if (typeof v.durable !== \"boolean\") return null;\n if (typeof v.reason !== \"string\") return null;\n let kind: JudgeVerdictKind | undefined;\n if (v.kind !== undefined) {\n if (typeof v.kind !== \"string\") return null;\n if (v.kind === \"accept\" || v.kind === \"reject\" || v.kind === \"defer\") {\n kind = v.kind;\n }\n // Unknown string `kind`: dropped to undefined for forward-compat.\n }\n const out: JudgeVerdict = { durable: v.durable, reason: v.reason };\n if (kind !== undefined) out.kind = kind;\n return out;\n}\n\nexport interface JudgeBatchResult {\n verdicts: Map<number, JudgeVerdict>;\n /** Number of verdicts served from cache. */\n cached: number;\n /** Number of verdicts produced by an LLM call. */\n judged: number;\n /** Total wall-clock time in milliseconds. */\n elapsed: number;\n /**\n * Number of verdicts in this batch that resolved to `\"defer\"` (issue #562,\n * PR 2). Callers can use this to decide whether to retain buffer turns for\n * the next extraction pass.\n */\n deferred: number;\n /**\n * Number of defers that were forcibly converted to `\"reject\"` because the\n * same candidate text had already been deferred at least\n * `extractionJudgeMaxDeferrals` times. Rolled out of `deferred` — a\n * candidate counted here is *not* also in `deferred`.\n */\n deferredCappedToReject: number;\n}\n\n/**\n * Per-verdict observation emitted by `judgeFactDurability` when an\n * `onVerdict` callback is supplied (issue #562, PR 3). Used to wire the\n * observation ledger / telemetry stream without coupling the judge module\n * directly to filesystem I/O. One event is emitted for every resolved\n * verdict, including auto-approved and cache-hit paths.\n */\nexport interface JudgeVerdictObservation {\n verdict: JudgeVerdict;\n /** The original `JudgeCandidate` passed in (same reference). */\n candidate: JudgeCandidate;\n /** SHA-256 of `text\\0category`, same key the cache/deferCounter use. */\n contentHash: string;\n /** Verdict resolution path. Useful for debugging + dashboards. */\n source: \"auto-approve\" | \"cache\" | \"llm\" | \"llm-cap-rejected\" | \"fail-open\";\n /**\n * How many times this candidate had already been deferred before this\n * verdict resolved. 0 when the candidate had never been deferred.\n */\n priorDeferrals: number;\n /**\n * Milliseconds from batch start to now. Shared across verdicts emitted in\n * the same batch.\n */\n elapsedMs: number;\n}\n\n// ---------------------------------------------------------------------------\n// Prompt (embedded; mirrors prompts/extraction_judge.prompt.md)\n// ---------------------------------------------------------------------------\n\nconst JUDGE_SYSTEM_PROMPT = `You are a memory curator evaluating whether extracted facts are **durable** — worth storing for long-term recall across sessions.\n\nA fact is **durable** if it will still be useful 30+ days from now and is relevant across multiple sessions, not just the current task.\n\nReturn one of three verdicts per candidate:\n\nACCEPT — the fact is durable, persist it:\n- Personal preferences, identities, or relationships\n- Decisions with rationale that affect future work\n- Corrections to previously held beliefs\n- Principles, rules, or constraints the user wants respected\n- Stable facts about projects, tools, or workflows\n- Commitments, deadlines, or obligations\n\nREJECT — the fact is not durable, drop it:\n- Transient task details (\"currently debugging line 42\")\n- Ephemeral state (\"the build is running now\")\n- Routine operations (\"ran npm install\")\n- Conversational filler or acknowledgements\n- Information that will be stale within hours\n- Step-by-step instructions for a one-time task\n\nDEFER — the fact MIGHT be durable but needs more context to decide. The candidate will be re-evaluated on a later extraction pass with fresh context; if it cannot be resolved within a small number of re-evaluations it will be rejected.\n- Ambiguous referents (\"he said they'd follow up on it\")\n- Partial or in-progress statements that might become durable once completed\n- Future-tense commitments whose subject or timeline is unclear\n- Facts whose durability hinges on context not present in the candidate text\n\nDo NOT use defer as a soft reject. Reject facts you are confident are transient. Only defer when another turn of context would genuinely change the verdict.\n\nReturn a JSON array of objects with these fields:\n- index: number (the candidate index)\n- kind: string — one of \"accept\", \"reject\", \"defer\"\n- reason: string (brief explanation, under 80 characters)\n\nYou may also include durable (boolean) for backwards compatibility: true for accept, false for reject or defer. If kind is omitted, durable determines the verdict.\n\nRules:\n1. Return exactly one verdict per input candidate, matched by index.\n2. When in doubt between accept and reject, lean toward accept — false negatives (losing a useful fact) are worse than false positives (keeping a marginal one).\n3. Use defer only when another turn of context would genuinely change the verdict.\n4. Output valid JSON only. No markdown fences, no commentary.\n\nExample output:\n[{\"index\": 0, \"kind\": \"accept\", \"durable\": true, \"reason\": \"Stable personal preference\"}, {\"index\": 1, \"kind\": \"reject\", \"durable\": false, \"reason\": \"Ephemeral build status\"}, {\"index\": 2, \"kind\": \"defer\", \"durable\": false, \"reason\": \"Ambiguous pronoun\"}]`;\n\n// ---------------------------------------------------------------------------\n// Content-hash cache (in-memory, per-process fallback)\n// ---------------------------------------------------------------------------\n\n/** Maximum entries before evicting the oldest half. */\nconst VERDICT_CACHE_MAX_SIZE = 10_000;\n\n/** Module-level fallback cache, used when callers do not pass their own. */\nconst defaultVerdictCache = new Map<string, JudgeVerdict>();\n\n/**\n * Per-content-hash deferral counter (issue #562, PR 2).\n *\n * When the judge emits a `\"defer\"` verdict for a candidate whose content\n * has already been deferred `extractionJudgeMaxDeferrals` times, the verdict\n * is forcibly converted to `\"reject\"` so a pathological LLM response cannot\n * produce an infinite defer loop.\n *\n * Module-level with a size cap so stale test state cannot leak between runs\n * in the unlikely case a caller does not clear it between processes.\n */\nconst defaultDeferCounts = new Map<string, number>();\nconst DEFER_COUNT_MAX_SIZE = 20_000;\n\nfunction cacheKey(text: string, category: string): string {\n return createHash(\"sha256\").update(`${text}\\0${category}`).digest(\"hex\");\n}\n\n/**\n * Resolve the effective defer cap from config, defaulting to 2 when the\n * config value is missing or non-positive. Matches the PR 2 spec.\n */\nfunction resolveDeferCap(config: PluginConfig): number {\n const raw = (config as { extractionJudgeMaxDeferrals?: number })\n .extractionJudgeMaxDeferrals;\n if (typeof raw === \"number\" && Number.isFinite(raw) && raw >= 1) {\n return Math.floor(raw);\n }\n return 2;\n}\n\n/**\n * Enforce the max-size invariant on a verdict cache. When the cache exceeds\n * VERDICT_CACHE_MAX_SIZE, the oldest half of entries are deleted (Map\n * iteration order is insertion order).\n */\nfunction enforceMaxCacheSize(cache: Map<string, JudgeVerdict>): void {\n if (cache.size <= VERDICT_CACHE_MAX_SIZE) return;\n const deleteCount = Math.floor(cache.size / 2);\n let deleted = 0;\n for (const key of cache.keys()) {\n if (deleted >= deleteCount) break;\n cache.delete(key);\n deleted++;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Categories that bypass the judge (safety / correctness)\n// ---------------------------------------------------------------------------\n\nconst AUTO_APPROVE_CATEGORIES = new Set([\"correction\", \"principle\"]);\n\n/** Explicit trigger phrasing — procedures must match to persist (issue #519). */\nconst PROCEDURE_TRIGGER_RE =\n /(when you|whenever|before you|before running|always\\s|first\\b.*\\bthen|to deploy|to ship|run these steps|follow these steps|how (i|we)\\s|recipe for|workflow|each time you)/i;\n\n/**\n * Deterministic gate for extracted `procedure` memories: ≥2 steps with non-empty\n * intents and explicit trigger wording in title and/or steps.\n */\nexport function validateProcedureExtraction(input: {\n content: string;\n procedureSteps?: unknown;\n}): JudgeVerdict {\n const steps = normalizeProcedureSteps(input.procedureSteps);\n if (steps.length < 2) {\n return { durable: false, reason: \"Procedure requires at least two steps with intents\" };\n }\n const combined = [input.content, ...steps.map((s) => s.intent)].join(\" \").toLowerCase();\n if (!PROCEDURE_TRIGGER_RE.test(combined)) {\n return { durable: false, reason: \"Procedure missing explicit trigger phrasing\" };\n }\n return { durable: true, reason: \"Procedure structure validated\" };\n}\n\n// ---------------------------------------------------------------------------\n// Core judge function\n// ---------------------------------------------------------------------------\n\n/**\n * Evaluate a batch of candidate facts for durability.\n *\n * Auto-approves corrections, principles, and critical-importance facts.\n * Remaining candidates are batched (up to extractionJudgeBatchSize),\n * checked against an in-memory content-hash cache, and sent to the LLM\n * for verdict.\n */\nexport async function judgeFactDurability(\n candidates: JudgeCandidate[],\n config: PluginConfig,\n localLlm: LocalLlmClient | null,\n fallbackLlm: FallbackLlmClient | null,\n cache?: Map<string, JudgeVerdict>,\n deferCounts?: Map<string, number>,\n onVerdict?: (observation: JudgeVerdictObservation) => void,\n): Promise<JudgeBatchResult> {\n const startMs = Date.now();\n const verdicts = new Map<number, JudgeVerdict>();\n let cached = 0;\n let judged = 0;\n let deferred = 0;\n let deferredCappedToReject = 0;\n\n // Use caller-provided cache for per-orchestrator scoping, or fall back\n // to the module-level default cache.\n const verdictCache = cache ?? defaultVerdictCache;\n const deferCountMap = deferCounts ?? defaultDeferCounts;\n const deferCap = resolveDeferCap(config);\n\n // Lazy emit (Codex P2): when `onVerdict` is undefined (default path —\n // telemetry off), payload construction is skipped entirely. Callers\n // pass a factory instead of a pre-built observation so the `sha256`\n // `contentHash` and surrounding object allocation only run when a\n // subscriber is present. For large batches with telemetry off this\n // removes per-verdict overhead that would otherwise fire on every\n // auto-approved / cache / fail-open path.\n const emit = (build: () => JudgeVerdictObservation): void => {\n if (!onVerdict) return;\n let observation: JudgeVerdictObservation;\n try {\n observation = build();\n } catch (err) {\n log.debug(\n `extraction-judge: onVerdict builder threw (non-fatal): ${err instanceof Error ? err.message : String(err)}`,\n );\n return;\n }\n try {\n onVerdict(observation);\n } catch (err) {\n // Fail-open: telemetry errors must never block extraction.\n log.debug(\n `extraction-judge: onVerdict callback threw (non-fatal): ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n };\n\n if (candidates.length === 0) {\n return {\n verdicts,\n cached,\n judged,\n elapsed: 0,\n deferred,\n deferredCappedToReject,\n };\n }\n\n // Indices that need LLM judgment\n const pendingIndices: number[] = [];\n\n for (let i = 0; i < candidates.length; i++) {\n const c = candidates[i];\n\n // Auto-approve safety categories\n if (AUTO_APPROVE_CATEGORIES.has(c.category)) {\n const v: JudgeVerdict = {\n durable: true,\n reason: `Auto-approved: ${c.category} category bypasses judge`,\n };\n verdicts.set(i, v);\n emit(() => ({\n verdict: v,\n candidate: c,\n contentHash: cacheKey(c.text, c.category),\n source: \"auto-approve\",\n priorDeferrals: 0,\n elapsedMs: Date.now() - startMs,\n }));\n continue;\n }\n\n // Auto-approve critical importance\n if (c.importanceLevel === \"critical\") {\n const v: JudgeVerdict = {\n durable: true,\n reason: \"Auto-approved: critical importance\",\n };\n verdicts.set(i, v);\n emit(() => ({\n verdict: v,\n candidate: c,\n contentHash: cacheKey(c.text, c.category),\n source: \"auto-approve\",\n priorDeferrals: 0,\n elapsedMs: Date.now() - startMs,\n }));\n continue;\n }\n\n // Check cache\n const key = cacheKey(c.text, c.category);\n const cachedVerdict = verdictCache.get(key);\n if (cachedVerdict) {\n verdicts.set(i, cachedVerdict);\n cached++;\n emit(() => ({\n verdict: cachedVerdict,\n candidate: c,\n contentHash: key,\n source: \"cache\",\n priorDeferrals: deferCountMap.get(key) ?? 0,\n elapsedMs: Date.now() - startMs,\n }));\n continue;\n }\n\n pendingIndices.push(i);\n }\n\n // If all resolved without LLM, return early\n if (pendingIndices.length === 0) {\n return {\n verdicts,\n cached,\n judged,\n elapsed: Date.now() - startMs,\n deferred,\n deferredCappedToReject,\n };\n }\n\n // Batch the pending candidates up to batchSize\n const batchSize = config.extractionJudgeBatchSize;\n for (let batchStart = 0; batchStart < pendingIndices.length; batchStart += batchSize) {\n const batchIndices = pendingIndices.slice(batchStart, batchStart + batchSize);\n const batchPayload = batchIndices.map((idx) => ({\n index: idx,\n text: candidates[idx].text,\n category: candidates[idx].category,\n confidence: candidates[idx].confidence,\n }));\n\n const userPrompt = JSON.stringify(batchPayload);\n\n try {\n const llmResponse = await callJudgeLlm(\n userPrompt,\n config,\n localLlm,\n fallbackLlm,\n );\n\n if (llmResponse) {\n const parsed = parseJudgeResponse(llmResponse, batchIndices);\n // Per-batch defer-increment dedupe (codex P2): a single extraction\n // pass must not advance the cap more than once for identical\n // candidate content, even if the same text appears multiple times\n // in the same LLM response. Duplicate hits share the first\n // increment's `priorDeferrals` snapshot.\n const deferredThisBatch = new Set<string>();\n for (const [idx, rawVerdict] of parsed.entries()) {\n const c = candidates[idx];\n const key = cacheKey(c.text, c.category);\n let verdict = rawVerdict;\n let source: JudgeVerdictObservation[\"source\"] = \"llm\";\n const priorDefers = deferCountMap.get(key) ?? 0;\n\n // Defer cap (issue #562, PR 2). A candidate that has already been\n // deferred `deferCap` times is forcibly rejected so a pathological\n // LLM response cannot produce an infinite defer loop.\n if (getVerdictKind(verdict) === \"defer\") {\n if (priorDefers >= deferCap) {\n verdict = {\n durable: false,\n reason: `Defer cap reached (${deferCap} prior defers); rejecting`,\n kind: \"reject\",\n };\n source = \"llm-cap-rejected\";\n // Only clear + count the cap conversion once per batch for\n // this key — duplicates in the same response all resolve to\n // reject but should not inflate the cap-rejection counter.\n if (!deferredThisBatch.has(key)) {\n deferCountMap.delete(key);\n deferredCappedToReject++;\n deferredThisBatch.add(key);\n }\n } else if (!deferredThisBatch.has(key)) {\n deferCountMap.set(key, priorDefers + 1);\n deferred++;\n deferredThisBatch.add(key);\n // Bound the per-process defer-counter map.\n if (deferCountMap.size > DEFER_COUNT_MAX_SIZE) {\n const drop = Math.floor(deferCountMap.size / 2);\n let dropped = 0;\n for (const k of deferCountMap.keys()) {\n if (dropped >= drop) break;\n deferCountMap.delete(k);\n dropped++;\n }\n }\n }\n // else: duplicate defer for a key already counted this batch —\n // no additional counter increment, verdict still marked defer.\n } else {\n // On accept/reject, clear any outstanding defer counter so a\n // future reappearance of the same text starts fresh.\n deferCountMap.delete(key);\n }\n\n verdicts.set(idx, verdict);\n judged++;\n // Cache non-defer verdicts. Defer is intentionally NOT cached:\n // caching it would short-circuit the re-evaluation pass that is\n // the entire point of the defer verdict.\n if (getVerdictKind(verdict) !== \"defer\") {\n verdictCache.set(key, verdict);\n }\n emit(() => ({\n verdict,\n candidate: c,\n contentHash: key,\n source,\n priorDeferrals: priorDefers,\n elapsedMs: Date.now() - startMs,\n }));\n }\n // Evict oldest entries if cache exceeds max size\n enforceMaxCacheSize(verdictCache);\n }\n } catch (err) {\n // Fail-open: if the LLM call fails, approve all candidates in this batch\n log.warn(\n `extraction-judge: LLM call failed, approving batch (fail-open): ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n\n // Fill in any missing verdicts from this batch (fail-open: approve).\n // Clear defer counts so a transient outage doesn't leave stale state\n // that causes later defers to hit the cap early.\n for (const idx of batchIndices) {\n if (!verdicts.has(idx)) {\n const c = candidates[idx];\n const hash = cacheKey(c.text, c.category);\n // Capture the prior deferral count BEFORE clearing so the\n // telemetry event reflects the true state rather than always 0.\n const priorDefers = deferCountMap.get(hash) ?? 0;\n deferCountMap.delete(hash);\n const v: JudgeVerdict = {\n durable: true,\n reason: \"Approved by default (judge unavailable or parse error)\",\n };\n verdicts.set(idx, v);\n emit(() => {\n return {\n verdict: v,\n candidate: c,\n contentHash: hash,\n source: \"fail-open\",\n priorDeferrals: priorDefers,\n elapsedMs: Date.now() - startMs,\n };\n });\n }\n }\n }\n\n return {\n verdicts,\n cached,\n judged,\n elapsed: Date.now() - startMs,\n deferred,\n deferredCappedToReject,\n };\n}\n\n// ---------------------------------------------------------------------------\n// LLM call helpers\n// ---------------------------------------------------------------------------\n\nasync function callJudgeLlm(\n userPrompt: string,\n config: PluginConfig,\n localLlm: LocalLlmClient | null,\n fallbackLlm: FallbackLlmClient | null,\n): Promise<string | null> {\n const messages: Array<{ role: \"system\" | \"user\"; content: string }> = [\n { role: \"system\", content: JUDGE_SYSTEM_PROMPT },\n { role: \"user\", content: userPrompt },\n ];\n\n const modelOverride = config.extractionJudgeModel || undefined;\n\n // When modelSource is \"gateway\", skip localLlm and go directly to fallback\n // (the gateway-routed backend). This respects the operator's explicit\n // routing preference.\n const skipLocal = config.modelSource === \"gateway\";\n\n // Resolve the gateway agent ID so the fallback LLM routes through the\n // correct agent persona's model chain — identical to the pattern used\n // by ExtractionEngine.withGatewayAgent().\n const agentId =\n config.modelSource === \"gateway\"\n ? (config.gatewayAgentId || undefined)\n : undefined;\n\n // Try local LLM first (unless modelSource says gateway)\n if (localLlm && !skipLocal) {\n try {\n const result = await (localLlm as any).chatCompletion(messages, {\n temperature: 0.1,\n maxTokens: 2048,\n responseFormat: { type: \"json_object\" },\n timeoutMs: 1500,\n operation: \"extraction-judge\",\n ...(modelOverride ? { model: modelOverride } : {}),\n });\n if (result?.content) {\n return result.content;\n }\n } catch (err) {\n log.debug(\n `extraction-judge: local LLM failed, trying fallback: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n // Try fallback LLM\n if (fallbackLlm) {\n try {\n const result = await fallbackLlm.chatCompletion(\n messages as Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n {\n temperature: 0.1,\n maxTokens: 2048,\n timeoutMs: 1500,\n ...(modelOverride ? { model: modelOverride } : {}),\n ...(agentId ? { agentId } : {}),\n },\n );\n if (result?.content) {\n return result.content;\n }\n } catch (err) {\n log.debug(\n `extraction-judge: fallback LLM failed: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// Response parsing\n// ---------------------------------------------------------------------------\n\nfunction parseJudgeResponse(\n raw: string,\n expectedIndices: number[],\n): Map<number, JudgeVerdict> {\n const result = new Map<number, JudgeVerdict>();\n const expectedSet = new Set(expectedIndices);\n\n try {\n // Try direct parse first, then fall back to JSON extraction\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n const candidates = extractJsonCandidates(raw);\n if (candidates.length > 0) {\n parsed = JSON.parse(candidates[0]);\n }\n }\n\n if (!Array.isArray(parsed)) {\n // Might be wrapped in an object with a key\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n const values = Object.values(parsed as Record<string, unknown>);\n for (const v of values) {\n if (Array.isArray(v)) {\n parsed = v;\n break;\n }\n }\n }\n if (!Array.isArray(parsed)) {\n log.debug(\"extraction-judge: response is not an array, cannot parse\");\n return result;\n }\n }\n\n for (const item of parsed) {\n if (\n typeof item !== \"object\" ||\n item === null ||\n typeof (item as any).index !== \"number\"\n ) {\n continue;\n }\n const idx = (item as any).index as number;\n if (!expectedSet.has(idx)) continue;\n\n // Parse kind first — it's the primary signal in PR 2 and above.\n // Fall back to durable for pre-PR-2 model responses that only return\n // the boolean.\n let kind: JudgeVerdictKind | undefined;\n const rawKind = (item as any).kind;\n const rawAction = (item as any).action;\n if (rawKind === \"accept\" || rawKind === \"reject\" || rawKind === \"defer\") {\n kind = rawKind;\n } else if (\n rawAction === \"accept\" ||\n rawAction === \"reject\" ||\n rawAction === \"defer\"\n ) {\n // Tolerate `action` as an alias — MemReader uses that word in the\n // paper and models may echo it.\n kind = rawAction;\n }\n\n const hasDurable = typeof (item as any).durable === \"boolean\";\n const durableFromModel = hasDurable\n ? ((item as any).durable as boolean)\n : undefined;\n\n // Resolve the durable flag from kind when present; otherwise trust\n // the model's boolean; otherwise fail-open to durable=true.\n let durable: boolean;\n if (kind === \"accept\") {\n durable = true;\n } else if (kind === \"reject\" || kind === \"defer\") {\n durable = false;\n } else if (durableFromModel !== undefined) {\n durable = durableFromModel;\n } else {\n durable = true; // fail-open\n }\n\n const reason =\n typeof (item as any).reason === \"string\"\n ? ((item as any).reason as string).slice(0, 120)\n : \"No reason provided\";\n\n const verdict: JudgeVerdict = { durable, reason };\n if (kind !== undefined) verdict.kind = kind;\n result.set(idx, verdict);\n }\n } catch (err) {\n log.debug(\n `extraction-judge: failed to parse response: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// Cache management (exposed for testing)\n// ---------------------------------------------------------------------------\n\n/** Clear the in-memory default verdict cache. Primarily for tests. */\nexport function clearVerdictCache(): void {\n defaultVerdictCache.clear();\n defaultDeferCounts.clear();\n}\n\n/** Return the current default verdict cache size. Primarily for tests. */\nexport function verdictCacheSize(): number {\n return defaultVerdictCache.size;\n}\n\n/** Create a new per-instance verdict cache. Orchestrators should hold one. */\nexport function createVerdictCache(): Map<string, JudgeVerdict> {\n return new Map();\n}\n\n/**\n * Create a new per-instance defer-counter map. Orchestrators should hold one\n * alongside their verdict cache so defer counts survive across extraction\n * passes within a single orchestrator but do not leak across orchestrators.\n */\nexport function createDeferCountMap(): Map<string, number> {\n return new Map();\n}\n"],"mappings":";;;;;;;;;;;AAeA,SAAS,kBAAkB;AAwEpB,SAAS,eAAe,SAAyC;AACtE,QAAM,MAAM,QAAQ;AACpB,MAAI,QAAQ,YAAY,QAAQ,YAAY,QAAQ,SAAS;AAC3D,WAAO;AAAA,EACT;AACA,SAAO,QAAQ,UAAU,WAAW;AACtC;AAOO,SAA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T;AAOO,SAAS,oBAA0B;AACxC,sBAAoB,MAAM;AAC1B,qBAAmB,MAAM;AAC3B;AAGO,SAAS,mBAA2B;AACzC,SAAO,oBAAoB;AAC7B;AAGO,SAAS,qBAAgD;AAC9D,SAAO,oBAAI,IAAI;AACjB;AAOO,SAAS,sBAA2C;AACzD,SAAO,oBAAI,IAAI;AACjB;","names":[]}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./chunk-DT5TVLJE.js";
|
|
8
8
|
import {
|
|
9
9
|
StorageManager
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-F5VP6YCB.js";
|
|
11
11
|
import {
|
|
12
12
|
getCachedEpisodeMap,
|
|
13
13
|
setCachedEpisodeMap
|
|
@@ -105,4 +105,4 @@ async function searchVerifiedEpisodes(options) {
|
|
|
105
105
|
export {
|
|
106
106
|
searchVerifiedEpisodes
|
|
107
107
|
};
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
108
|
+
//# sourceMappingURL=chunk-CUPFXL3J.js.map
|