diff --git a/REFERENCE.md b/REFERENCE.md index da6b28f6..ee466d96 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -29,6 +29,7 @@ Tests: `pytest tests/`. | `logs` | tail the daemon log | operational | | `fix` | emit a Claude remediation bundle (`ci`/`dirty`/`drift`/`timing`) | remediation entry point | | `validate` | ingest release-validation artifacts into `validation_report.json` | release rehearsal evidence | +| `freeze` | set/clear the release-validation freeze flag (`--set/--until/--clear/--show`) | the validation window, made visible | | `smoke` | isolated local workspace smoke suites | deep validation | | `verify_install` | deep pip/conda install-path check (slow) | deep readiness signal | | `url_check` / `url_sweep` | offline URL-hygiene guard / ecosystem sweep | monitoring only | @@ -119,6 +120,49 @@ back to grey after 48 h (`DEVBOX_FRESH_SECONDS`). `red > yellow > stale > green`. The `score` (0–100) is advisory/sortable only — the colour is the gate. Persisted to `~/.pyauto-heart/release_ready.json`. +## The release freeze window (`freeze`) + +A release validation is a window in which the library `main` branches must not +move: a merge landing mid-validation invalidates the evidence and restales the +rehearsal (~75 minutes, measured 2026-08-29). `pyauto-heart freeze` is the flag +that says so out loud. + +- **The file.** `$HEART_STATE_DIR/freeze.json` — `{reason, set_at, until, + set_by}`, written atomically like every other sidecar. Heart is the only + writer. +- **The verb.** `freeze --set "" --until <90m|2h|1d|ISO-8601> + [--set-by WHO]`, `freeze --clear`, `freeze --show [--json]` (the default + action). `--until` is **mandatory**: a freeze with no expiry never clears. +- **Expiry.** Past `until` the flag reads as clear for every consumer, while + `--show` reports it as `expired` — a forgotten set stays visible instead of + vanishing. An unreadable or expiry-less file also reads as clear: a freeze + nobody can parse must not be able to block a merge. +- **Exit codes.** A *read* exits `3` while a freeze is active (so + `pyauto-heart freeze --show` is a one-call shell gate), `0` when clear or + expired, `2` on a usage error. `--set` always exits `0`, so a driver under + `set -e` does not abort on the freeze it just took out. + +**It is not part of the readiness verdict, deliberately.** `heart/readiness.py` +never reads it. A freeze is not a health problem, and folding it into the +colour would make every ship and release gate in the organism block on it. It +is advice — with teeth in exactly one place. + +### Who sets it, who clears it, who reads it + +| Call site | What it does | +|---|---| +| `PyAutoHands/skills/pre_build/pre_build.md` | **sets** it before dispatching the release workflow — the window opens there | +| `pyauto-heart validate --ingest` | **clears** it: the ingest of the evidence *is* the end of the window (never on `--out`, which is an inspection path) | +| `PyAutoHeart/skills/review_release/review_release.md` | checks it while triaging the run and **clears** a freeze the ingest did not | +| expiry | clears it on its own if none of the above happens | +| the scheduled nightly release run (`PyAutoBrain/agents/conductors/release/nightly.sh` → Hands `release.yml`) | **not wired**: it runs unattended in CI, where this dev-box state file does not exist. Set the freeze on the dev box if a nightly run's window needs to be visible locally; wiring CI would need the flag to live somewhere both can see, which is a bigger change than this one | + +Readers are all in PyAutoBrain and all read-only: the `vitals` faculty prints +`FROZEN: until ` as a warning line, `/prm` refuses to merge a +**library** repo's PR while it is active (`--thaw` overrides, logged to +`PyAutoMind/autonomy_log.md`), and `batch collect` carries one line. Organ and +workspace repos are not gated, and no other skill blocks on it. + ## GitHub workflows (`.github/workflows/`) - **heart-health.yml** — daily cloud sweep; renders + publishes the Pages @@ -136,8 +180,9 @@ the colour is the gate. Persisted to `~/.pyauto-heart/release_ready.json`. ## State (`~/.pyauto-heart/`) `state.json` (aggregated snapshot), `release_ready.json` (the verdict), -`validation_report.json`, per-repo sidecars, rolling `timings/`, -`url_check.json`, `verify_install.json`, daemon `heart.pid`, `logs/heart.log`. +`validation_report.json`, `freeze.json` (the release freeze window), per-repo +sidecars, rolling `timings/`, `url_check.json`, `verify_install.json`, daemon +`heart.pid`, `logs/heart.log`. ## Internals diff --git a/bin/pyauto-heart b/bin/pyauto-heart index 455de2c4..2d7fb4bd 100755 --- a/bin/pyauto-heart +++ b/bin/pyauto-heart @@ -28,6 +28,7 @@ SUBCOMMAND_ORDER=( fix "# Release validation (ingest-and-judge only; never dispatches a build)" validate + freeze "# Deep checks (on-demand; too slow for the tick)" smoke verify_install @@ -48,6 +49,7 @@ declare -A SHORT_DESC=( [dashboard]="The unified health board (--oneline/--md/--html/--json); reads cache, no tick" [publish]="Push a distilled dev-box board into the repo so the cloud page fills its grey rows" [validate]="Ingest release-validation artifacts into validation_report.json" + [freeze]="Set/clear the release-validation freeze flag (library mains should not move)" [smoke]="Prepare isolated local environments and run workspace smoke suites" [logs]="Tail the daemon log" [fix]="Bundle context for a specific topic and emit a Claude command" @@ -301,6 +303,40 @@ cmd_validate() { exec env PYTHONPATH="$HEART_HOME" python3 -m heart.validate "$@" } +help_freeze() { cat <" --until <90m|2h|1d|ISO-8601> [--set-by WHO] +pyauto-heart freeze --clear + +The release-validation freeze flag: while it is set, the library \`main\` +branches should not move, because a merge landing mid-validation invalidates +the evidence and restales the rehearsal (~75 minutes, measured 2026-08-29). + +Heart OWNS the flag and is the only writer; \$HEART_STATE_DIR/freeze.json holds +{reason, set_at, until, set_by}. PyAutoBrain reads it and never writes it: +\`pyauto-brain vitals\` prints it as a warning line, \`/prm\` refuses to merge a +LIBRARY repo's PR while it is active (\`--thaw\` overrides, logged), and +\`batch collect\` carries one line. It does NOT enter the readiness verdict — +a freeze is not a health problem, and gating every skill on it was never the +intent. + +--until is MANDATORY: a freeze with no expiry never clears. Past the expiry the +flag reads as clear for every consumer, and \`--show\` reports it as "expired" +so a forgotten set is visible. + +Exit codes: 3 while a freeze is ACTIVE (so \`freeze --show\` is a one-call shell +gate), 0 when clear or expired, 2 on a usage error. \`--set\` always exits 0. + +Call sites: pre_build sets it before dispatching the release workflow; +\`pyauto-heart validate --ingest\` clears it (the ingest is the end of the +window); review_release clears a freeze the ingest did not. +EOF +} +cmd_freeze() { + mkdir -p "$HEART_STATE_DIR" + exec env PYTHONPATH="$HEART_HOME" python3 -m heart.freeze "$@" +} + help_logs() { cat < datetime.datetime: + return now or datetime.datetime.now(datetime.timezone.utc) + + +def _iso(ts: datetime.datetime) -> str: + return ts.astimezone(datetime.timezone.utc).replace(microsecond=0).isoformat() + + +def parse_until(value: str, now: datetime.datetime | None = None) -> datetime.datetime: + """``90m``/``2h``/``1d`` or an ISO-8601 timestamp → an aware datetime. + + A naive timestamp is read as UTC — Heart's sidecars are UTC throughout, and + guessing the local zone here would make the same string mean two things on + two machines. + """ + v = (value or "").strip() + if not v: + raise ValueError("--until is required: a freeze with no expiry never clears") + m = DURATION_RE.match(v) + if m: + return _now(now) + datetime.timedelta(**{_UNITS[m.group(2).lower()]: int(m.group(1))}) + try: + ts = datetime.datetime.fromisoformat(v.replace("Z", "+00:00")) + except ValueError as e: + raise ValueError( + f"--until: {v!r} is neither a duration (90m / 2h / 1d) nor an " + "ISO-8601 timestamp" + ) from e + if ts.tzinfo is None: + ts = ts.replace(tzinfo=datetime.timezone.utc) + return ts + + +def _read_file() -> dict[str, Any] | None: + if not FREEZE_FILE.is_file(): + return None + try: + data = json.loads(FREEZE_FILE.read_text()) + except (OSError, json.JSONDecodeError): + return None + return data if isinstance(data, dict) else None + + +def read(now: datetime.datetime | None = None) -> dict[str, Any]: + """The current reading: ``{"state": clear|active|expired, ...fields}``. + + Never raises and never writes — an unreadable or malformed file reads as + clear, because a freeze nobody can parse must not be able to block a merge. + """ + data = _read_file() + if not data: + return {"state": CLEAR} + until = data.get("until") + try: + expires = parse_until(str(until), now=now) if until else None + except ValueError: + expires = None + if expires is None: + # A file with no parseable expiry is not a licence to freeze forever. + return {"state": CLEAR, "malformed": True} + out = { + "state": ACTIVE if _now(now) < expires else EXPIRED, + "reason": str(data.get("reason") or "unspecified"), + "set_at": str(data.get("set_at") or ""), + "until": _iso(expires), + "set_by": str(data.get("set_by") or ""), + } + return out + + +def is_frozen(now: datetime.datetime | None = None) -> bool: + """True only while a freeze is *active* — expired reads as thawed.""" + return read(now=now)["state"] == ACTIVE + + +def render_line(rec: dict[str, Any]) -> str: + """The one wording, shared by every surface that shows the flag. + + ``FROZEN: until `` while active, ``""`` otherwise — so a + caller can `if line:` rather than re-deciding what counts as frozen. + """ + if rec.get("state") != ACTIVE: + return "" + return f"FROZEN: {rec['reason']} until {rec['until']}" + + +def set_freeze(reason: str, until: str, set_by: str = "", + now: datetime.datetime | None = None) -> dict[str, Any]: + """Write the flag. ``until`` is mandatory (see ``parse_until``).""" + reason = (reason or "").strip() + if not reason: + raise ValueError("--set needs a reason: an unexplained freeze cannot be judged") + expires = parse_until(until, now=now) + ts = _now(now) + if expires <= ts: + raise ValueError(f"--until {until!r} is already in the past") + record = { + "reason": reason, + "set_at": _iso(ts), + "until": _iso(expires), + "set_by": set_by or os.environ.get("USER") or "unknown", + } + state.atomic_write_json(FREEZE_FILE, record) + return read(now=now) + + +def clear(now: datetime.datetime | None = None) -> dict[str, Any]: + """Remove the flag; return what was there (``state`` as it read before).""" + was = read(now=now) + try: + FREEZE_FILE.unlink() + except FileNotFoundError: + pass + return was + + +# ------------------------------------------------------------------- CLI --- +def _render(rec: dict[str, Any]) -> list[str]: + st = rec.get("state") + if st == ACTIVE: + return [render_line(rec), + f" set {rec['set_at']} by {rec['set_by'] or 'unknown'}"] + if st == EXPIRED: + return [f"expired: {rec['reason']} — expiry {rec['until']} has passed " + "(reads as clear; `freeze --clear` removes the file)"] + return ["not frozen"] + + +def main(argv: list[str] | None = None) -> int: + ap = argparse.ArgumentParser( + prog="pyauto-heart freeze", + description="The release-validation freeze flag: library mains should " + "not move while it is set.", + ) + ap.add_argument("--set", dest="set_reason", metavar="REASON", + help="set the flag with this reason (needs --until)") + ap.add_argument("--until", default="", + help="expiry: a duration (90m / 2h / 1d) or an ISO-8601 " + "timestamp. Mandatory with --set.") + ap.add_argument("--set-by", default="", + help="who set it (default: $USER)") + ap.add_argument("--clear", action="store_true", help="remove the flag") + ap.add_argument("--show", action="store_true", + help="print the current reading (the default action)") + ap.add_argument("--json", action="store_true", dest="as_json", + help="print the reading as JSON") + ns = ap.parse_args(argv) + + if ns.set_reason and ns.clear: + print("freeze: --set and --clear are opposites; pick one", file=sys.stderr) + return 2 + + try: + if ns.set_reason: + rec = set_freeze(ns.set_reason, ns.until, set_by=ns.set_by) + elif ns.clear: + was = clear() + if ns.as_json: + json.dump({"cleared": was}, sys.stdout, indent=2, sort_keys=True) + sys.stdout.write("\n") + else: + print(f"cleared: {was['reason']}" if was["state"] != CLEAR + else "nothing to clear") + return 0 + else: + rec = read() + except ValueError as e: + print(f"freeze: {e}", file=sys.stderr) + return 2 + + if ns.as_json: + json.dump(rec, sys.stdout, indent=2, sort_keys=True) + sys.stdout.write("\n") + else: + for line in _render(rec): + print(line) + # A *read* reports RC_FROZEN while active, so `pyauto-heart freeze --show` + # is a one-call shell gate. A --set always exits 0: it is a successful + # command, and a driver running under `set -e` must not abort on the freeze + # it just took out itself. + if ns.set_reason: + return 0 + return RC_FROZEN if rec.get("state") == ACTIVE else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/heart/validate.py b/heart/validate.py index 5e926898..a9f3fad2 100644 --- a/heart/validate.py +++ b/heart/validate.py @@ -116,7 +116,7 @@ from pathlib import Path from typing import Any, Iterable, Sequence -from heart import state +from heart import freeze, state SCHEMA_VERSION = 1 @@ -975,6 +975,16 @@ def main(argv: list[str] | None = None) -> int: commit_shas=commit_shas, out=Path(ns.out) if ns.out else None, ) + # The ingest of the validation evidence IS the end of the validation + # window, so it is where the freeze flag comes off — not a separate + # thing to remember. Only on a real ingest: `--out` redirects the + # report for inspection and must not touch live state, exactly as the + # verify_install sidecar above. Never on the read-only path. + if ns.out is None: + was = freeze.clear() + if was["state"] != freeze.CLEAR: + print(f"freeze cleared: {was['reason']} " + f"(set {was['set_at']} by {was['set_by'] or 'unknown'})") if ns.json: json.dump(report, sys.stdout, indent=2, sort_keys=True) diff --git a/skills/review_release/review_release.md b/skills/review_release/review_release.md index 94158fee..b5bb95e9 100644 --- a/skills/review_release/review_release.md +++ b/skills/review_release/review_release.md @@ -77,6 +77,27 @@ The Heart verdict is authoritative even when it differs from the selected build's conclusion. Releases require GREEN. Never acknowledge YELLOW or infer GREEN inside this skill. +**Then read the freeze window.** A validation run is a window in which the +library `main` branches should not move, and `pre_build` sets a flag saying so: + +```bash +pyauto-heart freeze --show # exit 3 = still frozen, 0 = clear/expired +``` + +The ingest (`pyauto-heart validate --ingest`) clears it on its own, so a freeze +still standing here means the run ended without one — a rehearsal that never +ingested, a failed live run, or a dispatch that never completed. Report the +line, then clear it, because reviewing the run is the end of the window either +way: + +```bash +pyauto-heart freeze --clear +``` + +Never clear it while the run is still **in progress** (step 1) — that is the +one case where the window is genuinely still open. An `expired` reading needs +no action beyond the clear; it means nobody closed the window and time did. + ### 4. Explain adverse evidence For each build failure, show the failing job and the error detail actually diff --git a/tests/test_freeze.py b/tests/test_freeze.py new file mode 100644 index 00000000..1900e09e --- /dev/null +++ b/tests/test_freeze.py @@ -0,0 +1,188 @@ +"""tests/test_freeze.py — the release-validation freeze flag. + +The flag's whole job is to be believed by three surfaces that do not run in +this process, so what is tested here is the contract they read: the file's +shape, the three readings (clear / active / expired), the exit codes, and the +one line every surface prints. `conftest.py` has already pointed +`HEART_STATE_DIR` at a throwaway directory, so none of this can reach the +developer's live state. +""" + +from __future__ import annotations + +import datetime +import json + +import pytest + +from heart import freeze + + +@pytest.fixture(autouse=True) +def _clean_slate(): + """Every test starts with no flag and leaves none behind.""" + freeze.FREEZE_FILE.unlink(missing_ok=True) + yield + freeze.FREEZE_FILE.unlink(missing_ok=True) + + +def _at(hours: float) -> datetime.datetime: + return (datetime.datetime.now(datetime.timezone.utc) + + datetime.timedelta(hours=hours)) + + +# --- reading nothing -------------------------------------------------------- +def test_no_file_reads_as_clear(): + assert freeze.read()["state"] == freeze.CLEAR + assert freeze.is_frozen() is False + assert freeze.render_line(freeze.read()) == "" + + +def test_unparseable_file_reads_as_clear_rather_than_blocking(): + # A freeze nobody can parse must not be able to stop a merge — fail open, + # because the failure mode of the other choice is an unclearable block. + freeze.FREEZE_FILE.parent.mkdir(parents=True, exist_ok=True) + freeze.FREEZE_FILE.write_text("{not json") + assert freeze.read()["state"] == freeze.CLEAR + freeze.FREEZE_FILE.write_text(json.dumps({"reason": "no expiry here"})) + assert freeze.read()["state"] == freeze.CLEAR + freeze.FREEZE_FILE.write_text(json.dumps({"reason": "x", "until": "tuesday"})) + assert freeze.read()["state"] == freeze.CLEAR + + +# --- set / show / clear ----------------------------------------------------- +def test_set_writes_the_four_fields_and_reads_back_active(): + rec = freeze.set_freeze("release validation", "90m", set_by="release-validate") + assert rec["state"] == freeze.ACTIVE + on_disk = json.loads(freeze.FREEZE_FILE.read_text()) + assert set(on_disk) == {"reason", "set_at", "until", "set_by"} + assert on_disk["reason"] == "release validation" + assert on_disk["set_by"] == "release-validate" + # Both stamps are UTC ISO-8601 and `until` is after `set_at`. + assert on_disk["until"] > on_disk["set_at"] + assert on_disk["until"].endswith("+00:00") + assert freeze.is_frozen() is True + + +def test_the_line_every_surface_prints(): + rec = freeze.set_freeze("release validation", "2h") + line = freeze.render_line(rec) + assert line.startswith("FROZEN: release validation until ") + assert line.endswith(rec["until"]) + + +def test_clear_removes_the_file_and_reports_what_was_there(): + freeze.set_freeze("release validation", "2h") + was = freeze.clear() + assert was["state"] == freeze.ACTIVE + assert was["reason"] == "release validation" + assert not freeze.FREEZE_FILE.exists() + assert freeze.read()["state"] == freeze.CLEAR + # Clearing nothing is not an error. + assert freeze.clear()["state"] == freeze.CLEAR + + +# --- expiry ----------------------------------------------------------------- +def test_expiry_reads_as_expired_and_is_not_frozen(): + freeze.set_freeze("release validation", "30m") + later = _at(1) + rec = freeze.read(now=later) + assert rec["state"] == freeze.EXPIRED + assert freeze.is_frozen(now=later) is False + # An expired freeze prints nothing — every consumer treats it as clear. + assert freeze.render_line(rec) == "" + # ...but the file is still there to be reported on, which is the point: + # a forgotten set stays visible instead of vanishing. + assert freeze.FREEZE_FILE.exists() + + +def test_an_already_past_expiry_is_refused(): + with pytest.raises(ValueError): + freeze.set_freeze("release validation", "2020-01-01T00:00:00+00:00") + + +def test_a_reason_is_mandatory(): + with pytest.raises(ValueError): + freeze.set_freeze(" ", "2h") + + +# --- --until parsing -------------------------------------------------------- +@pytest.mark.parametrize("spec,hours", [("90m", 1.5), ("2h", 2), ("1d", 24), + ("+45m", 0.75)]) +def test_duration_shorthand(spec, hours): + now = datetime.datetime(2026, 9, 3, 12, 0, tzinfo=datetime.timezone.utc) + assert freeze.parse_until(spec, now=now) == now + datetime.timedelta(hours=hours) + + +def test_iso_timestamps_with_and_without_a_zone(): + naive = freeze.parse_until("2026-09-03T19:30:00") + zulu = freeze.parse_until("2026-09-03T19:30:00Z") + offset = freeze.parse_until("2026-09-03T19:30:00+00:00") + # A naive stamp is read as UTC, so all three name the same instant — the + # same string must not mean two things on two machines. + assert naive == zulu == offset + + +def test_an_empty_or_nonsense_until_is_an_error(): + with pytest.raises(ValueError): + freeze.parse_until("") + with pytest.raises(ValueError): + freeze.parse_until("soon") + + +# --- the CLI contract ------------------------------------------------------- +def test_show_exit_codes_are_the_shell_gate(capsys): + assert freeze.main(["--show"]) == 0 + assert "not frozen" in capsys.readouterr().out + + # `--set` always exits 0: a driver running under `set -e` must not abort on + # the freeze it just took out itself. + assert freeze.main(["--set", "release validation", "--until", "90m"]) == 0 + capsys.readouterr() + + # A read while active exits 3 — one call, no JSON parse. + assert freeze.main(["--show"]) == freeze.RC_FROZEN + out = capsys.readouterr().out + assert out.startswith("FROZEN: release validation until ") + assert "set " in out and "by " in out + + assert freeze.main(["--clear"]) == 0 + assert "cleared: release validation" in capsys.readouterr().out + assert freeze.main([]) == 0 # no args == --show + assert "not frozen" in capsys.readouterr().out + + +def test_show_json_is_what_brain_reads(capsys): + freeze.main(["--set", "release validation", "--until", "2h", + "--set-by", "pre-build"]) + capsys.readouterr() + assert freeze.main(["--show", "--json"]) == freeze.RC_FROZEN + rec = json.loads(capsys.readouterr().out) + assert rec["state"] == "active" + assert rec["reason"] == "release validation" + assert rec["set_by"] == "pre-build" + assert rec["until"] and rec["set_at"] + + +def test_expired_show_says_expired_and_exits_clear(capsys): + # Set a freeze that has already run out by writing the record directly — + # `set_freeze` refuses a past expiry, which is the behaviour tested above. + freeze.FREEZE_FILE.parent.mkdir(parents=True, exist_ok=True) + freeze.FREEZE_FILE.write_text(json.dumps({ + "reason": "release validation", "set_at": "2026-09-03T10:00:00+00:00", + "until": "2026-09-03T11:00:00+00:00", "set_by": "pre-build"})) + now = datetime.datetime(2026, 9, 3, 12, 0, tzinfo=datetime.timezone.utc) + assert freeze.read(now=now)["state"] == freeze.EXPIRED + assert freeze.main(["--show"]) == 0 + assert "expired" in capsys.readouterr().out + + +def test_set_and_clear_together_is_a_usage_error(capsys): + assert freeze.main(["--set", "x", "--until", "2h", "--clear"]) == 2 + assert "opposites" in capsys.readouterr().err + + +def test_set_without_until_is_a_usage_error_not_a_permanent_freeze(capsys): + assert freeze.main(["--set", "release validation"]) == 2 + assert "--until is required" in capsys.readouterr().err + assert not freeze.FREEZE_FILE.exists() diff --git a/tests/test_validate.py b/tests/test_validate.py index df6aac7b..0476e57b 100644 --- a/tests/test_validate.py +++ b/tests/test_validate.py @@ -1153,3 +1153,47 @@ def test_null_discriminator_is_malformed_not_absent(tmp_path): assert validate.report_outcome(nul) == "fail" _write(tmp_path / "validation_report.json", nul) assert validate.ingest([tmp_path])["validation_outcome"] == "fail" + + +# --- the freeze window ------------------------------------------------------ +def test_ingest_clears_the_freeze_because_the_window_has_ended(tmp_path, capsys): + """`validate --ingest` is where the validation window closes. + + The evidence landing IS the end of the freeze, so the flag comes off there + rather than being something a human has to remember after a green run. + """ + from heart import freeze + + freeze.set_freeze("release validation", "2h", set_by="pre-build") + _write(tmp_path / "rehearsal.json", REHEARSAL) + assert validate.main(["--ingest", str(tmp_path)]) == 0 + assert "freeze cleared: release validation" in capsys.readouterr().out + assert freeze.read()["state"] == freeze.CLEAR + + +def test_out_redirected_ingest_leaves_the_freeze_alone(tmp_path): + """`--out` is an inspection path: it touches no live state, freeze included.""" + from heart import freeze + + freeze.set_freeze("release validation", "2h", set_by="pre-build") + try: + _write(tmp_path / "rehearsal.json", REHEARSAL) + assert validate.main(["--ingest", str(tmp_path), + "--out", str(tmp_path / "report.json")]) == 0 + assert freeze.read()["state"] == freeze.ACTIVE + finally: + freeze.clear() + + +def test_reading_the_report_does_not_clear_the_freeze(tmp_path): + """The read-only path (`validate` with no --ingest) is not the end of anything.""" + from heart import freeze + + _write(tmp_path / "rehearsal.json", REHEARSAL) + validate.main(["--ingest", str(tmp_path)]) + freeze.set_freeze("release validation", "2h", set_by="pre-build") + try: + assert validate.main([]) == 0 + assert freeze.read()["state"] == freeze.ACTIVE + finally: + freeze.clear()