Repository navigation
fix(drivers): a slow success is a success - #1889
Merged
Merged
Conversation
A command that the device accepted after the caller's deadline was turned into DeadlineExceeded, and the actor then sent driver_default_mode. A driver slower than half the control interval flipped between forced and autonomous mode on every tick. The caller's deadline now bounds only its wait. A started command runs for at least 5 s; an explicit cancel, the lifecycle and SendDefault still stop it, and a failure or timeout still restores the default. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
A wallbox-cycle ev_pause that succeeded after the caller's deadline set evPausePending, but the cycle owner had already given up and never sent the resume. Every later cycle pause was then refused as superseded until a default or an operator command cleared the latch. Cycle steps (cycleID != 0) now run under the caller's deadline, as before the slow-success change. A late cycle step fails, restores the default and leaves no pending pause. Other commands keep the 5 s run bound. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Item B1 of the stable plan.
Problem
At the default 2 s control interval, every dispatch send waits 1 s (
driverCommandTimeout, driver_command_deadline.go:43-52).beginCommandtied the command's context to that wait, and afterdriver_commandreturned success,commandContextError(registry.go:1092) turned it intoDeadlineExceededonce the wait had ended.restoreAfterCommandthen randriver_default_mode.So a driver that needs more than 1 s to answer is put back in its default after every command the device accepted. The default succeeds and clears the block, so the next tick sends again and the cycle repeats: forced, autonomous, forced. Sungrow through a WiNet dongle (four Modbus round trips per command) and Easee Cloud (whose default pauses the car at 0 A) are both exposed. The repro: a device that accepts at 40 ms with a 20 ms caller wait gave 3 commands and 3 defaults in 3 ticks.
Change
In
internal/drivers/registry.goonly:commandRunContext: once a command has started, a caller deadline shorter than 5 s (defaultRecoveryTimeout) no longer cuts it short. The command runs for at least 5 s. Longer caller deadlines (vehicle wake, 15-30 s) and callers with no deadline are unchanged.SendEVContinuation,cycleID != 0) keep the caller's deadline. The cycle owner gives up at that deadline and sends no resume, so a pause that lands late fails and restores the default, as on master, instead of latchingevPausePendingand blocking every later cycle pause.commandContextErrorignores the caller's deadline. A success that arrives late is a success. An explicit caller cancel, the driver lifecycle andSendDefaultstill stop the command, and a failure or run timeout still restores the default.The caller still gets
ErrCommandMayHaveRunat its own deadline.SendWithOutcomenow reports the real result (nil) to the actor-owned outcome callback, and telemetry records "accepted", not "unconfirmed". The loadpoint saves its offer before the send, so a raise that lands late is already counted for the fuse.A command queued behind a slow one still expires in the queue at its caller's deadline, as before, so the lag does not grow.
Tests
go/internal/drivers/registry_slow_command_test.go(repro from the audit, renamed). Both tests fail on master and pass here.TestLateWallboxCyclePauseRestoresDefaultAndDoesNotLatchcovers the cycle-step case: it fails without the cycle-step exception and passes here.TestSendReturnsAtDeadlineWhileDriverIsWedgedandTestRegistryCancelAfterCommandStartedRestoresDefaultstay green.go test -race -count=1 ./internal/drivers/... ./internal/loadpoint/... ./internal/api/... ./cmd/ftw/...: ok.go test -count=1 ./...: ok.go build ./...andgo vet ./...: ok.Risk
Medium. The actor can now spend up to 5 s on a stuck, context-aware command before the default, where before it gave up at 1 s and then spent up to 5 s on the default.
SendDefaultand the staleness watchdog still cancel a running command at once. Rig scenario R10 (charger that answers in 2.5 s) covers this; OCPP uses its own path and is a separate item (W2-11).The comment at loadpoint/controller.go:1696-1698 says a timeout restores the default; it is now true only when the command fails. Three open PRs touch that file, so I left it.
🤖 Generated with Claude Code