Repository navigation
fix(drivers): harden driver stop, failed start and reload paths - #1444
Merged
Merged
Conversation
- observe_only drivers are never handed back on the way out: Remove, Restart, Reload and ShutdownAll skip driver_default_mode and driver_cleanup for them, and SendDefault returns ErrObserveOnly, as main's watchdog already did. A VPP-owned battery keeps its settings. - driver_cleanup runs again on a controlled driver's shutdown. It was called with the already-canceled lifecycle context and aborted at its first instruction, so Sungrow's curtailment release was lost. It now gets its own 5 s bound; probes and observe_only drivers discard the VM without it, including when their driver_init fails. - A failed Add closes the MQTT, Modbus, serial, WebSocket and TCP capabilities it opened. A leaked MQTT client reconnected forever under the same client ID and fought the next Add for the session. - Restart, RestartByName and Reload start the replacement with a context detached from the caller's cancellation, so an HTTP client that disconnects after the old generation stopped no longer leaves the driver (possibly the site meter) stopped until the next reload. - sameDriverConfig compares the HTTP grant (allowed hosts, TLS pin, allow_write), the WebSocket grant and supports_pv_curtail, so reload applies a revoked allow_write or a rotated pin. nil and empty allowlists stay equal to avoid a second restart after a settings save. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7
The control release now maps ErrObserveOnly the same way the control POST does, so a normal refusal is not reported as a server error. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7
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. |
frahlg
added a commit
that referenced
this pull request
Sep 27, 2026
…st proxies (#1454) Owner decision 2026-09-26: the signed control v2 runtime has been unreachable since the Device Support package format was removed (#1432); driverrepo only ever binds a read-only policy now. - #16 Remove control v2: LuaDriver.CommandV2/DefaultModeV2, the v2 load and lifecycle timeouts, write scopes, write budget and host evidence, the command/result envelope types and validation, the registry's v2 dispatch, lease timer, stale/lease-expiry defaults and v2 startup default, and Registry.CommandResultSink with its main.go wiring. The legacy driver_command/driver_default_mode path, the recovery gate and the observe_only handling from #1444 are unchanged. - RuntimePolicy (control_v2.go -> runtime_policy.go) keeps only the read-only policy; validate rejects any other, and allowWrite refuses every write from a driver that carries a policy. - Drop the 100 ms host.sleep cap that, after v2, applied only to signed read-only drivers, so a file sleeps the same whichever source it came from (new test). - driver_command_results is no longer created and its write-only store method is gone; existing tables are left inert with a note in migrate(). - #38 Delete the unused HostEnv mqttSubscribe, mqttPublish, mqttPollMessages, modbusWriteSingle and modbusWriteMulti proxies. - Move the surviving read-only lifecycle test, adapt the HTTP 302 and OAuth sign-in tests, and update the roadmap, driver guide and comments that described v2. Claude-Session: https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7 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.
From the multi-agent hardening review of master. Each finding was confirmed by a skeptic reading the code, and the diff was reviewed again after the fix.
Fixed
observe_onlydriver was handed back to its default mode on every Remove, Restart, Reload and shutdown.set_self_consumptionwritten on each FTW restart or update.removeLockednow treatsobserve_onlyas skip-default. The VM is discarded withoutdriver_cleanup, because many cleanups write hardware.SendDefaultreturnsErrObserveOnly, as main's watchdog already did, andDELETE /api/drivers/{name}/controlanswers 403.driver_initor a failed "Test connection" left a paho client reconnecting forever under the same client id. The next successful Add then fought it for the broker session, which is the flap behind the ferroamp incident.HostEnv.closeCapabilities.add()defers it on every error return.driver_cleanupnever ran on shutdown or restart. It got an already-canceled context, so it had been silently skipped since 1f6686b. It now runs after the shutdown default with its own 5 s bound. Probes andobserve_onlystops discard the VM instead.context.WithoutCancel.allow_write), the WebSocket grant andsupports_pv_curtailwere ignored; they now restart the driver.Not changed (owner decisions)
driver_pollreturns. This would change the poll cadence of about 15 bundled drivers: some Modbus drivers would poll 5× more often, and myuplink could flap at the 60 s watchdog.driver_init. Slow or offline devices would fail at boot instead of starting degraded.Behaviour to know
driver_initfinishes before ShutdownAll.Evidence
registry_lifecycle_test.goandregistry_config_values_test.go. All of them fail with the oldregistry.go/host.go.go test ./internal/driverspasses, also with-raceon the lifecycle tests../internal/api,driverrepo,driverinventory,integration,modbus,mqtt,./cmd/ftwandFTW_E2E=1 ./test/e2e.🤖 Generated with Claude Code
https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7