@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
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toRecallExplainJson
|
|
3
|
+
} from "./chunk-ZAIM4TUE.js";
|
|
4
|
+
import {
|
|
5
|
+
buildProposedActions,
|
|
6
|
+
buildQualityScore,
|
|
7
|
+
groupActionsByStatus,
|
|
8
|
+
listMemoryGovernanceRuns,
|
|
9
|
+
readMemoryGovernanceRunArtifact,
|
|
10
|
+
runMemoryGovernance
|
|
11
|
+
} from "./chunk-3OGMS3PE.js";
|
|
1
12
|
import {
|
|
2
13
|
getTrustZoneStoreStatus,
|
|
3
14
|
isTrustZoneName,
|
|
@@ -8,18 +19,8 @@ import {
|
|
|
8
19
|
summarizeTrustZonePromotionReadiness
|
|
9
20
|
} from "./chunk-EQINRHYR.js";
|
|
10
21
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
groupActionsByStatus,
|
|
14
|
-
listMemoryGovernanceRuns,
|
|
15
|
-
readMemoryGovernanceRunArtifact,
|
|
16
|
-
runMemoryGovernance
|
|
17
|
-
} from "./chunk-POBPGDWI.js";
|
|
18
|
-
import {
|
|
19
|
-
persistExplicitCapture,
|
|
20
|
-
queueExplicitCaptureForReview,
|
|
21
|
-
validateExplicitCaptureInput
|
|
22
|
-
} from "./chunk-QDYXG4CS.js";
|
|
22
|
+
recordMemoryOutcome
|
|
23
|
+
} from "./chunk-EIR5VLIH.js";
|
|
23
24
|
import {
|
|
24
25
|
wrapWorkLayerContext
|
|
25
26
|
} from "./chunk-EEQLFRUM.js";
|
|
@@ -27,23 +28,34 @@ import {
|
|
|
27
28
|
buildProcedurePersistBody,
|
|
28
29
|
normalizeProcedureSteps
|
|
29
30
|
} from "./chunk-QDW3E4RD.js";
|
|
31
|
+
import {
|
|
32
|
+
persistExplicitCapture,
|
|
33
|
+
queueExplicitCaptureForReview,
|
|
34
|
+
validateExplicitCaptureInput
|
|
35
|
+
} from "./chunk-3FPTCC3Z.js";
|
|
36
|
+
import {
|
|
37
|
+
CrossNamespaceBudget
|
|
38
|
+
} from "./chunk-GDFS42HT.js";
|
|
30
39
|
import {
|
|
31
40
|
filterTrajectoriesByLookbackDays,
|
|
32
41
|
readCausalTrajectoryRecords
|
|
33
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-RBBWYEFJ.js";
|
|
34
43
|
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
canReadNamespace,
|
|
45
|
+
canWriteNamespace,
|
|
46
|
+
defaultNamespaceForPrincipal,
|
|
47
|
+
recallNamespacesForPrincipal,
|
|
48
|
+
resolvePrincipal
|
|
49
|
+
} from "./chunk-N5AKDXAI.js";
|
|
38
50
|
import {
|
|
39
51
|
FileCalendarSource,
|
|
40
52
|
buildBriefing,
|
|
41
53
|
parseBriefingFocus,
|
|
42
54
|
parseBriefingWindow
|
|
43
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-WVVA7F5A.js";
|
|
44
56
|
import {
|
|
45
57
|
parseEntityFile
|
|
46
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-F5VP6YCB.js";
|
|
47
59
|
import {
|
|
48
60
|
inferMemoryStatus,
|
|
49
61
|
toMemoryPathRel
|
|
@@ -59,10 +71,12 @@ import {
|
|
|
59
71
|
log
|
|
60
72
|
} from "./chunk-2ODBA7MQ.js";
|
|
61
73
|
import {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
74
|
+
AccessAuditAdapter
|
|
75
|
+
} from "./chunk-TVVEYCNW.js";
|
|
76
|
+
import {
|
|
77
|
+
AccessIdempotencyStore,
|
|
78
|
+
hashAccessIdempotencyPayload
|
|
79
|
+
} from "./chunk-XKECPATV.js";
|
|
66
80
|
|
|
67
81
|
// src/access-service.ts
|
|
68
82
|
import { stat } from "fs/promises";
|
|
@@ -677,6 +691,7 @@ async function importWorkBoardSnapshot(options) {
|
|
|
677
691
|
}
|
|
678
692
|
|
|
679
693
|
// src/procedural/procedure-miner.ts
|
|
694
|
+
var PROCEDURE_CLUSTER_ATTR_MAX = 500;
|
|
680
695
|
function clusterKey(record) {
|
|
681
696
|
const goal = record.goal.trim().toLowerCase().replace(/\s+/g, " ").slice(0, 120);
|
|
682
697
|
const refs = [...record.entityRefs ?? []].map((r) => r.trim().toLowerCase()).sort();
|
|
@@ -709,11 +724,12 @@ function pseudoStepsFromCluster(group) {
|
|
|
709
724
|
}));
|
|
710
725
|
}
|
|
711
726
|
async function hasExistingClusterWrite(storage, cluster) {
|
|
727
|
+
const clusterKey2 = cluster.slice(0, PROCEDURE_CLUSTER_ATTR_MAX);
|
|
712
728
|
const memories = await storage.readAllMemories();
|
|
713
729
|
for (const m of memories) {
|
|
714
730
|
if (m.frontmatter.category !== "procedure") continue;
|
|
715
731
|
const c = m.frontmatter.structuredAttributes?.procedure_cluster;
|
|
716
|
-
if (c ===
|
|
732
|
+
if (c === clusterKey2) return true;
|
|
717
733
|
}
|
|
718
734
|
return false;
|
|
719
735
|
}
|
|
@@ -725,8 +741,10 @@ async function runProcedureMining(options) {
|
|
|
725
741
|
if (cfg.minOccurrences <= 0) {
|
|
726
742
|
return { clustersProcessed: 0, proceduresWritten: 0, skippedReason: "minOccurrences_zero" };
|
|
727
743
|
}
|
|
744
|
+
const trajectoryDir = typeof options.config.causalTrajectoryStoreDir === "string" && options.config.causalTrajectoryStoreDir.trim().length > 0 ? options.config.causalTrajectoryStoreDir.trim() : void 0;
|
|
728
745
|
const { trajectories } = await readCausalTrajectoryRecords({
|
|
729
|
-
memoryDir: options.memoryDir
|
|
746
|
+
memoryDir: options.memoryDir,
|
|
747
|
+
causalTrajectoryStoreDir: trajectoryDir
|
|
730
748
|
});
|
|
731
749
|
const recent = filterTrajectoriesByLookbackDays(trajectories, cfg.lookbackDays);
|
|
732
750
|
const clusters = /* @__PURE__ */ new Map();
|
|
@@ -757,7 +775,7 @@ async function runProcedureMining(options) {
|
|
|
757
775
|
status: promote ? "active" : "pending_review",
|
|
758
776
|
tags: ["procedure-miner", "causal-trajectory"],
|
|
759
777
|
structuredAttributes: {
|
|
760
|
-
procedure_cluster: key.slice(0,
|
|
778
|
+
procedure_cluster: key.slice(0, PROCEDURE_CLUSTER_ATTR_MAX),
|
|
761
779
|
trajectory_ids: group.map((g) => g.trajectoryId).join(",").slice(0, 1900),
|
|
762
780
|
trajectory_count: String(group.length),
|
|
763
781
|
success_rate: rate.toFixed(4)
|
|
@@ -768,6 +786,125 @@ async function runProcedureMining(options) {
|
|
|
768
786
|
return { clustersProcessed, proceduresWritten };
|
|
769
787
|
}
|
|
770
788
|
|
|
789
|
+
// src/procedural/procedure-stats.ts
|
|
790
|
+
function snapshotConfig(config) {
|
|
791
|
+
const p = config.procedural;
|
|
792
|
+
return {
|
|
793
|
+
enabled: p?.enabled === true,
|
|
794
|
+
minOccurrences: typeof p?.minOccurrences === "number" ? p.minOccurrences : 0,
|
|
795
|
+
successFloor: typeof p?.successFloor === "number" ? p.successFloor : 0,
|
|
796
|
+
autoPromoteOccurrences: typeof p?.autoPromoteOccurrences === "number" ? p.autoPromoteOccurrences : 0,
|
|
797
|
+
autoPromoteEnabled: p?.autoPromoteEnabled === true,
|
|
798
|
+
lookbackDays: typeof p?.lookbackDays === "number" ? p.lookbackDays : 0,
|
|
799
|
+
recallMaxProcedures: typeof p?.recallMaxProcedures === "number" ? p.recallMaxProcedures : 0
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
function tsMs(value) {
|
|
803
|
+
if (typeof value !== "string") return null;
|
|
804
|
+
const ms = Date.parse(value);
|
|
805
|
+
return Number.isFinite(ms) ? ms : null;
|
|
806
|
+
}
|
|
807
|
+
async function computeProcedureStats(options) {
|
|
808
|
+
const { storage, config } = options;
|
|
809
|
+
const nowMs = options.nowMs ?? Date.now();
|
|
810
|
+
const sevenDaysMs = 7 * 24 * 60 * 60 * 1e3;
|
|
811
|
+
const counts = {
|
|
812
|
+
total: 0,
|
|
813
|
+
active: 0,
|
|
814
|
+
pending_review: 0,
|
|
815
|
+
rejected: 0,
|
|
816
|
+
quarantined: 0,
|
|
817
|
+
superseded: 0,
|
|
818
|
+
archived: 0,
|
|
819
|
+
other: 0
|
|
820
|
+
};
|
|
821
|
+
let lastWriteMs = null;
|
|
822
|
+
let writesLast7Days = 0;
|
|
823
|
+
let minerSourced = 0;
|
|
824
|
+
const known = [
|
|
825
|
+
"active",
|
|
826
|
+
"pending_review",
|
|
827
|
+
"rejected",
|
|
828
|
+
"quarantined",
|
|
829
|
+
"superseded",
|
|
830
|
+
"archived"
|
|
831
|
+
];
|
|
832
|
+
const seen = /* @__PURE__ */ new Set();
|
|
833
|
+
const live = await storage.readAllMemories();
|
|
834
|
+
const archived = await storage.readArchivedMemories();
|
|
835
|
+
const pool = [...live, ...archived];
|
|
836
|
+
for (const m of pool) {
|
|
837
|
+
if (m.frontmatter.category !== "procedure") continue;
|
|
838
|
+
if (seen.has(m.frontmatter.id)) continue;
|
|
839
|
+
seen.add(m.frontmatter.id);
|
|
840
|
+
counts.total += 1;
|
|
841
|
+
const status = m.frontmatter.status ?? "active";
|
|
842
|
+
if (known.includes(status)) {
|
|
843
|
+
counts[status] += 1;
|
|
844
|
+
} else {
|
|
845
|
+
counts.other += 1;
|
|
846
|
+
}
|
|
847
|
+
const createdMs = tsMs(m.frontmatter.created);
|
|
848
|
+
const updatedMs = tsMs(m.frontmatter.updated);
|
|
849
|
+
const latestMs = createdMs !== null && updatedMs !== null ? Math.max(createdMs, updatedMs) : updatedMs ?? createdMs;
|
|
850
|
+
if (latestMs !== null) {
|
|
851
|
+
if (lastWriteMs === null || latestMs > lastWriteMs) {
|
|
852
|
+
lastWriteMs = latestMs;
|
|
853
|
+
}
|
|
854
|
+
if (latestMs >= nowMs - sevenDaysMs && latestMs < nowMs) {
|
|
855
|
+
writesLast7Days += 1;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
if (m.frontmatter.source === "procedure-miner") {
|
|
859
|
+
minerSourced += 1;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
return {
|
|
863
|
+
schemaVersion: 1,
|
|
864
|
+
generatedAt: new Date(nowMs).toISOString(),
|
|
865
|
+
counts,
|
|
866
|
+
recent: {
|
|
867
|
+
lastWriteAt: lastWriteMs !== null ? new Date(lastWriteMs).toISOString() : null,
|
|
868
|
+
writesLast7Days,
|
|
869
|
+
minerSourced
|
|
870
|
+
},
|
|
871
|
+
config: snapshotConfig(config)
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
function formatProcedureStatsText(report) {
|
|
875
|
+
const { counts, recent, config } = report;
|
|
876
|
+
const lines = [];
|
|
877
|
+
lines.push(`Procedural memory stats (schema v${report.schemaVersion})`);
|
|
878
|
+
lines.push(` generated: ${report.generatedAt}`);
|
|
879
|
+
lines.push("");
|
|
880
|
+
lines.push(` config:`);
|
|
881
|
+
lines.push(` enabled: ${config.enabled}`);
|
|
882
|
+
lines.push(` minOccurrences: ${config.minOccurrences}`);
|
|
883
|
+
lines.push(` successFloor: ${config.successFloor}`);
|
|
884
|
+
lines.push(` autoPromoteOccurrences: ${config.autoPromoteOccurrences}`);
|
|
885
|
+
lines.push(` autoPromoteEnabled: ${config.autoPromoteEnabled}`);
|
|
886
|
+
lines.push(` lookbackDays: ${config.lookbackDays}`);
|
|
887
|
+
lines.push(` recallMaxProcedures: ${config.recallMaxProcedures}`);
|
|
888
|
+
lines.push("");
|
|
889
|
+
lines.push(` counts:`);
|
|
890
|
+
lines.push(` total: ${counts.total}`);
|
|
891
|
+
lines.push(` active: ${counts.active}`);
|
|
892
|
+
lines.push(` pending_review: ${counts.pending_review}`);
|
|
893
|
+
lines.push(` rejected: ${counts.rejected}`);
|
|
894
|
+
lines.push(` quarantined: ${counts.quarantined}`);
|
|
895
|
+
lines.push(` superseded: ${counts.superseded}`);
|
|
896
|
+
lines.push(` archived: ${counts.archived}`);
|
|
897
|
+
if (counts.other > 0) {
|
|
898
|
+
lines.push(` other: ${counts.other}`);
|
|
899
|
+
}
|
|
900
|
+
lines.push("");
|
|
901
|
+
lines.push(` recent:`);
|
|
902
|
+
lines.push(` lastWriteAt: ${recent.lastWriteAt ?? "(none)"}`);
|
|
903
|
+
lines.push(` writesLast7Days: ${recent.writesLast7Days}`);
|
|
904
|
+
lines.push(` minerSourced: ${recent.minerSourced}`);
|
|
905
|
+
return lines.join("\n") + "\n";
|
|
906
|
+
}
|
|
907
|
+
|
|
771
908
|
// src/access-service.ts
|
|
772
909
|
var EngramAccessInputError = class extends Error {
|
|
773
910
|
};
|
|
@@ -887,10 +1024,39 @@ var EngramAccessService = class {
|
|
|
887
1024
|
constructor(orchestrator) {
|
|
888
1025
|
this.orchestrator = orchestrator;
|
|
889
1026
|
this.idempotency = new AccessIdempotencyStore(orchestrator.config.memoryDir);
|
|
1027
|
+
this.budget = new CrossNamespaceBudget({
|
|
1028
|
+
enabled: orchestrator.config.recallCrossNamespaceBudgetEnabled,
|
|
1029
|
+
windowMs: orchestrator.config.recallCrossNamespaceBudgetWindowMs,
|
|
1030
|
+
softLimit: orchestrator.config.recallCrossNamespaceBudgetSoftLimit,
|
|
1031
|
+
hardLimit: orchestrator.config.recallCrossNamespaceBudgetHardLimit
|
|
1032
|
+
});
|
|
1033
|
+
const auditEnabled = orchestrator.config.recallAuditAnomalyDetectionEnabled === true;
|
|
1034
|
+
const auditLogEnabled = false;
|
|
1035
|
+
if (auditEnabled || auditLogEnabled) {
|
|
1036
|
+
const auditConfig = {
|
|
1037
|
+
audit: {
|
|
1038
|
+
enabled: auditLogEnabled,
|
|
1039
|
+
rootDir: orchestrator.config.memoryDir
|
|
1040
|
+
},
|
|
1041
|
+
detection: {
|
|
1042
|
+
enabled: auditEnabled,
|
|
1043
|
+
windowMs: orchestrator.config.recallAuditAnomalyWindowMs,
|
|
1044
|
+
repeatQueryLimit: orchestrator.config.recallAuditAnomalyRepeatQueryLimit,
|
|
1045
|
+
namespaceWalkLimit: orchestrator.config.recallAuditAnomalyNamespaceWalkLimit,
|
|
1046
|
+
highCardinalityReturnLimit: orchestrator.config.recallAuditAnomalyHighCardinalityLimit,
|
|
1047
|
+
rapidFireLimit: orchestrator.config.recallAuditAnomalyRapidFireLimit
|
|
1048
|
+
}
|
|
1049
|
+
};
|
|
1050
|
+
this.auditAdapter = new AccessAuditAdapter(auditConfig);
|
|
1051
|
+
} else {
|
|
1052
|
+
this.auditAdapter = null;
|
|
1053
|
+
}
|
|
890
1054
|
}
|
|
891
1055
|
orchestrator;
|
|
892
1056
|
idempotency;
|
|
893
1057
|
idempotencyLocks = /* @__PURE__ */ new Map();
|
|
1058
|
+
budget;
|
|
1059
|
+
auditAdapter;
|
|
894
1060
|
get briefingEnabled() {
|
|
895
1061
|
return this.orchestrator.config.briefing?.enabled === true;
|
|
896
1062
|
}
|
|
@@ -1143,14 +1309,117 @@ var EngramAccessService = class {
|
|
|
1143
1309
|
followupsUnavailableReason: result.followupsUnavailableReason
|
|
1144
1310
|
};
|
|
1145
1311
|
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Attach a coding context to a session (issue #569). Used by the Claude
|
|
1314
|
+
* Code / Codex / generic-MCP connectors at session start so that recall +
|
|
1315
|
+
* write paths can route to a project- / branch-scoped namespace.
|
|
1316
|
+
*
|
|
1317
|
+
* Validates the input shape and rejects malformed payloads rather than
|
|
1318
|
+
* silently accepting them (CLAUDE.md #51). Pass `codingContext: null` to
|
|
1319
|
+
* clear.
|
|
1320
|
+
*/
|
|
1321
|
+
setCodingContext(request) {
|
|
1322
|
+
const sessionKey = typeof request.sessionKey === "string" ? request.sessionKey.trim() : "";
|
|
1323
|
+
if (!sessionKey) {
|
|
1324
|
+
throw new EngramAccessInputError("sessionKey is required for setCodingContext");
|
|
1325
|
+
}
|
|
1326
|
+
if (request.codingContext === null) {
|
|
1327
|
+
this.orchestrator.setCodingContextForSession(sessionKey, null);
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
1330
|
+
const ctx = request.codingContext;
|
|
1331
|
+
if (!ctx || typeof ctx !== "object") {
|
|
1332
|
+
throw new EngramAccessInputError("codingContext must be an object or null");
|
|
1333
|
+
}
|
|
1334
|
+
if (typeof ctx.projectId !== "string" || ctx.projectId.trim().length === 0) {
|
|
1335
|
+
throw new EngramAccessInputError("codingContext.projectId must be a non-empty string");
|
|
1336
|
+
}
|
|
1337
|
+
if (typeof ctx.rootPath !== "string" || ctx.rootPath.trim().length === 0) {
|
|
1338
|
+
throw new EngramAccessInputError("codingContext.rootPath must be a non-empty string");
|
|
1339
|
+
}
|
|
1340
|
+
if (ctx.branch !== null && typeof ctx.branch !== "string") {
|
|
1341
|
+
throw new EngramAccessInputError("codingContext.branch must be a string or null");
|
|
1342
|
+
}
|
|
1343
|
+
if (ctx.defaultBranch !== null && typeof ctx.defaultBranch !== "string") {
|
|
1344
|
+
throw new EngramAccessInputError("codingContext.defaultBranch must be a string or null");
|
|
1345
|
+
}
|
|
1346
|
+
this.orchestrator.setCodingContextForSession(sessionKey, {
|
|
1347
|
+
projectId: ctx.projectId,
|
|
1348
|
+
branch: ctx.branch,
|
|
1349
|
+
rootPath: ctx.rootPath,
|
|
1350
|
+
defaultBranch: ctx.defaultBranch
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1146
1353
|
async recall(request) {
|
|
1147
1354
|
const query = request.query.trim();
|
|
1148
1355
|
if (query.length === 0) {
|
|
1149
1356
|
throw new EngramAccessInputError("query is required");
|
|
1150
1357
|
}
|
|
1358
|
+
if (request.codingContext !== void 0 && request.sessionKey) {
|
|
1359
|
+
this.setCodingContext({
|
|
1360
|
+
sessionKey: request.sessionKey,
|
|
1361
|
+
codingContext: request.codingContext
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1151
1364
|
const namespaceOverride = this.resolveRecallNamespace(request.namespace, request.sessionKey);
|
|
1152
1365
|
const namespace = namespaceOverride ?? this.orchestrator.config.defaultNamespace;
|
|
1153
1366
|
const mode = this.normalizeRecallMode(request.mode);
|
|
1367
|
+
const principal = resolvePrincipal(request.sessionKey, this.orchestrator.config);
|
|
1368
|
+
const principalNamespace = defaultNamespaceForPrincipal(principal, this.orchestrator.config);
|
|
1369
|
+
const modeSkipsBudget = mode === "no_recall";
|
|
1370
|
+
const effectiveNamespaces = namespaceOverride ? [namespaceOverride] : recallNamespacesForPrincipal(principal, this.orchestrator.config);
|
|
1371
|
+
let budgetDecision;
|
|
1372
|
+
if (modeSkipsBudget) {
|
|
1373
|
+
budgetDecision = {
|
|
1374
|
+
allowed: true,
|
|
1375
|
+
reason: "allowed-same-namespace",
|
|
1376
|
+
count: 0,
|
|
1377
|
+
limit: {
|
|
1378
|
+
softLimit: this.orchestrator.config.recallCrossNamespaceBudgetSoftLimit ?? 10,
|
|
1379
|
+
hardLimit: this.orchestrator.config.recallCrossNamespaceBudgetHardLimit ?? 30,
|
|
1380
|
+
windowMs: this.orchestrator.config.recallCrossNamespaceBudgetWindowMs ?? 6e4
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
} else {
|
|
1384
|
+
let anyCrossNamespace = false;
|
|
1385
|
+
let denied = null;
|
|
1386
|
+
for (const ns of effectiveNamespaces) {
|
|
1387
|
+
const peek = this.budget.peek({
|
|
1388
|
+
principal,
|
|
1389
|
+
principalNamespace,
|
|
1390
|
+
queryNamespace: ns
|
|
1391
|
+
});
|
|
1392
|
+
if (peek.reason !== "allowed-same-namespace") {
|
|
1393
|
+
anyCrossNamespace = true;
|
|
1394
|
+
}
|
|
1395
|
+
if (!peek.allowed) {
|
|
1396
|
+
denied = peek;
|
|
1397
|
+
break;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
if (denied) {
|
|
1401
|
+
budgetDecision = denied;
|
|
1402
|
+
} else if (anyCrossNamespace) {
|
|
1403
|
+
budgetDecision = this.budget.record(principal);
|
|
1404
|
+
} else {
|
|
1405
|
+
budgetDecision = {
|
|
1406
|
+
allowed: true,
|
|
1407
|
+
reason: "allowed-same-namespace",
|
|
1408
|
+
count: 0,
|
|
1409
|
+
limit: {
|
|
1410
|
+
softLimit: this.orchestrator.config.recallCrossNamespaceBudgetSoftLimit ?? 10,
|
|
1411
|
+
hardLimit: this.orchestrator.config.recallCrossNamespaceBudgetHardLimit ?? 30,
|
|
1412
|
+
windowMs: this.orchestrator.config.recallCrossNamespaceBudgetWindowMs ?? 6e4
|
|
1413
|
+
}
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
if (!budgetDecision.allowed) {
|
|
1417
|
+
throw new EngramAccessInputError(
|
|
1418
|
+
`recall denied: cross-namespace budget exceeded (${budgetDecision.count}/${budgetDecision.limit.hardLimit} in ${budgetDecision.limit.windowMs}ms window)`
|
|
1419
|
+
);
|
|
1420
|
+
}
|
|
1421
|
+
this.budget.gc();
|
|
1422
|
+
}
|
|
1154
1423
|
const topK = Number.isFinite(request.topK) ? Math.max(0, Math.floor(request.topK ?? 0)) : void 0;
|
|
1155
1424
|
const recallOptions = {
|
|
1156
1425
|
namespace: namespaceOverride,
|
|
@@ -1168,6 +1437,36 @@ var EngramAccessService = class {
|
|
|
1168
1437
|
request.includeDebug === true,
|
|
1169
1438
|
request.sessionKey
|
|
1170
1439
|
);
|
|
1440
|
+
let auditAnomalies;
|
|
1441
|
+
if (this.auditAdapter) {
|
|
1442
|
+
try {
|
|
1443
|
+
const resolvedAgentId = resolvePrincipal(
|
|
1444
|
+
request.sessionKey,
|
|
1445
|
+
this.orchestrator.config
|
|
1446
|
+
);
|
|
1447
|
+
const auditEntry = {
|
|
1448
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1449
|
+
sessionKey: request.sessionKey ?? "",
|
|
1450
|
+
agentId: resolvedAgentId,
|
|
1451
|
+
trigger: "access-surface",
|
|
1452
|
+
queryText: query,
|
|
1453
|
+
candidateMemoryIds: snapshot?.memoryIds ?? [],
|
|
1454
|
+
summary: context.slice(0, 200) || null,
|
|
1455
|
+
injectedChars: context.length,
|
|
1456
|
+
toggleState: "enabled",
|
|
1457
|
+
latencyMs: Date.now() - startedAt,
|
|
1458
|
+
plannerMode: snapshot?.plannerMode ?? mode,
|
|
1459
|
+
requestedMode: mode,
|
|
1460
|
+
fallbackUsed: snapshot?.fallbackUsed ?? false
|
|
1461
|
+
};
|
|
1462
|
+
const auditResult = await this.auditAdapter.record(
|
|
1463
|
+
resolvedAgentId || "__anonymous__",
|
|
1464
|
+
auditEntry
|
|
1465
|
+
);
|
|
1466
|
+
auditAnomalies = auditResult.anomalies;
|
|
1467
|
+
} catch {
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1171
1470
|
return {
|
|
1172
1471
|
query,
|
|
1173
1472
|
sessionKey: request.sessionKey,
|
|
@@ -1182,6 +1481,8 @@ var EngramAccessService = class {
|
|
|
1182
1481
|
fallbackUsed: snapshot?.fallbackUsed ?? false,
|
|
1183
1482
|
sourcesUsed: snapshot?.sourcesUsed ?? [],
|
|
1184
1483
|
budgetsApplied: snapshot?.budgetsApplied,
|
|
1484
|
+
auditAnomalies,
|
|
1485
|
+
budgetWarning: budgetDecision.reason === "warn-over-soft" ? budgetDecision : void 0,
|
|
1185
1486
|
latencyMs: snapshot?.latencyMs ?? Date.now() - startedAt,
|
|
1186
1487
|
debug
|
|
1187
1488
|
};
|
|
@@ -1213,6 +1514,108 @@ var EngramAccessService = class {
|
|
|
1213
1514
|
if (!snapshot && !intent && !graph) return { found: false };
|
|
1214
1515
|
return { found: true, snapshot: snapshot ?? void 0, intent, graph };
|
|
1215
1516
|
}
|
|
1517
|
+
async recallTierExplain(sessionKey, namespace, authenticatedPrincipal) {
|
|
1518
|
+
const namespacesEnabled = this.orchestrator.config.namespacesEnabled;
|
|
1519
|
+
const requestedNamespace = namespace?.trim() ? this.resolveNamespace(namespace) : void 0;
|
|
1520
|
+
const principal = authenticatedPrincipal?.trim() || resolvePrincipal(sessionKey, this.orchestrator.config);
|
|
1521
|
+
if (requestedNamespace) {
|
|
1522
|
+
if (!canReadNamespace(principal, requestedNamespace, this.orchestrator.config)) {
|
|
1523
|
+
return toRecallExplainJson(null);
|
|
1524
|
+
}
|
|
1525
|
+
} else if (namespacesEnabled && !authenticatedPrincipal?.trim() && !sessionKey?.trim()) {
|
|
1526
|
+
return toRecallExplainJson(null);
|
|
1527
|
+
}
|
|
1528
|
+
const candidate = sessionKey ? this.orchestrator.lastRecall.get(sessionKey) : this.orchestrator.lastRecall.getMostRecent();
|
|
1529
|
+
const snapshot = (() => {
|
|
1530
|
+
if (!candidate) return null;
|
|
1531
|
+
if (requestedNamespace) {
|
|
1532
|
+
return candidate.namespace === requestedNamespace ? candidate : null;
|
|
1533
|
+
}
|
|
1534
|
+
if (!namespacesEnabled) return candidate;
|
|
1535
|
+
const snapshotNs = candidate.namespace ?? this.orchestrator.config.defaultNamespace;
|
|
1536
|
+
return canReadNamespace(principal, snapshotNs, this.orchestrator.config) ? candidate : null;
|
|
1537
|
+
})();
|
|
1538
|
+
return toRecallExplainJson(snapshot);
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Recall X-ray (issue #570). Runs a recall with `xrayCapture: true`
|
|
1542
|
+
* and returns the resulting snapshot as structured JSON so every
|
|
1543
|
+
* surface (CLI / HTTP / MCP) gets the same payload. Namespace scope
|
|
1544
|
+
* is enforced before the recall fires (CLAUDE.md rule 42 — read and
|
|
1545
|
+
* write paths must resolve through the same namespace layer) so an
|
|
1546
|
+
* unauthorized principal cannot capture an x-ray for a namespace it
|
|
1547
|
+
* cannot read.
|
|
1548
|
+
*/
|
|
1549
|
+
async recallXray(request) {
|
|
1550
|
+
const query = typeof request.query === "string" ? request.query : "";
|
|
1551
|
+
if (query.trim().length === 0) {
|
|
1552
|
+
throw new Error("recallXray: query is required and must be non-empty");
|
|
1553
|
+
}
|
|
1554
|
+
const namespacesEnabled = this.orchestrator.config.namespacesEnabled;
|
|
1555
|
+
const requestedNamespace = request.namespace?.trim() ? this.resolveNamespace(request.namespace) : void 0;
|
|
1556
|
+
const authenticatedPrincipal = request.authenticatedPrincipal?.trim();
|
|
1557
|
+
const principal = authenticatedPrincipal || resolvePrincipal(request.sessionKey, this.orchestrator.config);
|
|
1558
|
+
if (requestedNamespace) {
|
|
1559
|
+
if (!canReadNamespace(
|
|
1560
|
+
principal,
|
|
1561
|
+
requestedNamespace,
|
|
1562
|
+
this.orchestrator.config
|
|
1563
|
+
)) {
|
|
1564
|
+
return { snapshotFound: false };
|
|
1565
|
+
}
|
|
1566
|
+
} else if (namespacesEnabled && !authenticatedPrincipal && !request.sessionKey?.trim()) {
|
|
1567
|
+
return { snapshotFound: false };
|
|
1568
|
+
}
|
|
1569
|
+
let budgetOverride;
|
|
1570
|
+
if (request.budget !== void 0 && request.budget !== null) {
|
|
1571
|
+
const parsed = typeof request.budget === "number" ? request.budget : Number(request.budget);
|
|
1572
|
+
if (!Number.isFinite(parsed) || parsed <= 0 || !Number.isInteger(parsed)) {
|
|
1573
|
+
throw new Error(
|
|
1574
|
+
`recallXray: budget expects a positive integer; got ${JSON.stringify(request.budget)}`
|
|
1575
|
+
);
|
|
1576
|
+
}
|
|
1577
|
+
budgetOverride = parsed;
|
|
1578
|
+
}
|
|
1579
|
+
const previousQueue = this.xrayQueue;
|
|
1580
|
+
let release = () => {
|
|
1581
|
+
};
|
|
1582
|
+
this.xrayQueue = new Promise((resolve) => {
|
|
1583
|
+
release = resolve;
|
|
1584
|
+
});
|
|
1585
|
+
await previousQueue;
|
|
1586
|
+
try {
|
|
1587
|
+
this.orchestrator.clearLastXraySnapshot();
|
|
1588
|
+
await this.orchestrator.recall(query, request.sessionKey?.trim() || void 0, {
|
|
1589
|
+
xrayCapture: true,
|
|
1590
|
+
...requestedNamespace ? { namespace: requestedNamespace } : {},
|
|
1591
|
+
...budgetOverride !== void 0 ? { budgetCharsOverride: budgetOverride } : {},
|
|
1592
|
+
// When the caller supplies an authenticated principal, forward
|
|
1593
|
+
// it via the dedicated override channel so orchestrator-side
|
|
1594
|
+
// ACL decisions use the SAME principal the access-surface
|
|
1595
|
+
// pre-check above authorized. Threading an
|
|
1596
|
+
// `authenticatedPrincipal` through `sessionKey` would be wrong:
|
|
1597
|
+
// `resolvePrincipal(sessionKey)` only maps configured raw
|
|
1598
|
+
// session keys and otherwise collapses to `"default"`, which
|
|
1599
|
+
// in namespace-enabled deployments produces false denials /
|
|
1600
|
+
// wrong-scope serving despite the pre-check passing
|
|
1601
|
+
// (CLAUDE.md rule 42).
|
|
1602
|
+
...authenticatedPrincipal ? { principalOverride: authenticatedPrincipal } : {}
|
|
1603
|
+
});
|
|
1604
|
+
const snapshot = this.orchestrator.getLastXraySnapshot();
|
|
1605
|
+
if (!snapshot) return { snapshotFound: false };
|
|
1606
|
+
if (requestedNamespace && snapshot.namespace !== requestedNamespace) {
|
|
1607
|
+
return { snapshotFound: false };
|
|
1608
|
+
}
|
|
1609
|
+
return { snapshotFound: true, snapshot };
|
|
1610
|
+
} finally {
|
|
1611
|
+
release();
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
// Sequence lock for `recallXray` — see comment inside the method.
|
|
1615
|
+
// Lives on the instance so every x-ray call on the same service
|
|
1616
|
+
// shares it, and so separate services in the same process (e.g.
|
|
1617
|
+
// per-tenant) do not block each other.
|
|
1618
|
+
xrayQueue = Promise.resolve();
|
|
1216
1619
|
async memoryStore(request) {
|
|
1217
1620
|
const namespace = this.resolveWritableNamespace(
|
|
1218
1621
|
request.namespace,
|
|
@@ -1727,6 +2130,23 @@ var EngramAccessService = class {
|
|
|
1727
2130
|
skippedReason: result.skippedReason
|
|
1728
2131
|
};
|
|
1729
2132
|
}
|
|
2133
|
+
/**
|
|
2134
|
+
* Procedural memory stats (issue #567 PR 5/5). Read-only — resolves the
|
|
2135
|
+
* namespace via the same path used by `recallExplain` / `trustZoneStatus`
|
|
2136
|
+
* so cross-tenant reads are impossible (CLAUDE.md rule 42).
|
|
2137
|
+
*/
|
|
2138
|
+
async procedureStats(request = {}, principal) {
|
|
2139
|
+
const resolvedNamespace = this.resolveReadableNamespace(
|
|
2140
|
+
request.namespace,
|
|
2141
|
+
principal
|
|
2142
|
+
);
|
|
2143
|
+
const storage = await this.orchestrator.getStorage(resolvedNamespace);
|
|
2144
|
+
const report = await computeProcedureStats({
|
|
2145
|
+
storage,
|
|
2146
|
+
config: this.orchestrator.config
|
|
2147
|
+
});
|
|
2148
|
+
return { namespace: resolvedNamespace, ...report };
|
|
2149
|
+
}
|
|
1730
2150
|
async trustZoneStatus(namespace, principal) {
|
|
1731
2151
|
const resolvedNamespace = this.resolveReadableNamespace(namespace, principal);
|
|
1732
2152
|
const storage = await this.orchestrator.getStorage(resolvedNamespace);
|
|
@@ -2529,6 +2949,38 @@ ${next}`);
|
|
|
2529
2949
|
);
|
|
2530
2950
|
return { recorded: true };
|
|
2531
2951
|
}
|
|
2952
|
+
/**
|
|
2953
|
+
* Record a Memory Worth outcome observation (issue #560 PR 3).
|
|
2954
|
+
*
|
|
2955
|
+
* This is distinct from `memoryFeedback` — feedback is a human thumbs
|
|
2956
|
+
* up/down on whether a recalled memory was relevant; outcome is an
|
|
2957
|
+
* automated signal about whether the session that consumed the memory
|
|
2958
|
+
* ultimately succeeded or failed. Outcomes feed the Laplace-smoothed
|
|
2959
|
+
* worth score (`computeMemoryWorth`, PR 2) that PR 4 will use to
|
|
2960
|
+
* downweight memories correlated with bad sessions.
|
|
2961
|
+
*
|
|
2962
|
+
* The underlying writer only touches fact-category memories. Corrections,
|
|
2963
|
+
* procedures, and other kinds return `{ ok: false, reason:
|
|
2964
|
+
* "ineligible_category" }` so a ledger drainer doesn't need to pre-filter.
|
|
2965
|
+
*/
|
|
2966
|
+
async memoryOutcome(request) {
|
|
2967
|
+
if (request.memoryId.includes("/") || request.memoryId.includes("\\")) {
|
|
2968
|
+
throw new EngramAccessInputError(
|
|
2969
|
+
"memoryId must not contain path separators"
|
|
2970
|
+
);
|
|
2971
|
+
}
|
|
2972
|
+
const resolvedNs = this.resolveWritableNamespace(
|
|
2973
|
+
request.namespace,
|
|
2974
|
+
request.sessionKey,
|
|
2975
|
+
request.principal
|
|
2976
|
+
);
|
|
2977
|
+
const storage = await this.orchestrator.getStorage(resolvedNs);
|
|
2978
|
+
return recordMemoryOutcome(storage, {
|
|
2979
|
+
memoryPath: `${request.memoryId}.md`,
|
|
2980
|
+
outcome: request.outcome,
|
|
2981
|
+
timestamp: request.timestamp
|
|
2982
|
+
});
|
|
2983
|
+
}
|
|
2532
2984
|
async memoryPromote(request) {
|
|
2533
2985
|
const resolvedNs = this.resolveWritableNamespace(request.namespace, request.sessionKey, request.principal);
|
|
2534
2986
|
const storage = await this.orchestrator.getStorage(resolvedNs);
|
|
@@ -2607,12 +3059,42 @@ ${next}`);
|
|
|
2607
3059
|
}
|
|
2608
3060
|
return { submitted: memoryIds.length, matched: matchedIds.length };
|
|
2609
3061
|
}
|
|
3062
|
+
// ── Contradiction Review (issue #520) ──────────────────────────────────────
|
|
3063
|
+
get memoryDir() {
|
|
3064
|
+
return this.orchestrator.config.memoryDir;
|
|
3065
|
+
}
|
|
3066
|
+
get storageRef() {
|
|
3067
|
+
return this.orchestrator.storage;
|
|
3068
|
+
}
|
|
3069
|
+
get configRef() {
|
|
3070
|
+
return this.orchestrator.config;
|
|
3071
|
+
}
|
|
3072
|
+
get localLlmRef() {
|
|
3073
|
+
return this.orchestrator.localLlm ?? null;
|
|
3074
|
+
}
|
|
3075
|
+
get fallbackLlmRef() {
|
|
3076
|
+
return this.orchestrator.fastGatewayLlm ?? null;
|
|
3077
|
+
}
|
|
3078
|
+
get embeddingLookupFactoryRef() {
|
|
3079
|
+
return (storage) => {
|
|
3080
|
+
if (!this.orchestrator.config.embeddingFallbackEnabled) return void 0;
|
|
3081
|
+
return async (content, limit) => {
|
|
3082
|
+
try {
|
|
3083
|
+
return await this.orchestrator.semanticDedupLookup(content, limit, storage);
|
|
3084
|
+
} catch {
|
|
3085
|
+
return [];
|
|
3086
|
+
}
|
|
3087
|
+
};
|
|
3088
|
+
};
|
|
3089
|
+
}
|
|
2610
3090
|
};
|
|
2611
3091
|
|
|
2612
3092
|
export {
|
|
2613
3093
|
WorkStorage,
|
|
3094
|
+
computeProcedureStats,
|
|
3095
|
+
formatProcedureStatsText,
|
|
2614
3096
|
EngramAccessInputError,
|
|
2615
3097
|
ENGRAM_ACCESS_WRITE_SCHEMA_VERSION,
|
|
2616
3098
|
EngramAccessService
|
|
2617
3099
|
};
|
|
2618
|
-
//# sourceMappingURL=chunk-
|
|
3100
|
+
//# sourceMappingURL=chunk-GKFXUTJ2.js.map
|