Repository navigation
Description
Summary
The dev-lead agent fails on review/CI intents whenever it operates on a PR branch that predates one of the agent's own prompt or script files. The agent's prompt templates (prompts/dev-lead/*.md) and scripts (scripts/*) live in the same repository it operates on. When a review/CI intent runs, the agent does an in-place gh pr checkout, which switches the working tree to the PR branch. If that branch was cut before a given prompt was added, the file vanishes mid-run and the script aborts.
Observed failure
Run: https://github.com/petry-projects/.github-private/actions/runs/27077585464/job/79917480705
Switched to a new branch 'fix/gemini-fallback-quota'
scripts/dev-lead-fix-reviews.sh: line 51: prompts/dev-lead/on-mention.md: No such file or directory
scripts/engine.sh: line 296: /tmp/dev-lead-on-mention-prompt-2522.md: No such file or directory
##[error]Process completed with exit code 1.
- Trigger:
@dev-leadcomment on PR fix(engine): handle gemini quota exhaustion and capture stderr #226 (fix/gemini-fallback-quota), routed to theon-mentionintent →scripts/dev-lead-fix-reviews.sh. - The script runs
gh pr checkout 226, switching the working tree in place to the PR branch. - It then resolves the prompt template relative to the working tree:
prompts/dev-lead/on-mention.md. on-mention.mdwas introduced in52b84f5(feat(dev-lead): harden agent instructions with Plan→TDD→Verify→Rubber Duck→Report pattern #358) — after PR fix(engine): handle gemini quota exhaustion and capture stderr #226's branch was created — so the file is absent on that branch andenvsubstfails.
git ls-tree origin/fix/gemini-fallback-quota -- prompts/dev-lead/on-mention.md returns nothing, confirming the file is absent on the PR branch.
Root cause
gh pr checkout mutates the working tree in place. Because the agent's own assets live in that same tree, any PR branch older than a referenced prompt/script breaks the run. This is a self-referential checkout hazard, most acute when .github-private operates on its own PRs. It affects every script that checks out a PR branch in place:
scripts/dev-lead-fix-reviews.sh(intents:fix-reviews,on-mention,fix-bot-comment,review-changes)scripts/dev-lead-fix-ci.sh(intent:fix-ci)
Fix
Check out the PR branch in an isolated git worktree instead of switching the agent's working tree in place. The agent checkout (and its prompts/, scripts/) stays on the agent ref; the engine runs inside the worktree against the PR branch; prompt templates are read via an absolute PROMPTS_DIR resolved before entering the worktree. The worktree is removed on exit.
This eliminates the entire class of "agent assets disappear when checking out an old PR branch" failures.
Activity
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
docs(dev-lead): fix review nits — terminology, grammar, autolink
test(dev-lead): assert per-issue/per-PR concurrency lanes (align with #…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
test(dev-lead): assert per-issue/per-PR concurrency lanes (align with #…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
test(dev-lead): assert per-issue/per-PR concurrency lanes (align with #…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
docs(dev-lead): concurrency ownership, @main pin, and the permission …
docs(dev-lead): concurrency ownership, @main pin, and the permission …
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
10 remaining items
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
test(dev-lead): assert per-issue/per-PR concurrency lanes (align with #…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
test(dev-lead): assert per-issue/per-PR concurrency lanes (align with #…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…
fix(dev-lead): check out PR branches in an isolated worktree (#448) (#…