@equationalapplications/core-llm-wiki 8.1.0 → 8.2.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-UJSUPVPH.mjs → chunk-FOX6TNFO.mjs} +88 -24
- package/dist/chunk-FOX6TNFO.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +90 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-CG8Hw5Ph.d.mts → testing-D6So3dKX.d.mts} +9 -1
- package/dist/{testing-CG8Hw5Ph.d.ts → testing-D6So3dKX.d.ts} +9 -1
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +84 -22
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-UJSUPVPH.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-D6So3dKX.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-D6So3dKX.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-D6So3dKX.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-D6So3dKX.js';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.js
CHANGED
|
@@ -5986,7 +5986,8 @@ var SEVERITY = {
|
|
|
5986
5986
|
resolve_failed: "warn",
|
|
5987
5987
|
read_budget: "info",
|
|
5988
5988
|
event_retention_held: "info",
|
|
5989
|
-
event_created_at_clamped: "warn"
|
|
5989
|
+
event_created_at_clamped: "warn",
|
|
5990
|
+
event_created_at_restamped: "info"
|
|
5990
5991
|
};
|
|
5991
5992
|
var MESSAGE = {
|
|
5992
5993
|
ingest_chunk_failed: "One or more document chunks failed to parse or generate.",
|
|
@@ -6009,7 +6010,8 @@ var MESSAGE = {
|
|
|
6009
6010
|
resolve_failed: "Reconciliation failed for a candidate; it was stored as a draft.",
|
|
6010
6011
|
read_budget: "A read was packed to a token budget.",
|
|
6011
6012
|
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."
|
|
6013
|
+
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.",
|
|
6014
|
+
event_created_at_restamped: "Imported events that would have sorted behind the librarian position, or had an unusable date, were adjusted: an affected created_at was re-dated just after the current time, or after the librarian position if that is later, keeping their order; an unusable occurred_at was cleared."
|
|
6013
6015
|
};
|
|
6014
6016
|
var warnedNonFunction = /* @__PURE__ */ new WeakSet();
|
|
6015
6017
|
function copyDetail(detail) {
|
|
@@ -9461,22 +9463,68 @@ var MaintenanceScheduler = class {
|
|
|
9461
9463
|
};
|
|
9462
9464
|
}
|
|
9463
9465
|
};
|
|
9464
|
-
|
|
9465
|
-
|
|
9466
|
-
var
|
|
9466
|
+
|
|
9467
|
+
// src/services/importEventStamps.ts
|
|
9468
|
+
var DATE_MAX = 864e13;
|
|
9467
9469
|
var DECIMAL_TEXT = /^\s*[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?\s*$/;
|
|
9468
9470
|
function createdAtValue(v) {
|
|
9469
9471
|
if (typeof v === "number") return v;
|
|
9470
9472
|
if (typeof v === "string" && DECIMAL_TEXT.test(v)) return Number(v);
|
|
9471
9473
|
return NaN;
|
|
9472
9474
|
}
|
|
9473
|
-
function
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
|
|
9478
|
-
|
|
9475
|
+
function isUsableDate(v) {
|
|
9476
|
+
return Number.isFinite(v) && v >= -DATE_MAX && v <= DATE_MAX;
|
|
9477
|
+
}
|
|
9478
|
+
function parseSourceWatermark(raw) {
|
|
9479
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return null;
|
|
9480
|
+
const { at, id } = raw;
|
|
9481
|
+
if (typeof at !== "number" || !Number.isFinite(at) || typeof id !== "string") return null;
|
|
9482
|
+
return { at, id };
|
|
9483
|
+
}
|
|
9484
|
+
var cmp = (a, b) => a === b ? 0 : a < b ? -1 : 1;
|
|
9485
|
+
function planEventStamps(events, ctx) {
|
|
9486
|
+
const { now, floor, merge, localWm, sourceWm } = ctx;
|
|
9487
|
+
const after = (v, id, wm) => v > wm.at || v === wm.at && id > wm.id;
|
|
9488
|
+
const plan = /* @__PURE__ */ new Map();
|
|
9489
|
+
const restamp = [];
|
|
9490
|
+
for (const e of events) {
|
|
9491
|
+
const v = createdAtValue(e.created_at);
|
|
9492
|
+
const o = createdAtValue(e.occurred_at);
|
|
9493
|
+
let occurredAt = null;
|
|
9494
|
+
let occurredInvalid = false;
|
|
9495
|
+
if (e.occurred_at != null) {
|
|
9496
|
+
if (isUsableDate(o)) occurredAt = Math.trunc(o);
|
|
9497
|
+
else occurredInvalid = true;
|
|
9498
|
+
}
|
|
9499
|
+
let reason = null;
|
|
9500
|
+
const invalidCreated = Number.isNaN(v) || v < -DATE_MAX;
|
|
9501
|
+
if (invalidCreated) reason = "invalid";
|
|
9502
|
+
else if (v > now) reason = "future";
|
|
9503
|
+
else if (merge && localWm !== null && Number.isFinite(localWm.at) && !after(v, e.id, localWm) && (sourceWm === null || after(v, e.id, sourceWm))) {
|
|
9504
|
+
reason = "behind_watermark";
|
|
9505
|
+
}
|
|
9506
|
+
if (reason === "behind_watermark" && occurredAt === null && Number.isFinite(v) && v >= 0) {
|
|
9507
|
+
occurredAt = Math.trunc(v);
|
|
9508
|
+
}
|
|
9509
|
+
const stamp = { createdAt: v, occurredAt, reason };
|
|
9510
|
+
if (reason === null && occurredInvalid) stamp.reason = "invalid";
|
|
9511
|
+
plan.set(e, stamp);
|
|
9512
|
+
if (reason !== null) restamp.push({ e, key: invalidCreated ? -Infinity : v, stamp });
|
|
9513
|
+
}
|
|
9514
|
+
restamp.sort((x, y) => cmp(x.key, y.key) || cmp(x.e.id, y.e.id));
|
|
9515
|
+
if (restamp.length > 0 && floor + restamp.length > Number.MAX_SAFE_INTEGER) {
|
|
9516
|
+
throw new RangeError(`importDump: cannot re-date ${restamp.length} event(s): the floor (${floor}) is too close to Number.MAX_SAFE_INTEGER to keep them ordered.`);
|
|
9517
|
+
}
|
|
9518
|
+
restamp.forEach((x, i) => {
|
|
9519
|
+
x.stamp.createdAt = floor + 1 + i;
|
|
9520
|
+
});
|
|
9521
|
+
return plan;
|
|
9479
9522
|
}
|
|
9523
|
+
|
|
9524
|
+
// src/services/ImportExportService.ts
|
|
9525
|
+
var MAX_EMBEDDING_BLOB_BYTES = 32 * 1024;
|
|
9526
|
+
var IMPORT_TITLE_MAX = 500;
|
|
9527
|
+
var IMPORT_BODY_MAX = 8e3;
|
|
9480
9528
|
var ImportExportService = class {
|
|
9481
9529
|
constructor(db, entryRepo, taskRepo, eventRepo, edgeRepo, metadataRepo, searchService, jobManager, embeddingService, options = {}) {
|
|
9482
9530
|
this.db = db;
|
|
@@ -9529,6 +9577,7 @@ var ImportExportService = class {
|
|
|
9529
9577
|
}
|
|
9530
9578
|
}
|
|
9531
9579
|
async getFullBundle(entityId, opts) {
|
|
9580
|
+
const wm = await this.metadataRepo.getLibrarianWatermark(entityId, this.db);
|
|
9532
9581
|
const [factsRaw, tasks, events, edges, summaryValue] = await Promise.all([
|
|
9533
9582
|
opts?.includeBlobs ? this.entryRepo.findAllByEntityIdWithBlobs(entityId) : this.entryRepo.findAllByEntityId(entityId),
|
|
9534
9583
|
this.taskRepo.findAllByEntityId(entityId),
|
|
@@ -9558,7 +9607,8 @@ var ImportExportService = class {
|
|
|
9558
9607
|
tasks,
|
|
9559
9608
|
events,
|
|
9560
9609
|
edges,
|
|
9561
|
-
...summaryValue != null ? { summary: summaryValue } : {}
|
|
9610
|
+
...summaryValue != null ? { summary: summaryValue } : {},
|
|
9611
|
+
...wm ? { librarian_watermark: wm } : {}
|
|
9562
9612
|
};
|
|
9563
9613
|
}
|
|
9564
9614
|
/** Single-entity import transaction + post-processing; package-internal hook for tests. */
|
|
@@ -9570,6 +9620,7 @@ var ImportExportService = class {
|
|
|
9570
9620
|
const softDeletedFactIds = [];
|
|
9571
9621
|
const clippedTextByFactId = /* @__PURE__ */ new Map();
|
|
9572
9622
|
let clampedEvents = 0;
|
|
9623
|
+
const restamped = { behind_watermark: 0, invalid: 0 };
|
|
9573
9624
|
await this.db.withTransactionAsync(async (tx) => {
|
|
9574
9625
|
if (!merge) {
|
|
9575
9626
|
const deletedLiveFactIds = await this.entryRepo.findIdsBySource(
|
|
@@ -9793,9 +9844,9 @@ var ImportExportService = class {
|
|
|
9793
9844
|
const now = Date.now();
|
|
9794
9845
|
const wm = bundle.events.length > 0 ? await seedLegacyWatermark(this.metadataRepo, this.eventRepo, entityId, tx) : await this.metadataRepo.getLibrarianWatermark(entityId, tx);
|
|
9795
9846
|
const floor = wm && Number.isFinite(wm.at) && wm.at > now ? wm.at : now;
|
|
9796
|
-
const
|
|
9847
|
+
const planned = planEventStamps(bundle.events, { now, floor, merge, localWm: wm, sourceWm: parseSourceWatermark(bundle.librarian_watermark) });
|
|
9797
9848
|
for (const event of bundle.events) {
|
|
9798
|
-
const
|
|
9849
|
+
const stamp = planned.get(event);
|
|
9799
9850
|
const inserted = await this.eventRepo.addIgnoreDuplicate(
|
|
9800
9851
|
{
|
|
9801
9852
|
id: event.id,
|
|
@@ -9803,12 +9854,14 @@ var ImportExportService = class {
|
|
|
9803
9854
|
event_type: event.event_type,
|
|
9804
9855
|
summary: event.summary,
|
|
9805
9856
|
related_entry_id: event.related_entry_id ?? null,
|
|
9806
|
-
created_at:
|
|
9807
|
-
occurred_at:
|
|
9857
|
+
created_at: stamp.createdAt,
|
|
9858
|
+
occurred_at: stamp.occurredAt
|
|
9808
9859
|
},
|
|
9809
9860
|
tx
|
|
9810
9861
|
);
|
|
9811
|
-
if (inserted
|
|
9862
|
+
if (!inserted || stamp.reason === null) continue;
|
|
9863
|
+
if (stamp.reason === "future") clampedEvents++;
|
|
9864
|
+
else restamped[stamp.reason]++;
|
|
9812
9865
|
}
|
|
9813
9866
|
for (const edge of bundle.edges ?? []) {
|
|
9814
9867
|
await this.edgeRepo.addIgnoreDuplicate(
|
|
@@ -9833,6 +9886,17 @@ var ImportExportService = class {
|
|
|
9833
9886
|
detail: { count: clampedEvents }
|
|
9834
9887
|
});
|
|
9835
9888
|
}
|
|
9889
|
+
for (const reason of ["behind_watermark", "invalid"]) {
|
|
9890
|
+
if (restamped[reason] > 0) {
|
|
9891
|
+
emitDiagnostic(this.options, {
|
|
9892
|
+
code: "event_created_at_restamped",
|
|
9893
|
+
operation: "importDump",
|
|
9894
|
+
trigger: "call",
|
|
9895
|
+
entityId,
|
|
9896
|
+
detail: { count: restamped[reason], reason }
|
|
9897
|
+
});
|
|
9898
|
+
}
|
|
9899
|
+
}
|
|
9836
9900
|
if (merge) {
|
|
9837
9901
|
await this.searchService.syncEntries(entityId, [...upsertedFactIds]);
|
|
9838
9902
|
} else {
|
|
@@ -10609,7 +10673,7 @@ var RetrievalService = class {
|
|
|
10609
10673
|
if (topK.length < maxBackfill) {
|
|
10610
10674
|
let insertIdx = topK.length;
|
|
10611
10675
|
for (let i = 0; i < topK.length; i++) {
|
|
10612
|
-
const
|
|
10676
|
+
const cmp2 = this._compareScoredRows(
|
|
10613
10677
|
{
|
|
10614
10678
|
id: candidate.row.id,
|
|
10615
10679
|
score: candidate.kwScore,
|
|
@@ -10623,7 +10687,7 @@ var RetrievalService = class {
|
|
|
10623
10687
|
access_count: topK[i].row.access_count
|
|
10624
10688
|
}
|
|
10625
10689
|
);
|
|
10626
|
-
if (
|
|
10690
|
+
if (cmp2 < 0) {
|
|
10627
10691
|
insertIdx = i;
|
|
10628
10692
|
break;
|
|
10629
10693
|
}
|
|
@@ -10647,7 +10711,7 @@ var RetrievalService = class {
|
|
|
10647
10711
|
if (cmpWorst < 0) {
|
|
10648
10712
|
let insertIdx = maxBackfill - 1;
|
|
10649
10713
|
for (let i = 0; i < topK.length; i++) {
|
|
10650
|
-
const
|
|
10714
|
+
const cmp2 = this._compareScoredRows(
|
|
10651
10715
|
{
|
|
10652
10716
|
id: candidate.row.id,
|
|
10653
10717
|
score: candidate.kwScore,
|
|
@@ -10661,7 +10725,7 @@ var RetrievalService = class {
|
|
|
10661
10725
|
access_count: topK[i].row.access_count
|
|
10662
10726
|
}
|
|
10663
10727
|
);
|
|
10664
|
-
if (
|
|
10728
|
+
if (cmp2 < 0) {
|
|
10665
10729
|
insertIdx = i;
|
|
10666
10730
|
break;
|
|
10667
10731
|
}
|
|
@@ -13106,9 +13170,13 @@ function buildEventLogEntries(events, factIdToFilename) {
|
|
|
13106
13170
|
const factFilename = e.related_entry_id ? factIdToFilename.get(e.related_entry_id) : void 0;
|
|
13107
13171
|
const summary = e.summary.replace(/\\/g, "\\\\").replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\r?\n/g, " ");
|
|
13108
13172
|
const text = factFilename ? `(${e.event_type}) [${summary}](./facts/${factFilename}.md)` : `(${e.event_type}) ${summary}`;
|
|
13109
|
-
|
|
13173
|
+
const occurred = createdAtValue(e.occurred_at);
|
|
13174
|
+
const logTime = e.occurred_at != null && isUsableDate(occurred) && occurred >= OKF_DATE_MIN && occurred <= OKF_DATE_MAX && occurred <= e.created_at ? occurred : e.created_at;
|
|
13175
|
+
return { date: formatLogDate(logTime), text: coreOkf.appendEventIdComment(text, e.id) };
|
|
13110
13176
|
});
|
|
13111
13177
|
}
|
|
13178
|
+
var OKF_DATE_MIN = -621672192e5;
|
|
13179
|
+
var OKF_DATE_MAX = 253402300799999;
|
|
13112
13180
|
function formatOkfBundle(dump, options) {
|
|
13113
13181
|
const profile = options?.profile ?? DEFAULT_PROFILE;
|
|
13114
13182
|
const okfVersion = profile === "llm-wiki/2" ? "0.2" : "0.1";
|