fix: test suite clobbers live ~/.pyauto-heart state#79
Merged
Conversation
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>
This was referenced Jul 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Running PyAutoHeart's own unit tests clobbered the developer's live
~/.pyauto-heartstate (#78):heart/checks/test_run.pyandheart/checks/version_skew.pyperformed an unconditionalstate.atomic_write_jsoninsiderun(), and their tests callrun()directly. Measured 2026-07-15: a 10,234-byte realtest_run.jsonwas replaced by a 251-byte fixture, destroying the recorded failures and the 58-entryparked_stalelist. 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()), whichpython -m heart.checks.<name>(heart/tick.sh) invokes unchanged.tests/conftest.pyadditionally sandboxesHEART_STATE_DIRat 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_skewsibling 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 passingleg 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
HEART_STATE_DIRsandboxed — before the fixtest_test_run.pyandtest_version_skew.pywrote state; after, none do.HEART_STATE_DIRunset against a throwawayHOME: the state dir gains zero files (measured, per the issue's constraint).python -m heart.checks.test_runstill writes the sidecar (10,234 bytes, byte-size-identical to live state).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 tomain()(thepython -m heart.checks.test_runtick 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-timeHEART_STATE_DIRsandbox.tests/test_test_run.pyandtests/test_version_skew.py(no-write contract +main()persist).Generated by the PyAutoLabs agent workflow.