aifastdb 3.8.9 → 3.10.0

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.
@@ -18,6 +18,622 @@ exports.ChangeTypes = exports.AnchorStatus = exports.AnchorTypes = exports.Memor
18
18
  exports.createSocialGraphV2 = createSocialGraphV2;
19
19
  exports.createHighThroughputSocialGraph = createHighThroughputSocialGraph;
20
20
  exports.createLowLatencySocialGraph = createLowLatencySocialGraph;
21
+ function normalizeImportSession(raw) {
22
+ if (!raw)
23
+ return null;
24
+ return {
25
+ sessionId: raw.sessionId ?? raw.session_id,
26
+ datasetKey: raw.datasetKey ?? raw.dataset_key,
27
+ sourceName: raw.sourceName ?? raw.source_name,
28
+ importBatchId: raw.importBatchId ?? raw.import_batch_id,
29
+ mode: raw.mode,
30
+ status: raw.status,
31
+ startedAt: raw.startedAt ?? raw.started_at,
32
+ committedAt: raw.committedAt ?? raw.committed_at,
33
+ checkpointToken: raw.checkpointToken ?? raw.checkpoint_token,
34
+ metadata: raw.metadata,
35
+ };
36
+ }
37
+ function normalizeImportCheckpoint(raw) {
38
+ if (!raw)
39
+ return null;
40
+ return {
41
+ sessionId: raw.sessionId ?? raw.session_id,
42
+ checkpointToken: raw.checkpointToken ?? raw.checkpoint_token,
43
+ lastEntityCursor: raw.lastEntityCursor ?? raw.last_entity_cursor,
44
+ lastRelationCursor: raw.lastRelationCursor ?? raw.last_relation_cursor,
45
+ processedItems: raw.processedItems ?? raw.processed_items ?? 0,
46
+ createdItems: raw.createdItems ?? raw.created_items ?? 0,
47
+ updatedItems: raw.updatedItems ?? raw.updated_items ?? 0,
48
+ skippedItems: raw.skippedItems ?? raw.skipped_items ?? 0,
49
+ failedItems: raw.failedItems ?? raw.failed_items ?? 0,
50
+ createdAt: raw.createdAt ?? raw.created_at,
51
+ metadata: raw.metadata,
52
+ };
53
+ }
54
+ function normalizeBatchWriteResult(raw) {
55
+ return {
56
+ sessionId: raw?.sessionId ?? raw?.session_id,
57
+ batchId: raw?.batchId ?? raw?.batch_id,
58
+ success: raw?.success ?? false,
59
+ total: raw?.total ?? 0,
60
+ created: raw?.created ?? 0,
61
+ updated: raw?.updated ?? 0,
62
+ skipped: raw?.skipped ?? 0,
63
+ failed: raw?.failed ?? 0,
64
+ unchanged: raw?.unchanged ?? 0,
65
+ checkpointToken: raw?.checkpointToken ?? raw?.checkpoint_token,
66
+ items: (raw?.items ?? []).map((item) => ({
67
+ index: item.index,
68
+ itemType: item.itemType ?? item.item_type,
69
+ inputId: item.inputId ?? item.input_id,
70
+ resolvedId: item.resolvedId ?? item.resolved_id,
71
+ status: item.status,
72
+ reasonCode: item.reasonCode ?? item.reason_code,
73
+ message: item.message,
74
+ conflictPolicy: item.conflictPolicy ?? item.conflict_policy,
75
+ warnings: item.warnings,
76
+ diagnostics: item.diagnostics,
77
+ })),
78
+ stats: raw?.stats,
79
+ warnings: raw?.warnings,
80
+ };
81
+ }
82
+ function normalizeRelationEvidenceResult(raw) {
83
+ return {
84
+ relation: raw.relation,
85
+ evidenceEntities: raw.evidenceEntities ?? raw.evidence_entities ?? [],
86
+ sourceChapterId: raw.sourceChapterId ?? raw.source_chapter_id,
87
+ sourceChapterTitle: raw.sourceChapterTitle ?? raw.source_chapter_title,
88
+ sourceSpan: raw.sourceSpan ?? raw.source_span,
89
+ sourceQuote: raw.sourceQuote ?? raw.source_quote,
90
+ };
91
+ }
92
+ function normalizeSourceBundleResult(raw) {
93
+ if (!raw)
94
+ return null;
95
+ return {
96
+ sourceEntity: raw.sourceEntity ?? raw.source_entity,
97
+ claims: raw.claims ?? [],
98
+ facts: raw.facts ?? [],
99
+ evidenceEntities: raw.evidenceEntities ?? raw.evidence_entities ?? [],
100
+ };
101
+ }
102
+ function normalizeHistoricalSourceExcerptResult(raw) {
103
+ if (!raw)
104
+ return null;
105
+ return {
106
+ excerptId: raw.excerptId ?? raw.excerpt_id,
107
+ sourceEntity: raw.sourceEntity ?? raw.source_entity ?? null,
108
+ sourceChapterId: raw.sourceChapterId ?? raw.source_chapter_id,
109
+ sourceChapterTitle: raw.sourceChapterTitle ?? raw.source_chapter_title,
110
+ sourceSpan: raw.sourceSpan ?? raw.source_span,
111
+ sourceQuote: raw.sourceQuote ?? raw.source_quote,
112
+ relationIds: raw.relationIds ?? raw.relation_ids ?? [],
113
+ evidenceEntities: raw.evidenceEntities ?? raw.evidence_entities ?? [],
114
+ claimEntities: raw.claimEntities ?? raw.claim_entities ?? [],
115
+ factEntities: raw.factEntities ?? raw.fact_entities ?? [],
116
+ yearStart: raw.yearStart ?? raw.year_start,
117
+ yearEnd: raw.yearEnd ?? raw.year_end,
118
+ timeLabel: raw.timeLabel ?? raw.time_label,
119
+ dynasty: raw.dynasty,
120
+ supportCount: raw.supportCount ?? raw.support_count ?? 0,
121
+ reasonCodes: raw.reasonCodes ?? raw.reason_codes ?? [],
122
+ };
123
+ }
124
+ function normalizeHistoricalEvidenceContextSummaryResult(raw) {
125
+ return {
126
+ excerptCount: raw?.excerptCount ?? raw?.excerpt_count ?? 0,
127
+ quotedExcerptCount: raw?.quotedExcerptCount ?? raw?.quoted_excerpt_count ?? 0,
128
+ sourceEntityCount: raw?.sourceEntityCount ?? raw?.source_entity_count ?? 0,
129
+ relationCount: raw?.relationCount ?? raw?.relation_count ?? 0,
130
+ evidenceCount: raw?.evidenceCount ?? raw?.evidence_count ?? 0,
131
+ claimCount: raw?.claimCount ?? raw?.claim_count ?? 0,
132
+ factCount: raw?.factCount ?? raw?.fact_count ?? 0,
133
+ };
134
+ }
135
+ function normalizeHistoricalEvidenceContextResult(raw) {
136
+ if (!raw)
137
+ return null;
138
+ return {
139
+ targetEntity: raw.targetEntity ?? raw.target_entity,
140
+ excerpts: (raw.excerpts ?? [])
141
+ .map(normalizeHistoricalSourceExcerptResult)
142
+ .filter(Boolean),
143
+ sourceEntities: raw.sourceEntities ?? raw.source_entities ?? [],
144
+ evidenceEntities: raw.evidenceEntities ?? raw.evidence_entities ?? [],
145
+ claimEntities: raw.claimEntities ?? raw.claim_entities ?? [],
146
+ factEntities: raw.factEntities ?? raw.fact_entities ?? [],
147
+ summary: normalizeHistoricalEvidenceContextSummaryResult(raw.summary),
148
+ reasons: raw.reasons ?? [],
149
+ };
150
+ }
151
+ function normalizeEntityHistoryBundleResult(raw) {
152
+ if (!raw)
153
+ return null;
154
+ return {
155
+ entity: raw.entity,
156
+ relatedEntities: raw.relatedEntities ?? raw.related_entities ?? [],
157
+ timeline: raw.timeline ?? [],
158
+ evidence: (raw.evidence ?? []).map(normalizeRelationEvidenceResult),
159
+ claims: raw.claims ?? [],
160
+ facts: raw.facts ?? [],
161
+ chapters: raw.chapters ?? [],
162
+ conflictClusters: (raw.conflictClusters ?? raw.conflict_clusters ?? []).map(normalizeConflictClusterResult).filter(Boolean),
163
+ summary: {
164
+ relatedEntityCount: raw.summary?.relatedEntityCount ?? raw.summary?.related_entity_count ?? 0,
165
+ timelineCount: raw.summary?.timelineCount ?? raw.summary?.timeline_count ?? 0,
166
+ evidenceCount: raw.summary?.evidenceCount ?? raw.summary?.evidence_count ?? 0,
167
+ claimCount: raw.summary?.claimCount ?? raw.summary?.claim_count ?? 0,
168
+ factCount: raw.summary?.factCount ?? raw.summary?.fact_count ?? 0,
169
+ chapterCount: raw.summary?.chapterCount ?? raw.summary?.chapter_count ?? 0,
170
+ conflictClusterCount: raw.summary?.conflictClusterCount ?? raw.summary?.conflict_cluster_count ?? 0,
171
+ hasSourceBundle: raw.summary?.hasSourceBundle ?? raw.summary?.has_source_bundle ?? false,
172
+ },
173
+ sourceBundle: normalizeSourceBundleResult(raw.sourceBundle ?? raw.source_bundle),
174
+ };
175
+ }
176
+ function normalizeTimelineBucketResult(raw) {
177
+ if (!raw)
178
+ return null;
179
+ return {
180
+ bucketKey: raw.bucketKey ?? raw.bucket_key,
181
+ yearStart: raw.yearStart ?? raw.year_start,
182
+ yearEnd: raw.yearEnd ?? raw.year_end,
183
+ timeLabel: raw.timeLabel ?? raw.time_label,
184
+ dynasty: raw.dynasty,
185
+ hits: raw.hits ?? [],
186
+ hitCount: raw.hitCount ?? raw.hit_count ?? 0,
187
+ };
188
+ }
189
+ function normalizeHistoricalTimelineEventResult(raw) {
190
+ if (!raw)
191
+ return null;
192
+ return {
193
+ event: raw.event,
194
+ yearStart: raw.yearStart ?? raw.year_start,
195
+ yearEnd: raw.yearEnd ?? raw.year_end,
196
+ timeLabel: raw.timeLabel ?? raw.time_label,
197
+ dynasty: raw.dynasty,
198
+ participantCount: raw.participantCount ?? raw.participant_count ?? 0,
199
+ chapterCount: raw.chapterCount ?? raw.chapter_count ?? 0,
200
+ evidenceCount: raw.evidenceCount ?? raw.evidence_count ?? 0,
201
+ claimCount: raw.claimCount ?? raw.claim_count ?? 0,
202
+ factCount: raw.factCount ?? raw.fact_count ?? 0,
203
+ conflictClusterCount: raw.conflictClusterCount ?? raw.conflict_cluster_count ?? 0,
204
+ };
205
+ }
206
+ function normalizeHistoricalEventParticipantResult(raw) {
207
+ if (!raw)
208
+ return null;
209
+ return {
210
+ participant: raw.participant,
211
+ relation: raw.relation,
212
+ role: raw.role,
213
+ stance: raw.stance,
214
+ side: raw.side,
215
+ narrativeWeight: raw.narrativeWeight ?? raw.narrative_weight,
216
+ sourceEntities: raw.sourceEntities ?? raw.source_entities ?? [],
217
+ evidenceEntities: raw.evidenceEntities ?? raw.evidence_entities ?? [],
218
+ yearStart: raw.yearStart ?? raw.year_start,
219
+ yearEnd: raw.yearEnd ?? raw.year_end,
220
+ timeLabel: raw.timeLabel ?? raw.time_label,
221
+ dynasty: raw.dynasty,
222
+ };
223
+ }
224
+ function normalizeHistoricalEntityEventRoleResult(raw) {
225
+ const event = normalizeHistoricalTimelineEventResult(raw?.event);
226
+ if (!raw || !event)
227
+ return null;
228
+ return {
229
+ event,
230
+ relation: raw.relation,
231
+ role: raw.role,
232
+ stance: raw.stance,
233
+ side: raw.side,
234
+ narrativeWeight: raw.narrativeWeight ?? raw.narrative_weight,
235
+ sourceEntities: raw.sourceEntities ?? raw.source_entities ?? [],
236
+ evidenceEntities: raw.evidenceEntities ?? raw.evidence_entities ?? [],
237
+ };
238
+ }
239
+ function normalizeHistoricalActorInteractionResult(raw) {
240
+ if (!raw)
241
+ return null;
242
+ return {
243
+ counterpart: raw.counterpart,
244
+ interactionScore: raw.interactionScore ?? raw.interaction_score ?? 0,
245
+ coEventCount: raw.coEventCount ?? raw.co_event_count ?? 0,
246
+ conflictTouchCount: raw.conflictTouchCount ?? raw.conflict_touch_count ?? 0,
247
+ sharedSourceCount: raw.sharedSourceCount ?? raw.shared_source_count ?? 0,
248
+ timeOverlapScore: raw.timeOverlapScore ?? raw.time_overlap_score ?? 0,
249
+ directRelationCount: raw.directRelationCount ?? raw.direct_relation_count ?? 0,
250
+ relationTypes: raw.relationTypes ?? raw.relation_types ?? [],
251
+ sharedEventIds: raw.sharedEventIds ?? raw.shared_event_ids ?? [],
252
+ sourceEntities: raw.sourceEntities ?? raw.source_entities ?? [],
253
+ evidenceEntities: raw.evidenceEntities ?? raw.evidence_entities ?? [],
254
+ reasons: raw.reasons ?? [],
255
+ };
256
+ }
257
+ function normalizeHistoricalInteractionSummaryStatsResult(raw) {
258
+ return {
259
+ counterpartCount: raw?.counterpartCount ?? raw?.counterpart_count ?? 0,
260
+ personCounterpartCount: raw?.personCounterpartCount ?? raw?.person_counterpart_count ?? 0,
261
+ eventCounterpartCount: raw?.eventCounterpartCount ?? raw?.event_counterpart_count ?? 0,
262
+ directRelationCount: raw?.directRelationCount ?? raw?.direct_relation_count ?? 0,
263
+ coEventCount: raw?.coEventCount ?? raw?.co_event_count ?? 0,
264
+ conflictTouchCount: raw?.conflictTouchCount ?? raw?.conflict_touch_count ?? 0,
265
+ sharedSourceCount: raw?.sharedSourceCount ?? raw?.shared_source_count ?? 0,
266
+ strongestInteractionScore: raw?.strongestInteractionScore ?? raw?.strongest_interaction_score ?? 0,
267
+ averageInteractionScore: raw?.averageInteractionScore ?? raw?.average_interaction_score ?? 0,
268
+ };
269
+ }
270
+ function normalizeHistoricalInteractionSummaryResult(raw) {
271
+ if (!raw)
272
+ return null;
273
+ return {
274
+ anchorEntity: raw.anchorEntity ?? raw.anchor_entity,
275
+ interactions: (raw.interactions ?? [])
276
+ .map(normalizeHistoricalActorInteractionResult)
277
+ .filter(Boolean),
278
+ strongestPersonInteraction: normalizeHistoricalActorInteractionResult(raw.strongestPersonInteraction ?? raw.strongest_person_interaction),
279
+ strongestEventInteraction: normalizeHistoricalActorInteractionResult(raw.strongestEventInteraction ?? raw.strongest_event_interaction),
280
+ summary: normalizeHistoricalInteractionSummaryStatsResult(raw.summary),
281
+ reasons: raw.reasons ?? [],
282
+ };
283
+ }
284
+ function normalizeHistoricalActivityItemResult(raw) {
285
+ const event = normalizeHistoricalTimelineEventResult(raw?.event);
286
+ if (!raw)
287
+ return null;
288
+ return {
289
+ activityId: raw.activityId ?? raw.activity_id,
290
+ activityType: raw.activityType ?? raw.activity_type,
291
+ primaryEntity: raw.primaryEntity ?? raw.primary_entity,
292
+ relatedEntities: raw.relatedEntities ?? raw.related_entities ?? [],
293
+ sourceEntities: raw.sourceEntities ?? raw.source_entities ?? [],
294
+ evidenceEntities: raw.evidenceEntities ?? raw.evidence_entities ?? [],
295
+ relation: raw.relation ?? null,
296
+ event,
297
+ yearStart: raw.yearStart ?? raw.year_start,
298
+ yearEnd: raw.yearEnd ?? raw.year_end,
299
+ timeLabel: raw.timeLabel ?? raw.time_label,
300
+ dynasty: raw.dynasty,
301
+ importanceScore: raw.importanceScore ?? raw.importance_score ?? null,
302
+ conflictStatus: raw.conflictStatus ?? raw.conflict_status ?? null,
303
+ reasonCodes: raw.reasonCodes ?? raw.reason_codes ?? [],
304
+ };
305
+ }
306
+ function normalizeHistoricalActivityStreamResult(raw) {
307
+ if (!raw)
308
+ return null;
309
+ const summary = raw.summary ?? {};
310
+ return {
311
+ anchorEntity: raw.anchorEntity ?? raw.anchor_entity ?? null,
312
+ items: (raw.items ?? []).map(normalizeHistoricalActivityItemResult).filter(Boolean),
313
+ summary: {
314
+ activityCount: summary.activityCount ?? summary.activity_count ?? 0,
315
+ eventCount: summary.eventCount ?? summary.event_count ?? 0,
316
+ relationCount: summary.relationCount ?? summary.relation_count ?? 0,
317
+ claimCount: summary.claimCount ?? summary.claim_count ?? 0,
318
+ factCount: summary.factCount ?? summary.fact_count ?? 0,
319
+ evidenceCount: summary.evidenceCount ?? summary.evidence_count ?? 0,
320
+ conflictCount: summary.conflictCount ?? summary.conflict_count ?? 0,
321
+ },
322
+ };
323
+ }
324
+ function normalizeHistoricalEventImportanceScoreBreakdownResult(raw) {
325
+ return {
326
+ participantScore: raw?.participantScore ?? raw?.participant_score ?? 0,
327
+ chapterScore: raw?.chapterScore ?? raw?.chapter_score ?? 0,
328
+ evidenceScore: raw?.evidenceScore ?? raw?.evidence_score ?? 0,
329
+ claimScore: raw?.claimScore ?? raw?.claim_score ?? 0,
330
+ factScore: raw?.factScore ?? raw?.fact_score ?? 0,
331
+ conflictScore: raw?.conflictScore ?? raw?.conflict_score ?? 0,
332
+ chronologyScore: raw?.chronologyScore ?? raw?.chronology_score ?? 0,
333
+ };
334
+ }
335
+ function normalizeHistoricalEventImportanceResult(raw) {
336
+ const event = normalizeHistoricalTimelineEventResult(raw?.event);
337
+ if (!raw || !event)
338
+ return null;
339
+ return {
340
+ event,
341
+ score: raw.score ?? 0,
342
+ reasons: raw.reasons ?? [],
343
+ scoreBreakdown: normalizeHistoricalEventImportanceScoreBreakdownResult(raw.scoreBreakdown ?? raw.score_breakdown),
344
+ };
345
+ }
346
+ function normalizeHistoricalNarrativeOrderResult(raw) {
347
+ const event = normalizeHistoricalTimelineEventResult(raw?.event);
348
+ if (!raw || !event)
349
+ return null;
350
+ const scoreBreakdownRaw = raw.scoreBreakdown ?? raw.score_breakdown ?? {};
351
+ const scoreBreakdown = {
352
+ chronologyScore: scoreBreakdownRaw.chronologyScore ?? scoreBreakdownRaw.chronology_score ?? 0,
353
+ supportDensityScore: scoreBreakdownRaw.supportDensityScore ?? scoreBreakdownRaw.support_density_score ?? 0,
354
+ excerptSignalScore: scoreBreakdownRaw.excerptSignalScore ?? scoreBreakdownRaw.excerpt_signal_score ?? 0,
355
+ narrativeSignalScore: scoreBreakdownRaw.narrativeSignalScore ?? scoreBreakdownRaw.narrative_signal_score ?? 0,
356
+ anchorRelevanceScore: scoreBreakdownRaw.anchorRelevanceScore ?? scoreBreakdownRaw.anchor_relevance_score ?? 0,
357
+ };
358
+ return {
359
+ event,
360
+ score: raw.score ?? 0,
361
+ reasons: raw.reasons ?? [],
362
+ scoreBreakdown,
363
+ };
364
+ }
365
+ function normalizeHistoricalTimelineBucketResult(raw) {
366
+ if (!raw)
367
+ return null;
368
+ return {
369
+ bucketKey: raw.bucketKey ?? raw.bucket_key,
370
+ yearStart: raw.yearStart ?? raw.year_start,
371
+ yearEnd: raw.yearEnd ?? raw.year_end,
372
+ timeLabel: raw.timeLabel ?? raw.time_label,
373
+ dynasty: raw.dynasty,
374
+ events: (raw.events ?? []).map(normalizeHistoricalTimelineEventResult).filter(Boolean),
375
+ eventCount: raw.eventCount ?? raw.event_count ?? 0,
376
+ participantCount: raw.participantCount ?? raw.participant_count ?? 0,
377
+ };
378
+ }
379
+ function normalizeHistoricalEntitySpotlightResult(raw) {
380
+ if (!raw)
381
+ return null;
382
+ const summary = raw.summary ?? {};
383
+ return {
384
+ entity: raw.entity,
385
+ canonicalEntity: raw.canonicalEntity ?? raw.canonical_entity,
386
+ aliasEntities: raw.aliasEntities ?? raw.alias_entities ?? [],
387
+ bundle: normalizeEntityHistoryBundleResult(raw.bundle),
388
+ kinshipRelations: raw.kinshipRelations ?? raw.kinship_relations ?? [],
389
+ politicalRelations: raw.politicalRelations ?? raw.political_relations ?? [],
390
+ eventRelations: raw.eventRelations ?? raw.event_relations ?? [],
391
+ summary: {
392
+ aliasCount: summary.aliasCount ?? summary.alias_count ?? 0,
393
+ kinshipRelationCount: summary.kinshipRelationCount ?? summary.kinship_relation_count ?? 0,
394
+ politicalRelationCount: summary.politicalRelationCount ?? summary.political_relation_count ?? 0,
395
+ eventRelationCount: summary.eventRelationCount ?? summary.event_relation_count ?? 0,
396
+ chapterCount: summary.chapterCount ?? summary.chapter_count ?? 0,
397
+ timelineCount: summary.timelineCount ?? summary.timeline_count ?? 0,
398
+ conflictClusterCount: summary.conflictClusterCount ?? summary.conflict_cluster_count ?? 0,
399
+ },
400
+ };
401
+ }
402
+ function normalizeHistoricalConflictOverviewResult(raw) {
403
+ if (!raw)
404
+ return null;
405
+ const summary = raw.summary ?? {};
406
+ return {
407
+ entity: raw.entity,
408
+ clusters: (raw.clusters ?? []).map(normalizeConflictClusterResult).filter(Boolean),
409
+ sourceEntities: raw.sourceEntities ?? raw.source_entities ?? [],
410
+ evidenceEntities: raw.evidenceEntities ?? raw.evidence_entities ?? [],
411
+ summary: {
412
+ clusterCount: summary.clusterCount ?? summary.cluster_count ?? 0,
413
+ claimEntityCount: summary.claimEntityCount ?? summary.claim_entity_count ?? 0,
414
+ factEntityCount: summary.factEntityCount ?? summary.fact_entity_count ?? 0,
415
+ sourceEntityCount: summary.sourceEntityCount ?? summary.source_entity_count ?? 0,
416
+ evidenceEntityCount: summary.evidenceEntityCount ?? summary.evidence_entity_count ?? 0,
417
+ dominantLevels: summary.dominantLevels ?? summary.dominant_levels ?? [],
418
+ conflictKinds: summary.conflictKinds ?? summary.conflict_kinds ?? [],
419
+ },
420
+ };
421
+ }
422
+ function normalizeHistoricalConflictScoreBreakdownResult(raw) {
423
+ return {
424
+ structuralScore: raw?.structuralScore ?? raw?.structural_score ?? 0,
425
+ evidenceScore: raw?.evidenceScore ?? raw?.evidence_score ?? 0,
426
+ sourceScore: raw?.sourceScore ?? raw?.source_score ?? 0,
427
+ factPriorityScore: raw?.factPriorityScore ?? raw?.fact_priority_score ?? 0,
428
+ kindDiversityScore: raw?.kindDiversityScore ?? raw?.kind_diversity_score ?? 0,
429
+ spreadScore: raw?.spreadScore ?? raw?.spread_score ?? 0,
430
+ };
431
+ }
432
+ function normalizeHistoricalConflictAdjudicationResult(raw) {
433
+ if (!raw)
434
+ return null;
435
+ return {
436
+ scope: raw.scope,
437
+ targetId: raw.targetId ?? raw.target_id,
438
+ score: raw.score ?? 0,
439
+ severity: raw.severity ?? 'low',
440
+ status: raw.status ?? 'monitor',
441
+ recommendedAction: raw.recommendedAction ?? raw.recommended_action ?? 'monitor_conflicts',
442
+ reasons: raw.reasons ?? [],
443
+ scoreBreakdown: normalizeHistoricalConflictScoreBreakdownResult(raw.scoreBreakdown ?? raw.score_breakdown),
444
+ };
445
+ }
446
+ function normalizeHistoricalConflictAdjudicationContainerResult(raw) {
447
+ const overview = normalizeHistoricalConflictOverviewResult(raw?.overview);
448
+ const overviewAssessment = normalizeHistoricalConflictAdjudicationResult(raw?.overviewAssessment ?? raw?.overview_assessment);
449
+ if (!raw || !overview || !overviewAssessment)
450
+ return null;
451
+ return {
452
+ entity: raw.entity,
453
+ overview,
454
+ overviewAssessment,
455
+ clusterAssessments: (raw.clusterAssessments ?? raw.cluster_assessments ?? [])
456
+ .map(normalizeHistoricalConflictAdjudicationResult)
457
+ .filter(Boolean),
458
+ };
459
+ }
460
+ function normalizeHistoricalGraphDiagnosticsResult(raw) {
461
+ if (!raw)
462
+ return null;
463
+ return {
464
+ counts: {
465
+ historicalEntityCount: raw.counts?.historicalEntityCount ?? raw.counts?.historical_entity_count ?? 0,
466
+ historicalRelationCount: raw.counts?.historicalRelationCount ?? raw.counts?.historical_relation_count ?? 0,
467
+ personCount: raw.counts?.personCount ?? raw.counts?.person_count ?? 0,
468
+ eventCount: raw.counts?.eventCount ?? raw.counts?.event_count ?? 0,
469
+ documentCount: raw.counts?.documentCount ?? raw.counts?.document_count ?? 0,
470
+ evidenceCount: raw.counts?.evidenceCount ?? raw.counts?.evidence_count ?? 0,
471
+ claimCount: raw.counts?.claimCount ?? raw.counts?.claim_count ?? 0,
472
+ factCount: raw.counts?.factCount ?? raw.counts?.fact_count ?? 0,
473
+ },
474
+ timeCoverage: {
475
+ datedEntityCount: raw.timeCoverage?.datedEntityCount ?? raw.time_coverage?.dated_entity_count ?? 0,
476
+ undatedEntityCount: raw.timeCoverage?.undatedEntityCount ?? raw.time_coverage?.undated_entity_count ?? 0,
477
+ datedEventCount: raw.timeCoverage?.datedEventCount ?? raw.time_coverage?.dated_event_count ?? 0,
478
+ undatedEventCount: raw.timeCoverage?.undatedEventCount ?? raw.time_coverage?.undated_event_count ?? 0,
479
+ datedRelationCount: raw.timeCoverage?.datedRelationCount ?? raw.time_coverage?.dated_relation_count ?? 0,
480
+ undatedRelationCount: raw.timeCoverage?.undatedRelationCount ?? raw.time_coverage?.undated_relation_count ?? 0,
481
+ },
482
+ integrity: {
483
+ danglingRelationEndpointCount: raw.integrity?.danglingRelationEndpointCount ?? raw.integrity?.dangling_relation_endpoint_count ?? 0,
484
+ danglingSourceEntityRefCount: raw.integrity?.danglingSourceEntityRefCount ?? raw.integrity?.dangling_source_entity_ref_count ?? 0,
485
+ danglingEvidenceRefCount: raw.integrity?.danglingEvidenceRefCount ?? raw.integrity?.dangling_evidence_ref_count ?? 0,
486
+ danglingClaimRefCount: raw.integrity?.danglingClaimRefCount ?? raw.integrity?.dangling_claim_ref_count ?? 0,
487
+ danglingCanonicalEntityRefCount: raw.integrity?.danglingCanonicalEntityRefCount ?? raw.integrity?.dangling_canonical_entity_ref_count ?? 0,
488
+ danglingCanonicalFactRefCount: raw.integrity?.danglingCanonicalFactRefCount ?? raw.integrity?.dangling_canonical_fact_ref_count ?? 0,
489
+ },
490
+ metadataCompleteness: {
491
+ claimsMissingSubjectEntityCount: raw.metadataCompleteness?.claimsMissingSubjectEntityCount ?? raw.metadata_completeness?.claims_missing_subject_entity_count ?? 0,
492
+ claimsMissingRelationTypeCount: raw.metadataCompleteness?.claimsMissingRelationTypeCount ?? raw.metadata_completeness?.claims_missing_relation_type_count ?? 0,
493
+ factsMissingClaimIdsCount: raw.metadataCompleteness?.factsMissingClaimIdsCount ?? raw.metadata_completeness?.facts_missing_claim_ids_count ?? 0,
494
+ factsMissingEvidenceIdsCount: raw.metadataCompleteness?.factsMissingEvidenceIdsCount ?? raw.metadata_completeness?.facts_missing_evidence_ids_count ?? 0,
495
+ evidenceMissingReferencedEntityIdsCount: raw.metadataCompleteness?.evidenceMissingReferencedEntityIdsCount ?? raw.metadata_completeness?.evidence_missing_referenced_entity_ids_count ?? 0,
496
+ evidenceMissingSourceEntityCount: raw.metadataCompleteness?.evidenceMissingSourceEntityCount ?? raw.metadata_completeness?.evidence_missing_source_entity_count ?? 0,
497
+ relationsMissingRelationFamilyCount: raw.metadataCompleteness?.relationsMissingRelationFamilyCount ?? raw.metadata_completeness?.relations_missing_relation_family_count ?? 0,
498
+ },
499
+ metrics: {
500
+ totalRequests: raw.metrics?.totalRequests ?? raw.metrics?.total_requests ?? 0,
501
+ successfulWrites: raw.metrics?.successfulWrites ?? raw.metrics?.successful_writes ?? 0,
502
+ failedWrites: raw.metrics?.failedWrites ?? raw.metrics?.failed_writes ?? 0,
503
+ rejectedRequests: raw.metrics?.rejectedRequests ?? raw.metrics?.rejected_requests ?? 0,
504
+ batchesFlushed: raw.metrics?.batchesFlushed ?? raw.metrics?.batches_flushed ?? 0,
505
+ batchDocuments: raw.metrics?.batchDocuments ?? raw.metrics?.batch_documents ?? 0,
506
+ avgQueueTimeUs: raw.metrics?.avgQueueTimeUs ?? raw.metrics?.avg_queue_time_us ?? 0,
507
+ avgWriteTimeUs: raw.metrics?.avgWriteTimeUs ?? raw.metrics?.avg_write_time_us ?? 0,
508
+ entityCount: raw.metrics?.entityCount ?? raw.metrics?.entity_count ?? 0,
509
+ relationCount: raw.metrics?.relationCount ?? raw.metrics?.relation_count ?? 0,
510
+ queueFillRatio: raw.metrics?.queueFillRatio ?? raw.metrics?.queue_fill_ratio ?? 0,
511
+ },
512
+ issues: (raw.issues ?? []).map((issue) => ({
513
+ code: issue.code,
514
+ severity: issue.severity,
515
+ message: issue.message,
516
+ entityId: issue.entityId ?? issue.entity_id,
517
+ relationId: issue.relationId ?? issue.relation_id,
518
+ })),
519
+ };
520
+ }
521
+ function normalizeAliasMergeResult(raw) {
522
+ if (!raw)
523
+ return null;
524
+ return {
525
+ canonicalEntity: raw.canonicalEntity ?? raw.canonical_entity,
526
+ aliasEntity: raw.aliasEntity ?? raw.alias_entity,
527
+ mergedAliasNames: raw.mergedAliasNames ?? raw.merged_alias_names ?? [],
528
+ };
529
+ }
530
+ function normalizeHistoricalGraphProjectionResult(raw) {
531
+ if (!raw)
532
+ return null;
533
+ return {
534
+ rootEntity: raw.rootEntity ?? raw.root_entity,
535
+ entities: raw.entities ?? [],
536
+ relations: raw.relations ?? [],
537
+ timelineBuckets: (raw.timelineBuckets ?? raw.timeline_buckets ?? []).map(normalizeTimelineBucketResult).filter(Boolean),
538
+ summary: {
539
+ relatedEntityCount: raw.summary?.relatedEntityCount ?? raw.summary?.related_entity_count ?? 0,
540
+ timelineCount: raw.summary?.timelineCount ?? raw.summary?.timeline_count ?? 0,
541
+ evidenceCount: raw.summary?.evidenceCount ?? raw.summary?.evidence_count ?? 0,
542
+ claimCount: raw.summary?.claimCount ?? raw.summary?.claim_count ?? 0,
543
+ factCount: raw.summary?.factCount ?? raw.summary?.fact_count ?? 0,
544
+ chapterCount: raw.summary?.chapterCount ?? raw.summary?.chapter_count ?? 0,
545
+ conflictClusterCount: raw.summary?.conflictClusterCount ?? raw.summary?.conflict_cluster_count ?? 0,
546
+ hasSourceBundle: raw.summary?.hasSourceBundle ?? raw.summary?.has_source_bundle ?? false,
547
+ },
548
+ sections: {
549
+ relatedEntityIds: raw.sections?.relatedEntityIds ?? raw.sections?.related_entity_ids ?? [],
550
+ timelineEntityIds: raw.sections?.timelineEntityIds ?? raw.sections?.timeline_entity_ids ?? [],
551
+ claimIds: raw.sections?.claimIds ?? raw.sections?.claim_ids ?? [],
552
+ factIds: raw.sections?.factIds ?? raw.sections?.fact_ids ?? [],
553
+ chapterIds: raw.sections?.chapterIds ?? raw.sections?.chapter_ids ?? [],
554
+ evidenceEntityIds: raw.sections?.evidenceEntityIds ?? raw.sections?.evidence_entity_ids ?? [],
555
+ sourceEntityIds: raw.sections?.sourceEntityIds ?? raw.sections?.source_entity_ids ?? [],
556
+ conflictEntityIds: raw.sections?.conflictEntityIds ?? raw.sections?.conflict_entity_ids ?? [],
557
+ relationIds: raw.sections?.relationIds ?? raw.sections?.relation_ids ?? [],
558
+ },
559
+ };
560
+ }
561
+ function normalizeConflictClusterResult(raw) {
562
+ if (!raw)
563
+ return null;
564
+ return {
565
+ anchorEntity: raw.anchorEntity ?? raw.anchor_entity,
566
+ clusterEntities: raw.clusterEntities ?? raw.cluster_entities ?? [],
567
+ conflictRelations: raw.conflictRelations ?? raw.conflict_relations ?? [],
568
+ relatedEntities: raw.relatedEntities ?? raw.related_entities ?? [],
569
+ sourceEntities: raw.sourceEntities ?? raw.source_entities ?? [],
570
+ evidenceEntities: raw.evidenceEntities ?? raw.evidence_entities ?? [],
571
+ conflictLevels: raw.conflictLevels ?? raw.conflict_levels ?? [],
572
+ conflictKinds: raw.conflictKinds ?? raw.conflict_kinds ?? [],
573
+ claimEntities: raw.claimEntities ?? raw.claim_entities ?? [],
574
+ factEntities: raw.factEntities ?? raw.fact_entities ?? [],
575
+ claimConflictRelations: raw.claimConflictRelations ?? raw.claim_conflict_relations ?? [],
576
+ factConflictRelations: raw.factConflictRelations ?? raw.fact_conflict_relations ?? [],
577
+ mixedConflictRelations: raw.mixedConflictRelations ?? raw.mixed_conflict_relations ?? [],
578
+ summary: {
579
+ dominantLevel: raw.summary?.dominantLevel ?? raw.summary?.dominant_level,
580
+ clusterEntityCount: raw.summary?.clusterEntityCount ?? raw.summary?.cluster_entity_count ?? 0,
581
+ claimEntityCount: raw.summary?.claimEntityCount ?? raw.summary?.claim_entity_count ?? 0,
582
+ factEntityCount: raw.summary?.factEntityCount ?? raw.summary?.fact_entity_count ?? 0,
583
+ claimConflictCount: raw.summary?.claimConflictCount ?? raw.summary?.claim_conflict_count ?? 0,
584
+ factConflictCount: raw.summary?.factConflictCount ?? raw.summary?.fact_conflict_count ?? 0,
585
+ mixedConflictCount: raw.summary?.mixedConflictCount ?? raw.summary?.mixed_conflict_count ?? 0,
586
+ sourceEntityCount: raw.summary?.sourceEntityCount ?? raw.summary?.source_entity_count ?? 0,
587
+ evidenceEntityCount: raw.summary?.evidenceEntityCount ?? raw.summary?.evidence_entity_count ?? 0,
588
+ },
589
+ };
590
+ }
591
+ function normalizeHistoricalEntityRecommendationResult(raw) {
592
+ if (!raw)
593
+ return null;
594
+ return {
595
+ entity: raw.entity,
596
+ score: raw.score ?? 0,
597
+ reasons: raw.reasons ?? [],
598
+ };
599
+ }
600
+ function normalizePathResult(raw) {
601
+ if (!raw)
602
+ return null;
603
+ return {
604
+ path: raw.path ?? [],
605
+ hops: raw.hops ?? 0,
606
+ intermediaries: raw.intermediaries ?? [],
607
+ relationChain: raw.relationChain ?? raw.relation_chain ?? [],
608
+ };
609
+ }
610
+ function normalizeAllPathsResult(raw) {
611
+ return {
612
+ paths: (raw?.paths ?? []).map(normalizePathResult).filter(Boolean),
613
+ shortestHops: raw?.shortestHops ?? raw?.shortest_hops ?? 0,
614
+ };
615
+ }
616
+ function normalizeHistoricalPathScoreBreakdownResult(raw) {
617
+ return {
618
+ hopScore: raw?.hopScore ?? raw?.hop_score ?? 0,
619
+ relationWeightScore: raw?.relationWeightScore ?? raw?.relation_weight_score ?? 0,
620
+ confidenceScore: raw?.confidenceScore ?? raw?.confidence_score ?? 0,
621
+ provenanceScore: raw?.provenanceScore ?? raw?.provenance_score ?? 0,
622
+ chronologyScore: raw?.chronologyScore ?? raw?.chronology_score ?? 0,
623
+ inferredPenalty: raw?.inferredPenalty ?? raw?.inferred_penalty ?? 0,
624
+ };
625
+ }
626
+ function normalizeHistoricalPathRankingResult(raw) {
627
+ const path = normalizePathResult(raw?.path);
628
+ if (!raw || !path)
629
+ return null;
630
+ return {
631
+ path,
632
+ score: raw.score ?? 0,
633
+ reasons: raw.reasons ?? [],
634
+ scoreBreakdown: normalizeHistoricalPathScoreBreakdownResult(raw.scoreBreakdown ?? raw.score_breakdown),
635
+ };
636
+ }
21
637
  // ============================================================================
22
638
  // Main SocialGraphV2 Class
23
639
  // ============================================================================
@@ -204,6 +820,16 @@ class SocialGraphV2 {
204
820
  async addPersonAsync(input) {
205
821
  return this.native.addPersonAsync(input);
206
822
  }
823
+ /**
824
+ * Add a new person (async, fire-and-forget — maximum throughput)
825
+ *
826
+ * Enqueues the write and returns immediately. Does NOT wait for WAL persistence.
827
+ * Use when eventual consistency is acceptable and throughput is the priority.
828
+ * Call `flush()` / `save()` afterwards to ensure all writes are persisted.
829
+ */
830
+ async addPersonFast(input) {
831
+ return this.native.addPersonFast(input);
832
+ }
207
833
  /**
208
834
  * Update a person (async)
209
835
  */
@@ -258,6 +884,15 @@ class SocialGraphV2 {
258
884
  async addFriendAsync(personA, personB, config) {
259
885
  return this.native.addFriendAsync(personA, personB, config);
260
886
  }
887
+ /**
888
+ * Add a friend relationship (async, fire-and-forget — maximum throughput)
889
+ *
890
+ * Enqueues the write and returns immediately. Does NOT wait for WAL persistence.
891
+ * Call `flush()` / `save()` afterwards to ensure persistence.
892
+ */
893
+ async addFriendFast(personA, personB, config) {
894
+ return this.native.addFriendFast(personA, personB, config);
895
+ }
261
896
  /**
262
897
  * Remove a friend relationship (async)
263
898
  */
@@ -1225,6 +1860,403 @@ class SocialGraphV2 {
1225
1860
  putRelation(sourceId, targetId, relationType, weight, bidirectional) {
1226
1861
  return this.native.putRelation(sourceId, targetId, relationType, weight, bidirectional);
1227
1862
  }
1863
+ /**
1864
+ * Begin a logical historical graph import session.
1865
+ */
1866
+ beginImportSession(input) {
1867
+ return normalizeImportSession(this.native.beginImportSession(input));
1868
+ }
1869
+ /**
1870
+ * Commit a logical historical graph import session.
1871
+ */
1872
+ commitImportSession(sessionId) {
1873
+ return normalizeImportSession(this.native.commitImportSession(sessionId));
1874
+ }
1875
+ /**
1876
+ * Roll back a logical historical graph import session.
1877
+ */
1878
+ rollbackImportSession(sessionId) {
1879
+ return normalizeImportSession(this.native.rollbackImportSession(sessionId));
1880
+ }
1881
+ /**
1882
+ * Read the latest or a specific import checkpoint for a historical graph import session.
1883
+ */
1884
+ getImportCheckpoint(sessionId, checkpointToken) {
1885
+ const raw = checkpointToken === undefined
1886
+ ? this.native.getImportCheckpoint(sessionId)
1887
+ : this.native.getImportCheckpoint(sessionId, checkpointToken);
1888
+ return normalizeImportCheckpoint(raw);
1889
+ }
1890
+ /**
1891
+ * Resume a historical graph import session from the latest or a specific checkpoint.
1892
+ */
1893
+ resumeImportSession(sessionId, checkpointToken) {
1894
+ const raw = checkpointToken === undefined
1895
+ ? this.native.resumeImportSession(sessionId)
1896
+ : this.native.resumeImportSession(sessionId, checkpointToken);
1897
+ return normalizeImportSession(raw);
1898
+ }
1899
+ /**
1900
+ * Add a first-class historical claim node.
1901
+ */
1902
+ addHistoricalClaim(input) {
1903
+ return this.native.addHistoricalClaim(input) ?? null;
1904
+ }
1905
+ /**
1906
+ * Add a first-class historical fact node.
1907
+ */
1908
+ addHistoricalFact(input) {
1909
+ return this.native.addHistoricalFact(input) ?? null;
1910
+ }
1911
+ /**
1912
+ * Add a first-class historical evidence node.
1913
+ */
1914
+ addHistoricalEvidence(input) {
1915
+ return this.native.addHistoricalEvidence(input) ?? null;
1916
+ }
1917
+ /**
1918
+ * Add a historical conflict relation between claim/fact nodes.
1919
+ */
1920
+ addHistoricalConflict(input) {
1921
+ return this.native.addHistoricalConflict(input) ?? null;
1922
+ }
1923
+ /**
1924
+ * List claim nodes using the shared claim/fact/evidence filter contract.
1925
+ */
1926
+ listHistoricalClaims(filter) {
1927
+ return this.native.listHistoricalClaims(filter);
1928
+ }
1929
+ /**
1930
+ * List fact nodes using the shared claim/fact/evidence filter contract.
1931
+ */
1932
+ listHistoricalFacts(filter) {
1933
+ return this.native.listHistoricalFacts(filter);
1934
+ }
1935
+ /**
1936
+ * List evidence nodes using the shared claim/fact/evidence filter contract.
1937
+ */
1938
+ listHistoricalEvidence(filter) {
1939
+ return this.native.listHistoricalEvidence(filter);
1940
+ }
1941
+ /**
1942
+ * Get claim nodes emitted from a source/document entity.
1943
+ */
1944
+ getClaimsBySource(sourceEntityId, filter) {
1945
+ return this.native.getClaimsBySource(sourceEntityId, filter);
1946
+ }
1947
+ /**
1948
+ * Get fact nodes emitted from a source/document entity.
1949
+ */
1950
+ getFactsBySource(sourceEntityId, filter) {
1951
+ return this.native.getFactsBySource(sourceEntityId, filter);
1952
+ }
1953
+ /**
1954
+ * Get evidence nodes emitted from a source/document entity.
1955
+ */
1956
+ getEvidenceBySource(sourceEntityId, filter) {
1957
+ return this.native.getEvidenceBySource(sourceEntityId, filter);
1958
+ }
1959
+ /**
1960
+ * Get grouped source excerpts supporting an entity-centered historical view.
1961
+ */
1962
+ getHistoricalSourceExcerptsForEntity(entityId, filter) {
1963
+ return this.native
1964
+ .getHistoricalSourceExcerptsForEntity(entityId, filter)
1965
+ .map(normalizeHistoricalSourceExcerptResult)
1966
+ .filter(Boolean);
1967
+ }
1968
+ /**
1969
+ * Get grouped source excerpts supporting an event-centered historical view.
1970
+ */
1971
+ getHistoricalSourceExcerptsForEvent(eventId, filter) {
1972
+ return this.native
1973
+ .getHistoricalSourceExcerptsForEvent(eventId, filter)
1974
+ .map(normalizeHistoricalSourceExcerptResult)
1975
+ .filter(Boolean);
1976
+ }
1977
+ /**
1978
+ * Summarize source excerpts and supporting material around a target historical entity.
1979
+ */
1980
+ summarizeHistoricalEvidenceContext(entityId, filter) {
1981
+ return normalizeHistoricalEvidenceContextResult(this.native.summarizeHistoricalEvidenceContext(entityId, filter));
1982
+ }
1983
+ /**
1984
+ * Get claim nodes citing a specific evidence node.
1985
+ */
1986
+ getClaimsByEvidence(evidenceId, filter) {
1987
+ return this.native.getClaimsByEvidence(evidenceId, filter);
1988
+ }
1989
+ /**
1990
+ * Get fact nodes citing a specific evidence node.
1991
+ */
1992
+ getFactsByEvidence(evidenceId, filter) {
1993
+ return this.native.getFactsByEvidence(evidenceId, filter);
1994
+ }
1995
+ /**
1996
+ * Refresh a relation's lightweight metadata summary from claim/fact nodes.
1997
+ */
1998
+ syncHistoricalRelationSummary(relationId) {
1999
+ return this.native.syncHistoricalRelationSummary(relationId) ?? null;
2000
+ }
2001
+ /**
2002
+ * Refresh lightweight relation metadata summaries in bulk.
2003
+ */
2004
+ backfillHistoricalRelationSummaries(filter) {
2005
+ return this.native.backfillHistoricalRelationSummaries(filter);
2006
+ }
2007
+ /**
2008
+ * Add a historical entity using the standardized Phase-317 contract.
2009
+ */
2010
+ addHistoricalEntity(input) {
2011
+ return this.native.addHistoricalEntity(input) ?? null;
2012
+ }
2013
+ /**
2014
+ * Add multiple historical entities using the standardized Phase-317 contract.
2015
+ */
2016
+ addHistoricalEntitiesBatch(inputs) {
2017
+ return this.native.addHistoricalEntitiesBatch(inputs);
2018
+ }
2019
+ /**
2020
+ * Add multiple historical entities and receive detailed batch diagnostics.
2021
+ */
2022
+ addHistoricalEntitiesBatchDetailed(inputs, options, sessionId) {
2023
+ return normalizeBatchWriteResult(this.native.addHistoricalEntitiesBatchDetailed(inputs, options, sessionId));
2024
+ }
2025
+ /**
2026
+ * Add a historical relation using the standardized Phase-316 contract.
2027
+ */
2028
+ addHistoricalRelation(input) {
2029
+ return this.native.addHistoricalRelation(input) ?? null;
2030
+ }
2031
+ /**
2032
+ * Add multiple historical relations using the standardized Phase-316 contract.
2033
+ */
2034
+ addHistoricalRelationsBatch(inputs) {
2035
+ return this.native.addHistoricalRelationsBatch(inputs);
2036
+ }
2037
+ /**
2038
+ * Add multiple historical relations and receive detailed batch diagnostics.
2039
+ */
2040
+ addHistoricalRelationsBatchDetailed(inputs, options, sessionId) {
2041
+ return normalizeBatchWriteResult(this.native.addHistoricalRelationsBatchDetailed(inputs, options, sessionId));
2042
+ }
2043
+ /**
2044
+ * Get related entities for any entity using the advanced historical filter contract.
2045
+ */
2046
+ getRelatedEntities(entityId, filter) {
2047
+ return this.native.getRelatedEntities(entityId, filter);
2048
+ }
2049
+ /**
2050
+ * Get timeline-oriented related entities for any entity.
2051
+ */
2052
+ getEntityTimeline(entityId, filter) {
2053
+ return this.native.getEntityTimeline(entityId, filter);
2054
+ }
2055
+ /**
2056
+ * Get grouped timeline buckets for any entity.
2057
+ */
2058
+ getEntityTimelineBuckets(entityId, filter) {
2059
+ return this.native.getEntityTimelineBuckets(entityId, filter).map(normalizeTimelineBucketResult).filter(Boolean);
2060
+ }
2061
+ /**
2062
+ * Get globally ordered historical events with summary counts for timeline exploration.
2063
+ */
2064
+ getHistoricalEventTimeline(filter) {
2065
+ return this.native.getHistoricalEventTimeline(filter).map(normalizeHistoricalTimelineEventResult).filter(Boolean);
2066
+ }
2067
+ /**
2068
+ * Project a global historical activity stream across events, relations, provenance, and conflicts.
2069
+ */
2070
+ getHistoricalActivityStream(filter) {
2071
+ return normalizeHistoricalActivityStreamResult(this.native.getHistoricalActivityStream(filter));
2072
+ }
2073
+ /**
2074
+ * Get grouped buckets for the global historical event timeline.
2075
+ */
2076
+ getHistoricalEventTimelineBuckets(filter) {
2077
+ return this.native.getHistoricalEventTimelineBuckets(filter).map(normalizeHistoricalTimelineBucketResult).filter(Boolean);
2078
+ }
2079
+ /**
2080
+ * Score historical events with deterministic importance breakdowns.
2081
+ */
2082
+ scoreHistoricalEvents(filter) {
2083
+ return this.native.scoreHistoricalEvents(filter).map(normalizeHistoricalEventImportanceResult).filter(Boolean);
2084
+ }
2085
+ /**
2086
+ * Order historical events by chronology first, then narrative sequencing signals.
2087
+ */
2088
+ orderHistoricalNarrativeTimeline(filter) {
2089
+ return this.native
2090
+ .orderHistoricalNarrativeTimeline(filter)
2091
+ .map(normalizeHistoricalNarrativeOrderResult)
2092
+ .filter(Boolean);
2093
+ }
2094
+ /**
2095
+ * Get evidence bundles for all relations touching an entity.
2096
+ */
2097
+ getEntityEvidence(entityId, filter) {
2098
+ return this.native.getEntityEvidence(entityId, filter).map(normalizeRelationEvidenceResult);
2099
+ }
2100
+ /**
2101
+ * List relations using the advanced historical filter contract.
2102
+ */
2103
+ listRelationsAdvanced(filter) {
2104
+ return this.native.listRelationsAdvanced(filter);
2105
+ }
2106
+ /**
2107
+ * Get related entities connected by the provided relation types.
2108
+ */
2109
+ getRelatedEntitiesByTypes(entityId, relationTypes, filter) {
2110
+ return this.native.getRelatedEntitiesByTypes(entityId, relationTypes, filter);
2111
+ }
2112
+ /**
2113
+ * Get event hits associated with a person.
2114
+ */
2115
+ getEventsByPerson(personId, filter) {
2116
+ return this.native.getEventsByPerson(personId, filter);
2117
+ }
2118
+ /**
2119
+ * Get person hits associated with an event.
2120
+ */
2121
+ getPersonsByEvent(eventId, filter) {
2122
+ return this.native.getPersonsByEvent(eventId, filter);
2123
+ }
2124
+ /**
2125
+ * Get role-aware participant rows for an event.
2126
+ */
2127
+ getHistoricalEventParticipants(eventId, filter) {
2128
+ return this.native
2129
+ .getHistoricalEventParticipants(eventId, filter)
2130
+ .map(normalizeHistoricalEventParticipantResult)
2131
+ .filter(Boolean);
2132
+ }
2133
+ /**
2134
+ * Get role-aware event participation rows for an entity.
2135
+ */
2136
+ getEntityEventRoles(entityId, filter) {
2137
+ return this.native
2138
+ .getEntityEventRoles(entityId, filter)
2139
+ .map(normalizeHistoricalEntityEventRoleResult)
2140
+ .filter(Boolean);
2141
+ }
2142
+ /**
2143
+ * Rank historical actors/events by interaction strength around an anchor entity.
2144
+ */
2145
+ rankHistoricalActorInteractions(entityId, filter) {
2146
+ return this.native
2147
+ .rankHistoricalActorInteractions(entityId, filter)
2148
+ .map(normalizeHistoricalActorInteractionResult)
2149
+ .filter(Boolean);
2150
+ }
2151
+ /**
2152
+ * Build a summary view over ranked historical interactions for an anchor entity.
2153
+ */
2154
+ getHistoricalInteractionSummary(entityId, filter) {
2155
+ return normalizeHistoricalInteractionSummaryResult(this.native.getHistoricalInteractionSummary(entityId, filter));
2156
+ }
2157
+ /**
2158
+ * Get chapter/document hits associated with an entity.
2159
+ */
2160
+ getChaptersByEntity(entityId, filter) {
2161
+ return this.native.getChaptersByEntity(entityId, filter);
2162
+ }
2163
+ /**
2164
+ * Resolve evidence entities and inline source metadata for a relation.
2165
+ */
2166
+ getEvidenceForRelation(relationId) {
2167
+ const raw = this.native.getEvidenceForRelation(relationId);
2168
+ return raw ? normalizeRelationEvidenceResult(raw) : null;
2169
+ }
2170
+ /**
2171
+ * Get claim nodes related to an entity.
2172
+ */
2173
+ getEntityClaims(entityId) {
2174
+ return this.native.getEntityClaims(entityId);
2175
+ }
2176
+ /**
2177
+ * Get fact nodes related to an entity.
2178
+ */
2179
+ getEntityFacts(entityId) {
2180
+ return this.native.getEntityFacts(entityId);
2181
+ }
2182
+ /**
2183
+ * Resolve an entity to its canonical entity, following canonical links when present.
2184
+ */
2185
+ resolveCanonicalEntity(entityId) {
2186
+ return this.native.resolveCanonicalEntity(entityId);
2187
+ }
2188
+ /**
2189
+ * List alias entities that currently point at a canonical entity.
2190
+ */
2191
+ getAliasEntities(canonicalEntityId) {
2192
+ return this.native.getAliasEntities(canonicalEntityId);
2193
+ }
2194
+ /**
2195
+ * Merge alias metadata into a canonical entity and link the alias entity to it.
2196
+ */
2197
+ mergeEntityAlias(canonicalEntityId, aliasEntityId) {
2198
+ return normalizeAliasMergeResult(this.native.mergeEntityAlias(canonicalEntityId, aliasEntityId));
2199
+ }
2200
+ /**
2201
+ * Get a grouped source bundle containing claim/fact/evidence nodes.
2202
+ */
2203
+ getSourceBundle(sourceEntityId) {
2204
+ return normalizeSourceBundleResult(this.native.getSourceBundle(sourceEntityId));
2205
+ }
2206
+ /**
2207
+ * Get an aggregated entity-centered historical graph bundle.
2208
+ */
2209
+ getEntityHistoryBundle(entityId, filter) {
2210
+ return normalizeEntityHistoryBundleResult(this.native.getEntityHistoryBundle(entityId, filter));
2211
+ }
2212
+ /**
2213
+ * Project an entity-centered historical activity stream.
2214
+ */
2215
+ getEntityHistoricalActivityStream(entityId, filter) {
2216
+ return normalizeHistoricalActivityStreamResult(this.native.getEntityHistoricalActivityStream(entityId, filter));
2217
+ }
2218
+ /**
2219
+ * Export an entity-centered historical projection with section metadata for view rendering.
2220
+ */
2221
+ exportEntityHistoryProjection(entityId, filter) {
2222
+ return normalizeHistoricalGraphProjectionResult(this.native.exportEntityHistoryProjection(entityId, filter));
2223
+ }
2224
+ /**
2225
+ * Get a product-facing spotlight view for an entity's historical universe.
2226
+ */
2227
+ getHistoricalEntitySpotlight(entityId, filter) {
2228
+ return normalizeHistoricalEntitySpotlightResult(this.native.getHistoricalEntitySpotlight(entityId, filter));
2229
+ }
2230
+ /**
2231
+ * Get the connected conflict component rooted at a claim/fact node.
2232
+ */
2233
+ getConflictCluster(entityId, filter) {
2234
+ return normalizeConflictClusterResult(this.native.getConflictCluster(entityId, filter));
2235
+ }
2236
+ /**
2237
+ * Get conflict clusters touching any claim/fact linked to an entity.
2238
+ */
2239
+ getEntityConflictClusters(entityId, filter) {
2240
+ return this.native.getEntityConflictClusters(entityId, filter).map(normalizeConflictClusterResult).filter(Boolean);
2241
+ }
2242
+ /**
2243
+ * Get an entity-level overview across conflict clusters, sources, and evidence.
2244
+ */
2245
+ getHistoricalConflictOverview(entityId, filter) {
2246
+ return normalizeHistoricalConflictOverviewResult(this.native.getHistoricalConflictOverview(entityId, filter));
2247
+ }
2248
+ /**
2249
+ * Build an entity-level conflict adjudication container with overview and per-cluster actions.
2250
+ */
2251
+ adjudicateHistoricalConflicts(entityId, filter) {
2252
+ return normalizeHistoricalConflictAdjudicationContainerResult(this.native.adjudicateHistoricalConflicts(entityId, filter));
2253
+ }
2254
+ /**
2255
+ * Build a global diagnostics report for the historical graph slice.
2256
+ */
2257
+ getHistoricalGraphDiagnostics() {
2258
+ return normalizeHistoricalGraphDiagnosticsResult(this.native.getHistoricalGraphDiagnostics());
2259
+ }
1228
2260
  // ========================================================================
1229
2261
  // Batch Operations (High Throughput)
1230
2262
  // ========================================================================
@@ -1652,7 +2684,28 @@ class SocialGraphV2 {
1652
2684
  * @param maxPaths Maximum number of paths (default: 10)
1653
2685
  */
1654
2686
  findAllPaths(fromId, toId, maxHops, maxPaths) {
1655
- return this.native.findAllPaths(fromId, toId, maxHops, maxPaths);
2687
+ return normalizeAllPathsResult(this.native.findAllPaths(fromId, toId, maxHops, maxPaths));
2688
+ }
2689
+ /**
2690
+ * Find all paths constrained by the historical relation filter contract.
2691
+ */
2692
+ findPathsWithRelationFilter(fromId, toId, filter, maxPaths) {
2693
+ return normalizeAllPathsResult(this.native.findPathsWithRelationFilter(fromId, toId, filter, maxPaths));
2694
+ }
2695
+ /**
2696
+ * Find all paths constrained by a historical time window.
2697
+ */
2698
+ findPathsWithTimeWindow(fromId, toId, yearStart, yearEnd, filter, maxPaths) {
2699
+ return normalizeAllPathsResult(this.native.findPathsWithTimeWindow(fromId, toId, yearStart, yearEnd, filter, maxPaths));
2700
+ }
2701
+ /**
2702
+ * Rank historical paths using provenance-aware scoring.
2703
+ */
2704
+ rankHistoricalPaths(fromId, toId, filter, maxPaths) {
2705
+ return this.native
2706
+ .rankHistoricalPaths(fromId, toId, filter, maxPaths)
2707
+ .map(normalizeHistoricalPathRankingResult)
2708
+ .filter(Boolean);
1656
2709
  }
1657
2710
  /**
1658
2711
  * Find intermediaries who can connect two persons
@@ -1875,6 +2928,12 @@ class SocialGraphV2 {
1875
2928
  searchEntitiesByVector(embedding, k, entityTypeFilter) {
1876
2929
  return this.native.searchEntitiesByVector(embedding, k, entityTypeFilter);
1877
2930
  }
2931
+ /**
2932
+ * Search historical entities by vector similarity using historical filters.
2933
+ */
2934
+ searchHistoricalEntitiesByVector(embedding, k, filter) {
2935
+ return this.native.searchHistoricalEntitiesByVector(embedding, k, filter);
2936
+ }
1878
2937
  /**
1879
2938
  * Hybrid search combining vector similarity and text attribute matching.
1880
2939
  *
@@ -1902,6 +2961,21 @@ class SocialGraphV2 {
1902
2961
  hybridSearch(embedding, textQuery, k, entityTypeFilter) {
1903
2962
  return this.native.hybridSearch(embedding, textQuery, k, entityTypeFilter);
1904
2963
  }
2964
+ /**
2965
+ * Hybrid search historical entities using vector and/or text signals.
2966
+ */
2967
+ hybridSearchHistoricalEntities(embedding, textQuery, k, filter) {
2968
+ return this.native.hybridSearchHistoricalEntities(embedding, textQuery, k, filter);
2969
+ }
2970
+ /**
2971
+ * Recommend related historical entities from the entity-centered historical context.
2972
+ */
2973
+ recommendRelatedHistoricalEntities(entityId, limit, filter) {
2974
+ return this.native
2975
+ .recommendRelatedHistoricalEntities(entityId, limit, filter)
2976
+ .map(normalizeHistoricalEntityRecommendationResult)
2977
+ .filter(Boolean);
2978
+ }
1905
2979
  /**
1906
2980
  * Get the embedding dimension used by the HNSW index.
1907
2981
  * Returns null if vector search is not enabled.
@@ -2299,6 +3373,9 @@ class SocialGraphV2 {
2299
3373
  * Anchors are deduplicated by `(name, anchor_type)`. If an anchor with
2300
3374
  * the same name and type already exists, it is returned (with updated
2301
3375
  * description/overview if changed). Otherwise a new anchor entity is created.
3376
+ * Use `mergeMode: 'soft_merge'` to merge only near-duplicate writes, or
3377
+ * `mergeMode: 'create_distinct'` / `mergeIfExists: false` to always create
3378
+ * a new anchor instance.
2302
3379
  *
2303
3380
  * @param name - Canonical name (e.g., "SocialGraphV2", "RagChat")
2304
3381
  * @param anchorType - Classification: module | concept | api | architecture | feature | library | protocol
@@ -2306,8 +3383,8 @@ class SocialGraphV2 {
2306
3383
  * @param overview - Optional L2 directory-index overview (inspired by OpenViking `.overview.md`)
2307
3384
  * @returns AnchorInfo with id, version, status, overview, etc.
2308
3385
  */
2309
- anchorUpsert(name, anchorType, description, overview) {
2310
- return this.native.anchorUpsert(name, anchorType, description, overview ?? undefined);
3386
+ anchorUpsert(name, anchorType, description, overview, options) {
3387
+ return this.native.anchorUpsert(name, anchorType, description, overview ?? undefined, options ?? undefined);
2311
3388
  }
2312
3389
  /**
2313
3390
  * Update only the overview of an existing anchor (by entity ID).