@equationalapplications/core-llm-wiki 9.2.0 → 9.4.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.
@@ -862,13 +862,15 @@ type WikiDiagnosticSeverity = 'info' | 'warn' | 'error';
862
862
  * Closed for this release series, but new codes are added in minor versions:
863
863
  * hosts must tolerate codes they do not recognize.
864
864
  */
865
- type WikiDiagnosticCode = 'ingest_chunk_failed' | 'fact_rejected' | 'task_rejected' | 'fact_deduplicated' | 'edge_dropped' | 'embedding_failed' | 'hook_failed' | 'background_job_failed' | 'heal_skipped' | 'grounding_missing' | 'grounding_failed' | 'classification_low_confidence' | 'classification_invalid' | 'llm_usage' | 'librarian_gate' | 'librarian_op_rejected' | 'contradicts_document' | 'resolve_failed' | 'read_budget' | 'event_retention_held' | 'event_created_at_clamped' | 'event_created_at_restamped' | 'external_deletion_pending' | 'external_deletion_discarded' | 'guidance_too_long' | 'guidance_resolver_failed' | 'source_pointer_unresolved' | 'source_pointer_invalid' | 'source_store_source_too_large' | 'source_store_budget_exceeded' | 'source_store_hash_mismatch' | 'source_store_duplicate_hash' | 'source_store_text_not_storable';
865
+ type WikiDiagnosticCode = 'ingest_chunk_failed' | 'fact_rejected' | 'task_rejected' | 'fact_deduplicated' | 'edge_dropped' | 'embedding_failed' | 'hook_failed' | 'background_job_failed' | 'heal_skipped' | 'grounding_missing' | 'grounding_failed' | 'classification_low_confidence' | 'classification_invalid' | 'llm_usage' | 'librarian_gate' | 'librarian_op_rejected' | 'contradicts_document' | 'resolve_failed' | 'read_budget' | 'event_retention_held' | 'prune_checkpoint_incomplete' | 'erase_secure_delete_off' | 'erase_entity_skipped' | 'erase_retired_vtab_undroppable' | 'erase_fts_orphan_cleared' | 'erase_retired_remaining' | 'erase_tombstones_remaining' | 'erase_retired_read_failed' | 'erase_registry_sweep_skipped' | 'import_tombstone_skipped' | 'event_created_at_clamped' | 'event_created_at_restamped' | 'external_deletion_pending' | 'external_deletion_discarded' | 'guidance_too_long' | 'guidance_resolver_failed' | 'source_pointer_unresolved' | 'source_pointer_invalid' | 'source_store_source_too_large' | 'source_store_budget_exceeded' | 'source_store_hash_mismatch' | 'source_store_duplicate_hash' | 'source_store_text_not_storable';
866
866
  /** The service run that emitted the diagnostic. */
867
- type WikiDiagnosticOperation = 'ingest' | 'upsertGraph' | 'librarian' | 'heal' | 'ontologyBackfill' | 'reembed' | 'importDump' | 'write' | 'supersede' | 'remember' | 'read' | 'prune' | 'externalDeletion' | 'sourceStore';
867
+ type WikiDiagnosticOperation = 'ingest' | 'upsertGraph' | 'librarian' | 'heal' | 'ontologyBackfill' | 'reembed' | 'importDump' | 'write' | 'supersede' | 'remember' | 'read' | 'prune' | 'externalDeletion' | 'sourceStore' | 'erase';
868
868
  /** `'auto'` when a write threshold started the run (auto-librarian / auto-heal); `'call'` when the host did. */
869
869
  type WikiDiagnosticTrigger = 'call' | 'auto';
870
870
  /** Identifiers only — never titles, bodies, quotes, LLM output, provider messages, or hashes of content. */
871
871
  interface WikiDiagnosticDetail {
872
+ /** The FTS5 surface the diagnostic names. */
873
+ table?: string;
872
874
  factId?: string;
873
875
  sourceRef?: string;
874
876
  chunkIndex?: number;
@@ -911,6 +913,8 @@ interface WikiDiagnosticDetail {
911
913
  guidanceLength?: number;
912
914
  /** guidance_too_long only: which configured value was refused. */
913
915
  guidanceSource?: 'per_entity' | 'default';
916
+ /** `erase_retired_remaining` only: retired FTS table names still present after reclamation. */
917
+ tables?: string[];
914
918
  }
915
919
  interface WikiDiagnostic {
916
920
  code: WikiDiagnosticCode;
@@ -1162,8 +1166,12 @@ interface EntityStatus {
1162
1166
  * and `'forget'` were added in v3.0. `'ontologyBackfill'` was added afterward.
1163
1167
  * Exhaustive `switch` / narrowing on this type must be updated (or given a
1164
1168
  * `default` arm) to compile without errors.
1169
+ *
1170
+ * `'erase'` was added by a MINOR release (forget-erasure spec §2, ruling F).
1171
+ * Exhaustive switches over this type must add a `default` arm; widening this
1172
+ * union rides the MINOR by policy and does not recur as a breaking change.
1165
1173
  */
1166
- type WikiBusyOperation = 'ingest' | 'librarian' | 'heal' | 'prune' | 'reembed' | 'import' | 'forget' | 'ontologyBackfill' | 'store';
1174
+ type WikiBusyOperation = 'ingest' | 'librarian' | 'heal' | 'prune' | 'reembed' | 'import' | 'forget' | 'ontologyBackfill' | 'store' | 'erase';
1167
1175
  /**
1168
1176
  * Thrown when a background mutator is already running for the requested entity.
1169
1177
  */
@@ -1287,6 +1295,14 @@ declare class WikiTransactionError extends Error {
1287
1295
  /** Selectors for {@link WikiMemory.forget}. `clearAll` excludes the other selectors. */
1288
1296
  interface ForgetParams {
1289
1297
  entryId?: string;
1298
+ /**
1299
+ * With `entryId` only: also forget the entry's supersession chain (every
1300
+ * predecessor and successor reached by walking `superseded_by` links, capped
1301
+ * at 100 per direction). The walk is NOT the connected component: with
1302
+ * fan-in A→C←B, forgetting A reaches C but not B. The forward walk deletes
1303
+ * the live current fact. Does not compose with other selectors.
1304
+ */
1305
+ includeChain?: boolean;
1290
1306
  taskId?: string;
1291
1307
  sourceRef?: string;
1292
1308
  sourceHash?: string;
@@ -1307,6 +1323,12 @@ interface ForgetResult {
1307
1323
  events?: number;
1308
1324
  };
1309
1325
  metadataReset?: boolean;
1326
+ /** With `includeChain`: the chain ids forgotten alongside `entryId` (excludes `entryId`). */
1327
+ chainEntryIds?: string[];
1328
+ /** With `includeChain`: true when the walk hit the depth cap and the chain was cut short. */
1329
+ truncated?: boolean;
1330
+ /** Present with `truncated`: the depth-cap notice. */
1331
+ notice?: string;
1310
1332
  }
1311
1333
  /**
1312
1334
  * Thrown by `runPrune()` after it has finished its other work, when the host's
@@ -1426,12 +1448,12 @@ declare class WikiDraftNotFound extends Error {
1426
1448
  readonly code: "WIKI_DRAFT_NOT_FOUND";
1427
1449
  constructor();
1428
1450
  }
1429
- type WikiSupersedeReason = 'not_found' | 'already_superseded' | 'immutable_target' | 'cycle' | 'cross_entity';
1430
- /** Thrown by `supersede()` (spec §4.3). Contextless like {@link WikiDraftNotFound}. */
1451
+ type WikiSupersedeReason = 'not_found' | 'already_superseded' | 'immutable_target' | 'cycle' | 'cross_entity' | 'already_expired' | 'invalid_interval';
1452
+ /** Thrown by `supersede()` and `expire()` (spec §4.3). Contextless like {@link WikiDraftNotFound}. */
1431
1453
  declare class WikiSupersedeError extends Error {
1432
1454
  readonly code: "WIKI_SUPERSEDE_REJECTED";
1433
1455
  readonly reason: WikiSupersedeReason;
1434
- constructor(reason: WikiSupersedeReason);
1456
+ constructor(reason: WikiSupersedeReason, verb?: string);
1435
1457
  }
1436
1458
  /** A new fact to create as the replacement, or the id of an existing fact. */
1437
1459
  type SupersedeReplacement = string | {
@@ -1791,6 +1813,7 @@ declare class EntryRepository extends BaseRepository {
1791
1813
  id: string;
1792
1814
  entity_id: string;
1793
1815
  updated_at: number;
1816
+ deleted_at: number | null;
1794
1817
  }>>;
1795
1818
  findIdById(id: string, entityId: string, tx?: SQLiteAdapter): Promise<string | null>;
1796
1819
  findIdsBySource(entityId: string, sourceRef: string | null, sourceHash: string | null, tx?: SQLiteAdapter, includeDeleted?: boolean): Promise<string[]>;
@@ -1816,7 +1839,9 @@ declare class EntryRepository extends BaseRepository {
1816
1839
  * Fetch IDs + entity_ids of soft-deleted rows older than cutoff for a given entity.
1817
1840
  * Used by runPrune().
1818
1841
  */
1819
- getPrunableMetadata(entityId: string, cutoff: number, tx?: SQLiteAdapter): Promise<Array<{
1842
+ getPrunableMetadata(entityId: string, cutoff: number, tx?: SQLiteAdapter, opts?: {
1843
+ noCutoff?: boolean;
1844
+ }): Promise<Array<{
1820
1845
  id: string;
1821
1846
  entity_id: string;
1822
1847
  }>>;
@@ -1824,7 +1849,9 @@ declare class EntryRepository extends BaseRepository {
1824
1849
  * Fetch all non-deleted entries for an entity, ordered by updated_at DESC.
1825
1850
  * Used by _getFullBundle().
1826
1851
  */
1827
- findAllByEntityId(entityId: string, tx?: SQLiteAdapter): Promise<WikiFact[]>;
1852
+ findAllByEntityId(entityId: string, tx?: SQLiteAdapter, opts?: {
1853
+ includeDeleted?: boolean;
1854
+ }): Promise<WikiFact[]>;
1828
1855
  /**
1829
1856
  * Fetch live, mutable entries for an entity — everything heal is allowed to
1830
1857
  * downgrade or delete — oldest first, capped at `limit`, skipping anything
@@ -1866,7 +1893,9 @@ declare class EntryRepository extends BaseRepository {
1866
1893
  * Fetch all non-deleted entries for an entity with embedding blobs preserved.
1867
1894
  * Used by ImportExportService for export/import round-tripping.
1868
1895
  */
1869
- findAllByEntityIdWithBlobs(entityId: string, tx?: SQLiteAdapter): Promise<WikiFact[]>;
1896
+ findAllByEntityIdWithBlobs(entityId: string, tx?: SQLiteAdapter, opts?: {
1897
+ includeDeleted?: boolean;
1898
+ }): Promise<WikiFact[]>;
1870
1899
  /**
1871
1900
  * Count non-deleted entries for the given entities whose embedding_blob dimension
1872
1901
  * doesn't match queryVecLength. Used by read() to detect model-switch mismatches.
@@ -1891,6 +1920,7 @@ declare class EntryRepository extends BaseRepository {
1891
1920
  bulkDeletePruned(entityId: string, cutoff: number, ids: string[], tx: SQLiteAdapter, opts?: {
1892
1921
  keepUnconfirmedRemovals?: boolean;
1893
1922
  deletedIds?: string[];
1923
+ noCutoff?: boolean;
1894
1924
  }): Promise<number>;
1895
1925
  /**
1896
1926
  * Mark orphaned entries (never accessed, old) as deleted.
@@ -1928,9 +1958,25 @@ declare class EntryRepository extends BaseRepository {
1928
1958
  * entries_temporal_idx.
1929
1959
  */
1930
1960
  findNonLiveIdsByEntityIds(entityIds: readonly string[], mode: LiveMode, t: number, tx?: SQLiteAdapter): Promise<Set<string>>;
1961
+ /**
1962
+ * Depth-aware supersession walk for chain forget (spec forget-erasure §3).
1963
+ * Probes `maxDepth + 1` levels so a chain longer than the cap is detectable;
1964
+ * the returned ids are capped to `maxDepth` per direction (successors nearest first; predecessors are returned farthest-first).
1965
+ * No `deleted_at` filter: soft-deleted links still carry the chain.
1966
+ */
1967
+ findSupersessionChainWalk(entityId: string, factId: string, maxDepth: number, tx?: SQLiteAdapter): Promise<{
1968
+ ids: string[];
1969
+ truncated: boolean;
1970
+ }>;
1931
1971
  findSupersessionChainIds(entityId: string, factId: string, maxDepth: number, tx?: SQLiteAdapter): Promise<{
1932
- predecessors: string[];
1933
- successors: string[];
1972
+ predecessors: Array<{
1973
+ id: string;
1974
+ depth: number;
1975
+ }>;
1976
+ successors: Array<{
1977
+ id: string;
1978
+ depth: number;
1979
+ }>;
1934
1980
  }>;
1935
1981
  findExpiredIds(entityId: string, cutoff: number, tx?: SQLiteAdapter): Promise<string[]>;
1936
1982
  /**
@@ -2214,6 +2260,10 @@ type LibrarianWatermark = {
2214
2260
  at: number;
2215
2261
  id: string;
2216
2262
  };
2263
+ /** A `wal_checkpoint(TRUNCATE)` that did not fully drain the WAL (erase step 5/8). */
2264
+ declare class CheckpointIncompleteError extends Error {
2265
+ readonly code = "erase_checkpoint_incomplete";
2266
+ }
2217
2267
  declare class MetadataRepository extends BaseRepository {
2218
2268
  getCheckpoint(entityId: string, tx: SQLiteAdapter): Promise<{
2219
2269
  memory?: number;
@@ -2241,6 +2291,12 @@ declare class MetadataRepository extends BaseRepository {
2241
2291
  clearDimensionMismatch(tx: SQLiteAdapter): Promise<void>;
2242
2292
  tableExists(tableName: string, tx?: SQLiteAdapter): Promise<boolean>;
2243
2293
  getTableDdl(tableName: string, tx?: SQLiteAdapter): Promise<string | null>;
2294
+ /**
2295
+ * `PRAGMA wal_checkpoint(TRUNCATE)`, verified: `busy !== 0` or
2296
+ * `log !== checkpointed` means frames survive in the WAL, so a deleted
2297
+ * row's bytes may still be on disk. Non-WAL reports (0,-1,-1) = complete.
2298
+ */
2299
+ checkpointTruncateVerified(): Promise<void>;
2244
2300
  vacuum(): Promise<void>;
2245
2301
  /**
2246
2302
  * Returns the set of distinct `entity_id` values across entries/tasks/events.
@@ -2250,8 +2306,16 @@ declare class MetadataRepository extends BaseRepository {
2250
2306
  * soft-deleted, so the host's maintenance sweep can visit such
2251
2307
  * "decommissioned-scope" namespaces and reap the soft-deleted rows. Sorting
2252
2308
  * is `entity_id COLLATE BINARY` for stable, locale-independent ordering.
2253
- */
2254
- getDistinctEntityIds(tx?: SQLiteAdapter): Promise<string[]>;
2309
+ *
2310
+ * With `opts.softDeletedAtOrBefore` the walk is narrowed to entities holding
2311
+ * at least one soft-deleted entry or task with `deleted_at` at or before
2312
+ * that cutoff (erase's hard-delete walk, forget-erasure spec §2). Without
2313
+ * the option the host-facing semantics above are unchanged.
2314
+ */
2315
+ getDistinctEntityIds(tx?: SQLiteAdapter, opts?: {
2316
+ softDeletedAtOrBefore?: number;
2317
+ softDeletedAll?: boolean;
2318
+ }): Promise<string[]>;
2255
2319
  getManifest(entityId: string, tx?: SQLiteAdapter): Promise<{
2256
2320
  mode: OntologyMode;
2257
2321
  manifest: OntologyManifest;
@@ -2590,6 +2654,26 @@ declare class SearchService {
2590
2654
  * pass). Serialized on the sync chain; never rejects, like sync().
2591
2655
  */
2592
2656
  syncPassages(db: SQLiteAdapter, prefix: string, entityId?: string, deadline?: number): Promise<void>;
2657
+ /** Run `fn` on the sync chain; the caller sees its rejection, the chain never rejects. */
2658
+ private chainSurfaced;
2659
+ /** True when the active strategy is the transient outage placeholder (erase orphan remediation, D1: never drop under it). */
2660
+ isIndexUnavailable(): boolean;
2661
+ /** True when the active strategy has both strict erase drains (FTS5); false for MiniSearch / Unavailable. */
2662
+ hasStrictDrain(): boolean;
2663
+ /** Erase step 3: chained passage drain, no deadline, errors surfaced. */
2664
+ drainPassagesSurfaced(): Promise<void>;
2665
+ /** Erase step 4: listed retired FTS tables (empty for strategies without any). */
2666
+ retiredTables(): Promise<string[]>;
2667
+ /** True when the active strategy can DROP retired tables (FTS5); false for MiniSearch / Unavailable. */
2668
+ canReclaimRetired(): boolean;
2669
+ /** Erase step 3: store-wide entries-side fts_pending drain on the sync chain, no deadline, errors surfaced. */
2670
+ drainEntriesLedgerSurfaced(): Promise<void>;
2671
+ /** Erase step 4: reclaim retired tables to completion; errors surfaced. */
2672
+ reclaimRetiredSurfaced(): Promise<void>;
2673
+ /** Erase step 7: FTS optimize on every FTS table that exists. */
2674
+ optimizeSurfaced(): Promise<void>;
2675
+ /** `erase({ rebuild: true })` wiring point; the orchestration (T6) calls it. */
2676
+ rebuildSurfaced(): Promise<void>;
2593
2677
  /**
2594
2678
  * Stored-source passage search for ONE entity (spec source-store section 7:
2595
2679
  * ranking and caps are per entity). Rides the active strategy; a strategy
@@ -2625,7 +2709,7 @@ declare class SearchService {
2625
2709
  private _compareSearchResults;
2626
2710
  }
2627
2711
 
2628
- type OperationType = 'prune' | 'librarian' | 'heal' | 'ingest' | 'reembed' | 'global_reembed' | 'import' | 'global_import' | 'forget' | 'ontologyBackfill' | 'store';
2712
+ type OperationType = 'prune' | 'librarian' | 'heal' | 'ingest' | 'reembed' | 'global_reembed' | 'import' | 'global_import' | 'forget' | 'ontologyBackfill' | 'store' | 'erase';
2629
2713
  declare class JobManager {
2630
2714
  private prefix;
2631
2715
  private activeMaintenanceJobs;
@@ -2673,6 +2757,7 @@ declare class JobManager {
2673
2757
  private _pruneKey;
2674
2758
  private _reembedKey;
2675
2759
  private _globalReembedKey;
2760
+ private _eraseKey;
2676
2761
  private _importKey;
2677
2762
  private _globalImportKey;
2678
2763
  private _forgetKey;
@@ -2682,7 +2767,7 @@ declare class JobManager {
2682
2767
  private _ontologyBackfillKey;
2683
2768
  /**
2684
2769
  * Lookup table for acquireLock/releaseLock's dynamic-dispatch branch.
2685
- * Excludes 'ingest' | 'global_reembed' | 'global_import', which those
2770
+ * Excludes 'ingest' | 'global_reembed' | 'global_import' | 'erase', which those
2686
2771
  * methods already handle via explicit if/else branches before reaching
2687
2772
  * this table.
2688
2773
  */
@@ -2710,7 +2795,12 @@ declare class JobManager {
2710
2795
  private _addIngestJob;
2711
2796
  private _removeIngestJob;
2712
2797
  private _isIngestActiveFor;
2713
- acquireLock(operation: OperationType, entityId: string, sourceRef?: string): void;
2798
+ /**
2799
+ * `owner` is the fourth parameter (the third, `sourceRef`, is ingest-only).
2800
+ * `'erase'` marks the erase() pipeline's own per-entity prune, the only
2801
+ * operation exempt from the universal erase pre-check below.
2802
+ */
2803
+ acquireLock(operation: OperationType, entityId: string, sourceRef?: string, owner?: 'host' | 'erase'): void;
2714
2804
  releaseLock(operation: OperationType, entityId: string, sourceRef?: string): void;
2715
2805
  /**
2716
2806
  * Returns true if acquireLock(operation, entityId) would throw WikiBusyError.
@@ -3476,6 +3566,7 @@ declare class TaskRepository extends BaseRepository {
3476
3566
  id: string;
3477
3567
  entity_id: string;
3478
3568
  updated_at: number;
3569
+ deleted_at: number | null;
3479
3570
  }>>;
3480
3571
  /**
3481
3572
  * Upsert a WikiTask within the provided transaction.
@@ -3501,12 +3592,16 @@ declare class TaskRepository extends BaseRepository {
3501
3592
  * Fetch all non-deleted tasks for an entity, ordered by priority DESC, created_at ASC.
3502
3593
  * Used by _getFullBundle().
3503
3594
  */
3504
- findAllByEntityId(entityId: string, tx?: SQLiteAdapter): Promise<WikiTask[]>;
3595
+ findAllByEntityId(entityId: string, tx?: SQLiteAdapter, opts?: {
3596
+ includeDeleted?: boolean;
3597
+ }): Promise<WikiTask[]>;
3505
3598
  /**
3506
3599
  * Bulk delete pruned tasks (already soft-deleted) by cutoff date.
3507
3600
  * Used by runPrune(). Returns number of deleted rows.
3508
3601
  */
3509
- bulkDeletePruned(entityId: string, cutoff: number, tx: SQLiteAdapter): Promise<number>;
3602
+ bulkDeletePruned(entityId: string, cutoff: number, tx: SQLiteAdapter, opts?: {
3603
+ noCutoff?: boolean;
3604
+ }): Promise<number>;
3510
3605
  /**
3511
3606
  * Soft-delete a task by ID within a transaction.
3512
3607
  * Stages a DELETE outbox entry in the same transaction.
@@ -3710,6 +3805,50 @@ declare const ONTOLOGY_BACKFILL_RECHECK_MS: number;
3710
3805
  declare const HEAL_BATCH_SIZE = 25;
3711
3806
  /** Cooldown before an already-healed fact is offered again. Matches ontology backfill. */
3712
3807
  declare const HEAL_RECHECK_MS: number;
3808
+ /** Report of the erase core (steps 0/1/1b); T6 extends it with the file steps. */
3809
+ interface EraseReport {
3810
+ /** True only when every step ran and the pragma read back ON. */
3811
+ verified: boolean;
3812
+ /** `PRAGMA secure_delete` as read back on the connection (1 = ON). */
3813
+ secureDelete: number | null;
3814
+ sqliteVersion: string;
3815
+ /** Entities step 1 enumerated. */
3816
+ entities: string[];
3817
+ /** External-removal holds, per entity (event-retention holds cannot arise: events are kept). */
3818
+ holds: Array<{
3819
+ entityId: string;
3820
+ deleted: number;
3821
+ deletedTasks: number;
3822
+ failedAt: string;
3823
+ remaining: number;
3824
+ }>;
3825
+ /** Entities skipped because their per-entity prune lock was busy. */
3826
+ skipped: string[];
3827
+ /** Superset of the hard-deleted entry ids, for the step-6 index sync (containment, not equality). */
3828
+ syncedIds: string[];
3829
+ registrySweep: {
3830
+ skipped: boolean;
3831
+ deleted: number;
3832
+ };
3833
+ /** Retired FTS tables left listed (module-less runtime): shadow tables emptied, DROP deferred to an FTS5-capable open. */
3834
+ retiredUndroppable: string[];
3835
+ /** FTS5 orphan surfaces cleared (Path A/C) or dropped (Path B) by the step-3 remediation (specs/erase-fts-remediation D3). Names are recorded only after the owning transaction commits. */
3836
+ ftsOrphansCleared: string[];
3837
+ failedStep: 'secure_delete' | 'vacuum' | 'checkpoint' | 'prune' | 'registry_sweep' | 'passage_drain' | 'retired_reclaim' | 'index_sync' | 'optimize' | 'rebuild' | 'tombstone_gate' | 'fts_orphan_clear' | null;
3838
+ /** JS runtime the erase ran on (no overclaiming: this is not a storage-layer guarantee). */
3839
+ runtime: string;
3840
+ /** Every step's outcome, in execution order; a failed step is last. `partial` = ran with skipped entities or holds, or was skipped by design (`registry_sweep` on a pre-v9 store; `tombstone_gate` when holds/skips already account for surviving rows). */
3841
+ steps: Array<{
3842
+ step: string;
3843
+ outcome: 'ok' | 'partial' | 'failed';
3844
+ }>;
3845
+ }
3846
+ /** A failed erase step: carries the partial report (`verified: false`). */
3847
+ declare class EraseStepError extends Error {
3848
+ readonly code: string;
3849
+ readonly report: EraseReport;
3850
+ constructor(code: string, message: string, report: EraseReport, cause?: unknown);
3851
+ }
3713
3852
  declare class MaintenanceService {
3714
3853
  private db;
3715
3854
  private prefix;
@@ -3732,11 +3871,61 @@ declare class MaintenanceService {
3732
3871
  retainSoftDeletedFor?: number | null;
3733
3872
  retainEventsFor?: number | null;
3734
3873
  vacuum?: boolean;
3874
+ syncedIds?: string[];
3735
3875
  }): Promise<{
3736
3876
  entries: number;
3737
3877
  tasks: number;
3738
3878
  events: number;
3739
3879
  }>;
3880
+ /**
3881
+ * Shared prune body. `owner: 'erase'` lets erase()'s own per-entity prune
3882
+ * through the universal erase fence in JobManager; the public `runPrune`
3883
+ * always passes `'host'`.
3884
+ */
3885
+ private _runPrune;
3886
+ /** Shared by runPrune and erase step 5. */
3887
+ private _wrappedVacuum;
3888
+ /**
3889
+ * Erase core (forget-erasure spec §2, steps 0 / 1 / 1b). Thin entry: T6
3890
+ * completes the pipeline (FTS, VACUUM, checkpoint, sync). Never reports a
3891
+ * success it cannot verify: a failed step throws {@link EraseStepError}
3892
+ * carrying the partial report with `verified: false`.
3893
+ */
3894
+ erase(opts?: {
3895
+ rebuild?: boolean;
3896
+ }): Promise<EraseReport>;
3897
+ private static readonly FTS_SHADOW_SUFFIXES;
3898
+ /**
3899
+ * Step 3 remediation (specs/erase-fts-remediation): on a runtime without
3900
+ * usable strict drains, clear orphaned FTS5 surfaces so erasure can
3901
+ * complete verified. Per surface: existence gate (vtab OR any shadow) →
3902
+ * strategy check → vtab probe → path body → companions → state write.
3903
+ * Dispatch order is D4; exact-name allowlist interpolation is D2.
3904
+ */
3905
+ _eraseClearFtsOrphans(report: EraseReport): Promise<void>;
3906
+ /**
3907
+ * Step 3: chained, surfaced drains (no deadline). Entries-ledger failures are
3908
+ * the entries/index-sync step (`index_sync`); passage failures `passage_drain`.
3909
+ * N2 guard (probe lives here, strategy-agnostic): a strategy without the strict
3910
+ * drains (Unavailable / MiniSearch) cannot drain, so rows in either FTS ledger
3911
+ * mean text was never drained -> the step fails and erasure is unverified.
3912
+ * Absent or empty ledgers proceed.
3913
+ */
3914
+ _eraseDrainPassages(report: EraseReport): Promise<void>;
3915
+ /**
3916
+ * Step 4 (and its re-run after step 6): reclaim retired FTS tables to
3917
+ * completion. A module-less runtime cannot DROP a virtual table, so each
3918
+ * retired table's shadow tables are emptied under the pragma and the name
3919
+ * stays listed; a later FTS5-capable open's step 4 completes the DROP.
3920
+ */
3921
+ _eraseReclaimRetired(report: EraseReport): Promise<void>;
3922
+ /** Retired list straight from metadata (same key Fts5IndexStrategy maintains), independent of the active strategy. */
3923
+ private _retiredList;
3924
+ private sourceTableExists;
3925
+ /** Step 6 sync: `syncEntries` resolving false means the ledger drain failed — a failed step. */
3926
+ _eraseSyncEntries(entityId: string, ids: string[], report: EraseReport): Promise<void>;
3927
+ /** Step 7: FTS optimize on both FTS tables, after syncEntries. */
3928
+ _eraseOptimize(report: EraseReport): Promise<void>;
3740
3929
  runLibrarian(entityId: string, options?: {
3741
3930
  promptOverride?: string;
3742
3931
  }): Promise<void>;
@@ -3993,7 +4182,9 @@ declare class ImportExportService {
3993
4182
  constructor(db: SQLiteAdapter, entryRepo: EntryRepository, taskRepo: TaskRepository, eventRepo: EventRepository, edgeRepo: EdgeRepository, metadataRepo: MetadataRepository, searchService: SearchService, jobManager: JobManager, embeddingService: EmbeddingService, options?: Pick<WikiOptions, 'onDiagnostic' | 'forceDeleteIgnoreRankerHook' | 'config'>, vectorRemoval?: VectorRemovalService | undefined,
3994
4183
  /** Table prefix for the source store; undefined (unit-test mocks) means no store access. */
3995
4184
  prefix?: string | undefined);
3996
- exportDump(entityIds?: string[]): Promise<MemoryDump>;
4185
+ exportDump(entityIds?: string[], opts?: {
4186
+ includeForgotten?: boolean;
4187
+ }): Promise<MemoryDump>;
3997
4188
  importDump(dump: MemoryDump, opts?: {
3998
4189
  merge?: boolean;
3999
4190
  }): Promise<ImportDumpResult>;
@@ -4011,6 +4202,7 @@ declare class ImportExportService {
4011
4202
  getFullBundle(entityId: string, opts?: {
4012
4203
  maxEvents?: number;
4013
4204
  includeBlobs?: boolean;
4205
+ includeForgotten?: boolean;
4014
4206
  }): Promise<MemoryBundle>;
4015
4207
  /** Single-entity import transaction + post-processing; package-internal hook for tests. */
4016
4208
  doImportEntity(entityId: string, bundle: MemoryDumpEntity, merge: boolean): Promise<ImportDumpResult['skippedSources']>;
@@ -4120,6 +4312,13 @@ declare class TemporalService {
4120
4312
  }): Promise<{
4121
4313
  newId: string;
4122
4314
  }>;
4315
+ /**
4316
+ * End `factId`'s validity without a replacement — an archive, not a
4317
+ * deletion (INTENT rule 12, spec specs/expire). Sets `valid_to` only.
4318
+ */
4319
+ expire(entityId: string, factId: string, options?: {
4320
+ at?: number;
4321
+ }): Promise<void>;
4123
4322
  history(entityId: string, factId: string): Promise<WikiFact[]>;
4124
4323
  }
4125
4324
 
@@ -4376,6 +4575,15 @@ declare class WikiMemory {
4376
4575
  listEntityIds(options?: {
4377
4576
  prefix?: string;
4378
4577
  }): Promise<string[]>;
4578
+ /**
4579
+ * Erase everything soft-deleted, store-wide, and verify it (forget-erasure
4580
+ * spec §2). Throws `EraseStepError` (partial report, `verified: false`) when
4581
+ * a step fails; skipped entities report `verified: false`.
4582
+ * `{ rebuild: true }` additionally restarts the FTS rebuild.
4583
+ */
4584
+ erase(options?: {
4585
+ rebuild?: boolean;
4586
+ }): Promise<EraseReport>;
4379
4587
  runPrune(entityId: string, options?: {
4380
4588
  retainSoftDeletedFor?: number | null;
4381
4589
  retainEventsFor?: number | null;
@@ -4504,7 +4712,20 @@ declare class WikiMemory {
4504
4712
  * so the ids stay stashed for the first sync after a re-init (#284 review).
4505
4713
  */
4506
4714
  private syncDrained;
4507
- exportDump(entityIds?: string[]): Promise<MemoryDump>;
4715
+ exportDump(entityIds?: string[], opts?: {
4716
+ includeForgotten?: boolean;
4717
+ }): Promise<MemoryDump>;
4718
+ /**
4719
+ * The retention windows `runPrune()` uses when the host runs it (shipped
4720
+ * defaults plus host overrides), for GDPR disclosure. Nothing prunes
4721
+ * automatically; `erase()` ignores `retainSoftDeletedFor`. Days; `null`
4722
+ * means "keep forever". Read-only.
4723
+ */
4724
+ getRetentionPolicy(): {
4725
+ retainSoftDeletedFor: number;
4726
+ retainEventsFor: number | null;
4727
+ pruneSupersededAfter: number | null;
4728
+ };
4508
4729
  /** Entity summary prose persisted from an OKF profile ≥ 1 import; null when none stored. */
4509
4730
  getEntitySummary(entityId: string): Promise<string | null>;
4510
4731
  importDump(dump: MemoryDump, opts?: {
@@ -4542,13 +4763,25 @@ declare class WikiMemory {
4542
4763
  /**
4543
4764
  * End `oldId`'s validity and link it to its replacement (spec §4.3). One
4544
4765
  * transaction. Throws `WikiSupersedeError` for missing, foreign, already
4545
- * superseded, immutable-document, or cyclic targets.
4766
+ * superseded, already expired, immutable-document, or cyclic targets.
4546
4767
  */
4547
4768
  supersede(entityId: string, oldId: string, replacement: SupersedeReplacement, options?: {
4548
4769
  validFrom?: number;
4549
4770
  }): Promise<{
4550
4771
  newId: string;
4551
4772
  }>;
4773
+ /**
4774
+ * End `factId`'s validity without a replacement — an archive, not a
4775
+ * deletion (INTENT rule 12). Sets `valid_to` only: `superseded_by`,
4776
+ * `superseded_at` and `deleted_at` stay untouched, and an `asOf` read at
4777
+ * `T` with `COALESCE(valid_from, created_at) <= T < valid_to` still returns
4778
+ * the fact. Throws `WikiSupersedeError` for
4779
+ * a missing, foreign, already superseded, immutable-document, or already
4780
+ * expired target, and for an inverted or empty interval (`invalid_interval`).
4781
+ */
4782
+ expire(entityId: string, factId: string, options?: {
4783
+ at?: number;
4784
+ }): Promise<void>;
4552
4785
  /** The supersession chain containing `factId`, oldest first. [] when unknown. */
4553
4786
  history(entityId: string, factId: string): Promise<WikiFact[]>;
4554
4787
  /**
@@ -4765,5 +4998,5 @@ declare class WikiMemory {
4765
4998
  setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
4766
4999
  }
4767
5000
 
4768
- export { HEAL_BATCH_SIZE as H, ONTOLOGY_BACKFILL_BATCH_SIZE as P, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as Q, ONTOLOGY_BACKFILL_RECHECK_MS as T, PromptService as a4, PrunePartialFailureError as a5, WikiGraphNodeOwnershipConflict as aA, WikiIngestEmptyError as aB, WikiInvalidReadOptions as aD, WikiMigrationRequiredError as aG, WikiParseError as aI, WikiSearchUnavailableError as aJ, WikiSourceRefHashCollision as aL, WikiStrictOntologyViolation as aM, WikiSupersedeError as aN, WikiTransactionError as aQ, isWikiSearchUnavailableError as aR, validateManifest as aS, EmbeddingService as aT, ImportExportService as aU, IngestionService as aV, JobManager as aW, MaintenanceService as aX, RetrievalService as aY, SearchService as aZ, WriteService as a_, WikiBusyError as ak, WikiDraftNotFound as au, WikiDuplicateHashError as av, WikiExternalDeletionError as ay, WikiMemory as c, HEAL_RECHECK_MS as u, HOOK_TIMEOUT_MARKER as v };
4769
- export type { OntologyUpdates as $, LockedMaintenanceJob as A, MaintenanceJob as B, ChunkFailure as C, DegradedRecord as D, EmbedFactResult as E, FormatContextOptions as F, GraphNeighborhood as G, ImportDumpResult as I, MaintenanceStopReason as J, MemoryDumpEntity as K, LLMProvider as L, MemoryBundle as M, MigrationPolicy as N, OntologyMode as O, ReadOptions as R, SQLiteAdapter as S, OntologyBackfillResult as U, OntologyConfig as V, WikiOptions as W, OntologyEdgeType as X, OntologyManifest as Y, OntologyNodeType as Z, OntologyPromptContext as _, MemoryDump as a, PendingMaintenance as a0, PendingMigrationWork as a1, PendingSourceStatus as a2, PromptOverrides as a3, ReembedResult as a6, RememberInput as a7, RunPendingMaintenanceOptions as a8, RunPendingMaintenanceResult as a9, WikiInstructions as aC, WikiLintReport as aE, WikiMemoryTestAccess as aF, WikiOutboxEvent as aH, WikiSourcePointer as aK, WikiSupersedeReason as aO, WikiTask as aP, SourcePassage as aa, StoreSourceResult as ab, StoredSource as ac, StoredSourceDump as ad, StoredSourceSummary as ae, SupersedeReplacement as af, VectorRanker as ag, VectorRankerFallback as ah, VectorRankerRankArgs as ai, VectorRankerSemanticResult as aj, WikiBusyOperation as al, WikiCheckpoint as am, WikiConfig as an, WikiDiagnostic as ao, WikiDiagnosticCode as ap, WikiDiagnosticDetail as aq, WikiDiagnosticOperation as ar, WikiDiagnosticSeverity as as, WikiDiagnosticTrigger as at, WikiEdge as aw, WikiEvent as ax, WikiFact as az, FormattedMemoryDump as b, ClassifierAnswer as d, ClassifierQuestion as e, ClassifyRequest as f, ClassifyResponse as g, DraftPage as h, EmbedFailureKind as i, EmbeddingMarkerKind as j, EntityMaintenanceReport as k, EntityStatus as l, ExtractedFact as m, ExtractedFactEdge as n, ExtractedFactWithOntology as o, ExtractedTask as p, ForgetParams as q, ForgetResult as r, GraphTraversalOptions as s, GroundingConfig as t, HealResult as w, IngestDocumentResult as x, LibrarianConfig as y, LibrarianGateConfig as z };
5001
+ export { CheckpointIncompleteError as C, HEAL_BATCH_SIZE as H, ONTOLOGY_BACKFILL_BATCH_SIZE as U, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as V, ONTOLOGY_BACKFILL_RECHECK_MS as X, RetrievalService as a$, PromptService as a7, PrunePartialFailureError as a8, WikiExternalDeletionError as aB, WikiGraphNodeOwnershipConflict as aD, WikiIngestEmptyError as aE, WikiInvalidReadOptions as aG, WikiMigrationRequiredError as aJ, WikiParseError as aL, WikiSearchUnavailableError as aM, WikiSourceRefHashCollision as aO, WikiStrictOntologyViolation as aP, WikiSupersedeError as aQ, WikiTransactionError as aT, isWikiSearchUnavailableError as aU, validateManifest as aV, EmbeddingService as aW, ImportExportService as aX, IngestionService as aY, JobManager as aZ, MaintenanceService as a_, WikiBusyError as an, WikiDraftNotFound as ax, WikiDuplicateHashError as ay, SearchService as b0, WriteService as b1, WikiMemory as c, EraseStepError as o, HEAL_RECHECK_MS as x, HOOK_TIMEOUT_MARKER as y };
5002
+ export type { OntologyManifest as $, IngestDocumentResult as A, LibrarianConfig as B, DegradedRecord as D, EmbedFactResult as E, FormatContextOptions as F, GraphNeighborhood as G, ImportDumpResult as I, LibrarianGateConfig as J, LockedMaintenanceJob as K, LLMProvider as L, MemoryBundle as M, MaintenanceJob as N, OntologyMode as O, MaintenanceStopReason as P, MemoryDumpEntity as Q, ReadOptions as R, SQLiteAdapter as S, MigrationPolicy as T, WikiOptions as W, OntologyBackfillResult as Y, OntologyConfig as Z, OntologyEdgeType as _, MemoryDump as a, OntologyNodeType as a0, OntologyPromptContext as a1, OntologyUpdates as a2, PendingMaintenance as a3, PendingMigrationWork as a4, PendingSourceStatus as a5, PromptOverrides as a6, ReembedResult as a9, WikiEvent as aA, WikiFact as aC, WikiInstructions as aF, WikiLintReport as aH, WikiMemoryTestAccess as aI, WikiOutboxEvent as aK, WikiSourcePointer as aN, WikiSupersedeReason as aR, WikiTask as aS, RememberInput as aa, RunPendingMaintenanceOptions as ab, RunPendingMaintenanceResult as ac, SourcePassage as ad, StoreSourceResult as ae, StoredSource as af, StoredSourceDump as ag, StoredSourceSummary as ah, SupersedeReplacement as ai, VectorRanker as aj, VectorRankerFallback as ak, VectorRankerRankArgs as al, VectorRankerSemanticResult as am, WikiBusyOperation as ao, WikiCheckpoint as ap, WikiConfig as aq, WikiDiagnostic as ar, WikiDiagnosticCode as as, WikiDiagnosticDetail as at, WikiDiagnosticOperation as au, WikiDiagnosticSeverity as av, WikiDiagnosticTrigger as aw, WikiEdge as az, FormattedMemoryDump as b, ChunkFailure as d, ClassifierAnswer as e, ClassifierQuestion as f, ClassifyRequest as g, ClassifyResponse as h, DraftPage as i, EmbedFailureKind as j, EmbeddingMarkerKind as k, EntityMaintenanceReport as l, EntityStatus as m, EraseReport as n, ExtractedFact as p, ExtractedFactEdge as q, ExtractedFactWithOntology as r, ExtractedTask as s, ForgetParams as t, ForgetResult as u, GraphTraversalOptions as v, GroundingConfig as w, HealResult as z };