@equationalapplications/core-llm-wiki 9.12.0 → 9.13.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-KB37MGFF.mjs → chunk-4TG7RQF6.mjs} +94 -5
- package/dist/chunk-4TG7RQF6.mjs.map +1 -0
- package/dist/index.d.mts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +93 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-imNjsm-X.d.mts → testing-DkKZcrhE.d.mts} +19 -4
- package/dist/{testing-imNjsm-X.d.ts → testing-DkKZcrhE.d.ts} +19 -4
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +91 -2
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-KB37MGFF.mjs.map +0 -1
|
@@ -5,13 +5,14 @@ import { OkfSource, OkfVerifiedEntry, OkfSourceUsageWindow } from '@equationalap
|
|
|
5
5
|
*
|
|
6
6
|
* Boundary: S1-0 owns exactly `typing`, `minConfidence` (with the `'typing'`
|
|
7
7
|
* member), and `onLowConfidence`; the edge-suggestions step adds `edges` and
|
|
8
|
-
* the `'edges'` member
|
|
9
|
-
*
|
|
8
|
+
* the `'edges'` member; the resolution step adds `resolve` and the
|
|
9
|
+
* `'resolve'` member. Later PRs add more threshold sites
|
|
10
|
+
* (`'healScreen'`) — each as one new line in
|
|
10
11
|
* `SystemOneThresholdSite`, so sibling PRs merge cleanly. Nothing outside
|
|
11
12
|
* that boundary belongs here.
|
|
12
13
|
*/
|
|
13
|
-
/** Sites a System-One threshold can apply to. Exactly
|
|
14
|
-
type SystemOneThresholdSite = 'typing' | 'edges';
|
|
14
|
+
/** Sites a System-One threshold can apply to. Exactly three members today: `'typing'`, `'edges'`, and `'resolve'` (§10 fence). */
|
|
15
|
+
type SystemOneThresholdSite = 'typing' | 'edges' | 'resolve';
|
|
15
16
|
interface SystemOneConfig {
|
|
16
17
|
/**
|
|
17
18
|
* Typing mode for ontology backfill. `'auto'` uses
|
|
@@ -31,6 +32,20 @@ interface SystemOneConfig {
|
|
|
31
32
|
* adds no configuration that can silently discard a model-proposed edge.
|
|
32
33
|
*/
|
|
33
34
|
edges?: 'auto' | 'llm';
|
|
35
|
+
/**
|
|
36
|
+
* Resolution mode for the librarian's ops resolve step. `'llm'` (default)
|
|
37
|
+
* keeps resolution on the generative path exactly as today. `'auto'`
|
|
38
|
+
* engages the classifier resolution screen (§4) when
|
|
39
|
+
* `llmProvider.classify` is present AND an explicit
|
|
40
|
+
* `minConfidence.resolve` floor is set (missing floor under `'auto'`
|
|
41
|
+
* warns once and the site resolves `'llm'`); a confident duplicate
|
|
42
|
+
* answer at or above the floor settles the candidate as a terminal NOOP,
|
|
43
|
+
* and every other answer falls through to the generative resolve of the
|
|
44
|
+
* same pass. An unavailable classifier warns once per process and the
|
|
45
|
+
* whole batch falls through. There is no `'off'`: this adds no
|
|
46
|
+
* configuration that can silently discard a candidate fact.
|
|
47
|
+
*/
|
|
48
|
+
resolve?: 'auto' | 'llm';
|
|
34
49
|
/** Per-site minimum confidence. Only the classifier path reads a floor. */
|
|
35
50
|
minConfidence?: Partial<Record<SystemOneThresholdSite, number>>;
|
|
36
51
|
/**
|
|
@@ -5,13 +5,14 @@ import { OkfSource, OkfVerifiedEntry, OkfSourceUsageWindow } from '@equationalap
|
|
|
5
5
|
*
|
|
6
6
|
* Boundary: S1-0 owns exactly `typing`, `minConfidence` (with the `'typing'`
|
|
7
7
|
* member), and `onLowConfidence`; the edge-suggestions step adds `edges` and
|
|
8
|
-
* the `'edges'` member
|
|
9
|
-
*
|
|
8
|
+
* the `'edges'` member; the resolution step adds `resolve` and the
|
|
9
|
+
* `'resolve'` member. Later PRs add more threshold sites
|
|
10
|
+
* (`'healScreen'`) — each as one new line in
|
|
10
11
|
* `SystemOneThresholdSite`, so sibling PRs merge cleanly. Nothing outside
|
|
11
12
|
* that boundary belongs here.
|
|
12
13
|
*/
|
|
13
|
-
/** Sites a System-One threshold can apply to. Exactly
|
|
14
|
-
type SystemOneThresholdSite = 'typing' | 'edges';
|
|
14
|
+
/** Sites a System-One threshold can apply to. Exactly three members today: `'typing'`, `'edges'`, and `'resolve'` (§10 fence). */
|
|
15
|
+
type SystemOneThresholdSite = 'typing' | 'edges' | 'resolve';
|
|
15
16
|
interface SystemOneConfig {
|
|
16
17
|
/**
|
|
17
18
|
* Typing mode for ontology backfill. `'auto'` uses
|
|
@@ -31,6 +32,20 @@ interface SystemOneConfig {
|
|
|
31
32
|
* adds no configuration that can silently discard a model-proposed edge.
|
|
32
33
|
*/
|
|
33
34
|
edges?: 'auto' | 'llm';
|
|
35
|
+
/**
|
|
36
|
+
* Resolution mode for the librarian's ops resolve step. `'llm'` (default)
|
|
37
|
+
* keeps resolution on the generative path exactly as today. `'auto'`
|
|
38
|
+
* engages the classifier resolution screen (§4) when
|
|
39
|
+
* `llmProvider.classify` is present AND an explicit
|
|
40
|
+
* `minConfidence.resolve` floor is set (missing floor under `'auto'`
|
|
41
|
+
* warns once and the site resolves `'llm'`); a confident duplicate
|
|
42
|
+
* answer at or above the floor settles the candidate as a terminal NOOP,
|
|
43
|
+
* and every other answer falls through to the generative resolve of the
|
|
44
|
+
* same pass. An unavailable classifier warns once per process and the
|
|
45
|
+
* whole batch falls through. There is no `'off'`: this adds no
|
|
46
|
+
* configuration that can silently discard a candidate fact.
|
|
47
|
+
*/
|
|
48
|
+
resolve?: 'auto' | 'llm';
|
|
34
49
|
/** Per-site minimum confidence. Only the classifier path reads a floor. */
|
|
35
50
|
minConfidence?: Partial<Record<SystemOneThresholdSite, number>>;
|
|
36
51
|
/**
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { a_ as EmbeddingService, a$ as ImportExportService, b0 as IngestionService, b1 as JobManager, b1 as JobManagerType, b2 as MaintenanceService, b3 as RetrievalService, b4 as SearchService, b4 as SearchServiceType, aL as WikiMemoryTestAccess, b5 as WriteService } from './testing-
|
|
1
|
+
export { a_ as EmbeddingService, a$ as ImportExportService, b0 as IngestionService, b1 as JobManager, b1 as JobManagerType, b2 as MaintenanceService, b3 as RetrievalService, b4 as SearchService, b4 as SearchServiceType, aL as WikiMemoryTestAccess, b5 as WriteService } from './testing-DkKZcrhE.mjs';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { a_ as EmbeddingService, a$ as ImportExportService, b0 as IngestionService, b1 as JobManager, b1 as JobManagerType, b2 as MaintenanceService, b3 as RetrievalService, b4 as SearchService, b4 as SearchServiceType, aL as WikiMemoryTestAccess, b5 as WriteService } from './testing-
|
|
1
|
+
export { a_ as EmbeddingService, a$ as ImportExportService, b0 as IngestionService, b1 as JobManager, b1 as JobManagerType, b2 as MaintenanceService, b3 as RetrievalService, b4 as SearchService, b4 as SearchServiceType, aL as WikiMemoryTestAccess, b5 as WriteService } from './testing-DkKZcrhE.js';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
package/dist/testing.js
CHANGED
|
@@ -4126,6 +4126,16 @@ function resolveSystemOneEdges(config) {
|
|
|
4126
4126
|
}
|
|
4127
4127
|
return edges ?? "llm";
|
|
4128
4128
|
}
|
|
4129
|
+
function resolveSystemOneResolve(config) {
|
|
4130
|
+
const resolve = config?.systemOne?.resolve;
|
|
4131
|
+
if (resolve !== void 0 && !isTypingMode(resolve)) {
|
|
4132
|
+
warnOnce(
|
|
4133
|
+
`[core-llm-wiki] systemOne: \`systemOne.resolve\` is ${formatConfigValue(resolve)}, which is not 'auto' or 'llm'. The key is treated as unset; the default ('llm') applies.`
|
|
4134
|
+
);
|
|
4135
|
+
return "llm";
|
|
4136
|
+
}
|
|
4137
|
+
return resolve ?? "llm";
|
|
4138
|
+
}
|
|
4129
4139
|
var DEFAULT_SHORTLIST_K = 10;
|
|
4130
4140
|
function resolveShortlistK(config) {
|
|
4131
4141
|
const k = config?.ontology?.shortlistK;
|
|
@@ -4165,6 +4175,15 @@ function resolveEdgesMinConfidence(config) {
|
|
|
4165
4175
|
);
|
|
4166
4176
|
return void 0;
|
|
4167
4177
|
}
|
|
4178
|
+
function resolveResolveMinConfidence(config) {
|
|
4179
|
+
if (resolveSystemOneResolve(config) !== "auto") return void 0;
|
|
4180
|
+
const floor = config?.systemOne?.minConfidence?.resolve;
|
|
4181
|
+
if (isEdgesFloor(floor)) return floor;
|
|
4182
|
+
warnOnce(
|
|
4183
|
+
floor === void 0 ? "[core-llm-wiki] systemOne: `systemOne.minConfidence.resolve` is required when `systemOne.resolve` is 'auto'. A wrong NOOP drops a live fact, so there is no default floor. The resolution screen is off; resolution stays on the generative path." : `[core-llm-wiki] systemOne: \`systemOne.minConfidence.resolve\` is ${formatConfigValue(floor)}, which is not a finite number in [0.5, 1]. A wrong NOOP drops a live fact, so the resolution screen is off; resolution stays on the generative path.`
|
|
4184
|
+
);
|
|
4185
|
+
return void 0;
|
|
4186
|
+
}
|
|
4168
4187
|
|
|
4169
4188
|
// src/utils/embedding.ts
|
|
4170
4189
|
function parseEmbedding(blob, text) {
|
|
@@ -5582,6 +5601,46 @@ async function gateCandidates(deps, ctx, candidates, cfg) {
|
|
|
5582
5601
|
}
|
|
5583
5602
|
|
|
5584
5603
|
// src/services/librarian/ops/resolve.ts
|
|
5604
|
+
async function screenResolveCandidates(ambiguous, mode, floor, ask) {
|
|
5605
|
+
const whole = (warnReason) => warnReason ? { settled: /* @__PURE__ */ new Map(), rest: ambiguous, warnReason } : { settled: /* @__PURE__ */ new Map(), rest: ambiguous };
|
|
5606
|
+
if (mode !== "auto") return whole();
|
|
5607
|
+
if (floor === void 0) return whole("no-floor");
|
|
5608
|
+
if (!ask) return whole("no-classifier");
|
|
5609
|
+
const settled = /* @__PURE__ */ new Map();
|
|
5610
|
+
const rest = [];
|
|
5611
|
+
for (const g of ambiguous) {
|
|
5612
|
+
const best = g.neighbours[0];
|
|
5613
|
+
if (!best) {
|
|
5614
|
+
rest.push(g);
|
|
5615
|
+
continue;
|
|
5616
|
+
}
|
|
5617
|
+
const question = {
|
|
5618
|
+
kind: "binary",
|
|
5619
|
+
instructions: `Does this candidate add NO information beyond neighbour ${best.ref} (a pure duplicate: same claims, no new content)?
|
|
5620
|
+
Neighbour ${best.ref} title: ${best.title}
|
|
5621
|
+
Neighbour ${best.ref} body: ${safeSlice(best.body, 0, OPS_NEIGHBOUR_BODY_CHARS)}`
|
|
5622
|
+
};
|
|
5623
|
+
let response;
|
|
5624
|
+
try {
|
|
5625
|
+
response = await ask({
|
|
5626
|
+
state: classifierStateForFact({ title: g.candidate.fact.title, body: g.candidate.fact.body, tags: [] }),
|
|
5627
|
+
questions: { [best.ref]: question }
|
|
5628
|
+
});
|
|
5629
|
+
} catch (err) {
|
|
5630
|
+
if (err instanceof WikiBudgetExhausted) {
|
|
5631
|
+
return { settled: /* @__PURE__ */ new Map(), rest: ambiguous, budgetStop: { requiredEstimate: err.requiredEstimate } };
|
|
5632
|
+
}
|
|
5633
|
+
return whole("classifier-threw");
|
|
5634
|
+
}
|
|
5635
|
+
const checked = validateClassifierAnswer(response, best.ref, question);
|
|
5636
|
+
if (checked.ok && checked.answer.kind === "binary" && checked.answer.probability >= floor) {
|
|
5637
|
+
settled.set(g, { op: "NOOP", targetId: best.id });
|
|
5638
|
+
} else {
|
|
5639
|
+
rest.push(g);
|
|
5640
|
+
}
|
|
5641
|
+
}
|
|
5642
|
+
return { settled, rest };
|
|
5643
|
+
}
|
|
5585
5644
|
function validateOp(raw, aliases) {
|
|
5586
5645
|
if (!raw || typeof raw !== "object") return null;
|
|
5587
5646
|
const r = raw;
|
|
@@ -5601,11 +5660,31 @@ function validateOp(raw, aliases) {
|
|
|
5601
5660
|
}
|
|
5602
5661
|
var aliasMapOf = (g) => new Map(g.neighbours.map((n) => [n.ref, n.id]));
|
|
5603
5662
|
async function runResolve(deps, ctx, ambiguous, budget) {
|
|
5604
|
-
const out = { ops: /* @__PURE__ */ new Map(), rejected: [], failed: [], overflowSkipped: [] };
|
|
5663
|
+
const out = { ops: /* @__PURE__ */ new Map(), rejected: [], failed: [], overflowSkipped: [], classifierSettled: [] };
|
|
5605
5664
|
if (ambiguous.length === 0) return out;
|
|
5606
5665
|
const { entityId, trigger } = ctx;
|
|
5666
|
+
const mode = resolveSystemOneResolve(deps.options.config);
|
|
5667
|
+
const floor = resolveResolveMinConfidence(deps.options.config);
|
|
5668
|
+
const provider = deps.options.llmProvider;
|
|
5669
|
+
const ask = mode === "auto" && typeof provider.classify === "function" ? (request) => callClassify(deps.options, { operation: "librarian", entityId, trigger, meter: ctx.meter }, request) : void 0;
|
|
5670
|
+
const screen = await screenResolveCandidates(ambiguous, mode, floor, ask);
|
|
5671
|
+
if (screen.budgetStop) return { ...out, budgetStop: screen.budgetStop };
|
|
5672
|
+
if (screen.warnReason === "no-classifier") {
|
|
5673
|
+
warnOnce(
|
|
5674
|
+
"[core-llm-wiki] systemOne: `systemOne.resolve` is 'auto' but the provider has no classify(); ambiguous candidates fall through to the generative resolve."
|
|
5675
|
+
);
|
|
5676
|
+
} else if (screen.warnReason === "classifier-threw") {
|
|
5677
|
+
warnOnce(
|
|
5678
|
+
"[core-llm-wiki] systemOne: `systemOne.resolve` is 'auto' but classify() threw during the resolve screen; ambiguous candidates fall through to the generative resolve."
|
|
5679
|
+
);
|
|
5680
|
+
}
|
|
5681
|
+
for (const [g, op] of screen.settled) {
|
|
5682
|
+
out.ops.set(g, op);
|
|
5683
|
+
out.classifierSettled.push(g.candidate.index);
|
|
5684
|
+
}
|
|
5685
|
+
if (screen.rest.length === 0) return out;
|
|
5607
5686
|
const outcome = await runBatched({
|
|
5608
|
-
items:
|
|
5687
|
+
items: screen.rest,
|
|
5609
5688
|
buildPrompt: (batch) => deps.promptService.buildOpsResolvePrompt(
|
|
5610
5689
|
batch.map((g, i) => ({
|
|
5611
5690
|
item: i,
|
|
@@ -5894,6 +5973,16 @@ var runOpsLibrarianPass = async (deps, ctx) => {
|
|
|
5894
5973
|
// (index into the merged extract batch)
|
|
5895
5974
|
});
|
|
5896
5975
|
}
|
|
5976
|
+
for (const itemIndex of res.classifierSettled) {
|
|
5977
|
+
diagnostics.push({
|
|
5978
|
+
entityId,
|
|
5979
|
+
operation: "librarian",
|
|
5980
|
+
trigger,
|
|
5981
|
+
code: "fact_deduplicated",
|
|
5982
|
+
detail: { itemIndex, reason: "classifier" }
|
|
5983
|
+
// (index into the merged extract batch)
|
|
5984
|
+
});
|
|
5985
|
+
}
|
|
5897
5986
|
if (res.budgetStop) {
|
|
5898
5987
|
diagnostics.discard();
|
|
5899
5988
|
return { processedThrough: null, factsWritten: 0, budgetStop: res.budgetStop };
|