@equationalapplications/core-llm-wiki 6.2.0 → 6.3.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/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, WikiSourceRefHashCollision, generateId, BaseRepository, validateManifest, emptyManifest, resolveNodeType, WikiStrictOntologyViolation, validateInlineEdges, resolveEdgeDefinitions, typeSatisfies, normalizeTitleKey, WikiTransactionError, extractSqliteCode } from './chunk-YEESP6J2.mjs';
2
- export { DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, 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, WikiDuplicateHashError, WikiIngestEmptyError, WikiParseError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiTransactionError, chunkText, configureRandomSource, parseEmbedding, safeSlice, validateManifest } from './chunk-YEESP6J2.mjs';
1
+ import { __privateAdd, MetadataRepository, EmbeddingService, SearchService, JobManager, PromptService, IngestionService, MaintenanceService, ImportExportService, RetrievalService, WriteService, __privateGet, __privateSet, normalizeSourceRef, normalizeSourceHash, entitySummaryMetaKey, WikiSourceRefHashCollision, validateManifest, generateId, BaseRepository, emptyManifest, resolveNodeType, WikiStrictOntologyViolation, validateInlineEdges, resolveEdgeDefinitions, typeSatisfies, normalizeTitleKey, WikiTransactionError, extractSqliteCode } from './chunk-YDTJ2OO4.mjs';
2
+ export { DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, 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, WikiDuplicateHashError, WikiIngestEmptyError, WikiParseError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiTransactionError, chunkText, configureRandomSource, parseEmbedding, safeSlice, validateManifest } from './chunk-YDTJ2OO4.mjs';
3
3
  import { appendRelatedSection, buildConceptDocument, buildLogMd, buildEntityIndexMd, buildRootIndexMd, isAllowedOkfPath, parseRootIndexMd, parseEntityIndexMd, parseConcept, splitRelatedSection, extractMarkdownLinks, parseLogMd, parseEventIdComment, latestVerified, formatSourcesJson, appendEventIdComment, parseVerifiedFlexible, parseCitationsList, deriveTrustTier, isStaleAfter } from '@equationalapplications/core-okf';
4
4
 
5
5
  // src/db/schema.ts
@@ -3078,13 +3078,64 @@ var WikiMemory = class {
3078
3078
  * Seeds or replaces an entity's ontology manifest and optional mode override.
3079
3079
  * Validates manifest invariants (unique type slugs, edge endpoints reference node types).
3080
3080
  * Invalidates the in-memory ontology cache for this entity.
3081
+ *
3082
+ * Delegates to `setOntologyManifests` so there is a single write path. The
3083
+ * observable contract is unchanged: same upsert semantics, same cache
3084
+ * invalidation, same `void` result.
3081
3085
  */
3082
3086
  async setOntologyManifest(entityId, manifest, options) {
3083
- const mode = options?.mode ?? this.ontologyService.resolveMode();
3084
- await this.db.withTransactionAsync(
3085
- (tx) => this.metadataRepo.setManifest(entityId, { mode, manifest }, tx)
3086
- );
3087
- this.ontologyService.invalidateCache(entityId);
3087
+ await this.setOntologyManifests([{ entityId, manifest, mode: options?.mode }]);
3088
+ }
3089
+ /**
3090
+ * Write several entities' ontology manifests in a single transaction.
3091
+ *
3092
+ * All succeed or none do. The transaction is opened on this instance's
3093
+ * serialized adapter — callers pass data, never a transaction handle, because
3094
+ * a consumer holds the unwrapped adapter and a transaction opened on it would
3095
+ * bypass the serialization mutex applied in the constructor.
3096
+ *
3097
+ * Returns which entities were written. `skipped` is only ever non-empty under
3098
+ * `opts.ifAbsent`.
3099
+ *
3100
+ * Sharp edge: `ifAbsent` checks for a PERSISTED row, not for an effective
3101
+ * manifest. An entity whose manifest currently comes from
3102
+ * `WikiConfig.ontology.seedManifests` has no row until the seed is
3103
+ * materialized on first access that supplies a transaction (in practice, an
3104
+ * ingest). Until then `ifAbsent` treats the entity as absent, writes the new
3105
+ * manifest over the configured seed, and reports it in `written`; the same
3106
+ * call after the seed has been materialized reports it in `skipped`. See the
3107
+ * `ifAbsent` notes in the package README.
3108
+ */
3109
+ async setOntologyManifests(entries, opts) {
3110
+ if (entries.length === 0) return { written: [], skipped: [] };
3111
+ const seen = /* @__PURE__ */ new Set();
3112
+ for (const entry of entries) {
3113
+ if (seen.has(entry.entityId)) {
3114
+ throw new Error(`Duplicate entityId in batch: ${entry.entityId}`);
3115
+ }
3116
+ seen.add(entry.entityId);
3117
+ }
3118
+ for (const entry of entries) {
3119
+ validateManifest(entry.manifest);
3120
+ }
3121
+ const written = [];
3122
+ const skipped = [];
3123
+ await this.db.withTransactionAsync(async (tx) => {
3124
+ for (const entry of entries) {
3125
+ const mode = entry.mode ?? this.ontologyService.resolveMode();
3126
+ const wrote = await this.metadataRepo.setManifest(
3127
+ entry.entityId,
3128
+ { mode, manifest: entry.manifest },
3129
+ tx,
3130
+ { ifAbsent: opts?.ifAbsent === true }
3131
+ );
3132
+ (wrote ? written : skipped).push(entry.entityId);
3133
+ }
3134
+ });
3135
+ for (const entry of entries) {
3136
+ this.ontologyService.invalidateCache(entry.entityId);
3137
+ }
3138
+ return { written, skipped };
3088
3139
  }
3089
3140
  /** Append a verification event to a fact. Does NOT touch `updated_at`. */
3090
3141
  async writeOkfTrust(entryId, entityId, verified) {