← Back to Pull requests

sdk/meshnet: add embedded Go SDK for Agent Mesh #843

Closed
unknown closed this pull request without merging on Nov 02, 2026 09:26 UTC
View on GitHub
unknown unknown commented on Nov 01, 2026 13:55 UTC
Author

Summary

Adds github.com/google/agentmesh/sdk/meshnet (modeled on tailscale.com/tsnet), allowing Go applications and agent frameworks (such as a2a-cli) to join an Agent Mesh directly in-process as a single binary—without managing an external agentmesh-node sidecar process, loopback bearer token, or port coordination.

Key Capabilities

  • Lifecycle & State Directory Interop (Server.Up, Server.Refresh, Server.Close, WriteStateDir, ReadStateDir):

  • - Persists identity.key and credential.json (0700/0600) byte-for-byte compatible with agentmesh-node state export|import, sdk/js, and sdk/python.
    - Supports cached credential resume, BootstrapTokenPath / BootstrapToken (POST /enroll + GET /enroll/status polling), JWTPath / TokenSource (POST /register), oidc_session refresh-token recovery, proactive background renewal (POST /refresh), signed /keys verification, and /mesh/events/v1 (StrictSign) live revocations, key rotations, and bans.
  • In-Process A2A Listeners (Server.ListenA2A) & Unspoofable Server.WhoIs:

  • - Returns in-memory net.Listeners (PrivateListener over /libp2p-http and optional PublicListener over /mesh/ingress/1.0.0 in INGRESS_AUTH_MODE_EDGE or INGRESS_AUTH_MODE_PASSTHROUGH) plus canonical PrivateURL and PublicURL endpoints.
    - Falls back cleanly to internal-only announcement (PublicURL = nil) when the hub's policy ceiling refuses ServiceIngress.
    - Automatically relativizes and rewrites A2A AgentCard supportedInterfaces URLs per caller.
    - Maps http.Request.RemoteAddr via an in-memory net.Pipe connection table to cryptographically verified CallerInfo (PeerID, Principal, Roles, Labels, Task).
  • *Outbound Mesh http.Client, Discovery & Offline Attenuation (Server.HTTPClient, Server.Discover, Server.AttenuateToken):

  • - Routes http://agentmesh.local/mesh/<peer_id>/<type>/<name>[/<rest>] over authenticated libp2p streams, enforcing provider Biscuit verification, allowed_publish Datalog checks, EgressRequireLabels, and X-Mesh-Required-Labels before sending request bytes.
    - Mints and optionally seals task-scoped Biscuits (tar_block fact, 0 rules, 0 checks) in memory.
  • Local Mesh MCP & Zero-Secret OpenAI /v1 Surfaces (Server.MCPServer, Server.MCPHandler, Server.InferenceHandler):*

  • - Exposes the 6 progressive-discovery mesh MCP tools (list_local_services, discover_remote_services, get_mesh_info, find_remote_tools, describe_remote_tool, call_remote_tool) and system://mesh.catalog.
    - Serves GET /v1/models, POST /v1/chat/completions, and POST /v1/completions routed over mesh inference://
    providers with streaming SSE pass-through.

    Security Invariants

  • Both in-mesh stream authorization and external HTTP ingress build their Datalog authorizer from a single meshPolicy() helper via identity.AuthorizeMeshRequest + MeshRequest.TaskRequest(), and validate paths with api.HasDotSegment.

  • Every libp2p stream protocol registered by meshnet.Server is classified and verified in sdk/meshnet/protocol_inventory_test.go (mirroring internal/node/protocol_inventory_test.go).

  • /mesh/ingress/1.0.0 is gated exclusively to authenticated peers holding mesh:role:router before the HTTP server reads a byte, re-verifies end-caller Biscuits locally in EDGE mode, and strips spoofed X-Mesh-* headers in PASSTHROUGH mode.

  • Zero new go.mod dependencies.
  • Validation

  • go test -race -count=1 ./sdk/meshnet/...

  • go test -race -p 1 -count=1 -run TestMeshnet ./tests/integration/...

  • make && make lint && make test
  • Diff: 457 lines (+342 / -115) across 5 files Reviewer: aojea Review duration: 1170m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 457 lines diff across 5 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.367
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #843"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.5% (MEDIUM) · Higher = larger blast radius
    45.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.0% · Safe to merge
    18.0%