@equationalapplications/core-llm-wiki 8.0.5 → 8.1.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.
- package/dist/{chunk-GYF5QLYK.mjs → chunk-UJSUPVPH.mjs} +64 -24
- package/dist/chunk-UJSUPVPH.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +67 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -4
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-BPddGTkl.d.mts → testing-CG8Hw5Ph.d.mts} +5 -3
- package/dist/{testing-BPddGTkl.d.ts → testing-CG8Hw5Ph.d.ts} +5 -3
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +64 -22
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-GYF5QLYK.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-
|
|
2
|
-
export { C as ChunkFailure, d as ClassifierAnswer, e as ClassifierQuestion, f as ClassifyRequest, g as ClassifyResponse, D as DegradedRecord, h as DraftPage, E as EmbedFactResult, i as EmbedFailureKind, j as EmbeddingMarkerKind, k as EntityMaintenanceReport, l as EntityStatus, m as ExtractedFact, n as ExtractedFactEdge, o as ExtractedFactWithOntology, p as ExtractedTask, q as GraphTraversalOptions, r as GroundingConfig, H as HEAL_BATCH_SIZE, s as HEAL_RECHECK_MS, t as HOOK_TIMEOUT_MARKER, u as HealResult, I as IngestDocumentResult, L as LLMProvider, v as LibrarianConfig, w as LibrarianGateConfig, x as MaintenanceJob, y as MaintenanceStopReason, z as MigrationPolicy, O as ONTOLOGY_BACKFILL_BATCH_SIZE, A as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, B as ONTOLOGY_BACKFILL_RECHECK_MS, J as OntologyBackfillResult, K as OntologyConfig, N as OntologyEdgeType, P as OntologyManifest, Q as OntologyMode, T as OntologyNodeType, U as OntologyPromptContext, V as OntologyUpdates, X as PendingMaintenance, Y as PendingMigrationWork, Z as PendingSourceStatus, _ as PromptOverrides, $ as PromptService, a0 as PrunePartialFailureError, a1 as ReembedResult, a2 as RememberInput, a3 as RunPendingMaintenanceOptions, a4 as RunPendingMaintenanceResult, a5 as SupersedeReplacement, a6 as VectorRanker, a7 as VectorRankerFallback, a8 as VectorRankerRankArgs, a9 as VectorRankerSemanticResult, aa as WikiBusyError, ab as WikiBusyOperation, ac as WikiCheckpoint, ad as WikiConfig, ae as WikiDiagnostic, af as WikiDiagnosticCode, ag as WikiDiagnosticDetail, ah as WikiDiagnosticOperation, ai as WikiDiagnosticSeverity, aj as WikiDiagnosticTrigger, ak as WikiDraftNotFound, al as WikiDuplicateHashError, am as WikiEdge, an as WikiEvent, ao as WikiFact, ap as WikiGraphNodeOwnershipConflict, aq as WikiIngestEmptyError, ar as WikiInstructions, as as WikiInvalidReadOptions, at as WikiLintReport, au as WikiMemoryTestAccess, av as WikiMigrationRequiredError, aw as WikiOutboxEvent, ax as WikiParseError, ay as WikiSearchUnavailableError, az as WikiSourceRefHashCollision, aA as WikiStrictOntologyViolation, aB as WikiSupersedeError, aC as WikiSupersedeReason, aD as WikiTask, aE as WikiTransactionError, aF as isWikiSearchUnavailableError, aG as validateManifest } from './testing-
|
|
1
|
+
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-CG8Hw5Ph.mjs';
|
|
2
|
+
export { C as ChunkFailure, d as ClassifierAnswer, e as ClassifierQuestion, f as ClassifyRequest, g as ClassifyResponse, D as DegradedRecord, h as DraftPage, E as EmbedFactResult, i as EmbedFailureKind, j as EmbeddingMarkerKind, k as EntityMaintenanceReport, l as EntityStatus, m as ExtractedFact, n as ExtractedFactEdge, o as ExtractedFactWithOntology, p as ExtractedTask, q as GraphTraversalOptions, r as GroundingConfig, H as HEAL_BATCH_SIZE, s as HEAL_RECHECK_MS, t as HOOK_TIMEOUT_MARKER, u as HealResult, I as IngestDocumentResult, L as LLMProvider, v as LibrarianConfig, w as LibrarianGateConfig, x as MaintenanceJob, y as MaintenanceStopReason, z as MigrationPolicy, O as ONTOLOGY_BACKFILL_BATCH_SIZE, A as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, B as ONTOLOGY_BACKFILL_RECHECK_MS, J as OntologyBackfillResult, K as OntologyConfig, N as OntologyEdgeType, P as OntologyManifest, Q as OntologyMode, T as OntologyNodeType, U as OntologyPromptContext, V as OntologyUpdates, X as PendingMaintenance, Y as PendingMigrationWork, Z as PendingSourceStatus, _ as PromptOverrides, $ as PromptService, a0 as PrunePartialFailureError, a1 as ReembedResult, a2 as RememberInput, a3 as RunPendingMaintenanceOptions, a4 as RunPendingMaintenanceResult, a5 as SupersedeReplacement, a6 as VectorRanker, a7 as VectorRankerFallback, a8 as VectorRankerRankArgs, a9 as VectorRankerSemanticResult, aa as WikiBusyError, ab as WikiBusyOperation, ac as WikiCheckpoint, ad as WikiConfig, ae as WikiDiagnostic, af as WikiDiagnosticCode, ag as WikiDiagnosticDetail, ah as WikiDiagnosticOperation, ai as WikiDiagnosticSeverity, aj as WikiDiagnosticTrigger, ak as WikiDraftNotFound, al as WikiDuplicateHashError, am as WikiEdge, an as WikiEvent, ao as WikiFact, ap as WikiGraphNodeOwnershipConflict, aq as WikiIngestEmptyError, ar as WikiInstructions, as as WikiInvalidReadOptions, at as WikiLintReport, au as WikiMemoryTestAccess, av as WikiMigrationRequiredError, aw as WikiOutboxEvent, ax as WikiParseError, ay as WikiSearchUnavailableError, az as WikiSourceRefHashCollision, aA as WikiStrictOntologyViolation, aB as WikiSupersedeError, aC as WikiSupersedeReason, aD as WikiTask, aE as WikiTransactionError, aF as isWikiSearchUnavailableError, aG as validateManifest } from './testing-CG8Hw5Ph.mjs';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-
|
|
2
|
-
export { C as ChunkFailure, d as ClassifierAnswer, e as ClassifierQuestion, f as ClassifyRequest, g as ClassifyResponse, D as DegradedRecord, h as DraftPage, E as EmbedFactResult, i as EmbedFailureKind, j as EmbeddingMarkerKind, k as EntityMaintenanceReport, l as EntityStatus, m as ExtractedFact, n as ExtractedFactEdge, o as ExtractedFactWithOntology, p as ExtractedTask, q as GraphTraversalOptions, r as GroundingConfig, H as HEAL_BATCH_SIZE, s as HEAL_RECHECK_MS, t as HOOK_TIMEOUT_MARKER, u as HealResult, I as IngestDocumentResult, L as LLMProvider, v as LibrarianConfig, w as LibrarianGateConfig, x as MaintenanceJob, y as MaintenanceStopReason, z as MigrationPolicy, O as ONTOLOGY_BACKFILL_BATCH_SIZE, A as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, B as ONTOLOGY_BACKFILL_RECHECK_MS, J as OntologyBackfillResult, K as OntologyConfig, N as OntologyEdgeType, P as OntologyManifest, Q as OntologyMode, T as OntologyNodeType, U as OntologyPromptContext, V as OntologyUpdates, X as PendingMaintenance, Y as PendingMigrationWork, Z as PendingSourceStatus, _ as PromptOverrides, $ as PromptService, a0 as PrunePartialFailureError, a1 as ReembedResult, a2 as RememberInput, a3 as RunPendingMaintenanceOptions, a4 as RunPendingMaintenanceResult, a5 as SupersedeReplacement, a6 as VectorRanker, a7 as VectorRankerFallback, a8 as VectorRankerRankArgs, a9 as VectorRankerSemanticResult, aa as WikiBusyError, ab as WikiBusyOperation, ac as WikiCheckpoint, ad as WikiConfig, ae as WikiDiagnostic, af as WikiDiagnosticCode, ag as WikiDiagnosticDetail, ah as WikiDiagnosticOperation, ai as WikiDiagnosticSeverity, aj as WikiDiagnosticTrigger, ak as WikiDraftNotFound, al as WikiDuplicateHashError, am as WikiEdge, an as WikiEvent, ao as WikiFact, ap as WikiGraphNodeOwnershipConflict, aq as WikiIngestEmptyError, ar as WikiInstructions, as as WikiInvalidReadOptions, at as WikiLintReport, au as WikiMemoryTestAccess, av as WikiMigrationRequiredError, aw as WikiOutboxEvent, ax as WikiParseError, ay as WikiSearchUnavailableError, az as WikiSourceRefHashCollision, aA as WikiStrictOntologyViolation, aB as WikiSupersedeError, aC as WikiSupersedeReason, aD as WikiTask, aE as WikiTransactionError, aF as isWikiSearchUnavailableError, aG as validateManifest } from './testing-
|
|
1
|
+
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-CG8Hw5Ph.js';
|
|
2
|
+
export { C as ChunkFailure, d as ClassifierAnswer, e as ClassifierQuestion, f as ClassifyRequest, g as ClassifyResponse, D as DegradedRecord, h as DraftPage, E as EmbedFactResult, i as EmbedFailureKind, j as EmbeddingMarkerKind, k as EntityMaintenanceReport, l as EntityStatus, m as ExtractedFact, n as ExtractedFactEdge, o as ExtractedFactWithOntology, p as ExtractedTask, q as GraphTraversalOptions, r as GroundingConfig, H as HEAL_BATCH_SIZE, s as HEAL_RECHECK_MS, t as HOOK_TIMEOUT_MARKER, u as HealResult, I as IngestDocumentResult, L as LLMProvider, v as LibrarianConfig, w as LibrarianGateConfig, x as MaintenanceJob, y as MaintenanceStopReason, z as MigrationPolicy, O as ONTOLOGY_BACKFILL_BATCH_SIZE, A as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, B as ONTOLOGY_BACKFILL_RECHECK_MS, J as OntologyBackfillResult, K as OntologyConfig, N as OntologyEdgeType, P as OntologyManifest, Q as OntologyMode, T as OntologyNodeType, U as OntologyPromptContext, V as OntologyUpdates, X as PendingMaintenance, Y as PendingMigrationWork, Z as PendingSourceStatus, _ as PromptOverrides, $ as PromptService, a0 as PrunePartialFailureError, a1 as ReembedResult, a2 as RememberInput, a3 as RunPendingMaintenanceOptions, a4 as RunPendingMaintenanceResult, a5 as SupersedeReplacement, a6 as VectorRanker, a7 as VectorRankerFallback, a8 as VectorRankerRankArgs, a9 as VectorRankerSemanticResult, aa as WikiBusyError, ab as WikiBusyOperation, ac as WikiCheckpoint, ad as WikiConfig, ae as WikiDiagnostic, af as WikiDiagnosticCode, ag as WikiDiagnosticDetail, ah as WikiDiagnosticOperation, ai as WikiDiagnosticSeverity, aj as WikiDiagnosticTrigger, ak as WikiDraftNotFound, al as WikiDuplicateHashError, am as WikiEdge, an as WikiEvent, ao as WikiFact, ap as WikiGraphNodeOwnershipConflict, aq as WikiIngestEmptyError, ar as WikiInstructions, as as WikiInvalidReadOptions, at as WikiLintReport, au as WikiMemoryTestAccess, av as WikiMigrationRequiredError, aw as WikiOutboxEvent, ax as WikiParseError, ay as WikiSearchUnavailableError, az as WikiSourceRefHashCollision, aA as WikiStrictOntologyViolation, aB as WikiSupersedeError, aC as WikiSupersedeReason, aD as WikiTask, aE as WikiTransactionError, aF as isWikiSearchUnavailableError, aG as validateManifest } from './testing-CG8Hw5Ph.js';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.js
CHANGED
|
@@ -3537,9 +3537,10 @@ var EventRepository = class extends BaseRepository {
|
|
|
3537
3537
|
]
|
|
3538
3538
|
);
|
|
3539
3539
|
}
|
|
3540
|
+
/** Insert unless the id already exists. Returns true when a row was inserted. */
|
|
3540
3541
|
async addIgnoreDuplicate(event, tx) {
|
|
3541
3542
|
const executor = this.getExecutor(tx);
|
|
3542
|
-
await executor.runAsync(
|
|
3543
|
+
const result = await executor.runAsync(
|
|
3543
3544
|
`INSERT OR IGNORE INTO ${this.prefix}events (id, entity_id, event_type, summary, related_entry_id, created_at, occurred_at)
|
|
3544
3545
|
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
|
3545
3546
|
[
|
|
@@ -3552,6 +3553,7 @@ var EventRepository = class extends BaseRepository {
|
|
|
3552
3553
|
event.occurred_at ?? null
|
|
3553
3554
|
]
|
|
3554
3555
|
);
|
|
3556
|
+
return result.changes > 0;
|
|
3555
3557
|
}
|
|
3556
3558
|
/**
|
|
3557
3559
|
* Return the most recent events for an entity, newest first.
|
|
@@ -5983,7 +5985,8 @@ var SEVERITY = {
|
|
|
5983
5985
|
contradicts_document: "warn",
|
|
5984
5986
|
resolve_failed: "warn",
|
|
5985
5987
|
read_budget: "info",
|
|
5986
|
-
event_retention_held: "info"
|
|
5988
|
+
event_retention_held: "info",
|
|
5989
|
+
event_created_at_clamped: "warn"
|
|
5987
5990
|
};
|
|
5988
5991
|
var MESSAGE = {
|
|
5989
5992
|
ingest_chunk_failed: "One or more document chunks failed to parse or generate.",
|
|
@@ -6005,7 +6008,8 @@ var MESSAGE = {
|
|
|
6005
6008
|
contradicts_document: "A candidate contradicted a document fact and was stored as a draft.",
|
|
6006
6009
|
resolve_failed: "Reconciliation failed for a candidate; it was stored as a draft.",
|
|
6007
6010
|
read_budget: "A read was packed to a token budget.",
|
|
6008
|
-
event_retention_held: "Event pruning was held back because the librarian has not processed those events yet."
|
|
6011
|
+
event_retention_held: "Event pruning was held back because the librarian has not processed those events yet.",
|
|
6012
|
+
event_created_at_clamped: "Imported events dated in the future were re-dated just after the current time, or after the librarian position if that is later, keeping their order."
|
|
6009
6013
|
};
|
|
6010
6014
|
var warnedNonFunction = /* @__PURE__ */ new WeakSet();
|
|
6011
6015
|
function copyDetail(detail) {
|
|
@@ -7225,6 +7229,28 @@ function warnChangedDefaultsOnce(config) {
|
|
|
7225
7229
|
}
|
|
7226
7230
|
}
|
|
7227
7231
|
|
|
7232
|
+
// src/services/legacyWatermark.ts
|
|
7233
|
+
async function anchorAtLegacyBoundary(metadataRepo, eventRepo, entityId, checkpoint, total, db) {
|
|
7234
|
+
if (checkpoint <= 0 || total <= 0) return null;
|
|
7235
|
+
const ev = await eventRepo.getAtOffset(entityId, Math.min(checkpoint, total) - 1, db);
|
|
7236
|
+
if (!ev) return null;
|
|
7237
|
+
const wm = { at: ev.created_at, id: ev.id };
|
|
7238
|
+
await metadataRepo.setLibrarianWatermark(entityId, wm, db);
|
|
7239
|
+
return wm;
|
|
7240
|
+
}
|
|
7241
|
+
async function seedLegacyWatermark(metadataRepo, eventRepo, entityId, db) {
|
|
7242
|
+
const existing = await metadataRepo.getLibrarianWatermark(entityId, db);
|
|
7243
|
+
if (existing) return existing;
|
|
7244
|
+
const memory = (await metadataRepo.getCheckpoint(entityId, db)).memory ?? 0;
|
|
7245
|
+
if (memory <= 0) return null;
|
|
7246
|
+
const total = await eventRepo.count(entityId, db);
|
|
7247
|
+
if (memory > total) {
|
|
7248
|
+
await metadataRepo.setLibrarianWatermark(entityId, START_OF_LOG_WATERMARK, db);
|
|
7249
|
+
return START_OF_LOG_WATERMARK;
|
|
7250
|
+
}
|
|
7251
|
+
return anchorAtLegacyBoundary(metadataRepo, eventRepo, entityId, memory, total, db);
|
|
7252
|
+
}
|
|
7253
|
+
|
|
7228
7254
|
// src/services/BoundedLlmCall.ts
|
|
7229
7255
|
var DEFAULT_BATCH_SIZE = 10;
|
|
7230
7256
|
var ESTIMATED_OUTPUT_TOKENS_PER_ITEM = 150;
|
|
@@ -8617,13 +8643,8 @@ var MaintenanceService = class {
|
|
|
8617
8643
|
* nothing and returns null when there is no legacy history or no such
|
|
8618
8644
|
* event; each caller picks its own fallback.
|
|
8619
8645
|
*/
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
const ev = await this.eventRepo.getAtOffset(entityId, Math.min(checkpoint, total) - 1, db);
|
|
8623
|
-
if (!ev) return null;
|
|
8624
|
-
const wm = { at: ev.created_at, id: ev.id };
|
|
8625
|
-
await this.metadataRepo.setLibrarianWatermark(entityId, wm, db);
|
|
8626
|
-
return wm;
|
|
8646
|
+
anchorAtLegacyBoundary(entityId, checkpoint, total, db) {
|
|
8647
|
+
return anchorAtLegacyBoundary(this.metadataRepo, this.eventRepo, entityId, checkpoint, total, db);
|
|
8627
8648
|
}
|
|
8628
8649
|
/**
|
|
8629
8650
|
* Spec §10.3: first ops pass on a legacy DB starts after what the count
|
|
@@ -8633,16 +8654,7 @@ var MaintenanceService = class {
|
|
|
8633
8654
|
* drift and gets {@link START_OF_LOG_WATERMARK} (spec ops-auto-first-batch §2).
|
|
8634
8655
|
*/
|
|
8635
8656
|
async seedLibrarianWatermark(entityId) {
|
|
8636
|
-
|
|
8637
|
-
const cp = await this.metadataRepo.getCheckpoint(entityId, this.db);
|
|
8638
|
-
const memory = cp.memory ?? 0;
|
|
8639
|
-
if (memory <= 0) return;
|
|
8640
|
-
const total = await this.eventRepo.count(entityId, this.db);
|
|
8641
|
-
if (memory > total) {
|
|
8642
|
-
await this.metadataRepo.setLibrarianWatermark(entityId, START_OF_LOG_WATERMARK, this.db);
|
|
8643
|
-
return;
|
|
8644
|
-
}
|
|
8645
|
-
await this.anchorAtLegacyBoundary(entityId, memory, total, this.db);
|
|
8657
|
+
await seedLegacyWatermark(this.metadataRepo, this.eventRepo, entityId, this.db);
|
|
8646
8658
|
}
|
|
8647
8659
|
/**
|
|
8648
8660
|
* Core heal pass (locks handled by {@link runHeal}). Package-internal orchestration hook.
|
|
@@ -9452,8 +9464,21 @@ var MaintenanceScheduler = class {
|
|
|
9452
9464
|
var MAX_EMBEDDING_BLOB_BYTES = 32 * 1024;
|
|
9453
9465
|
var IMPORT_TITLE_MAX = 500;
|
|
9454
9466
|
var IMPORT_BODY_MAX = 8e3;
|
|
9467
|
+
var DECIMAL_TEXT = /^\s*[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?\s*$/;
|
|
9468
|
+
function createdAtValue(v) {
|
|
9469
|
+
if (typeof v === "number") return v;
|
|
9470
|
+
if (typeof v === "string" && DECIMAL_TEXT.test(v)) return Number(v);
|
|
9471
|
+
return NaN;
|
|
9472
|
+
}
|
|
9473
|
+
function clampFutureCreatedAt(events, now, floor) {
|
|
9474
|
+
const future = events.map((e) => ({ e, at: createdAtValue(e.created_at) })).filter((x) => x.at > now).sort((x, y) => (x.at === y.at ? 0 : x.at < y.at ? -1 : 1) || (x.e.id < y.e.id ? -1 : x.e.id > y.e.id ? 1 : 0));
|
|
9475
|
+
if (future.length > 0 && floor + future.length > Number.MAX_SAFE_INTEGER) {
|
|
9476
|
+
throw new RangeError(`importDump: cannot re-date ${future.length} future-dated event(s): the floor (${floor}) is too close to Number.MAX_SAFE_INTEGER to keep them ordered.`);
|
|
9477
|
+
}
|
|
9478
|
+
return new Map(future.map((x, i) => [x.e, floor + 1 + i]));
|
|
9479
|
+
}
|
|
9455
9480
|
var ImportExportService = class {
|
|
9456
|
-
constructor(db, entryRepo, taskRepo, eventRepo, edgeRepo, metadataRepo, searchService, jobManager, embeddingService) {
|
|
9481
|
+
constructor(db, entryRepo, taskRepo, eventRepo, edgeRepo, metadataRepo, searchService, jobManager, embeddingService, options = {}) {
|
|
9457
9482
|
this.db = db;
|
|
9458
9483
|
this.entryRepo = entryRepo;
|
|
9459
9484
|
this.taskRepo = taskRepo;
|
|
@@ -9463,6 +9488,7 @@ var ImportExportService = class {
|
|
|
9463
9488
|
this.searchService = searchService;
|
|
9464
9489
|
this.jobManager = jobManager;
|
|
9465
9490
|
this.embeddingService = embeddingService;
|
|
9491
|
+
this.options = options;
|
|
9466
9492
|
}
|
|
9467
9493
|
async exportDump(entityIds) {
|
|
9468
9494
|
let ids;
|
|
@@ -9543,6 +9569,7 @@ var ImportExportService = class {
|
|
|
9543
9569
|
const preservedBlobDims = /* @__PURE__ */ new Set();
|
|
9544
9570
|
const softDeletedFactIds = [];
|
|
9545
9571
|
const clippedTextByFactId = /* @__PURE__ */ new Map();
|
|
9572
|
+
let clampedEvents = 0;
|
|
9546
9573
|
await this.db.withTransactionAsync(async (tx) => {
|
|
9547
9574
|
if (!merge) {
|
|
9548
9575
|
const deletedLiveFactIds = await this.entryRepo.findIdsBySource(
|
|
@@ -9763,19 +9790,25 @@ var ImportExportService = class {
|
|
|
9763
9790
|
updated_at: safeUpdatedAt
|
|
9764
9791
|
});
|
|
9765
9792
|
}
|
|
9793
|
+
const now = Date.now();
|
|
9794
|
+
const wm = bundle.events.length > 0 ? await seedLegacyWatermark(this.metadataRepo, this.eventRepo, entityId, tx) : await this.metadataRepo.getLibrarianWatermark(entityId, tx);
|
|
9795
|
+
const floor = wm && Number.isFinite(wm.at) && wm.at > now ? wm.at : now;
|
|
9796
|
+
const clampedAt = clampFutureCreatedAt(bundle.events, now, floor);
|
|
9766
9797
|
for (const event of bundle.events) {
|
|
9767
|
-
|
|
9798
|
+
const stamped = clampedAt.get(event);
|
|
9799
|
+
const inserted = await this.eventRepo.addIgnoreDuplicate(
|
|
9768
9800
|
{
|
|
9769
9801
|
id: event.id,
|
|
9770
9802
|
entity_id: entityId,
|
|
9771
9803
|
event_type: event.event_type,
|
|
9772
9804
|
summary: event.summary,
|
|
9773
9805
|
related_entry_id: event.related_entry_id ?? null,
|
|
9774
|
-
created_at: event.created_at,
|
|
9806
|
+
created_at: stamped ?? event.created_at,
|
|
9775
9807
|
occurred_at: event.occurred_at ?? null
|
|
9776
9808
|
},
|
|
9777
9809
|
tx
|
|
9778
9810
|
);
|
|
9811
|
+
if (inserted && stamped !== void 0) clampedEvents++;
|
|
9779
9812
|
}
|
|
9780
9813
|
for (const edge of bundle.edges ?? []) {
|
|
9781
9814
|
await this.edgeRepo.addIgnoreDuplicate(
|
|
@@ -9791,6 +9824,15 @@ var ImportExportService = class {
|
|
|
9791
9824
|
);
|
|
9792
9825
|
}
|
|
9793
9826
|
});
|
|
9827
|
+
if (clampedEvents > 0) {
|
|
9828
|
+
emitDiagnostic(this.options, {
|
|
9829
|
+
code: "event_created_at_clamped",
|
|
9830
|
+
operation: "importDump",
|
|
9831
|
+
trigger: "call",
|
|
9832
|
+
entityId,
|
|
9833
|
+
detail: { count: clampedEvents }
|
|
9834
|
+
});
|
|
9835
|
+
}
|
|
9794
9836
|
if (merge) {
|
|
9795
9837
|
await this.searchService.syncEntries(entityId, [...upsertedFactIds]);
|
|
9796
9838
|
} else {
|
|
@@ -11835,7 +11877,8 @@ var WikiMemory = class {
|
|
|
11835
11877
|
this.metadataRepo,
|
|
11836
11878
|
this.searchService,
|
|
11837
11879
|
this.jobManager,
|
|
11838
|
-
this.embeddingService
|
|
11880
|
+
this.embeddingService,
|
|
11881
|
+
this.options
|
|
11839
11882
|
);
|
|
11840
11883
|
this.retrievalService = new RetrievalService(
|
|
11841
11884
|
this.options,
|