H-A-771 unchanged-no-backup: back up a data module before its apply only when its move changed (issue 1984)

On ace at 03:40:55 the node-engine backed up lidarr (5.6 GB) for a move whose one difference was
env.MESH_FINGERPRINT, judged unchanged; the backup ran past its 10 minutes, lidarr was held, the operator
was asked, and the agent's loop stood still for 10 minutes. A move judged unchanged changes nothing of
the module, so it needs no backup.

- The apply backs a data module up only when the judge finds the move changed (any judgement but
  unchanged), or when the want carries the operator's answer again.
- The judgement compares the composition to what the machine applied (this engine's last apply, else
  the applied store's composition read at the start), never to a have, which in issue 1585's shape
  names a held composition not yet applied; with neither, the move is changed.
- A module held for a failed backup of a move judged unchanged has its hold ended at the engine's
  start, said in the journal, and is applied with no backup; the assigner takes its ask back as stale
  once the have runs.

Builds: design 47 H2 H-A-771, H-A-772 (1), (2)
This commit is contained in:
2026-11-26 04:10:26 +01:00
parent b4a9052669
commit 50dffe299f
2 changed files with 162 additions and 37 deletions
+41 -3
View File
@@ -274,6 +274,10 @@ type Agent struct {
// composition, read once at the start (loadHad): what runs of a module the agent has not taken yet, ahead of the kept
// declaration (issue 924).
had map[string]compNow
// appliedKept is, for each module, the composition the engine's applied store kept at the start (loadApplied), as the
// store has it, never replaced by a have: with applied, what the machine applied, which the judgement of a move before
// its backup compares to (design 47 H2 H-A-771, H-A-772 (1)).
appliedKept map[string]compNow
// keptData is, for each module of the kept declaration whose manifest could be read, whether it declares data
// (Env.HoldsData): the Data of what runs of it from the kept declaration.
keptData map[string]bool
@@ -362,7 +366,7 @@ func New(env Env) *Agent {
if env.Say == nil {
env.Say = func(string) {}
}
return &Agent{env: env, wants: map[string]wantNow{}, comps: map[string]compNow{}, running: map[string]nodeengine.HaveByNodeModuleValue{}, applied: map[string]compNow{}, had: map[string]compNow{}, keptData: map[string]bool{},
return &Agent{env: env, wants: map[string]wantNow{}, comps: map[string]compNow{}, running: map[string]nodeengine.HaveByNodeModuleValue{}, applied: map[string]compNow{}, had: map[string]compNow{}, appliedKept: map[string]compNow{}, keptData: map[string]bool{},
attempt: map[string]attempt{}, checked: map[string]bool{}, prior: map[string]bool{}, said: map[string]string{}, waited: map[string]string{}, notComposed: map[string]notComposedMark{},
pulls: map[string]*pullWait{}, settledAt: map[string]time.Time{}, settledSeq: map[string]int{},
retry: make(chan []string, 8), reconcile: make(chan []string, 64), failedAgain: make(chan string, 8), tries: map[string]int{}, again: make(chan againAsk, 64),
@@ -1338,6 +1342,7 @@ func (a *Agent) loadApplied(ctx context.Context) {
}
a.mu.Lock()
a.had[m] = compNow{Raw: kept[m], C: c, Dig: dig}
a.appliedKept[m] = a.had[m]
a.mu.Unlock()
switch {
case unread:
@@ -1828,6 +1833,17 @@ func (a *Agent) baseline(ctx context.Context, module string, w wantNow, comp com
h.Wait = nil
a.writeHave(ctx, h)
}
if h.Phase == string(nodeengineclient.PhaseHeld) && !judgedAgain(h) && recoveryCause(h) == recoveryNone &&
!a.moveChanged(module, comp) {
// Held for a failed backup of a move the judge finds unchanged (lidarr on ace, 2026-11-26 03:50): a backup
// H-A-771 no longer asks, so it is applied with no backup and its hold ends, said here; its ask is the
// assigner's to take back, as a stale ask is, once its have runs (design 47 H2 H-A-772 (2)).
a.mu.Lock()
a.sayOnce("unheld:"+module+":"+comp.Dig, fmt.Sprintf("%s's hold for a failed backup (%s) ends at this start: its "+
"move to %s is judged unchanged, so it is applied with no backup", module, h.Detail, short(comp.Dig)))
a.mu.Unlock()
return false
}
if h.Phase == string(nodeengineclient.PhaseHeld) && !judgedAgain(h) {
// Held for a failed backup, and the operator's answer is still to come: the hold is kept, nothing is
// backed up again or applied, and the next revision of the want is the answer (ADR 0568 §4). Said, so
@@ -1927,8 +1943,12 @@ func (a *Agent) apply(ctx context.Context, module string, w wantNow, comp compNo
}
// A data module is backed up before a new composition of it moves (ADR 0429 §14), unless the want says to go on
// without one (ADR 0539 §16).
if comp.C.Data && ranBefore && a.env.Backup != nil && w.Want.Backup != meshwants.WantsByWantNodeModuleValueBackupSkip {
// without one (ADR 0539 §16), and only when the judge finds the move from what the machine applied changed: a move
// judged unchanged (its one difference env.MESH_FINGERPRINT) changes nothing of the module, so it applies with no
// backup, no hold and no ask (design 47 H2 H-A-771). The operator's answer again backs it up whatever the judgement
// says (H-A-772 (1)).
if comp.C.Data && ranBefore && a.env.Backup != nil && w.Want.Backup != meshwants.WantsByWantNodeModuleValueBackupSkip &&
(w.Want.Backup == meshwants.WantsByWantNodeModuleValueBackupAgain || a.moveChanged(module, comp)) {
// What runs, read before the have says backing-up: a module known only from its have (a.prior) has no running
// entry, and its held have kept naming nothing (postgres on novox, 2026-10-31), as the not-composed mark keeps it.
a.mu.Lock()
@@ -2093,6 +2113,7 @@ func (a *Agent) remove(ctx context.Context, module string, w wantNow) {
delete(a.attempt, module)
delete(a.pulls, module)
delete(a.had, module)
delete(a.appliedKept, module)
a.running[module] = nodeengine.HaveByNodeModuleValue{Phase: nodeengineclient.PhaseRemoved}
a.mu.Unlock()
if a.env.Applied != nil {
@@ -2225,6 +2246,23 @@ func (a *Agent) waitsForYes(ctx context.Context, module string, w wantNow, comp
return true
}
// moveChanged says the judge finds moving module from what the machine applied to comp changed: any judgement but
// unchanged (design 47 H2 H-A-771). What the machine applied is the composition this engine last applied it from, else the
// one its applied store kept at the start, never a have, which may name a held composition not yet applied (H-A-772 (1),
// issue 1585's shape); a module with neither cannot be judged, and is changed. Called without a.mu held.
func (a *Agent) moveChanged(module string, comp compNow) bool {
a.mu.Lock()
from, known := a.applied[module]
if !known || from.Err != nil {
from, known = a.appliedKept[module]
}
a.mu.Unlock()
if !known {
return true
}
return judge.JudgeMove(&from.C, comp.C).Judgement != judge.JudgedUnchanged
}
// buildAlone says a move of module from what runs to the build want changes the build alone (ADR 0601 §1): another build than
// the one it runs, and the build it runs composed with today's settings and secrets is the composition it runs. Anything it
// cannot tell is no: the move is then asked of a person.