Skip to content

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

Open
roonakyadav wants to merge 2 commits into
google:mainfrom
roonakyadav:docs/957-custom-access-role-guide
Open

roonakyadav wants to merge 2 commits into
google:mainfrom
roonakyadav:docs/957-custom-access-role-guide

Conversation

@roonakyadav

Copy link
Copy Markdown
Contributor

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 correctly switch to policy bindings are often confused 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.

Documentation Changes

This PR implements the immediate documentation improvements outlined by @aojea in #957:

  • Architectural distinction: Clarified the difference between component roles (mesh:role:node, mesh:role:router) and custom access roles (caller, developer, analyst) in the policy reference, concepts, and guides.
  • Bootstrap token role constraints: Documented that bootstrap tokens enroll component identities (mesh:role:node or mesh:role:router), not arbitrary access roles.
  • Step-by-step recipe: Added a practical, step-by-step 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.
    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, 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.

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 (roles & bindings reference, evaluation, sync jitter window)
  • 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)

Scope & Runtime Behavior

Validation Performed

  • Validated commands, flags, routes, and responses (agentmesh-one token create, agentmesh-node join, agentmesh-node run, /debug/mesh-info, /mesh/identity, POST /policies, /mcp, /mesh/...) against the codebase.
  • Checked git whitespace and formatting across all modified markdown files (git diff --check).
  • Verified policy Datalog rule execution and tests (go test ./... -run TestSyncMeshPolicyUsesDatalogRules).

- Distinguish component roles (mesh:role:node, mesh:role:router) from custom access roles (caller, developer, analyst).
- Clarify that bootstrap tokens only enroll component identities and cannot enroll arbitrary access roles.
- Add practical step-by-step guide under guides/custom-node-roles.md demonstrating token creation, enrollment, PeerID lookup, policy binding via node:<peer-id>, and call verification.
- Document policy propagation timing within the sync jitter window (0-90s by default).
- Clarify that effective permissions come from policy evaluation rather than the roles printed in a node's Biscuit credential.
- Update policy, headless enrollment, control-plane, agentmesh-one, and agentmesh-node references.

Closes google#957
@roonakyadav
roonakyadav requested a review from aojea as a code owner November 28, 2026 19:58

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new guide on granting custom access roles to a node and updates existing documentation to clarify the distinction between component roles and access roles. The review feedback points out two important improvements for the new guide: first, adding a step to pre-create the API token file to prevent startup failures, and second, adding a warning to ensure users merge policy changes rather than overwriting their entire mesh policy.

Comment on lines +99 to +107
Once joined, start the node:

```bash
agentmesh-node run \
--control-plane https://mesh.example.com \
--data-dir ./n1 \
--bind-addr 127.0.0.1:8080 \
--api-token-path ./n1/api-token
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since agentmesh-node run is executed in the foreground (without --daemonize), it expects the file specified by --api-token-path to already exist and contain a valid token. If ./n1/api-token does not exist, the command will fail to start.\n\nPlease add a step to generate or create this token file before running the node, for example:\nbash\necho "some-secure-token" > ./n1/api-token\n\nor use openssl rand -hex 16 > ./n1/api-token.

@roonakyadav roonakyadav Nov 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 0759ad4: Added an explicit step to generate ./n1/api-token before running agentmesh-node run in the foreground.

Comment on lines +155 to +159
Add your custom access role under `roles` and bind it to the node's PeerID
under `bindings`. For example, to grant a role named `caller` that allows
invoking `mcp://calculator` and any inference model:

```json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since POST /policies replaces the entire mesh policy rather than patching it, posting this example JSON directly will overwrite and remove any other existing roles (such as mesh:role:router) and bindings, which can break router enrollment and other mesh functions.\n\nPlease add a warning note advising the user to merge these new roles and bindings into their existing policy.json fetched in the previous step, rather than replacing the file entirely with this example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 0759ad4: Added a warning note explaining that POST /policies replaces the full document and provided a jq example showing how to merge new roles and bindings into the existing policy.json.

- Pre-create ./n1/api-token before running agentmesh-node in foreground.
- Add warning note that POST /policies replaces the whole policy and provide jq merge example to prevent dropping existing roles.
| Command | Flags | Effect |
|---|---|---|
| `token create` | `--role` (`mesh:role:node`), `--ttl-hours` (24), `--max-usages` (1), `--description`, `--autonomous-recovery` | Mint a token. Prints it once on stdout. |
| `token create` | `--role` (`mesh:role:node`), `--ttl-hours` (24), `--max-usages` (1), `--description`, `--autonomous-recovery` | Mint a component enrollment token (`mesh:role:node` or `mesh:role:router`). Prints it once on stdout. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to add validation on the flags to ensure the value of role is allowed , see my original comment


## Roles

Agent Mesh distinguishes between **component roles** and **access roles**:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is too verbose

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: step-by-step recipe for giving a node a custom role

2 participants