Packet filter control verbs: the node-engine renders allowances within the compose-ask bound and keeps the loaded filter when unanswered (ADR 0683) #246

Merged
mesh-tools merged 7 commits from feat/packet-filter-allow into main 2026-11-21 21:36:37 +00:00
2 changed files with 25 additions and 1 deletions
Showing only changes of commit d0129d08ae - Show all commits
+2 -1
View File
@@ -162,7 +162,8 @@
"mesh.seat.mesh-catalog.event.seat-definition-changed",
"mesh.seat.mesh-catalog.event.seat-definition-removed",
"mesh.seat.node-engine.call.*.NODE.*",
"mesh.seat.node-engine.tool.*.NODE"
"mesh.seat.node-engine.tool.*.NODE",
"mesh.seat.node-packet-filter.event.allowances-changed.*"
],
"AllowResponses": true
}
+23
View File
@@ -13,6 +13,7 @@ import (
"time"
"github.com/novox/mesh-host/internal/agent"
"github.com/novox/mesh-host/internal/nodegrant"
"git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
@@ -248,6 +249,14 @@ func TestAModulesClaimsAreReadFromTheEntryOfItsWantsBuild(t *testing.T) {
if own == nil || other != nil {
t.Fatalf("heard %v, want the own node's allowances-changed and no other's", heard)
}
// And the node's grant lets it subscribe there, as the grants part grants the consume (every machine's, as `*`).
granted := false
for _, f := range nodegrant.For("n1").Subscribe {
granted = granted || subjectCovers(f, nodepacketfilter.SubjectAllowancesChanged("n1"))
}
if !granted {
t.Errorf("the node's grant does not let it subscribe to %s", nodepacketfilter.SubjectAllowancesChanged("n1"))
}
select {
case own <- []byte(`{"node":"n1","change":"allowed"}`):
case <-time.After(10 * time.Second):
@@ -359,3 +368,17 @@ type storeAway struct{}
func (storeAway) Error() string { return "artifact-store answered 503 Service Unavailable" }
func (storeAway) StoreAnswered() bool { return false }
// subjectCovers says whether the subject filter f matches the subject s, by NATS's wildcards (* one token, > the rest).
func subjectCovers(f, s string) bool {
ft, st := strings.Split(f, "."), strings.Split(s, ".")
for i, t := range ft {
if t == ">" {
return i < len(st)
}
if i >= len(st) || (t != "*" && t != st[i]) {
return false
}
}
return len(ft) == len(st)
}