← Back to Pull requests

sdk/python: bound every dial the DHT walk makes #532

Closed
unknown closed this pull request without merging on Sep 27, 2026 16:33 UTC
View on GitHub
unknown unknown commented on Sep 27, 2026 16:08 UTC
Author

Fixes the hub v0.1.0-rc.7 rollout and the bananas main deploys failing since fe2141c2 at "Deploy and run the SDK cold-path probe" (e.g. https://github.com/google/sam/actions/runs/36317528367/job/108643796199).

What was happening

The Python call.py probe printed nothing and sat until the Job deadline killed it, while the JS probe and the Python A2A agent in the same pod were fine. In the pod the process held one socket in SYN_SENT (9 retransmits) to the GCE VM router's public address, which the cluster network policy drops.

find_peer / find_providers follow the closer peers a router names with a bare host.connect. py-libp2p has no dial timeout of its own, so the SYN waited on the kernel, and since every in-cluster router names the dark router as closer to every key, the walk parked there before the first call could be answered. The session's own dials were already bounded by DIAL_TIMEOUT (15s); these were not.

Changes

  • DIAL_TIMEOUT/dial move to host.py and bound the closer-peer dials. A peer whose dial failed is remembered so the next rounds do not dial it again (three rounds would otherwise cost 3× the bound per lookup).

  • The shielded host.disconnect after a stalled stream open is bounded too: it writes a GO_AWAY on the very connection that stalled.

  • New tests/test_discovery.py drives the walks against a fake router that names a dark closer peer: the pre-fix walk never returns, the fixed one dials once and ends at DIAL_TIMEOUT (MockClock, no wall time).

  • probe.sh runs each call under timeout, so a hung program yields a stage failure carrying its last output instead of a silent Job deadline.
  • Validation

  • sdk/python: 87 passed

  • go test ./tests/integration -run 'TestNativeSDK|TestSDK': all pass (incl. TestNativeSDKsAcrossRouters)

  • make lint, make test green
  • Diff: 231 lines (+173 / -58) across 2 files Reviewer: aojea Review duration: 25m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 231 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: 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.326
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #532"
    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: 37% (MEDIUM) · Higher = larger blast radius
    37%
    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: 14.6% · Safe to merge
    14.6%