Skip to content

refactor(drivers): remove the control v2 driver runtime and unused host proxies - #1454

Merged
frahlg merged 2 commits into
masterfrom
refactor/remove-control-v2-runtime
Sep 27, 2026
Merged

frahlg merged 2 commits into
masterfrom
refactor/remove-control-v2-runtime

Conversation

@frahlg

@frahlg frahlg commented Sep 27, 2026

Copy link
Copy Markdown
Member

Round 2 of the multi-agent hardening and refactor review. A skeptic confirmed each finding against the code, and a second reviewer checked this diff and ran its tests. Removals follow the owner decisions of 2026-09-26.

Changes

  • Docs: curated Lua driver catalog #16 Removed the control v2 runtime. Gone: LuaDriver.CommandV2/DefaultModeV2, the v2 load and lifecycle timeouts, commandResult, boundedLuaContext and the evidence helpers (lua.go); the write phase, deadline, budget and evidence state, beginWriteScope/endWriteScope and recordWriteEvidence (host.go); controlV2Runtime, luaRuntime.CommandV2/DefaultModeV2, runningDriver.policy/leaseExpiresAt, the v2 startup default, the lease timer, the driver_stale and lease_expired defaults, dispatchV2Command, defaultDriver (now a direct DefaultMode call), recordCommandResult, newControlID and Registry.CommandResultSink (registry.go); the CommandResultSink wiring in main.go; and the v2 constants, types and validation. control_v2.go became runtime_policy.go and keeps only the read-only RuntimePolicy. validate rejects any policy that is not read-only, and allowWrite now refuses every write from a driver that …
    • Test: go/internal/drivers/read_only_policy_test.go: TestSignedReadOnlyPolicyDeniesWritesInEveryLifecyclePhase (moved from the deleted control_v2_test.go and rebuilt on writeCountingModbus), TestRuntimePolicyThatMayWriteIsRefused, and TestSignedReadOnlyDriverSleepsLikeABundledOne. With the old sleep cap …
  • fix(solaredge_pv): read SunSpec scale factors every poll, not cached #38 Deleted the unused HostEnv methods mqttSubscribe, mqttPublish, mqttPollMessages, modbusWriteSingle and modbusWriteMulti from go/internal/drivers/host.go, plus the now-unused context import. modbusRead stays; the Lua modbus_read host function calls it.
    • Test: Removal with no behaviour change. go build, go vet and go test ./internal/drivers pass. A grep across go/ finds no remaining callers.

Evidence

From /home/fredde/repos/ftw/.claude/worktrees/wf_8f55b108-a0d-4/go, using the scratchpad Go toolchain (/tmp/claude-1000/-home-fredde-repos-ftw/1c09d855-6ddf-43b8-949b-c49a26936713/scratchpad/go/bin) with GOTMPDIR=/home/fredde/.cache/go-tmp:

  • gofmt -l on every changed Go file: no output (PASS). A directory-wide run lists lua_ferroamp_stuck_pv_test.go and tibber_test.go, which were already unformatted and are untouched here.
  • go build ./... : PASS
  • go vet ./internal/drivers ./internal/state ./internal/api ./internal/driverrepo ./cmd/ftw : PASS
  • go test ./internal/drivers ./internal/driverrepo ./internal/state -count=1 : PASS (drivers 4.3s, driverrepo 2.2s, state 74.4s)
  • go test ./internal/api ./cmd/ftw -count=1 : PASS (api 61.9s, cmd/ftw 13.7s)
  • FTW_E2E=1 go test ./test/e2e -count=1 -timeout 300s : PASS (28.6s)
  • Check that the new test fails without the change: with the old sleep cap temporarily put back, go test ./internal/drivers -run TestSignedReadOnlyDriverSleepsLikeABundledOne FAILs. I then restored lua.go from a backup and re-ran vet and the drivers tests: PASS.
  • npm test: not run, because nothing under web/ changed.

Review

Both findings are resolved correctly, and I found no blockers.

Finding 16 (control v2 runtime removal):

  • Unreachable in production. driverrepo.directManifestRuntimePolicy returns only nil or a read-only policy with RuntimeABI gopher-lua-source-v1. A driver with control_enabled gets nil and runs on the legacy path, so no IsControlV2 branch could run.
  • Legacy path unchanged. The deleted branches were all v2-gated: the startup default, the command dispatch, defaultDriver, the lease timer and its driver_stale/lease_expired defaults, the v2 load timeout and the 10 s lifecycle timeout. What remains is behaviourally identical for nil and read-only policies. The recovery gate (recoveryRequired, attemptDefault, scheduleRecovery), restoreAfterCommand and the observe_only handling in add() are intact.
  • Write gating is equal or stricter. allowWrite now refuses any non-nil policy, and validate() accepts only read-only policies. Every mutating verb still calls allowWrite: mqtt.publish, modbus.write (single and multi), http.post and http.patch. The removed persist_secret=nil branch for non-read-only policies is still covered by allowsSecretPersistence, which returns false for …

🤖 Generated with Claude Code

https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7

…st proxies

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.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-27T06:35:17.926225Z 445c0c3 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.

@frahlg
frahlg merged commit f5f6c21 into master Sep 27, 2026
15 checks passed
@frahlg
frahlg deleted the refactor/remove-control-v2-runtime branch September 27, 2026 07:08
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