← Back to Pull requests

core: Snapshot active_conversation_info in typing-notification loop. #1656

Open
unknown opened this pull request with 194 lines diff across 2 files
View on GitHub
unknown unknown commented on Sep 04, 2026 12:09 UTC
Author

Fixes: #1501

Root cause: Controller.show_typing_notification (core.py) runs on its own thread (via @asynch) and read self.active_conversation_info twice per loop iteration — once in the while condition, once to subscript ["sender_name"]. The model thread (_handle_typing_event) reassigns that attribute to a new {} on a typing stop event. If the reset lands between the two reads, the subscript raises KeyError: 'sender_name', killing the notification thread instead of exiting the loop cleanly. That is the intermittent test_show_typing_notification failure — and a latent crash in real usage, not just a test artifact.

Fix: read the attribute once per iteration into a local (conversation_info) and test/subscript only that snapshot. A concurrent reset then either still shows the previous dict (which always carries the key) or an empty dict that exits the loop.

Test hardening: test_show_typing_notification now joins the notification thread (with timeout) before asserting — asserting while the thread was still starting up raced it under CI load and failed the footer-text assertions intermittently.

Verification:

  • Standalone race repro hammering both patterns with a concurrent reset: old double-read raised KeyError in 2000/2000 trials; fixed snapshot in 0/2000.

  • tests/core/test_core.py -k typing: 2 passed, repeated 5x, stable.

  • Full tests/core/test_core.py + tests/model/test_model.py: 1033 passed.

  • Lint clean on changed files: ruff, black --check, isort --check (project config).
  • Diff: 194 lines (+145 / -49) across 2 files Reviewer: Adarsh-Me Review duration: 126766m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.43) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 194 lines diff across 2 files
    0.43
    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%
    44%
    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.315
    Real PR Conversation Timeline
    1 comments
    "Review active on #1656"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.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: 43% (MEDIUM) · Higher = larger blast radius
    43%
    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: 44.7% · Lower = rushed or shallow review
    44.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: 23.8% · Safe to merge
    23.8%