Skip to content

fix(loop): pin transient driver units to the repo root via --working-directory - #131

Merged
robercano merged 1 commit into
mainfrom
fix/loop-driver-working-directory
Jul 16, 2026
Merged

fix(loop): pin transient driver units to the repo root via --working-directory#131
robercano merged 1 commit into
mainfrom
fix/loop-driver-working-directory

Conversation

@robercano-ghbot

Copy link
Copy Markdown
Collaborator

Problem

Since the 2026-07-16 08:38Z re-arm (which activated #119's transient-unit spawn path), every loop driver started in $HOME instead of the repo: systemd-run --user transient units default their WorkingDirectory to the user's home. A driver started there never loads reCode/.claude/settings.local.json's bypassPermissions profile, so its first gh/bot-gh.sh call dies on "requires approval" (no approver in headless -p mode) and the driver exits clean with no work — ledgered result=phantom rc=0 by #111's classifier.

Impact: issue #97 burned all 5 of its per_issue_attempts on back-to-back phantoms in ~1h before the #95 attempt budget parked the loop with needs-human escalation.

Forensic fingerprint for future debugging: a homeless driver's transcript files under ~/.claude/projects/-home-rcano/ instead of ...-reCode/.

Fix

One flag on the systemd-run invocation in run_driver: --working-directory="$root". The setsid fallback path needs no change — a plain child inherits the daemon's own cwd (the repo, per the service unit).

Tests

Scenario 11 now asserts --working-directory=<resolved repo root> is passed. Full loop-daemon.test.sh: 75/75 green; self test + lint gates green.

Deploy note

Takes effect only on daemon restart (functions load at start). The loop is currently parked on reason=attempt-budget, so restarting is safe right now. After restart, clear issue #97's entry in .claude/state/loop-issue-attempts.json to let it retry.

🤖 Generated with Claude Code

…directory

A systemd-run --user transient unit defaults WorkingDirectory to $HOME,
so every driver spawned via issue #119's transient-unit path started
outside the repo, never loaded .claude/settings.local.json's
bypassPermissions profile, and died phantom on its first gh call
("requires approval", no approver headless). Went live at the
2026-07-16 08:38Z re-arm and burned all 5 of issue #97's attempts in
~1h before the #95 attempt budget parked the loop.

Scenario 11 now asserts the flag is passed with the resolved repo root.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants