Roles & Permissions
Crewship implements role-based access control at two levels: workspace roles (human users) and agent roles (AI agents within crews).Guest routine execution in v1
Guests can use explicitly shared View, Results, Edit and Publish rights on routines and drafts. Publishing saves the reviewed version; it never launches execution. Guest-initiated runs of published routines are deferred from the v1 contract. Routine runs in the supported v1 flow are initiated by team members or crew triggers, subject to their existing authorization and publication rules. Guest execution requires a separately qualified private runtime. A default installation refuses Guest run requests with HTTP 503 and coderestricted_runtime_unavailable, without queuing or starting work. An
administrator must explicitly configure the qualified runtime; a Run share
alone does not install it. See the private workflow contract.
Resource Access v1
Resource Access v1 adds explicit resource sharing to the workspace roles below. Guest is the UI name for an account in restricted access mode, rather than another value in the workspace-role enum. Its restriction applies across the account; a grant does not change the account mode or grant a workspace role. The v1 release includes:- Per-object grants for agents, routines, and projects and their issues. An unshared object remains unavailable through its supported Guest view. Routine definition View, Results, Edit, Publish and Run are separate permissions.
- Crew View/Use sharing for Guests and explicit Manage sharing for trusted MEMBER/MANAGER recipients. Guest crew presets preview and confirm None, View or Use; Manage remains a separate explicit share. View/Use covers current and future agents, with each agent’s authority and execution preflight still required. Manage permits profile/configuration and ordinary membership, while explicit role assignment/removal, deletion, budgets and workspace administration keep their existing administrator guards.
- Pages with their existing, separate ACL and issuer checks. This release does not migrate Pages to the unified resource-grant model.
- Routine Publish controls in the web UI, API and CLI. Publish requires Edit; publishing also requires current View. Publishing a definition does not grant execution. Existing triggers and member execution retain their own guards.
- Atomic permission mutations and chained audit records, a sealed audit keyring at rest, key rotation, tail verification and chain-break alerts. Verification reports retain their distinction between verified continuation and older unverified history; an alert or successful tail check is not proof that all historical records have been verified.
Deferred to v1.1
The following are not delivered by Resource Access v1:- Credential resource grants, including separate See, Use and Reveal rights.
- Crews and workspaces as grant recipients; current resource grants target people.
- A person Access card with complete inherited-source explanations and the people × objects permissions grid. Existing explicit policy editors and the Guest’s own-access explanation do not provide that complete interface.
- A universal leak guard across all GET routes and streams, and a universal constant-query-count guard for resource lists.
- Migration of Pages from their existing ACL to unified resource grants.
- Guest execution of published routines and its provider-backed acceptance. In a default installation, without a qualified restricted runtime, this execution remains unavailable and Run is rejected with HTTP 503 before work is created. Guests can still view shared definitions/results, edit shared drafts and publish with the required rights. Members or existing triggers start runs under the crew’s normal execution policy.
Workspace Roles (Human Users)
The table describes the trusted workspace-role baseline; restricted Guest mode and explicit resource grants apply the additional boundaries described above. Users are assigned one of five roles within a workspace:
Roles are defined as the
OrgRole enum in the Prisma schema:
Permission Mapping (Code Implementation)
ThecanRole() function in Go (internal/api/helpers.go) maps roles to internal actions, grouped into three permission tiers:
In the current implementation, MEMBER and VIEWER have identical permissions (both map to
read only). The distinction exists in the schema for future granularity (e.g., MEMBER may gain send_message or run_agent permissions).Mutation routes declare their role at registration (complete mediation)
Every state-changing endpoint (POST/PUT/PATCH/DELETE) declares the
role it requires at route registration, and a single middleware enforces
that declaration before the handler runs. This is Saltzer & Schroeder
complete mediation: authorization is a property of the route table, not a
hand-placed check a new handler might forget.
Workspace-scoped mutations register through authedMut(method, pattern, role, handler)
(internal/api/rbac_routes.go), which records {method, pattern, role} into a
walkable table and mounts the route behind RequireAuth → RequireWorkspace → requireRoleMW(role). The declared role is one of:
create—MANAGER+ (the create/update tier). AMEMBER/VIEWERis refused403.manage—ADMIN+ (the manage/delete tier, e.g. workspace/member administration, feature flags, backups, approvals, hooks, GDPR data deletion).self— self-scoped: the handler enforces ownership byuser_id(own preferences, reactions, a saved view the caller owns, inbox items the caller can see).inline— the handler runs a layered gate the middleware must not pre-empt: the role-or-capability gate (aMEMBERholding an explicit capability passes) or the per-agent owner / per-crew-elevation gate. The middleware guarantees workspace membership and passes through; the handler decides.
MANAGER+ include crew-template deploy, crew
policy, routine execution/control (run, replay, bulk_replay, signal,
metadata, dry_run, test_run, tags, step overrides), checkpoints, agent /
crew persona edits, and crew-composition suggestions.
Two tests make this a build-time invariant
(
internal/api/route_authz_invariant_test.go):
TestEveryMutationRouteDeclaresRole walks the recorded route table and fails
if any mutation route lacks a declared role, and
TestNoLegacyAuthedMutationRegistration fails if a mutation route is
registered through the old authed(...) chain instead of authedMut /
authedSelfMut. Adding a new mutation route without declaring its role
fails the build — the omission that previously slipped past review can no
longer ship. The pre-existing inline requireRole / canRole checks are
kept as belt-and-suspenders behind the middleware.Signup Control
New user registration is controlled by theCREWSHIP_ALLOW_SIGNUP environment variable (or auth.allow_signup in YAML config). When disabled, only existing users can invite new members.
Agent Roles
Every AI agent has one of two functional roles:AGENT
Individual contributor. Executes tasks, writes code, runs tools. The standard role for most agents.
LEAD
Crew orchestrator. Assigns tasks to agents, creates missions, monitors progress. Has access to the full sidecar API.
Agent Role Capabilities
The Equality Principle
Agent roles are functional, not hierarchical. A Lead is an equal colleague with orchestration responsibility — not a boss. This is a core Crewship philosophy.
You are part of a crew on the Crewship — an expedition with a shared purpose that transcends any individual.LEAD:
You are a crew member with orchestration responsibility. You are not a boss — you are an equal colleague who carries the soul and mission of the expedition to the whole team.
Internal API Authentication
The internal API (sidecar-to-crewshipd communication) uses token-based authentication:- Auto-generated cryptographically at startup if not configured
- Passed to sidecar processes via the IPC config
- Verified on every internal API request
Container Security Boundaries
Agent processes run as UID 1001, while the sidecar runs as UID 1002. This prevents agents from:- Reading the sidecar’s credential store
- Modifying network policy configuration
- Accessing the IPC token
- Tampering with the proxy’s authentication headers
Credential Access Control
Credentials are protected by multiple layers, but neither assignment nor delivery has one universal shape:- Workspace scoping: Every credential belongs to a workspace, and each delivery query proves the receiving agent belongs to that workspace.
- Three delivery sources: An agent can receive a credential from an
explicit
agent_credentialsgrant, a resolved binding scoped to an agent, crew or workspace, or a legacycredential_crewslink. An explicit grant is the most specific source; it is not the only source. - Encryption at rest: Secret material uses AES-256-GCM with versioned keys.
- Channel-specific delivery: Supported reverse-proxy routes keep the real
provider key in the sidecar. OAuth/CLI tokens, file credentials and API keys
for adapters without a routable endpoint can enter the agent environment or
/secretstree. See the adapter matrix. - Optional Keeper mediation: Keeper is off by default. When enabled, the
delivery-policy table withholds
SECRETcredentials and mediates their use; other known credential types are not Keeper-gated today. L1-L4 changes the decision policy for a Keeper request, not whether every credential type is delivered at boot. - Audit: Delivery, Keeper, lease, reveal and mutation paths emit audit records. A direct read by a process that already holds an env/file value is not a new brokered access event and cannot be logged as one.
JWT Authentication
User authentication uses JWT tokens signed withNEXTAUTH_SECRET:
- WebSocket connections use short-lived tokens (
ws_token_expiry, default 5 minutes) - API requests use session-based JWT tokens
- Token validation is handled by the middleware layer
Explicit Guest crew shares
Workspace OWNER/ADMIN users can open Share in a crew’s Settings profile, or select Crew in a person’s resource Access editor. These controls use the same member-policy API ascrewship share crew and crewship unshare crew.
They change only explicit View/Use shares for Guest accounts and preserve all
other resource operations. Saving a share never changes the person’s account
mode or grants a crew role.
View shares crew identity and current agent identities/status. Use additionally
shares Chat and Run for current and future agents in that crew, with each
agent’s authority and execution preflight still required. Newly added agents
become discoverable. Neither choice grants Delegate, credential visibility,
existing conversations, activity or crew administration. Execution can still use the
crew’s configured credentials after normal preflight. The sharing dialog states
this dynamic audience before the administrator saves it.
Saved grants keep their issuer. An inactive share requires an explicit
Reissue as me choice; a revision conflict requires reloading and reviewing
the current policy. A Guest can see the crew source and an explanation of inherited agent capabilities in
Settings → Your access, without receiving access to another person’s policy.
Explicit trusted crew Manage shares
The crew Share dialog also displays trusted recipients. OWNER/ADMIN can select Manage crew for a trusted MEMBER or MANAGER. The person Access editor also offers Crew / Manage for these trusted recipients, using the same versioned member-policy API andcrewship share crew --operation manage CLI. The control
preserves trusted mode and shares for other resources. It does not grant a crew
role, agent Delegate, credential visibility or additional reveal scope.
Manage permits that crew’s profile/configuration and ordinary membership,
without assigning/removing explicit crew roles, deleting the crew, changing
budgets/policy or administering the workspace. Saved inactive shares remain
visible after a recipient becomes VIEWER, ADMIN or OWNER: they can be removed,
but a new or reissued Manage share requires a trusted MEMBER/MANAGER. The API
rechecks current recipient and issuer authority on every save. Conflicts require
an explicit reload, and account mode is never changed by the Share dialog.
A trusted recipient with a currently allowed Manage share sees Add Member
and Remove for ordinary crew members in Crew Settings. Memberships with
an explicit crew role can be removed or edited only by the existing
administrator controls. The UI checks the signed-in actor’s own effective
access and hides grant-based controls while checking, after a failed refresh,
or after an account, crew or workspace switch. The API remains authoritative
and rechecks every mutation; an earlier successful display never authorizes a
later request. Budgets, deletion and workspace administration keep their guards.
The corresponding CLI commands remain crewship crew member add and
crewship crew member remove under the same server policy.
Losing management authority closes and discards an open Add Member draft.
Losing the administrator floor also discards an open role editor, even if an
ordinary Manage share remains. Restoring access never reopens those drafts.