78 lines
3.1 KiB
TypeScript
78 lines
3.1 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { slimDecisionReceipt } from "../src/lib/rectification-agentic/v9/case-receipt-projection.ts";
|
|
import { buildInferenceState } from "../src/lib/rectification-agentic/core/build-state.ts";
|
|
import { parseV9CaseDossier } from "../src/lib/rectification-agentic/v9/tool-service.ts";
|
|
import {
|
|
activeFocusFixture,
|
|
candidateSnapshotFixture,
|
|
conversationSummaryFixture,
|
|
dossierFixture,
|
|
} from "./rectification-v9-test-support.ts";
|
|
|
|
test("default Case receipt projection keeps decision and inference state while slimming render-only payloads", () => {
|
|
const inference = buildInferenceState({
|
|
range_start: "04:53",
|
|
range_end: "05:07",
|
|
candidates: [
|
|
{ id: "05:00", time: "05:00", relative_support: 50 },
|
|
{ id: "05:07", time: "05:07", relative_support: 40 },
|
|
{ id: "04:00", time: "04:00", relative_support: 10 },
|
|
],
|
|
events: [],
|
|
probes: [],
|
|
});
|
|
const fullInference = {
|
|
...inference,
|
|
candidates: inference.candidates.map((candidate) => (
|
|
candidate.time === "04:00" ? { ...candidate, status: "eliminated" as const } : candidate
|
|
)),
|
|
};
|
|
const dossier = parseV9CaseDossier(dossierFixture({
|
|
latestResult: candidateSnapshotFixture({
|
|
representativeTime: "05:00",
|
|
decisionReceipt: { inference_state: fullInference },
|
|
}),
|
|
conversationSummary: conversationSummaryFixture({
|
|
activeFocus: activeFocusFixture({
|
|
expectedAnswerSchema: {
|
|
collect: true,
|
|
probe_id: "probe-current",
|
|
semantic_key: "current.semantic",
|
|
candidate_split_hash: "current-split",
|
|
},
|
|
}),
|
|
}),
|
|
}));
|
|
assert.ok(dossier);
|
|
const decision = { status: "nonterminal", next: "ask" };
|
|
const receipt = {
|
|
decision,
|
|
gates: { can_adopt: false, selection_allowed: false },
|
|
inference_state: fullInference,
|
|
house_tables_by_time: {
|
|
"04:00": { time: "04:00", houses: Array(12).fill({ sign: "x" }) },
|
|
"05:00": { time: "05:00", houses: Array(12).fill({ sign: "x" }) },
|
|
"05:07": { time: "05:07", houses: Array(12).fill({ sign: "x" }) },
|
|
},
|
|
house_table: { time: "05:00", houses: Array(12).fill({ sign: "x" }) },
|
|
discriminating_event_probes: [
|
|
{ id: "probe-current", question: "当前" },
|
|
{ id: "probe-old", question: "旧" },
|
|
],
|
|
evidence_collection_probes: [
|
|
{ semantic_key: "current.semantic", question: "当前" },
|
|
{ semantic_key: "old.semantic", question: "旧" },
|
|
],
|
|
};
|
|
|
|
const slim = slimDecisionReceipt(receipt, dossier!);
|
|
assert.deepEqual(slim.decision, decision);
|
|
assert.deepEqual(slim.gates, receipt.gates);
|
|
assert.deepEqual(slim.inference_state, fullInference);
|
|
assert.deepEqual(Object.keys(slim.house_tables_by_time as Record<string, unknown>).sort(), ["05:00", "05:07"]);
|
|
assert.deepEqual((slim.discriminating_event_probes as Array<Record<string, unknown>>).map((row) => row.id), ["probe-current"]);
|
|
assert.deepEqual((slim.evidence_collection_probes as Array<Record<string, unknown>>).map((row) => row.semantic_key), ["current.semantic"]);
|
|
});
|