@equationalapplications/core-llm-wiki 9.18.0 → 9.19.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-FX4J6MLA.mjs → chunk-JTKJXNB6.mjs} +79 -11
- package/dist/chunk-JTKJXNB6.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +77 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{testing-CI0n5qQk.d.mts → testing-hg6O6N-X.d.mts} +11 -3
- package/dist/{testing-CI0n5qQk.d.ts → testing-hg6O6N-X.d.ts} +11 -3
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +34 -0
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-FX4J6MLA.mjs.map +0 -1
|
@@ -311,6 +311,8 @@ var SEVERITY = {
|
|
|
311
311
|
external_deletion_pending: "warn",
|
|
312
312
|
supersede_scheduled_end_replaced: "info",
|
|
313
313
|
external_deletion_discarded: "warn",
|
|
314
|
+
vector_removals_backlog: "warn",
|
|
315
|
+
vector_removals_trim_failed: "warn",
|
|
314
316
|
guidance_too_long: "warn",
|
|
315
317
|
guidance_resolver_failed: "warn",
|
|
316
318
|
source_pointer_unresolved: "warn",
|
|
@@ -371,6 +373,8 @@ var MESSAGE = {
|
|
|
371
373
|
supersede_scheduled_end_replaced: "A supersede replaced a scheduled end date on the old fact; the prior end is kept in prior_valid_to and reopen() can restore it.",
|
|
372
374
|
external_deletion_pending: "Removals owed to the external vector index are still pending.",
|
|
373
375
|
external_deletion_discarded: "Pending external vector removals were discarded because forceDeleteIgnoreRankerHook is set.",
|
|
376
|
+
vector_removals_backlog: "Pending external vector removals are accumulating faster than the host drains them.",
|
|
377
|
+
vector_removals_trim_failed: "The prune-time check of pending external vector removals failed; it will retry on the next prune pass.",
|
|
374
378
|
guidance_too_long: "The configured guidance exceeded the length cap and was not sent for this pass.",
|
|
375
379
|
guidance_resolver_failed: "The per-entity guidance resolver failed; its value was not used for this pass.",
|
|
376
380
|
source_pointer_unresolved: "A stored librarian fact carries no source pointer because the model answer could not yield one, or the librarian merged such an unattributed candidate into this fact in place (its derived_events list was not extended).",
|
|
@@ -4991,6 +4995,40 @@ var VectorRemovalRepository = class extends BaseRepository {
|
|
|
4991
4995
|
);
|
|
4992
4996
|
return { count: row?.c ?? 0, oldestEnqueuedAt: row?.o ?? null, maxAttempts: row?.m ?? 0 };
|
|
4993
4997
|
}
|
|
4998
|
+
/**
|
|
4999
|
+
* Trim an entity's pending rows down toward `cap`, deleting at most `chunk`
|
|
5000
|
+
* of the oldest per call. Uses the lower of the two cutoffs (cap overflow,
|
|
5001
|
+
* chunk bound); a no-op when at or under cap or when the external-index
|
|
5002
|
+
* marker is set. Without `tx` it opens its own single short transaction.
|
|
5003
|
+
* Returns the number of rows deleted.
|
|
5004
|
+
*/
|
|
5005
|
+
async trimPendingOverflow(entityId, cap, chunk, tx) {
|
|
5006
|
+
if (chunk > cap) throw new Error(`trimPendingOverflow: chunk (${chunk}) must be <= cap (${cap})`);
|
|
5007
|
+
const run = async (ex) => {
|
|
5008
|
+
const t = `${this.prefix}vector_removals`;
|
|
5009
|
+
const capRow = await ex.getFirstAsync(
|
|
5010
|
+
`SELECT seq FROM ${t} WHERE entity_id = ? AND confirmed_at IS NULL
|
|
5011
|
+
ORDER BY seq DESC LIMIT 1 OFFSET ?`,
|
|
5012
|
+
[entityId, cap]
|
|
5013
|
+
);
|
|
5014
|
+
if (!capRow) return 0;
|
|
5015
|
+
const chunkRow = await ex.getFirstAsync(
|
|
5016
|
+
`SELECT seq FROM ${t} WHERE entity_id = ? AND confirmed_at IS NULL
|
|
5017
|
+
ORDER BY seq ASC LIMIT 1 OFFSET ?`,
|
|
5018
|
+
[entityId, chunk - 1]
|
|
5019
|
+
);
|
|
5020
|
+
const cuts = [capRow.seq, chunkRow?.seq].filter((x) => x != null);
|
|
5021
|
+
const cutoff = Math.min(...cuts);
|
|
5022
|
+
const r = await ex.runAsync(
|
|
5023
|
+
`DELETE FROM ${t}
|
|
5024
|
+
WHERE entity_id = ? AND confirmed_at IS NULL AND seq <= ?
|
|
5025
|
+
AND NOT EXISTS (SELECT 1 FROM ${this.prefix}meta WHERE key = 'external_index_in_use' AND value = '1')`,
|
|
5026
|
+
[entityId, cutoff]
|
|
5027
|
+
);
|
|
5028
|
+
return r.changes;
|
|
5029
|
+
};
|
|
5030
|
+
return tx ? run(tx) : this.db.withTransactionAsync(run);
|
|
5031
|
+
}
|
|
4994
5032
|
async entitiesWithPending() {
|
|
4995
5033
|
const rows = await this.db.getAllAsync(
|
|
4996
5034
|
`SELECT DISTINCT entity_id FROM ${this.prefix}vector_removals
|
|
@@ -7707,6 +7745,9 @@ async function runLibrarianStrategy(deps, ctx) {
|
|
|
7707
7745
|
|
|
7708
7746
|
// src/services/MaintenanceService.ts
|
|
7709
7747
|
var CHAIN_TRUNCATED_NOTICE = `includeChain walk stopped at the depth cap (${HISTORY_MAX_DEPTH} links per direction); the chain is longer than the ids listed. Run forget again on a remaining chain id to continue.`;
|
|
7748
|
+
var MAX_PENDING_LEDGER_ROWS = 1e4;
|
|
7749
|
+
var WARN_PENDING_LEDGER_ROWS = 500;
|
|
7750
|
+
var TRIM_CHUNK_ROWS = 5e3;
|
|
7710
7751
|
var ONTOLOGY_BACKFILL_BATCH_SIZE = 25;
|
|
7711
7752
|
var ONTOLOGY_BACKFILL_RECHECK_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
7712
7753
|
var HEAL_ANCHOR_SEARCH_OVERFETCH = 4;
|
|
@@ -7951,6 +7992,33 @@ var _MaintenanceService = class _MaintenanceService {
|
|
|
7951
7992
|
}
|
|
7952
7993
|
}
|
|
7953
7994
|
}
|
|
7995
|
+
if (gate === "none" && this.vectorRemoval && this.vectorRemovalRepo) {
|
|
7996
|
+
try {
|
|
7997
|
+
if (await this.vectorRemoval.ledgerPresent()) {
|
|
7998
|
+
if (!await this.vectorRemoval.externalIndexInUse()) {
|
|
7999
|
+
await this.vectorRemovalRepo.trimPendingOverflow(entityId, MAX_PENDING_LEDGER_ROWS, TRIM_CHUNK_ROWS);
|
|
8000
|
+
} else if (owner === "host") {
|
|
8001
|
+
const st = await this.vectorRemovalRepo.pendingStats(entityId);
|
|
8002
|
+
if (st.count > WARN_PENDING_LEDGER_ROWS) {
|
|
8003
|
+
emitDiagnostic(this.options, {
|
|
8004
|
+
code: "vector_removals_backlog",
|
|
8005
|
+
operation: "prune",
|
|
8006
|
+
trigger: "call",
|
|
8007
|
+
entityId,
|
|
8008
|
+
detail: {
|
|
8009
|
+
count: st.count,
|
|
8010
|
+
...st.oldestEnqueuedAt !== null ? { oldestEnqueuedAt: st.oldestEnqueuedAt } : {},
|
|
8011
|
+
maxAttempts: st.maxAttempts
|
|
8012
|
+
}
|
|
8013
|
+
});
|
|
8014
|
+
}
|
|
8015
|
+
}
|
|
8016
|
+
}
|
|
8017
|
+
} catch (err) {
|
|
8018
|
+
const reason = err instanceof Error ? typeof err.code === "string" ? err.code : err.name : "unknown";
|
|
8019
|
+
emitDiagnostic(this.options, { code: "vector_removals_trim_failed", operation: "prune", trigger: "call", entityId, detail: { reason } });
|
|
8020
|
+
}
|
|
8021
|
+
}
|
|
7954
8022
|
let vacuumCheckpointErr;
|
|
7955
8023
|
if (vacuum) {
|
|
7956
8024
|
try {
|
|
@@ -10236,6 +10304,14 @@ var DEFAULT_MAX_TOTAL_CHARS = 5e6;
|
|
|
10236
10304
|
function limitOr(value, fallback) {
|
|
10237
10305
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.floor(value) : fallback;
|
|
10238
10306
|
}
|
|
10307
|
+
function listStoredSourcesSql(prefix) {
|
|
10308
|
+
return `SELECT d.source_ref, d.source_hash, d.char_count, d.created_at,
|
|
10309
|
+
(SELECT COUNT(*) FROM ${prefix}source_passages p
|
|
10310
|
+
WHERE p.document_id = d.id AND +p.entity_id = d.entity_id) AS passage_count
|
|
10311
|
+
FROM ${prefix}source_documents d
|
|
10312
|
+
WHERE d.entity_id = ?
|
|
10313
|
+
ORDER BY d.source_ref COLLATE BINARY`;
|
|
10314
|
+
}
|
|
10239
10315
|
var SourceStoreService = class {
|
|
10240
10316
|
constructor(db, prefix, options, jobManager) {
|
|
10241
10317
|
this.db = db;
|
|
@@ -10314,15 +10390,7 @@ var SourceStoreService = class {
|
|
|
10314
10390
|
}
|
|
10315
10391
|
/** Spec §4/§7: full store listing, including sources stored with no ingest. */
|
|
10316
10392
|
async listStoredSources(entityId) {
|
|
10317
|
-
const rows = await this.db.getAllAsync(
|
|
10318
|
-
`SELECT d.source_ref, d.source_hash, d.char_count, d.created_at,
|
|
10319
|
-
(SELECT COUNT(*) FROM ${this.prefix}source_passages p
|
|
10320
|
-
WHERE p.entity_id = d.entity_id AND p.document_id = d.id) AS passage_count
|
|
10321
|
-
FROM ${this.prefix}source_documents d
|
|
10322
|
-
WHERE d.entity_id = ?
|
|
10323
|
-
ORDER BY d.source_ref COLLATE BINARY`,
|
|
10324
|
-
[entityId]
|
|
10325
|
-
);
|
|
10393
|
+
const rows = await this.db.getAllAsync(listStoredSourcesSql(this.prefix), [entityId]);
|
|
10326
10394
|
return rows.map((r) => ({
|
|
10327
10395
|
sourceRef: r.source_ref,
|
|
10328
10396
|
sourceHash: r.source_hash,
|
|
@@ -12578,5 +12646,5 @@ var WriteService = class {
|
|
|
12578
12646
|
};
|
|
12579
12647
|
|
|
12580
12648
|
export { BaseRepository, CLASSIFIER_MAX_CHOICES, CURRENT_SCHEMA_VERSION, CheckpointIncompleteError, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_TYPING_MIN_CONFIDENCE, DiagnosticBuffer, EMBED_CHARS_CEILING, EdgeRepository, EmbeddingService, EraseStepError, FTS5_DRAIN_CHUNK, FTS5_REBUILD_SNAPSHOT_KEY, FTS5_REBUILD_WM_KEY, FTS5_RECLAIM_MERGE_PAGES, FTS5_RETIRED_COUNTER_KEY, FTS5_RETIRED_TABLES_KEY, FTS5_STATE_KEY, FTS5_SWEEP_CURSOR_KEY, HEAL_ANCHORS_PER_CANDIDATE, HEAL_BATCH_SIZE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, HEAL_RECHECK_MS, HOOK_TIMEOUT_MARKER, ImportExportService, IngestionService, JobManager, MAX_EMBED_ATTEMPTS, MIGRATIONS, MaintenanceService, MetadataRepository, ONTOLOGY_ABSTAIN_SENTINEL, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, RetrievalService, SearchService, SourceStoreService, TemporalService, UnavailableIndexStrategy, UsageMeter, VectorRemovalRepository, VectorRemovalService, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiExternalDeletionError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, WriteService, __privateAdd, __privateGet, __privateSet, assertEntityId, assertEpochMs, canEngageIngestTyping, canEngageWriteTyping, chunkText, configureRandomSource, createEntriesDeletedIndex, createEventsForgottenIndex, createLegacySourceTypeIndex, createdAtValue, detectSchemaVersion, drainChunkSql, drainHiSql, edgeTripleAllowed, emitDiagnostic, emptyManifest, entityDrainChunkSql, entityDrainHiSql, entitySummaryMetaKey, extractSqliteCode, factTokenCost, fts5LedgerDropSql, fts5PendingIndexesDdl, fts5TablesDdl, fts5TriggerNames, fts5TriggersDdl, generateId, idDrainChunkSql, idReindexChunkSql, isLiveAt, isReservedAbstainSlug, isRetiredTableName, isUsableDate, isWikiSearchUnavailableError, liveAtSql, nodeTypeReceipts, normalizeSourceHash, normalizeSourceRef, normalizeTitleKey, packFactsByBudget, parseEmbedding, parseJsonArray, parseJsonObject, parseStoredDerivedEvents, parseStoredSourcePointer, passageFtsTablesDdl, passageFtsTriggerNames, passageFtsTriggersDdl, probePendingWork, readRebuildProgress, reanchorRebuildFingerprint, resolveContextBudget, resolveContextBudgetOrThrow, resolveDefaultChunkLength, resolveEdgeDefinitions, resolveEdgesMinConfidence, resolveGrounding, resolveHealScreenMinConfidence, resolveLibrarianStrategy, resolveMaxPromptChars, resolveNodeType, resolveNodeTypeMatch, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneHealScreen, resolveSystemOneResolve, resolveSystemOneTypeOnIngest, resolveSystemOneTypeOnWrite, resolveSystemOneTyping, resolveTypingMinConfidence, retiredTableName, runSourceRefNormalize, safeSlice, serializeDerivedEvents, serializeSourcePointer, setupDatabase, shouldEmitOntologyReceipt, sweepChunkSql, sweepHiSql, typeSatisfies, validUsage, validateDerivedEventsValue, validateInlineEdges, validateManifest, validateSourcePointerValue, warnChangedDefaultsOnce, warnOnce, windowChunkSql, windowHiSql, writeNormalizeStamp, writeRebuildStart };
|
|
12581
|
-
//# sourceMappingURL=chunk-
|
|
12582
|
-
//# sourceMappingURL=chunk-
|
|
12649
|
+
//# sourceMappingURL=chunk-JTKJXNB6.mjs.map
|
|
12650
|
+
//# sourceMappingURL=chunk-JTKJXNB6.mjs.map
|