Skip to content

refactor: simplify FTW modules and release flow - #578

Merged
frahlg merged 2 commits into
masterfrom
codex/ftw-cleanup-release
Jul 17, 2026
Merged

frahlg merged 2 commits into
masterfrom
codex/ftw-cleanup-release

Conversation

@frahlg

@frahlg frahlg commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary

  • make the core / drivers / optimizer module boundaries explicit and remove retired remote relay, pair/P2P, fleet-statistics and incomplete OCPP code
  • remove legacy UI assets, archived plans/specs/ADRs and redundant package-level documentation; keep a small architecture/safety/operator documentation set
  • keep only beta and stable update channels, with exact-commit beta-to-stable promotion for core and signed drivers
  • split CI into path-classified parallel core, optimizer, web, driver, compose and full-stack jobs while preserving the required go test + vet check
  • include the pending Sourceful prices, Easee, Deye and Sourceful Zap driver work and their changesets

Why

FTW's history left several abandoned subsystems and more than 40k lines of plans, archives and generated guidance in the active repository. The repository now follows the intended modular architecture: core owns safety and orchestration, Lua drivers own vendor protocols/sign conversion, and the optional optimizer stays behind the core contract.

Impact

This intentionally removes unsupported legacy remote access and the incomplete embedded OCPP server. Existing persisted edge update selections migrate to beta. Legacy Compose installations still use the retained migration path.

Five Changesets are included; the resulting candidate is a minor release.

Verification

  • make verify
  • make ci (full-stack E2E, native + Linux/ARM64 builds, Chrome desktop/setup/mobile smoke)
  • make verify-all (Linux ARM64/AMD64 and Windows cross-builds)
  • npm test — 42/42
  • optimizer — 35/35
  • workflow YAML parse, Markdown link audit, brand scan and git diff --check

@frahlg
frahlg merged commit 61c5250 into master Jul 17, 2026
12 checks passed
@frahlg
frahlg deleted the codex/ftw-cleanup-release branch July 17, 2026 14:14
frahlg pushed a commit to HuggeK/ftw that referenced this pull request Aug 19, 2026
Brings back go/internal/ocpp, retired as unused in srcfl#578, so EV chargers can
connect to FTW directly instead of through a vendor cloud.

The package is restored unchanged and still builds, vets and passes its own
tests against the current tree. github.com/lorenzodonini/ocpp-go resolves to
v0.19.0 at @latest — the same version that was removed, since upstream has not
cut a release since August 2025.

Nothing is wired into main.go yet, so this changes no runtime behaviour. Two
known gaps are carried over from the original and must be closed before the
server is enabled:

- Config.Bind is advisory only. ocpp-go does not expose a bind address, so the
  listener takes 0.0.0.0 regardless, and Phase 1 has no TLS.
- Handlers are read-only. Charge Amps needs SetChargingProfile-based control,
  because its RemoteStopTransaction is unreliable in the field.

Co-authored-by: HuggeK <[email protected]>
HuggeK added a commit to HuggeK/ftw that referenced this pull request Aug 29, 2026
Brings back go/internal/ocpp, retired as unused in srcfl#578, so EV chargers can
connect to FTW directly instead of through a vendor cloud.

The package is restored unchanged and still builds, vets and passes its own
tests against the current tree. github.com/lorenzodonini/ocpp-go resolves to
v0.19.0 at @latest — the same version that was removed, since upstream has not
cut a release since August 2025.

Nothing is wired into main.go yet, so this changes no runtime behaviour. Two
known gaps are carried over from the original and must be closed before the
server is enabled:

- Config.Bind is advisory only. ocpp-go does not expose a bind address, so the
  listener takes 0.0.0.0 regardless, and Phase 1 has no TLS.
- Handlers are read-only. Charge Amps needs SetChargingProfile-based control,
  because its RemoteStopTransaction is unreliable in the field.

Co-authored-by: HuggeK <[email protected]>
frahlg added a commit that referenced this pull request Aug 29, 2026
* fix(units): store watts and 0-1 fractions in core

PV arrays use rated_w. SoC, planner bounds, and related settings are
0-1. kWp and 0-100 exist only at UI, HA, appproto, calendar titles, and
the forecast.solar URL. Config load still folds the old keys. A units
package plus consistency tests reject kWp and soc_pct leaking back into
core structs.

* fix(units): loadpoint, vehicle, and calendar SoC are 0-1

Core stored EV SoC as 0-100 while the battery planner already used 0-1.
That mix, not a missing clamp, is what let percent-scale values leak
into watt math. Loadpoint state, schedules, boost leases, vehicle
telemetry, calendar intents, V2X envelopes, and shadow SoC are now
fractions. 0-100 remains only at UI, HA, appproto, calendar titles,
Tesla verify, and optimizer protocol v1. The units harness fails if
_pct names or kWp return to those core structs.

Nameplate ceilings stay as physics gates. They are not the unit fix.

* fix(units): drop _pct names on 0-1 planner and dispatch SoC

Slot directives, live PV surplus caps, and the operator absorb cap
already stored 0-1. The Pct suffix made them look like 0-100. Rename
the fields, convert golden dump keys, and fail the units harness if
those names return.

* feat(ocpp): restore the OCPP 1.6J Central System package

Brings back go/internal/ocpp, retired as unused in #578, so EV chargers can
connect to FTW directly instead of through a vendor cloud.

The package is restored unchanged and still builds, vets and passes its own
tests against the current tree. github.com/lorenzodonini/ocpp-go resolves to
v0.19.0 at @latest — the same version that was removed, since upstream has not
cut a release since August 2025.

Nothing is wired into main.go yet, so this changes no runtime behaviour. Two
known gaps are carried over from the original and must be closed before the
server is enabled:

- Config.Bind is advisory only. ocpp-go does not expose a bind address, so the
  listener takes 0.0.0.0 regardless, and Phase 1 has no TLS.
- Handlers are read-only. Charge Amps needs SetChargingProfile-based control,
  because its RemoteStopTransaction is unreliable in the field.

Co-authored-by: HuggeK <[email protected]>

* chore: add changeset for the OCPP central system restore

Co-authored-by: HuggeK <[email protected]>

* feat(ocpp): enable the central system and document driverless OCPP chargers

Wires the restored OCPP 1.6J Central System into the process behind a new
opt-in ocpp config section, and documents the part that is easy to miss: an
OCPP charger needs no driver at all.

OCPP is vendor-neutral, so one server in core covers every charger that speaks
it. Chargers dial FTW rather than being polled, so there is nothing to add
under drivers: — a charge point becomes a device on its first BootNotification,
keyed by the last segment of the URL it connected to.

Enabling the server requires a username and password, and config validation
rejects an enabled section without them. This is deliberate. ocpp-go builds its
listen address from the port alone, so the socket is reachable on every
interface and cannot be pinned to one; basic auth is the only gate in front of
it. That is a mitigation, not a fix, and the docs say so.

Documented in docs/ocpp.md, with pointers from the README, config.example.yaml
and writing-a-driver.md so nobody starts a Lua driver for a charger that does
not need one.

Tests cover the fail-closed credential rule and assert the shipped example
config still parses, ships disabled and validates.

Co-authored-by: HuggeK <[email protected]>

* feat(ocpp): control chargers with charging profiles instead of remote stop

FTW can now throttle, pause and resume an OCPP charger. Command has the same
signature as drivers.Registry.Send and speaks the vocabulary every EV driver
already implements, so main.go routes by name and loadpoints never learn that
an OCPP charger is not a Lua driver.

Every command is a current limit, never a remote start or stop.
RemoteStopTransaction is unreliable on Charge Amps hardware — units acknowledge
the stop and then resume charging on their own — while a 0 A charging profile is
honoured consistently. It also leaves the transaction open, so the session meter
keeps counting across a pause instead of splitting into two sessions.

Two safety decisions worth calling out:

- Below the IEC 61851 minimum of 6 A the charger is told 0 A rather than rounded
  up. When the allocator has less headroom than that to give, rounding up draws
  current the site fuse was never asked to carry, so refusing to charge is the
  safe direction of error.
- A pause records no limit, so resuming returns to the last non-zero rate rather
  than the fallback ceiling. Caught by TestResumeRestoresLastLimit.

Also splits charger state in two. connected already meant "a connector has a
vehicle on it" and was never set by OnConnect, so it could not gate control: a
default charging profile is exactly the thing you set on an idle charger. online
now tracks the WebSocket session and is what control gates on.

Co-authored-by: HuggeK <[email protected]>

* fix(ocpp): stop serving the OCPP password over /api/config

MaskSecrets covered every other credential section but not the new ocpp one, so
GET /api/config returned the password in plaintext to any UI client. That is
the one credential that must not leak: the OCPP listener is reachable on every
interface and basic auth is the only thing in front of it.

Masking alone would have traded a leak for a wipe, because the settings tab
posts the config back and the masked password returns empty.
PreserveMaskedSecrets now keeps the stored value when the incoming one is
blank, while a genuinely new password still wins.

Co-authored-by: HuggeK <[email protected]>

* feat(ocpp): serve OCPP 2.0.1 alongside 1.6J

Newer chargers now connect without a driver too. Each version listens on its
own port, because a charger picks its dialect during the WebSocket handshake
before any message is sent, and ocpp-go's ws.Server keeps a single message
handler per listener — one port cannot serve both. Set ocpp.port_v201 to enable
2.0.1; leaving it unset keeps 1.6J only.

Only the encoding differs. Both dialects share one charger map, one telemetry
path and one control path, so a 2.0.1 charger is metered, throttled and paused
exactly like a 1.6 one and dispatch cannot tell them apart. Which listener a
charger reached is recorded on connect, and control encodes the profile to
match.

2.0.1 restructures more than the names suggest: Start/StopTransaction collapse
into one TransactionEvent, transaction ids become strings, connector status
loses its charging meaning, and meter samples arrive inside transaction events
as well as alone. The new handler normalises all of it back to the same state.

OCPP 2.1 is deliberately absent. No production-grade Go implementation exists —
ocpp-go covers 1.6 and 2.0.1 only, and the Go projects claiming 2.1 are
early-stage validators and emulators rather than servers. Adding it later is one
handler and one listener; the version-neutral core is unaffected.

Co-authored-by: HuggeK <[email protected]>

* docs(ocpp): document where the protocol code comes from

Records the boundary between the vendored protocol layer and FTW's own code,
so a reader knows which side of it a bug is on: transport, OCPP-J framing,
message types and schema validation are ocpp-go; handlers, telemetry mapping,
control semantics and safety clamps are ours.

Also corrects a false claim carried over from the retired package. The doc
comment said ocpp-go was "also used by SteVe" — SteVe is a Java project
(GPL-3.0), so it cannot depend on a Go library, and ocpp-go's README names no
production users at all. Replaced with facts that can be checked: MIT, v0.19.0,
no release since August 2025, and upstream's own description of its 2.0.1
support as needing more real-world testing.

The package doc was stale in other ways too — it still described a 1.6-only,
read-only server whose Phase 2 would add control, all of which has since landed.

Co-authored-by: HuggeK <[email protected]>

* docs: note 2.0.1 in the driver-writing OCPP callout

Co-authored-by: HuggeK <[email protected]>

* docs(ocpp): reword the licence line for the brand-copy check

The brand-cleanup workflow inventories "MIT licensed" as classified copy, so
the new provenance paragraph tripped it. Same fact, different wording.

Co-authored-by: HuggeK <[email protected]>

* feat(ui): Chargers tab with an OCPP panel and charge-point bindings

Rename the Loadpoints settings tab and dashboard section to Chargers —
the thing an operator recognises is the charger, not the internal
loadpoint binding (config keys keep their spelling).

The tab gains an OCPP panel: the exact backend URL to enter on a
charger, how to enable the server when it is off, live state for every
connected charge point, and a warning to reserve the FTW host's IP in
the router before commissioning — chargers store the URL and some
whitelist addresses, so a DHCP move silently orphans them.

Charge points seen by the OCPP server now appear in the charger-driver
dropdown, so binding an OCPP charger to the planner is a dropdown pick
instead of a YAML edit. Backed by GET /api/ocpp/chargers, which reports
the effective ports plus a per-charger view extended with online state,
dialect, vendor/model and the last accepted limit.

Co-authored-by: HuggeK <[email protected]>

* feat(ocpp): quarantine unadopted charge points as pending

A charge point that authenticates but is not named by any charger entry
(loadpoint) now connects as "pending": visible in Settings -> Chargers and
GET /api/ocpp/chargers so it can be adopted, but its telemetry never
reaches the site - no DerEV reading, no driver health, no metrics - and it
is never commanded. Without this, any device holding the shared basic-auth
secret could fabricate EV load and suppress home-battery discharge through
the dispatch clamp.

Co-authored-by: HuggeK <[email protected]>

* feat(ocpp): hot-apply charger adoption with the loadpoint reload

Loadpoints hot-reload on config save, so the quarantine's approved set must
follow in the same applier — otherwise adopting a pending charger would arm
the loadpoint controller immediately while telemetry stayed blocked until a
restart. Revoking an adoption now also pushes a zero DerEV reading, for the
same reason OnDisconnect does: the last power figure must not linger in a
sum the charger is no longer part of.

Co-authored-by: HuggeK <[email protected]>

* docs(ocpp): vehicle capacity describes one car; per-car profiles need 2.0.1/15118

Note on the config field, the settings tooltip and docs/ocpp.md: a charger
entry's vehicle_capacity_wh models the one car the charger usually serves,
and a wrong value costs planning accuracy, never safety. Detecting which car
is plugged in - to switch capacity automatically - needs vehicle identity
from the protocol: OCPP 1.6's idTag names the RFID card, not the car; real
identity (MacAddress autocharge / eMAID) and NotifyEVChargingNeeds are OCPP
2.0.1 + ISO 15118 territory, listed as future work.

Co-authored-by: HuggeK <[email protected]>

* feat(ocpp): vehicle profiles — identify the car, switch capacity and policy

A vehicles: config list (and a Vehicles section on Settings -> Chargers)
gives each car a capacity, identifiers and a charging policy: PV-surplus-only
and/or a target SoC the planner fills toward in the cheapest hours. When a
charging session identifies the car - the RFID idTag on 1.6, a MacAddress
(autocharge) or eMAID (ISO 15118) idToken on 2.0.1 - the loadpoint switches
to that car's capacity and policy for the session. Capacity reverts on
plug-out and survives config hot-reloads. A session matching no profile
changes nothing (the visitor default), and its identity shows in the
Chargers table so the operator can paste it into a profile. Quarantine
applies: pending chargers store identity for display but never fire the
profile hook.

Co-authored-by: HuggeK <[email protected]>

* feat(ocpp): probe, record and present whether a charger can be steered

Shortly after a charger connects, core reads SupportedFeatureProfiles (1.6)
or SmartChargingCtrlr.Available (2.0.1), stores the raw answer and derives a
tri-state verdict: smart charging, telemetry only, or not reported. Surfaced
as steerable/feature_profiles on GET /api/ocpp/chargers and as a Control
column on Settings -> Chargers, with a warning before an operator binds a
metering-only charger to a charger entry and waits for a planner that will
never move it.

Advisory, never a gate: commands are still attempted, because vendors
under-report and firmware changes the answer. What decides remains the
response to a real SetChargingProfile, handled by the actuation tracker.

Co-authored-by: HuggeK <[email protected]>

* fix(ocpp): ask each charger for its capabilities once, not twice

Connect and boot both trigger the probe milliseconds apart, long before any
answer can arrive, so every charger was asked twice. An in-flight marker
collapses that into one request, cleared on every callback path (and on a
send that never left) so an unanswered probe still retries on the next
connect - which is how a firmware update that adds SmartCharging is noticed.

Co-authored-by: HuggeK <[email protected]>

* fix(ocpp): clear the capability marker when a charger drops mid-probe

A probe in flight when the socket dies may never get its callback, which
would leave the in-flight marker set and block every later probe for that
charger. The reconnect is exactly when we want to ask again, so OnDisconnect
clears it.

Co-authored-by: HuggeK <[email protected]>

* fix(units): store OCPP vehicle target SoC as a 0-1 fraction

Vehicle profiles used 0-100 target_soc_pct. Core stores fractions;
legacy YAML target_soc_pct still folds at the config door.

* chore: drop the units changeset that already shipped

.changeset/si-core-units.md survived the merge because this branch carries a
rebased copy of the units commits while master carries the squashed one: master
added the file and then consumed it in release #956, so relative to the merge
base only this branch appeared to add it.

The entry it describes is already in CHANGELOG.md, attributed to f258a4d.
Keeping the file would print the same paragraph a second time in the next
release. Master's .changeset/ is empty; this PR's six OCPP changesets are the
only ones that should be pending.

Co-authored-by: HuggeK <[email protected]>

* fix(ocpp): compare basic-auth credentials in constant time

Review follow-up on #979: the plain string compare was the only gate in
front of a 0.0.0.0 listener. subtle.ConstantTimeCompare on both fields,
shared by the 1.6J and 2.0.1 listeners.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01C7xyXX1HYi2i1aax8EsCFx

---------

Signed-off-by: Cursor Agent <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: HuggeK <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
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.

1 participant