hub: review fix 1 — a box that lies about its app list cannot have the store agreed in one window unseen (D84 narrowed)

The hub's 30-day check rests on the box's own reports: a box could name an app
that never existed, or stop listing a living one, wait 30 days, and get every
snapshot agreed beside the cap, with no operator signal.

- One window agrees to at most the size of its own cap, from the hub's OWN
  count of the store; the oldest files first; the rest waits for the next
  window. A narrowing of D84, decided by CC unattended — the operator may
  reverse it (07 §8.2f holds the question, both options and their cost).
- offsite_end_claim_unseen (warning, mailed, operator-only): a box first names
  an app the hub never saw installed — once per household and app, at most 8
  per household, 30 days before anything can be agreed.
- offsite_ended_large_agreement (warning, mailed, operator-only): a request
  for more than half of the store waits one week; that window agrees to none.
- 07 §8.2f: the limit rewritten (no honest ended app is needed, only 30 days),
  what bounds it, what is still open. 08 §6.5: the two events.

Also carries the red-proof outputs of the controller's review fixes 2 and 3
(felhom-controller 3928c3d and the next commit).

Tests seen red on bb226f23; 15 mutations seen red (redproof-review-1.txt).

Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
admin committed 2026-11-15 14:41:58 +01:00
1 parent 90ba98b1a0
commit 875c339cf5
13 files changed
+839 -23

No files matched your search

+24 -1
View File
@@ -27,6 +27,7 @@ import (
"gitea.dooplex.hu/admin/felhom-hub/internal/mailhold"
"gitea.dooplex.hu/admin/felhom-hub/internal/mailrelay"
"gitea.dooplex.hu/admin/felhom-hub/internal/notify"
"gitea.dooplex.hu/admin/felhom-hub/internal/offsitekeys"
"gitea.dooplex.hu/admin/felhom-hub/internal/store"
)
@@ -3699,7 +3700,29 @@ func (h *Handler) noteAppList(customerID string, body []byte) {
claimed = append(claimed, e.App)
}
}
if err := h.store.NoteAppList(customerID, p.Stacks.Deployed, claimed, time.Now()); err != nil {
unseen, err := h.store.NoteAppListClaims(customerID, p.Stacks.Deployed, claimed, time.Now())
if err != nil {
h.logger.Printf("[WARN] [api] report from %s: the hub's own app record could not be updated: %v", customerID, err)
return
}
// Review of 2026-11-15: an app the hub NEVER saw in this box's app list, named in an end record for the first
// time. It is the honest shape of „removed before the hub kept this record” — and the shape of a box that invents
// an app to have its copies agreed. The operator hears it now, 30 days before the hub could agree to anything.
// The store returns each app once and at most a few per household; the name has the shape of an app name.
for _, u := range unseen {
day := u.AbsentSince.Add(offsitekeys.EndedAppAfter).UTC().Format("2006-01-02")
msg := fmt.Sprintf("Off-site: the box of %s holds an end record for the app %q (its off-site copies are to be deleted 30 days after „delete backup data”), "+
"and the hub never saw that app in this box's app list. The hub's own 30 days start now: from %s it would agree, in a clean-up window, "+
"to remove that app's off-site snapshots — at most the window's cap per week. If the household did not remove an app of that name, "+
"look at the box before that day and switch the weekly windows off for it.", customerID, u.App, day)
details, _ := json.Marshal(map[string]any{"subject": u.App, "app": u.App, "agrees_from": day})
h.logger.Printf("[WARN] [api] report from %s: an end record names %q, an app the hub never saw installed — operator told; the hub would agree from %s", customerID, u.App, day)
if _, eerr := h.store.SaveEvent(customerID, offsitekeys.EventEndedClaimUnseen, "warning", msg, string(details), "hub"); eerr != nil {
h.logger.Printf("[WARN] [api] %s event save FAILED for %s: %v", offsitekeys.EventEndedClaimUnseen, customerID, eerr)
continue // the audit row first: a mail without its event row lies
}
if h.dispatcher != nil {
go h.dispatcher.ProcessEvent(customerID, offsitekeys.EventEndedClaimUnseen, "warning", msg, string(details), "hub")
}
}
}