← Back to Pull requests

fix(simulator): try a trip start again when its failure may pass #792

Closed
unknown closed this pull request without merging on Nov 30, 2026 15:50 UTC
View on GitHub
unknown unknown commented on Nov 30, 2026 12:34 UTC
Author

A follow-up to a note on #327: drive stopped a vehicle for good on any single error in starting its next trip, so one 503 or one dropped connection cost that vehicle the rest of the run.

What I changed:

  • A start that fails for a reason that may pass is tried again: the server was not reached, or it answered 429 or a 5xx. The vehicle waits a second first, the wait doubles with each failure in a row up to 30 seconds, and a trip that starts puts it back to a second. Reading the route's trips and the trip's shape count as part of the start, since both come before it.

  • Anything else still stops the vehicle at once, as before: a 401, 403 or 409, any other 4xx, a route with no trip to drive, a trip with no shape, and a driver whose refresh the server refused.

  • A vehicle still waiting to try again when the run ends counts as stopped, so the simulator still exits 1. Otherwise make smoke against a server that fails every start would end with no report sent and exit 0.

  • To tell the answers apart, postJSON and getJSON return the statusError that login and refresh already did. Their messages read as before.
  • Not handled: a start the server took but whose answer was lost. The second try gets a 409 and the vehicle stops. Before, the lost answer itself stopped it.

    Tests:

  • A fake server fails the first start with 503, with 429 and by dropping the connection, and fails the route's trip list with 502. Each time the vehicle waits one second, starts the same trip on the second try and reports. The waits are recorded, not slept.

  • Three failures in a row wait 1, 2 and 4 seconds, and after a trip has been driven the next failure waits 1 second again.

  • A 401, 403 or 409 stops the vehicle after one request, and a run that ends during a wait returns the error.

  • I broke the change 18 ways, among them each kind of answer, the wait, its growth and its reset, and a test failed each time.

  • I also ran it against a real server behind a small proxy that answered each of three vehicles' first start with 503. main's simulator lost all three, sent no report and exited 1. This one waited a second, started all three, sent its reports and exited 0.
  • docs/demo.md says what a failed start does now. #746 edits the same file at another line, and the two merge cleanly. The admin session fix for #345's note also touches cmd/simulator/main.go, in other functions, and those two merge cleanly in either order.

    go fmt, go vet and go test ./... pass, with the database tests (4,658 tests).

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Bug Fixes
    Simulator vehicle starts now retry temporary network failures, rate limits, and server errors. The wait increases from one second up to 30 seconds while failures continue, and resets after a successful start. Permanent errors still stop the run without retrying.
    If a run ends while a vehicle start is still failing, the simulator reports that failure.

    Documentation
    * Updated the simulator guide to describe retry timing and how an unresolved start failure is handled when a run ends.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 404 lines (+303 / -101) across 5 files Reviewer: aaronbrethorst Review duration: 196m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 404 lines diff across 5 files
    0.45
    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.359
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #792"
    general weight: 0.35
    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: 44.8% (MEDIUM) · Higher = larger blast radius
    44.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: 17.7% · Safe to merge
    17.7%