TLS-1, TLS-2, TLS-3: the runner declares its own secret ledgers, refuses a bundle tool named as a ledger repair, and states the capabilities of its calls in its PING (issue 1966)

Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
2026-11-04 11:40:03 +01:00
parent 84ede95c4a
commit 8b1ab467a9
8 changed files with 153 additions and 6 deletions
@@ -15,6 +15,7 @@ import (
"github.com/nats-io/nats.go/jetstream"
"github.com/novox/mesh-tools/node-tools/internal/bus"
"github.com/novox/mesh-tools/node-tools/internal/launch"
mt "github.com/novox/mesh-tools/node-tools/internal/meshtest"
)
@@ -179,3 +180,45 @@ func TestAnApplyIsStampedWithTheCallerTheRuntimeProved(t *testing.T) {
t.Fatal("a call that ended was still taken as in flight")
}
}
// issue 1966 TLS-2: a bundle's tool named as one of the runner's ledger repairs is refused at the load, naming the tool and the
// repair; any other name is served.
func TestABundleToolNamedAsALedgerRepairIsRefused(t *testing.T) {
for _, c := range []struct{ name, tool, want string }{
{"rebuild", RepairRebuild, "m's bundle serves a tool named ledger_rebuild, which is also the ledger repair the runner serves for m"},
{"reindex", RepairReindex, "ledger_reindex"},
{"snapshot", RepairSnapshot, "ledger_snapshot"},
{"lag", RepairLag, "ledger_lag"},
{"another name", "ledger_status", ""},
} {
t.Run(c.name, func(t *testing.T) {
got := repairClash("m", []launch.Tool{{Name: "first"}, {Name: c.tool}})
if (c.want == "") != (got == "") || !strings.Contains(got, c.want) {
t.Errorf("clash %q, want one containing %q", got, c.want)
}
})
}
}
// issue 1966 TLS-3: every method of a capability the runner states is a call it answers, and the two states its calls under
// no other name; none answers "the runtime answers no ...".
func TestEveryCallOfAStatedCapabilityIsAnswered(t *testing.T) {
m, _, _ := aLedger(t)
if got := strings.Join(CallCapabilities(), ","); got != "bus-state-calls,ledger-calls" {
t.Fatalf("the runner states %s", got)
}
for capability, methods := range callFamilies {
for _, method := range methods {
t.Run(capability+" "+method, func(t *testing.T) {
_, err := m.BusState(method, json.RawMessage(`"not a request"`))
if err != nil && strings.Contains(err.Error(), "the runtime answers no") {
if stop, werr := m.BusStateWatch(method, json.RawMessage(`"not a request"`), func(json.RawMessage) error { return nil }); werr != nil && strings.Contains(werr.Error(), "the runtime answers no") {
t.Errorf("%s is stated under %s and answered by neither BusState nor BusStateWatch", method, capability)
} else if stop != nil {
stop()
}
}
})
}
}
}