member backups 2b: /fleet/backups shows incomplete evidence (review fixes)
Whole-branch review round 1 (CODEX-FINDINGS-2b-branch.md), three items: - P2: the record walk now uses provision.ListAllRecordsTolerantUnreadable (new, returns readAllRecords' skipped-host set) and a nonempty set makes the view incomplete, so a malformed or path-mismatched instance record no longer drops out of the counts under complete: true. - P2: the partial banner wins over the empty banner, so a partial walk before the first publication is not hidden. - P3: the partial banner uses the warning tone, as failed restores do. Wording unchanged; the build-failure banner keeps the negative tone. Census: internal/provision envelope re-pinned in the member-backups-2b overlay, no unit changes; claims file gains one comment line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 files changed,
+113
−9
docs/superpowers/notes/census-claims-member-backups-2b.tsv+1 −0internal/console/fleetbackups.go+4 −2internal/console/fleetbackups_page.go+7 −5internal/console/fleetbackups_page_test.go+61 −1internal/console/fleetbackups_test.go+29 −0internal/provision/reconcile.go+10 −0internal/provision/testdata/plan14-root-reads-member-backups-2b.tsv+1 −1
diff --git a/docs/superpowers/notes/census-claims-member-backups-2b.tsv b/docs/superpowers/notes/census-claims-member-backups-2b.tsv| index 7ced3ac08..1f49e4f25 100644 |
| --- a/docs/superpowers/notes/census-claims-member-backups-2b.tsv |
| +++ b/docs/superpowers/notes/census-claims-member-backups-2b.tsv |
| @@ -14,3 +14,4 @@ |
| # internal/backupswords (display.go, words.go): pure formatting. Display gains TestInput and the test tile |
| # fields (value, detail, note, time, gap), computed from its input and the clock; words.go adds the approved |
| # strings. No I/O of any kind. |
| +# Branch fix round 1 (2026-11-13): internal/provision envelope re-pinned, no unit changes, no new read. reconcile.go adds ListAllRecordsTolerantUnreadable, which returns readAllRecords(ctx, s, false) whole (the skipped-host set ListAllRecordsTolerant discards); same walk, same reads, no write. Its only caller is the console's /fleet/backups view. |
diff --git a/internal/console/fleetbackups.go b/internal/console/fleetbackups.go| index d3035c3f7..967fcdd70 100644 |
| --- a/internal/console/fleetbackups.go |
| +++ b/internal/console/fleetbackups.go |
| @@ -218,11 +218,13 @@ func (s *Server) buildFleetBackups(ctx context.Context, now time.Time) (fleetBac |
| v.NoRecords = v.Loaded && len(r.Boxes()) == 0 |
| src, _ := s.recordWalkStore(ctx, s.cfg.Releases) |
| - recs, complete, err := provision.ListAllRecordsTolerant(ctx, src) |
| + // A record that read but would not decode, or named another host, is |
| + // out of the counts and the denominator: the view is incomplete. |
| + recs, complete, unreadable, err := provision.ListAllRecordsTolerantUnreadable(ctx, src) |
| if err != nil { |
| return fleetBackupsView{}, err |
| } |
| - if !complete { |
| + if !complete || len(unreadable) > 0 { |
| v.Complete = false |
| } |
diff --git a/internal/console/fleetbackups_page.go b/internal/console/fleetbackups_page.go| index ac93d3d29..fdeea8ccd 100644 |
| --- a/internal/console/fleetbackups_page.go |
| +++ b/internal/console/fleetbackups_page.go |
| @@ -135,18 +135,20 @@ type fleetBackupsPageClass struct { |
| func (*fleetBackupsPage) W() *fleetBackupsWords { return &fbCopy } |
| // fleetBackupsPageOf is the page for v. Banners: not loaded alone, else |
| -// no records, else partial; one line at most. No records wins over |
| -// partial because "some test records couldn't be read" would be untrue |
| -// when the reader found none. |
| +// partial, else no records; one line at most. Partial wins over no |
| +// records: a walk that missed something leaves the counts low even before |
| +// the first publication, and the empty state would hide that. Partial is |
| +// in the warning tone, as failed restores are: it says the counts may be |
| +// low, not that anything failed. |
| func fleetBackupsPageOf(v fleetBackupsView) *fleetBackupsPage { |
| p := &fleetBackupsPage{} |
| switch { |
| case !v.Loaded: |
| p.Banner, p.BannerIcon = fbCopy.BannerNotLoaded, "info" |
| + case !v.Complete: |
| + p.Banner, p.BannerTone, p.BannerIcon = fbCopy.BannerPartial, "warning", "triangle-alert" |
| case v.NoRecords: |
| p.Banner, p.BannerIcon = fbCopy.BannerEmpty, "info" |
| - case !v.Complete: |
| - p.Banner, p.BannerTone, p.BannerIcon = fbCopy.BannerPartial, "negative", "triangle-alert" |
| } |
| now := v.GeneratedAt |
| for _, g := range v.Regions { |
diff --git a/internal/console/fleetbackups_page_test.go b/internal/console/fleetbackups_page_test.go| index 4cb16af35..3339258b4 100644 |
| --- a/internal/console/fleetbackups_page_test.go |
| +++ b/internal/console/fleetbackups_page_test.go |
| @@ -221,7 +221,7 @@ func TestFleetBackupsPageStates(t *testing.T) { |
| view: fleetBackupsView{GeneratedAt: fbPageNow, Loaded: true, Complete: false, Regions: []fleetBackupsRegion{partialRegion}}, |
| banner: bannerPartial, |
| want: []string{ |
| - `<div rst-callout rst-tone="negative">`, |
| + `<div rst-callout rst-tone="warning">`, |
| `<span rst-stat-label>Oldest test</span><span rst-stat-num>26 hours ago</span><span rst-stat-note>Wed 11 Nov</span>`, |
| "<h3 co-h3>Boxes to look at</h3>", |
| `<td><code>box-3</code></td><td><time datetime="2026-11-10T23:00:00Z">40 hours ago</time></td><td><span rst-status rst-tone="warning">No recent test</span> <span rst-status rst-tone="warning">Record unreadable</span></td>`, |
| @@ -255,6 +255,18 @@ func TestFleetBackupsPageStates(t *testing.T) { |
| `<td co-wrap>Tests refused: storage prefix differs</td><td>0</td>`, |
| }, |
| }, |
| + { |
| + // Before the first publication, a walk that missed something: |
| + // the counts may be low, and saying so wins over the empty |
| + // state. |
| + name: "no records and partial", |
| + view: fleetBackupsView{GeneratedAt: fbPageNow, Loaded: true, Complete: false, NoRecords: true, Regions: []fleetBackupsRegion{emptyRegion}}, |
| + banner: bannerPartial, |
| + want: []string{ |
| + `<div rst-callout rst-tone="warning">`, |
| + `<span rst-stat-label>Never tested</span><span rst-stat-num>44</span>`, |
| + }, |
| + }, |
| } |
| for _, tc := range cases { |
| t.Run(tc.name, func(t *testing.T) { |
| @@ -357,6 +369,54 @@ func TestAPISystemBackupsGate(t *testing.T) { |
| } |
| } |
| +// TestFleetBackupsSkippedRecordDoors: an instance record that reads but |
| +// will not decode, or whose body names another host, makes both doors say |
| +// the view is incomplete: the JSON's complete is false and the page shows |
| +// the partial banner, in the warning tone, not the empty one, though no |
| +// box has published a restore test yet. |
| +func TestFleetBackupsSkippedRecordDoors(t *testing.T) { |
| + const ( |
| + bannerPartial = "Some test records couldn't be read, so these counts may be low." |
| + bannerEmpty = "No box has published a restore test yet." |
| + ) |
| + mismatched, err := json.Marshal(provision.Record{Account: release.OpsAccount, App: "kass", Host: "elsewhere.go.tito.io"}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for name, body := range map[string][]byte{"malformed": []byte("{"), "path-mismatched": mismatched} { |
| + t.Run(name, func(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + fbWorld(t, fx) |
| + if _, err := fx.rel.Put(context.Background(), provision.RecordKey(release.OpsAccount, "kass", "bad.go.tito.io"), body, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + c := signInOperator(t, fx) |
| + tok := cliToken(t, fx, "paul@keymail.dev", "code-fb-skipped") |
| + |
| + res := cliGet(t, fx.ts.URL+"/api/cli/system/backups", tok) |
| + var raw map[string]any |
| + err := json.NewDecoder(res.Body).Decode(&raw) |
| + res.Body.Close() |
| + if res.StatusCode != http.StatusOK || err != nil { |
| + t.Fatalf("JSON = %d %v", res.StatusCode, err) |
| + } |
| + if raw["complete"] != false { |
| + t.Fatalf("JSON complete = %v, want false", raw["complete"]) |
| + } |
| + |
| + st, _, page := get(t, c, fx.ts.URL+"/fleet/backups") |
| + if st != http.StatusOK { |
| + t.Fatalf("page = %d", st) |
| + } |
| + main := fbMainOf(t, page) |
| + if strings.Count(main, bannerPartial) != 1 || strings.Contains(main, bannerEmpty) || |
| + !strings.Contains(main, `<div rst-callout rst-tone="warning">`) { |
| + t.Fatalf("want the partial banner alone, in the warning tone:\n%s", main) |
| + } |
| + }) |
| + } |
| +} |
| + |
| func cliGet(t *testing.T, u, bearer string) *http.Response { |
| t.Helper() |
| req, err := http.NewRequest(http.MethodGet, u, nil) |
diff --git a/internal/console/fleetbackups_test.go b/internal/console/fleetbackups_test.go| index 766d50682..1439b94b6 100644 |
| --- a/internal/console/fleetbackups_test.go |
| +++ b/internal/console/fleetbackups_test.go |
| @@ -597,6 +597,35 @@ func TestFleetBackupsPartial(t *testing.T) { |
| t.Fatalf("view %+v, want incomplete with the readable records counted", v) |
| } |
| }) |
| + // An instance record that reads but will not decode, or whose body |
| + // names another host, is skipped by the walk: it drops out of the |
| + // counts and the denominator, so the view must not say complete. |
| + for name, body := range map[string][]byte{ |
| + "malformed instance record": []byte("{"), |
| + "path-mismatched instance record": fbRecordBody(t, provision.Record{Account: release.OpsAccount, App: "shop", Host: fbHost("elsewhere")}), |
| + } { |
| + t.Run(name, func(t *testing.T) { |
| + f := setup(t) |
| + if _, err := f.raw.Put(f.ctx, provision.RecordKey(release.OpsAccount, "shop", fbHost("bad")), body, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + f.load() |
| + v := f.view() |
| + if home := fbRegion(t, v, ""); v.Complete || home.Classes.Replicated != 1 || home.Tests.PassedWeek != 1 { |
| + t.Fatalf("complete %v, home %+v, want incomplete with the readable records counted", v.Complete, home) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// fbRecordBody is rec as stored. |
| +func fbRecordBody(t *testing.T, rec provision.Record) []byte { |
| + t.Helper() |
| + body, err := json.Marshal(rec) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return body |
| } |
| // TestFleetBackupsMemoised: two calls within five minutes build once; one |
diff --git a/internal/provision/reconcile.go b/internal/provision/reconcile.go| index 72e988df7..239d72bd7 100644 |
| --- a/internal/provision/reconcile.go |
| +++ b/internal/provision/reconcile.go |
| @@ -3255,6 +3255,16 @@ func ListAllRecordsTolerant(ctx context.Context, s release.Store) (recs []Record |
| return recs, complete, err |
| } |
| +// ListAllRecordsTolerantUnreadable is ListAllRecordsTolerant with the hosts |
| +// it skipped because their record read but did not decode or disagreed |
| +// with its own path (keyed by the host in the path), which leave complete |
| +// true. A caller reporting counts over the records (the operator backups |
| +// view) treats a nonempty unreadable as incomplete. unreadable is non-nil |
| +// whenever err is nil. |
| +func ListAllRecordsTolerantUnreadable(ctx context.Context, s release.Store) (recs []Record, complete bool, unreadable map[string]bool, err error) { |
| + return readAllRecords(ctx, s, false) |
| +} |
| + |
| // readAllRecords is both: strict fails on any read failure, as |
| // ListAllRecords documents; tolerant logs it, skips what it could not read |
| // and reports complete false. In both modes unreadable holds the path host |
diff --git a/internal/provision/testdata/plan14-root-reads-member-backups-2b.tsv b/internal/provision/testdata/plan14-root-reads-member-backups-2b.tsv| index b76dafda7..4026a44e9 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-member-backups-2b.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-member-backups-2b.tsv |
| @@ -2,4 +2,4 @@ |
| # 0 body, 0 sites, 3 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| @coverage . c74a47076c527cb99e8daca60c5bf7b67ed6ca7fd5483a63e68f299ebbeffebb |
| @coverage internal/backupswords 33d98350e8cb59a49548cb8e31221ee9ebc670e936f51cee7db167cb63f899a3 |
| -@coverage internal/provision a71993fde3214692c28817fd9f1f3e611fc806279035989b361b4230258eb367 |
| +@coverage internal/provision 40ef72c9db55952d7c54ce96a296d70ac224b6cec6963a6dcd36c0f631c684e2 |