The node-engine's live path holds a module whose claim or credential fails (issue 1966, review round 1)
mesh/delivery merged: source.main moved to novox/mesh-host@6e461bd24aa5
mesh/check being carried to ef41fa2e2796 on 6e461bd24aa5 | from 7c483da93a03

compose.CompositionsHolding returns the modules the declaration leaves out for a claim that cannot be held or a refused
credential; frombus composeEach holds each with those words, so the node-engine keeps what it handed of the module (no
stop of a running module), the candidate answer and the check's sandbox name it refused, and the rest composes.
CredentialsNeeded asks nothing for a held module. Resolve and checkClaims move to a test helper (production uses
ResolveHolding and holdClaims); a pass refused anyway names a held module's reason among the others.

Quick fix: Declared.Held read in the composer only. Thorough, chosen: the same held words reach every reader of the
composition (selfcompose, ComposeSent, the candidate answer) through composeEach's one hold path.

Claude-Session: https://claude.ai/code/session_01NcbgfFfQ4Z9UE5jK32PmE5
This commit is contained in:
2026-11-09 13:04:55 +01:00
parent 868ee6beb0
commit ef41fa2e27
7 changed files with 125 additions and 57 deletions
+14 -1
View File
@@ -337,7 +337,8 @@ func composeEach(in compose.Input, node string, fps map[string]string, applied b
hold(m, failed[m], "")
}
for {
out, skipped, stood, err = compose.CompositionsIn(in, node, fps, mode)
var leftOut map[string]string
out, skipped, stood, leftOut, err = compose.CompositionsHolding(in, node, fps, mode)
if err != nil {
module, leave := culprit(in, node, fps, mode, failed, err)
if module == "" {
@@ -346,6 +347,18 @@ func composeEach(in compose.Input, node string, fps map[string]string, applied b
hold(module, err.Error(), leave)
continue
}
// A module the node leaves out because its claim cannot be held or its credential was refused (issue 1966) is held with
// those words: its handed composition stays and the check names it refused; the rest composes.
heldNow := false
for _, m := range sortedKeys(leftOut) {
if _, done := failed[m]; !done {
hold(m, leftOut[m], "")
heldNow = true
}
}
if heldNow {
continue
}
again := false
if applied && len(stood) > 0 {
placed := map[string]bool{}
@@ -300,3 +300,35 @@ func aHeldModuleOfItsOwnAccountNeverRefusesTheNode(t *testing.T) {
}
}
}
// Issue 1966: two modules claiming one seat held once cost the second claimant, not the node: Compose holds it with the claim's
// words, composes the first, and (the node-engine keeping what it handed of a held module) leaves its composition out, whether or
// not it runs.
func TestASecondClaimantOfASeatIsHeldAndTheNodeComposesTheRest(t *testing.T) {
first := `{"module":"alpha","version":"1","claims":[{"name":"the-seat","scope":"node"}]}`
second := `{"module":"beta","version":"1","claims":[{"name":"the-seat","scope":"node"}]}`
for _, running := range []bool{false, true} {
b, fps := aNode(t, first, second)
scope := Scope{Node: "n1"}
if running {
scope.Running = []engcomp.Composed{{Node: "n1", Module: "beta", FP: fps["beta"], Resources: nil}}
}
got, _, held, err := Compose(context.Background(), b, Mesh{}, scope, fps)
if err != nil || len(held) != 1 || !strings.Contains(held["beta"], "alpha and beta both claim") {
t.Fatalf("running %v: err %v, held %v; want beta held with the claim's words", running, err, held)
}
for _, c := range got {
if c.Module == "beta" {
t.Errorf("running %v: the held claimant is composed: %+v", running, c)
}
}
// A check that adds the second claimant is refused for it, in the claim's words, and not judged to compose.
p := b.assignments["n1"]
ans := Answer(context.Background(), b, Mesh{}, Scope{Node: "n1", Assignments: map[string]*meshmoduleassigner.Assignments{"n1": &p}},
fps, scope.Running, "p-h1", 1)
if ans.Verdict != nodeengine.CandidateAnswerVerdictRefused || len(ans.Refusals) != 1 || ans.Refusals[0].Module != "beta" ||
!strings.Contains(ans.Refusals[0].Why, "both claim") {
t.Errorf("running %v: the answer is %+v, want beta refused with the claim's words", running, ans)
}
}
}