Repository navigation
Pin the COLOR wire range to a fixed width, so no wire layout follows a -D - #9
Conversation
hmtl_program_color_t embedded pixel_range_t, whose fields are PIXEL_ADDR_TYPE — uint8_t by default, uint16_t under -DBIG_PIXELS. So this one struct had a wire layout that followed a BUILD FLAG: 5 bytes with range at 3 in one half of the fleet, 7 in the other. Shipped envs really do differ (lightbringer_*, rfm_328_10_2, esp32_routed set it; nano, uno, esp32_breadboard do not), so two ATMega328 modules already disagreed about it with no ESP32 in sight. HMTL#7 packed the struct, which fixed AVR-vs-ESP32 within each flag setting, and deliberately left flag-vs-flag alone. This closes it: the range is now a named wire_pixel_range_t of two uint16_t, 7 bytes with range at 3 on every ABI under both flag settings. uint16_t and not uint8_t because the builds that set -DBIG_PIXELS are exactly the ones whose strips exceed 255 pixels. The cost is that the only in-tree producer, `HMTLClient -P color -C r,g,b,start,length`, emitted the 5-byte form through ProgramGeneric's raw bytes; that is what the new ProgramColor class, the --color option and the -P color warning are for. program_color() converts to pixel_range_t at the setRangeRGB call and bounds both fields on the way. Two questions, not one: whether the start is inside the strip, and whether it survives the narrowing at all — on a default build 300 would otherwise become 44 and paint a range nobody asked for. Start is checked first so an over-long range can never degrade into a whole-strip fill: length == 0 keeps its documented "whole strip" meaning, and because avail >= 1 the clamp cannot manufacture a zero. The assert goes from `3 + 2 * sizeof(PIXEL_ADDR_TYPE)` to a literal 7, which is the visible proof this worked. Worth recording why the expression form was weak rather than just deleting it: an assert written in terms of a configurable agrees with whatever that configurable happens to be, so it held on both sides of the disagreement it was meant to catch. Verification, and the part that nearly went wrong: * The sweep passes on host, host-avr-proxy, avr-g++ and xtensa under both flag settings — the same 7 everywhere is the point. * Negative control for the widening itself: reverting to pixel_range_t in a scratch copy goes red on all three real ABIs under DEFAULT flags, and stays green under -DBIG_PIXELS where the old layout coincided with the new one. That is the exact inverse of the old situation, where only -DBIG_PIXELS could catch the struct being unpacked. * Which means the sweep's -DBIG_PIXELS axis lost its justification. Rather than keep an axis whose halves now compile identical layouts, this adds pixel_range_t width asserts (2 B default, 4 B under the flag) — each visible to only one half. It is still the type program_color() narrows into, so its width is load-bearing even though it is off the wire. * Negative control on the new firmware tests, not just the asserts: dropping the representability check turns start=300 into a painted pixel 44, and letting length == 0 skip the start check floods the strip on a stale invocation. One test each goes red for exactly that reason. * test_protocol.py is the first test in python/ that packs a program message — ProgramFade/Sparkle/Circular never had one, which is much of why this struct drifted. Its expectations are literal byte strings transcribed from the C struct, not derived from FORMAT, so the two implementations check each other. `make test-python` names it explicitly; a guard no target invokes is the same defect as an assert no toolchain compiles. * The HMTL_Test PixelUtil stub diverged from the real setRangeRGB in exactly the two cases a range test exercises (length == 0 filled start.._num rather than the whole strip; start past the end clamped into a full-strip fill). Aligned first, so the tests do not encode the stub's behaviour as the expectation. make test passes end to end: 19 python, 60 native, avr build, the four-ABI sweep, and 484/484 perturbations breaking the build as required. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
…iled Two reviews (self-review and an adjacent-context review carrying the HMTL#7 packing task) independently put the same defect first, and the self-review found a correctness gap underneath it. **The stale-invocation guard failed open on the fleet this change was for.** Rejecting a start "past the addressable range" is strip-length dependent: start=2560, length=0 is caught by addr_max==255 on a default build, but on a 3000-pixel -DBIG_PIXELS module it is inside the strip AND representable, so it passed every check and length==0 flooded the whole strip. Exactly the failure the guard existed to prevent, on exactly the builds the widening was for. The rule that actually holds is simpler and flag-independent: length == 0 means the whole strip, which makes start meaningless, so a NONZERO start with a zero length is not a request anyone can have meant. It is also the shape every stale 5-byte `-P color -C r,g,b,s,l` takes. The one zero-length form that must survive is start == 0 — what HMTLprotocol.py's zero-fill produces for a colour program carrying only an RGB triple. This also removes the oddity of validating a start and then discarding it. **The -DBIG_PIXELS half of the new test was compiled by nothing.** tests/layout/ sweeps the flag over layout ASSERTS; no env compiled it into a running test, so the `#ifdef BIG_PIXELS` branch asserting start=300 landing on pixels 300-301 — the payoff of widening the range — was dead source, while the branch that did run asserts rejection at the narrow width. A test that only ever compiles its negative half is the same guard-that-cannot-fail this subsystem keeps producing, and the previous commit shipped one. Adds [env:native_bigpixels] and runs both envs from `make test-native`. It earned its place on the first run: it immediately caught the assertion strings this commit had just changed. Also from the reviews: * test-python now takes the DIRECTORY with test_CircularBuffer excluded rather than a list of files. Naming files meant a new test ran under no target until someone remembered to add it — which its own new comment described while the recipe did it. * test_color_message_carries_the_payload_after_the_headers derived its expectation from the pack() under test; now a literal byte string, like the rest of the file. * The reject path emitted one message for three causes (no pixels / past the end / not representable). Split, and the inert (uint32_t) casts dropped. * The stale-invocation test moved to a 3000-pixel strip, so the rejection can only come from the new rule and not from start >= numPixels(). * New test for start > 0 with length == 0, which was unasserted. Negative control on the new rule: disabling it turns both the zero-length test and the stale-invocation test red under BOTH pixel widths. 18 native tests per env x 2 envs, 19 python. make test green end to end. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
Both reviews on this PR made the same point: aphelps/HMTL#9 adds behavioural tests for program_color() — the narrowing, the zero-length rule, the stale-invocation rejection — and NOTHING invoked them. HMTL has no .github/workflows, and test-hmtl here reached only HMTL/tests/layout/. So CI got the new static_asserts and none of the code that reads those structs. The sweep covers compile-time LAYOUT. That is a different question from whether the reader is correct, and this repo is the only place both get asked. Both pixel-width envs, because an `#ifdef BIG_PIXELS` branch in a test body is dead source unless something compiles the flag — which is exactly how HMTL#9's first draft shipped a test whose wide-width half had never been built. Delegated to HMTL's own `make test-native` so the env list stays in the repo that owns it. PIO defaults to the venv setup.sh builds and falls back to PATH; if neither resolves, this is a skipped suite like any other. Verified both ways rather than assumed: lenient exits 0 with a "-- skipped: --" note, STRICT=1 exits non-zero with the ERROR line. HMTL's `test-python` is deliberately NOT wired in. It needs pytest, which is not in WLED/requirements.txt, so it would fail on a fresh CI venv — a local venv that happens to have pytest would have hidden that. Adding pytest to the pinned toolchain is a separate decision about this repo's dependency set; filed rather than smuggled in here. Pointer moves to dbd6673, which also carries HMTL#9's review fixes. Verified on this combination: make test STRICT=1 — sweep on host/host-avr-proxy/avr/xtensa x both flags, 484/484 perturbations red as required, 61 native tests per pixel-width env, router relay+election+attach pio run -e ampworks — SUCCESS after rm -rf .pio/libdeps/ampworks Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
The re-review's finding, and it is the sharpest one this PR has had: the
zero-length rule landed in the C READER and nowhere else. For one commit the
Python encoder's docstring asserted the OPPOSITE rule ("length == 0 means the
whole strip, whatever start says"), pack() happily produced messages the module
now drops, `--color` printed "(length 0 = whole strip)" for one of them, and the
`-P color` warning still claimed the stale form is only rejected "on any strip
shorter than 2561 pixels" — the exact sentence that was the round-1 evidence,
left behind by its own fix.
So the two-implementation cross-check this PR exists to build had drifted within
one round. On a validity rule rather than a layout, which is worse in one
respect: a layout mismatch is caught by a byte-for-byte test, and this was
caught by nothing.
The rule is now stated in all three places a sender can read it and pinned by a
test:
* HMTLPrograms.h — as part of the contract next to the struct, not only as an
implementation comment in the .cpp.
* ProgramColor — raises ValueError at construction, so the traceback points at
the caller that chose the values, and the docstring says why the rule is
about the start/length PAIRING rather than the magnitude of start. Every
5-byte invocation leaves wire bytes 5-6 zero, so wire length is ALWAYS 0;
pairing catches them all on every strip and both flag settings, magnitude
does not.
* HMTLClient — refuses before announcing. It previously printed
"Sending ... (whole strip)" and THEN failed, which is both untrue and the one
description the rule exists to deny. The --color help and the -P color
warning now describe the rule that is actually enforced.
* test_protocol.py — three cases: the pairing is refused, start == 0 with
length == 0 still packs (the form a bare RGB triple produces, and the reason
the migration is small), and a nonzero start with a real length is untouched.
Also from the re-review, on the super-repo side: the "(both pixel widths)"
banner is asserted by this repo but the env list lives in HMTL, so an older
pin could run one env under a banner claiming two. Dropped; HMTL's own
test-native says what it ran.
make test green: 22 python, 61 native x 2 pixel widths, 484/484 perturbations.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
Round 3 of review. Two of these are problems the PREVIOUS round introduced by
making ProgramColor raise — a validation seam is only useful if it catches
everything that can go wrong at it.
* The new `except ValueError` in HMTLClient wrapped the int() conversions too,
so `--color 255,0,x` printed a bare "invalid literal for int()" under a
comment claiming the module would drop the message. Nothing had been built to
drop. Parsing and validation are now separate steps with separate messages.
* struct.error is NOT a ValueError, so an out-of-range field escaped pack() as
a raw traceback — on the very path two warnings now tell operators to use.
`--color 255,0,0,70000,5` and `--color 300,0,0,0,5` both did it. ProgramColor
now range-checks every field, which makes ValueError the single failure mode
and is what lets that except clause mean anything.
* The docstring claimed "an operator finds out at the CLI, not by watching a
strip do nothing". Over-claimed: `--color 0,0,255,300,10` packs fine and is
dropped by any default-width module, because a sender cannot know how many
pixels the target has. The rewrite had deleted the still-true past-the-end
sentence instead of correcting it; it now says which half each side owns.
* test_protocol.py was the last file still narrating the pre-fix rule ("the
firmware refuses a start past the end for exactly this reason"), with a stale
cross-reference to boot — the file whose job is documenting the cross-check
was the one describing the old contract.
Four new CLI tests pin what this round and the last one actually shipped and
nothing covered: the refusal happens before anything announces a send, a parse
error reads as a parse error, an out-of-range field reads as a range error
rather than a traceback, and a valid range still goes through. They invoke the
script as a subprocess with PYTHONPATH set explicitly — during this work a
hand-run imported an INSTALLED hmtl package instead of the checkout and
reported "no attribute 'ProgramColor'", so a CLI check proves nothing until you
know which copy it loaded. That is in a comment on the helper.
Negative controls, both confirmed: restoring the announce-then-construct order
turns the ordering test red, and removing the width checks turns the
struct.error test red.
make test green: 26 python, 61 native x 2 pixel widths, 484/484 perturbations.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
…:6000 Round 4 of review, and the finding is squarely mine: of the four CLI tests added last round, only test_cli_accepts_a_valid_range reaches the ACCEPT path, and past validation HMTLClient falls through to connecting to its default command server at localhost:6000 and transmitting. The test passed only because nothing happened to be listening on this machine. On a machine running a real HMTL command server it would have put a live broadcast COLOR on the fleet, and against a socket that accepts and stays quiet it hangs `make test` forever — neither multiprocessing.connection.Client nor send_and_ack's `while True` has a timeout. Fixed by aiming every CLI invocation at a port nothing is listening on (bind to 0, read the number, release it) and giving subprocess.run a timeout so a hang reads as a failure instead of a stall. The three refusal tests never reached the network — they sys.exit(1) well before the client is constructed — so this was only ever one test, but the harness is the right place for the fix. The accept test also asserted only on stdout while its returncode is 1, the same value its siblings use as evidence of REJECTION. It now says in the test why the exit code is not asserted (it means two different things on this path) and checks it got past validation rather than being refused for another reason. Reproduced rather than argued, and the first attempt did NOT reproduce: a listener that accepts and drops the connection lets the client fail fast, so the pre-fix invocation returned in under a second and the control proved nothing. With a listener that accepts and HOLDS the connection open, the pre-fix invocation hangs past 25s. The fixed suite finishes in 0.17s with that same listener running, because it never touches 6000. Also, the docstring nit the reviewer said to fold in if there was a commit anyway: an over-long LENGTH is clamped rather than rejected, so a lit strip is not proof the range was accepted verbatim. make test green: 26 python, 61 native x 2 pixel widths, 484/484 perturbations. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
aphelps/HMTL#9's new CLI tests aimed at HMTLClient's default command server. Only the accept-path test reached it, and it passed only because nothing was listening; against a socket that accepts and holds, `make test` hangs forever. They now target a deliberately dead port with a subprocess timeout. That matters here specifically: this repo's test-hmtl runs HMTL's suite in CI, so a test that hangs on a live listener would hang the workflow rather than fail it. Verified: make test STRICT=1 green at this pin. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
aphelps-reviewer-bot
left a comment
There was a problem hiding this comment.
Fresh-eyes review of the whole diff (main..640114b), not of a delta. This is the first review posted on this repo's PR — rounds 1-5 all landed on the super-repo pointer-bump PR (aphelps/WLED_dev#35), so a reader of HMTL alone has seen none of it. Where the earlier rounds' fixes are visibly correct in the final state I have not re-derived them.
The change is coherent as a whole. wire_pixel_range_t is the right shape — named rather than two inlined fields, packed, converted at the setRangeRGB call site rather than by widening pixel_range_t for every build. The literal HMTL_LAYOUT_SIZE(hmtl_program_color_t, 7) is the visible proof the task worked, and the cross-check it establishes is real: bytes hand-transcribed on the C side and hand-transcribed again on the Python side, neither derived from the other. The validity rule now reads identically in all four places a reader can meet it (the HMTLPrograms.h contract block, program_color(), ProgramColor's docstring, the --color help), which was round 2's finding and is genuinely closed. Five rounds of patching have not left a confusing result.
The one thing a series of delta reviews could not see is that the clamp's second question is answered by the stub, not by the library the stub mirrors. Detail inline on HMTLPrograms.cpp:733 and stubs/PixelUtil.h:23; in short, ArduinoLibs' PixelUtil stores num_pixels as PIXEL_ADDR_TYPE and init() rejects _numPixels > 255 on a default build, so numPixels() <= addr_max always holds and the start >= num check strictly subsumes start > addr_max. The representability branch — correction #1 in the plan's Outcome, "caught by writing the test first and watching it fail" — cannot fire against the shipped library; the test that pins it reaches it only because the stub's _num is an unconditional uint16_t with no init() bound. Not a correctness bug: the message is still rejected, just by the neighbouring branch with a different DEBUG1 line. But it is the same recurring shape this PR names in its own round-5 note — a guard checked against the environment that happened to be present — and the comment calling it "load-bearing at the default width" is the one claim here a reader will believe and be wrong about.
Two smaller whole-read notes, both inline:
- Coverage is inverted between the two rejection branches. The branch that can actually fire on hardware (
start >= numwith a nonzero length) has no test at all, and neither doesnum == 0; the branch that cannot fire has two. -P colorand--colordisagree about the 7-byte generic form.test_typed_and_generic_forms_agree_when_the_generic_one_is_written_outblesses it as byte-identical toProgramColor, while the CLI shouts a WARNING that the invocation is MISREAD at exactly that call.
None of this blocks. The wire layout, the conversion, the zero-length rule and the encoder are correct as shipped.
…therwise Found by reviewing the PR as a WHOLE rather than as a delta — five rounds of incremental review could not see it, because each looked only at what changed. ArduinoLibs' PixelUtil stores num_pixels as PIXEL_ADDR_TYPE and its init() rejects more than 255 pixels unless BIG_PIXELS is set. So numPixels() can never exceed addr_max, `start >= num` strictly subsumes `start > addr_max`, and the representability branch cannot fire against the shipped library. The comment calling it "load-bearing at the default width" was wrong. Worse, the test that appeared to prove it built a 400-pixel strip on a DEFAULT-flag build — a configuration the firmware cannot have. It only compiled because this suite's PixelUtil stub declared _num as an unconditional uint16_t with no init() bound, under a comment claiming to "mirror the real PixelUtil.h exactly". The mutation that turned it red therefore went red for a strip that cannot exist. That is the same defect this PR spent five rounds finding elsewhere, sitting in the PR's own evidence. * The stub's _num is now PIXEL_ADDR_TYPE, and its constructor complains when asked for more pixels than the flag can address, mirroring what init() treats as a hard error. * The check stays, correctly labelled: subsumed today, kept only because it is the one thing that would catch numPixels() and PIXEL_ADDR_TYPE drifting apart, which is the assumption the narrowing rests on. * The default-flag half of the test now uses a 200-pixel strip and asserts what a real default build actually does with start=300 — rejects it as past the end. The -DBIG_PIXELS half is unchanged and still asserts the payoff. * Coverage was inverted: the unreachable branch had two tests and the two reachable ones had none. Added tests for `start >= num` and for an output with no pixels (using the length==0 form, the only input that would otherwise reach setAllRGB and iterate). Also from the same review: * The `-P color` warning fired on every -P color invocation, including the correct 7-byte form that test_typed_and_generic_forms_agree_... explicitly blesses. Gated on five values, since warning on the right answer trains people to ignore the warning that matters. * HMTLPrograms.h still cited the colour struct as the justification for the sweep's -DBIG_PIXELS axis while tests/layout/Makefile, in this same PR, says that justification is spent. Now agrees with it. make test green: 26 python, 63 native x 2 pixel widths, 484/484 perturbations. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
aphelps/HMTL#9's representability check (`start > addr_max`) cannot fire against the shipped ArduinoLibs — PixelUtil holds num_pixels as PIXEL_ADDR_TYPE and init() refuses more than 255 pixels by default, so `start >= num` subsumes it. The test that appeared to prove otherwise built a 400-pixel default-flag strip, possible only because the HMTL_Test stub declared _num as an unconditional uint16_t while claiming to mirror the real header. Found by reviewing that PR as a whole rather than as a delta, which is the one thing five rounds of incremental review could not do. Verified: make test STRICT=1 green at this pin (63 native tests per pixel-width env, 484/484 perturbations red as required). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
Narrowing the stub's _num to PIXEL_ADDR_TYPE — the fix for a test asserting
behaviour in an impossible strip — silently rewrote a different test's premise
one file over. test_color_stale_five_byte_invocation_is_rejected_not_flooded
asked for 3000 pixels unconditionally; under -e native that now truncates to
184. It stayed green only because the zero-length rule is checked first, its
comment ("on a short strip the rejection could come from start >= numPixels()
and prove nothing") became false at the default width, and its reads at
2560/2999 became out-of-bounds lookups returning a default CRGB — assertions
that cannot fail.
Exactly the defect the previous commit was opened to remove, reintroduced by
the fix for it. Which is the argument for the guard rather than the fix:
* The strip size is per-flag (3000 under -DBIG_PIXELS where start=2560 is
genuinely inside the strip; 200 by default) and ASSERTED via numPixels() at
the setup. A stub change cannot quietly rewrite the premise again without a
test going red — verified by restoring the impossible 3000 and watching it
report "Expected 3000 Was 184".
* The probe indices are derived from that size instead of hard-coded, so they
stay inside the strip under both flags.
* The stub complains on stderr when over-asked. Verified honestly: `pio test`
does NOT surface a passing test's stderr, so this is a hint for someone
already reading output, not the guard. The numPixels() assertion is the
guard, and the comment now says so rather than implying otherwise.
Also the coverage gap the reviewer flagged: the `-P color` warning's five-value
gate had no test on either side. Three now — warns on the stale 5-value form,
silent on the correct 7-byte one, silent on other programs.
make test green: 29 python, 63 native x 2 pixel widths, 484/484 perturbations.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
aphelps/HMTL#9's stub narrowing silently truncated another test's 3000-pixel strip to 184 under the default width, leaving its comment false and three of its assertions unable to fail. Strip sizes are now per-flag and asserted via numPixels(), so a stub change cannot rewrite a test's premise unnoticed. Verified: make test STRICT=1 green at this pin. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
The reviewer marked this "not worth a commit" — the only failure mode is a cosmetic warning on a non-COLOR program — and on impact alone that is right. Taking it anyway because of what it IS rather than what it costs: a test named test_other_generic_programs_are_never_warned_about that cannot fail for the reason its name gives. `-C 1,2,3` is kept silent by the len()==5 half of the gate on its own, so the `program == color` half was untested. Leaving one of those behind in a PR whose entire subject is guards that cannot fail would be an odd place to start making exceptions. Five values now. Mutation-checked both ways: deleting the program check leaves this green at three values and turns it red at five. No further review round: this is the fix the reviewer specified and verified, applied verbatim to a single test argument. 16 python tests pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
Final commit on aphelps/HMTL#9. `-C 1,2,3` was kept silent by the len()==5 half of the warning gate alone, so test_other_generic_programs_are_never_warned_about could not fail for the reason its name gives. Five values now, mutation-checked both ways. Verified: make test STRICT=1 green at this pin. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
The last unaddressed inline comment on this PR, and a fair one: the docstring is unusually careful about what a receiver does with the range — rejects a start past the end, clamps an over-long length — while omitting the one in-tree receiver that never reads it at all. WLED's RS485 bridge handles PROGRAM_COLOR by taking programVals[0..2] and nothing else (usermod_rs485_bridge.cpp:432-435, verified). So a COLOR sent through the bridge ignores start and length entirely, which is exactly the kind of thing to know before concluding a module misparsed a range it never read. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
Last inline comment on aphelps/HMTL#9. ProgramColor's docstring detailed what receivers do with the range while omitting the one in-tree receiver that never reads it — this repo's own RS485 bridge, which takes programVals[0..2] and nothing else. Docstring only; no behaviour change, so the C and layout suites are unaffected. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
aphelps-reviewer-bot
left a comment
There was a problem hiding this comment.
Confirmation pass over 640114b..d7d7e8b (four commits). This content was already reviewed through the parent PR (aphelps/WLED_dev#35); this round exists to bring HMTL#9's own record current. All three findings from my last review here are closed, the four commits compose correctly, and nothing regressed.
Prior findings
- The representability check is answered by the stub, not by the library the stub mirrors. Closed.
HMTLPrograms.cppnow labels the branch SUBSUMED and says why (PixelUtil::init()refuses >255 pixels withoutBIG_PIXELS, sonumPixels() <= addr_maxalways holds andstart >= numfires first), keeping it only as the guard onnumPixels()andPIXEL_ADDR_TYPEdrifting apart. The stub's_numisPIXEL_ADDR_TYPE, and the default-flag half oftest_color_start_beyond_a_byte_is_not_truncatedruns on a 200-pixel strip asserting what a real build does (COLOR start past end of strip:300). Nothing still asserts the subsumednot representableline: the only remaining occurrences in the tree are theDEBUG1itself and the comment recording the history. - Coverage inverted between the two rejection branches. Closed, and verified by mutation rather than by reading: neutering
start >= numturnstest_color_start_past_the_end_of_the_strip_is_rejectedand the default half of the beyond-a-byte test red (2 failed / 18 passed); neuteringnum == 0turnstest_color_on_an_empty_output_draws_nothingred on its own (1 failed / 19 passed). -P colorand--colordisagreed about the correct 7-byte generic form. Closed: the warning is gated on five values. Both halves of the gate are load-bearing and I checked each by mutation — droppinglen(commandvalues) == 5reddenstest_generic_color_is_silent_on_the_correct_seven_byte_form; dropping theprogram == colorhalf reddenstest_other_generic_programs_are_never_warned_about, which is exactly what 3566ca5's-C 1,2,3->-C 1,2,3,4,5bought.
Composition — the part five separate patches can get wrong
- fd8477a's stub narrowing silently truncated a 3000-pixel strip and 07717b8 fixed that one call site. The question only the composed result answers is whether any other test carried the same premise. None does: every remaining
PixelUtilconstruction in the suite is 0, 3, 4 or 8 pixels, so_numbecomingPIXEL_ADDR_TYPEhas no second latent victim. (test_color_start_beyond_a_byte_is_not_truncatedhas nonumPixels()tripwire of its own and does not need one — 200 and 400 are each representable at their own width.) HMTLPrograms.handtests/layout/Makefilenow tell the same story about the-DBIG_PIXELSaxis (the colour struct's justification is spent; thepixel_range_tasserts hold it up), which was the last inconsistency between them.- d7d7e8b's docstring addition is factually right:
usermod_rs485_bridge.cpp:432-435requiresprogramLen >= 3and callsseg.setColor()withprogramVals[0..2]only — it never reads the range.
Run at d7d7e8b, not asserted from the PR body: 29 Python tests; 63 native tests x 2 pixel widths; the layout sweep green across host / host-avr-proxy / avr / xtensa x both flag settings; negative control 484/484 perturbations caught.
No new findings, and nothing outstanding from earlier rounds. Ready to merge as it stands.
aphelps
left a comment
There was a problem hiding this comment.
Comments in this PR are way to wordy. Please make these more concise and only what someone reading the code should know, but then you can merge
HMTL#8 and this branch both fixed the same stub divergence in
setRangeRGB, so main and pin-color-wire-range-width collided on
platformio/HMTL_Test/stubs/PixelUtil.h. Everything else merged clean.
Resolution, and why:
- setRangeRGB body: took main's. The two are semantically equivalent
for all three branches EXCEPT that main's start-past-end branch emits
DEBUG1_VALUELN("setRangeRGB: start past end:", ...) and this branch's
is silent. main's test_set_range_rgb_start_at_end_writes_nothing
asserts debug_log_contains("setRangeRGB: start past end:8"), so
taking this branch's form would have failed a test on main.
- setRangeRGB comment: kept this branch's. It is the fuller one — it
records why length == 0 meaning the whole strip is load-bearing
(HMTLprotocol.py zero-fills unspecified program bytes, so a colour
program carrying only an RGB triple arrives as {0, 0}).
- The _num/PIXEL_ADDR_TYPE comment (ours) and the new init() (theirs)
were not a real collision — independent additions at the same spot,
both kept.
Verified on the merge result, not argued:
pio test -e native 70/70 cases, incl. test_pixelutil
make -C tests/layout host, host-avr-proxy, avr, xtensa
x [default BIG_PIXELS] — all green
make -C tests/layout packed-access clean at both pixel widths
Known inconsistency left for the branch owner: main's new init() does
_num = n with no truncation complaint, while this branch's constructor
warns on truncation. Merging does not make that worse, but the two
entry points now differ.
Co-Authored-By: Claude Opus 5 <[email protected]>
The main-merge that reconciled the two independent PixelUtil stub fixes left init() on the pre-#9 shape: _num = n; _leds = new CRGB[n](); That was correct while _num was uint16_t. It is not correct now: #9 narrowed _num to PIXEL_ADDR_TYPE, so init() implicitly truncates _num while allocating the full n — and, more to the point, it silently re-admits exactly the impossible strips the constructor was changed to reject. A test that wanted a 400-pixel strip on a default-flag build can simply reach it through init() instead of the constructor and get _num == 144 backed by a 400-element array. Neither PR had this defect on its own; it exists only in the combination, which is why it survived both reviews. Fixed so the two entry points narrow, allocate and complain identically. 70 native tests pass at both pixel widths. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
aphelps-reviewer-bot
left a comment
There was a problem hiding this comment.
Re-review of d7d7e8b..9b0dcd8 — three commits from two sessions: the merge of main (b139269, which resolved the stubs/PixelUtil.h conflict against the just-merged PixelUtil bounds stack), 1c4e2de arriving with it, and 9b0dcd8 (the init() narrowing). The conflict resolution is correct, nothing was dropped from either side, and the PR's own wire-layout work is untouched by the merge. One new finding, inline, in the stub; plus one blocker that lives in the parent PR rather than here.
The setRangeRGB resolution is right, and is the stricter of the two sides.
- The merged body is main's three-branch form verbatim —
length == 0->setAllRGB(whole strip,startignored),start >= _num->DEBUG1_VALUELN("setRangeRGB: start past end:", ...)and no write, otherwise theavail/lenclamp — with this PR's(unsigned)casts on thesnprintfkept. So both semantics survive: thelength == 0whole-strip meaning and the start-past-end no-op. The resolution additionally gains the diagnostic this PR's own version did not have. - It still matches the shipped library: branch-for-branch identical to
ArduinoLibsmainPixelUtil/PixelUtil.cpp:146-156(9194ddf), including computingavailfrom the span sostart + lengthis never formed. - Not asserted from reading it: main's four new
test_pixelutilcases exercise exactly the two divergent cases ({3,0}on 8 px fills 0..7;{8,5}and{200,5}write nothing and log the guard;{5,10}clamps to 5..7), and they pass on this branch under both pixel widths.
Nothing was dropped. Three files were touched by both sides. For python/bin/HMTLClient and python/hmtl/HMTLprotocol.py the merge is exactly both diffs — base->main (29+/5-, 6+/1-) reproduces as PR->merge, and base->PR (68+, 108+) reproduces as main->merge — so --color / ProgramColor / the five-value -P color gate and main's DumpConfigHdr offset fix + dumpconfig response filter all landed intact. PixelUtil.h is the only genuinely reconciled file, and git diff d7d7e8b 9b0dcd8 over Libraries/HMTLMessaging, tests/layout, Makefile, platformio/HMTL_Test/platformio.ini, test_pixel_programs/ and test_protocol.py is empty — the reviewed wire-layout work is byte-identical to d7d7e8b.
1c4e2de does not interact with the wire-layout work. Its Python edits are DumpConfigHdr.from_data (honour offset, py3 byte indexing), client.get_ack logging, and the dumpconfig response filter — disjoint from ProgramColor, the -P color gate and hmtl_program_color_t. Its C edit is hmtl_write_config pre-validation in HMTLTypes.cpp. HMTLprotocol/HMTLWireFormat.h is untouched across the whole delta, so the WLED bridge is unaffected and the test plan's pio run -e ampworks item stays the formality it was described as.
The init() fix is correct and complete as far as entry points go. _num is assigned in exactly three places — the default ctor, init(), and the value ctor — and all three now narrow identically; there is no fourth way to construct or resize a strip in the stub. What it is missing is not another entry point but a guard: see the two inline comments (they are one finding in two parts, and the first closes the second).
Blocker, but in the parent PR: aphelps/WLED_dev#35 still pins HMTL at d7d7e8b — verified via the contents API against its head d61a119, not from the PR body. It must be re-pointed at whatever HMTL#9 lands as before #35 merges, or the super-repo builds the truncating init() this round fixed; and if #9 is squash-merged, d7d7e8b is unreachable, which is exactly the repair that had to be done by hand on #33.
Run at 9b0dcd8, not asserted from the PR body: 70 native tests x 2 pixel widths green (up from 63 — main brought test_hmtl_config and the test_pixelutil range cases); 37 Python tests green; layout sweep green across host / host-avr-proxy / avr / xtensa x both flag settings; negative control 484/484 perturbations caught.
Note, pre-existing and not from this delta: make test-python only passes where the hmtl package is importable by subprocesses. Without make install-dev or an explicit PYTHONPATH, all 13 test_emulator cases fail with Emulator did not start within 5s, because bin/HMTLEmulator cannot import hmtl (pytest's rootdir insertion does not reach the child). That was equally true of the old recipe, and the new test_protocol.py cases are unaffected — flagged only because the recipe widened in this PR and the failure mode is precisely this workstream's recurring shape.
| delete[] _leds; | ||
| _num = n; | ||
| _leds = new CRGB[n](); | ||
| _num = (PIXEL_ADDR_TYPE)n; |
There was a problem hiding this comment.
The two entry points now agree by duplication rather than by construction: the same ~15 lines of narrow-cast-and-complain exist twice, in the one file whose entire recorded history is these two drifting apart (fd8477a narrowed _num, 07717b8 repaired the 3000 -> 184 truncation it caused, this commit repairs init()).
The real library does not have this problem because its constructor delegates — ArduinoLibs/PixelUtil/PixelUtil.cpp:27-32 is initialized = false; init(numPixels, dataPin, clockPin, order);. Mirroring that makes the drift impossible rather than merely fixed:
PixelUtil(uint16_t n, uint8_t data, uint8_t clock, uint8_t order = 0)
: _num(0), _leds(nullptr)
{
init(n, data, clock, order);
}(with the constructor's stderr/numPixels() commentary moved onto init() and the duplicate if (n > ...) fprintf deleted). delete[] nullptr at the top of init() is a no-op, so the member-init list is enough.
Verified in a scratch copy of 9b0dcd8 rather than argued: it compiles and 70 tests x both pixel widths stay green — and it also closes the gap in the comment below, because every PixelUtil pixels(N, ...) in the suite then runs init(). Mutating _num to 0 inside init() goes from 0 failures today to 23 with the delegation in place.
Not blocking on its own; together with the next comment it is the difference between a fix and a guard, which is the lesson this PR has been recording for eight rounds.
| // environment that will never occur" shape this suite keeps finding. | ||
| /* Real HMTLTypes.cpp's pixel setup path calls init() on a default-constructed | ||
| * instance; mirror the allocating constructor. */ | ||
| void init(uint16_t n, uint8_t /*data*/, uint8_t /*clock*/, uint8_t /*order*/ = 0) { |
There was a problem hiding this comment.
Suggested test: nothing in the suite executes this function. Verified by mutation on a scratch copy of 9b0dcd8, not inferred: replacing _num = (PIXEL_ADDR_TYPE)n with _num = 0 here leaves 70/70 green under -e native and 70/70 under -e native_bigpixels.
init() exists because HMTLTypes.cpp:238 calls it on the hmtl_configure_output pixel path, but no test drives that path — every test constructs its strip directly — so the inconsistency this commit fixes can return unnoticed, which is exactly what happened to the constructor two commits ago.
Cheapest closure is the delegation in the comment above, which makes the existing constructor tests cover init(). Failing that, a direct case in test_pixelutil: default-construct, init(300, 0, 0, 0), then assert numPixels() is 300 under -DBIG_PIXELS and 44 without — the same numPixels() tripwire shape 07717b8 added, applied to the one entry point that has none. Worth a second case for re-init() too: the real PixelUtil::init refuses a second call (DEBUG_ERR_REINIT) where this stub silently reallocates, which is another "behaviour the firmware cannot have" available to a test.
Re-review finding on my own previous commit, and it is the defect this PR exists to remove — reintroduced by the fix for it. `9b0dcd8` made `init()` narrow, allocate and complain exactly as the constructor does. What it did not do is give `init()` a single test that executes it: every test builds its strip through the constructor, so `init()` had no caller in the suite at all. Mutating `_num = 0` inside it left **70/70 green in both envs** — a guard that cannot fail, sitting in a commit whose message argues against guards that cannot fail. The structural fix is the one the real library already uses: the constructor delegates to `init()` (ArduinoLibs `PixelUtil.cpp:27-32` is `initialized = false; init(...)`). Now every strip any test builds goes through `init()`, and the duplicated body is gone rather than left to drift — an over-sized strip would otherwise have printed the complaint twice. Verified by mutation rather than by argument: the same `_num = 0` edit now reddens **23 tests in both `native` and `native_bigpixels`**, up from 0. 70/70 green at both pixel widths with the mutation reverted. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
…hey got here Per review: comments were too wordy and carried change history. Trimmed across the PR to what someone reading the code needs — the invariant, the constraint, and why the code cannot be simplified away — dropping "used to be", "the lesson that put it here", and the round-by-round narrative. Comments only; no code changed. 70 native tests x both pixel widths, 16 protocol tests, and the layout sweep all still pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01F4oTr1YW3z7ozksMUT1z5j
|
This is approved, but I'm not sure you ever responded to my "Comments in this PR are way to wordy. Please make these more concise and only what someone reading the code should know, but then you can merge" comment |
aphelps
left a comment
There was a problem hiding this comment.
Comments are better, just merge this
…width * origin/main: HMTL_Module: opt out of WiFiBase's config-endpoint auth, drop the copy-assign
* origin/main: Pin the COLOR wire range to a fixed width, so no wire layout follows a -D (#9)
* bump HMTL for the COLOR wire-range widening aphelps/HMTL#9 gives hmtl_program_color_t a fixed-width range so its wire layout no longer follows -DBIG_PIXELS. Nothing on the WLED build path changes: rs485_bridge_protocol.h imports only HMTLprotocol/HMTLWireFormat.h, and the bridge reads PROGRAM_COLOR's payload as d.programVals[0..2] — the RGB triple at offset 0, which no range width can move. Carrying the pointer here is what puts the new asserts in super-repo CI: `make test STRICT=1` runs HMTL's four-ABI x two-flag layout sweep and its negative control, neither of which the WLED firmware build would reach. Verified on this combination: make test STRICT=1 — 484/484 perturbations broke the build as required, sweep covered host/host-avr-proxy/avr/xtensa, esp-now-router relay+election+attach all passed pio run -e ampworks — SUCCESS after rm -rf .pio/libdeps/ampworks Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ * run HMTL's native suite from test-hmtl, not just the layout sweep Both reviews on this PR made the same point: aphelps/HMTL#9 adds behavioural tests for program_color() — the narrowing, the zero-length rule, the stale-invocation rejection — and NOTHING invoked them. HMTL has no .github/workflows, and test-hmtl here reached only HMTL/tests/layout/. So CI got the new static_asserts and none of the code that reads those structs. The sweep covers compile-time LAYOUT. That is a different question from whether the reader is correct, and this repo is the only place both get asked. Both pixel-width envs, because an `#ifdef BIG_PIXELS` branch in a test body is dead source unless something compiles the flag — which is exactly how HMTL#9's first draft shipped a test whose wide-width half had never been built. Delegated to HMTL's own `make test-native` so the env list stays in the repo that owns it. PIO defaults to the venv setup.sh builds and falls back to PATH; if neither resolves, this is a skipped suite like any other. Verified both ways rather than assumed: lenient exits 0 with a "-- skipped: --" note, STRICT=1 exits non-zero with the ERROR line. HMTL's `test-python` is deliberately NOT wired in. It needs pytest, which is not in WLED/requirements.txt, so it would fail on a fresh CI venv — a local venv that happens to have pytest would have hidden that. Adding pytest to the pinned toolchain is a separate decision about this repo's dependency set; filed rather than smuggled in here. Pointer moves to dbd6673, which also carries HMTL#9's review fixes. Verified on this combination: make test STRICT=1 — sweep on host/host-avr-proxy/avr/xtensa x both flags, 484/484 perturbations red as required, 61 native tests per pixel-width env, router relay+election+attach pio run -e ampworks — SUCCESS after rm -rf .pio/libdeps/ampworks Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ * bump HMTL for the encoder-side validity rule, and stop over-claiming coverage Pointer moves to 3e23ada, which teaches python/'s ProgramColor and HMTLClient the zero-length rule the C reader learned last round — the two implementations had disagreed about message VALIDITY for one commit, which is the drift this whole PR exists to prevent. Also from the re-review, on this side: the "== HMTL native behaviour tests (both pixel widths) ==" banner was asserted HERE while the env list lives in HMTL's own Makefile, so an older HMTL pin would run a single env under a banner claiming two. Dropped the claim; HMTL's test-native prints what it actually ran. Verified: make test STRICT=1 green (61 native tests per pixel-width env, 484/484 perturbations red as required, router suites passing). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ * bump HMTL for the round-3 encoder fixes, and stop promising an env list we do not own Pointer moves to d8769c3: ProgramColor now range-checks every field (struct.error is not a ValueError, so an out-of-range field was escaping HMTLClient's except clause as a raw traceback), parsing and validation are separated so a typo does not report as a module rejection, and the docstring no longer claims the CLI catches mistakes that depend on the target strip. On this side, the leftover from last round: the comment block still promised "Both pixel-width envs" five lines above the paragraph explaining that the env list lives in HMTL's Makefile, not here. Same defect as the banner, one comment over — a claim made by the repo that cannot keep it. It now says why it declines to name the envs at all. Verified: make test STRICT=1 green (61 native tests per pixel-width env at this pin, 484/484 perturbations red as required, router suites passing). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ * bump HMTL: the CLI tests no longer talk to localhost:6000 aphelps/HMTL#9's new CLI tests aimed at HMTLClient's default command server. Only the accept-path test reached it, and it passed only because nothing was listening; against a socket that accepts and holds, `make test` hangs forever. They now target a deliberately dead port with a subprocess timeout. That matters here specifically: this repo's test-hmtl runs HMTL's suite in CI, so a test that hangs on a live listener would hang the workflow rather than fail it. Verified: make test STRICT=1 green at this pin. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ * bump HMTL: correct a guard that could not fire, and the stub that hid it aphelps/HMTL#9's representability check (`start > addr_max`) cannot fire against the shipped ArduinoLibs — PixelUtil holds num_pixels as PIXEL_ADDR_TYPE and init() refuses more than 255 pixels by default, so `start >= num` subsumes it. The test that appeared to prove otherwise built a 400-pixel default-flag strip, possible only because the HMTL_Test stub declared _num as an unconditional uint16_t while claiming to mirror the real header. Found by reviewing that PR as a whole rather than as a delta, which is the one thing five rounds of incremental review could not do. Verified: make test STRICT=1 green at this pin (63 native tests per pixel-width env, 484/484 perturbations red as required). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ * bump HMTL: pin the test strip sizes the stub fix had shrunk aphelps/HMTL#9's stub narrowing silently truncated another test's 3000-pixel strip to 184 under the default width, leaving its comment false and three of its assertions unable to fail. Strip sizes are now per-flag and asserted via numPixels(), so a stub change cannot rewrite a test's premise unnoticed. Verified: make test STRICT=1 green at this pin. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ * bump HMTL: the -P color gate test now tests the half it names Final commit on aphelps/HMTL#9. `-C 1,2,3` was kept silent by the len()==5 half of the warning gate alone, so test_other_generic_programs_are_never_warned_about could not fail for the reason its name gives. Five values now, mutation-checked both ways. Verified: make test STRICT=1 green at this pin. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ * bump HMTL: docstring names the receiver that ignores the range Last inline comment on aphelps/HMTL#9. ProgramColor's docstring detailed what receivers do with the range while omitting the one in-tree receiver that never reads it — this repo's own RS485 bridge, which takes programVals[0..2] and nothing else. Docstring only; no behaviour change, so the C and layout suites are unaffected. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ * Re-point HMTL at the merged COLOR wire-range commit HMTL#9 landed as a squash (ab149d6), which makes the previously pinned d7d7e8b unreachable once the topic branch goes. The pin also predated the last three commits on that PR, including the init() narrowing fix — building against d7d7e8b would have shipped the truncating stub this PR exists to depend on. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01F4oTr1YW3z7ozksMUT1z5j --------- Co-authored-by: aphelps-claude-bot <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
What
hmtl_program_color_tembeddedpixel_range_t, whose fields arePIXEL_ADDR_TYPE—uint8_tby default,uint16_tunder-DBIG_PIXELS. So this one wire struct had a layout that followed a build flag: 5 bytes withrangeat 3 in one half of the fleet, 7 in the other. Shipped envs really do differ —lightbringer_*,rfm_328_10_2andesp32_routedset the flag;nano,unoandesp32_breadboarddo not — so two ATMega328 modules already disagreed about it, with no ESP32 involved.#7 packed the struct, fixing AVR-vs-ESP32 within each flag setting, and deliberately left flag-vs-flag alone as a fleet-compatibility decision. This closes it. The range is now a named
wire_pixel_range_tof twouint16_t: 7 bytes withrangeat 3 on every ABI under both flag settings.Why
uint16_tand notuint8_tuint8_tis what the only in-tree producer naturally emits, so it would have been the cheaper migration. But the builds that set-DBIG_PIXELSare exactly the ones whose strips exceed 255 pixels, and narrowing would have capped range addressing there forever. Decided 2026-08-05.The cost is real and is handled rather than noted:
HMTLClient -P color -C r,g,b,start,lengthwent throughProgramGeneric's 32 raw bytes and therefore emitted the 5-byte form without ever naming a layout. Hence the newProgramColorclass, the--coloroption, and a warning printed by-P coloritself — a PR body is not visible to whoever runs the shell alias.The conversion is where the new hazard lives
setRangeRGBstill takespixel_range_t, soprogram_color()narrows into it. That asks two questions, not one:start = 300would otherwise become 44 and paint a range nobody asked for.Start is checked before length so an over-long range can never degrade into a whole-strip fill:
length == 0keeps its documented "whole strip" meaning, and becauseavail >= 1the clamp cannot manufacture a zero. A start past the end is rejected with aDEBUG1line rather than clamped — a stale 5-byte invocation lands as a huge start, and that line is what turns "the strip did nothing" into a diagnosis.The assert gets stronger, and why the old one was weak
HMTL_LAYOUT_SIZE(hmtl_program_color_t, 3 + 2 * sizeof(PIXEL_ADDR_TYPE))becomes a literal7. The expression form is worth remembering rather than silently deleting: an assert written in terms of a configurable agrees with whatever that configurable happens to be, so it held happily on both sides of the disagreement it was meant to catch.Verification, including the part that nearly went wrong
make test-layoutpasses on host, host-fpack-struct=1,avr-g++andxtensa-esp32-elf-g++, each under both flag settings. That the same7holds everywhere is the change.pixel_range_tin a scratch copy goes red on all three real ABIs under default flags, and stays green under-DBIG_PIXELS, where the old layout coincided with the new one. That is the exact inverse of the previous situation, where only-DBIG_PIXELScould catch the struct being unpacked.-DBIG_PIXELSaxis its justification. That axis existed because this struct was flag-sensitive; with it pinned, both halves would compile identical layouts and the second axis could no longer fail differently from the first — the dead-guard shape this subsystem keeps producing. Rather than keep it on a stale rationale, this addspixel_range_twidth asserts (2 B default, 4 B under the flag), each visible to only one half. That type is off the wire now but is still whatprogram_color()narrows into, so its width is load-bearing.start = 300; lettinglength == 0skip the start check floods the strip on a stale invocation.test_protocol.pyis the first test inpython/that packs a program message.ProgramFade/Sparkle/Circularnever had one, which is much of why this struct drifted. Its expectations are literal byte strings transcribed from the C struct, not derived fromFORMAT— deriving them would only proveFORMATagrees with itself.make test-pythonnames the file explicitly, because a guard no target invokes is the same defect as an assert no toolchain compiles.HMTL_Test'sPixelUtilstub diverged from the realsetRangeRGBin exactly the two cases a range test exercises:length == 0filledstart.._numinstead of the whole strip, and a start past the end clamped into a full-strip fill. Aligned first, so the tests do not encode the stub's behaviour as the expectation.make testpasses end to end: 19 python, 60 native, the AVR firmware build, the four-ABI × two-flag sweep, and 484/484 perturbations breaking the build as required.Deliberately not done
hmtl_program_color_fmt(). Every other program has one; COLOR has none, and that is arguably why it drifted. But nothing in C originates a COLOR message (HMTL_Command_CLIhas no program command at all), so a formatter would be an encoder with no caller and no test — free to drift exactly as the layout did. The two independent statements of this layout areProgramColorand the hand-transcribed bytes in the native suite. Recorded in the header.## Testing Required. These are compile-time layout properties plus host-testable conversion logic; a bench observation would be strictly weaker. Nothing in the v1 bridge command set decodes this payload, so there is no runtime behaviour on hardware to observe either.Note for the fleet
This is a genuine wire change for
-P colorsenders. Default-flag modules and-DBIG_PIXELSmodules now agree, which they did not before, but any hand-assembled 5-byte invocation must move to--color. Per the plan discussion there are no out-of-tree senders (decided 2026-08-05), so this is a small in-tree migration rather than a fleet migration.🤖 Generated with Claude Code
https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ