From db62653472e71c16ad40a443573a86c55345e3b2 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 17 Nov 2026 10:45:20 +0100 Subject: [PATCH] assigner: a composition step never passes on a machine it did not judge, and hands the composer the trunk seat list (A-467) A machine the composer says `not judged` ends the step could not run, naming why (was a warning). A revision that names no seat definition (A-234's stand-in) hands the composer every definition of the trunk seat list, read through mesh-catalog's seat-definitions; a list or definition not read ends the step could not run, naming it (was an empty list, no error). The integration bed makes the inputs object store, which a request carrying the seat list needs. Builds: design 47 G A-467, A-234, A-252, A-261 --- .../mesh-delivery-assigner/compositionrun.go | 87 +++++++++++++------ .../compositionrun_test.go | 51 ++++++++++- .../compositionstep_integration_test.go | 3 + .../integration_test.go | 5 ++ 4 files changed, 119 insertions(+), 27 deletions(-) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go index 5d98c8cd..e42a9f29 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go @@ -136,7 +136,7 @@ type machineEnd struct { } // run runs one composition step and answers what it came to: failed when a machine does not compose, could not run when a machine -// could not be composed, else passed with a warning per machine away or not judged. +// could not be composed or was not judged, else passed with a warning per machine away. func (r *compositionRun) run(ctx context.Context, _ string, run meshwants.StepRun) stepOutcome { half, err := r.revision(ctx, run) if err != nil { @@ -250,7 +250,7 @@ func (r *compositionRun) machine(ctx context.Context, in nodeInput, ask string, return verdictOf(node, answer) } -// verdictOf reads the composer's verdict of one machine: not composing is failed, naming why; not judged passes with a warning. +// verdictOf reads the composer's verdict of one machine: not composing is failed, naming why; not judged is could not run, naming why (A-467). func verdictOf(node string, answer []byte) machineEnd { var v composer.Verdict if err := json.Unmarshal(answer, &v); err != nil { @@ -267,8 +267,8 @@ func verdictOf(node string, answer []byte) machineEnd { switch { case !ok: return machineEnd{couldNot: node + ": the composer's verdict names no such machine"} - case m.NotJudged != "": - return machineEnd{warning: node + " was not judged: " + m.NotJudged} + case m.NotJudged != "": // a step never passes on a machine it did not judge (A-467) + return machineEnd{couldNot: node + " was not judged: " + m.NotJudged} case !m.Composes: return machineEnd{failed: node + " does not compose: " + strings.Join(appendSome(append(slices.Clone(m.Problems), m.Refusals...), m.Reason), "; ")} } @@ -317,38 +317,75 @@ func (r *compositionRun) readRevision(ctx context.Context, run meshwants.StepRun } } -// seats are the definitions of the revision's (seat, digest) pairs, raw (A-261): the revision's definitions carry no definition -// yet (A-234), so each is mesh-catalog's seat-definitions answer for the seat where the trunk's digest is the revision's; a digest -// neither holds is an error naming the seat and the digest. +// seats are the definitions the composer is handed, raw. A revision that names definitions (A-261): the definition of each (seat, digest) +// pair, from mesh-catalog's seat-definitions where the trunk's digest is the revision's; a digest neither holds is an error naming the seat +// and the digest. A revision that names none (A-234's stand-in, A-467): every definition of the trunk seat list, read through +// seat-definitions; a list or a definition that cannot be read is an error naming it, never an empty list. func (r *compositionRun) seats(ctx context.Context, defs []meshcatalog.CatalogRevisionDefinitionsItem) ([]json.RawMessage, error) { + if len(defs) == 0 { + return r.trunkSeats(ctx) + } out := make([]json.RawMessage, 0, len(defs)) for _, d := range defs { - if def, ok := r.reads.seatKept(d.Seat, d.Digest); ok { // a definition at a digest never changes - out = append(out, def) - continue - } - what := "the definition of the seat " + d.Seat + " is not read" - body, said, err := r.callRetry(ctx, seatDefinitionsKey, meshcatalog.SeatDefinitionsInput{Seat: d.Seat}) - if err != nil || body == nil { - return nil, unreadErr(what, err, said) - } - var a meshcatalog.SeatDefinitionsAnswer - if err := json.Unmarshal(body, &a); err != nil { - return nil, fmt.Errorf("%s: %w", what, err) - } - if a.Entry == nil || a.Entry.Digest != d.Digest || a.Entry.Definition == nil { - return nil, fmt.Errorf("no definition of the seat %s with the digest %s is held: neither the revision nor the trunk holds it", d.Seat, d.Digest) - } - def, err := json.Marshal(a.Entry.Definition) + def, err := r.seatAt(ctx, d.Seat, d.Digest) if err != nil { return nil, err } - r.reads.keepSeat(d.Seat, d.Digest, def) out = append(out, def) } return out, nil } +// trunkSeats are the definitions of every seat of the trunk's seat list (seat-definitions with no seat names them with their digests). +func (r *compositionRun) trunkSeats(ctx context.Context) ([]json.RawMessage, error) { + what := "the trunk's seat list is not read" + body, said, err := r.callRetry(ctx, seatDefinitionsKey, meshcatalog.SeatDefinitionsInput{}) + if err != nil || body == nil { + return nil, unreadErr(what, err, said) + } + var list meshcatalog.SeatDefinitionsAnswer + if err := json.Unmarshal(body, &list); err != nil { + return nil, fmt.Errorf("%s: %w", what, err) + } + if len(list.Seats) == 0 { + return nil, errors.New(what + ": mesh-catalog's seat-definitions names no seat, so the composer has no seat list to judge by") + } + out := make([]json.RawMessage, 0, len(list.Seats)) + for _, s := range list.Seats { + def, err := r.seatAt(ctx, s.Seat, s.Digest) + if err != nil { + return nil, err + } + out = append(out, def) + } + return out, nil +} + +// seatAt is the definition of a seat at a digest, kept once read (a definition at a digest never changes). +func (r *compositionRun) seatAt(ctx context.Context, seat, digest string) (json.RawMessage, error) { + if def, ok := r.reads.seatKept(seat, digest); ok { + return def, nil + } + what := "the definition of the seat " + seat + " is not read" + body, said, err := r.callRetry(ctx, seatDefinitionsKey, meshcatalog.SeatDefinitionsInput{Seat: seat}) + if err != nil || body == nil { + return nil, unreadErr(what, err, said) + } + var a meshcatalog.SeatDefinitionsAnswer + if err := json.Unmarshal(body, &a); err != nil { + return nil, fmt.Errorf("%s: %w", what, err) + } + if a.Entry == nil || a.Entry.Digest != digest || a.Entry.Definition == nil { + return nil, fmt.Errorf("no definition of the seat %s with the digest %s is held: neither the revision nor the trunk holds it", seat, digest) + } + def, err := json.Marshal(a.Entry.Definition) + if err != nil { + return nil, err + } + r.reads.keepSeat(seat, digest, def) + return def, nil +} + // caseOf is the case's manifests and verdicts from the revision's entries: each manifest whole, and the verdict of each one not // accepted (a module without one is accepted). func caseOf(half mcc.Half) (map[string]composer.Manifest, map[string]json.RawMessage, error) { diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go index c9ccd69e..fc4cd908 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go @@ -30,6 +30,12 @@ type runStand struct { requests map[string]composer.Request // by node entries []string // the fingerprints `entry` was asked r *compositionRun + // noDefinitions: the revision names no seat definition (A-234's stand-in); trunkSeats: the trunk's seat list as (seat, digest) + // pairs; unjudged: the machine the composer does not judge; listFault: the trunk's seat list cannot be read. + noDefinitions bool + trunkSeats []meshcatalog.SeatDefinitionsAnswerSeatsItem + unjudged string + listFault error } func newRunStand(t *testing.T, revisionEngine, trunkEngine, seatDigest string) *runStand { @@ -57,8 +63,22 @@ func newRunStand(t *testing.T, revisionEngine, trunkEngine, seatDigest string) * if in.Revision != 7 || in.Branch != "main" { return nil, errors.New("asked another revision") } - return json.Marshal(pages[in.After]) + page := pages[in.After] + if s.noDefinitions && page.Revision != nil { + rev := *page.Revision + rev.Definitions = nil + page.Revision = &rev + } + return json.Marshal(page) case seatDefinitionsKey: + var sin meshcatalog.SeatDefinitionsInput + _ = json.Unmarshal(raw, &sin) + if sin.Seat == "" { + if s.listFault != nil { + return nil, s.listFault + } + return json.Marshal(meshcatalog.SeatDefinitionsAnswer{Seats: s.trunkSeats}) + } return json.Marshal(meshcatalog.SeatDefinitionsAnswer{Found: true, Entry: &meshcatalog.SeatDefinitionsAnswerEntry{Seat: "s1", Digest: seatDigest, Definition: map[string]any{"seat": "s1"}}}) case entryVerbKey: var in meshcatalog.EntryInput @@ -104,7 +124,9 @@ func newRunStand(t *testing.T, revisionEngine, trunkEngine, seatDigest string) * s.asks[node], s.requests[node] = a, req s.mu.Unlock() m := composer.Machine{Composes: true} - if node == "g14" { + if node == s.unjudged { + m = composer.Machine{NotJudged: "the composer was handed no seat list"} + } else if node == "g14" { m = composer.Machine{Reason: "two modules own one path", Problems: []string{"/etc/x is m's and bad's"}} } v, _ := json.Marshal(composer.Verdict{V: composer.Version, Cases: []composer.CaseVerdict{{Name: changeCase, Machines: map[string]composer.Machine{node: m}}}}) @@ -179,6 +201,31 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) { t.Errorf("a seat digest not held came to %+v, %d asks", out, len(other.asks)) } + // A revision naming no definition (A-234's stand-in): the composer is handed the trunk seat list's definitions, read through + // seat-definitions (A-467); a list that cannot be read, or names no seat, ends the step could not run, naming it, with no ask put. + bare := newRunStand(t, "src2:e1", "src2:e1", "d1") + bare.noDefinitions, bare.trunkSeats = true, []meshcatalog.SeatDefinitionsAnswerSeatsItem{{Seat: "s1", Digest: "d1"}} + if out := bare.r.run(context.Background(), "ask-step", step); out.Outcome != meshwants.StepEndedOutcomeFailed || + len(bare.requests["ace"].Seats) != 1 || string(bare.requests["ace"].Seats[0]) != `{"seat":"s1"}` { + t.Errorf("a revision with no definitions came to %+v, seats %v", out, bare.requests["ace"].Seats) + } + for name, fault := range map[string]error{"unreadable": errors.New("no responder"), "empty": nil} { + s := newRunStand(t, "src2:e1", "src2:e1", "d1") + s.noDefinitions, s.listFault = true, fault + if out := s.r.run(context.Background(), "ask-step", step); out.Outcome != meshwants.StepEndedOutcomeCouldNotRun || + !strings.Contains(out.Said, "seat list is not read") || len(s.asks) != 0 { + t.Errorf("the %s seat list came to %+v, %d asks", name, out, len(s.asks)) + } + } + + // A machine the composer did not judge is could not run, naming why: a step that judged nothing never passes (A-467). + nj := newRunStand(t, "src2:e1", "src2:e1", "d1") + nj.unjudged = "g14" + if out := nj.r.run(context.Background(), "ask-step", step); out.Outcome != meshwants.StepEndedOutcomeCouldNotRun || + !strings.Contains(out.Said, "g14 was not judged: the composer was handed no seat list") { + t.Errorf("a machine not judged came to %+v", out) + } + // At the inputs state's cap the ask is refused, naming the store (ยง354). full := newRunStand(t, "src2:e1", "src2:e1", "d1") full.r.keeper.used = func() (int64, error) { return inputsCap, nil } diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep_integration_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep_integration_test.go index daef24b8..140f2382 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep_integration_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep_integration_test.go @@ -146,6 +146,9 @@ func TestTheCompositionStepComposesEachMachineThroughTheBuildSeat(t *testing.T) if err != nil || len(req.Machines) != 1 { t.Fatalf("the request of %s: %+v %v", a.ID, req, err) } + if len(req.Seats) == 0 { // the revision names no definition: the request carries the trunk seat list's (A-467) + t.Errorf("the request of %s carries no seat definition", a.ID) + } node := req.Machines[0] programs[node] = a.Run.Program.Commit m := composer.Machine{Composes: true} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go index 9168fddb..e4213e17 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go @@ -178,6 +178,11 @@ func startBed(t *testing.T, leaveOut string) *bed { } b.buckets[name] = kv } + // The object store beside the state inputs, which the grants part makes from the manifest's objects: a composition request that + // carries the whole seat list (A-467) is too big for the state's value and is kept there. + if _, err := js.CreateObjectStore(ctx, jetstream.ObjectStoreConfig{Bucket: catalogue.BusName("mesh-delivery-assigner", catalogue.StateObjectsName(buckets.InputsState))}); err != nil { + t.Fatal(err) + } // The builder's module log, as the runtime raises it (ADR 0297): the running commits are read from it (ADR 0571 clause 1). if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: buscompose.LogStreamName(builds.BuilderModule, builds.BuilderLog), Subjects: []string{buscompose.LogSubject(builds.BuilderModule, builds.BuilderLog) + ".>"}, AllowDirect: true}); err != nil {