Files
Jyotisha/frontend/src/lib/rectification-agentic/core/select-probe.ts
T
Jesse_ChenandCursor 29750d3835
Independent Staging Quality Gate / validate (push) Failing after 9m53s
Independent Staging Quality Gate / publish (push) Has been skipped
fix(web): persist C/D rectification answers without waiting for rescore
Choice C/D without new evidence never changed the candidate posterior until the next dated-event rescore, and persist-v2 would cache-hit on the same evidence fingerprint. Patch the latest decision_receipt.inference_state in place so the next follow-up sees the asked split immediately.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-23 22:41:01 +08:00

29 lines
1014 B
TypeScript

import { isDuplicateProbe } from "./duplicate-probes.ts";
import { HIGH_INFORMATION_GAIN, type ConflictProbe, type ProbeAnswer } from "./types.ts";
export function selectHighestGainProbe(
probes: readonly ConflictProbe[],
asked: readonly ProbeAnswer[],
options: { minGain?: number } = {},
): ConflictProbe | null {
const minGain = options.minGain ?? 0;
const ranked = [...probes]
.filter((probe) => probe.information_gain >= minGain && !isDuplicateProbe(probe, asked))
.sort((left, right) => {
if (right.information_gain !== left.information_gain) {
return right.information_gain - left.information_gain;
}
return left.semantic_key.localeCompare(right.semantic_key);
});
return ranked[0] ?? null;
}
export function remainingHighValueProbes(
probes: readonly ConflictProbe[],
asked: readonly ProbeAnswer[],
): ConflictProbe[] {
return probes.filter((probe) => (
probe.information_gain >= HIGH_INFORMATION_GAIN && !isDuplicateProbe(probe, asked)
));
}