Design 47 H1: an assignment no watched branch lists is left out of a machine's composition, said and raised as a finding (H-A-148, H-A-149, H-A-152, H-A-153) #272

Merged
mesh-tools merged 4 commits from fix/47-H1-unlisted-assignment-left-out into main 2026-11-20 15:54:36 +00:00
11 changed files with 337 additions and 23 deletions
@@ -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"
@@ -20,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
@@ -59,8 +62,13 @@ 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)
// 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),
@@ -131,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)
@@ -240,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
@@ -254,8 +277,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, unlisted); 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,11 +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: 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).
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 != "":
@@ -578,23 +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) {
listed := false
for _, b := range r.watched(m) {
if _, ok := newest[b].Entries[m]; ok {
listed = true
break
}
}
if !listed {
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)
}
}
@@ -602,6 +634,67 @@ func (r *compositionRun) unlistedOn(node string) []string {
return slices.Compact(out)
}
// 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)
if !ok {
return nil, nil
}
var unlisted []string
for _, m := range a.Modules {
if slices.Contains(set, m.Module) {
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, ", "))
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)) {
@@ -729,6 +822,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 {
@@ -11,12 +11,17 @@ 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"
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 (
@@ -283,6 +288,80 @@ 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). 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
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"}, 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}
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 }
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 <node>.<module>, 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)
}
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 {
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")
@@ -489,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)
}
@@ -673,3 +754,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")
}
})
}
}
@@ -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 == ""
}
@@ -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: "{}"}
@@ -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, 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)
@@ -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, `<seat>`, and one per node of a node seat, `<seat>.<node>`, 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
@@ -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
}
@@ -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 `<node>.<module>`, severity warning.
const (
KindAssignmentUnlisted = "assignment-unlisted"
ScopeAssignmentUnlisted = "delivery"
)
// UnlistedKey is its finding's key, `delivery.<node>.<module>.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)
}
@@ -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"`
}
@@ -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": [
@@ -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<string, unknown>;
}