@equationalapplications/core-llm-wiki 9.12.0 → 9.14.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-2FCE7ZAC.mjs} +215 -14
- package/dist/chunk-2FCE7ZAC.mjs.map +1 -0
- package/dist/index.d.mts +33 -3
- package/dist/index.d.ts +33 -3
- package/dist/index.js +216 -11
- 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-BclOvn3q.d.mts} +66 -7
- package/dist/{testing-imNjsm-X.d.ts → testing-BclOvn3q.d.ts} +66 -7
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +212 -11
- 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
|
@@ -2271,10 +2271,11 @@ Keep facts concise. Do not return markdown, just raw JSON.`;
|
|
|
2271
2271
|
var HEAL_SYSTEM_PROMPT = `You are a memory grooming agent. Your job is to review a full dump of facts and recent events to resolve contradictions, downgrade stale claims, and flag obsolete facts for deletion.
|
|
2272
2272
|
Return ONLY a valid JSON object matching this schema:
|
|
2273
2273
|
{
|
|
2274
|
-
"downgraded": ["string (fact
|
|
2275
|
-
"deleted": ["string (fact
|
|
2274
|
+
"downgraded": [{ "id": "string (fact ID)", "confidence": "number 0-1" }],
|
|
2275
|
+
"deleted": [{ "id": "string (fact ID)", "confidence": "number 0-1" }],
|
|
2276
2276
|
"newFacts": [{ "title": "string (max 80 chars)", "body": "string (max 800 chars)", "tags": ["string"], "confidence": "certain|inferred|tentative" }]
|
|
2277
2277
|
}
|
|
2278
|
+
For downgraded and deleted entries, "confidence" is your confidence in that verdict.
|
|
2278
2279
|
Do not return markdown, just raw JSON.`;
|
|
2279
2280
|
var INGEST_SYSTEM_PROMPT = `You are a document ingestion agent. Your job is to extract factual knowledge from the provided document chunk.
|
|
2280
2281
|
Return ONLY a valid JSON object matching this schema:
|
|
@@ -2829,6 +2830,8 @@ var SEVERITY = {
|
|
|
2829
2830
|
hook_failed: "warn",
|
|
2830
2831
|
background_job_failed: "error",
|
|
2831
2832
|
heal_skipped: "warn",
|
|
2833
|
+
heal_deleted: "info",
|
|
2834
|
+
heal_downgraded: "info",
|
|
2832
2835
|
grounding_missing: "warn",
|
|
2833
2836
|
grounding_failed: "warn",
|
|
2834
2837
|
classification_low_confidence: "info",
|
|
@@ -2882,6 +2885,8 @@ var MESSAGE = {
|
|
|
2882
2885
|
hook_failed: "A host hook threw or rejected.",
|
|
2883
2886
|
background_job_failed: "A background maintenance job failed.",
|
|
2884
2887
|
heal_skipped: "Heal skipped a candidate fact, or the whole LLM pass when keyword search is unavailable.",
|
|
2888
|
+
heal_deleted: "Heal soft-deleted a fact (or withheld the delete below the confidence floor).",
|
|
2889
|
+
heal_downgraded: "Heal downgraded a fact to tentative (or withheld the downgrade below the confidence floor).",
|
|
2885
2890
|
grounding_missing: "A fact carried no qualifying evidence and was stored as a draft.",
|
|
2886
2891
|
grounding_failed: "A fact carried evidence not found in its source and was stored as a draft.",
|
|
2887
2892
|
classification_low_confidence: "A classifier answer was below the confidence threshold and was not applied.",
|
|
@@ -3974,6 +3979,16 @@ function resolveSystemOneEdges(config) {
|
|
|
3974
3979
|
}
|
|
3975
3980
|
return edges ?? "llm";
|
|
3976
3981
|
}
|
|
3982
|
+
function resolveSystemOneResolve(config) {
|
|
3983
|
+
const resolve = config?.systemOne?.resolve;
|
|
3984
|
+
if (resolve !== void 0 && !isTypingMode(resolve)) {
|
|
3985
|
+
warnOnce(
|
|
3986
|
+
`[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.`
|
|
3987
|
+
);
|
|
3988
|
+
return "llm";
|
|
3989
|
+
}
|
|
3990
|
+
return resolve ?? "llm";
|
|
3991
|
+
}
|
|
3977
3992
|
var DEFAULT_SHORTLIST_K = 10;
|
|
3978
3993
|
function resolveShortlistK(config) {
|
|
3979
3994
|
const k = config?.ontology?.shortlistK;
|
|
@@ -4013,6 +4028,34 @@ function resolveEdgesMinConfidence(config) {
|
|
|
4013
4028
|
);
|
|
4014
4029
|
return void 0;
|
|
4015
4030
|
}
|
|
4031
|
+
function resolveResolveMinConfidence(config) {
|
|
4032
|
+
if (resolveSystemOneResolve(config) !== "auto") return void 0;
|
|
4033
|
+
const floor = config?.systemOne?.minConfidence?.resolve;
|
|
4034
|
+
if (isEdgesFloor(floor)) return floor;
|
|
4035
|
+
warnOnce(
|
|
4036
|
+
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.`
|
|
4037
|
+
);
|
|
4038
|
+
return void 0;
|
|
4039
|
+
}
|
|
4040
|
+
function resolveSystemOneHealScreen(config) {
|
|
4041
|
+
const healScreen = config?.systemOne?.healScreen;
|
|
4042
|
+
if (healScreen !== void 0 && !isTypingMode(healScreen)) {
|
|
4043
|
+
warnOnce(
|
|
4044
|
+
`[core-llm-wiki] systemOne: \`systemOne.healScreen\` is ${formatConfigValue(healScreen)}, which is not 'auto' or 'llm'. The key is treated as unset; the default ('llm') applies.`
|
|
4045
|
+
);
|
|
4046
|
+
return "llm";
|
|
4047
|
+
}
|
|
4048
|
+
return healScreen ?? "llm";
|
|
4049
|
+
}
|
|
4050
|
+
function resolveHealScreenMinConfidence(config) {
|
|
4051
|
+
if (resolveSystemOneHealScreen(config) !== "auto") return void 0;
|
|
4052
|
+
const floor = config?.systemOne?.minConfidence?.healScreen;
|
|
4053
|
+
if (isEdgesFloor(floor)) return floor;
|
|
4054
|
+
warnOnce(
|
|
4055
|
+
floor === void 0 ? "[core-llm-wiki] systemOne: `systemOne.minConfidence.healScreen` is required when `systemOne.healScreen` is 'auto'. The heal screen is off for this site; heal stays ungated." : `[core-llm-wiki] systemOne: \`systemOne.minConfidence.healScreen\` is ${formatConfigValue(floor)}, which is not a finite number in [0.5, 1]. The heal screen is off for this site; heal stays ungated.`
|
|
4056
|
+
);
|
|
4057
|
+
return void 0;
|
|
4058
|
+
}
|
|
4016
4059
|
|
|
4017
4060
|
// src/utils/classifier.ts
|
|
4018
4061
|
var isUnit = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 1;
|
|
@@ -6682,6 +6725,46 @@ async function gateCandidates(deps, ctx, candidates, cfg) {
|
|
|
6682
6725
|
}
|
|
6683
6726
|
|
|
6684
6727
|
// src/services/librarian/ops/resolve.ts
|
|
6728
|
+
async function screenResolveCandidates(ambiguous, mode, floor, ask) {
|
|
6729
|
+
const whole = (warnReason) => warnReason ? { settled: /* @__PURE__ */ new Map(), rest: ambiguous, warnReason } : { settled: /* @__PURE__ */ new Map(), rest: ambiguous };
|
|
6730
|
+
if (mode !== "auto") return whole();
|
|
6731
|
+
if (floor === void 0) return whole("no-floor");
|
|
6732
|
+
if (!ask) return whole("no-classifier");
|
|
6733
|
+
const settled = /* @__PURE__ */ new Map();
|
|
6734
|
+
const rest = [];
|
|
6735
|
+
for (const g of ambiguous) {
|
|
6736
|
+
const best = g.neighbours[0];
|
|
6737
|
+
if (!best) {
|
|
6738
|
+
rest.push(g);
|
|
6739
|
+
continue;
|
|
6740
|
+
}
|
|
6741
|
+
const question = {
|
|
6742
|
+
kind: "binary",
|
|
6743
|
+
instructions: `Does this candidate add NO information beyond neighbour ${best.ref} (a pure duplicate: same claims, no new content)?
|
|
6744
|
+
Neighbour ${best.ref} title: ${best.title}
|
|
6745
|
+
Neighbour ${best.ref} body: ${safeSlice(best.body, 0, OPS_NEIGHBOUR_BODY_CHARS)}`
|
|
6746
|
+
};
|
|
6747
|
+
let response;
|
|
6748
|
+
try {
|
|
6749
|
+
response = await ask({
|
|
6750
|
+
state: classifierStateForFact({ title: g.candidate.fact.title, body: g.candidate.fact.body, tags: [] }),
|
|
6751
|
+
questions: { [best.ref]: question }
|
|
6752
|
+
});
|
|
6753
|
+
} catch (err) {
|
|
6754
|
+
if (err instanceof WikiBudgetExhausted) {
|
|
6755
|
+
return { settled: /* @__PURE__ */ new Map(), rest: ambiguous, budgetStop: { requiredEstimate: err.requiredEstimate } };
|
|
6756
|
+
}
|
|
6757
|
+
return whole("classifier-threw");
|
|
6758
|
+
}
|
|
6759
|
+
const checked = validateClassifierAnswer(response, best.ref, question);
|
|
6760
|
+
if (checked.ok && checked.answer.kind === "binary" && checked.answer.probability >= floor) {
|
|
6761
|
+
settled.set(g, { op: "NOOP", targetId: best.id });
|
|
6762
|
+
} else {
|
|
6763
|
+
rest.push(g);
|
|
6764
|
+
}
|
|
6765
|
+
}
|
|
6766
|
+
return { settled, rest };
|
|
6767
|
+
}
|
|
6685
6768
|
function validateOp(raw, aliases) {
|
|
6686
6769
|
if (!raw || typeof raw !== "object") return null;
|
|
6687
6770
|
const r = raw;
|
|
@@ -6701,11 +6784,31 @@ function validateOp(raw, aliases) {
|
|
|
6701
6784
|
}
|
|
6702
6785
|
var aliasMapOf = (g) => new Map(g.neighbours.map((n) => [n.ref, n.id]));
|
|
6703
6786
|
async function runResolve(deps, ctx, ambiguous, budget) {
|
|
6704
|
-
const out = { ops: /* @__PURE__ */ new Map(), rejected: [], failed: [], overflowSkipped: [] };
|
|
6787
|
+
const out = { ops: /* @__PURE__ */ new Map(), rejected: [], failed: [], overflowSkipped: [], classifierSettled: [] };
|
|
6705
6788
|
if (ambiguous.length === 0) return out;
|
|
6706
6789
|
const { entityId, trigger } = ctx;
|
|
6790
|
+
const mode = resolveSystemOneResolve(deps.options.config);
|
|
6791
|
+
const floor = resolveResolveMinConfidence(deps.options.config);
|
|
6792
|
+
const provider = deps.options.llmProvider;
|
|
6793
|
+
const ask = mode === "auto" && typeof provider.classify === "function" ? (request) => callClassify(deps.options, { operation: "librarian", entityId, trigger, meter: ctx.meter }, request) : void 0;
|
|
6794
|
+
const screen = await screenResolveCandidates(ambiguous, mode, floor, ask);
|
|
6795
|
+
if (screen.budgetStop) return { ...out, budgetStop: screen.budgetStop };
|
|
6796
|
+
if (screen.warnReason === "no-classifier") {
|
|
6797
|
+
warnOnce(
|
|
6798
|
+
"[core-llm-wiki] systemOne: `systemOne.resolve` is 'auto' but the provider has no classify(); ambiguous candidates fall through to the generative resolve."
|
|
6799
|
+
);
|
|
6800
|
+
} else if (screen.warnReason === "classifier-threw") {
|
|
6801
|
+
warnOnce(
|
|
6802
|
+
"[core-llm-wiki] systemOne: `systemOne.resolve` is 'auto' but classify() threw during the resolve screen; ambiguous candidates fall through to the generative resolve."
|
|
6803
|
+
);
|
|
6804
|
+
}
|
|
6805
|
+
for (const [g, op] of screen.settled) {
|
|
6806
|
+
out.ops.set(g, op);
|
|
6807
|
+
out.classifierSettled.push(g.candidate.index);
|
|
6808
|
+
}
|
|
6809
|
+
if (screen.rest.length === 0) return out;
|
|
6707
6810
|
const outcome = await runBatched({
|
|
6708
|
-
items:
|
|
6811
|
+
items: screen.rest,
|
|
6709
6812
|
buildPrompt: (batch) => deps.promptService.buildOpsResolvePrompt(
|
|
6710
6813
|
batch.map((g, i) => ({
|
|
6711
6814
|
item: i,
|
|
@@ -6994,6 +7097,16 @@ var runOpsLibrarianPass = async (deps, ctx) => {
|
|
|
6994
7097
|
// (index into the merged extract batch)
|
|
6995
7098
|
});
|
|
6996
7099
|
}
|
|
7100
|
+
for (const itemIndex of res.classifierSettled) {
|
|
7101
|
+
diagnostics.push({
|
|
7102
|
+
entityId,
|
|
7103
|
+
operation: "librarian",
|
|
7104
|
+
trigger,
|
|
7105
|
+
code: "fact_deduplicated",
|
|
7106
|
+
detail: { itemIndex, reason: "classifier" }
|
|
7107
|
+
// (index into the merged extract batch)
|
|
7108
|
+
});
|
|
7109
|
+
}
|
|
6997
7110
|
if (res.budgetStop) {
|
|
6998
7111
|
diagnostics.discard();
|
|
6999
7112
|
return { processedThrough: null, factsWritten: 0, budgetStop: res.budgetStop };
|
|
@@ -8244,12 +8357,24 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
8244
8357
|
* `result.remaining > 0` for convergence — see {@link HealResult.remaining}
|
|
8245
8358
|
* for what convergence means here, and for the no-progress flags
|
|
8246
8359
|
* (`searchUnavailable`, `budgetStop`) a loop must also stop on.
|
|
8360
|
+
*
|
|
8361
|
+
* Heal screen (`systemOne.healScreen: 'auto'` + `minConfidence.healScreen`):
|
|
8362
|
+
* a model-directed delete or downgrade whose valid `confidence` is below the
|
|
8363
|
+
* floor is withheld from every reader (apply, sync, removals, counts, id
|
|
8364
|
+
* lists); a missing or invalid confidence is applied unscreened. Each
|
|
8365
|
+
* model-directed move emits a `heal_deleted` / `heal_downgraded` receipt
|
|
8366
|
+
* after commit (`applied`, `applied_unscreened`, or `below_floor`), in every
|
|
8367
|
+
* mode. An `applied` receipt records that the model VERDICT was applied
|
|
8368
|
+
* (`downgradeByIds` runs unconditionally): a fact that was already at
|
|
8369
|
+
* reduced confidence still gets an `applied` receipt. A withheld delete paired with a restating `newFact` leaves the fact
|
|
8370
|
+
* live and the restatement is skipped as `fact_deduplicated`.
|
|
8247
8371
|
*/
|
|
8248
8372
|
async doRunHeal(entityId, options) {
|
|
8249
8373
|
const promptOverride = options?.promptOverride;
|
|
8250
8374
|
const batchSize = options?.batchSize ?? HEAL_BATCH_SIZE;
|
|
8251
8375
|
const trigger = options?.trigger ?? "call";
|
|
8252
8376
|
const diagBase = { entityId, operation: "heal", trigger };
|
|
8377
|
+
const healFloor = resolveHealScreenMinConfidence(this.options.config);
|
|
8253
8378
|
if (!Number.isInteger(batchSize) || batchSize < 1) {
|
|
8254
8379
|
throw new Error("Invalid batchSize: must be an integer >= 1");
|
|
8255
8380
|
}
|
|
@@ -8295,6 +8420,8 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
8295
8420
|
downgraded: staleDowngradedIds.length,
|
|
8296
8421
|
deleted: orphanedIds.length,
|
|
8297
8422
|
newFactsCreated: 0,
|
|
8423
|
+
downgradedIds: Array.from(new Set(staleDowngradedIds)),
|
|
8424
|
+
deletedIds: Array.from(new Set(orphanedIds)),
|
|
8298
8425
|
skipped: [],
|
|
8299
8426
|
degraded: [],
|
|
8300
8427
|
remaining: counts2.eligible,
|
|
@@ -8345,10 +8472,30 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
8345
8472
|
call: (prompts) => callLlm(this.options, { operation: "heal", entityId, trigger, meter: options?.meter }, prompts),
|
|
8346
8473
|
parse: (responseText, batch, prompts) => {
|
|
8347
8474
|
const result = parseJsonResponse(responseText);
|
|
8475
|
+
const normalize = (raw) => {
|
|
8476
|
+
const ids = [];
|
|
8477
|
+
const confidence = /* @__PURE__ */ new Map();
|
|
8478
|
+
if (!Array.isArray(raw)) return { ids, confidence };
|
|
8479
|
+
for (const entry of raw) {
|
|
8480
|
+
const id = typeof entry === "string" ? entry : entry?.id;
|
|
8481
|
+
if (typeof id !== "string") continue;
|
|
8482
|
+
ids.push(id);
|
|
8483
|
+
const c = typeof entry === "object" && entry !== null ? entry.confidence : void 0;
|
|
8484
|
+
if (typeof c === "number" && Number.isFinite(c) && c >= 0 && c <= 1) {
|
|
8485
|
+
const prev = confidence.get(id);
|
|
8486
|
+
if (prev === void 0 || c < prev) confidence.set(id, c);
|
|
8487
|
+
}
|
|
8488
|
+
}
|
|
8489
|
+
return { ids, confidence };
|
|
8490
|
+
};
|
|
8491
|
+
const down = normalize(result.downgraded);
|
|
8492
|
+
const del = normalize(result.deleted);
|
|
8348
8493
|
return {
|
|
8349
8494
|
batch,
|
|
8350
|
-
downgraded:
|
|
8351
|
-
deleted:
|
|
8495
|
+
downgraded: down.ids,
|
|
8496
|
+
deleted: del.ids,
|
|
8497
|
+
downgradedConfidence: down.confidence,
|
|
8498
|
+
deletedConfidence: del.confidence,
|
|
8352
8499
|
newFacts: Array.isArray(result.newFacts) ? result.newFacts : [],
|
|
8353
8500
|
corpus: corpusByPrompt.get(prompts) ?? null
|
|
8354
8501
|
};
|
|
@@ -8388,8 +8535,42 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
8388
8535
|
newFactCorpora.push(batchResult.corpus);
|
|
8389
8536
|
});
|
|
8390
8537
|
}
|
|
8538
|
+
const downgradeConfidence = /* @__PURE__ */ new Map();
|
|
8539
|
+
const deleteConfidence = /* @__PURE__ */ new Map();
|
|
8540
|
+
const mergeLowest = (into, id, c) => {
|
|
8541
|
+
if (c === void 0) return;
|
|
8542
|
+
const prev = into.get(id);
|
|
8543
|
+
if (prev === void 0 || c < prev) into.set(id, c);
|
|
8544
|
+
};
|
|
8545
|
+
for (const batchResult of outcome.results) {
|
|
8546
|
+
const mutableIds = new Set(batchResult.batch.map((f) => f.id));
|
|
8547
|
+
for (const id of batchResult.downgraded) if (mutableIds.has(id)) mergeLowest(downgradeConfidence, id, batchResult.downgradedConfidence.get(id));
|
|
8548
|
+
for (const id of batchResult.deleted) if (mutableIds.has(id)) mergeLowest(deleteConfidence, id, batchResult.deletedConfidence.get(id));
|
|
8549
|
+
}
|
|
8391
8550
|
const safeDowngraded = Array.from(safeDowngradedSet);
|
|
8392
8551
|
const safeDeleted = Array.from(safeDeletedSet);
|
|
8552
|
+
const withheldDowngraded = /* @__PURE__ */ new Map();
|
|
8553
|
+
const withheldDeleted = /* @__PURE__ */ new Map();
|
|
8554
|
+
let appliedDowngraded = safeDowngraded;
|
|
8555
|
+
let appliedDeleted = safeDeleted;
|
|
8556
|
+
if (healFloor !== void 0) {
|
|
8557
|
+
const screen = (ids, confidences, withheld) => {
|
|
8558
|
+
const applied = [];
|
|
8559
|
+
for (const id of ids) {
|
|
8560
|
+
const c = confidences.get(id);
|
|
8561
|
+
if (c !== void 0 && c < healFloor) withheld.set(id, c);
|
|
8562
|
+
else applied.push(id);
|
|
8563
|
+
}
|
|
8564
|
+
return applied;
|
|
8565
|
+
};
|
|
8566
|
+
appliedDowngraded = screen(safeDowngraded, downgradeConfidence, withheldDowngraded);
|
|
8567
|
+
appliedDeleted = screen(safeDeleted, deleteConfidence, withheldDeleted);
|
|
8568
|
+
if (appliedDowngraded.some((id) => !downgradeConfidence.has(id)) || appliedDeleted.some((id) => !deleteConfidence.has(id))) {
|
|
8569
|
+
warnOnce(
|
|
8570
|
+
'[core-llm-wiki] systemOne: heal returned downgraded/deleted verdicts without a valid `confidence` (out-of-range or non-numeric), so the heal screen could not gate them and they were applied. Restore the schema \u2014 or a `healSystemPrompt` override \u2014 to the `{ "id", "confidence" }` entry contract with confidences in 0-1 (see HEAL_SYSTEM_PROMPT).'
|
|
8571
|
+
);
|
|
8572
|
+
}
|
|
8573
|
+
}
|
|
8393
8574
|
const diagBuffer = new DiagnosticBuffer();
|
|
8394
8575
|
const validNewFacts = [];
|
|
8395
8576
|
const validNewFactItemIndexes = [];
|
|
@@ -8406,10 +8587,10 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
8406
8587
|
}
|
|
8407
8588
|
});
|
|
8408
8589
|
const insertedFacts = [];
|
|
8409
|
-
const uniqueDeletedFactIds = Array.from(new Set(
|
|
8590
|
+
const uniqueDeletedFactIds = Array.from(new Set(appliedDeleted));
|
|
8410
8591
|
await this.db.withTransactionAsync(async (tx) => {
|
|
8411
|
-
await this.entryRepo.downgradeByIds(
|
|
8412
|
-
await this.entryRepo.softDeleteByIds(
|
|
8592
|
+
await this.entryRepo.downgradeByIds(appliedDowngraded, entityId, tx);
|
|
8593
|
+
await this.entryRepo.softDeleteByIds(appliedDeleted, entityId, tx);
|
|
8413
8594
|
const healFactsForDedupe = await this.entryRepo.findInferredTitlesByEntityId(entityId, tx);
|
|
8414
8595
|
for (const [k, fact] of validNewFacts.entries()) {
|
|
8415
8596
|
const newTokens = titleTokens(fact.title);
|
|
@@ -8473,11 +8654,29 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
8473
8654
|
for (const { item, reason } of outcome.skipped) {
|
|
8474
8655
|
diagBuffer.push({ ...diagBase, code: "heal_skipped", detail: { factId: item.id, reason } });
|
|
8475
8656
|
}
|
|
8657
|
+
const pushReceipts = (code, applied, confidences, withheld) => {
|
|
8658
|
+
for (const factId of applied) {
|
|
8659
|
+
if (healFloor !== void 0 && !confidences.has(factId)) {
|
|
8660
|
+
diagBuffer.push({ ...diagBase, code, detail: { factId, reason: "applied_unscreened" } });
|
|
8661
|
+
} else {
|
|
8662
|
+
diagBuffer.push({ ...diagBase, code, detail: { factId, reason: "applied" } });
|
|
8663
|
+
}
|
|
8664
|
+
}
|
|
8665
|
+
for (const [factId, confidence] of withheld) {
|
|
8666
|
+
diagBuffer.push({
|
|
8667
|
+
...diagBase,
|
|
8668
|
+
code,
|
|
8669
|
+
detail: { factId, reason: "below_floor", ...confidence !== void 0 ? { confidence } : {} }
|
|
8670
|
+
});
|
|
8671
|
+
}
|
|
8672
|
+
};
|
|
8673
|
+
pushReceipts("heal_downgraded", appliedDowngraded, downgradeConfidence, withheldDowngraded);
|
|
8674
|
+
pushReceipts("heal_deleted", appliedDeleted, deleteConfidence, withheldDeleted);
|
|
8476
8675
|
diagBuffer.flush(this.options);
|
|
8477
8676
|
const healSyncIds = Array.from(/* @__PURE__ */ new Set([
|
|
8478
8677
|
...orphanedIds,
|
|
8479
8678
|
...staleDowngradedIds,
|
|
8480
|
-
...
|
|
8679
|
+
...appliedDowngraded,
|
|
8481
8680
|
...uniqueDeletedFactIds,
|
|
8482
8681
|
...insertedFacts.map((f) => f.id)
|
|
8483
8682
|
]));
|
|
@@ -8496,13 +8695,15 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
8496
8695
|
}
|
|
8497
8696
|
let scanned = outcome.skipped.length;
|
|
8498
8697
|
for (const batchResult of outcome.results) scanned += batchResult.batch.length;
|
|
8499
|
-
const allDowngraded = /* @__PURE__ */ new Set([...staleDowngradedIds, ...
|
|
8698
|
+
const allDowngraded = /* @__PURE__ */ new Set([...staleDowngradedIds, ...appliedDowngraded]);
|
|
8500
8699
|
const allDeleted = /* @__PURE__ */ new Set([...orphanedIds, ...uniqueDeletedFactIds]);
|
|
8501
8700
|
const counts = await this.entryRepo.countHealCandidatesByEntityId(entityId, recheckCutoff);
|
|
8502
8701
|
return {
|
|
8503
8702
|
scanned,
|
|
8504
8703
|
downgraded: allDowngraded.size,
|
|
8505
8704
|
deleted: allDeleted.size,
|
|
8705
|
+
downgradedIds: Array.from(allDowngraded),
|
|
8706
|
+
deletedIds: Array.from(allDeleted),
|
|
8506
8707
|
newFactsCreated: insertedFacts.length,
|
|
8507
8708
|
skipped: outcome.skipped.map(({ item, reason }) => ({ id: item.id, reason })),
|
|
8508
8709
|
degraded: healedDegraded,
|
|
@@ -11789,6 +11990,6 @@ var WriteService = class {
|
|
|
11789
11990
|
}
|
|
11790
11991
|
};
|
|
11791
11992
|
|
|
11792
|
-
export { BaseRepository, CLASSIFIER_MAX_CHOICES, CURRENT_SCHEMA_VERSION, CheckpointIncompleteError, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_TYPING_MIN_CONFIDENCE, DiagnosticBuffer, EMBED_CHARS_CEILING, EdgeRepository, EmbeddingService, EraseStepError, 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_ABSTAIN_SENTINEL, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, RetrievalService, SearchService, SourceStoreService, TemporalService, UnavailableIndexStrategy, UsageMeter, VectorRemovalRepository, VectorRemovalService, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiExternalDeletionError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, WriteService, __privateAdd, __privateGet, __privateSet, assertEntityId, assertEpochMs, chunkText, configureRandomSource, createLegacySourceTypeIndex, createdAtValue, detectSchemaVersion, drainChunkSql, drainHiSql, edgeTripleAllowed, emitDiagnostic, emptyManifest, entityDrainChunkSql, entityDrainHiSql, entitySummaryMetaKey, extractSqliteCode, factTokenCost, fts5LedgerDropSql, fts5PendingIndexesDdl, fts5TablesDdl, fts5TriggerNames, fts5TriggersDdl, generateId, idDrainChunkSql, idReindexChunkSql, isLiveAt, isReservedAbstainSlug, isRetiredTableName, isUsableDate, isWikiSearchUnavailableError, liveAtSql, nodeTypeReceipts, normalizeSourceHash, normalizeSourceRef, normalizeTitleKey, packFactsByBudget, parseEmbedding, parseJsonArray, parseJsonObject, parseStoredSourcePointer, passageFtsTablesDdl, passageFtsTriggerNames, passageFtsTriggersDdl, probePendingWork, readRebuildProgress, reanchorRebuildFingerprint, resolveContextBudget, resolveContextBudgetOrThrow, resolveDefaultChunkLength, resolveEdgeDefinitions, resolveEdgesMinConfidence, resolveGrounding, resolveLibrarianStrategy, resolveMaxPromptChars, resolveNodeType, resolveNodeTypeMatch, resolveSystemOneEdges, resolveSystemOneTyping, resolveTypingMinConfidence, retiredTableName, runSourceRefNormalize, safeSlice, serializeSourcePointer, setupDatabase, shouldEmitOntologyReceipt, sweepChunkSql, sweepHiSql, typeSatisfies, validUsage, validateInlineEdges, validateManifest, validateSourcePointerValue, warnChangedDefaultsOnce, warnOnce, windowChunkSql, windowHiSql, writeNormalizeStamp, writeRebuildStart };
|
|
11793
|
-
//# sourceMappingURL=chunk-
|
|
11794
|
-
//# sourceMappingURL=chunk-
|
|
11993
|
+
export { BaseRepository, CLASSIFIER_MAX_CHOICES, CURRENT_SCHEMA_VERSION, CheckpointIncompleteError, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_TYPING_MIN_CONFIDENCE, DiagnosticBuffer, EMBED_CHARS_CEILING, EdgeRepository, EmbeddingService, EraseStepError, 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_ABSTAIN_SENTINEL, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, RetrievalService, SearchService, SourceStoreService, TemporalService, UnavailableIndexStrategy, UsageMeter, VectorRemovalRepository, VectorRemovalService, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiExternalDeletionError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, WriteService, __privateAdd, __privateGet, __privateSet, assertEntityId, assertEpochMs, chunkText, configureRandomSource, createLegacySourceTypeIndex, createdAtValue, detectSchemaVersion, drainChunkSql, drainHiSql, edgeTripleAllowed, emitDiagnostic, emptyManifest, entityDrainChunkSql, entityDrainHiSql, entitySummaryMetaKey, extractSqliteCode, factTokenCost, fts5LedgerDropSql, fts5PendingIndexesDdl, fts5TablesDdl, fts5TriggerNames, fts5TriggersDdl, generateId, idDrainChunkSql, idReindexChunkSql, isLiveAt, isReservedAbstainSlug, isRetiredTableName, isUsableDate, isWikiSearchUnavailableError, liveAtSql, nodeTypeReceipts, normalizeSourceHash, normalizeSourceRef, normalizeTitleKey, packFactsByBudget, parseEmbedding, parseJsonArray, parseJsonObject, parseStoredSourcePointer, passageFtsTablesDdl, passageFtsTriggerNames, passageFtsTriggersDdl, probePendingWork, readRebuildProgress, reanchorRebuildFingerprint, resolveContextBudget, resolveContextBudgetOrThrow, resolveDefaultChunkLength, resolveEdgeDefinitions, resolveEdgesMinConfidence, resolveGrounding, resolveHealScreenMinConfidence, resolveLibrarianStrategy, resolveMaxPromptChars, resolveNodeType, resolveNodeTypeMatch, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneHealScreen, resolveSystemOneResolve, resolveSystemOneTyping, resolveTypingMinConfidence, retiredTableName, runSourceRefNormalize, safeSlice, serializeSourcePointer, setupDatabase, shouldEmitOntologyReceipt, sweepChunkSql, sweepHiSql, typeSatisfies, validUsage, validateInlineEdges, validateManifest, validateSourcePointerValue, warnChangedDefaultsOnce, warnOnce, windowChunkSql, windowHiSql, writeNormalizeStamp, writeRebuildStart };
|
|
11994
|
+
//# sourceMappingURL=chunk-2FCE7ZAC.mjs.map
|
|
11995
|
+
//# sourceMappingURL=chunk-2FCE7ZAC.mjs.map
|