fix(rectification): read credible_range as the still-valid union

Write and read used different range definitions at the same lead of 8, so a real separation always fail-closed the candidate projection.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-08-28 23:12:16 +08:00
co-authored by Cursor
parent 7de36e11d6
commit 53eb815c95
5 changed files with 278 additions and 68 deletions
@@ -14,6 +14,7 @@ import {
} from "../src/lib/rectification-agentic/v9/varga-observations.ts";
import { WINDOW_SCAN_DISPLAY_LAYER_ORDER } from "../src/lib/rectification-agentic/v9/refinement-packet.ts";
import { RECTIFICATION_SKILL_VERSION } from "../src/lib/rectification-agentic/v9/case-status.ts";
import { buildInferenceState } from "../src/lib/rectification-agentic/core/build-state.ts";
import { decideRectification } from "../src/lib/rectification-agentic/core/rectification-decision.ts";
import { readVedastroMinuteSensitiveStatus } from "../src/lib/rectification-agentic/v9/confirmation-gate.ts";
import { authoritativeCandidateProjection } from "../src/lib/rectification-agentic/v9/inference-adapter.ts";
@@ -58,6 +59,23 @@ function collectDecision(candidates: readonly { time: string; relativeSupport?:
});
}
function producedInferenceState(
candidates: readonly Readonly<{ id: string; time: string; relative_support: number }>[],
) {
const times = candidates.map((item) => item.time).sort();
return buildInferenceState({
range_start: times[0]!,
range_end: times[times.length - 1]!,
candidates: candidates.map((item) => ({
id: item.id,
time: item.time,
relative_support: item.relative_support,
})),
events: [],
probes: [],
});
}
const DYNAMIC_STYLE_OPTIONS = [
{ label: "明确发生且时间吻合", answer_class: "yes" as const },
{ label: "发生过但程度较弱", answer_class: "weak_yes" as const },
@@ -1020,26 +1038,10 @@ test("cached candidates retry a failed VedAstro validation without recomputing r
representativeTime: "05:02",
evidenceLedgerFingerprint: evidenceFingerprint,
decisionReceipt: {
inference_state: {
algorithm_version: "rectification-inference-v1",
candidate_set_id: "04:55-05:02:04:55,05:02",
revision: 1,
phase: "discrimination",
result_status: "credible_range",
range_start: "04:55",
range_end: "05:02",
candidates: [
{ id: CANDIDATE_ID, time: "05:02", cluster_range: ["05:02", "05:02"], prior_score: 58, posterior_score: 58, probability: 0.58, status: "active", rank: 1, strong_conflict_count: 0 },
{ id: SECOND_CANDIDATE_ID, time: "04:55", cluster_range: ["04:55", "04:55"], prior_score: 42, posterior_score: 42, probability: 0.42, status: "active", rank: 2, strong_conflict_count: 0 },
],
events: [],
probes: [],
answered_probes: [],
rounds: [],
entropy: 0.98,
representative_time: "05:02",
credible_range: ["04:55", "05:02"],
},
inference_state: producedInferenceState([
{ id: CANDIDATE_ID, time: "05:02", relative_support: 58 },
{ id: SECOND_CANDIDATE_ID, time: "04:55", relative_support: 42 },
]),
gates: {
exact_confirmation: {
external_validation_status: "failed",
@@ -1361,27 +1363,15 @@ test("public tool surface stays at 14 and new cases bind 10.0.13", () => {
assert.match(tools, /current_probe: null/);
});
test("Mastra hides active candidates when the receipt range excludes one of them", () => {
test("Mastra hides active candidates when the receipt range is corrupted", () => {
const candidates = [
{ candidateId: CANDIDATE_ID, time: "05:00", rank: 1, relativeSupport: 20, tiedMinuteCount: 1 },
{ candidateId: SECOND_CANDIDATE_ID, time: "05:07", rank: 2, relativeSupport: 15, tiedMinuteCount: 1 },
];
const inferenceState = {
algorithm_version: "rectification-inference-v1",
candidate_set_id: "05:00-05:07:05:00,05:07",
revision: 2,
phase: "discrimination",
result_status: "credible_range",
range_start: "05:00",
range_end: "05:07",
candidates: [
{ id: CANDIDATE_ID, time: "05:00", cluster_range: ["05:00", "05:00"], prior_score: 20, posterior_score: 20, probability: 0.57, status: "active", rank: 1, strong_conflict_count: 0 },
{ id: SECOND_CANDIDATE_ID, time: "05:07", cluster_range: ["05:07", "05:07"], prior_score: 15, posterior_score: 15, probability: 0.43, status: "active", rank: 2, strong_conflict_count: 0 },
],
events: [], probes: [], answered_probes: [], rounds: [], entropy: 0.98,
representative_time: "05:00",
credible_range: ["05:00", "05:07"],
};
const inferenceState = producedInferenceState([
{ id: CANDIDATE_ID, time: "05:00", relative_support: 20 },
{ id: SECOND_CANDIDATE_ID, time: "05:07", relative_support: 15 },
]);
const latest = {
resultId: RESULT_ID,
candidates,
@@ -1408,7 +1398,7 @@ test("Mastra hides active candidates when the receipt range excludes one of them
const invalid = latestResultToolProjection({
...latest,
decisionReceipt: {
inference_state: { ...inferenceState, credible_range: ["05:00", "05:00"] },
inference_state: { ...inferenceState, credible_range: ["04:00", "04:10"] },
},
}, session);
assert.deepEqual(invalid.candidates, []);
@@ -2810,26 +2800,10 @@ test("paused case with selection_allowed may offer the escape hatch", async () =
{ candidate_id: SECOND_CANDIDATE_ID, rank: 2, time: "04:49", relative_support: 42, tied_minute_count: 2 },
],
decisionReceipt: {
inference_state: {
algorithm_version: "rectification-inference-v1",
candidate_set_id: "04:48-04:49:04:48,04:49",
revision: 1,
phase: "discrimination",
result_status: "credible_range",
range_start: "04:48",
range_end: "04:49",
candidates: [
{ id: CANDIDATE_ID, time: "04:48", cluster_range: ["04:48", "04:48"], prior_score: 58, posterior_score: 58, probability: 0.58, status: "active", rank: 1, strong_conflict_count: 0 },
{ id: SECOND_CANDIDATE_ID, time: "04:49", cluster_range: ["04:49", "04:49"], prior_score: 42, posterior_score: 42, probability: 0.42, status: "active", rank: 2, strong_conflict_count: 0 },
],
events: [],
probes: [],
answered_probes: [],
rounds: [],
entropy: 0.98,
representative_time: "04:48",
credible_range: ["04:48", "04:49"],
},
inference_state: producedInferenceState([
{ id: CANDIDATE_ID, time: "04:48", relative_support: 58 },
{ id: SECOND_CANDIDATE_ID, time: "04:49", relative_support: 42 },
]),
},
}),
}),