| 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.rows import row_returncode
|
| 14 | from oakbench.output_semantics import OUTPUT_ORACLE_VERSION, PATCH_ORACLE_VERSION
|
| 15 | from oakbench.workflow_oracles import SCENARIOS as TRUSTED_WORKFLOWS, VERSION as WORKFLOW_ORACLE_VERSION
|
| 16 |
|
| 17 |
|
| 18 | def output_evidence_failures(row: dict[str, Any]) -> list[str]:
|
| 19 | failures: list[str] = []
|
| 20 | for flag in ("pipe_compatible_unified", "patch_apply_ok", "patch_tree_matches", "patch_application_required"):
|
| 21 | if row.get(flag) is not None and type(row[flag]) is not bool:
|
| 22 | failures.append(f"{flag} is not a nullable boolean")
|
| 23 | for metric, source in (
|
| 24 | ("information_recall", "information_recall_source"),
|
| 25 | ("information_precision", "information_precision_source"),
|
| 26 | ):
|
| 27 | value = row.get(metric)
|
| 28 | if value is not None and (
|
| 29 | type(value) not in (int, float) or not math.isfinite(value) or not 0 <= value <= 1
|
| 30 | ):
|
| 31 | failures.append(f"{metric} is not a finite fraction")
|
| 32 | if row.get(metric) is not None and (
|
| 33 | row.get("output_oracle_version") != OUTPUT_ORACLE_VERSION
|
| 34 | or row.get(source) != "exact_metadata_path_set"
|
| 35 | ):
|
| 36 | failures.append(f"{metric} lacks versioned exact-path evidence")
|
| 37 |
|
| 38 | claims_applicability = row.get("patch_application_required") is True or row.get("patch_apply_ok") is True
|
| 39 | if claims_applicability and not (
|
| 40 | row.get("patch_apply_ok") is True
|
| 41 | and row.get("patch_tree_matches") is True
|
| 42 | and row.get("patch_apply_returncode") == 0
|
| 43 | and type(row.get("patch_apply_returncode")) is int
|
| 44 | and row.get("patch_oracle_version") == PATCH_ORACLE_VERSION
|
| 45 | and row.get("patch_apply_source") == "git_apply_exact_tree"
|
| 46 | and isinstance(row.get("patch_instrument_sha256"), str)
|
| 47 | and re.fullmatch(r"[0-9a-f]{64}", row["patch_instrument_sha256"])
|
| 48 | and isinstance(row.get("patch_instrument_version"), str)
|
| 49 | and row["patch_instrument_version"].strip()
|
| 50 | and not row.get("patch_skip_reason")
|
| 51 | and not row.get("patch_failure_reason")
|
| 52 | and not row.get("probe_output_truncated")
|
| 53 | and not row.get("output_truncated")
|
| 54 | ):
|
| 55 | failures.append("structural/applicability success lacks a successful exact-tree patch application")
|
| 56 | return failures
|
| 57 |
|
| 58 |
|
| 59 | def workflow_evidence_failures(rows: list[dict[str, Any]]) -> list[str]:
|
| 60 | """Require independent persisted-state evidence for trusted payload tasks.
|
| 61 |
|
| 62 | Source labels describe how observations were obtained; they are not
|
| 63 | equivalence classes. Scripted summaries must pass; measured agent failures
|
| 64 | remain evidence for success-rate accounting.
|
| 65 | In particular, this rule does not certify bugfix_test_loop persistence.
|
| 66 | """
|
| 67 | groups = {}
|
| 68 | failures = []
|
| 69 | for row in rows:
|
| 70 | operation = row.get("operation")
|
| 71 | if operation not in {"agent.workflow", "workflow.total", "workflow.skipped"}:
|
| 72 | continue
|
| 73 | code = row_returncode(row)
|
| 74 | integrity = row.get("workflow_integrity_passed")
|
| 75 | measured_agent_failure = (
|
| 76 | operation == "agent.workflow" and type(integrity) is bool
|
| 77 | and row.get("outcome") in {"fail", "timeout", "error"}
|
| 78 | and row.get("success") is False and code not in {0, 77}
|
| 79 | and not row.get("skipped")
|
| 80 | )
|
| 81 | if not measured_agent_failure and (
|
| 82 | operation == "workflow.skipped" or integrity is not True or code != 0
|
| 83 | or row.get("skipped") or row.get("success") is False
|
| 84 | or row.get("correctness_passed") is False
|
| 85 | or (operation == "agent.workflow" and row.get("outcome") not in {None, "pass"})
|
| 86 | ):
|
| 87 | failures.append(f"{row.get('subject')}/{row.get('scenario')}: workflow correctness is failed, skipped or unmeasured")
|
| 88 | if row.get("operation") in {"agent.workflow", "workflow.total"} and row.get("workflow_integrity_evidence_class") == "independent_committed_tree":
|
| 89 | instrument = row.get("git_head_instrument_sha256")
|
| 90 | subject = row.get("workflow_subject_binary_sha256")
|
| 91 | if (not all(isinstance(value, str) and re.fullmatch(r"[0-9a-f]{64}", value) for value in (instrument, subject))
|
| 92 | or instrument == subject or "subject_produced" in str(row.get("workflow_integrity_source", ""))):
|
| 93 | failures.append("independent reader lacks distinct observed subject/instrument identities or uses subject-produced evidence")
|
| 94 | if row.get("scenario") not in TRUSTED_WORKFLOWS:
|
| 95 | continue
|
| 96 | agent = row.get("agent") if isinstance(row.get("agent"), dict) else {}
|
| 97 | key = (row.get("scenario"), "workflow.total" if operation == "workflow.skipped" else operation, row.get("benchmark_track"),
|
| 98 | row.get("instruction_level", agent.get("instruction_level")),
|
| 99 | agent.get("name"), agent.get("model"), agent.get("provider"),
|
| 100 | agent.get("environment"))
|
| 101 | groups.setdefault(key, []).append(row)
|
| 102 | for key, items in groups.items():
|
| 103 | if len({item.get("subject") for item in items}) < 2:
|
| 104 | continue
|
| 105 | if any(item.get("oracle_version") != WORKFLOW_ORACLE_VERSION for item in items):
|
| 106 | failures.append(f"{key}: trusted task validator version is incompatible or missing")
|
| 107 | # Failed task validation can finish before any HEAD reader runs. It
|
| 108 | # measures failure, not persisted completion; keep those trials in
|
| 109 | # success-rate evidence without inventing an independent reader.
|
| 110 | if any(item.get("workflow_integrity_evidence_class") != "independent_committed_tree" for item in items
|
| 111 | if not (item.get("operation") == "agent.workflow" and item.get("workflow_integrity_passed") is False)):
|
| 112 | failures.append(f"{key}: trusted persisted-state comparison requires independent committed-tree readers; subject-produced exports and metadata are insufficient")
|
| 113 | if any(not isinstance(item.get("workflow_integrity_source"), str) or not item["workflow_integrity_source"].strip() for item in items):
|
| 114 | failures.append(f"{key}: correctness evidence source is missing")
|
| 115 | if any("subject_produced" in str(item.get("workflow_integrity_source", ""))
|
| 116 | and item.get("workflow_integrity_evidence_class") == "independent_committed_tree" for item in items):
|
| 117 | failures.append(f"{key}: subject-produced evidence cannot declare an independent reader class")
|
| 118 | if any(type(item.get("workflow_integrity_passed")) is not bool for item in items):
|
| 119 | failures.append(f"{key}: correctness evidence is failed or unmeasured")
|
| 120 | return failures
|