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

@@ -36,6 +36,9 @@ type OffsiteEndedClaim struct {
SnapshotIDs []string `json:"snapshot_ids"`
}
// maxEndedClaimIDs is the most snapshot ids ONE window request carries (the hub reads as many: its maxEndedClaimIDs).
const maxEndedClaimIDs = 5000
// OffsiteEndedRefusal is one refusal the hub sent back, in its own words (logged).
type OffsiteEndedRefusal struct {
App string `json:"app"`
@@ -319,3 +322,21 @@ func (m *Manager) PendingOffsiteEnds() []settings.OffsiteEnd { return m.settings
func (m *Manager) OffsiteEndsHistory() []settings.OffsiteEndDone {
return m.settings.GetOffsiteEndsDone()
}
// boundEndedClaims cuts a request to at most limit snapshot ids in all (the hub reads no more). What is cut is asked
// again in a later window: the record stays while a copy of the app is in the store.
func boundEndedClaims(claims []OffsiteEndedClaim, limit int) []OffsiteEndedClaim {
left := limit
var out []OffsiteEndedClaim
for _, c := range claims {
if left <= 0 {
break
}
if len(c.SnapshotIDs) > left {
c.SnapshotIDs = c.SnapshotIDs[:left]
}
left -= len(c.SnapshotIDs)
out = append(out, c)
}
return out
}