Repository navigation
feat(channel): let a read-only MQTT driver declare its read requests; victron_mqtt 1.2.1 - #275
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
force-pushed
the
mqtt-read-requests
branch
from
November 22, 2026 13:04
bc899cb to
c20fc1b
Compare
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>
….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:16
c20fc1b to
02d0325
Compare
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/ftw#2071 (Core). 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").victron_mqtt1.2.0 (#268) sends one every 30 s, but from the signed channel it never reaches the GX:host.mqtt_publish = __sourceful_ftw_write_deniedfor every read-only driver, andvictron_mqttis not bundled in FTW, so every FTW user runs the channel copy.Change
Two commits.
1.
feat(channel): let a read-only MQTT driver declare its read requests. No published artifact changes:check-versionsagainstdrivers-betareportsadded: [],changed: [].mqtt_read_request_topics, for example["R/+/keepalive"]. It sits in the manifest rather than theDRIVERtable becausevictron_mqtthas noDRIVERtable, and it is a grant that review should see besidecontrolandprotocol.tools/manifest_parser.pyholds the topic rule, the same as Core's. The first level must be exactlyR, Venus's read-request namespace. A literal first level alone would admitW/+/settings/..., a Venus write.+is a whole level,#is refused, levels are printable ASCII without spaces (checked withfullmatch, so a trailing newline is refused as Core refuses it), at most 256 bytes.tools/ftw_repository.pychecks 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. The guard letshost.mqtt_publishandhost.mqtt_pubthrough only to a topic underR/that matches a declared pattern level by level, with at most 1 KiB of string payload, and raises for anything else. It checks theR/level itself, so it does not rely on the build's check. Only a driver that declares topics gets the guard.["mqtt.subscribe"], and verification still refusesmqtt.publishon a read-only driver, declared topics or not. A Core that does not know the field therefore accepts the policy, starts the driver, and refuses the request as it does today.mqtt.subscribe.validate_manifest.py(make check) holds the manifest to the same rule.docs/WRITING-A-DRIVER.md, "A read-only driver that has to ask", covering the sign-in paths (not documented here before) and read-request topics. Alsospec/manifest-v2.md(field, rule 13, V2.5) andspec/host-api.md.2.
feat(victron_mqtt): declare the Venus keep-alive as a read request (1.2.1). Onlymanifests/victron_mqtt.yamlgainsmqtt_read_request_topics: ["R/+/keepalive"]. The Lua source is unchanged. The artifact changes, so the version moves from 1.2.0 (published) to 1.2.1, with the generated catalog files and a changelog entry.Trust model: what a read-only driver still cannot do
W/..., anotherR/...topic, a deeper or shorter one, and one carrying+,#, a space or an empty level. Both the guard and Core check this.R/, Venus's read-request namespace, whatever its manifest says.mqtt.publishor any other write permission.Signing is unchanged. Public PR builds stay unsigned; only the release workflow on
mainsigns.Tests
tests/test_ftw_repository.py:W/+/x,W/+/settings/0/Settings/CGwacs/AcPowerSetPoint,X/+/keepalive,+/abc123/keepalive,R,keepaliveandR/+/keepalive\n.W/+/xpattern still refusesW/abc123/x, run in./lua55.["mqtt.subscribe"], and the signed manifest verifies../lua55with a mock host:R/abc123/keepalive: empty, with the suppress-republish JSON, with 1024 bytes, and throughmqtt_pubtoo;W/...,R/abc123/system/0/Serial,R/abc123/keepalive/x,R/abc123,R/#,R/#/keepalive,R/+/keepalive,R//keepalive, a space, an empty topic, 1025 bytes and a nil topic;W/pattern), a Modbus driver (sdm630) and a control driver (ferroamp) are refused while building.mqtt.publishwith or without topics, topics withoutmqtt.subscribe, andR/#.make check's manifest validator refuses the same.mqtt.publish, and onlyvictron_mqttloses the blanket publish denial.Older Core, checked against FTW
master's own code. I built this branch's signedvictron_mqtt1.2.1 entry and artifact with a throwaway key. A temporary FTWdriverrepotest (not committed) installed them from a signed manifest, built the runtime policy and started the driver with a fake broker.origin/master(1015e6b2), 1.2.1 passesvalidateand starts. Its keep-alive passes the guard, the host refuses it (mqtt.publish: read-only driver cannot write), and the driver logs one warning. That is what 1.2.0 does today.R/c0619ab1234/keepalive.Results:
make check: 5429 passed, 928 skipped.make test-driver ID=victron_mqtt: 76 passed, 4 skipped.check-versionsagainstdrivers-beta(8c84ab9): commit 1 alone changes nothing; both commits change onlyvictron_mqtt, under a higher version.Merge order
The two PRs merge independently.
victron_mqtt1.2.1 on the push tomain. A Core without feat(drivers): let a signed read-only driver send its declared MQTT read requests ftw#2071 runs it as it runs 1.2.0, and refuses the keep-alive.#266, #267, #268, #269, #270, #272, #273 and #274 merged while this was being written. This branch is based on
mainafter them.Not tested against a real GX.
Refs #256
🤖 Generated with Claude Code