Node-engine: only an image the mesh built is a part of a want (A-454)

A container's image counts as fetched for the parts check only when the composition
names the seat it came through; an upstream image its manifest pins by digest is no
part and is never 'fetched and not in the want's parts'.

Builds: design 47 G A-454 (§421's parts check, A-432)
This commit is contained in:
2026-11-17 00:48:46 +01:00
parent 1b9f9355b5
commit dbb77efab1
2 changed files with 14 additions and 1 deletions
+9 -1
View File
@@ -363,10 +363,18 @@ func TestAWantAndItsCompositionApplyTheModuleAndTheHaveNamesBoth(t *testing.T) {
}
}
// A container's digest is the one after its image's @.
container := json.RawMessage(`{"id":"web.c","type":"container","name":"web-c","image":"store/web@` + d3 + `","module":"web"}`)
container := json.RawMessage(`{"id":"web.c","type":"container","name":"web-c","image":"store/web@` + d3 + `","image-seat":"mesh-artifact-store","image-holder":"n1","module":"web"}`)
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container}); got != "" {
t.Fatalf("a container whose digest is in the parts differs: %q", got)
}
// A-454: an image the manifest pins from outside, by its digest, is no part of the want's parts, and a mesh-built one still is.
upstream := json.RawMessage(`{"id":"web.u","type":"container","name":"web-u","image":"registry@` + d2 + `","module":"web"}`)
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container, upstream}); got != "" {
t.Fatalf("an upstream image pinned by its digest is a part: %q", got)
}
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{upstream}); !strings.Contains(got, "in the want's parts and not fetched: "+d3) || strings.Contains(got, d2) {
t.Fatalf("with only an upstream image the mesh-built one is not missing, or the upstream one is named: %q", got)
}
// A-432: a runtime of its own runs the tool runner's program, which the module's parts do not name.
ownRuntime := json.RawMessage(`{"id":"web.own-runtime","type":"process","name":"web-runtime","source":"store/node-tools","digest":"` + d1 + `","run":["./node-tools"],"module":"web"}`)
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container, ownRuntime}); got != "" {
+5
View File
@@ -69,6 +69,11 @@ func partsDifference(parts map[string]string, resources []json.RawMessage) strin
fetched[res.Digest] = true
}
case *declaration.Container:
// Only an image the mesh built is a part: the composition names the seat it came through (the artifact store or a
// registry seat) beside it. An image the manifest pins from outside, by its digest, is no part (design 47 G A-454).
if res.ImageSeat == "" {
continue
}
if strings.HasPrefix(res.Image, "sha256:") {
fetched[res.Image] = true
} else if _, digest, ok := strings.Cut(res.Image, "@"); ok {