Repository navigation
fix(ci): add deterministic backstop for PRs opened outside the pipeline - #225
Conversation
dev-agent.yml's risk-classification + status:needs-qa handoff only runs as the tail of its own triage-and-implement job, i.e. only for PRs it opens itself via the pipeline App token in that same job run. A PR opened any other way (a human, or a Claude Code session working an issue directly rather than through status:ready-for-dev) never enters that job, so it carries no risk:*/status:* label and nothing downstream ever picks it up. Confirmed live: issue #223's actual fix, PR #224, was opened this way by a session outside the pipeline and sat unlabeled until a human noticed and hand-applied risk:low/status:needs-qa manually. Adds pr-intake.yml: triggers on pull_request opened/reopened, skips PRs authored by libravault-pipeline-bot[bot] (already handled synchronously by dev-agent.yml) and PRs already carrying a pipeline status label (idempotent against reopened re-firing), then runs the same deterministic classify-and-label step dev-agent.yml's tail runs for its own PRs. Runs no agent - pure backstop, not a fourth triage path. Documents the gap and fix in docs/agent-team-pipeline.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
This PR was opened outside the automated pipeline (author isn't |
📱 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 #225
|
There was a problem hiding this comment.
Principal review — PR #225
Risk label: risk:high (correctly applied — the PR touches .github/workflows/pr-intake.yml, matching sensitive_paths: .github/workflows/** in agent-policy.yml; diff is well under the 400-line auto-merge threshold otherwise). No commits landed after the label was last set (single commit 8342be6), so the label is current — re-running classify_pr_risk.py locally reproduces risk:high for the same reason. Per policy this routes to human-merge regardless of findings below.
CI: Verified against the actual check runs, not the PR's own claims — JVM Tests, iOS build, QA Agent verify, and PR Intake intake all show SUCCESS; UI Tests (Emulator) is SKIPPED, consistent with a workflow/docs-only diff. Nothing red.
Finding (CONFIRMED, live-verified)
resolve_linked_issue.sh's closing-keyword regex mismatches prose in this PR's own body, and it's not a hypothetical — it actually fired that way on this exact PR.
The PR's guard step ("Check whether this PR needs intake") is supposed to skip PRs with no linked issue. Pulling the real run log for this PR (gh run view 31994594534 --log, run for PR #225 itself) shows the guard step never printed the "doesn't link an issue" skip path — it went straight through to risk classification, meaning resolve_linked_issue.sh returned a non-empty issue number for PR #225's body.
The PR body opens with "Related to #223 / #224, not closing either" — but later contains "PR #224 (which fixes #223)", describing PR #224, not this PR. resolve_linked_issue.sh's regex (\b(close[sd]?|fix(e[sd])?|resolve[sd]?) #[0-9]+) has no way to distinguish "this PR fixes #N" from prose describing what another PR fixed — it matched "fixes #223" and returned 223 as "the linked issue," directly contradicting the PR's own explicit statement that it doesn't close anything.
In this specific run it's inconsequential — I checked issue #223 (gh issue view 223) and it doesn't carry status:blocked, so the guard proceeded and labeled correctly. But the mechanism is real and will recur, and it's a materially bigger problem for pr-intake.yml than it ever was for dev-agent.yml/qa-agent.yml's existing use of the same script:
dev-agent.ymlonly ever runs this against its own agent-generated PR bodies, which always contain a literal templatedCloses #Nline — there's essentially no ambiguous prose for the regex to misfire against.pr-intake.ymlis specifically built for the opposite case — arbitrary human/session-authored bodies. Referencing other issues/PRs by number in prose (exactly as this PR itself does) is completely normal PR-writing style, not an edge case.
The failure mode this produces is silent and hard to notice: if the guard step resolves to an unrelated issue that does carry status:blocked, it sets skip=true and exits — no PR comment, just a line in the Actions run's stderr — leaving an otherwise-legitimate, unrelated PR sitting with no risk/status label. That's a reoccurrence of the exact bug this PR exists to fix (see #223/#224's history in the PR description), just triggered by an incidental word match instead of "author isn't the pipeline bot."
Suggest before merge: make the guard step's "linked issue resolved to #N but that issue is blocked" path visibly distinct from a genuine no-op (e.g. leave a PR comment naming which issue it matched and why it's skipping), so a human can catch a bad match instead of it disappearing into workflow logs. Tightening the regex itself (e.g. requiring the keyword phrase to be on its own line, closer to how GitHub's own auto-link UI treats it) would also reduce false positives, though a comment-on-skip is probably the more robust fix since prose will always be somewhat ambiguous.
Everything else checked
- No new networking dependency/call (the
pip install pyyaml+gh/API calls all mirror the existing patterndev-agent.yml's tail already uses). - No other
agent-policy.ymlsensitive_pathstouched (.claude/agents/**,agent-policy.ymlitself, vault/crypto, billing, versions.toml all untouched) — and the one sensitive path that is touched (.github/workflows/**) is explicitly flagged in the PR's own "Risk" section, as the persona requires. - Verified
PIPELINE_APP_ID/PIPELINE_APP_PRIVATE_KEYApp-token usage, permissions block, fork-exclusion (head.repo.full_name == github.repository), and pipeline-bot exclusion (user.login != 'libravault-pipeline-bot[bot]') all match the equivalent, already-proven logic indev-agent.yml's own tail step — cross-checked field-for-field, including confirming viagh api repos/.../pulls/221that the raw RESTuser.loginvalue for a pipeline-bot PR really is"libravault-pipeline-bot[bot]"(thegh pr view --json authorCLI wrapper displays it differently, asapp/libravault-pipeline-bot, which could otherwise look like a mismatch). - YAML validated independently (
python3 -c "import yaml; yaml.safe_load(...)") — valid. docs/agent-team-pipeline.mdadditions accurately describe what the workflow actually does; no drift between prose and implementation.- This PR's own
pr-intake.ymladdition self-exercised live on PR #225 (same-repopull_requestruns use the workflow file from the PR's own branch) and did correctly applyrisk:high— so the PR's "Test plan" claim that there's "no way to fire a realpull_request: openedevent pre-merge" undersells what actually happened; it was live-tested by virtue of being opened as a same-repo PR. Worth noting only because it means the finding above isn't theoretical either — it's drawn from this PR's own real run.
Verdict
risk:high alone already mandates human-merge. Combined with the CONFIRMED finding above (real, reproducible, not blast-radius-zero for future PRs even though harmless on this one), routing to a human with the full write-up rather than a bare comment.
…nce (#230) Live on PR #225: qa-agent.yml tried to verify it against issue #223's acceptance criteria, completely unrelated (#225 is a CI pipeline-infra fix; #223 is a separate feature closed by the separate PR #224). Root cause: PR #225's own body mentioned, in passing prose, "PR #224 (which fixes #223)" - background context, not PR #225's own closing keyword - and the shared regex matched it anyway. qa-agent caught the mismatch itself and evaluated the PR on its own merits, but flagged it as a process signal. Confirmed via the GitHub GraphQL API (closingIssuesReferences) that this isn't just our script being loose - GitHub's own real closing-keyword parser is exactly this naive too: it had linked PR #225 as a genuine closing reference for issue #223, meaning merging it would have auto-closed the wrong issue a second time. That's a footgun in GitHub's parser this script can't fix, but resolve_linked_issue.sh's actual job (telling dev-agent/qa-agent/principal-review which issue's acceptance criteria a PR should be judged against) is a stricter question than "what would GitHub technically auto-close" - matching GitHub's looser behavior here isn't worth keeping. Anchors the keyword to the start of its (trimmed) line, stripping optional markdown list/heading/blockquote markers first - matches how every real PR in this pipeline already writes it ("Closes #N" alone on its own line) and rejects mid-sentence mentions. Verified against real PR bodies: #224 still resolves to 223, #229 still resolves to 227, #221 (pre-existing pipeline PR) still resolves to 4, #225 now correctly resolves to nothing. Also cleaned up PR #225's own body to stop tripping this (both the original phrasing and, ironically, an early draft of this explanation itself re-triggered the same match). Closes #228 Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Rebased on top of #230, which already fixed #228's core bug (line-start anchoring instead of a bare \b match). This adds what #230 didn't cover: - resolve_linked_issue.sh now explicitly rejects PR bodies with more than one distinct closing-issue line, instead of silently taking the first match via `head -1` — every downstream caller only supports a single linked issue, so ambiguity now fails loudly (consistent with the script's existing "fail loudly, don't guess" stance on gh failures) rather than picking one guess and dropping the other. - Refactors the matching logic into resolve_from_body() so it can be tested without a live `gh` call; adds test_resolve_linked_issue.sh (13 cases: the real PR #225 false-positive, #230's synthetic cases bullet/heading/indented/blockquote, mid-sentence rejection, the disclosed/enclosed substring guard, and the new ambiguity rejection). No bats/pytest harness exists for .github/scripts/* in this repo — #230's own PR body noted the same gap — so this is a standalone script matching how the sibling scripts here are invoked. - Updates dev-agent.md's PR-body guidance and the two "Could not resolve..." operator-facing messages in dev-agent.yml/qa-agent.yml to say the closing line must stand on its own, so future dev-agent PRs don't unknowingly write it in prose and fall through to "no linked issue" (safe, just misses the automatic QA/review advance). Closes #228
…#232) Rebased on top of #230, which already fixed #228's core bug (line-start anchoring instead of a bare \b match). This adds what #230 didn't cover: - resolve_linked_issue.sh now explicitly rejects PR bodies with more than one distinct closing-issue line, instead of silently taking the first match via `head -1` — every downstream caller only supports a single linked issue, so ambiguity now fails loudly (consistent with the script's existing "fail loudly, don't guess" stance on gh failures) rather than picking one guess and dropping the other. - Refactors the matching logic into resolve_from_body() so it can be tested without a live `gh` call; adds test_resolve_linked_issue.sh (13 cases: the real PR #225 false-positive, #230's synthetic cases bullet/heading/indented/blockquote, mid-sentence rejection, the disclosed/enclosed substring guard, and the new ambiguity rejection). No bats/pytest harness exists for .github/scripts/* in this repo — #230's own PR body noted the same gap — so this is a standalone script matching how the sibling scripts here are invoked. - Updates dev-agent.md's PR-body guidance and the two "Could not resolve..." operator-facing messages in dev-agent.yml/qa-agent.yml to say the closing line must stand on its own, so future dev-agent PRs don't unknowingly write it in prose and fall through to "no linked issue" (safe, just misses the automatic QA/review advance). Closes #228
📱 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. |
Summary
Related to #223 / #224, not closing either — this is a pipeline-infra fix
prompted by what happened on them, not a change to either.
While addressing issue #223's comment thread,
I found that PR #224 — the actual fix for #223 — was opened by a Claude
Code session directly, not by the
dev-agent.ymlworkflow — and as a resultit carried no
risk:*/status:*label at all and nothing downstreamwould ever have picked it up. I had to hand-classify it and manually
apply
risk:low/status:needs-qato get it moving through the pipeline.Root cause
dev-agent.yml's risk-classification +status:needs-qahandoff onlyruns as the last step of its own triage-and-implement job — i.e. only
for PRs it opens itself, via the pipeline App token, in that same job
run. The workflow's own comment on why PR creation doesn't need the App
token explicitly assumed this away: "PR creation itself doesn't trigger
any workflow this pipeline cares about (ours all trigger on
labeled,not
opened)" — true for pipeline-opened PRs, but it meant any PR openedanother way (a human, or a session working an issue directly rather than
through
status:ready-for-dev) falls through every trigger in thepipeline and sits unlabeled indefinitely.
Fix
Adds
pr-intake.yml, a deterministic backstop (no agent):pull_request: opened/reopened.libravault-pipeline-bot[bot](already handledsynchronously by
dev-agent.ymlitself — confirmed live via the APIthat pipeline-opened PRs carry that exact login).
against
reopenedre-firing, and against a PR a human/QA/review roundhas already moved along).
Closes #Netc.) — not a pipeline PR.status:blockedon the linked issue, same asdev-agent.yml.classify_pr_risk.py+ App-tokenstatus:needs-qastep
dev-agent.yml's own tail runs for its own PRs.Documents the gap and the fix in
docs/agent-team-pipeline.md(new "PRintake backstop" section, right after "Cross-workflow triggering").
Risk
Touches
.github/workflows/**, a sensitive path peragent-policy.yml— will classify as
risk:highand land on human-merge regardless, asintended for pipeline-config changes.
Test plan
python3 -c "import yaml; yaml.safe_load(open('.github/workflows/pr-intake.yml'))"— valid YAML.ifconditions and guard-step logic against realAPI data pulled from PR fix(reader): make ReaderTopBar icon button sizes consistent #221 (pipeline-opened:
author.login == "libravault-pipeline-bot[bot]",type: "Bot") and PR feat(ios): add vault deletion to Manage Vaults #224(session-opened:
author.login == "libravault-xyz",is_bot: false)to confirm the exclusion condition discriminates correctly between the
two cases this backstop needs to tell apart.
pull_request: openedevent pre-merge withoutopening a throwaway PR against
dev— deferred to the first real PRthat lands this way after merge; flagged here rather than silently
assumed to work.
Edit history
Reworded the sentence above that used to read "PR #224 (which fixes
#223)" — that incidental phrasing was itself a real closing-keyword match
(confirmed via
closingIssuesReferencesin the GitHub GraphQL API), sothis PR was on track to automatically close issue 223 a second time on
merge despite having nothing to do with it. Root-caused as issue #228,
fixed there.
qa-agent.ymlalso independently caught the resultingissue/PR pairing mismatch live and flagged it — see this PR's own
comments. (Deliberately spelling out "issue 223" instead of "#223" in
this paragraph so this explanation doesn't itself retrigger the exact
bug it's describing.)
🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com