From 5e3d92ae337250abf81dbdd27c6a0131a015d6ac Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 16:29:16 +0100 Subject: [PATCH 1/4] assigner: leave a stale assignment out of a machine's composition (H-A-148) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The retired checker's assignment on the control-node made every composition there refuse "nothing provides", so every composition step on that machine ended could not run. A module assigned to a machine that the case's manifests do not hold (no watched branch lists it) is now left out of the case's assignments as well, said in the journal and at the judgement as unlisted, and the machine is judged on what remains: a stale assignment is a fault of the assignments, not of the change judged. Builds: design 47 H H-A-148, H-A-143; ADR 0578 §2 --- .../mesh-delivery-assigner/compositionrun.go | 52 +++++++++++++++++-- .../compositionrun_test.go | 48 +++++++++++++++++ .../cmd/mesh-delivery-assigner/main.go | 2 +- .../cmd/mesh-delivery-assigner/world.go | 6 +++ 4 files changed, 102 insertions(+), 6 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 5b7fa7e8..fe5d5e44 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go @@ -13,6 +13,8 @@ import ( "github.com/nats-io/nats.go/jetstream" + mmac "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient" + mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner" ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" meshcatalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" @@ -59,8 +61,10 @@ type compositionRun struct { // them (design 47 H-A-143, G §532). Nil: the step's revision alone. newest func() map[string]mcc.Half watched func(module string) []string - // assigned is the modules the assignments place on a machine (world.assignments), for the modules no watched branch lists. - assigned func(node string) []string + // assigned is the modules the assignments place on a machine (world.assignments), for the modules no watched branch lists; + // assignment is the machine's assignments whole, which the case composes with those modules left out (H-A-148). + assigned func(node string) []string + assignment func(node string) (mma.Assignments, bool) // running is the last `running` heard of a module on a node (world.runningOf), never the node-engine's bucket. running func(node, module string) (ne.Running, bool) // away says the watchman holds machine away (machine-away, not back since): the one presence the assigner keeps (world.awayNow), @@ -254,8 +258,15 @@ func (r *compositionRun) start(ctx context.Context, key string, run meshwants.Co end(node + ": " + err.Error()) return } + cs := composer.Case{Name: changeCase, Manifests: prep.manifests, None: prep.none} + if left, err := r.leftOut(node, prep.manifests); err != nil { + end(node + ": " + err.Error()) + return + } else if left != nil { + cs.Assignments = left + } req := composer.Request{V: composer.Version, Input: in.Body, Depth: composer.DepthCompose, Machines: []string{node}, - Cases: []composer.Case{{Name: changeCase, Manifests: prep.manifests, None: prep.none}}, Seats: prep.seats, + Cases: []composer.Case{cs}, Seats: prep.seats, BlameTries: r.runs.set.blameTries} // the composer's bound of its search for culprits (§721, A-466r) raw, err := json.Marshal(req) if err != nil { @@ -301,8 +312,9 @@ const notTried = "not tried: the search reached its bound" // it, on the node's own account; a verdict with no `blamed` (a composer before §721) is judged as before, with the warning "the // composer names no culprits"; otherwise the machine passes, with a warning for each other module blamed there. // -// unlisted are the modules the machine is assigned that none of their watched branches lists: each is said on every path, in the -// machine's failed or could-not-run words where one is set, else as a warning, never dropped in silence (H-A-143, H-A-144). +// unlisted are the modules the machine is assigned that none of their watched branches lists, left out of its composition: each is +// said on every path, in the machine's failed or could-not-run words where one is set, else as a warning, never the machine's +// failure and never dropped in silence (H-A-143, H-A-144, H-A-148). func judgeRun(module string, run meshwants.CompositionRun, unlisted []string) machineEnd { end := judgeVerdict(module, run) for _, u := range unlisted { @@ -602,6 +614,36 @@ func (r *compositionRun) unlistedOn(node string) []string { return slices.Compact(out) } +// leftOut is the case's assignments of node with each module the case's manifests do not hold (none of its watched branches lists +// it) left out, or nil where none is (the case then composes the input's): a stale assignment is a fault of the assignments, not of +// the change judged, so it is left out of the composition, said in the journal and, at the judgement, as unlisted (design 47 +// H-A-148, H-A-143; ADR 0578 §2). +func (r *compositionRun) leftOut(node string, manifests map[string]composer.Manifest) (map[string]json.RawMessage, error) { + if r.assignment == nil { + return nil, nil + } + a, ok := r.assignment(node) + if !ok { + return nil, nil + } + var unlisted []string + for _, m := range a.Modules { + if _, held := manifests[m.Module]; !held { + unlisted = append(unlisted, m.Module) + } + } + if len(unlisted) == 0 { + return nil, nil + } + a.Modules = slices.DeleteFunc(slices.Clone(a.Modules), func(m mma.PlacedModule) bool { return slices.Contains(unlisted, m.Module) }) + raw, err := mmac.EncodeAssignments(a) + if err != nil { + return nil, fmt.Errorf("its assignments with %s left out cannot be encoded: %w", strings.Join(unlisted, ", "), err) + } + r.logf("%s: the composition leaves out %s, assigned there and listed on no watched branch (H-A-148)", node, strings.Join(unlisted, ", ")) + return map[string]json.RawMessage{node: raw}, nil +} + // nodeEngineEntry is the entry of the module that claims the seat node-engine, or false. func nodeEngineEntry(entries map[string]meshcatalog.CatalogEntry) (meshcatalog.CatalogEntry, bool) { for _, name := range slices.Sorted(mapsKeys(entries)) { 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 96b3404a..b1fe0423 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 @@ -11,6 +11,8 @@ import ( "testing" "time" + mmac "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient" + mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner" ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" meshcatalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" @@ -283,6 +285,52 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) { c.Manifests["lidarr"].Raw != nil { t.Errorf("the case across the watched branches holds %v", slices.Sorted(maps.Keys(c.Manifests))) } + if c := across.requests["ace"].Cases[0]; c.Assignments != nil { + t.Errorf("with no assignments held the case composes the input's, it carries %v", c.Assignments) + } + + // A stale assignment is left out of the case's assignments as well, said, and the machine composes; a listed module stays in + // (H-A-148, ADR 0578 §2). + for _, tc := range []struct { + name string + assigned []string + want []string // the case's modules of ace; nil: the input's assignments + }{ + {"a stale assignment left out and said, the machine composes", []string{"m", "f1-circuits", "checker"}, []string{"m", "f1-circuits"}}, + {"listed modules alone: the input's assignments", []string{"m", "f1-circuits"}, nil}, + } { + left := newRunStand(t, "src2:e1", "src2:e1", "d1") + left.r.newest, left.r.watched = across.r.newest, across.r.watched + left.r.assigned = func(string) []string { return tc.assigned } + left.r.assignment = func(node string) (mma.Assignments, bool) { + a := mma.Assignments{Node: node} + for _, m := range tc.assigned { + a.Modules = append(a.Modules, mma.PlacedModule{Module: m}) + } + return a, true + } + left.verdict = func(string) (composer.Machine, bool) { return composer.Machine{Composes: true}, true } + out := left.r.run(context.Background(), "ask-step", step) + said := "ace is assigned checker, which no watched branch lists (H-A-143)" + if out.Outcome != meshwants.StepEndedOutcomePassed || (tc.want != nil) != slices.Contains(out.Warnings, said) { + t.Errorf("%s: the step came to %+v", tc.name, out) + } + raw, ok := left.requests["ace"].Cases[0].Assignments["ace"] + if tc.want == nil { + if ok { + t.Errorf("%s: the case carries assignments %s", tc.name, raw) + } + continue + } + a, err := mmac.DecodeAssignments(raw) + var got []string + for _, m := range a.Modules { + got = append(got, m.Module) + } + if err != nil || !slices.Equal(got, tc.want) { + t.Errorf("%s: the case composes ace with %v (%v), want %v", tc.name, got, err, tc.want) + } + } // At the inputs state's cap the ask is refused, naming the store (§354). full := newRunStand(t, "src2:e1", "src2:e1", "d1") diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go index e4fac8b3..06eb445f 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go @@ -665,7 +665,7 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber, // The composition step (design 47 G §22, §354): the seat mesh-wants' accepted kind step, run by one run ask per machine. if bus != nil && js != nil && inputs != nil && p.publishWants != nil && runs != nil { run := &compositionRun{runs: runs, inputs: &compositionInputs{machines: w.machinesOf, callFile: bus.CallFile}, keeper: inputs, reads: &compositionReads{}, call: bus.CallKept, - trunk: trunkOf(iv, w.trunkName), newest: iv.newestOf(), watched: iv.watchedOf, assigned: w.assignedOn, running: w.runningOf, away: func(machine string) bool { return w.awayNow()[machine] }, put: runAskPublisher(js), ask: bus.CallFile, now: time.Now, logf: logger.Printf} + trunk: trunkOf(iv, w.trunkName), newest: iv.newestOf(), watched: iv.watchedOf, assigned: w.assignedOn, assignment: w.assignmentOf, running: w.runningOf, away: func(machine string) bool { return w.awayNow()[machine] }, put: runAskPublisher(js), ask: bus.CallFile, now: time.Now, logf: logger.Printf} steps := &compositionSteps{node: thisNode, say: p.publishWants, run: run.run, resume: run.resume, validate: run.validate, resumeValidate: run.resumeValidate, ended: runs.stepEnded, now: time.Now, logf: logger.Printf} move := steps.move(ctx) // the readers a rerun carried (§727, A-470d) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/world.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/world.go index bb82e620..024beb5b 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/world.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/world.go @@ -562,3 +562,9 @@ func (w *world) assignedOn(node string) []string { } return out } + +// assignmentOf is node's assignments, or false where none is held. +func (w *world) assignmentOf(node string) (mma.Assignments, bool) { + a, ok := w.assignments()[node] + return a, ok +} -- 2.54.0 From d428650ce4f82cf59451c6c41d46f087605a49e7 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 16:31:50 +0100 Subject: [PATCH 2/4] assigner: raise assignment-unlisted where a step leaves one out, clear it in the pass (H-A-149) A stale assignment left out of a machine's composition is now a finding the condition keeper carries: kind assignment-unlisted, scope delivery, id ., a warning, raised by the composition step that leaves it out. The pass over the assignments clears it when the assignment is gone or a watched branch of the module lists it again, so the clear never waits for the next step on that machine. Builds: design 47 H H-A-149, H-A-148 --- .../mesh-delivery-assigner/compositionrun.go | 52 ++++++++++++++++--- .../compositionrun_test.go | 51 ++++++++++++++++++ .../cmd/mesh-delivery-assigner/main.go | 4 +- .../cmd/mesh-delivery-assigner/pass.go | 30 +++++++++++ .../internal/assign/unlisted.go | 46 ++++++++++++++++ 5 files changed, 173 insertions(+), 10 deletions(-) create mode 100644 modules/mesh-delivery-assigner/internal/assign/unlisted.go 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 fe5d5e44..f85db835 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go @@ -22,6 +22,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer" "git.novox.be/novox/mesh-sdk/go/keys" + "mesh-delivery-assigner/internal/assign" ) // The run of a composition step (design 47 G §354, §63, §64, §718; A-226, A-238, A-240, A-252, A-254, A-261): the step reads one @@ -65,6 +66,9 @@ type compositionRun struct { // assignment is the machine's assignments whole, which the case composes with those modules left out (H-A-148). assigned func(node string) []string assignment func(node string) (mma.Assignments, bool) + // findings is where the step raises the finding assignment-unlisted of each assignment it leaves out (H-A-149); the pass over + // the assignments clears it. + findings assign.Findings // running is the last `running` heard of a module on a node (world.runningOf), never the node-engine's bucket. running func(node, module string) (ne.Running, bool) // away says the watchman holds machine away (machine-away, not back since): the one presence the assigner keeps (world.awayNow), @@ -599,14 +603,7 @@ func (r *compositionRun) unlistedOn(node string) []string { newest := r.newest() var out []string for _, m := range r.assigned(node) { - listed := false - for _, b := range r.watched(m) { - if _, ok := newest[b].Entries[m]; ok { - listed = true - break - } - } - if !listed { + if !listedOn(newest, r.watched(m), m) { out = append(out, m) } } @@ -641,9 +638,40 @@ func (r *compositionRun) leftOut(node string, manifests map[string]composer.Mani return nil, fmt.Errorf("its assignments with %s left out cannot be encoded: %w", strings.Join(unlisted, ", "), err) } r.logf("%s: the composition leaves out %s, assigned there and listed on no watched branch (H-A-148)", node, strings.Join(unlisted, ", ")) + for _, m := range unlisted { + r.raiseUnlisted(node, m) + } return map[string]json.RawMessage{node: raw}, nil } +// raiseUnlisted writes the finding assignment-unlisted of module on node (H-A-149); one not written is said in the journal. +func (r *compositionRun) raiseUnlisted(node, module string) { + if r.findings.Put == nil { + return + } + now := r.now + if now == nil { + now = time.Now + } + f, err := assign.UnlistedFinding(node, module, now()) + if err == nil { + err = r.findings.Put(f) + } + if err != nil { + r.logf("the finding %s is not written: %v", assign.UnlistedKey(node, module), err) + } +} + +// listedOn says whether the newest revision of one of module's watched branches lists it (H-A-143, H-A-144). +func listedOn(newest map[string]mcc.Half, watched []string, module string) bool { + for _, b := range watched { + if _, ok := newest[b].Entries[module]; ok { + return true + } + } + return false +} + // nodeEngineEntry is the entry of the module that claims the seat node-engine, or false. func nodeEngineEntry(entries map[string]meshcatalog.CatalogEntry) (meshcatalog.CatalogEntry, bool) { for _, name := range slices.Sorted(mapsKeys(entries)) { @@ -771,6 +799,14 @@ func (iv *catalogViews) newestOf() func() map[string]mcc.Half { } } +// listed says whether one of module's watched branches lists it in the newest revision the views hold (H-A-149's clear). +func (iv *catalogViews) listed(module string) bool { + if iv == nil || iv.h == nil { + return false + } + return listedOn(iv.h.views(), iv.h.watchedOf(module), module) +} + // watchedOf is a module's watched branches in its registration's order (halves.watchedOf); none while the half is not followed. func (iv *catalogViews) watchedOf(module string) []string { if iv == nil || iv.h == nil { 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 b1fe0423..d6c37833 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 @@ -14,11 +14,14 @@ import ( mmac "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient" mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner" ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" + mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" meshcatalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" meshwants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer" + "git.novox.be/novox/mesh-sdk/go/keys" + "mesh-delivery-assigner/internal/assign" ) const ( @@ -310,7 +313,16 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) { return a, true } left.verdict = func(string) (composer.Machine, bool) { return composer.Machine{Composes: true}, true } + raised := map[string][]byte{} + left.r.findings = assign.Findings{Put: putInto(raised)} out := left.r.run(context.Background(), "ask-step", step) + // H-A-149: the step that leaves an assignment out raises assignment-unlisted, scope delivery, id ., a warning. + var f mcseat.Finding + _ = json.Unmarshal(raised[assign.UnlistedKey("ace", "checker")], &f) + if want := tc.want != nil; want != (f.Kind == assign.KindAssignmentUnlisted && f.Scope == "delivery" && f.ID == "ace.checker" && + f.Severity == mcseat.FindingSeverityWarning) || (!want && len(raised) != 0) { + t.Errorf("%s: raised %v", tc.name, raised) + } said := "ace is assigned checker, which no watched branch lists (H-A-143)" if out.Outcome != meshwants.StepEndedOutcomePassed || (tc.want != nil) != slices.Contains(out.Warnings, said) { t.Errorf("%s: the step came to %+v", tc.name, out) @@ -721,3 +733,42 @@ func TestACompositionTakesEachModuleAcrossTheWatchedBranches(t *testing.T) { }) } } + +// Design 47 H-A-149: the pass over the assignments clears assignment-unlisted when the assignment is gone or one of the module's +// watched branches lists it again, and keeps it while it stands; another finding is left alone. +func TestThePassClearsAnUnlistedAssignmentsFinding(t *testing.T) { + for _, tc := range []struct { + name string + assigned []string // novox's modules + listed bool + kept bool + }{ + {"still assigned and listed nowhere: kept", []string{"checker"}, false, true}, + {"the assignment gone: cleared", []string{"web"}, false, false}, + {"listed again: cleared", []string{"checker"}, true, false}, + } { + t.Run(tc.name, func(t *testing.T) { + w := newWorld() + a := mma.Assignments{V: keys.Version, Node: "novox"} + for _, m := range tc.assigned { + a.Modules = append(a.Modules, mma.PlacedModule{Module: m}) + } + putAssignments(w, a) + findings := map[string][]byte{} + f, _ := assign.UnlistedFinding("novox", "checker", time.Now()) + _ = putInto(findings)(f) + other, _ := assign.UnplacedFinding("g14", time.Now()) + _ = putInto(findings)(other) + p := &passer{w: w, logf: t.Logf, listed: func(string) bool { return tc.listed }, findings: assign.Findings{Put: putInto(findings), + Delete: func(k string) error { delete(findings, k); return nil }, + Keys: func() ([]string, error) { return slices.Collect(maps.Keys(findings)), nil }}} + p.clearUnlisted() + if _, ok := findings[assign.UnlistedKey("novox", "checker")]; ok != tc.kept { + t.Errorf("the finding kept %v, want %v", ok, tc.kept) + } + if _, ok := findings[assign.UnplacedKey("g14")]; !ok { + t.Error("another finding is cleared") + } + }) + } +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go index 06eb445f..2733c801 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go @@ -581,7 +581,7 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber, } } p := &passer{kvs: kvs, w: w, logf: logger.Printf, say: say, findings: findings, said: map[string]bool{}, answeredAt: map[string]uint64{}, - reads: reads, seats: gate, askForFile: getenv("MESH_ASSIGNER_ASK_OPERATOR_FOR_FILE")} + reads: reads, seats: gate, askForFile: getenv("MESH_ASSIGNER_ASK_OPERATOR_FOR_FILE"), listed: iv.listed} p.askOperatorFor() // the setting ask-operator-for said once at the start (design 47 G A-425a) // The setting tier-bound (design 47 H §751) and the one timer that wakes the pass at a tier's deadline (H-A-56). tierBound, err := tierBoundSetting(getenv) @@ -665,7 +665,7 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber, // The composition step (design 47 G §22, §354): the seat mesh-wants' accepted kind step, run by one run ask per machine. if bus != nil && js != nil && inputs != nil && p.publishWants != nil && runs != nil { run := &compositionRun{runs: runs, inputs: &compositionInputs{machines: w.machinesOf, callFile: bus.CallFile}, keeper: inputs, reads: &compositionReads{}, call: bus.CallKept, - trunk: trunkOf(iv, w.trunkName), newest: iv.newestOf(), watched: iv.watchedOf, assigned: w.assignedOn, assignment: w.assignmentOf, running: w.runningOf, away: func(machine string) bool { return w.awayNow()[machine] }, put: runAskPublisher(js), ask: bus.CallFile, now: time.Now, logf: logger.Printf} + trunk: trunkOf(iv, w.trunkName), newest: iv.newestOf(), watched: iv.watchedOf, assigned: w.assignedOn, assignment: w.assignmentOf, findings: findings, running: w.runningOf, away: func(machine string) bool { return w.awayNow()[machine] }, put: runAskPublisher(js), ask: bus.CallFile, now: time.Now, logf: logger.Printf} steps := &compositionSteps{node: thisNode, say: p.publishWants, run: run.run, resume: run.resume, validate: run.validate, resumeValidate: run.resumeValidate, ended: runs.stepEnded, now: time.Now, logf: logger.Printf} move := steps.move(ctx) // the readers a rerun carried (§727, A-470d) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go index 4a5afd27..8ce224a0 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go @@ -56,6 +56,8 @@ type passer struct { findings assign.Findings // unplaced are the nodes whose unplaced finding this process wrote. unplaced map[string]bool + // listed says whether a module's watched branches list it (catalogViews.listed), for the clear of assignment-unlisted. + listed func(module string) bool // answeredAt is, by the id of a backup ask, how many values the have had when its answer was written into the want. answeredAt map[string]uint64 // now is the clock; nil is time.Now. @@ -208,6 +210,7 @@ func (p *passer) wants(ctx context.Context) { })) chosen, _ := assign.DecodePolicies(p.w.read(assign.PoliciesBucket())) defer p.unplacedFindings() + defer p.clearUnlisted() defer func() { p.seatHolders(ctx, viewOf(p.w.trunkName()).manifests) }() p.clearStaleCalls() placed := p.w.placedNodes() @@ -655,6 +658,33 @@ func (p *passer) unplacedFindings() { } } +// clearUnlisted clears, in the pass over the assignments, each finding assignment-unlisted whose assignment is gone or whose module +// one of its watched branches lists again, so the clear never waits for the next composition step on that machine (H-A-149). +func (p *passer) clearUnlisted() { + if p.findings.Keys == nil || p.findings.Delete == nil || p.listed == nil { + return + } + keys, err := p.findings.Keys() + if err != nil { + p.logf("the findings assignment-unlisted are not read, so none is cleared in this pass: %v", err) + return + } + assignments := p.w.assignments() + for _, key := range keys { + node, module, ok := assign.UnlistedOfKey(key) + if !ok { + continue + } + assigned := slices.ContainsFunc(assignments[node].Modules, func(m mma.PlacedModule) bool { return m.Module == module }) + if assigned && !p.listed(module) { + continue + } + if err := p.findings.Delete(key); err != nil { + p.logf("the finding %s is not cleared: %v", key, err) + } + } +} + // seatHolders writes the seat mesh-module-assigner's state seat-holders from every node's assignments (ADR 0571 §4): one key per // seat held once, ``, and one per node of a node seat, `.`, written only where it differs, and a key no // assignments holds any more deleted. A pass follows each assignments change and each manifest the indexer takes in, so no diff --git a/modules/mesh-delivery-assigner/internal/assign/unlisted.go b/modules/mesh-delivery-assigner/internal/assign/unlisted.go new file mode 100644 index 00000000..11b4f0b8 --- /dev/null +++ b/modules/mesh-delivery-assigner/internal/assign/unlisted.go @@ -0,0 +1,46 @@ +package assign + +import ( + "fmt" + "strings" + "time" + + mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" + "git.novox.be/novox/mesh-sdk/go/views" +) + +// KindAssignmentUnlisted is a module assigned to a node that no watched branch lists, left out of that node's composition +// (design 47 H-A-148, H-A-149): scope delivery, id `.`, severity warning. +const ( + KindAssignmentUnlisted = "assignment-unlisted" + ScopeAssignmentUnlisted = "delivery" +) + +// UnlistedKey is its finding's key, `delivery...assignment-unlisted`. +func UnlistedKey(node, module string) string { + return views.FindingKey(ScopeAssignmentUnlisted, KeyID(node+"."+module), KindAssignmentUnlisted) +} + +// UnlistedOfKey is the node and module of an assignment-unlisted finding's key, or false for another finding's. +func UnlistedOfKey(key string) (node, module string, ok bool) { + rest, ok := strings.CutPrefix(key, ScopeAssignmentUnlisted+".") + if !ok { + return "", "", false + } + if rest, ok = strings.CutSuffix(rest, "."+KindAssignmentUnlisted); !ok { + return "", "", false + } + node, module, ok = strings.Cut(rest, ".") + return node, module, ok && node != "" && module != "" && !strings.Contains(module, ".") +} + +// UnlistedFinding is the finding of module assigned to node and listed on none of its watched branches, raised by the composition +// step that leaves the assignment out (H-A-149). +func UnlistedFinding(node, module string, at time.Time) (mcseat.Finding, error) { + summary := fmt.Sprintf("%s is assigned %s, which no watched branch lists, so its composition leaves the assignment out", node, module) + return encode(Observed{Scope: ScopeAssignmentUnlisted, ID: node + "." + module, Kind: KindAssignmentUnlisted, Machine: node, + Severity: mcseat.FindingSeverityWarning, Summary: summary, Headline: clipHeadline(module + " on " + node + " is listed nowhere"), + Explanation: summary + ": a stale assignment is a fault of the assignments, not of the change judged (ADR 0578 §2). " + + "Take it off, or register the module on a watched branch.", + Source: "assigner." + KindAssignmentUnlisted}, at) +} -- 2.54.0 From f053e3b04162f8d5dce27939cdbb0e335f25d2f5 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 16:47:57 +0100 Subject: [PATCH 3/4] mesh-wants: a composition run carries its unlisted assignments (H-A-153) The judgement of every step reading a run, and the resume after a restart, read only the stored run; the set of assignments left out is written there when the run starts, so it is not kept in a step's memory. Builds: design 47 H H-A-153 --- .../mesh-delivery-contracts/go/seats/meshwants/contract.go | 2 ++ modules/mesh-delivery-contracts/seats/mesh-wants/seat.json | 7 +++++++ .../mesh-delivery-contracts/ts/seats/meshwants/index.d.ts | 2 ++ 3 files changed, 11 insertions(+) diff --git a/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go b/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go index 9ef9156c..a4dc8aa9 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go @@ -899,6 +899,8 @@ type CompositionRun struct { // the outcome's words Said string `json:"said,omitempty"` Started *time.Time `json:"started,omitempty"` + // the module names of the assignments left out of the machine's composition, those no watched branch's newest revision lists, written when the run starts and read by every step's judgement and by the resume (design 47 H-A-152, H-A-153) + Unlisted []string `json:"unlisted,omitempty"` // that machine's composer verdict (design 47 G §721) Verdict map[string]any `json:"verdict,omitempty"` } diff --git a/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json b/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json index 11f475d6..f09ae1f9 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json @@ -1701,6 +1701,13 @@ "verdict": { "type": "object", "description": "that machine's composer verdict (design 47 G §721)" + }, + "unlisted": { + "type": "array", + "items": { + "type": "string" + }, + "description": "the module names of the assignments left out of the machine's composition, those no watched branch's newest revision lists, written when the run starts and read by every step's judgement and by the resume (design 47 H-A-152, H-A-153)" } }, "required": [ diff --git a/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts index 5e250410..0b53c871 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts @@ -319,6 +319,8 @@ export interface CompositionRun { /** the outcome's words */ "said"?: string; "started"?: string; + /** the module names of the assignments left out of the machine's composition, those no watched branch's newest revision lists, written when the run starts and read by every step's judgement and by the resume (design 47 H-A-152, H-A-153) */ + "unlisted"?: string[]; /** that machine's composer verdict (design 47 G §721) */ "verdict"?: Record; } -- 2.54.0 From 0b1ce0898517d0a2125c0d421a3006f73b37e241 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 16:51:28 +0100 Subject: [PATCH 4/4] assigner: one set of unlisted assignments, carried on the run (H-A-152, H-A-153) The leaving-out took every assigned module the case's manifests lacked, while the judgement said only those the watched branches' newest revisions list nowhere, read again at judgement time. Now the set is read once from the newest revisions when the run starts, written on the run, and used for the leaving-out, the finding and every step's judgement and the resume. The candidate never enters it: a module the change drops while still assigned stays in and fails the composition as its own fault. While no newest revision is followed nothing is left out. Builds: design 47 H H-A-152, H-A-153 --- .../mesh-delivery-assigner/compositionrun.go | 57 +++++++++++++------ .../compositionrun_test.go | 31 ++++++++-- .../mesh-delivery-assigner/compositionruns.go | 2 +- .../compositionruns_test.go | 2 +- 4 files changed, 68 insertions(+), 24 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 f85db835..8c5ad01e 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go @@ -139,7 +139,7 @@ func (r *compositionRun) read(ctx context.Context, module string, keys []string, runs := r.runs.await(ctx, keys) setPhase(ctx, meshwants.StepProgressEventPhaseReport) for _, key := range keys { - ends = append(ends, judgeRun(module, runs[key], r.unlistedOn(runs[key].Machine))) + ends = append(ends, judgeRun(module, runs[key])) } out := outcomeOf(ends) out.Shared = r.runs.sharedOf(keys, runs) @@ -248,6 +248,21 @@ func (r *compositionRun) start(ctx context.Context, key string, run meshwants.Co r.logf("the composition run %s is not ended: %v", key, err) } } + // The one set of unlisted assignments, read once at the run's start and carried on the run to the leaving-out, the finding and + // every step's judgement, the resume's too (design 47 H-A-152, H-A-153). + unlisted := r.unlistedOn(node) + if len(unlisted) > 0 { + if _, _, err := r.runs.change(key, func(c *meshwants.CompositionRun) bool { + if c.Ask != ask || c.Ended != nil { + return false + } + c.Unlisted = unlisted + return true + }); err != nil { + end(node + ": the run's unlisted assignments are not written: " + err.Error()) + return + } + } if err := prep.get(ctx); err != nil { end(node + ": " + err.Error()) return @@ -263,7 +278,7 @@ func (r *compositionRun) start(ctx context.Context, key string, run meshwants.Co return } cs := composer.Case{Name: changeCase, Manifests: prep.manifests, None: prep.none} - if left, err := r.leftOut(node, prep.manifests); err != nil { + if left, err := r.leftOut(node, unlisted); err != nil { end(node + ": " + err.Error()) return } else if left != nil { @@ -316,12 +331,13 @@ const notTried = "not tried: the search reached its bound" // it, on the node's own account; a verdict with no `blamed` (a composer before §721) is judged as before, with the warning "the // composer names no culprits"; otherwise the machine passes, with a warning for each other module blamed there. // -// unlisted are the modules the machine is assigned that none of their watched branches lists, left out of its composition: each is -// said on every path, in the machine's failed or could-not-run words where one is set, else as a warning, never the machine's -// failure and never dropped in silence (H-A-143, H-A-144, H-A-148). -func judgeRun(module string, run meshwants.CompositionRun, unlisted []string) machineEnd { +// The run's unlisted are the modules the machine is assigned that no watched branch's newest revision lists, left out of its +// composition, as the run's start read them (H-A-152, H-A-153): each is said on every path, in the machine's failed or +// could-not-run words where one is set, else as a warning, never the machine's failure and never dropped in silence (H-A-143, +// H-A-144, H-A-148). +func judgeRun(module string, run meshwants.CompositionRun) machineEnd { end := judgeVerdict(module, run) - for _, u := range unlisted { + for _, u := range run.Unlisted { said := run.Machine + " is assigned " + u + ", which no watched branch lists (H-A-143)" switch { case end.failed != "": @@ -594,16 +610,23 @@ func acrossBranches(step meshwants.StepRun, candidate mcc.Half, newest map[strin return out } -// unlistedOn is the modules the assignments place on node that the newest revision of none of their watched branches lists, a -// module with no watched branches among them (H-A-143, H-A-144), by name. +// unlistedOn is the one set of unlisted assignments of node (H-A-152): the modules the assignments place there that the newest +// revision of none of their watched branches lists, a module with no watched branches among them (H-A-143, H-A-144), by name. +// The candidate never enters it, so a module the change drops while still assigned stays in the composition and fails it as the +// change's own fault (ADR 0578 §2). Where the newest revisions are not followed yet nothing is unlisted: none while no branch's +// newest is held, and not a module one of whose watched branches' newest is not held yet. func (r *compositionRun) unlistedOn(node string) []string { if r.assigned == nil || r.newest == nil || r.watched == nil { return nil } newest := r.newest() + if len(newest) == 0 { + return nil + } var out []string for _, m := range r.assigned(node) { - if !listedOn(newest, r.watched(m), m) { + watched := r.watched(m) + if !listedOn(newest, watched, m) && !slices.ContainsFunc(watched, func(b string) bool { _, held := newest[b]; return !held }) { out = append(out, m) } } @@ -611,12 +634,12 @@ func (r *compositionRun) unlistedOn(node string) []string { return slices.Compact(out) } -// leftOut is the case's assignments of node with each module the case's manifests do not hold (none of its watched branches lists -// it) left out, or nil where none is (the case then composes the input's): a stale assignment is a fault of the assignments, not of -// the change judged, so it is left out of the composition, said in the journal and, at the judgement, as unlisted (design 47 -// H-A-148, H-A-143; ADR 0578 §2). -func (r *compositionRun) leftOut(node string, manifests map[string]composer.Manifest) (map[string]json.RawMessage, error) { - if r.assignment == nil { +// leftOut is the case's assignments of node with each module of the run's unlisted set left out, or nil where none is (the case +// then composes the input's): a stale assignment is a fault of the assignments, not of the change judged, so it is left out of the +// composition, said in the journal, raised as assignment-unlisted and, at the judgement, said as unlisted from the same set +// (design 47 H-A-148, H-A-149, H-A-152, H-A-143; ADR 0578 §2). +func (r *compositionRun) leftOut(node string, set []string) (map[string]json.RawMessage, error) { + if r.assignment == nil || len(set) == 0 { return nil, nil } a, ok := r.assignment(node) @@ -625,7 +648,7 @@ func (r *compositionRun) leftOut(node string, manifests map[string]composer.Mani } var unlisted []string for _, m := range a.Modules { - if _, held := manifests[m.Module]; !held { + if slices.Contains(set, m.Module) { unlisted = append(unlisted, m.Module) } } 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 d6c37833..9bf5111e 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 @@ -293,17 +293,32 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) { } // A stale assignment is left out of the case's assignments as well, said, and the machine composes; a listed module stays in - // (H-A-148, ADR 0578 §2). + // (H-A-148, ADR 0578 §2). The one set is the watched branches' newest revisions', carried on the run (H-A-152, H-A-153): a module + // the candidate drops while the newest still lists it stays in, the change's own fault, and while no newest revision is followed + // nothing is left out. + dropsWeb := func() map[string]mcc.Half { + h := across.r.newest() + h["main"] = mcc.Half{Revision: meshcatalog.CatalogRevision{Branch: "main", Revision: 6}, + Entries: map[string]meshcatalog.CatalogEntry{"m": {Module: "m", Manifest: map[string]any{"module": "m"}}, + "web": {Module: "web", Fp: "w1", Manifest: map[string]any{"module": "web"}}}} + return h + } for _, tc := range []struct { name string assigned []string - want []string // the case's modules of ace; nil: the input's assignments + newest func() map[string]mcc.Half // nil: across's + want []string // the case's modules of ace; nil: the input's assignments }{ - {"a stale assignment left out and said, the machine composes", []string{"m", "f1-circuits", "checker"}, []string{"m", "f1-circuits"}}, - {"listed modules alone: the input's assignments", []string{"m", "f1-circuits"}, nil}, + {"a stale assignment left out and said, the machine composes", []string{"m", "f1-circuits", "checker"}, nil, []string{"m", "f1-circuits"}}, + {"listed modules alone: the input's assignments", []string{"m", "f1-circuits"}, nil, nil}, + {"a module the candidate drops, the newest lists: kept", []string{"m", "f1-circuits", "web"}, dropsWeb, nil}, + {"no newest revision followed: nothing left out", []string{"m", "checker"}, func() map[string]mcc.Half { return map[string]mcc.Half{} }, nil}, } { left := newRunStand(t, "src2:e1", "src2:e1", "d1") left.r.newest, left.r.watched = across.r.newest, across.r.watched + if tc.newest != nil { + left.r.newest = tc.newest + } left.r.assigned = func(string) []string { return tc.assigned } left.r.assignment = func(node string) (mma.Assignments, bool) { a := mma.Assignments{Node: node} @@ -327,6 +342,10 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) { if out.Outcome != meshwants.StepEndedOutcomePassed || (tc.want != nil) != slices.Contains(out.Warnings, said) { t.Errorf("%s: the step came to %+v", tc.name, out) } + if run, _, _, _ := left.runs.read(runKeyOf("main.7", "ace")); (tc.want != nil) != slices.Equal(run.Unlisted, []string{"checker"}) || + (tc.want == nil && run.Unlisted != nil) { + t.Errorf("%s: the run carries the unlisted %v", tc.name, run.Unlisted) + } raw, ok := left.requests["ace"].Cases[0].Assignments["ace"] if tc.want == nil { if ok { @@ -549,7 +568,9 @@ func TestAMachineIsJudgedByTheModulesItBlames(t *testing.T) { []string{"ace is assigned photos, which no watched branch lists (H-A-143)"}, []string{"photos"}}, } { t.Run(tc.name, func(t *testing.T) { - e := judgeRun(tc.module, tc.run, tc.unlisted) + run := tc.run + run.Unlisted = tc.unlisted // the set the run's start wrote (H-A-153) + e := judgeRun(tc.module, run) if e.failed != tc.failed || e.couldNot != tc.couldNo || !slices.Equal(e.warnings, tc.warnings) { t.Errorf("judged %+v, want failed %q, could not run %q, warnings %q", e, tc.failed, tc.couldNo, tc.warnings) } diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns.go index f8844555..22d71366 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns.go @@ -818,7 +818,7 @@ func (r *compositionRuns) leave(pipeline string, stop func(ids []string)) ([]str // passedOn is whether the step of module passed on the machine of an ended run (§722): neither failed nor could not run there. func passedOn(module string, run meshwants.CompositionRun) bool { - e := judgeRun(module, run, nil) // the unlisted modules change only the words, never whether it passed + e := judgeVerdict(module, run) // the unlisted modules change only the words, never whether it passed return e.failed == "" && e.couldNot == "" } diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns_test.go index d0be3c0d..7a0ccf15 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns_test.go @@ -416,7 +416,7 @@ func TestACompositionRunsBoundTimesOwedProgress(t *testing.T) { len(*drops) != 1 || !strings.HasPrefix((*drops)[0], "run-1: ") { t.Fatalf("past the bound: %+v, drops %v", run, *drops) } - if got := judgeRun("a", run, nil); got.couldNot != run.Said { + if got := judgeRun("a", run); got.couldNot != run.Said { t.Errorf("a reader of the run past its bound: %+v", got) } late := buildstep.StepEnded{Ask: "run-1", Asker: runAsker, Outcome: buildstep.OutcomePassed, Output: "{}"} -- 2.54.0