@equationalapplications/core-llm-wiki 9.3.0 → 9.4.2
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-TJYITTAO.mjs} +151 -23
- package/dist/chunk-TJYITTAO.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +164 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-DsD-idCv.d.mts → testing-BVY5P6BS.d.mts} +41 -6
- package/dist/{testing-DsD-idCv.d.ts → testing-BVY5P6BS.d.ts} +41 -6
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +162 -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
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-
|
|
2
|
-
export { C as CheckpointIncompleteError, d as ChunkFailure, e as ClassifierAnswer, f as ClassifierQuestion, g as ClassifyRequest, h as ClassifyResponse, D as DegradedRecord, i as DraftPage, E as EmbedFactResult, j as EmbedFailureKind, k as EmbeddingMarkerKind, l as EntityMaintenanceReport, m as EntityStatus, n as EraseReport, o as EraseStepError, p as ExtractedFact, q as ExtractedFactEdge, r as ExtractedFactWithOntology, s as ExtractedTask, t as ForgetParams, u as ForgetResult, v as GraphTraversalOptions, w as GroundingConfig, H as HEAL_BATCH_SIZE, x as HEAL_RECHECK_MS, y as HOOK_TIMEOUT_MARKER, z as HealResult, I as ImportDumpResult, A as IngestDocumentResult, L as LLMProvider, B as LibrarianConfig, J as LibrarianGateConfig, K as LockedMaintenanceJob, N as MaintenanceJob, P as MaintenanceStopReason, Q as MemoryDumpEntity, T as MigrationPolicy, U as ONTOLOGY_BACKFILL_BATCH_SIZE, V as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, X as ONTOLOGY_BACKFILL_RECHECK_MS, Y as OntologyBackfillResult, Z as OntologyConfig, _ as OntologyEdgeType, $ as OntologyManifest, a0 as OntologyNodeType, a1 as OntologyPromptContext, a2 as OntologyUpdates, a3 as PendingMaintenance, a4 as PendingMigrationWork, a5 as PendingSourceStatus, a6 as PromptOverrides, a7 as PromptService, a8 as PrunePartialFailureError, a9 as ReembedResult, aa as RememberInput, ab as RunPendingMaintenanceOptions, ac as RunPendingMaintenanceResult, ad as SourcePassage, ae as StoreSourceResult, af as StoredSource, ag as StoredSourceDump, ah as StoredSourceSummary, ai as SupersedeReplacement, aj as VectorRanker, ak as VectorRankerFallback, al as VectorRankerRankArgs, am as VectorRankerSemanticResult, an as WikiBusyError, ao as WikiBusyOperation, ap as WikiCheckpoint, aq as WikiConfig, ar as WikiDiagnostic, as as WikiDiagnosticCode, at as WikiDiagnosticDetail, au as WikiDiagnosticOperation, av as WikiDiagnosticSeverity, aw as WikiDiagnosticTrigger, ax as WikiDraftNotFound, ay as WikiDuplicateHashError, az as WikiEdge, aA as WikiEvent, aB as WikiExternalDeletionError, aC as WikiFact, aD as WikiGraphNodeOwnershipConflict, aE as WikiIngestEmptyError, aF as WikiInstructions, aG as WikiInvalidReadOptions, aH as WikiLintReport, aI as WikiMemoryTestAccess, aJ as WikiMigrationRequiredError, aK as WikiOutboxEvent, aL as WikiParseError, aM as WikiSearchUnavailableError, aN as WikiSourcePointer, aO as WikiSourceRefHashCollision, aP as WikiStrictOntologyViolation, aQ as WikiSupersedeError, aR as WikiSupersedeReason, aS as WikiTask, aT as WikiTransactionError, aU as isWikiSearchUnavailableError, aV as validateManifest } from './testing-
|
|
1
|
+
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-BVY5P6BS.mjs';
|
|
2
|
+
export { C as CheckpointIncompleteError, d as ChunkFailure, e as ClassifierAnswer, f as ClassifierQuestion, g as ClassifyRequest, h as ClassifyResponse, D as DegradedRecord, i as DraftPage, E as EmbedFactResult, j as EmbedFailureKind, k as EmbeddingMarkerKind, l as EntityMaintenanceReport, m as EntityStatus, n as EraseReport, o as EraseStepError, p as ExtractedFact, q as ExtractedFactEdge, r as ExtractedFactWithOntology, s as ExtractedTask, t as ForgetParams, u as ForgetResult, v as GraphTraversalOptions, w as GroundingConfig, H as HEAL_BATCH_SIZE, x as HEAL_RECHECK_MS, y as HOOK_TIMEOUT_MARKER, z as HealResult, I as ImportDumpResult, A as IngestDocumentResult, L as LLMProvider, B as LibrarianConfig, J as LibrarianGateConfig, K as LockedMaintenanceJob, N as MaintenanceJob, P as MaintenanceStopReason, Q as MemoryDumpEntity, T as MigrationPolicy, U as ONTOLOGY_BACKFILL_BATCH_SIZE, V as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, X as ONTOLOGY_BACKFILL_RECHECK_MS, Y as OntologyBackfillResult, Z as OntologyConfig, _ as OntologyEdgeType, $ as OntologyManifest, a0 as OntologyNodeType, a1 as OntologyPromptContext, a2 as OntologyUpdates, a3 as PendingMaintenance, a4 as PendingMigrationWork, a5 as PendingSourceStatus, a6 as PromptOverrides, a7 as PromptService, a8 as PrunePartialFailureError, a9 as ReembedResult, aa as RememberInput, ab as RunPendingMaintenanceOptions, ac as RunPendingMaintenanceResult, ad as SourcePassage, ae as StoreSourceResult, af as StoredSource, ag as StoredSourceDump, ah as StoredSourceSummary, ai as SupersedeReplacement, aj as VectorRanker, ak as VectorRankerFallback, al as VectorRankerRankArgs, am as VectorRankerSemanticResult, an as WikiBusyError, ao as WikiBusyOperation, ap as WikiCheckpoint, aq as WikiConfig, ar as WikiDiagnostic, as as WikiDiagnosticCode, at as WikiDiagnosticDetail, au as WikiDiagnosticOperation, av as WikiDiagnosticSeverity, aw as WikiDiagnosticTrigger, ax as WikiDraftNotFound, ay as WikiDuplicateHashError, az as WikiEdge, aA as WikiEvent, aB as WikiExternalDeletionError, aC as WikiFact, aD as WikiGraphNodeOwnershipConflict, aE as WikiIngestEmptyError, aF as WikiInstructions, aG as WikiInvalidReadOptions, aH as WikiLintReport, aI as WikiMemoryTestAccess, aJ as WikiMigrationRequiredError, aK as WikiOutboxEvent, aL as WikiParseError, aM as WikiSearchUnavailableError, aN as WikiSourcePointer, aO as WikiSourceRefHashCollision, aP as WikiStrictOntologyViolation, aQ as WikiSupersedeError, aR as WikiSupersedeReason, aS as WikiTask, aT as WikiTransactionError, aU as isWikiSearchUnavailableError, aV as validateManifest } from './testing-BVY5P6BS.mjs';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-
|
|
2
|
-
export { C as CheckpointIncompleteError, d as ChunkFailure, e as ClassifierAnswer, f as ClassifierQuestion, g as ClassifyRequest, h as ClassifyResponse, D as DegradedRecord, i as DraftPage, E as EmbedFactResult, j as EmbedFailureKind, k as EmbeddingMarkerKind, l as EntityMaintenanceReport, m as EntityStatus, n as EraseReport, o as EraseStepError, p as ExtractedFact, q as ExtractedFactEdge, r as ExtractedFactWithOntology, s as ExtractedTask, t as ForgetParams, u as ForgetResult, v as GraphTraversalOptions, w as GroundingConfig, H as HEAL_BATCH_SIZE, x as HEAL_RECHECK_MS, y as HOOK_TIMEOUT_MARKER, z as HealResult, I as ImportDumpResult, A as IngestDocumentResult, L as LLMProvider, B as LibrarianConfig, J as LibrarianGateConfig, K as LockedMaintenanceJob, N as MaintenanceJob, P as MaintenanceStopReason, Q as MemoryDumpEntity, T as MigrationPolicy, U as ONTOLOGY_BACKFILL_BATCH_SIZE, V as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, X as ONTOLOGY_BACKFILL_RECHECK_MS, Y as OntologyBackfillResult, Z as OntologyConfig, _ as OntologyEdgeType, $ as OntologyManifest, a0 as OntologyNodeType, a1 as OntologyPromptContext, a2 as OntologyUpdates, a3 as PendingMaintenance, a4 as PendingMigrationWork, a5 as PendingSourceStatus, a6 as PromptOverrides, a7 as PromptService, a8 as PrunePartialFailureError, a9 as ReembedResult, aa as RememberInput, ab as RunPendingMaintenanceOptions, ac as RunPendingMaintenanceResult, ad as SourcePassage, ae as StoreSourceResult, af as StoredSource, ag as StoredSourceDump, ah as StoredSourceSummary, ai as SupersedeReplacement, aj as VectorRanker, ak as VectorRankerFallback, al as VectorRankerRankArgs, am as VectorRankerSemanticResult, an as WikiBusyError, ao as WikiBusyOperation, ap as WikiCheckpoint, aq as WikiConfig, ar as WikiDiagnostic, as as WikiDiagnosticCode, at as WikiDiagnosticDetail, au as WikiDiagnosticOperation, av as WikiDiagnosticSeverity, aw as WikiDiagnosticTrigger, ax as WikiDraftNotFound, ay as WikiDuplicateHashError, az as WikiEdge, aA as WikiEvent, aB as WikiExternalDeletionError, aC as WikiFact, aD as WikiGraphNodeOwnershipConflict, aE as WikiIngestEmptyError, aF as WikiInstructions, aG as WikiInvalidReadOptions, aH as WikiLintReport, aI as WikiMemoryTestAccess, aJ as WikiMigrationRequiredError, aK as WikiOutboxEvent, aL as WikiParseError, aM as WikiSearchUnavailableError, aN as WikiSourcePointer, aO as WikiSourceRefHashCollision, aP as WikiStrictOntologyViolation, aQ as WikiSupersedeError, aR as WikiSupersedeReason, aS as WikiTask, aT as WikiTransactionError, aU as isWikiSearchUnavailableError, aV as validateManifest } from './testing-
|
|
1
|
+
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-BVY5P6BS.js';
|
|
2
|
+
export { C as CheckpointIncompleteError, d as ChunkFailure, e as ClassifierAnswer, f as ClassifierQuestion, g as ClassifyRequest, h as ClassifyResponse, D as DegradedRecord, i as DraftPage, E as EmbedFactResult, j as EmbedFailureKind, k as EmbeddingMarkerKind, l as EntityMaintenanceReport, m as EntityStatus, n as EraseReport, o as EraseStepError, p as ExtractedFact, q as ExtractedFactEdge, r as ExtractedFactWithOntology, s as ExtractedTask, t as ForgetParams, u as ForgetResult, v as GraphTraversalOptions, w as GroundingConfig, H as HEAL_BATCH_SIZE, x as HEAL_RECHECK_MS, y as HOOK_TIMEOUT_MARKER, z as HealResult, I as ImportDumpResult, A as IngestDocumentResult, L as LLMProvider, B as LibrarianConfig, J as LibrarianGateConfig, K as LockedMaintenanceJob, N as MaintenanceJob, P as MaintenanceStopReason, Q as MemoryDumpEntity, T as MigrationPolicy, U as ONTOLOGY_BACKFILL_BATCH_SIZE, V as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, X as ONTOLOGY_BACKFILL_RECHECK_MS, Y as OntologyBackfillResult, Z as OntologyConfig, _ as OntologyEdgeType, $ as OntologyManifest, a0 as OntologyNodeType, a1 as OntologyPromptContext, a2 as OntologyUpdates, a3 as PendingMaintenance, a4 as PendingMigrationWork, a5 as PendingSourceStatus, a6 as PromptOverrides, a7 as PromptService, a8 as PrunePartialFailureError, a9 as ReembedResult, aa as RememberInput, ab as RunPendingMaintenanceOptions, ac as RunPendingMaintenanceResult, ad as SourcePassage, ae as StoreSourceResult, af as StoredSource, ag as StoredSourceDump, ah as StoredSourceSummary, ai as SupersedeReplacement, aj as VectorRanker, ak as VectorRankerFallback, al as VectorRankerRankArgs, am as VectorRankerSemanticResult, an as WikiBusyError, ao as WikiBusyOperation, ap as WikiCheckpoint, aq as WikiConfig, ar as WikiDiagnostic, as as WikiDiagnosticCode, at as WikiDiagnosticDetail, au as WikiDiagnosticOperation, av as WikiDiagnosticSeverity, aw as WikiDiagnosticTrigger, ax as WikiDraftNotFound, ay as WikiDuplicateHashError, az as WikiEdge, aA as WikiEvent, aB as WikiExternalDeletionError, aC as WikiFact, aD as WikiGraphNodeOwnershipConflict, aE as WikiIngestEmptyError, aF as WikiInstructions, aG as WikiInvalidReadOptions, aH as WikiLintReport, aI as WikiMemoryTestAccess, aJ as WikiMigrationRequiredError, aK as WikiOutboxEvent, aL as WikiParseError, aM as WikiSearchUnavailableError, aN as WikiSourcePointer, aO as WikiSourceRefHashCollision, aP as WikiStrictOntologyViolation, aQ as WikiSupersedeError, aR as WikiSupersedeReason, aS as WikiTask, aT as WikiTransactionError, aU as isWikiSearchUnavailableError, aV as validateManifest } from './testing-BVY5P6BS.js';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,7 @@ var SEVERITY = {
|
|
|
41
41
|
erase_secure_delete_off: "error",
|
|
42
42
|
erase_entity_skipped: "warn",
|
|
43
43
|
erase_retired_vtab_undroppable: "warn",
|
|
44
|
+
erase_fts_orphan_cleared: "info",
|
|
44
45
|
erase_retired_remaining: "error",
|
|
45
46
|
erase_tombstones_remaining: "error",
|
|
46
47
|
erase_retired_read_failed: "error",
|
|
@@ -83,7 +84,8 @@ var MESSAGE = {
|
|
|
83
84
|
event_retention_held: "Event pruning was held back because the librarian has not processed those events yet.",
|
|
84
85
|
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.",
|
|
85
86
|
erase_secure_delete_off: "secure_delete could not be confirmed ON on the connection; erasure is unverified and the erase was stopped.",
|
|
86
|
-
erase_retired_vtab_undroppable: "A retired FTS table could not be dropped on a runtime without FTS5; its shadow
|
|
87
|
+
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.",
|
|
88
|
+
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.",
|
|
87
89
|
erase_retired_remaining: "Erase stopped: retired FTS tables still exist after reclamation; the erase is incomplete.",
|
|
88
90
|
erase_tombstones_remaining: "Erase stopped: soft-deleted rows remain in the database file after the erase pipeline; the erase is incomplete and unverified.",
|
|
89
91
|
erase_retired_read_failed: "Erase stopped: the retired-FTS-table inventory read failed; the erase is incomplete and unverified.",
|
|
@@ -393,8 +395,8 @@ var WikiDraftNotFound = class _WikiDraftNotFound extends Error {
|
|
|
393
395
|
}
|
|
394
396
|
};
|
|
395
397
|
var WikiSupersedeError = class _WikiSupersedeError extends Error {
|
|
396
|
-
constructor(reason) {
|
|
397
|
-
super(
|
|
398
|
+
constructor(reason, verb = "supersede()") {
|
|
399
|
+
super(`${verb} rejected: ${reason}`);
|
|
398
400
|
this.code = "WIKI_SUPERSEDE_REJECTED";
|
|
399
401
|
this.name = "WikiSupersedeError";
|
|
400
402
|
this.reason = reason;
|
|
@@ -5184,6 +5186,10 @@ var _SearchService = class _SearchService {
|
|
|
5184
5186
|
this.syncChain = work.then(() => void 0, () => void 0);
|
|
5185
5187
|
return work;
|
|
5186
5188
|
}
|
|
5189
|
+
/** True when the active strategy is the transient outage placeholder (erase orphan remediation, D1: never drop under it). */
|
|
5190
|
+
isIndexUnavailable() {
|
|
5191
|
+
return this.indexStrategy instanceof UnavailableIndexStrategy;
|
|
5192
|
+
}
|
|
5187
5193
|
/** True when the active strategy has both strict erase drains (FTS5); false for MiniSearch / Unavailable. */
|
|
5188
5194
|
hasStrictDrain() {
|
|
5189
5195
|
const s = this.indexStrategy;
|
|
@@ -5805,6 +5811,7 @@ var Fts5IndexStrategy = class {
|
|
|
5805
5811
|
const queued = await tx.getFirstAsync(`SELECT 1 AS x FROM ${p}source_passages_fts_pending LIMIT 1`);
|
|
5806
5812
|
if (mapped === null && queued === null) {
|
|
5807
5813
|
await tx.runAsync(`DELETE FROM ${p}source_passages_fts`);
|
|
5814
|
+
await tx.runAsync(`INSERT INTO ${p}source_passages_fts(${p}source_passages_fts) VALUES('rebuild')`);
|
|
5808
5815
|
await tx.runAsync(
|
|
5809
5816
|
`INSERT INTO ${p}source_passages_fts_pending (entity_id, doc_id)
|
|
5810
5817
|
SELECT entity_id, id FROM ${p}source_documents`
|
|
@@ -8553,6 +8560,7 @@ var TemporalService = class {
|
|
|
8553
8560
|
if (!old || old.deleted_at != null) throw new WikiSupersedeError("not_found");
|
|
8554
8561
|
if (old.entity_id !== entityId) throw new WikiSupersedeError("cross_entity");
|
|
8555
8562
|
if (old.superseded_by != null) throw new WikiSupersedeError("already_superseded");
|
|
8563
|
+
if (old.valid_to != null && old.valid_to <= Math.max(now, Date.now())) throw new WikiSupersedeError("already_expired");
|
|
8556
8564
|
if (old.source_type === "immutable_document") throw new WikiSupersedeError("immutable_target");
|
|
8557
8565
|
if (newId === oldId) throw new WikiSupersedeError("cycle");
|
|
8558
8566
|
const repl = await this.entryRepo.findTemporalRow(newId, tx);
|
|
@@ -8561,6 +8569,8 @@ var TemporalService = class {
|
|
|
8561
8569
|
if (repl.superseded_by != null) throw new WikiSupersedeError("already_superseded");
|
|
8562
8570
|
const { predecessors } = await this.entryRepo.findSupersessionChainIds(entityId, oldId, HISTORY_MAX_DEPTH, tx);
|
|
8563
8571
|
if (predecessors.some((r) => r.id === newId)) throw new WikiSupersedeError("cycle");
|
|
8572
|
+
const start = old.valid_from ?? old.created_at;
|
|
8573
|
+
if (t <= start) throw new WikiSupersedeError("invalid_interval");
|
|
8564
8574
|
await this.entryRepo.setTemporal(oldId, entityId, { valid_to: t, superseded_by: newId, superseded_at: now }, tx);
|
|
8565
8575
|
if (repl.valid_from == null) {
|
|
8566
8576
|
await this.entryRepo.setTemporal(newId, entityId, { valid_from: t }, tx);
|
|
@@ -8612,6 +8622,27 @@ var TemporalService = class {
|
|
|
8612
8622
|
this.searchService.evictCache(entityId);
|
|
8613
8623
|
return { newId };
|
|
8614
8624
|
}
|
|
8625
|
+
/**
|
|
8626
|
+
* End `factId`'s validity without a replacement — an archive, not a
|
|
8627
|
+
* deletion (INTENT rule 12, spec specs/expire). Sets `valid_to` only.
|
|
8628
|
+
*/
|
|
8629
|
+
async expire(entityId, factId, options) {
|
|
8630
|
+
const t = options?.at === void 0 ? Date.now() : assertEpochMs("options.at", options.at);
|
|
8631
|
+
await this.db.withTransactionAsync(async (tx) => {
|
|
8632
|
+
const old = await this.entryRepo.findTemporalRow(factId, tx);
|
|
8633
|
+
if (!old || old.deleted_at != null) throw new WikiSupersedeError("not_found", "expire()");
|
|
8634
|
+
if (old.entity_id !== entityId) throw new WikiSupersedeError("cross_entity", "expire()");
|
|
8635
|
+
if (old.superseded_by != null) throw new WikiSupersedeError("already_superseded", "expire()");
|
|
8636
|
+
if (old.valid_to != null) throw new WikiSupersedeError("already_expired", "expire()");
|
|
8637
|
+
if (old.source_type === "immutable_document") throw new WikiSupersedeError("immutable_target", "expire()");
|
|
8638
|
+
const start = old.valid_from ?? old.created_at;
|
|
8639
|
+
if (t <= start) throw new WikiSupersedeError("invalid_interval", "expire()");
|
|
8640
|
+
const changes = await this.entryRepo.setTemporal(factId, entityId, { valid_to: t }, tx);
|
|
8641
|
+
if (changes === 0) throw new WikiSupersedeError("cross_entity", "expire()");
|
|
8642
|
+
});
|
|
8643
|
+
await this.searchService.syncEntries(entityId, [factId]);
|
|
8644
|
+
this.searchService.evictCache(entityId);
|
|
8645
|
+
}
|
|
8615
8646
|
async history(entityId, factId) {
|
|
8616
8647
|
const start = await this.entryRepo.findTemporalRow(factId);
|
|
8617
8648
|
if (!start || start.entity_id !== entityId || start.deleted_at != null) return [];
|
|
@@ -10133,7 +10164,7 @@ var EraseStepError = class extends Error {
|
|
|
10133
10164
|
if (cause !== void 0) this.cause = cause;
|
|
10134
10165
|
}
|
|
10135
10166
|
};
|
|
10136
|
-
var
|
|
10167
|
+
var _MaintenanceService = class _MaintenanceService {
|
|
10137
10168
|
constructor(db, prefix, options, entryRepo, sourceRefIndexRepo, taskRepo, eventRepo, metadataRepo, searchService, jobManager, embeddingService, promptService, ontologyService, edgeRepo, vectorRemoval, vectorRemovalRepo) {
|
|
10138
10169
|
this.db = db;
|
|
10139
10170
|
this.prefix = prefix;
|
|
@@ -10362,6 +10393,7 @@ var MaintenanceService = class {
|
|
|
10362
10393
|
syncedIds: [],
|
|
10363
10394
|
registrySweep: { skipped: false, deleted: 0 },
|
|
10364
10395
|
retiredUndroppable: [],
|
|
10396
|
+
ftsOrphansCleared: [],
|
|
10365
10397
|
failedStep: null,
|
|
10366
10398
|
runtime: eraseRuntime(),
|
|
10367
10399
|
steps: []
|
|
@@ -10524,7 +10556,110 @@ var MaintenanceService = class {
|
|
|
10524
10556
|
this.jobManager.releaseLock("erase", "*");
|
|
10525
10557
|
}
|
|
10526
10558
|
}
|
|
10527
|
-
|
|
10559
|
+
/**
|
|
10560
|
+
* Step 3 remediation (specs/erase-fts-remediation): on a runtime without
|
|
10561
|
+
* usable strict drains, clear orphaned FTS5 surfaces so erasure can
|
|
10562
|
+
* complete verified. Per surface: existence gate (vtab OR any shadow) →
|
|
10563
|
+
* strategy check → vtab probe → path body → companions → state write.
|
|
10564
|
+
* Dispatch order is D4; exact-name allowlist interpolation is D2.
|
|
10565
|
+
*/
|
|
10566
|
+
async _eraseClearFtsOrphans(report) {
|
|
10567
|
+
const surfaces = [`${this.prefix}entries_fts`, `${this.prefix}source_passages_fts`];
|
|
10568
|
+
let remediationRequired = false;
|
|
10569
|
+
const pathBTargets = [];
|
|
10570
|
+
try {
|
|
10571
|
+
for (const surface of surfaces) {
|
|
10572
|
+
const vtabExists = await this.sourceTableExists(surface);
|
|
10573
|
+
const shadows = [];
|
|
10574
|
+
for (const sfx of _MaintenanceService.FTS_SHADOW_SUFFIXES) {
|
|
10575
|
+
const name = `${surface}${sfx}`;
|
|
10576
|
+
if (await this.sourceTableExists(name)) shadows.push(name);
|
|
10577
|
+
}
|
|
10578
|
+
if (!vtabExists && shadows.length === 0) continue;
|
|
10579
|
+
remediationRequired = true;
|
|
10580
|
+
if (this.searchService.isIndexUnavailable()) {
|
|
10581
|
+
report.failedStep = "index_sync";
|
|
10582
|
+
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);
|
|
10583
|
+
}
|
|
10584
|
+
let moduleLess = false;
|
|
10585
|
+
if (vtabExists) {
|
|
10586
|
+
try {
|
|
10587
|
+
await this.db.getFirstAsync(`SELECT 1 AS x FROM ${surface} LIMIT 1`);
|
|
10588
|
+
} catch (err) {
|
|
10589
|
+
let absent = false;
|
|
10590
|
+
let cur = err;
|
|
10591
|
+
for (let depth = 0; depth < 3 && cur != null && !absent; depth++) {
|
|
10592
|
+
let msg = "";
|
|
10593
|
+
try {
|
|
10594
|
+
msg = String(cur.message ?? cur);
|
|
10595
|
+
} catch {
|
|
10596
|
+
break;
|
|
10597
|
+
}
|
|
10598
|
+
absent = /no such module/i.test(msg);
|
|
10599
|
+
try {
|
|
10600
|
+
cur = cur.cause;
|
|
10601
|
+
} catch {
|
|
10602
|
+
break;
|
|
10603
|
+
}
|
|
10604
|
+
}
|
|
10605
|
+
if (!absent) {
|
|
10606
|
+
report.failedStep = "index_sync";
|
|
10607
|
+
throw new EraseStepError("erase_fts_orphan_probe_failed", `erase stopped at step 3: could not classify orphaned vtab ${surface}`, report, err);
|
|
10608
|
+
}
|
|
10609
|
+
moduleLess = true;
|
|
10610
|
+
}
|
|
10611
|
+
}
|
|
10612
|
+
if (vtabExists && !moduleLess) {
|
|
10613
|
+
if (this.options.config?.indexStrategy !== "minisearch") {
|
|
10614
|
+
report.failedStep = "index_sync";
|
|
10615
|
+
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);
|
|
10616
|
+
}
|
|
10617
|
+
pathBTargets.push(surface);
|
|
10618
|
+
continue;
|
|
10619
|
+
}
|
|
10620
|
+
const cleared = [];
|
|
10621
|
+
for (const name of shadows) {
|
|
10622
|
+
if (name.endsWith("_config")) continue;
|
|
10623
|
+
const res = await this.db.runAsync(name.endsWith("_data") ? `DELETE FROM ${name} WHERE id NOT IN (1, 10)` : `DELETE FROM ${name}`);
|
|
10624
|
+
if ((res?.changes ?? 0) > 0) cleared.push(name);
|
|
10625
|
+
}
|
|
10626
|
+
for (const name of cleared) {
|
|
10627
|
+
if (!report.ftsOrphansCleared.includes(name)) report.ftsOrphansCleared.push(name);
|
|
10628
|
+
emitDiagnostic(this.options, { code: "erase_fts_orphan_cleared", operation: "erase", trigger: "call", entityId: "", detail: { table: name } });
|
|
10629
|
+
}
|
|
10630
|
+
}
|
|
10631
|
+
if (!remediationRequired) return;
|
|
10632
|
+
const tailCleared = [];
|
|
10633
|
+
await this.db.withTransactionAsync(async (tx) => {
|
|
10634
|
+
for (const companion of [`${this.prefix}fts_pending`, `${this.prefix}fts_map`, `${this.prefix}source_passages_fts_pending`, `${this.prefix}source_passages_fts_map`]) {
|
|
10635
|
+
if (await this.sourceTableExists(companion, tx)) {
|
|
10636
|
+
const res = await tx.runAsync(`DELETE FROM ${companion}`);
|
|
10637
|
+
if ((res?.changes ?? 0) > 0 && !tailCleared.includes(companion)) tailCleared.push(companion);
|
|
10638
|
+
}
|
|
10639
|
+
}
|
|
10640
|
+
for (const surface of pathBTargets) {
|
|
10641
|
+
await tx.execAsync(`DROP TABLE IF EXISTS ${surface}`);
|
|
10642
|
+
if (!tailCleared.includes(surface)) tailCleared.push(surface);
|
|
10643
|
+
}
|
|
10644
|
+
if (pathBTargets.length > 0) {
|
|
10645
|
+
const [ai, ad] = passageFtsTriggerNames(this.prefix);
|
|
10646
|
+
await tx.execAsync(fts5LedgerDropSql(this.prefix) + `
|
|
10647
|
+
DROP TRIGGER IF EXISTS ${ai};
|
|
10648
|
+
DROP TRIGGER IF EXISTS ${ad};`);
|
|
10649
|
+
}
|
|
10650
|
+
await this.metadataRepo.setMeta(FTS5_STATE_KEY, "detached", tx);
|
|
10651
|
+
});
|
|
10652
|
+
for (const name of tailCleared) {
|
|
10653
|
+
if (!report.ftsOrphansCleared.includes(name)) report.ftsOrphansCleared.push(name);
|
|
10654
|
+
emitDiagnostic(this.options, { code: "erase_fts_orphan_cleared", operation: "erase", trigger: "call", entityId: "", detail: { table: name } });
|
|
10655
|
+
}
|
|
10656
|
+
report.steps.push({ step: "fts_orphan_clear", outcome: "ok" });
|
|
10657
|
+
} catch (err) {
|
|
10658
|
+
if (err instanceof EraseStepError) throw err;
|
|
10659
|
+
report.failedStep = "fts_orphan_clear";
|
|
10660
|
+
throw new EraseStepError("erase_fts_orphan_clear", "erase stopped at step 3: clearing an orphaned FTS surface failed; erasure is unverified", report, err);
|
|
10661
|
+
}
|
|
10662
|
+
}
|
|
10528
10663
|
/**
|
|
10529
10664
|
* Step 3: chained, surfaced drains (no deadline). Entries-ledger failures are
|
|
10530
10665
|
* the entries/index-sync step (`index_sync`); passage failures `passage_drain`.
|
|
@@ -10535,6 +10670,7 @@ var MaintenanceService = class {
|
|
|
10535
10670
|
*/
|
|
10536
10671
|
async _eraseDrainPassages(report) {
|
|
10537
10672
|
if (!this.searchService.hasStrictDrain()) {
|
|
10673
|
+
await this._eraseClearFtsOrphans(report);
|
|
10538
10674
|
for (const [table, failedStep, code] of [
|
|
10539
10675
|
[`${this.prefix}fts_pending`, "index_sync", "erase_index_sync_failed"],
|
|
10540
10676
|
[`${this.prefix}source_passages_fts_pending`, "passage_drain", "erase_passage_drain_failed"]
|
|
@@ -10551,19 +10687,6 @@ var MaintenanceService = class {
|
|
|
10551
10687
|
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);
|
|
10552
10688
|
}
|
|
10553
10689
|
}
|
|
10554
|
-
for (const suffix of ["entries_fts_content", "source_passages_fts_content"]) {
|
|
10555
|
-
let orphaned = false;
|
|
10556
|
-
try {
|
|
10557
|
-
orphaned = await this.sourceTableExists(`${this.prefix}${suffix}`);
|
|
10558
|
-
} catch (err) {
|
|
10559
|
-
report.failedStep = "index_sync";
|
|
10560
|
-
throw new EraseStepError("erase_orphaned_fts_content", `erase stopped: could not probe ${this.prefix}${suffix}`, report, err);
|
|
10561
|
-
}
|
|
10562
|
-
if (orphaned) {
|
|
10563
|
-
report.failedStep = "index_sync";
|
|
10564
|
-
throw new EraseStepError("erase_orphaned_fts_content", "erase stopped: orphaned full-text content tables may still hold forgotten text", report);
|
|
10565
|
-
}
|
|
10566
|
-
}
|
|
10567
10690
|
}
|
|
10568
10691
|
try {
|
|
10569
10692
|
await this.searchService.drainEntriesLedgerSurfaced();
|
|
@@ -10599,7 +10722,10 @@ var MaintenanceService = class {
|
|
|
10599
10722
|
try {
|
|
10600
10723
|
for (const name of await this._retiredList()) {
|
|
10601
10724
|
for (const sfx of ["_content", "_data", "_idx", "_docsize", "_config"]) {
|
|
10602
|
-
if (
|
|
10725
|
+
if (sfx === "_config") continue;
|
|
10726
|
+
if (await this.sourceTableExists(`${name}${sfx}`)) {
|
|
10727
|
+
await this.db.runAsync(sfx === "_data" ? `DELETE FROM ${name}_data WHERE id NOT IN (1, 10)` : `DELETE FROM ${name}${sfx}`);
|
|
10728
|
+
}
|
|
10603
10729
|
}
|
|
10604
10730
|
if (!report.retiredUndroppable.includes(name)) report.retiredUndroppable.push(name);
|
|
10605
10731
|
emitDiagnostic(this.options, { code: "erase_retired_vtab_undroppable", operation: "erase", trigger: "call", entityId: "" });
|
|
@@ -10619,8 +10745,8 @@ var MaintenanceService = class {
|
|
|
10619
10745
|
}
|
|
10620
10746
|
return Array.isArray(raw) ? raw.filter((n) => isRetiredTableName(this.prefix, n)) : [];
|
|
10621
10747
|
}
|
|
10622
|
-
sourceTableExists(name) {
|
|
10623
|
-
return this.metadataRepo.tableExists(name);
|
|
10748
|
+
sourceTableExists(name, tx) {
|
|
10749
|
+
return this.metadataRepo.tableExists(name, tx);
|
|
10624
10750
|
}
|
|
10625
10751
|
/** Step 6 sync: `syncEntries` resolving false means the ledger drain failed — a failed step. */
|
|
10626
10752
|
async _eraseSyncEntries(entityId, ids, report) {
|
|
@@ -11715,6 +11841,9 @@ var MaintenanceService = class {
|
|
|
11715
11841
|
return sanitizeRankerError(err, this.options.sanitizeRankerErrors);
|
|
11716
11842
|
}
|
|
11717
11843
|
};
|
|
11844
|
+
// ── Erase FTS surfaces (spec §2 steps 3/4/6-sync/7). T6 composes these into erase(). ──
|
|
11845
|
+
_MaintenanceService.FTS_SHADOW_SUFFIXES = ["_content", "_data", "_idx", "_docsize", "_config"];
|
|
11846
|
+
var MaintenanceService = _MaintenanceService;
|
|
11718
11847
|
|
|
11719
11848
|
// src/services/MaintenanceScheduler.ts
|
|
11720
11849
|
var MaintenanceScheduler = class {
|
|
@@ -15593,11 +15722,24 @@ var WikiMemory = class {
|
|
|
15593
15722
|
/**
|
|
15594
15723
|
* End `oldId`'s validity and link it to its replacement (spec §4.3). One
|
|
15595
15724
|
* transaction. Throws `WikiSupersedeError` for missing, foreign, already
|
|
15596
|
-
* superseded, immutable-document, or cyclic targets
|
|
15725
|
+
* superseded, already expired, immutable-document, or cyclic targets, and
|
|
15726
|
+
* for an inverted or empty interval (`invalid_interval`).
|
|
15597
15727
|
*/
|
|
15598
15728
|
async supersede(entityId, oldId, replacement, options) {
|
|
15599
15729
|
return this.temporalService.supersede(entityId, oldId, replacement, options);
|
|
15600
15730
|
}
|
|
15731
|
+
/**
|
|
15732
|
+
* End `factId`'s validity without a replacement — an archive, not a
|
|
15733
|
+
* deletion (INTENT rule 12). Sets `valid_to` only: `superseded_by`,
|
|
15734
|
+
* `superseded_at` and `deleted_at` stay untouched, and an `asOf` read at
|
|
15735
|
+
* `T` with `COALESCE(valid_from, created_at) <= T < valid_to` still returns
|
|
15736
|
+
* the fact. Throws `WikiSupersedeError` for
|
|
15737
|
+
* a missing, foreign, already superseded, immutable-document, or already
|
|
15738
|
+
* expired target, and for an inverted or empty interval (`invalid_interval`).
|
|
15739
|
+
*/
|
|
15740
|
+
async expire(entityId, factId, options) {
|
|
15741
|
+
return this.temporalService.expire(entityId, factId, options);
|
|
15742
|
+
}
|
|
15601
15743
|
/** The supersession chain containing `factId`, oldest first. [] when unknown. */
|
|
15602
15744
|
async history(entityId, factId) {
|
|
15603
15745
|
return this.temporalService.history(entityId, factId);
|