Skip to content

Add central memory-class ladder (MemClass.h) with fail-safe-small defaults - #10901

Merged
thebentern merged 5 commits into
developfrom
feat/memclass-tiers
Jul 6, 2026
Merged

Add central memory-class ladder (MemClass.h) with fail-safe-small defaults#10901
thebentern merged 5 commits into
developfrom
feat/memclass-tiers

Conversation

@thebentern

@thebentern thebentern commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Stacked on #10898 (base is that branch; GitHub will retarget to develop when it merges). Review just this PR's two-file diff.

Problem

The 2.8.0 nRF52840 heap exhaustion (#10898) had a structural cause beyond the numbers: every RAM-sized cache picks its per-platform tier from its own chip #ifdef ladder, and every ladder's fallthrough default was its largest non-PSRAM tier. nRF52 was never explicitly named in the TMM ladder, so it silently inherited 1000-entry caches on a ~115 KB arena. Nothing stops the next feature from repeating this.

Change

New src/memory/MemClass.h — a single MESHTASTIC_MEM_CLASS (TINY / SMALL / MEDIUM / LARGE) ranked by usable app heap after platform overheads (SoftDevice, WiFi+BLE stacks), which is why classic ESP32 shares a class with nRF52840. Two deliberate properties:

  1. Unclassified chips land in SMALL. A new target boots with small caches until someone opts it up in one visible place — the structural fix for the fallthrough-to-largest bug.
  2. A per-class MESHTASTIC_BOOT_CACHE_BUDGET is static_asserted in mesh-pb-constants.h over the three big boot-allocated caches (TMM cache + warm store + packet history), so a future cache-adding PR that would blow a small platform's budget fails to compile instead of exhausting heap in the field. (Skipped where MAX_NUM_NODES is runtime-resolved: ESP32-S3 and portduino.)

The TMM cache, warm store, MAX_RX_TOPHONE, and MAX_SATELLITE_NODES ladders now key off the class. Branches pinned by something other than RAM stay explicit and say why (nRF52840's SoftDevice-shared arena → TMM 250; RP2040's warm.dat watchdog bound → warm 150). MAX_NUM_NODES intentionally stays separate — it's flash-shaped (nodes.proto vs LittleFS), not heap-shaped. All ladders remain #ifndef-guarded, so existing variant overrides keep working.

No-op proof

Rebuilt one env per class on this branch vs its base and compared size output:

Env Class text/data/bss
rak4631 SMALL (nRF52840) byte-identical
tbeam SMALL (classic ESP32) byte-identical
rak11310 SMALL (RP2040) byte-identical
wio-e5 TINY (STM32WL) byte-identical

MEDIUM/LARGE (S3/C6/P4, PSRAM, portduino) are covered by the value-by-value mapping in the diff (each class value equals the branch it replaced) and by CI.

Verification

  • Docker native suite: 536/536 passed
  • Builds green: rak4631, tbeam, rak11310, wio-e5

Follow-up candidates deliberately not changed here (kept historical values, flagged inline): MESSAGE_HISTORY_LIMIT normalization, ESP32-C3's MAX_RX_TOPHONE=32.

Summary by CodeRabbit

  • New Features

    • Improved memory-aware sizing across devices by introducing a compile-time memory class ladder and tier-based cache budgeting.
    • Added stricter packet history limits derived from node count to keep mesh caching within the configured boot-cache budget.
  • Bug Fixes

    • Reduced memory-related instability by enforcing compile-time size consistency and validating packet history sizing against the new caps.
    • Enabled larger display buffers on select nRF52840 variants by unsetting the display memory reduction flag.

Field reports on 2.8.0 show nRF52840 devices at 99% heap (114/115 KB)
within minutes of boot; operator new asserts on OOM, so these devices
are one allocation from a reboot. The 2.8.0 cache sizing ladders gave
nRF52 the largest non-PSRAM tiers on the assumption that a BLE-only
part has a roomy heap - the arena is actually ~125 KB shared with the
FreeRTOS task stacks.

Per-target retiers (nRF52840 unless noted):
- Traffic Management cache 1000 -> 250 entries (10 KB -> 2.5 KB); the
  unclassified fallthrough drops 1000 -> 400 to match the classic-ESP32
  tier (also affects RP2040/RP2350)
- Warm node store 200 -> 100 entries (8 KB -> 4 KB); the non-XXAA
  fallthrough drops 320 -> 100 so an unclassified RAM-constrained part
  can't boot-allocate 12.8 KB
- MESSAGE_HISTORY_LIMIT 20 -> 10 (text pool 4.4 KB -> 2.2 KB), the tier
  classic ESP32 already ships
- MAX_RX_TOPHONE 32 -> 16, shrinking the static packet pool 70 -> 54
  slots (~6.6 KB of .bss returned to the heap arena)
- PacketHistory hash index off arch-wide (1 KB); O(n) over 240 records
  is negligible at LoRa packet rates
- OLEDDISPLAY_REDUCE_MEMORY arch-wide (~1 KB OLED back buffer); the five
  TFT variants -U it because TFTDisplay.cpp needs buffer_back for
  dirty-window diffing
- Drop the stale "for testing" 1024-entry TMM override on T1000-E

Measured on rak4631: heap arena grows 124,572 -> 131,180 B and boot
allocations drop ~15.7 KB, roughly +22 KB free heap on the field-report
device class.

Migration: the nRF52840 warm flash ring replays through place() (LRU),
so the newest 100 identities survive the shrink; the file backend
rejects oversized snapshots cleanly (new test covers this). Native
suites pass (536/536 Docker, 13/13 native-macos warm store); rak4631,
heltec-mesh-node-t114 (TFT) and tracker-t1000-e build green.
…aults

The 2.8.0 nRF52840 heap exhaustion happened because each RAM-sized cache
picked its per-platform tier from its own chip #ifdef ladder, and every
ladder's fallthrough default was its largest non-PSRAM tier - nRF52 was
never named, so it silently got 1000-entry caches on a ~115 KB arena.

This introduces src/memory/MemClass.h: a single MESHTASTIC_MEM_CLASS
(TINY / SMALL / MEDIUM / LARGE) ranked by usable app heap after platform
overheads, with the deliberate property that an unclassified chip lands
in SMALL - a new target boots with small caches until someone opts it up
in one visible place.

The TMM cache, warm store, MAX_RX_TOPHONE and MAX_SATELLITE_NODES
ladders in mesh-pb-constants.h now key off the class; branches pinned by
something other than RAM stay explicit and say why (nRF52840's SoftDevice
arena, RP2040's warm.dat watchdog bound). MAX_NUM_NODES intentionally
stays separate - it is flash-shaped (nodes.proto vs LittleFS), not
heap-shaped.

A per-class MESHTASTIC_BOOT_CACHE_BUDGET static_assert now covers the
three big boot-allocated caches, so the next cache-adding PR that would
blow a small platform's budget fails to compile instead of exhausting
heap in the field.

No values change for any existing target: rak4631, tbeam, rak11310 and
wio-e5 build byte-identical before/after; all ladders remain
#ifndef-guarded so variant overrides keep working.
@thebentern thebentern added the enhancement New feature or request label Jul 6, 2026
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1e6a5a93-d060-4baf-acf3-e17e927141fa

📥 Commits

Reviewing files that changed from the base of the PR and between 85a3c2f and 08476c2.

📒 Files selected for processing (3)
  • src/memory/MemClass.h
  • src/mesh/PacketHistory.cpp
  • src/mesh/mesh-pb-constants.h
💤 Files with no reviewable changes (1)
  • src/mesh/PacketHistory.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/memory/MemClass.h
  • src/mesh/mesh-pb-constants.h

📝 Walkthrough

Walkthrough

Introduces a memory-class tier abstraction, drives mesh cache sizing from that tier, adds compile-time size checks for packet history and cache budgets, and updates two nRF52840 variant build flags.

Changes

Memory class tiering and cache budget enforcement

Layer / File(s) Summary
Memory class constants and boot-cache budget definitions
src/memory/MemClass.h
Defines memory-class tier constants, selects a default MESHTASTIC_MEM_CLASS from compile-time target macros, and derives MESHTASTIC_BOOT_CACHE_BUDGET from that tier.
Cache sizing macros refactored to use memory class tiers
src/mesh/mesh-pb-constants.h
Includes MemClass.h, refactors cache-related macros to use MESHTASTIC_MEM_CLASS, adds PACKETHISTORY_MAX, and adds a compile-time budget check against MESHTASTIC_BOOT_CACHE_BUDGET.
PacketRecord size and packet history constant cleanup
src/mesh/PacketHistory.h, src/mesh/PacketHistory.cpp
Adds a compile-time PacketRecord size assertion and removes the local PACKETHISTORY_MAX definition from the packet history translation unit.

nRF52840 OLED display memory build flag

Layer / File(s) Summary
Add OLED memory build flag to variant configs
variants/nrf52840/heltec_mesh_node_t114/platformio.ini, variants/nrf52840/heltec_mesh_solar/platformio.ini
Adds -UOLEDDISPLAY_REDUCE_MEMORY to the two nRF52840 variant environment build flags.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Poem

A bunny counted bytes with care,
From tiny caches to spacious air.
Tier by tier the build grew wise,
With tidy checks in rabbit eyes.
Two OLED flags went hopping free,
And memory paths now scale like tea. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the central change: a shared memory-class ladder with conservative defaults.
Description check ✅ Passed The description is substantive and covers problem, change, and verification, but it does not follow the template’s attestation checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

⚡ Try this PR in the Web Flasher

Note

Building this pull request… the flash button, badges and supported-board
list will appear here automatically once CI finishes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a centralized memory-class ladder (MESHTASTIC_MEM_CLASS) to drive RAM-shaped cache sizing decisions from a single, fail-safe-small policy point, and adds a compile-time guardrail (MESHTASTIC_BOOT_CACHE_BUDGET) to prevent future boot-time cache growth from silently exhausting heap on constrained targets.

Changes:

  • Add src/memory/MemClass.h defining MEM_CLASS_{TINY,SMALL,MEDIUM,LARGE} with an explicit “unknown chips default to SMALL” policy and per-class boot-cache budgets.
  • Refactor several cache/limit ladders in src/mesh/mesh-pb-constants.h to key off MESHTASTIC_MEM_CLASS (with documented exceptions).
  • Add a static_assert budget check over the three major boot-allocated mesh caches (TMM cache, warm store, packet history) where MAX_NUM_NODES is compile-time constant.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

File Description
src/mesh/mesh-pb-constants.h Switch cache tier ladders to use MESHTASTIC_MEM_CLASS and add a compile-time boot-cache budget assertion.
src/memory/MemClass.h New central classification header defining memory classes and per-class boot-cache budgets with fail-safe-small defaulting.

Comment thread src/memory/MemClass.h
Comment thread src/mesh/mesh-pb-constants.h
…ssert

- MemClass.h's class table claimed RP2350 was MEDIUM while the mapping
  ladder classifies it SMALL (with RP2040) - the table now matches the
  ladder, with a note that RP2350 is a MEDIUM candidate whenever someone
  wants to tune it up (kept SMALL here so this header stays a behavioral
  no-op).
- The boot-cache budget comment referenced a static_assert pinning
  PacketHistory::PacketRecord at 20 B that did not exist (only a layout
  comment). Add the real static_assert so the budget math in
  mesh-pb-constants.h fails to compile if the record layout changes.

Also merges develop (the base #10898 landed there as a squash, which is
what made this stacked branch conflict); develop's mesh-pb-constants.h
is byte-identical to this branch's base, so the resolution keeps the
MemClass ladder unchanged. rak4631 and wio-e5 build green;
test_packet_history 47/47.
@thebentern

Copy link
Copy Markdown
Contributor Author

Both review findings addressed in 85a3c2f, and the merge conflict is resolved (the base #10898 landed on develop as a squash, which is what tripped this stacked branch — develop was merged in; its mesh-pb-constants.h is byte-identical to this branch's base, so the ladder is unchanged):

  1. RP2350 class-table doc — the table now matches the ladder: RP2350 rides with RP2040 in SMALL (deliberately, to keep this header a behavioral no-op), with an inline note that it's a MEDIUM candidate whenever someone wants to tune it up.
  2. PacketRecord "pinned by static_assert" — the assert the budget comment referenced didn't actually exist; it does now (static_assert(sizeof(PacketRecord) == 20, …) in PacketHistory.h), so a future layout change breaks the build instead of silently skewing the budget math.

Verified: rak4631 and wio-e5 build green post-merge; test_packet_history 47/47.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/mesh/mesh-pb-constants.h (1)

10-14: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Comment block exceeds repo guideline of 1-2 lines.

As per coding guidelines, **/*.{c,cc,cpp,h,hpp} should "use at most one or two lines, only when the reason is not obvious; do not add multi-paragraph explanatory comments." This 5-line policy comment could be trimmed to a one-liner referencing memory/MemClass.h.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/mesh/mesh-pb-constants.h` around lines 10 - 14, The comment block in
mesh-pb-constants.h is too verbose for the repository’s header comment style.
Trim the existing multi-line policy note near the mesh options constants down to
a single short line, keeping only the essential reference to memory/MemClass.h
and the safe-small fallback rationale. Use the surrounding constants and
mesh.options context to preserve meaning while removing the extra explanatory
lines.

Source: Coding guidelines

src/memory/MemClass.h (1)

3-38: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Trim the header comment block to comply with repo comment-length guideline.

This block is ~36 lines of prose. As per coding guidelines, **/*.{c,cc,cpp,cxx,h,hpp,hh} requires "one or two lines mმაximum, only when the reason is not obvious, and do not restate the next line." Consider moving the rationale/history into the PR description or a design doc, and keeping only a short pointer comment in the header (e.g., a one-liner plus a link to docs).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/memory/MemClass.h` around lines 3 - 38, The top-of-file comment in
MemClass.h is far too long for the header comment guideline; trim it down to a
one- or two-line pointer that keeps only the essential note about
MESHTASTIC_MEM_CLASS and where the fuller rationale lives. Move the detailed
history, platform ranking, and override explanation out of the header and into
the PR description or a design doc, keeping the remaining comment near the
MemClass.h definitions brief and easy to scan.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/mesh/mesh-pb-constants.h`:
- Around line 209-225: The boot-cache budget check in mesh-pb-constants.h is
duplicating the PACKETHISTORY_MAX arithmetic from PacketHistory.cpp, so the
assert and the runtime clamp can diverge. Move the packet-history capacity bound
into a shared constexpr or header symbol (for example alongside
PacketHistory/PacketHistory::PacketRecord definitions) and update both the
static_assert in mesh-pb-constants.h and the constructor clamp in
PacketHistory.cpp to use that single shared value.

---

Nitpick comments:
In `@src/memory/MemClass.h`:
- Around line 3-38: The top-of-file comment in MemClass.h is far too long for
the header comment guideline; trim it down to a one- or two-line pointer that
keeps only the essential note about MESHTASTIC_MEM_CLASS and where the fuller
rationale lives. Move the detailed history, platform ranking, and override
explanation out of the header and into the PR description or a design doc,
keeping the remaining comment near the MemClass.h definitions brief and easy to
scan.

In `@src/mesh/mesh-pb-constants.h`:
- Around line 10-14: The comment block in mesh-pb-constants.h is too verbose for
the repository’s header comment style. Trim the existing multi-line policy note
near the mesh options constants down to a single short line, keeping only the
essential reference to memory/MemClass.h and the safe-small fallback rationale.
Use the surrounding constants and mesh.options context to preserve meaning while
removing the extra explanatory lines.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c4c4b9bc-11b9-4a07-a0de-1b9ee9cfc95c

📥 Commits

Reviewing files that changed from the base of the PR and between d846780 and 85a3c2f.

📒 Files selected for processing (5)
  • src/memory/MemClass.h
  • src/mesh/PacketHistory.h
  • src/mesh/mesh-pb-constants.h
  • variants/nrf52840/heltec_mesh_node_t114/platformio.ini
  • variants/nrf52840/heltec_mesh_solar/platformio.ini

Comment thread src/mesh/mesh-pb-constants.h
- Hoist PACKETHISTORY_MAX from PacketHistory.cpp into
  mesh-pb-constants.h (next to the MAX_NUM_NODES it derives from) so the
  constructor clamp and the boot-cache budget static_assert use one
  definition instead of hand-mirrored arithmetic that could drift. The
  expression stays valid where MAX_NUM_NODES resolves at runtime
  (ESP32-S3, portduino); the pointless 2.0 double math becomes integer.
- Trim the MemClass.h header (36 -> 16 comment lines) and the budget /
  sizing-policy comments per the repo comment-length guideline, keeping
  the class table, the fail-safe-small rule, the override mechanism, and
  the include-order constraint.

rak4631 (compile-time MAX_NUM_NODES) and heltec-v3 (runtime) build
green; test_packet_history 47/47.
@thebentern

Copy link
Copy Markdown
Contributor Author

CodeRabbit feedback addressed in 08476c2:

  1. PACKETHISTORY_MAX hoisted (the actionable finding) — the definition now lives in mesh-pb-constants.h next to the MAX_NUM_NODES it derives from, and both consumers use it: PacketHistory's constructor clamp and the boot-cache budget static_assert. No more hand-mirrored arithmetic to drift. The expression remains valid on targets where MAX_NUM_NODES resolves at runtime (ESP32-S3 flash-size probe, portduino config) — verified by building heltec-v3 alongside rak4631 — and the old * 2.0 double math is now plain integer.
  2. Comment-length nitpicks — MemClass.h's header prose cut from 36 to 16 lines and the sizing-policy/budget comments trimmed to guideline size. I kept the class table, the fail-safe-small rule, the override mechanism, and the include-order constraint in the header deliberately: they're the API contract a contributor needs at the point of use; the 2.8.0 backstory now lives only in the commit history.

Verified: rak4631 + heltec-v3 build green, test_packet_history 47/47.

@thebentern
thebentern merged commit 12b2d97 into develop Jul 6, 2026
6 checks passed
@thebentern
thebentern deleted the feat/memclass-tiers branch July 6, 2026 19:51
Itzdavid01 pushed a commit to Itzdavid01/firmware that referenced this pull request Sep 5, 2026
…aults (meshtastic#10901)

* Right-size nRF52 heap tiers after 2.8.0 heap-exhaustion field reports

Field reports on 2.8.0 show nRF52840 devices at 99% heap (114/115 KB)
within minutes of boot; operator new asserts on OOM, so these devices
are one allocation from a reboot. The 2.8.0 cache sizing ladders gave
nRF52 the largest non-PSRAM tiers on the assumption that a BLE-only
part has a roomy heap - the arena is actually ~125 KB shared with the
FreeRTOS task stacks.

Per-target retiers (nRF52840 unless noted):
- Traffic Management cache 1000 -> 250 entries (10 KB -> 2.5 KB); the
  unclassified fallthrough drops 1000 -> 400 to match the classic-ESP32
  tier (also affects RP2040/RP2350)
- Warm node store 200 -> 100 entries (8 KB -> 4 KB); the non-XXAA
  fallthrough drops 320 -> 100 so an unclassified RAM-constrained part
  can't boot-allocate 12.8 KB
- MESSAGE_HISTORY_LIMIT 20 -> 10 (text pool 4.4 KB -> 2.2 KB), the tier
  classic ESP32 already ships
- MAX_RX_TOPHONE 32 -> 16, shrinking the static packet pool 70 -> 54
  slots (~6.6 KB of .bss returned to the heap arena)
- PacketHistory hash index off arch-wide (1 KB); O(n) over 240 records
  is negligible at LoRa packet rates
- OLEDDISPLAY_REDUCE_MEMORY arch-wide (~1 KB OLED back buffer); the five
  TFT variants -U it because TFTDisplay.cpp needs buffer_back for
  dirty-window diffing
- Drop the stale "for testing" 1024-entry TMM override on T1000-E

Measured on rak4631: heap arena grows 124,572 -> 131,180 B and boot
allocations drop ~15.7 KB, roughly +22 KB free heap on the field-report
device class.

Migration: the nRF52840 warm flash ring replays through place() (LRU),
so the newest 100 identities survive the shrink; the file backend
rejects oversized snapshots cleanly (new test covers this). Native
suites pass (536/536 Docker, 13/13 native-macos warm store); rak4631,
heltec-mesh-node-t114 (TFT) and tracker-t1000-e build green.

* Add central memory-class ladder (MemClass.h) with fail-safe-small defaults

The 2.8.0 nRF52840 heap exhaustion happened because each RAM-sized cache
picked its per-platform tier from its own chip #ifdef ladder, and every
ladder's fallthrough default was its largest non-PSRAM tier - nRF52 was
never named, so it silently got 1000-entry caches on a ~115 KB arena.

This introduces src/memory/MemClass.h: a single MESHTASTIC_MEM_CLASS
(TINY / SMALL / MEDIUM / LARGE) ranked by usable app heap after platform
overheads, with the deliberate property that an unclassified chip lands
in SMALL - a new target boots with small caches until someone opts it up
in one visible place.

The TMM cache, warm store, MAX_RX_TOPHONE and MAX_SATELLITE_NODES
ladders in mesh-pb-constants.h now key off the class; branches pinned by
something other than RAM stay explicit and say why (nRF52840's SoftDevice
arena, RP2040's warm.dat watchdog bound). MAX_NUM_NODES intentionally
stays separate - it is flash-shaped (nodes.proto vs LittleFS), not
heap-shaped.

A per-class MESHTASTIC_BOOT_CACHE_BUDGET static_assert now covers the
three big boot-allocated caches, so the next cache-adding PR that would
blow a small platform's budget fails to compile instead of exhausting
heap in the field.

No values change for any existing target: rak4631, tbeam, rak11310 and
wio-e5 build byte-identical before/after; all ladders remain
#ifndef-guarded so variant overrides keep working.

* Address review: fix RP2350 class-table doc, add PacketRecord static_assert

- MemClass.h's class table claimed RP2350 was MEDIUM while the mapping
  ladder classifies it SMALL (with RP2040) - the table now matches the
  ladder, with a note that RP2350 is a MEDIUM candidate whenever someone
  wants to tune it up (kept SMALL here so this header stays a behavioral
  no-op).
- The boot-cache budget comment referenced a static_assert pinning
  PacketHistory::PacketRecord at 20 B that did not exist (only a layout
  comment). Add the real static_assert so the budget math in
  mesh-pb-constants.h fails to compile if the record layout changes.

Also merges develop (the base meshtastic#10898 landed there as a squash, which is
what made this stacked branch conflict); develop's mesh-pb-constants.h
is byte-identical to this branch's base, so the resolution keeps the
MemClass ladder unchanged. rak4631 and wio-e5 build green;
test_packet_history 47/47.

* Address review: share PACKETHISTORY_MAX, trim policy comments

- Hoist PACKETHISTORY_MAX from PacketHistory.cpp into
  mesh-pb-constants.h (next to the MAX_NUM_NODES it derives from) so the
  constructor clamp and the boot-cache budget static_assert use one
  definition instead of hand-mirrored arithmetic that could drift. The
  expression stays valid where MAX_NUM_NODES resolves at runtime
  (ESP32-S3, portduino); the pointless 2.0 double math becomes integer.
- Trim the MemClass.h header (36 -> 16 comment lines) and the budget /
  sizing-policy comments per the repo comment-length guideline, keeping
  the class table, the fail-safe-small rule, the override mechanism, and
  the include-order constraint.

rak4631 (compile-time MAX_NUM_NODES) and heltec-v3 (runtime) build
green; test_packet_history 47/47.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants