← Back to Pull requests

TRT-2884: add backfill-infra-failures command (phase 2) #3927

Closed
unknown closed this pull request without merging on Aug 25, 2026 13:19 UTC
View on GitHub
unknown unknown commented on Aug 20, 2026 20:04 UTC
Author

Summary

Adds a backfill-infra-failures CLI command that syncs InfraFailure labels from BigQuery into PostgreSQL and corrects the shared summary tables. This is Phase 2 of TRT-2884, building on the foundation from #3922.

Problem

PG's prow_job_runs.labels is only populated at initial load or by the re-evaluator — it is not kept in sync with BigQuery's job_labels table. As a result, ~85% of InfraFailure-labeled runs in BQ are missing the label (and the corresponding summary table corrections) in PG.

What this PR adds

New command: sippy backfill-infra-failures

A management command that:
1. Queries BQ job_labels for InfraFailure-labeled runs within a configurable time window
2. Pre-checks PG in batches to classify already-labeled vs missing runs
3. Calls RecordInfraFailure() for each missing run — atomically adding the label AND subtracting from all summary tables
4. Reports statistics: total BQ runs found, already labeled in PG, newly synced, errors

Flags

| Flag | Default | Description |
|------|---------|-------------|
| --since | (none) | Start of time window (date string, e.g. 2026-07-01) |
| --days | 90 | Look back N days from now (used when --since is not set) |
| --dry-run | false | Report what would be done without making changes |
| --batch-size | 100 | Process runs in batches of this size |

Plus the standard --database-dsn, BigQuery, and Google Cloud credential flags.

Key design points

  • Idempotent: Safe to run repeatedly — RecordInfraFailure is a no-op for already-labeled runs

  • Testable: Core logic uses function-field seams (matching the project's regressiontracker.go pattern) for unit-testable pure functions

  • Thin command layer: cmd/sippy/backfill_infra_failures.go wires up clients; pkg/dataloader/infrafailurebackfill/backfill.go holds all logic

  • Outcome tracking: RecordInfraFailureWithOutcome distinguishes subtracted / already-labeled / not-found for accurate stats reporting
  • Evidence from local testing

    Labeling (7-day window against staging DB)

    $ ./sippy backfill-infra-failures \
      --database-dsn "$STAGING_DSN" \
      --days 7 \
      --log-level info
    sippy built from f56456bf7
    INFO starting InfraFailure backfill  batchSize=100 dryRun=false since=2026-08-15
    INFO fetched InfraFailure runs from BigQuery  count=22
    INFO InfraFailure backfill complete  alreadyLabeled=1 errors=0 newlySynced=1 notFoundInPG=20 totalBQRuns=22
    INFO backfill-infra-failures completed successfully
    

  • 22 InfraFailure runs found in BQ for the last 7 days

  • 1 newly synced (label + summary subtraction applied)

  • 1 already labeled (correctly skipped)

  • 20 not found in staging PG (correctly skipped)
  • Idempotency (re-run immediately after)

    $ ./sippy backfill-infra-failures \
      --database-dsn "$STAGING_DSN" \
      --days 7 \
      --log-level info
    sippy built from f56456bf7
    INFO starting InfraFailure backfill  batchSize=100 dryRun=false since=2026-08-15
    INFO fetched InfraFailure runs from BigQuery  count=22
    INFO InfraFailure backfill complete  alreadyLabeled=2 errors=0 newlySynced=0 notFoundInPG=20 totalBQRuns=22
    INFO backfill-infra-failures completed successfully
    

  • 0 newly synced, 2 already labeled — confirms the previously-synced run is now correctly detected as already labeled
  • Testing

    # Unit tests
    go test -mod=vendor ./pkg/dataloader/infrafailurebackfill/...
    
    # Dry run (requires BQ credentials + PG connection)
    sippy backfill-infra-failures --database-dsn "$DSN" --google-service-account-credential-file creds.json --days 90 --dry-run
    
    # Full sync
    sippy backfill-infra-failures --database-dsn "$DSN" --google-service-account-credential-file creds.json --since 2026-06-01
    

    Jira: https://redhat.atlassian.net/browse/TRT-2884

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    New Features
    Added a command to backfill infrastructure-failure records.
    Supports configurable time windows, batch sizes, dry-run mode, and UTC-based processing.
    Provides completion status, failure reporting, and processing statistics.
    Added outcome tracking for successful, reclassified, and unknown results.

    Bug Fixes
    Improved error handling to avoid exposing credential or connection details.

    Tests
    * Added unit, integration, and command-level coverage for backfill behavior and outcomes.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 566 lines (+424 / -142) across 7 files Reviewer: neisw Review duration: 6795m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.73) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.73 · 566 lines diff across 7 files
    0.73
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.379
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.073
    Real PR Conversation Timeline
    1 comments
    "Review active on #3927"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 72.9% (HIGH) · Higher = larger blast radius
    72.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 28.8% · Safe to merge
    28.8%