← Back to Pull requests

fix(agent-hypervisor): report ring 0 in the current ring gauge #4586

Open
unknown opened this pull request with 316 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 17, 2026 08:17 UTC
Author

Related Issue


Fixes #4585

Problem & Solution


RingMetricsCollector read the new ring with payload.get("to_ring") or payload.get("ring"). Ring 0 (ExecutionRing.RING_0_ROOT) is falsy, so a {"to_ring": 0} event fell through to "ring", got None, and the current-ring gauge kept the previous ring. Now it falls back to "ring" only when "to_ring" is missing.

Impact on Your Work


The agent_hypervisor_ring_current gauge (and export_to_prometheus) showed the wrong ring for any agent whose last move was to ring 0.

Timeline


None

Alternatives Considered


None; this is the minimal change.

Type of Change


  • Bug fix (non-breaking change that fixes an issue)
  • Package(s) Affected


  • agent-hypervisor
  • Testing

    Unit Testing


    Added test_current_ring_updates_to_ring_zero in tests/unit/test_prometheus_collector.py (ring 2, then ring 0, expects 0).

    Before the fix:

    E   assert 2 == 0
    1 failed, 8 passed
    

    After:

    tests/unit/test_prometheus_collector.py: 9 passed
    agent-hypervisor suite: 666 passed, 24 skipped
    

    ruff check and ruff format --check pass on the changed files.

    Manual Testing


    Ran the repro from #4585: printed {'a': 2} before, {'a': 0} after.

    Checklist


  • I have linked a related issue above, or completed "Problem & Solution", "Impact on Your Work", and "Alternatives Considered"

  • My code follows the project style guidelines (ruff check)

  • I have added tests that prove my fix/feature works

  • All new and existing tests pass (pytest)

  • I have updated documentation as needed

  • I have signed the Microsoft CLA
  • Attribution & Prior Art


  • This contribution does not contain code copied or derived from other projects without attribution
  • AI Assistance


  • I can explain every meaningful change in this PR: what it does, why, and what tradeoffs were considered

  • I have run tests and verification appropriate for this change

  • No part of this PR was autonomously submitted by an AI agent without my review

  • I have not used AI to generate review comments on others' PRs
  • AI note: an AI coding agent (Claude Code) helped find the bug, write the fix and test, and prepare this PR.

    IP, Patents, and Licensing


  • This contribution does not implement patent-pending or patent-encumbered techniques

  • This contribution does not require an NDA or licensing agreement to understand or use

  • Any AI tools used have terms compatible with the MIT License
  • Diff: 316 lines (+237 / -79) across 3 files Reviewer: MohammadHaroonAbuomar Review duration: 7944m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 316 lines diff across 3 files
    0.40
    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
    Diff Size diff_size
    0.345
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #4586"
    general weight: 0.35
    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: 40.4% (MEDIUM) · Higher = larger blast radius
    40.4%
    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: 21.5% · Safe to merge
    21.5%