Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
fix kind mesh e2e permissions
Antonio Ojea2a949035f034
diff --git a/.github/workflows/kind-mesh-e2e.yml b/.github/workflows/kind-mesh-e2e.ymlindex 320a3a53..5919bc7e 100644--- a/.github/workflows/kind-mesh-e2e.yml+++ b/.github/workflows/kind-mesh-e2e.yml@@ -55,70 +55,8 @@ jobs:- name: Bring up the kind meshrun: make kind-up ARGS="-s"- - name: Enroll a local sam-node- run: |- ./development/kind/run-local-node.sh > "$RUNNER_TEMP/local-node.log" 2>&1 &- PID=$!- for _ in $(seq 1 60); do- grep -q "SAM Node Online" "$RUNNER_TEMP/local-node.log" && break- kill -0 "$PID" 2>/dev/null || { echo "local node exited early:"; cat "$RUNNER_TEMP/local-node.log"; exit 1; }- sleep 1- done- grep -q "SAM Node Online" "$RUNNER_TEMP/local-node.log" \- || { echo "local node did not come online:"; cat "$RUNNER_TEMP/local-node.log"; exit 1; }- echo "local node online"-- - name: Mesh info, discover, find + call calculator- run: |- set -euo pipefail- URL=http://127.0.0.1:9099/mcp- mcp() { ./bin/mcp-client -url "$URL" -timeout 20 "$@" 2>/dev/null; }-- echo "== get_mesh_info =="- info=$(mcp -tool get_mesh_info -args '{}')- echo "$info"- echo "$info" | jq -e '.hub_peer_id != "" and (.dht_size > 0)' >/dev/null \- || { echo "get_mesh_info assertion failed"; exit 1; }-- echo "== discover services / find calculator (poll) =="- peer=""- for i in $(seq 1 90); do- tools="$(mcp -tool discover_services -args '{}' 2>/dev/null || true)"- echo "discover attempt $i: $tools"-- peer="$(printf '%s' "$tools" \- | jq -r '.[]? | select(.tool_name=="calculator.add") | .peer_id' 2>/dev/null \- | head -n1)"-- if [ -n "$peer" ]; then- echo "calculator.add discovered on peer: $peer (attempt $i)"- break- fi-- # periodic mesh debug- if [ $((i % 10)) -eq 0 ]; then- echo "mesh info (attempt $i):"- mcp -tool get_mesh_info -args '{}' || true- fi-- sleep 1- done-- [ -n "$peer" ] || {- echo "calculator.add not discovered after 90s"- echo "final discover_services:"- mcp -tool discover_services -args '{}' || true- echo "final mesh info:"- mcp -tool get_mesh_info -args '{}' || true- exit 1- }-- echo "== call calculator.add(2,3) =="- result=$(mcp -tool call_remote_tool \- -args "{\"peer_id\":\"$peer\",\"tool_name\":\"calculator.add\",\"arguments\":{\"a\":2,\"b\":3}}")- echo "result: $result"- printf '%s' "$result" | grep -q 5 || { echo "calculator.add did not return 5"; exit 1; }- echo "OK: calculator.add(2,3) == 5"+ - name: Run e2e mesh tests+ run: make kind-e2e-mesh- name: Collect logs on failureif: failure()diff --git a/Makefile b/Makefileindex 49a5b0ab..e7ed7847 100644--- a/Makefile+++ b/Makefile@@ -31,6 +31,10 @@ kind-down:kind-local-node:./development/kind/run-local-node.sh $(ARGS)+.PHONY: kind-e2e-mesh+kind-e2e-mesh: build+ ./development/kind/test-mesh-e2e.sh+test:CGO_ENABLED=1 go test -v -race -count 1 $(if $(WHAT),-run $(WHAT)) ./...diff --git a/development/examples/calc-mcp/sam-node-config.yaml b/development/examples/calc-mcp/sam-node-config.yamlindex c53bdbb0..12a306b3 100644--- a/development/examples/calc-mcp/sam-node-config.yaml+++ b/development/examples/calc-mcp/sam-node-config.yaml@@ -3,7 +3,7 @@ attenuation:# Allow cross-node MCP only when the caller's biscuit carries a# node($peer) fact — i.e. it was issued by our hub upon enrollment.policies:- - 'allow if operation("/sam/mcp/1.0.0"), node($peer)'+ - 'allow if operation("calculator"), node($peer)'services:- type: "mcp"name: "calculator"diff --git a/development/examples/greeter-mcp/sam-node-config.yaml b/development/examples/greeter-mcp/sam-node-config.yamlindex 465fba04..8ccaa8e9 100644--- a/development/examples/greeter-mcp/sam-node-config.yaml+++ b/development/examples/greeter-mcp/sam-node-config.yaml@@ -1,7 +1,7 @@version: "v1alpha1"attenuation:policies:- - 'allow if operation("/sam/mcp/1.0.0"), node($peer)'+ - 'allow if operation("greeter"), node($peer)'services:- type: "mcp"name: "greeter"diff --git a/development/kind/test-mesh-e2e.sh b/development/kind/test-mesh-e2e.shnew file mode 100755index 00000000..41613a57--- /dev/null+++ b/development/kind/test-mesh-e2e.sh@@ -0,0 +1,83 @@+#!/usr/bin/env bash+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.++set -euo pipefail++# If running locally, we might want to store logs in a temp dir+LOG_DIR="${RUNNER_TEMP:-$(mktemp -d)}"++echo "== Enrolling a local sam-node =="+./development/kind/run-local-node.sh > "$LOG_DIR/local-node.log" 2>&1 &+PID=$!+for _ in $(seq 1 60); do+ grep -q "SAM Node Online" "$LOG_DIR/local-node.log" && break+ kill -0 "$PID" 2>/dev/null || { echo "local node exited early:"; cat "$LOG_DIR/local-node.log"; exit 1; }+ sleep 1+done+grep -q "SAM Node Online" "$LOG_DIR/local-node.log" \+ || { echo "local node did not come online:"; cat "$LOG_DIR/local-node.log"; exit 1; }+echo "local node online"++# Make sure we clean up the local node when the script exits+trap 'kill $PID 2>/dev/null || true' EXIT++URL=http://127.0.0.1:9099/mcp+mcp() { ./bin/mcp-client -url "$URL" -timeout 20 "$@" 2>/dev/null; }++echo "== get_mesh_info =="+info=$(mcp -tool get_mesh_info -args '{}')+echo "$info"+echo "$info" | jq -e '.hub_peer_id != "" and (.dht_size > 0)' >/dev/null \+ || { echo "get_mesh_info assertion failed"; exit 1; }++echo "== discover services / find calculator (poll) =="+peer=""+for i in $(seq 1 90); do+ tools="$(mcp -tool find_remote_tools -args '{}' 2>/dev/null || true)"+ echo "discover attempt $i: $tools"++ peer="$(printf '%s' "$tools" \+ | jq -r '.items[]? | select(.tool_name=="calculator.add") | .peer_id' 2>/dev/null \+ | head -n1 || true)"++ if [ -n "$peer" ]; then+ echo "calculator.add discovered on peer: $peer (attempt $i)"+ break+ fi++ # periodic mesh debug+ if [ $((i % 10)) -eq 0 ]; then+ echo "mesh info (attempt $i):"+ mcp -tool get_mesh_info -args '{}' || true+ fi++ sleep 1+done++[ -n "$peer" ] || {+ echo "calculator.add not discovered after 90s"+ echo "final find_remote_tools:"+ mcp -tool find_remote_tools -args '{}' || true+ echo "final mesh info:"+ mcp -tool get_mesh_info -args '{}' || true+ exit 1+}++echo "== call calculator.add(2,3) =="+result=$(mcp -tool call_remote_tool \+ -args "{\"peer_id\":\"$peer\",\"tool_name\":\"calculator.add\",\"arguments\":{\"a\":2,\"b\":3}}")+echo "result: $result"+printf '%s' "$result" | grep -q 5 || { echo "calculator.add did not return 5"; exit 1; }+echo "OK: calculator.add(2,3) == 5"