Repository navigation
Description
What happened
During PR #375's principal-review run (workflow run 32414815714), the review agent's very first diagnostic command — before it had done anything else — found the working tree was dirty in a way that shouldn't be possible right after a checkout:
$ git branch --show-current; git log --oneline -3; git status; git diff HEAD -- .claude/agents/principal-review-agent.md | head -50
fix/principal-review-file-issues
557c679 fix(ci): principal-review-agent files an issue for every CONFIRMED finding
0fb8f74 fix(ci): open dev-agent's PR early as a checkpoint, not as its last step (#368)
60b398e fix(ios): verify and pin EPUB bookmark/locator compatibility with block model (#367)
On branch fix/principal-review-file-issues
Your branch is up to date with 'origin/fix/principal-review-file-issues'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .claude/agents/dev-agent.md
modified: .claude/agents/human-merge-sweep-agent.md
modified: .claude/agents/principal-review-agent.md
HEAD (557c679, confirmed by git log) is PR #375's real tip, which does commit the "Documenting real findings" section this PR adds — but the working tree file did not have that section; git diff HEAD showed it as an unstaged removal. Same story for dev-agent.md/human-merge-sweep-agent.md: both files exist on disk with content that doesn't match what's actually committed at HEAD.
Sequence of events (from the run log)
actions/checkout@v4(fetch-depth: 0, no explicitref:) — for apull_request-family trigger this checks out GitHub's syntheticrefs/pull/375/mergeref. Log line:Previous HEAD position was c9e0e29 Merge 557c679...into 0fb8f74...— i.e. a merge of PR fix(ci): principal-review-agent files an issue for every CONFIRMED finding #375's tip into0fb8f74, the commit PR fix(ci): principal-review-agent files an issue for every CONFIRMED finding #375's branch was actually cut from (not necessarily currentdevat run time).gh pr checkout 375— log line:Switched to a new branch 'fix/principal-review-file-issues', trackingorigin/fix/principal-review-file-issues. This reports success and looks like a clean branch switch.git fetch origin dev(the workflow-file-drift OIDC self-check, fetch only — doesn't touch the working tree).- The agent's own first command (quoted above) already shows the dirty state — nothing the agent itself ran caused it; there's no
git checkout/git reset/git stashanywhere earlier in its own command history.
So the dirty state exists immediately after step 2, despite gh pr checkout's own output claiming a clean switch.
Likely relevant context (not fully confirmed as root cause)
dev-agent.md and human-merge-sweep-agent.md were both modified by PRs that merged to dev shortly before this run (#381 at 20:21:46Z, #372 at 19:36:37Z) — after PR #375's branch (fix/principal-review-file-issues) was cut from dev at 0fb8f74 but before this review run's checkout at ~20:34:39Z. Whether that timing is actually why — e.g. some interaction between the initial merge-ref checkout and gh pr checkout's branch-switch not doing a full clean overwrite for files also touched on dev in the meantime — is a real hypothesis, not confirmed. I did not reproduce this deliberately or trace gh's actual checkout implementation; flagging the observed facts rather than asserting a mechanism I haven't verified.
Why this matters (and why it didn't cause a wrong outcome this time)
The review agent's actual verdict on PR #375 was correct — it used gh pr diff/gh pr view --json files (API-based, not local git state) as its real source of truth for what the PR contains, explicitly noted the dirty state as "not part of PR #375's actual diff," and didn't let it affect the outcome. That's the right instinct and it held here.
But principal-review.yml's own "Check for workflow-file drift (GitHub OIDC self-check)" step (see #254 for why it exists) does rely on local git diff --quiet origin/dev -- <workflow file> — the same kind of comparison that was wrong here, just for a different file. In this specific run that check happened to land on the right answer (principal-review.yml itself wasn't among the files reported dirty), but if this checkout inconsistency can affect an arbitrary file, it could in principle affect that self-check's own file too, undermining the anti-tampering guard it exists to provide. Same risk applies to any other automated step in this pipeline that trusts local git diff/git status against a freshly-checked-out PR branch (dev-agent.yml's equivalent revise-mode workflow-drift check is the other place this pattern is used).
Suggested next step
Not fixing this now — filing per the new "document CONFIRMED findings" policy (#375) since it's a real, verified anomaly with unclear root cause and potential (unconfirmed) implications for the workflow-drift anti-tampering checks. Worth a deliberate reproduction (e.g. trigger a review run on a PR whose branch predates a dev change to a file outside the PR's own diff, then inspect git status the same way) before deciding whether this needs a fix, or is an artifact specific to gh pr checkout's interaction with the default merge-ref checkout that's already known/documented upstream.
Activity
fix(ci): force clean working tree after gh pr checkout in pipeline wo…
fix(ci): force clean working tree after gh pr checkout in pipeline wo…
fix(ci): force clean working tree after gh pr checkout in pipeline wo…
libravault-xyz commentedon Aug 22, 2026
Automated pipeline health check: This issue's own
status:ready-for-dev/status:in-progresslabels are stale — its linked PR, #387, already exists and has advanced tostatus:escalated.Root cause (confirmed by reading
.github/workflows/dev-agent.yml): the triage-and-implement step's success path only clearsstatus:in-progressand labels the PR; it never revisits the originating issue's status labels once a PR is opened. Same signature confirmed on #401 (→PR #405), #402 (→PR #404), #403 (→PR #407) — a new, 6th failure mode not in the 5 this routine currently tracks. Not self-healing (label cleanup on an already-advanced issue isn't in this routine's authorized action set) — flagging for a human to file/fix.Generated by Claude Code
fix(ci): force clean working tree after gh pr checkout in pipeline wo…
fix(ci): reset working tree before the forced synchronize commit