Skip to content

feat(fleetping): say coarsely how the box ran in the anonymous daily report - #1821

Merged
frahlg merged 9 commits into
masterfrom
feat/fleet-report-health
Oct 24, 2026
Merged

frahlg merged 9 commits into
masterfrom
feat/fleet-report-health

Conversation

@frahlg

@frahlg frahlg commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Problem

Fredrik, 24 October 2026: Sourceful needs to understand the fleet's operation, internally and in aggregate, to know where engineering time goes. The anonymous daily report says what a box is (version, drivers, battery, zone, age), not how it runs: is the planner fast enough on the hardware boxes use, does it fall back, do drivers fail, do updates fail.

What changes

ftw.fleet/2 adds four buckets to the same report, under the same switch (projectReportsAllowed: the saved switch and the project statistics answer):

Field Buckets Source in Core
plan_solve none, 0-1s, 1-5s, 5s+: the slowest plan of the last 24 h planner_diagnostics (kept 7 days), new state.PlannerDay
plan_fallbacks none, 0, 1-3, 4+: plans of the last 24 h that fell back the same query, $.solver.fallback
driver_errors none, 0, 0-1%, 1%+: share of driver polls that failed in the last 24 h new 24-slot hourly count in the telemetry store (CountPoll from the driver registry's poll loop, PollsLastDay), all drivers together
update none, ok, failed: the newest update of the last 7 days selfupdate.Checker.Status(), action update only
  • fleetwire.Decode takes ftw.fleet/1 (7 fields) and ftw.fleet/2 (11 fields, each health value from its fixed list) and nothing else. A Day counts health only from reports that carry it; a day without one has no health fields, so the public view and older readers see what they saw.
  • Settings → FTW app → Anonymous daily report names the new fields in its paragraph ("ten things") and shows them in the preview, in plain words. Reviewed in a browser against a local Core.
  • docs/architecture.md, "Fleet ping", says what the buckets are and where they come from.
  • Rebased on feat(stats): one statistics answer, and anonymous daily reports through an OHTTP relay #1820 at a7c025e (report id and day as inner request fields), on top of its relay rework (4cfd65f): the fleet report now travels through the relay inside one padded inner request. reportwire's TestEveryReportHasOneLength now builds the largest ftw.fleet/2 report, with the longest health values. Its body is 1,331 bytes, and with the report id and day the padded request still fits 1,536.

How driver_errors counts (review fixes)

  • Only the driver registry's poll loop counts, a failed poll and a good one alike (CountPoll). An OCPP charger's messages record health but are not polls and are counted neither way. Before, an OCPP-only site with one faulted connector read 1%+ (TestOnlyPollsAreCounted, TestRunLoopCountsPollsAndFailedPolls).
  • The count lives in memory. Until it covers six hours, as after an update's restart, the box reports none ("too few reads to say" in Settings), so a start-up burst of failed polls cannot read as trouble. none therefore means no polls or too few hours of them.

Why these fields cannot single out a box

  • Few values, a common answer. Each field has at most four values (a test holds that), and most boxes share one: 0 fallbacks, 0 errors, none updates. A rare answer sits in a crowd of boxes that differ in it and agree on everything else.
  • They describe the last day or week, not the house. They move as the box runs, so they are a weaker join key between two days' reports than the static fields the report already carries. They add no counter, no time and no id: the slowest solve is a bucket, never a duration; errors are a share, never a count; an update is an outcome, never a version.
  • No new stable trait. A box that does not update itself (Docker, Home Assistant) says none, like a native box that had no update, so the install method does not become a field. Driver errors are summed over all drivers, never named.
  • Only marginals survive. FTW Cloud keeps each field's daily count apart (fleetwire.Day), never the combination of fields, and keeps no report. The combination exists only in the request.
  • The relay hides the address. Since feat(stats): one statistics answer, and anonymous daily reports through an OHTTP relay #1820 the report reaches FTW Cloud through the relay, so the request no longer shows the box's address either.
  • Same honest limit as before. On a day with one report, the day's counts are that report. The quasi-identifier argument in go/internal/fleetping and on the Settings screen still holds; four coarse, changing fields do not change its shape.

Order and pairs

Checks

make verify passes (Go and Python suites, vet, build, protocol boundary). node --test web/fleet-ping-tab.test.mjs: 27 pass. New tests: TestHealthBucketsAreAFewFixedWords, TestADayCountsHealthOnlyFromReportsThatCarryIt (fleetwire), TestHealthTravelsOnlyAsBuckets (fleetping), TestPlannerDaySumsThePlansSinceATime (state), TestPollsLastDayCountsADayOfPollsAndErrors (telemetry), TestFleetHealthReadsTheBoxsLastDay (cmd/ftw).

The planner_diagnostics query runs json_extract over about a day of plan snapshots (roughly 100 rows of 85–170 kB) once a day and on each Settings preview. Not measured on a Pi.

🤖 Generated with Claude Code

…elay

Once per closed UTC day, 1 to 12 hours after it closes, the box sends the
date and six whole-kWh sums (solar, grid import and export, battery charge
and discharge, vehicle charge), sealed with Oblivious HTTP (RFC 9458) to FTW
Cloud's pinned gateway key and posted to an independent relay. The relay
never sees the report and FTW Cloud never sees the box's address.

- go/protocol/ohttp: RFC 9458 on crypto/hpke for one suite, with known-length
  Binary HTTP; the RFC's Appendix A vectors pass byte for byte.
- go/protocol/energywire: the report and its strict decoder.
- go/internal/energyreport: the complete-day rule on the energy ledger, the
  schedule and the sender. The relay URL and the gateway key are
  compile-time pins, both empty, so this release sends nothing.
- The fleet report's answer is the gate, shared in one function; a site a
  partner controls is left out. Settings shows the report beside the fleet
  report.
- ADR 0008 records what each party sees, the limits and the open ePrivacy
  question.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T06:34:52.953124Z 55bb9e4 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 55bb9e4849

ℹ️ 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 go/internal/telemetry/store.go Outdated
s.mu.Lock()
defer s.mu.Unlock()
s.driverHealthLocked(name).RecordError(err)
s.countPollLocked(time.Now(), true)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Count failed polls separately from general driver errors

For an approved OCPP 2.0.1 charger, a faulted StatusNotification calls telError in go/internal/ocpp/handlers_v201.go, which reaches RecordDriverError without any poll occurring. This change counts that notification as a failed poll, while successful OCPP messages use RecordDriverSuccess and never enter the denominator. Consequently, an OCPP-only site with one connector fault reports a 100% poll failure rate regardless of its successful traffic, and mixed sites can also land in the wrong fleet-health bucket. Record poll outcomes explicitly in the registry's poll branch rather than treating every driver-health error as a failed poll.

Useful? React with 👍 / 👎.

…e relay

Fredrik's change of scope, 24 October 2026: statistics are one answer on
the box, and every report goes the same way.

- One answer for both anonymous reports (cloudlink.SharesStatistics): part
  of FTW Cloud under the current terms, with no off switch; on for a box
  without Cloud until its owner turns it off. Nobody is asked. Stored state
  is read once (MigrateStatistics): a local No, a fleet report switched off
  in the config, or Cloud turned off on an earlier release stays off; a
  local yes stays yes; every other box is on by default. fleet_ping.enabled
  is no longer a switch. A box without Cloud no longer starts a
  statistics-only Cloud link.
- A box that shares only by default posts nothing straight to FTW Cloud,
  which would see its address; it waits for the relay.
- go/internal/statsrelay holds the relay and gateway pins and sends sealed
  reports; the fleet report goes through it once a release names a relay,
  the energy report always. Each report travels alone at its own time.
- go/protocol/reportwire: one padded inner request for both kinds
  (1,536 bytes); the gateway picks the decoder by schema.
- Settings: Anonymous statistics with the one switch beside both messages;
  the Cloud panel no longer asks local boxes.
- ADR 0008 and the protocol doc record the model, the two-report rule and
  the open ePrivacy question.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@frahlg
frahlg force-pushed the feat/fleet-report-health branch from 55bb9e4 to da5077f Compare October 24, 2026 06:43
frahlg and others added 2 commits October 24, 2026 09:04
From review of srcfl/ftw-cloud#50: the gateway counted a replayed request
again, and a fleet report, which has no date, could be replayed on any later
day. Each inner request now carries a random report id and the UTC date it
was sent, as Binary HTTP header fields inside the sealed message, at the
same fixed length. reportwire.Fresh refuses a report sent before yesterday;
the gateway keeps an id hash per date to count each report once.

ADR 0008 also states the open limit: the floor of five counts reports, and
anyone with the key configuration can post them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
frahlg added a commit that referenced this pull request Oct 24, 2026
…rs six hours

Review of #1821: OCPP errors fed the poll count through
RecordDriverError while OCPP successes did not, so an OCPP-only site
with one faulted connector read 1%+. Only the driver registry's poll
loop counts now (telemetry CountPoll), a failed poll and a good one
alike; health records are not polls.

The count lives in memory, so after an update's restart it covered
minutes and a start-up burst of failed polls could read as trouble.
PollsLastDay now says how much of the day it covers, and the report
says none until that is six hours.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@frahlg
frahlg force-pushed the feat/fleet-report-health branch from da5077f to 45a3e55 Compare October 24, 2026 07:15
… new sessions

From review of #1820:
- The hourly C8 upload read only the grant's stats purpose. It now reads
  the one answer too: off, or Cloud under older terms, sends no hour. Under
  older terms, asking for statistics is refused (ErrCloudTermsFirst, 409)
  instead of adding the stats purpose beside the old terms; Status says so
  (statisticsNeedTerms) and Settings shows it. After the migration,
  ReconcileStatistics takes the stats purpose out of a grant whose answer is
  off, and ends a statistics-only link, as turning statistics off does.
- A stored grant counts only through the running link, which honours it
  only with its key (Link.SharesStatistics, Link.SaidYesToStatistics). With
  no link, the box's own answer alone.
- While a Cloud that was turned off waits for its deletion receipt, the
  local answer can still change.
- energyreport.Day: a charger's session counter starts again at every
  plug-in, which the ledger marks as a reset and covers from power; that no
  longer drops the day. An asset first seen after the day ended is not part
  of it.
- statsrelay: FTW Cloud's host is refused in any case and with a trailing
  dot.
- ADR 0008 records Fredrik's decisions: a default box waits for the relay,
  and the floor of five counts reports, accepted, with Privacy Pass later.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
frahlg added a commit that referenced this pull request Oct 24, 2026
…rs six hours

Review of #1821: OCPP errors fed the poll count through
RecordDriverError while OCPP successes did not, so an OCPP-only site
with one faulted connector read 1%+. Only the driver registry's poll
loop counts now (telemetry CountPoll), a failed poll and a good one
alike; health records are not polls.

The count lives in memory, so after an update's restart it covered
minutes and a start-up burst of failed polls could read as trouble.
PollsLastDay now says how much of the day it covers, and the report
says none until that is six hours.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@frahlg
frahlg force-pushed the feat/fleet-report-health branch from 45a3e55 to 84da122 Compare October 24, 2026 07:49
frahlg and others added 3 commits October 24, 2026 10:09
The settings text and docs now say that a report sent through the relay
carries two sealed things beside it: a random number drawn new for each
report, and the UTC day it was sent. Settings shows both under each
report.

The hourly C8 upload now needs a given yes (Cloud under the current terms
or a local yes). A box that shares only by default sends no hour.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…report

The fleet report (ftw.fleet/2) adds four buckets: the slowest plan of the
last 24 hours, how many of those plans fell back, the share of driver
polls that failed, and the newest update of the last 7 days. Core reads
them from the plans it keeps (planner_diagnostics, PlannerDay), a new
24-hour count of polls in the telemetry store (PollsLastDay), and the
updater's status. Each bucket is at most four words wide and describes
the last day or week, not the house. A box that does not update itself
says none, so the install method does not become a field.

fleetwire accepts ftw.fleet/1 and ftw.fleet/2, and a day counts health
only from reports that carry it. Same switch as the rest of the report;
Settings names the new fields and shows them in the preview.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rs six hours

Review of #1821: OCPP errors fed the poll count through
RecordDriverError while OCPP successes did not, so an OCPP-only site
with one faulted connector read 1%+. Only the driver registry's poll
loop counts now (telemetry CountPoll), a failed poll and a good one
alike; health records are not polls.

The count lives in memory, so after an update's restart it covered
minutes and a start-up burst of failed polls could read as trouble.
PollsLastDay now says how much of the day it covers, and the report
says none until that is six hours.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@frahlg
frahlg force-pushed the feat/fleet-report-health branch from 84da122 to 6a04673 Compare October 24, 2026 08:14
@frahlg
frahlg changed the base branch from feat/anonymous-energy-ohttp to master October 24, 2026 08:23
…ealth

# Conflicts:
#	docs/architecture.md
#	go/cmd/ftw/fleet_ping.go
#	go/cmd/ftw/fleet_ping_test.go
#	go/cmd/ftw/main.go
#	go/internal/fleetping/fleetping_test.go
#	go/protocol/reportwire/report_test.go
#	web/settings/tabs/fleet.js
@frahlg
frahlg merged commit 2d7c8eb into master Oct 24, 2026
23 checks passed
@frahlg
frahlg deleted the feat/fleet-report-health branch November 11, 2026 09:17
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