@equationalapplications/core-llm-wiki 7.2.1 → 7.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/README.md +23 -0
- package/dist/{chunk-TTECJ3S3.mjs → chunk-IAYO63DQ.mjs} +346 -41
- package/dist/chunk-IAYO63DQ.mjs.map +1 -0
- package/dist/index.d.mts +3 -5
- package/dist/index.d.ts +3 -5
- package/dist/index.js +388 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -11
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-DYeMd9d1.d.mts → testing-ht1qOvcD.d.mts} +98 -6
- package/dist/{testing-DYeMd9d1.d.ts → testing-ht1qOvcD.d.ts} +98 -6
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +336 -38
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-TTECJ3S3.mjs.map +0 -1
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, validateManifest, generateId, BaseRepository, WikiGraphNodeOwnershipConflict, emptyManifest, resolveNodeType, WikiStrictOntologyViolation, validateInlineEdges, resolveEdgeDefinitions, typeSatisfies, normalizeTitleKey, WikiTransactionError, extractSqliteCode } 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, WikiDuplicateHashError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiParseError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiTransactionError, chunkText, configureRandomSource, parseEmbedding, safeSlice, validateManifest } from './chunk-
|
|
1
|
+
import { __privateAdd, MetadataRepository, EmbeddingService, SearchService, JobManager, PromptService, IngestionService, MaintenanceService, ImportExportService, RetrievalService, WriteService, __privateGet, __privateSet, normalizeSourceRef, normalizeSourceHash, entitySummaryMetaKey, WikiSourceRefHashCollision, DiagnosticBuffer, validateManifest, generateId, BaseRepository, WikiGraphNodeOwnershipConflict, emptyManifest, resolveNodeType, WikiStrictOntologyViolation, validateInlineEdges, resolveEdgeDefinitions, typeSatisfies, normalizeTitleKey, WikiTransactionError, extractSqliteCode } from './chunk-IAYO63DQ.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, WikiDuplicateHashError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiParseError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiTransactionError, chunkText, configureRandomSource, parseEmbedding, safeSlice, validateManifest } from './chunk-IAYO63DQ.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
|
|
@@ -2499,6 +2499,17 @@ var OntologyService = class {
|
|
|
2499
2499
|
const canonical = resolveNodeType(rawType, manifest);
|
|
2500
2500
|
if (!canonical) {
|
|
2501
2501
|
if (strict) throw new WikiStrictOntologyViolation(opts?.entityId ?? "", "node", rawType);
|
|
2502
|
+
if (opts?.drops && Array.isArray(fact.edges)) {
|
|
2503
|
+
for (const edge of fact.edges) {
|
|
2504
|
+
opts.drops.push({
|
|
2505
|
+
reason: "no_source_type",
|
|
2506
|
+
sourceId: null,
|
|
2507
|
+
edgeType: typeof edge?.edge_type === "string" ? edge.edge_type : null,
|
|
2508
|
+
sourceNodeType: null,
|
|
2509
|
+
targetNodeType: null
|
|
2510
|
+
});
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2502
2513
|
return { okf_type: null, edges: [] };
|
|
2503
2514
|
}
|
|
2504
2515
|
const edges = validateInlineEdges(canonical, null, fact.edges ?? [], manifest, opts);
|
|
@@ -2511,18 +2522,39 @@ var OntologyService = class {
|
|
|
2511
2522
|
* writes inside their own transaction (e.g. `IngestionService.ingestDocument`
|
|
2512
2523
|
* when delegating to `upsertGraphCore`).
|
|
2513
2524
|
*/
|
|
2514
|
-
resolveEdges(entityId, sourceId, sourceType, edges, manifest, titleIndex, now) {
|
|
2515
|
-
if (
|
|
2525
|
+
resolveEdges(entityId, sourceId, sourceType, edges, manifest, titleIndex, now, drops) {
|
|
2526
|
+
if (edges.length === 0) return [];
|
|
2527
|
+
if (!sourceType) {
|
|
2528
|
+
for (const edge of edges) {
|
|
2529
|
+
drops?.push({ reason: "no_source_type", sourceId, edgeType: edge.edge_type, sourceNodeType: null, targetNodeType: null });
|
|
2530
|
+
}
|
|
2531
|
+
return [];
|
|
2532
|
+
}
|
|
2516
2533
|
const out = [];
|
|
2517
2534
|
for (const edge of edges) {
|
|
2518
2535
|
const candidates = resolveEdgeDefinitions(edge.edge_type, manifest).filter((d) => typeSatisfies(d.source_type, sourceType, manifest));
|
|
2519
|
-
if (candidates.length === 0)
|
|
2536
|
+
if (candidates.length === 0) {
|
|
2537
|
+
drops?.push({ reason: "type_not_in_manifest", sourceId, edgeType: edge.edge_type, sourceNodeType: sourceType, targetNodeType: null });
|
|
2538
|
+
continue;
|
|
2539
|
+
}
|
|
2520
2540
|
const targetKey = normalizeTitleKey(edge.target_title);
|
|
2521
2541
|
const target = titleIndex.get(targetKey);
|
|
2522
|
-
if (!target)
|
|
2542
|
+
if (!target) {
|
|
2543
|
+
drops?.push({ reason: "target_not_found", sourceId, edgeType: edge.edge_type, sourceNodeType: sourceType, targetNodeType: null });
|
|
2544
|
+
continue;
|
|
2545
|
+
}
|
|
2523
2546
|
const targetType = (target.okf_type ?? "").trim().toLowerCase();
|
|
2524
2547
|
const def = candidates.find((d) => d.target_type.trim().toLowerCase() === targetType) ?? candidates.find((d) => typeSatisfies(d.target_type, targetType, manifest));
|
|
2525
|
-
if (!def)
|
|
2548
|
+
if (!def) {
|
|
2549
|
+
drops?.push({
|
|
2550
|
+
reason: "target_type_mismatch",
|
|
2551
|
+
sourceId,
|
|
2552
|
+
edgeType: edge.edge_type,
|
|
2553
|
+
sourceNodeType: sourceType,
|
|
2554
|
+
targetNodeType: target.okf_type ?? null
|
|
2555
|
+
});
|
|
2556
|
+
continue;
|
|
2557
|
+
}
|
|
2526
2558
|
out.push({
|
|
2527
2559
|
id: generateId(),
|
|
2528
2560
|
entity_id: entityId,
|
|
@@ -2541,8 +2573,8 @@ var OntologyService = class {
|
|
|
2541
2573
|
* want self-contained edge persistence (e.g. MaintenanceService heal /
|
|
2542
2574
|
* backfill callers that do not have a separate edge-write step).
|
|
2543
2575
|
*/
|
|
2544
|
-
async resolveAndPersistEdges(entityId, sourceId, sourceType, edges, manifest, titleIndex, tx, now) {
|
|
2545
|
-
const resolved = this.resolveEdges(entityId, sourceId, sourceType, edges, manifest, titleIndex, now);
|
|
2576
|
+
async resolveAndPersistEdges(entityId, sourceId, sourceType, edges, manifest, titleIndex, tx, now, drops) {
|
|
2577
|
+
const resolved = this.resolveEdges(entityId, sourceId, sourceType, edges, manifest, titleIndex, now, drops);
|
|
2546
2578
|
let persisted = 0;
|
|
2547
2579
|
for (const edge of resolved) {
|
|
2548
2580
|
const inserted = await this.edgeRepo.addIgnoreDuplicate(edge, tx);
|
|
@@ -3163,11 +3195,15 @@ var WikiMemory = class {
|
|
|
3163
3195
|
attemptedSourceRef: sourceRef
|
|
3164
3196
|
});
|
|
3165
3197
|
}
|
|
3166
|
-
|
|
3198
|
+
const diagBuffer = new DiagnosticBuffer();
|
|
3199
|
+
const result = await this.ingestionService.upsertGraphCore(
|
|
3167
3200
|
entityId,
|
|
3168
3201
|
{ sourceRef, sourceHash, nodes: params.nodes, edges: params.edges },
|
|
3169
|
-
adapter
|
|
3202
|
+
adapter,
|
|
3203
|
+
{ diag: { buffer: diagBuffer, operation: "upsertGraph" } }
|
|
3170
3204
|
);
|
|
3205
|
+
diagBuffer.flush(this.options);
|
|
3206
|
+
return result;
|
|
3171
3207
|
}
|
|
3172
3208
|
/**
|
|
3173
3209
|
* Returns up to `limit` unprocessed outbox events, oldest first.
|