← Back to Pull requests

sdk/python: dial routers and DHT peers at once, stop when the record is in hand #536

Closed
unknown closed this pull request without merging on Sep 27, 2026 19:07 UTC
View on GitHub
unknown unknown commented on Sep 27, 2026 18:41 UTC
Author

The bananas deploy of bd58efb8 failed the SDK cold-path probe again (https://github.com/google/sam/actions/runs/36338262423/job/108677106672); with #532's timeout the probe now reports it instead of hanging:

{"probe":"sam-sdk-python","ok":false,"stage":"node-mcp","error":"no answer with 'Echo: sam-sdk-probe' in 120s (1 attempts; last: on the mesh as 12D3KooWPZ… (hung for 120s))"}

Measured in the probe's pod (same image, token and env)

Cold path before: enroll 0.2s, join 16s, discover 15s, connect 0.2s. Each 15s is one bounded dial to the GCE router the control plane lists but the cluster's network policy drops — and every step dialed one peer after another. Right after a rollout the routers' tables also name the pods just replaced as closer peers (another 15s each), which is what pushed the first attempt past 120s on the deploy and made the hub's first attempt a coin toss.

After, three cold runs: join 15.3s (the dark router's timeout, alone), discover 0.1s, connect 0.3s, call 0.2s.

Changes

  • One shared DHT walk (_walk) for find_peer/find_providers: a round asks its peers at once and returns as soon as an answer satisfies the lookup; only otherwise are the closer peers dialed, also at once. A round costs one query and one dial timeout, not one per peer. Drops the duplicate GET_PROVIDERS helper.

  • _admit dials and authenticates every router at once; the reservation still goes to the first admitted router of the list (same reachability semantics as before).

  • Tests: providers in hand end the walk with no dial; three stale closer peers cost one dial timeout together; a slow router does not delay the others; join with a dark router first in the list ends at DIAL_TIMEOUT with the reservation on the first admitting router.
  • Validation

  • sdk/python: 91 passed

  • go test ./tests/integration -run 'TestNativeSDK|TestSDK': all pass (incl. TestNativeSDKsAcrossRouters, JS and Python)
  • Diff: 244 lines (+183 / -61) across 3 files Reviewer: aojea Review duration: 26m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 244 lines diff across 3 files
    0.39
    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.329
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #536"
    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: 38.8% (MEDIUM) · Higher = larger blast radius
    38.8%
    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.3% · Safe to merge
    15.3%