@equationalapplications/core-llm-wiki 7.11.2 → 7.12.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.
@@ -209,6 +209,10 @@ interface HealResult {
209
209
  * cooldown", not "there is no more work" — it climbs back as the cooldown lapses
210
210
  * and as new facts are written. A host loop terminates, but it converges to
211
211
  * "corpus swept once this cooldown window", not to a drained queue.
212
+ *
213
+ * A pass that could not make progress (`searchUnavailable` or `budgetStop`
214
+ * set) leaves `remaining > 0`, so a convergence loop must also stop on those:
215
+ * `while (r.remaining > 0 && !r.searchUnavailable && !r.budgetStop)`.
212
216
  */
213
217
  remaining: number;
214
218
  /** Heal candidates inside the recheck cooldown. */
@@ -217,6 +221,12 @@ interface HealResult {
217
221
  budgetStop?: {
218
222
  requiredEstimate: number;
219
223
  };
224
+ /**
225
+ * True when the LLM pass was skipped because keyword search is unavailable
226
+ * (heal anchors need it; spec #280). Candidates stay eligible and unattempted;
227
+ * retry after `syncSearchIndex()` restores keyword search.
228
+ */
229
+ searchUnavailable?: true;
220
230
  }
221
231
  /**
222
232
  * Opt-in evidence check for LLM-authored facts (spec §6). Default off: 7.x
@@ -324,6 +334,12 @@ interface WikiConfig {
324
334
  * entries table, so memory stays flat at any size. The first `setup()` that
325
335
  * attaches FTS5 to an existing database rebuilds the index in one
326
336
  * transaction, holding the write lock for its whole duration.
337
+ * If FTS5 init fails under `'auto'`, `setup()` retries once after 250 ms and
338
+ * then completes with keyword search unavailable (queries throw
339
+ * `WikiSearchUnavailableError`); it never demotes to MiniSearch. MiniSearch
340
+ * is used only when pinned or when the SQLite build lacks FTS5/json1, and it
341
+ * holds all entry text in the JS heap: the measured ceiling is ~1M entries
342
+ * on a default Node heap (raise `--max-old-space-size` for larger stores).
327
343
  * @default 'auto'
328
344
  */
329
345
  indexStrategy?: 'fts5' | 'minisearch' | 'auto';
@@ -355,6 +371,14 @@ interface WikiConfig {
355
371
  maintenance?: 'auto' | 'deferred';
356
372
  /** `'auto'` mode only: also trigger the librarian when pending event text reaches ~this many tokens (chars/4). */
357
373
  autoLibrarianTokenThreshold?: number;
374
+ /**
375
+ * Migration policy for setup().
376
+ * - `'allow'`: Run all migrations (default, preserves existing behavior)
377
+ * - `'refuse'`: Throw WikiMigrationRequiredError before any mutations
378
+ * - `'auto'`: Run the source_ref normalize if pending; throw if a schema migration is pending
379
+ * @default 'allow'
380
+ */
381
+ migrations?: MigrationPolicy;
358
382
  }
359
383
  interface ReadOptions {
360
384
  maxResults?: number;
@@ -1266,6 +1290,12 @@ interface EntityMaintenanceReport {
1266
1290
  reembedded: boolean;
1267
1291
  /** Set when a lock was held elsewhere; nothing ran for that job. */
1268
1292
  busy?: MaintenanceJob[];
1293
+ /**
1294
+ * Set when keyword search is unavailable and the job could not run for this
1295
+ * entity (spec #280). Its watermark/checkpoint is kept; retry after
1296
+ * `syncSearchIndex()` restores keyword search.
1297
+ */
1298
+ searchUnavailable?: MaintenanceJob[];
1269
1299
  }
1270
1300
  interface RunPendingMaintenanceResult {
1271
1301
  perEntity: EntityMaintenanceReport[];
@@ -1276,6 +1306,33 @@ interface RunPendingMaintenanceResult {
1276
1306
  remaining: number | null;
1277
1307
  stoppedReason: MaintenanceStopReason;
1278
1308
  }
1309
+ type MigrationPolicy = 'allow' | 'refuse' | 'auto';
1310
+ /** Work the migration gate found pending on an existing store. Watermarks are resume rowids (0 = not started). */
1311
+ type PendingMigrationWork = {
1312
+ type: 'schema_migration';
1313
+ fromVersion: number;
1314
+ toVersion: number;
1315
+ } | {
1316
+ type: 'source_ref_normalize';
1317
+ entriesWatermark: number;
1318
+ sourceRefIndexWatermark: number;
1319
+ };
1320
+ declare class WikiMigrationRequiredError extends Error {
1321
+ readonly code = "WIKI_MIGRATION_REQUIRED";
1322
+ readonly pendingWork: PendingMigrationWork;
1323
+ constructor(message: string, pendingWork: PendingMigrationWork);
1324
+ }
1325
+ /**
1326
+ * Thrown per keyword-search query while the keyword index is unavailable
1327
+ * (FTS5 init failed after its retry; spec #280 Change 4). Writes keep working
1328
+ * and the index converges once a later open or no-arg syncSearchIndex()
1329
+ * re-inits successfully. `cause` is the underlying init error.
1330
+ */
1331
+ declare class WikiSearchUnavailableError extends Error {
1332
+ constructor(message?: string, cause?: unknown);
1333
+ }
1334
+ /** Proxy-safe `instanceof WikiSearchUnavailableError` (issue #96). */
1335
+ declare function isWikiSearchUnavailableError(err: unknown): boolean;
1279
1336
 
1280
1337
  interface WikiOutboxEvent<T = unknown> {
1281
1338
  id: string;
@@ -1395,6 +1452,8 @@ declare class EntryRepository extends BaseRepository {
1395
1452
  private static readonly MINI_SEARCH_LIVE_WHERE;
1396
1453
  private chunkSize;
1397
1454
  constructor(db: SQLiteAdapter, prefix: string, outbox: OutboxRepository);
1455
+ /** Whether the entity has any non-deleted row (librarian gate: keyword ranking over zero facts is trivially empty). */
1456
+ hasLiveEntry(entityId: string, tx?: SQLiteAdapter): Promise<boolean>;
1398
1457
  /**
1399
1458
  * Fetch facts by IDs, optionally scoped to entity IDs.
1400
1459
  * Returns facts in the order of the input IDs (first match wins).
@@ -1653,11 +1712,6 @@ declare class EntryRepository extends BaseRepository {
1653
1712
  hasLegacySourceTypes(tx?: SQLiteAdapter): Promise<boolean>;
1654
1713
  countLegacySourceTypes(tx?: SQLiteAdapter): Promise<number>;
1655
1714
  findAllForReembed(entityId?: string, tx?: SQLiteAdapter): Promise<ReembedCandidateRow[]>;
1656
- findRowsForSourceRefMigration(tx?: SQLiteAdapter): Promise<Array<{
1657
- rowid: number;
1658
- source_ref: string;
1659
- }>>;
1660
- updateSourceRefByRowid(rowid: number, sourceRef: string | null, tx: SQLiteAdapter): Promise<void>;
1661
1715
  findLatestSourceHash(entityId: string, sourceRef: string, tx?: SQLiteAdapter): Promise<string | null>;
1662
1716
  /**
1663
1717
  * Batch version of {@link findLatestSourceHash}. Returns a Map covering every
@@ -2123,6 +2177,8 @@ declare class SearchService {
2123
2177
  * service runs on an empty MiniSearch placeholder, as it always has.
2124
2178
  */
2125
2179
  setIndexStrategy(strategy: IndexStrategy): void;
2180
+ /** False while the installed strategy is the degraded UnavailableIndexStrategy (spec #280 Change 4). */
2181
+ isKeywordAvailable(): boolean;
2126
2182
  /**
2127
2183
  * One serialized drain turn for strategies with a durable ledger. Like
2128
2184
  * sync(), it never rejects: the keyword index is rebuildable, and a failed
@@ -3192,7 +3248,8 @@ declare class MaintenanceService {
3192
3248
  *
3193
3249
  * Bounded: at most `batchSize` candidates per pass (#67). Loop on
3194
3250
  * `result.remaining > 0` for convergence — see {@link HealResult.remaining}
3195
- * for what convergence means here.
3251
+ * for what convergence means here, and for the no-progress flags
3252
+ * (`searchUnavailable`, `budgetStop`) a loop must also stop on.
3196
3253
  */
3197
3254
  doRunHeal(entityId: string, options?: {
3198
3255
  promptOverride?: string;
@@ -3368,6 +3425,7 @@ declare class WriteService {
3368
3425
  * {@link write}) so a partial pass retries on the next write.
3369
3426
  */
3370
3427
  private maybeRunHeal;
3428
+ private warnedSearchUnavailable;
3371
3429
  private reportBackgroundFailure;
3372
3430
  }
3373
3431
 
@@ -3457,7 +3515,25 @@ declare class WikiMemory {
3457
3515
  * If `NODE_ENV` is not `"test"`, emits a single `console.warn` per instance (skipped when `process` is undefined).
3458
3516
  */
3459
3517
  get __testAccess(): WikiMemoryTestAccess;
3460
- setup(): Promise<void>;
3518
+ private reinitSearch;
3519
+ /** Monotonic time before which a no-arg syncSearchIndex() skips the re-init (0 = no cooldown). */
3520
+ private reinitRetryAt;
3521
+ /** Consecutive failed re-inits; drives the exponential backoff. */
3522
+ private reinitFailures;
3523
+ /**
3524
+ * Opens the store: migration gate, DDL, schema migrations, then the stamped
3525
+ * source_ref normalize. Await it before any other call on this instance — the
3526
+ * normalize commits in chunks, so a sourceRef-keyed call (forget, upsertGraph,
3527
+ * hasChanged, ingest) issued before setup() resolves can see partially
3528
+ * normalized refs.
3529
+ *
3530
+ * Pass `{ migrations: 'refuse' }` from inside a writer lease: pending one-time
3531
+ * work then throws WikiMigrationRequiredError before any mutation, and the
3532
+ * host runs a plain `setup()` outside the lease.
3533
+ */
3534
+ setup(opts?: {
3535
+ migrations?: MigrationPolicy;
3536
+ }): Promise<void>;
3461
3537
  hasChanged(entityId: string, sourceRef: string, sourceHash: string): Promise<boolean>;
3462
3538
  /**
3463
3539
  * Batched overload.
@@ -3644,7 +3720,10 @@ declare class WikiMemory {
3644
3720
  * indexed; otherwise it is a no-op that still waits for rebuilds already
3645
3721
  * queued. Without an argument, rebuilds every entity currently marked
3646
3722
  * stale; when none is, it resolves immediately and does not wait for rebuilds
3647
- * already queued.
3723
+ * already queued. While keyword search is unavailable it first retries the
3724
+ * index init; after a failed attempt it waits at least 5 s, doubling per
3725
+ * consecutive failure up to 5 min (longer when an attempt is itself slow),
3726
+ * before retrying again.
3648
3727
  *
3649
3728
  * Call only after the host's transaction commits: called inside it, the
3650
3729
  * rebuild may index rows that later roll back, or miss them and clear the
@@ -3887,4 +3966,4 @@ declare class WikiMemory {
3887
3966
  setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
3888
3967
  }
3889
3968
 
3890
- export { type ReembedResult as $, ONTOLOGY_BACKFILL_RECHECK_MS as A, type OntologyBackfillResult as B, type ChunkFailure as C, type DegradedRecord as D, type EmbedFactResult as E, type FormatContextOptions as F, type GraphNeighborhood as G, HEAL_BATCH_SIZE as H, type IngestDocumentResult as I, type OntologyConfig as J, type OntologyEdgeType as K, type LLMProvider as L, type MemoryBundle as M, type OntologyManifest as N, ONTOLOGY_BACKFILL_BATCH_SIZE as O, type OntologyMode as P, type OntologyNodeType as Q, type ReadOptions as R, type SQLiteAdapter as S, type OntologyPromptContext as T, type OntologyUpdates as U, type PendingMaintenance as V, type WikiOptions as W, type PendingSourceStatus as X, type PromptOverrides as Y, PromptService as Z, PrunePartialFailureError as _, type MemoryDump as a, type RunPendingMaintenanceOptions as a0, type RunPendingMaintenanceResult as a1, type SupersedeReplacement as a2, type VectorRanker as a3, type VectorRankerFallback as a4, type VectorRankerRankArgs as a5, type VectorRankerSemanticResult as a6, WikiBusyError as a7, type WikiBusyOperation as a8, type WikiCheckpoint as a9, validateManifest as aA, EmbeddingService as aB, ImportExportService as aC, IngestionService as aD, JobManager as aE, MaintenanceService as aF, RetrievalService as aG, SearchService as aH, WriteService as aI, type WikiConfig as aa, type WikiDiagnostic as ab, type WikiDiagnosticCode as ac, type WikiDiagnosticDetail as ad, type WikiDiagnosticOperation as ae, type WikiDiagnosticSeverity as af, type WikiDiagnosticTrigger as ag, WikiDraftNotFound as ah, WikiDuplicateHashError as ai, type WikiEdge as aj, type WikiEvent as ak, type WikiFact as al, WikiGraphNodeOwnershipConflict as am, WikiIngestEmptyError as an, type WikiInstructions as ao, WikiInvalidReadOptions as ap, type WikiLintReport as aq, type WikiMemoryTestAccess as ar, type WikiOutboxEvent as as, WikiParseError as at, WikiSourceRefHashCollision as au, WikiStrictOntologyViolation as av, WikiSupersedeError as aw, type WikiSupersedeReason as ax, type WikiTask as ay, WikiTransactionError as az, type FormattedMemoryDump as b, WikiMemory as c, type ClassifierAnswer as d, type ClassifierQuestion as e, type ClassifyRequest as f, type ClassifyResponse as g, type DraftPage as h, type EmbedFailureKind as i, type EmbeddingMarkerKind as j, type EntityMaintenanceReport as k, type EntityStatus as l, type ExtractedFact as m, type ExtractedFactEdge as n, type ExtractedFactWithOntology as o, type ExtractedTask as p, type GraphTraversalOptions as q, type GroundingConfig as r, HEAL_RECHECK_MS as s, HOOK_TIMEOUT_MARKER as t, type HealResult as u, type LibrarianConfig as v, type LibrarianGateConfig as w, type MaintenanceJob as x, type MaintenanceStopReason as y, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as z };
3969
+ export { PromptService as $, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as A, ONTOLOGY_BACKFILL_RECHECK_MS as B, type ChunkFailure as C, type DegradedRecord as D, type EmbedFactResult as E, type FormatContextOptions as F, type GraphNeighborhood as G, HEAL_BATCH_SIZE as H, type IngestDocumentResult as I, type OntologyBackfillResult as J, type OntologyConfig as K, type LLMProvider as L, type MemoryBundle as M, type OntologyEdgeType as N, ONTOLOGY_BACKFILL_BATCH_SIZE as O, type OntologyManifest as P, type OntologyMode as Q, type ReadOptions as R, type SQLiteAdapter as S, type OntologyNodeType as T, type OntologyPromptContext as U, type OntologyUpdates as V, type WikiOptions as W, type PendingMaintenance as X, type PendingMigrationWork as Y, type PendingSourceStatus as Z, type PromptOverrides as _, type MemoryDump as a, PrunePartialFailureError as a0, type ReembedResult as a1, type RunPendingMaintenanceOptions as a2, type RunPendingMaintenanceResult as a3, type SupersedeReplacement as a4, type VectorRanker as a5, type VectorRankerFallback as a6, type VectorRankerRankArgs as a7, type VectorRankerSemanticResult as a8, WikiBusyError as a9, WikiSupersedeError as aA, type WikiSupersedeReason as aB, type WikiTask as aC, WikiTransactionError as aD, isWikiSearchUnavailableError as aE, validateManifest as aF, EmbeddingService as aG, ImportExportService as aH, IngestionService as aI, JobManager as aJ, MaintenanceService as aK, RetrievalService as aL, SearchService as aM, WriteService as aN, type WikiBusyOperation as aa, type WikiCheckpoint as ab, type WikiConfig as ac, type WikiDiagnostic as ad, type WikiDiagnosticCode as ae, type WikiDiagnosticDetail as af, type WikiDiagnosticOperation as ag, type WikiDiagnosticSeverity as ah, type WikiDiagnosticTrigger as ai, WikiDraftNotFound as aj, WikiDuplicateHashError as ak, type WikiEdge as al, type WikiEvent as am, type WikiFact as an, WikiGraphNodeOwnershipConflict as ao, WikiIngestEmptyError as ap, type WikiInstructions as aq, WikiInvalidReadOptions as ar, type WikiLintReport as as, type WikiMemoryTestAccess as at, WikiMigrationRequiredError as au, type WikiOutboxEvent as av, WikiParseError as aw, WikiSearchUnavailableError as ax, WikiSourceRefHashCollision as ay, WikiStrictOntologyViolation as az, type FormattedMemoryDump as b, WikiMemory as c, type ClassifierAnswer as d, type ClassifierQuestion as e, type ClassifyRequest as f, type ClassifyResponse as g, type DraftPage as h, type EmbedFailureKind as i, type EmbeddingMarkerKind as j, type EntityMaintenanceReport as k, type EntityStatus as l, type ExtractedFact as m, type ExtractedFactEdge as n, type ExtractedFactWithOntology as o, type ExtractedTask as p, type GraphTraversalOptions as q, type GroundingConfig as r, HEAL_RECHECK_MS as s, HOOK_TIMEOUT_MARKER as t, type HealResult as u, type LibrarianConfig as v, type LibrarianGateConfig as w, type MaintenanceJob as x, type MaintenanceStopReason as y, type MigrationPolicy as z };
@@ -209,6 +209,10 @@ interface HealResult {
209
209
  * cooldown", not "there is no more work" — it climbs back as the cooldown lapses
210
210
  * and as new facts are written. A host loop terminates, but it converges to
211
211
  * "corpus swept once this cooldown window", not to a drained queue.
212
+ *
213
+ * A pass that could not make progress (`searchUnavailable` or `budgetStop`
214
+ * set) leaves `remaining > 0`, so a convergence loop must also stop on those:
215
+ * `while (r.remaining > 0 && !r.searchUnavailable && !r.budgetStop)`.
212
216
  */
213
217
  remaining: number;
214
218
  /** Heal candidates inside the recheck cooldown. */
@@ -217,6 +221,12 @@ interface HealResult {
217
221
  budgetStop?: {
218
222
  requiredEstimate: number;
219
223
  };
224
+ /**
225
+ * True when the LLM pass was skipped because keyword search is unavailable
226
+ * (heal anchors need it; spec #280). Candidates stay eligible and unattempted;
227
+ * retry after `syncSearchIndex()` restores keyword search.
228
+ */
229
+ searchUnavailable?: true;
220
230
  }
221
231
  /**
222
232
  * Opt-in evidence check for LLM-authored facts (spec §6). Default off: 7.x
@@ -324,6 +334,12 @@ interface WikiConfig {
324
334
  * entries table, so memory stays flat at any size. The first `setup()` that
325
335
  * attaches FTS5 to an existing database rebuilds the index in one
326
336
  * transaction, holding the write lock for its whole duration.
337
+ * If FTS5 init fails under `'auto'`, `setup()` retries once after 250 ms and
338
+ * then completes with keyword search unavailable (queries throw
339
+ * `WikiSearchUnavailableError`); it never demotes to MiniSearch. MiniSearch
340
+ * is used only when pinned or when the SQLite build lacks FTS5/json1, and it
341
+ * holds all entry text in the JS heap: the measured ceiling is ~1M entries
342
+ * on a default Node heap (raise `--max-old-space-size` for larger stores).
327
343
  * @default 'auto'
328
344
  */
329
345
  indexStrategy?: 'fts5' | 'minisearch' | 'auto';
@@ -355,6 +371,14 @@ interface WikiConfig {
355
371
  maintenance?: 'auto' | 'deferred';
356
372
  /** `'auto'` mode only: also trigger the librarian when pending event text reaches ~this many tokens (chars/4). */
357
373
  autoLibrarianTokenThreshold?: number;
374
+ /**
375
+ * Migration policy for setup().
376
+ * - `'allow'`: Run all migrations (default, preserves existing behavior)
377
+ * - `'refuse'`: Throw WikiMigrationRequiredError before any mutations
378
+ * - `'auto'`: Run the source_ref normalize if pending; throw if a schema migration is pending
379
+ * @default 'allow'
380
+ */
381
+ migrations?: MigrationPolicy;
358
382
  }
359
383
  interface ReadOptions {
360
384
  maxResults?: number;
@@ -1266,6 +1290,12 @@ interface EntityMaintenanceReport {
1266
1290
  reembedded: boolean;
1267
1291
  /** Set when a lock was held elsewhere; nothing ran for that job. */
1268
1292
  busy?: MaintenanceJob[];
1293
+ /**
1294
+ * Set when keyword search is unavailable and the job could not run for this
1295
+ * entity (spec #280). Its watermark/checkpoint is kept; retry after
1296
+ * `syncSearchIndex()` restores keyword search.
1297
+ */
1298
+ searchUnavailable?: MaintenanceJob[];
1269
1299
  }
1270
1300
  interface RunPendingMaintenanceResult {
1271
1301
  perEntity: EntityMaintenanceReport[];
@@ -1276,6 +1306,33 @@ interface RunPendingMaintenanceResult {
1276
1306
  remaining: number | null;
1277
1307
  stoppedReason: MaintenanceStopReason;
1278
1308
  }
1309
+ type MigrationPolicy = 'allow' | 'refuse' | 'auto';
1310
+ /** Work the migration gate found pending on an existing store. Watermarks are resume rowids (0 = not started). */
1311
+ type PendingMigrationWork = {
1312
+ type: 'schema_migration';
1313
+ fromVersion: number;
1314
+ toVersion: number;
1315
+ } | {
1316
+ type: 'source_ref_normalize';
1317
+ entriesWatermark: number;
1318
+ sourceRefIndexWatermark: number;
1319
+ };
1320
+ declare class WikiMigrationRequiredError extends Error {
1321
+ readonly code = "WIKI_MIGRATION_REQUIRED";
1322
+ readonly pendingWork: PendingMigrationWork;
1323
+ constructor(message: string, pendingWork: PendingMigrationWork);
1324
+ }
1325
+ /**
1326
+ * Thrown per keyword-search query while the keyword index is unavailable
1327
+ * (FTS5 init failed after its retry; spec #280 Change 4). Writes keep working
1328
+ * and the index converges once a later open or no-arg syncSearchIndex()
1329
+ * re-inits successfully. `cause` is the underlying init error.
1330
+ */
1331
+ declare class WikiSearchUnavailableError extends Error {
1332
+ constructor(message?: string, cause?: unknown);
1333
+ }
1334
+ /** Proxy-safe `instanceof WikiSearchUnavailableError` (issue #96). */
1335
+ declare function isWikiSearchUnavailableError(err: unknown): boolean;
1279
1336
 
1280
1337
  interface WikiOutboxEvent<T = unknown> {
1281
1338
  id: string;
@@ -1395,6 +1452,8 @@ declare class EntryRepository extends BaseRepository {
1395
1452
  private static readonly MINI_SEARCH_LIVE_WHERE;
1396
1453
  private chunkSize;
1397
1454
  constructor(db: SQLiteAdapter, prefix: string, outbox: OutboxRepository);
1455
+ /** Whether the entity has any non-deleted row (librarian gate: keyword ranking over zero facts is trivially empty). */
1456
+ hasLiveEntry(entityId: string, tx?: SQLiteAdapter): Promise<boolean>;
1398
1457
  /**
1399
1458
  * Fetch facts by IDs, optionally scoped to entity IDs.
1400
1459
  * Returns facts in the order of the input IDs (first match wins).
@@ -1653,11 +1712,6 @@ declare class EntryRepository extends BaseRepository {
1653
1712
  hasLegacySourceTypes(tx?: SQLiteAdapter): Promise<boolean>;
1654
1713
  countLegacySourceTypes(tx?: SQLiteAdapter): Promise<number>;
1655
1714
  findAllForReembed(entityId?: string, tx?: SQLiteAdapter): Promise<ReembedCandidateRow[]>;
1656
- findRowsForSourceRefMigration(tx?: SQLiteAdapter): Promise<Array<{
1657
- rowid: number;
1658
- source_ref: string;
1659
- }>>;
1660
- updateSourceRefByRowid(rowid: number, sourceRef: string | null, tx: SQLiteAdapter): Promise<void>;
1661
1715
  findLatestSourceHash(entityId: string, sourceRef: string, tx?: SQLiteAdapter): Promise<string | null>;
1662
1716
  /**
1663
1717
  * Batch version of {@link findLatestSourceHash}. Returns a Map covering every
@@ -2123,6 +2177,8 @@ declare class SearchService {
2123
2177
  * service runs on an empty MiniSearch placeholder, as it always has.
2124
2178
  */
2125
2179
  setIndexStrategy(strategy: IndexStrategy): void;
2180
+ /** False while the installed strategy is the degraded UnavailableIndexStrategy (spec #280 Change 4). */
2181
+ isKeywordAvailable(): boolean;
2126
2182
  /**
2127
2183
  * One serialized drain turn for strategies with a durable ledger. Like
2128
2184
  * sync(), it never rejects: the keyword index is rebuildable, and a failed
@@ -3192,7 +3248,8 @@ declare class MaintenanceService {
3192
3248
  *
3193
3249
  * Bounded: at most `batchSize` candidates per pass (#67). Loop on
3194
3250
  * `result.remaining > 0` for convergence — see {@link HealResult.remaining}
3195
- * for what convergence means here.
3251
+ * for what convergence means here, and for the no-progress flags
3252
+ * (`searchUnavailable`, `budgetStop`) a loop must also stop on.
3196
3253
  */
3197
3254
  doRunHeal(entityId: string, options?: {
3198
3255
  promptOverride?: string;
@@ -3368,6 +3425,7 @@ declare class WriteService {
3368
3425
  * {@link write}) so a partial pass retries on the next write.
3369
3426
  */
3370
3427
  private maybeRunHeal;
3428
+ private warnedSearchUnavailable;
3371
3429
  private reportBackgroundFailure;
3372
3430
  }
3373
3431
 
@@ -3457,7 +3515,25 @@ declare class WikiMemory {
3457
3515
  * If `NODE_ENV` is not `"test"`, emits a single `console.warn` per instance (skipped when `process` is undefined).
3458
3516
  */
3459
3517
  get __testAccess(): WikiMemoryTestAccess;
3460
- setup(): Promise<void>;
3518
+ private reinitSearch;
3519
+ /** Monotonic time before which a no-arg syncSearchIndex() skips the re-init (0 = no cooldown). */
3520
+ private reinitRetryAt;
3521
+ /** Consecutive failed re-inits; drives the exponential backoff. */
3522
+ private reinitFailures;
3523
+ /**
3524
+ * Opens the store: migration gate, DDL, schema migrations, then the stamped
3525
+ * source_ref normalize. Await it before any other call on this instance — the
3526
+ * normalize commits in chunks, so a sourceRef-keyed call (forget, upsertGraph,
3527
+ * hasChanged, ingest) issued before setup() resolves can see partially
3528
+ * normalized refs.
3529
+ *
3530
+ * Pass `{ migrations: 'refuse' }` from inside a writer lease: pending one-time
3531
+ * work then throws WikiMigrationRequiredError before any mutation, and the
3532
+ * host runs a plain `setup()` outside the lease.
3533
+ */
3534
+ setup(opts?: {
3535
+ migrations?: MigrationPolicy;
3536
+ }): Promise<void>;
3461
3537
  hasChanged(entityId: string, sourceRef: string, sourceHash: string): Promise<boolean>;
3462
3538
  /**
3463
3539
  * Batched overload.
@@ -3644,7 +3720,10 @@ declare class WikiMemory {
3644
3720
  * indexed; otherwise it is a no-op that still waits for rebuilds already
3645
3721
  * queued. Without an argument, rebuilds every entity currently marked
3646
3722
  * stale; when none is, it resolves immediately and does not wait for rebuilds
3647
- * already queued.
3723
+ * already queued. While keyword search is unavailable it first retries the
3724
+ * index init; after a failed attempt it waits at least 5 s, doubling per
3725
+ * consecutive failure up to 5 min (longer when an attempt is itself slow),
3726
+ * before retrying again.
3648
3727
  *
3649
3728
  * Call only after the host's transaction commits: called inside it, the
3650
3729
  * rebuild may index rows that later roll back, or miss them and clear the
@@ -3887,4 +3966,4 @@ declare class WikiMemory {
3887
3966
  setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
3888
3967
  }
3889
3968
 
3890
- export { type ReembedResult as $, ONTOLOGY_BACKFILL_RECHECK_MS as A, type OntologyBackfillResult as B, type ChunkFailure as C, type DegradedRecord as D, type EmbedFactResult as E, type FormatContextOptions as F, type GraphNeighborhood as G, HEAL_BATCH_SIZE as H, type IngestDocumentResult as I, type OntologyConfig as J, type OntologyEdgeType as K, type LLMProvider as L, type MemoryBundle as M, type OntologyManifest as N, ONTOLOGY_BACKFILL_BATCH_SIZE as O, type OntologyMode as P, type OntologyNodeType as Q, type ReadOptions as R, type SQLiteAdapter as S, type OntologyPromptContext as T, type OntologyUpdates as U, type PendingMaintenance as V, type WikiOptions as W, type PendingSourceStatus as X, type PromptOverrides as Y, PromptService as Z, PrunePartialFailureError as _, type MemoryDump as a, type RunPendingMaintenanceOptions as a0, type RunPendingMaintenanceResult as a1, type SupersedeReplacement as a2, type VectorRanker as a3, type VectorRankerFallback as a4, type VectorRankerRankArgs as a5, type VectorRankerSemanticResult as a6, WikiBusyError as a7, type WikiBusyOperation as a8, type WikiCheckpoint as a9, validateManifest as aA, EmbeddingService as aB, ImportExportService as aC, IngestionService as aD, JobManager as aE, MaintenanceService as aF, RetrievalService as aG, SearchService as aH, WriteService as aI, type WikiConfig as aa, type WikiDiagnostic as ab, type WikiDiagnosticCode as ac, type WikiDiagnosticDetail as ad, type WikiDiagnosticOperation as ae, type WikiDiagnosticSeverity as af, type WikiDiagnosticTrigger as ag, WikiDraftNotFound as ah, WikiDuplicateHashError as ai, type WikiEdge as aj, type WikiEvent as ak, type WikiFact as al, WikiGraphNodeOwnershipConflict as am, WikiIngestEmptyError as an, type WikiInstructions as ao, WikiInvalidReadOptions as ap, type WikiLintReport as aq, type WikiMemoryTestAccess as ar, type WikiOutboxEvent as as, WikiParseError as at, WikiSourceRefHashCollision as au, WikiStrictOntologyViolation as av, WikiSupersedeError as aw, type WikiSupersedeReason as ax, type WikiTask as ay, WikiTransactionError as az, type FormattedMemoryDump as b, WikiMemory as c, type ClassifierAnswer as d, type ClassifierQuestion as e, type ClassifyRequest as f, type ClassifyResponse as g, type DraftPage as h, type EmbedFailureKind as i, type EmbeddingMarkerKind as j, type EntityMaintenanceReport as k, type EntityStatus as l, type ExtractedFact as m, type ExtractedFactEdge as n, type ExtractedFactWithOntology as o, type ExtractedTask as p, type GraphTraversalOptions as q, type GroundingConfig as r, HEAL_RECHECK_MS as s, HOOK_TIMEOUT_MARKER as t, type HealResult as u, type LibrarianConfig as v, type LibrarianGateConfig as w, type MaintenanceJob as x, type MaintenanceStopReason as y, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as z };
3969
+ export { PromptService as $, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as A, ONTOLOGY_BACKFILL_RECHECK_MS as B, type ChunkFailure as C, type DegradedRecord as D, type EmbedFactResult as E, type FormatContextOptions as F, type GraphNeighborhood as G, HEAL_BATCH_SIZE as H, type IngestDocumentResult as I, type OntologyBackfillResult as J, type OntologyConfig as K, type LLMProvider as L, type MemoryBundle as M, type OntologyEdgeType as N, ONTOLOGY_BACKFILL_BATCH_SIZE as O, type OntologyManifest as P, type OntologyMode as Q, type ReadOptions as R, type SQLiteAdapter as S, type OntologyNodeType as T, type OntologyPromptContext as U, type OntologyUpdates as V, type WikiOptions as W, type PendingMaintenance as X, type PendingMigrationWork as Y, type PendingSourceStatus as Z, type PromptOverrides as _, type MemoryDump as a, PrunePartialFailureError as a0, type ReembedResult as a1, type RunPendingMaintenanceOptions as a2, type RunPendingMaintenanceResult as a3, type SupersedeReplacement as a4, type VectorRanker as a5, type VectorRankerFallback as a6, type VectorRankerRankArgs as a7, type VectorRankerSemanticResult as a8, WikiBusyError as a9, WikiSupersedeError as aA, type WikiSupersedeReason as aB, type WikiTask as aC, WikiTransactionError as aD, isWikiSearchUnavailableError as aE, validateManifest as aF, EmbeddingService as aG, ImportExportService as aH, IngestionService as aI, JobManager as aJ, MaintenanceService as aK, RetrievalService as aL, SearchService as aM, WriteService as aN, type WikiBusyOperation as aa, type WikiCheckpoint as ab, type WikiConfig as ac, type WikiDiagnostic as ad, type WikiDiagnosticCode as ae, type WikiDiagnosticDetail as af, type WikiDiagnosticOperation as ag, type WikiDiagnosticSeverity as ah, type WikiDiagnosticTrigger as ai, WikiDraftNotFound as aj, WikiDuplicateHashError as ak, type WikiEdge as al, type WikiEvent as am, type WikiFact as an, WikiGraphNodeOwnershipConflict as ao, WikiIngestEmptyError as ap, type WikiInstructions as aq, WikiInvalidReadOptions as ar, type WikiLintReport as as, type WikiMemoryTestAccess as at, WikiMigrationRequiredError as au, type WikiOutboxEvent as av, WikiParseError as aw, WikiSearchUnavailableError as ax, WikiSourceRefHashCollision as ay, WikiStrictOntologyViolation as az, type FormattedMemoryDump as b, WikiMemory as c, type ClassifierAnswer as d, type ClassifierQuestion as e, type ClassifyRequest as f, type ClassifyResponse as g, type DraftPage as h, type EmbedFailureKind as i, type EmbeddingMarkerKind as j, type EntityMaintenanceReport as k, type EntityStatus as l, type ExtractedFact as m, type ExtractedFactEdge as n, type ExtractedFactWithOntology as o, type ExtractedTask as p, type GraphTraversalOptions as q, type GroundingConfig as r, HEAL_RECHECK_MS as s, HOOK_TIMEOUT_MARKER as t, type HealResult as u, type LibrarianConfig as v, type LibrarianGateConfig as w, type MaintenanceJob as x, type MaintenanceStopReason as y, type MigrationPolicy as z };
@@ -1,2 +1,2 @@
1
- export { aB as EmbeddingService, aC as ImportExportService, aD as IngestionService, aE as JobManager, aE as JobManagerType, aF as MaintenanceService, aG as RetrievalService, aH as SearchService, aH as SearchServiceType, ar as WikiMemoryTestAccess, aI as WriteService } from './testing-B0UtFCq1.mjs';
1
+ export { aG as EmbeddingService, aH as ImportExportService, aI as IngestionService, aJ as JobManager, aJ as JobManagerType, aK as MaintenanceService, aL as RetrievalService, aM as SearchService, aM as SearchServiceType, at as WikiMemoryTestAccess, aN as WriteService } from './testing-7d76Ptlq.mjs';
2
2
  import '@equationalapplications/core-okf';
package/dist/testing.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { aB as EmbeddingService, aC as ImportExportService, aD as IngestionService, aE as JobManager, aE as JobManagerType, aF as MaintenanceService, aG as RetrievalService, aH as SearchService, aH as SearchServiceType, ar as WikiMemoryTestAccess, aI as WriteService } from './testing-B0UtFCq1.js';
1
+ export { aG as EmbeddingService, aH as ImportExportService, aI as IngestionService, aJ as JobManager, aJ as JobManagerType, aK as MaintenanceService, aL as RetrievalService, aM as SearchService, aM as SearchServiceType, at as WikiMemoryTestAccess, aN as WriteService } from './testing-7d76Ptlq.js';
2
2
  import '@equationalapplications/core-okf';