@equationalapplications/core-llm-wiki 7.15.1 → 7.16.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/README.md +20 -1615
- package/dist/{chunk-BC3QHSF3.mjs → chunk-G7F5QPVR.mjs} +32 -4
- package/dist/chunk-G7F5QPVR.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +30 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{testing-BlGhilQw.d.mts → testing-Des97-_i.d.mts} +20 -0
- package/dist/{testing-BlGhilQw.d.ts → testing-Des97-_i.d.ts} +20 -0
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +30 -2
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-BC3QHSF3.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseRepository, WikiGraphNodeOwnershipConflict, parseJsonObject, parseJsonArray, liveAtSql, reanchorRebuildFingerprint, __privateAdd, MetadataRepository, EmbeddingService, SearchService, TemporalService, JobManager, PromptService, resolveGrounding, IngestionService, MaintenanceService, ImportExportService, RetrievalService, WriteService, __privateGet, __privateSet, createLegacySourceTypeIndex, writeNormalizeStamp, CURRENT_SCHEMA_VERSION, detectSchemaVersion, MIGRATIONS, runSourceRefNormalize, normalizeSourceRef, normalizeSourceHash, entitySummaryMetaKey, WikiSourceRefHashCollision, DiagnosticBuffer, validateManifest, WikiDraftNotFound, generateId, emptyManifest, resolveNodeType, WikiStrictOntologyViolation, validateInlineEdges, resolveEdgeDefinitions, typeSatisfies, normalizeTitleKey, edgeTripleAllowed, MAX_EMBED_ATTEMPTS, UsageMeter, isWikiSearchUnavailableError, WikiBusyError, WikiInvalidReadOptions, isLiveAt, packFactsByBudget, factTokenCost, probePendingWork, WikiMigrationRequiredError, setupDatabase, UnavailableIndexStrategy, assertEntityId, assertEpochMs, FTS5_STATE_KEY, fts5LedgerDropSql, fts5TablesDdl, fts5PendingIndexesDdl, fts5TriggersDdl, writeRebuildStart, FTS5_RETIRED_COUNTER_KEY, retiredTableName, FTS5_RETIRED_TABLES_KEY, isRetiredTableName, idReindexChunkSql, readRebuildProgress, FTS5_DRAIN_CHUNK, FTS5_RECLAIM_MERGE_PAGES, windowHiSql, windowChunkSql, FTS5_REBUILD_WM_KEY, sweepHiSql, sweepChunkSql, FTS5_SWEEP_CURSOR_KEY, drainHiSql, drainChunkSql, FTS5_REBUILD_SNAPSHOT_KEY, idDrainChunkSql, entityDrainHiSql, entityDrainChunkSql, fts5TriggerNames, extractSqliteCode, WikiTransactionError } from './chunk-
|
|
2
|
-
export { DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, EMBED_CHARS_CEILING, HEAL_ANCHORS_PER_CANDIDATE, HEAL_BATCH_SIZE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, HEAL_RECHECK_MS, HOOK_TIMEOUT_MARKER, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, chunkText, configureRandomSource, isWikiSearchUnavailableError, parseEmbedding, safeSlice, validateManifest } from './chunk-
|
|
1
|
+
import { BaseRepository, WikiGraphNodeOwnershipConflict, parseJsonObject, parseJsonArray, liveAtSql, reanchorRebuildFingerprint, __privateAdd, MetadataRepository, EmbeddingService, SearchService, TemporalService, JobManager, PromptService, resolveGrounding, IngestionService, MaintenanceService, ImportExportService, RetrievalService, WriteService, __privateGet, __privateSet, createLegacySourceTypeIndex, writeNormalizeStamp, CURRENT_SCHEMA_VERSION, detectSchemaVersion, MIGRATIONS, runSourceRefNormalize, normalizeSourceRef, normalizeSourceHash, entitySummaryMetaKey, WikiSourceRefHashCollision, DiagnosticBuffer, validateManifest, WikiDraftNotFound, generateId, emptyManifest, resolveNodeType, WikiStrictOntologyViolation, validateInlineEdges, resolveEdgeDefinitions, typeSatisfies, normalizeTitleKey, edgeTripleAllowed, MAX_EMBED_ATTEMPTS, UsageMeter, isWikiSearchUnavailableError, WikiBusyError, WikiInvalidReadOptions, isLiveAt, packFactsByBudget, factTokenCost, probePendingWork, WikiMigrationRequiredError, setupDatabase, UnavailableIndexStrategy, assertEntityId, assertEpochMs, FTS5_STATE_KEY, fts5LedgerDropSql, fts5TablesDdl, fts5PendingIndexesDdl, fts5TriggersDdl, writeRebuildStart, FTS5_RETIRED_COUNTER_KEY, retiredTableName, FTS5_RETIRED_TABLES_KEY, isRetiredTableName, idReindexChunkSql, readRebuildProgress, FTS5_DRAIN_CHUNK, FTS5_RECLAIM_MERGE_PAGES, windowHiSql, windowChunkSql, FTS5_REBUILD_WM_KEY, sweepHiSql, sweepChunkSql, FTS5_SWEEP_CURSOR_KEY, drainHiSql, drainChunkSql, FTS5_REBUILD_SNAPSHOT_KEY, idDrainChunkSql, entityDrainHiSql, entityDrainChunkSql, fts5TriggerNames, extractSqliteCode, WikiTransactionError } from './chunk-G7F5QPVR.mjs';
|
|
2
|
+
export { DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, EMBED_CHARS_CEILING, HEAL_ANCHORS_PER_CANDIDATE, HEAL_BATCH_SIZE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, HEAL_RECHECK_MS, HOOK_TIMEOUT_MARKER, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, chunkText, configureRandomSource, isWikiSearchUnavailableError, parseEmbedding, safeSlice, validateManifest } from './chunk-G7F5QPVR.mjs';
|
|
3
3
|
import { deriveTrustTier, isStaleAfter, appendRelatedSection, buildConceptDocument, buildLogMd, buildEntityIndexMd, buildRootIndexMd, isAllowedOkfPath, parseRootIndexMd, parseEntityIndexMd, parseConcept, splitRelatedSection, extractMarkdownLinks, parseLogMd, parseEventIdComment, latestVerified, formatSourcesJson, appendEventIdComment, parseVerifiedFlexible, parseCitationsList } from '@equationalapplications/core-okf';
|
|
4
4
|
import MiniSearch from 'minisearch';
|
|
5
5
|
|
|
@@ -3269,6 +3269,26 @@ declare class MaintenanceService {
|
|
|
3269
3269
|
};
|
|
3270
3270
|
metadataReset?: boolean;
|
|
3271
3271
|
}>;
|
|
3272
|
+
/**
|
|
3273
|
+
* Whether forget() should soft-delete in source_ref_index (#316,
|
|
3274
|
+
* specs/forget-pre-v9 §3.1). Normally true: setup()'s DDL creates the table.
|
|
3275
|
+
* False only when the table is absent AND the store is pre-v9 (stored
|
|
3276
|
+
* schema_version < 9; a missing key or unparseable value counts as 0, like
|
|
3277
|
+
* detectSchemaVersion; a store without the meta table at all is not
|
|
3278
|
+
* supported and fails as before) — the v9 recovery path, where there is no index row
|
|
3279
|
+
* to retire and v9's backfill reads live entries only. A v9+ store without
|
|
3280
|
+
* its index is corrupt: throw rather than skip, so the TOCTOU guard is never
|
|
3281
|
+
* silently bypassed.
|
|
3282
|
+
*
|
|
3283
|
+
* Every read runs on `tx`, so a v9 committed by *another connection* between
|
|
3284
|
+
* this probe and forget()'s writes can only fail the write-lock upgrade
|
|
3285
|
+
* (SQLite serializes writers), never make forget() skip a live index. A
|
|
3286
|
+
* setup() racing forget() on the *same* connection (expo passes the shared
|
|
3287
|
+
* db as tx) is not serialized against it; v9 runs in autocommit, a
|
|
3288
|
+
* pre-existing limit out of scope here. Await setup() before other calls,
|
|
3289
|
+
* as WikiMemory.setup() documents.
|
|
3290
|
+
*/
|
|
3291
|
+
private sourceRefIndexPresent;
|
|
3272
3292
|
/**
|
|
3273
3293
|
* Read-only dry-run preview of {@link forget}. Returns the same shape as a
|
|
3274
3294
|
* real call would, without acquiring the lock, opening a transaction, staging
|
|
@@ -3269,6 +3269,26 @@ declare class MaintenanceService {
|
|
|
3269
3269
|
};
|
|
3270
3270
|
metadataReset?: boolean;
|
|
3271
3271
|
}>;
|
|
3272
|
+
/**
|
|
3273
|
+
* Whether forget() should soft-delete in source_ref_index (#316,
|
|
3274
|
+
* specs/forget-pre-v9 §3.1). Normally true: setup()'s DDL creates the table.
|
|
3275
|
+
* False only when the table is absent AND the store is pre-v9 (stored
|
|
3276
|
+
* schema_version < 9; a missing key or unparseable value counts as 0, like
|
|
3277
|
+
* detectSchemaVersion; a store without the meta table at all is not
|
|
3278
|
+
* supported and fails as before) — the v9 recovery path, where there is no index row
|
|
3279
|
+
* to retire and v9's backfill reads live entries only. A v9+ store without
|
|
3280
|
+
* its index is corrupt: throw rather than skip, so the TOCTOU guard is never
|
|
3281
|
+
* silently bypassed.
|
|
3282
|
+
*
|
|
3283
|
+
* Every read runs on `tx`, so a v9 committed by *another connection* between
|
|
3284
|
+
* this probe and forget()'s writes can only fail the write-lock upgrade
|
|
3285
|
+
* (SQLite serializes writers), never make forget() skip a live index. A
|
|
3286
|
+
* setup() racing forget() on the *same* connection (expo passes the shared
|
|
3287
|
+
* db as tx) is not serialized against it; v9 runs in autocommit, a
|
|
3288
|
+
* pre-existing limit out of scope here. Await setup() before other calls,
|
|
3289
|
+
* as WikiMemory.setup() documents.
|
|
3290
|
+
*/
|
|
3291
|
+
private sourceRefIndexPresent;
|
|
3272
3292
|
/**
|
|
3273
3293
|
* Read-only dry-run preview of {@link forget}. Returns the same shape as a
|
|
3274
3294
|
* real call would, without acquiring the lock, opening a transaction, staging
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { aH as EmbeddingService, aI as ImportExportService, aJ as IngestionService, aK as JobManager, aK as JobManagerType, aL as MaintenanceService, aM as RetrievalService, aN as SearchService, aN as SearchServiceType, au as WikiMemoryTestAccess, aO as WriteService } from './testing-
|
|
1
|
+
export { aH as EmbeddingService, aI as ImportExportService, aJ as IngestionService, aK as JobManager, aK as JobManagerType, aL as MaintenanceService, aM as RetrievalService, aN as SearchService, aN as SearchServiceType, au as WikiMemoryTestAccess, aO as WriteService } from './testing-Des97-_i.mjs';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { aH as EmbeddingService, aI as ImportExportService, aJ as IngestionService, aK as JobManager, aK as JobManagerType, aL as MaintenanceService, aM as RetrievalService, aN as SearchService, aN as SearchServiceType, au as WikiMemoryTestAccess, aO as WriteService } from './testing-
|
|
1
|
+
export { aH as EmbeddingService, aI as ImportExportService, aJ as IngestionService, aK as JobManager, aK as JobManagerType, aL as MaintenanceService, aM as RetrievalService, aN as SearchService, aN as SearchServiceType, au as WikiMemoryTestAccess, aO as WriteService } from './testing-Des97-_i.js';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
package/dist/testing.js
CHANGED
|
@@ -3040,7 +3040,7 @@ var MIGRATIONS = [
|
|
|
3040
3040
|
if (duplicates.length > 0) {
|
|
3041
3041
|
const sample = duplicates.slice(0, 5).map((d) => `(entity_id=${d.entity_id}, source_hash=${d.source_hash.slice(0, 12)}\u2026, n_refs=${d.n_refs})`).join(", ");
|
|
3042
3042
|
throw new Error(
|
|
3043
|
-
`Migration v9 (add_source_ref_index) failed: existing live rows have multiple sourceRefs sharing a hash. Found ${duplicates.length} duplicate (entity_id, source_hash) groups. First ${Math.min(5, duplicates.length)}: ${sample}. Resolve each by calling forget({ sourceRef: <loser> }) for the
|
|
3043
|
+
`Migration v9 (add_source_ref_index) failed: existing live rows have multiple sourceRefs sharing a hash. Found ${duplicates.length} duplicate (entity_id, source_hash) groups. First ${Math.min(5, duplicates.length)}: ${sample}. Resolve each group by calling forget(entityId, { sourceRef: <loser>, sourceHash: <group's full source_hash> }) for every losing sourceRef in that group (works on pre-v9 databases; list full hashes with the query in the docs' errors reference), then re-run setup().`
|
|
3044
3044
|
);
|
|
3045
3045
|
}
|
|
3046
3046
|
await db.execAsync(
|
|
@@ -4312,6 +4312,7 @@ var MaintenanceService = class {
|
|
|
4312
4312
|
if (params.sourceRef !== void 0 && !sourceRef) throw new Error("Invalid sourceRef");
|
|
4313
4313
|
const sourceHash = params.sourceHash !== void 0 ? normalizeSourceHash(params.sourceHash) : null;
|
|
4314
4314
|
if (params.sourceHash !== void 0 && !sourceHash) throw new Error("Invalid sourceHash (must be 64-char hex string)");
|
|
4315
|
+
const touchSourceRefIndex = sourceRef !== null && await this.sourceRefIndexPresent(tx);
|
|
4315
4316
|
if (params.entryId) {
|
|
4316
4317
|
const entryId = await this.entryRepo.findIdById(params.entryId, entityId, tx);
|
|
4317
4318
|
if (entryId) deletedEntryIds.push(entryId);
|
|
@@ -4322,7 +4323,7 @@ var MaintenanceService = class {
|
|
|
4322
4323
|
const entryPromise = params.entryId ? this.entryRepo.softDelete(params.entryId, entityId, tx).then((r) => r.changes > 0) : null;
|
|
4323
4324
|
const taskDeletedPromise = params.taskId ? this.taskRepo.softDeleteById(params.taskId, entityId, tx).then((r) => r.changes > 0) : null;
|
|
4324
4325
|
const refPromise = sourceRef || sourceHash ? this.entryRepo.softDeleteBySource(entityId, tx, sourceRef, sourceHash) : null;
|
|
4325
|
-
const sourceRefIndexPromise = sourceRef ? this.sourceRefIndexRepo.softDeleteByEntityAndSourceRef(entityId, sourceRef, tx).then(() => void 0) : null;
|
|
4326
|
+
const sourceRefIndexPromise = touchSourceRefIndex && sourceRef ? this.sourceRefIndexRepo.softDeleteByEntityAndSourceRef(entityId, sourceRef, tx).then(() => void 0) : null;
|
|
4326
4327
|
const [entryResult, taskResult, refResult] = await Promise.all([
|
|
4327
4328
|
entryPromise ?? Promise.resolve(false),
|
|
4328
4329
|
taskDeletedPromise ?? Promise.resolve(false),
|
|
@@ -4356,6 +4357,33 @@ var MaintenanceService = class {
|
|
|
4356
4357
|
this.jobManager.releaseLock("forget", entityId);
|
|
4357
4358
|
}
|
|
4358
4359
|
}
|
|
4360
|
+
/**
|
|
4361
|
+
* Whether forget() should soft-delete in source_ref_index (#316,
|
|
4362
|
+
* specs/forget-pre-v9 §3.1). Normally true: setup()'s DDL creates the table.
|
|
4363
|
+
* False only when the table is absent AND the store is pre-v9 (stored
|
|
4364
|
+
* schema_version < 9; a missing key or unparseable value counts as 0, like
|
|
4365
|
+
* detectSchemaVersion; a store without the meta table at all is not
|
|
4366
|
+
* supported and fails as before) — the v9 recovery path, where there is no index row
|
|
4367
|
+
* to retire and v9's backfill reads live entries only. A v9+ store without
|
|
4368
|
+
* its index is corrupt: throw rather than skip, so the TOCTOU guard is never
|
|
4369
|
+
* silently bypassed.
|
|
4370
|
+
*
|
|
4371
|
+
* Every read runs on `tx`, so a v9 committed by *another connection* between
|
|
4372
|
+
* this probe and forget()'s writes can only fail the write-lock upgrade
|
|
4373
|
+
* (SQLite serializes writers), never make forget() skip a live index. A
|
|
4374
|
+
* setup() racing forget() on the *same* connection (expo passes the shared
|
|
4375
|
+
* db as tx) is not serialized against it; v9 runs in autocommit, a
|
|
4376
|
+
* pre-existing limit out of scope here. Await setup() before other calls,
|
|
4377
|
+
* as WikiMemory.setup() documents.
|
|
4378
|
+
*/
|
|
4379
|
+
async sourceRefIndexPresent(tx) {
|
|
4380
|
+
if (await this.metadataRepo.tableExists(`${this.prefix}source_ref_index`, tx)) return true;
|
|
4381
|
+
const raw = await this.metadataRepo.getMeta("schema_version", tx);
|
|
4382
|
+
const parsed = raw ? parseInt(raw, 10) : 0;
|
|
4383
|
+
const version = Number.isFinite(parsed) ? parsed : 0;
|
|
4384
|
+
if (version < 9) return false;
|
|
4385
|
+
throw new Error(`forget(): source_ref_index is missing on a schema_version=${version} database; run setup()`);
|
|
4386
|
+
}
|
|
4359
4387
|
/**
|
|
4360
4388
|
* Read-only dry-run preview of {@link forget}. Returns the same shape as a
|
|
4361
4389
|
* real call would, without acquiring the lock, opening a transaction, staging
|