@equationalapplications/core-llm-wiki 9.17.0 → 9.18.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/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { BaseRepository, WikiGraphNodeOwnershipConflict, serializeSourcePointer, serializeDerivedEvents, parseStoredDerivedEvents, parseStoredSourcePointer, parseJsonObject, parseJsonArray, liveAtSql, reanchorRebuildFingerprint, __privateAdd, warnChangedDefaultsOnce, resolveContextBudgetOrThrow, EdgeRepository, MetadataRepository, EmbeddingService, VectorRemovalRepository, VectorRemovalService, SearchService, TemporalService, JobManager, PromptService, resolveGrounding, IngestionService, MaintenanceService, ImportExportService, RetrievalService, SourceStoreService, WriteService, __privateGet, __privateSet, createLegacySourceTypeIndex, createEntriesDeletedIndex, writeNormalizeStamp, CURRENT_SCHEMA_VERSION, detectSchemaVersion, MIGRATIONS, runSourceRefNormalize, emitDiagnostic, normalizeSourceRef, normalizeSourceHash, canEngageWriteTyping, canEngageIngestTyping, resolveLibrarianStrategy, entitySummaryMetaKey, WikiSourceRefHashCollision, DiagnosticBuffer, validateManifest, isReservedAbstainSlug, ONTOLOGY_ABSTAIN_SENTINEL, WikiDraftNotFound, generateId, emptyManifest, resolveNodeTypeMatch, WikiStrictOntologyViolation, validateInlineEdges, resolveEdgeDefinitions, typeSatisfies, normalizeTitleKey, edgeTripleAllowed, resolveNodeType, shouldEmitOntologyReceipt, nodeTypeReceipts, MAX_EMBED_ATTEMPTS, UsageMeter, isWikiSearchUnavailableError, WikiBusyError, WikiInvalidReadOptions, isLiveAt, packFactsByBudget, factTokenCost, probePendingWork, WikiMigrationRequiredError, setupDatabase, UnavailableIndexStrategy, createdAtValue, isUsableDate, validateDerivedEventsValue, validateSourcePointerValue, assertEntityId, assertEpochMs, passageFtsTriggerNames, FTS5_STATE_KEY, fts5LedgerDropSql, passageFtsTablesDdl, passageFtsTriggersDdl, fts5TablesDdl, fts5PendingIndexesDdl, fts5TriggersDdl, writeRebuildStart, FTS5_RETIRED_COUNTER_KEY, retiredTableName, FTS5_RETIRED_TABLES_KEY, isRetiredTableName, idReindexChunkSql, readRebuildProgress, FTS5_DRAIN_CHUNK, FTS5_RECLAIM_MERGE_PAGES, windowHiSql, windowChunkSql, FTS5_REBUILD_WM_KEY, sweepHiSql, sweepChunkSql, FTS5_SWEEP_CURSOR_KEY, drainHiSql, drainChunkSql, FTS5_REBUILD_SNAPSHOT_KEY, idDrainChunkSql, entityDrainHiSql, entityDrainChunkSql, fts5TriggerNames, extractSqliteCode, WikiTransactionError } from './chunk-QRGFHMFR.mjs';
2
- export { CLASSIFIER_MAX_CHOICES, CheckpointIncompleteError, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_TYPING_MIN_CONFIDENCE, EMBED_CHARS_CEILING, EraseStepError, HEAL_ANCHORS_PER_CANDIDATE, HEAL_BATCH_SIZE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, HEAL_RECHECK_MS, HOOK_TIMEOUT_MARKER, ONTOLOGY_ABSTAIN_SENTINEL, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiExternalDeletionError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, chunkText, configureRandomSource, isReservedAbstainSlug, isWikiSearchUnavailableError, parseEmbedding, resolveContextBudget, resolveDefaultChunkLength, resolveEdgesMinConfidence, resolveHealScreenMinConfidence, resolveMaxPromptChars, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneHealScreen, resolveSystemOneResolve, resolveSystemOneTypeOnIngest, resolveSystemOneTypeOnWrite, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateManifest, warnOnce } from './chunk-QRGFHMFR.mjs';
1
+ import { BaseRepository, WikiGraphNodeOwnershipConflict, serializeSourcePointer, serializeDerivedEvents, parseStoredDerivedEvents, parseStoredSourcePointer, parseJsonObject, parseJsonArray, liveAtSql, reanchorRebuildFingerprint, __privateAdd, warnChangedDefaultsOnce, resolveContextBudgetOrThrow, EdgeRepository, MetadataRepository, EmbeddingService, VectorRemovalRepository, VectorRemovalService, SearchService, TemporalService, JobManager, PromptService, resolveGrounding, IngestionService, MaintenanceService, ImportExportService, RetrievalService, SourceStoreService, WriteService, __privateGet, __privateSet, createLegacySourceTypeIndex, createEntriesDeletedIndex, createEventsForgottenIndex, writeNormalizeStamp, CURRENT_SCHEMA_VERSION, detectSchemaVersion, MIGRATIONS, runSourceRefNormalize, emitDiagnostic, normalizeSourceRef, normalizeSourceHash, canEngageWriteTyping, canEngageIngestTyping, resolveLibrarianStrategy, entitySummaryMetaKey, WikiSourceRefHashCollision, DiagnosticBuffer, validateManifest, isReservedAbstainSlug, ONTOLOGY_ABSTAIN_SENTINEL, WikiDraftNotFound, generateId, emptyManifest, resolveNodeTypeMatch, WikiStrictOntologyViolation, validateInlineEdges, resolveEdgeDefinitions, typeSatisfies, normalizeTitleKey, edgeTripleAllowed, resolveNodeType, shouldEmitOntologyReceipt, nodeTypeReceipts, MAX_EMBED_ATTEMPTS, UsageMeter, isWikiSearchUnavailableError, WikiBusyError, WikiInvalidReadOptions, isLiveAt, packFactsByBudget, factTokenCost, probePendingWork, WikiMigrationRequiredError, setupDatabase, UnavailableIndexStrategy, createdAtValue, isUsableDate, validateDerivedEventsValue, validateSourcePointerValue, assertEntityId, assertEpochMs, passageFtsTriggerNames, FTS5_STATE_KEY, fts5LedgerDropSql, passageFtsTablesDdl, passageFtsTriggersDdl, fts5TablesDdl, fts5PendingIndexesDdl, fts5TriggersDdl, writeRebuildStart, FTS5_RETIRED_COUNTER_KEY, retiredTableName, FTS5_RETIRED_TABLES_KEY, isRetiredTableName, idReindexChunkSql, readRebuildProgress, FTS5_DRAIN_CHUNK, FTS5_RECLAIM_MERGE_PAGES, windowHiSql, windowChunkSql, FTS5_REBUILD_WM_KEY, sweepHiSql, sweepChunkSql, FTS5_SWEEP_CURSOR_KEY, drainHiSql, drainChunkSql, FTS5_REBUILD_SNAPSHOT_KEY, idDrainChunkSql, entityDrainHiSql, entityDrainChunkSql, fts5TriggerNames, extractSqliteCode, WikiTransactionError } from './chunk-FX4J6MLA.mjs';
2
+ export { CLASSIFIER_MAX_CHOICES, CheckpointIncompleteError, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_TYPING_MIN_CONFIDENCE, EMBED_CHARS_CEILING, EraseStepError, HEAL_ANCHORS_PER_CANDIDATE, HEAL_BATCH_SIZE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, HEAL_RECHECK_MS, HOOK_TIMEOUT_MARKER, ONTOLOGY_ABSTAIN_SENTINEL, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiExternalDeletionError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, chunkText, configureRandomSource, isReservedAbstainSlug, isWikiSearchUnavailableError, parseEmbedding, resolveContextBudget, resolveDefaultChunkLength, resolveEdgesMinConfidence, resolveHealScreenMinConfidence, resolveMaxPromptChars, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneHealScreen, resolveSystemOneResolve, resolveSystemOneTypeOnIngest, resolveSystemOneTypeOnWrite, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateManifest, warnOnce } from './chunk-FX4J6MLA.mjs';
3
3
  import { deriveTrustTier, isStaleAfter, appendRelatedSection, buildConceptDocument, buildLogMd, buildEntityIndexMd, buildRootIndexMd, isAllowedOkfPath, parseRootIndexMd, parseEntityIndexMd, parseConcept, splitRelatedSection, extractMarkdownLinks, parseLogMd, parseEventIdComment, createEventIdDeriver, latestVerified, formatSourcesJson, appendEventIdComment, parseVerifiedFlexible, parseCitationsList } from '@equationalapplications/core-okf';
4
4
  import MiniSearch from 'minisearch';
5
5
 
@@ -2136,12 +2136,13 @@ function afterArgs(wm) {
2136
2136
  return [wm.at, wm.at, wm.id];
2137
2137
  }
2138
2138
  function mapEvent(row) {
2139
- if (row.occurred_at == null) {
2140
- const rest = { ...row };
2141
- delete rest.occurred_at;
2142
- return rest;
2143
- }
2144
- return row;
2139
+ const dropOccurred = row.occurred_at == null;
2140
+ const dropForgotten = row.forgotten_at == null;
2141
+ if (!dropOccurred && !dropForgotten) return row;
2142
+ const rest = { ...row };
2143
+ if (dropOccurred) delete rest.occurred_at;
2144
+ if (dropForgotten) delete rest.forgotten_at;
2145
+ return rest;
2145
2146
  }
2146
2147
  var EventRepository = class extends BaseRepository {
2147
2148
  /**
@@ -2168,8 +2169,8 @@ var EventRepository = class extends BaseRepository {
2168
2169
  async addIgnoreDuplicate(event, tx) {
2169
2170
  const executor = this.getExecutor(tx);
2170
2171
  const result = await executor.runAsync(
2171
- `INSERT OR IGNORE INTO ${this.prefix}events (id, entity_id, event_type, summary, related_entry_id, created_at, occurred_at)
2172
- VALUES (?, ?, ?, ?, ?, ?, ?)`,
2172
+ `INSERT OR IGNORE INTO ${this.prefix}events (id, entity_id, event_type, summary, related_entry_id, created_at, occurred_at, forgotten_at)
2173
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
2173
2174
  [
2174
2175
  event.id,
2175
2176
  event.entity_id,
@@ -2177,7 +2178,8 @@ var EventRepository = class extends BaseRepository {
2177
2178
  event.summary,
2178
2179
  event.related_entry_id ?? null,
2179
2180
  event.created_at,
2180
- event.occurred_at ?? null
2181
+ event.occurred_at ?? null,
2182
+ event.forgotten_at ?? null
2181
2183
  ]
2182
2184
  );
2183
2185
  return result.changes > 0;
@@ -2186,27 +2188,37 @@ var EventRepository = class extends BaseRepository {
2186
2188
  * The subset of `ids` that exist as events of `entityId` (specs/
2187
2189
  * inplace-update-provenance §3). Chunked so a large batch stays under the
2188
2190
  * bound-variable limit. Pass `tx` to read inside the caller's transaction.
2191
+ * `liveOnly` (default false) also requires `forgotten_at IS NULL`.
2189
2192
  */
2190
- async findExistingIds(entityId, ids, tx) {
2193
+ async findIds(entityId, ids, liveOnly, tx) {
2191
2194
  const executor = this.getExecutor(tx);
2192
2195
  const found = /* @__PURE__ */ new Set();
2196
+ const live = liveOnly ? " AND forgotten_at IS NULL" : "";
2193
2197
  for (let i = 0; i < ids.length; i += 500) {
2194
2198
  const chunk = ids.slice(i, i + 500);
2195
2199
  const rows = await executor.getAllAsync(
2196
- `SELECT id FROM ${this.prefix}events WHERE entity_id = ? AND id IN (${chunk.map(() => "?").join(",")})`,
2200
+ `SELECT id FROM ${this.prefix}events WHERE entity_id = ? AND id IN (${chunk.map(() => "?").join(",")})${live}`,
2197
2201
  [entityId, ...chunk]
2198
2202
  );
2199
2203
  for (const r of rows) found.add(r.id);
2200
2204
  }
2201
2205
  return found;
2202
2206
  }
2207
+ /** Events that exist as rows, forgotten or not (apply re-check's gone-vs-forgotten probe, specs/forget-event-exclusion §4). */
2208
+ async findExistingIds(entityId, ids, tx) {
2209
+ return this.findIds(entityId, ids, false, tx);
2210
+ }
2211
+ /** Events that exist and are not forgotten (specs/forget-event-exclusion §4). */
2212
+ async findLiveIds(entityId, ids, tx) {
2213
+ return this.findIds(entityId, ids, true, tx);
2214
+ }
2203
2215
  /**
2204
2216
  * Return the most recent events for an entity, newest first.
2205
2217
  * Defaults to a limit of 50.
2206
2218
  */
2207
2219
  async getRecent(entityId, limit = 50) {
2208
2220
  const rows = await this.db.getAllAsync(
2209
- `SELECT * FROM ${this.prefix}events WHERE entity_id = ? ORDER BY created_at DESC LIMIT ?`,
2221
+ `SELECT * FROM ${this.prefix}events WHERE entity_id = ? AND forgotten_at IS NULL ORDER BY created_at DESC LIMIT ?`,
2210
2222
  [entityId, limit]
2211
2223
  );
2212
2224
  return rows.map(mapEvent);
@@ -2219,7 +2231,7 @@ var EventRepository = class extends BaseRepository {
2219
2231
  if (entityIds.length === 0) return [];
2220
2232
  const placeholders = entityIds.map(() => "?").join(", ");
2221
2233
  const rows = await this.db.getAllAsync(
2222
- `SELECT * FROM ${this.prefix}events WHERE entity_id IN (${placeholders}) ORDER BY created_at DESC LIMIT ?`,
2234
+ `SELECT * FROM ${this.prefix}events WHERE entity_id IN (${placeholders}) AND forgotten_at IS NULL ORDER BY created_at DESC LIMIT ?`,
2223
2235
  [...entityIds, limit]
2224
2236
  );
2225
2237
  return rows.map(mapEvent);
@@ -2260,7 +2272,7 @@ var EventRepository = class extends BaseRepository {
2260
2272
  async countHeldBack(entityId, cutoff, wm) {
2261
2273
  const where = wm ? ` AND ${AFTER_SQL}` : "";
2262
2274
  const row = await this.db.getFirstAsync(
2263
- `SELECT COUNT(*) AS n FROM ${this.prefix}events WHERE entity_id = ? AND created_at <= ?${where}`,
2275
+ `SELECT COUNT(*) AS n FROM ${this.prefix}events WHERE entity_id = ? AND created_at <= ? AND forgotten_at IS NULL${where}`,
2264
2276
  [entityId, cutoff, ...wm ? afterArgs(wm) : []]
2265
2277
  );
2266
2278
  return Number(row?.n ?? 0);
@@ -2293,16 +2305,17 @@ var EventRepository = class extends BaseRepository {
2293
2305
  * Return all events for an entity in chronological (ASC) order.
2294
2306
  * When limit is provided, fetches newest-first then reverses to preserve chronological order.
2295
2307
  */
2296
- async getByEntityId(entityId, limit) {
2308
+ async getByEntityId(entityId, limit, opts) {
2309
+ const live = opts?.includeDeleted ? "" : " AND forgotten_at IS NULL";
2297
2310
  if (limit != null) {
2298
2311
  const rows2 = await this.db.getAllAsync(
2299
- `SELECT * FROM ${this.prefix}events WHERE entity_id = ? ORDER BY created_at DESC LIMIT ?`,
2312
+ `SELECT * FROM ${this.prefix}events WHERE entity_id = ?${live} ORDER BY created_at DESC LIMIT ?`,
2300
2313
  [entityId, limit]
2301
2314
  );
2302
2315
  return rows2.map(mapEvent).slice().reverse();
2303
2316
  }
2304
2317
  const rows = await this.db.getAllAsync(
2305
- `SELECT * FROM ${this.prefix}events WHERE entity_id = ? ORDER BY created_at ASC`,
2318
+ `SELECT * FROM ${this.prefix}events WHERE entity_id = ?${live} ORDER BY created_at ASC`,
2306
2319
  [entityId]
2307
2320
  );
2308
2321
  return rows.map(mapEvent);
@@ -2317,7 +2330,7 @@ var EventRepository = class extends BaseRepository {
2317
2330
  async getAfter(entityId, wm, limit) {
2318
2331
  const limitClause = limit != null ? ` LIMIT ?` : "";
2319
2332
  const params = wm ? [entityId, wm.at, wm.at, wm.id] : [entityId];
2320
- const where = wm ? `entity_id = ? AND ${AFTER_SQL}` : `entity_id = ?`;
2333
+ const where = wm ? `entity_id = ? AND forgotten_at IS NULL AND ${AFTER_SQL}` : `entity_id = ? AND forgotten_at IS NULL`;
2321
2334
  if (limit != null) params.push(limit);
2322
2335
  const rows = await this.db.getAllAsync(
2323
2336
  `SELECT * FROM ${this.prefix}events WHERE ${where} ORDER BY created_at ASC, id ASC${limitClause}`,
@@ -2333,7 +2346,7 @@ var EventRepository = class extends BaseRepository {
2333
2346
  */
2334
2347
  async countAfter(entityId, wm) {
2335
2348
  const params = wm ? [entityId, wm.at, wm.at, wm.id] : [entityId];
2336
- const where = wm ? `entity_id = ? AND ${AFTER_SQL}` : `entity_id = ?`;
2349
+ const where = wm ? `entity_id = ? AND forgotten_at IS NULL AND ${AFTER_SQL}` : `entity_id = ? AND forgotten_at IS NULL`;
2337
2350
  const row = await this.db.getFirstAsync(
2338
2351
  `SELECT COUNT(*) as count FROM ${this.prefix}events WHERE ${where}`,
2339
2352
  params
@@ -2365,13 +2378,68 @@ var EventRepository = class extends BaseRepository {
2365
2378
  async sumSummaryCharsAfter(entityId, wm, tx) {
2366
2379
  const executor = this.getExecutor(tx);
2367
2380
  const params = wm ? [entityId, wm.at, wm.at, wm.id] : [entityId];
2368
- const where = wm ? `entity_id = ? AND ${AFTER_SQL}` : `entity_id = ?`;
2381
+ const where = wm ? `entity_id = ? AND forgotten_at IS NULL AND ${AFTER_SQL}` : `entity_id = ? AND forgotten_at IS NULL`;
2369
2382
  const row = await executor.getFirstAsync(
2370
2383
  `SELECT SUM(LENGTH(summary)) as total FROM ${this.prefix}events WHERE ${where}`,
2371
2384
  params
2372
2385
  );
2373
2386
  return row?.total ?? 0;
2374
2387
  }
2388
+ /**
2389
+ * Mark one event forgotten (specs/forget-event-exclusion §2). Entity scoped
2390
+ * (rule 3) and idempotent: an unknown id, another entity's id or an already
2391
+ * forgotten row changes nothing and reports 0.
2392
+ */
2393
+ async markForgotten(entityId, eventId, now, tx) {
2394
+ const r = await this.getExecutor(tx).runAsync(
2395
+ `UPDATE ${this.prefix}events SET forgotten_at = ? WHERE entity_id = ? AND id = ? AND forgotten_at IS NULL`,
2396
+ [now, entityId, eventId]
2397
+ );
2398
+ return r.changes > 0 ? 1 : 0;
2399
+ }
2400
+ /** 1 when the event exists for the entity and is not yet forgotten, else 0 (the forget dry run). */
2401
+ async countForgettable(entityId, eventId) {
2402
+ const row = await this.db.getFirstAsync(
2403
+ `SELECT COUNT(*) AS n FROM ${this.prefix}events WHERE entity_id = ? AND id = ? AND forgotten_at IS NULL`,
2404
+ [entityId, eventId]
2405
+ );
2406
+ return Number(row?.n ?? 0) > 0 ? 1 : 0;
2407
+ }
2408
+ /** True when `deleteForgotten` with the same arguments would delete at least one row. */
2409
+ async hasDeletableForgotten(entityId, cutoff, tx, opts) {
2410
+ const row = opts?.noCutoff ? await tx.getFirstAsync(`SELECT 1 AS x FROM ${this.prefix}events WHERE entity_id = ? AND forgotten_at IS NOT NULL LIMIT 1`, [entityId]) : await tx.getFirstAsync(`SELECT 1 AS x FROM ${this.prefix}events WHERE entity_id = ? AND forgotten_at IS NOT NULL AND forgotten_at <= ? LIMIT 1`, [entityId, cutoff]);
2411
+ return !!row;
2412
+ }
2413
+ /**
2414
+ * How many of the entity's first `n` events, in `(created_at, id)` order,
2415
+ * `deleteForgotten` with the same arguments would delete. The memory and
2416
+ * heal checkpoints count rows in that order, so this is exactly how far a
2417
+ * checkpoint must drop (specs/forget-event-exclusion §5). Call before the delete.
2418
+ */
2419
+ async countForgottenInPrefix(entityId, n, cutoff, tx, opts) {
2420
+ if (n <= 0) return 0;
2421
+ const pred = opts?.noCutoff ? "forgotten_at IS NOT NULL" : "forgotten_at IS NOT NULL AND forgotten_at <= ?";
2422
+ const row = await tx.getFirstAsync(
2423
+ `SELECT COUNT(*) AS n FROM (SELECT forgotten_at FROM ${this.prefix}events WHERE entity_id = ? ORDER BY created_at ASC, id ASC LIMIT ?) WHERE ${pred}`,
2424
+ opts?.noCutoff ? [entityId, Math.trunc(n)] : [entityId, Math.trunc(n), cutoff]
2425
+ );
2426
+ return Number(row?.n ?? 0);
2427
+ }
2428
+ /**
2429
+ * Hard-delete the entity's forgotten events (specs/forget-event-exclusion
2430
+ * §5). No watermark guard and no `retainEventsFor`: a forgotten row is never
2431
+ * read. `noCutoff` drops the age predicate (erase) so a non-numeric or
2432
+ * future `forgotten_at` cannot escape.
2433
+ */
2434
+ async deleteForgotten(entityId, cutoff, tx, opts) {
2435
+ if (opts?.noCutoff) {
2436
+ return tx.runAsync(`DELETE FROM ${this.prefix}events WHERE entity_id = ? AND forgotten_at IS NOT NULL`, [entityId]);
2437
+ }
2438
+ return tx.runAsync(
2439
+ `DELETE FROM ${this.prefix}events WHERE entity_id = ? AND forgotten_at IS NOT NULL AND forgotten_at <= ?`,
2440
+ [entityId, cutoff]
2441
+ );
2442
+ }
2375
2443
  };
2376
2444
 
2377
2445
  // src/utils/monotonicNow.ts
@@ -4736,6 +4804,7 @@ var WikiMemory = class {
4736
4804
  await this.db.withTransactionAsync(async (tx) => {
4737
4805
  await createLegacySourceTypeIndex(tx, this.prefix);
4738
4806
  await createEntriesDeletedIndex(tx, this.prefix);
4807
+ await createEventsForgottenIndex(tx, this.prefix);
4739
4808
  await writeNormalizeStamp(this.metadataRepo, tx);
4740
4809
  await this.metadataRepo.setMeta("schema_version", String(CURRENT_SCHEMA_VERSION), tx);
4741
4810
  });
@@ -6121,7 +6190,7 @@ function conceptRelativePath(sourceFilePath, targetFilePath) {
6121
6190
  return targetFilePath.replace(/^entities\/[^/]+\//, "");
6122
6191
  }
6123
6192
  function buildEventLogEntries(events, factIdToFilename) {
6124
- return events.map((e) => {
6193
+ return events.filter((e) => e.forgotten_at == null).map((e) => {
6125
6194
  const factFilename = e.related_entry_id ? factIdToFilename.get(e.related_entry_id) : void 0;
6126
6195
  const summary = e.summary.replace(/\\/g, "\\\\").replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\r?\n/g, " ");
6127
6196
  const text = factFilename ? `(${e.event_type}) [${summary}](./facts/${factFilename}.md)` : `(${e.event_type}) ${summary}`;