@equationalapplications/core-llm-wiki 7.14.0 → 7.15.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 +25 -0
- package/dist/{chunk-PCRYIUV5.mjs → chunk-BC3QHSF3.mjs} +13 -8
- package/dist/chunk-BC3QHSF3.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +140 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +132 -9
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-DbrL569t.d.mts → testing-BlGhilQw.d.mts} +52 -3
- package/dist/{testing-DbrL569t.d.ts → testing-BlGhilQw.d.ts} +52 -3
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +10 -5
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-PCRYIUV5.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -67,6 +67,29 @@ For programmatic pipelines — importing pre-classified data, building a GraphRA
|
|
|
67
67
|
|
|
68
68
|
This is the GraphRAG seed path: load a corpus, walk it.
|
|
69
69
|
|
|
70
|
+
## Direct fact writes
|
|
71
|
+
|
|
72
|
+
`remember()` stores one mutable fact in one transaction, with no text-generation (LLM) call, and returns the stored row. When `llmProvider.embed` is configured it does await one embedding call before resolving (failures surface as `embedding_failed`, not a throw). Use it when the host already knows the fact (a user preference, an agent's observation the user approved). To replace a fact, use `supersede()` so history is kept.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
const fact = await wiki.remember('user-123', {
|
|
76
|
+
title: 'Prefers merge commits',
|
|
77
|
+
body: 'Kurt wants PRs merged with merge commits, never squashed.',
|
|
78
|
+
tags: ['git'], // default []
|
|
79
|
+
confidence: 'certain', // default
|
|
80
|
+
source_type: 'user_stated', // or 'user_confirmed'; default 'user_stated'
|
|
81
|
+
okf_type: 'Preference', // optional; resolved like an upsertGraph node type
|
|
82
|
+
valid_from: Date.parse('2026-03-01'), // optional epoch ms
|
|
83
|
+
});
|
|
84
|
+
fact.id; // 'fact_…' — the row as stored: timestamps, defaults, isStale, trustTier
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- Validation throws `TypeError` before anything is written: `title` non-empty, `body` a string, `tags` an array of strings, known `confidence` and `source_type` (explicit `null` is rejected; omit the field to take the default), `okf_type` a non-empty string or null, finite and >= 0 `valid_from`. Nothing is clipped; length limits are the host's.
|
|
88
|
+
- `okf_type` follows the `upsertGraph` rule: the manifest's canonical slug when known; `WikiStrictOntologyViolation` under strict mode otherwise; `null` otherwise.
|
|
89
|
+
- Never starts the librarian or heal and writes no event, in `'auto'` and `'deferred'` mode alike. Embeds through `llmProvider.embed` when present (failures surface as `embedding_failed` with `operation: 'remember'`); keyword-only otherwise, and `getPendingMaintenance().reembedPending` picks it up once an `embed` exists.
|
|
90
|
+
- Not idempotent: two identical calls store two facts. Hosts that expose retries own the idempotency key.
|
|
91
|
+
- Opens its own transaction. Do not call it inside `withTransactionAsync`.
|
|
92
|
+
|
|
70
93
|
## Temporal facts
|
|
71
94
|
|
|
72
95
|
Facts carry an optional validity window. Nothing changes until you use it: facts without validity data are always current.
|
|
@@ -132,6 +155,7 @@ const report = await wiki.runPendingMaintenance({ tokenBudget: 20_000, deadlineM
|
|
|
132
155
|
```
|
|
133
156
|
|
|
134
157
|
- `getPendingMaintenance()` shows the backlog per entity without calling a model.
|
|
158
|
+
- `remember()` and `supersede()` never schedule maintenance in either mode; only `write()` does.
|
|
135
159
|
- The budget covers text-generation tokens only; embedding calls are not counted. Figures are provider-reported when `generateTextWithUsage` exists, otherwise estimated at characters ÷ 4.
|
|
136
160
|
- Entities share the budget fairly: each round runs one batch per entity.
|
|
137
161
|
- `budget_too_small` names the first job and entity whose smallest step needed more than the whole budget; other entities may have hit the same limit in that run.
|
|
@@ -720,6 +744,7 @@ const wiki = createWiki(db, {
|
|
|
720
744
|
- **Isolated.** The hook is called synchronously. A throwing or rejecting hook never affects the operation, and its failure is logged with `console.warn`.
|
|
721
745
|
- **After commit.** Transactional diagnostics are delivered after the operation's transaction commits. An operation that throws delivers none; the exception is the signal. `upsertGraph` runs in your transaction, so its diagnostics are delivered when it resolves. Disregard them if you roll back.
|
|
722
746
|
- **`trigger`.** `'auto'` marks work started by `autoLibrarianThreshold` / `autoHealThreshold`. A failed background job is reported as `background_job_failed` with `operation` set to the job.
|
|
747
|
+
- **`operation`** names the entry point: `ingest`, `upsertGraph`, `librarian`, `heal`, `ontologyBackfill`, `reembed`, `importDump`, `write`, `supersede`, `remember`, `read`, `prune`. New values may be added in minor releases.
|
|
723
748
|
- **Forward-compatible.** New codes may be added in minor releases; ignore codes you don't recognize.
|
|
724
749
|
- **Console output is unchanged** when a hook is set and succeeds: every existing core line is identical. A throwing or rejecting hook adds only its own `console.warn`, and a non-function `onDiagnostic` warns once.
|
|
725
750
|
|
|
@@ -7499,6 +7499,15 @@ var RetrievalService = class {
|
|
|
7499
7499
|
}
|
|
7500
7500
|
};
|
|
7501
7501
|
|
|
7502
|
+
// src/utils/entityId.ts
|
|
7503
|
+
function assertEntityId(entityId) {
|
|
7504
|
+
if (typeof entityId !== "string" || entityId.length === 0 || entityId.length > 200 || entityId.includes("\0")) {
|
|
7505
|
+
throw new TypeError(
|
|
7506
|
+
`Invalid entityId: must be a non-empty string at most 200 chars with no null bytes; got ${JSON.stringify(entityId)}.`
|
|
7507
|
+
);
|
|
7508
|
+
}
|
|
7509
|
+
}
|
|
7510
|
+
|
|
7502
7511
|
// src/services/WriteService.ts
|
|
7503
7512
|
var WriteService = class {
|
|
7504
7513
|
constructor(db, options, entryRepo, eventRepo, metadataRepo, jobManager, maintenanceService) {
|
|
@@ -7524,11 +7533,7 @@ var WriteService = class {
|
|
|
7524
7533
|
}
|
|
7525
7534
|
}
|
|
7526
7535
|
async write(entityId, event) {
|
|
7527
|
-
|
|
7528
|
-
throw new TypeError(
|
|
7529
|
-
`Invalid entityId: must be a non-empty string at most 200 chars with no null bytes; got ${JSON.stringify(entityId)}.`
|
|
7530
|
-
);
|
|
7531
|
-
}
|
|
7536
|
+
assertEntityId(entityId);
|
|
7532
7537
|
if (event === null || typeof event !== "object" || Array.isArray(event)) {
|
|
7533
7538
|
throw new TypeError("Invalid event: must be a non-null object.");
|
|
7534
7539
|
}
|
|
@@ -7673,6 +7678,6 @@ var WriteService = class {
|
|
|
7673
7678
|
}
|
|
7674
7679
|
};
|
|
7675
7680
|
|
|
7676
|
-
export { BaseRepository, CURRENT_SCHEMA_VERSION, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DiagnosticBuffer, EMBED_CHARS_CEILING, EmbeddingService, FTS5_DRAIN_CHUNK, FTS5_REBUILD_SNAPSHOT_KEY, FTS5_REBUILD_WM_KEY, FTS5_RECLAIM_MERGE_PAGES, FTS5_RETIRED_COUNTER_KEY, FTS5_RETIRED_TABLES_KEY, FTS5_STATE_KEY, FTS5_SWEEP_CURSOR_KEY, HEAL_ANCHORS_PER_CANDIDATE, HEAL_BATCH_SIZE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, HEAL_RECHECK_MS, HOOK_TIMEOUT_MARKER, ImportExportService, IngestionService, JobManager, MAX_EMBED_ATTEMPTS, MIGRATIONS, MaintenanceService, MetadataRepository, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, RetrievalService, SearchService, TemporalService, UnavailableIndexStrategy, UsageMeter, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, WriteService, __privateAdd, __privateGet, __privateSet, chunkText, configureRandomSource, createLegacySourceTypeIndex, detectSchemaVersion, drainChunkSql, drainHiSql, edgeTripleAllowed, emptyManifest, entityDrainChunkSql, entityDrainHiSql, entitySummaryMetaKey, extractSqliteCode, factTokenCost, fts5LedgerDropSql, fts5PendingIndexesDdl, fts5TablesDdl, fts5TriggerNames, fts5TriggersDdl, generateId, idDrainChunkSql, idReindexChunkSql, isLiveAt, isRetiredTableName, isWikiSearchUnavailableError, liveAtSql, normalizeSourceHash, normalizeSourceRef, normalizeTitleKey, packFactsByBudget, parseEmbedding, parseJsonArray, parseJsonObject, probePendingWork, readRebuildProgress, reanchorRebuildFingerprint, resolveEdgeDefinitions, resolveGrounding, resolveNodeType, retiredTableName, runSourceRefNormalize, safeSlice, setupDatabase, sweepChunkSql, sweepHiSql, typeSatisfies, validateInlineEdges, validateManifest, windowChunkSql, windowHiSql, writeNormalizeStamp, writeRebuildStart };
|
|
7677
|
-
//# sourceMappingURL=chunk-
|
|
7678
|
-
//# sourceMappingURL=chunk-
|
|
7681
|
+
export { BaseRepository, CURRENT_SCHEMA_VERSION, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DiagnosticBuffer, EMBED_CHARS_CEILING, EmbeddingService, FTS5_DRAIN_CHUNK, FTS5_REBUILD_SNAPSHOT_KEY, FTS5_REBUILD_WM_KEY, FTS5_RECLAIM_MERGE_PAGES, FTS5_RETIRED_COUNTER_KEY, FTS5_RETIRED_TABLES_KEY, FTS5_STATE_KEY, FTS5_SWEEP_CURSOR_KEY, HEAL_ANCHORS_PER_CANDIDATE, HEAL_BATCH_SIZE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, HEAL_RECHECK_MS, HOOK_TIMEOUT_MARKER, ImportExportService, IngestionService, JobManager, MAX_EMBED_ATTEMPTS, MIGRATIONS, MaintenanceService, MetadataRepository, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, RetrievalService, SearchService, TemporalService, UnavailableIndexStrategy, UsageMeter, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, WriteService, __privateAdd, __privateGet, __privateSet, assertEntityId, assertEpochMs, chunkText, configureRandomSource, createLegacySourceTypeIndex, detectSchemaVersion, drainChunkSql, drainHiSql, edgeTripleAllowed, emptyManifest, entityDrainChunkSql, entityDrainHiSql, entitySummaryMetaKey, extractSqliteCode, factTokenCost, fts5LedgerDropSql, fts5PendingIndexesDdl, fts5TablesDdl, fts5TriggerNames, fts5TriggersDdl, generateId, idDrainChunkSql, idReindexChunkSql, isLiveAt, isRetiredTableName, isWikiSearchUnavailableError, liveAtSql, normalizeSourceHash, normalizeSourceRef, normalizeTitleKey, packFactsByBudget, parseEmbedding, parseJsonArray, parseJsonObject, probePendingWork, readRebuildProgress, reanchorRebuildFingerprint, resolveEdgeDefinitions, resolveGrounding, resolveNodeType, retiredTableName, runSourceRefNormalize, safeSlice, setupDatabase, sweepChunkSql, sweepHiSql, typeSatisfies, validateInlineEdges, validateManifest, windowChunkSql, windowHiSql, writeNormalizeStamp, writeRebuildStart };
|
|
7682
|
+
//# sourceMappingURL=chunk-BC3QHSF3.mjs.map
|
|
7683
|
+
//# sourceMappingURL=chunk-BC3QHSF3.mjs.map
|