@remnic/core 9.3.641 → 9.3.643

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.
@@ -77,6 +77,7 @@ interface RemnicChatGptMemoryInspectorInput {
77
77
  sessionKey?: string;
78
78
  namespace?: string;
79
79
  currentContextScopes?: string[];
80
+ allowUnverifiedPreview?: boolean;
80
81
  }
81
82
  interface RemnicChatGptMemoryCard {
82
83
  id: string;
@@ -6,7 +6,7 @@ import {
6
6
  REMNIC_CHATGPT_MEMORY_INSPECTOR_WIDGET_URI,
7
7
  buildChatGptMemoryInspectorActionRequest,
8
8
  buildChatGptMemoryInspectorResult
9
- } from "./chunk-6L46YAEZ.js";
9
+ } from "./chunk-T4WDJPEZ.js";
10
10
  import "./chunk-PZ5AY32C.js";
11
11
  export {
12
12
  REMNIC_CHATGPT_MEMORY_INSPECTOR_CANONICAL_TOOL,
package/dist/schemas.d.ts CHANGED
@@ -275,12 +275,12 @@ declare const EntityMentionSchema: z.ZodObject<{
275
275
  title: z.ZodString;
276
276
  facts: z.ZodArray<z.ZodString, "many">;
277
277
  }, "strip", z.ZodTypeAny, {
278
- title: string;
279
278
  key: string;
279
+ title: string;
280
280
  facts: string[];
281
281
  }, {
282
- title: string;
283
282
  key: string;
283
+ title: string;
284
284
  facts: string[];
285
285
  }>, "many">>>;
286
286
  }, "strip", z.ZodTypeAny, {
@@ -288,8 +288,8 @@ declare const EntityMentionSchema: z.ZodObject<{
288
288
  name: string;
289
289
  facts: string[];
290
290
  structuredSections?: {
291
- title: string;
292
291
  key: string;
292
+ title: string;
293
293
  facts: string[];
294
294
  }[] | null | undefined;
295
295
  promptedByQuestion?: string | null | undefined;
@@ -298,8 +298,8 @@ declare const EntityMentionSchema: z.ZodObject<{
298
298
  name: string;
299
299
  facts: string[];
300
300
  structuredSections?: {
301
- title: string;
302
301
  key: string;
302
+ title: string;
303
303
  facts: string[];
304
304
  }[] | null | undefined;
305
305
  promptedByQuestion?: string | null | undefined;
@@ -584,12 +584,12 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
584
584
  title: z.ZodString;
585
585
  facts: z.ZodArray<z.ZodString, "many">;
586
586
  }, "strip", z.ZodTypeAny, {
587
- title: string;
588
587
  key: string;
588
+ title: string;
589
589
  facts: string[];
590
590
  }, {
591
- title: string;
592
591
  key: string;
592
+ title: string;
593
593
  facts: string[];
594
594
  }>, "many">>>;
595
595
  }, "strip", z.ZodTypeAny, {
@@ -597,8 +597,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
597
597
  name: string;
598
598
  facts: string[];
599
599
  structuredSections?: {
600
- title: string;
601
600
  key: string;
601
+ title: string;
602
602
  facts: string[];
603
603
  }[] | null | undefined;
604
604
  promptedByQuestion?: string | null | undefined;
@@ -607,8 +607,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
607
607
  name: string;
608
608
  facts: string[];
609
609
  structuredSections?: {
610
- title: string;
611
610
  key: string;
611
+ title: string;
612
612
  facts: string[];
613
613
  }[] | null | undefined;
614
614
  promptedByQuestion?: string | null | undefined;
@@ -665,8 +665,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
665
665
  name: string;
666
666
  facts: string[];
667
667
  structuredSections?: {
668
- title: string;
669
668
  key: string;
669
+ title: string;
670
670
  facts: string[];
671
671
  }[] | null | undefined;
672
672
  promptedByQuestion?: string | null | undefined;
@@ -714,8 +714,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
714
714
  name: string;
715
715
  facts: string[];
716
716
  structuredSections?: {
717
- title: string;
718
717
  key: string;
718
+ title: string;
719
719
  facts: string[];
720
720
  }[] | null | undefined;
721
721
  promptedByQuestion?: string | null | undefined;
@@ -952,12 +952,12 @@ declare const ExtractionResultSchema: z.ZodObject<{
952
952
  title: z.ZodString;
953
953
  facts: z.ZodArray<z.ZodString, "many">;
954
954
  }, "strip", z.ZodTypeAny, {
955
- title: string;
956
955
  key: string;
956
+ title: string;
957
957
  facts: string[];
958
958
  }, {
959
- title: string;
960
959
  key: string;
960
+ title: string;
961
961
  facts: string[];
962
962
  }>, "many">>>;
963
963
  }, "strip", z.ZodTypeAny, {
@@ -965,8 +965,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
965
965
  name: string;
966
966
  facts: string[];
967
967
  structuredSections?: {
968
- title: string;
969
968
  key: string;
969
+ title: string;
970
970
  facts: string[];
971
971
  }[] | null | undefined;
972
972
  promptedByQuestion?: string | null | undefined;
@@ -975,8 +975,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
975
975
  name: string;
976
976
  facts: string[];
977
977
  structuredSections?: {
978
- title: string;
979
978
  key: string;
979
+ title: string;
980
980
  facts: string[];
981
981
  }[] | null | undefined;
982
982
  promptedByQuestion?: string | null | undefined;
@@ -1047,8 +1047,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
1047
1047
  name: string;
1048
1048
  facts: string[];
1049
1049
  structuredSections?: {
1050
- title: string;
1051
1050
  key: string;
1051
+ title: string;
1052
1052
  facts: string[];
1053
1053
  }[] | null | undefined;
1054
1054
  promptedByQuestion?: string | null | undefined;
@@ -1102,8 +1102,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
1102
1102
  name: string;
1103
1103
  facts: string[];
1104
1104
  structuredSections?: {
1105
- title: string;
1106
1105
  key: string;
1106
+ title: string;
1107
1107
  facts: string[];
1108
1108
  }[] | null | undefined;
1109
1109
  promptedByQuestion?: string | null | undefined;
@@ -1172,12 +1172,12 @@ declare const ConsolidationResultSchema: z.ZodObject<{
1172
1172
  title: z.ZodString;
1173
1173
  facts: z.ZodArray<z.ZodString, "many">;
1174
1174
  }, "strip", z.ZodTypeAny, {
1175
- title: string;
1176
1175
  key: string;
1176
+ title: string;
1177
1177
  facts: string[];
1178
1178
  }, {
1179
- title: string;
1180
1179
  key: string;
1180
+ title: string;
1181
1181
  facts: string[];
1182
1182
  }>, "many">>>;
1183
1183
  }, "strip", z.ZodTypeAny, {
@@ -1185,8 +1185,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
1185
1185
  name: string;
1186
1186
  facts: string[];
1187
1187
  structuredSections?: {
1188
- title: string;
1189
1188
  key: string;
1189
+ title: string;
1190
1190
  facts: string[];
1191
1191
  }[] | null | undefined;
1192
1192
  promptedByQuestion?: string | null | undefined;
@@ -1195,8 +1195,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
1195
1195
  name: string;
1196
1196
  facts: string[];
1197
1197
  structuredSections?: {
1198
- title: string;
1199
1198
  key: string;
1199
+ title: string;
1200
1200
  facts: string[];
1201
1201
  }[] | null | undefined;
1202
1202
  promptedByQuestion?: string | null | undefined;
@@ -1215,8 +1215,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
1215
1215
  name: string;
1216
1216
  facts: string[];
1217
1217
  structuredSections?: {
1218
- title: string;
1219
1218
  key: string;
1219
+ title: string;
1220
1220
  facts: string[];
1221
1221
  }[] | null | undefined;
1222
1222
  promptedByQuestion?: string | null | undefined;
@@ -1235,8 +1235,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
1235
1235
  name: string;
1236
1236
  facts: string[];
1237
1237
  structuredSections?: {
1238
- title: string;
1239
1238
  key: string;
1239
+ title: string;
1240
1240
  facts: string[];
1241
1241
  }[] | null | undefined;
1242
1242
  promptedByQuestion?: string | null | undefined;
@@ -313,13 +313,13 @@ declare const CapsuleBlockSchema: z.ZodObject<{
313
313
  peerProfiles: boolean;
314
314
  }>;
315
315
  }, "strip", z.ZodTypeAny, {
316
- schemaVersion: string;
317
316
  includes: {
318
317
  procedural: boolean;
319
318
  taxonomy: boolean;
320
319
  identityAnchors: boolean;
321
320
  peerProfiles: boolean;
322
321
  };
322
+ schemaVersion: string;
323
323
  id: string;
324
324
  description: string;
325
325
  version: string;
@@ -334,13 +334,13 @@ declare const CapsuleBlockSchema: z.ZodObject<{
334
334
  directAnswerEnabled: boolean;
335
335
  };
336
336
  }, {
337
- schemaVersion: string;
338
337
  includes: {
339
338
  procedural: boolean;
340
339
  taxonomy: boolean;
341
340
  identityAnchors: boolean;
342
341
  peerProfiles: boolean;
343
342
  };
343
+ schemaVersion: string;
344
344
  id: string;
345
345
  description: string;
346
346
  version: string;
@@ -464,13 +464,13 @@ declare const ExportManifestV2Schema: z.ZodObject<{
464
464
  peerProfiles: boolean;
465
465
  }>;
466
466
  }, "strip", z.ZodTypeAny, {
467
- schemaVersion: string;
468
467
  includes: {
469
468
  procedural: boolean;
470
469
  taxonomy: boolean;
471
470
  identityAnchors: boolean;
472
471
  peerProfiles: boolean;
473
472
  };
473
+ schemaVersion: string;
474
474
  id: string;
475
475
  description: string;
476
476
  version: string;
@@ -485,13 +485,13 @@ declare const ExportManifestV2Schema: z.ZodObject<{
485
485
  directAnswerEnabled: boolean;
486
486
  };
487
487
  }, {
488
- schemaVersion: string;
489
488
  includes: {
490
489
  procedural: boolean;
491
490
  taxonomy: boolean;
492
491
  identityAnchors: boolean;
493
492
  peerProfiles: boolean;
494
493
  };
494
+ schemaVersion: string;
495
495
  id: string;
496
496
  description: string;
497
497
  version: string;
@@ -518,13 +518,13 @@ declare const ExportManifestV2Schema: z.ZodObject<{
518
518
  pluginVersion: string;
519
519
  includesTranscripts: boolean;
520
520
  capsule: {
521
- schemaVersion: string;
522
521
  includes: {
523
522
  procedural: boolean;
524
523
  taxonomy: boolean;
525
524
  identityAnchors: boolean;
526
525
  peerProfiles: boolean;
527
526
  };
527
+ schemaVersion: string;
528
528
  id: string;
529
529
  description: string;
530
530
  version: string;
@@ -551,13 +551,13 @@ declare const ExportManifestV2Schema: z.ZodObject<{
551
551
  pluginVersion: string;
552
552
  includesTranscripts: boolean;
553
553
  capsule: {
554
- schemaVersion: string;
555
554
  includes: {
556
555
  procedural: boolean;
557
556
  taxonomy: boolean;
558
557
  identityAnchors: boolean;
559
558
  peerProfiles: boolean;
560
559
  };
560
+ schemaVersion: string;
561
561
  id: string;
562
562
  description: string;
563
563
  version: string;
@@ -683,13 +683,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
683
683
  peerProfiles: boolean;
684
684
  }>;
685
685
  }, "strip", z.ZodTypeAny, {
686
- schemaVersion: string;
687
686
  includes: {
688
687
  procedural: boolean;
689
688
  taxonomy: boolean;
690
689
  identityAnchors: boolean;
691
690
  peerProfiles: boolean;
692
691
  };
692
+ schemaVersion: string;
693
693
  id: string;
694
694
  description: string;
695
695
  version: string;
@@ -704,13 +704,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
704
704
  directAnswerEnabled: boolean;
705
705
  };
706
706
  }, {
707
- schemaVersion: string;
708
707
  includes: {
709
708
  procedural: boolean;
710
709
  taxonomy: boolean;
711
710
  identityAnchors: boolean;
712
711
  peerProfiles: boolean;
713
712
  };
713
+ schemaVersion: string;
714
714
  id: string;
715
715
  description: string;
716
716
  version: string;
@@ -737,13 +737,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
737
737
  pluginVersion: string;
738
738
  includesTranscripts: boolean;
739
739
  capsule: {
740
- schemaVersion: string;
741
740
  includes: {
742
741
  procedural: boolean;
743
742
  taxonomy: boolean;
744
743
  identityAnchors: boolean;
745
744
  peerProfiles: boolean;
746
745
  };
746
+ schemaVersion: string;
747
747
  id: string;
748
748
  description: string;
749
749
  version: string;
@@ -770,13 +770,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
770
770
  pluginVersion: string;
771
771
  includesTranscripts: boolean;
772
772
  capsule: {
773
- schemaVersion: string;
774
773
  includes: {
775
774
  procedural: boolean;
776
775
  taxonomy: boolean;
777
776
  identityAnchors: boolean;
778
777
  peerProfiles: boolean;
779
778
  };
779
+ schemaVersion: string;
780
780
  id: string;
781
781
  description: string;
782
782
  version: string;
@@ -815,13 +815,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
815
815
  pluginVersion: string;
816
816
  includesTranscripts: boolean;
817
817
  capsule: {
818
- schemaVersion: string;
819
818
  includes: {
820
819
  procedural: boolean;
821
820
  taxonomy: boolean;
822
821
  identityAnchors: boolean;
823
822
  peerProfiles: boolean;
824
823
  };
824
+ schemaVersion: string;
825
825
  id: string;
826
826
  description: string;
827
827
  version: string;
@@ -854,13 +854,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
854
854
  pluginVersion: string;
855
855
  includesTranscripts: boolean;
856
856
  capsule: {
857
- schemaVersion: string;
858
857
  includes: {
859
858
  procedural: boolean;
860
859
  taxonomy: boolean;
861
860
  identityAnchors: boolean;
862
861
  peerProfiles: boolean;
863
862
  };
863
+ schemaVersion: string;
864
864
  id: string;
865
865
  description: string;
866
866
  version: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remnic/core",
3
- "version": "9.3.641",
3
+ "version": "9.3.643",
4
4
  "description": "Framework-agnostic Remnic memory engine — orchestrator, storage, extraction, search, trust zones",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/access-mcp.ts CHANGED
@@ -715,6 +715,11 @@ export class EngramMcpServer {
715
715
  description:
716
716
  "Optional current user-context scopes, such as repo, work, personal, client, or private.",
717
717
  },
718
+ allowUnverifiedPreview: {
719
+ type: "boolean",
720
+ description:
721
+ "If true, the inspector may show recalled preview text when X-ray provenance is missing or unavailable. Explicitly blocked memories remain redacted.",
722
+ },
718
723
  },
719
724
  required: ["query"],
720
725
  additionalProperties: false,
@@ -2608,6 +2613,17 @@ export class EngramMcpServer {
2608
2613
  if (currentContextScopes !== undefined) {
2609
2614
  input.currentContextScopes = currentContextScopes;
2610
2615
  }
2616
+ if (
2617
+ args.allowUnverifiedPreview !== undefined &&
2618
+ args.allowUnverifiedPreview !== null
2619
+ ) {
2620
+ if (typeof args.allowUnverifiedPreview !== "boolean") {
2621
+ throw new EngramAccessInputError(
2622
+ "allowUnverifiedPreview must be a boolean",
2623
+ );
2624
+ }
2625
+ input.allowUnverifiedPreview = args.allowUnverifiedPreview;
2626
+ }
2611
2627
  const recallSessionKey = resolveChatGptInspectorRecallSessionKey(
2612
2628
  input.sessionKey,
2613
2629
  effectivePrincipal,
package/src/index.ts CHANGED
@@ -754,9 +754,7 @@ export {
754
754
  type ExtensionSchema,
755
755
  } from "./memory-extension-host/index.js";
756
756
 
757
- export {
758
- buildExtensionsBlockForConsolidation,
759
- } from "./semantic-consolidation.js";
757
+ export { buildExtensionsBlockForConsolidation } from "./semantic-consolidation.js";
760
758
 
761
759
  // ---------------------------------------------------------------------------
762
760
  // Connector Manager
@@ -1084,6 +1082,12 @@ export {
1084
1082
  type FallbackLlmRuntimeContext,
1085
1083
  } from "./fallback-llm.js";
1086
1084
 
1085
+ // ---------------------------------------------------------------------------
1086
+ // Local AI session summary drafts
1087
+ // ---------------------------------------------------------------------------
1088
+
1089
+ export * from "./session-summaries/index.js";
1090
+
1087
1091
  // ---------------------------------------------------------------------------
1088
1092
  // Training-data export (issue #459)
1089
1093
  // ---------------------------------------------------------------------------
@@ -1178,7 +1182,6 @@ export type {
1178
1182
  CrossNamespaceBudgetConfig,
1179
1183
  } from "./cross-namespace-budget.js";
1180
1184
 
1181
-
1182
1185
  // ---------------------------------------------------------------------------
1183
1186
  // Recall-audit anomaly detector (issue #565 PR 5/5)
1184
1187
  // ---------------------------------------------------------------------------
@@ -18,6 +18,7 @@ export interface RemnicChatGptMemoryInspectorInput {
18
18
  sessionKey?: string;
19
19
  namespace?: string;
20
20
  currentContextScopes?: string[];
21
+ allowUnverifiedPreview?: boolean;
21
22
  }
22
23
 
23
24
  export interface RemnicChatGptMemoryCard {
@@ -115,21 +116,42 @@ export function buildChatGptMemoryInspectorResult(
115
116
  actionConfidence: ActionConfidenceResult,
116
117
  ): RemnicChatGptMemoryInspectorResult {
117
118
  const xrayUnavailable = xray === null;
118
- const matchXrayResult = buildXrayResultMatcher(xray);
119
+ const allowUnverifiedPreview = input.allowUnverifiedPreview === true;
120
+ const matchXrayResult = buildXrayResultMatcher(xray, recall.results);
119
121
  const matchedXrayResults = recall.results.map(matchXrayResult);
122
+ const hasBlockedSameId = buildBlockedSameIdMatcher(xray);
120
123
 
121
124
  const memories = recall.results.slice(0, 8).map((summary) => {
122
125
  const xrayResult = matchXrayResult(summary);
123
126
  const provenance = xrayResult?.provenance;
124
- const unverified = !xrayUnavailable && provenance === undefined;
125
- const blocked = provenance?.safety === "blocked";
127
+ const blockedByAmbiguousSameId = !xrayUnavailable
128
+ && xrayResult === undefined
129
+ && hasBlockedSameId(summary.id);
130
+ const blocked = provenance?.safety === "blocked" || blockedByAmbiguousSameId;
131
+ const unverified = !xrayUnavailable && provenance === undefined && !blockedByAmbiguousSameId;
126
132
  const preview = xrayUnavailable
127
- ? "Preview withheld: X-ray provenance was unavailable for this recall."
128
- : unverified
129
- ? "Preview withheld: X-ray provenance was missing for this memory."
133
+ ? allowUnverifiedPreview
134
+ ? summary.preview
135
+ : "Preview withheld: X-ray provenance was unavailable for this recall."
130
136
  : blocked
131
137
  ? "Preview withheld: this memory is blocked in the current context."
132
- : summary.preview;
138
+ : unverified
139
+ ? allowUnverifiedPreview
140
+ ? summary.preview
141
+ : "Preview withheld: X-ray provenance was missing for this memory."
142
+ : summary.preview;
143
+ const fallbackSafety = blockedByAmbiguousSameId
144
+ ? "blocked"
145
+ : xrayUnavailable || unverified
146
+ ? allowUnverifiedPreview
147
+ ? "requires-review"
148
+ : "blocked"
149
+ : undefined;
150
+ const fallbackSafetyReason = xrayUnavailable
151
+ ? "X-ray provenance was unavailable for this recall."
152
+ : blockedByAmbiguousSameId
153
+ ? "An unmatched X-ray row with this memory id was blocked."
154
+ : "X-ray provenance was missing for this memory.";
133
155
  return {
134
156
  id: summary.id,
135
157
  path: summary.path,
@@ -144,25 +166,43 @@ export function buildChatGptMemoryInspectorResult(
144
166
  confidence: provenance?.confidence,
145
167
  stale: provenance?.stale,
146
168
  corrected: provenance?.corrected,
147
- safeToUse: provenance?.safeToUse ?? (unverified ? false : undefined),
148
- safety: provenance?.safety ?? (unverified ? "blocked" : undefined),
169
+ safeToUse: provenance?.safeToUse
170
+ ?? (xrayUnavailable || unverified || blockedByAmbiguousSameId ? false : undefined),
171
+ safety: provenance?.safety ?? fallbackSafety,
149
172
  safetyReasons: provenance?.safetyReasons
150
- ?? (unverified ? ["X-ray provenance was missing for this memory."] : []),
173
+ ?? (
174
+ xrayUnavailable || unverified || blockedByAmbiguousSameId
175
+ ? [fallbackSafetyReason]
176
+ : []
177
+ ),
151
178
  userContextScopes: provenance?.userContextScopes ?? [],
152
179
  };
153
180
  });
154
181
  const blockedCount = matchedXrayResults
155
182
  .filter((result) => result?.provenance?.safety === "blocked")
156
183
  .length;
184
+ const ambiguousBlockedCount = recall.results
185
+ .filter((summary, index) =>
186
+ matchedXrayResults[index] === undefined && hasBlockedSameId(summary.id)
187
+ )
188
+ .length;
157
189
  const missingProvenanceCount = xrayUnavailable
158
190
  ? 0
159
191
  : matchedXrayResults
160
- .filter((result) => result?.provenance === undefined)
192
+ .filter((result, index) =>
193
+ result?.provenance === undefined
194
+ && !(result === undefined && hasBlockedSameId(recall.results[index]?.id ?? ""))
195
+ )
161
196
  .length;
197
+ const totalBlockedCount = blockedCount + ambiguousBlockedCount;
162
198
  const safeRecallPreview = xrayUnavailable
163
- ? "Recall preview withheld: X-ray provenance was unavailable, so memory safety could not be verified."
164
- : blockedCount > 0 || missingProvenanceCount > 0
165
- ? formatUnsafeRecallPreview(blockedCount, missingProvenanceCount)
199
+ ? allowUnverifiedPreview
200
+ ? `Unverified recall preview: X-ray provenance was unavailable, so memory safety could not be verified.\n\n${truncate(recall.context, 1_500)}`
201
+ : "Recall preview withheld: X-ray provenance was unavailable, so memory safety could not be verified."
202
+ : totalBlockedCount > 0 || missingProvenanceCount > 0
203
+ ? totalBlockedCount > 0 || !allowUnverifiedPreview
204
+ ? formatUnsafeRecallPreview(totalBlockedCount, missingProvenanceCount)
205
+ : `Unverified recall preview: ${missingProvenanceCount} retrieved ${memoryNoun(missingProvenanceCount)} ${isAre(missingProvenanceCount)} missing X-ray provenance.\n\n${truncate(recall.context, 1_500)}`
166
206
  : truncate(recall.context, 1_500);
167
207
 
168
208
  const primaryMemoryId = memories[0]?.id ?? "<memory-id>";
@@ -372,7 +412,7 @@ function buildRecallProvenances(
372
412
  if (xray === null) {
373
413
  return recall.results.map(missingRecallProvenance);
374
414
  }
375
- const matchXrayResult = buildXrayResultMatcher(xray);
415
+ const matchXrayResult = buildXrayResultMatcher(xray, recall.results);
376
416
  return recall.results.map((summary) => {
377
417
  const result = matchXrayResult(summary);
378
418
  if (result === undefined) {
@@ -384,21 +424,43 @@ function buildRecallProvenances(
384
424
 
385
425
  function buildXrayResultMatcher(
386
426
  xray: RecallXraySnapshot | null,
427
+ recallResults: EngramAccessRecallResponse["results"],
387
428
  ): (summary: EngramAccessRecallResponse["results"][number]) => RecallXrayResult | undefined {
388
429
  const xrayById = new Map<string, RecallXrayResult>();
430
+ const xrayIdCounts = new Map<string, number>();
431
+ const recallIdCounts = new Map<string, number>();
389
432
  const xrayByPath = new Map<string, RecallXrayResult>();
433
+ for (const summary of recallResults) {
434
+ recallIdCounts.set(summary.id, (recallIdCounts.get(summary.id) ?? 0) + 1);
435
+ }
390
436
  for (const result of xray?.results ?? []) {
391
437
  xrayById.set(result.memoryId, result);
438
+ xrayIdCounts.set(result.memoryId, (xrayIdCounts.get(result.memoryId) ?? 0) + 1);
392
439
  xrayByPath.set(result.path, result);
393
440
  }
394
441
  return (summary) => {
395
442
  if (summary.path) {
396
- return xrayByPath.get(summary.path);
443
+ const pathMatch = xrayByPath.get(summary.path);
444
+ if (pathMatch) return pathMatch;
397
445
  }
398
- return xrayById.get(summary.id);
446
+ return xrayIdCounts.get(summary.id) === 1 && recallIdCounts.get(summary.id) === 1
447
+ ? xrayById.get(summary.id)
448
+ : undefined;
399
449
  };
400
450
  }
401
451
 
452
+ function buildBlockedSameIdMatcher(
453
+ xray: RecallXraySnapshot | null,
454
+ ): (memoryId: string) => boolean {
455
+ const blockedIds = new Set<string>();
456
+ for (const result of xray?.results ?? []) {
457
+ if (result.provenance?.safety === "blocked") {
458
+ blockedIds.add(result.memoryId);
459
+ }
460
+ }
461
+ return (memoryId) => blockedIds.has(memoryId);
462
+ }
463
+
402
464
  function missingProvenance(result: RecallXrayResult): RetrievedMemoryProvenance {
403
465
  return {
404
466
  source: "unknown",