@remnic/core 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-audit.d.ts +56 -0
- package/dist/access-audit.js +9 -0
- package/dist/access-cli.js +70 -53
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.d.ts +16 -9
- package/dist/access-http.js +26 -18
- package/dist/access-mcp.d.ts +16 -9
- package/dist/access-mcp.js +30 -8
- package/dist/access-schema.d.ts +124 -33
- package/dist/access-schema.js +5 -1
- package/dist/{access-service-HmO1Trrx.d.ts → access-service-Br8ZydTK.d.ts} +158 -63
- package/dist/access-service.d.ts +13 -6
- package/dist/access-service.js +23 -14
- package/dist/bootstrap.d.ts +6 -3
- package/dist/briefing.d.ts +1 -0
- package/dist/briefing.js +8 -6
- 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 +6 -6
- package/dist/causal-behavior.js +4 -4
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.js +19 -18
- 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-ITRLGI2T.js → chunk-3OGMS3PE.js} +2 -2
- package/dist/{chunk-DEPL3635.js → chunk-3YGHKTBF.js} +1446 -196
- package/dist/chunk-3YGHKTBF.js.map +1 -0
- package/dist/{chunk-BLKTA7MM.js → chunk-4HQS2HPX.js} +54 -21
- package/dist/chunk-4HQS2HPX.js.map +1 -0
- 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-OIT5QGG4.js → chunk-6AUUAZEX.js} +72 -2
- package/dist/chunk-6AUUAZEX.js.map +1 -0
- package/dist/{chunk-3QHL5ABG.js → chunk-6YJHX2DL.js} +191 -10
- package/dist/chunk-6YJHX2DL.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-44ICJRF3.js → chunk-AYXIPSZO.js} +5 -5
- package/dist/{chunk-MBJHSA7F.js → chunk-BECYBZLX.js} +265 -20
- package/dist/chunk-BECYBZLX.js.map +1 -0
- package/dist/chunk-C4SQJZAF.js +486 -0
- package/dist/chunk-C4SQJZAF.js.map +1 -0
- package/dist/{chunk-6UJ47TVX.js → chunk-CUPFXL3J.js} +2 -2
- package/dist/chunk-DF3RVK3X.js +119 -0
- package/dist/chunk-DF3RVK3X.js.map +1 -0
- package/dist/{chunk-N42IWANG.js → chunk-DG6YMRDC.js} +3 -3
- package/dist/chunk-DGVM5SFL.js +69 -0
- package/dist/chunk-DGVM5SFL.js.map +1 -0
- package/dist/{chunk-3SV6CQHO.js → chunk-DIXB44VE.js} +102 -66
- package/dist/chunk-DIXB44VE.js.map +1 -0
- package/dist/chunk-EIR5VLIH.js +90 -0
- package/dist/chunk-EIR5VLIH.js.map +1 -0
- package/dist/{chunk-GV6NLQ4X.js → chunk-F5VP6YCB.js} +374 -16
- 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-7WQ6SLIE.js → chunk-FVA6TGI3.js} +2 -2
- package/dist/{chunk-PAORGQRI.js → chunk-GA5P7RST.js} +37 -23
- package/dist/chunk-GA5P7RST.js.map +1 -0
- package/dist/chunk-GDFS42HT.js +206 -0
- package/dist/chunk-GDFS42HT.js.map +1 -0
- package/dist/chunk-IISBCCWR.js +52 -0
- package/dist/chunk-IISBCCWR.js.map +1 -0
- package/dist/chunk-JBMSGZEQ.js +441 -0
- package/dist/chunk-JBMSGZEQ.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-KVBLZUKV.js +173 -0
- package/dist/chunk-KVBLZUKV.js.map +1 -0
- package/dist/{chunk-4LACOVZX.js → chunk-L7IXWRYE.js} +10 -5
- package/dist/chunk-L7IXWRYE.js.map +1 -0
- package/dist/chunk-LBLXEFWK.js +51 -0
- package/dist/chunk-LBLXEFWK.js.map +1 -0
- package/dist/{chunk-WBSAYXVI.js → chunk-LOIMBRDE.js} +201 -45
- package/dist/chunk-LOIMBRDE.js.map +1 -0
- package/dist/{chunk-3WHVNEN7.js → chunk-LTCGGW2D.js} +1 -1
- package/dist/chunk-LTCGGW2D.js.map +1 -0
- package/dist/{chunk-ZVBB3T7V.js → chunk-NBVAS5MT.js} +25 -23
- package/dist/chunk-NBVAS5MT.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-NQEVYWX6.js → chunk-OC5OXUQ4.js} +211 -7
- package/dist/chunk-OC5OXUQ4.js.map +1 -0
- package/dist/{chunk-LK6SGL53.js → chunk-OR64ZGRZ.js} +3 -2
- package/dist/chunk-OR64ZGRZ.js.map +1 -0
- package/dist/{chunk-SYUK3VLY.js → chunk-PVICZTKG.js} +117 -5
- package/dist/chunk-PVICZTKG.js.map +1 -0
- package/dist/chunk-PVPWZSSI.js +37 -0
- package/dist/chunk-PVPWZSSI.js.map +1 -0
- package/dist/{chunk-JL2PU6AI.js → chunk-R2XRID2N.js} +2 -2
- 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-SOBJ6NEY.js +18 -0
- package/dist/chunk-SOBJ6NEY.js.map +1 -0
- package/dist/{chunk-JIU55F3X.js → chunk-SPI27QT6.js} +2 -2
- package/dist/{chunk-MVTHXUBX.js → chunk-STGWEHYR.js} +479 -20
- package/dist/chunk-STGWEHYR.js.map +1 -0
- package/dist/{chunk-6LX5ORAS.js → chunk-TMYO7B5P.js} +4 -4
- 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-37UIFYWO.js → chunk-UWB5LMWY.js} +108 -9
- package/dist/chunk-UWB5LMWY.js.map +1 -0
- package/dist/{chunk-47UU5PU2.js → chunk-VBVG2M5G.js} +18 -3
- package/dist/chunk-VBVG2M5G.js.map +1 -0
- package/dist/{chunk-7ECD5ATE.js → chunk-VDX363PS.js} +2 -2
- package/dist/{chunk-O5ETUNBT.js → chunk-VTU2B4VF.js} +7 -3
- package/dist/chunk-VTU2B4VF.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-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-DHHP2Z4X.js → chunk-XXVWLXSG.js} +2 -2
- package/dist/{chunk-XZ2TIKGC.js → chunk-Y7R2XJ5Q.js} +25 -9
- package/dist/chunk-Y7R2XJ5Q.js.map +1 -0
- package/dist/{chunk-ALXMCZEU.js → chunk-Z2E7VW55.js} +6 -3
- package/dist/chunk-Z2E7VW55.js.map +1 -0
- package/dist/chunk-ZAIM4TUE.js +488 -0
- package/dist/chunk-ZAIM4TUE.js.map +1 -0
- package/dist/chunk-ZZTOURJI.js +91 -0
- package/dist/chunk-ZZTOURJI.js.map +1 -0
- package/dist/{cli-BneVIEvh.d.ts → cli-BkeRaYfk.d.ts} +2 -2
- package/dist/cli.d.ts +13 -6
- package/dist/cli.js +42 -31
- package/dist/config.js +2 -2
- 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-scan-GR33PONM.js → contradiction-scan-E3GJTI4F.js} +43 -7
- 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.js +5 -70
- package/dist/direct-answer-wiring.js.map +1 -1
- package/dist/embedding-fallback.js +2 -1
- package/dist/{engine-5TIQBYZR.js → engine-72LSIWQP.js} +8 -7
- package/dist/engine-72LSIWQP.js.map +1 -0
- package/dist/entity-retrieval.d.ts +1 -0
- package/dist/entity-retrieval.js +7 -6
- 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 +10 -9
- package/dist/fallback-llm.js +3 -3
- 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/importance.js +1 -1
- package/dist/index.d.ts +585 -20
- package/dist/index.js +542 -344
- package/dist/index.js.map +1 -1
- package/dist/local-llm.js +2 -2
- 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 +25 -16
- package/dist/{orchestrator-DRYA6_lW.d.ts → orchestrator-CmJ-NTdJ.d.ts} +233 -8
- package/dist/orchestrator.d.ts +6 -3
- package/dist/orchestrator.js +54 -44
- 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 +3 -3
- 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 +12 -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/resolve-provider-secret.d.ts +5 -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 +309 -53
- 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 +22 -7
- package/dist/semantic-rule-promotion.js +7 -6
- package/dist/semantic-rule-verifier.js +7 -6
- package/dist/storage.d.ts +82 -1
- package/dist/storage.js +6 -5
- package/dist/summarizer.js +6 -6
- package/dist/temporal-supersession.d.ts +1 -0
- package/dist/tier-migration.d.ts +2 -1
- package/dist/tokens.js +2 -1
- package/dist/types.d.ts +276 -2
- package/dist/types.js +1 -1
- package/dist/verified-recall.js +7 -6
- package/package.json +1 -1
- package/dist/chunk-37UIFYWO.js.map +0 -1
- package/dist/chunk-3QHL5ABG.js.map +0 -1
- package/dist/chunk-3SV6CQHO.js.map +0 -1
- package/dist/chunk-3WHVNEN7.js.map +0 -1
- package/dist/chunk-47UU5PU2.js.map +0 -1
- package/dist/chunk-4LACOVZX.js.map +0 -1
- package/dist/chunk-6ZH4TU6I.js.map +0 -1
- package/dist/chunk-ALXMCZEU.js.map +0 -1
- package/dist/chunk-BLKTA7MM.js.map +0 -1
- package/dist/chunk-DEPL3635.js.map +0 -1
- package/dist/chunk-GV6NLQ4X.js.map +0 -1
- package/dist/chunk-J4IYOZZ5.js.map +0 -1
- package/dist/chunk-LAYN4LDC.js +0 -267
- package/dist/chunk-LAYN4LDC.js.map +0 -1
- package/dist/chunk-LK6SGL53.js.map +0 -1
- package/dist/chunk-MBJHSA7F.js.map +0 -1
- package/dist/chunk-MTLYEMJB.js.map +0 -1
- package/dist/chunk-MVTHXUBX.js.map +0 -1
- package/dist/chunk-NQEVYWX6.js.map +0 -1
- package/dist/chunk-O5ETUNBT.js.map +0 -1
- package/dist/chunk-OIT5QGG4.js.map +0 -1
- package/dist/chunk-PAORGQRI.js.map +0 -1
- package/dist/chunk-QDYXG4CS.js.map +0 -1
- package/dist/chunk-QNJMBKFK.js.map +0 -1
- package/dist/chunk-SYUK3VLY.js.map +0 -1
- package/dist/chunk-UEYA6UC7.js.map +0 -1
- package/dist/chunk-UVJFDP7P.js +0 -202
- package/dist/chunk-UVJFDP7P.js.map +0 -1
- package/dist/chunk-WBSAYXVI.js.map +0 -1
- package/dist/chunk-XZ2TIKGC.js.map +0 -1
- package/dist/chunk-ZVBB3T7V.js.map +0 -1
- package/dist/contradiction-scan-GR33PONM.js.map +0 -1
- /package/dist/{engine-5TIQBYZR.js.map → access-audit.js.map} +0 -0
- /package/dist/{chunk-ITRLGI2T.js.map → chunk-3OGMS3PE.js.map} +0 -0
- /package/dist/{chunk-44ICJRF3.js.map → chunk-AYXIPSZO.js.map} +0 -0
- /package/dist/{chunk-6UJ47TVX.js.map → chunk-CUPFXL3J.js.map} +0 -0
- /package/dist/{chunk-N42IWANG.js.map → chunk-DG6YMRDC.js.map} +0 -0
- /package/dist/{chunk-7WQ6SLIE.js.map → chunk-FVA6TGI3.js.map} +0 -0
- /package/dist/{chunk-JL2PU6AI.js.map → chunk-R2XRID2N.js.map} +0 -0
- /package/dist/{chunk-4NRAJUDS.js.map → chunk-RBBWYEFJ.js.map} +0 -0
- /package/dist/{chunk-JIU55F3X.js.map → chunk-SPI27QT6.js.map} +0 -0
- /package/dist/{chunk-6LX5ORAS.js.map → chunk-TMYO7B5P.js.map} +0 -0
- /package/dist/{chunk-7ECD5ATE.js.map → chunk-VDX363PS.js.map} +0 -0
- /package/dist/{chunk-3QFQGRHO.js.map → chunk-XMHBH5H6.js.map} +0 -0
- /package/dist/{chunk-DHHP2Z4X.js.map → chunk-XXVWLXSG.js.map} +0 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-DT5TVLJE.js";
|
|
5
5
|
import {
|
|
6
6
|
StorageManager
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-F5VP6YCB.js";
|
|
8
8
|
import {
|
|
9
9
|
getCachedRuleMemories,
|
|
10
10
|
setCachedRuleMemories
|
|
@@ -110,4 +110,4 @@ async function searchVerifiedSemanticRules(options) {
|
|
|
110
110
|
export {
|
|
111
111
|
searchVerifiedSemanticRules
|
|
112
112
|
};
|
|
113
|
-
//# sourceMappingURL=chunk-
|
|
113
|
+
//# sourceMappingURL=chunk-SPI27QT6.js.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toRecallExplainJson
|
|
3
|
+
} from "./chunk-ZAIM4TUE.js";
|
|
1
4
|
import {
|
|
2
5
|
buildProposedActions,
|
|
3
6
|
buildQualityScore,
|
|
@@ -5,7 +8,7 @@ import {
|
|
|
5
8
|
listMemoryGovernanceRuns,
|
|
6
9
|
readMemoryGovernanceRunArtifact,
|
|
7
10
|
runMemoryGovernance
|
|
8
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-3OGMS3PE.js";
|
|
9
12
|
import {
|
|
10
13
|
getTrustZoneStoreStatus,
|
|
11
14
|
isTrustZoneName,
|
|
@@ -16,10 +19,8 @@ import {
|
|
|
16
19
|
summarizeTrustZonePromotionReadiness
|
|
17
20
|
} from "./chunk-EQINRHYR.js";
|
|
18
21
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
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,28 +28,38 @@ 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
44
|
canReadNamespace,
|
|
36
45
|
canWriteNamespace,
|
|
46
|
+
defaultNamespaceForPrincipal,
|
|
47
|
+
recallNamespacesForPrincipal,
|
|
37
48
|
resolvePrincipal
|
|
38
49
|
} from "./chunk-N5AKDXAI.js";
|
|
39
|
-
import {
|
|
40
|
-
AccessIdempotencyStore,
|
|
41
|
-
hashAccessIdempotencyPayload
|
|
42
|
-
} from "./chunk-XKECPATV.js";
|
|
43
50
|
import {
|
|
44
51
|
FileCalendarSource,
|
|
45
52
|
buildBriefing,
|
|
46
53
|
parseBriefingFocus,
|
|
47
54
|
parseBriefingWindow
|
|
48
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-L7IXWRYE.js";
|
|
49
56
|
import {
|
|
50
57
|
parseEntityFile
|
|
51
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-F5VP6YCB.js";
|
|
59
|
+
import {
|
|
60
|
+
inferMemoryStatus,
|
|
61
|
+
toMemoryPathRel
|
|
62
|
+
} from "./chunk-TP4FZJIZ.js";
|
|
52
63
|
import {
|
|
53
64
|
normalizeProjectionPreview,
|
|
54
65
|
normalizeProjectionTags
|
|
@@ -56,13 +67,16 @@ import {
|
|
|
56
67
|
import {
|
|
57
68
|
getMemoryProjectionPath
|
|
58
69
|
} from "./chunk-BOUYNNYD.js";
|
|
59
|
-
import {
|
|
60
|
-
inferMemoryStatus,
|
|
61
|
-
toMemoryPathRel
|
|
62
|
-
} from "./chunk-TP4FZJIZ.js";
|
|
63
70
|
import {
|
|
64
71
|
log
|
|
65
72
|
} from "./chunk-2ODBA7MQ.js";
|
|
73
|
+
import {
|
|
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";
|
|
@@ -772,6 +786,125 @@ async function runProcedureMining(options) {
|
|
|
772
786
|
return { clustersProcessed, proceduresWritten };
|
|
773
787
|
}
|
|
774
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
|
+
|
|
775
908
|
// src/access-service.ts
|
|
776
909
|
var EngramAccessInputError = class extends Error {
|
|
777
910
|
};
|
|
@@ -891,10 +1024,39 @@ var EngramAccessService = class {
|
|
|
891
1024
|
constructor(orchestrator) {
|
|
892
1025
|
this.orchestrator = orchestrator;
|
|
893
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
|
+
}
|
|
894
1054
|
}
|
|
895
1055
|
orchestrator;
|
|
896
1056
|
idempotency;
|
|
897
1057
|
idempotencyLocks = /* @__PURE__ */ new Map();
|
|
1058
|
+
budget;
|
|
1059
|
+
auditAdapter;
|
|
898
1060
|
get briefingEnabled() {
|
|
899
1061
|
return this.orchestrator.config.briefing?.enabled === true;
|
|
900
1062
|
}
|
|
@@ -1147,14 +1309,117 @@ var EngramAccessService = class {
|
|
|
1147
1309
|
followupsUnavailableReason: result.followupsUnavailableReason
|
|
1148
1310
|
};
|
|
1149
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
|
+
}
|
|
1150
1353
|
async recall(request) {
|
|
1151
1354
|
const query = request.query.trim();
|
|
1152
1355
|
if (query.length === 0) {
|
|
1153
1356
|
throw new EngramAccessInputError("query is required");
|
|
1154
1357
|
}
|
|
1358
|
+
if (request.codingContext !== void 0 && request.sessionKey) {
|
|
1359
|
+
this.setCodingContext({
|
|
1360
|
+
sessionKey: request.sessionKey,
|
|
1361
|
+
codingContext: request.codingContext
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1155
1364
|
const namespaceOverride = this.resolveRecallNamespace(request.namespace, request.sessionKey);
|
|
1156
1365
|
const namespace = namespaceOverride ?? this.orchestrator.config.defaultNamespace;
|
|
1157
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
|
+
}
|
|
1158
1423
|
const topK = Number.isFinite(request.topK) ? Math.max(0, Math.floor(request.topK ?? 0)) : void 0;
|
|
1159
1424
|
const recallOptions = {
|
|
1160
1425
|
namespace: namespaceOverride,
|
|
@@ -1172,6 +1437,36 @@ var EngramAccessService = class {
|
|
|
1172
1437
|
request.includeDebug === true,
|
|
1173
1438
|
request.sessionKey
|
|
1174
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
|
+
}
|
|
1175
1470
|
return {
|
|
1176
1471
|
query,
|
|
1177
1472
|
sessionKey: request.sessionKey,
|
|
@@ -1186,6 +1481,8 @@ var EngramAccessService = class {
|
|
|
1186
1481
|
fallbackUsed: snapshot?.fallbackUsed ?? false,
|
|
1187
1482
|
sourcesUsed: snapshot?.sourcesUsed ?? [],
|
|
1188
1483
|
budgetsApplied: snapshot?.budgetsApplied,
|
|
1484
|
+
auditAnomalies,
|
|
1485
|
+
budgetWarning: budgetDecision.reason === "warn-over-soft" ? budgetDecision : void 0,
|
|
1189
1486
|
latencyMs: snapshot?.latencyMs ?? Date.now() - startedAt,
|
|
1190
1487
|
debug
|
|
1191
1488
|
};
|
|
@@ -1217,6 +1514,108 @@ var EngramAccessService = class {
|
|
|
1217
1514
|
if (!snapshot && !intent && !graph) return { found: false };
|
|
1218
1515
|
return { found: true, snapshot: snapshot ?? void 0, intent, graph };
|
|
1219
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();
|
|
1220
1619
|
async memoryStore(request) {
|
|
1221
1620
|
const namespace = this.resolveWritableNamespace(
|
|
1222
1621
|
request.namespace,
|
|
@@ -1731,6 +2130,23 @@ var EngramAccessService = class {
|
|
|
1731
2130
|
skippedReason: result.skippedReason
|
|
1732
2131
|
};
|
|
1733
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
|
+
}
|
|
1734
2150
|
async trustZoneStatus(namespace, principal) {
|
|
1735
2151
|
const resolvedNamespace = this.resolveReadableNamespace(namespace, principal);
|
|
1736
2152
|
const storage = await this.orchestrator.getStorage(resolvedNamespace);
|
|
@@ -2533,6 +2949,38 @@ ${next}`);
|
|
|
2533
2949
|
);
|
|
2534
2950
|
return { recorded: true };
|
|
2535
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
|
+
}
|
|
2536
2984
|
async memoryPromote(request) {
|
|
2537
2985
|
const resolvedNs = this.resolveWritableNamespace(request.namespace, request.sessionKey, request.principal);
|
|
2538
2986
|
const storage = await this.orchestrator.getStorage(resolvedNs);
|
|
@@ -2625,17 +3073,28 @@ ${next}`);
|
|
|
2625
3073
|
return this.orchestrator.localLlm ?? null;
|
|
2626
3074
|
}
|
|
2627
3075
|
get fallbackLlmRef() {
|
|
2628
|
-
return null;
|
|
3076
|
+
return this.orchestrator.fastGatewayLlm ?? null;
|
|
2629
3077
|
}
|
|
2630
|
-
get
|
|
2631
|
-
return
|
|
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
|
+
};
|
|
2632
3089
|
}
|
|
2633
3090
|
};
|
|
2634
3091
|
|
|
2635
3092
|
export {
|
|
2636
3093
|
WorkStorage,
|
|
3094
|
+
computeProcedureStats,
|
|
3095
|
+
formatProcedureStatsText,
|
|
2637
3096
|
EngramAccessInputError,
|
|
2638
3097
|
ENGRAM_ACCESS_WRITE_SCHEMA_VERSION,
|
|
2639
3098
|
EngramAccessService
|
|
2640
3099
|
};
|
|
2641
|
-
//# sourceMappingURL=chunk-
|
|
3100
|
+
//# sourceMappingURL=chunk-STGWEHYR.js.map
|