composer: the search for culprits goes on past a hold that changes the problem (G-24 review r2)

A hold that changes the problem but leaves the machine not composing keeps that module held and blamed,
and the search goes on against the retry's problem within the same blame_tries, until the machine
composes or no hold changes it: every module the change refuses is blamed, never only the first.

Builds: design 47 G §721, §722, A-470c, A-470v
This commit is contained in:
2026-11-17 13:10:51 +01:00
parent f21b8c202d
commit ed7cefb5d8
2 changed files with 41 additions and 15 deletions
+4
View File
@@ -206,6 +206,10 @@ func TestTheCommandWritesOneVerdictPerManifestAndMachine(t *testing.T) {
// problem is then no changed module's, and none is blamed. // problem is then no changed module's, and none is blamed.
{"a module its build was made of is not tried", search, []string{"m1", "m2", "m3"}, {"a module its build was made of is not tried", search, []string{"m1", "m2", "m3"},
&compose.ComposedHow{Node: "a", Manifests: map[string]string{"m2": digest(t, search["m2"])}}, 20, []blame{}}, &compose.ComposedHow{Node: "a", Manifests: map[string]string{"m2": digest(t, search["m2"])}}, 20, []blame{}},
// A-470v: a hold that changes the problem but leaves the machine not composing keeps that module held and blamed,
// and the search goes on against the retry's problem: both modules the change refuses are blamed.
{"every module the change refuses is blamed", map[string]string{"m1": file("m1", "/var/lib/m1/env", secret), "m2": file("m2", "/var/lib/m2/env", secret), "m3": plain("m3")},
[]string{"m1", "m2", "m3"}, &compose.ComposedHow{Node: "a"}, 20, []blame{{Module: "m1", Problem: "repository"}, {Module: "m2", Problem: "repository"}}},
// G-24 H-AC4: past the request's blame_tries the modules not yet tried are named so. // G-24 H-AC4: past the request's blame_tries the modules not yet tried are named so.
{"past blame_tries the untried are named", search, []string{"m1", "m2", "m3"}, &compose.ComposedHow{Node: "a"}, 1, {"past blame_tries the untried are named", search, []string{"m1", "m2", "m3"}, &compose.ComposedHow{Node: "a"}, 1,
[]blame{{Module: "m2", Problem: composer.NotTried}, {Module: "m3", Problem: composer.NotTried}}}, []blame{{Module: "m2", Problem: composer.NotTried}, {Module: "m3", Problem: composer.NotTried}}},
+34 -12
View File
@@ -735,14 +735,14 @@ func ComposingInput(ctx context.Context, r Reader, mesh Mesh, s Scope, fps map[s
// It runs the one search for culprits (design 47 G §721; A-469j, A-468i): where the composition fails with no module held // It runs the one search for culprits (design 47 G §721; A-469j, A-468i): where the composition fails with no module held
// that the node held neither in the read nor before the change, and no path owned twice names its owners, each of // that the node held neither in the read nor before the change, and no path owned twice names its owners, each of
// s.Changed is held in turn, one composition each, and the first whose hold ends the problem (the try composes or fails // s.Changed is held in turn, one composition each, and the first whose hold ends the problem (the try composes or fails
// otherwise) is blamed with it. At most s.Tries tries; past them each module not yet tried is blamed NotTried. With no // otherwise) is blamed with it; one that leaves the machine not composing stays held, and the search goes on (A-470v). At most s.Tries tries; past them each module not yet tried is blamed NotTried. With no
// tries there is no search: the failure is the node's own (err). // tries there is no search: the failure is the node's own (err).
func ComposeSent(in compose.Input, node string, s Search) (map[string]engcomp.Composed, bool, error) { func ComposeSent(in compose.Input, node string, s Search) (map[string]engcomp.Composed, bool, error) {
c := in.ComposedHow c := in.ComposedHow
if c == nil || c.Node != node { if c == nil || c.Node != node {
return nil, false, nil return nil, false, nil
} }
compose1 := func(also string) (map[string]engcomp.Composed, map[string]string, error) { compose1 := func(also ...string) (map[string]engcomp.Composed, map[string]string, error) {
held := maps.Clone(c.Held) held := maps.Clone(c.Held)
if held == nil { if held == nil {
held = map[string]string{} held = map[string]string{}
@@ -754,8 +754,8 @@ func ComposeSent(in compose.Input, node string, s Search) (map[string]engcomp.Co
held[m] = why held[m] = why
} }
} }
if also != "" { for _, m := range also {
held[also] = triedHeld held[m] = triedHeld
} }
out, _, _, err := composeEach(in, node, c.Builds, false, c.Running, held, nil, false) out, _, _, err := composeEach(in, node, c.Builds, false, c.Running, held, nil, false)
return out, held, err return out, held, err
@@ -765,7 +765,7 @@ func ComposeSent(in compose.Input, node string, s Search) (map[string]engcomp.Co
_, before := c.HeldBefore[m] _, before := c.HeldBefore[m]
return !was && !before return !was && !before
} }
out, held, err := compose1("") out, held, err := compose1()
// A module the sandbox held that the node-engine held neither in the read nor composing without the change is the change // A module the sandbox held that the node-engine held neither in the read nor composing without the change is the change
// refusing it: the node does not compose, said in that module's words, never passed with the rest composed (issue 774, // refusing it: the node does not compose, said in that module's words, never passed with the rest composed (issue 774,
// review of the sandbox input). // review of the sandbox input).
@@ -789,19 +789,41 @@ func ComposeSent(in compose.Input, node string, s Search) (map[string]engcomp.Co
} }
} }
} }
// A hold that changes the problem but leaves the machine not composing keeps that module held and blamed, and the
// search goes on against the retry's problem, from the first changed module not held, within the same tries, until the
// machine composes or no hold changes it (A-470v): every module the change refuses is blamed, never only the first.
if err != nil && len(blamed) == 0 && s.Tries > 0 { if err != nil && len(blamed) == 0 && s.Tries > 0 {
problem := err.Error() problem, tries := err.Error(), 0
for i, mod := range s.Changed { var kept []string
if i == s.Tries { search:
for _, untried := range s.Changed[i:] { for {
tried := map[string]bool{} // against the problem of now
for _, mod := range s.Changed {
if slices.Contains(kept, mod) {
continue
}
if tries == s.Tries {
for _, untried := range s.Changed {
if _, done := blamed[untried]; !done && !tried[untried] {
blamed[untried] = NotTried blamed[untried] = NotTried
} }
break
} }
if _, _, again := compose1(mod); again == nil || again.Error() != problem { break search
}
tries++
tried[mod] = true
_, _, again := compose1(append(slices.Clone(kept), mod)...)
if again == nil {
blamed[mod] = problem blamed[mod] = problem
break break search
} }
if again.Error() != problem {
blamed[mod], problem = problem, again.Error()
kept = append(kept, mod)
continue search
}
}
break // no hold changes the problem
} }
} }
if len(blamed) == 0 { if len(blamed) == 0 {