← Back to Pull requests

feat(tenant-quota): add ci-failure-patterns controller and results table #8006

Closed
unknown closed this pull request without merging on Nov 10, 2026 14:06 UTC
View on GitHub
unknown unknown commented on Nov 09, 2026 09:07 UTC
Author

Tracks AROSLSRE-2676 — Port deterministic failure-pattern extraction from CIHealth to an ARO-HCP CLI.

Follows #7945 (shared extractor and hcpctl replay tooling). This is the normal-reconciliation controller and its results table; the upgrade controller, activation table and ADX active-version helper are a later PR.

Why

#7945 made failure-pattern extraction deterministic and reviewable offline. To use it for DEV CI telemetry the findings must be computed continuously and stored where users can join them with the raw CI tables, without every consumer re-running extraction.

How

A new ciFailurePatterns controller in tooling/tenant-quota (pkg/cipatterns), next to the existing ciJobOutcomes collector:

  • Discovery: a head poll reads the 64 newest failed build IDs every interval; a paced history sweep (advances only while less than one page of work is outstanding) walks all retained builds newest to oldest, 128 IDs per step, then rests 12 h. No time cutoff or permanent completion marker, so late raw rows and name changes are picked up.

  • Per build: reads the exact raw failed inputs (with multiplicity) and the resolved test name from ciTestResults/ciTestNames, runs the shared extractor in process, and submits complete findings through managed queued ingestion.

  • Idempotency: a result key hashes the raw fingerprint, resolved test name, extractor version and schema. Visible results are read back with complete, strong-consistency, cache-disabled queries; accepted ingestion is never treated as completion. Retry copies collapse logically; conflicting findings for one key are an integrity error. A per-key submission cache avoids resubmitting computations still awaiting visibility.

  • Results table (ciFailurePatterns, deployed by the Kusto bicep module): identity, resolved testName, findings (dynamic), computedAt, producerCommit. Raw message and timings are not copied: join ciTestResults on (buildId, source, testId, messageHash); messageHash is the SHA-256 of the raw message, equal to Kusto's hash_sha256(message) (verified against the emulator and DEV), and disambiguates tests that fail more than once in a run. In a live measurement the message was 82% of the stored bytes.

  • Shared Kusto transport/mapping/ingestion helpers moved into tooling/tenant-quota/pkg/kusto; the hcpctl complete-query helper is reused for strict response handling.

  • Info logs show only lifecycle and work discovery; per-build detail is debug.
  • Verification

  • go vet and go test -race -p 1 for tenant-quota, plus the hcpctl packages touched.

  • Local Kusto emulator integration test: configured raw queries, extraction, real JSON mappings, paged discovery over more than 64 MiB of aggregate message text, repeated inputs, null/zero timestamps, late names.

  • HTTP-wire tests of the SDK queued-ingestion and complete-response paths.

  • Live DEV run against hcp-dev-us-2 with a throwaway results table (dropped afterwards): about 1.0 finding per failed row, no ingestion failures, no duplicate result keys, every result joined exactly one raw row, and all finding offsets fell inside the joined message. The history sweep over about 2.8k failed builds was projected at about one hour with 4 workers.
  • Operational notes

  • The controller always runs in the tenant-quota collector (there is no enable flag). config/config-dev-ci.yaml configures it for DEV-CI (interval: 5m, workers: 4) and ciJobOutcomes connection settings are required. It writes only to the new results table.

  • The controller has no upgrade coordinator: it computes the compiled extractor/schema pair. Bumping cifailurepatterns.Version later writes a second version side by side until PR 3 adds activation.

  • Results are append-only. Consumers deduplicate by resultKey until the planned active-version helper exists.

  • Not verified: production rollout, multi-replica behavior, and managed-ingestion completion under load beyond the DEV run.
  • PR Checklist

  • PR is scoped to a single task (no mixed concerns)

  • Title follows Conventional Commits format

  • Summary explains the "Why" behind the change

  • Linked to relevant ticket/issue

  • Screenshots included (not applicable: backend controller, no UI)

  • Self-reviewed the diff

  • CI/CD checks are passing (ignore Tide)

  • Draft PR used

  • Commit history is clean

  • Tricky code blocks are commented

  • Specific reviewers tagged (left to the author)

  • All comment threads resolved before merge
  • Diff: 574 lines (+430 / -144) across 7 files Reviewer: ziccardi Review duration: 1738m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.55) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.55 · 574 lines diff across 7 files
    0.55
    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.380
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #8006"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    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: 54.8% (MEDIUM) · Higher = larger blast radius
    54.8%
    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: 21.6% · Safe to merge
    21.6%
    Repository