← Back to Pull requests

fix(tests): deriva timeout da suíte live do budget real de retry #3057

Closed
unknown closed this pull request without merging on Nov 02, 2026 23:33 UTC
View on GitHub
unknown unknown commented on Nov 02, 2026 22:24 UTC
Author

Causa raiz

callEdge() em tests/edge-functions/live/_live-client.ts faz até 4 tentativas de 15s (TIMEOUT_MS) com backoff linear (800ms × (1+2+3)), somando até 64.8s no pior caso. _live-suite.ts cortava cada it() em 30_000ms fixos — menor que esse budget.

Resultado real observado (2026-11-02): intelligence-substitute-applied e magic-up-score falharam com Test timed out in 30000ms em run 41534739744 (PR #3055) e um padrão análogo (health-check 503 com latências de 15-24s) já tinha ocorrido em main no run 41524218467 — não era flakiness genérica de rede, era o próprio retry interno ainda em andamento quando o vitest cortava o teste.

Fix

  • _live-client.ts: exporta MAX_RETRY_BUDGET_MS, calculado a partir das mesmas constantes (TIMEOUT_MS, RETRY_COUNT, RETRY_DELAY_MS) que já definem o comportamento real do retry — nunca mais pode ficar fora de sincronia com elas.

  • _live-suite.ts: LIVE_TEST_TIMEOUT passa a derivar de MAX_RETRY_BUDGET_MS * 1.2 (margem de 20%) em vez de 30_000 fixo, mantendo o override via EDGE_LIVE_TEST_TIMEOUT_MS para quem precisar de um valor explícito.
  • Diff mínimo — só os dois arquivos da causa raiz, sem tocar no workflow (edge-integration-all.yml já tem timeout-minutes: 20 no job, folga suficiente).

    Verificado de verdade

  • npx tsc --noEmit → 0 erros nos arquivos tocados.

  • npx eslint tests/edge-functions/live/_live-client.ts tests/edge-functions/live/_live-suite.ts → limpo.

  • npx vitest run tests/edge-functions/live/ (sem credenciais live, skip silencioso) → 1 passed | 109 skipped, 0 falhas.

  • Cálculo manual do novo default: (3+1)×15000 + 800×6 = 64800 → LIVE_TEST_TIMEOUT = ceil(64800×1.2) = 77760ms, confirmado via node -e.
  • Não roda a suíte LIVE real (precisaria de credenciais de produção) — a correção é estrutural (timeout derivado do budget, não um número arbitrário), então se continuar falhando por esse motivo específico não vai mais acontecer independente de quanto o Supabase demorar, desde que dentro do que o próprio retry já tolera.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01N1ArYQYUMHo9B9k67vpvBo

    Diff: 292 lines (+219 / -73) across 3 files Reviewer: adm01-debug Review duration: 69m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 292 lines diff across 3 files
    0.40
    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.340
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3057"
    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: 39.9% (MEDIUM) · Higher = larger blast radius
    39.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: 15.8% · Safe to merge
    15.8%