@equationalapplications/core-llm-wiki 9.3.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.
- package/dist/{chunk-H436I7OM.mjs → chunk-T75YZCVX.mjs} +149 -23
- package/dist/chunk-T75YZCVX.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +161 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-DsD-idCv.d.mts → testing-C2HwksLd.d.mts} +40 -6
- package/dist/{testing-DsD-idCv.d.ts → testing-C2HwksLd.d.ts} +40 -6
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +160 -21
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-H436I7OM.mjs.map +0 -1
|
@@ -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' | 'prune_checkpoint_incomplete' | 'erase_secure_delete_off' | 'erase_entity_skipped' | 'erase_retired_vtab_undroppable' | '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';
|
|
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
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;
|
|
@@ -1446,12 +1448,12 @@ declare class WikiDraftNotFound extends Error {
|
|
|
1446
1448
|
readonly code: "WIKI_DRAFT_NOT_FOUND";
|
|
1447
1449
|
constructor();
|
|
1448
1450
|
}
|
|
1449
|
-
type WikiSupersedeReason = 'not_found' | 'already_superseded' | 'immutable_target' | 'cycle' | 'cross_entity';
|
|
1450
|
-
/** 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}. */
|
|
1451
1453
|
declare class WikiSupersedeError extends Error {
|
|
1452
1454
|
readonly code: "WIKI_SUPERSEDE_REJECTED";
|
|
1453
1455
|
readonly reason: WikiSupersedeReason;
|
|
1454
|
-
constructor(reason: WikiSupersedeReason);
|
|
1456
|
+
constructor(reason: WikiSupersedeReason, verb?: string);
|
|
1455
1457
|
}
|
|
1456
1458
|
/** A new fact to create as the replacement, or the id of an existing fact. */
|
|
1457
1459
|
type SupersedeReplacement = string | {
|
|
@@ -2654,6 +2656,8 @@ declare class SearchService {
|
|
|
2654
2656
|
syncPassages(db: SQLiteAdapter, prefix: string, entityId?: string, deadline?: number): Promise<void>;
|
|
2655
2657
|
/** Run `fn` on the sync chain; the caller sees its rejection, the chain never rejects. */
|
|
2656
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;
|
|
2657
2661
|
/** True when the active strategy has both strict erase drains (FTS5); false for MiniSearch / Unavailable. */
|
|
2658
2662
|
hasStrictDrain(): boolean;
|
|
2659
2663
|
/** Erase step 3: chained passage drain, no deadline, errors surfaced. */
|
|
@@ -3828,7 +3832,9 @@ interface EraseReport {
|
|
|
3828
3832
|
};
|
|
3829
3833
|
/** Retired FTS tables left listed (module-less runtime): shadow tables emptied, DROP deferred to an FTS5-capable open. */
|
|
3830
3834
|
retiredUndroppable: string[];
|
|
3831
|
-
|
|
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;
|
|
3832
3838
|
/** JS runtime the erase ran on (no overclaiming: this is not a storage-layer guarantee). */
|
|
3833
3839
|
runtime: string;
|
|
3834
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). */
|
|
@@ -3888,6 +3894,15 @@ declare class MaintenanceService {
|
|
|
3888
3894
|
erase(opts?: {
|
|
3889
3895
|
rebuild?: boolean;
|
|
3890
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>;
|
|
3891
3906
|
/**
|
|
3892
3907
|
* Step 3: chained, surfaced drains (no deadline). Entries-ledger failures are
|
|
3893
3908
|
* the entries/index-sync step (`index_sync`); passage failures `passage_drain`.
|
|
@@ -4297,6 +4312,13 @@ declare class TemporalService {
|
|
|
4297
4312
|
}): Promise<{
|
|
4298
4313
|
newId: string;
|
|
4299
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>;
|
|
4300
4322
|
history(entityId: string, factId: string): Promise<WikiFact[]>;
|
|
4301
4323
|
}
|
|
4302
4324
|
|
|
@@ -4741,13 +4763,25 @@ declare class WikiMemory {
|
|
|
4741
4763
|
/**
|
|
4742
4764
|
* End `oldId`'s validity and link it to its replacement (spec §4.3). One
|
|
4743
4765
|
* transaction. Throws `WikiSupersedeError` for missing, foreign, already
|
|
4744
|
-
* superseded, immutable-document, or cyclic targets.
|
|
4766
|
+
* superseded, already expired, immutable-document, or cyclic targets.
|
|
4745
4767
|
*/
|
|
4746
4768
|
supersede(entityId: string, oldId: string, replacement: SupersedeReplacement, options?: {
|
|
4747
4769
|
validFrom?: number;
|
|
4748
4770
|
}): Promise<{
|
|
4749
4771
|
newId: string;
|
|
4750
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>;
|
|
4751
4785
|
/** The supersession chain containing `factId`, oldest first. [] when unknown. */
|
|
4752
4786
|
history(entityId: string, factId: string): Promise<WikiFact[]>;
|
|
4753
4787
|
/**
|
|
@@ -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' | 'prune_checkpoint_incomplete' | 'erase_secure_delete_off' | 'erase_entity_skipped' | 'erase_retired_vtab_undroppable' | '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';
|
|
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
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;
|
|
@@ -1446,12 +1448,12 @@ declare class WikiDraftNotFound extends Error {
|
|
|
1446
1448
|
readonly code: "WIKI_DRAFT_NOT_FOUND";
|
|
1447
1449
|
constructor();
|
|
1448
1450
|
}
|
|
1449
|
-
type WikiSupersedeReason = 'not_found' | 'already_superseded' | 'immutable_target' | 'cycle' | 'cross_entity';
|
|
1450
|
-
/** 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}. */
|
|
1451
1453
|
declare class WikiSupersedeError extends Error {
|
|
1452
1454
|
readonly code: "WIKI_SUPERSEDE_REJECTED";
|
|
1453
1455
|
readonly reason: WikiSupersedeReason;
|
|
1454
|
-
constructor(reason: WikiSupersedeReason);
|
|
1456
|
+
constructor(reason: WikiSupersedeReason, verb?: string);
|
|
1455
1457
|
}
|
|
1456
1458
|
/** A new fact to create as the replacement, or the id of an existing fact. */
|
|
1457
1459
|
type SupersedeReplacement = string | {
|
|
@@ -2654,6 +2656,8 @@ declare class SearchService {
|
|
|
2654
2656
|
syncPassages(db: SQLiteAdapter, prefix: string, entityId?: string, deadline?: number): Promise<void>;
|
|
2655
2657
|
/** Run `fn` on the sync chain; the caller sees its rejection, the chain never rejects. */
|
|
2656
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;
|
|
2657
2661
|
/** True when the active strategy has both strict erase drains (FTS5); false for MiniSearch / Unavailable. */
|
|
2658
2662
|
hasStrictDrain(): boolean;
|
|
2659
2663
|
/** Erase step 3: chained passage drain, no deadline, errors surfaced. */
|
|
@@ -3828,7 +3832,9 @@ interface EraseReport {
|
|
|
3828
3832
|
};
|
|
3829
3833
|
/** Retired FTS tables left listed (module-less runtime): shadow tables emptied, DROP deferred to an FTS5-capable open. */
|
|
3830
3834
|
retiredUndroppable: string[];
|
|
3831
|
-
|
|
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;
|
|
3832
3838
|
/** JS runtime the erase ran on (no overclaiming: this is not a storage-layer guarantee). */
|
|
3833
3839
|
runtime: string;
|
|
3834
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). */
|
|
@@ -3888,6 +3894,15 @@ declare class MaintenanceService {
|
|
|
3888
3894
|
erase(opts?: {
|
|
3889
3895
|
rebuild?: boolean;
|
|
3890
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>;
|
|
3891
3906
|
/**
|
|
3892
3907
|
* Step 3: chained, surfaced drains (no deadline). Entries-ledger failures are
|
|
3893
3908
|
* the entries/index-sync step (`index_sync`); passage failures `passage_drain`.
|
|
@@ -4297,6 +4312,13 @@ declare class TemporalService {
|
|
|
4297
4312
|
}): Promise<{
|
|
4298
4313
|
newId: string;
|
|
4299
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>;
|
|
4300
4322
|
history(entityId: string, factId: string): Promise<WikiFact[]>;
|
|
4301
4323
|
}
|
|
4302
4324
|
|
|
@@ -4741,13 +4763,25 @@ declare class WikiMemory {
|
|
|
4741
4763
|
/**
|
|
4742
4764
|
* End `oldId`'s validity and link it to its replacement (spec §4.3). One
|
|
4743
4765
|
* transaction. Throws `WikiSupersedeError` for missing, foreign, already
|
|
4744
|
-
* superseded, immutable-document, or cyclic targets.
|
|
4766
|
+
* superseded, already expired, immutable-document, or cyclic targets.
|
|
4745
4767
|
*/
|
|
4746
4768
|
supersede(entityId: string, oldId: string, replacement: SupersedeReplacement, options?: {
|
|
4747
4769
|
validFrom?: number;
|
|
4748
4770
|
}): Promise<{
|
|
4749
4771
|
newId: string;
|
|
4750
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>;
|
|
4751
4785
|
/** The supersession chain containing `factId`, oldest first. [] when unknown. */
|
|
4752
4786
|
history(entityId: string, factId: string): Promise<WikiFact[]>;
|
|
4753
4787
|
/**
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { aW as EmbeddingService, aX as ImportExportService, aY as IngestionService, aZ as JobManager, aZ as JobManagerType, a_ as MaintenanceService, a$ as RetrievalService, b0 as SearchService, b0 as SearchServiceType, aI as WikiMemoryTestAccess, b1 as WriteService } from './testing-
|
|
1
|
+
export { aW as EmbeddingService, aX as ImportExportService, aY as IngestionService, aZ as JobManager, aZ as JobManagerType, a_ as MaintenanceService, a$ as RetrievalService, b0 as SearchService, b0 as SearchServiceType, aI as WikiMemoryTestAccess, b1 as WriteService } from './testing-C2HwksLd.mjs';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { aW as EmbeddingService, aX as ImportExportService, aY as IngestionService, aZ as JobManager, aZ as JobManagerType, a_ as MaintenanceService, a$ as RetrievalService, b0 as SearchService, b0 as SearchServiceType, aI as WikiMemoryTestAccess, b1 as WriteService } from './testing-
|
|
1
|
+
export { aW as EmbeddingService, aX as ImportExportService, aY as IngestionService, aZ as JobManager, aZ as JobManagerType, a_ as MaintenanceService, a$ as RetrievalService, b0 as SearchService, b0 as SearchServiceType, aI as WikiMemoryTestAccess, b1 as WriteService } from './testing-C2HwksLd.js';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
package/dist/testing.js
CHANGED
|
@@ -162,8 +162,8 @@ var WikiInvalidReadOptions = class _WikiInvalidReadOptions extends Error {
|
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
164
|
var WikiSupersedeError = class _WikiSupersedeError extends Error {
|
|
165
|
-
constructor(reason) {
|
|
166
|
-
super(
|
|
165
|
+
constructor(reason, verb = "supersede()") {
|
|
166
|
+
super(`${verb} rejected: ${reason}`);
|
|
167
167
|
this.code = "WIKI_SUPERSEDE_REJECTED";
|
|
168
168
|
this.name = "WikiSupersedeError";
|
|
169
169
|
this.reason = reason;
|
|
@@ -728,6 +728,7 @@ var SEVERITY = {
|
|
|
728
728
|
erase_secure_delete_off: "error",
|
|
729
729
|
erase_entity_skipped: "warn",
|
|
730
730
|
erase_retired_vtab_undroppable: "warn",
|
|
731
|
+
erase_fts_orphan_cleared: "info",
|
|
731
732
|
erase_retired_remaining: "error",
|
|
732
733
|
erase_tombstones_remaining: "error",
|
|
733
734
|
erase_retired_read_failed: "error",
|
|
@@ -770,7 +771,8 @@ var MESSAGE = {
|
|
|
770
771
|
event_retention_held: "Event pruning was held back because the librarian has not processed those events yet.",
|
|
771
772
|
prune_checkpoint_incomplete: "The post-VACUUM WAL checkpoint was incomplete while a prune partial failure was also reported; deleted bytes may remain in the WAL.",
|
|
772
773
|
erase_secure_delete_off: "secure_delete could not be confirmed ON on the connection; erasure is unverified and the erase was stopped.",
|
|
773
|
-
erase_retired_vtab_undroppable: "A retired FTS table could not be dropped on a runtime without FTS5; its shadow
|
|
774
|
+
erase_retired_vtab_undroppable: "A retired FTS table could not be dropped on a runtime without FTS5; its shadow-table text rows were emptied (fts5 %_config and %_data ids 1 and 10 are intentionally kept) and the name stays listed until an FTS5-capable open drops it.",
|
|
775
|
+
erase_fts_orphan_cleared: "An orphaned FTS5 surface (shadow or companion table, or a queryable vtab) was cleared during erase so forgotten text cannot survive in it.",
|
|
774
776
|
erase_retired_remaining: "Erase stopped: retired FTS tables still exist after reclamation; the erase is incomplete.",
|
|
775
777
|
erase_tombstones_remaining: "Erase stopped: soft-deleted rows remain in the database file after the erase pipeline; the erase is incomplete and unverified.",
|
|
776
778
|
erase_retired_read_failed: "Erase stopped: the retired-FTS-table inventory read failed; the erase is incomplete and unverified.",
|
|
@@ -3624,6 +3626,7 @@ var TemporalService = class {
|
|
|
3624
3626
|
if (!old || old.deleted_at != null) throw new WikiSupersedeError("not_found");
|
|
3625
3627
|
if (old.entity_id !== entityId) throw new WikiSupersedeError("cross_entity");
|
|
3626
3628
|
if (old.superseded_by != null) throw new WikiSupersedeError("already_superseded");
|
|
3629
|
+
if (old.valid_to != null && old.valid_to <= Math.max(now, Date.now())) throw new WikiSupersedeError("already_expired");
|
|
3627
3630
|
if (old.source_type === "immutable_document") throw new WikiSupersedeError("immutable_target");
|
|
3628
3631
|
if (newId === oldId) throw new WikiSupersedeError("cycle");
|
|
3629
3632
|
const repl = await this.entryRepo.findTemporalRow(newId, tx);
|
|
@@ -3683,6 +3686,27 @@ var TemporalService = class {
|
|
|
3683
3686
|
this.searchService.evictCache(entityId);
|
|
3684
3687
|
return { newId };
|
|
3685
3688
|
}
|
|
3689
|
+
/**
|
|
3690
|
+
* End `factId`'s validity without a replacement — an archive, not a
|
|
3691
|
+
* deletion (INTENT rule 12, spec specs/expire). Sets `valid_to` only.
|
|
3692
|
+
*/
|
|
3693
|
+
async expire(entityId, factId, options) {
|
|
3694
|
+
const t = options?.at === void 0 ? Date.now() : assertEpochMs("options.at", options.at);
|
|
3695
|
+
await this.db.withTransactionAsync(async (tx) => {
|
|
3696
|
+
const old = await this.entryRepo.findTemporalRow(factId, tx);
|
|
3697
|
+
if (!old || old.deleted_at != null) throw new WikiSupersedeError("not_found", "expire()");
|
|
3698
|
+
if (old.entity_id !== entityId) throw new WikiSupersedeError("cross_entity", "expire()");
|
|
3699
|
+
if (old.superseded_by != null) throw new WikiSupersedeError("already_superseded", "expire()");
|
|
3700
|
+
if (old.valid_to != null) throw new WikiSupersedeError("already_expired", "expire()");
|
|
3701
|
+
if (old.source_type === "immutable_document") throw new WikiSupersedeError("immutable_target", "expire()");
|
|
3702
|
+
const start = old.valid_from ?? old.created_at;
|
|
3703
|
+
if (t <= start) throw new WikiSupersedeError("invalid_interval", "expire()");
|
|
3704
|
+
const changes = await this.entryRepo.setTemporal(factId, entityId, { valid_to: t }, tx);
|
|
3705
|
+
if (changes === 0) throw new WikiSupersedeError("cross_entity", "expire()");
|
|
3706
|
+
});
|
|
3707
|
+
await this.searchService.syncEntries(entityId, [factId]);
|
|
3708
|
+
this.searchService.evictCache(entityId);
|
|
3709
|
+
}
|
|
3686
3710
|
async history(entityId, factId) {
|
|
3687
3711
|
const start = await this.entryRepo.findTemporalRow(factId);
|
|
3688
3712
|
if (!start || start.entity_id !== entityId || start.deleted_at != null) return [];
|
|
@@ -4105,11 +4129,24 @@ function isRetiredTableName(p, name) {
|
|
|
4105
4129
|
var FTS5_REBUILD_WM_KEY = "fts5_rebuild_wm";
|
|
4106
4130
|
var FTS5_REBUILD_SNAPSHOT_KEY = "fts5_rebuild_snapshot";
|
|
4107
4131
|
var FTS5_SWEEP_CURSOR_KEY = "fts5_orphan_sweep_cursor";
|
|
4132
|
+
function fts5TriggerNames(prefix) {
|
|
4133
|
+
return [`${prefix}entries_fts_ai`, `${prefix}entries_fts_au`, `${prefix}entries_fts_ad`];
|
|
4134
|
+
}
|
|
4108
4135
|
function fts5PendingIndexesDdl(p) {
|
|
4109
4136
|
return `
|
|
4110
4137
|
CREATE INDEX IF NOT EXISTS ${p}fts_pending_id ON ${p}fts_pending(id);
|
|
4111
4138
|
CREATE INDEX IF NOT EXISTS ${p}fts_pending_entity ON ${p}fts_pending(entity_id);`;
|
|
4112
4139
|
}
|
|
4140
|
+
function fts5LedgerDropSql(p) {
|
|
4141
|
+
return [
|
|
4142
|
+
...fts5TriggerNames(p).map((n) => `DROP TRIGGER IF EXISTS ${n};`),
|
|
4143
|
+
`DROP TABLE IF EXISTS ${p}fts_pending;`,
|
|
4144
|
+
`DROP TABLE IF EXISTS ${p}fts_map;`
|
|
4145
|
+
].join("\n");
|
|
4146
|
+
}
|
|
4147
|
+
function passageFtsTriggerNames(p) {
|
|
4148
|
+
return [`${p}source_passages_fts_ai`, `${p}source_passages_fts_ad`];
|
|
4149
|
+
}
|
|
4113
4150
|
|
|
4114
4151
|
// src/db/migrations.ts
|
|
4115
4152
|
var MIGRATIONS = [
|
|
@@ -5300,7 +5337,7 @@ var EraseStepError = class extends Error {
|
|
|
5300
5337
|
if (cause !== void 0) this.cause = cause;
|
|
5301
5338
|
}
|
|
5302
5339
|
};
|
|
5303
|
-
var
|
|
5340
|
+
var _MaintenanceService = class _MaintenanceService {
|
|
5304
5341
|
constructor(db, prefix, options, entryRepo, sourceRefIndexRepo, taskRepo, eventRepo, metadataRepo, searchService, jobManager, embeddingService, promptService, ontologyService, edgeRepo, vectorRemoval, vectorRemovalRepo) {
|
|
5305
5342
|
this.db = db;
|
|
5306
5343
|
this.prefix = prefix;
|
|
@@ -5529,6 +5566,7 @@ var MaintenanceService = class {
|
|
|
5529
5566
|
syncedIds: [],
|
|
5530
5567
|
registrySweep: { skipped: false, deleted: 0 },
|
|
5531
5568
|
retiredUndroppable: [],
|
|
5569
|
+
ftsOrphansCleared: [],
|
|
5532
5570
|
failedStep: null,
|
|
5533
5571
|
runtime: eraseRuntime(),
|
|
5534
5572
|
steps: []
|
|
@@ -5691,7 +5729,110 @@ var MaintenanceService = class {
|
|
|
5691
5729
|
this.jobManager.releaseLock("erase", "*");
|
|
5692
5730
|
}
|
|
5693
5731
|
}
|
|
5694
|
-
|
|
5732
|
+
/**
|
|
5733
|
+
* Step 3 remediation (specs/erase-fts-remediation): on a runtime without
|
|
5734
|
+
* usable strict drains, clear orphaned FTS5 surfaces so erasure can
|
|
5735
|
+
* complete verified. Per surface: existence gate (vtab OR any shadow) →
|
|
5736
|
+
* strategy check → vtab probe → path body → companions → state write.
|
|
5737
|
+
* Dispatch order is D4; exact-name allowlist interpolation is D2.
|
|
5738
|
+
*/
|
|
5739
|
+
async _eraseClearFtsOrphans(report) {
|
|
5740
|
+
const surfaces = [`${this.prefix}entries_fts`, `${this.prefix}source_passages_fts`];
|
|
5741
|
+
let remediationRequired = false;
|
|
5742
|
+
const pathBTargets = [];
|
|
5743
|
+
try {
|
|
5744
|
+
for (const surface of surfaces) {
|
|
5745
|
+
const vtabExists = await this.sourceTableExists(surface);
|
|
5746
|
+
const shadows = [];
|
|
5747
|
+
for (const sfx of _MaintenanceService.FTS_SHADOW_SUFFIXES) {
|
|
5748
|
+
const name = `${surface}${sfx}`;
|
|
5749
|
+
if (await this.sourceTableExists(name)) shadows.push(name);
|
|
5750
|
+
}
|
|
5751
|
+
if (!vtabExists && shadows.length === 0) continue;
|
|
5752
|
+
remediationRequired = true;
|
|
5753
|
+
if (this.searchService.isIndexUnavailable()) {
|
|
5754
|
+
report.failedStep = "index_sync";
|
|
5755
|
+
throw new EraseStepError("erase_fts_index_unavailable", "erase stopped at step 3: the index strategy is unavailable and orphaned FTS surfaces remain; erasure is unverified", report);
|
|
5756
|
+
}
|
|
5757
|
+
let moduleLess = false;
|
|
5758
|
+
if (vtabExists) {
|
|
5759
|
+
try {
|
|
5760
|
+
await this.db.getFirstAsync(`SELECT 1 AS x FROM ${surface} LIMIT 1`);
|
|
5761
|
+
} catch (err) {
|
|
5762
|
+
let absent = false;
|
|
5763
|
+
let cur = err;
|
|
5764
|
+
for (let depth = 0; depth < 3 && cur != null && !absent; depth++) {
|
|
5765
|
+
let msg = "";
|
|
5766
|
+
try {
|
|
5767
|
+
msg = String(cur.message ?? cur);
|
|
5768
|
+
} catch {
|
|
5769
|
+
break;
|
|
5770
|
+
}
|
|
5771
|
+
absent = /no such module/i.test(msg);
|
|
5772
|
+
try {
|
|
5773
|
+
cur = cur.cause;
|
|
5774
|
+
} catch {
|
|
5775
|
+
break;
|
|
5776
|
+
}
|
|
5777
|
+
}
|
|
5778
|
+
if (!absent) {
|
|
5779
|
+
report.failedStep = "index_sync";
|
|
5780
|
+
throw new EraseStepError("erase_fts_orphan_probe_failed", `erase stopped at step 3: could not classify orphaned vtab ${surface}`, report, err);
|
|
5781
|
+
}
|
|
5782
|
+
moduleLess = true;
|
|
5783
|
+
}
|
|
5784
|
+
}
|
|
5785
|
+
if (vtabExists && !moduleLess) {
|
|
5786
|
+
if (this.options.config?.indexStrategy !== "minisearch") {
|
|
5787
|
+
report.failedStep = "index_sync";
|
|
5788
|
+
throw new EraseStepError("erase_fts_index_unavailable", `erase stopped at step 3: ${surface} is live and queryable but MiniSearch is not the configured strategy; erasure is unverified`, report);
|
|
5789
|
+
}
|
|
5790
|
+
pathBTargets.push(surface);
|
|
5791
|
+
continue;
|
|
5792
|
+
}
|
|
5793
|
+
const cleared = [];
|
|
5794
|
+
for (const name of shadows) {
|
|
5795
|
+
if (name.endsWith("_config")) continue;
|
|
5796
|
+
const res = await this.db.runAsync(name.endsWith("_data") ? `DELETE FROM ${name} WHERE id NOT IN (1, 10)` : `DELETE FROM ${name}`);
|
|
5797
|
+
if ((res?.changes ?? 0) > 0) cleared.push(name);
|
|
5798
|
+
}
|
|
5799
|
+
for (const name of cleared) {
|
|
5800
|
+
if (!report.ftsOrphansCleared.includes(name)) report.ftsOrphansCleared.push(name);
|
|
5801
|
+
emitDiagnostic(this.options, { code: "erase_fts_orphan_cleared", operation: "erase", trigger: "call", entityId: "", detail: { table: name } });
|
|
5802
|
+
}
|
|
5803
|
+
}
|
|
5804
|
+
if (!remediationRequired) return;
|
|
5805
|
+
const tailCleared = [];
|
|
5806
|
+
await this.db.withTransactionAsync(async (tx) => {
|
|
5807
|
+
for (const companion of [`${this.prefix}fts_pending`, `${this.prefix}fts_map`, `${this.prefix}source_passages_fts_pending`, `${this.prefix}source_passages_fts_map`]) {
|
|
5808
|
+
if (await this.sourceTableExists(companion, tx)) {
|
|
5809
|
+
const res = await tx.runAsync(`DELETE FROM ${companion}`);
|
|
5810
|
+
if ((res?.changes ?? 0) > 0 && !tailCleared.includes(companion)) tailCleared.push(companion);
|
|
5811
|
+
}
|
|
5812
|
+
}
|
|
5813
|
+
for (const surface of pathBTargets) {
|
|
5814
|
+
await tx.execAsync(`DROP TABLE IF EXISTS ${surface}`);
|
|
5815
|
+
if (!tailCleared.includes(surface)) tailCleared.push(surface);
|
|
5816
|
+
}
|
|
5817
|
+
if (pathBTargets.length > 0) {
|
|
5818
|
+
const [ai, ad] = passageFtsTriggerNames(this.prefix);
|
|
5819
|
+
await tx.execAsync(fts5LedgerDropSql(this.prefix) + `
|
|
5820
|
+
DROP TRIGGER IF EXISTS ${ai};
|
|
5821
|
+
DROP TRIGGER IF EXISTS ${ad};`);
|
|
5822
|
+
}
|
|
5823
|
+
await this.metadataRepo.setMeta(FTS5_STATE_KEY, "detached", tx);
|
|
5824
|
+
});
|
|
5825
|
+
for (const name of tailCleared) {
|
|
5826
|
+
if (!report.ftsOrphansCleared.includes(name)) report.ftsOrphansCleared.push(name);
|
|
5827
|
+
emitDiagnostic(this.options, { code: "erase_fts_orphan_cleared", operation: "erase", trigger: "call", entityId: "", detail: { table: name } });
|
|
5828
|
+
}
|
|
5829
|
+
report.steps.push({ step: "fts_orphan_clear", outcome: "ok" });
|
|
5830
|
+
} catch (err) {
|
|
5831
|
+
if (err instanceof EraseStepError) throw err;
|
|
5832
|
+
report.failedStep = "fts_orphan_clear";
|
|
5833
|
+
throw new EraseStepError("erase_fts_orphan_clear", "erase stopped at step 3: clearing an orphaned FTS surface failed; erasure is unverified", report, err);
|
|
5834
|
+
}
|
|
5835
|
+
}
|
|
5695
5836
|
/**
|
|
5696
5837
|
* Step 3: chained, surfaced drains (no deadline). Entries-ledger failures are
|
|
5697
5838
|
* the entries/index-sync step (`index_sync`); passage failures `passage_drain`.
|
|
@@ -5702,6 +5843,7 @@ var MaintenanceService = class {
|
|
|
5702
5843
|
*/
|
|
5703
5844
|
async _eraseDrainPassages(report) {
|
|
5704
5845
|
if (!this.searchService.hasStrictDrain()) {
|
|
5846
|
+
await this._eraseClearFtsOrphans(report);
|
|
5705
5847
|
for (const [table, failedStep, code] of [
|
|
5706
5848
|
[`${this.prefix}fts_pending`, "index_sync", "erase_index_sync_failed"],
|
|
5707
5849
|
[`${this.prefix}source_passages_fts_pending`, "passage_drain", "erase_passage_drain_failed"]
|
|
@@ -5718,19 +5860,6 @@ var MaintenanceService = class {
|
|
|
5718
5860
|
throw new EraseStepError(code, `erase stopped at step 3: ${table} holds undrained rows and the FTS index strategy cannot drain them; erasure is unverified`, report);
|
|
5719
5861
|
}
|
|
5720
5862
|
}
|
|
5721
|
-
for (const suffix of ["entries_fts_content", "source_passages_fts_content"]) {
|
|
5722
|
-
let orphaned = false;
|
|
5723
|
-
try {
|
|
5724
|
-
orphaned = await this.sourceTableExists(`${this.prefix}${suffix}`);
|
|
5725
|
-
} catch (err) {
|
|
5726
|
-
report.failedStep = "index_sync";
|
|
5727
|
-
throw new EraseStepError("erase_orphaned_fts_content", `erase stopped: could not probe ${this.prefix}${suffix}`, report, err);
|
|
5728
|
-
}
|
|
5729
|
-
if (orphaned) {
|
|
5730
|
-
report.failedStep = "index_sync";
|
|
5731
|
-
throw new EraseStepError("erase_orphaned_fts_content", "erase stopped: orphaned full-text content tables may still hold forgotten text", report);
|
|
5732
|
-
}
|
|
5733
|
-
}
|
|
5734
5863
|
}
|
|
5735
5864
|
try {
|
|
5736
5865
|
await this.searchService.drainEntriesLedgerSurfaced();
|
|
@@ -5766,7 +5895,10 @@ var MaintenanceService = class {
|
|
|
5766
5895
|
try {
|
|
5767
5896
|
for (const name of await this._retiredList()) {
|
|
5768
5897
|
for (const sfx of ["_content", "_data", "_idx", "_docsize", "_config"]) {
|
|
5769
|
-
if (
|
|
5898
|
+
if (sfx === "_config") continue;
|
|
5899
|
+
if (await this.sourceTableExists(`${name}${sfx}`)) {
|
|
5900
|
+
await this.db.runAsync(sfx === "_data" ? `DELETE FROM ${name}_data WHERE id NOT IN (1, 10)` : `DELETE FROM ${name}${sfx}`);
|
|
5901
|
+
}
|
|
5770
5902
|
}
|
|
5771
5903
|
if (!report.retiredUndroppable.includes(name)) report.retiredUndroppable.push(name);
|
|
5772
5904
|
emitDiagnostic(this.options, { code: "erase_retired_vtab_undroppable", operation: "erase", trigger: "call", entityId: "" });
|
|
@@ -5786,8 +5918,8 @@ var MaintenanceService = class {
|
|
|
5786
5918
|
}
|
|
5787
5919
|
return Array.isArray(raw) ? raw.filter((n) => isRetiredTableName(this.prefix, n)) : [];
|
|
5788
5920
|
}
|
|
5789
|
-
sourceTableExists(name) {
|
|
5790
|
-
return this.metadataRepo.tableExists(name);
|
|
5921
|
+
sourceTableExists(name, tx) {
|
|
5922
|
+
return this.metadataRepo.tableExists(name, tx);
|
|
5791
5923
|
}
|
|
5792
5924
|
/** Step 6 sync: `syncEntries` resolving false means the ledger drain failed — a failed step. */
|
|
5793
5925
|
async _eraseSyncEntries(entityId, ids, report) {
|
|
@@ -6882,6 +7014,9 @@ var MaintenanceService = class {
|
|
|
6882
7014
|
return sanitizeRankerError(err, this.options.sanitizeRankerErrors);
|
|
6883
7015
|
}
|
|
6884
7016
|
};
|
|
7017
|
+
// ── Erase FTS surfaces (spec §2 steps 3/4/6-sync/7). T6 composes these into erase(). ──
|
|
7018
|
+
_MaintenanceService.FTS_SHADOW_SUFFIXES = ["_content", "_data", "_idx", "_docsize", "_config"];
|
|
7019
|
+
var MaintenanceService = _MaintenanceService;
|
|
6885
7020
|
|
|
6886
7021
|
// src/readOptions.ts
|
|
6887
7022
|
function normalizeEntityIds(entityId) {
|
|
@@ -8022,6 +8157,10 @@ var _SearchService = class _SearchService {
|
|
|
8022
8157
|
this.syncChain = work.then(() => void 0, () => void 0);
|
|
8023
8158
|
return work;
|
|
8024
8159
|
}
|
|
8160
|
+
/** True when the active strategy is the transient outage placeholder (erase orphan remediation, D1: never drop under it). */
|
|
8161
|
+
isIndexUnavailable() {
|
|
8162
|
+
return this.indexStrategy instanceof UnavailableIndexStrategy;
|
|
8163
|
+
}
|
|
8025
8164
|
/** True when the active strategy has both strict erase drains (FTS5); false for MiniSearch / Unavailable. */
|
|
8026
8165
|
hasStrictDrain() {
|
|
8027
8166
|
const s = this.indexStrategy;
|