H-14: a module held for its claim is the finding module-held until it is composed or no longer wanted

Builds: design 47 main file (A claim problem holds its module), test 55

Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
2026-11-11 12:12:55 +01:00
parent f3813a279e
commit b41a0d59b6
6 changed files with 208 additions and 7 deletions
+10
View File
@@ -20,11 +20,13 @@ import (
"git.novox.be/novox/mesh-networking/modules/mesh-wireguard/go/overlay"
"git.novox.be/novox/mesh-sdk/go/declaration"
"git.novox.be/novox/mesh-sdk/go/views"
"github.com/novox/mesh-host/internal/agent"
"github.com/novox/mesh-host/internal/apply"
"github.com/novox/mesh-host/internal/compose/frombus"
"github.com/novox/mesh-host/internal/link"
"github.com/novox/mesh-host/internal/liveness"
"github.com/novox/mesh-host/internal/seatwait"
"github.com/novox/mesh-host/internal/selfcompose"
"github.com/novox/mesh-host/internal/store"
)
@@ -598,6 +600,9 @@ func nodeAgent(ctx context.Context, opts options, signer ed25519.PublicKey, trus
}
// The marks of the haves run off the composition pass, each bounded (see marker).
marks := newMarker(run)
findings := findingsOfTheNode{session}
heldFindings := &seatwait.HeldKeeper{Node: node, Observer: "node-engine", Writer: findings,
Left: func() ([]views.Finding, error) { return findings.left(node) }, Say: say}
hooks := composerHooks{
seatList: seats,
seatListFailed: err != nil,
@@ -626,6 +631,11 @@ func nodeAgent(ctx context.Context, opts options, signer ed25519.PublicKey, trus
// A module held alone marks that module, never the others (issue 1126); the marking never holds the pass.
marks.set("refused", func(ctx context.Context) { now.NotComposedEach(ctx, why, held) })
}
// And each module held says it as the finding `module-held`, cleared when it is composed again or no longer
// wanted here. A node refused whole (why) says nothing of its modules: their findings stand as they were.
if why == "" && run.Err() == nil {
marks.set("module-held", func(context.Context) { heldFindings.Reconcile(held) })
}
},
// And what it keeps of a module as it runs, for a manifest that does not say it yet: on the module's have (ADR 0601 §4).
kept: func(kept map[string][]string) {
+29 -3
View File
@@ -107,10 +107,16 @@ func (realClock) AfterFunc(d time.Duration, f func()) seatwait.Timer {
type findingsOfTheNode struct{ session *link.Session }
func (w findingsOfTheNode) encode(f views.Finding) (string, []byte, error) {
key := conditions.Key(conditions.ScopeMachine, f.ID, f.Kind)
// The seat list's finding is of the machine; a held module's is of the module on a machine, `<module>.<node>`.
scope, machine, source := conditions.ScopeMachine, f.ID, "seat-list-unread"
if f.Kind == seatwait.HeldKind {
scope, source = conditions.ScopeModule, seatwait.HeldKind
machine = f.ID[strings.LastIndex(f.ID, ".")+1:]
}
key := conditions.Key(scope, f.ID, f.Kind)
v := condseat.FindingsByKeyValue{V: 1, Key: key, Kind: f.Kind, Observer: f.Observer, Severity: conditions.Warning,
Subject: condseat.Subject{Scope: conditions.ScopeMachine, ID: f.ID, Machine: f.ID}, Summary: f.Summary,
Headline: f.Headline, Explanation: f.Explanation, Source: "seat-list-unread", At: f.At.UTC()}
Subject: condseat.Subject{Scope: scope, ID: f.ID, Machine: machine}, Summary: f.Summary,
Headline: f.Headline, Explanation: f.Explanation, Source: source, At: f.At.UTC()}
if err := conditions.CheckFinding(v); err != nil {
return "", nil, err
}
@@ -118,6 +124,26 @@ func (w findingsOfTheNode) encode(f views.Finding) (string, []byte, error) {
return key, raw, err
}
// left is the findings of held modules an earlier run of this engine left on node: its keys of this kind.
func (w findingsOfTheNode) left(node string) ([]views.Finding, error) {
keys, err := w.session.FindingKeys()
if err != nil {
return nil, err
}
var out []views.Finding
for _, k := range keys {
id, ok := strings.CutPrefix(k, conditions.ScopeModule+".")
if !ok {
continue
}
if id, ok = strings.CutSuffix(id, "."+seatwait.HeldKind); !ok || !strings.HasSuffix(id, "."+node) {
continue
}
out = append(out, views.Finding{Observer: "node-engine", Kind: seatwait.HeldKind, ID: id})
}
return out, nil
}
func (w findingsOfTheNode) Put(f views.Finding) error {
key, raw, err := w.encode(f)
if err != nil {
+8
View File
@@ -3,6 +3,8 @@ package main
import (
"testing"
"git.novox.be/novox/mesh-sdk/go/views"
"github.com/novox/mesh-host/internal/seatwait"
"github.com/novox/mesh-host/internal/selfcompose"
)
@@ -19,4 +21,10 @@ func TestAReaderThatCouldNotStartHoldsTheComposer(t *testing.T) {
if got := composerEnv(nil, "n1", func(string) {}, composerHooks{}).SeatList; got != nil {
t.Errorf("a composer with no reader asked for gates by %v, want none (the shadow)", got)
}
// The finding of a held module is of the module on its machine, in a layout the condition keeper accepts (design 47, test 55).
key, raw, err := findingsOfTheNode{}.encode(views.Finding{Observer: "node-engine", Kind: seatwait.HeldKind,
ID: seatwait.HeldID("mesh-grants", "ace"), Summary: "mesh-grants is held on ace: x", Headline: "h", Explanation: "e"})
if err != nil || key != "module.mesh-grants.ace.module-held" || len(raw) == 0 {
t.Errorf("a held module's finding encodes as %q, %v", key, err)
}
}