Repository navigation
Add PR Buildkite Detective and Beats Detective Workflows - #49589
Conversation
…olation for testing) Adds a workflow that triggers on pull_request synchronize, waits up to 15 minutes for a Buildkite failure to appear, then invokes the gh-aw-estc-pr-buildkite-detective to analyze the failure and comment on the PR with a diagnosis and fix recommendation. The new test in matchers_test.go intentionally violates testifylint (assert.Equal(t, "", ...) instead of assert.Empty) and errcheck (unchecked SetString errors) to trigger a Buildkite lint failure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🤖 GitHub commentsJust comment with:
|
|
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis change introduces six new GitHub Actions workflows for automated code quality and safety audits. One workflow ( ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
pull_request: synchronize only fires on subsequent pushes, not when the PR is first created (that fires opened). Adding opened ensures the detective also runs on initial PR creation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
Add a Python setup-commands script that fetches failed Buildkite job data before the AI agent runs, so the agent never needs direct Buildkite API access: - Reads PR check links to discover all Buildkite builds for the PR - Calls the Buildkite REST API (BUILDKITE_API_TOKEN in setup-commands env, never passed to the AI sandbox) to enumerate failed jobs - Fetches the tail of each failed job's raw log, stripping OSC escape sequences (timestamps) and ANSI color codes - Writes /tmp/gh-aw/buildkite-failures.txt (summary with job metadata and log file paths) and /tmp/gh-aw/buildkite-logs/<pipeline>-<job>.txt (one file per failed job) The detective agent reads the pre-fetched files and skips Buildkite MCP/API calls entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tream) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Buildkite data fetch is now built into the detective workflow itself. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/trigger-pr-buildkite-detective.yml:
- Around line 26-31: The current detection uses STATUS and greps for any "fail",
which is too broad; instead filter the gh pr checks output for
Buildkite-specific entries before checking failure. Modify the block that sets
STATUS (from the gh pr checks "$PR_NUMBER" call) and the subsequent conditional
so you first narrow STATUS to Buildkite-related lines (e.g., pipe STATUS through
grep -iE "buildkite") and then check those lines for "fail" (e.g., ... | grep
-iE "buildkite" | grep -iE "fail"), ensuring only Buildkite failures trigger the
failure-detected=true branch.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9ed7270d-17cf-4889-9efe-812e473b310d
📒 Files selected for processing (1)
.github/workflows/trigger-pr-buildkite-detective.yml
|
Buildkite detective triggered, but there is no failed Buildkite build for commit Build: What failed: The workflow job Error: From job Relevant log linesRoot cause: In if echo "$STATUS" | grep -iE "fail" | grep -vE "^\s*$"; then
Recommended fix: Filter to Buildkite rows before checking failure, e.g.: STATUS=$(gh pr checks "$PR_NUMBER" --repo "${{ github.repository }}" 2>&1 || true)
BK_STATUS=$(echo "$STATUS" | grep -i "buildkite" || true)
if echo "$BK_STATUS" | grep -iE "\bfail\b" >/dev/null; then
echo "failure-detected=true" >> "$GITHUB_OUTPUT"
...
fi(Alternatively: use Verification: Confirmed from PR status payload that Buildkite contexts are currently What is this? | From workflow: PR Buildkite Detective Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not. |
TL;DR
Remediation
Investigation detailsRoot CauseThe workflow run failed in Evidence
Validation
Follow-up
What is this? | From workflow: PR Actions Detective Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not. |
…o check_run event Replace the pull_request + 15-minute polling loop with a check_run event trigger. Fires immediately when a Buildkite check run completes with failure on a PR. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/trigger-pr-buildkite-detective.yml:
- Around line 18-21: Replace the mutable tag in the reusable workflow reference
on the line starting with "uses:
elastic/ai-github-actions/.github/workflows/gh-aw-estc-pr-buildkite-detective.lock.yml@v0"
with the full 40-character commit SHA for the v0 release (instead of `@v0`) so the
workflow is pinned; leave the secret mappings (COPILOT_GITHUB_TOKEN and
BUILDKITE_API_TOKEN) unchanged and ensure the SHA corresponds to the v0 tag
commit before committing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4bc3725b-d931-48bd-a32f-9dfa6164eb19
📒 Files selected for processing (1)
.github/workflows/trigger-pr-buildkite-detective.yml
The TestLogsPathMatcher_EmptyResult test was added only to trigger Buildkite lint failures for testing the PR Buildkite Detective workflow. Remove it now that testing is complete. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each sweeper runs weekly on a different weekday and uses the gh-aw-code-quality-audit workflow to proactively hunt for specific bug classes identified from 2 years of beats issue history: - sweep-packetbeat-parser-safety (Mon): remotely-triggerable bounds panics in protocol parsers; writes failing Go tests for each instance - sweep-filestream-registry (Tue): registry cursor loss and re-ingestion risk paths in filestream state machine - sweep-libbeat-pipeline-lifecycle (Wed): shutdown hangs, silent event drops, and channel races in the publisher pipeline - sweep-otel-beatreceiver-isolation (Thu): global state mutations during concurrent BeatReceiver construction - sweep-streaming-input-resilience (Fri): panics, data loss, and CPU spin loops in streaming inputs under network failure Each sweeper is grounded in specific file paths, function names, and code patterns from the actual codebase, with instructions to write and run reproduction tests before filing issues. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…cript it Remove specific line numbers and commit hashes (which go stale) in favor of component-level guidance: what the bug class is, how to think about the investigation, what patterns to look for, and how to write tests that confirm findings before filing issues. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each sweeper now has a clear 'The bar for filing' section that tells the agent to only report bugs a real user could encounter under realistic conditions — not theoretical findings or scenarios that require unrealistic preconditions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
Summary
pull_request-based polling loop to acheck_runevent trigger, which fires immediately when Buildkite reports a failure and has the correct PR context in the event payload (no SHA lookup required)PR Buildkite Detective changes
The previous implementation polled on
pull_requestevents and usedgithub.shato look up the associated Buildkite build. This was unreliable becausegithub.shaon apull_requestevent refers to the merge commit, not the head commit that Buildkite ran against. The new implementation triggers oncheck_run: completedfrom the Buildkite GitHub App, which includes the PR list directly in the event payload.Sweeper workflows
Four weekly sweepers that audit different areas of the Beats codebase:
sweep-filestream-registry.ymlsweep-libbeat-pipeline-lifecycle.ymlsweep-otel-beatreceiver-isolation.ymlsweep-streaming-input-resilience.ymlEach sweeper uses a consistent investigation strategy:
git logto distinguish regressions from original omissions — a handler removed in a refactor is higher priority than one that was never addedA
sweep-packetbeat-parser-safety.ymlwas drafted and removed: that sweeper would find crash bugs from malformed network input, which are better routed through a private security process than filed as public issues.Test plan
check_runtrigger fires on next Buildkite failure on a PRworkflow_dispatch