Fix #281: recreate stale default workdirs after reboot when only logs remain#282
Conversation
… remain After a reboot, a tool-owned default workdir can survive as a bare directory containing only .agent-loop-logs (or other tool-owned artifacts) without a git checkout. The previous code aborted with "exists but is not a git checkout". Add _is_stale_default_workdir() to detect this condition (dir exists, no .git/, contents are a non-empty subset of known tool artifact names), and in ensure_temp_checkout() remove and re-clone the workdir when this condition is met for default-owned dirs. Explicit agent dirs (--claude-dir / --codex-dir / --gemini-dir) still fail clearly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Opened PR #282 to fix this. Root cause: Fix: Added Three new tests cover: stale-with-only-logs → re-cloned; stale-with-unknown-files → still fails; explicit-dir-with-logs → still fails (no clone attempted). All 716 tests pass. -- Anthropic Claude |
|
Review verdict: Approved Approved; the stale default workdir recreation is limited to default-owned paths with only known tool artifacts, explicit dirs still fail, and regression coverage is in place. -- OpenAI Codex |
|
Review verdict: Approved The PR successfully addresses the issue of stale default workdirs surviving reboots. It introduces a safe mechanism to identify and recreate default-owned agent workdirs that contain only tool-generated artifacts (logs, memory, responses) but are missing a -- Google Gemini |
Summary
Fixes #281
After a machine reboot, a tool-owned default agent workdir under
/tmp/coding-review-agent-loop/...can survive as a bare directory containing only tool-created artifacts (e.g.,.agent-loop-logs/) with no git checkout. Previously the tool aborted with:This PR adds auto-recreation for that stale scenario:
_is_stale_default_workdir(path)— detects a dir that exists, has no.git/, and whose contents are a non-empty subset of known tool artifact names (.agent-loop-logs,.agent-loop,.agent-loop-responses). Empty dirs are intentionally excluded (no artifacts → could be any empty dir).ensure_temp_checkout()— callsshutil.rmtree()on stale default-owned workdirs before the existing clone-if-missing branch, so the normalgh repo clone+ validation flow runs fresh.--claude-dir/--codex-dir/--gemini-dir) are unchanged — they still fail clearly when not a git checkout.Test plan
test_stale_default_workdir_only_logs_is_recreated— default auto workdir with only.agent-loop-logs/is removed and fresh clone is triggered; log message confirms detection.test_stale_default_workdir_with_unknown_files_still_fails— dir with.agent-loop-logs/plus an unknown file is not treated as stale; error is raised.test_explicit_dir_not_git_checkout_is_not_recreated— explicit (non-auto) dir with only logs still aborts with a clear error; no clone attempted.🤖 Generated with Claude Code