@equationalapplications/core-llm-wiki 9.4.2 → 9.5.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-TJYITTAO.mjs → chunk-ZVVZACYI.mjs} +36 -12
- package/dist/chunk-ZVVZACYI.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +101 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-BVY5P6BS.d.mts → testing-CTCRwhs0.d.mts} +39 -2
- package/dist/{testing-BVY5P6BS.d.ts → testing-CTCRwhs0.d.ts} +39 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +34 -10
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-TJYITTAO.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseRepository, WikiGraphNodeOwnershipConflict, serializeSourcePointer, parseStoredSourcePointer, parseJsonObject, parseJsonArray, liveAtSql, reanchorRebuildFingerprint, __privateAdd, warnChangedDefaultsOnce, EdgeRepository, MetadataRepository, EmbeddingService, VectorRemovalRepository, VectorRemovalService, SearchService, TemporalService, JobManager, PromptService, resolveGrounding, IngestionService, MaintenanceService, ImportExportService, RetrievalService, SourceStoreService, WriteService, __privateGet, __privateSet, createLegacySourceTypeIndex, writeNormalizeStamp, CURRENT_SCHEMA_VERSION, detectSchemaVersion, MIGRATIONS, runSourceRefNormalize, emitDiagnostic, normalizeSourceRef, normalizeSourceHash, resolveLibrarianStrategy, 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, createdAtValue, isUsableDate, validateSourcePointerValue, assertEntityId, assertEpochMs, passageFtsTriggerNames, FTS5_STATE_KEY, fts5LedgerDropSql, passageFtsTablesDdl, passageFtsTriggersDdl, 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 { CheckpointIncompleteError, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, EMBED_CHARS_CEILING, EraseStepError, 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, WikiExternalDeletionError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, chunkText, configureRandomSource, isWikiSearchUnavailableError, parseEmbedding, safeSlice, validateManifest } from './chunk-
|
|
1
|
+
import { BaseRepository, WikiGraphNodeOwnershipConflict, serializeSourcePointer, parseStoredSourcePointer, parseJsonObject, parseJsonArray, liveAtSql, reanchorRebuildFingerprint, __privateAdd, warnChangedDefaultsOnce, EdgeRepository, MetadataRepository, EmbeddingService, VectorRemovalRepository, VectorRemovalService, SearchService, TemporalService, JobManager, PromptService, resolveGrounding, IngestionService, MaintenanceService, ImportExportService, RetrievalService, SourceStoreService, WriteService, __privateGet, __privateSet, createLegacySourceTypeIndex, writeNormalizeStamp, CURRENT_SCHEMA_VERSION, detectSchemaVersion, MIGRATIONS, runSourceRefNormalize, emitDiagnostic, normalizeSourceRef, normalizeSourceHash, resolveLibrarianStrategy, 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, createdAtValue, isUsableDate, validateSourcePointerValue, assertEntityId, assertEpochMs, passageFtsTriggerNames, FTS5_STATE_KEY, fts5LedgerDropSql, passageFtsTablesDdl, passageFtsTriggersDdl, 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-ZVVZACYI.mjs';
|
|
2
|
+
export { CheckpointIncompleteError, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, EMBED_CHARS_CEILING, EraseStepError, 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, WikiExternalDeletionError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, chunkText, configureRandomSource, isWikiSearchUnavailableError, parseEmbedding, safeSlice, validateManifest } from './chunk-ZVVZACYI.mjs';
|
|
3
3
|
import { deriveTrustTier, isStaleAfter, appendRelatedSection, buildConceptDocument, buildLogMd, buildEntityIndexMd, buildRootIndexMd, isAllowedOkfPath, parseRootIndexMd, parseEntityIndexMd, parseConcept, splitRelatedSection, extractMarkdownLinks, parseLogMd, parseEventIdComment, createEventIdDeriver, latestVerified, formatSourcesJson, appendEventIdComment, parseVerifiedFlexible, parseCitationsList } from '@equationalapplications/core-okf';
|
|
4
4
|
import MiniSearch from 'minisearch';
|
|
5
5
|
|
|
@@ -524,6 +524,59 @@ var _EntryRepository = class _EntryRepository extends BaseRepository {
|
|
|
524
524
|
}
|
|
525
525
|
return result.changes;
|
|
526
526
|
}
|
|
527
|
+
/**
|
|
528
|
+
* IDs of the entity's entries whose source_pointer names the event id.
|
|
529
|
+
* `includeDeleted = true` returns live + tombstoned rows (the forget
|
|
530
|
+
* enumeration superset for index sync and the ledger backstop).
|
|
531
|
+
*/
|
|
532
|
+
async findIdsByPointerEvent(entityId, eventId, tx, includeDeleted = false) {
|
|
533
|
+
const executor = this.getExecutor(tx);
|
|
534
|
+
let sql = `SELECT id FROM ${this.prefix}entries WHERE entity_id = ? AND ${_EntryRepository.POINTER_EVENT_MATCH_SQL}`;
|
|
535
|
+
const args = [entityId, eventId];
|
|
536
|
+
if (!includeDeleted) sql += ` AND deleted_at IS NULL`;
|
|
537
|
+
const rows = await executor.getAllAsync(sql, args);
|
|
538
|
+
return rows.map((r) => r.id);
|
|
539
|
+
}
|
|
540
|
+
/** Live-row count for the event id — dry-run only (a real call is idempotent over tombstones). */
|
|
541
|
+
async countLiveByPointerEvent(entityId, eventId, tx) {
|
|
542
|
+
const executor = this.getExecutor(tx);
|
|
543
|
+
const row = await executor.getFirstAsync(
|
|
544
|
+
`SELECT COUNT(*) AS n FROM ${this.prefix}entries WHERE entity_id = ? AND deleted_at IS NULL AND ${_EntryRepository.POINTER_EVENT_MATCH_SQL}`,
|
|
545
|
+
[entityId, eventId]
|
|
546
|
+
);
|
|
547
|
+
return row?.n ?? 0;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Soft-delete the entity's entries whose source_pointer names the event id,
|
|
551
|
+
* within a transaction. Stages a DELETE outbox entry for each row that
|
|
552
|
+
* changed, in the same transaction (parity with softDeleteBySource — synced
|
|
553
|
+
* replicas learn of the tombstones through the outbox). The `deleted_at
|
|
554
|
+
* IS NULL` guard makes the call idempotent: already-tombstoned rows are
|
|
555
|
+
* no-op hits and are not counted. `tx` is REQUIRED.
|
|
556
|
+
* Returns the number of rows deleted.
|
|
557
|
+
*/
|
|
558
|
+
async softDeleteByPointerEvent(entityId, eventId, tx) {
|
|
559
|
+
const executor = this.getExecutor(tx);
|
|
560
|
+
const now = Date.now();
|
|
561
|
+
const idsToDelete = await executor.getAllAsync(
|
|
562
|
+
`SELECT id FROM ${this.prefix}entries WHERE entity_id = ? AND deleted_at IS NULL AND ${_EntryRepository.POINTER_EVENT_MATCH_SQL}`,
|
|
563
|
+
[entityId, eventId]
|
|
564
|
+
);
|
|
565
|
+
const result = await executor.runAsync(
|
|
566
|
+
`UPDATE ${this.prefix}entries SET deleted_at = ?, updated_at = ? WHERE entity_id = ? AND deleted_at IS NULL AND ${_EntryRepository.POINTER_EVENT_MATCH_SQL}`,
|
|
567
|
+
[now, now, entityId, eventId]
|
|
568
|
+
);
|
|
569
|
+
for (const row of idsToDelete) {
|
|
570
|
+
await this.outbox.push({
|
|
571
|
+
entityId,
|
|
572
|
+
tableName: "entries",
|
|
573
|
+
recordId: row.id,
|
|
574
|
+
operation: "DELETE",
|
|
575
|
+
payload: { id: row.id, entity_id: entityId, deleted_at: now }
|
|
576
|
+
}, tx);
|
|
577
|
+
}
|
|
578
|
+
return result.changes;
|
|
579
|
+
}
|
|
527
580
|
/**
|
|
528
581
|
* Fetch IDs + entity_ids of soft-deleted rows older than cutoff for a given entity.
|
|
529
582
|
* Used by runPrune().
|
|
@@ -1548,6 +1601,18 @@ var _EntryRepository = class _EntryRepository extends BaseRepository {
|
|
|
1548
1601
|
*/
|
|
1549
1602
|
_EntryRepository.MINI_SEARCH_COLUMNS = "id, entity_id, title, body, tags";
|
|
1550
1603
|
_EntryRepository.MINI_SEARCH_LIVE_WHERE = "WHERE deleted_at IS NULL";
|
|
1604
|
+
/**
|
|
1605
|
+
* Shared JSON match predicate for source_pointer event ids
|
|
1606
|
+
* (specs/forget-by-event-id §D1). Every JSON call sits under the single
|
|
1607
|
+
* `json_valid` guard: unguarded JSON functions RAISE on malformed text, and
|
|
1608
|
+
* three-valued logic forces evaluation of AND operands after a NULL-guarded
|
|
1609
|
+
* term — a two-term form is only as safe as the planner's term-splitting.
|
|
1610
|
+
* The tombstone guard (`deleted_at IS NULL`) is added per-method.
|
|
1611
|
+
*/
|
|
1612
|
+
_EntryRepository.POINTER_EVENT_MATCH_SQL = `CASE WHEN json_valid(source_pointer)
|
|
1613
|
+
THEN json_type(source_pointer, '$.event_id') = 'text'
|
|
1614
|
+
AND json_extract(source_pointer, '$.event_id') = ?
|
|
1615
|
+
ELSE 0 END`;
|
|
1551
1616
|
var EntryRepository = _EntryRepository;
|
|
1552
1617
|
|
|
1553
1618
|
// src/repositories/OutboxRepository.ts
|
|
@@ -4976,7 +5041,8 @@ var WikiMemory = class {
|
|
|
4976
5041
|
}
|
|
4977
5042
|
}
|
|
4978
5043
|
/**
|
|
4979
|
-
* Soft-delete facts and tasks by id, by source,
|
|
5044
|
+
* Soft-delete facts and tasks by id, by source, by source-pointer event id,
|
|
5045
|
+
* or all of them (`clearAll`).
|
|
4980
5046
|
* `clearAll` also deletes the entity's edges and its source-ref index rows.
|
|
4981
5047
|
* Add `includeEvents: true` to `clearAll` to hard-delete every event too,
|
|
4982
5048
|
* read or not, and reset the librarian's position: without it a later
|