Viewing files at commit 2310099b696dCommit detailsView latest

Browse files
scripts/oakbench/public_output.py 79 lines · 3.8 KB · python
1
"""Evidence requirements for publishing output-usefulness measurements.
2
3
Legacy structural markers remain diagnostic data. They cannot certify that
4
standard patch tooling reconstructs the intended repository tree.
5
"""
6
7
from __future__ import annotations
8
9
from typing import Any
10
import math
11
import re
12
13
from oakbench.output_semantics import OUTPUT_ORACLE_VERSION, PATCH_ORACLE_VERSION
14
15
16
def output_evidence_failures(row: dict[str, Any]) -> list[str]:
17
    failures: list[str] = []
18
    for flag in ("pipe_compatible_unified", "patch_apply_ok", "patch_tree_matches", "patch_application_required"):
19
        if row.get(flag) is not None and type(row[flag]) is not bool:
20
            failures.append(f"{flag} is not a nullable boolean")
21
    for metric, source in (
22
        ("information_recall", "information_recall_source"),
23
        ("information_precision", "information_precision_source"),
24
    ):
25
        value = row.get(metric)
26
        if value is not None and (
27
            type(value) not in (int, float) or not math.isfinite(value) or not 0 <= value <= 1
28
        ):
29
            failures.append(f"{metric} is not a finite fraction")
30
        if row.get(metric) is not None and (
31
            row.get("output_oracle_version") != OUTPUT_ORACLE_VERSION
32
            or row.get(source) != "exact_metadata_path_set"
33
        ):
34
            failures.append(f"{metric} lacks versioned exact-path evidence")
35
36
    claims_applicability = row.get("patch_application_required") is True or row.get("patch_apply_ok") is True
37
    if claims_applicability and not (
38
        row.get("patch_apply_ok") is True
39
        and row.get("patch_tree_matches") is True
40
        and row.get("patch_apply_returncode") == 0
41
        and type(row.get("patch_apply_returncode")) is int
42
        and row.get("patch_oracle_version") == PATCH_ORACLE_VERSION
43
        and row.get("patch_apply_source") == "git_apply_exact_tree"
44
        and isinstance(row.get("patch_instrument_sha256"), str)
45
        and re.fullmatch(r"[0-9a-f]{64}", row["patch_instrument_sha256"])
46
        and isinstance(row.get("patch_instrument_version"), str)
47
        and row["patch_instrument_version"].strip()
48
        and not row.get("patch_skip_reason")
49
        and not row.get("patch_failure_reason")
50
        and not row.get("probe_output_truncated")
51
        and not row.get("output_truncated")
52
    ):
53
        failures.append("structural/applicability success lacks a successful exact-tree patch application")
54
    return failures
55
56
57
def workflow_evidence_failures(rows: list[dict[str, Any]]) -> list[str]:
58
    """A shared task name cannot erase unequal committed-tree evidence."""
59
    groups = {}
60
    for row in rows:
61
        if row.get("operation") not in {"agent.workflow", "workflow.total"}:
62
            continue
63
        agent = row.get("agent") if isinstance(row.get("agent"), dict) else {}
64
        key = (row.get("scenario"), row.get("operation"), row.get("benchmark_track"),
65
               row.get("instruction_level", agent.get("instruction_level")),
66
               agent.get("name"), agent.get("model"), agent.get("provider"),
67
               agent.get("environment"))
68
        groups.setdefault(key, []).append(row)
69
    failures = []
70
    for key, items in groups.items():
71
        if len({item.get("subject") for item in items}) < 2:
72
            continue
73
        source_values = [item.get("workflow_integrity_source") for item in items]
74
        sources = {value if isinstance(value, str) else None for value in source_values}
75
        if None in sources or "" in sources or len(sources) != 1:
76
            failures.append(f"{key}: cross-subject correctness evidence differs or is missing: {sorted(map(str, sources))}")
77
        elif any(item.get("workflow_integrity_passed") is not True for item in items):
78
            failures.append(f"{key}: correctness evidence is failed or unmeasured")
79
    return failures