agent: a held have is judged again at a start from its wait's reason, not from its detail's opening words (A-453, §541)

Builds: design 47 G A-453, §541, A-484
This commit is contained in:
2026-11-18 00:34:36 +01:00
parent d1768241dc
commit 0cc1728a04
3 changed files with 35 additions and 16 deletions
+2 -2
View File
@@ -1539,7 +1539,7 @@ func (a *Agent) baseline(ctx context.Context, module string, w wantNow, comp com
a.mu.Unlock()
return false
}
if h.Phase == string(nodeengineclient.PhaseHeld) && !judgedAgain(h.Detail) {
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
// why it holds is read from the journal and not guessed (issue 1585: this branch was silent).
@@ -1643,7 +1643,7 @@ func (a *Agent) apply(ctx context.Context, module string, w wantNow, comp compNo
}
a.env.Say(fmt.Sprintf("%s is held: %s", module, words))
a.writeHave(ctx, Have{Module: module, FP: prev.Fp, Composed: prev.Composed, Phase: string(nodeengineclient.PhaseHeld),
Detail: words, Wait: a.composeWait("parts-differ", words)})
Detail: words, Wait: a.composeWait(strings.TrimSuffix(PartsDiffer, ":"), words)})
return
}
+19 -8
View File
@@ -859,20 +859,28 @@ func TestADataModuleIsBackedUpFirstAndHeldWhenItFails(t *testing.T) {
detail, backup string
backups, applied int
phase string
namesNothing bool // the have names no fp and no composition
namesNothing bool // the have names no fp and no composition
reason string // the reason of the wait the have carries; empty: it carries none
}{
{BackupInterrupted, meshwants.WantsByWantNodeModuleValueBackupAgain, 1, 1, nodeengineclient.PhaseRunning, false},
{BackupInterrupted, meshwants.WantsByWantNodeModuleValueBackupAgain, 1, 1, nodeengineclient.PhaseRunning, false, ""},
// novox's postgres: its held have, written before mesh-host #189, names nothing it runs.
{BackupInterrupted, "", 1, 1, nodeengineclient.PhaseRunning, true},
{BackupInterrupted, "", 1, 1, nodeengineclient.PhaseRunning, true, ""},
// A backup that failed, and the want carries the operator's answer, written before this start (nats on novox,
// 2026-11-04, issue 1585): again backs it up and applies, skip applies without one; no answer keeps the hold.
{"restic: the repository is locked", meshwants.WantsByWantNodeModuleValueBackupAgain, 1, 1, nodeengineclient.PhaseRunning, false},
{"restic: the repository is locked", meshwants.WantsByWantNodeModuleValueBackupSkip, 0, 1, nodeengineclient.PhaseRunning, false},
{"restic: the repository is locked", "", 0, 0, nodeengineclient.PhaseHeld, false},
{"restic: the repository is locked", meshwants.WantsByWantNodeModuleValueBackupAgain, 1, 1, nodeengineclient.PhaseRunning, false, ""},
{"restic: the repository is locked", meshwants.WantsByWantNodeModuleValueBackupSkip, 0, 1, nodeengineclient.PhaseRunning, false, ""},
{"restic: the repository is locked", "", 0, 0, nodeengineclient.PhaseHeld, false, ""},
// A hold the node-engine judges again (novox's indexer, 2026-11-16): its parts differed or its entry was not
// held, which no answer of the operator's releases; at a start it is judged again, here backed up and applied.
{PartsDiffer + " fetched and not in the want's parts: sha256:a03131c6", "", 1, 1, nodeengineclient.PhaseRunning, false},
{EntryMissing + " the catalog half holds no entry of the build", "", 1, 1, nodeengineclient.PhaseRunning, false},
{PartsDiffer + " fetched and not in the want's parts: sha256:a03131c6", "", 1, 1, nodeengineclient.PhaseRunning, false, "parts-differ"},
{EntryMissing + " the catalog half holds no entry of the build", "", 1, 1, nodeengineclient.PhaseRunning, false, "entry-missing"},
// g14's feh, 2026-11-18: the kept step's hold opens "whether ..." and says its reason in its wait; the words decide nothing.
{"whether feh's kept data changes form is not known", "", 1, 1, nodeengineclient.PhaseRunning, false, "entry-missing"},
{EntryAsked + " the entry is asked", "", 1, 1, nodeengineclient.PhaseRunning, false, "entry-asked"},
// Opening words alone are no reason: a failed backup's detail that opens with them waits for the answer.
{PartsDiffer + " as the words of a failed backup", "", 0, 0, nodeengineclient.PhaseHeld, false, ""},
// A restore point not taken waits for the answer, its reason being its words.
{"the restore point of db's data was not taken", "", 0, 0, nodeengineclient.PhaseHeld, false, "the restore point of db's data was not taken"},
} {
r := newBed(t)
r.comps.before(ck1, craw1)
@@ -880,6 +888,9 @@ func TestADataModuleIsBackedUpFirstAndHeldWhenItFails(t *testing.T) {
wk, wraw := wantFor(t, "db", fp2, dig2, row.backup)
r.wants.before(wk, wraw)
held := Have{Module: "db", FP: fp1, Composed: dig1, Phase: string(nodeengineclient.PhaseHeld), Detail: row.detail}
if row.reason != "" {
held.Wait = &nodeengine.Wait{Owner: nodeengine.Seat, Step: nodeengine.WaitStepCompose, Reason: row.reason, Words: row.detail}
}
if row.namesNothing {
held.FP, held.Composed = "", ""
}
+14 -6
View File
@@ -23,12 +23,20 @@ const (
EntryMissing = "entry-missing:"
)
// judgedAgain says a held have's detail is a hold the node-engine judges again at a start, not one that waits for the
// operator's answer: its want's parts differ from its composition (§524) or its entry is not held (§421). Only a failed
// backup or restore point waits for an answer (ADR 0568 §4); novox, 2026-11-16: the indexer held "parts-differ" was kept
// at a start as "held for a failed backup", waiting for an answer nobody was asked.
func judgedAgain(why string) bool {
return strings.HasPrefix(why, PartsDiffer) || heldForEntry(why)
// judgedAgain says a held have is a hold the node-engine judges again at a start, not one that waits for the operator's answer:
// its wait's reason (the structured field the have carries) is that its want's parts differ from its composition (§524) or its
// entry is not held (§421), whatever words its detail opens with. Only a failed backup or restore point waits for an answer (ADR
// 0568 §4); novox, 2026-11-16: the indexer held "parts-differ" was kept at a start as "held for a failed backup"; g14, 2026-11-18:
// feh held "whether ..." with the reason entry-missing was kept the same way.
func judgedAgain(h Have) bool {
if h.Wait == nil {
return false
}
switch h.Wait.Reason {
case strings.TrimSuffix(PartsDiffer, ":"), strings.TrimSuffix(EntryAsked, ":"), strings.TrimSuffix(EntryMissing, ":"):
return true
}
return false
}
// heldReason is the opening of a detail held for an entry: EntryAsked or EntryMissing.