Skip to content

fix(drivers): give slow cloud drivers time, hand devices back on removal - #2079

Merged
frahlg merged 2 commits into
masterfrom
fix/slow-cloud-driver-release
Nov 25, 2026
Merged

frahlg merged 2 commits into
masterfrom
fix/slow-cloud-driver-release

Conversation

@frahlg

@frahlg frahlg commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Problem

The first field test of Zaptec control (v0.167.0-beta.1, Zaptec Go, 20 A fuse, one-phase cars) could not charge. Two of the causes sit in Core's driver host:

  • 5 s per call is too short for a vendor cloud. A Zaptec resume is a current write and a command, each a round trip to Zaptec Cloud. A command that ran out of the 5 s run time failed, and restoreAfterCommand then ran driver_default_mode, which for a charger is 0 A and a pause. Lifecycle calls (driver_default_mode, driver_cleanup) had a fixed 5 s in LuaDriver.call, whatever the caller allowed.
  • Removal left the safe stop on the device. Removing or disabling a driver ran driver_default_mode. For Zaptec that stores maxChargeCurrent = 0 on the charger. The owner found "Max Current lower than Min Current" in the Zaptec portal; neither the Zaptec app nor their other load balancer could start the charger until they fixed it by hand.

Change

  • host.set_command_timeout_s(seconds): a driver asks for up to 30 s per call from driver_init. It sets the least run time for commands, the startup default, recovery and watchdog defaults, the shutdown default and cleanup. Callers keep their own deadlines, so the control tick never waits longer; the call finishes in the driver's actor, and only a call that runs out of the driver's own time counts as failed.
  • Optional driver_release(): Reload calls it instead of driver_default_mode when a driver has left the config or been disabled. A driver without it is stopped with its default, as before. A restart, a config change, shutdown and a stale reading keep driver_default_mode. A refused release keeps the name's recovery gate, as a refused default does.
  • docs/writing-a-driver.md documents both; patch changeset.

Paired with srcfl/device-drivers#279 (zaptec_cloud 0.3.0), which uses both. The second commit moves the driver pin to srcfl/device-drivers@28c771fd (#279 merged): zaptec_cloud 0.3.0, plus the easee_cloud fixes merged since e7b94b11 (#183, #227, #194, #236, #200), whose Core side (#2050, #2062) is already on master.

Tests

On this machine: make verify passed. New registry_release_test.go: removal and disable call release and not the default; shutdown, restart and config change call the default and not release; a driver without release gets its default; a refused release keeps the gate; set_command_timeout_s bounds (default, 12 s, cap 30 s, floor, negative refused); and a 6.5 s command with a 500 ms caller deadline finishes without the safe default when the driver declared 15 s, and trips it when it did not.

🤖 Generated with Claude Code

A Zaptec Cloud command that took longer than 5 s failed, and the safe
default then paused the charger at 0 A. A driver can now ask for up to
30 s per call with host.set_command_timeout_s; the control tick still waits
only its short deadline and the call finishes in the driver's queue.

Removing or disabling a driver calls its optional driver_release instead of
driver_default_mode, so a charger goes back to the owner's own current
rather than staying at FTW's 0 A. Restarts, shutdown and stale readings
keep the safe default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T06:04:47.563702Z f3193dc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Move the pin to srcfl/device-drivers@28c771fd (#279). zaptec_cloud 0.3.0
uses host.set_command_timeout_s and driver_release from this PR. The pin
also carries the easee_cloud fixes merged since e7b94b11 (#183, #227, #194,
#236, #200), whose Core side (#2050, #2062) is already on master.

Tell the stopped instance's default apart from a replacement's startup
default in TestOtherStopsKeepTheSafeDefault (review finding).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@frahlg
frahlg merged commit d9fa6f6 into master Nov 25, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant