@equationalapplications/core-llm-wiki 9.14.1 → 9.16.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-JX7VMQ55.mjs → chunk-DD5G4VRF.mjs} +3624 -3223
- package/dist/chunk-DD5G4VRF.mjs.map +1 -0
- package/dist/index.d.mts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +1484 -942
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +174 -34
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-BclOvn3q.d.mts → testing-C8sYdo2S.d.mts} +169 -41
- package/dist/{testing-BclOvn3q.d.ts → testing-C8sYdo2S.d.ts} +169 -41
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +465 -71
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-JX7VMQ55.mjs.map +0 -1
|
@@ -8,8 +8,10 @@ import { OkfSource, OkfVerifiedEntry, OkfSourceUsageWindow } from '@equationalap
|
|
|
8
8
|
* the `'edges'` member; the resolution step added the `'resolve'` member and
|
|
9
9
|
* the heal-screen step added the `'healScreen'` member. Each landed as one
|
|
10
10
|
* new line in
|
|
11
|
-
* `SystemOneThresholdSite`, so sibling PRs merged cleanly.
|
|
12
|
-
*
|
|
11
|
+
* `SystemOneThresholdSite`, so sibling PRs merged cleanly. The type-on-write
|
|
12
|
+
* step landed the `typeOnWrite` key; it reuses the `'typing'` floor and added
|
|
13
|
+
* no `SystemOneThresholdSite` member. Nothing outside that boundary belongs
|
|
14
|
+
* here.
|
|
13
15
|
*/
|
|
14
16
|
/** Sites a System-One threshold can apply to. Exactly four members today: `'typing'`, `'edges'`, `'resolve'` and `'healScreen'` (§10 fence). */
|
|
15
17
|
type SystemOneThresholdSite = 'typing' | 'edges' | 'resolve' | 'healScreen';
|
|
@@ -60,6 +62,19 @@ interface SystemOneConfig {
|
|
|
60
62
|
* configuration that can silently discard a model-directed heal action.
|
|
61
63
|
*/
|
|
62
64
|
healScreen?: 'auto' | 'llm';
|
|
65
|
+
/**
|
|
66
|
+
* Write-time typing for the librarian (both strategies). `'llm'` (default)
|
|
67
|
+
* keeps today's write path exactly: the generative prompt carries the
|
|
68
|
+
* ontology block and the model types each fact inline, or leaves it for
|
|
69
|
+
* backfill. `'auto'` asks `llmProvider.classify` to type every fact the
|
|
70
|
+
* librarian is about to insert, inside the pass's own token meter, and the
|
|
71
|
+
* ontology block leaves the write prompt for that pass. Facts the
|
|
72
|
+
* classifier does not type are written untyped exactly as today and stay
|
|
73
|
+
* eligible for backfill. Engages only when a classifier is present and the
|
|
74
|
+
* manifest is representable. Facts typed this way carry no
|
|
75
|
+
* manifest-drawn edges. There is no `'off'`.
|
|
76
|
+
*/
|
|
77
|
+
typeOnWrite?: 'auto' | 'llm';
|
|
63
78
|
/** Per-site minimum confidence. Only the classifier path reads a floor. */
|
|
64
79
|
minConfidence?: Partial<Record<SystemOneThresholdSite, number>>;
|
|
65
80
|
/**
|
|
@@ -196,6 +211,17 @@ interface OntologyPromptContext {
|
|
|
196
211
|
ontologyManifest: string;
|
|
197
212
|
ontologyModeInstructions: string;
|
|
198
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* The ontology prompt context for the WRITE builders (ingest, librarian, ops
|
|
216
|
+
* extract; specs/type-on-write §5). Same two fields as `OntologyPromptContext`
|
|
217
|
+
* plus a literal brand, so a write context and a backfill context are not
|
|
218
|
+
* interchangeable at compile time.
|
|
219
|
+
*/
|
|
220
|
+
interface WriteOntologyPromptContext {
|
|
221
|
+
site: 'write';
|
|
222
|
+
ontologyManifest: string;
|
|
223
|
+
ontologyModeInstructions: string;
|
|
224
|
+
}
|
|
199
225
|
/** Result of a single ontology backfill run. Omissions (facts the model declined
|
|
200
226
|
* to classify) are carried by `abstained`, not derived from the other counters. */
|
|
201
227
|
interface OntologyBackfillResult {
|
|
@@ -731,8 +757,19 @@ interface WikiFact {
|
|
|
731
757
|
superseded_by?: string | null;
|
|
732
758
|
/** Epoch ms the supersession was recorded (transaction time). Audit only. */
|
|
733
759
|
superseded_at?: number | null;
|
|
760
|
+
/** The `valid_to` this fact carried immediately before its current supersession (a scheduled end `supersede()` overwrote). Restored by `reopen()`. Absent when the fact was open-ended or the supersession predates schema 18. */
|
|
761
|
+
prior_valid_to?: number | null;
|
|
734
762
|
/** Structured provenance from this librarian fact to its source event, with the verified quote. Null for legacy/heal/ingest facts. */
|
|
735
763
|
source_pointer?: WikiSourcePointer | null;
|
|
764
|
+
/**
|
|
765
|
+
* Ids of further events this fact's stored wording also rests on, beyond
|
|
766
|
+
* the one `source_pointer` names (specs/inplace-update-provenance). Written
|
|
767
|
+
* by the ops librarian when it merges event text into an existing fact. A
|
|
768
|
+
* contribution ledger, not a second pointer: no quote, no position. Present
|
|
769
|
+
* only when non-empty; absent for facts updated before schema v18.
|
|
770
|
+
* `forget({ eventId })` matches it.
|
|
771
|
+
*/
|
|
772
|
+
derived_events?: string[];
|
|
736
773
|
}
|
|
737
774
|
interface WikiTask {
|
|
738
775
|
id: string;
|
|
@@ -1008,7 +1045,7 @@ type WikiDiagnosticSeverity = 'info' | 'warn' | 'error';
|
|
|
1008
1045
|
* Closed for this release series, but new codes are added in minor versions:
|
|
1009
1046
|
* hosts must tolerate codes they do not recognize.
|
|
1010
1047
|
*/
|
|
1011
|
-
type WikiDiagnosticCode = 'ingest_chunk_failed' | 'fact_rejected' | 'task_rejected' | 'fact_deduplicated' | 'edge_dropped' | 'embedding_failed' | 'hook_failed' | 'background_job_failed' | 'heal_skipped' | 'heal_deleted' | 'heal_downgraded' | 'grounding_missing' | 'grounding_failed' | 'classification_low_confidence' | 'classification_invalid' | 'classification_abstained' | 'node_type_assigned' | 'context_overflow_skipped' | 'llm_usage' | 'librarian_gate' | 'librarian_op_rejected' | 'contradicts_document' | 'ontology_backfill_held' | 'resolve_failed' | 'read_budget' | 'event_retention_held' | 'prune_checkpoint_incomplete' | 'erase_secure_delete_off' | 'erase_entity_skipped' | 'erase_retired_vtab_undroppable' | 'erase_fts_orphan_cleared' | 'erase_retired_remaining' | 'erase_tombstones_remaining' | 'erase_retired_read_failed' | 'erase_registry_sweep_skipped' | 'import_tombstone_skipped' | 'event_created_at_clamped' | 'event_created_at_restamped' | 'external_deletion_pending' | 'external_deletion_discarded' | 'guidance_too_long' | 'guidance_resolver_failed' | 'source_pointer_unresolved' | 'source_pointer_invalid' | 'source_store_source_too_large' | 'source_store_budget_exceeded' | 'source_store_hash_mismatch' | 'source_store_duplicate_hash' | 'source_store_text_not_storable' | 'node_type_dropped' | 'node_type_folded' | 'ontology_update_rejected' | 'ingest_zero_facts';
|
|
1048
|
+
type WikiDiagnosticCode = 'ingest_chunk_failed' | 'fact_rejected' | 'task_rejected' | 'fact_deduplicated' | 'edge_dropped' | 'embedding_failed' | 'hook_failed' | 'background_job_failed' | 'heal_skipped' | 'heal_deleted' | 'heal_downgraded' | 'grounding_missing' | 'grounding_failed' | 'classification_low_confidence' | 'classification_invalid' | 'classification_abstained' | 'node_type_assigned' | 'context_overflow_skipped' | 'llm_usage' | 'librarian_gate' | 'librarian_op_rejected' | 'librarian_rewritten' | 'librarian_superseded' | 'contradicts_document' | 'ontology_backfill_held' | 'resolve_failed' | 'read_budget' | 'event_retention_held' | 'prune_checkpoint_incomplete' | 'erase_secure_delete_off' | 'erase_entity_skipped' | 'erase_retired_vtab_undroppable' | 'erase_fts_orphan_cleared' | 'erase_retired_remaining' | 'erase_tombstones_remaining' | 'erase_retired_read_failed' | 'erase_registry_sweep_skipped' | 'import_tombstone_skipped' | 'event_created_at_clamped' | 'event_created_at_restamped' | 'external_deletion_pending' | 'supersede_scheduled_end_replaced' | 'external_deletion_discarded' | 'guidance_too_long' | 'guidance_resolver_failed' | 'source_pointer_unresolved' | 'source_pointer_invalid' | 'source_event_gone' | 'derived_events_invalid' | 'source_store_source_too_large' | 'source_store_budget_exceeded' | 'source_store_hash_mismatch' | 'source_store_duplicate_hash' | 'source_store_text_not_storable' | 'node_type_dropped' | 'node_type_folded' | 'ontology_update_rejected' | 'ingest_zero_facts';
|
|
1012
1049
|
/** The service run that emitted the diagnostic. */
|
|
1013
1050
|
type WikiDiagnosticOperation = 'ingest' | 'upsertGraph' | 'librarian' | 'heal' | 'ontologyBackfill' | 'reembed' | 'importDump' | 'write' | 'supersede' | 'remember' | 'read' | 'prune' | 'externalDeletion' | 'sourceStore' | 'erase';
|
|
1014
1051
|
/** `'auto'` when a write threshold started the run (auto-librarian / auto-heal); `'call'` when the host did. */
|
|
@@ -1055,6 +1092,8 @@ interface WikiDiagnosticDetail {
|
|
|
1055
1092
|
oldestEnqueuedAt?: number;
|
|
1056
1093
|
/** external_deletion_pending only: highest attempt count among pending rows. */
|
|
1057
1094
|
maxAttempts?: number;
|
|
1095
|
+
/** supersede_scheduled_end_replaced only: epoch ms of the scheduled end the supersede overwrote (a timestamp, not content). */
|
|
1096
|
+
priorValidTo?: number;
|
|
1058
1097
|
/** guidance_too_long only: length of the refused value in UTF-16 code units. */
|
|
1059
1098
|
guidanceLength?: number;
|
|
1060
1099
|
/** guidance_too_long only: which configured value was refused. */
|
|
@@ -1069,6 +1108,8 @@ interface WikiDiagnosticDetail {
|
|
|
1069
1108
|
to?: string;
|
|
1070
1109
|
/** `node_type_folded` only: always `'normalize'`. */
|
|
1071
1110
|
via?: 'normalize';
|
|
1111
|
+
/** `librarian_superseded` only: the id of the fact that replaced `factId`. */
|
|
1112
|
+
replacementId?: string;
|
|
1072
1113
|
/** `node_type_assigned` only: the manifest slug the fact was typed with (≤ 64 chars). */
|
|
1073
1114
|
okfType?: string;
|
|
1074
1115
|
/** `node_type_assigned` only: which path typed the fact. */
|
|
@@ -1284,7 +1325,9 @@ interface MemoryDump {
|
|
|
1284
1325
|
* Source-pointer parse report (specs/source-pointers §Export, import, and OKF).
|
|
1285
1326
|
* Present ONLY when `parseOkfBundle` dropped a malformed `source_pointer`
|
|
1286
1327
|
* value: entry ids and a reason slug — never raw pointer values, because a
|
|
1287
|
-
* pointer can carry quote text.
|
|
1328
|
+
* pointer can carry quote text. Also carries `derived_events_malformed`
|
|
1329
|
+
* entries for a dropped OKF `derived_events` list. Export-only metadata;
|
|
1330
|
+
* `importDump` ignores it.
|
|
1288
1331
|
*/
|
|
1289
1332
|
dropped_pointer_values?: Array<{
|
|
1290
1333
|
factId: string;
|
|
@@ -1471,7 +1514,8 @@ interface ForgetParams {
|
|
|
1471
1514
|
sourceHash?: string;
|
|
1472
1515
|
/**
|
|
1473
1516
|
* Soft-delete every librarian fact whose `source_pointer` names this event
|
|
1474
|
-
* id
|
|
1517
|
+
* id, or whose `derived_events` list contains it (a fact the librarian
|
|
1518
|
+
* merged this event's text into is deleted whole; entity-scoped; exact match, no normalization — event ids are
|
|
1475
1519
|
* engine-generated). Mutually exclusive with every other selector;
|
|
1476
1520
|
* `clearAll` excludes it. Removal reports through the return value and the
|
|
1477
1521
|
* per-row outbox DELETE events. See `specs/forget-by-event-id/` (issue #386).
|
|
@@ -1619,8 +1663,8 @@ declare class WikiDraftNotFound extends Error {
|
|
|
1619
1663
|
readonly code: "WIKI_DRAFT_NOT_FOUND";
|
|
1620
1664
|
constructor();
|
|
1621
1665
|
}
|
|
1622
|
-
type WikiSupersedeReason = 'not_found' | 'already_superseded' | 'immutable_target' | 'cycle' | 'cross_entity' | 'already_expired' | 'invalid_interval';
|
|
1623
|
-
/** Thrown by `supersede()` and `
|
|
1666
|
+
type WikiSupersedeReason = 'not_found' | 'already_superseded' | 'immutable_target' | 'cycle' | 'cross_entity' | 'already_expired' | 'invalid_interval' | 'not_superseded' | 'successor_live';
|
|
1667
|
+
/** Thrown by `supersede()`, `expire()` and `reopen()` (spec §4.3). Contextless like {@link WikiDraftNotFound}. */
|
|
1624
1668
|
declare class WikiSupersedeError extends Error {
|
|
1625
1669
|
readonly code: "WIKI_SUPERSEDE_REJECTED";
|
|
1626
1670
|
readonly reason: WikiSupersedeReason;
|
|
@@ -1767,6 +1811,12 @@ interface EntityMaintenanceReport {
|
|
|
1767
1811
|
ontologyBackfillPasses: number;
|
|
1768
1812
|
/** Facts that received an okf_type during this run's ontology-backfill passes. */
|
|
1769
1813
|
typed: number;
|
|
1814
|
+
/**
|
|
1815
|
+
* Facts typed by the classifier at the librarian write door during this run
|
|
1816
|
+
* (`systemOne.typeOnWrite: 'auto'`). Absent unless write-time typing engaged
|
|
1817
|
+
* for at least one pass. Kept apart from `typed` (backfill): two writers, two counters.
|
|
1818
|
+
*/
|
|
1819
|
+
typedOnWrite?: number;
|
|
1770
1820
|
/** Set when a lock was held elsewhere; nothing ran for that job. */
|
|
1771
1821
|
busy?: LockedMaintenanceJob[];
|
|
1772
1822
|
/**
|
|
@@ -1890,6 +1940,7 @@ type TemporalFields = {
|
|
|
1890
1940
|
valid_to?: number | null;
|
|
1891
1941
|
superseded_by?: string | null;
|
|
1892
1942
|
superseded_at?: number | null;
|
|
1943
|
+
prior_valid_to?: number | null;
|
|
1893
1944
|
};
|
|
1894
1945
|
/** Lightweight projection used by TemporalService for supersession chain walks. */
|
|
1895
1946
|
type TemporalRow = {
|
|
@@ -1901,6 +1952,7 @@ type TemporalRow = {
|
|
|
1901
1952
|
valid_from: number | null;
|
|
1902
1953
|
valid_to: number | null;
|
|
1903
1954
|
superseded_by: string | null;
|
|
1955
|
+
prior_valid_to: number | null;
|
|
1904
1956
|
};
|
|
1905
1957
|
type EntryRowMetadata = {
|
|
1906
1958
|
id: string;
|
|
@@ -2009,7 +2061,7 @@ declare class EntryRepository extends BaseRepository {
|
|
|
2009
2061
|
}>>;
|
|
2010
2062
|
findIdById(id: string, entityId: string, tx?: SQLiteAdapter): Promise<string | null>;
|
|
2011
2063
|
findIdsBySource(entityId: string, sourceRef: string | null, sourceHash: string | null, tx?: SQLiteAdapter, includeDeleted?: boolean): Promise<string[]>;
|
|
2012
|
-
upsertForImport(fact: WikiFact, tx: SQLiteAdapter, sourcePointerPresent?: boolean): Promise<{
|
|
2064
|
+
upsertForImport(fact: WikiFact, tx: SQLiteAdapter, sourcePointerPresent?: boolean, derivedEventsPresent?: boolean): Promise<{
|
|
2013
2065
|
changes: number;
|
|
2014
2066
|
lastInsertRowId: number;
|
|
2015
2067
|
}>;
|
|
@@ -2028,16 +2080,25 @@ declare class EntryRepository extends BaseRepository {
|
|
|
2028
2080
|
*/
|
|
2029
2081
|
softDeleteBySource(entityId: string, tx: SQLiteAdapter, sourceRef?: string | null, sourceHash?: string | null): Promise<number>;
|
|
2030
2082
|
/**
|
|
2031
|
-
* Shared JSON match predicate for
|
|
2032
|
-
* (specs/forget-by-event-id §D1
|
|
2083
|
+
* Shared JSON match predicate for an event id
|
|
2084
|
+
* (specs/forget-by-event-id §D1, widened by specs/inplace-update-provenance
|
|
2085
|
+
* §4): a row matches when its `source_pointer` names the event OR its
|
|
2086
|
+
* `derived_events` list contains it. Every JSON call sits under its own
|
|
2033
2087
|
* `json_valid` guard: unguarded JSON functions RAISE on malformed text, and
|
|
2034
2088
|
* three-valued logic forces evaluation of AND operands after a NULL-guarded
|
|
2035
2089
|
* term — a two-term form is only as safe as the planner's term-splitting.
|
|
2090
|
+
* The `json_each` term additionally requires `json_type = 'array'` (a JSON
|
|
2091
|
+
* object or scalar would otherwise iterate its members). The event id binds
|
|
2092
|
+
* TWICE (pointer term, then derived_events term); use `eventMatchArgs`.
|
|
2036
2093
|
* The tombstone guard (`deleted_at IS NULL`) is added per-method.
|
|
2037
2094
|
*/
|
|
2038
|
-
static readonly
|
|
2095
|
+
static readonly EVENT_MATCH_SQL = "((CASE WHEN json_valid(source_pointer)\n THEN json_type(source_pointer, '$.event_id') = 'text'\n AND json_extract(source_pointer, '$.event_id') = ?\n ELSE 0 END)\n OR\n (CASE WHEN json_valid(derived_events)\n THEN (CASE WHEN json_type(derived_events) = 'array'\n THEN EXISTS (SELECT 1 FROM json_each(derived_events) WHERE json_each.type = 'text' AND json_each.value = ?)\n ELSE 0 END)\n ELSE 0 END))";
|
|
2096
|
+
/** Bind values for `EVENT_MATCH_SQL` after an `entity_id = ?` term: the event id twice. */
|
|
2097
|
+
static eventMatchArgs(entityId: string, eventId: string): [string, string, string];
|
|
2098
|
+
/** Old name kept as an alias (tests and external references). */
|
|
2099
|
+
static readonly POINTER_EVENT_MATCH_SQL = "((CASE WHEN json_valid(source_pointer)\n THEN json_type(source_pointer, '$.event_id') = 'text'\n AND json_extract(source_pointer, '$.event_id') = ?\n ELSE 0 END)\n OR\n (CASE WHEN json_valid(derived_events)\n THEN (CASE WHEN json_type(derived_events) = 'array'\n THEN EXISTS (SELECT 1 FROM json_each(derived_events) WHERE json_each.type = 'text' AND json_each.value = ?)\n ELSE 0 END)\n ELSE 0 END))";
|
|
2039
2100
|
/**
|
|
2040
|
-
* IDs of the entity's entries whose source_pointer names the event id.
|
|
2101
|
+
* IDs of the entity's entries whose source_pointer names the event id or whose derived_events list contains it.
|
|
2041
2102
|
* `includeDeleted = true` returns live + tombstoned rows (the forget
|
|
2042
2103
|
* enumeration superset for index sync and the ledger backstop).
|
|
2043
2104
|
*/
|
|
@@ -2165,7 +2226,7 @@ declare class EntryRepository extends BaseRepository {
|
|
|
2165
2226
|
* Used by MaintenanceService.doRunHeal().
|
|
2166
2227
|
*/
|
|
2167
2228
|
softDeleteByIds(ids: string[], entityId: string, tx: SQLiteAdapter): Promise<void>;
|
|
2168
|
-
/** Spec §4: write any subset of the
|
|
2229
|
+
/** Spec §4: write any subset of the five temporal columns. Absent key = untouched; null = clear. */
|
|
2169
2230
|
setTemporal(id: string, entityId: string, fields: TemporalFields, tx: SQLiteAdapter, opts?: {
|
|
2170
2231
|
outbox?: boolean;
|
|
2171
2232
|
}): Promise<number>;
|
|
@@ -3486,6 +3547,15 @@ declare class OntologyService {
|
|
|
3486
3547
|
manifest: OntologyManifest;
|
|
3487
3548
|
}>;
|
|
3488
3549
|
buildPromptContext(entityId: string): Promise<OntologyPromptContext | null>;
|
|
3550
|
+
/**
|
|
3551
|
+
* Ontology prompt context for the WRITE builders (specs/type-on-write §5).
|
|
3552
|
+
* `null` when the mode is `'off'` or when write-time typing is `engaged`
|
|
3553
|
+
* (the classifier types the fact, so the manifest leaves the write prompt).
|
|
3554
|
+
* Backfill keeps `buildPromptContext`.
|
|
3555
|
+
*/
|
|
3556
|
+
buildWritePromptContext(entityId: string, opts: {
|
|
3557
|
+
engaged: boolean;
|
|
3558
|
+
}): Promise<WriteOntologyPromptContext | null>;
|
|
3489
3559
|
mergeEmergentUpdates(entityId: string, updates: OntologyUpdates, tx: SQLiteAdapter): Promise<{
|
|
3490
3560
|
manifest: OntologyManifest;
|
|
3491
3561
|
rejected: string[];
|
|
@@ -3553,6 +3623,11 @@ interface GuidanceDiagnostic {
|
|
|
3553
3623
|
};
|
|
3554
3624
|
}
|
|
3555
3625
|
|
|
3626
|
+
/** Backfill builders accept the backfill context only: a write context (branded) is rejected. */
|
|
3627
|
+
type BackfillOntologyContext = OntologyPromptContext & {
|
|
3628
|
+
site?: never;
|
|
3629
|
+
};
|
|
3630
|
+
|
|
3556
3631
|
declare class PromptService {
|
|
3557
3632
|
private globalOverrides?;
|
|
3558
3633
|
private grounding;
|
|
@@ -3588,8 +3663,12 @@ declare class PromptService {
|
|
|
3588
3663
|
private hasOntologyPlaceholders;
|
|
3589
3664
|
/** Removes ontology placeholders until none remain, so a nested form cannot reassemble one (closes CodeQL #11). */
|
|
3590
3665
|
private stripOntologyPlaceholders;
|
|
3591
|
-
|
|
3592
|
-
private
|
|
3666
|
+
/** Write-site variant (ingest, librarian, ops extract). Body identical to the backfill variant by design (specs/type-on-write §5). */
|
|
3667
|
+
private buildWriteSystemPrompt;
|
|
3668
|
+
private appendWriteOntology;
|
|
3669
|
+
/** Backfill-site variant. Body identical to the write variant by design (specs/type-on-write §5). */
|
|
3670
|
+
private buildBackfillSystemPrompt;
|
|
3671
|
+
private appendBackfillOntology;
|
|
3593
3672
|
buildIngestPrompt(documentChunk: string, runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null, guidance?: string): {
|
|
3594
3673
|
systemPrompt: string;
|
|
3595
3674
|
userPrompt: string;
|
|
@@ -3629,7 +3708,7 @@ declare class PromptService {
|
|
|
3629
3708
|
degraded: DegradedRecord[];
|
|
3630
3709
|
groundingCorpus?: string[];
|
|
3631
3710
|
};
|
|
3632
|
-
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?:
|
|
3711
|
+
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: BackfillOntologyContext | null, candidateSections?: string): {
|
|
3633
3712
|
systemPrompt: string;
|
|
3634
3713
|
userPrompt: string;
|
|
3635
3714
|
};
|
|
@@ -3661,7 +3740,21 @@ declare class PromptService {
|
|
|
3661
3740
|
* placeholders and leaves data placeholders verbatim; heal never receives
|
|
3662
3741
|
* ontology context, matching `buildHealPrompt`.
|
|
3663
3742
|
*/
|
|
3664
|
-
buildInstructionTemplates(
|
|
3743
|
+
buildInstructionTemplates(writeContext: OntologyPromptContext | null, librarianStrategy: 'legacy' | 'ops', guidance?: string,
|
|
3744
|
+
/**
|
|
3745
|
+
* The backfill context (specs/type-on-write §5). Omitted: derived from
|
|
3746
|
+
* `writeContext`, which preserves the single-context behavior of this
|
|
3747
|
+
* method before the split. `WikiMemory.getInstructions` passes it
|
|
3748
|
+
* explicitly because an engaged entity's write context is `null` while
|
|
3749
|
+
* its backfill prompt still carries the manifest.
|
|
3750
|
+
*/
|
|
3751
|
+
backfillContext?: BackfillOntologyContext | null,
|
|
3752
|
+
/**
|
|
3753
|
+
* The ingest write context. Omitted: `writeContext`. `getInstructions`
|
|
3754
|
+
* passes the un-engaged context here because write-time typing governs the
|
|
3755
|
+
* librarian only (specs/type-on-write §5, step-14 seam).
|
|
3756
|
+
*/
|
|
3757
|
+
ingestContext?: OntologyPromptContext | null): WikiInstructions;
|
|
3665
3758
|
}
|
|
3666
3759
|
|
|
3667
3760
|
declare class IngestionService {
|
|
@@ -3887,6 +3980,12 @@ declare class EventRepository extends BaseRepository {
|
|
|
3887
3980
|
add(event: WikiEvent, tx?: SQLiteAdapter): Promise<void>;
|
|
3888
3981
|
/** Insert unless the id already exists. Returns true when a row was inserted. */
|
|
3889
3982
|
addIgnoreDuplicate(event: WikiEvent, tx?: SQLiteAdapter): Promise<boolean>;
|
|
3983
|
+
/**
|
|
3984
|
+
* The subset of `ids` that exist as events of `entityId` (specs/
|
|
3985
|
+
* inplace-update-provenance §3). Chunked so a large batch stays under the
|
|
3986
|
+
* bound-variable limit. Pass `tx` to read inside the caller's transaction.
|
|
3987
|
+
*/
|
|
3988
|
+
findExistingIds(entityId: string, ids: readonly string[], tx?: SQLiteAdapter): Promise<Set<string>>;
|
|
3890
3989
|
/**
|
|
3891
3990
|
* Return the most recent events for an entity, newest first.
|
|
3892
3991
|
* Defaults to a limit of 50.
|
|
@@ -3991,18 +4090,21 @@ declare class UsageMeter {
|
|
|
3991
4090
|
}
|
|
3992
4091
|
|
|
3993
4092
|
/**
|
|
3994
|
-
*
|
|
3995
|
-
*
|
|
3996
|
-
*
|
|
3997
|
-
* editing the body. The verbatim legacy move lives in `legacy.ts`; the
|
|
3998
|
-
* dispatcher in `index.ts` is the only place that knows which strategies
|
|
3999
|
-
* exist. New strategies register there.
|
|
4000
|
-
*
|
|
4001
|
-
* `LibrarianStrategy` is the contract every implementation satisfies. The
|
|
4002
|
-
* pass is identified by its `(entityId, trigger, promptOverride?, meter?)`
|
|
4003
|
-
* context; the strategy returns what it processed so the caller can
|
|
4004
|
-
* advance checkpoints / watermarks.
|
|
4093
|
+
* Upper bound on one classifier choice question (specs/system-one-config §5):
|
|
4094
|
+
* manifest slugs plus the abstain sentinel. Owned here so the backfill site
|
|
4095
|
+
* and the write site cannot drift; `MaintenanceService` re-exports it.
|
|
4005
4096
|
*/
|
|
4097
|
+
declare const CLASSIFIER_MAX_CHOICES: 255;
|
|
4098
|
+
/** Per-pass typing counters (specs/type-on-write §8). */
|
|
4099
|
+
interface TypingCounters {
|
|
4100
|
+
asked: number;
|
|
4101
|
+
typed: number;
|
|
4102
|
+
abstained: number;
|
|
4103
|
+
lowConfidence: number;
|
|
4104
|
+
invalid: number;
|
|
4105
|
+
skipped: number;
|
|
4106
|
+
unattempted: number;
|
|
4107
|
+
}
|
|
4006
4108
|
|
|
4007
4109
|
/** Per-pass inputs the caller decides; the strategy cannot derive these. */
|
|
4008
4110
|
interface LibrarianContext {
|
|
@@ -4047,18 +4149,17 @@ interface LibrarianResult {
|
|
|
4047
4149
|
budgetStop?: {
|
|
4048
4150
|
requiredEstimate: number;
|
|
4049
4151
|
};
|
|
4152
|
+
/** Present only when write-time typing engaged for the pass (type-on-write §8). */
|
|
4153
|
+
typing?: TypingCounters;
|
|
4154
|
+
/** Ops only, internal: ids of existing facts the pass rewrote in place (type-on-write §9). */
|
|
4155
|
+
rewrittenIds?: string[];
|
|
4156
|
+
/** Ops only, internal: ids of facts the pass superseded (type-on-write §9). */
|
|
4157
|
+
supersededIds?: string[];
|
|
4050
4158
|
}
|
|
4051
4159
|
|
|
4052
4160
|
declare const ONTOLOGY_BACKFILL_BATCH_SIZE = 25;
|
|
4053
4161
|
|
|
4054
4162
|
declare const ONTOLOGY_BACKFILL_RECHECK_MS: number;
|
|
4055
|
-
/**
|
|
4056
|
-
* Upper bound on one classifier choice question (specs/system-one-config §5):
|
|
4057
|
-
* manifest slugs plus the abstain sentinel. A manifest with more slugs than
|
|
4058
|
-
* the cap allows, or carrying the reserved sentinel slug, falls back to the
|
|
4059
|
-
* generative path for the pass.
|
|
4060
|
-
*/
|
|
4061
|
-
declare const CLASSIFIER_MAX_CHOICES: 255;
|
|
4062
4163
|
|
|
4063
4164
|
/**
|
|
4064
4165
|
* Heal candidates fetched per pass. Bounds the pool runBatched draws from, not
|
|
@@ -4480,8 +4581,8 @@ declare class MaintenanceScheduler {
|
|
|
4480
4581
|
* `budget_too_small` > `complete`. `budget_too_small` means a job's smallest
|
|
4481
4582
|
* unit needs more than the WHOLE budget — that job is skipped this run and
|
|
4482
4583
|
* the run continues; `budget_exhausted` means a unit needs more than what
|
|
4483
|
-
* REMAINS — the run stops. The token budget meters
|
|
4484
|
-
*
|
|
4584
|
+
* REMAINS — the run stops. The token budget meters generation and classify
|
|
4585
|
+
* calls; embeddings are never metered.
|
|
4485
4586
|
*/
|
|
4486
4587
|
run(opts?: RunPendingMaintenanceOptions): Promise<RunPendingMaintenanceResult>;
|
|
4487
4588
|
/**
|
|
@@ -4633,7 +4734,9 @@ declare class TemporalService {
|
|
|
4633
4734
|
* already exist. Throws WikiSupersedeError on any rule violation; the
|
|
4634
4735
|
* caller's transaction then rolls back.
|
|
4635
4736
|
*/
|
|
4636
|
-
supersedeInTx(tx: SQLiteAdapter, entityId: string, oldId: string, newId: string, t: number, now: number): Promise<
|
|
4737
|
+
supersedeInTx(tx: SQLiteAdapter, entityId: string, oldId: string, newId: string, t: number, now: number): Promise<{
|
|
4738
|
+
replacedScheduledEnd: number | null;
|
|
4739
|
+
}>;
|
|
4637
4740
|
supersede(entityId: string, oldId: string, replacement: SupersedeReplacement, options?: {
|
|
4638
4741
|
validFrom?: number;
|
|
4639
4742
|
}): Promise<{
|
|
@@ -4646,6 +4749,14 @@ declare class TemporalService {
|
|
|
4646
4749
|
expire(entityId: string, factId: string, options?: {
|
|
4647
4750
|
at?: number;
|
|
4648
4751
|
}): Promise<void>;
|
|
4752
|
+
/**
|
|
4753
|
+
* Return a superseded fact to live once its replacement is forgotten or gone
|
|
4754
|
+
* (INTENT rule 12, specs/supersede-future-valid-to D4). Restores `valid_to`
|
|
4755
|
+
* to `prior_valid_to` (null when none was recorded).
|
|
4756
|
+
*/
|
|
4757
|
+
reopen(entityId: string, factId: string): Promise<{
|
|
4758
|
+
valid_to: number | null;
|
|
4759
|
+
}>;
|
|
4649
4760
|
history(entityId: string, factId: string): Promise<WikiFact[]>;
|
|
4650
4761
|
}
|
|
4651
4762
|
|
|
@@ -5096,7 +5207,10 @@ declare class WikiMemory {
|
|
|
5096
5207
|
* End `oldId`'s validity and link it to its replacement (spec §4.3). One
|
|
5097
5208
|
* transaction. Throws `WikiSupersedeError` for missing, foreign, already
|
|
5098
5209
|
* superseded, already expired, immutable-document, or cyclic targets, and
|
|
5099
|
-
* for an inverted or empty interval (`invalid_interval`).
|
|
5210
|
+
* for an inverted or empty interval (`invalid_interval`). When the old
|
|
5211
|
+
* fact carried a future `valid_to`, that scheduled end is overwritten but
|
|
5212
|
+
* kept in `prior_valid_to` (restored by `reopen()`) and reported as the
|
|
5213
|
+
* `supersede_scheduled_end_replaced` diagnostic.
|
|
5100
5214
|
*/
|
|
5101
5215
|
supersede(entityId: string, oldId: string, replacement: SupersedeReplacement, options?: {
|
|
5102
5216
|
validFrom?: number;
|
|
@@ -5115,6 +5229,20 @@ declare class WikiMemory {
|
|
|
5115
5229
|
expire(entityId: string, factId: string, options?: {
|
|
5116
5230
|
at?: number;
|
|
5117
5231
|
}): Promise<void>;
|
|
5232
|
+
/**
|
|
5233
|
+
* Return a superseded fact to live once its replacement has been forgotten
|
|
5234
|
+
* or hard-deleted (INTENT rule 12). Clears `superseded_by`/`superseded_at`
|
|
5235
|
+
* and restores `valid_to` to the scheduled end `supersede()` overwrote
|
|
5236
|
+
* (`prior_valid_to`), or null when the fact was open-ended. Resolves with
|
|
5237
|
+
* the restored `valid_to`. Throws `WikiSupersedeError` for a missing or
|
|
5238
|
+
* foreign fact, one that is not superseded (an `expire()`-ended fact is
|
|
5239
|
+
* not reopened), an immutable-document fact, or `successor_live` while the
|
|
5240
|
+
* direct replacement is still live. A restored end that has already passed
|
|
5241
|
+
* leaves the fact expired.
|
|
5242
|
+
*/
|
|
5243
|
+
reopen(entityId: string, factId: string): Promise<{
|
|
5244
|
+
valid_to: number | null;
|
|
5245
|
+
}>;
|
|
5118
5246
|
/** The supersession chain containing `factId`, oldest first. [] when unknown. */
|
|
5119
5247
|
history(entityId: string, factId: string): Promise<WikiFact[]>;
|
|
5120
5248
|
/**
|
|
@@ -5331,5 +5459,5 @@ declare class WikiMemory {
|
|
|
5331
5459
|
setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
|
|
5332
5460
|
}
|
|
5333
5461
|
|
|
5334
|
-
export { HEAL_RECHECK_MS as A, HOOK_TIMEOUT_MARKER as B, CLASSIFIER_MAX_CHOICES as C, HEAL_BATCH_SIZE as H, ONTOLOGY_ABSTAIN_SENTINEL as Y, ONTOLOGY_BACKFILL_BATCH_SIZE as Z, ONTOLOGY_BACKFILL_RECHECK_MS as _,
|
|
5335
|
-
export type { OntologyBackfillResult as $, DegradedRecord as D, EmbedFactResult as E, FormatContextOptions as F, GraphNeighborhood as G, HealResult as I, ImportDumpResult as J, IngestDocumentResult as K, LLMProvider as L, MemoryBundle as M, LibrarianConfig as N, OntologyMode as O, LibrarianGateConfig as P, LockedMaintenanceJob as Q, ReadOptions as R, SQLiteAdapter as S, MaintenanceJob as T, MaintenanceStopReason as U, MemoryDumpEntity as V, WikiConfig as W, MigrationPolicy as X, MemoryDump as a, OntologyEdgeType as a0, OntologyManifest as a1, OntologyNodeType as a2, OntologyPromptContext as a3, OntologyUpdates as a4, PendingMaintenance as a5, PendingMigrationWork as a6, PendingSourceStatus as a7, PromptOverrides as a8, WikiEdge as aC, WikiEvent as aD, WikiFact as aF, WikiInstructions as aI, WikiLintReport as aK, WikiMemoryTestAccess as aL, WikiOutboxEvent as aN, WikiSourcePointer as aQ, WikiSupersedeReason as aU, WikiTask as aV, ReembedResult as ab, RememberInput as ac, RunPendingMaintenanceOptions as ad, RunPendingMaintenanceResult as ae, SourcePassage as af, StoreSourceResult as ag, StoredSource as ah, StoredSourceDump as ai, StoredSourceSummary as aj, SupersedeReplacement as ak, SystemOneConfig as al, SystemOneThresholdSite as am, VectorRanker as an, VectorRankerFallback as ao, VectorRankerRankArgs as ap, VectorRankerSemanticResult as aq, WikiBusyOperation as as, WikiCheckpoint as at, WikiDiagnostic as au, WikiDiagnosticCode as av, WikiDiagnosticDetail as aw, WikiDiagnosticOperation as ax, WikiDiagnosticSeverity as ay, WikiDiagnosticTrigger as az, FormattedMemoryDump as b, OntologyConfig as c, WikiOptions as d, ChunkFailure as g, ClassifierAnswer as h, ClassifierQuestion as i, ClassifyRequest as j, ClassifyResponse as k, DraftPage as l, EmbedFailureKind as m, EmbeddingMarkerKind as n, EntityMaintenanceReport as o, EntityStatus as p, EraseReport as q, ExtractedFact as s, ExtractedFactEdge as t, ExtractedFactWithOntology as u, ExtractedTask as v, ForgetParams as w, ForgetResult as x, GraphTraversalOptions as y, GroundingConfig as z };
|
|
5462
|
+
export { HEAL_RECHECK_MS as A, HOOK_TIMEOUT_MARKER as B, CLASSIFIER_MAX_CHOICES as C, HEAL_BATCH_SIZE as H, ONTOLOGY_ABSTAIN_SENTINEL as Y, ONTOLOGY_BACKFILL_BATCH_SIZE as Z, ONTOLOGY_BACKFILL_RECHECK_MS as _, EmbeddingService as a$, PromptService as a9, WikiDraftNotFound as aA, WikiDuplicateHashError as aB, WikiExternalDeletionError as aE, WikiGraphNodeOwnershipConflict as aG, WikiIngestEmptyError as aH, WikiInvalidReadOptions as aJ, WikiMigrationRequiredError as aM, WikiParseError as aO, WikiSearchUnavailableError as aP, WikiSourceRefHashCollision as aR, WikiStrictOntologyViolation as aS, WikiSupersedeError as aT, WikiTransactionError as aW, isReservedAbstainSlug as aY, isWikiSearchUnavailableError as aZ, validateManifest as a_, PrunePartialFailureError as aa, WikiBusyError as ar, ImportExportService as b0, IngestionService as b1, JobManager as b2, MaintenanceService as b3, RetrievalService as b4, SearchService as b5, WriteService as b6, WikiMemory as e, CheckpointIncompleteError as f, EraseStepError as r };
|
|
5463
|
+
export type { OntologyBackfillResult as $, DegradedRecord as D, EmbedFactResult as E, FormatContextOptions as F, GraphNeighborhood as G, HealResult as I, ImportDumpResult as J, IngestDocumentResult as K, LLMProvider as L, MemoryBundle as M, LibrarianConfig as N, OntologyMode as O, LibrarianGateConfig as P, LockedMaintenanceJob as Q, ReadOptions as R, SQLiteAdapter as S, MaintenanceJob as T, MaintenanceStopReason as U, MemoryDumpEntity as V, WikiConfig as W, MigrationPolicy as X, MemoryDump as a, OntologyEdgeType as a0, OntologyManifest as a1, OntologyNodeType as a2, OntologyPromptContext as a3, OntologyUpdates as a4, PendingMaintenance as a5, PendingMigrationWork as a6, PendingSourceStatus as a7, PromptOverrides as a8, WikiEdge as aC, WikiEvent as aD, WikiFact as aF, WikiInstructions as aI, WikiLintReport as aK, WikiMemoryTestAccess as aL, WikiOutboxEvent as aN, WikiSourcePointer as aQ, WikiSupersedeReason as aU, WikiTask as aV, WriteOntologyPromptContext as aX, ReembedResult as ab, RememberInput as ac, RunPendingMaintenanceOptions as ad, RunPendingMaintenanceResult as ae, SourcePassage as af, StoreSourceResult as ag, StoredSource as ah, StoredSourceDump as ai, StoredSourceSummary as aj, SupersedeReplacement as ak, SystemOneConfig as al, SystemOneThresholdSite as am, VectorRanker as an, VectorRankerFallback as ao, VectorRankerRankArgs as ap, VectorRankerSemanticResult as aq, WikiBusyOperation as as, WikiCheckpoint as at, WikiDiagnostic as au, WikiDiagnosticCode as av, WikiDiagnosticDetail as aw, WikiDiagnosticOperation as ax, WikiDiagnosticSeverity as ay, WikiDiagnosticTrigger as az, FormattedMemoryDump as b, OntologyConfig as c, WikiOptions as d, ChunkFailure as g, ClassifierAnswer as h, ClassifierQuestion as i, ClassifyRequest as j, ClassifyResponse as k, DraftPage as l, EmbedFailureKind as m, EmbeddingMarkerKind as n, EntityMaintenanceReport as o, EntityStatus as p, EraseReport as q, ExtractedFact as s, ExtractedFactEdge as t, ExtractedFactWithOntology as u, ExtractedTask as v, ForgetParams as w, ForgetResult as x, GraphTraversalOptions as y, GroundingConfig as z };
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a$ as EmbeddingService, b0 as ImportExportService, b1 as IngestionService, b2 as JobManager, b2 as JobManagerType, b3 as MaintenanceService, b4 as RetrievalService, b5 as SearchService, b5 as SearchServiceType, aL as WikiMemoryTestAccess, b6 as WriteService } from './testing-C8sYdo2S.mjs';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a$ as EmbeddingService, b0 as ImportExportService, b1 as IngestionService, b2 as JobManager, b2 as JobManagerType, b3 as MaintenanceService, b4 as RetrievalService, b5 as SearchService, b5 as SearchServiceType, aL as WikiMemoryTestAccess, b6 as WriteService } from './testing-C8sYdo2S.js';
|
|
2
2
|
import '@equationalapplications/core-okf';
|