fix(rectification): resolve typed focus answers deterministically
Independent Staging Quality Gate / validate (push) Successful in 19m52s
Independent Staging Quality Gate / publish (push) Successful in 53m47s

This commit is contained in:
Jesse_Chen
2026-08-27 20:31:05 +08:00
parent f3327235ea
commit 85db4591d3
24 changed files with 695 additions and 168 deletions
@@ -293,25 +293,21 @@ export function applyHoldoutAnswer(
};
}
export function classifyChoiceAnswer(key: string, schema?: unknown): AnswerClass {
if (key === "A") return "yes";
if (key === "B") return "weak_yes";
if (key === "C") {
if (schemaMapsCToUnsure(schema)) return "unsure";
return "no";
}
return "unsure";
}
function schemaMapsCToUnsure(schema: unknown): boolean {
if (!schema || typeof schema !== "object") return false;
export function classifyChoiceAnswer(key: string, schema?: unknown): AnswerClass | null {
if (!schema || typeof schema !== "object" || Array.isArray(schema)) return null;
const row = schema as Record<string, unknown>;
if (row.choice_kind !== "varga_style") return false;
const choice = row.choice && typeof row.choice === "object" && !Array.isArray(row.choice)
? row.choice as Record<string, unknown>
: row;
const optionC = typeof choice.option_c === "string" ? choice.option_c : "";
return optionC.includes("都不像");
if (!Array.isArray(choice.options)) return null;
const option = choice.options.find((item) => (
item && typeof item === "object" && !Array.isArray(item) && (item as { key?: unknown }).key === key
));
if (!option || typeof option !== "object") return null;
const answerClass = (option as { answer_class?: unknown }).answer_class;
return answerClass === "yes" || answerClass === "weak_yes" || answerClass === "no" || answerClass === "unsure"
? answerClass
: null;
}
function rebuildWithAnswers(state: InferenceState, incoming: readonly ProbeAnswer[]): InferenceState {