← Back to Pull requests

Circuit breaker, bounded retry and stale cache for the talent network API #6

Closed
unknown closed this pull request without merging on Nov 22, 2026 19:18 UTC
View on GitHub
unknown unknown commented on Nov 22, 2026 19:17 UTC
Author

Changes


  • Circuit breaker (lib/breaker.ts), covering every talent API call:

  • - Opens after 5 outages within 60 s, where an outage is a network error, timeout, 5xx or 429.
    - While open, it fails fast for 30 s, then allows one trial call.
    - A 404 is treated as an answer, not an outage.
  • Retry: 8 s timeout per attempt, and at most one retry with jittered backoff. Only network errors, timeouts and 5xx are retried, never a 429.

  • Stale fallback: the last good search and job results are kept for an hour. When a fresh call fails, they're served and marked stale:

  • - the web search shows a note
    - search_roles adds stale_minutes and a sentence in its text
    - /api/health reports the breaker's state and counts
  • Metrics: one talent_api log line per call (op, status, attempts, duration, breaker state), plus a line for each breaker transition. Query text and job ids are never logged.

  • docs/talent-api.md: the API is documented (developer page plus OpenAPI 3.1), needs no auth, and asks callers to identify themselves with ?source=, which One Link does. The doc also covers caching, observed limits, failure modes, and the business dependency: there's no agreement with the speedrun team.
  • Verification


  • 222 tests pass (11 new):

  • - breaker state transitions, a single half-open trial, and the failure window
    - 5xx retried once, 429 never retried, 404 doesn't trip the breaker
    - logs contain no query text
    - stale cache served on failure
  • Live smoke test against a local build that calls the real API: all checks pass, health reports the breaker closed, and calls are logged.

  • Not deployed.
  • 🤖 Generated with Claude Code

    Diff: 214 lines (+160 / -54) across 2 files Reviewer: cursor[bot] Review duration: 1m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.37) × (1 − Review Confidence (0.33)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 214 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 25% · Reviewer familiarity: 35%
    33%
    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.321
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #6"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 33.1% 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: 36.6% (MEDIUM) · Higher = larger blast radius
    36.6%
    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: 33.1% · Lower = rushed or shallow review
    33.1%
    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: 24.5% · Safe to merge
    24.5%