fix: keep the newer report when an older one finishes after it #837
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.40) × (1 − Review Confidence (0.56)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 289 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 81% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.339
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #837"
general
weight: 0.35
aaronbrethorst
Tracker.UpdateAuthorizedstores whichever report finishes last, whatever itstimestampsays. One vehicle can have two reports in flight at once: the per-vehicle limiter allows a burst of 2, and a client can retry a request whose response was lost. If the older one finishes second,/gtfs-rt/vehicle-positionsand trip-updates publish the older position and timestamp until the next report arrives.The rest of the code already keeps the newest report:
GetRecentLocations, the startup seed, keeps the latest report by the fix's own timestamp (ORDER BY lp.timestamp DESC). So after a restart the feed shows the newest report, but while running it shows whichever finished last.A retried copy of an older report already hits
ON CONFLICT DO NOTHINGwhen saved, but it still moved the tracker back.Changes:
UpdateAuthorizeddrops a report whose timestamp is older than the vehicle's current one. A report with an equal timestamp is still applied.truein that case.falsestays reserved for "a Remove won", so the handler doesn't log the misleading "vehicle removed while its report was processed". The doc comment now says so.Test:
TestTracker_UpdateAuthorized_KeepsTheNewerReportapplies a newer report, then one 5s older. Onmainthe vehicle's timestamp and position go back to the older report (expected: 1796118865 actual: 1796118860).A phone clock corrected backwards would hold the vehicle in place for that many seconds.
validate()already limits skew to ±5 minutes, and trip end callsRemove, so the next trip starts fresh.Checks run locally:
gofmt -l,go vet .,go test -run TestTracker .. All passed.<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Bug Fixes
When reports for the same vehicle arrive out of order, the latest report is now retained instead of being replaced by an older one. This keeps the vehicle’s displayed timestamp and location consistent with its most recent reported information.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->