File size: 3,068 Bytes
7962689
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""Check the frozen dataset and evaluator without browser, model or network."""
from collections import Counter
import hashlib
import itertools
import json
from pathlib import Path
import sys

ROOT = Path(__file__).resolve().parent
sys.path.insert(0, str(ROOT / "runtime"))
from financeclawbench.financial_work180_cases import case, public_contract, TASK_IDS
from financeclawbench.financial_work180_runner import runtime_hash


def check(condition, message):
    if not condition:
        raise ValueError(message)


def read_table(name):
    text = (ROOT / "data" / (name + ".jsonl")).read_text(encoding="utf-8")
    return [json.loads(line) for line in text.splitlines()]


def main():
    for line in (ROOT / "SHA256SUMS").read_text(encoding="utf-8").splitlines():
        expected, name = line.split("  ", 1)
        path = (ROOT / name).resolve()
        check(path.is_relative_to(ROOT) and path.is_file(), f"Missing or invalid path: {name}")
        check(hashlib.sha256(path.read_bytes()).hexdigest() == expected, f"Changed file: {name}")
    check(runtime_hash() == "2ad917a7a2e129a807675b02ed0656aaacac12758a951df613d003dd9f1d63b6", "Wrong evaluator")
    tasks, results = read_table("tasks"), read_table("results")
    ids = {r["task_id"] for r in tasks}
    check(len(tasks) == len(ids) == 180 and ids == set(TASK_IDS), "Wrong task set")
    check(Counter(r["work_area"] for r in tasks) == {f"F{x}": 10 for x in range(1, 19)}, "Area mismatch")
    check(Counter(r["workflow"] for r in tasks) == {"public_method_and_case": 142, "native_web_then_workbook": 38}, "Workflow mismatch")
    for t in tasks:
        i = t["task_id"]
        check(json.loads(t["public_contract_json"]) == public_contract(i), f"Public contract mismatch: {i}")
        check({v["name"]: json.loads(v["value_json"]) for v in t["case_inputs"]} == case(i).get("client_facts", {}), f"Case input mismatch: {i}")
    expected = {
        "deepseek-flash": (51, 127, 154), "glm-5.3": (39, 117, 168),
        "gpt-6.1-sol": (128, 176, 180), "qwen3.8-max-0902": (51, 138, 168)
    }
    keys = {(r["task_id"], r["model"]) for r in results}
    check(len(results) == 720 and keys == set(itertools.product(ids, expected)), "Duplicate or missing model/task")
    families = {r["task_id"]: r["work_area"] for r in tasks}
    for row in results:
        check(row["work_area"] == families[row["task_id"]], "Mismatched area in results")
        for k, v in row.items():
            if k.endswith("_pass"):
                check(type(v) is bool or (k == "financial_pass" and v is None), f"Invalid flag: {k}")
    for m, reference in expected.items():
        rows = [r for r in results if r["model"] == m]
        counts = (sum(r["overall_pass"] for r in rows), sum(r["financial_pass"] is True for r in rows),
                  sum(r["financial_pass"] is not None for r in rows))
        check(counts == reference, f"Score mismatch for {m}: {counts}")
    print("Verified: 180 tasks, 18 areas, 720 outcomes; 269 overall passes and 558/670 financial passes.")


if __name__ == "__main__":
    main()