frombus: a held module still provides what its running build provides (A-480)

A module the node holds keeps running what it runs, so a module that requires what it provides is no longer held for
"nothing provides": the held offer's provisions are the running composition's build's manifest, else the manifest the
module's running event names.

Builds: design 47 G A-480 (G-22-lead-answers-2.md)
This commit is contained in:
2026-11-17 22:58:11 +01:00
parent 9172eccbc4
commit baeb87d195
2 changed files with 69 additions and 0 deletions
+23
View File
@@ -358,11 +358,21 @@ func composeEach(in compose.Input, node string, fps map[string]string, applied b
if !ok {
return
}
running, known := catalogue.Manifest{}, false
if ran != nil {
if was, ok := ran(m); ok {
man.Contributes, man.ContributesMany, man.Listens = was.Contributes, was.ContributesMany, was.Listens
running, known = was, true
}
}
if !known {
running, known = heardManifest(in, node, m)
}
if known {
// A held module keeps running what it runs, so it keeps providing what that build provides, whatever its version and
// whether the catalog lists the build: the module that requires it is no "nothing provides" (A-480).
man.Provides = running.Provides
}
src[m] = man
}
if leave != "" {
@@ -512,6 +522,19 @@ func manifestOn(in compose.Input, node, module string) (catalogue.Manifest, bool
return man, ok
}
// heardManifest is the manifest of the build node said it runs of module (its `running` event's manifest, read by the event's digest,
// Node.Heard): false where nothing runs of it, it is stopped or the digest could not be read.
func heardManifest(in compose.Input, node, module string) (catalogue.Manifest, bool) {
for _, n := range in.Nodes {
if n.Name == node {
if h, ok := n.Heard[module]; ok && h.Read && !h.Stopped {
return h.Manifest, true
}
}
}
return catalogue.Manifest{}, false
}
// culprit is the module placed on node whose composition the error is of, and what of its offer to leave out: the
// first, in assignment order, whose stub (compose.Stub) makes the composition in mode succeed or fail otherwise (leave
// ""); else the first whose stub without what it contributes to one provision does (leave that provision: de-spiegel's
@@ -338,3 +338,49 @@ func TestASecondClaimantOfASeatIsHeldAndTheNodeComposesTheRest(t *testing.T) {
}
}
}
// A-480 (design 47 G): a module the node holds keeps running what it runs, and so keeps providing what its running build provides,
// whatever its catalogue entry: the module that requires it is not held for "nothing provides" (live, 2026-11-17 22:52: feh on g14
// held for "x11-display" while xorg runs there, held only for want of an entry of its wanted build). The offer is the running
// composition's build's manifest (the builder's done key), else the manifest the module's `running` event names; a module
// neither running nor composable still gives "nothing provides".
func TestAHeldModuleStillProvidesWhatItsRunningBuildProvides(t *testing.T) {
const xorgRunning = `{"module":"xorg","version":"1","provides":[{"name":"x11-display"}]}`
feh := `{"module":"feh","version":"1","requires":["x11-display"]}`
nameOnly := `{"module":"xorg","version":"0"}`
for _, row := range []struct {
name string
scope func(fps map[string]string, b *bus) Scope
provided bool
}{
{"it runs a build its running event names", func(fps map[string]string, b *bus) Scope {
digest := meshcatalogclient.ManifestDigest([]byte(xorgRunning))
b.manifests[digest] = []byte(xorgRunning)
return Scope{Heard: map[string]map[string]Heard{"n1": {"xorg": {Fingerprint: "src2:" + strings.Repeat("r", 64), Manifest: digest}}}}
}, true},
{"its composition runs a build the builder holds done", func(fps map[string]string, b *bus) Scope {
fp := "src2:" + strings.Repeat("r", 64)
digest := meshcatalogclient.ManifestDigest([]byte(xorgRunning))
b.manifests[digest] = []byte(xorgRunning)
b.builds["xorg "+fp] = &builds.BuilderBuild{State: builds.BuildDone, Manifest: digest}
return Scope{Running: []engcomp.Composed{{Node: "n1", Module: "xorg", FP: fp}}}
}, true},
{"nothing of it runs", func(map[string]string, *bus) Scope { return Scope{} }, false},
} {
b, fps := aNode(t, nameOnly, feh)
scope := row.scope(fps, b)
scope.Node = "n1"
scope.Held = map[string]string{"xorg": "entry-missing: the catalog half holds no entry of the build"}
_, _, held, err := Compose(context.Background(), b, Mesh{}, scope, fps)
why, fehHeld := held["feh"]
if row.provided && (err != nil || fehHeld) {
t.Errorf("%s: err %v, feh held %q; want feh composed with xorg held as what runs", row.name, err, why)
}
if !row.provided && !(fehHeld && strings.Contains(why, `nothing provides "x11-display"`)) && (err == nil || !strings.Contains(err.Error(), "nothing provides")) {
t.Errorf("%s: err %v, held %v; want nothing provides", row.name, err, held)
}
if !strings.Contains(held["xorg"], "entry-missing") {
t.Errorf("%s: xorg's own hold is %q, want it said", row.name, held["xorg"])
}
}
}