@equationalapplications/core-llm-wiki 4.22.0 → 4.23.1

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/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { __privateAdd, MetadataRepository, EmbeddingService, SearchService, JobManager, PromptService, IngestionService, MaintenanceService, ImportExportService, RetrievalService, WriteService, __privateGet, __privateSet, normalizeSourceRef, normalizeSourceHash, entitySummaryMetaKey, generateId, BaseRepository, emptyManifest, resolveNodeType, validateInlineEdges, resolveEdgeDefinitions, normalizeTitleKey, WikiTransactionError, extractSqliteCode } from './chunk-LCAU6NYC.mjs';
2
- export { HOOK_TIMEOUT_MARKER, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, WikiBusyError, WikiTransactionError, configureRandomSource, parseEmbedding, validateManifest } from './chunk-LCAU6NYC.mjs';
1
+ import { __privateAdd, MetadataRepository, EmbeddingService, SearchService, JobManager, PromptService, IngestionService, MaintenanceService, ImportExportService, RetrievalService, WriteService, __privateGet, __privateSet, normalizeSourceRef, normalizeSourceHash, entitySummaryMetaKey, generateId, BaseRepository, emptyManifest, resolveNodeType, validateInlineEdges, resolveEdgeDefinitions, normalizeTitleKey, WikiTransactionError, extractSqliteCode } from './chunk-MYZJLVX4.mjs';
2
+ export { HOOK_TIMEOUT_MARKER, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, WikiBusyError, WikiTransactionError, configureRandomSource, parseEmbedding, validateManifest } from './chunk-MYZJLVX4.mjs';
3
3
  import { appendRelatedSection, buildConceptDocument, buildLogMd, buildEntityIndexMd, buildRootIndexMd, isAllowedOkfPath, parseRootIndexMd, parseEntityIndexMd, parseConcept, splitRelatedSection, extractMarkdownLinks, parseLogMd, parseEventIdComment, appendEventIdComment } from '@equationalapplications/core-okf';
4
4
 
5
5
  // src/db/schema.ts
@@ -602,6 +602,45 @@ var EntryRepository = class extends BaseRepository {
602
602
  );
603
603
  return rows.map(mapRowToFact);
604
604
  }
605
+ /**
606
+ * Fetch live, mutable entries for an entity — everything heal is allowed to
607
+ * downgrade or delete. Heal previously loaded every row via
608
+ * findAllByEntityId and filtered in JS, which on a document-heavy corpus
609
+ * meant loading 2560 rows to keep 31.
610
+ */
611
+ async findHealCandidatesByEntityId(entityId, tx) {
612
+ const executor = this.getExecutor(tx);
613
+ const rows = await executor.getAllAsync(
614
+ `SELECT * FROM ${this.prefix}entries
615
+ WHERE entity_id = ? AND deleted_at IS NULL AND source_type != 'immutable_document'
616
+ ORDER BY updated_at DESC`,
617
+ [entityId]
618
+ );
619
+ return rows.map(mapRowToFact);
620
+ }
621
+ /**
622
+ * Resolve search hits to document anchors. The MiniSearch index holds every
623
+ * fact, not only immutable_document rows, so the source-type restriction has
624
+ * to be applied here, after retrieval.
625
+ */
626
+ async findAnchorRowsByIds(entityId, ids, tx) {
627
+ if (ids.length === 0) return [];
628
+ const executor = this.getExecutor(tx);
629
+ const rows = [];
630
+ for (let i = 0; i < ids.length; i += this.chunkSize) {
631
+ const chunk = ids.slice(i, i + this.chunkSize);
632
+ const placeholders = chunk.map(() => "?").join(", ");
633
+ const chunkRows = await executor.getAllAsync(
634
+ `SELECT id, title, source_ref FROM ${this.prefix}entries
635
+ WHERE entity_id = ? AND deleted_at IS NULL
636
+ AND source_type = 'immutable_document'
637
+ AND id IN (${placeholders})`,
638
+ [entityId, ...chunk]
639
+ );
640
+ rows.push(...chunkRows);
641
+ }
642
+ return rows;
643
+ }
605
644
  /**
606
645
  * Fetch recent non-deleted entries for an entity (limited), ordered by updated_at DESC.
607
646
  * Used by MaintenanceService.doRunLibrarian().