import type { Submission } from "../vocab/index.ts"; // 一份已经收下的核验、消融核验的结论(任务书 10 第三部分第 2、3 条):判的是"收下之后通过没有",不是"收不收"。 /** * 核验通过没有(方法.md 4.3 ⑨):任何一项没落实,或者任何一条没有归属的改动判为越界,就不通过。 * 没落实的条款、因子、保障和越界的改动分开列:保障短名可能和别的编号同形。 */ export function verificationOutcome(v: Submission<"verification">): { passed: boolean; clauses: string[]; factors: string[]; safeguards: string[]; outOfScope: string[]; } { const clauses = v.clauses.filter((x) => !x.found).map((x) => x.clause); const factors = v.factors.filter((x) => !x.found).map((x) => x.factor); const safeguards = v.safeguards.filter((x) => !x.found).map((x) => x.safeguard); const outOfScope = v.unassigned.filter((x) => x.outOfScope).map((x) => x.location); return { passed: clauses.length + factors.length + safeguards.length + outOfScope.length === 0, clauses, factors, safeguards, outOfScope }; } /** * 消融核验通过没有(方法.md 4.3 ⑯):这一格要关的因子(off)和实验员报的一起关的因子(alsoOff)都写了"关着", * 其余因子都写了"照留",才算通过。leftOn 是该关却照留的,wronglyOff 是该留却关了的。 */ export function ablationOutcome( v: Submission<"ablationVerification">, off: string, alsoOff: readonly string[], ): { passed: boolean; leftOn: string[]; wronglyOff: string[] } { const shouldBeOff = new Set([off, ...alsoOff]); const leftOn = v.factors.filter((f) => shouldBeOff.has(f.factor) && !f.off).map((f) => f.factor); const wronglyOff = v.factors.filter((f) => !shouldBeOff.has(f.factor) && f.off).map((f) => f.factor); return { passed: leftOn.length + wronglyOff.length === 0, leftOn, wronglyOff }; }