v0.306.0: R-570 — the off-site note decides on its kind only; the pre-0.251.0 text fallback is deleted
gates / gates (push) Successful in 1m14s

Fleet condition read on each box's settings.json 2026-10-10 (offbox.last_success ~02:16Z on 0.304.0).
Red-proof: the new no-kind row of TestR553_StaleNoteDecisionSurvivesWordingChange failed against the fallback.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
2026-10-10 15:08:42 +02:00
parent c255195e37
commit 9e5b88146e
9 changed files with 41 additions and 69 deletions
+3 -3
View File
@@ -1186,9 +1186,9 @@ func (m *Manager) runOffboxBackup(ctx context.Context, withProgress bool) error
// must not be told "nothing is selected".
// R-240: the sentence no longer opens with „Sikeres" — a run that covered nothing was
// congratulating the household on it. The verdict stays `ok` (an unconfigured selection is
// not a failure). Still a Hungarian LITERAL and still carrying the lowercase marker
// „nincs mentésre jelölt alkalmazás" (R-570: boxes with the older persisted text are
// recognised by those words). Pinned by TestR240_ZeroSelectionRunDoesNotSaySuccess.
// not a failure). Still a Hungarian LITERAL; since R-570 closed (2026-10-10) no reader depends
// on its words — the page decides on warnKind — so localisation may translate it.
// Pinned by TestR240_ZeroSelectionRunDoesNotSaySuccess.
if len(apps) == 0 && !runResult.sharesBackedUp {
warns = append(warns, "Ez a futás semmit nem mentett: nincs mentésre jelölt alkalmazás")
warnKind = OffboxWarnNoAppsSelected // R-553: the page reads this, not the sentence
@@ -156,37 +156,6 @@ func backupNoteHU(t *testing.T, key string) string {
return newNoteManager(t).note(key)
}
// TestR570SentenceStaysHungarian — the ONE saved note release C may not translate.
//
// A box upgraded to 0.251.0 carries the OLD persisted warning with no kind until its next off-site
// run rewrites it, so `offboxWarningDisplay` still falls back to a substring test on those words when
// the kind is empty (R-553's documented exception). Translating the PRODUCER while that fallback is
// load-bearing would strand exactly the boxes the fallback exists for: their stale note would stop
// being recognised and would keep telling a household that nothing is covered.
//
// **Delete this test when R-570 closes** — it is named for the row on purpose.
//
// RED-PROOF (REPORT): turn the producer into m.note("…") → this test fails naming the line.
func TestR570SentenceStaysHungarian(t *testing.T) {
const sentence = "Ez a futás semmit nem mentett: nincs mentésre jelölt alkalmazás"
src, err := os.ReadFile("offbox.go")
if err != nil {
t.Fatal(err)
}
if !strings.Contains(string(src), `"`+sentence+`"`) {
t.Errorf("the R-570 producer no longer writes %q as a literal — a box that has not run off-site "+
"since 0.251.0 carries that exact text with no kind, and offboxWarningDisplay finds it by "+
"those words. Translating it strands them. Close R-570 first.", sentence)
}
// And the sentence must not have quietly acquired a bundle key either: a key would render
// Hungarian today and something else the day someone adds a translation.
for _, k := range []string{"note.offsite.no_apps_selected", "note.offsite.zero_toggle"} {
if strings.Contains(string(src), k) {
t.Errorf("the R-570 producer now names a bundle key (%s) — same problem, one step further away", k)
}
}
}
// TestNoteHelpersAreNotCalledUnderTheSettingsLock — release C (R-557), and it is a REGRESSION test,
// not a precaution.
//
@@ -10,7 +10,7 @@ import (
// SUCCESSFUL right beside NOTHING SELECTED, the same shape as R-203/R-234 (a warning beside a success
// is read as a success). The consequence asserted through the real run: the verdict stays `ok` (an
// empty selection is not a failure), the note says plainly that the run saved nothing, it does NOT
// say „Sikeres", and it still carries the lowercase marker the R-570 legacy fallback reads.
// say „Sikeres", and it records its KIND (the page decides on the kind; R-570 removed the text fallback).
func TestR240_ZeroSelectionRunDoesNotSaySuccess(t *testing.T) {
m, sett := newOffboxManager(t)
m.SetOffboxRunner(func(_ context.Context, _ []string, args ...string) ([]byte, error) {
@@ -32,9 +32,6 @@ func TestR240_ZeroSelectionRunDoesNotSaySuccess(t *testing.T) {
if !strings.Contains(st.LastWarning, "semmit nem mentett") {
t.Errorf("R-240: the note does not say the run saved nothing: %q", st.LastWarning)
}
if !strings.Contains(st.LastWarning, "nincs mentésre jelölt alkalmazás") {
t.Errorf("the R-570 marker is gone from the note: %q", st.LastWarning)
}
if st.LastWarningKind != OffboxWarnNoAppsSelected {
t.Errorf("the kind is not recorded: %q", st.LastWarningKind)
}
+5 -17
View File
@@ -1055,13 +1055,7 @@ func (s *Server) backupsOffboxData(data map[string]interface{}, lang string) {
}
}
// offboxStaleWarningMarker is the substring the zero-toggled offbox run wrote into LastWarning before
// v0.251.0, when the run started recording a KIND beside it (R-553). It is kept ONLY to read boxes
// upgraded with that older text already persisted — see offboxWarningDisplay.
const (
offboxStaleWarningMarker = "nincs mentésre jelölt alkalmazás"
offboxSelectionChangedKey = "offbox.selection_changed"
)
const offboxSelectionChangedKey = "offbox.selection_changed"
// offboxWarningDisplay picks what the Távoli mentés page shows for the persisted
// Offbox.LastWarning. A zero-toggled run records "Sikeres — nincs mentésre jelölt
@@ -1069,13 +1063,10 @@ const (
// replace it with the honest "selection changed, the next run covers it" note.
// Pure display logic: the persisted LastWarning is never touched, and every other
// warning (quota, partial failure) passes through verbatim.
// R-553 — the decision is made on the KIND the run recorded, not on the words of the sentence.
// The one text test that remains runs ONLY when there is no kind, i.e. on a box whose last off-site
// run happened before v0.251.0 and whose persisted warning therefore predates kinds.
//
// R-553 legacy: remove after every fleet box has completed one off-site run on ≥ 0.251.0 (row R-570).
// Localisation slice 2 (R-557) must not translate the producer at backup/offbox.go until that row is
// closed — translating it while this fallback is still needed would strand exactly those boxes.
// R-553 — the decision is made on the KIND the run recorded, never on the words of the sentence.
// R-570 (2026-10-10): the legacy text test for pre-0.251.0 warnings is removed — every fleet box has
// completed an off-site run on ≥ 0.251.0, so every persisted warning carries its kind. Pinned by
// TestR553_StaleNoteDecisionSurvivesWordingChange (no kind → verbatim).
func (s *Server) offboxWarningDisplay(lastWarning, kind string, toggledCount int, lang string) string {
if toggledCount < 1 {
return lastWarning
@@ -1083,9 +1074,6 @@ func (s *Server) offboxWarningDisplay(lastWarning, kind string, toggledCount int
if kind == backup.OffboxWarnNoAppsSelected {
return s.msgLang(lang, offboxSelectionChangedKey)
}
if kind == "" && strings.Contains(lastWarning, offboxStaleWarningMarker) {
return s.msgLang(lang, offboxSelectionChangedKey)
}
return lastWarning
}
@@ -4,6 +4,7 @@ import (
"strings"
"testing"
"gitea.dooplex.hu/admin/felhom-controller/internal/backup"
"gitea.dooplex.hu/admin/felhom-controller/internal/settings"
)
@@ -13,8 +14,8 @@ import (
// COMPANION red-proof (recorded in REPORT): make offboxWarningDisplay return lastWarning
// unconditionally → TestOffboxWarningDisplay_Pick's 1-enabled case FAILS.
//
// R-553 (v0.251.0): these calls pass an EMPTY kind on purpose — they are now the LEGACY path, a box
// whose last off-site run predates kinds. The kind path is TestR553_StaleNoteDecisionSurvivesWordingChange.
// R-570 (2026-10-10): the legacy no-kind path is gone; these calls carry the kind the run records. The
// no-kind contract (verbatim) is pinned by TestR553_StaleNoteDecisionSurvivesWordingChange.
const staleZeroToggleWarning = "Sikeres — nincs mentésre jelölt alkalmazás volt a futáskor."
@@ -22,11 +23,11 @@ func TestOffboxWarningDisplay_Pick(t *testing.T) {
s, _, _ := newOffboxWebServer(t)
selectionChanged := s.msgLang("hu", offboxSelectionChangedKey)
// warning + ≥1 enabled → the replacement line
if got := s.offboxWarningDisplay(staleZeroToggleWarning, "", 1, "hu"); got != selectionChanged {
if got := s.offboxWarningDisplay(staleZeroToggleWarning, backup.OffboxWarnNoAppsSelected, 1, "hu"); got != selectionChanged {
t.Errorf("stale warning + 1 toggled: got %q, want the selection-changed line", got)
}
// warning + 0 enabled → the original line, verbatim (the v0.123.0 honesty stays)
if got := s.offboxWarningDisplay(staleZeroToggleWarning, "", 0, "hu"); got != staleZeroToggleWarning {
if got := s.offboxWarningDisplay(staleZeroToggleWarning, backup.OffboxWarnNoAppsSelected, 0, "hu"); got != staleZeroToggleWarning {
t.Errorf("stale warning + 0 toggled: got %q, want the original warning unchanged", got)
}
// any OTHER warning passes through regardless of toggles (quota, partial failure)
@@ -47,9 +48,9 @@ func TestOffboxWarningDisplay_RemotePageRender(t *testing.T) {
data := appRowSplitData()
data["Offbox"] = &settings.OffboxTarget{
Enabled: true, Host: "nas.local", LastStatus: "ok", EscrowState: "escrowed",
LastWarning: staleZeroToggleWarning,
LastWarning: staleZeroToggleWarning, LastWarningKind: backup.OffboxWarnNoAppsSelected,
}
data["OffboxWarningDisplay"] = s.offboxWarningDisplay(staleZeroToggleWarning, "", 1, "hu")
data["OffboxWarningDisplay"] = s.offboxWarningDisplay(staleZeroToggleWarning, backup.OffboxWarnNoAppsSelected, 1, "hu")
html := renderBackupPage(t, "backups_remote", data)
if !strings.Contains(html, selectionChanged) {
t.Error("selection-changed note missing with 1 app toggled")
@@ -64,9 +65,9 @@ func TestOffboxWarningDisplay_RemotePageRender(t *testing.T) {
data["OffboxToggledCount"] = 0
data["Offbox"] = &settings.OffboxTarget{
Enabled: true, Host: "nas.local", LastStatus: "ok", EscrowState: "escrowed",
LastWarning: staleZeroToggleWarning,
LastWarning: staleZeroToggleWarning, LastWarningKind: backup.OffboxWarnNoAppsSelected,
}
data["OffboxWarningDisplay"] = s.offboxWarningDisplay(staleZeroToggleWarning, "", 0, "hu")
data["OffboxWarningDisplay"] = s.offboxWarningDisplay(staleZeroToggleWarning, backup.OffboxWarnNoAppsSelected, 0, "hu")
html = renderBackupPage(t, "backups_remote", data)
if !strings.Contains(html, staleZeroToggleWarning) {
t.Error("0 toggled: the original run warning must render unchanged")
@@ -35,10 +35,12 @@ func TestR553_StaleNoteDecisionSurvivesWordingChange(t *testing.T) {
{"still nothing selected → the honest note stays", hu, backup.OffboxWarnNoAppsSelected, 0, hu},
{"a quota note passes through", "A tároló a keret 84%-át használja (42/50 GB).", "", 3,
"A tároló a keret 84%-át használja (42/50 GB)."},
// LEGACY: a box upgraded to v0.251.0 still carries the OLD text with no kind until its next
// off-site run rewrites it. Until then the text test is what it has.
{"legacy persisted text, no kind", hu, "", 1, selectionChanged},
{"legacy: any other text without a kind is shown verbatim", "Valami más történt.", "", 1, "Valami más történt."},
// R-570 (2026-10-10): the legacy text test is GONE. Every fleet box ran off-site on ≥ 0.251.0 (read on
// demo-hp, demo-felhom and Tester 1: last_success 2026-10-10 ~02:16Z, controller 0.304.0), so no box carries
// the old text without a kind. The decision is the kind and ONLY the kind: the same words with no kind are
// shown verbatim — the words never decide again (red against the fallback: it returned the replacement).
{"no kind: the words alone decide nothing", hu, "", 1, hu},
{"no kind: any other text is shown verbatim", "Valami más történt.", "", 1, "Valami más történt."},
}
for _, c := range cases {
if got := s.offboxWarningDisplay(c.warning, c.kind, c.toggled, "hu"); got != c.want {