Fix: pre-authorize agent output dirs (--add-dir) for headless spawns - #18
Merged
Merged
Conversation
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
force-pushed
the
alejandro/fix-agent-output-dirs
branch
from
July 2, 2026 09:30
4df2df1 to
f98510c
Compare
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.
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. Headlessclaude --printsessions 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_reviewgrants the findings dir; both plan spawns (generate + rework, via the sharedspawn_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