@equationalapplications/core-llm-wiki 8.2.0 → 8.3.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/README.md +1 -1
- package/dist/{chunk-FOX6TNFO.mjs → chunk-V432RHCG.mjs} +239 -29
- package/dist/chunk-V432RHCG.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +108 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -183
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-D6So3dKX.d.mts → testing-BT5qSnGB.d.mts} +57 -34
- package/dist/{testing-D6So3dKX.d.ts → testing-BT5qSnGB.d.ts} +57 -34
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +245 -16
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-FOX6TNFO.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
|
|
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-BT5qSnGB.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 ForgetParams, r as ForgetResult, s as GraphTraversalOptions, t as GroundingConfig, H as HEAL_BATCH_SIZE, u as HEAL_RECHECK_MS, v as HOOK_TIMEOUT_MARKER, w as HealResult, I as IngestDocumentResult, L as LLMProvider, x as LibrarianConfig, y as LibrarianGateConfig, z as MaintenanceJob, A as MaintenanceStopReason, B as MigrationPolicy, O as ONTOLOGY_BACKFILL_BATCH_SIZE, J as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, K as ONTOLOGY_BACKFILL_RECHECK_MS, N as OntologyBackfillResult, P as OntologyConfig, Q as OntologyEdgeType, T as OntologyManifest, U as OntologyMode, V as OntologyNodeType, X as OntologyPromptContext, Y as OntologyUpdates, Z as PendingMaintenance, _ as PendingMigrationWork, $ as PendingSourceStatus, a0 as PromptOverrides, a1 as PromptService, a2 as PrunePartialFailureError, a3 as ReembedResult, a4 as RememberInput, a5 as RunPendingMaintenanceOptions, a6 as RunPendingMaintenanceResult, a7 as SupersedeReplacement, a8 as VectorRanker, a9 as VectorRankerFallback, aa as VectorRankerRankArgs, ab as VectorRankerSemanticResult, ac as WikiBusyError, ad as WikiBusyOperation, ae as WikiCheckpoint, af as WikiConfig, ag as WikiDiagnostic, ah as WikiDiagnosticCode, ai as WikiDiagnosticDetail, aj as WikiDiagnosticOperation, ak as WikiDiagnosticSeverity, al as WikiDiagnosticTrigger, am as WikiDraftNotFound, an as WikiDuplicateHashError, ao as WikiEdge, ap as WikiEvent, aq as WikiFact, ar as WikiGraphNodeOwnershipConflict, as as WikiIngestEmptyError, at as WikiInstructions, au as WikiInvalidReadOptions, av as WikiLintReport, aw as WikiMemoryTestAccess, ax as WikiMigrationRequiredError, ay as WikiOutboxEvent, az as WikiParseError, aA as WikiSearchUnavailableError, aB as WikiSourceRefHashCollision, aC as WikiStrictOntologyViolation, aD as WikiSupersedeError, aE as WikiSupersedeReason, aF as WikiTask, aG as WikiTransactionError, aH as isWikiSearchUnavailableError, aI as validateManifest } from './testing-BT5qSnGB.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
|
|
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-BT5qSnGB.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 ForgetParams, r as ForgetResult, s as GraphTraversalOptions, t as GroundingConfig, H as HEAL_BATCH_SIZE, u as HEAL_RECHECK_MS, v as HOOK_TIMEOUT_MARKER, w as HealResult, I as IngestDocumentResult, L as LLMProvider, x as LibrarianConfig, y as LibrarianGateConfig, z as MaintenanceJob, A as MaintenanceStopReason, B as MigrationPolicy, O as ONTOLOGY_BACKFILL_BATCH_SIZE, J as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, K as ONTOLOGY_BACKFILL_RECHECK_MS, N as OntologyBackfillResult, P as OntologyConfig, Q as OntologyEdgeType, T as OntologyManifest, U as OntologyMode, V as OntologyNodeType, X as OntologyPromptContext, Y as OntologyUpdates, Z as PendingMaintenance, _ as PendingMigrationWork, $ as PendingSourceStatus, a0 as PromptOverrides, a1 as PromptService, a2 as PrunePartialFailureError, a3 as ReembedResult, a4 as RememberInput, a5 as RunPendingMaintenanceOptions, a6 as RunPendingMaintenanceResult, a7 as SupersedeReplacement, a8 as VectorRanker, a9 as VectorRankerFallback, aa as VectorRankerRankArgs, ab as VectorRankerSemanticResult, ac as WikiBusyError, ad as WikiBusyOperation, ae as WikiCheckpoint, af as WikiConfig, ag as WikiDiagnostic, ah as WikiDiagnosticCode, ai as WikiDiagnosticDetail, aj as WikiDiagnosticOperation, ak as WikiDiagnosticSeverity, al as WikiDiagnosticTrigger, am as WikiDraftNotFound, an as WikiDuplicateHashError, ao as WikiEdge, ap as WikiEvent, aq as WikiFact, ar as WikiGraphNodeOwnershipConflict, as as WikiIngestEmptyError, at as WikiInstructions, au as WikiInvalidReadOptions, av as WikiLintReport, aw as WikiMemoryTestAccess, ax as WikiMigrationRequiredError, ay as WikiOutboxEvent, az as WikiParseError, aA as WikiSearchUnavailableError, aB as WikiSourceRefHashCollision, aC as WikiStrictOntologyViolation, aD as WikiSupersedeError, aE as WikiSupersedeReason, aF as WikiTask, aG as WikiTransactionError, aH as isWikiSearchUnavailableError, aI as validateManifest } from './testing-BT5qSnGB.js';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.js
CHANGED
|
@@ -3137,6 +3137,19 @@ var SourceRefIndexRepository = class extends BaseRepository {
|
|
|
3137
3137
|
[generateId("sri_"), entityId, sourceHash, sourceRef, Date.now()]
|
|
3138
3138
|
);
|
|
3139
3139
|
}
|
|
3140
|
+
/**
|
|
3141
|
+
* Hard-delete every row of the entity, live or soft-deleted (forget clearAll,
|
|
3142
|
+
* spec import-followups §6 rev 4). Nothing reads a soft-deleted row and
|
|
3143
|
+
* runPrune never sweeps this table, so a wipe leaves no tombstones.
|
|
3144
|
+
*/
|
|
3145
|
+
async deleteByEntityId(entityId, tx) {
|
|
3146
|
+
const executor = this.getExecutor(tx);
|
|
3147
|
+
const result = await executor.runAsync(
|
|
3148
|
+
`DELETE FROM ${this.prefix}source_ref_index WHERE entity_id = ?`,
|
|
3149
|
+
[entityId]
|
|
3150
|
+
);
|
|
3151
|
+
return result.changes;
|
|
3152
|
+
}
|
|
3140
3153
|
/**
|
|
3141
3154
|
* Idempotent soft-delete of the live row for (entity_id, source_ref).
|
|
3142
3155
|
* Called at the start of every ingestDocument to remove the prior run's
|
|
@@ -3579,6 +3592,10 @@ var EventRepository = class extends BaseRepository {
|
|
|
3579
3592
|
);
|
|
3580
3593
|
return rows.map(mapEvent);
|
|
3581
3594
|
}
|
|
3595
|
+
/** Hard-delete every event of the entity, read or not (requested wipe, spec import-followups §6). */
|
|
3596
|
+
async deleteByEntityId(entityId, tx) {
|
|
3597
|
+
return tx.runAsync(`DELETE FROM ${this.prefix}events WHERE entity_id = ?`, [entityId]);
|
|
3598
|
+
}
|
|
3582
3599
|
/**
|
|
3583
3600
|
* Delete events for an entity that were created at or before the given cutoff timestamp.
|
|
3584
3601
|
* Returns the number of deleted rows.
|
|
@@ -7613,7 +7630,9 @@ async function runExtract(deps, ctx, batch) {
|
|
|
7613
7630
|
const base = { entityId, operation: "librarian", trigger };
|
|
7614
7631
|
const diagnostics = [];
|
|
7615
7632
|
const byLabel = new Map(batch.map((l) => [l.label, l]));
|
|
7616
|
-
|
|
7633
|
+
let newestAt = batch[0].at;
|
|
7634
|
+
for (const l of batch) if (l.at > newestAt) newestAt = l.at;
|
|
7635
|
+
const defaultValidFrom = Math.min(newestAt, Date.now());
|
|
7617
7636
|
const candidates = [];
|
|
7618
7637
|
(Array.isArray(parsed.facts) ? parsed.facts : []).forEach((raw, index) => {
|
|
7619
7638
|
const fact = validateFact(raw);
|
|
@@ -7623,7 +7642,7 @@ async function runExtract(deps, ctx, batch) {
|
|
|
7623
7642
|
}
|
|
7624
7643
|
const r = raw;
|
|
7625
7644
|
const sourceLabel = typeof r.source_event === "string" && byLabel.has(r.source_event) ? r.source_event : null;
|
|
7626
|
-
const validFrom = parseValidFrom(r.valid_from) ?? (sourceLabel ? byLabel.get(sourceLabel).at :
|
|
7645
|
+
const validFrom = parseValidFrom(r.valid_from) ?? (sourceLabel ? byLabel.get(sourceLabel).at : defaultValidFrom);
|
|
7627
7646
|
candidates.push({ index, fact, sourceLabel, validFrom });
|
|
7628
7647
|
});
|
|
7629
7648
|
const tasks = [];
|
|
@@ -8193,7 +8212,7 @@ var formatSkipError = (err) => {
|
|
|
8193
8212
|
return base;
|
|
8194
8213
|
};
|
|
8195
8214
|
var MaintenanceService = class {
|
|
8196
|
-
constructor(db, prefix, options, entryRepo, sourceRefIndexRepo, taskRepo, eventRepo, metadataRepo, searchService, jobManager, embeddingService, promptService, ontologyService) {
|
|
8215
|
+
constructor(db, prefix, options, entryRepo, sourceRefIndexRepo, taskRepo, eventRepo, metadataRepo, searchService, jobManager, embeddingService, promptService, ontologyService, edgeRepo) {
|
|
8197
8216
|
this.db = db;
|
|
8198
8217
|
this.prefix = prefix;
|
|
8199
8218
|
this.options = options;
|
|
@@ -8207,6 +8226,7 @@ var MaintenanceService = class {
|
|
|
8207
8226
|
this.embeddingService = embeddingService;
|
|
8208
8227
|
this.ontologyService = ontologyService;
|
|
8209
8228
|
this.promptService = promptService ?? new PromptService(this.options.config?.prompts, resolveGrounding(this.options.config?.grounding));
|
|
8229
|
+
this.edgeRepo = edgeRepo ?? new EdgeRepository(this.db, this.prefix);
|
|
8210
8230
|
}
|
|
8211
8231
|
async runPrune(entityId, options) {
|
|
8212
8232
|
this.jobManager.acquireLock("prune", entityId);
|
|
@@ -8437,6 +8457,9 @@ var MaintenanceService = class {
|
|
|
8437
8457
|
if (params.clearAll && (params.entryId !== void 0 || params.taskId !== void 0 || params.sourceRef !== void 0 || params.sourceHash !== void 0)) {
|
|
8438
8458
|
throw new Error("forget() clearAll is mutually exclusive with entryId, taskId, sourceRef, and sourceHash");
|
|
8439
8459
|
}
|
|
8460
|
+
if (params.includeEvents && !params.clearAll) {
|
|
8461
|
+
throw new Error("forget() includeEvents requires clearAll: true");
|
|
8462
|
+
}
|
|
8440
8463
|
if (opts?.dryRun === true) {
|
|
8441
8464
|
return this.forgetDryRun(entityId, params);
|
|
8442
8465
|
}
|
|
@@ -8445,13 +8468,23 @@ var MaintenanceService = class {
|
|
|
8445
8468
|
const now = Date.now();
|
|
8446
8469
|
let deletedEntries = 0;
|
|
8447
8470
|
let deletedTasks = 0;
|
|
8471
|
+
let deletedEvents = 0;
|
|
8448
8472
|
const deletedEntryIds = [];
|
|
8449
8473
|
await this.db.withTransactionAsync(async (tx) => {
|
|
8450
8474
|
if (params.clearAll) {
|
|
8451
|
-
|
|
8475
|
+
for (const id of await this.entryRepo.findIdsBySource(entityId, null, null, tx, true)) deletedEntryIds.push(id);
|
|
8452
8476
|
deletedEntries = await this.entryRepo.bulkSoftDeleteByEntityId(entityId, tx);
|
|
8453
8477
|
deletedTasks = await this.taskRepo.bulkSoftDeleteByEntityId(entityId, tx);
|
|
8454
|
-
await this.
|
|
8478
|
+
if (await this.sourceRefIndexPresent(tx)) {
|
|
8479
|
+
await this.sourceRefIndexRepo.deleteByEntityId(entityId, tx);
|
|
8480
|
+
}
|
|
8481
|
+
await this.edgeRepo.bulkDeleteByEntityId(entityId, tx);
|
|
8482
|
+
if (params.includeEvents) {
|
|
8483
|
+
deletedEvents = (await this.eventRepo.deleteByEntityId(entityId, tx)).changes;
|
|
8484
|
+
await this.metadataRepo.deleteCheckpoint(entityId, tx);
|
|
8485
|
+
} else {
|
|
8486
|
+
await this.metadataRepo.updateCheckpoint(entityId, { memory: 0, heal: 0 }, tx);
|
|
8487
|
+
}
|
|
8455
8488
|
await this.metadataRepo.deleteMeta(entitySummaryMetaKey(entityId), tx);
|
|
8456
8489
|
} else {
|
|
8457
8490
|
const hasIdSelectors = params.entryId !== void 0 || params.taskId !== void 0;
|
|
@@ -8469,7 +8502,7 @@ var MaintenanceService = class {
|
|
|
8469
8502
|
if (entryId) deletedEntryIds.push(entryId);
|
|
8470
8503
|
}
|
|
8471
8504
|
if (sourceRef || sourceHash) {
|
|
8472
|
-
|
|
8505
|
+
for (const id of await this.entryRepo.findIdsBySource(entityId, sourceRef, sourceHash, tx, true)) deletedEntryIds.push(id);
|
|
8473
8506
|
}
|
|
8474
8507
|
const entryPromise = params.entryId ? this.entryRepo.softDelete(params.entryId, entityId, tx).then((r) => r.changes > 0) : null;
|
|
8475
8508
|
const taskDeletedPromise = params.taskId ? this.taskRepo.softDeleteById(params.taskId, entityId, tx).then((r) => r.changes > 0) : null;
|
|
@@ -8503,7 +8536,8 @@ var MaintenanceService = class {
|
|
|
8503
8536
|
throw new Error(`forget(${entityId}/${factId}) failed: ANN cleanup hook rejected`, { cause: this._sanitizeRankerError(hookErr) });
|
|
8504
8537
|
}
|
|
8505
8538
|
}
|
|
8506
|
-
|
|
8539
|
+
if (!params.clearAll) return { deleted: { entries: deletedEntries, tasks: deletedTasks } };
|
|
8540
|
+
return params.includeEvents ? { deleted: { entries: deletedEntries, tasks: deletedTasks, events: deletedEvents }, metadataReset: true } : { deleted: { entries: deletedEntries, tasks: deletedTasks }, metadataReset: true };
|
|
8507
8541
|
} finally {
|
|
8508
8542
|
this.jobManager.releaseLock("forget", entityId);
|
|
8509
8543
|
}
|
|
@@ -8554,6 +8588,10 @@ var MaintenanceService = class {
|
|
|
8554
8588
|
if (params.clearAll) {
|
|
8555
8589
|
const entries2 = await this.entryRepo.countLiveByEntityId(entityId);
|
|
8556
8590
|
const tasks = await this.taskRepo.countLiveByEntityId(entityId);
|
|
8591
|
+
if (params.includeEvents) {
|
|
8592
|
+
const events = await this.eventRepo.count(entityId);
|
|
8593
|
+
return { deleted: { entries: entries2, tasks, events }, metadataReset: true };
|
|
8594
|
+
}
|
|
8557
8595
|
return { deleted: { entries: entries2, tasks }, metadataReset: true };
|
|
8558
8596
|
}
|
|
8559
8597
|
const sourceRef = params.sourceRef !== void 0 ? normalizeSourceRef(params.sourceRef) : null;
|
|
@@ -9913,7 +9951,19 @@ var ImportExportService = class {
|
|
|
9913
9951
|
tags: Array.isArray(fact.tags) || typeof fact.tags === "string" ? fact.tags : []
|
|
9914
9952
|
}, { operation: "importDump", trigger: "call" });
|
|
9915
9953
|
if (!embedded) {
|
|
9916
|
-
|
|
9954
|
+
try {
|
|
9955
|
+
await this.embeddingService.notifyEmbeddingPersisted(entityId, fact.id, null);
|
|
9956
|
+
} catch (hookErr) {
|
|
9957
|
+
console.warn(
|
|
9958
|
+
`[WikiMemory] onEmbeddingPersisted hook failed for unembedded fact ${fact.id}:`,
|
|
9959
|
+
hookErr
|
|
9960
|
+
);
|
|
9961
|
+
this.embeddingService.reportHookFailed(
|
|
9962
|
+
{ operation: "importDump", trigger: "call" },
|
|
9963
|
+
entityId,
|
|
9964
|
+
fact.id
|
|
9965
|
+
);
|
|
9966
|
+
}
|
|
9917
9967
|
}
|
|
9918
9968
|
}
|
|
9919
9969
|
}
|
|
@@ -11921,7 +11971,8 @@ var WikiMemory = class {
|
|
|
11921
11971
|
this.jobManager,
|
|
11922
11972
|
this.embeddingService,
|
|
11923
11973
|
this.promptService,
|
|
11924
|
-
this.ontologyService
|
|
11974
|
+
this.ontologyService,
|
|
11975
|
+
this.edgeRepo
|
|
11925
11976
|
);
|
|
11926
11977
|
this.maintenanceScheduler = new MaintenanceScheduler(
|
|
11927
11978
|
this.db,
|
|
@@ -12434,6 +12485,16 @@ var WikiMemory = class {
|
|
|
12434
12485
|
async importDump(dump, opts) {
|
|
12435
12486
|
return this.importExportService.importDump(dump, opts);
|
|
12436
12487
|
}
|
|
12488
|
+
/**
|
|
12489
|
+
* Soft-delete facts and tasks by id, by source, or all of them (`clearAll`).
|
|
12490
|
+
* `clearAll` also deletes the entity's edges and its source-ref index rows.
|
|
12491
|
+
* Add `includeEvents: true` to `clearAll` to hard-delete every event too,
|
|
12492
|
+
* read or not, and reset the librarian's position: without it a later
|
|
12493
|
+
* maintenance run can read the events into facts again. `runPrune()` then
|
|
12494
|
+
* hard-deletes the soft-deleted rows once they are older than
|
|
12495
|
+
* `retainSoftDeletedFor` (7 days by default; pass 0 to remove them now).
|
|
12496
|
+
* `dryRun` previews the counts.
|
|
12497
|
+
*/
|
|
12437
12498
|
async forget(entityId, params, opts) {
|
|
12438
12499
|
return this.maintenanceService.forget(entityId, params, opts);
|
|
12439
12500
|
}
|
|
@@ -13360,6 +13421,24 @@ function parseStaleAfterRaw(raw) {
|
|
|
13360
13421
|
}
|
|
13361
13422
|
return ms;
|
|
13362
13423
|
}
|
|
13424
|
+
function replaceLoneSurrogates(s) {
|
|
13425
|
+
let out = "";
|
|
13426
|
+
for (let i = 0; i < s.length; i++) {
|
|
13427
|
+
const c = s.charCodeAt(i);
|
|
13428
|
+
if (c >= 55296 && c <= 56319) {
|
|
13429
|
+
const n = i + 1 < s.length ? s.charCodeAt(i + 1) : 0;
|
|
13430
|
+
if (n >= 56320 && n <= 57343) {
|
|
13431
|
+
out += s[i] + s[i + 1];
|
|
13432
|
+
i++;
|
|
13433
|
+
} else out += "\uFFFD";
|
|
13434
|
+
} else if (c >= 56320 && c <= 57343) {
|
|
13435
|
+
out += "\uFFFD";
|
|
13436
|
+
} else {
|
|
13437
|
+
out += s[i];
|
|
13438
|
+
}
|
|
13439
|
+
}
|
|
13440
|
+
return out;
|
|
13441
|
+
}
|
|
13363
13442
|
function unescapeLogSummary(summary) {
|
|
13364
13443
|
return summary.replace(/\\\]/g, "]").replace(/\\\[/g, "[").replace(/\\\\/g, "\\");
|
|
13365
13444
|
}
|
|
@@ -13372,7 +13451,7 @@ function parseLogEntryText(text) {
|
|
|
13372
13451
|
if (linkPath) {
|
|
13373
13452
|
return { event_type, summary: unescapeLogSummary(linkedSummary), linkPath };
|
|
13374
13453
|
}
|
|
13375
|
-
return { event_type, summary: (plainSummary ?? "").trim() };
|
|
13454
|
+
return { event_type, summary: unescapeLogSummary((plainSummary ?? "").trim()) };
|
|
13376
13455
|
}
|
|
13377
13456
|
function frontmatterToFact(entityId, id, frontmatter, body, now) {
|
|
13378
13457
|
const created_at = parseFrontmatterTimestamp(frontmatter.created_at, now);
|
|
@@ -13584,6 +13663,7 @@ function parseOkfBundle(entityId, files, options) {
|
|
|
13584
13663
|
}
|
|
13585
13664
|
const events = [];
|
|
13586
13665
|
if (logContent != null) {
|
|
13666
|
+
const pending = [];
|
|
13587
13667
|
const logPath = logMdPath ?? `entities/${entityId}/log.md`;
|
|
13588
13668
|
for (const entry of coreOkf.parseLogMd(logContent)) {
|
|
13589
13669
|
const { text, eventId } = coreOkf.parseEventIdComment(entry.text);
|
|
@@ -13601,8 +13681,9 @@ function parseOkfBundle(entityId, files, options) {
|
|
|
13601
13681
|
}
|
|
13602
13682
|
const created_at = (/* @__PURE__ */ new Date(`${entry.date}T00:00:00.000Z`)).getTime();
|
|
13603
13683
|
if (!Number.isFinite(created_at)) continue;
|
|
13684
|
+
if (eventId === void 0) pending.push({ index: events.length, date: entry.date });
|
|
13604
13685
|
events.push({
|
|
13605
|
-
id: eventId ??
|
|
13686
|
+
id: eventId ?? "",
|
|
13606
13687
|
entity_id: entityId,
|
|
13607
13688
|
event_type: parsed.event_type,
|
|
13608
13689
|
summary: parsed.summary,
|
|
@@ -13610,6 +13691,22 @@ function parseOkfBundle(entityId, files, options) {
|
|
|
13610
13691
|
created_at
|
|
13611
13692
|
});
|
|
13612
13693
|
}
|
|
13694
|
+
const taken = new Set(events.map((e) => e.id).filter((id) => id !== ""));
|
|
13695
|
+
const nextOccurrence = /* @__PURE__ */ new Map();
|
|
13696
|
+
for (const { index, date } of pending) {
|
|
13697
|
+
const e = events[index];
|
|
13698
|
+
const key = JSON.stringify([date, e.event_type, replaceLoneSurrogates(e.summary)]);
|
|
13699
|
+
let occurrence = nextOccurrence.get(key) ?? 0;
|
|
13700
|
+
const derive = coreOkf.createEventIdDeriver({ entityId, date, eventType: e.event_type, summary: e.summary });
|
|
13701
|
+
let id = derive(occurrence);
|
|
13702
|
+
while (taken.has(id)) {
|
|
13703
|
+
occurrence += 1;
|
|
13704
|
+
id = derive(occurrence);
|
|
13705
|
+
}
|
|
13706
|
+
taken.add(id);
|
|
13707
|
+
nextOccurrence.set(key, occurrence + 1);
|
|
13708
|
+
e.id = id;
|
|
13709
|
+
}
|
|
13613
13710
|
}
|
|
13614
13711
|
return {
|
|
13615
13712
|
generatedAt: now,
|