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.
Agent access to artifacts from chat
Behind the workspace feature flagartifact_agent_access_modes, off by
default (crewship feature-flag turns it on per workspace). With it off the
artifact_refs message key is ignored, and turning it off later starts
already-referenced runs the ordinary way, binding nothing.
- An agent reaches an artifact from a chat run only through a structured reference the human attached to the message (a composer chip, resolved by the server when the message is sent), never through text the model reads.
- The server checks each reference against the human as an ordinary member. Access the human holds only through the ADMIN or OWNER role is never delegated.
- A refused reference gets one error whether the artifact is missing, unreadable or in another workspace.
- Only the human message admission records references and binds them to the run, checking each one again at run start. Database triggers refuse any reference that is not the human’s own message and workspace page, and any other run scope row. Agents and internal tokens cannot widen it.
- References are accepted only in the human’s own private chat with the agent.
- With the flag on, a chat run reads an artifact only if it was attached, was created by the agent in this chat and is still the human’s, or the agent holds its own grant on it; the human’s member-level access is rechecked on every use. Writes are limited to the human’s own attached or created artifacts; agents never share or publish.
- A folder can let the agents of its owning crew read its non-private
pages (
crewship page folder agent-access, or Can suggest / Viewer in Folder settings; admin or the crew’s MANAGER+). Never edit, never another crew’s agents, never Personal pages; in a chat run the human’s access is still required. Atpropose, agents can read; on Docs they can propose changes for an editor to accept: only through the human’s explicit iteration request, only while the human edits the Document as an ordinary member (never through the ADMIN or OWNER role), re-checked on every proposal, and accepted only by a person with Edit. The run never commits, checkpoints or accepts through a folder. On every other kindproposeis the same asread; the folder dialog says so and offers Can suggest only for the kinds the server names inagent_propose_kinds(Docs). - With the flag on, a run under any propose mandate (every iteration on a
schema 4–6 Document: through a page grant, a folder at
propose, or on the human’s own Document) cannot take or renew a Document’s writer lease, so it can never block a person who edits or accepts; it may still release one. - A run without a human (a routine a person started, a schedule’s fire, an
agent’s webhook or cron run) reaches artifacts only
when crewshipd recorded the run (agent, crew, trigger, source) before its
agent started and minted a random capability for that one run. A
schedule’s fire (cron or “run now”) counts only when a person created the
schedule or last changed what it runs (cron, timezone, inputs, target,
pin, wake check) with their own session or CLI token, and when each step
starts that person still holds the same membership (not left and
rejoined), a MANAGER+ role, trusted (not restricted) access, is not
suspended and has had no access revocation since. Enabling, disabling or
renaming a schedule, or changing its failure limit, catch-up policy or
spread, does not change its creator. A schedule an agent
saved, or one saved before the creator was recorded, never counts until a
person changes what it runs. A step already running keeps its capability
until it ends (at most 2 hours); a run resumed after a wait or approval
gets none. A delayed or
debounced run, a queued occurrence, a webhook,
call_pipeline, an issue, an automation or another agent records nothing and reaches no artifact, and neither does a routine an agent authored, whoever runs it. A sidecar restart loses the run’s capability: later calls get 403run_capability_lostand the run reaches nothing more. The capability goes to the crew’s sidecar, never the agent’s environment, and ends with the run (its end, its terminal journal entry, or its own timeout plus 5 minutes, at most 2 hours). A run token alone is not enough, because the crew container holds the key that derives run tokens for any agent and run of the crew. Such a run reads only artifacts its agent holds its own live grant on, or non-private pages of a folder that lets its crew’s agents read, never Personal artifacts and never anything through a role, at mostrun_read_limitdistinct artifacts per run (429artifact_run_limit). It writes only through a livewritegrant the artifact’s owner gave the agent on that artifact, never through a folder, and it does not create, share, restore, comment or touch dashboard data. Not solved: agents of one crew container share UID 1001, so a sibling that steals another agent’s run token (for example from/proc/<pid>/environ) also gets that run’s capability through the sidecar. The capability adds nothing beyond the token; this is the same exposure chat runs have. - Per-run limits (3 created, 50 distinct standing reads) and a per-crew hourly
page limit (20) come from
crewship workspace artifact-policy. - A Design is reached the same way as an artifact project. A run reads the version its human is entitled to: the shared version for a Viewer or Commenter, the latest for an Editor (edit held only through the ADMIN or OWNER role does not count). Agents still never create a Design.
- Word documents, Sheets (GridCraft) and Mooring documents are read through
the run’s scope like any other artifact, with the human’s own read of that
kind rechecked on every use: a Word document as an ordinary member reads
it, a Sheet only as its owner or an owner-named editor, a Mooring document
only as its owner. Agent grants and folders never reach a Sheet or Mooring
document. Changing one still needs its own exact-run consent (a drafting or
iteration consent, or a mandate), which binds every write’s targets, base
revision and lease, so an agent write under another person’s lease ends as
a proposal, never a direct edit. Without it a Sheet or Mooring change
answers
proposal_requiredand a Word document change is refused; no lease is taken. The run sidecar forwards only a singlepage_idon the Word draft view (crewship doc draft view --page) and refuses every other query; the server alone decides reach, and an unreached page is answered like a missing one. Scope reach serves only that view: a Word document’s export, comments and checkpoints are never read through it, and a page one of the run’s own consents names is served by that consent alone, with its block limit. With the flag off the server refuses all of this as before, but some refusals now come from the server instead of the sidecar, with another status or body (listed indocs/specs/pages.md§7.1c). Native Word and Sheet Craft tasks are unchanged. - Every access through this path is audited as
artifact.agent_run_accessed, naming the human the agent acted for, the agent, run, reach and operation, in the same transaction; no audit record, no access. This covers artifact projects, Designs, Word documents, Sheets and Mooring documents (under a consent or mandate with reachconsented, a created Word document withcreated, a read through the scope with its reach, a Docs proposal through a folder withfolder). A Docs proposal is recorded with operationpropose, neverwrite. A run without a human has no user on the record; its metadata names the trigger and source, and a scheduled run also itsschedule_id. Reads and writes are recorded once per run and artifact, creates every time. Native Craft tasks are not covered. Read them withcrewship audit --action artifact.agent_run_accessed -f json.
docs/specs/pages.md §7.1c.
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.