|
FILES = json.loads('{"benchmarks/verified_patch/v1/base/invoice.py": "def invoice_total(subtotal_cents: int, member: bool = False) -> int:\\n if subtotal_cents < 0:\\n raise ValueError(\\"subtotal must be non-negative\\")\\n discounted = subtotal_cents - (subtotal_cents // 10 if member else 0)\\n shipping = 0 if subtotal_cents > 5000 else 500\\n return discounted + shipping\\n", "benchmarks/verified_patch/v1/base/test_invoice.py": "from invoice import invoice_total\\n\\n\\ndef test_paid_shipping_below_boundary():\\n assert invoice_total(4999) == 5499\\n\\n\\ndef test_free_shipping_boundary():\\n assert invoice_total(5000) == 5000\\n", "benchmarks/verified_patch/v1/manifest.json": "{\\n \\"protocol_version\\": \\"1.0.0\\",\\n \\"protocol_path\\": \\"docs/marketing/QUALITY_GATE_BENCHMARK_PROTOCOL.md\\",\\n \\"defect_family\\": \\"invoice_free_shipping_threshold\\",\\n \\"repetitions_per_fixture_per_arm\\": 10,\\n \\"arms\\": [\\"qualitymax_verify_patch\\", \\"pytest_head_only\\", \\"pytest_base_head\\"],\\n \\"base_files\\": [\\"base/invoice.py\\", \\"base/test_invoice.py\\"],\\n \\"oracle_path\\": \\"oracle/test_invoice_contract.py\\",\\n \\"artifacts_sha256\\": {\\n \\"base/invoice.py\\": \\"c19cdb5db566358c31ddb077e12918890f1f62329b026d5e56f02e3c9fba356c\\",\\n \\"base/test_invoice.py\\": \\"cecf4300cd3a213b078a0c1e279a783a2c949ee65db2f940dc1864c8892038eb\\",\\n \\"oracle/test_invoice_contract.py\\": \\"2098f380a6e91cdbacc870370a88400d97f197830d2cc4ca7b902204291e3f11\\",\\n \\"patches/broken.patch\\": \\"213ef03e849885fbfd68157de8e7aa360691ddbe91de2ae18978e6a6a02b0c0d\\",\\n \\"patches/collateral.patch\\": \\"048c595db45c17c3b0b844bcd68e1f05f411c046f6436b4ad33dcac47ea5db17\\",\\n \\"patches/overbroad.patch\\": \\"cc85d6eec0e5c77fb14a10f2a35de8e9dfff69814289f5aca1a52c47c9c837a0\\",\\n \\"patches/repair.patch\\": \\"50e15e51504948d6edc18de9e8835e9b86815b5b7689c4b0b51ca35ccae7efe1\\",\\n \\"patches/syntax_error.patch\\": \\"c341b6bf6a2d70cf2959e2ac178af40d00cef875ecec1fb0425e843a34d8fca2\\",\\n \\"patches/test_only.patch\\": \\"d012976cb47d0b6375413e069694764908bebae158d8300fd34d553bdbaa328d\\",\\n \\"requirements.txt\\": \\"52df5ed8fd46a690a6ea457a18ee138399d8607c88f01b891f43b3c6916db629\\"\\n },\\n \\"fixtures\\": [\\n {\\n \\"id\\": \\"repair\\",\\n \\"patch\\": \\"patches/repair.patch\\",\\n \\"test_path\\": \\"test_invoice.py::test_free_shipping_boundary\\",\\n \\"contract_satisfied\\": true,\\n \\"reproduction_eligible\\": true,\\n \\"expected_base_exit_code\\": 1,\\n \\"expected_candidate_exit_code\\": 0,\\n \\"expected_oracle_exit_code\\": 0,\\n \\"expected_qualitymax_policy\\": \\"pass\\"\\n },\\n {\\n \\"id\\": \\"broken\\",\\n \\"patch\\": \\"patches/broken.patch\\",\\n \\"test_path\\": \\"test_invoice.py::test_free_shipping_boundary\\",\\n \\"contract_satisfied\\": false,\\n \\"reproduction_eligible\\": false,\\n \\"expected_base_exit_code\\": 1,\\n \\"expected_candidate_exit_code\\": 1,\\n \\"expected_oracle_exit_code\\": 1,\\n \\"expected_qualitymax_policy\\": \\"needs_human\\"\\n },\\n {\\n \\"id\\": \\"overbroad\\",\\n \\"patch\\": \\"patches/overbroad.patch\\",\\n \\"test_path\\": \\"test_invoice.py::test_free_shipping_boundary\\",\\n \\"contract_satisfied\\": false,\\n \\"reproduction_eligible\\": true,\\n \\"expected_base_exit_code\\": 1,\\n \\"expected_candidate_exit_code\\": 0,\\n \\"expected_oracle_exit_code\\": 1,\\n \\"expected_qualitymax_policy\\": \\"pass\\"\\n },\\n {\\n \\"id\\": \\"collateral\\",\\n \\"patch\\": \\"patches/collateral.patch\\",\\n \\"test_path\\": \\"test_invoice.py::test_free_shipping_boundary\\",\\n \\"contract_satisfied\\": false,\\n \\"reproduction_eligible\\": true,\\n \\"expected_base_exit_code\\": 1,\\n \\"expected_candidate_exit_code\\": 0,\\n \\"expected_oracle_exit_code\\": 1,\\n \\"expected_qualitymax_policy\\": \\"pass\\"\\n },\\n {\\n \\"id\\": \\"non_reproducing\\",\\n \\"patch\\": \\"patches/repair.patch\\",\\n \\"test_path\\": \\"test_invoice.py::test_paid_shipping_below_boundary\\",\\n \\"contract_satisfied\\": true,\\n \\"reproduction_eligible\\": false,\\n \\"expected_base_exit_code\\": 0,\\n \\"expected_candidate_exit_code\\": 0,\\n \\"expected_oracle_exit_code\\": 0,\\n \\"expected_qualitymax_policy\\": \\"needs_human\\"\\n },\\n {\\n \\"id\\": \\"test_only\\",\\n \\"patch\\": \\"patches/test_only.patch\\",\\n \\"test_path\\": \\"test_invoice.py::test_free_shipping_boundary\\",\\n \\"contract_satisfied\\": false,\\n \\"reproduction_eligible\\": false,\\n \\"expected_base_exit_code\\": 1,\\n \\"expected_candidate_exit_code\\": 0,\\n \\"expected_oracle_exit_code\\": 1,\\n \\"expected_qualitymax_policy\\": \\"tool_error\\"\\n },\\n {\\n \\"id\\": \\"syntax_error\\",\\n \\"patch\\": \\"patches/syntax_error.patch\\",\\n \\"test_path\\": \\"test_invoice.py::test_free_shipping_boundary\\",\\n \\"contract_satisfied\\": false,\\n \\"reproduction_eligible\\": false,\\n \\"expected_base_exit_code\\": 1,\\n \\"expected_candidate_exit_code\\": 4,\\n \\"expected_oracle_exit_code\\": 2,\\n \\"expected_qualitymax_policy\\": \\"needs_human\\"\\n }\\n ]\\n}\\n", "benchmarks/verified_patch/v1/oracle/test_invoice_contract.py": "import pytest\\nfrom invoice import invoice_total\\n\\n\\n@pytest.mark.parametrize(\\n (\\"subtotal_cents\\", \\"member\\", \\"expected\\"),\\n [\\n (0, False, 500),\\n (4999, False, 5499),\\n (5000, False, 5000),\\n (5001, False, 5001),\\n (4999, True, 5000),\\n (5000, True, 4500),\\n (5001, True, 4501),\\n ],\\n)\\ndef test_invoice_contract(subtotal_cents, member, expected):\\n assert invoice_total(subtotal_cents, member) == expected\\n\\n\\ndef test_negative_subtotal_rejected():\\n with pytest.raises(ValueError, match=\\"non-negative\\"):\\n invoice_total(-1)\\n", "benchmarks/verified_patch/v1/patches/broken.patch": "diff --git a/invoice.py b/invoice.py\\n--- a/invoice.py\\n+++ b/invoice.py\\n@@ -2,5 +2,5 @@\\n if subtotal_cents < 0:\\n raise ValueError(\\"subtotal must be non-negative\\")\\n discounted = subtotal_cents - (subtotal_cents // 10 if member else 0)\\n- shipping = 0 if subtotal_cents > 5000 else 500\\n+ shipping = 0 if subtotal_cents > 10000 else 500\\n return discounted + shipping\\n", "benchmarks/verified_patch/v1/patches/collateral.patch": "diff --git a/invoice.py b/invoice.py\\n--- a/invoice.py\\n+++ b/invoice.py\\n@@ -2,5 +2,5 @@\\n if subtotal_cents < 0:\\n raise ValueError(\\"subtotal must be non-negative\\")\\n- discounted = subtotal_cents - (subtotal_cents // 10 if member else 0)\\n- shipping = 0 if subtotal_cents > 5000 else 500\\n+ discounted = subtotal_cents\\n+ shipping = 0 if subtotal_cents >= 5000 else 500\\n return discounted + shipping\\n", "benchmarks/verified_patch/v1/patches/overbroad.patch": "diff --git a/invoice.py b/invoice.py\\n--- a/invoice.py\\n+++ b/invoice.py\\n@@ -2,5 +2,5 @@\\n if subtotal_cents < 0:\\n raise ValueError(\\"subtotal must be non-negative\\")\\n discounted = subtotal_cents - (subtotal_cents // 10 if member else 0)\\n- shipping = 0 if subtotal_cents > 5000 else 500\\n+ shipping = 0\\n return discounted + shipping\\n", "benchmarks/verified_patch/v1/patches/repair.patch": "diff --git a/invoice.py b/invoice.py\\n--- a/invoice.py\\n+++ b/invoice.py\\n@@ -2,5 +2,5 @@\\n if subtotal_cents < 0:\\n raise ValueError(\\"subtotal must be non-negative\\")\\n discounted = subtotal_cents - (subtotal_cents // 10 if member else 0)\\n- shipping = 0 if subtotal_cents > 5000 else 500\\n+ shipping = 0 if subtotal_cents >= 5000 else 500\\n return discounted + shipping\\n", "benchmarks/verified_patch/v1/patches/syntax_error.patch": "diff --git a/invoice.py b/invoice.py\\n--- a/invoice.py\\n+++ b/invoice.py\\n@@ -2,5 +2,5 @@\\n if subtotal_cents < 0:\\n raise ValueError(\\"subtotal must be non-negative\\")\\n discounted = subtotal_cents - (subtotal_cents // 10 if member else 0)\\n- shipping = 0 if subtotal_cents > 5000 else 500\\n+ shipping =\\n return discounted + shipping\\n", "benchmarks/verified_patch/v1/patches/test_only.patch": "diff --git a/test_invoice.py b/test_invoice.py\\n--- a/test_invoice.py\\n+++ b/test_invoice.py\\n@@ -8,2 +8,2 @@\\n def test_free_shipping_boundary():\\n- assert invoice_total(5000) == 5000\\n+ assert invoice_total(5000) == 5500\\n", "benchmarks/verified_patch/v1/requirements.txt": "iniconfig==2.1.0\\npackaging==24.2\\npluggy==1.5.0\\npytest==8.3.5\\n", "scripts/verified_patch_no_signup_sample.py": "#!/usr/bin/env python3\\n\\"\\"\\"No-signup local reproduction sample for the verified-patch protocol.\\n\\nThis runner is intentionally limited to the frozen public fixture manifest. It\\ndoes not execute arbitrary caller patches, does not call QualityMax services,\\nand does not sign verdicts. Its output is local evidence for inspection only.\\n\\"\\"\\"\\n\\nfrom __future__ import annotations\\n\\nimport argparse\\nimport hashlib\\nimport importlib.metadata\\nimport importlib.util\\nimport json\\nimport os\\nimport platform\\nimport shutil\\nimport subprocess\\nimport sys\\nimport tempfile\\nimport time\\nimport uuid\\nimport venv\\nimport xml.etree.ElementTree as ET\\nfrom pathlib import Path\\nfrom typing import Any\\n\\nREPO_ROOT = Path(__file__).resolve().parents[1]\\nROOT = REPO_ROOT / \\"benchmarks\\" / \\"verified_patch\\" / \\"v1\\"\\nFROZEN_MANIFEST_SHA256 = \\"6387aca0791539d9d9fde91bf9c09ae0b9fb7705b8a6aed3bc01d5c5f8054e7f\\"\\nSAMPLE_FIXTURES = (\\"broken\\", \\"repair\\", \\"non_reproducing\\", \\"overbroad\\", \\"collateral\\", \\"syntax_error\\")\\nWALKTHROUGH_TIMEOUT_SECONDS = 240\\nPYTEST_ENV = {\\n \\"PYTEST_DISABLE_PLUGIN_AUTOLOAD\\": \\"1\\",\\n \\"PYTHONDONTWRITEBYTECODE\\": \\"1\\",\\n \\"PYTHONHASHSEED\\": \\"0\\",\\n}\\n\\n\\ndef _sha256(path: Path) -> str:\\n return hashlib.sha256(path.read_bytes()).hexdigest()\\n\\n\\ndef _load_manifest() -> dict[str, Any]:\\n manifest_path = ROOT / \\"manifest.json\\"\\n manifest_bytes = manifest_path.read_bytes()\\n if hashlib.sha256(manifest_bytes).hexdigest() != FROZEN_MANIFEST_SHA256:\\n raise SystemExit(\\"manifest integrity check failed: only frozen v1 inputs are admitted\\")\\n manifest = json.loads(manifest_bytes)\\n expected = manifest[\\"artifacts_sha256\\"]\\n for relative_path, digest in expected.items():\\n actual = _sha256(ROOT / relative_path)\\n if actual != digest:\\n raise SystemExit(f\\"fixture integrity check failed for {relative_path}: {actual} != {digest}\\")\\n return manifest\\n\\n\\ndef _fixture_by_id(manifest: dict[str, Any], fixture_id: str) -> dict[str, Any]:\\n for fixture in manifest[\\"fixtures\\"]:\\n if fixture[\\"id\\"] == fixture_id:\\n return fixture\\n choices = \\", \\".join(item[\\"id\\"] for item in manifest[\\"fixtures\\"])\\n raise SystemExit(f\\"unknown fixture {fixture_id!r}; choose one of: {choices}\\")\\n\\n\\ndef _copy_base(manifest: dict[str, Any], workspace: Path) -> None:\\n for relative_path in manifest[\\"base_files\\"]:\\n shutil.copyfile(ROOT / relative_path, workspace / Path(relative_path).name)\\n\\n\\ndef _run_pytest(workspace: Path, target: str, report: Path) -> dict[str, Any]:\\n started = time.monotonic()\\n command = [\\n sys.executable,\\n \\"-m\\",\\n \\"pytest\\",\\n \\"-c\\",\\n os.devnull,\\n \\"--rootdir=.\\",\\n \\"-q\\",\\n f\\"--junitxml={report}\\",\\n target,\\n ]\\n try:\\n result = subprocess.run(\\n command,\\n cwd=workspace,\\n env={\\"PATH\\": os.defpath, **PYTEST_ENV, \\"PYTHONPATH\\": str(workspace)},\\n capture_output=True,\\n text=True,\\n timeout=30,\\n check=False,\\n )\\n except subprocess.TimeoutExpired:\\n return {\\n \\"command\\": command,\\n \\"exit_code\\": None,\\n \\"duration_seconds\\": round(time.monotonic() - started, 6),\\n \\"junit\\": None,\\n \\"cases\\": [],\\n \\"execution_error\\": \\"timeout\\",\\n }\\n duration_seconds = round(time.monotonic() - started, 6)\\n cases: list[dict[str, Any]] = []\\n if report.exists():\\n root = ET.parse(report).getroot()\\n for case in root.iter(\\"testcase\\"):\\n child_tags = {child.tag.rsplit(\\"}\\", 1)[-1] for child in case}\\n if \\"error\\" in child_tags:\\n outcome = \\"error\\"\\n elif \\"failure\\" in child_tags:\\n outcome = \\"fail\\"\\n elif \\"skipped\\" in child_tags:\\n outcome = \\"skipped\\"\\n else:\\n outcome = \\"pass\\"\\n cases.append({\\"name\\": case.get(\\"name\\"), \\"classname\\": case.get(\\"classname\\"), \\"outcome\\": outcome})\\n return {\\n \\"command\\": command,\\n \\"exit_code\\": result.returncode,\\n \\"duration_seconds\\": duration_seconds,\\n \\"junit\\": str(report),\\n \\"cases\\": cases,\\n \\"stdout_tail\\": result.stdout[-1200:],\\n \\"stderr_tail\\": result.stderr[-1200:],\\n }\\n\\n\\ndef _apply_manifest_patch(workspace: Path, patch: Path, git: str) -> None:\\n for options in ((\\"--check\\",), ()):\\n subprocess.run(\\n [git, \\"apply\\", *options, \\"--\\", str(patch)],\\n cwd=workspace,\\n env={\\"PATH\\": os.defpath},\\n capture_output=True,\\n text=True,\\n check=True,\\n timeout=10,\\n )\\n\\n\\ndef _policy(base: dict[str, Any], head: dict[str, Any]) -> str:\\n base_failed = base[\\"exit_code\\"] == 1 and any(case[\\"outcome\\"] == \\"fail\\" for case in base[\\"cases\\"])\\n head_passed = head[\\"exit_code\\"] == 0 and head[\\"cases\\"] and all(case[\\"outcome\\"] == \\"pass\\" for case in head[\\"cases\\"])\\n same_nodes = [(case[\\"classname\\"], case[\\"name\\"]) for case in base[\\"cases\\"]] == [\\n (case[\\"classname\\"], case[\\"name\\"]) for case in head[\\"cases\\"]\\n ]\\n return \\"pass\\" if base_failed and head_passed and same_nodes else \\"needs_human\\"\\n\\n\\ndef build_parser() -> argparse.ArgumentParser:\\n parser = argparse.ArgumentParser(description=\\"Run the public no-signup verified-patch sample.\\")\\n parser.add_argument(\\n \\"--fixture\\",\\n choices=SAMPLE_FIXTURES,\\n help=\\"run one frozen fixture and print its JSON receipt; test-only patches are not admitted\\",\\n )\\n parser.add_argument(\\"--out\\", help=\\"new evidence directory (must not already exist)\\")\\n parser.add_argument(\\n \\"--bootstrap\\", action=\\"store_true\\", help=\\"install only pinned sample dependencies in a temporary virtualenv\\"\\n )\\n return parser\\n\\n\\ndef _bootstrap(git: str) -> int:\\n with tempfile.TemporaryDirectory(prefix=\\"qmax-sample-venv-\\") as temporary:\\n venv.EnvBuilder(with_pip=True).create(temporary)\\n python = str(Path(temporary) / \\"bin\\" / \\"python\\")\\n subprocess.run(\\n [\\n python,\\n \\"-m\\",\\n \\"pip\\",\\n \\"--isolated\\",\\n \\"install\\",\\n \\"--disable-pip-version-check\\",\\n \\"--index-url\\",\\n \\"https://pypi.org/simple\\",\\n \\"-r\\",\\n str(ROOT / \\"requirements.txt\\"),\\n ],\\n env={\\"PATH\\": os.defpath},\\n stdout=subprocess.DEVNULL,\\n stderr=subprocess.DEVNULL,\\n check=True,\\n timeout=180,\\n )\\n arguments = [argument for argument in sys.argv[1:] if argument != \\"--bootstrap\\"]\\n return subprocess.run(\\n [python, str(Path(__file__).resolve()), *arguments],\\n env={\\"PATH\\": str(Path(git).parent) + os.pathsep + os.defpath},\\n timeout=WALKTHROUGH_TIMEOUT_SECONDS,\\n ).returncode\\n\\n\\ndef _run_fixture(manifest: dict[str, Any], fixture_id: str, out_dir: Path, git: str) -> tuple[dict[str, Any], int]:\\n fixture = _fixture_by_id(manifest, fixture_id)\\n out_dir.mkdir(parents=True, exist_ok=False)\\n patch_path = ROOT / fixture[\\"patch\\"]\\n\\n with tempfile.TemporaryDirectory(prefix=\\"qmax-verified-patch-\\") as tmp:\\n base_workspace = Path(tmp) / \\"base\\"\\n head_workspace = Path(tmp) / \\"head\\"\\n base_workspace.mkdir()\\n head_workspace.mkdir()\\n _copy_base(manifest, base_workspace)\\n _copy_base(manifest, head_workspace)\\n _apply_manifest_patch(head_workspace, patch_path, git)\\n\\n base = _run_pytest(base_workspace, fixture[\\"test_path\\"], out_dir / \\"base-selected.xml\\")\\n head = _run_pytest(head_workspace, fixture[\\"test_path\\"], out_dir / \\"head-selected.xml\\")\\n oracle = _run_pytest(head_workspace, str(ROOT / manifest[\\"oracle_path\\"]), out_dir / \\"head-oracle.xml\\")\\n for name, workspace in ((\\"base\\", base_workspace), (\\"head\\", head_workspace)):\\n shutil.copytree(workspace, out_dir / name, ignore=shutil.ignore_patterns(\\".pytest_cache\\", \\"__pycache__\\"))\\n shutil.copyfile(patch_path, out_dir / \\"candidate.patch\\")\\n\\n verdict_status = _policy(base, head)\\n evidence = {\\n \\"sample\\": \\"verified_patch_no_signup\\",\\n \\"warning\\": \\"local fixture reproduction only; not a QualityMax MCP result and not signed\\",\\n \\"protocol_version\\": manifest[\\"protocol_version\\"],\\n \\"protocol_path\\": manifest[\\"protocol_path\\"],\\n \\"manifest_sha256\\": _sha256(ROOT / \\"manifest.json\\"),\\n \\"runner_sha256\\": _sha256(Path(__file__)),\\n \\"environment\\": {\\n \\"python\\": platform.python_version(),\\n \\"system\\": platform.system(),\\n \\"machine\\": platform.machine(),\\n \\"pytest\\": importlib.metadata.version(\\"pytest\\"),\\n },\\n \\"trees_sha256\\": {\\n name: {Path(relative).name: _sha256(out_dir / name / Path(relative).name) for relative in manifest[\\"base_files\\"]}\\n for name in (\\"base\\", \\"head\\")\\n },\\n \\"fixture\\": {\\n \\"id\\": fixture[\\"id\\"],\\n \\"patch\\": fixture[\\"patch\\"],\\n \\"patch_sha256\\": _sha256(patch_path),\\n \\"selected_test\\": fixture[\\"test_path\\"],\\n \\"contract_satisfied\\": fixture[\\"contract_satisfied\\"],\\n },\\n \\"verdict\\": {\\n \\"status\\": verdict_status,\\n \\"reason\\": \\"base selected test failed and head selected test passed\\"\\n if verdict_status == \\"pass\\"\\n else \\"base/head reproduction did not establish a repair\\",\\n \\"signature\\": None,\\n \\"signature_note\\": \\"Absent by design. Protocol signatures prove provenance, not correctness.\\",\\n },\\n \\"runs\\": {\\"base_selected\\": base, \\"head_selected\\": head, \\"head_oracle\\": oracle},\\n \\"evidence_files\\": {\\n \\"json\\": str(out_dir / \\"sample-result.json\\"),\\n \\"base_junit\\": str(out_dir / \\"base-selected.xml\\"),\\n \\"head_junit\\": str(out_dir / \\"head-selected.xml\\"),\\n \\"oracle_junit\\": str(out_dir / \\"head-oracle.xml\\"),\\n \\"patch\\": str(out_dir / \\"candidate.patch\\"),\\n \\"base\\": str(out_dir / \\"base\\"),\\n \\"head\\": str(out_dir / \\"head\\"),\\n },\\n }\\n (out_dir / \\"sample-result.json\\").write_text(json.dumps(evidence, indent=2, sort_keys=True) + \\"\\\\n\\")\\n exit_code = 2 if any(run.get(\\"execution_error\\") for run in (base, head, oracle)) else 0\\n if exit_code == 0 and verdict_status != fixture[\\"expected_qualitymax_policy\\"]:\\n exit_code = 1\\n return evidence, exit_code\\n\\n\\ndef _walkthrough_completed(evidence: dict[str, Any]) -> bool:\\n \\"\\"\\"An abstention alone does not establish the advertised fixture outcome.\\"\\"\\"\\n runs = evidence[\\"runs\\"]\\n expected = {\\n \\"base_selected\\": [\\"fail\\"],\\n \\"head_selected\\": [\\"fail\\"] if evidence[\\"fixture\\"][\\"id\\"] == \\"broken\\" else [\\"pass\\"],\\n \\"head_oracle\\": [\\"fail\\"] * 4 + [\\"pass\\"] * 4 if evidence[\\"fixture\\"][\\"id\\"] == \\"broken\\" else [\\"pass\\"] * 8,\\n }\\n return all(\\n not runs[name].get(\\"execution_error\\")\\n and runs[name][\\"exit_code\\"] == (1 if \\"fail\\" in outcomes else 0)\\n and sorted(case[\\"outcome\\"] for case in runs[name][\\"cases\\"]) == outcomes\\n for name, outcomes in expected.items()\\n ) and [(case[\\"classname\\"], case[\\"name\\"]) for case in runs[\\"base_selected\\"][\\"cases\\"]] == [\\n (case[\\"classname\\"], case[\\"name\\"]) for case in runs[\\"head_selected\\"][\\"cases\\"]\\n ]\\n\\n\\ndef _print_walkthrough_result(label: str, evidence: dict[str, Any]) -> None:\\n fixture = evidence[\\"fixture\\"]\\n runs = evidence[\\"runs\\"]\\n out_dir = Path(evidence[\\"evidence_files\\"][\\"json\\"]).parent\\n if any(run.get(\\"execution_error\\") for run in runs.values()):\\n print(f\\"{label}: execution stopped early; inspect {out_dir / \'sample-result.json\'}.\\")\\n return\\n base_failed = runs[\\"base_selected\\"][\\"exit_code\\"] == 1 and any(\\n case[\\"outcome\\"] == \\"fail\\" for case in runs[\\"base_selected\\"][\\"cases\\"]\\n )\\n head_passed = (\\n runs[\\"head_selected\\"][\\"exit_code\\"] == 0\\n and runs[\\"head_selected\\"][\\"cases\\"]\\n and all(case[\\"outcome\\"] == \\"pass\\" for case in runs[\\"head_selected\\"][\\"cases\\"])\\n )\\n head_failed = runs[\\"head_selected\\"][\\"exit_code\\"] == 1 and any(\\n case[\\"outcome\\"] == \\"fail\\" for case in runs[\\"head_selected\\"][\\"cases\\"]\\n )\\n if evidence[\\"verdict\\"][\\"status\\"] == \\"pass\\" and base_failed and head_passed:\\n print(f\\"{label}: the same unchanged test failed before the repair and passed after it; this repair succeeded.\\")\\n elif head_failed:\\n print(f\\"{label}: the same unchanged test still fails after the proposed change; needs human review.\\")\\n else:\\n print(f\\"{label}: the run did not establish a repair; inspect {out_dir / \'sample-result.json\'}.\\")\\n print(f\\" Original source: {out_dir / \'base\' / \'invoice.py\'}\\")\\n print(f\\" Proposed source: {out_dir / \'head\' / \'invoice.py\'}\\")\\n print(f\\" Unchanged test: {out_dir / \'base\' / fixture[\'selected_test\'].split(\'::\', 1)[0]}\\")\\n print(f\\" Receipt: {out_dir / \'sample-result.json\'}\\")\\n\\n\\ndef main() -> int:\\n parser = build_parser()\\n args = parser.parse_args()\\n\\n if sys.version_info[:2] not in ((3, 11), (3, 12)) or os.name != \\"posix\\":\\n parser.error(\\"supported environment: CPython 3.11 or 3.12 on macOS or Linux, with git available\\")\\n git = shutil.which(\\"git\\")\\n if git is None:\\n parser.error(\\"git is missing; install Git and make it available on PATH\\")\\n git = str(Path(git).absolute())\\n if args.bootstrap:\\n try:\\n _load_manifest()\\n return _bootstrap(git)\\n except (OSError, subprocess.SubprocessError):\\n parser.exit(2, \\"sample setup failed; verify Python venv support and public PyPI connectivity\\\\n\\")\\n\\n manifest = _load_manifest()\\n if importlib.util.find_spec(\\"pytest\\") is None:\\n parser.error(\\"pytest is missing; use --bootstrap for isolated pinned dependencies\\")\\n if args.fixture:\\n out_dir = (\\n Path(args.out).resolve() if args.out else (Path.cwd() / \\"artifacts\\" / \\"verified-patch-sample\\" / uuid.uuid4().hex)\\n )\\n evidence, exit_code = _run_fixture(manifest, args.fixture, out_dir, git)\\n print(\\n json.dumps(\\n {\\n \\"fixture\\": args.fixture,\\n \\"status\\": evidence[\\"verdict\\"][\\"status\\"],\\n \\"evidence\\": str(out_dir / \\"sample-result.json\\"),\\n },\\n sort_keys=True,\\n )\\n )\\n return exit_code\\n\\n parent_dir = (\\n Path(args.out).resolve() if args.out else (Path.cwd() / \\"artifacts\\" / \\"verified-patch-sample\\" / uuid.uuid4().hex)\\n )\\n parent_dir.mkdir(parents=True, exist_ok=False)\\n print(\\"Verified Patch Sample walkthrough\\")\\n print(\\"Problem: a $50 order is charged $55 because free shipping starts above $50.\\")\\n print(\\"\\\\n1 of 2 \\u2014 Rejected proposed patch\\")\\n broken, broken_exit = _run_fixture(manifest, \\"broken\\", parent_dir / \\"broken\\", git)\\n _print_walkthrough_result(\\"Rejected proposed patch\\", broken)\\n print(\\"\\\\n2 of 2 \\u2014 Repair candidate\\")\\n repair, repair_exit = _run_fixture(manifest, \\"repair\\", parent_dir / \\"repair\\", git)\\n _print_walkthrough_result(\\"Repair candidate\\", repair)\\n print(f\\"\\\\nWalkthrough evidence: {parent_dir}\\")\\n print(\\"This is a fixed, unsigned example. Passing the selected test does not prove whole-patch correctness.\\")\\n if not all(_walkthrough_completed(evidence) for evidence in (broken, repair)):\\n print(\\"Walkthrough incomplete: the expected test outcomes were not all observed. Inspect both receipts.\\")\\n return max(1, broken_exit, repair_exit)\\n return max(broken_exit, repair_exit)\\n\\n\\nif __name__ == \\"__main__\\":\\n raise SystemExit(main())\\n"}') |