Skip to content

Adapt core #837 refactors to current main with safe SIOF fixes, audit integration, and build-flag cleanup - #891

Merged
rbergen merged 9 commits into
PlummersSoftwareLLC:mainfrom
rbergen:integrate-pr837
Jun 6, 2026
Merged

rbergen merged 9 commits into
PlummersSoftwareLLC:mainfrom
rbergen:integrate-pr837

Conversation

@rbergen

@rbergen rbergen commented Jun 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR ports the safe, high-value intent of #837 onto the current main branch state.

It includes five focused commits (followed by a clean-up one) that:

  • apply static-initialization-order safety improvements in webserver and effect paths,
  • carry forward include/dependency hygiene updates that are compatible with current main,
  • integrate coding-standard audits into the PlatformIO build flow,
  • add an opt-in strict audit mode for local and CI workflows,
  • and apply the build-flag cleanup from Fix static initialization order fiasco for psram_allocator globals #837.

Relationship to #837: What Was Implemented

The following concepts from #837 are implemented in this PR, adapted to the current main codebase:

  1. Static initialization safety improvements

    • Webserver and polar-map initialization paths were refactored to avoid static initialization order hazards.
    • Effect metadata/decoder initialization was also refactored to remove startup-order risks.
  2. Build-time coding-standard auditing

    • The audit script is wired into PlatformIO pre-build execution so audits run consistently with builds.
  3. Include/dependency hygiene and build-flag cleanup

Implementation Deviations from #837 (Beyond Branch Drift)

These are intentional deviations from #837 itself, not just consequences of old-base drift:

  1. Effect resource ownership model

    • Instead of moving heavy effect resources to per-instance class members, this PR uses shared function-local statics for those resources.
    • Rationale: preserves SIOF safety while avoiding duplicate heavy allocations across instances.
  2. Audit enforcement policy

    • Fix static initialization order fiasco for psram_allocator globals #837 enforced audits as hard-fail by default.
    • This PR keeps default behavior as soft-fail and introduces opt-in hard-fail via local configuration.
    • Rationale: enables gradual enforcement and avoids immediately breaking existing workflows while still supporting strict mode when desired. The code in this PR passes audit and strict mode will become the CI policy on the short term.

What Was Not Included from #837, and Why

  1. Allocator-policy cleanup changes

    • Changes that remove/customize allocator pathways and JSON allocation behavior were not merged.
    • Rationale: recent experiences have shown that these are behavior-sensitive memory-policy decisions that can lead to significant functional breakages and need specific and deep validation.
  2. Additional runtime behavior tweaks bundled with janitorial edits

    • Non-essential behavioral tuning (for example, threshold-level runtime warning changes) was not carried over.
    • Rationale: out of scope for this port and not required to realize the core safety/build intent.
  3. Old-base environment/config churn

    • Broad environment/config differences present due old branch ancestry were not imported.
    • Rationale: unrelated to the core intent and risky to bring forward without dedicated review.

Validation

  • Local builds were successfully run on the adapted changes on envs mesmerizer, spectrum, m5demo
  • A full CI run was successfully executed on the PR head branch

Notes

Contributing requirements

  • I read the contribution guidelines in CONTRIBUTING.md.
  • I understand the BlinkenPerBit metric, and maximized it in this PR.
  • I selected main as the target branch.
  • All code herein is subjected to the license terms in COPYING.txt.

@robertlipe robertlipe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Making the audits optional means that they're going to be ignored by submitters and will thus just continue to decay. I don't know why you worked so hard to NOT just turn it on and leave it on. "Those smoke detectors keep going off. Let's remove the batteries."

This PR is still a solid improvement as far as it goes. Thanx.

Comment thread include/webserver.h Resolved

@rbergen rbergen left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Audits will be enforced in CI soon as I indicated in the PR description, and there is a reason for making that a two-step process, which relates to a smooth adoption in the broader context.

As for the ability to make them not abort the build locally, that relates to different people preferring different development workflows. Which is fine - in the end CI will decide what passes the gauntlet and what doesn't.

In any case, thanks for your review!

Comment thread include/webserver.h Resolved
@rbergen
rbergen merged commit 33a1133 into PlummersSoftwareLLC:main Jun 6, 2026
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-g3 in global build_flags significantly slows compilation and bloats object files

2 participants