Skip to content

refactor(config): PSRAM-axis Kconfig derives, snap static_asserts, heap-classifier coverage (B1-434, B1-435, B1-439)#616

Merged
jgangemi merged 1 commit into
mainfrom
jae/bb-config-coupling-coverage
Jun 30, 2026
Merged

refactor(config): PSRAM-axis Kconfig derives, snap static_asserts, heap-classifier coverage (B1-434, B1-435, B1-439)#616
jgangemi merged 1 commit into
mainfrom
jae/bb-config-coupling-coverage

Conversation

@jgangemi

Copy link
Copy Markdown
Member

PART 1 — DERIVE (B1-435)

bb_pub/Kconfig: BB_PUB_TELEM_SNAP_MAX and BB_PUB_TELEM_SERIALIZE_MAX now
derive from SPIRAM: default 1024 when CONFIG_SPIRAM=y (bitaxe), default 512
otherwise (wroom32, tdongle-s3, c3-supermini, s2-mini). Kconfig defaults are
lowest precedence, so TaipanMiner's explicit sdkconfig fragment values still
win — no behavior change on any currently-shipped board. The derive closes
the silent-misconfiguration window for boards that don't carry an explicit
fragment entry (the TA-505 S2 root cause: sdkconfig.defaults=1024 was
inherited because the S2-mini fragment lacked the override; TM #607 fixed it
with an explicit override, this derive prevents the class from recurring).

bb_mdns/Kconfig: BB_MDNS_BATCH_RING_DEPTH derives SPIRAM-axis: default 4
with SPIRAM (ring lives in SPIRAM, large batches affordable), default 3
without (internal heap bottleneck; aligns with TaipanMiner sdkconfig/no-psram
which sets 3 explicitly). BB_MDNS_BATCH_MAX is intentionally NOT derived here
— it is set for DIFFERENT reasons by both single-core and no-PSRAM TM
fragments (the single-core axis is orthogonal to the PSRAM axis). RING_DEPTH
is the cleanly PSRAM-axis knob.

TaipanMiner cross-repo note (do NOT change TM in this PR): after this lands,
the following TM fragment lines become REDUNDANT and can be dropped in a
re-pin:
sdkconfig/no-psram: BB_PUB_TELEM_SERIALIZE_MAX=512, BB_PUB_TELEM_SNAP_MAX=512,
BB_MDNS_BATCH_RING_DEPTH=3
sdkconfig/esp32-s2-mini: any duplicated 512 caps that chain from no-psram

PART 2 — ENFORCE (B1-434)

Add compile-time static_assert (negative-array-size idiom) for every telem
snap_t struct that was missing one:

  • bb_pub_power.c → _power_snap_size_check
  • bb_pub_fan.c → _fan_snap_size_check
  • bb_pub_wifi.c → _wifi_snap_size_check
  • bb_pub_thermal.c → _thermal_snap_size_check
  • bb_net_health_espidf.c → _net_health_snap_size_check (ESP-IDF only)

bb_pub_telemetry_host.c (_meta_snap_size_check) and bb_pub_info.c
(_info_snap_size_check) already had their guards from PR #615 — not touched.
Each host+ESP file also adds the CONFIG_BB_PUB_TELEM_SNAP_MAX host fallback
(512, matching the no-PSRAM default) so the assert compiles on host where
sdkconfig.h is absent. The host assert conservatively checks the no-PSRAM
floor, catching snap growth before it reaches constrained hardware.

B1-374 (Kconfig bridge macro): the existing bridge instances in the files
touched here use the correct CONFIG_-prefixed pattern (not the broken bare
BB_-prefix form). No mis-bridged symbols found in this scope. The macro
itself (BB_KCONFIG_INT/BB_KCONFIG_BOOL) is deferred — add it when more
instances are found across the codebase (the DERIVE changes in Part 1 reduce
the surface area of the problem).

PART 3 — COVERAGE (B1-439)

bb_net_health.c had 86% branch coverage (lines 17, 20, 40 uncovered):

  • bb_net_health_classify_heap: CRITICAL and LOW branches never exercised
  • bb_heap_state_str: default (unknown enum) branch never exercised

Eight new tests in test_bb_net_health.c:
test_bb_net_health_classify_heap_{ok,low,critical,zero}
test_bb_heap_state_str_{ok,low,critical,unknown_returns_ok}

Branch coverage: 99.6% → 100.0% (1813/1820 → 1820/1820)
Test count: 2918 → 2925 (+7)

DEFERRED COUPLINGS (B1-434 full audit not yet complete):

  • OTA heap/chunk bounds (BB_OTA_PULL_HTTP_CHUNK_SIZE vs OTA_PULL buffer)
  • net-health threshold crossing (HEAP_LOW > HEAP_CRITICAL enforce)
  • WDT reboot race (B1-353 safeguard window vs AP recovery window)
  • HTTP header buffer overflow (BB_SINK_HTTP_HEADERS_MAX vs buf allocation)
  • MQTT/HTTP TLS stack depth (BB_PUB_WORKER_STACK vs TLS chain budget)
  • Single-core panic on pinned worker core (BB_PUB_WORKER_CORE=0 on S2)
  • Auto-register conflict (BB_OTA_PULL vs BB_OTA_BOOT double-owner)
    These will be addressed in subsequent PRs.

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

@coveralls

coveralls commented Jun 30, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 28481948377

Coverage increased (+0.4%) to 100.0%

Details

  • Coverage increased (+0.4%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 3190
Covered Lines: 3190
Line Coverage: 100.0%
Relevant Branches: 1850
Covered Branches: 1850
Branch Coverage: 100.0%
Branches in Coverage %: Yes
Coverage Strength: 1225.03 hits per line

💛 - Coveralls

…ap-classifier coverage (B1-434, B1-435, B1-439)

PART 1 — DERIVE (B1-435)

bb_pub/Kconfig: BB_PUB_TELEM_SNAP_MAX and BB_PUB_TELEM_SERIALIZE_MAX now
derive from SPIRAM: default 1024 when CONFIG_SPIRAM=y (bitaxe), default 512
otherwise (wroom32, tdongle-s3, c3-supermini, s2-mini).  Kconfig defaults are
lowest precedence, so TaipanMiner's explicit sdkconfig fragment values still
win — no behavior change on any currently-shipped board.  The derive closes
the silent-misconfiguration window for boards that don't carry an explicit
fragment entry (the TA-505 S2 root cause: sdkconfig.defaults=1024 was
inherited because the S2-mini fragment lacked the override; TM #607 fixed it
with an explicit override, this derive prevents the class from recurring).

bb_mdns/Kconfig: BB_MDNS_BATCH_RING_DEPTH derives SPIRAM-axis: default 4
with SPIRAM (ring lives in SPIRAM, large batches affordable), default 3
without (internal heap bottleneck; aligns with TaipanMiner sdkconfig/no-psram
which sets 3 explicitly).  BB_MDNS_BATCH_MAX is intentionally NOT derived here
— it is set for DIFFERENT reasons by both single-core and no-PSRAM TM
fragments (the single-core axis is orthogonal to the PSRAM axis).  RING_DEPTH
is the cleanly PSRAM-axis knob.

TaipanMiner cross-repo note (do NOT change TM in this PR): after this lands,
the following TM fragment lines become REDUNDANT and can be dropped in a
re-pin:
  sdkconfig/no-psram: BB_PUB_TELEM_SERIALIZE_MAX=512, BB_PUB_TELEM_SNAP_MAX=512,
                      BB_MDNS_BATCH_RING_DEPTH=3
  sdkconfig/esp32-s2-mini: any duplicated 512 caps that chain from no-psram

PART 2 — ENFORCE (B1-434)

Add compile-time static_assert (negative-array-size idiom) for every telem
snap_t struct that was missing one:
  - bb_pub_power.c  → _power_snap_size_check
  - bb_pub_fan.c    → _fan_snap_size_check
  - bb_pub_wifi.c   → _wifi_snap_size_check
  - bb_pub_thermal.c → _thermal_snap_size_check
  - bb_net_health_espidf.c → _net_health_snap_size_check (ESP-IDF only)

bb_pub_telemetry_host.c (_meta_snap_size_check) and bb_pub_info.c
(_info_snap_size_check) already had their guards from PR #615 — not touched.
Each host+ESP file also adds the CONFIG_BB_PUB_TELEM_SNAP_MAX host fallback
(512, matching the no-PSRAM default) so the assert compiles on host where
sdkconfig.h is absent.  The host assert conservatively checks the no-PSRAM
floor, catching snap growth before it reaches constrained hardware.

B1-374 (Kconfig bridge macro): the existing bridge instances in the files
touched here use the correct CONFIG_-prefixed pattern (not the broken bare
BB_-prefix form).  No mis-bridged symbols found in this scope.  The macro
itself (BB_KCONFIG_INT/BB_KCONFIG_BOOL) is deferred — add it when more
instances are found across the codebase (the DERIVE changes in Part 1 reduce
the surface area of the problem).

PART 3 — COVERAGE (B1-439)

bb_net_health.c had 86% branch coverage (lines 17, 20, 40 uncovered):
  - bb_net_health_classify_heap: CRITICAL and LOW branches never exercised
  - bb_heap_state_str: default (unknown enum) branch never exercised

Eight new tests in test_bb_net_health.c:
  test_bb_net_health_classify_heap_{ok,low,critical,zero}
  test_bb_heap_state_str_{ok,low,critical,unknown_returns_ok}

Branch coverage: 99.6% → 100.0% (1813/1820 → 1820/1820)
Test count: 2918 → 2925 (+7)

DEFERRED COUPLINGS (B1-434 full audit not yet complete):
  - OTA heap/chunk bounds (BB_OTA_PULL_HTTP_CHUNK_SIZE vs OTA_PULL buffer)
  - net-health threshold crossing (HEAP_LOW > HEAP_CRITICAL enforce)
  - WDT reboot race (B1-353 safeguard window vs AP recovery window)
  - HTTP header buffer overflow (BB_SINK_HTTP_HEADERS_MAX vs buf allocation)
  - MQTT/HTTP TLS stack depth (BB_PUB_WORKER_STACK vs TLS chain budget)
  - Single-core panic on pinned worker core (BB_PUB_WORKER_CORE=0 on S2)
  - Auto-register conflict (BB_OTA_PULL vs BB_OTA_BOOT double-owner)
These will be addressed in subsequent PRs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jgangemi jgangemi force-pushed the jae/bb-config-coupling-coverage branch from 9e74c7f to c0e10b0 Compare June 30, 2026 23:13
@jgangemi jgangemi merged commit 93106a5 into main Jun 30, 2026
11 checks passed
@jgangemi jgangemi deleted the jae/bb-config-coupling-coverage branch June 30, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants