Fix rebuilds from deleted hook cwd#1703
Open
FranciscoJSBarragan wants to merge 1 commit into
Open
Conversation
What changed - Stabilize relative rebuild execution before graphify-out queue/lock setup. - Recover from deleted transient hook CWDs when GRAPHIFY_REPO_ROOT points at the repository root. - Fail cleanly when the current working directory is gone and no repo root fallback is available. - Add regression coverage for both fallback and clean-failure paths. Why - Detached post-commit/post-checkout rebuilds can inherit a transient CWD that is deleted before the background process starts. - _rebuild_code previously used relative graphify-out paths before Path.cwd()/watch_path resolution could be handled, causing FileNotFoundError: [Errno 2] No such file or directory. Validation - .venv/bin/pytest tests/test_watch.py -q: 54 passed, 2 skipped. - .venv/bin/ruff check graphify/watch.py tests/test_watch.py: passed. - .venv/bin/python -m py_compile graphify/watch.py tests/test_watch.py: passed. - env -u PYTHONPATH -u PYTHONHOME PYTHONHASHSEED=0 .venv/bin/pytest -q: 2904 passed, 30 skipped. Notes - Full suite without PYTHONHASHSEED=0 exposed an unrelated ordering-sensitive labeling test; with the deterministic hash seed used by graphify hooks, the suite passes.
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
Fix detached rebuilds that inherit a deleted transient working directory before graphify can create
graphify-out/.pending_changesor acquire the rebuild lock.Problem
Post-commit/post-checkout hook rebuilds can run in a background process after the launcher CWD has disappeared. In that state, relative path setup such as
graphify-outqueue/lock creation can raise:This happens before the main rebuild body reaches the existing path/root handling.
Changes
_stabilize_rebuild_cwd()and call it at the start of_rebuild_code()before_queue_pending()/_rebuild_lock().GRAPHIFY_REPO_ROOTwhen hooks provide it.Falsewith a clear message if the CWD is gone and no repo-root fallback is available.Validation
.venv/bin/pytest tests/test_watch.py -q→54 passed, 2 skipped.venv/bin/ruff check graphify/watch.py tests/test_watch.py→ passed.venv/bin/python -m py_compile graphify/watch.py tests/test_watch.py→ passedenv -u PYTHONPATH -u PYTHONHOME PYTHONHASHSEED=0 .venv/bin/pytest -q→2904 passed, 30 skippedNote: running the full suite without
PYTHONHASHSEED=0exposed an unrelated ordering-sensitive labeling assertion ([100, 50, 100]vs[100, 100, 50]). With the deterministic hash seed already used by graphify hooks, the full suite passes.