The off-site copies of a removed app end 30 days after „delete backup data” — the box's half (felhom.eu R-1374 part 1; D72, D84)
gates / gates (push) Successful in 41s

Built, not released; no box has run it. felhom.eu `07-backup-architecture.md` §8.2f.
It does nothing without a hub that knows it: an older hub agrees to no id.

- The record: settings `offsite_ends` {app, removed_at, ends_at}. One writer
  (backup.StartOffsiteEnd), called by a removal only with „delete backup data”
  and by „Törlés 30 nap múlva” on the restore page. A second press changes
  nothing. No record, no deletion. Only on the hub-provisioned tier.
- The date is on the remove dialog before the press; the restore page shows
  „Törlésre kijelölve …” with „Mégis megtartom”, and one history line per
  carried-out end. An install of the same app deletes the record.
- The weekly window: after the guard has passed the policy's plan under the cap
  as before, it adds the snapshots whose app tags are ALL due records, that the
  hub agreed to and the box named in the same request; the result names them
  apart (removed_for_ended_apps). `_shares`, the box's own stacks and an
  installed app are never due.
- The report carries the pending records; the household gets one mail per
  press (offsite_end_scheduled), in both languages.

MinAgent unchanged (0.158.1). 143 parity fixtures gained the dialog's one new
script line (patched, not regenerated); one new parity case.
Tests TestD72_*, TestD84_*; 56 mutations seen red
(felhom.eu documentation/audits/build-release-4-2026-11-15/A/redproof-ctrl-*.txt).

Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
admin committed 2026-11-15 14:09:47 +01:00
1 parent 591195fadd
commit f628cb5082
177 files changed
+3705 -164

No files matched your search

@@ -0,0 +1,71 @@
package stacks
import (
"io"
"log"
"path/filepath"
"testing"
"time"
"gitea.dooplex.hu/admin/felhom-controller/internal/settings"
)
// D72 (`09` §3 decision 292; `07-backup-architecture.md` §8.2f, the edge-case table): AN INSTALL OF THE SAME APP
// DELETES ITS OFF-SITE END RECORD — „the household uses the app; deleting its history a few days later would be a
// surprise”. This is the wrong case „an ended app that is installed again the day before the window”, on the box:
// the record is gone at the install, so the window finds nothing to claim. Through the real DeployStack (the
// composeExecFn seam and gateManager's docker stub: nothing reaches Docker). Another app's record is not touched.
// RED-PROOF: felhom.eu/documentation/audits/build-release-4-2026-11-15/A/redproof-ctrl-press.txt.
func TestD72_AnInstallDeletesTheEndRecord(t *testing.T) {
m := gateManager(t, gatedYml)
sett, err := settings.Load(filepath.Join(t.TempDir(), "settings.json"), log.New(io.Discard, "", 0))
if err != nil {
t.Fatal(err)
}
m.SetMigrationDeps(sett, func() bool { return false })
removed := time.Now().Add(-29 * 24 * time.Hour) // the window would run tomorrow
if _, _, err := sett.StartOffsiteEnd("gapp", removed); err != nil {
t.Fatal(err)
}
other, _, err := sett.StartOffsiteEnd("vikunja", removed)
if err != nil {
t.Fatal(err)
}
m.composeExecFn = func(string, map[string]string, ...string) (string, error) { return "", nil }
done := make(chan bool, 1)
m.SetDeployDoneHook(func(_ string, ok bool, _ string) { done <- ok })
if _, err := m.DeployStack(DeployRequest{StackName: "gapp", Values: map[string]string{}}); err != nil {
t.Fatal(err)
}
select {
case <-done:
case <-time.After(20 * time.Second):
t.Fatal("the deploy never ended")
}
if rec, ok := sett.GetOffsiteEnd("gapp"); ok {
t.Fatalf("the app is installed again and its off-site end record is still there (%+v) — the next window would delete a living app's history", rec)
}
if got, ok := sett.GetOffsiteEnd("vikunja"); !ok || got != other {
t.Fatalf("another app's record changed at this install: %+v ok=%v", got, ok)
}
}
// A deploy that is REFUSED changes nothing: the record stays.
func TestD72_ARefusedInstallKeepsTheEndRecord(t *testing.T) {
m := gateManager(t, gatedYml)
sett, err := settings.Load(filepath.Join(t.TempDir(), "settings.json"), log.New(io.Discard, "", 0))
if err != nil {
t.Fatal(err)
}
m.SetMigrationDeps(sett, func() bool { return false })
rec, _, _ := sett.StartOffsiteEnd("gapp", time.Now())
m.mu.Lock()
m.stacks["gapp"].Deployed = true // „already deployed” is refused before anything is written
m.mu.Unlock()
if _, err := m.DeployStack(DeployRequest{StackName: "gapp", Values: map[string]string{}}); err == nil {
t.Fatal("fixture: the deploy was not refused")
}
if got, ok := sett.GetOffsiteEnd("gapp"); !ok || got != rec {
t.Fatalf("a refused deploy deleted or changed the record: %+v ok=%v", got, ok)
}
}
+4
View File
@@ -205,6 +205,10 @@ type BackupDataResponse struct {
Stack string `json:"stack"`
BackupPaths []HDDPath `json:"backup_paths"` // reuses HDDPath (path, size, exists)
HasBackups bool `json:"has_backups"`
// OffsiteEndDate (D72, `07` §8.2f) is the day this app's OFF-SITE copies would be deleted if the household
// pressed „delete backup data” now — written in the household's date form. Empty when the box has no
// hub-provisioned off-site tier: then the dialog says nothing about off-site copies. Set by the API handler.
OffsiteEndDate string `json:"offsite_end_date,omitempty"`
}
// HDDDataResponse holds information about HDD data associated with a stack.
+8
View File
@@ -565,6 +565,14 @@ func (m *Manager) DeployStack(req DeployRequest) (string, error) {
clearDeploying()
return "", fmt.Errorf("saving app config: %w", err)
}
// D72 (`07` §8.2f): an install of the same app ENDS its pending off-site end record — the household uses the
// app again, and its old copies are restore sources again. Here, at the first write of the install: a deploy
// that was refused above changed nothing. Pinned by TestD72_AnInstallDeletesTheEndRecord.
if m.settings != nil {
if _, cerr := m.settings.CancelOffsiteEnd(req.StackName, "the app is installed again"); cerr != nil {
m.logger.Printf("[WARN] [stacks] deploy %s: its off-site end record could not be deleted (%v) — the clean-up window skips an installed app anyway", req.StackName, cerr)
}
}
// Debug: log final env var keys (not values)
envKeys := make([]string, 0, len(env))