Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
refactor(api): remove the LabelRegion constant
Antonio Ojeaa1f7d0edd194
diff --git a/api/datalog.go b/api/datalog.goindex bbcc4495..29888947 100644--- a/api/datalog.go+++ b/api/datalog.go@@ -204,8 +204,8 @@ const (// attested with region="us-east-1" carries label("region", "us-east-1"),// satisfying `check if label("region", "us-east-1")` only — composition// across values is left entirely to the operator (attest as many labels- // as needed). Distinct from LabelRegion, the unauthenticated gossip- // routing hint.+ // as needed). Distinct from the unauthenticated gossip routing hint+ // carried in ServiceAnnounce.labels.// Contains: biscuit.String(key), biscuit.String(value)// Example Datalog: check if label("region", "us-east-1")FactLabel = "label"diff --git a/api/labels.go b/api/labels.goindex 4bb1c249..278c0098 100644--- a/api/labels.go+++ b/api/labels.go@@ -28,8 +28,8 @@ import (// requirement also matches) is entirely up to the operator. Matching is// exact and case-sensitive on both key and value (see LabelCheck).//-// Well-known keys (e.g. LabelRegion) are just conventions; SAM does not-// validate or interpret their values beyond ValidateLabelValue.+// Keys are plain conventions agreed by operators (e.g. "region"); SAM does+// not reserve or interpret any key beyond ValidateLabelKey/ValidateLabelValue.// labelKeySyntax bounds label keys to a safe, portable charset.var labelKeySyntax = regexp.MustCompile(`^[a-zA-Z0-9_.-]{1,63}$`)diff --git a/api/network.go b/api/network.goindex 5daa0e6a..e6f3a128 100644--- a/api/network.go+++ b/api/network.go@@ -118,29 +118,10 @@ const (//// Reserved as part of the sidecar contract; enforced by the provider// scorer. Label declarations are routing hints until attested via the- // node's Biscuit (see LabelRegion).+ // node's Biscuit (see api/labels.go).HeaderSamRequiredLabels = "X-Sam-Required-Labels")-// ============================================================================-// Well-Known Node Labels-// ============================================================================-//-// Placement rule: anything two nodes must agree on to interoperate (topics,-// headers, labels, wire caps, canonical value forms) is defined here in api/.-// Behavioral tuning a node decides alone (intervals, TTLs, table bounds)-// lives in the package that owns the behavior.--const (- // LabelRegion is the operator-declared jurisdiction of a node, a- // free-form value (e.g. "us-east-1", "EU-DE"); see api/labels.go. It is- // carried in ServiceAnnounce messages as a routing hint. Absent means- // the node makes no region claim, and consumers with a region- // requirement will never select it. Operator-declared labels always- // take precedence over runtime-derived values.- LabelRegion = "region"-)-// ============================================================================// Service Classification & Namespaces// ============================================================================diff --git a/api/sam.pb.go b/api/sam.pb.goindex 0aadd3f3..3f1afa1b 100644--- a/api/sam.pb.go+++ b/api/sam.pb.go@@ -1025,7 +1025,7 @@ type ServiceAnnounce struct {// Routing keys served by this service: model IDs for inference,// tool names for MCP.Keys []string `protobuf:"bytes,4,rep,name=keys,proto3" json:"keys,omitempty"`- // Operator-declared labels (e.g. LabelRegion). Operator claims always+ // Operator-declared labels (e.g. "region"). Operator claims always// take precedence over runtime-derived values.Labels map[string]string `protobuf:"bytes,5,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`// Runtime load hints; zero values mean unknown.diff --git a/api/sam.proto b/api/sam.protoindex ed0d869c..371e2ea1 100644--- a/api/sam.proto+++ b/api/sam.proto@@ -140,7 +140,7 @@ message ServiceAnnounce {// Routing keys served by this service: model IDs for inference,// tool names for MCP.repeated string keys = 4;- // Operator-declared labels (e.g. LabelRegion). Operator claims always+ // Operator-declared labels (e.g. "region"). Operator claims always// take precedence over runtime-derived values.map<string, string> labels = 5;// Runtime load hints; zero values mean unknown.diff --git a/internal/node/discovery/discovery_test.go b/internal/node/discovery/discovery_test.goindex 47fd2c24..e329dd3b 100644--- a/internal/node/discovery/discovery_test.go+++ b/internal/node/discovery/discovery_test.go@@ -77,7 +77,7 @@ func TestAnnounceReachesInterestedConsumer(t *testing.T) {Type: api.ServiceType_SERVICE_TYPE_INFERENCE,Name: "llm",Keys: []string{"model-a", "model-b"},- Labels: map[string]string{api.LabelRegion: "eu"},+ Labels: map[string]string{"region": "eu"},Load: Load{ActiveRequests: 3},}}})@@ -91,7 +91,7 @@ func TestAnnounceReachesInterestedConsumer(t *testing.T) {for time.Now().Before(deadline) {if ps := consumer.Providers(api.ServiceType_SERVICE_TYPE_INFERENCE, "model-a"); len(ps) == 1 {p := ps[0]- if p.Service != "llm" || p.Labels[api.LabelRegion] != "eu" || p.Load.ActiveRequests != 3 {+ if p.Service != "llm" || p.Labels["region"] != "eu" || p.Load.ActiveRequests != 3 {t.Fatalf("unexpected provider: %+v", p)}if !p.ServesKey("model-b") {@@ -241,11 +241,11 @@ func TestPeerLabels(t *testing.T) {d.observe(rawMessage(t, signer, &api.ServiceAnnounce{PeerId: signer.String(), Type: api.ServiceType_SERVICE_TYPE_MCP,ServiceName: "reviewer", Keys: []string{"review_pr"},- Labels: map[string]string{api.LabelRegion: "eu"},+ Labels: map[string]string{"region": "eu"},Timestamp: time.Now().Unix(),}))- if got := d.PeerLabels(signer.String()); got[api.LabelRegion] != "eu" {+ if got := d.PeerLabels(signer.String()); got["region"] != "eu" {t.Errorf("PeerLabels: got %v, want region=eu", got)}if got := d.PeerLabels("unknown-peer"); got != nil {@@ -280,7 +280,7 @@ func TestValidateServiceAnnounceCaps(t *testing.T) {a.Labels = map[string]string{"k": string(make([]byte, api.MaxAnnounceStringLen+1))}}, true},{"free-form region label", func(a *api.ServiceAnnounce) {- a.Labels = map[string]string{api.LabelRegion: "us-east-1"}+ a.Labels = map[string]string{"region": "us-east-1"}}, false},}for _, tt := range tests {diff --git a/internal/node/mcp_discovery_test.go b/internal/node/mcp_discovery_test.goindex 85bf2dd5..90c680fd 100644--- a/internal/node/mcp_discovery_test.go+++ b/internal/node/mcp_discovery_test.go@@ -72,7 +72,7 @@ func (f *fakeToolService) Tools(_ context.Context) ([]string, error) {func TestDiscoverySource(t *testing.T) {node := &SamNode{services: NewServiceRegistry(&fakeDHT{}),- config: Options{Labels: map[string]string{api.LabelRegion: "EU"}},+ config: Options{Labels: map[string]string{"region": "EU"}},}ctx := context.Background()@@ -106,7 +106,7 @@ func TestDiscoverySource(t *testing.T) {t.Errorf("reviewer announcement: %+v", a)}for name, a := range byName {- if a.Labels[api.LabelRegion] != "EU" {+ if a.Labels["region"] != "EU" {t.Errorf("%s labels: got %v, want region=EU", name, a.Labels)}}@@ -128,14 +128,14 @@ func TestCapKeys(t *testing.T) {func TestGossipToolRows(t *testing.T) {provs := []samdiscovery.Provider{- {PeerID: "peerA", Service: "reviewer", Labels: map[string]string{api.LabelRegion: "eu"}},+ {PeerID: "peerA", Service: "reviewer", Labels: map[string]string{"region": "eu"}},{PeerID: "peerB", Service: "other"},}rows := gossipToolRows(provs, "review_pr", "")if len(rows) != 2 {t.Fatalf("rows: got %+v, want 2", rows)}- if rows[0].ToolName != "mcp://reviewer/review_pr" || rows[0].Labels[api.LabelRegion] != "eu" {+ if rows[0].ToolName != "mcp://reviewer/review_pr" || rows[0].Labels["region"] != "eu" {t.Errorf("row 0: %+v", rows[0])}if len(rows[1].Labels) != 0 {