CrossSWE-Bench / scripts /evaluate_reusable_batch06_scoped_v1.py
Silin-Chen's picture
CrossSWE-Bench: current 171-instance release
0e239c6
Raw History Blame Contribute Delete
2.48 kB
"""Pinned unchanged batch06 baseline with an explicit release-root binding."""
import hashlib
from pathlib import Path
import sys
import tempfile
import types
sys.dont_write_bytecode = True
PINS = {'evaluate_reusable_batch06_image.py': '99bfbe785ff03efa19a02c1755839847dfda57e9e5e93f52d7ff19381798a523', 'reusable_support/batch06_case_reports.py': '71be1b571260f84a250dd6c1e4689bde8d80a4f71f6926d0103e18272145f675', 'reusable_support/batch06_git_state.py': '87b2720ada6307f55e8550661ffff21267c69b547e89d254e0b82d5f2935af32', 'reusable_support/batch06_runtime_resources.py': 'f68535cdf3feeb9435129649c04020ca5361a2d86aa08359ca2dccf957ecb486', 'reusable_support/batch06_source_audit.py': 'fe8dcb35ca7d9fb28d4ddf484e17fa02a706d13aa928d392be708e6d499c12fd', 'reusable_support/batch06_source_files.py': 'a9ccfb607e04ade3d165cf14e2fc2579326d220f93539c1e09e9ce4fbe7dab95', 'reusable_support/execution_io.py': 'fca4f9c2a2fe83af2203257c1155af2db45bb065080ae47fb23378affd3cf407', 'reusable_support/image_identity.py': '82764a71a677364e7dbbe40023885ca3f15bf8f307a98dd8378bfb80966decf0', 'reusable_support/validation_policy.py': '42dee62ae6ac69fd6fecfa1e04530ad598e1b230fe3fd67e81047d9c44f067ea'}
def main():
root = Path(__file__).resolve().parents[1]
scoped = root / 'scripts/candidate_batch06_support_v1'
captured = {}
for name, digest in PINS.items():
path = scoped / name
if not path.is_file() or any(p.is_symlink() for p in (path, *path.parents)):
raise ValueError('Unsafe scoped baseline support source')
data = path.read_bytes()
if hashlib.sha256(data).hexdigest() != digest:
raise ValueError('Scoped baseline support SHA mismatch: ' + name)
captured[name] = data
with tempfile.TemporaryDirectory(prefix='crossswe-baseline-reader-') as directory:
snapshot = Path(directory)
for name, data in captured.items():
target = snapshot / name
target.parent.mkdir(parents=True, exist_ok=True)
with target.open('xb') as stream:
stream.write(data)
path = snapshot / 'evaluate_reusable_batch06_image.py'
module = types.ModuleType('crossswe_unchanged_batch06_baseline')
module.__file__ = str(path)
exec(compile(captured[path.name], str(path), 'exec'), module.__dict__)
module.ROOT = root
module.CODE = snapshot / 'reusable_support'
module.main()
if __name__ == '__main__':
main()