|
| 1 | +## Context |
| 2 | + |
| 3 | +`SectionValidator` lazily validates device parameter support before a section or |
| 4 | +hot-water group is read. It currently stores completion as a section-wide set in |
| 5 | +`APIValidator` and a group-wide set in `SectionValidator`. An `include` request |
| 6 | +validates only a subset but records that coarse completion state, so a later |
| 7 | +request for different names or all names can skip validation. |
| 8 | + |
| 9 | +The resulting configuration has not established whether every requested |
| 10 | +parameter is supported. For normal sections, an unvalidated parameter can remain |
| 11 | +in the configuration and later produce a strict response-mapping failure. For |
| 12 | +hot water, the cache contains only the first subset and later reads silently use |
| 13 | +that incomplete cache. |
| 14 | + |
| 15 | +## Goals / Non-Goals |
| 16 | + |
| 17 | +**Goals:** |
| 18 | + |
| 19 | +- Record lazy-validation coverage by parameter ID for sections and hot-water |
| 20 | + groups. |
| 21 | +- Revalidate only the parameter IDs required by a later request when they have |
| 22 | + not already been covered. |
| 23 | +- Retain the existing public method signatures, include-filter validation, and |
| 24 | + per-section/group locking model. |
| 25 | +- Add regression tests for sequential filtered and unfiltered access. |
| 26 | + |
| 27 | +**Non-Goals:** |
| 28 | + |
| 29 | +- Change the public `include` API or make it accept parameter IDs. |
| 30 | +- Alter device-response parsing, model serialization, or unsupported-parameter |
| 31 | + rules. |
| 32 | +- Retry or cache failed validation requests. |
| 33 | + |
| 34 | +## Decisions |
| 35 | + |
| 36 | +### Track covered parameter IDs per validation owner |
| 37 | + |
| 38 | +`APIValidator` will maintain a mapping from section name to the set of parameter |
| 39 | +IDs whose support was checked. `SectionValidator` will maintain the equivalent |
| 40 | +mapping for hot-water group names. Completion for a request is determined by |
| 41 | +whether its requested IDs are a subset of that owner’s covered IDs. |
| 42 | + |
| 43 | +Parameter IDs are chosen over parameter names because they are the identifiers |
| 44 | +sent to BSB-LAN and remain unambiguous if a configuration ever aliases a name. |
| 45 | +When a response establishes an ID is unsupported, it is removed from the active |
| 46 | +configuration/cache but remains covered, preventing needless repeated probes. |
| 47 | + |
| 48 | +Alternative considered: avoid persisting any completion after an `include` |
| 49 | +request. This avoids the defect but discards useful knowledge and repeatedly |
| 50 | +validates already checked parameters. Parameter-level coverage keeps lazy |
| 51 | +loading efficient while remaining correct. |
| 52 | + |
| 53 | +### Derive requested IDs before the one-time gate |
| 54 | + |
| 55 | +Each ensure method will first resolve the configured IDs for its section or |
| 56 | +group, applying `include` when present. Its lock’s fast and post-lock checks will |
| 57 | +compare that specific requested-ID set to coverage rather than use a coarse |
| 58 | +section/group marker. A full request resolves all currently configured IDs and |
| 59 | +therefore completes only after each is covered. |
| 60 | + |
| 61 | +An include filter that matches no IDs will not add coverage or mark a group or |
| 62 | +section complete. Existing downstream include validation remains responsible for |
| 63 | +returning the appropriate invalid-include error. |
| 64 | + |
| 65 | +Alternative considered: retain a boolean for full validation plus a separate |
| 66 | +partial set. This duplicates state and makes configuration changes harder to |
| 67 | +reason about; one coverage mapping expresses both cases. |
| 68 | + |
| 69 | +### Preserve locks and recheck coverage after waiting |
| 70 | + |
| 71 | +The existing per-section and per-group locks remain in place. The completion |
| 72 | +predicate will calculate coverage for the current requested IDs both before and |
| 73 | +after lock acquisition. Concurrent calls requesting different subsets therefore |
| 74 | +serialize safely, and the second call still validates its uncovered IDs. |
| 75 | + |
| 76 | +## Risks / Trade-offs |
| 77 | + |
| 78 | +- [Configuration mutation during validation] → Derive the requested IDs from |
| 79 | + the current configuration at each completion check; removed unsupported IDs |
| 80 | + no longer need validation. |
| 81 | +- [Stale internal tests inspect completion sets] → Update tests to assert |
| 82 | + parameter coverage and externally observable request/cache behavior instead |
| 83 | + of obsolete whole-group completion. |
| 84 | +- [Additional first-read requests] → A later request for previously unrequested |
| 85 | + parameters necessarily makes one validation request; already covered IDs are |
| 86 | + not re-requested. |
0 commit comments