Repository navigation
test: refuse drivers that emit numbers they never read - #168
Merged
Merged
Conversation
A failed read must leave the value nil so the host sends null. `local w = 0` before a read, or `decode(...) or 0` after one, turns a dead device into a reading of 0 W, 0 % SoC or 50 Hz that nothing downstream can tell from a real one. lua_harness/no_invented_numbers.lua runs a driver twice with different registers, config and clock, then fails every read and shortens every Modbus reply. A number equal in both runs that was not read is invented. It is the same file Sourceful's driver registry runs on every publish. 44 of 91 drivers fail it today, so test_no_invented_numbers.py ratchets against invented-number-baseline.json like the absent-register test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: David Mozart <dmozartandraws@gmail.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
A failed read must leave the value nil, so the host sends null.
local w = 0before a read, ordecode(...) or 0after one, turns a dead device into a reading: 0 W, 0 A, 0 % SoC, 50 Hz. Nothing downstream can tell it from a real one. A meter at 0 W looks like a balanced site, and a battery at 0 % looks empty and ready to charge.drivers/tests/lua_harness/no_invented_numbers.luaruns a driver twice, A and B, with different register values, numeric config and clock. Then it fails every read for three polls and shortens every Modbus reply to half for three more. A number still emitted that is equal in both runs and was not read came from none of the driver's inputs, so it was invented. The data model's default SoC window (0.05 / 1.0) is the one allowed constant. Sourceful's driver registry runs this same file, byte for byte, on every publish and refuses a driver that fails it.drivers/tests/test_no_invented_numbers.pyratchets againstinvented-number-baseline.json, the same waytest_absent_register_settles.pydoes: a count that rises fails, a driver not listed must be clean, and a count that falls fails until the file is updated.make invented-number-report ID=<id>prints the fields for one driver.No driver changes. The baseline only records the current debt.
Driver evidence
driver_initfails with the probe config (zaptec_cloud: no credentials) is not measured. A configured constant emitted while the device is down, such asctekev.phases, counts as invented.Safety
Control evidence
required: not applicableChecks
Signed-off-by.make test-driver ID=<id>:pytest drivers/tests/test_no_invented_numbers.py91 passed. Withhelloremoved from the baseline andabb_meterraised by one, the expected 2 tests fail.make check: 4901 passed, 923 skipped🤖 Generated with Claude Code