Skip to content

fix(ci): route dev-agent triage failures to needs-info when a PR was found - #239

Merged
libravault-xyz merged 3 commits into
devfrom
fix/dev-agent-triage-pr-found-failure-check
Aug 17, 2026
Merged

libravault-xyz merged 3 commits into
devfrom
fix/dev-agent-triage-pr-found-failure-check

Conversation

@libravault-xyz

@libravault-xyz libravault-xyz commented Aug 17, 2026 •

Copy link
Copy Markdown
Collaborator

What

Force-classify risk and advance to QA in dev-agent.yml checks steps.agent.outcome == 'failure' in two of the three PR_NUMBER cases:

  • revise mode, where the PR is already known
  • triage mode, where no PR was found at all

but not the third: triage mode where a PR was found (either written by the agent to dev-agent-pr-number.txt, or recovered via find_linked_pr.sh's fallback) before the "Run dev agent" step itself failed. In that case the workflow fell straight through to risk-classification and status:needs-qa, treating an unconfirmed PR as if the run had completed cleanly.

Live repro

Run 31998889829: the dev agent was triaging issue #233, reported a successful result, but took 43 turns against the configured 40-turn cap, so the "Run dev agent" step failed. It had already opened PR #234. Force-classify found PR #234 via the fallback lookup and advanced it straight to status:needs-qa — the dev-agent failure was silently dropped. PR #234 only ended up on status:needs-info because qa-agent's own run separately failed (no verdict produced) and hit its own backstop. If QA had happened to pass an unconfirmed diff, nothing would have caught it.

Fix

Add the same steps.agent.outcome == 'failure' check used in the other two cases, right before risk-classification: if the agent step failed, label the PR status:needs-info (with an explanatory comment) and stop, instead of classifying and forwarding to QA.

Not addressed here (separate, lower-priority): once a PR exists, Force-classify only ever edits labels on the PR, never on the originating issue — so issue #233 is still sitting on stale status:ready-for-dev + status:in-progress labels. Filing as a follow-up if wanted, out of scope for this fix.

Testing

This logic lives inline in the workflow's bash step (no standalone script to unit-test, unlike find_linked_pr.sh/resolve_linked_issue.sh). Validated:

  • python3 -c "import yaml; yaml.safe_load(...)" — YAML parses cleanly.
  • Manual trace of all three PR_NUMBER/steps.agent.outcome combinations against the new control flow.

No live workflow run to verify against without triggering a real dev-agent invocation.

Closes #241

…found

Force-classify risk and advance to QA checked steps.agent.outcome for
two of three PR_NUMBER cases (revise mode with a known PR, and triage
mode with no PR found) but not the third: triage mode where a PR was
opened or located via find_linked_pr.sh before the agent step failed
(crashed or exhausted its turn budget). That gap let an unconfirmed PR
be silently risk-classified and advanced to status:needs-qa as if the
run had completed cleanly.

Live-reproduced on run 31998889829 (issue #233 -> PR #234): the dev
agent exceeded its 40-turn budget, but had already opened the PR, so
Force-classify proceeded straight to QA. PR #234 only ended up on
status:needs-info because qa-agent's own run separately failed and hit
its own backstop -- the dev-agent failure itself was never surfaced.

Add the same failure check used in the other two cases: if the agent
step failed, label the PR status:needs-info and stop instead of
classifying and forwarding to QA.
@github-actions

Copy link
Copy Markdown
Contributor

📱 iOS Build Status: FAILED

❌ iOS Simulator Build & Unit Tests - cancelled
✅ 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

@libravault-xyz

Copy link
Copy Markdown
Collaborator Author

Re-opening to re-trigger PR Intake now that the body links #241.

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

Copy link
Copy Markdown
Contributor

This PR was opened outside the automated pipeline (author isn't libravault-pipeline-bot[bot]), so dev-agent.yml's own end-of-run classification step never ran for it — it would otherwise have sat with no risk/status label and nothing downstream would pick it up (see issue #223's actual history). This deterministic backstop (pr-intake.yml) classified its risk and applied status:needs-qa to route it into the normal pipeline from here.

@github-actions

Copy link
Copy Markdown
Contributor

📱 iOS Build Status: FAILED

❌ iOS Simulator Build & Unit Tests - cancelled
❌ Android Core Modules - cancelled

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

View run details

@claude

claude Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

QA verification — PR #239 vs issue #241

Scope: .github/workflows/dev-agent.yml only, +18/-0 lines, single commit. No JVM/Kotlin/Swift code touched.

Acceptance criteria (issue #241)

  • ✅ PR-found + agent-failure → status:needs-info, not QA. Traced the "Force-classify risk and advance to QA" step by hand against the pre-fix version (a39ddfd). Pre-fix: once PR_NUMBER was non-empty (from dev-agent-pr-number.txt or find_linked_pr.sh's fallback), control fell straight through to echo "Classifying risk for PR #$PR_NUMBER" regardless of steps.agent.outcome. Post-fix: a new block at lines 487–493, inserted after the "no PR found" branch (which already exit 0s) and before the risk-classification echo, checks steps.agent.outcome == 'failure' and — if true — removes status:in-progress, adds status:needs-info, posts an explanatory gh pr comment, and exit 0s before ever reaching classify_pr_risk.py or the status:needs-qa label. This exactly reproduces and closes the gap described in the live repro (run 31998889829, issue Release-variant unit tests are broken by construction: ./gradlew test fails #233 → PR fix(build): disable release-variant unit tests repo-wide #234).
  • ✅ Revise-mode and triage-no-PR-found handling unchanged. The diff is purely additive (18 insertions, 0 deletions — confirmed via git diff a39ddfd 4c36918); the two existing steps.agent.outcome == 'failure' checks (lines 400 and 447) are untouched.
  • ✅ YAML parses cleanly. python3 -c "import yaml; yaml.safe_load(open('.github/workflows/dev-agent.yml'))" succeeds.
  • ✅ Control flow traced for all PR_NUMBER / steps.agent.outcome combinations — verified independently above, not just taking the PR description's word for it.

Tests run

  • ./gradlew testDebugUnitTest --continue (full suite, foreground, ~8m46s): BUILD SUCCESSFUL, 429 actionable tasks. Grepped all test-results/**/*.xml for failures="[1-9] / errors="[1-9]" — none found. (One coroutine TestMainDispatcher stack trace appeared mid-log for ReaderViewModelTest but is teardown noise from a worker thread, not a reported test failure — the build and that module's task both report success.) Expected to be a no-op given the change is workflow-only, but run anyway to confirm no regression.
  • No standalone unit test added for the new bash logic, and none is expected: this is inline run: bash inside the workflow YAML, and the repo has no harness for testing GitHub Actions bash steps (confirmed — no .bats/shellspec, and find_linked_pr.sh itself has no test file, only resolve_linked_issue.sh does). The two sibling checks this PR mirrors (99a73ee, adding the revise-mode and triage-no-PR-found failure checks) were also shipped with no test file, only manual trace — same precedent this PR follows.

AGENTS.md conventions

  • Branch name fix/dev-agent-triage-pr-found-failure-check matches fix/<slug> convention.
  • Commit message is Conventional-Commits format (fix(ci): …) with a clear why in the body.
  • Single concern, single commit — no scope creep (the PR body explicitly defers the "issue labels stay stale" follow-up rather than bundling it in).

No gaps found against the issue's acceptance criteria or repo conventions.

QA verdict: PASS

@github-actions github-actions Bot removed the status:needs-qa PR open, awaiting qa-agent verification label Aug 17, 2026
@libravault-pipeline-bot libravault-pipeline-bot Bot added the status:needs-review QA passed, awaiting principal-review-agent label Aug 17, 2026
@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

@libravault-pipeline-bot libravault-pipeline-bot Bot added the status:needs-qa PR open, awaiting qa-agent verification label Aug 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Principal review — PR #239

Verdict: risk:high (label correct, confirmed) → human-merge. No CONFIRMED findings against the diff itself.

What I verified directly

  • Diff scope: only .github/workflows/dev-agent.yml, +18/-0, one commit. Matches the PR description exactly (git diff inspected in full, not summarized).
  • risk:high label is correct and current: the sole changed file matches sensitive_paths: .github/workflows/** in .github/agent-policy.yml. No commits landed after the label was set, so no re-run of classify_pr_risk.py was needed — but I re-derived the classification by hand from the policy file anyway rather than trusting the label blindly.
  • Control-flow trace: read the full "Force-classify risk and advance to QA" step (lines 367–519), not just the diff hunk. The new block at lines 487–493 sits after the "no PR found" branch (which already exit 0s) and before echo "Classifying risk for PR #$PR_NUMBER", so it's only reachable when PR_NUMBER is non-empty and mode is triage (the revise-mode failure path already exits earlier at line 405). This closes exactly the gap described in issue dev-agent: triage failures after PR creation aren't routed to needs-info #241 and the live repro (run 31998889829, issue Release-variant unit tests are broken by construction: ./gradlew test fails #233 → PR fix(build): disable release-variant unit tests repo-wide #234) — traced all PR_NUMBER × steps.agent.outcome combinations by hand and found no path where an unconfirmed PR still reaches classify_pr_risk.py.
  • Token usage: new block uses the default GH_TOKEN (GITHUB_TOKEN) for gh pr edit/gh pr comment, consistent with the two sibling failure-handling blocks it mirrors. status:needs-info isn't a trigger label for dev-agent.yml (only status:ready-for-dev on issues and status:in-progress on PRs are), so there's no cross-workflow-triggering concern that would require the App token — confirmed by reading the on: triggers at the top of the file.
  • Syntax: python3 -c "import yaml; yaml.safe_load(...)" — parses cleanly. Additionally extracted the step's run: block, stripped ${{ }} expressions, and ran bash -n + shellcheck on it myself — no syntax errors, no real shellcheck findings (only expected false positives from the expression-stripping).
  • CI: Unit & Integration Tests (JVM), Build Android App, Build & Test iOS (Simulator), intake all pass. review (this very principal-review workflow run) and iOS UI Tests (informational) are the only non-terminal checks — the latter is explicitly informational and not a merge gate, and it's been stuck pending for a while, which looks like macOS runner queue pressure unrelated to this change (a CI-YAML-only diff can't affect iOS UI test outcomes).
  • QA agent's report (already on the thread) independently traced the same control flow and ran the JVM suite in full (BUILD SUCCESSFUL, no reported failures) — my own trace agrees with it rather than just taking it at face value.
  • Networking: no new network dependency/call introduced. AGENTS.md/commit conventions followed (Conventional Commits, single concern, branch name matches fix/<slug>).

Known, called-out limitation (not a blocking finding)

The PR body explicitly flags that once a PR exists, this step only ever edits PR labels, never the originating issue's — so issue #233 (and future cases hitting this same path) will be left on stale status:ready-for-dev/status:in-progress issue labels even though the PR itself correctly lands on status:needs-info. This is real, but it's an existing pre-existing gap in the surrounding step (the revise-mode branch has the same property, for the same reason — PR_NUMBER known, issue not touched), it's disclosed rather than hidden, and the PR author has explicitly scoped it out with an offer to file a follow-up. Not a reason to block this fix, but worth a human's eyes given the risk:high routing anyway.

Outcome

risk:high is correctly applied (sensitive path: .github/workflows/**), so this routes to human-merge regardless of the clean review — posting via gh pr comment per persona instructions since the change itself is fine and the routing is purely the risk-tier consequence, not a correctness objection.

@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 17, 2026
@claude

claude Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

QA verdict: verified against issue #241

Acceptance criteria (from #241):

  • ✅ PASS — When Run dev agent fails/exhausts its turn budget in triage mode and a PR is nonetheless found (scratch file or find_linked_pr.sh fallback), Force-classify now labels it status:needs-info with an explanatory comment instead of risk-classifying and forwarding to QA. Verified by reading .github/workflows/dev-agent.yml:477-493: the new block sits right after PR_NUMBER is resolved (scratch file or fallback) and before the echo "Classifying risk..." line, checks steps.agent.outcome == 'failure', removes status:in-progress, adds status:needs-info, comments, and exits 0 — mirroring the two existing checks (revise-mode at L400, triage-no-PR-found at L447).
  • ✅ PASS — Existing revise-mode and triage-no-PR-found failure handling is unchanged. gh pr diff 239 shows a pure addition (+18/-0 lines); the surrounding blocks are byte-for-byte identical to what's on dev.
  • ✅ PASS — YAML parses cleanly and control flow was traced for all PR_NUMBER/steps.agent.outcome combinations, independently reproduced (not just taking the PR description's word for it):
    • python3 -c "import yaml; yaml.safe_load(open('.github/workflows/dev-agent.yml'))" → parses.
    • Extracted the step's run: bash script, substituted the GitHub Actions expressions, and ran bash -n (syntax OK) and shellcheck (only spurious SC2050 "constant expression" warnings from my literal substitution of ${{ }} expressions — not a real issue).
    • Manually traced all 4 reachable combinations: revise+failure (L400, unchanged) → needs-info on PR; triage+no-PR+failure (L447, unchanged) → needs-info on issue; triage+PR-found+failure (L487, new) → needs-info on PR; triage+PR-found+success → falls through to risk-classification unchanged. All four behave as specified.

What I ran:

No gaps found. This PR does exactly what #241 asks, doesn't touch the two existing failure-handling branches, and the new branch's control flow is sound.

QA verdict: PASS

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

Copy link
Copy Markdown
Contributor

Principal review — PR #239

Verdict: risk:high (confirmed) → human-merge. No CONFIRMED findings against the diff.

What I independently verified (not just re-reading the prior comments on this thread)

  • Diff scope: git diff shows exactly one file, .github/workflows/dev-agent.yml, +18/-0, one commit. Matches the PR description.
  • Risk label: re-ran .github/scripts/classify_pr_risk.py origin/dev HEAD myself (after unshallowing the clone, since the shallow checkout otherwise fails the git diff it shells out to) — it independently outputs risk:high, matching path .github/workflows/**. The label is current; only one commit exists on this branch.
  • Control-flow correctness: read the full "Force-classify risk and advance to QA" step (not just the diff hunk) and traced all four reachable mode × PR_NUMBER × steps.agent.outcome combinations by hand:
    • revise + failure → existing block, unchanged, exits before reaching the new code.
    • triage + no PR found + failure → existing block, unchanged, exits before reaching the new code.
    • triage + PR found + failure → new block, correctly placed after PR_NUMBER resolution (scratch file or find_linked_pr.sh fallback) and before classify_pr_risk.py, removes status:in-progress, adds status:needs-info, comments, exits 0.
    • triage + PR found + success → falls through to risk-classification unchanged.
      This closes exactly the gap in the live repro (run 31998889829, issue Release-variant unit tests are broken by construction: ./gradlew test fails #233 → PR fix(build): disable release-variant unit tests repo-wide #234).
  • No self-trigger risk: the new block labels the PR status:needs-info using the default GITHUB_TOKEN. Checked dev-agent.yml's own pull_request: types: [labeled] guard condition (line 85) — it only reacts to status:in-progress, not status:needs-info, so this can't cause a recursive re-trigger of this same workflow. Consistent with the two sibling blocks it mirrors, which use the same token for the same reason.
  • YAML/shell sanity: python3 -c "import yaml; yaml.safe_load(...)" parses cleanly. bash -n on the extracted run: block (after stripping ${{ }} expressions) has no syntax errors.
  • Test exemption is legitimate, not just asserted: AGENTS.md requires tests for bug fixes, but this is inline run: bash in workflow YAML with no test harness in the repo (no .bats/shellspec, find_linked_pr.sh itself has no test file). Checked the precedent the PR cites — commit 99a73ee (fix(ci): detect a dev-agent crash mid-triage, not just mid-revise #212), which added the sibling revise-mode/triage-no-PR-found checks — and confirmed it also shipped with no test file, only a manual trace. Same exemption, same precedent, actually verified rather than taken on faith.
  • CI: JVM tests, Android build, iOS build/tests, and PR Intake all green. No new networking dependency introduced. status:blocked not present on the PR or on issue dev-agent: triage failures after PR creation aren't routed to needs-info #241.

Outcome

Sole changed file matches sensitive_paths: .github/workflows/** in .github/agent-policy.yml, so this routes to human-merge on the risk tier alone, independent of the clean review — posting via gh pr comment per persona instructions since there's no correctness objection driving this, just the sensitive-path routing.

@github-actions github-actions Bot removed the status:needs-review QA passed, awaiting principal-review-agent label Aug 17, 2026
@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

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

@libravault-xyz
libravault-xyz merged commit 7b0c812 into dev Aug 17, 2026
7 checks passed
@libravault-xyz
libravault-xyz deleted the fix/dev-agent-triage-pr-found-failure-check branch August 17, 2026 08:31
libravault-xyz added a commit that referenced this pull request Aug 17, 2026
)

* fix(ci): self-heal stale branch during principal-review auto-merge

"Auto-merge if approved" treated any gh pr merge failure the same way
-- conflict, branch protection, or a merely-stale branch all fell
through to status:needs-human-merge with a generic error message. In
a busy pipeline, dev routinely advances between approval and the
actual merge call (other PRs from the same pipeline landing
concurrently), which makes gh pr merge fail on "the head branch is
not up to date with the base branch" -- a transient, self-resolvable
race, not a real problem with the PR.

Live-hit manually merging PR #239 (issue #246): the branch went
BEHIND twice within ~15 minutes from ordinary pipeline throughput,
each requiring a manual git-merge-and-push before gh pr merge would
succeed.

Before each merge attempt, check mergeStateStatus:
- BEHIND -> request GitHub's server-side "Update branch"
  (PUT /pulls/{n}/update-branch) and retry, bounded.
- DIRTY (real conflict) -> don't retry, route to
  status:needs-human-merge immediately, same as before.
- UNKNOWN (mergeability still computing) -> brief bounded wait, then
  re-check.
Bounded outer retry (5 attempts) so a burst of concurrent merges
doesn't defeat auto-merge, while a genuinely stuck/failing merge
still terminates and routes to a human instead of spinning
indefinitely.

* fix(ci): guard mergeStateStatus lookup against transient gh failures

QA on PR #247 (issue #246) found a real gap: MERGE_STATE=$(gh pr view
... -q .mergeStateStatus) is an unguarded command substitution under
set -euo pipefail. A transient gh API failure there (timeout,
rate-limit) kills the whole step before it ever reaches the
DIRTY/status:needs-human-merge fallback, leaving the PR silently
stuck on status:approved-auto-merge with no comment -- ironic given
this step exists specifically to add resilience against transient
failures.

Guard it the same way the CI-wait loop above already guards its own
gh pr checks call (2>/dev/null || echo "pending"): a failed lookup
now falls into the existing bounded UNKNOWN wait-and-recheck branch
instead of crashing the step.

The dev agent diagnosed and wrote this exact fix during PR #247's
automated revise round but couldn't push it -- GitHub blocks App
tokens from pushing to .github/workflows/** without an explicit
`workflows` permission grant this pipeline's installation doesn't
have (same standing gap noted in issue #246's history). Applying it
manually as the human it routed to.
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: triage failures after PR creation aren't routed to needs-info

1 participant