Skip to content

Fix: pre-authorize agent output dirs (--add-dir) for headless spawns - #18

Merged
alejandro-nexcade merged 1 commit into
mainfrom
alejandro/fix-agent-output-dirs
Jul 2, 2026
Merged

Fix: pre-authorize agent output dirs (--add-dir) for headless spawns#18
alejandro-nexcade merged 1 commit into
mainfrom
alejandro/fix-agent-output-dirs

Conversation

@alejandro-nexcade

Copy link
Copy Markdown
Collaborator

What broke (live dogfooding)

The pre-review agent completed a 24-tool review of a real PR, then lost it: every Write to ~/.cockpit/findings/… was permission-blocked. Headless claude --print sessions only get the worktree as an allowed directory and nobody is present to grant more — so any output contract outside the worktree silently fails. The plan document path (~/.cockpit/plans/…) had the same latent fragility (previously noted in DOGFOODING.md as "the plan doc only populates if the planner happens to write there").

Fix

SpawnConfig::with_extra_dir(dir) appends --add-dir <dir> to the spawn args. pre_review grants the findings dir; both plan spawns (generate + rework, via the shared spawn_plan_agent) grant the plans dir. Implement/fix/restack agents write inside their worktrees and need nothing. Narrow grants — one directory each, not ~/.cockpit.

Verified

cargo fmt/clippy -D warnings/test --all (459, incl. new arg-construction test) · tsc strict clean · FE untouched.

🤖 Generated with Claude Code

LifeLex added a commit that referenced this pull request Jul 2, 2026
spawn_agent resolves logs_dir() from the ambient env; the three restack
tests that spawn agents raced with temp_env tests swapping COCKPIT_HOME
to transient tempdirs (Io(NotFound) flake surfaced on #18's CI). Each
now owns a locked tempdir home, per the agent.rs test precedent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Headless --print sessions can't grant permissions interactively, so the
reviewer's findings file and the planner's plan doc — both outside the
worktree — were silently blocked (the pre-review completed its analysis
and lost it). SpawnConfig::with_extra_dir appends --add-dir; pre_review
grants the findings dir, plan spawns grant the plans dir.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@LifeLex
LifeLex force-pushed the alejandro/fix-agent-output-dirs branch from 4df2df1 to f98510c Compare July 2, 2026 09:30
@alejandro-nexcade
alejandro-nexcade merged commit f711f60 into main Jul 2, 2026
2 checks passed
@alejandro-nexcade
alejandro-nexcade deleted the alejandro/fix-agent-output-dirs branch July 2, 2026 09:33
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