@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
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-C2HwksLd.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-C2HwksLd.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-C2HwksLd.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-C2HwksLd.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);
|
|
@@ -8612,6 +8620,27 @@ var TemporalService = class {
|
|
|
8612
8620
|
this.searchService.evictCache(entityId);
|
|
8613
8621
|
return { newId };
|
|
8614
8622
|
}
|
|
8623
|
+
/**
|
|
8624
|
+
* End `factId`'s validity without a replacement — an archive, not a
|
|
8625
|
+
* deletion (INTENT rule 12, spec specs/expire). Sets `valid_to` only.
|
|
8626
|
+
*/
|
|
8627
|
+
async expire(entityId, factId, options) {
|
|
8628
|
+
const t = options?.at === void 0 ? Date.now() : assertEpochMs("options.at", options.at);
|
|
8629
|
+
await this.db.withTransactionAsync(async (tx) => {
|
|
8630
|
+
const old = await this.entryRepo.findTemporalRow(factId, tx);
|
|
8631
|
+
if (!old || old.deleted_at != null) throw new WikiSupersedeError("not_found", "expire()");
|
|
8632
|
+
if (old.entity_id !== entityId) throw new WikiSupersedeError("cross_entity", "expire()");
|
|
8633
|
+
if (old.superseded_by != null) throw new WikiSupersedeError("already_superseded", "expire()");
|
|
8634
|
+
if (old.valid_to != null) throw new WikiSupersedeError("already_expired", "expire()");
|
|
8635
|
+
if (old.source_type === "immutable_document") throw new WikiSupersedeError("immutable_target", "expire()");
|
|
8636
|
+
const start = old.valid_from ?? old.created_at;
|
|
8637
|
+
if (t <= start) throw new WikiSupersedeError("invalid_interval", "expire()");
|
|
8638
|
+
const changes = await this.entryRepo.setTemporal(factId, entityId, { valid_to: t }, tx);
|
|
8639
|
+
if (changes === 0) throw new WikiSupersedeError("cross_entity", "expire()");
|
|
8640
|
+
});
|
|
8641
|
+
await this.searchService.syncEntries(entityId, [factId]);
|
|
8642
|
+
this.searchService.evictCache(entityId);
|
|
8643
|
+
}
|
|
8615
8644
|
async history(entityId, factId) {
|
|
8616
8645
|
const start = await this.entryRepo.findTemporalRow(factId);
|
|
8617
8646
|
if (!start || start.entity_id !== entityId || start.deleted_at != null) return [];
|
|
@@ -10133,7 +10162,7 @@ var EraseStepError = class extends Error {
|
|
|
10133
10162
|
if (cause !== void 0) this.cause = cause;
|
|
10134
10163
|
}
|
|
10135
10164
|
};
|
|
10136
|
-
var
|
|
10165
|
+
var _MaintenanceService = class _MaintenanceService {
|
|
10137
10166
|
constructor(db, prefix, options, entryRepo, sourceRefIndexRepo, taskRepo, eventRepo, metadataRepo, searchService, jobManager, embeddingService, promptService, ontologyService, edgeRepo, vectorRemoval, vectorRemovalRepo) {
|
|
10138
10167
|
this.db = db;
|
|
10139
10168
|
this.prefix = prefix;
|
|
@@ -10362,6 +10391,7 @@ var MaintenanceService = class {
|
|
|
10362
10391
|
syncedIds: [],
|
|
10363
10392
|
registrySweep: { skipped: false, deleted: 0 },
|
|
10364
10393
|
retiredUndroppable: [],
|
|
10394
|
+
ftsOrphansCleared: [],
|
|
10365
10395
|
failedStep: null,
|
|
10366
10396
|
runtime: eraseRuntime(),
|
|
10367
10397
|
steps: []
|
|
@@ -10524,7 +10554,110 @@ var MaintenanceService = class {
|
|
|
10524
10554
|
this.jobManager.releaseLock("erase", "*");
|
|
10525
10555
|
}
|
|
10526
10556
|
}
|
|
10527
|
-
|
|
10557
|
+
/**
|
|
10558
|
+
* Step 3 remediation (specs/erase-fts-remediation): on a runtime without
|
|
10559
|
+
* usable strict drains, clear orphaned FTS5 surfaces so erasure can
|
|
10560
|
+
* complete verified. Per surface: existence gate (vtab OR any shadow) →
|
|
10561
|
+
* strategy check → vtab probe → path body → companions → state write.
|
|
10562
|
+
* Dispatch order is D4; exact-name allowlist interpolation is D2.
|
|
10563
|
+
*/
|
|
10564
|
+
async _eraseClearFtsOrphans(report) {
|
|
10565
|
+
const surfaces = [`${this.prefix}entries_fts`, `${this.prefix}source_passages_fts`];
|
|
10566
|
+
let remediationRequired = false;
|
|
10567
|
+
const pathBTargets = [];
|
|
10568
|
+
try {
|
|
10569
|
+
for (const surface of surfaces) {
|
|
10570
|
+
const vtabExists = await this.sourceTableExists(surface);
|
|
10571
|
+
const shadows = [];
|
|
10572
|
+
for (const sfx of _MaintenanceService.FTS_SHADOW_SUFFIXES) {
|
|
10573
|
+
const name = `${surface}${sfx}`;
|
|
10574
|
+
if (await this.sourceTableExists(name)) shadows.push(name);
|
|
10575
|
+
}
|
|
10576
|
+
if (!vtabExists && shadows.length === 0) continue;
|
|
10577
|
+
remediationRequired = true;
|
|
10578
|
+
if (this.searchService.isIndexUnavailable()) {
|
|
10579
|
+
report.failedStep = "index_sync";
|
|
10580
|
+
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);
|
|
10581
|
+
}
|
|
10582
|
+
let moduleLess = false;
|
|
10583
|
+
if (vtabExists) {
|
|
10584
|
+
try {
|
|
10585
|
+
await this.db.getFirstAsync(`SELECT 1 AS x FROM ${surface} LIMIT 1`);
|
|
10586
|
+
} catch (err) {
|
|
10587
|
+
let absent = false;
|
|
10588
|
+
let cur = err;
|
|
10589
|
+
for (let depth = 0; depth < 3 && cur != null && !absent; depth++) {
|
|
10590
|
+
let msg = "";
|
|
10591
|
+
try {
|
|
10592
|
+
msg = String(cur.message ?? cur);
|
|
10593
|
+
} catch {
|
|
10594
|
+
break;
|
|
10595
|
+
}
|
|
10596
|
+
absent = /no such module/i.test(msg);
|
|
10597
|
+
try {
|
|
10598
|
+
cur = cur.cause;
|
|
10599
|
+
} catch {
|
|
10600
|
+
break;
|
|
10601
|
+
}
|
|
10602
|
+
}
|
|
10603
|
+
if (!absent) {
|
|
10604
|
+
report.failedStep = "index_sync";
|
|
10605
|
+
throw new EraseStepError("erase_fts_orphan_probe_failed", `erase stopped at step 3: could not classify orphaned vtab ${surface}`, report, err);
|
|
10606
|
+
}
|
|
10607
|
+
moduleLess = true;
|
|
10608
|
+
}
|
|
10609
|
+
}
|
|
10610
|
+
if (vtabExists && !moduleLess) {
|
|
10611
|
+
if (this.options.config?.indexStrategy !== "minisearch") {
|
|
10612
|
+
report.failedStep = "index_sync";
|
|
10613
|
+
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);
|
|
10614
|
+
}
|
|
10615
|
+
pathBTargets.push(surface);
|
|
10616
|
+
continue;
|
|
10617
|
+
}
|
|
10618
|
+
const cleared = [];
|
|
10619
|
+
for (const name of shadows) {
|
|
10620
|
+
if (name.endsWith("_config")) continue;
|
|
10621
|
+
const res = await this.db.runAsync(name.endsWith("_data") ? `DELETE FROM ${name} WHERE id NOT IN (1, 10)` : `DELETE FROM ${name}`);
|
|
10622
|
+
if ((res?.changes ?? 0) > 0) cleared.push(name);
|
|
10623
|
+
}
|
|
10624
|
+
for (const name of cleared) {
|
|
10625
|
+
if (!report.ftsOrphansCleared.includes(name)) report.ftsOrphansCleared.push(name);
|
|
10626
|
+
emitDiagnostic(this.options, { code: "erase_fts_orphan_cleared", operation: "erase", trigger: "call", entityId: "", detail: { table: name } });
|
|
10627
|
+
}
|
|
10628
|
+
}
|
|
10629
|
+
if (!remediationRequired) return;
|
|
10630
|
+
const tailCleared = [];
|
|
10631
|
+
await this.db.withTransactionAsync(async (tx) => {
|
|
10632
|
+
for (const companion of [`${this.prefix}fts_pending`, `${this.prefix}fts_map`, `${this.prefix}source_passages_fts_pending`, `${this.prefix}source_passages_fts_map`]) {
|
|
10633
|
+
if (await this.sourceTableExists(companion, tx)) {
|
|
10634
|
+
const res = await tx.runAsync(`DELETE FROM ${companion}`);
|
|
10635
|
+
if ((res?.changes ?? 0) > 0 && !tailCleared.includes(companion)) tailCleared.push(companion);
|
|
10636
|
+
}
|
|
10637
|
+
}
|
|
10638
|
+
for (const surface of pathBTargets) {
|
|
10639
|
+
await tx.execAsync(`DROP TABLE IF EXISTS ${surface}`);
|
|
10640
|
+
if (!tailCleared.includes(surface)) tailCleared.push(surface);
|
|
10641
|
+
}
|
|
10642
|
+
if (pathBTargets.length > 0) {
|
|
10643
|
+
const [ai, ad] = passageFtsTriggerNames(this.prefix);
|
|
10644
|
+
await tx.execAsync(fts5LedgerDropSql(this.prefix) + `
|
|
10645
|
+
DROP TRIGGER IF EXISTS ${ai};
|
|
10646
|
+
DROP TRIGGER IF EXISTS ${ad};`);
|
|
10647
|
+
}
|
|
10648
|
+
await this.metadataRepo.setMeta(FTS5_STATE_KEY, "detached", tx);
|
|
10649
|
+
});
|
|
10650
|
+
for (const name of tailCleared) {
|
|
10651
|
+
if (!report.ftsOrphansCleared.includes(name)) report.ftsOrphansCleared.push(name);
|
|
10652
|
+
emitDiagnostic(this.options, { code: "erase_fts_orphan_cleared", operation: "erase", trigger: "call", entityId: "", detail: { table: name } });
|
|
10653
|
+
}
|
|
10654
|
+
report.steps.push({ step: "fts_orphan_clear", outcome: "ok" });
|
|
10655
|
+
} catch (err) {
|
|
10656
|
+
if (err instanceof EraseStepError) throw err;
|
|
10657
|
+
report.failedStep = "fts_orphan_clear";
|
|
10658
|
+
throw new EraseStepError("erase_fts_orphan_clear", "erase stopped at step 3: clearing an orphaned FTS surface failed; erasure is unverified", report, err);
|
|
10659
|
+
}
|
|
10660
|
+
}
|
|
10528
10661
|
/**
|
|
10529
10662
|
* Step 3: chained, surfaced drains (no deadline). Entries-ledger failures are
|
|
10530
10663
|
* the entries/index-sync step (`index_sync`); passage failures `passage_drain`.
|
|
@@ -10535,6 +10668,7 @@ var MaintenanceService = class {
|
|
|
10535
10668
|
*/
|
|
10536
10669
|
async _eraseDrainPassages(report) {
|
|
10537
10670
|
if (!this.searchService.hasStrictDrain()) {
|
|
10671
|
+
await this._eraseClearFtsOrphans(report);
|
|
10538
10672
|
for (const [table, failedStep, code] of [
|
|
10539
10673
|
[`${this.prefix}fts_pending`, "index_sync", "erase_index_sync_failed"],
|
|
10540
10674
|
[`${this.prefix}source_passages_fts_pending`, "passage_drain", "erase_passage_drain_failed"]
|
|
@@ -10551,19 +10685,6 @@ var MaintenanceService = class {
|
|
|
10551
10685
|
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
10686
|
}
|
|
10553
10687
|
}
|
|
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
10688
|
}
|
|
10568
10689
|
try {
|
|
10569
10690
|
await this.searchService.drainEntriesLedgerSurfaced();
|
|
@@ -10599,7 +10720,10 @@ var MaintenanceService = class {
|
|
|
10599
10720
|
try {
|
|
10600
10721
|
for (const name of await this._retiredList()) {
|
|
10601
10722
|
for (const sfx of ["_content", "_data", "_idx", "_docsize", "_config"]) {
|
|
10602
|
-
if (
|
|
10723
|
+
if (sfx === "_config") continue;
|
|
10724
|
+
if (await this.sourceTableExists(`${name}${sfx}`)) {
|
|
10725
|
+
await this.db.runAsync(sfx === "_data" ? `DELETE FROM ${name}_data WHERE id NOT IN (1, 10)` : `DELETE FROM ${name}${sfx}`);
|
|
10726
|
+
}
|
|
10603
10727
|
}
|
|
10604
10728
|
if (!report.retiredUndroppable.includes(name)) report.retiredUndroppable.push(name);
|
|
10605
10729
|
emitDiagnostic(this.options, { code: "erase_retired_vtab_undroppable", operation: "erase", trigger: "call", entityId: "" });
|
|
@@ -10619,8 +10743,8 @@ var MaintenanceService = class {
|
|
|
10619
10743
|
}
|
|
10620
10744
|
return Array.isArray(raw) ? raw.filter((n) => isRetiredTableName(this.prefix, n)) : [];
|
|
10621
10745
|
}
|
|
10622
|
-
sourceTableExists(name) {
|
|
10623
|
-
return this.metadataRepo.tableExists(name);
|
|
10746
|
+
sourceTableExists(name, tx) {
|
|
10747
|
+
return this.metadataRepo.tableExists(name, tx);
|
|
10624
10748
|
}
|
|
10625
10749
|
/** Step 6 sync: `syncEntries` resolving false means the ledger drain failed — a failed step. */
|
|
10626
10750
|
async _eraseSyncEntries(entityId, ids, report) {
|
|
@@ -11715,6 +11839,9 @@ var MaintenanceService = class {
|
|
|
11715
11839
|
return sanitizeRankerError(err, this.options.sanitizeRankerErrors);
|
|
11716
11840
|
}
|
|
11717
11841
|
};
|
|
11842
|
+
// ── Erase FTS surfaces (spec §2 steps 3/4/6-sync/7). T6 composes these into erase(). ──
|
|
11843
|
+
_MaintenanceService.FTS_SHADOW_SUFFIXES = ["_content", "_data", "_idx", "_docsize", "_config"];
|
|
11844
|
+
var MaintenanceService = _MaintenanceService;
|
|
11718
11845
|
|
|
11719
11846
|
// src/services/MaintenanceScheduler.ts
|
|
11720
11847
|
var MaintenanceScheduler = class {
|
|
@@ -15593,11 +15720,23 @@ var WikiMemory = class {
|
|
|
15593
15720
|
/**
|
|
15594
15721
|
* End `oldId`'s validity and link it to its replacement (spec §4.3). One
|
|
15595
15722
|
* transaction. Throws `WikiSupersedeError` for missing, foreign, already
|
|
15596
|
-
* superseded, immutable-document, or cyclic targets.
|
|
15723
|
+
* superseded, already expired, immutable-document, or cyclic targets.
|
|
15597
15724
|
*/
|
|
15598
15725
|
async supersede(entityId, oldId, replacement, options) {
|
|
15599
15726
|
return this.temporalService.supersede(entityId, oldId, replacement, options);
|
|
15600
15727
|
}
|
|
15728
|
+
/**
|
|
15729
|
+
* End `factId`'s validity without a replacement — an archive, not a
|
|
15730
|
+
* deletion (INTENT rule 12). Sets `valid_to` only: `superseded_by`,
|
|
15731
|
+
* `superseded_at` and `deleted_at` stay untouched, and an `asOf` read at
|
|
15732
|
+
* `T` with `COALESCE(valid_from, created_at) <= T < valid_to` still returns
|
|
15733
|
+
* the fact. Throws `WikiSupersedeError` for
|
|
15734
|
+
* a missing, foreign, already superseded, immutable-document, or already
|
|
15735
|
+
* expired target, and for an inverted or empty interval (`invalid_interval`).
|
|
15736
|
+
*/
|
|
15737
|
+
async expire(entityId, factId, options) {
|
|
15738
|
+
return this.temporalService.expire(entityId, factId, options);
|
|
15739
|
+
}
|
|
15601
15740
|
/** The supersession chain containing `factId`, oldest first. [] when unknown. */
|
|
15602
15741
|
async history(entityId, factId) {
|
|
15603
15742
|
return this.temporalService.history(entityId, factId);
|