MAINT-21: comments only - trim restated notes, add DECISIONS pointers
checks / unit (pull_request) Successful in 25m17s
infra-pin / fresh (pull_request) Successful in 1s

No code change: tools/maint21_same_ast.py and tools/maint20_same_code.py HEAD~
both print OK, and the -OO code objects are the same.

- Trims 56 comment and docstring lines (2088 -> 2032) in app/main.py and the
  new files that only restated their MAIN-orchestration.md bullet, each cut to
  its first sentence and a pointer. What the cut comments said and the bullet
  did not is now in the bullet: why a SAFETY-02 latch is restored, why the
  SAFETY-30 site check is not armed at one inverter, the SAFETY-18 re-derive,
  the MAINT-05 one-config rule, the OPT-09 sizing rules, the "no plan" row,
  the 5 400 s age bound, and the guard being the only latch repair.
- Adds the missing DECISIONS pointers on the SMA-10, SAFETY-137 and SMA-2
  comments (FALLBACK_BUDGET_S, write_setpoint, _await_inflight,
  _release_last, the retry wait, the failed-release branch, release_zero_sent,
  the in-flight write, the stop_event hand-back, the SMA-2 read and driver).
- DECISIONS/SAFETY-32: the stale `main.py:932-936` now names
  Controller.pack_floor_soc.
- main.py's docstring and import block say where the Controller's parts are.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
glenn schrooyen
2026-11-09 00:41:34 +01:00
co-authored by Claude
parent 27a867f34b
commit 902da3f723
8 changed files with 87 additions and 141 deletions
+5 -10
View File
@@ -29,20 +29,14 @@ METER_QUIET_REPEAT_S = 600.0
_mono = time.monotonic # patched by the checks; asyncio keeps the real one
# OPT-04: the background tariff refresh. `static_tariff.resolve_tariff()` may
# do an HTTPS fetch, and a supplier's TLS timeout on the control tick could
# starve the ESP32 heartbeat into layer 1. So the tick NEVER awaits a fetch: it
# reads `self.tariff_plan`, which this task assigns.
# The cadence is not about how often prices change (day-ahead publishes once,
# 14-16 h CET; 30 min picks it up inside the hour with 48 fetches a day).
# OPT-04: the background tariff refresh. The tick NEVER awaits a fetch: it
# reads `self.tariff_plan`, which the refresh task assigns.
# DECISIONS/MAIN-orchestration.md.
TARIFF_REFRESH_S = 1800.0
# The age bound is a different question from the refresh: a failed refresh
# still stores a plan (the 11.4 static fallback, provisional). The bound covers
# the refresh task dying and a stale plan standing as current. Three missed
# refreshes, for `p1.max_age_s`'s reason.
# The age bound covers the refresh task dying: three missed refreshes.
# DECISIONS/MAIN-orchestration.md.
TARIFF_MAX_AGE_S = 3 * TARIFF_REFRESH_S
@@ -330,6 +324,7 @@ class InputsMixin:
check and the delivery check, which a frozen register would fool.
The standing command is asked of the unit, not recomputed."""
# SMA-2: the driver reads SoC, then power, as this method always did.
# DECISIONS/SMA-2-driver-seam.md.
inv.soc, raw, _extra = await self._driver(inv).read()
was_stale = inv.batt_fresh.stale
was_releases = inv.batt_fresh.releases