Skip to content

fix(ci): re-classify PR risk on every push, not just PR-open - #560

Open
libravault-pipeline-bot[bot] wants to merge 2 commits into
devfrom
fix/pr-intake-reclassify-on-push
Open

libravault-pipeline-bot[bot] wants to merge 2 commits into
devfrom
fix/pr-intake-reclassify-on-push

Conversation

@libravault-pipeline-bot

Copy link
Copy Markdown
Contributor

Problem

pr-intake.yml (the deterministic risk-classification backstop for PRs opened outside the automated dev-agent pipeline) only ran classify_pr_risk.py once, at PR-open time (pull_request: opened/reopened). Subsequent pushes to an already-open PR never re-triggered it, unlike dev-agent.yml's own tail step, which re-classifies after every push it makes during a revise-mode run.

Concrete case (PR #543): opened with a single low-risk commit, correctly classified risk:low. Nine more commits were pushed afterward via plain git push, including one touching core/vaultstore/** (a sensitive_paths entry). The risk:low label never updated, even though the final diff is actually risk:high. Caught manually during review.

This matters because agent-policy.yml's whole design assumes risk:high is a hard backstop, independent of what QA/review conclude — a PR that starts small and grows into sensitive-path territory can otherwise stay eligible for auto-merge for its entire lifetime if it wasn't opened by the pipeline bot itself.

Fix

  • pr-intake.yml now also triggers on pull_request: synchronize.
  • On synchronize, the intake job re-runs classify_pr_risk.py --apply-label (idempotent — it just does a remove-other/add-current label swap) but explicitly skips:
    • the "already carries a pipeline status label" idempotency guard (that guard exists to stop opened/reopened from redoing intake on a PR already in the pipeline — for synchronize that state is exactly what's expected, not a skip condition)
    • the status:needs-qa/status:needs-review handoff itself, and the accompanying PR comment (redoing that on every push would fight whatever status a QA/review round has since moved the PR to)
  • The status:blocked-on-linked-issue check still applies on every push (still skips reclassification for a blocked issue, consistent with "leave this alone" semantics), but only posts its explanatory comment on opened/reopened to avoid reposting it on every subsequent push to a blocked PR.
  • Bot-authored PRs (libravault-pipeline-bot[bot]) remain excluded from this workflow entirely, including on synchronize — dev-agent.yml's own tail step already reclassifies after each push it makes during a revise-mode run, so there's nothing for this workflow to catch there.
  • Updated docs/agent-team-pipeline.md's description of pr-intake.yml to match.

Risk

This touches .github/workflows/pr-intake.yml, which matches agent-policy.yml's sensitive_paths (".github/workflows/**") — classify_pr_risk.py will force risk:high on this PR regardless of anything said here, so this is flagged explicitly per the dev-agent persona's instructions, not to argue it away.

Verification

  • python3 -c "import yaml; yaml.safe_load(open('.github/workflows/pr-intake.yml'))" — YAML parses cleanly.
  • No existing automated test harness covers inline pull_request workflow-step bash in this repo (the .github/scripts/test_*.sh files only cover standalone scripts like resolve_linked_issue.sh) — this change doesn't add a standalone script, so there's nothing new to add a harness for. I traced both EVENT_ACTION branches (opened/reopened vs. synchronize) by hand against the guard/classify step logic above.
  • Could not locally simulate an actual pull_request: synchronize GitHub Actions event (no self-hosted runner / act available here) — CI running this workflow for real on this PR's own subsequent pushes is the actual verification signal once it's live.

Closes #558

pr-intake.yml only ran classify_pr_risk.py at pull_request: opened/
reopened, so a non-pipeline-authored PR that started risk:low and later
grew into sensitive-path territory via a plain git push stayed
mislabeled for its entire lifetime — defeating risk:high's role as a
hard auto-merge backstop (confirmed live on PR #543).

Add pull_request: synchronize to the trigger and, on that event, only
re-run the deterministic risk classifier (idempotent) without redoing
the status:needs-qa/status:needs-review handoff, since the PR is
already further along the pipeline than "just intake'd" by the time
it's pushed to again.

Closes #558
@github-actions
github-actions Bot marked this pull request as ready for review August 24, 2026 20:56
@github-actions github-actions Bot added the risk:high Touches a sensitive path or exceeds diff-size threshold — always human merge label Aug 24, 2026
@libravault-pipeline-bot libravault-pipeline-bot Bot added the status:needs-qa PR open, awaiting qa-agent verification label Aug 24, 2026
@claude

claude Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

QA verification — PR #560 vs. issue #558

Issue is a bug/process report (no explicit acceptance checklist), so the bar applied is: the repro case (PR #543 — risk label never updated after a plain git push added a sensitive-path commit) no longer reproduces, and the mechanism is exercised, not just asserted in prose.

Checks

  • ✅ on.pull_request.types now includes synchronize (.github/workflows/pr-intake.yml:66), alongside opened/reopened — closes the actual gap issue pr-intake.yml never re-classifies risk on pushes after PR open (PR #543) #558 reports.
  • ✅ classify_pr_risk.py --apply-label re-runs on synchronize and refreshes the risk label idempotently (unchanged script, confirmed by reading it — the apply_label() remove-other/add-current swap already handles repeated calls safely).
  • ✅ Status handoff correctly not re-run on synchronize — the classify step exits right after the risk relabel when EVENT_ACTION = synchronize, before ever reaching the status:needs-qa/status:needs-review branch. Verified by reading the step logic; it can't fight an in-flight QA/review round the way an unconditional handoff would.
  • ✅ Idempotency guard correctly skipped only for synchronize, not opened/reopened — traced the guard step and reproduced it in an isolated bash harness (mocked gh pr view/gh issue view/gh pr comment + resolve_linked_issue.sh) across 5 scenarios: synchronize+already-labeled → proceeds (skip=false); synchronize+blocked-linked-issue → skips, no comment; opened+blocked-linked-issue → skips, comment posted; opened+already-labeled → skips via idempotency guard; synchronize+unlabeled+unblocked → proceeds. All five matched the PR's stated design exactly.
  • ✅ status:blocked comment only posted on opened/reopened, not re-posted on every synchronize to a blocked PR — confirmed in the same harness run (scenario 2 above: 0 comments posted on a blocked-issue synchronize).
  • ✅ Bot-authored PRs (libravault-pipeline-bot[bot]) still excluded on synchronize — the job-level if: gates on github.event.pull_request.user.login, the PR's original author, which is unaffected by who pushes the triggering commit. dev-agent.yml's own tail step already reclassifies after its own pushes, so this is correctly a no-op for that path, not a double-classification.
  • ✅ YAML parses cleanly (python3 -c "import yaml; yaml.safe_load(...)") and shellcheck finds no issues in any of the three inline run: blocks (GH Actions ${{ }} expressions swapped for placeholders first, to isolate real shell bugs from expected false positives).
  • ✅ docs/agent-team-pipeline.md accurately describes the new synchronize behavior and the idempotency-guard carve-out — matches the actual workflow logic.
  • ⚠️ No automated regression test ships with this change — but this is consistent with existing repo convention, not a new gap: the .github/scripts/test_*.sh harnesses only cover standalone extracted scripts (resolve_linked_issue.sh, find_linked_pr.sh, etc. — reused across multiple workflows), and no other workflow's single-file inline pull_request-triggered bash has a test harness either. I verified the actual logic myself via the bash-harness simulation above, which is the same coverage a test would have provided.
  • ⚠️ Minor commit-hygiene note: the branch carries a merge commit (2ce5d47, merging origin/dev back in) rather than a rebase, where AGENTS.md's "Working in a worktree" section states to rebase onto dev before opening a PR. Not functionally significant and doesn't affect this review's verdict.
  • N/A ./gradlew testDebugUnitTest --continue — ran it anyway per QA persona's standing instruction: BUILD SUCCESSFUL in 8m 15s, 439 actionable tasks, no failures. Diff touches only .github/workflows/pr-intake.yml and docs/agent-team-pipeline.md, no Kotlin/JVM code, so this is a baseline-health check rather than a targeted regression check for this change.
  • ✅ PR's own "Risk" section correctly self-flags risk:high (touches .github/workflows/**, a sensitive_paths entry) — matches the label actually on the PR (risk:high).

Verdict rationale

The fix directly closes the gap described in #558 and confirmed live on PR #543: a risk label that only gets set once, at PR-open time, can go stale as a PR grows into sensitive-path territory. The synchronize-triggered reclassification is idempotent, doesn't disturb in-flight QA/review status, doesn't affect bot-authored PRs, and the guard/comment carve-outs behave exactly as documented — verified by direct simulation, not just by reading the diff. No functional defects found.

QA verdict: PASS

@github-actions github-actions Bot removed the status:needs-qa PR open, awaiting qa-agent verification label Aug 24, 2026
@libravault-pipeline-bot libravault-pipeline-bot Bot added the status:needs-review QA passed, awaiting principal-review-agent label Aug 24, 2026

@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.

Principal review — verdict: human-merge

Risk classification

risk:high is correctly applied and current (label timestamp
2026-08-24T20:56:34Z is after the branch's last commit,
2026-08-24T20:55:17Z). Independently re-ran
classify_pr_risk.py origin/dev origin/fix/pr-intake-reclassify-on-push
myself — confirms risk:high, .github/workflows/pr-intake.yml matches
the sensitive_paths pattern .github/workflows/**. risk:high alone
already forces human-merge regardless of the finding below; the PR's own
"Risk" section correctly self-flags this.

What the PR does

Adds pull_request: synchronize to pr-intake.yml's trigger so
classify_pr_risk.py re-runs on every push to an in-flight PR, not just at
open time — closing the real gap #558 describes (confirmed live on #543: a
PR that started risk:low and grew into core/vaultstore/** via plain
pushes never got relabeled). On synchronize it deliberately skips the
idempotency guard (correct — that guard's "already has a status label"
condition is exactly the expected state on a later push) and skips redoing
the status:needs-qa/status:needs-review handoff (correct — would
otherwise fight an in-flight QA/review round). Traced both EVENT_ACTION
branches by hand against the actual step logic; they do what the PR
description claims.

CONFIRMED finding — filed as #561

Skipping the idempotency guard on synchronize also skips the only
place pr-intake.yml checked a PR's own status:blocked label — that
guard's regex incidentally included blocked alongside
needs-qa/needs-review/etc. The guard step's remaining blocked check
only looks at the linked issue's labels
(.github/workflows/pr-intake.yml:161-180), and only if an issue is
linked at all.

Per docs/agent-team-pipeline.md: "applying status:blocked to an issue
or PR stops every agent from acting on it" — every sibling workflow
(dev-agent.yml, qa-agent.yml, principal-review.yml) enforces this
with a dedicated, unconditional check of the PR's own labels; pr-intake.yml
only ever got this via the guard's side effect, and this PR's synchronize
carve-out drops it for that event without replacing it.

Concretely: a PR with status:blocked applied directly (not via its
linked issue, or with no linked issue at all) still gets
classify_pr_risk.py --apply-label run against it on the next push,
changing its risk:* label despite a human having explicitly paused it.
Reproduced locally by extracting the guard logic with gh mocked to
report status:blocked as the PR's only label and no linked issue —
skip never becomes true.

This wasn't caught by QA's own bash-harness simulation either (its 5
scenarios cover issue-level blocking and idempotency, but not a
PR-level-only status:blocked on synchronize).

Filed as #561, fix sketch included there (check the PR's own
status:blocked unconditionally, same pattern as the other three
workflows' guard steps, separate from the opened/reopened-only
idempotency check).

Minor, non-blocking

  • Branch carries a merge commit (2ce5d47) instead of a rebase onto
    dev, per AGENTS.md's "Working in a worktree" section (git worktree add → rebase before opening a PR). Doesn't affect correctness, already
    flagged by QA.

Other checks

  • No new networking dependency/call introduced.
  • Only sensitive path touched is .github/workflows/pr-intake.yml itself,
    which the PR description explicitly flags (per policy, not to argue it
    away) — consistent with the persona's requirement.
  • docs/agent-team-pipeline.md update accurately reflects the new
    synchronize behavior and guard carve-out.
  • CI: path-filtered JVM/iOS/UI suites correctly skip (docs+workflow-only
    diff); no red checks.

Outcome

risk:high plus a CONFIRMED finding (#561) — routing to human-merge.
The synchronize fix itself is sound and closes a real gap; the blocked-PR
edge case is worth fixing before or shortly after merge, a human's call.

@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 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Human-merge sweep: this PR modifies .github/workflows/pr-intake.yml. Per this repo's hard rule (.claude/agents/human-merge-sweep-agent.md), this sweep never merges anything touching .github/workflows/**, .github/agent-policy.yml, or .claude/agents/**, however clean the diff looks — those files change what agents in this repo are allowed to do unattended. Leaving this for a human to merge directly; no blocking correctness issue found in a read of the diff.

@github-actions

Copy link
Copy Markdown
Contributor

Human-merge sweep: re-verified. Diff matches the principal review's description — synchronize now re-runs classify_pr_risk.py while correctly skipping the idempotency guard and the status handoff, closing the real gap from #558/PR #543. CONFIRMED finding #561 (the synchronize carve-out also skips the PR's own status:blocked check, since the idempotency guard was the only place that happened) is filed, open, and accurately described. No commits landed after the review (last commit 2026-08-24T20:55:17Z, review at 21:12:35Z), so nothing has drifted. This PR's only touched files (.github/workflows/pr-intake.yml, docs/agent-team-pipeline.md) put it on this sweep's hard-rule exclusion list regardless of review outcome — leaving for a human to merge directly.

@github-actions

Copy link
Copy Markdown
Contributor

Human-merge sweep: re-verified again. No new commits since the last review (still 2ce5d47, 2026-08-24T20:55:17Z) and no defect found beyond the already-filed CONFIRMED finding #561. New since the last check: this PR now shows mergeStateStatus: DIRTY / mergeable: CONFLICTING against dev — checked whether it's superseded (issue #558 is still open, only linked closer is this PR itself), so this is ordinary drift from other PRs merging into dev, not staleness. Still on this sweep's hard-rule exclusion list regardless (.github/workflows/pr-intake.yml) — leaving for a human, who will also need to rebase before merging.

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.

pr-intake.yml never re-classifies risk on pushes after PR open (PR #543)

0 participants