From 377833355b3e5408fa0afa573181297404752384 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Wed, 29 Jul 2026 13:18:14 +0100 Subject: [PATCH] test: verify Python 3.12 install floor --- .github/workflows/workspace-validation.yml | 21 ++- bin/pyauto-heart | 12 +- docs/release_validation.md | 35 ++-- health_agent/capabilities.md | 7 +- health_agent/capabilities.yaml | 6 +- heart/checks/verify_install.sh | 184 ++++++++++++++++----- heart/checks/verify_install_helpers.sh | 46 ++++++ heart/dashboard.py | 16 +- heart/readiness.py | 11 ++ heart/validate.py | 7 +- skills/verify_install/verify_install.md | 19 ++- tests/test_dashboard.py | 30 ++++ tests/test_readiness.py | 18 ++ tests/test_validate.py | 4 +- tests/test_verify_install_script.py | 161 +++++++++++++++++- 15 files changed, 497 insertions(+), 80 deletions(-) create mode 100644 heart/checks/verify_install_helpers.sh diff --git a/.github/workflows/workspace-validation.yml b/.github/workflows/workspace-validation.yml index ba31b08b..4a489e40 100644 --- a/.github/workflows/workspace-validation.yml +++ b/.github/workflows/workspace-validation.yml @@ -25,7 +25,7 @@ name: Workspace Validation # FAST_PLOTS=1 for user workspaces, PYAUTO_TEST_MODE=0 (real searches, # each script's own n_like_max caps) + full-res + real plots for # *_workspace_test (closes Gap B; see PyAutoHeart/docs/release_validation.md -# for the full table). Also runs `verify_install` A-E against the same +# for the full table). Also runs `verify_install` A-F against the same # wheels, and emits a `{"stage": "integrate", ...}` report # `pyauto-heart validate --ingest` understands. Skips notebook execution — # out of scope for M3, scripts are the release-validation surface. @@ -472,7 +472,8 @@ jobs: # --------------------------------------------------------------------------- # mode=release only, from here down. verify_install_release closes item 5 - # (verify_install A-E against the same wheels); emit_release_report closes + # (verify_install A-F against the same exact wheels, including the Python + # 3.11 Requires-Python rejection); emit_release_report closes # item 4 (the {"stage": "integrate", ...} report `pyauto-heart validate # --ingest` understands). Both are pure CI-side steps run with Heart's own # code, checked out from THIS repo — no dispatch, no other-repo mutation. @@ -485,7 +486,21 @@ jobs: steps: - name: Checkout PyAutoHeart uses: actions/checkout@v4 - - name: Run verify_install A-E against the TestPyPI wheels + # Check B invokes each explicit pythonX.Y binary in one job. setup-python + # prepends each toolcache interpreter without removing the earlier paths. + - name: Expose Python 3.11 for the below-floor rejection + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Expose supported Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Expose supported Python 3.13 + uses: actions/setup-python@v5 + with: + python-version: '3.13' + - name: Run verify_install A-F against the TestPyPI wheels env: TESTPYPI_VERSION: ${{ inputs.testpypi_version }} run: | diff --git a/bin/pyauto-heart b/bin/pyauto-heart index a1f083bd..805f4f5e 100755 --- a/bin/pyauto-heart +++ b/bin/pyauto-heart @@ -332,10 +332,11 @@ cmd_fix() { } help_verify_install() { cat < installs by explicit pin + F Colab bootstrap simulation + one real notebook cell + +Check B requires python3.11, python3.12, and python3.13 on PATH. A passing +--find-links run is development-only evidence and leaves readiness STALE; +PyPI/TestPyPI evidence is required for the release gate. Arguments are forwarded to the underlying check; see \`-h\` on the script. EOF diff --git a/docs/release_validation.md b/docs/release_validation.md index c01e97da..62813f17 100644 --- a/docs/release_validation.md +++ b/docs/release_validation.md @@ -20,7 +20,7 @@ untouched, default `mode: smoke` per-PR path): wheels at the rehearsed version and puts **no** library source on `PYTHONPATH`, still executing from inside the workspace checkout. - `verify_install_release` runs `heart/checks/verify_install.sh --testpypi - --version ` A–E against the same wheels. + --version ` A–F against the same wheels. - `emit_release_report` reshapes Build's `aggregate_results.py` report.json (via the new `heart/validate.py::to_stage_report` / `pyauto-heart validate --emit-stage-report`) into the `{"stage": "integrate", ...}` contract @@ -112,11 +112,24 @@ carries `profile` and `commit_shas`, so the gate can enforce them): `pip install` the wheels **but still execute scripts from within the workspace checkout** (for `config/` + `dataset/`), with no source on `PYTHONPATH`. -The integration run also performs `verify_install` A–E against the same wheels. -That result feeds the install-verification readiness leg (see "How the gate -enforces these"), tagged `index: testpypi` — it proves the wheels **about to -ship** install, which is the right evidence for a release gate, and is reported -as such rather than as proof that installing from PyPI works today. +The integration run also performs `verify_install` A–F against the same wheels. +Check B reuses that exact TestPyPI version: it must install and import on Python +3.12 and 3.13, while Python 3.11 must reject it specifically because its +`Requires-Python` metadata is `>=3.12`. An unpinned install is not sufficient +evidence because pip may select an older compatible release. + +That TestPyPI A–F result feeds the install-verification readiness leg (see +"How the gate enforces these"), tagged `index: testpypi`. It proves the wheels +**about to ship** install, which is the right evidence for a release gate, and +is reported as such rather than as proof that installing from PyPI works today. + +For pre-publication development, `verify_install B --version +--find-links ` exercises the same exact-version logic against local +wheels while retaining PyPI for third-party dependencies. Its sidecar is +labelled `index: find-links`, so it cannot be mistaken for PyPI or TestPyPI +release evidence. Heart retains a fresh passing local result as development +evidence but reports STALE until a PyPI or TestPyPI verification replaces it; +a failing local artifact remains RED. ## How the gate enforces these @@ -130,10 +143,12 @@ as such rather than as proof that installing from PyPI works today. The install-verification leg is separate and reads `~/.pyauto-heart/verify_install.json`, written either by a local `pyauto-heart -verify_install --report-json` run (`index: pypi`) or by `--ingest` folding the -block out of a Stage 3 artifact (`index: testpypi`). Both satisfy the leg; the -index is named in every reason line so the verdict states which install path it -actually verified. +verify_install --report-json` invocation (`index: pypi`, `testpypi`, or +`find-links`, according to its flags) or by `--ingest` folding the block out of +a Stage 3 artifact (`index: testpypi`). Both release indexes satisfy the leg; +the index is named in every reason line so the verdict states which install path +it actually verified. Development-only `index: find-links` evidence does not +satisfy this release gate. Before M3 (or if the Release Agent only runs the M1 rehearsal and skips dispatching `workspace-validation.yml` in `mode: release`), an ingested diff --git a/health_agent/capabilities.md b/health_agent/capabilities.md index 89fbe228..0241b30b 100644 --- a/health_agent/capabilities.md +++ b/health_agent/capabilities.md @@ -48,9 +48,10 @@ Audited at commit `a2543d0` (Rename PyAutoPulse to PyAutoHeart). **Deep** (slow, on-demand / cloud cron, never in the tick): -- **verify_install** (`checks/verify_install.sh`) — pip & conda install-path - checks A–E in throwaway envs across Python versions. RED if last run - `ready==false`; YELLOW if stale (`>14d`) or never run. Moved here from +- **verify_install** (`checks/verify_install.sh`) — pip, conda, and Colab + install-path checks A–F. Check B proves one exact release succeeds on Python + 3.12/3.13 and rejects on 3.11. RED if the last run has `ready==false`; STALE + if it is find-links-only, older than 14 days, or never run. Moved here from PyAutoHands — install verification is Heart's job. - **url_check / url_sweep / url_check_live** — offline regex guard, ecosystem sweep, and live HTTP reachability audit. **Monitoring only — never gates diff --git a/health_agent/capabilities.yaml b/health_agent/capabilities.yaml index b54bca7a..f42c0384 100644 --- a/health_agent/capabilities.yaml +++ b/health_agent/capabilities.yaml @@ -92,8 +92,8 @@ deep_checks: - id: verify_install impl: heart/checks/verify_install.sh cli: "pyauto-heart verify_install" - measures: "pip & conda install-path checks A-E in throwaway envs across Python versions" - gate_role: "RED if last run ready==false; YELLOW if stale (>14d) or never run" + measures: "pip, conda, and Colab install-path checks A-F; exact release succeeds on Python 3.12/3.13 and rejects on 3.11" + gate_role: "RED if last run ready==false; STALE if find-links-only, older than 14d, or never run" - id: url_check impl: heart/checks/url_check.sh cli: "pyauto-heart url_check [dir]" @@ -192,7 +192,7 @@ workflows: vs current library main, source-shadowed via PYTHONPATH; writes the report.json the test_run check + readiness consume. mode=release (Brain Release Agent dispatch only, M3): pip-installs the rehearsed TestPyPI wheels (no source on - PYTHONPATH) under the `release` env profile, runs verify_install A-E against + PYTHONPATH) under the `release` env profile, runs verify_install A-F against the same wheels, and emits the `release-stage-report` artifact `pyauto-heart validate --ingest` consumes. Reuses Build's executor primitives (script_matrix/run_python/aggregate_results) unmodified in both modes. diff --git a/heart/checks/verify_install.sh b/heart/checks/verify_install.sh index 01ef735b..11e9822f 100755 --- a/heart/checks/verify_install.sh +++ b/heart/checks/verify_install.sh @@ -11,7 +11,7 @@ # Runs a suite of independent install-path checks: # # A pip install autolens (default Python) + start_here.py + welcome.py -# B pip install autolens succeeds + imports on python3.9 / 3.10 / 3.11 / 3.13 +# B one exact autolens release installs on 3.12/3.13 and rejects on 3.11 # C conda install flow (python=3.12) + start_here.py + welcome.py # D pip install "autolens[optional]" resolves # E pip install autolens==2026.2.26.4 still installs by explicit pin @@ -25,13 +25,18 @@ # verify_install # run all checks # verify_install A # run a single check # verify_install A C E # run a subset -# verify_install --version 2026.4.5.2 # pin a specific PyPI version (A/C/D) +# verify_install --version 2026.4.5.2 # pin a specific PyPI version (A/B/C/D) # verify_install --testpypi # install from test.pypi.org (pre-release rehearsal) +# verify_install --find-links dist/ # prefer exact locally-built wheels # verify_install --keep # don't clean up at the end # verify_install -h | --help set -uo pipefail # NB: no -e — checks must continue past expected failures. +VERIFY_INSTALL_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=verify_install_helpers.sh +source "$VERIFY_INSTALL_DIR/verify_install_helpers.sh" + # Unset PYTHONPATH so checks aren't shadowed by user-side editable installs. # When the calling shell exports PYTHONPATH=/path/to/PyAutoNerves:/path/to/... # (a common setup when developing the libs), throwaway venvs created here @@ -48,11 +53,13 @@ usage() { verify_install — release-readiness gate for PyAutoLens. Usage: - verify_install [CHECKS...] [--version VERSION] [--testpypi] [--keep] [-h] + verify_install [CHECKS...] [--version VERSION] [--testpypi] + [--find-links DIR] [--keep] [-h] Checks: A pip install autolens (default python3) + start_here.py + welcome.py - B pip install autolens succeeds + imports on python3.9, 3.10, 3.11, 3.13 + B one exact autolens release installs on python3.12 and python3.13, + while python3.11 rejects it because Requires-Python is >=3.12 C conda install flow (python=3.12) + start_here.py + welcome.py D pip install "autolens[optional]" resolves and imports E pip install autolens==2026.2.26.4 (yanked) installs by explicit pin @@ -62,14 +69,18 @@ Checks: Default: run all checks. Options: - --version VERSION Pin a specific PyPI version (applies to A, C, D). + --version VERSION Pin a specific PyPI version (applies to A, B, C, D). --testpypi Install from test.pypi.org with PyPI as a fallback for - non-PyAuto deps (applies to A, C, D, E). Use this for a + non-PyAuto deps (applies to A, B, C, D, E). Use this for a pre-release rehearsal against a TestPyPI dry-run upload. + --find-links DIR Prefer wheel artifacts in DIR while retaining the selected + index for third-party dependencies. Evidence is labelled + find-links, never PyPI/TestPyPI. Useful before publication. --keep Don't clean up venvs / conda envs / clones at the end. - --report-json PATH Also write a machine-readable {ts,ready,version,index, - checks} JSON sidecar to PATH (consumed by pyauto-heart - readiness; `index` is testpypi or pypi). + --report-json PATH Also write a machine-readable {ts,ready,version, + check_b_version,index,checks} JSON sidecar to PATH + (consumed by pyauto-heart readiness; `index` is pypi, + testpypi, or find-links). -h, --help Show this help. USAGE } @@ -79,6 +90,7 @@ USAGE TARGET_VERSION="" KEEP=0 USE_TESTPYPI=0 +FIND_LINKS="" REPORT_JSON="" REQUESTED_CHECKS=() @@ -100,6 +112,14 @@ while [ $# -gt 0 ]; do USE_TESTPYPI=1 shift ;; + --find-links) + if [ $# -lt 2 ]; then + echo "verify_install: --find-links requires a directory" >&2 + exit 2 + fi + FIND_LINKS="$2" + shift 2 + ;; --keep) KEEP=1 shift @@ -124,6 +144,14 @@ while [ $# -gt 0 ]; do esac done +if [ -n "$FIND_LINKS" ]; then + if [ ! -d "$FIND_LINKS" ]; then + echo "verify_install: --find-links is not a directory: $FIND_LINKS" >&2 + exit 2 + fi + FIND_LINKS=$(cd "$FIND_LINKS" && pwd) +fi + # When --testpypi is set, route every PyAuto-package pip install through # TestPyPI as the primary index and fall back to PyPI for transitive deps not # mirrored there (matplotlib, scipy, nufftax, jax, etc.). Cleared otherwise — @@ -135,6 +163,9 @@ PIP_INDEX_ARGS=() if [ "$USE_TESTPYPI" -eq 1 ]; then PIP_INDEX_ARGS=(--index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/) fi +if [ -n "$FIND_LINKS" ]; then + PIP_INDEX_ARGS+=(--find-links "$FIND_LINKS") +fi if [ ${#REQUESTED_CHECKS[@]} -eq 0 ]; then REQUESTED_CHECKS=(all) @@ -261,21 +292,24 @@ print(f'autonerves: {autonerves.__version__}') fi } -# ----- check B: install + import on every supported python version ----- +# ----- check B: exact-release support floor ----- # -# requires-python = ">=3.9", classifiers cover 3.9–3.13. 3.12 / 3.13 are the -# recommended versions; 3.9 / 3.10 / 3.11 print a loud (bypassable) banner on -# autonerves import. Check B confirms install + import works on each of -# 3.9 / 3.10 / 3.11 / 3.13. Check A covers the recommended-default-python -# path with full workspace script execution (typically python3 = 3.12). +# The 3.12 run resolves the current release when --version is absent; every +# later cell reuses that exact version. This is essential on 3.11: an unpinned +# `pip install autolens` may legitimately select an older compatible wheel, +# which is migration fallback rather than evidence that the new release accepts +# 3.11. A rejected install passes only when pip explicitly reports the +# Requires-Python constraint — index/network/resolver failures stay failures. -check_b_one() { +CHECK_B_VERSION="$TARGET_VERSION" + +check_b_supported() { local pybin="$1" local label="${pybin#python}" if ! command -v "$pybin" > /dev/null 2>&1; then - step "$pybin not installed — SKIP" - RESULTS+=("B|SKIP|$pybin not installed") + step "$pybin not installed — FAIL (required Check B interpreter)" + RESULTS+=("B|FAIL|$pybin not installed") return fi @@ -292,23 +326,37 @@ check_b_one() { source "$venv/bin/activate" pip install --upgrade pip > /dev/null 2>&1 || true - step "$pybin: pip install $PIP_INSTALL_TARGET" + local install_target="autolens" + if [ -n "$CHECK_B_VERSION" ]; then + install_target="autolens==$CHECK_B_VERSION" + fi + + step "$pybin: pip install $install_target" local pip_out pip_rc=0 - pip_out=$(pip install "${PIP_INDEX_ARGS[@]}" "$PIP_INSTALL_TARGET" 2>&1) || pip_rc=$? + pip_out=$(pip install "${PIP_INDEX_ARGS[@]}" "$install_target" 2>&1) || pip_rc=$? if [ "$pip_rc" -ne 0 ]; then - RESULTS+=("B|FAIL|$pybin pip install failed (rc=$pip_rc)") + RESULTS+=("B|FAIL|$pybin pip install $install_target failed (rc=$pip_rc)") tail_log "Check B ($pybin) pip output" "$pip_out" deactivate return fi step "$pybin: importing autolens, autogalaxy, autoarray, autofit, autonerves" - local import_out import_rc=0 + local import_out import_rc=0 installed_version="" versions_equivalent=1 import_out=$(python -c " import autolens, autogalaxy, autoarray, autofit, autonerves print(f'autolens={autolens.__version__}') " 2>&1) || import_rc=$? + if [ "$import_rc" -eq 0 ]; then + installed_version=$(python -c \ + 'from importlib.metadata import version; print(version("autolens"))') + if [ -n "$installed_version" ] && [ -n "$CHECK_B_VERSION" ] \ + && ! verify_install_versions_equivalent \ + python "$installed_version" "$CHECK_B_VERSION"; then + versions_equivalent=0 + fi + fi deactivate printf '%s\n' "$import_out" | sed 's/^/ /' @@ -318,30 +366,72 @@ print(f'autolens={autolens.__version__}') tail_log "Check B ($pybin) import output" "$import_out" return fi + if [ -z "$installed_version" ]; then + RESULTS+=("B|FAIL|$pybin could not read installed autolens metadata version") + return + fi - # Soft banner check on non-recommended versions (3.9 / 3.10 / 3.11). - # The banner copy may evolve, so banner-missing is reported in the detail - # line but does not flip PASS to FAIL. - local detail="$pybin install + import OK" - case "$label" in - 3.9|3.10|3.11) - if printf '%s' "$import_out" | grep -qiE "recommended.*python|python.*version.*recommend"; then - detail="$detail (banner present)" - else - detail="$detail (no banner detected)" - fi - ;; - esac - RESULTS+=("B|PASS|$detail") + if [ "$versions_equivalent" -ne 1 ]; then + RESULTS+=("B|FAIL|$pybin installed $installed_version, expected $CHECK_B_VERSION") + return + fi + # pip accepted the exact specifier above. Retain its canonical metadata + # spelling so every later interpreter reuses one byte-identical pin even + # when the user supplied a PEP 440-equivalent spelling such as 2026.07. + CHECK_B_VERSION="$installed_version" + RESULTS+=("B|PASS|$pybin installed + imported autolens==$installed_version") +} + +check_b_rejected() { + local pybin="python3.11" + + if ! command -v "$pybin" > /dev/null 2>&1; then + step "$pybin not installed — FAIL (required floor-rejection interpreter)" + RESULTS+=("B|FAIL|$pybin not installed") + return + fi + if [ -z "$CHECK_B_VERSION" ]; then + RESULTS+=("B|FAIL|no exact autolens version resolved for $pybin rejection") + return + fi + + local venv="/tmp/autolens_verify_B_reject_3.11_$TS" + local install_target="autolens==$CHECK_B_VERSION" + ARTEFACTS+=("$venv") + + step "$pybin: creating rejection venv at $venv" + if ! make_venv "$venv" "$pybin"; then + RESULTS+=("B|FAIL|$pybin could not create venv") + return + fi + + # shellcheck source=/dev/null + source "$venv/bin/activate" + pip install --upgrade pip > /dev/null 2>&1 || true + + step "$pybin: expecting Requires-Python rejection for $install_target" + local pip_out pip_rc=0 + pip_out=$(pip install "${PIP_INDEX_ARGS[@]}" "$install_target" 2>&1) || pip_rc=$? + deactivate + + if [ "$pip_rc" -eq 0 ]; then + RESULTS+=("B|FAIL|$pybin unexpectedly installed $install_target") + return + fi + if verify_install_requires_python_rejection "$pip_out" "$CHECK_B_VERSION"; then + RESULTS+=("B|PASS|$pybin rejected $install_target (Requires-Python >=3.12)") + else + RESULTS+=("B|FAIL|$pybin install failed without a Requires-Python rejection (rc=$pip_rc)") + tail_log "Check B ($pybin) unexpected pip output" "$pip_out" + fi } check_b() { echo - echo "=== Check B: install + import on python3.9 / 3.10 / 3.11 / 3.13 ===" - check_b_one python3.9 - check_b_one python3.10 - check_b_one python3.11 - check_b_one python3.13 + echo "=== Check B: exact release on 3.12/3.13; rejected on 3.11 ===" + check_b_supported python3.12 + check_b_supported python3.13 + check_b_rejected } # ----- check C: conda flow ----- @@ -696,9 +786,16 @@ if [ -n "$REPORT_JSON" ]; then # proves the about-to-ship wheels install; it says nothing about the current # PyPI release. Readiness reports the index rather than flattening the two, # so the verdict never claims more than was verified. - if [ "$USE_TESTPYPI" -eq 1 ]; then vi_index=testpypi; else vi_index=pypi; fi + if [ -n "$FIND_LINKS" ]; then + vi_index=find-links + elif [ "$USE_TESTPYPI" -eq 1 ]; then + vi_index=testpypi + else + vi_index=pypi + fi printf '%s\n' "${RESULTS[@]}" | \ - VI_READY="$ready_bool" VI_VERSION="$TARGET_VERSION" VI_REPORT_JSON="$REPORT_JSON" \ + VI_READY="$ready_bool" VI_VERSION="$TARGET_VERSION" VI_CHECK_B_VERSION="$CHECK_B_VERSION" \ + VI_REPORT_JSON="$REPORT_JSON" \ VI_INDEX="$vi_index" \ python3 -c ' import datetime, json, os, sys @@ -713,6 +810,7 @@ out = { "ts": datetime.datetime.now(datetime.timezone.utc).isoformat(), "ready": os.environ["VI_READY"] == "true", "version": os.environ.get("VI_VERSION") or None, + "check_b_version": os.environ.get("VI_CHECK_B_VERSION") or None, "index": os.environ.get("VI_INDEX") or "pypi", "checks": checks, } diff --git a/heart/checks/verify_install_helpers.sh b/heart/checks/verify_install_helpers.sh new file mode 100644 index 00000000..b7393629 --- /dev/null +++ b/heart/checks/verify_install_helpers.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# Pure helpers shared by verify_install.sh and its fast classifier tests. + +verify_install_requires_python_rejection() { + local pip_output="$1" + local version="$2" + + # Local-wheel path: pip has built a candidate and names the package in its + # candidate-level Requires-Python diagnostic. + if printf '%s\n' "$pip_output" | grep -qiE \ + "package ['\"]?autolens['\"]? requires a different python(:| version)[^[:cntrl:]]*>= ?3\\.12"; then + return 0 + fi + + # Index path: PyPI/TestPyPI exposes data-requires-python, so pip filters the + # link before candidacy. Its diagnostic splits the constraint and requested + # package across lines; require the exact pinned version in both places so a + # network/resolver/dependency failure cannot be mistaken for floor evidence. + if printf '%s\n' "$pip_output" | grep -qi \ + "Ignored the following versions that require a different python version:" \ + && printf '%s\n' "$pip_output" | grep -Fqi \ + "$version Requires-Python >=3.12" \ + && printf '%s\n' "$pip_output" | grep -Fqi \ + "autolens==$version"; then + return 0 + fi + + return 1 +} + +verify_install_versions_equivalent() { + local pybin="$1" + local left="$2" + local right="$3" + + "$pybin" - "$left" "$right" <<'PY' +import sys +from pip._vendor.packaging.version import InvalidVersion, Version + +try: + equivalent = Version(sys.argv[1]) == Version(sys.argv[2]) +except InvalidVersion: + equivalent = False +raise SystemExit(0 if equivalent else 1) +PY +} diff --git a/heart/dashboard.py b/heart/dashboard.py index 546ded62..2a2f4f03 100644 --- a/heart/dashboard.py +++ b/heart/dashboard.py @@ -518,14 +518,26 @@ def build_board( # Install verification --------------------------------------------------- vi = snapshot.get("verify_install") or {} if isinstance(vi, dict) and "ready" in vi: + index = str(vi.get("index") or "index unknown") if vi.get("ready") is False: fails = [c.get("check") for c in (vi.get("checks") or []) if str(c.get("status")).upper() == "FAIL"] - summary = f"FAILED ({', '.join(map(str, fails)) or '?'}) ({vi.get('ts', '?')})" + summary = ( + f"FAILED ({index}; {', '.join(map(str, fails)) or '?'}) " + f"({vi.get('ts', '?')})" + ) sections.append(Section("verify_install", "Install verify", FAIL, summary, [])) + elif index == "find-links": + sections.append(Section( + "verify_install", + "Install verify", + WARN, + f"development-only (find-links; last run {vi.get('ts', '?')})", + [], + )) else: sections.append(Section("verify_install", "Install verify", OK, - f"passed (last run {vi.get('ts', '?')})", [])) + f"passed ({index}; last run {vi.get('ts', '?')})", [])) # Release validation ----------------------------------------------------- vr = validation if isinstance(validation, dict) and validation else (snapshot.get("validation_report") or {}) diff --git a/heart/readiness.py b/heart/readiness.py index 6fff40b9..322630ed 100644 --- a/heart/readiness.py +++ b/heart/readiness.py @@ -122,6 +122,7 @@ "skew_bad": (25, 50), "skew_unknown": (10, 30), "install_not_ready": (40, 40), + "install_non_release": (10, 10), "install_stale": (10, 10), "install_unknown": (10, 10), "test_stale": (10, 10), @@ -388,6 +389,10 @@ def scope_local(msg: str, key: str) -> None: # (human decision, 2026-07-15). The index is named in every reason line so # the verdict states which install path it actually verified — a TestPyPI # pass must never silently read as proof that installing from PyPI works. + # Development-only `find-links` evidence is useful before publication but + # cannot satisfy a release gate: a pass stays STALE until PyPI/TestPyPI is + # exercised. A failure remains RED because an exact local artifact failing + # its install contract is still actionable evidence. vi = snapshot.get("verify_install") if isinstance(vi, dict) and "ready" in vi: index = str(vi.get("index") or "index unknown") @@ -401,6 +406,12 @@ def scope_local(msg: str, key: str) -> None: f"install verification FAILED ({index}; checks {', '.join(failed) or '?'})" ) hit("install_not_ready") + elif index == "find-links": + stale.append( + "install verification development-only (find-links; " + "PyPI/TestPyPI evidence required)" + ) + hit("install_non_release") else: age = _age_days(vi.get("ts"), ref) if age is None or age > INSTALL_STALE_DAYS: diff --git a/heart/validate.py b/heart/validate.py index b1bccadc..0a3df408 100644 --- a/heart/validate.py +++ b/heart/validate.py @@ -447,7 +447,9 @@ def normalize_verify_install(sidecar: Any) -> dict[str, Any] | None: ``index`` records which package index the wheels came from. A ``--testpypi`` run proves the about-to-ship wheels install; it is not evidence about the current PyPI release. Sidecars written before this field existed carry no - index, which stays ``None`` (unknown) rather than being guessed at. + index, which stays ``None`` (unknown) rather than being guessed at. A + ``find-links`` run is development-only evidence; preserving that provenance + lets readiness keep a pass STALE instead of laundering it into release proof. """ if not isinstance(sidecar, dict) or "ready" not in sidecar: return None @@ -466,6 +468,7 @@ def normalize_verify_install(sidecar: Any) -> dict[str, Any] | None: "ts": sidecar.get("ts"), "ready": sidecar.get("ready") is True, "version": sidecar.get("version"), + "check_b_version": sidecar.get("check_b_version"), "index": str(index) if index else None, "checks": checks, } @@ -495,7 +498,7 @@ def to_stage_report( it can be ingested by ``run``/``ingest`` unmodified. Pure — no I/O. ``force_fail`` lets the caller fold a result Build's aggregate step knows - nothing about (e.g. ``verify_install`` A-E against the same wheels) into the + nothing about (e.g. ``verify_install`` A-F against the same wheels) into the stage's pass/fail axis without inventing a second stage. ``verify_install`` carries that same sidecar through as *evidence* rather diff --git a/skills/verify_install/verify_install.md b/skills/verify_install/verify_install.md index 57a39352..176b3787 100644 --- a/skills/verify_install/verify_install.md +++ b/skills/verify_install/verify_install.md @@ -14,14 +14,15 @@ about cleanup if they ran with `--keep`. | Check | What it verifies | |-------|------------------| | A | `pip install autolens` in a venv on default `python3`; `start_here.py` and `welcome.py` both run cleanly. | -| B | `pip install autolens` succeeds and imports cleanly on `python3.9`, `python3.10`, `python3.11`, and `python3.13` — each in its own throwaway venv. Confirms the `requires-python = ">=3.9"` floor and that 3.12-only assumptions have not crept in. The loud "recommended Python version" banner is checked softly on 3.9 / 3.10 / 3.11 (banner-missing is reported in the detail line but does not fail the check, since the banner copy may evolve). | +| B | One exact `autolens` version installs and imports cleanly on `python3.12` and `python3.13`, then the same exact version is rejected by `python3.11` specifically because `Requires-Python` is `>=3.12`. An unpinned 3.11 install is not evidence because pip may select an older compatible release. | | C | The conda flow from `installation/conda.rst` works end-to-end (`conda create … python=3.12` → `pip install autolens` → clone workspace → run `welcome.py` + `start_here.py`). | | D | `pip install "autolens[optional]"` resolves cleanly and imports. | | E | `pip install autolens==2026.2.26.4` (a yanked release the docs reference) still installs by explicit pin. | | F | The Colab bootstrap path end-to-end: a venv emulating Colab's preinstalled env (`autolens` + `jax` from PyPI), a fake `google.colab` package so the on-Colab branch activates, then the injected setup cell verbatim (`pip install autoconf --no-deps` → `setup_colab.setup("autolens")` → workspace clone at the release tag) and one real notebook cell (`al.Imaging.from_fits` on `dataset/imaging/simple`). SKIPs while the installed autoconf predates the `setup_colab` registry (self-activates at the next release). | -A check that cannot run on the current host (interpreter missing, conda missing) is -reported as **SKIP** and does not count toward overall failure. +The three Check B interpreters are required evidence: a missing `python3.11`, +`python3.12`, or `python3.13` is **FAIL**. Optional host capabilities such as +conda remain **SKIP** when unavailable and do not count toward overall failure. ## Running without a skill harness @@ -34,7 +35,10 @@ with PyAutoHands on PATH.) pyauto-heart verify_install # run all checks (default) pyauto-heart verify_install A # run a single check pyauto-heart verify_install A C E # run a subset -pyauto-heart verify_install --version 2026.4.5.2 # pin a specific PyPI version (applies to A/C/D) +pyauto-heart verify_install --version 2026.4.5.2 # pin a specific version (applies to A/B/C/D) +pyauto-heart verify_install --testpypi # TestPyPI rehearsal; PyPI fallback for third-party deps +pyauto-heart verify_install B --version 1.0.dev0 --find-links dist/ + # local-wheel development evidence pyauto-heart verify_install --keep # don't clean up at the end pyauto-heart verify_install --help ``` @@ -58,6 +62,11 @@ pyauto-heart verify_install pyauto-heart verify_install --version ``` +Use `--testpypi` for a pre-release rehearsal. Use `--find-links ` +for local artifacts; its sidecar is labelled `index: find-links`, so even a +passing result remains STALE until PyPI or TestPyPI evidence replaces it. A +failing local artifact remains RED. + If the user only wants a specific check (e.g. "just re-run the conda check"), pass the letter: @@ -71,7 +80,7 @@ The script prints a results table and any failure detail to stdout, then cleans Show the user the **table** verbatim and call out: - which checks PASSed, -- which were SKIPped (and why — usually a missing interpreter or conda), +- which were SKIPped (and why — for example, conda is unavailable), - which FAILed (with the captured stderr expanded inline). ### 3. Cleanup diff --git a/tests/test_dashboard.py b/tests/test_dashboard.py index 98186fd0..26c885c5 100644 --- a/tests/test_dashboard.py +++ b/tests/test_dashboard.py @@ -149,6 +149,36 @@ def test_fresh_board_not_stale(): assert board.stale is False +def test_find_links_install_pass_is_warned_as_development_only(): + snap = make_snapshot(verify_install={ + "ready": True, + "index": "find-links", + "ts": TS, + "checks": [{"check": "B", "status": "PASS"}], + }) + + board = dashboard.build_board(snap, make_verdict("stale", 90), now=FRESH_NOW) + section = next(s for s in board.sections if s.key == "verify_install") + + assert section.state == dashboard.WARN + assert "development-only (find-links" in section.summary + + +def test_release_install_pass_names_the_index(): + snap = make_snapshot(verify_install={ + "ready": True, + "index": "testpypi", + "ts": TS, + "checks": [{"check": "B", "status": "PASS"}], + }) + + board = dashboard.build_board(snap, make_verdict(), now=FRESH_NOW) + section = next(s for s in board.sections if s.key == "verify_install") + + assert section.state == dashboard.OK + assert "passed (testpypi" in section.summary + + # --- cloud-only-honest / unobserved path ------------------------------------ def test_cloud_marks_local_only_checks_unobserved(): snap = make_snapshot() diff --git a/tests/test_readiness.py b/tests/test_readiness.py index e1df623b..3e801270 100644 --- a/tests/test_readiness.py +++ b/tests/test_readiness.py @@ -176,6 +176,24 @@ def test_install_verification_fresh_pass_is_green(): assert not any("install" in r for r in v["reasons"]) +def test_find_links_install_evidence_cannot_satisfy_release_gate(): + snap = make_snapshot(verify_install={ + "ready": True, + "ts": "2026-06-01T00:00:00+00:00", + "index": "find-links", + "checks": [{"check": "B", "status": "PASS"}], + }) + + v = compute(snap) + + assert v["verdict"] == "stale" + assert v["score"] == 90 + assert any( + "development-only (find-links" in reason + for reason in v["stale_reasons"] + ) + + def test_install_verification_reasons_name_the_index(): """A testpypi pass must never read as proof that installing from PyPI works. diff --git a/tests/test_validate.py b/tests/test_validate.py index 0978ec27..a1dd7f88 100644 --- a/tests/test_validate.py +++ b/tests/test_validate.py @@ -429,7 +429,7 @@ def test_run_out_override(tmp_path, monkeypatch): # --- verify_install: carried as evidence, not only as a veto ---------------- # -# Stage 3 has always run verify_install A-E against the wheels, but the sidecar +# Stage 3 has always run verify_install A-F against the wheels, but the sidecar # was consulted only in the failure direction, so a PASS contributed nothing and # the readiness leg reported "install verification not run" forever. These cover # the carry + persist path that closes that gap. @@ -438,6 +438,7 @@ def test_run_out_override(tmp_path, monkeypatch): "ts": "2026-07-15T10:00:00+00:00", "ready": True, "version": "2026.7.15.1.dev66201", + "check_b_version": "2026.7.15.1.dev66201", "index": "testpypi", "checks": [ {"check": "A", "status": "PASS", "detail": "pip install + start_here.py"}, @@ -459,6 +460,7 @@ def test_normalize_verify_install_keeps_index_and_coerces_ready(): vi = validate.normalize_verify_install(VERIFY_INSTALL_PASS) assert vi["ready"] is True assert vi["index"] == "testpypi" + assert vi["check_b_version"] == "2026.7.15.1.dev66201" assert vi["version"] == "2026.7.15.1.dev66201" assert [c["check"] for c in vi["checks"]] == ["A", "C"] # Strict: only a real True is a pass (a stray truthy string is not). diff --git a/tests/test_verify_install_script.py b/tests/test_verify_install_script.py index c956a94f..cc6caba1 100644 --- a/tests/test_verify_install_script.py +++ b/tests/test_verify_install_script.py @@ -8,7 +8,16 @@ import subprocess from pathlib import Path +import yaml + SCRIPT = Path(__file__).resolve().parent.parent / "heart" / "checks" / "verify_install.sh" +HELPERS = SCRIPT.with_name("verify_install_helpers.sh") +WORKFLOW = ( + Path(__file__).resolve().parent.parent + / ".github" + / "workflows" + / "workspace-validation.yml" +) def run(*args): @@ -17,11 +26,29 @@ def run(*args): ) -def test_bash_syntax(): - result = subprocess.run( - ["bash", "-n", str(SCRIPT)], capture_output=True, text=True +def classify_rejection(output, version="2026.7.29.1"): + return subprocess.run( + [ + "bash", + "-c", + 'source "$1"; pip_output=$(cat); ' + 'verify_install_requires_python_rejection "$pip_output" "$2"', + "classifier", + str(HELPERS), + version, + ], + input=output, + capture_output=True, + text=True, ) - assert result.returncode == 0, result.stderr + + +def test_bash_syntax(): + for path in (SCRIPT, HELPERS): + result = subprocess.run( + ["bash", "-n", str(path)], capture_output=True, text=True + ) + assert result.returncode == 0, result.stderr def test_help_lists_all_checks_including_colab_simulation(): @@ -55,12 +82,136 @@ def test_sidecar_records_the_package_index(): # installing from PyPI works. Static check: running the writer for real means # a venv + a PyPI install, which this file deliberately never does. text = SCRIPT.read_text() - assert 'vi_index=testpypi; else vi_index=pypi' in text + assert "vi_index=find-links" in text + assert "vi_index=testpypi" in text + assert "vi_index=pypi" in text assert 'VI_INDEX="$vi_index"' in text + assert 'VI_CHECK_B_VERSION="$CHECK_B_VERSION"' in text assert '"index": os.environ.get("VI_INDEX") or "pypi",' in text + assert '"check_b_version": os.environ.get("VI_CHECK_B_VERSION") or None,' in text def test_help_documents_the_sidecar_index(): result = run("--help") assert result.returncode == 0 assert "index" in result.stdout + + +def test_find_links_is_documented_and_missing_directory_is_rejected(): + help_result = run("--help") + missing_result = run("B", "--find-links", "/definitely/missing/wheels") + + assert "--find-links DIR" in help_result.stdout + assert "Evidence is labelled" in help_result.stdout + assert missing_result.returncode == 2 + assert "is not a directory" in missing_result.stderr + + +def test_check_b_uses_the_new_floor_contract(): + text = SCRIPT.read_text() + + assert "check_b_supported python3.12" in text + assert "check_b_supported python3.13" in text + assert "check_b_rejected" in text + assert "python3.9" not in text + assert "python3.10" not in text + assert "banner present" not in text + assert "no banner detected" not in text + + +def test_check_b_reuses_one_exact_version_and_classifies_rejection(): + text = SCRIPT.read_text() + + assert 'CHECK_B_VERSION="$TARGET_VERSION"' in text + assert 'install_target="autolens==$CHECK_B_VERSION"' in text + assert "verify_install_requires_python_rejection" in text + assert "verify_install_versions_equivalent" in text + assert "failed without a Requires-Python rejection" in text + + +def test_version_comparison_runs_before_supported_venv_deactivation(): + text = SCRIPT.read_text() + body = text[ + text.index("check_b_supported()") : text.index("check_b_rejected()") + ] + comparison = body.index("&& ! verify_install_versions_equivalent") + deactivate_after_comparison = body.index("\n deactivate\n", comparison) + + assert comparison < deactivate_after_comparison + + +def test_rejection_classifier_accepts_candidate_and_index_pip_forms(): + candidate_output = ( + "ERROR: Package 'autolens' requires a different Python: " + "3.11.9 not in '>=3.12'\n" + ) + index_output = ( + "ERROR: Ignored the following versions that require a different " + "python version: 2026.7.29.1 Requires-Python >=3.12\n" + "ERROR: Could not find a version that satisfies the requirement " + "autolens==2026.7.29.1 (from versions: none)\n" + ) + + assert classify_rejection(candidate_output).returncode == 0 + assert classify_rejection(index_output).returncode == 0 + + +def test_rejection_classifier_rejects_unrelated_pip_failures(): + network_failure = ( + "WARNING: Retrying after connection broken by NewConnectionError\n" + "ERROR: No matching distribution found for autolens==2026.7.29.1\n" + ) + dependency_conflict = ( + "ERROR: Cannot install autolens==2026.7.29.1 because these package " + "versions have conflicting dependencies.\n" + ) + wrong_floor = ( + "ERROR: Package 'autolens' requires a different Python: " + "3.11.9 not in '>=3.13'\n" + ) + + for output in (network_failure, dependency_conflict, wrong_floor): + assert classify_rejection(output).returncode != 0 + + +def test_pep440_equivalent_versions_compare_equal(): + result = subprocess.run( + [ + "bash", + "-c", + 'source "$1"; verify_install_versions_equivalent python3 "$2" "$3"', + "versions", + str(HELPERS), + "2026.07.028.1", + "2026.7.28.1", + ], + capture_output=True, + text=True, + ) + + assert result.returncode == 0, result.stderr + + +def test_release_workflow_exposes_every_required_check_b_interpreter(): + jobs = yaml.safe_load(WORKFLOW.read_text())["jobs"] + steps = jobs["verify_install_release"]["steps"] + run_index = next( + index for index, step in enumerate(steps) + if step.get("name") == "Run verify_install A-F against the TestPyPI wheels" + ) + setup_versions = [ + str(step.get("with", {}).get("python-version")) + for index, step in enumerate(steps) + if index < run_index and step.get("uses") == "actions/setup-python@v5" + ] + + assert setup_versions == ["3.11", "3.12", "3.13"] + + +def test_help_describes_supported_success_and_below_floor_rejection(): + result = run("--help") + + assert result.returncode == 0 + assert "installs on python3.12 and python3.13" in result.stdout + assert "python3.11 rejects it because Requires-Python is >=3.12" in result.stdout + assert "applies to A, B, C, D" in result.stdout