composer: a machine that fails with no module held is searched for its culprit, bounded by blame_tries (G-24 H2)

The composer program has no settings, so the assigner bounds the search through the request: only the candidate's
changed modules placed on the machine are held, one at a time, the search ending at the first whose hold ends the
problem; past the bound the untried are named. A request with no blame_tries gets no search.

Builds: design 47 G §721, §733; A-468h, A-468i, A-469i, A-469j, A-469k
This commit is contained in:
2026-11-17 11:21:49 +01:00
parent 06781d4dbc
commit 8700aabba3
2 changed files with 109 additions and 10 deletions
+74 -3
View File
@@ -238,7 +238,9 @@ func runCase(r Request, c Case, depth string) (CaseVerdict, error) {
}
cv.Machines = map[string]Machine{}
for _, node := range r.Machines {
m := machine(in, node, depth, r.Declarations)
at := in // the input m is composed from
m := machine(at, node, depth, r.Declarations)
problem := problemOf(m) // what the search for culprits holds a module against, before any words are added
if words := awaitedOn(in, node, awaited); words != "" {
// Composed without the build it runs at: named per node and module, never a silent pass (issue 1921). The
// machine is then not judged, as for a node whose running state its engine does not send (ADR 0593 §9). Where
@@ -249,11 +251,12 @@ func runCase(r Request, c Case, depth string) (CaseVerdict, error) {
// shanks).
how := "composed from the change's manifest without its build: "
if !m.Composes && m.NotJudged == "" {
switch again := machine(heldAgain(in, held, awaited), node, depth, r.Declarations); {
lifted := heldAgain(in, held, awaited)
switch again := machine(lifted, node, depth, r.Declarations); {
case again.Composes:
m, how = again, "composed with it held as its node-engine holds it, since it does not compose without its build: "
case again.NotJudged == "":
m, how = again, "refused with it held as its node-engine holds it, since it does not compose without its build: "
m, how, at, problem = again, "refused with it held as its node-engine holds it, since it does not compose without its build: ", lifted, problemOf(again)
}
}
words = how + words
@@ -263,6 +266,11 @@ func runCase(r Request, c Case, depth string) (CaseVerdict, error) {
m.Reason += "; " + words
}
}
// A machine that does not compose with no module held is searched for the module whose hold ends its problem, bounded
// by the request's blame_tries; a request with none gets no search (design 47 G §721; A-468i, A-469j).
if !m.Composes && m.NotJudged == "" && len(m.Blamed) == 0 && r.BlameTries > 0 {
m.Blamed = culprits(at, held, node, depth, r.Declarations, changedOn(at, node, c, held.ComposedHow), r.BlameTries, problem)
}
if m.Blamed == nil {
m.Blamed = []blame{} // always written, so a verdict blaming none is told from an old composer's (A-469h)
}
@@ -502,6 +510,69 @@ func machine(in compose.Input, node, depth string, declarations bool) Machine {
return m
}
// NotTried is the problem of a changed module the search for culprits did not hold, its bound reached (design 47 G §721).
const NotTried = "not tried: the search reached its bound"
// triedHeld is the words a module is held with while the search for culprits tries it.
const triedHeld = "held by the composer's search for the module the machine's problem is of"
// culprits holds each of changed on node, one at a time, as its node-engine holds a module (heldAgain), each try
// composing once more, and blames the first whose hold ends problem: the try composes, or fails otherwise, as culprit
// blames a stub (frombus). At most tries tries; past them each module not yet tried is named NotTried (design 47 G §721).
// None ends it: no module is blamed, and the machine fails on the node's own account.
func culprits(in, held compose.Input, node, depth string, declarations bool, changed []string, tries int, problem string) []blame {
for i, mod := range changed {
if i == tries {
var out []blame
for _, untried := range changed[i:] {
out = append(out, blame{Module: untried, Problem: NotTried})
}
return out
}
try := machine(heldAgain(in, held, map[string]string{mod: triedHeld}), node, depth, declarations)
if try.NotJudged == "" && (try.Composes || problemOf(try) != problem) {
return []blame{{Module: mod, Problem: problem}}
}
}
return nil
}
// problemOf is a machine's problem in words: why it does not compose, with what the validator refuses.
func problemOf(m Machine) string {
if len(m.Problems) == 0 {
return m.Reason
}
return m.Reason + ": " + strings.Join(m.Problems, "; ")
}
// changedOn is each module placed on node, in assignment order, whose case manifest's content digest differs from the
// manifest its build was made of as the input names it (ComposedHow.Manifests), or that the input names none for: the
// candidate's changed modules (design 47 G §721; A-469k). A module the case carries no manifest of is not changed.
func changedOn(in compose.Input, node string, c Case, how *compose.ComposedHow) []string {
var out []string
for _, mod := range assignedOn(in, node) {
man, carried := c.Manifests[mod]
if !carried || len(man.Raw) == 0 {
continue
}
if digest, err := compose.ContentDigest(man.Raw); err == nil && digest == manifestOf(how, mod) {
continue
}
out = append(out, mod)
}
return out
}
// assignedOn is the modules placed on node, in assignment order.
func assignedOn(in compose.Input, node string) []string {
for _, n := range in.Nodes {
if n.Name == node {
return n.Assigned
}
}
return nil
}
// blame is one module a machine's verdict blames, with its problem (Machine.Blamed, design 47 G §721).
type blame = struct {
Module string `json:"module"`