Repository navigation
fix(ci): explicitly close linked issue on principal-review auto-merge - #404
Conversation
GitHub's implicit close-on-merge doesn't reliably fire for PRs merged by principal-review.yml's auto-merge step, leaving the originating issue open with stale status:ready-for-dev/status:in-progress labels (confirmed live on issues #178 and #314). Resolve the linked issue via resolve_linked_issue.sh after a successful merge, clear its stale pipeline labels, and close it explicitly instead of relying on GitHub's parser. Closes #402
QA verification — PR #404 vs issue #402Root cause fix vs issue's suggested fix: PASS. Cleanup requested in #402 ("#178 and #314 should be manually closed"):
What I ran:
Gap, not blocking: no automated regression test exercises the new QA verdict: PASS |
|
This PR's branch is stale relative to |
|
Automated pipeline health check: Confirmed the stale-branch/workflow-validation diagnosis in the comment above is correct (#254 pattern — this branch's copy of This PR's only changed file is A human (or a differently-scoped agent) needs to rebase Generated by Claude Code |
|
Human-merge sweep: not retrying this one, and flagging that the "rebase and re-apply status:needs-review" advice above is a dead end for this specific PR. This PR's diff is entirely The actual fix for this class of failure is PR #405 ( Leaving this on |
|
Rebased onto current dev (clean merge, picks up #405's workflow-drift classifier + other pipeline fixes). This PR's own diff modifies principal-review.yml directly, so it'll never get a real automated review run (drift self-check, correctly). Reviewed the diff by hand — small, well-scoped fix for #402 (explicit issue-close instead of relying on GitHub's not-always-reliable close-on-merge), best-effort/non-fatal on failure. Merging directly. |
What
principal-review.yml's auto-merge step now explicitly closes the PR'slinked issue (via
resolve_linked_issue.sh, the same logicdev-agent.yml/qa-agent.ymlalready share) right after a successfulgh pr merge --squash, instead of relying solely on GitHub's implicitclose-on-merge behaviour.
Why
Confirmed live: issue #178 (PR #264) and issue #314 (PR #316) both merged
via this exact auto-merge step, but were left open afterward carrying
stale
status:ready-for-dev/status:in-progresslabels — GitHub'simplicit close-on-merge silently didn't fire. Flagged by the pipeline
health-check routine at the time as "a new failure mode" but never
tracked until #402 filed it.
Approach
(
resolve_linked_issue.sh, already used elsewhere in this same step forthe audit-log entry — deduplicated into a single call now, computed once
and reused).
OPEN, strip its stale pipeline status labels(
status:triage/status:ready-for-dev/status:in-progress/status:needs-info) andgh issue closeit with an explanatory comment.the issue can't be resolved/read, log why and move on — best-effort,
never fails the run, matching the existing style of this step (e.g. the
audit-log block right below it).
Risk
This touches
.github/workflows/**, one ofagent-policy.yml'ssensitive_paths—classify_pr_risk.pywill forcerisk:highon thisPR regardless of diff size, and it will always land on
status:needs-human-merge, never auto-merge. Flagging explicitly perAGENTS.md/the dev-agent persona rather than leaving it for theprincipal reviewer to rediscover.
The change only adds calls after a merge has already succeeded
(
MERGED=true) — it cannot affect whether a PR merges, only what happensto the issue immediately afterward, and every new
gh issuecall isnon-fatal on failure (
|| true/ logged fallback), so it can't turn asuccessful merge into a failed workflow run.
Cleanup
Manually closed #178 and #314 (both confirmed merged via #264/#316) as
requested in #402's "Cleanup needed" section, with a comment explaining
why they'd been sitting open.
Out of scope (flagging, not fixing here)
human-merge-sweep-agent.md's manual-merge path (status:needs-human-merge→
gh pr merge --squashunder the sameGITHUB_TOKEN) is structurally thesame merge call and could plausibly hit the identical implicit-close gap —
but #402 only reports and asks for a fix on
principal-review.yml'sauto-merge step, and
.claude/agents/**is itself asensitive_pathsentry requiring direct human edit/review in this environment (this
session isn't permitted to write to it). Worth a human's judgment on
whether to file a follow-up for that path.
Testing
.github/scripts/test_resolve_linked_issue.sh— pre-existing regressionsuite for the shared resolution logic this change calls into, still
passes unchanged (this PR doesn't modify that script).
(
yaml.safe_load) and the extracted "Auto-merge if approved" step'sshell passes
bash -n.gh issue close/gh issue editcalls against a real merge) outside of a real PRmerge in this repo — CI on this PR is the first real signal on syntax/
permissions (
issues: writeis already granted at job level), and anactual live exercise of the new logic only happens the next time some
PR in this pipeline auto-merges cleanly.
Closes #402