Review fix 5: the box sends its end records only to a hub that says it reads them (version skew)
gates / gates (push) Successful in 32s

A new box with an older hub sent `ended` in the window request; that hub reads
4 KiB of it, decided the window on a wrong count, and the weekly clean-up
stalled.

- The box sends `ended` only when the hub's last window answer said
  accepts_ended (kept in settings, re-read from every answer, so a rolled-back
  hub stops getting them after one answer). Otherwise the request is the one
  every hub always got, and the ordinary clean-up runs.
- One request carries at most 5000 snapshot ids.

Tests seen red before the fix; 6 mutations seen red (felhom.eu
documentation/audits/build-release-4-2026-11-15/A/redproof-review-5.txt).

Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
admin committed 2026-11-15 15:05:38 +01:00
1 parent c7e4ec9b5e
commit c5acb91a44
10 files changed
+179 -5

No files matched your search

@@ -60,6 +60,10 @@ type OffsiteWindow struct {
// MaxRemove — and what it refused. Empty from a hub that does not know ended apps: then none is removed.
EndedAllowed []string
EndedRefused []OffsiteEndedRefusal
// AcceptsEnded: this hub said, in this answer, that it reads `ended` in a window request (the hub's
// `accepts_ended`; review of 2026-11-15, version skew). An older hub does not say it, and then the box sends it
// no end records: that hub reads only 4 KiB of the request and would decide the window on a wrong count.
AcceptsEnded bool
}
// OffsiteWindowResult is what the box reports when it is done (the hub closes the window on it).
@@ -238,11 +242,23 @@ func (m *Manager) offsiteWindowRetention(ctx context.Context, base, env []string
due := dueOffsiteEnds(m.settings.GetOffsiteEnds(), m.now(), m.offsiteEndLiving)
m.dropEndsWithNoCopies(snaps, due)
claims, candidate := endedCandidates(snaps, due)
// VERSION SKEW (review of 2026-11-15): the end records go ONLY to a hub that said, in its last window answer,
// that it reads them. An older hub reads 4 KiB of the request; a larger one made it open the window on a wrong
// count, and the weekly clean-up stalled. A hub that has not said it gets the request it always got.
if len(claims) > 0 && !m.settings.GetOffsiteHubAcceptsEnded() {
m.logger.Printf("[INFO] [offbox] %d removed app(s) are due, but the hub has not said that it reads end records (an older hub) — none is sent, nothing of them is removed; the ordinary clean-up goes on", len(claims))
claims, candidate = nil, map[string]bool{}
}
claims = boundEndedClaims(claims, maxEndedClaimIDs)
w, err := m.offsiteWindow.Open(ctx, len(snaps), claims)
if err != nil {
m.logger.Printf("[WARN] [offbox] retention skipped (%s): asking the hub for a window failed: %v", why, err)
return
}
// Remember what THIS answer said (granted or not): the next request follows it.
if serr := m.settings.SetOffsiteHubAcceptsEnded(w.AcceptsEnded); serr != nil {
m.logger.Printf("[WARN] [offbox] the hub's answer about end records could not be saved: %v", serr)
}
if !w.Granted {
m.logger.Printf("[INFO] [offbox] retention skipped (%s): no clean-up window now (%s) — nothing deleted (decision 68)", why, w.Reason)
return