Skip to content

feat: find flaky checks (prw flaky, MCP get_flaky_checks) - #22

Merged
devblac merged 1 commit into
feat/failed-job-logsfrom
feat/flaky-detection
Oct 25, 2026
Merged

devblac merged 1 commit into
feat/failed-job-logsfrom
feat/flaky-detection

Conversation

@devblac

@devblac devblac commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Roadmap #16. A job that failed and then passed when its workflow run was re-run — same commit, same code — is flaky. prw flaky finds them.

$ prw flaky grafana/grafana
grafana/grafana: scanned 300 workflow run(s) since 2026-10-24, 3 of them re-run.

FLAKED  WORKFLOW            JOB                         LAST SEEN         LATEST FAILED ATTEMPT
1x      Backend Unit Tests  Grafana Enterprise (3/8)    2026-10-24 15:32  https://github.com/grafana/grafana/actions/runs/…/job/…
1x      Integration Tests   Sqlite Enterprise (2/16)    2026-10-24 15:25  https://github.com/grafana/grafana/actions/runs/…/job/…

How

  • Lists the repo's last --runs workflow runs (default 300, max 1000); for each run with run_attempt > 1, fetches the jobs of every attempt.
  • A job is flaky in a run if it failed (failure / timed_out) in one attempt and succeeded in a later one. Cancelled jobs (fail-fast victims) don't count; jobs that kept failing aren't flaky. Counted once per run.
  • Grouped by workflow + job: count, last seen, link to the latest failed attempt; most frequent first. --json.
  • Accepts owner/repo or any GitHub URL in the repo (e.g. a PR URL).
  • MCP get_flaky_checks: lets an agent tell a known-flaky failure from one its change caused.
  • Speed: GitHub takes ~3–4 s per runs/jobs request on large repos, so pages and attempts are fetched in parallel (4 in flight) and runs are listed with exclude_pull_requests=true. grafana/grafana: 24 s → 9 s.
  • The "status history" half of feat: auto-watch your PRs and review requests (prw watch --mine) #16 was dropped: low value for its cost.

Test plan

  • go test ./... -race, go vet ./...
  • Detection rules (cancelled, kept failing, timed_out, several attempts, count per run, ordering, fetch errors as warnings, run cap), concurrent pagination order and stop, repo argument parsing, output, command against a fake API, MCP tool
  • A test caught a real bug (no link when timestamps are missing) — fixed
  • Live: grafana/grafana (4 flaky jobs / 300 runs), hashicorp/terraform (Quick Checks / Unit Tests), devblac/prw (none), MCP over stdio

Stacked on #21.

🤖 Generated with Claude Code

A job that failed and then passed when its workflow run was re-run is flaky:
same commit, same code, different result. `prw flaky <owner/repo | URL>`
scans the repository's last --runs workflow runs (default 300, max 1000),
fetches the jobs of every attempt of the re-run ones, and reports each job
that failed (failure / timed_out) in one attempt and succeeded in a later one,
grouped by workflow and job: how many runs it flaked in, when last, and the
latest failed attempt's link. Cancelled jobs (fail-fast victims) don't count;
jobs that kept failing aren't flaky. `--json` for scripts.

The MCP tool `get_flaky_checks` gives agents the same, so they can tell a
known-flaky failure from one their change caused.

GitHub takes seconds per runs/jobs request on large repositories, so pages
and attempts are fetched in parallel (4 at a time) and runs are listed
without their pull_requests payload: grafana/grafana went from 24s to 9s.

Verified live: grafana/grafana (4 flaky jobs in 300 runs), hashicorp/terraform
("Unit Tests"), devblac/prw (none) and over MCP stdio.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T00:04:53.827313Z c15292f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devblac
devblac merged commit ecc0eaf into feat/failed-job-logs Oct 25, 2026
@devblac
devblac deleted the feat/flaky-detection branch October 25, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant