← Back to Pull requests

test(ployz): keep the fake Cloud listening until the relay-stage client returns #3176

Closed
unknown closed this pull request without merging on Oct 23, 2026 03:27 UTC
View on GitHub
unknown unknown commented on Oct 23, 2026 02:38 UTC
Author

Fixes #3171. cloud_enroll::tests::enrollment_stages_name_the_relay_only_when_cloud_says_it_never_reaches_the_server flaked on main and has been ejecting PRs from the merge queue.

Cause

The fake Cloud answered one request with a 503 and Connection: close. It then spent the stage's 60s wait with a single manual advance, timed off the client closing that first connection. After that, the server task ended and dropped its listener. Two races came from this:

  • The one CI hit. The client's next attempt could already sit in the listener's backlog. Dropping the listener reset that connection, so ECONNRESET became the stage's last error in place of Cloud's answer. The main CI run 39878591469 shows exactly this: last: Some(Connect(... ConnectionReset ...)), in_flight: false, on the test's own fake-Cloud port.

  • A second race the review found. The jump wasn't tied to the client's progress. If it landed before attempt 1 had read its body, reqwest's expired 15s timeout could win instead.
  • Fix

    The test stops coordinating one clock jump with client internals.

  • It runs on paused time, and the fake Cloud answers every attempt with the same 503.

  • A 10ms ticker keeps paused auto-advance from jumping past reqwest's 10s and 15s timeouts while real loopback IO is in flight. This is the same pattern as tick_through_io in the checkin tests.

  • The stage retries about 60 times on virtual time. Its last error is Cloud's answer whether the deadline cuts an attempt in flight or a retry sleep.
  • The change is test-only and adds no real-clock wait.

    Design bets

    The change is test-only, so no bet is touched.

    Testing

    The testing rung is 1, the crate unit test.

  • Before the fix, --stress-count 300 passed 300 of 300 both idle and with 16 busy loops on 24 cores, so the race didn't show locally. The CI log above is the evidence for the cause.

  • The rewrite ran --stress-count 150 with 16 busy loops on 24 cores, and 150 of 150 passed. One run takes about 4s with a 1ms tick, and less with 10ms.

  • cargo clippy -p ployz --tests -D warnings was clean, and the real-wait lint over crates/* exited 0.
  • Diff: 268 lines (+201 / -67) across 3 files Reviewer: nick-potts Review duration: 48m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.44) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.44 · 268 lines diff across 3 files
    0.44
    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%
    56%
    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.335
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #3176"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 44.4% (MEDIUM) · Higher = larger blast radius
    44.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: 56.8% · Lower = rushed or shallow review
    56.8%
    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.2% · Safe to merge
    19.2%
    Repository