Cut the frame bench and vectors guard comments to their reason #72

Merged
Claude merged 5 commits from docs/frame-bench-comments into feat/firmware-updates 2026-09-20 06:24:09 +00:00
Collaborator

A comment pass over what this branch added to frame_bench, the vectors
refresh script and their tests. Narration and restatement are gone; what is
left is rationale, traps and spec citations, each cut to a line where it fits.

The one behaviour-adjacent change is in codec.py: _shortest_length had a
five-line docstring explaining a dense loop, so the loop now says it. The two
cases that end a frame early moved into _ends_the_frame_at, and the docstring
is one line. Same lengths out, covered by the existing bench tests.

tools/refresh-vectors keeps its guard and its reason — a merged firmware
branch is kept, so its vectors freeze the day it lands — just in three lines
rather than five. No change to what the guard does.

Test docstrings that only restate the test name could not simply be deleted:
ruff has D selected with no per-file ignores, so D103 requires one on every
public test function. Those were rewritten to carry a reason instead.

Comment and docstring lines across the ten files in scope: 348 before, 314
after. Of those, the lines this branch introduced went from 92 to 58.

Lint, format, mypy and the full suite are green.

A comment pass over what this branch added to `frame_bench`, the vectors refresh script and their tests. Narration and restatement are gone; what is left is rationale, traps and spec citations, each cut to a line where it fits. The one behaviour-adjacent change is in `codec.py`: `_shortest_length` had a five-line docstring explaining a dense loop, so the loop now says it. The two cases that end a frame early moved into `_ends_the_frame_at`, and the docstring is one line. Same lengths out, covered by the existing bench tests. `tools/refresh-vectors` keeps its guard and its reason — a merged firmware branch is kept, so its vectors freeze the day it lands — just in three lines rather than five. No change to what the guard does. Test docstrings that only restate the test name could not simply be deleted: `ruff` has `D` selected with no per-file ignores, so D103 requires one on every public test function. Those were rewritten to carry a reason instead. Comment and docstring lines across the ten files in scope: 348 before, 314 after. Of those, the lines this branch introduced went from 92 to 58. Lint, format, mypy and the full suite are green.
Cut the bench test comments to their reason
Some checks failed
Lint, type check and test / hassfest (pull_request) Successful in 9s
Lint, type check and test / release (pull_request) Has been cancelled
Lint, type check and test / quality (pull_request) Has been cancelled
97b00fdd56
Claude left a comment

Five wording points, inline. Nothing behavioural.

Five wording points, inline. Nothing behavioural.
@ -49,3 +48,2 @@
run: |
# Logged because the guard below turns on it, and a runner that
# leaves base_ref empty would skip it with nothing to show for it.
# A runner that leaves base_ref empty skips the guard silently.
Author
Collaborator

The comment no longer says why the echo below it exists, so it reads as a stray fact above a line someone could take for noise and delete. Suggest: # Logged because the guard turns on it: a runner leaving base_ref empty skips it silently.

The comment no longer says why the `echo` below it exists, so it reads as a stray fact above a line someone could take for noise and delete. Suggest: `# Logged because the guard turns on it: a runner leaving base_ref empty skips it silently.`
@ -107,3 +104,1 @@
One side sending eight bytes where the other expects two is the drift this
whole file exists to catch, and no byte of the payload gives it away.
"""
"""One side sending eight bytes where the other expects two, no byte wrong."""
Author
Collaborator

"no byte wrong" is cryptic — the point was that no byte of the payload gives the drift away, which is why comparing frames would not catch it. Suggest: Both sides must agree: eight bytes where the other expects two, with no byte of the payload wrong.

"no byte wrong" is cryptic — the point was that no byte of the *payload* gives the drift away, which is why comparing frames would not catch it. Suggest: `Both sides must agree: eight bytes where the other expects two, with no byte of the payload wrong.`
@ -135,3 +135,3 @@
def _hex_bytes(raw: object, width: int, trailing: bool = False) -> bytes:
"""Read a run of bytes typed as hex, padded out where it may end the frame."""
"""Read a run of bytes typed as hex, short only where it may end the frame."""
Author
Collaborator

_hex_bytes always returns exactly width bytes (value.ljust(width, b"\0")), so "short only where it may end the frame" reads as a short return that never happens. It is the accepted input that may be short. The old wording at least named the padding.

`_hex_bytes` always returns exactly `width` bytes (`value.ljust(width, b"\0")`), so "short only where it may end the frame" reads as a short return that never happens. It is the accepted *input* that may be short. The old wording at least named the padding.
@ -435,2 +435,4 @@
def _ends_the_frame_at(spec: FrameField, typed: object) -> int | None:
"""Give where a field's own size ends the frame: text, and a last `BULK_DATA`."""
Author
Collaborator

Private, so D103 does not force a docstring, and this one restates the two isinstance branches beneath it. The only thing it adds — that trailing means a last BULK_DATA — is already on RawField.trailing. Delete it.

Private, so D103 does not force a docstring, and this one restates the two `isinstance` branches beneath it. The only thing it adds — that trailing means a last `BULK_DATA` — is already on `RawField.trailing`. Delete it.
@ -73,3 +71,1 @@
The frame then stops before it, because section 8 has a sender use the
shortest length that carries what it means.
"""
"""Only these values of field `when` carry it; the frame stops there. Section 8."""
Author
Collaborator

The meaning flipped. "the frame stops there" attaches to the case where the field is carried; the original said the frame stops before it when it is not. Suggest: Only these values of field when put it on the wire; otherwise the frame stops before it. Section 8.

The meaning flipped. "the frame stops there" attaches to the case where the field *is* carried; the original said the frame stops before it when it is *not*. Suggest: `Only these values of field `when` put it on the wire; otherwise the frame stops before it. Section 8.`
Take the review: a cut that loses the reason is a cut too far
All checks were successful
Lint, type check and test / hassfest (pull_request) Successful in 28s
Lint, type check and test / quality (pull_request) Successful in 1m54s
Lint, type check and test / release (pull_request) Has been skipped
87dd2cceb7
Claude left a comment

All five taken. Nothing further.

All five taken. Nothing further.
Claude merged commit 0212445b71 into feat/firmware-updates 2026-09-20 06:24:09 +00:00
Claude deleted branch docs/frame-bench-comments 2026-09-20 06:24:09 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rob/CampervanHomeAssistant!72
No description provided.