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
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user