Skip to content

fix(ci): sweep open PRs missing status:* despite carrying risk:* - #407

Merged
libravault-xyz merged 2 commits into
devfrom
fix/pr-intake-missing-status-sweep
Aug 22, 2026
Merged

libravault-xyz merged 2 commits into
devfrom
fix/pr-intake-missing-status-sweep

Conversation

@libravault-pipeline-bot

Copy link
Copy Markdown
Contributor

What this fixes

Issue #403: a PR can carry a correctly-applied risk:* label but end up with no status:* 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 under GITHUB_TOKEN, but the very next call — handing off status:needs-qa under the App token — failed separately (the App installation token had expired; Run dev agent alone 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 existing intake job only fires on pull_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 same pr-intake.yml workflow file:

  • Triggered on a schedule (15 */4 * * *, offset 15 min from human-merge-sweep.yml's own 4-hourly cadence) and workflow_dispatch, guarded by AGENTS_PAUSED.
  • Lists all open PRs, filters (via jq) for ones carrying a risk:* label but no label starting with status: at all — this single check also naturally excludes anything already status:blocked/status:escalated, since those are themselves status:* labels.
  • For each match, resolves a linked issue with the existing .github/scripts/resolve_linked_issue.sh (unchanged, already covered by its own test_resolve_linked_issue.sh), checks whether that issue is status:blocked (same guard intake already has), and applies status:needs-qa (linked issue) or status:needs-review (no/ambiguous linked issue) — same routing logic intake already uses for its own manually-opened-PR case.
  • Uses PIPELINE_APP_TOKEN-style minted App token only for the label application itself (the one action that must trigger qa-agent.yml/principal-review.yml); everything read-only stays on GITHUB_TOKEN, matching intake's existing split.
  • Each PR is processed in its own subshell so one flaky gh call doesn't abort the whole batch under set -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 a status:* label).
  • No agent involved — pure deterministic script, same shape as intake and classify_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 (which human-merge-sweep.yml/its persona already does via numbered "Parts"). I went with the pr-intake.yml extension — 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 to intake'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 on agent-policy.yml's sensitive_paths list, so classify_pr_risk.py will force this PR to risk:high regardless 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 existing intake job 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, both intake and sweep-missing-status jobs present.
  • Extracted the new job's run: script and ran shellcheck against it — clean, no warnings.
  • Ran the actual jq filter against a hand-built sample (risk:low-only PR, risk:low+status:needs-qa PR, risk:high+status:blocked PR) and confirmed only the first one matches.

I do not have a way to actually trigger a schedule/workflow_dispatch run against live PRs from here, so CI (and eventually the first real scheduled tick) is the actual end-to-end signal.

Closes #403

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
@github-actions
github-actions Bot marked this pull request as ready for review August 22, 2026 00:43
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.
@github-actions

Copy link
Copy Markdown
Contributor

📱 iOS Build Status: PASSED

✅ iOS Simulator Build & Unit Tests - success
✅ Android Core Modules - success

iOS UI tests run in a separate, informational job and are not reflected above — check "iOS UI Tests (informational)" for those.

View run details

@github-actions github-actions Bot added the risk:high Touches a sensitive path or exceeds diff-size threshold — always human merge label Aug 22, 2026
@libravault-pipeline-bot libravault-pipeline-bot Bot added the status:needs-qa PR open, awaiting qa-agent verification label Aug 22, 2026
@claude

claude Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

QA verification — PR #407 vs issue #403

Issue 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 sweep-missing-status job in .github/workflows/pr-intake.yml runs on a schedule (15 */4 * * *) + workflow_dispatch, independent of pull_request events, so it can catch a PR that already existed when its status label silently went missing — the actual gap intake's opened/reopened-only trigger can't cover. Diff is pure addition (128 lines to pr-intake.yml, 0 deletions) — the existing intake job is untouched, so no regression risk there.

Independently re-verified the PR's own claims (not just trusted the PR description):

  • python3 -c "import yaml; yaml.safe_load(...)" — parses cleanly, both intake and sweep-missing-status jobs present. ✅
  • Extracted the job's run: script and ran shellcheck against it directly — clean, exit 0, no warnings. ✅
  • Rebuilt the jq filter and ran it against a 6-PR hand-built sample (risk-only, risk+needs-qa, risk-high+blocked, status-only, no-labels, risk-high+escalated) — matched exactly the one PR that should match (risk:* present, no status:* at all), correctly excluding status:blocked/status:escalated PRs (itself a status:* label, so naturally excluded by the "no status:* label" check) and PRs already routed. ✅
  • Spot-checked AGENTS_PAUSED guard usage, and the GITHUB_TOKEN (read-only)/App-token (label-only) split — both match the documented convention in docs/agent-team-pipeline.md's "Cross-workflow triggering" section and existing sibling workflows (dev-agent.yml, qa-agent.yml, principal-review.yml). ✅
  • Checked backtick escaping in the new gh pr comment --body strings (double-quoted heredoc-style with embedded `code` spans) — all correctly backslash-escaped, confirmed by the clean shellcheck run. ✅

Real test suite (./gradlew testDebugUnitTest): not run locally — this diff touches zero app code (only .github/workflows/pr-intake.yml and docs/agent-team-pipeline.md), so it's not relevant to what changed, per the persona's "run the suites relevant to what changed" guidance. Instead confirmed CI already ran it for real against this exact head commit (1d83771, the "trigger CI run" commit): Unit & Integration Tests (JVM) — pass (9m12s), Build Android App — pass, Build & Test iOS (Simulator) — pass. All green against the current head, not stale.

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 run: block, with no committed automated test — unlike resolve_linked_issue.sh, which was extracted specifically so test_resolve_linked_issue.sh could exercise it without a live gh call. That said, this matches existing repo precedent exactly: the intake job it sits beside, and classify_pr_risk.py's --apply-label path, are in the same boat (no dedicated test file), and there's no existing harness in this repo for testing GitHub Actions workflow files locally (no act, no workflow-specific test runner). Not treating this as a blocker given that precedent, but flagging it as a real gap worth a follow-up: the jq filter is exactly the kind of thing that could be pulled into a small standalone script (.github/scripts/find_missing_status_prs.sh or similar) with a test_*.sh companion, the same way resolve_linked_issue.sh was — that would give this specific job the same testability bar the rest of the pipeline holds itself to, rather than "I ran it by hand once in the PR description."

AGENTS.md conventions: ✅ Conventional Commits subject (fix(ci): ...), correct branch naming (fix/pr-intake-missing-status-sweep), one concern per commit (second commit is a scoped, explained CI-trigger empty commit, not scope creep). The "claude-code-action gotchas" section doesn't apply — this job invokes no claude-code-action step, it's a pure deterministic gh/jq script, consistent with the sibling intake job.

risk:high label: correctly applied — .github/workflows/** is on agent-policy.yml's sensitive_paths list, confirmed by reading that file directly.

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

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'))" — both intake and sweep-missing-status jobs present, matches the PR description's claim.
  • shellcheck clean: extracted the new job's run: script verbatim and ran shellcheck against it (v0.9.0) — no warnings, matches the PR description's claim.
  • jq filter logic: confirmed by inspection that (labels have risk:*) and not(labels have status:*) correctly excludes PRs already at status:blocked/status:escalated, as claimed — those are themselves status:* labels.
  • resolve_linked_issue.sh is 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.md unit-test requirement: no app code touched; the "no dedicated test file, same as intake/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-existing intake job.
  • .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_TOKEN split, the 15-PR cap with an explicit ::warning::, and the cron offset from human-merge-sweep.yml are all reasonable and match the PR description.
  • gh pr list --state open --json number,labels --limit 200 is 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).

@github-actions github-actions Bot added status:needs-human-merge Principal review done, requires human merge decision and removed status:needs-review QA passed, awaiting principal-review-agent labels Aug 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Human-merge sweep: this PR touches .github/workflows/pr-intake.yml, which falls under this sweep's hard-rule exclusion — it never merges anything touching .github/workflows/**, .github/agent-policy.yml, or .claude/agents/**, regardless of diff quality or risk label. Leaving status:needs-human-merge for a human's direct decision.

(For reference: CI is green, mergeable/CLEAN, and the diff looks like a well-scoped deterministic fix consistent with intake's existing patterns. No concerns raised, just routing per the hard rule.)

@github-actions

Copy link
Copy Markdown
Contributor

Not merging via the sweep: this PR touches .github/workflows/pr-intake.yml, which is on agent-policy.yml's sensitive-path list. Per the sweep's hard rule, PRs touching .github/workflows/**, .github/agent-policy.yml, or .claude/agents/** always route to a human directly, regardless of how clean the diff looks — leaving this for direct human review/merge. (CI is green and mergeable is clean as of this check, for what it's worth.)

@libravault-xyz
libravault-xyz merged commit 6acb64a into dev Aug 22, 2026
16 checks passed
@libravault-xyz
libravault-xyz deleted the fix/pr-intake-missing-status-sweep branch August 22, 2026 16:42
libravault-xyz added a commit that referenced this pull request Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:high Touches a sensitive path or exceeds diff-size threshold — always human merge status:needs-human-merge Principal review done, requires human merge decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dev-agent PRs can end up with no status:* label at all, stalling silently (distinct from #388's missing-risk-label gap)

1 participant