Repository navigation
Lifecycle, three-tier rebuild, correction, perf contracts, networks - #9
Merged
Merged
Conversation
MoonModule loop/loop20ms/loop1s base defaults now propagate to children via a shared tickChildren helper that gates each child by the same rule the Scheduler applies to top-level modules (respectsEnabled() || enabled()) and accumulates per-child timing. Leaf modules pay one predicted-not-taken branch per call. Layers / Drivers shed the per-child block they each carried; Layer keeps its custom Effect-only dispatch. With propagation in place, ImprovProvisioningModule moves from a top-level Scheduler module to a child of NetworkModule — the relationship matches the data flow (Improv polls credentials, pushes them into Network). NetworkModule's overrides chain to base so Improv participates in setup, control binding, loop1s, and teardown. To stop the persistence-apply step from trimming the code-wired Improv on devices whose saved Network.json predates the addition, MoonModule grows a markWiredByCode() flag. main.cpp marks Improv, FilesystemModule's applyNode skips wired-by-code children in both the position-replace and trim paths. Verified on real hardware: the same Network.json that caused Improv to vanish on every boot now loads cleanly without erase-flash. The UI rendered code-wired children invisibly because acceptsChildren() gated on a light-pipeline allowlist. Split into hasNestedChildren() (controls whether nested cards render) and acceptsNewChildren() (controls whether "+ add child" appears). Parent control collapse-by-default ties to acceptsNewChildren — Network keeps its controls expanded since the parent's settings are the focus there. CLAUDE.md drops the docs/history/plan-NN.md flow; plans live in the agent's own workspace, only their distilled lessons (decisions.md) land in the repo. Brings the process back to vanilla Claude Code planning. KPI: 16384lights | PC:356KB | tick:70/58/126/107us(FPS:14285/17241/7936/9345) | ESP32:1178KB | tick:83521us(FPS:11) | heap:154KB | src:60(9232) | test:33(4279) | lizard:33w - Core: - MoonModule: loop/loop20ms/loop1s defaults propagate via tickChildren; markWiredByCode/isWiredByCode added - NetworkModule: setup / loop1s / teardown / onBuildControls chain to base so the Improv child participates - FilesystemModule: applyNode preserves code-wired children in both position-replace and trim paths - Scheduler: unchanged (top-level walk still correct; recursion now happens inside each root's loop) - Light domain: - Layers: loop() override deleted (was pure propagation; base default does it) - Drivers: loop() shrinks to blendMap + MoonModule::loop() - Layer: unchanged (custom Effect-only dispatch with extrude logic) - UI: - app.js: acceptsChildren split into hasNestedChildren + acceptsNewChildren; collapse-by-default ties to acceptsNewChildren so Network's controls stay expanded - Scripts / MoonDeck: none - Tests: - test_lifecycle_propagation: 6 new cases pinning propagation gating + timing + leaf no-op - test_filesystem_persistence: 2 new cases pinning wiredByCode preservation in trim and position-replace - Docs / CI: - CLAUDE.md: removes the docs/history/plan-NN.md process; plans live in agent's workspace - architecture.md: new "Lifecycle propagation to children" subsection + Persistence bullet for code-wired children - testing.md: lifecycle-propagation test section - decisions.md: two new entries (asymmetric lifecycle was historical; override-and-chain conventions) - ImprovProvisioningModule.md: notes Improv-as-Network-child relationship + wiredByCode Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Summary
15-commit branch covering child-lifecycle propagation, the long-overdue closure of the coarse-rebuild debt, per-driver output correction, a real performance-contracts gate, NetworkModule polish, and the developer-environment Improv test loop.
Module lifecycle + module tree:
loop/loop20ms/loop1sbase defaults now propagate to children via a sharedtickChildrenhelper; the previously asymmetric "setup chains, loops don't" was historical, not principled. Override-and-chain convention codified inarchitecture.md § Lifecycle propagation to children.ImprovProvisioningModulemoves to a child ofNetworkModule(a four-line follow-up enabled by the propagation fix).markWiredByCode()flag on MoonModule preserves code-wired children across anapplyNodeload whose saved JSON predates the addition — fixes Improv vanishing on every reboot before this branch.Control-change + rebuild:
handleSetControl: cheaponUpdatealways,buildState()only whencontrolChangeTriggersBuildState(name)returns true (default false; overridden true onLayoutBase/ModifierBase). Slider drag no longer triggers a tree-wide realloc sweep. Mirrors MoonLight'sonUpdate/requestMappings/onSizeChangedsplit.onAllocateMemory→onBuildState(idempotent, history-agnostic — boot and later changes are the same call).Output correction:
Correction(256-entry brightness LUT + channel-order table + derive-white flag) handed to each physical driver viaconst Correction*. ArtNet was previously sending raw bytes; gap now closed. Preview exempt.Performance contracts + telemetry:
tick+heap+max_alloc_blockcontracts captured in every scenario JSON, with anobserved.<target>widen-only sibling block tracking the rolling [min, max] across runs.run_scenario.pywrites back observed values automatically.docs/performance.mdnow generated from the contracts — no hand-edited table to drift.NetworkModule polish:
mode/rssi/txPowerread-only metrics — required addingControlType::ReadOnlyInt(int8 + unit suffix). Static-IP fields gainControlType::IPv4(4-byte storage instead of 16-char dotted-quad).Idleinstead of crashing.ControlType dispatcher:
src/core/Control.cppextracts the per-ControlTypeswitchthat had drifted acrossHttpServerModule::writeControls,FilesystemModule::writeValue, andscenario_runner.cpp.ApplyPolicy::Strict(HTTP) vsClamp(FS load) preserves the tolerant-load semantics.JsonSinkgains a fixed-buffer mode (third backend alongside socket + heap-grow) so the FS serializer shares the codepath without growing a per-value allocation. Codified ascoding-standards.md § Per-type behaviour lives with the type.MoonDeck:
mutate_state(mutator)withRLock+ atomic temp-file write.Board → firmware rename:
firmware;boardis reserved for physical hardware (a separate concept, seedocs/plan.md § Board injection).Test reorganization:
test/unit/split intocore/andlight/subdirectories with CamelCase naming matching the source module.docs/tests/unit-tests.md+docs/tests/scenario-tests.mdindices from source — no hand-edited test catalog to drift.scenario_runnerandrun_live_scenarionow share contract semantics;min_pctbounds are runner-WARN, hardware-fail.Developer-environment Improv test loop:
scripts/run/preview_installer.pyflash-ready mode stages every localbuild/esp32-*/projectMM.binunderreleases/latest/in the preview server's tree, generates Pages-relative manifests via the same script production uses, and overlays the GitHublatesttag —http://localhost:8000/flashes the local build with full ESP Web Tools + Improv WiFi. Web Serial works on localhost without the secure-origin requirement.scripts/build/improv_smoke_test.py: three-step probe + WiFi provision + LAN reachability as a single CLI, exit codes for CI, wired into MoonDeck. Closes the gap that made every Improv-touching commit a high-friction "tag, wait for CI, deploy" cycle.KPI (head of branch)
PC tick squarely in the historical 46–85us / 48–59us / 121–196us / 107–158us band. ESP32 tick from a live Olimex board.
Test plan
ctest— all unit + scenario tests pass on every commitmm_scenarios(in-process) — all passrun_live_scenario.pyfor the touched scenarios; observed bands within contracterase_flash(themarkWiredByCodefix)Idlecleanly when init failspreview_installer.py→ browser → flash → Improv WiFi → device reachable on LANReviewer trail
git diff main...HEAD) — findings either fixed in commit158d727or accepted with reason.🤖 Generated with Claude Code