Repository navigation
fix(ci): sweep open PRs missing status:* despite carrying risk:* - #407
Conversation
Extends pr-intake.yml with a schedule-triggered sweep-missing-status job that re-scans every open PR for the "risk:* applied, status:* never applied" gap (confirmed live on PR #339: an App token expired between the risk-classify call and the status:needs-qa handoff on a >60-minute triage run). The existing intake job only fires on pull_request: opened/reopened, so it can never catch a PR that already existed when its status label went missing. The new job runs every 4 hours (offset from human-merge-sweep.yml's own cadence), resolves each match's linked issue the same way intake does, and routes it to status:needs-qa/needs-review accordingly -- a pure deterministic backstop, no agent involved. Closes #403
gh pr ready uses this session's GITHUB_TOKEN, which (like every other GITHUB_TOKEN-authenticated action in this pipeline) can't itself trigger a new workflow run -- so jvm-tests.yml/ios-app-build.yml's ready_for_review trigger never fired and every check stayed on the original draft-time "skipping" result. Empty commit to force a real synchronize event via the elevated token instead.
📱 iOS Build Status: PASSED✅ iOS Simulator Build & Unit Tests - success iOS UI tests run in a separate, informational job and are not reflected above — check "iOS UI Tests (informational)" for those. |
QA verification — PR #407 vs issue #403Issue type: bug report, no explicit acceptance checklist. Checklist used per persona: repro no longer reproduces, and there's proof (test or equivalent) the fix actually works. Repro (PR #339 pattern — risk: applied, status: never applied, no event left to catch it later):** ✅ addressed. The new Independently re-verified the PR's own claims (not just trusted the PR description):
Real test suite ( Regression test proving the fix ("does it exercise the real component"): this is the one soft spot. The core matching logic (the jq filter) lives inline in the workflow's AGENTS.md conventions: ✅ Conventional Commits subject ( risk:high label: correctly applied — No functional bugs found in the new job's logic; verified independently rather than taking the PR description's claims at face value. QA verdict: PASS |
There was a problem hiding this comment.
Verdict: human-merge
risk:high is already correctly applied (this diff touches .github/workflows/pr-intake.yml, which is on agent-policy.yml's sensitive_paths list) and no commits landed after that label was set — the last commit (1d83771) is an empty commit that only re-triggers CI, confirmed via git show --stat. So this was always routing to a human regardless of review findings. It also gets there independently via a CONFIRMED finding below.
What I verified
- YAML parses cleanly:
python3 -c "import yaml; yaml.safe_load(open('.github/workflows/pr-intake.yml'))"— bothintakeandsweep-missing-statusjobs present, matches the PR description's claim. - shellcheck clean: extracted the new job's
run:script verbatim and ranshellcheckagainst it (v0.9.0) — no warnings, matches the PR description's claim. jqfilter logic: confirmed by inspection that(labels have risk:*) and not(labels have status:*)correctly excludes PRs already atstatus:blocked/status:escalated, as claimed — those are themselvesstatus:*labels.resolve_linked_issue.shis executable (-rwxr-xr-x) and its existing regression test (test_resolve_linked_issue.sh) passes, unrelated to this diff but confirms the shared script itself is sound.AGENTS.mdunit-test requirement: no app code touched; the "no dedicated test file, same asintake/classify_pr_risk.py's existing precedent" justification in the PR description holds up — those genuinely have no test file either.- No new networking dependency: only
gh/jq, both already used identically by the pre-existingintakejob. .claude/agents/**untouched, as claimed.
CONFIRMED finding — filed as #408
sweep-missing-status's process_pr() calls resolve_linked_issue.sh and, on ANY non-zero exit, falls back to treating the PR as issue-less:
ISSUE_NUMBER=$(.github/scripts/resolve_linked_issue.sh "$PR_NUMBER") || {
echo "... treating as issue-less for routing purposes." >&2
ISSUE_NUMBER=""
}
resolve_linked_issue.sh's own header comment is explicit that this conflates two different things a caller must not conflate: a genuine ambiguous-multiple-issues result (exit 1, real "no single answer") vs. a genuine gh pr view infra failure (also non-zero, but explicitly documented as "NOT [to be] treated the same as 'no linked issue'... callers running under set -e [should] fail loudly with a distinct message"). This job does exactly what that docstring warns against.
This matters here specifically because sweep-missing-status only matches PRs missing a status:* label — the moment it applies status:needs-review, that PR permanently drops out of the filter and is never retried. So the PR description's claim that "a failure just gets flagged... and the next scheduled run retries it" doesn't hold for failures inside resolve_linked_issue.sh itself — only for failures in the later gh pr edit step. A transient rate-limit/5xx while resolving the linked issue silently and permanently routes a PR that does link an issue to status:needs-review instead of status:needs-qa, skipping acceptance-criteria verification entirely — worse for a risk:low PR, which would then proceed straight toward auto-merge with QA never having run.
Note the pre-existing intake job (same file, unmodified by this diff) doesn't have this problem: its ISSUE_NUMBER=$(...) is a plain assignment under set -euo pipefail with no swallowing ||, so an infra failure there aborts loudly, matching the script's documented contract. sweep-missing-status diverges from that established, correct pattern.
Full details and suggested fix (distinguish the two failure modes rather than collapsing them) are in #408.
Other notes (not blocking)
- Nothing else stood out as a correctness bug. The subshell-per-PR isolation, the App-token/
GITHUB_TOKENsplit, the 15-PR cap with an explicit::warning::, and the cron offset fromhuman-merge-sweep.ymlare all reasonable and match the PR description. gh pr list --state open --json number,labels --limit 200is a hardcoded cap with no corresponding "if this repo ever exceeds it" warning (unlike the 15-PR processing cap, which does warn) — low-risk at current repo scale, just flagging for awareness, not requesting a change.
Routing to human-merge for both the pre-existing risk:high label and this CONFIRMED finding (#408).
|
Human-merge sweep: this PR touches (For reference: CI is green, mergeable/CLEAN, and the diff looks like a well-scoped deterministic fix consistent with |
|
Not merging via the sweep: this PR touches |
What this fixes
Issue #403: a PR can carry a correctly-applied
risk:*label but end up with nostatus:*label at all, so nothing in the pipeline drives it forward. Confirmed live on PR #339 (now closed as superseded, so no action needed on that specific PR):dev-agent.yml's risk-classify call succeeded underGITHUB_TOKEN, but the very next call — handing offstatus:needs-qaunder the App token — failed separately (the App installation token had expired;Run dev agentalone took ~75 minutes on a >60-minute token TTL). This is a sibling gap to #388 (status present/risk missing), not the same defect.pr-intake.yml's existingintakejob only fires onpull_request: opened/reopened, so it can never catch a PR that already existed when the status label silently went missing — there's no later event to re-trigger it.Approach
Added a second job,
sweep-missing-status, to the samepr-intake.ymlworkflow file:schedule(15 */4 * * *, offset 15 min fromhuman-merge-sweep.yml's own 4-hourly cadence) andworkflow_dispatch, guarded byAGENTS_PAUSED.jq) for ones carrying arisk:*label but no label starting withstatus:at all — this single check also naturally excludes anything alreadystatus:blocked/status:escalated, since those are themselvesstatus:*labels..github/scripts/resolve_linked_issue.sh(unchanged, already covered by its owntest_resolve_linked_issue.sh), checks whether that issue isstatus:blocked(same guardintakealready has), and appliesstatus:needs-qa(linked issue) orstatus:needs-review(no/ambiguous linked issue) — same routing logicintakealready uses for its own manually-opened-PR case.PIPELINE_APP_TOKEN-style minted App token only for the label application itself (the one action that must triggerqa-agent.yml/principal-review.yml); everything read-only stays onGITHUB_TOKEN, matchingintake's existing split.ghcall doesn't abort the whole batch underset -e— a failure just gets flagged with a::warning::and the next scheduled run retries it (it'll still match the filter, since it's still missing astatus:*label).intakeandclassify_pr_risk.py.Also updated
docs/agent-team-pipeline.md's "PR intake backstop" section to document the new job.Why this shape, not a new Part 5 in human-merge-sweep-agent.md
The issue's suggested fix offered two options: extend
pr-intake.yml, or add a scheduled health-check pass (whichhuman-merge-sweep.yml/its persona already does via numbered "Parts"). I went with thepr-intake.ymlextension — it's a purely mechanical routing decision with no judgment call involved, so a deterministic script step is a better fit than spending an LLM turn on it, and it keeps the logic next tointake's own (near-identical) linked-issue/blocked-issue handling rather than duplicating it in a second file.Note on
.github/workflows/**and.claude/agents/**: this diff touches.github/workflows/pr-intake.yml, which is onagent-policy.yml'ssensitive_pathslist, soclassify_pr_risk.pywill force this PR torisk:highregardless of anything above — flagging that explicitly per the dev-agent persona's instructions. I did not touch any file under.claude/agents/**(a separate sensitive path) at all.Verification
No app code touched, so no JUnit/Kotlin/Swift tests apply (AGENTS.md's "trivial" carve-out doesn't quite fit a workflow-behavior change, but there's no local runner to execute this workflow against here either — same situation
classify_pr_risk.py/pr-intake.yml's existingintakejob are in, neither of which has its own dedicated test file). What I did verify locally:python3 -c "import yaml; yaml.safe_load(open('.github/workflows/pr-intake.yml'))"— parses cleanly,on:/jobs:keys as expected, bothintakeandsweep-missing-statusjobs present.run:script and ranshellcheckagainst it — clean, no warnings.jqfilter against a hand-built sample (risk:low-only PR,risk:low+status:needs-qaPR,risk:high+status:blockedPR) and confirmed only the first one matches.I do not have a way to actually trigger a
schedule/workflow_dispatchrun against live PRs from here, so CI (and eventually the first real scheduled tick) is the actual end-to-end signal.Closes #403