node-engine: compose-candidate reads a branch pipeline's catalog revision through mesh-catalog.revision and composes it as the candidate (A-226b)

Builds: design 47 G (G-22 lead answers 2) A-226b; ADR 0593 §7
This commit is contained in:
2026-11-16 13:58:36 +01:00
parent 7a30c0d54c
commit a1cd4a1a2f
2 changed files with 136 additions and 22 deletions
+27 -1
View File
@@ -85,7 +85,18 @@ func TestTheNodeComposesACandidateOnAsk(t *testing.T) {
t.Fatal(err)
}
entry := meshcatalog.CatalogEntry{Module: "lemurs", Fp: fp, Manifest: manifest, Repository: "novox/x", Commit: "c", ManifestDigest: digest}
env.Entry = EntryCall(func(_ context.Context, _, _ string, _ any) (json.RawMessage, error) {
// A-226b: the revision a branch pipeline names is read through the verb revision: revision 362 of main holds lemurs at its
// new build and manifest; no other revision is held.
env.Entry = EntryCall(func(_ context.Context, _, verb string, args any) (json.RawMessage, error) {
if verb == meshcatalog.VerbRevision {
in, _ := args.(meshcatalog.RevisionInput)
if in.Revision != 362 || in.Branch != "main" {
return json.Marshal(meshcatalog.RevisionAnswer{NoneYet: true})
}
moved := entry
moved.Fp, moved.ManifestDigest = fpNew, digest2
return json.Marshal(meshcatalog.RevisionAnswer{Revision: &meshcatalog.CatalogRevision{Branch: "main", Revision: 362}, Entries: []meshcatalog.CatalogEntry{moved}})
}
return json.Marshal(meshcatalog.EntryAnswer{Entry: entry})
})
var handed atomic.Int64
@@ -141,6 +152,21 @@ func TestTheNodeComposesACandidateOnAsk(t *testing.T) {
if _, err := nec.EncodeAnswer(r); err != nil {
t.Errorf("the refused answer does not fit the seat's shape: %v", err)
}
// A-226b: a branch pipeline's revision composes as the candidate, each module at the revision's build; one the catalog does
// not hold, and a run on request's key, are refused in words.
revKey, _ := nec.RevisionKey("main", 362)
rv := s.ComposeCandidate(ctx, nodeengine.ComposeCandidateInput{Candidate: revKey})
if rv.Verdict != nec.Composed || len(rv.Modules) != 1 || rv.Modules[0].Fp != fpNew || !rv.Modules[0].Changed {
t.Errorf("a catalog revision answered %+v", rv)
}
noRev, _ := nec.RevisionKey("main", 999)
if m := s.ComposeCandidate(ctx, nodeengine.ComposeCandidateInput{Candidate: noRev}); m.Verdict != nec.Refused || !strings.Contains(m.Refused, "holds no revision 999") {
t.Errorf("a revision the catalog does not hold answered %+v", m)
}
runKey, _ := nec.RunKey("r1")
if m := s.ComposeCandidate(ctx, nodeengine.ComposeCandidateInput{Candidate: runKey}); m.Verdict != nec.Refused || !strings.Contains(m.Refused, "run on request") {
t.Errorf("a run's key answered %+v", m)
}
missing, _ := nec.CompositionKey("novox/x#8", "0123456789ab")
if m := s.ComposeCandidate(ctx, nodeengine.ComposeCandidateInput{Candidate: missing}); !strings.Contains(m.Refused, "holds no candidate") {
t.Errorf("a candidate the indexer does not hold answered %+v", m)