Repository navigation
feat(drivers): let a signed read-only driver send its declared MQTT read requests - #2071
Merged
Merged
Conversation
Codex Review Summary: ✅ CompletedThis 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
to srcfl/device-drivers
that referenced
this pull request
Nov 22, 2026
….2.1) 1.2.0 sends R/<portal ID>/keepalive every 30 s, but the signed channel's guard and FTW refuse every publish from this read-only driver, so the keep-alive never reached a GX from the channel. The manifest now lists R/+/keepalive in mqtt_read_request_topics. The channel's guard lets the driver publish to that topic alone, with at most 1 KiB of payload; an FTW Core with srcfl/ftw#2071 also limits it to six a minute. The driver still holds only mqtt.subscribe, so a Core without srcfl/ftw#2071 runs it as it runs 1.2.0 and refuses the request. The Lua source is unchanged. A changed artifact needs a new version, so 1.2.1. Refs #256 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
frahlg
force-pushed
the
mqtt-read-requests
branch
from
November 22, 2026 13:05
0ba27fd to
1f4fcfd
Compare
…ead requests Victron's Venus OS publishes its MQTT values only while a client sends R/<portal ID>/keepalive. victron_mqtt is not bundled, so every FTW user runs it from the signed channel under a read-only policy, and allowWrite refused its keep-alive. Without one the GX goes quiet and the driver goes stale. RuntimePolicy gains MQTTReadRequestTopics, carried from the signed manifest's metadata the way AuthPostPaths is. A read request is not a write, so it needs no write permission: a read-only policy that declares topics and holds mqtt.subscribe may publish to those topics, and validate still refuses mqtt.publish. A Core without this change accepts the same signed policy and refuses the request, as before. validate refuses a bad pattern. A topic must start with R/, Venus's read-request namespace: a literal first level alone would admit W/+/settings/..., a Venus write, and a third-party repository's key may have signed the manifest. "+" is a whole level, "#" is refused, levels are printable ASCII without spaces, at most 256 bytes. host.mqtt_publish from such a driver passes only to a topic that matches a declared pattern level by level, with at most 1 KiB of payload and six requests in any 60 s. Setup measurement mode and fingerprint probes hold it as they hold writes. Every other publish, and every publish from a driver without a policy, goes through allowWrite unchanged. Refs srcfl/device-drivers#256 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
frahlg
force-pushed
the
mqtt-read-requests
branch
from
November 22, 2026 13:16
1f4fcfd to
10ca649
Compare
frahlg
added a commit
to srcfl/device-drivers
that referenced
this pull request
Nov 22, 2026
….2.1) 1.2.0 sends R/<portal ID>/keepalive every 30 s, but the signed channel's guard and FTW refuse every publish from this read-only driver, so the keep-alive never reached a GX from the channel. The manifest now lists R/+/keepalive in mqtt_read_request_topics. The channel's guard lets the driver publish to that topic alone, with at most 1 KiB of payload; an FTW Core with srcfl/ftw#2071 also limits it to six a minute. The driver still holds only mqtt.subscribe, so a Core without srcfl/ftw#2071 runs it as it runs 1.2.0 and refuses the request. The Lua source is unchanged. A changed artifact needs a new version, so 1.2.1. Refs #256 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
frahlg
added a commit
to srcfl/device-drivers
that referenced
this pull request
Nov 22, 2026
… victron_mqtt 1.2.1 (#275) * feat(channel): let a read-only MQTT driver declare its read requests Venus OS on a Victron GX publishes its MQTT values only while a client sends R/<portal ID>/keepalive. A driver from the signed channel cannot send one: the generated guard turns host.mqtt_publish into an error for every read-only driver, and FTW Core refuses the publish too. A catalog manifest may now list mqtt_read_request_topics. The channel build checks each topic, refuses the list on a driver that is not MQTT or that controls, carries it into the signed metadata, and generates a guard that lets host.mqtt_publish and host.mqtt_pub through only to a matching topic with at most 1 KiB of payload. A topic must start with R/, Venus's read-request namespace: a literal first level alone would admit W/+/settings/..., a Venus write. "+" is a whole level, "#" is refused, levels are printable ASCII without spaces, at most 256 bytes. The guard checks the R/ level itself as well. A read request is not a write, so the driver gets no write permission: the signed permissions stay read-only and verification still refuses mqtt.publish on a read-only driver. An FTW Core that does not know the field runs the driver as before and refuses the request. Verification and make check hold the topics to the same rule, and verification wants mqtt.subscribe beside them. Every other artifact is byte for byte the same. Refs #256 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com> * feat(victron_mqtt): declare the Venus keep-alive as a read request (1.2.1) 1.2.0 sends R/<portal ID>/keepalive every 30 s, but the signed channel's guard and FTW refuse every publish from this read-only driver, so the keep-alive never reached a GX from the channel. The manifest now lists R/+/keepalive in mqtt_read_request_topics. The channel's guard lets the driver publish to that topic alone, with at most 1 KiB of payload; an FTW Core with srcfl/ftw#2071 also limits it to six a minute. The driver still holds only mqtt.subscribe, so a Core without srcfl/ftw#2071 runs it as it runs 1.2.0 and refuses the request. The Lua source is unchanged. A changed artifact needs a new version, so 1.2.1. Refs #256 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com> --------- Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Paired with srcfl/device-drivers#275 (the channel side). The two PRs can merge in either order; see "Merge order".
Why
Venus OS on a Victron GX publishes its MQTT values only while a client sends a read request to
R/<portal ID>/keepalive(victronenergy/dbus-flashmq README, "Keep-alive"; it stops 60 s after the last one).victron_mqtt1.2.0 (srcfl/device-drivers#268, merged today) sends it every 30 s.victron_mqttis not bundled (drivers/BUNDLED_SOURCE.jsonlistsvictron, notvictron_mqtt), so every FTW user runs it from the signed channel under a read-onlyRuntimePolicy, andallowWriterefuses its publish ("read-only driver cannot write"). On a GX with no other MQTT client the values stop and the driver goes stale.Change
RuntimePolicy.MQTTReadRequestTopics(andCatalogEntry.MQTTReadRequestTopics, JSONmqtt_read_request_topics).driverrepocopies it from the verified signed manifest's metadata, the same way it copiesAuthPostPaths. Signature checks are unchanged: a manifest altered after signing is refused, and the policy stays the verified one.mqtt.subscribemay publish to those topics.validatestill refusesmqtt.publishin a read-only policy, as before. It also refuses a bad pattern, so a malformed signed entry fails at start.host.mqtt_publishgoes through a newallowMQTTPublish. A publish from a signed read-only driver passes only when the topic matches a declared pattern level by level. Everything else, and every publish from a driver without a policy, still goes throughallowWrite.go/internal/drivers/mqtt_read_request.go.host.goandlua.gochange by one field and one line, to stay clear of feat(control): read the inverter stream and say when its grid headroom is gone #2070, feat(drivers): add host.http_put for device APIs that write with PUT #2028 and fix(battery): explain calibration and suspend manual control #2017.Because the signed policy holds no new permission, a Core without this PR accepts it, starts the driver, and refuses the request as it does today.
Limits
R, Venus's read-request namespace. A literal first level alone would not be enough:W/+/settings/0/Settings/CGwacs/AcPowerSetPointis a valid pattern and a Venus write. AnddirectManifestRuntimePolicyalso builds policies for a third-party repository whose key the owner trusts, so we are not always the signer.+stands for one whole level and#is refused. A level is printable ASCII without spaces. Patterns and topics are at most 256 bytes. A+must match a non-empty level with no wildcard in it.{"keepalive-options": ["suppress-republish"]}(about 45 bytes).Together that caps a declared topic at about 130 bytes a second, too little to be a write channel.
Trust model: what a read-only driver still cannot do
W/..., anotherR/...topic, a deeper or shorter topic, and one carrying+,#or an empty level.mqtt.publish, or any other write permission.validaterefuses it with or without declared topics.DRIVERtable plays no part. The channel build in feat(channel): let a read-only MQTT driver declare its read requests; victron_mqtt 1.2.1 device-drivers#275 refuses them on a driver that is not MQTT or that controls.A declared read request still meets
allowWrite's other gates. Setup measurement mode holds it, so a GX with no other MQTT client goes quiet until setup ends, and a fingerprint probe never sends one.DeviceReadOnlyis left out: it means another client owns the driver's Modbus endpoint (registry.go sets it from the Modbus capability), and a read request goes to the MQTT broker, not to that endpoint. Bundled, local and control-capable signed drivers run without a policy and publish as before: any topic, any size, no rate limit, still blocked in setup measurement mode.Tests
go/internal/drivers/read_only_mqtt_read_request_test.go:validateaccepts:R/+/keepalivewithmqtt.subscribeonly;mqtt.subscribe(they grant nothing).validaterefuses:mqtt.publishwith or without topics;R:W/+/x,W/+/settings/0/Settings/CGwacs/AcPowerSetPoint,X/+/keepalive,r/+/keepalive,+/+/keepalive,Ralone,keepalive;R/#,#,keep#alive,+x;$SYS/...;mqtt.subscribe;R/abc123/keepalivewith both payloads and with 1024 bytes;W/abc123/settings/...,R/abc123/system/0/Serial,R/abc123/keepalive/x,R/#,R/#/keepalive,R/+/keepaliveandR//keepalive;mqtt.subscribe, or with no declared topics;W/write is.go/internal/driverrepo/mqtt_read_request_policy_test.go:mqtt.subscribeand the topics yields a policy withoutmqtt.publish, andNewLuaDriverWithPolicyaccepts it.R/#makes the Lua constructor refuse the policy.With the old
allowWritecall put back inlua.go, both managed-driver tests fail and the no-policy test passes.Older Core, checked against
master's own code. I built the signedvictron_mqtt1.2.1 entry and artifact from srcfl/device-drivers#275 with its channel tool, using a throwaway key. A temporarydriverrepotest (not committed) served them over a signed manifest, installed the driver, built its runtime policy and started it with a fake broker. After the GX'sN/c0619ab1234/system/0/Serialit polled three times.origin/master(1015e6b), the driver installs and passesvalidate. Its policy holdsmqtt.subscribeonly. It starts, and its keep-alive is refused (mqtt.publish: read-only driver cannot write) with one warning. Nothing reaches the broker, the same as 1.2.0 today.R/c0619ab1234/keepalive.Results:
go test ./internal/drivers/ ./internal/driverrepo/: ok.GOFLAGS=-p=4 make verify: 88 packages ok, vet and build clean.Merge order
The two PRs merge independently.
victron_mqtt1.2.1. A Core without this PR runs it as it runs 1.2.0, and refuses the keep-alive.Changeset:
minor(a new capability for signed drivers), which needs the owner's approval. Not tested against a real GX.Refs srcfl/device-drivers#256
🤖 Generated with Claude Code