0.3.0 Track A: DataModelHandler reads cache (water-leak endpoint)#34
Merged
Conversation
A commissioned Matter controller can now read BooleanState::StateValue
on a Water Leak Detector endpoint and get the value the wohl dispatcher
pushed into the cache. This closes the push/pull loop the architecture
critic flagged: publish_* (slice 5) writes the cache; this slice's
DataModelHandler reads it when rs-matter polls.
What's in this slice
src/commissioning.rs
- `CacheBooleanState` implements the rs-matter generated
`boolean_state::ClusterHandler` trait. Its `state_value` reads
`AttributeKey::new(wohl_endpoint_id, 0x0045, 0x0000)` from the
shared `Arc<AttributeCache>`; returns false (no leak) when the
cache has no entry yet — the safe default for a leak detector.
The read body is factored into a pure `current_state()` helper
so it's unit-testable without mocking rs-matter's ReadContext.
- `DEV_TYPE_WATER_LEAK_DETECTOR` (DTL 0x0043) defined locally —
this rs-matter rev ships no sensor device-type constants
(`DeviceType { dtype, drev }` is a plain pub struct, so we
define the ones we need). The mandatory server cluster for
this device type is BooleanState per DESIGN.md §2.
- NODE gains a Water Leak Detector endpoint (ep 1) exposing the
descriptor + BooleanState clusters, alongside the root endpoint.
- `bridge_handler(rand, cache)` (was `commissioning_only_handler`)
chains the endpoint's descriptor handler + the cache-backed
BooleanState handler via `EpClMatcher`.
- `start` / `run_matter` thread the `Arc<AttributeCache>` through
to the handler builder.
- 4 unit tests on `current_state()`: empty cache → false, leak
published → true, per-endpoint isolation, and the device-type id.
src/rs_matter.rs
- `start_commissioning()` passes `Arc::clone(&self.cache)` into
the commissioning thread, so the same cache that `publish_*`
writes is the one the handler reads.
End-to-end (feature on): construct RsMatterBridge → start_commissioning
spawns the thread with the cache → a sensor's water-leak alert flows
through publish_alert into the cache → a controller subscribed to the
water-leak endpoint sees StateValue=true.
What's NOT in this slice
- **Single endpoint, single cluster.** Only one Water Leak Detector
endpoint (ep 1), BooleanState only. The full Matter Bridge
topology (aggregator + dynamically-registered bridged endpoints,
one per wohl zone/contact/circuit, across all cluster types:
Temperature / Power / Concentration) is the next slice. Those
handlers follow the same shape — each generated cluster has its
own typed ClusterHandler trait (measurement clusters return
Nullable<T>).
- **Identity endpoint mapping.** wohl endpoint id == Matter
endpoint id for this demo (ep 1). The general wohl-zone →
Matter-endpoint allocation policy is DESIGN.md §7.1, formalised
in the multi-endpoint slice.
- **No aggregator / Bridged cluster.** This is a single
standalone device, not yet the aggregator+bridged-node topology
SWARCH-WOHL-006 describes. That topology + the BridgedHandler
land with the multi-endpoint slice.
- Still the rs-matter test DAC / vendor 0xFFF1.
Oracles green on 1.87.0
cargo +1.87.0 fmt -p wohl-matter-bridge --check OK
cargo +1.87.0 clippy ... --features rs-matter-backend
-- -D warnings OK
cargo +1.87.0 test -p wohl-matter-bridge --lib 34/34 (feature off)
cargo +1.87.0 test ... --features rs-matter-backend --lib 47/47 (feature on; +4)
cargo kani -p wohl-alert 4/4 harnesses
spar analyze (StarterHome.Deployed) 0 errors
rivet validate PASS
Verified line: untouched.
Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
Closes the push/pull loop. A commissioned Matter controller can now read
BooleanState::StateValueon a Water Leak Detector endpoint and get the value the wohl dispatcher pushed into the cache (slice 5). This is the pull side the architecture critic flagged in PR #29 — rs-matter polls ourDataModelHandler; we serve from theAttributeCache.End-to-end (feature on):
RsMatterBridge::start_commissioning()spawns the thread sharing the cache → a sensor's water-leak alert flows throughpublish_alertinto the cache → a controller subscribed to the water-leak endpoint seesStateValue=true.What's in this PR
src/commissioning.rsCacheBooleanStateimplements rs-matter's generatedboolean_state::ClusterHandler;state_valuereads the cache (factored into a pure, unit-testablecurrent_state()).DEV_TYPE_WATER_LEAK_DETECTOR(DTL 0x0043) defined locally — this rs-matter rev ships no sensor device-type constants. NODE gains the water-leak endpoint;bridge_handlerchains its descriptor + BooleanState handlers.start/run_matterthread theArc<AttributeCache>. 4 new unit tests.src/rs_matter.rsstart_commissioning()passesArc::clone(&self.cache)so the cachepublish_*writes is the one the handler reads.Oracles green on 1.87.0
What's NOT in this PR (next slice)
Nullable<T>.Verified line: untouched
Zero edits to
crates/wohl-{leak,temp,air,door,power,alert,ota,fw-door-bench}/,proofs/verus/, orfuzz/. Kani 4/4 onwohl-alert.Test plan
🤖 Generated with Claude Code