Skip to content

refactor(architecture): add typed controller command and snapshot contracts - #214

Merged
stritti merged 40 commits into
mainfrom
refactor/controller-architecture-contracts
Oct 10, 2026
Merged

stritti merged 40 commits into
mainfrom
refactor/controller-architecture-contracts

Conversation

@stritti

@stritti stritti commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Introduces the fixed-size, allocation-free controller command and immutable snapshot contracts needed for the architecture migration discussed in #170, without changing production behavior yet.

Contract surface

  • typed OperationMode with stable auto / manu / boost / timer wire values
  • fixed-size, trivially-copyable ControllerCommand covering existing runtime controller mutations
  • independent timer-start and timer-end commands so partial MQTT/Web updates remain lossless
  • bounded SET_NTP_SERVER plus ControllerSettingsSnapshot::ntpServer using a shared 127-byte-plus-NUL value with rejection instead of truncation
  • relative pool/solar pump toggles with explicit Web/NORVI/Olimex mode policy
  • relative CYCLE_MODE, evaluated by the owner against current state rather than an adapter snapshot
  • coherent SensorSnapshot with generation/timestamp, mapping identity and a deduplicated 20-device detected inventory with independent reading validity
  • SystemSnapshot projections for timer runtime, temperature-circulation settings, runtime settings and GREEN/YELLOW/RED time degradation
  • allocation-free local IPv4 projection (4 x uint8_t + valid) in NetworkSnapshot
  • both free heap and maximum allocatable heap diagnostics in SystemSnapshot
  • native contract tests plus OpenSpec requirements/design/tasks for ownership and migration gates

Scope boundary

The general controller command queue owns runtime controller/domain settings that must obey the Core-1 single-writer rule. WiFi/MQTT credentials and authentication secrets remain in dedicated provisioning/auth services.

NTP server text is a runtime controller setting, so validation/persistence belongs to Core 1. NTP client/network lifecycle remains owned by the time service. Local IP and heap values are read-only snapshot projections; outbound adapters format/use those copies rather than querying NetworkManager, WiFi or ESP after adoption.

Architectural constraints

  • no dynamic allocation in the contracts
  • no Arduino/protocol/hardware dependencies in the value types
  • mutable controller state remains single-writer on Core 1
  • OneWire/Dallas remains sensor-owner state after feat: multicore task architecture #170
  • external compatibility is unchanged, including historic manu
  • contracts remain compatible with the firmware C++ toolchain
  • native GCC ABI: ControllerCommand 156 bytes, SensorSnapshot 376 bytes, SystemSnapshot 596 bytes; transport PRs must verify queue/store and critical-section budgets

Follow-up dependency graph

Minimal robust graph:

#216 and #217 are currently stacked on an older #214 contract and must be synchronized with this completed surface. #218 already contains the current #216 and #217 heads as ancestors, so it should be restacked after those foundation PRs rather than reintroducing queue/store implementations.

For #218 sensor reads, first project the sensor owner's cached acquisition/discovery generation. If that bridge is not used, #220 becomes a hard predecessor of the sensor-read part of #218. #170 remains the ownership gate before any cross-task Dallas adoption.

A conservative serial merge order is therefore #214, #216, #217, #218, #219, #220, #221, with #216/#217 swappable and #220 movable earlier once #170 + #214 are satisfied.

Detailed merge gates, NTP legacy-value handling, resource budgets and regression scenarios are in openspec/changes/controller-architecture-contracts/design.md and the contract specification.

Validation

Current head: f5994e78c2bb25020bfa5e7e40114bf2cec40471.

  • Native Tests: success, 120 suites / 581 assertions, 0 failures
  • Relay Safety: success, 27 checks, 0 failures
  • PlatformIO: success for esp32dev, norvi_ae01_r and olimex_esp32_c6_evb
  • MegaLinter: success
  • CodeQL: success
  • all non-outdated review findings through 2026-10-05 are addressed and all review threads are resolved
  • SystemSnapshot retains a compile-time 600-byte budget guard and is 596 bytes on the native GCC ABI

Related to #170.

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

✅⚠️MegaLinter analysis: Success with warnings

Descriptor Linter Files Fixed Errors Max errors Warnings Elapsed time
✅ ACTION actionlint 8 0 0 0.63s
✅ BASH bash-exec 2 0 0 0.51s
✅ BASH shellcheck 2 0 0 0.54s
✅ BASH shfmt 2 0 0 0.01s
✅ C clang-format 1 0 0 0.04s
✅ C cppcheck 1 0 0 0.02s
✅ C cpplint 1 0 0 0.28s
✅ CPP clang-format 90 0 0 0.62s
✅ CPP cppcheck 90 0 0 5.56s
✅ CPP cpplint 90 0 0 6.81s
✅ EDITORCONFIG editorconfig-checker 275 0 0 0.6s
✅ JSON jsonlint 6 0 0 0.12s
✅ JSON v8r 6 0 0 4.33s
⚠️ MARKDOWN markdownlint 107 4 0 4.1s
✅ YAML yamllint 26 0 0 1.11s

Detailed Issues

⚠️ MARKDOWN / markdownlint - 4 errors
.opencode/skills/web-ui/SKILL.md:34 error MD028/no-blanks-blockquote Blank line inside blockquote
docs/superpowers/plans/2026-08-10-olimex-c6-local-ui-implementation.md:106:401 error MD013/line-length Line length [Expected: 400; Actual: 452]
docs/superpowers/plans/2026-08-16-norvi-button-calibration.md:7:401 error MD013/line-length Line length [Expected: 400; Actual: 412]
openspec/changes/controller-architecture-contracts/design.md:171:401 error MD013/line-length Line length [Expected: 400; Actual: 448]

Notices

⚠️ Your configuration references items that have been removed from MegaLinter and are ignored: MAKEFILE, MAKEFILE_CHECKMAKE, MARKDOWN_MARKDOWN_LINK_CHECK. See Removed linters to find their replacements.

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@10.1.0 --custom-flavor-setup --custom-flavor-linters ACTION_ACTIONLINT,BASH_EXEC,BASH_SHELLCHECK,BASH_SHFMT,C_CPPCHECK,C_CPPLINT,C_CLANG_FORMAT,CPP_CPPCHECK,CPP_CPPLINT,CPP_CLANG_FORMAT,EDITORCONFIG_EDITORCONFIG_CHECKER,JSON_JSONLINT,JSON_V8R,MARKDOWN_MARKDOWNLINT,YAML_YAMLLINT

MegaLinter is provided by OX Security
Show us your support by starring ⭐ the repository

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Native Test Coverage

Metric Value
Line Coverage 48.2%
Branch Coverage 74.8%
Lines Hit/Total 392/814
Branches Hit/Total 178/238

Report from native unit tests (ASan + gcov).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d81eeaa3ec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/ControllerCommand.hpp Outdated
Comment thread src/ControllerSnapshot.hpp
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Native Test Coverage

Metric Value
Line Coverage 48.2%
Branch Coverage 74.8%
Lines Hit/Total 392/814
Branches Hit/Total 178/238

Report from native unit tests (ASan + gcov).

1 similar comment
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Native Test Coverage

Metric Value
Line Coverage 48.2%
Branch Coverage 74.8%
Lines Hit/Total 392/814
Branches Hit/Total 178/238

Report from native unit tests (ASan + gcov).

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Native Test Coverage

Metric Value
Line Coverage 48.6%
Branch Coverage 76.0%
Lines Hit/Total 399/821
Branches Hit/Total 190/250

Report from native unit tests (ASan + gcov).

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Native Test Coverage

Metric Value
Line Coverage 48.6%
Branch Coverage 76.0%
Lines Hit/Total 399/821
Branches Hit/Total 190/250

Report from native unit tests (ASan + gcov).

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Native Test Coverage

Metric Value
Line Coverage 48.6%
Branch Coverage 76.0%
Lines Hit/Total 399/821
Branches Hit/Total 190/250

Report from native unit tests (ASan + gcov).

1 similar comment
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Native Test Coverage

Metric Value
Line Coverage 48.6%
Branch Coverage 76.0%
Lines Hit/Total 399/821
Branches Hit/Total 190/250

Report from native unit tests (ASan + gcov).

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Native Test Coverage

Metric Value
Line Coverage 48.6%
Branch Coverage 76.0%
Lines Hit/Total 399/821
Branches Hit/Total 190/250

Report from native unit tests (ASan + gcov).

1 similar comment
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Native Test Coverage

Metric Value
Line Coverage 48.6%
Branch Coverage 76.0%
Lines Hit/Total 399/821
Branches Hit/Total 190/250

Report from native unit tests (ASan + gcov).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 52b88a8c94

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/ControllerSnapshot.hpp
Comment thread src/ControllerSnapshot.hpp
Comment thread src/ControllerCommand.hpp
Comment thread src/ControllerSnapshot.hpp
Comment thread openspec/changes/controller-architecture-contracts/design.md Outdated
Comment thread src/NtpServerValue.hpp Outdated
Comment thread src/ControllerCommand.hpp
Co-authored-by: stritti <stritti@users.noreply.github.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Co-authored-by: stritti <stritti@users.noreply.github.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Native Test Coverage

Metric Value
Line Coverage 49.3%
Branch Coverage 76.4%
Lines Hit/Total 411/833
Branches Hit/Total 194/254

Report from native unit tests (ASan + gcov).

Co-authored-by: stritti <stritti@users.noreply.github.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Native Test Coverage

Metric Value
Line Coverage 49.3%
Branch Coverage 76.4%
Lines Hit/Total 411/833
Branches Hit/Total 194/254

Report from native unit tests (ASan + gcov).

Co-authored-by: stritti <stritti@users.noreply.github.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
Contributor

Native Test Coverage

Metric Value
Line Coverage 49.3%
Branch Coverage 76.4%
Lines Hit/Total 411/833
Branches Hit/Total 194/254

Report from native unit tests (ASan + gcov).

@stritti
stritti merged commit a6a2734 into main Oct 10, 2026
11 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.

2 participants