Repository navigation
CI: cancel stale runs, -Werror on app code, size budget, UBSan - #184
Conversation
- A new push to a PR cancels that PR's older run of each workflow. Runs
on main still finish.
- Board app libraries compile with -Wall -Wextra -Werror. Board/ shares a
binary with CubeMX and ST HAL code, so it is not covered.
- Each firmware image gets an {image}_size_test that fails above 85% of
flash or RAM, read from the ELF and the linker script's MEMORY block. The
VCU is at 26.6% flash and 41.1% RAM.
- --config=ubsan reruns the host tests with undefined behavior trapping.
The hermetic LLVM ships no ASan runtime, so trap-mode UBSan is the
sanitizer that works without one. Presubmit runs it on //boards and
//drivers.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Configure workflow run concurrency .github/workflows/{autonomy,bevo,docs,lint-format,presubmit,simulation,telemetry}.yml |
Each workflow groups runs by workflow and pull-request number, or by run ID when no pull-request number is available. In-progress runs are canceled only for pull-request events. |
Firmware checks
| Layer / File(s) | Summary |
|---|---|
Parse firmware memory usage tools/firmware/size_check.py, tools/firmware/size_check_test.py, tools/firmware/BUILD.bazel |
The checker parses linker memory regions and allocated sections from a 32-bit little-endian ELF. It accounts for run and load addresses, reports per-region usage, and returns failure when a region exceeds its budget. Tests cover parsing, accounting, and budget outcomes. |
Create a size test for each firmware image tools/firmware/firmware_project.bzl, tools/firmware/README.md |
The firmware macro creates a size test for each image, passing its ELF, linker script, and budget to the checker. It supports a default budget and per-region overrides. The app library enables -Wall, -Wextra, and -Werror. |
Run host tests with UBSan .bazelrc, .github/workflows/presubmit.yml, tools/ubsan/*, README.md, mkdocs.yml, tools/README.md, tools/firmware/README.md |
The UBSan configuration enables undefined-behavior checks in trap mode and excludes tests tagged firmware_size. Presubmit runs selected host tests and a trap canary, and adds firmware size-test output to the step summary. Documentation describes the configuration, canary, and size-test exclusion. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Other
Merge Risk: 
Minimal · up to 6cd2b
-
The firmware size checks and CI summary have no identified issue that needs fixing before merge.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 14.71% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 6 files. (2 skipped: 2 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
|
Safe to merge. I found no new problems, and all four of my earlier findings are fixed.
What I checkedChecked: I read the whole diff. I ran Didn't check: I did not run Bazel, so the Assumed: Ultron reviewed 6cd2b0e · it re-reviews on new pushes |
Strip comments before finding the MEMORY block, so a brace in a comment cannot end it. Accept hex LENGTH values. Fail clearly on a zero-length region instead of dividing by zero. Adds a parser test.
Keying by ref let a newer push or schedule drop a pending run on main. Keying by run_id keeps every non-PR run. PR runs still cancel the older run.
A linker script with other region names now fails with a message that lists the regions found, not a bare KeyError.
A LENGTH like "512K - 16K" used to parse as 512K, overstating the region and under-reporting usage. It's now an error naming the region. Region attributes are optional, as GNU ld allows. The tests now build a small ELF and check the budget math end to end, including .data counting against both flash and RAM. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The generated CAN pack/unpack code does the shifts and sign extension UBSan exists for, so //lib/codegen/cpp/... joins the UBSan step. //tools/ubsan:trap_test overflows on purpose and passes only if that traps, so the step can't go green just because the flags stopped reaching the compiler. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
| elif flash_origin <= addr < flash_origin + flash_len: | ||
| flash += size |
There was a problem hiding this comment.
🟡 Minor | Correctness
Fail on allocated sections that fall outside both FLASH and RAM instead of skipping them
The loop only counts a section if its address lies in the RAM or FLASH window and drops every other allocated section without a message. Sections in other regions (CCM SRAM, backup SRAM, a second RAM bank) are therefore left out of the budget. Their flash-resident initial values are left out too. An image can pass {image}_size_test while really being over budget. The VCU linker script has only RAM and FLASH, so this doesn't bite today. It will when a board adds a region.
| elif flash_origin <= addr < flash_origin + flash_len: | |
| flash += size | |
| elif flash_origin <= addr < flash_origin + flash_len: | |
| flash += size | |
| else: | |
| raise ValueError( | |
| f"allocated section at 0x{addr:x} ({size} bytes) is outside FLASH and RAM; " | |
| f"extend size_check.py to account for it") |
🤖 Prompt for AI agents
In tools/firmware/size_check.py around lines 71-72:
The loop over alloc_sections ignores sections whose address is in neither the FLASH nor the RAM window, so they escape the budget. Add an else branch that raises ValueError naming the address and size, so the test fails loudly until the region is handled. Add a case to size_check_test.py with a section at 0x10000000.
A section in another region (CCM SRAM, a second RAM bank) was skipped, so the budget could pass on an undercount. It's now an error naming the section and its address. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🔇 Additional comments: 15
.github/workflows/autonomy.yml: 1
25-28: LGTM!.github/workflows/bevo.yml: 1
16-19: LGTM!.github/workflows/docs.yml: 1
20-23: LGTM!.github/workflows/lint-format.yml: 1
6-9: LGTM!.github/workflows/simulation.yml: 1
26-29: LGTM!.github/workflows/telemetry.yml: 1
26-29: LGTM!tools/firmware/README.md: 1
26-26: LGTM!Also applies to: 79-84, 166-166, 171-190
.github/workflows/presubmit.yml: 1
6-7: LGTM!Also applies to: 9-9, 66-71
tools/ubsan/BUILD.bazel: 1
1-13: LGTM!tools/ubsan/trap_test.cpp: 1
1-21: LGTM!README.md: 1
99-99: LGTM!mkdocs.yml: 1
52-52: LGTM!tools/README.md: 1
13-13: LGTM!tools/ubsan/README.md: 1
1-32: LGTM!tools/firmware/size_check.py-74-74: 1
74-74:Major · Functional Correctness · Heavy lift
⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.Account for section placement in the size budget.
If two FLASH sections occupy offsets 0–999 and 1900–1999 in a 2048-byte region, the checker reports 53.7% and passes an 85% budget. The image extends through 97.7% of the region. GNU ld can introduce gaps when it aligns output sections. Calculate the occupied extent from section addresses; use load addresses for initialized RAM data stored in FLASH. (sourceware.org)

Review info
-
Run configuration-
- Source mode: Auto
- Repository: LonghornRacingElectric/lhre
- Branch: arjun/ci-hardening-main
- File: .coderabbit.yaml
- Commit: 78f7ac1
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Advanced
- Run ID:
c5056222-ae35-4bf9-975d-04b44a766595
Files selected for processing: 18-
.bazelrc.github/workflows/autonomy.yml.github/workflows/bevo.yml.github/workflows/docs.yml.github/workflows/lint-format.yml.github/workflows/presubmit.yml.github/workflows/simulation.yml.github/workflows/telemetry.ymlREADME.mdmkdocs.ymltools/README.mdtools/firmware/BUILD.bazeltools/firmware/README.mdtools/firmware/size_check.pytools/firmware/size_check_test.pytools/ubsan/BUILD.bazeltools/ubsan/README.mdtools/ubsan/trap_test.cpp
Files skipped from review as they are similar to previous changes: 1-
- .bazelrc
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
-
The check hardcoded FLASH and RAM, so an F4 using CCMRAM or an H7 with DTCMRAM and RAM_D1..D3 either failed outright or went uncounted. Now it budgets whatever regions the linker script declares and prints a usage line per region. Each section counts against the region it runs from and, read from the ELF's program headers, the region it's loaded from when that differs. That covers .data and code copied to CCM or ITCM without naming them. ORIGIN expressions are now refused like LENGTH ones, and size_budget_overrides gives a region meant to be full its own budget. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
size_check now prints its per-region usage as a markdown table, and presubmit copies each image's table from its size test log onto the run's summary page, even when the test fails. Memory use is visible on every PR without opening the test log. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Resolves the one conflict, in tools/firmware/README.md: keep main's -Werror note for the app library (#184) and this branch's recursive App/**/ globs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Targets
maindirectly and does not depend on #182. Replaces #183, whichwas stacked on #182.
Runs on
mainstill finish.-Wall -Wextra -Werroron each board's app library.Board/isexcluded, because it links with CubeMX and ST HAL sources that are not
warning-clean.
{image}_size_test: fails above 85% of flash or RAM(
size_budget_percentonfirmware_project). VCU onmain: 10.3% flash,12.9% RAM. With VCU: firmware reorg, control fixes, and feedforward power limit #182: 26.6% flash, 41.1% RAM.
--config=ubsan: host tests with undefined behavior trapping.Presubmit runs it on
//boardsand//drivers. ASan is not possiblebecause the hermetic LLVM ships no sanitizer runtime.
Checked in WSL with
--config=local, onmainalone: 17/17 tests pass,8/8 under UBSan, and the format check passes. On top of #182: 37/37, and
28/28 under UBSan.
Not included: the log-replay test. It needs trimmed CSV fixtures and a
plant model, so it gets its own PR.
Summary by CodeRabbit