From ec4322919d2e1efba33af9d7137bd9e9e800ed5b Mon Sep 17 00:00:00 2001 From: cnedwards Date: Tue, 17 Nov 2026 22:20:53 +0000 Subject: [PATCH 1/2] Fix release artifacts and macOS compatibility. --- .github/workflows/portability.yml | 17 ++++ README_DETAILED.md | 9 +- docs/release-artifacts.md | 40 +++++++++ pyproject.toml | 5 +- scripts/build_sweep_bundle.py | 84 ++++++++++++++---- scripts/fetch_sweeps.sh | 58 ++++++------- tests/test_cli_full_genome.py | 2 +- tests/test_release_portability.py | 139 ++++++++++++++++++++++++++++++ 8 files changed, 302 insertions(+), 52 deletions(-) create mode 100644 .github/workflows/portability.yml create mode 100644 docs/release-artifacts.md create mode 100644 tests/test_release_portability.py diff --git a/.github/workflows/portability.yml b/.github/workflows/portability.yml new file mode 100644 index 0000000..b5ecd39 --- /dev/null +++ b/.github/workflows/portability.yml @@ -0,0 +1,17 @@ +name: Release portability +on: [push, pull_request] +jobs: + test: + strategy: + matrix: + os: [ubuntu-latest, macos-14] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v6 + with: + python-version: "3.11" + - run: uv sync --extra torch + - run: uv run pytest + - run: uv run ruff check --select F src scripts tests + - run: bash -n scripts/fetch_sweeps.sh diff --git a/README_DETAILED.md b/README_DETAILED.md index 1e9e54b..54cc968 100644 --- a/README_DETAILED.md +++ b/README_DETAILED.md @@ -68,6 +68,10 @@ uv sync --extra torch # + AssayFormer (train-ranker / eval-ranker) and the `torch` is a 500 MB+ install and every module that needs it imports it lazily, which is why it is opt-in. Nothing else is gated. +The Torch extra uses CUDA 12.8 wheels on Linux/Windows and the PyPI build on +macOS (CPU/MPS). The sweep downloader supports Bash 3.2 and uses either +`sha256sum` or macOS's `shasum -a 256` for checksum verification. + **No credentials are required** to run the offline parts, and none are required to reproduce the AssayFormer numbers: every public screen description ships pre-embedded (see [Text embeddings](#text-embeddings)). You need an API key only for the LLM baselines, and @@ -374,8 +378,9 @@ A dash in a results table reads as "we measured nothing here", not "you did not data". The bundle's runs executed behind an internal gateway, so API keys, internal hostnames and -internal filesystem paths were replaced with placeholders before publication. No metric, -acquired-gene list, prompt or model output was altered. `scripts/build_sweep_bundle.py` does +internal filesystem paths were replaced with placeholders before publication. Metrics +and acquired-gene lists are preserved. Historical prompts and outputs are +retained except for those redactions. `scripts/build_sweep_bundle.py` does the redaction and refuses to write an archive that still trips its own secret scan; `MANIFEST.json` inside the bundle maps every sweep to the table row it backs. diff --git a/docs/release-artifacts.md b/docs/release-artifacts.md new file mode 100644 index 0000000..da2d6ea --- /dev/null +++ b/docs/release-artifacts.md @@ -0,0 +1,40 @@ +# Publishing the cached result bundles + +The table fetcher expects two assets on the GitHub release `data-v1`: + +- `assayloop-sweeps-v1.tar.gz` +- `assayloop-llm-calls-v1.tar.gz` + +Build them from the original result roots, using the public checkout: + +```bash +uv run python scripts/build_sweep_bundle.py \ + --results /path/to/results --shared /path/to/shared-results \ + --with-llm-calls --out dist/data-v1 +``` + +The inputs must contain `sweeps/` and `runs/`. The builder refuses unresolved +rows and missing result files. It removes credential values, internal hosts, +and internal paths; verifies that metrics, acquisition lists, observations, +and parsed response genes are unchanged; and scans for remaining known secret +patterns. Manifests record the checks and source sweep IDs. Review the staged +files before publication: pattern scans cannot identify every possible secret. + +Historical prompt text is preserved apart from these redactions. Differences +from the current prompt templates are provenance, not edits to be hidden. +Saved-response replay preserves the collected experiment; it does not imply +that a fresh API call with a different prompt produces equivalent results. + +Copy the printed SHA-256 hashes into `scripts/fetch_sweeps.sh`. Test both +archives together using a local mirror: + +```bash +ASSAYLOOP_BUNDLE_URL="file://$PWD/dist/data-v1" \ +ASSAYLOOP_PUBLISHED=/tmp/assayloop-bundle-check \ + bash scripts/fetch_sweeps.sh +``` + +Publish the two exact archives as release assets and verify a clean download +using the default URL. Keep the hashes and assets together: changing only the +fetcher does not fix a missing GitHub release. Do not replace already-published +immutable assets in place; use a new version for later changes. diff --git a/pyproject.toml b/pyproject.toml index d5ddd64..2a444b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,7 +87,10 @@ link-mode = "copy" # PyPI's default torch wheel is built for CUDA 13.0 (+cu130), which the GPU # hosts' CUDA 12.8 drivers cannot run. Pin torch to the cu128 build index # (newest is 2.11.0+cu128); cu128 runtimes also run on newer (13.x) drivers. -torch = { index = "pytorch-cu128" } +# macOS uses the ordinary PyPI build (CPU/MPS); CUDA wheels are unavailable there. +torch = [ + { index = "pytorch-cu128", marker = "sys_platform == 'linux' or sys_platform == 'win32'" }, +] [[tool.uv.index]] name = "pytorch-cu128" diff --git a/scripts/build_sweep_bundle.py b/scripts/build_sweep_bundle.py index 999bfdc..32c9ccc 100644 --- a/scripts/build_sweep_bundle.py +++ b/scripts/build_sweep_bundle.py @@ -53,7 +53,7 @@ python scripts/build_sweep_bundle.py --out dist/ --with-llm-calls ... Roots may also come from ``ASSAYLOOP_RESULTS`` / ``ASSAYLOOP_SHARED_PATH``. -The printed sha256 goes into ``scripts/fetch_sweeps.sh``'s EXPECTED map. +The printed sha256 goes into the pinned archive arguments in ``scripts/fetch_sweeps.sh``. """ from __future__ import annotations @@ -163,6 +163,43 @@ def scrub_obj(obj, counter: dict[str, int]): return obj +PROTECTED_FIELDS = {"acquired_batch", "new_observations", "metrics", "final_metrics", "aggregate"} + + +def verify_redaction(original, cleaned, audit: dict[str, int]) -> None: + """Refuse changed scientific results or changed parsed response gene lists.""" + if isinstance(original, dict): + for key, value in original.items(): + clean_key = scrub_obj(key, {}) + other = cleaned[clean_key] + if key in PROTECTED_FIELDS: + if value != other: + raise ValueError(f"redaction changed protected field {key}") + audit["protected_fields_verified"] = audit.get("protected_fields_verified", 0) + 1 + if key == "response_text" and isinstance(value, str): + if value != other: + from assayloop.llm.parse_genes import extract_gene_list + if extract_gene_list(value) != extract_gene_list(other): + raise ValueError("redaction changed parsed response genes; inspect privately") + audit["response_fields_verified"] = audit.get("response_fields_verified", 0) + 1 + verify_redaction(value, other, audit) + elif isinstance(original, list): + if len(original) != len(cleaned): + raise ValueError("redaction changed list length") + for value, other in zip(original, cleaned): + verify_redaction(value, other, audit) + elif isinstance(original, str) and original != cleaned: + audit["redacted_string_values"] = audit.get("redacted_string_values", 0) + 1 + elif not isinstance(original, str) and original is not cleaned and original != cleaned: + raise ValueError("redaction changed a numeric/boolean/null value") + + +def checked_scrub(obj, counts, audit): + cleaned = scrub_obj(obj, counts) + verify_redaction(obj, cleaned, audit) + return cleaned + + def deny_scan_tree(obj, where: str, path: str = "") -> list[str]: """Structural check: no credential key may carry a surviving value. @@ -175,10 +212,10 @@ def deny_scan_tree(obj, where: str, path: str = "") -> list[str]: sub = f"{path}/{k}" if (isinstance(k, str) and CREDENTIAL_KEYS.match(k) and isinstance(v, str) and v not in ("", REDACTED)): - problems.append(f"{where}: credential key {sub} = {v[:40]!r}") + problems.append(f"{where}: populated credential key {sub}") problems.extend(deny_scan_tree(v, where, sub)) elif isinstance(obj, list): - for i, v in enumerate(obj[:200]): + for i, v in enumerate(obj): problems.extend(deny_scan_tree(v, where, f"{path}[{i}]")) return problems @@ -189,10 +226,7 @@ def deny_scan(data: bytes, where: str) -> list[str]: for name, rx in DENY_PATTERNS: hits = rx.findall(data) if hits: - sample = (hits[0] if isinstance(hits[0], bytes) else hits[0][0]) - problems.append( - f"{where}: {name} x{len(hits)} " - f"(e.g. {sample.decode('utf8', 'replace')[:60]!r})") + problems.append(f"{where}: {name} x{len(hits)} (value withheld)") return problems @@ -200,7 +234,7 @@ def deny_scan(data: bytes, where: str) -> list[str]: # Discovery # --------------------------------------------------------------------------- -def required_sweep_ids() -> list[tuple[str, str]]: +def required_sweep_ids(roots: list[Path] | None = None) -> list[tuple[str, str]]: """Resolve (sweep_id, label) for every sweep the table cannot regenerate. Derived from ``full_genome_table``'s own method tables so the bundle stays @@ -210,6 +244,8 @@ def required_sweep_ids() -> list[tuple[str, str]]: from assayloop.scripts import full_genome_table as F from assayloop.scripts import results_index as R + if roots is not None: + R.SWEEP_DIRS = [root / "sweeps" for root in roots] index = R.load_sweep_index(R._load_all_sweeps()) found: dict[str, str] = {} unresolved: list[str] = [] @@ -285,7 +321,7 @@ def build(args) -> int: if not roots: raise SystemExit("no readable result roots; pass --results / --shared") - sweeps = required_sweep_ids() + sweeps = required_sweep_ids(roots) print(f"required sweeps: {len(sweeps)}") stage = Path(args.out) / f"assayloop-sweeps-{BUNDLE_VERSION}" @@ -301,6 +337,7 @@ def build(args) -> int: calls_stage.mkdir(parents=True) scrub_counts: dict[str, int] = {} + audit: dict[str, int] = {} violations: list[str] = [] hashes: dict[str, str] = {} entries = [] @@ -316,7 +353,7 @@ def build(args) -> int: bytes_sweeps += write_json( stage / "sweeps" / sweep_id / "sweep.json", - scrub_obj(sweep, scrub_counts), hashes, violations, + checked_scrub(sweep, scrub_counts, audit), hashes, violations, ) kept = [] @@ -330,7 +367,7 @@ def build(args) -> int: result = json.loads((rd / "result.json").read_text()) bytes_sweeps += write_json( stage / "runs" / run_id / "result.json", - scrub_obj(result, scrub_counts), hashes, violations, + checked_scrub(result, scrub_counts, audit), hashes, violations, ) kept.append(run_id) n_runs += 1 @@ -338,12 +375,18 @@ def build(args) -> int: if calls_stage is not None: src = rd / "llm_calls.jsonl" if not src.is_file(): + acq = str(sweep.get("config", {}).get("acq", "")) + if acq.startswith("llm"): + raise SystemExit( + f"missing llm_calls.jsonl for {run_id}; " + "refusing incomplete raw-response replay bundle" + ) continue lines = [] for line in src.read_text().splitlines(): if not line.strip(): continue - rec = scrub_obj(json.loads(line), scrub_counts) + rec = checked_scrub(json.loads(line), scrub_counts, audit) violations.extend( deny_scan_tree(rec, f"{run_id}/llm_calls.jsonl")) lines.append(json.dumps(rec, separators=(",", ":"))) @@ -359,10 +402,10 @@ def build(args) -> int: entries.append({ "sweep_id": sweep_id, "label": label, - "display_name": sweep.get("display_name"), - "model": sweep.get("config", {}).get("model"), - "acq": sweep.get("config", {}).get("acq"), - "tag": sweep.get("config", {}).get("tag"), + "display_name": scrub_obj(sweep.get("display_name"), scrub_counts), + "model": scrub_obj(sweep.get("config", {}).get("model"), scrub_counts), + "acq": scrub_obj(sweep.get("config", {}).get("acq"), scrub_counts), + "tag": scrub_obj(sweep.get("config", {}).get("tag"), scrub_counts), "n_runs": len(kept), "run_ids": kept, }) @@ -392,6 +435,7 @@ def build(args) -> int: print(f" {n:7d} {pat}") manifest = { + "redaction_checks": audit, "schema": 1, "bundle": f"assayloop-sweeps-{BUNDLE_VERSION}", "description": ( @@ -437,6 +481,8 @@ def build(args) -> int: "of model behaviour." ), "n_runs": n_calls, + "redaction_checks": audit, + "redaction": "Credential, host and path redactions only; historical prompts are not rewritten. Parsed response genes verified unchanged.", }, indent=2) + "\n") cpath = out_dir / CALLS_ARCHIVE _tar(calls_stage, cpath) @@ -445,7 +491,7 @@ def build(args) -> int: f"{cpath.stat().st_size/1e6:.1f} MB gz") print(f" sha256 {sha256_file(cpath)}") - print("\nPut those sha256 values in scripts/fetch_sweeps.sh EXPECTED.") + print("\nPut those sha256 values in the scripts/fetch_sweeps.sh calls.") return 0 @@ -508,8 +554,8 @@ def _tar(stage: Path, dest: Path) -> None: These runs executed behind an internal gateway. API keys, internal hostnames and internal filesystem paths have been replaced with placeholders such as -`sk-REDACTED` and `redacted-internal-host.invalid`. No metric, acquired-gene -list, prompt or model output was altered. The build refuses to produce an +`sk-REDACTED` and `redacted-internal-host.invalid`. Metrics and acquired-gene lists are preserved. Research text is retained except +for the redactions above. The build refuses to produce an archive if any known secret pattern survives. """ diff --git a/scripts/fetch_sweeps.sh b/scripts/fetch_sweeps.sh index 76204ad..f9c86f2 100755 --- a/scripts/fetch_sweeps.sh +++ b/scripts/fetch_sweeps.sh @@ -35,8 +35,8 @@ # # These runs executed behind an internal gateway. API keys, internal # hostnames and internal filesystem paths were replaced with placeholders -# (sk-REDACTED, redacted-internal-host.invalid) before publication. No -# metric, acquired-gene list, prompt or model output was altered. See +# (sk-REDACTED, redacted-internal-host.invalid) before publication. Research text is preserved +# except for these redactions. See # scripts/build_sweep_bundle.py. # # Default target: $ASSAYLOOP_PUBLISHED, falling back to /output/published @@ -57,7 +57,7 @@ for arg in "$@"; do --force) FORCE=1 ;; --with-llm-calls) WITH_CALLS=1 ;; --without-llm-calls) WITH_CALLS=0 ;; - -h|--help) sed -n '2,45p' "${BASH_SOURCE[0]}" | sed 's/^# \?//'; exit 0 ;; + -h|--help) sed -n '2,45p' "${BASH_SOURCE[0]}" | sed 's/^#//; s/^ //'; exit 0 ;; *) echo "unknown argument: $arg (try --help)" >&2; exit 2 ;; esac done @@ -65,31 +65,25 @@ done # Unlike the gene-set assets, these archives are immutable release artifacts, # so a sha256 mismatch is an error rather than a warning: it means you did not # get the bytes the paper was computed from. -declare -A URLS=( - ["assayloop-sweeps-v1.tar.gz"]="$BASE/assayloop-sweeps-v1.tar.gz" - ["assayloop-llm-calls-v1.tar.gz"]="$BASE/assayloop-llm-calls-v1.tar.gz" -) - -declare -A EXPECTED=( - ["assayloop-sweeps-v1.tar.gz"]="1073e6f543e278134d5b3bc1d41d1181e610157aad16053d7c8e44172181e50f" - ["assayloop-llm-calls-v1.tar.gz"]="c36fc84ce2358c5a1dccecf9e4995328faf58d93e864c52c4ce5b4cd3169f3c7" -) - -# A sentinel path per archive: present => already unpacked. The two archives -# merge into one runs/ tree (result.json from one, llm_calls.jsonl from the -# other), so each needs a marker the other does not also create. -declare -A SENTINEL=( - ["assayloop-sweeps-v1.tar.gz"]="MANIFEST.json" - ["assayloop-llm-calls-v1.tar.gz"]="MANIFEST-llm-calls.json" -) +# Positional arguments keep this compatible with macOS's default Bash 3.2. +checksum() { + if command -v sha256sum >/dev/null 2>&1; then + sha256sum "$1" | cut -d' ' -f1 + elif command -v shasum >/dev/null 2>&1; then + shasum -a 256 "$1" | cut -d' ' -f1 + else + echo "ERROR: install sha256sum or shasum to verify release archives." >&2 + return 1 + fi +} mkdir -p "$TARGET" echo "Fetching published sweeps into: $TARGET" -fetch_and_unpack() { +fetch_and_unpack() ( local name="$1" - local want="${EXPECTED[$name]}" - local sentinel="$TARGET/${SENTINEL[$name]}" + local want="$2" + local sentinel="$TARGET/$3" if [[ -e "$sentinel" && $FORCE -eq 0 ]]; then echo " [skip] $name already unpacked" @@ -98,13 +92,17 @@ fetch_and_unpack() { local tmp tmp="$(mktemp -d)" - trap 'rm -rf "$tmp"' RETURN + trap 'rm -rf "$tmp"' EXIT echo " [get ] $name" - curl -fsSL -o "$tmp/$name" "${URLS[$name]}" + if ! curl -fsSL -o "$tmp/$name" "$BASE/$name"; then + echo "ERROR: could not download $BASE/$name" >&2 + echo "Check https://github.com/Genentech/AssayLoop/releases/tag/data-v1 or set ASSAYLOOP_BUNDLE_URL to a published mirror." >&2 + return 1 + fi local got - got="$(sha256sum "$tmp/$name" | cut -d' ' -f1)" + got="$(checksum "$tmp/$name")" if [[ "$got" != "$want" ]]; then echo " ERROR: sha256 mismatch for $name" >&2 echo " expected $want" >&2 @@ -118,11 +116,13 @@ fetch_and_unpack() { # results_index.py scans. tar xzf "$tmp/$name" -C "$TARGET" --strip-components=1 echo " -> unpacked" -} +) -fetch_and_unpack "assayloop-sweeps-v1.tar.gz" +fetch_and_unpack "assayloop-sweeps-v1.tar.gz" \ + "587d6b492c1e0b8b83e6ed7a6834e4732f11dd6f1654bb3a030e5feec05c6395" "MANIFEST.json" if [[ $WITH_CALLS -eq 1 ]]; then - fetch_and_unpack "assayloop-llm-calls-v1.tar.gz" + fetch_and_unpack "assayloop-llm-calls-v1.tar.gz" \ + "05f5a0522b8a7950f86652660ca2d937793849e52b819eeb40b9cfffa369b208" "MANIFEST-llm-calls.json" else echo " [skip] assayloop-llm-calls-v1.tar.gz (exact raw-response replay unavailable)" fi diff --git a/tests/test_cli_full_genome.py b/tests/test_cli_full_genome.py index 3ac37f3..9ba31d2 100644 --- a/tests/test_cli_full_genome.py +++ b/tests/test_cli_full_genome.py @@ -9,7 +9,7 @@ def test_open_vocab_llm_defaults_to_shared_f2_universe(monkeypatch): captured = {} def fake_load_screens(*, target_set, dataset_names=None): - assert target_set == "public" + assert target_set == "paper_test" assert dataset_names is None return [ SimpleNamespace(genes=["A", "B"]), diff --git a/tests/test_release_portability.py b/tests/test_release_portability.py new file mode 100644 index 0000000..fbf5a29 --- /dev/null +++ b/tests/test_release_portability.py @@ -0,0 +1,139 @@ +import hashlib +import importlib.util +import io +import json +import os +from pathlib import Path +import re +import shutil +import subprocess +import tarfile + +import pytest + +ROOT = Path(__file__).resolve().parents[1] +spec = importlib.util.spec_from_file_location('bundle', ROOT / 'scripts/build_sweep_bundle.py') +bundle = importlib.util.module_from_spec(spec) +spec.loader.exec_module(bundle) + + +def test_redaction_scans_past_200_entries_without_printing_secret(): + secret = 'fake-private-value-for-testing' + obj = [{} for _ in range(250)] + [{'api_key': secret}] + problems = bundle.deny_scan_tree(obj, 'fixture') + assert problems and all(secret not in p for p in problems) + cleaned = bundle.checked_scrub(obj, {}, {}) + assert cleaned[-1]['api_key'] == 'REDACTED' + assert not bundle.deny_scan_tree(cleaned, 'fixture') + + +def test_scientific_content_and_historical_prompt_survive_redaction(): + original = {'prompt': 'Historical template. Predict TP53 and EGFR. /cv/home/tester/cache', + 'response_text': 'TP53, EGFR', 'metrics': {'ef': 4.2}, + 'acquired_batch': ['TP53', 'EGFR'], 'api_key': 'not-a-real-key'} + audit = {} + cleaned = bundle.checked_scrub(original, {}, audit) + assert cleaned['prompt'] == 'Historical template. Predict TP53 and EGFR. ' + assert cleaned['response_text'] == original['response_text'] + assert cleaned['metrics'] == original['metrics'] + assert cleaned['acquired_batch'] == original['acquired_batch'] + assert audit['protected_fields_verified'] == 2 + assert not bundle.deny_scan(json.dumps(cleaned).encode(), 'fixture') + with pytest.raises(ValueError, match='protected field'): + bundle.verify_redaction(original, {**cleaned, 'acquired_batch': ['MYC']}, {}) + with pytest.raises(ValueError, match='parsed response genes'): + bundle.verify_redaction(original, {**cleaned, 'response_text': 'MYC'}, {}) + + +def test_deny_scan_does_not_echo_secret(): + secret = 'sk-' + 'a' * 24 + problems = bundle.deny_scan(secret.encode(), 'fixture') + assert problems and secret not in str(problems) + + +def archive(path, files): + with tarfile.open(path, 'w:gz') as tf: + for name, content in files.items(): + data = content.encode() + info = tarfile.TarInfo('bundle/' + name) + info.size = len(data) + tf.addfile(info, io.BytesIO(data)) + return hashlib.sha256(path.read_bytes()).hexdigest() + + +@pytest.mark.parametrize('fallback', [False, True]) +def test_fetch_download_verify_merge_skip_and_reject_corruption(tmp_path, fallback): + mirror = tmp_path / 'mirror'; mirror.mkdir() + one = mirror / 'assayloop-sweeps-v1.tar.gz' + two = mirror / 'assayloop-llm-calls-v1.tar.gz' + hashes = [archive(one, {'MANIFEST.json': '{}', 'sweeps/s/sweep.json': '{}', 'runs/r/result.json': '{}'}), + archive(two, {'MANIFEST-llm-calls.json': '{}', 'runs/r/llm_calls.jsonl': '{}\n'})] + script = (ROOT / 'scripts/fetch_sweeps.sh').read_text() + expected = re.findall(r'"([a-f0-9]{64})"', script) + assert len(expected) == 2 + for old, new in zip(expected, hashes): + script = script.replace(old, new) + target_script = tmp_path / 'fetch.sh'; target_script.write_text(script) + commands = tmp_path / 'bin'; commands.mkdir() + for name in ['curl', 'tar', 'gzip', 'cut', 'mktemp', 'mkdir', 'rm', 'dirname', 'find', 'wc', 'sed'] + (['shasum'] if fallback else ['sha256sum']): + source = shutil.which(name) + if source is None: + pytest.skip(f'{name} unavailable') + (commands / name).symlink_to(source) + out = tmp_path / 'out'; scratch = tmp_path / 'scratch'; scratch.mkdir() + env = {**os.environ, 'ASSAYLOOP_PUBLISHED': str(out), 'ASSAYLOOP_BUNDLE_URL': mirror.as_uri(), + 'TMPDIR': str(scratch), 'PATH': str(commands)} + bash = os.environ.get('TEST_BASH', '/bin/bash') + def run(*args): + return subprocess.run([bash, str(target_script), *args], env=env, text=True, capture_output=True) + first = run() + assert first.returncode == 0, first.stderr + assert (out / 'runs/r/result.json').exists() and (out / 'runs/r/llm_calls.jsonl').exists() + assert (out / 'MANIFEST.json').exists() and (out / 'MANIFEST-llm-calls.json').exists() + assert not list(scratch.iterdir()) + assert '[skip]' in run().stdout + one.write_bytes(b'corrupt') + bad = run('--force') + assert bad.returncode != 0 and 'sha256 mismatch' in bad.stderr + assert not list(scratch.iterdir()) + one.unlink() + missing = run('--force') + assert missing.returncode != 0 and 'could not download' in missing.stderr + assert not list(scratch.iterdir()) + + +def test_bundle_requires_llm_calls_and_is_reproducible(tmp_path, monkeypatch): + from types import SimpleNamespace + + root = tmp_path / "source" + sweep_dir = root / "sweeps" / "sweep-test" + run_dir = root / "runs" / "run-test" + sweep_dir.mkdir(parents=True) + run_dir.mkdir(parents=True) + sweep = {"config": {"acq": "llm_single"}, + "per_screen": [{"run_id": "run-test"}], "aggregate": {"ef": 2.0}} + (sweep_dir / "sweep.json").write_text(json.dumps(sweep)) + (run_dir / "result.json").write_text(json.dumps({ + "final_metrics": {"ef": 2.0}, "steps": [{"acquired_batch": ["TP53"]}]})) + seen = [] + def required(roots): + seen.extend(roots) + return [("sweep-test", "Test LLM")] + monkeypatch.setattr(bundle, "required_sweep_ids", required) + args = SimpleNamespace(results=str(root), shared=None, with_llm_calls=True, + out=str(tmp_path / "release")) + with pytest.raises(SystemExit, match="missing llm_calls"): + bundle.build(args) + assert seen == [root] + (run_dir / "llm_calls.jsonl").write_text(json.dumps({ + "response_text": "TP53", "api_key": "test-only-secret"}) + "\n") + assert bundle.build(args) == 0 + archives = [Path(args.out) / bundle.SWEEP_ARCHIVE, Path(args.out) / bundle.CALLS_ARCHIVE] + hashes = [bundle.sha256_file(p) for p in archives] + assert bundle.build(args) == 0 + assert hashes == [bundle.sha256_file(p) for p in archives] + for p in archives: + with tarfile.open(p) as tf: + for member in tf.getmembers(): + if member.isfile(): + assert b"test-only-secret" not in tf.extractfile(member).read() From 0883bafa0b50251f329de9d9d37a5c6a1e3ea7a7 Mon Sep 17 00:00:00 2001 From: cnedwards Date: Tue, 17 Nov 2026 22:30:40 +0000 Subject: [PATCH 2/2] Use supported macOS 15 CI runner --- .github/workflows/portability.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/portability.yml b/.github/workflows/portability.yml index b5ecd39..3555467 100644 --- a/.github/workflows/portability.yml +++ b/.github/workflows/portability.yml @@ -4,7 +4,7 @@ jobs: test: strategy: matrix: - os: [ubuntu-latest, macos-14] + os: [ubuntu-latest, macos-15] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4