← Back to Pull requests

fix(core): thread circuit breaker generation and release slots in execute_tool #338

Open
unknown opened this pull request with 185 lines diff across 2 files
View on GitHub
unknown unknown commented on Oct 06, 2026 08:56 UTC
Author

Description

In progressive and semantic modes, execute_tool() was calling breaker.can_execute(), which discards the returned generation integer. Because of this, subsequent record_success() and record_failure() calls passed generation=None, bypassing the half-open staleness guard in CircuitBreaker.

In addition, neutral responses (non-infrastructure errors like not found or validation failures) were being recorded as successes rather than having their half-open probe slots released.

This change:

  • Switches execute_tool() to use breaker.acquire() and passes the generation integer to record_success(generation) and record_failure(generation).

  • Adds breaker.release(generation) for neutral results when is_success is False and is_infrastructure_error is False.

  • Adds unit tests in dynamic_tools_test.py covering generation passing, stale probe rejection across window rollover, and slot release on neutral responses.
  • Related Issue

    Fixes #337

    Checklist

  • I have read the [CONTRIBUTING](../CONTRIBUTING.md) guide

  • Tests pass locally (make test-python)

  • Linting passes (make verify)

  • Documentation updated (if applicable)

  • My commits are signed off (git commit -s)
  • Testing

  • Unit tests

  • Integration tests

  • E2E tests

  • Manually tested (describe below)
  • Ran unit tests locally on unfixed main (confirmed new tests fail) and on this branch (make test-python and make verify both pass).

    Diff: 185 lines (+138 / -47) across 2 files Reviewer: myselfkunal Review duration: 10670m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.36) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 185 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.313
    Real PR Conversation Timeline
    1 comments
    "Review active on #338"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 35.7% (MEDIUM) · Higher = larger blast radius
    35.7%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 19% · Safe to merge
    19%