Skip to content

fix: test suite clobbers live ~/.pyauto-heart state#79

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/heart-state-clobber
Jul 16, 2026
Merged

fix: test suite clobbers live ~/.pyauto-heart state#79
Jammy2211 merged 1 commit into
mainfrom
feature/heart-state-clobber

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Summary

Running PyAutoHeart's own unit tests clobbered the developer's live ~/.pyauto-heart state (#78): heart/checks/test_run.py and heart/checks/version_skew.py performed an unconditional state.atomic_write_json inside run(), and their tests call run() directly. Measured 2026-07-15: a 10,234-byte real test_run.json was replaced by a 251-byte fixture, destroying the recorded failures and the 58-entry parked_stale list. The state dir is the input to the release gate, so this was a release-safety issue, not tidiness.

The trap is deleted rather than patched: run() is now side-effect-free in both checks and the persist lives at the tick/CLI entrypoint (main()), which python -m heart.checks.<name> (heart/tick.sh) invokes unchanged. tests/conftest.py additionally sandboxes HEART_STATE_DIR at import time for the whole suite — a belt-and-braces backstop for the six other checks that still resolve the path at import.

The version_skew sibling was not filed: it was found by the empirical sweep the issue prescribes (every test file run against a sandboxed state dir; two of eighteen wrote state).

Shipped under the corrective-PR exception for Heart RED (human-authorized 2026-07-16 against the five verbatim reason strings; this PR is an integrity fix for the evidence behind the workspace validation not passing leg and touches no release surface).

API Changes

None — internal changes only. (No workspace-facing surface; the internal contract change — run() no longer persists, main() does — is listed below.)

Test Plan

  • Full suite: 280 passed.
  • Empirical sweep: each test file run with HEART_STATE_DIR sandboxed — before the fix test_test_run.py and test_version_skew.py wrote state; after, none do.
  • Full suite with HEART_STATE_DIR unset against a throwaway HOME: the state dir gains zero files (measured, per the issue's constraint).
  • Tick path: python -m heart.checks.test_run still writes the sidecar (10,234 bytes, byte-size-identical to live state).
  • Regression tests pin both directions: run() writes nothing; main() persists.
Full API Changes (for automation & release notes)

Changed Behaviour

  • heart.checks.test_run.run() — no longer writes $HEART_STATE_DIR/test_run.json; returns the summary only. The write moved to main() (the python -m heart.checks.test_run tick path — behaviour there unchanged).
  • heart.checks.version_skew.run() — same shape: no longer writes $HEART_STATE_DIR/version_skew.json; main() persists.

Added

  • tests/conftest.py — suite-wide import-time HEART_STATE_DIR sandbox.
  • Regression tests in tests/test_test_run.py and tests/test_version_skew.py (no-write contract + main() persist).

Generated by the PyAutoLabs agent workflow.

Running the test suite clobbered the developer's live ~/.pyauto-heart state
(#78): test_run.run() and version_skew.run() wrote their $HEART_STATE_DIR
sidecars unconditionally, and the tests call run() directly. Measured
2026-07-15: a 10,234-byte real test_run.json became a 251-byte fixture,
destroying the recorded failures and the 58-entry parked_stale list.

run() now returns the summary without writing; the persist happens at the
tick/CLI entrypoint (main()), which `python -m heart.checks.<name>` invokes
unchanged. tests/conftest.py sandboxes HEART_STATE_DIR at import time as a
belt-and-braces backstop for the other import-time-resolved checks, and
regression tests pin both the no-write contract and the main() persist.

Fixes #78

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release Merged changes awaiting the next release cycle label Jul 16, 2026
@Jammy2211 Jammy2211 merged commit 0319c1a into main Jul 16, 2026
4 checks passed
@Jammy2211 Jammy2211 deleted the feature/heart-state-clobber branch July 16, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release Merged changes awaiting the next release cycle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant