@equationalapplications/core-llm-wiki 5.5.0 → 6.0.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 +136 -31
- package/dist/{chunk-QVY5DFJV.mjs → chunk-HREQ6F6Z.mjs} +241 -45
- package/dist/chunk-HREQ6F6Z.mjs.map +1 -0
- package/dist/index.d.mts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +241 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-D0RnZjyW.d.mts → testing-DgqVB29I.d.mts} +72 -6
- package/dist/{testing-D0RnZjyW.d.ts → testing-DgqVB29I.d.ts} +72 -6
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +238 -42
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-QVY5DFJV.mjs.map +0 -1
|
@@ -101,6 +101,20 @@ interface OntologyBackfillResult {
|
|
|
101
101
|
* Stamped with the recheck cooldown, so they reappear as `deferred` next pass. */
|
|
102
102
|
skipped: number;
|
|
103
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* L3 heal-success record: a fact the model emitted a verdict for under a
|
|
106
|
+
* truncated view of its own body. `originalBodyChars` lets an operator flag
|
|
107
|
+
* the fact for re-inspection; `truncatedBodyChars` is the L3 cap actually
|
|
108
|
+
* applied. Emitted by `PromptService.buildHealPrompt`, surfaced via
|
|
109
|
+
* `HealResult.degraded`, mutually exclusive with `HealResult.skipped` on
|
|
110
|
+
* `id` (a fact can be either healed-under-degradation or dropped — never
|
|
111
|
+
* both).
|
|
112
|
+
*/
|
|
113
|
+
interface DegradedRecord {
|
|
114
|
+
id: string;
|
|
115
|
+
originalBodyChars: number;
|
|
116
|
+
truncatedBodyChars: number;
|
|
117
|
+
}
|
|
104
118
|
/** Result of a single heal run. */
|
|
105
119
|
interface HealResult {
|
|
106
120
|
/**
|
|
@@ -118,8 +132,32 @@ interface HealResult {
|
|
|
118
132
|
deleted: number;
|
|
119
133
|
/** New facts synthesized by heal. */
|
|
120
134
|
newFactsCreated: number;
|
|
121
|
-
/**
|
|
122
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Candidates that could not converge after the helper's full escalation
|
|
137
|
+
* path. `reason` distinguishes genuine non-convergence
|
|
138
|
+
* (`'non_convergent'` — terminal give-up at attemptLevel 3, parse error,
|
|
139
|
+
* or model-config error) from transient provider failures
|
|
140
|
+
* (`'call_error'` — non-truncation error originating in `call()` at
|
|
141
|
+
* `batch.length === 1`). `doRunHeal` excludes `'call_error'` ids from
|
|
142
|
+
* `markHealChecked`'s cooldown stamp so a momentary provider hiccup does
|
|
143
|
+
* not lock the fact out for `HEAL_RECHECK_MS`. Mutually exclusive with
|
|
144
|
+
* `degraded` on `id`.
|
|
145
|
+
*/
|
|
146
|
+
skipped: Array<{
|
|
147
|
+
id: string;
|
|
148
|
+
reason: 'non_convergent' | 'call_error';
|
|
149
|
+
}>;
|
|
150
|
+
/**
|
|
151
|
+
* L3 heal successes: facts the model emitted a verdict for under a
|
|
152
|
+
* truncated view of their own body. Each entry carries the truncation
|
|
153
|
+
* magnitude so an operator can flag the fact for re-inspection. The
|
|
154
|
+
* corresponding log line `[WikiMemory] heal healed under degraded
|
|
155
|
+
* context ...` fires for each entry. Mutually exclusive with `skipped`
|
|
156
|
+
* on `id` — the reconciliation step in doRunHeal drops any record
|
|
157
|
+
* whose id also appears in `skipped` (a contradiction: degraded means
|
|
158
|
+
* healed, skipped means dropped).
|
|
159
|
+
*/
|
|
160
|
+
degraded: Array<DegradedRecord>;
|
|
123
161
|
/**
|
|
124
162
|
* Heal candidates still eligible after this run — convergence signal: loop while > 0.
|
|
125
163
|
*
|
|
@@ -1530,9 +1568,34 @@ declare class PromptService {
|
|
|
1530
1568
|
systemPrompt: string;
|
|
1531
1569
|
userPrompt: string;
|
|
1532
1570
|
};
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1571
|
+
/**
|
|
1572
|
+
* Heal-prompt level interpretation for the `attemptLevel` ladder.
|
|
1573
|
+
*
|
|
1574
|
+
* Caller contract: `documentAnchors` may be a slice sized for `batch.length`
|
|
1575
|
+
* or a larger set (e.g. a cache hit from `_selectHealAnchors`). This function
|
|
1576
|
+
* applies the prompt-side anchor cap `min(HEAL_MAX_ANCHORS=50, batch.length
|
|
1577
|
+
* * HEAL_ANCHORS_PER_CANDIDATE=4)` so the rendered prompt is bounded
|
|
1578
|
+
* regardless of caller input. `HEAL_MAX_ANCHORS` and
|
|
1579
|
+
* `HEAL_ANCHORS_PER_CANDIDATE` live here too — keeping the formula
|
|
1580
|
+
* co-located with its application avoids a "MaintenanceService policy"
|
|
1581
|
+
* import cycle (`PromptService` is constructed before `MaintenanceService`
|
|
1582
|
+
* exists) and makes the cap testable without a `MaintenanceService`
|
|
1583
|
+
* instance. Task 3 exports the same two constants from `MaintenanceService`
|
|
1584
|
+
* for caller-side overfetch sizing; the values must match.
|
|
1585
|
+
*
|
|
1586
|
+
* Level semantics:
|
|
1587
|
+
* - L0: allTasks + recentEvents + full candidate bodies; anchors re-capped
|
|
1588
|
+
* - L1: drop allTasks; recentEvents present; candidate bodies full
|
|
1589
|
+
* - L2: drop allTasks and recentEvents; candidate bodies full
|
|
1590
|
+
* - L3: drop allTasks and recentEvents; truncate each candidate body to
|
|
1591
|
+
* `bodyTruncationChars` and emit a `degraded` record per truncated fact
|
|
1592
|
+
*/
|
|
1593
|
+
buildHealPrompt(healCandidates: unknown[], documentAnchors: unknown[], allTasks: unknown[], recentEvents: unknown[], runtimeOverride: string | undefined, attemptLevel: 0 | 1 | 2 | 3, bodyTruncationChars?: number): {
|
|
1594
|
+
prompts: {
|
|
1595
|
+
systemPrompt: string;
|
|
1596
|
+
userPrompt: string;
|
|
1597
|
+
};
|
|
1598
|
+
degraded: DegradedRecord[];
|
|
1536
1599
|
};
|
|
1537
1600
|
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
|
|
1538
1601
|
systemPrompt: string;
|
|
@@ -1748,6 +1811,7 @@ declare class EventRepository extends BaseRepository {
|
|
|
1748
1811
|
declare const ONTOLOGY_BACKFILL_BATCH_SIZE = 25;
|
|
1749
1812
|
declare const ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS = 40000;
|
|
1750
1813
|
declare const ONTOLOGY_BACKFILL_RECHECK_MS: number;
|
|
1814
|
+
|
|
1751
1815
|
/**
|
|
1752
1816
|
* Heal candidates fetched per pass. Bounds the pool runBatched draws from, not
|
|
1753
1817
|
* the size of an individual LLM call — runBatched still packs ~10 candidates per
|
|
@@ -1787,6 +1851,7 @@ declare class MaintenanceService {
|
|
|
1787
1851
|
runHeal(entityId: string, options?: {
|
|
1788
1852
|
promptOverride?: string;
|
|
1789
1853
|
batchSize?: number;
|
|
1854
|
+
bodyTruncationChars?: number;
|
|
1790
1855
|
}): Promise<HealResult>;
|
|
1791
1856
|
runOntologyBackfill(entityId: string, options?: {
|
|
1792
1857
|
promptOverride?: string;
|
|
@@ -1840,6 +1905,7 @@ declare class MaintenanceService {
|
|
|
1840
1905
|
doRunHeal(entityId: string, options?: {
|
|
1841
1906
|
promptOverride?: string;
|
|
1842
1907
|
batchSize?: number;
|
|
1908
|
+
bodyTruncationChars?: number;
|
|
1843
1909
|
}): Promise<HealResult>;
|
|
1844
1910
|
/** Core ontology backfill pass (locks handled by {@link runOntologyBackfill}). Package-internal orchestration hook. */
|
|
1845
1911
|
doRunOntologyBackfill(entityId: string, options?: {
|
|
@@ -2304,4 +2370,4 @@ declare class WikiMemory {
|
|
|
2304
2370
|
setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
|
|
2305
2371
|
}
|
|
2306
2372
|
|
|
2307
|
-
export {
|
|
2373
|
+
export { WikiSourceRefHashCollision as $, WikiBusyError as A, type WikiBusyOperation as B, type ChunkFailure as C, type DegradedRecord as D, type EntityStatus as E, type FormatContextOptions as F, type GraphNeighborhood as G, HEAL_BATCH_SIZE as H, type IngestDocumentResult as I, type WikiCheckpoint as J, type WikiConfig as K, type LLMProvider as L, type MemoryBundle as M, WikiDuplicateHashError as N, type OntologyManifest as O, type PromptOverrides as P, type WikiEdge as Q, type ReadOptions as R, type SQLiteAdapter as S, type WikiEvent as T, type WikiFact as U, type VectorRanker as V, type WikiOptions as W, WikiIngestEmptyError as X, type WikiMemoryTestAccess as Y, type WikiOutboxEvent as Z, WikiParseError as _, type MemoryDump as a, WikiStrictOntologyViolation as a0, type WikiTask as a1, WikiTransactionError as a2, EmbeddingService as a3, ImportExportService as a4, IngestionService as a5, JobManager as a6, MaintenanceService as a7, RetrievalService as a8, SearchService as a9, WriteService as aa, type FormattedMemoryDump as b, WikiMemory as c, type ExtractedFact as d, type ExtractedFactEdge as e, type ExtractedFactWithOntology as f, type ExtractedTask as g, type GraphTraversalOptions as h, HEAL_RECHECK_MS as i, HOOK_TIMEOUT_MARKER as j, type HealResult as k, ONTOLOGY_BACKFILL_BATCH_SIZE as l, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as m, ONTOLOGY_BACKFILL_RECHECK_MS as n, type OntologyBackfillResult as o, type OntologyConfig as p, type OntologyEdgeType as q, type OntologyMode as r, type OntologyNodeType as s, type OntologyPromptContext as t, type OntologyUpdates as u, PromptService as v, PrunePartialFailureError as w, type VectorRankerFallback as x, type VectorRankerRankArgs as y, type VectorRankerSemanticResult as z };
|
|
@@ -101,6 +101,20 @@ interface OntologyBackfillResult {
|
|
|
101
101
|
* Stamped with the recheck cooldown, so they reappear as `deferred` next pass. */
|
|
102
102
|
skipped: number;
|
|
103
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* L3 heal-success record: a fact the model emitted a verdict for under a
|
|
106
|
+
* truncated view of its own body. `originalBodyChars` lets an operator flag
|
|
107
|
+
* the fact for re-inspection; `truncatedBodyChars` is the L3 cap actually
|
|
108
|
+
* applied. Emitted by `PromptService.buildHealPrompt`, surfaced via
|
|
109
|
+
* `HealResult.degraded`, mutually exclusive with `HealResult.skipped` on
|
|
110
|
+
* `id` (a fact can be either healed-under-degradation or dropped — never
|
|
111
|
+
* both).
|
|
112
|
+
*/
|
|
113
|
+
interface DegradedRecord {
|
|
114
|
+
id: string;
|
|
115
|
+
originalBodyChars: number;
|
|
116
|
+
truncatedBodyChars: number;
|
|
117
|
+
}
|
|
104
118
|
/** Result of a single heal run. */
|
|
105
119
|
interface HealResult {
|
|
106
120
|
/**
|
|
@@ -118,8 +132,32 @@ interface HealResult {
|
|
|
118
132
|
deleted: number;
|
|
119
133
|
/** New facts synthesized by heal. */
|
|
120
134
|
newFactsCreated: number;
|
|
121
|
-
/**
|
|
122
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Candidates that could not converge after the helper's full escalation
|
|
137
|
+
* path. `reason` distinguishes genuine non-convergence
|
|
138
|
+
* (`'non_convergent'` — terminal give-up at attemptLevel 3, parse error,
|
|
139
|
+
* or model-config error) from transient provider failures
|
|
140
|
+
* (`'call_error'` — non-truncation error originating in `call()` at
|
|
141
|
+
* `batch.length === 1`). `doRunHeal` excludes `'call_error'` ids from
|
|
142
|
+
* `markHealChecked`'s cooldown stamp so a momentary provider hiccup does
|
|
143
|
+
* not lock the fact out for `HEAL_RECHECK_MS`. Mutually exclusive with
|
|
144
|
+
* `degraded` on `id`.
|
|
145
|
+
*/
|
|
146
|
+
skipped: Array<{
|
|
147
|
+
id: string;
|
|
148
|
+
reason: 'non_convergent' | 'call_error';
|
|
149
|
+
}>;
|
|
150
|
+
/**
|
|
151
|
+
* L3 heal successes: facts the model emitted a verdict for under a
|
|
152
|
+
* truncated view of their own body. Each entry carries the truncation
|
|
153
|
+
* magnitude so an operator can flag the fact for re-inspection. The
|
|
154
|
+
* corresponding log line `[WikiMemory] heal healed under degraded
|
|
155
|
+
* context ...` fires for each entry. Mutually exclusive with `skipped`
|
|
156
|
+
* on `id` — the reconciliation step in doRunHeal drops any record
|
|
157
|
+
* whose id also appears in `skipped` (a contradiction: degraded means
|
|
158
|
+
* healed, skipped means dropped).
|
|
159
|
+
*/
|
|
160
|
+
degraded: Array<DegradedRecord>;
|
|
123
161
|
/**
|
|
124
162
|
* Heal candidates still eligible after this run — convergence signal: loop while > 0.
|
|
125
163
|
*
|
|
@@ -1530,9 +1568,34 @@ declare class PromptService {
|
|
|
1530
1568
|
systemPrompt: string;
|
|
1531
1569
|
userPrompt: string;
|
|
1532
1570
|
};
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1571
|
+
/**
|
|
1572
|
+
* Heal-prompt level interpretation for the `attemptLevel` ladder.
|
|
1573
|
+
*
|
|
1574
|
+
* Caller contract: `documentAnchors` may be a slice sized for `batch.length`
|
|
1575
|
+
* or a larger set (e.g. a cache hit from `_selectHealAnchors`). This function
|
|
1576
|
+
* applies the prompt-side anchor cap `min(HEAL_MAX_ANCHORS=50, batch.length
|
|
1577
|
+
* * HEAL_ANCHORS_PER_CANDIDATE=4)` so the rendered prompt is bounded
|
|
1578
|
+
* regardless of caller input. `HEAL_MAX_ANCHORS` and
|
|
1579
|
+
* `HEAL_ANCHORS_PER_CANDIDATE` live here too — keeping the formula
|
|
1580
|
+
* co-located with its application avoids a "MaintenanceService policy"
|
|
1581
|
+
* import cycle (`PromptService` is constructed before `MaintenanceService`
|
|
1582
|
+
* exists) and makes the cap testable without a `MaintenanceService`
|
|
1583
|
+
* instance. Task 3 exports the same two constants from `MaintenanceService`
|
|
1584
|
+
* for caller-side overfetch sizing; the values must match.
|
|
1585
|
+
*
|
|
1586
|
+
* Level semantics:
|
|
1587
|
+
* - L0: allTasks + recentEvents + full candidate bodies; anchors re-capped
|
|
1588
|
+
* - L1: drop allTasks; recentEvents present; candidate bodies full
|
|
1589
|
+
* - L2: drop allTasks and recentEvents; candidate bodies full
|
|
1590
|
+
* - L3: drop allTasks and recentEvents; truncate each candidate body to
|
|
1591
|
+
* `bodyTruncationChars` and emit a `degraded` record per truncated fact
|
|
1592
|
+
*/
|
|
1593
|
+
buildHealPrompt(healCandidates: unknown[], documentAnchors: unknown[], allTasks: unknown[], recentEvents: unknown[], runtimeOverride: string | undefined, attemptLevel: 0 | 1 | 2 | 3, bodyTruncationChars?: number): {
|
|
1594
|
+
prompts: {
|
|
1595
|
+
systemPrompt: string;
|
|
1596
|
+
userPrompt: string;
|
|
1597
|
+
};
|
|
1598
|
+
degraded: DegradedRecord[];
|
|
1536
1599
|
};
|
|
1537
1600
|
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
|
|
1538
1601
|
systemPrompt: string;
|
|
@@ -1748,6 +1811,7 @@ declare class EventRepository extends BaseRepository {
|
|
|
1748
1811
|
declare const ONTOLOGY_BACKFILL_BATCH_SIZE = 25;
|
|
1749
1812
|
declare const ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS = 40000;
|
|
1750
1813
|
declare const ONTOLOGY_BACKFILL_RECHECK_MS: number;
|
|
1814
|
+
|
|
1751
1815
|
/**
|
|
1752
1816
|
* Heal candidates fetched per pass. Bounds the pool runBatched draws from, not
|
|
1753
1817
|
* the size of an individual LLM call — runBatched still packs ~10 candidates per
|
|
@@ -1787,6 +1851,7 @@ declare class MaintenanceService {
|
|
|
1787
1851
|
runHeal(entityId: string, options?: {
|
|
1788
1852
|
promptOverride?: string;
|
|
1789
1853
|
batchSize?: number;
|
|
1854
|
+
bodyTruncationChars?: number;
|
|
1790
1855
|
}): Promise<HealResult>;
|
|
1791
1856
|
runOntologyBackfill(entityId: string, options?: {
|
|
1792
1857
|
promptOverride?: string;
|
|
@@ -1840,6 +1905,7 @@ declare class MaintenanceService {
|
|
|
1840
1905
|
doRunHeal(entityId: string, options?: {
|
|
1841
1906
|
promptOverride?: string;
|
|
1842
1907
|
batchSize?: number;
|
|
1908
|
+
bodyTruncationChars?: number;
|
|
1843
1909
|
}): Promise<HealResult>;
|
|
1844
1910
|
/** Core ontology backfill pass (locks handled by {@link runOntologyBackfill}). Package-internal orchestration hook. */
|
|
1845
1911
|
doRunOntologyBackfill(entityId: string, options?: {
|
|
@@ -2304,4 +2370,4 @@ declare class WikiMemory {
|
|
|
2304
2370
|
setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
|
|
2305
2371
|
}
|
|
2306
2372
|
|
|
2307
|
-
export {
|
|
2373
|
+
export { WikiSourceRefHashCollision as $, WikiBusyError as A, type WikiBusyOperation as B, type ChunkFailure as C, type DegradedRecord as D, type EntityStatus as E, type FormatContextOptions as F, type GraphNeighborhood as G, HEAL_BATCH_SIZE as H, type IngestDocumentResult as I, type WikiCheckpoint as J, type WikiConfig as K, type LLMProvider as L, type MemoryBundle as M, WikiDuplicateHashError as N, type OntologyManifest as O, type PromptOverrides as P, type WikiEdge as Q, type ReadOptions as R, type SQLiteAdapter as S, type WikiEvent as T, type WikiFact as U, type VectorRanker as V, type WikiOptions as W, WikiIngestEmptyError as X, type WikiMemoryTestAccess as Y, type WikiOutboxEvent as Z, WikiParseError as _, type MemoryDump as a, WikiStrictOntologyViolation as a0, type WikiTask as a1, WikiTransactionError as a2, EmbeddingService as a3, ImportExportService as a4, IngestionService as a5, JobManager as a6, MaintenanceService as a7, RetrievalService as a8, SearchService as a9, WriteService as aa, type FormattedMemoryDump as b, WikiMemory as c, type ExtractedFact as d, type ExtractedFactEdge as e, type ExtractedFactWithOntology as f, type ExtractedTask as g, type GraphTraversalOptions as h, HEAL_RECHECK_MS as i, HOOK_TIMEOUT_MARKER as j, type HealResult as k, ONTOLOGY_BACKFILL_BATCH_SIZE as l, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as m, ONTOLOGY_BACKFILL_RECHECK_MS as n, type OntologyBackfillResult as o, type OntologyConfig as p, type OntologyEdgeType as q, type OntologyMode as r, type OntologyNodeType as s, type OntologyPromptContext as t, type OntologyUpdates as u, PromptService as v, PrunePartialFailureError as w, type VectorRankerFallback as x, type VectorRankerRankArgs as y, type VectorRankerSemanticResult as z };
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a3 as EmbeddingService, a4 as ImportExportService, a5 as IngestionService, a6 as JobManager, a6 as JobManagerType, a7 as MaintenanceService, a8 as RetrievalService, a9 as SearchService, a9 as SearchServiceType, Y as WikiMemoryTestAccess, aa as WriteService } from './testing-DgqVB29I.mjs';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
|
3
3
|
import 'minisearch';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a3 as EmbeddingService, a4 as ImportExportService, a5 as IngestionService, a6 as JobManager, a6 as JobManagerType, a7 as MaintenanceService, a8 as RetrievalService, a9 as SearchService, a9 as SearchServiceType, Y as WikiMemoryTestAccess, aa as WriteService } from './testing-DgqVB29I.js';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
|
3
3
|
import 'minisearch';
|