fix: make lifecycle teardown failure-safe - #73
Merged
Conversation
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
Make lifecycle teardown failure-safe when history persistence, cleanup hooks, logger handlers, or the cleanup call itself fails.
The lifecycle now:
finally;log_pathfrom history records when file logging is disabled.This fixes the release-blocking leak where a history writer exception left the current Context active, retained the temp directory and logger handlers, and could mask the command's own exception.
Issue
Fixes #51
Parent roadmap: #50
Validation
uv run --no-project --with pytest --with click --with pyyaml python -m pytest tests/test_app_lifecycle.py tests/test_generic_core.py— 9 passeduv run --no-project --with pytest --with click --with pyyaml python -m pytest— 115 passed./tests/validate.sh— passedpython3 -m compileall -q lib/python/base_cli tests— passedE4,E7,E9,F) on changed Python files — passedgit diff --check— passedNotes
This PR intentionally does not finalize
run.jsonor change interrupt/exit-code semantics. Those broader outcome contracts are next in the train under #52 and depend on this teardown guarantee.Checklist
<category>/<issue>-<YYYYMMDD>-<slug>, and its category prefix matches the issue's single standard category label.Fixes #51.