← Back to Pull requests

docs: clarify component vs access roles and add custom node roles recipe #985

Open
unknown opened this pull request with 621 lines diff across 7 files
View on GitHub
unknown unknown commented on Nov 28, 2026 19:58 UTC
Author

Closes #957

Problem

In Agent Mesh, the word "role" is used across two distinct architectural layers:

1. Component roles (mesh:role:node, mesh:role:router), which describe infrastructure binary identities fixed at enrollment.
2. Access roles (caller, developer, analyst), which describe what services a member may call or publish.

Because both concepts are named "role", users attempting to create a node bootstrap token with an access role (e.g. agentmesh-one token create --role caller) hit unexpected failures during enrollment: agentmesh-node always requests mesh:role:node (RequiredRole: api.RoleNode), and the control plane requires the requested role to match the bootstrap token's role. Furthermore, users who switch to policy bindings are often surprised when inspecting the enrolled node's Biscuit credential (/mesh/identity or X-Mesh-Roles), which still displays only mesh:role:node because custom roles are evaluated dynamically via distributed Datalog rules rather than baked into the Biscuit.

Changes

This PR implements the recipe and fail-fast validation requested in #957:

1. Documentation & Recipe


  • Step-by-step recipe: Added a practical guide (guides/custom-node-roles.md) explaining how to:

  • 1. Mint a bootstrap token with mesh:role:node.
    2. Enroll and run agentmesh-node.
    3. Obtain the node's PeerID (12D3KooW...) from startup logs, debug CLI (agentmesh-node debug mesh-info), or the local API (GET /debug/mesh-info).
    4. Grant a custom access role by adding {"role": "caller", "members": ["node:<peer-id>"]} to policy bindings and posting to POST /policies (merging into existing policies).
    5. Understand policy propagation (within the 0–90 second sync jitter window without restarts) and how effective permissions derive from Datalog authorizer evaluation rather than roles listed in the Biscuit.
    6. Verify allowed and denied calls via call_remote_tool and the HTTP proxy path.
  • Reference updates: Updated policy.md (concise distinction linking to guide), headless-enrollment.md, control-plane.md, agentmesh-one.md, and agentmesh-node.md to reference the component role requirements and cross-link to the new guide.

  • Concepts: Updated concepts/identity.md with component vs. access role distinctions and evaluation details.
  • 2. Fail-Fast Bootstrap Token Role Validation


  • agentmesh-one token create --role: Validates that --role is either mesh:role:node or mesh:role:router. If an arbitrary role is passed (e.g., caller), it immediately returns a descriptive error:

  • invalid role "caller": bootstrap tokens only enroll component types (mesh:role:node or mesh:role:router); custom access roles must be granted via policy bindings
  • Control plane: HandleAdminBootstrapTokens (POST /admin/bootstrap-tokens) and HandleUserBootstrapTokens (POST /user/bootstrap-tokens) validate that role is either api.RoleNode or api.RoleRouter, returning HTTP 400 Bad Request with the same explanatory message.

  • CLI help: Updated help text on --role in agentmesh-one token create to explicitly name (mesh:role:node or mesh:role:router).

  • Egress test alignment: Updated internal/controlplane/egress_test.go to enroll nodes using mesh:role:node and grant custom roles through policy bindings (node:<peer-id>).
  • Files Changed

  • site/content/docs/guides/custom-node-roles.md (new step-by-step recipe)

  • site/content/docs/guides/_index.md (guides directory index)

  • site/content/docs/guides/headless-enrollment.md (bootstrap token minting role clarification)

  • site/content/docs/reference/policy.md (concise role definition and guide link)

  • site/content/docs/reference/control-plane.md (bootstrap tokens endpoint description)

  • site/content/docs/reference/agentmesh-one.md (token create command description)

  • site/content/docs/reference/agentmesh-node.md (bootstrap-token-path flag description)

  • site/content/docs/concepts/identity.md (bootstrap token role and policy binding clarification)

  • cmd/agentmesh-one/admin.go (role validation and updated CLI flag help text)

  • cmd/agentmesh-one/admin_test.go (unit tests for role flag validation)

  • internal/controlplane/server.go (role validation in bootstrap token creation handlers)

  • internal/controlplane/server_test.go (unit tests for bootstrap token role validation)

  • internal/controlplane/egress_test.go (alignment with component role enrollment and policy bindings)
  • Validation Performed

  • make build: All binaries built cleanly.

  • golangci-lint: 0 issues found.

  • deadcode: 0 dead code detected across the repository.

  • Unit tests (go test -race ./cmd/agentmesh-one/... ./internal/controlplane/...): Passed without race conditions.

  • Integration tests (go test -p 1 -v ./tests/integration -run TestSilentEphemeralMembersAreForgotten): Passed.

  • Formatting & whitespace: Verified clean diff via git diff --check.
  • Diff: 621 lines (+465 / -156) across 7 files Reviewer: aojea Review duration: 2929m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.55) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.55 · 621 lines diff across 7 files
    0.55
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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.385
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #985"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 55.3% (MEDIUM) · Higher = larger blast radius
    55.3%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 29.5% · Safe to merge
    29.5%