Skip to content

Security: SamuelAlev/control-center

SECURITY.md

Security policy

Reporting a vulnerability

Do not open a public issue. Use this repository's private vulnerability reporting with impact, reproduction/PoC, affected component and version/commit. Reports receive acknowledgement and a fix or mitigation plan after triage; allow time to remediate before disclosure.

The server, relay, clients, workers, external tools and disposable rigs have different trust levels. This document owns their security contracts; ARCH.md covers implementation flow and AGENTS.md the coding rules.

Authorization and isolation

  • The server owns data, policy, external APIs and execution. A device PSK authenticates a device, not membership in any workspace. Principal distinguishes humans and agents; rate limits are per principal across devices.

  • The server owner is the user recorded in server_meta.server_owner_user_id at first boot, before any listener opens. A paired device belongs to the user who minted it, a redeemed invite always provisions a new account, and nothing reached over the network sets or changes the owner. Startup prints one cc_server exposure: line (bind address, TLS, relay, tunnel, owner) before the ready banner.

  • Only the server owner creates a workspace (workspace.create, serverAuthority: serverOwner); the server mints its id. workspace.upsert only updates a live workspace and ignores the wire's owner, deletion and creation time, so a deleted workspace's id never names a workspace again; workspace.transferOwnership (workspace owner) is the only way its owner changes.

  • Workspace operations require an explicit workspace_id. Check the registered, non-deleted workspace before membership lookup or opening its database; even role lookup can otherwise create an empty database for an unknown ID.

  • Enforce WorkspaceRoleResolver membership at every inbound lane: repo/call, sub/subscribe, tools/call, and HTTP media/backup handlers. Workspace sessions are not a substitute for per-call scoping. MCP over HTTP answers two callers only (see host tools): an agent run is confined to its attested grant, so the dispatcher forces workspace_id and a tool that takes no workspace is refused (newsfeed) or filtered to the grant's workspace (list_workspaces). Phone tools additionally use default-deny RemoteToolPolicy and RemoteRateLimiter, with tighter mutation caps.

  • Scope ID lookups or reject entity.workspaceId != workspaceId at the read/write chokepoint (WorkspaceMismatchException or explicit MCP error). Repo tools also verify isRepoLinkedToWorkspace; per-repo grants must not exceed forge access.

  • PR data follows the forge. A member receives a linked repository's PRs, counts or access records only while they are an admin or hold a read grant and their own forge sign-in can read it (PrRepoVisibility); not yet checked, or a check older than ten minutes that could not be renewed, is hidden. Review spaces, PR notifications (feed, live frames, Web Push) and per-repository review, merge-conflict and compose reads follow the same rule. So do:

    • every message, turn and op of a review space whose PR is hidden, including space lists and live watches, which end when the PR turns hidden;
    • agents' MCP space reads (get_messages, list_spaces), judged as the run's requester; an unattested caller sees no review space;
    • pipeline runs and steps tied to a hidden repository or review space;
    • agent run logs in a hidden review space;
    • the audit trail, which drops a hidden entry's target and details.

    Repository lists follow the Control Center grant (admins see all). Code follows the forge too: file trees and content, diffs, search, IDE data and a terminal in a space require, beyond the grant, that the caller's own forge sign-in can read every repository the op exposes (repoForgeReadCheck, at the dispatcher and in the catalog grant helpers). Workspace admins are not exempt; the server owner is, since they own the host's disk; a repository with no forge remote is grant-only. A forge that cannot be asked is a refusal (forge_unconfirmed), never a pass, and refusals are audited. What agents wrote about that code follows it as well: a space's content (messages, transcripts and tool output, search, conversation trees, todos, run logs, activity, notifications, context.inspect) is readable only by a member holding a read grant and forge read on every repository the space exposes (its selection, or every linked repository when it selects none), through one gate (SpaceRepoAccess, applied by PrDataGate.requireSpace); a space with no repositories is open to every member, and a space a caller may not read is left out of every list and refused by id with the code ops' own refusals. The runtime builds one SpaceRepoAccess, and the RPC catalog, the agent MCP lane and both notification paths (web push and live frames) use that same instance, so a run sees a space only as the person it acts for could and a notification is delivered only as the feed would show it; the server owner is exempt only from the forge half. Worktree, worktree-branch and stack ops check the space first, then the repository grant: read for listing and reading, write for anything that changes files or branches. Skill evaluations on a repository skill need the workspace grant, a linked repository and forge read, and are refused the way repository ops are. /blob serves attachment bytes to workspace members by content hash, which a caller learns only from a gated read. IDE background fetches use the viewer's own sign-in and are skipped without one. worktree.syncToPrHead fetches on the caller's own GitHub sign-in and raises needs_sign_in without one; only an environment following its PR head (a forge event, with no person acting) fetches with a one-repository automation read token. /proxy/media uses the viewer's own sign-in for the workspace it names, after a membership check, and keeps credentialed fetches out of the shared cache. Only a 404 or an access-refusing 403 is remembered as no access; a rate limit or forge outage fails closed and is retried. Hidden repositories are reported as counts per forge and reason, never by name. This applies to admins and the owner too, because the poller fetches with automation credentials no member should see through.

  • users.updateProfile and users.checkHandle act only on the caller (ctx.userId). identity.me tells the caller which identity provider their own account is pinned to (sso_issuer), never the subject and never anyone else's. An SSO login matches an account only by its pinned (issuer, subject), then by a verified email, never by a username the identity provider asserts: usernames are chosen by people, so a name match would hand over an account. An email address identifies an account only when both ends stand behind it: the provider's claim says it is verified (a missing email_verified is not), and the account's address is verified (User.emailVerified: set by SSO or SCIM, or by the server owner through users.vouchEmail, audited user.email_vouched without the address; the owner's own profile edit vouches for itself). An address a person typed about themselves, in their profile or an invite, is unverified and matches nothing, so it can never receive someone else's login, subject pin or group-derived memberships, and editing an address clears the flag. A provider-vouched identity takes an address from accounts that merely typed it (cleared, audited user.email_unvouched_cleared), never from one that holds it verified. An address is stored and compared trimmed and lowercased (normalizeEmail); a vouched address identifies an account only when exactly one account holds it vouched (two holders match nothing and are logged without the address), and no account can be vouched for a case variant of an address another holds vouched.

  • GlobalDatabase contains only explicitly shared state; each workspace has its own file. Never cache a workspace DAO. Use CrossWorkspaceQueries plus a CROSS-WORKSPACE BY DESIGN explanation for legitimate fan-out; no ad hoc workspace enumeration. Pre-auth IDs route through workspace_routes, with no scan-on-miss fallback.

  • Filter cross-workspace watchAll results per subscriber (_visibleRows), events in RemoteEventForwarder, and presence by repo grant. WorkspaceMemberRemoved drops that workspace's subscriptions and invalidates cached membership. Device revocation watches paired_devices and terminates its sessions.

  • Request cancellation is scoped to the authenticated connection and targets only reads or subscription setup. Unknown IDs leave no tombstone; other sessions and mutations are unaffected. Cancellation does not free a running handler's concurrency slot early, so cancel/reissue cannot bypass admission limits.

  • Registry operations self-gate: workspace update requires admin, delete requires owner, reorder filters to the caller's workspaces; confirmation.respond requires member. Server-owner operations (server settings, MCP, models, rigs, SSO, telemetry, connectivity) declare serverAuthority: serverOwner, which the dispatcher enforces before the handler runs; no handler re-checks it and no workspace role stands in for it (fullClientOnly keeps an op's authority, repo gate, audit rule and timeout). The owner checks that depend on data are made where the data is, at the write and again at the use: a host-running environment definition (ServerOwnerRequiredException, the same wire shape, on save; the recorded approval on every run) and a checkout outside workspace storage (RepoPathGuard.check at link, admit at read).

  • No op takes a host path from the wire and then opens it, unless it is server-owner-only (fs.browseDirectory, fs.persistLogo, workspace.import's source path) or confined to the workspace's own directory with symlinks resolved (confinedRealPath in fs_confinement.dart, which also refuses dangling links: fs.ensureDir, fs.writeString, repos.readFile, repos.listDirectory, worktree.readFile, worktree.writeFile). Run log paths, worktree rows and logo paths are written only by the server: agent_run_log ops accept no log_path and the reader is confined to the run's workspace directory, a workspace logo is only the workspace's own logo file (fs.persistLogoBytes takes an allowlisted extension, and the logo routes refuse anything else), and no client op writes an isolated-repo row.

  • process.detect lists only the live agent runs of registered, non-deleted workspaces the caller is a member of, and all of them for the server owner. process.kill resolves the pid against those live running runs at kill time and stops one only for a member of its workspace (or the server owner), so a pid that is not a live agent run, or not the caller's, answers not_found alike and is never signalled. agents.killProcesses (catalog/agent_run_log_write_ops.dart) stops through the same check and only in its own workspace, and skips live runs in spaces the caller cannot read (they are left out of killed). agent_run_log.stop follows the run's space: a run the caller cannot read answers not found, like a missing run, and is never signalled. Both process ops are full-client only, and they do not yet follow the run's space: process.detect lists, and process.kill stops, live runs in spaces the caller cannot read, because ProcessDetectionService decides from the workspace alone (fixing it needs detect and stopRun to receive the run).

  • The cache.* ops read and write only the caller's own editor layouts (EditorLayoutCacheKinds), stored in the workspace's editor_layouts table under the session's userId, never an argument. They reach no other table: the caches table holds only declared, re-fetchable kinds (CacheKindRegistry: PR payloads, repository access probes) and no client op reads or writes it. State that must hold (collaboration take-overs, approval escalation, who asked an agent for a pull request) lives in tables of its own; the last of these, agent_pull_request_requesters, is in global.db so that deleting or restoring a workspace cannot erase the record that keeps a requester from approving their own agent's pull request.

  • CachedPrReviewRepository shares cached PR rows across members only for a repo linked to the workspace (isRepoLinkedToWorkspace, checked when resolvePrReviewRepository builds it, after the member's repo grant). Otherwise every key carries u:<userId>|, so a private PR one member's credential fetched is never served to another. PR/commit preview chips are always keyed by the caller.

  • /meeting/audio and /workspace-logo verify membership after PSK authentication. Backup HTTP routes independently enforce workspace admin for export and scheduled backup downloads, and the server owner for whole-install snapshots and for backups of deleted workspaces, which no workspace role can reach; each owner check fails closed when no owner is recorded. Restoring a workspace adopts a database file whose rows the server then treats as its own, so restore (POST /backup/restore, like workspace.import) is the server owner's, and only for a workspace they still own (server_owner_required otherwise); no trigger, view, column or constraint the file brings is adopted. A workspace backup is the workspace's whole database (conversations, run logs, repo links, environment definitions, members), with no provider credential, device key, user secret or webhook secret, which live in the global database and the secret store, and without the code index, which is rebuilt; see backup lifecycle.

  • A restored or imported workspace file is data, not authority, whoever made it. The import (prepareStagedWorkspace) checks the file before anything is replaced (integrity, the snapshot's recorded checksum, that it is a workspace file of a version this server can read, that its webhooks and invites do not already route to another workspace) and takes out what the file could otherwise grant itself: host approvals of environment definitions are cleared, and allowing or prompting action policies, sandbox exec grants, repository grants above read, roles above member and invites to them wait in imported_authority_holds until the server owner accepts each one (workspace.importHolds.resolve, server-owner authority). The importer keeps the owner role; denying policies stay. WorkspaceRestored drops every cached decision derived from the old file.

  • The data directory is the server owner's alone: the server creates it 0700, tightens an existing one and every workspace directory in it, and refuses to boot (ServerBootRefusal, exit 78) when it cannot, or when its identity file cannot be read. It never starts on a fresh identity because the stored one was unreadable.

  • A workspace file that fails its integrity check takes no writes (storage.read_only on the RPC, MCP and webhook lanes) and is left out of new snapshots, so damage is neither built on nor copied over the last good backup, which is pinned until the workspace is restored. A global.db that is damaged, newer than the binary or not this server's stops the boot; the server never starts on a guessed or emptied one. See storage failures.

Regression coverage: cc_persistence/test/workspace_isolation_ratchet_test.dart, cc_host dispatcher/subscription/session tests, cc_server_core/test/fresh_boot_first_workspace_test.dart and remote-event-forwarder tests. New workspace surfaces need behavioral cross-workspace denial coverage, not only structural checks.

Credentials

Provider tokens live on the server, never in client storage or RPC responses. The client keychain (flutter_secure_storage) holds only its device credential. Non-secret preferences use nativeapi Preferences on the desktop and shared_preferences on the phone.

Client read snapshots contain previously authorized presentation data, not credentials or authorization decisions. They are isolated by verified server identity and authenticated user, with workspace/query arguments in each entry. Desktop files are owner-private; web snapshots are origin-local IndexedDB data. Fresh membership reads prune revoked workspace data, explicit authorization failures evict affected snapshots, and forgetting/disconnecting a server removes its persisted snapshots. Cached data never bypasses the cold-start authentication gate or authorizes a write.

Server credential lanes under packages/cc_server_core/lib/src/identity/:

Lane Storage and authority
Per-user UserCredentialsStore user_forge_<forge>_<userId> / user_ticket_<provider>_<userId> in 0600 FileSecretsStore; JSON access/refresh/expiry/source/account envelope. credentials.* always targets ctx.userId. A GitHub or Linear sign-in moves to a per-workspace slot (workspace_forge_github:<workspaceId>:<userId>, workspace_ticket_linear:<workspaceId>:<userId>) only in a workspace that runs its own app or its own Connect. A pasted GitLab or Bitbucket token is always the person's one server-wide credential: no op takes a workspace for it. People manage all of these under Settings → You → Profile.
App identity (ProviderAppSettings, GitHubAppClient) Operator-only providerApps.*; non-secrets in server_settings, secrets in the secrets file. Environment seeds each field once; stored values then win.
GitLab/Bitbucket automation tokens (ForgeAutomationTokens) workspace_forge_automation:<workspaceId>:<forge> (workspace slot) and …:repo:<repoId> (one repository) in the same FileSecretsStore; the token plus the bot's name, kind, scopes and status. Written only by workspace admins; deleted with the workspace, when the repository is unlinked, and by the link sweep; clients only ever see the description.
Commit signing keys (CommitSigningKeys) user_commit_signing_<userId> in the same FileSecretsStore: the Ed25519 seed, its public key and when it was created. Created and deleted only by that person (credentials.createCommitSigningKey / deleteCommitSigningKey, full client only); credentials.commitSigningKey and every other surface carry the public half and fingerprint only. Used only to sign that person's own commits.
Environment Operator app settings seeded once (see .env.template). Never a person's or a GitLab/Bitbucket forge credential.

ForgeCredentials resolution is deliberate:

  • With a calling user: that user's own credential in effect for the workspace, otherwise nothing. An op that needs it throws NeedsSignInException(lane) (RPC unauthorized, data.kind = needs_sign_in). Never borrow the owner's, another member's or the environment's credential for a person's action.
  • Without a caller (polling, webhooks, schedules, automatic review publication): GitHub uses one-repository installation tokens bounded by the workspace's accountable human; GitLab and Bitbucket use only the repository's automation token (its own, else the workspace's for that forge), never a person's: with none that can read the repository, automation there pauses and records automation_token_missing. There is no server-owner or environment forge credential.
  • A person typing (comment, review, approve, merge, reviewers, PR edits) acts on their own GitHub App user token, so GitHub shows them as the author. GitHub names the App only on issues and conversation comments (performed_via_github_app); a review and its inline comments carry no App label. Agent chatter and automation (AI review, PR-conversation replies, claim reactions, labels, pipelines) act on the App's installation token and show as the bot, with the scope clamped to the acting or accountable human's role. On Connect, Connect mints that installation token only after checking with the human's own sealed sign-in that they can see the repository; no installation is bound to a server. A PR an agent opens for a person, and the pushes to it, use that person's one-repository downscoped user token, so GitHub's own rules stop the requester approving it, and only if they may read that repository in the workspace (admin or read grant; accountableHuman applies the same grant check to automation bounded by a person). Control Center itself refuses, on every forge and for both submitted and published reviews, an approval with no person acting; from anyone the agent opened that PR for (the person who asked, or, for an unrequested run, every admin who armed its trigger or edited its template while armed), recorded before the PR is opened, keyed by the forge's durable repository id once it exists (a rename or transfer keeps the record) and checked across every workspace; or from the PR's own author, matched by account id when both sides have one, else by login. The check fails closed: a PR it cannot read, one with no repository id or no author, or an approver whose forge account cannot be resolved is refused with a retryable "Couldn't confirm … Try again." Approval is never automated.
  • GitLab and Bitbucket automation tokens are stored by forge.setAutomationToken and removed by forge.clearAutomationToken, both workspace-admin ops (forge.listAutomationTokens too) that check the workspace before membership and refuse a repo_id linked to another workspace. A token is verified with the forge before it is kept: GitLab must answer /personal_access_tokens/self and /user as a bot (a project or group access token), Bitbucket must be an access token (an email:token API token is refused, and so is any token /2.0/user answers for as an account other than an app_user, such as a person's OAuth token; a token is accepted only when /2.0/user answers app_user or refuses an ATCTT… access token, and an unreachable Bitbucket stores nothing), and it must read the repository it is for (a workspace token must read at least one linked repository; the rest are recorded as paused). The forge refusing it later marks it rejected and it stops being used. Its git username is oauth2 on GitLab and x-token-auth on Bitbucket. Automation clients for GitLab and Bitbucket refuse any request outside their repository, and any approval (refuseForgeAutomationRequest). A GitLab or Bitbucket token a person pastes for themselves is stored only after the forge answers for it as that person, with the scopes needed and unexpired (person_token.* refusals otherwise); GitLab's expiry is kept and shown to them. Forge logs name a credential only as hashed_token. The forge audit scrubs every kTokenPatterns shape and HTTP Basic credentials from what it records, and a lapse marker that cannot be written is logged by error type only.
  • Thread ctx.userId through per-actor factories (forgeHttpClientFactoryForActor, forgeRegistryForActor, prLifecycleRepositoryForActor, ReviewPublisherService.githubPrClientFor). Include acting user in prRepoCache keys so cached authenticated clients cannot misattribute another person's writes.
  • An agent run starts with no forge token. What it reads GitHub with is a ForgeTokenScope.review token for one linked repository it works on, which the agent run gateway mints when the run's git or gh first asks and revokes upstream when the run ends. It only reads (contents, issues, pull requests, checks, actions, statuses): it cannot push, comment, label, open, edit or review anything. An agent comments on its own pull request through the server's comment_on_pull_request tool (as the bot bounded by its requester, only on a PR from the base repository itself, never a fork, whose head is a branch the run pushed at a commit the run pushed, or its space branch at the space checkout's current head), changes the title or description of that same pull request, while it is open, through update_pull_request (on the requester's own token, the bot only for a run nobody requested, as for opening; an ActionClass.prPublish action that asks first by default; the agent marker kept) and opens one through open_pull_request (on the requester's own token); shell gh PR, issue and gh api conversation writes are refused with those directions. A pull request description keeps its @-mentions, opened or edited: bringing people in is part of a pull request, and it goes out as the same actor either way. Agent text the bot posts in a conversation (those comments, PR-conversation replies, automated AI review publishes and prReview.comment steps) has every @-mention made inert (neutralizeMentions) behind the attribution prefix, so it can page no user or team; a person publishing their own review keeps theirs. publish_review_to_github takes its space from the run's grant, never from the agent's arguments. A sandbox never holds a member's whole sign-in, a write token or a ticketing API key. Pipeline shell steps get ForgeTokenScope.read, which is read only whoever the human is. A write token is minted only by the agent run gateway or a human-opened terminal rig and never enters an agent's environment. Every scoped token must prove it covers exactly one repository with exactly the asked permissions, and automation clients refuse non-repository requests and other writes no one-repository token covers whoever is acting: an owner-wide client never sends a person's token and refuses every GraphQL mutation. A one-repository client (forRepo, and the requester's viaPerson lane) sends a GraphQL mutation only when every root field, read from the parsed document (comments, strings, aliases and fragments hide nothing), is on the allowlist githubGraphQlMutationScopes, at the highest scope listed: conversation comments, reactions, labels and assignees at comment; reviews, review threads and review requests at bot; a pull request's state, title, base or branch, review dismissals, and editing or deleting a comment that may be someone else's at write. An unlisted mutation, a subscription or an unreadable document is refused locally. REST makes the same split (githubScopeForRequest), except PATCH /issues/{n}, which stays comment because its URL cannot tell an issue from a pull request and ticket sync edits issues with it; the server sends it for no pull request. On Control Center Connect the shared App's bot is minted at most comment (issues:write) for any server, and bot (pull_requests:write) only for installs the Connect operator lists in CONNECT_GITHUB_REVIEW_BOT_INSTALLS; never contents:write. Connect refuses more with needs_requester before asking GitHub, so an unlisted server's bot can comment, label and react but never reviews, pushes, creates a branch or opens a pull request: those ride the requester's own token, which GitHub clamps to that person. For a review that is one decision (connectBotOrPerson): the bot is asked first, and on needs_requester the review goes out on the accountable person's own one-repository token and appears under their name; with nobody accountable it is refused. write is never asked of the bot. The PR conversation bridge claims and replies only when the scope it will post with can be minted (canPostAs: comment on the PR timeline, bot inside a review thread), so on an unlisted Connect install a review-thread reaction or reply goes out on the asking member's own narrowed user token and appears under their GitHub name, still carrying the attribution prefix, while timeline posts appear as the bot. For a listed install GitHub would let the bot token do more with pull requests (approve, dismiss reviews, open one from an existing branch, edit or close one, edit others' comments); the server never approves with it and sends none of those on it, since they ride write, which on Connect only a requester's own token holds. Nothing binds an organization's installation of a shared App to one server, by decision: any server holding the sealed sign-in of a member who can push to a repository can obtain the comment bot token for it, and Connect cannot police what a server does with a token it handed out. Skill catalogs are the one unlinked read: GitHubClients.forSkillSource sends only GETs and mints only read for a workspace's registered skill sources and the upstreams its skill lock pins, and agents, shell steps, rigs and the gateway never reach that path. A source the App cannot read is fetched with the requesting member's own sign-in, never another member's or the owner's, and an unattended update check does not fall back at all.

Every browser sign-in (github, google, linear, linear_app, slack) runs through ProviderSignInService (oauth.begin): on an own App the browser returns to <public origin>/oauth/<lane>/callback with a single-use, TTL-bounded state, and that unauthenticated callback stores nothing: it keeps the provider's one-time code, reflects nothing from the request and shows a confirm code; on Connect it returns to Connect, which shows the confirm code. Either way only oauth.complete, called by the person and workspace that began the attempt, exchanges and stores the grant (on Connect with the confirm code, this server's PKCE verifier and its signed install identity), so a link the local client did not start is never completed and a browser that finishes someone else's link signs nobody in. The stored grant is the account the provider itself names for it; an account another person already holds is refused and its grant revoked, and a grant that lands after its attempt ended is revoked. GitHub accepts only an expiring App user token (ghu_). There is no PAT entry for GitHub, and host gh credentials are not an authentication method. GitLab and Bitbucket take a pasted personal token; on Bitbucket that is an Atlassian API token with its account email (email:token, git user x-bitbucket-api-token-auth), and a repository, project or workspace access token is refused there because it belongs to no person. A GitLab token is asked GET /user before it is stored (checkPersonForgeToken): a project or group access token (bot: true) is refused toward the automation-token slot, and so is a token GitLab refuses or cannot be asked about.

Each attempt returns an opaque login_id. oauth.* calls name the active workspace, which is checked as registered and not deleted before membership; the person is always ctx.userId, and the server decides whether the grant lands in the workspace's slot or the global one. oauth.status checks the authenticated caller and the attempt's workspace and returns only pending, succeeded or failed (attempt_unknown after a restart). Success is reported after the credential is stored. Attempt tracking is bounded, and starting a login prunes expired outcomes. Clients watch this attempt independently of the dialog, refresh connection state on success, and do not treat an existing credential as completion of a new sign-in.

Provider credentials may be configured through supported Settings fields or the server's .env, never command-line flags. cc_server reads .env from its working directory, beside the executable or from a source checkout above it, beneath real environment values (environmentWithDotenv); clients do not forward it. It refuses to start (exit 78, refuseExportedProviderSecrets) when GITHUB_APP_PRIVATE_KEY, GITHUB_CLIENT_SECRET, GOOGLE_OAUTH_CLIENT_SECRET, LINEAR_API_KEY, any SLACK_*SECRET* or an embedded-Connect secret is exported in its real process environment (which variables are Connect secrets is decided by isConnectSecretEnvKey in cc_connect_core: every secret Connect reads, CONNECT_SENTRY_DSN included, and the previous generation of each dual secret, pinned by a Connect test to exactly what Connect's configuration reads as a secret), where every process it or its parent starts could read it; the same keys in .env are fine. Docker mounts the file read-only at /app/bin/.env. No build carries a provider credential: each lane uses a workspace's own app, the operator's own app or Control Center Connect, never a baked fallback. The server's own apps apply only while the Connect choice is Use my own apps (ConnectSettings.serverOwnAppsActive); with Control Center's or a custom Connect they stay stored but inactive. A workspace admin may override that choice for one workspace (workspaceConnect.set): Control Center's Connect, a custom Connect, or the workspace's own apps (GitHub, Google, Linear, Klipy), which then apply alone, fail closed when incomplete, and keep their secrets in FileSecretsStore, deleted with the workspace. An overriding workspace never uses the server's apps or Connect, and its members' GitHub and Linear grants live in its own slot. CC_CONNECT_URL also forbids a workspace Connect. A workspace's custom Connect URL must be HTTPS and is held to the /proxy/media SSRF rules when saved and on every connection, which goes to the address that passed the check; its TOFU pins are that workspace's own, so confirming a change there never moves the server's or another workspace's trust. A seal is sent only to the Connect origin that made it and opens only while its workspace still uses that origin with the same install identity; otherwise it is parked, or dead on an install-id mismatch at the same origin. Members may read the workspace's choice; its install id and pending pins are for admins. Connection RPCs return status/account only; secret settings are write-only, with presence flags returned.

Leaving a workspace revokes and deletes that person's provider credentials for it, and leaving the server's last workspace their global sign-ins too (CredentialOffboarding, one path every sign-in lane implements; a workspace's deletion runs it before its secrets go, and a boot check catches what was missed).

Personal credential operations bind to the authenticated user. Global harness/provider credential writes and OAuth state require the server owner, not merely a workspace owner or administrator. The phone can submit supported credentials but cannot read their secret values back or simulate host-only CLI authentication.

Control Center Connect runs one flow, a person's sign-in: a start carrying a purpose or naming an installation is refused. GitHub's authorize URL carries prompt=select_account. Connect's done page is first a consent page: it names what the starting server will be able to do as the person and for how long, says Connect cannot tell who runs that server, and shows the confirm code only after an explicit continue, a form post that must carry the page's single-use 256-bit form token (a post without it is refused and leaves the login untouched) and prove it came from Connect's own page: Sec-Fetch-Site, if sent, is same-origin, Origin, if it names an origin, is Connect's public origin, and at least one of the two is there. Origin: null names no origin and counts as not sent; the consent page carries Referrer-Policy: same-origin (every other answer no-referrer) so that browsers send Connect's origin with its form post. This is Connect's only browser form post; the signed /v1 machine routes, the Slack hooks and the health probes carry their own proof and are not subject to it. Cancel burns the login. A staged login moves forward only once per provider redirect and is stored by compare-and-set, so a replayed or concurrent callback cannot rewrite it; a claim before the provider redirected back spends none of the login's attempts and cannot succeed. A wrong code or verifier is code_mismatch; a grant the provider refused after the code matched is needs_sign_in, and Google and Slack grants refused that way are revoked upstream. A refresh is answered "sign in again" only for the provider codes in oauthRefreshRejectedErrors (invalid_grant, bad_refresh_token, unauthorized_client) plus a provider's own codes of the same meaning kept beside its client; every other refusal is transient and keeps the grant. A one-repository GitHub child token is revoked only for the install and GitHub account it was minted for. A GitHub disconnect revokes only that sign-in: Connect spends the seal's refresh token once under its rotation lease, deletes the returned and the seal's own user tokens, seals nothing, and revokes the children Connect recorded for the same install, workspace and account, so a copied seal answers needs_sign_in; Connect never deletes the person's App authorization. An install can retire itself (POST /v1/install/retire, signed by its own key and naming one credential seal Connect made for it, which must open under that install; no upstream call): Connect keeps retired ids for good, answers them install_blocked and releases their Slack team bindings; an install holding no seal is invalid_request, a seal of another install access_denied, and retirements are budgeted per address (IPv6 per /48). Tokens already handed out live until they expire (user tokens and children at most 8 hours, installation tokens 1 hour). Connect's GitHub token-endpoint calls are budgeted per account and install, per account across installs, per address and App-wide, with sign-ins on an App-wide ceiling of their own that refreshes and children never share; a sign-in over its account's budget has its new token revoked upstream and is refused; as: app mints are budgeted per install, per asking account and App-wide, all checked before GitHub is asked; and rate_limited never drops a grant. Connect logs a GitHub token only as hashed_token (base64 SHA-256, the value GitHub's organization audit log shows), drops any log value carrying a GitHub token prefix instead of writing it, and its Sentry reports carry the exception type, stack frames, route and request id, never a message, body or header. A Connect configured with CONNECT_CONFIG_PUBLIC_KEYS refuses to boot without a signed config. Every Connect read that authorizes a mint (installation, repository permission) is fresh, never cached, so a demotion or an uninstall applies to the next mint. A GitHub installation has no per-server binding: the account's install is its consent, and a one-repository token is the signed-in member's own user token clamped to their role, which never exceeds the user token every server already receives. Slack binding writes are compare-and-set. A Slack event is routed by the workspace its authorizations name, never by the envelope's team_id; one without a single agreeing workspace is dropped. An app_uninstalled or tokens_revoked event frees only that team and, for tokens_revoked, only when the bound bot is among the revoked. Connect writes its seed and bindings to files created 0600 and renamed into place. "Create my GitHub App" accepts only an app with exactly the attempt's single-use name nonce and no permission beyond the manifest's.

Linking a forge repository to a workspace (a new or retargeted link through repos.upsert or repos.addFromPath) needs a workspace admin, as granting repository access does, and on every forge the admin must be signed in and their own credential must see the repository. Owner and repository names must be single segments (no ., .. or separators). App not installed, repository not selected, an accountable human who cannot see it, or a GitLab or Bitbucket repository no automation token can read are returned as access_warnings and recorded in RepoAccessRegistry; automation without an acting person refuses a repository with a blocking record.

A linked checkout's path is checked when it is linked and every time it is read (RepoPathGuard), after symlinks are resolved: inside the workspace's own storage is accepted; the server's data dir, anything in it or anything containing it is refused; any other path on the host is served only when the server owner linked it, because only the host's owner may point the server at the host's files. Every reader that reaches a checkout through a stored repository path goes through GuardedRepoRepository / ServedWorkspaceRepository or calls RepoPathGuard.admit: the IDE, the space provisioner, environments, terminals, the code-graph tree check, the PR worktree source, the list_repos MCP tool and the code.index pipeline body, which takes its checkout from the served repository by repo_id and ignores any path in the trigger payload. An imported row, or one retargeted by a symlink, is therefore not served, but it is listed, never hidden, with path_issue set to the refusal code. It is fixed by linking it again: re-saving it, or adding its folder again, runs the full link checks under the person doing it (admin, path guard, origin, forge verification) and keeps the row id. The code graph is read only for repositories that are linked and served (servedCodeGraphRepos): search_code, code_symbol, code_callers, code_callees, code_impact and codeGraph.* refuse a repository whose stored path the guard refuses and leave its symbols out of traversal results, while its index is kept, so linking it again makes it readable (and RepoAdded re-indexes it). A forge repository's checkout must have an origin naming that repository. Unlinking is a workspace-admin op and forgets the forge credentials held for the repository.

A link is pinned to the forge's durable repository id, recorded from the linker's own verified read (a client-sent id is ignored). A path that now names a different repository (deleted and re-created, or moved and replaced) receives no token, push, comment or request: the refusal is repo_replaced (GitHub GitHubRefusal.repoReplaced, a local 409 on every forge), cached grants for it are revoked, and the link stays marked repo_replaced until an admin relinks it (repos.upsert with relink: true). A rename or transfer keeps the id and moves the stored path. A pinned GitLab or Bitbucket repository whose id cannot be read is not sent to. The pin is compared in one place (ForgeRepoPins) on every lane: automation mints and requests, and every request a person's own sign-in makes about a linked repository (confirmPersonRequest, on GitHub, GitLab and Bitbucket) first confirm that it still carries the id it was linked with. Cached answers mean a swap is caught within five minutes, and cached GitHub grants are bound to the repository id, so they cannot reach a replacement. A linked repository's forge identity (forge, owner, name) changes only through an admin's verified link: a rename by repos.upsert writes the display name alone, and a forge repository cannot be turned into a local-only one (repo_link.forge_remote_required), which would take it out of the forge check.

Every child process the server starts gets a ChildEnvironment (cc_domain), through ChildProcess (cc_infra) or IsolatedGit (cc_natives), never the parent's environment. It inherits only an allowlist of base variables, plus the toolchain or display families a caller asks for, and never a stripped key (GH_TOKEN, GITHUB_TOKEN, provider secrets, SSH_AUTH_SOCK and the like); callers add only the values the child needs. The server update runner verifies the release with gh attestation verify --bundle, with the Sigstore bundle fetched anonymously from GitHub's public attestations API, an empty GH_CONFIG_DIR and no token. A missing published attestation refuses the update when gh is installed.

Server git runs through IsolatedGit: GIT_CONFIG_GLOBAL=/dev/null (NUL on Windows), GIT_CONFIG_NOSYSTEM=1, GIT_TERMINAL_PROMPT=0, -c credential.helper=, -c protocol.ssh.allow=never, -c core.fsmonitor=false and no SSH agent. It runs no program a repository chooses: hooks are off (core.hooksPath is the null device), as are askpass, the ext:: transport, editors and every signing program, so a commit made in the IDE runs no repository hook, like git commit --no-verify. Server git diff always runs with --no-ext-diff (no diff.external and no diff-driver command; an empty diff.external would break the diff instead of disabling it), core.alternateRefsCommand is empty, and submodules are never recursed into. Programs git reads only from a repository's own config files (diff and merge drivers, filters, uploadpack) are kept out by denying every sandbox the write: .git/config, config.worktree, commondir, info and objects/info. That covers the IDE on server-managed worktrees too: SSH remotes fail closed except GitHub's, which are rewritten to HTTPS and authenticated with a token for the linked repo, never the remote URL's. A push or fetch a person clicks carries their sign-in narrowed to that one repository (viaPerson), never their whole user token. A commit a person makes in the IDE is theirs: their forge-verified address (their profile's git identity where no forge vouches for one), Control Center's co-author credit when their attribution setting is on, and their own signing key when they created one; a sync's or pull's rebase re-commits as them and is signed again (as Control Center <hi@usectrl.dev> when nobody can be named). An IDE push is the person's own push on their sign-in, not an agent push, so the push inspection does not apply to it, including to commits an agent made in that worktree: whoever pushes them from the IDE vouches for them. Server code never reads the host's own git config. A git credential is built in one place: forgeGitBasicAuthorization makes the Basic header (one username per forge, every token shape) and forgeGitAuthConfigParameter wraps it for GIT_CONFIG_PARAMETERS; the push gateway forwards with the same function. cc_server_core/test/github_identity_ratchet_test.dart fails on a raw Process spawn, a parent-environment spread, a git spawn, a host GH_TOKEN/GITHUB_TOKEN read or an authenticated GitHub client built outside GitHubClients and the transport primitives; every allowlisted exception carries its reason.

SSO, owner identity and other mutable settings belong in Settings. CC_SERVER_*/matching flags are for pre-boot process configuration (paths, bind, port, TLS, logging), not a second settings store. Redact logged command output before display.

Execution and untrusted input

Actions, tools and skills

ActionClass is a closed effect taxonomy. Every mutating tool declares its classes; the ratchet rejects undeclared tools. Policy precedence is space > agent > workspace > mode preset > built-in default; within a scope, longest-prefix then most-restrictive wins. prompt without a connected approver denies. The autonomy dial cannot turn an action-policy prompt or deny into silent approval, including for pinned output tools. Per-space autonomy profiles use this same store; delegation enforces depth, cycles, budget and autonomy ceilings server-side.

Agents carry no permission flags; push, PR, tracker and network permission are action rules. Shell command lines (harness bash, Claude Code's PreToolUse hook) are classified by ShellActionClassifier, including pushes, deletion, wrapped/compound commands and recognizable gh api PR writes. This remains a soft gate: arbitrary scripts, generated code and unrecognized API calls can conceal effects. Git's pushInsteadOf is routing, not authorization: credential-bearing URLs, explicit ports and command-local Git configuration can avoid its prefixes. Shell preflight therefore always checks gitPush, with the destination branches when every push in the command names them on a plain remote; the gateway independently authorizes actual refs. An operator's "yes" at the shell answers the gateway's ask for the same run for 15 minutes: an approval that named branches covers only those, an unnamed one covers only unconstrained asks (a branch-specific ask, such as one for main, still prompts), and a deny is never waived. A standing approval of a push (below) names the branch family (space/**), so it answers at both checks. The run's GitHub token is read-only, so GitHub itself refuses a push, comment or PR publication that slips past the classifier; the classifier decides only whether the operator is asked.

Standing approvals. Every approval card an agent's action raises is built in one place (ActionGuardService.approvalRequest) and offers "Approve for 8 hours" when the call has something narrower than its class to name: a branch family (a ref's first segment, feature/**), a folder (dir/**), the exact host, the exact command line or the exact tool. A push with no branch is remembered by its exact command, never as the class. A commit is the one action remembered with no constraint (standsWithoutConstraint): it stays in the run's worktree, has nothing narrower to name and its command differs every time. That holds only when a rule asked, the asked classes are exactly gitCommit and the request declares the class. confirmation.respond checks the same condition before it writes, so a client cannot widen what the card offered. It writes an expiring allow with provenance remembered at the space the question came from (the workspace only when an admin answers and chooses it), for 8 hours by default and 7 days at most. A standing approval is outside the precedence chain. It answers an ask set at its own scope or a broader one, for a call wholly inside its constraint (a command approval is the whole command line, not a prefix). It never answers a deny, a managed ask, an ask a command-prefix rule drove, or an ask that stands in for a deny the request could not be evaluated against. A gate that asks on its own account, not because a rule said ask (the MCP tier gate, a mode's command net, an ACP agent's own permission request, confirmCommand), is spared only by a live approval naming that exact tool or command (standingApprovalCovers). A tool that declares no effect class files its approval under ActionGuardService.undeclaredEffect (processSpawn), where policy is read only to find that approval. A plain rule and an approval are separate rows (ActionPolicyRule.sharesIdentityWith): changing an action's setting never rewrites an approval, a policy template never replaces one, approving again refreshes the same row's expiry, expired approvals are pruned at the next answer, and a template export leaves out every rule that expires or that a person did not set. The agent permissions page (desktop and phone) lists each approval under its action with what it covers, who gave it and when it ends, and revokes it; one under a denied action is shown as not in effect. Three cards keep two buttons by design: the sandbox folder exec grant, the destructive-operation confirm, and a skill install, which has no call to name and must ask again when the bundle changes. Only a person's answer is stored: a folder exec card that times out, is withdrawn or expires records neither an allow nor a deny. The run that asked keeps that folder closed for the rest of the run without asking again (ExecGrantRunAsks), unless a decision is stored meanwhile, and the next run asks again. Commands of one run that need the same folder at once share one card and its answer. The card names its run, so in a run the server started it waits the workspace's unattended expiry like any other approval.

Unprompted policy denials notify the operator as informational blocks, not approval requests. This includes a push denied during ref discovery. Live delivery and history remain workspace-filtered; declining an already announced approval produces no duplicate block notice. Notification preferences still apply, and a notification never authorizes an action. A desktop approval notification's Approve and Deny buttons answer through confirmation.respond on the signed-in session, like the in-app card. The server re-checks that the approval is still pending, that the responder is a member, and that it is routed to them. The notification carries only the wait id and the request's summary. It never offers "remember": a standing approval needs the full request on screen. When a wait ends, the client withdraws its notification. A later button press reaches a request that is no longer pending and does nothing.

SkillBundleService scans between fetch and write. No skill bytes or frontmatter enter disk/prompt without a pass/warn/quarantine verdict. Mandatory static rules and capability manifests execute nothing; LLM review is additive. Trust tiers express provenance, never bypass scanning. Bytes scanned = bytes written = bytes hash-locked. Repo skills use the same gate; context symlinks resolve only into explicitly permitted roots, never by recursively following repo-directory links.

External MCP servers and guest-extracted content are untrusted. Strip ANSI/control characters and cap external tool descriptions/results; external tools default to the cautious approval tier. wrapUntrustedRigContent labels guest data as data, not instructions. Framing is not enforcement: approval, filesystem/network limits and server authorization remain necessary. Deferred harness schemas never widen the admitted tool surface or bypass guards.

Agent-command output reads require full-client capability, workspace membership and the space's repository grants. process.agentShellOutput accepts an opaque, workspace/space-bound output identity, never a pathname or arbitrary PID. The server revalidates the owning process before accepting its first captured bytes; PID reuse cannot adopt another process's output. On macOS, regular stdout/stderr files are opened without following path-component symlinks and checked against the observed device/inode; Linux reads the validated process's regular /proc descriptors. Retained descriptors are close-on-exec, bounded and never reopened by a replaced pathname. Output is redacted before RPC delivery; pipes and PTYs are never read. The redactor (redactSecrets, which also scrubs every run-log line, environment command output and agent-shell output) runs in time linear in its input for every pattern, with no length bound on what it redacts: each pattern starts only where its match can start (a literal prefix, ://, the start of a run of token characters) and reads a run a fixed number of times, and a test holds each pattern's worst shape at 1 MiB under 2 s.

Controlled skill evaluation

Campaign admission, subscriptions, cancellation, attempt retrieval and export validate the registered workspace, membership and repository grants. Admission and execution also enforce action policy, active credentials and model support. API-key providers require a known worst-case call reservation, including documented pricing tiers. Claude Code and Codex OAuth subscription campaigns instead use an explicit API-equivalent usage stopping threshold: one in-flight call may exceed it, then no further calls start. This is not an invoice ceiling or subscription-quota measurement. Missing required pricing or unknown observed spend stops further calls; no paid rerun is implicit.

The evaluator re-scans and hash-locks the exact immutable package. Guest commands and file tools use the same enclosure: private fixture/home, no inherited credentials, denied external filesystem access and network, read-only skill assets, bounded output/files/descriptors/CPU and owned-process-group cleanup. Capability probes must succeed before model spend; unsupported hosts fail closed. macOS uses sandbox-exec plus resource limits and does not enforce a hard memory quota. Linux requires bubblewrap and applies an address-space limit; Windows and fleet evaluation are not supported by this controlled protocol.

Control Center never reads Claude Code's OAuth tokens, for usage or anything else. Subscription usage comes from asking the unmodified claude binary (get_usage over its control protocol), so the token stays inside the CLI that owns it. Anthropic's terms allow signing in to Claude Code itself and do not allow a third party to route or hold claude.ai credentials. Do not add a direct call to Anthropic's OAuth usage endpoints, and do not read .credentials.json or the keychain item.

The native Claude controller uses a pinned, managed Claude account and observed CLI version, never the operator's ambient login. Its host process retains provider credentials; its native tools, ambient skills and user/project settings are disabled. The only exposed tools are the authenticated loopback MCP bridge into the confined guest. Native init metadata must match the controlled tool surface and built-in plugin identities; unexpected skills, plugins or tool authority fail closed. CLI-native reported cost is API-equivalent usage, not billed subscription spend.

Candidate code never runs on the server host or receives the trusted expected answers. Built-in typed oracles compare independently specified outcomes in the controller; candidate Python executes in a separately contained copy. Untrusted setup scripts and arbitrary guest-supplied verifier programs are not admitted. Artifact reads reject symlinks/non-regular files and enforce byte limits.

Persisted attempt evidence is redacted and capped at 256 KiB; exports are capped at 16 MiB. When detailed traces exceed that budget, exports retain compact outcome/cost summaries for all admitted attempts and explicitly count omitted or summarized records. Secrets, private inputs and host paths are not exportable replay material. A safety-artifact pass does not override scanner quarantine, prove real-world attack resistance or grant additional authority.

Agent run gateway

AgentRunGateway serves /agent/env (environment shims, see Host environments), /agent/git/… (fetch and push proxy), /agent/forge-token (the read token a run's gh uses), /agent/git-sign (commit signing, see below) and /agent/hooks/pre-tool-use (Claude Code hook) on the MCP listener.

  • Loopback only: any non-loopback peer gets 403, whatever listener the routes are mounted on.
  • Each run is authenticated by a 32-byte random per-run secret sent as X-CC-Agent-Run (git http.<gateway>.extraHeader, hook header from CC_AGENT_RUN_TOKEN); unknown secrets get 401. The secret only lets a process ask: every answer comes from the action policy. On /mcp the secret proves a run only when the run's agent is an agent CLI handed the endpoint (AgentRunGrant.mcpEndpoint); a built-in harness run serves its tools in process, so its secret, which every process of the run can read, gets 401 there. Likewise the Claude Code hook route (/agent/hooks/pre-tool-use) answers only a Claude Code run, whose CLI installs that hook (AgentRunGrant.claudeHook); any other run's secret gets 401 there. Each refusal is logged with the run and workspace once per run and route. A harness run's secret still opens the routes its commands need: /agent/git/* (fetch and push), /agent/git-sign (when its commits are signed), /agent/forge-token (its gh) and /agent/env (environment commands).
  • Scope (workspace, space, agent, mode, acting user, the repositories it works on) comes from the AgentRunGrant registered at dispatch, never from the request, so one run cannot ask with another's identity. In a space those repositories are the server's own record of the space's checkouts (agentRunSpaceRepos: its worktrees joined to the workspace's linked repositories), never a checkout's origin, which the agent can rewrite, and never the directory the run starts in, which is no checkout and would answer for whatever repository encloses the data directory; outside a space they are the checkout the run starts in. Pushes are forwarded only to a GitHub repo linked to the workspace (the worktree's own included) on which the requester holds Control Center's RepoGrantLevel.write grant (admins hold every linked repo); what the requester could push on GitHub does not widen it. A run nobody requested is bounded by the link and its token's accountable human. Read-only modes deny pushes.
  • The git proxy speaks smart HTTP only, for github.com, gitlab.com and bitbucket.org: a fetch (git-upload-pack) or a push (git-receive-pack) of one repository, read from a path whose every segment is validated before it enters an upstream URL. Anything else is refused, Git LFS included. Upstream requests follow no redirect: a redirect comes back as 502, and an upstream 401 as 403, so git never prompts for a credential the run does not have. A push's ref-update preamble is capped at 1 MiB and a hook body at 32 MiB. Compressed pushes are decoded before policy evaluation; incomplete or uninspectable updates are rejected, never treated as ref-free probes. The write token is minted per lease, used server-side to forward, never returned to the agent, and revoked when the lease closes at teardown.
  • Fetches are proxied on every forge, and a run's git holds no credential. Each repository the run works on is rewritten to the gateway in every URL shape (url.<gateway>/<host>/<owner>/<name>.insteadOf for HTTPS, git@ and ssh://), so a sandbox that reaches no SSH agent still fetches; there is no credential helper. A fetch is a read and asks no one: the gateway resolves the "network egress" rule for the forge's host itself, since loopback sits outside the egress proxy, and only a deny refuses it. The run's own repository is forwarded under the name the server recorded, on a credential the server keeps: on GitHub the run's ForgeTokenScope.review token, on GitLab and Bitbucket the token agentFetchCredential answers with for a repository linked to the workspace: the requester's own sign-in for a run a person asked for, the repository's automation token for a run nobody asked for, never one in place of the other. Without it the fetch is refused with what to connect. The credential goes upstream only: it is in no response, log line, error, URL, argv, config or environment. The rewrites are prefix matches, so a sibling repository's fetch reaches the gateway too. One that is not the run's is forwarded with no credential, as git would fetch it without the gateway, and only on a host a sandbox reaches by itself (kBaselineAllowedDomains: github.com, gitlab.com); on Bitbucket only the run's own repositories are proxied, so the proxy opens no destination a run could not already reach. GitLab and Bitbucket pushes are refused at the gateway with directions to stack_publish.
  • A run's gh (a shim first on PATH, which finds the repository a command is about and then runs the real gh) asks the gateway at /agent/forge-token when it needs a token. The gateway mints a ForgeTokenScope.review token (read-only, one repository, the workspace's automation and never the requester's own sign-in, bounded by the run's accountable human) at most once per repository per lease, and revokes it when the lease closes. The request names a repository and decides nothing: one that is not on the run's grant is refused before anything is minted, linked to the workspace or not, and the broker still holds every mint to the workspace's link and the accountable human. The token is handed to the run's gh, which could already read that repository's checkout; it is in no URL, argv, config or starting environment. The shims hold no secret and decide nothing. There is no PAT fallback.
  • The run's shims and Claude Code's hook reach the gateway through the agent run client (runAgentRunClient: cc_server agent-run <hook|git-sign|forge-token|env>), not curl, so a run needs no tool the host may lack. It is the server's own binary, imports only dart: libraries, dials only a loopback IP literal over plain HTTP, and uses no proxy and follows no redirect. Every sandbox may execute it and none may change it (withAgentRunClient): the executable is an exec literal, never its directory, and its files are install roots, which a writable tree cannot write or move. A server run from source starts the client on the Dart VM instead, and there the SDK and package files it loads are not protected: that is a development mode, not a deployment.
  • Commit signing is the person's own, and opt-in. A person may create a commit signing key (CommitSigningKeys: one Ed25519 SSH key per person per server, its seed in the 0600 secrets file) and add its public half to their own forge account as a signing key. Nothing registers it for them, and until they create one nothing is signed. Runs they ask for and commits they make in the IDE are then signed; a run nobody asked for never is. The private half never leaves the server process and never enters a sandbox: git inside a run's sandbox signs through a shim that posts the commit object to /agent/git-sign, and the gateway signs only a well-formed, unsigned commit that is the run's own by the rule a push is held to (author, committer, co-author trailers, UTF-8, no sign-off) and is being made now (committer date within five minutes of the server's clock, author date not in the future), for at most 1000 commits per run, while the person's key is still the one the run started with and the "Create a commit" rule allows it. An "ask" rule is answered by the operator's yes to the committing shell command for 15 minutes; a commit that never passed the shell gate (built with plumbing, or posted to the route directly) is asked about at the route, which gives up after 50 seconds. Policy decisions are guard-decision records; identity, date, count and key refusals are logged with the run, workspace and person. What a signature says is therefore narrow: a run this person started made this commit, as them, at this time. It does not say which repository or history the commit belongs to (its tree and parents are whatever the run wrote), so a run that was talked into it can obtain a signed commit that also verifies in another repository of the same person. It cannot sign as anyone else, sign a tag, date a commit into the past or the future, or reach the key. The cost is said to the person where they create the key: whoever controls the server can sign commits as them for as long as the key is on their account, and on GitHub a commit already shown as verified stays verified after the key is removed. Nothing is signed on Bitbucket, where an SSH key on an account is also a login: this server's key must never be added there. Server-run git (IDE commits) is given no signer either. Before every IDE push, CommitResigner signs the person's own unsigned commits in the outgoing range with plumbing (ignoring replace refs and grafts), never rewrites a commit another key signed or anything below it, and the push is refused if one of their own commits would stay unsigned. The macOS profile denies unix sockets outside the session's private TMPDIR, so a sandbox never reaches the user's SSH agent (1Password included); never expose the agent socket: that hands an agent the user's SSH authentication. ~/.config/git, ~/.gitconfig, $XDG_CONFIG_HOME/git and $GIT_CONFIG_GLOBAL are write-denied to every sandbox.
  • Commit attribution is one rule, decided by who started the work (AgentCommitIdentity, resolved by AgentCommitIdentities in cc_server_core). A person started it (a chat in a space, a pipeline they started, a commit they make in the IDE): they are author and committer, and only under an address a forge verified for them: on GitHub the noreply <id>+<login>@users.noreply.github.com of their own GitHub sign-in; on GitLab and Bitbucket the email the forge reports for their sign-in (GitLab's commit email, else its primary email; Bitbucket's primary confirmed address). A self-set profile or workspace Git email is never used for a run, and a person with no verified address there is not written as an author at all: the run commits as the agent and says so in its notes. With attribution on, their commits credit Control Center <hi@usectrl.dev> in a Co-Authored-By: trailer. Nobody started it (a schedule, a webhook): the agent is author and committer: on GitHub the bot of the workspace's App lane, <slug>[bot] <<bot_user_id>+<slug>[bot]@users.noreply.github.com> (the bare <slug>[bot]@users.noreply.github.com until GitHub has answered for the bot's user id); with no GitHub App, or off GitHub, Control Center <hi@usectrl.dev>. With attribution on, it credits each person who armed the trigger behind the run, under their verified address, and nobody else. hi@usectrl.dev is the project's own mailbox: a forge shows a co-author or author under whichever account verified that address, so the mailbox must stay under the project's control. Attribution is a setting (agent_commit_attribution): the workspace's override, else the person's own preference, else on. Identity names and emails refuse <, >, CR, LF and NUL, and are taken as every git writes them (AgentCommitIdentity.asGitWrites: surrounding whitespace and .,:;<>"'\ stripped), so a commit's name is compared byte for byte; a GitLab or Bitbucket identity with nothing left after that is not written as an author. The push proxy adds no-thin to GitHub's advertisement and spools the pack (2 GiB cap). It indexes the pack in a scratch repository with IsolatedGit and checks every commit and tag (PushedCommitInspector) before a byte is forwarded. The push is refused if an object names another author, committer or tagger (name or email), declares a non-UTF-8 encoding, or carries Signed-off-by: (the DCO is a statement only its human signer makes); if a commit's co-author credit is not exactly the run's: every line that reads like a Co-authored-by: line, in any case and anywhere in the message, must be one of the run's and must stand where git reads trailers (the message's last paragraph, not its subject, made only of Key: value lines), and each of the run's lines must be among them (a forge shows co-authors unverified, so credit is neither dropped nor borrowed); or if its signature is not what the run's identity says: none when the run has no signing key, and a valid SSH signature by exactly that key, over exactly that commit's bytes, when it has one. Tags are never signed. A push publishes nothing it does not carry. A ref update whose new tip the pack does not carry is refused unless GitHub advertises that object as a branch or tag tip of the repository (refs/heads/, refs/tags/; never a .have line or a pull request ref, which is what the repository merely stores for its fork network), so a push with no new objects cannot move a ref onto an uninspected commit (a rewind is refused too; revert instead). A parent of a carried commit, or the target of a carried tag, that the pack does not carry must be such a tip, or a commit GitHub's compare reports on the default branch or below what a ref being pushed points at today (published only on a 200 with ahead_by == 0; a 404 or a commit ahead is not); anything else is refused, and so is a push GitHub could not be asked about (transport failure, 5xx or rate limit, audited github.push_ancestry.unanswered). So a run cannot publish somebody else's commit, forged or real, as history under its own. A run with no identity cannot push commits.
  • stack_publish pushes from the server, outside the gateway, and is inspected the same way. StackLayerPusher pushes from a scratch bare repository that borrows the checkout's objects through objects/info/alternates. It fetches the remote's branches and tags into its own namespace and inspects every commit and tag reachable from the layer that the remote lacks. It then pushes to an explicit https://<forge>/<owner>/<name>.git with --no-verify. So the agent-controlled checkout's config, hooks, origin, insteadOf rules and remote-tracking refs decide neither what is inspected nor where it goes, and a forge PAT is never sent to a URL the agent chose. An agent run's publish holds every new commit to the run's own identities, read from its grants on the server (AgentPullRequestPort.commitIdentitiesOf), never from the model. A person publishing a stack themselves publishes their own work: only commits authored (tags: tagged) as one of the workspace's agent identities are held to the agent rule, and their own commits, even ones the agent rebased, are theirs. IDE pushes of a person's commits likewise go out on their own sign-in and are not agent pushes.
  • Every push made for a person needs their write grant on that repository at the moment of the push, on every forge: the GitHub push gateway checks it, and a stack publish (RPC or a run's stack_publish) checks every repository of the stack before pushing any.
  • A run may change only the worktrees of repositories its accountable person holds Control Center's write grant on (admins hold every linked repository; a run nobody asked for answers for the same human its automation token is bounded by). Every other worktree of the space is bound read-only in the run's sandbox, and the harness file tools, ACP fs/write_text_file and the Claude Code PreToolUse hook refuse writes there with repo_grant_required (level write). The server decides this from grants once at run start (agentWritableWorktrees), a failed lookup leaves every worktree read-only, and the list is part of the SandboxSpec, so a grant change takes effect on the next run and never reuses a warm sandbox. Without a sandbox (the owner turned it off) only the tool and hook refusals hold: shell commands can still change the checkout, and the push checks above remain the boundary. A worktree added to the space while a run is live is not covered until the next run.
  • Claude uses a command PreToolUse hook, not a fail-open HTTP hook. The agent run client's request must receive a 2xx with the explicit allow verdict; denied, empty, malformed, unauthenticated and failed responses exit 2 and block the tool, and so does a client that cannot start. The hook covers Bash and Claude Code's own file-write and web tools (AgentRunGateway.guardedClaudeTools). Missing leases install a blocking Bash hook. The gateway denies unanswered approvals at 55 minutes, the client gives up at 56 minutes, and Claude's hook timeout is 60 minutes.
  • Approval is triggered by an attempted action, not a command printed in chat. When publishing is part of the task, Claude is instructed to invoke the guarded push/PR command and wait for the verdict, rather than hand it back to the operator. This guidance is not an enforcement boundary.

Pipeline shell steps

A bashScript step runs only inside the OS sandbox (sandbox-exec on macOS, bubblewrap on Linux); without one the step fails and never runs on the bare host. It uses the agent sandbox policy, including its restricted egress. As for every sandbox, the server data directory and .env are hidden (SandboxManager.hiddenPaths), and only the step's run directory is reopened. Its environment is the ChildEnvironment allowlist plus git isolation (GIT_CONFIG_GLOBAL=/dev/null, GIT_CONFIG_NOSYSTEM=1) and an empty GH_CONFIG_DIR. When repo_full_name names a GitHub repo linked to the workspace, it gets a minted one-repository read GH_TOKEN, revoked when the step ends; otherwise it gets no token. Only a workspace admin can create a pipeline with a shell step or edit one that has one (pipeline_template.upsert), or create or edit a trigger that would run one (pipeline_trigger.insert/update): a trigger fires with no RPC behind it. Trigger payloads are untrusted; each placeholder value is escaped for the quoting it sits in, so it is one literal word unquoted, in '…', in "…" or inside $(…). The script that runs is the one in the graph the run was pinned to at start, never the live template, and it is killed after the node's timeoutMs or 30 minutes. Built-in steps run no git of their own; agent steps push through the agent run gateway.

Pipeline triggers and runs

  • Arming is admin-gated. A trigger that is enabled on an event, schedule or webhook starts its pipeline with no requester, so the run acts as the workspace's accountable human. Only an admin may arm (or re-configure while armed) a trigger whose template has any step outside kMemberArmableBodyKeys (trigger, condition, human gate, post to space, code index); members may add such a trigger disarmed or as manual, and may always disarm one. A member may not add such a step to a template while one of its triggers is armed. Shell templates stay admin-only for any trigger. Enforced server-side in preparePipelineTriggerWrite / preparePipelineTemplateWrite, which also record every admin who arms or re-configures a trigger while it stays armed (armedByUserIds, never the client's value; disarming clears the set), and savePipelineTemplate adds whoever edits the template behind an armed trigger. The engine stamps the set on the runs it starts (kPipelineArmedByKey, never from a payload), so none of them can approve the pull requests those runs open. A prReview.comment message takes the repository and number from the run's trigger payload (checked, never from step state), renders author only as a valid username for the forge, escapes every other placeholder value as literal markdown and renders only consolidated_findings raw, with its mentions made inert.
  • Webhook tokens are server-minted. The token is both the /webhooks/<token> route and the HMAC secret. pipeline_trigger.insert mints it and ignores a client-supplied one; an update keeps the stored token. The repository refuses (WorkspaceMismatchException) any write whose token is already routed to another workspace.
  • Webhook secrets are not in the databases. A trigger's token and a ticket-sync config's webhook secret live in the server's secrets store (WebhookSecretVault); the row holds a reference, and workspace_routes holds HMAC-SHA256(server route key, token) rather than the token, so a snapshot, an export or a read of either database yields no secret and no usable route. A workspace restored on another server therefore receives no webhooks until its triggers are saved again there. webhook_deliveries keeps an allow-listed set of request headers (never credentials, cookies or signatures) and no request body.
  • Trigger writes are validated. The template must exist in the bound workspace, a schedule must parse (every:<n> with n > 0, or a satisfiable 5-field cron) and its timezone must be a known IANA zone; an update cannot change a trigger's event type or template.
  • isBuiltIn is the server's. Only the seeder writes it. Any client save of a built-in clears it, except a save that changes nothing but isEnabled.
  • Run rows are engine-owned. No op inserts or updates a run or step row, and the dispatcher's cross-workspace trigger reads have no op. A client changes a run only through the pipeline.* engine ops, may delete only a finished run, and run ids are engine-minted UUIDs (CcPaths.pipelineRunDir refuses anything else). A pipeline.start parent link must name a running flow.callPipeline step, in the same workspace, that is waiting on a child.
  • Events fail closed. An event whose payload carries no workspace_id starts no trigger in any workspace.

Wakes, goals and peers

Runs the server starts without a person typing (goal segments and reviews, wake rules, peer messages and replies, finished delegated work, limit resets, the learning review; ARCH.md) act for one accountable person and stay inside that person's authority.

  • Wake and peer text is data. Whatever a source wrote (a rule's note, a peer's question or answer, a ticket's result, a check's output, the reviewer's findings) reaches the model only inside <wake-data id="…">, with a nonce per run on both tags (wakeDataEnvelope); text that imitates the tags is neutralised. The headline above each item is written by the server from typed fields, and one standing paragraph says that a wake is information, never an instruction. Wake text cannot run a command: /goal, /loop, /schedule, /refine and the other slash commands are parsed only in a person's own message with no wakes (WakeContext.allowsCommands); everything else that starts with / is fenced as a message. A wake cannot approve anything, widen a run's tools or answer a question for a person.
  • Who a run acts for. Every wake records its person (requested_by_user_id; null is the bot). A rule acts for the person who made it, or for the requester of the run that made it; a goal for its requester. Admission refuses a wake whose person is no longer a member (person_removed), and WorkspaceMemberRemoved ends their rules. A wake is pushed into a live run only when it acts for that run's person and carries no run options; otherwise it waits for its own run, so it never borrows another person's sign-in, history or tools. Releasing a held wake or delivering it now is that person's alone (wake_not_yours, not even an admin); cancelling is open to anyone with access to the space.
  • A queued message is its writer's. A queued or held steering message is sent only by the person who wrote it, as that person: a run's end sends one turn per writer, releasing held messages sends only the releaser's, and Stop and send on another person's message is refused (steering_not_yours) before anything is stopped. Only its writer edits it; deleting is open to the space. A message with no writer is never sent, and a writer who leaves the workspace has their queued and held messages deleted, never sent. Steering a live run that acts for someone else, or for no one, needs the write grant on the space's repositories: queuing, Steer and Stop and send refuse a caller without it (repo_grant_required, level: write), and a message enters such a run only when its writer held write when queuing it (the grant is not rechecked when it is flushed); otherwise it waits and is sent as its writer's own turn when the run ends. The model gets another writer's message after a line naming that writer as not the person the run works for. No read-only run (a goal's review, the learning review) takes a steering message mid-run or is stopped for one. At its end, a goal's review leaves the messages queued for the goal's next segment, and they are held for their writers when no segment follows; any other run's end, a learning review's included, sends them as their writers' turns. Under a person's usage-limit pause only that person's messages wait with the pause; everyone else's are held for them at once.
  • Forced identities. Tools this area adds or changes take every agent and person from the run's attested identity, never from arguments: agent_id on 19 tools, and sender_id, requester_id and reviewer_id. cancel_wake cancels only what the calling agent made. complete_goal is refused unless the calling run is the goal's active segment. allow_quarantine_override is not in the model's schema.
  • Delegation gate and rate limits. ask_agent, consult_agent, request_peer_review, send_to_agent and delegate_task pass PeerDelegationGate before any side effect: a parent ticket must exist (and for an ask be the caller's), depth (3) and cycles are read from rows (the chains of the wakes the run took and of the asks it answers), then the autonomy ceiling and the budget envelope; a missing policy port refuses. Each ordered agent pair is limited to 10 messages a minute (PairRateLimiter, peer_rate_limited). Ask rows are capped at 10 pending per asker and 20 per recipient, and a repeat within 10 minutes is refused, in one transaction. A chain of wakes (at most 16 agents) travels with every wake a run in it enqueues, so a rule's expiry, run cap and cost cap reach through peer replies, delegated tickets and limit resets: the cost of every run that carried the chain's wake counts against its cap, and a carried wake of a closed or spent chain is skipped (budget_blocked). A run another run of the chain starts directly through a tool call (dispatch_reviewers, assign_ticket) joins the chain through the run log's started_by_run_id and is charged after it settles, but is not admitted or capped by the chain: it needs a live, admitted run of the chain and that tool's own policy (approval for assign_ticket, processSpawn for the reviewers). Wake-started runs are capped at 30 an hour per conversation and 300 per workspace. The gate runs only for agents; a person's own client is not a hand-off.
  • Rule limits. An agent's repeating rule needs a run cap or an expiry, and an agent's rule expires within 30 days; every rule run is cost-capped (5 USD by default), and an agent's rule made by a run that an agent's rule started shares the first rule's expiry, runs and cost (wake_lineage_ended); each of its runs is capped at the smaller of its own per-run cap and what the chain has left. When the first rule ends for any reason but firing, the whole chain ends with it and nothing joins it; pausing the first rule pauses nothing else. A person's own rule starts no such chain: its runs are a person's runs, a rule an agent sets in one is a new root with its own caps, and nothing an agent does ends a person's rule. wake_rule_limits (counts, cost caps, expiries, default time zone) is written by admins only (wakeRules.setLimits). Resuming a rule, changing its note or raising its limits is its person's (an admin's for a bot's rule); pausing and deleting are open to the space, and a pause by anyone but the rule's person posts a row naming them (wake_rule_paused). A watch's target is checked through the space read gate when it is made and every time it fires (watch_target_unreadable), so a watch never reports a pull request its person cannot read.
  • Goal checks run in a sandbox. A contract's checks are run by the server, never by the agent and never on the bare host: each command in a one-shot sandbox over the conversation's worktree, confined like the agent's own bash and under the workspace's egress rule, or as the space environment's named task. With no sandbox nothing runs and the goal stops for a person (sandbox_unavailable); the only exception is a server whose owner turned sandboxing off for every run (--sandbox off), where checks run as the agent's bash does. Output reaches the reviewer as data, cut to its last 6,000 characters. Changing a goal's contract or checker needs the write grant, a paused goal and its requester (an admin for a goal with none; goal_not_yours).
  • The reviewer is read-only with fresh history. A goal review and an improvement review run with ReadOnlyRunProfile on every backend: reads and submit_output only, worktrees bound read-only, no bash, no subagents, no web, no wakes to anyone, and no prior conversation turns. Its scripts cannot store or keep values, and its tool outputs go to a scope of its own that is cleared at the run's end. A backend that cannot enforce read-only (ACP) is refused before a run row exists (read_only_unavailable); a reviewer that cannot run pauses the goal for a person (checker_unavailable), with no quiet fallback to another agent. The reviewer is told that the conversation, the notes and the claim are the worker's account, not evidence, and it gets the full diff of the tests and check files the worker changed. Only a passing review or a person (agentGoalRuns.approveCompletion, recorded) closes a goal; for a goal a pipeline started that person is its requester (an admin for a goal with none). The agent's own claim never does.
  • Who may resume or spend. Resuming a goal, anything that lets it spend more, changing its contract or checker, and closing a goal a pipeline started are its requester's (an admin's for a goal with none; goal_not_yours); an admin does not act for a goal that has a requester. Pausing and cancelling are open to the space. Every segment is capped at the lower of 5 USD and what is left of the goal's budget, a review at 2 USD, and the 50 USD default budget is the goal's.
  • Approvals for wake-started runs expire as denied. An approval or question raised by a run a wake started, that nobody answers, expires at the workspace's unattended_requests expiry (72 hours by default, 1 hour to 7 days): the approval is denied and the question withdrawn, never approved, and the goal pauses for review. After one of a run's requests expired, its later approvals and questions are refused at once, with no card or form, until the run ends; such a refusal approves nothing and the producer stores no decision. --unattended assume releases only a goal segment's question after 10 minutes, never an approval and never a review's request. A person's own run keeps its ordinary deadlines.
  • Who may accept an improvement. A member who can read the proposal's space may accept, reject or roll back a memory fact, an agent note or a space- or agent-scoped policy. A workspace-scoped policy and every skill proposal need a workspace admin (improvement_admin_required), for accept, reject, rollback and improvements.startCampaign, and evals.cancelCampaign applies the same rule to a campaign a proposal owns. A skill candidate is a staged revision that no run uses until it is accepted after a passing campaign. Proposals are validated server-side (unknown ids, targets and checks are dropped) and record their provenance (refine:<id>).
  • Who may move an orchestration. The moves that start or widen work (orchestration.approve, .approveNodes, .continueNode, .saveRevision) need the member role and the write grant on every repository the space exposes (repo_grant_required, level: write; an orchestration with no space asks no grant), after the space gate, whose refusal a hidden one still gets. Approving nodes and continuing a node are also the run's person's (an admin's for a run with none; orchestration_not_yours), in every status, so before a run exists only an admin passes. orchestration.cancel needs only the space.
  • Who may raise an orchestration cap. A pipeline run held at its orchestration cap resumes only when its requester raises the cap (an admin when the run has none; orchestration_not_yours) with orchestration.raiseCap, behind the space gate and the write grant on every repository the space exposes: an integer above the current cap and above the spend, at most 1,000 USD, written conditionally and recorded. A cap is never removed. No operation a member can call writes an orchestration row directly: orchestration.insert and orchestration.update no longer exist, and the server writes the row. The orchestration.* pipeline step bodies act only for the orchestration's own run (pipeline_run_id), and a client-saved template, an admin's included, cannot add such a step (it may keep the ones the stored template has). A row is written only while it is still what the writer read (revision and status), and its cost cap follows a write only while the row is proposed, so the cap that runs is the cap of the approved revision.
  • Isolation. agent_wakes, wake_rules, peer_asks and improvement_proposals live in each workspace's database. Every operation over them validates the workspace, then membership, then the space gate of the row's conversation or space; ids are looked up in the caller's workspace, and another workspace's id is WorkspaceMismatchException or not found. A conversation's watch (wakes., wakeRules., peerAsks.watchForConversation) checks the space gate when it subscribes; a workspace's watch (wakeRules., agentGoalRuns., improvements.watchForWorkspace) sends only rows of spaces the subscriber can read. Event-driven watches subscribe to events filtered by workspace. An orchestration follows its space: every orchestration.* read and move (catalog/orchestration_ops.dart), and plan.estimate's write into an orchestration, goes through the space gate (PrDataGate.requireSpace). In a space the caller cannot read, a read answers null, a list or watch frame leaves the orchestration out, and a move is refused with the gate's refusal; an orchestration with no space is the workspace's.

Sandboxes and rigs

  • Every sandbox hides the server data directory and .env (SandboxManager.hiddenPaths, applied inside wrap, so dispatch, harness shell tools, ACP, terminals and pipeline steps cannot skip it). A run sees only the paths it is handed: its overlay and the space's worktrees, its agent config and skills (read-only), attachments (read-only), its run directory, the pooled Claude account directories it was given and its tool dirs. Other runs, secrets.json, the databases, the Connect identity, backups, logs and .env are not reachable. On Linux the hidden directory is a tmpfs (a hidden file is /dev/null) with the handed paths bound back in. Windows has no native sandbox and enforces none of this.
  • A run's shims and git signer are tool dirs (SandboxSpec.toolDirs): executable, never writable, and their folder cannot be renamed away on macOS.
  • No directory the host resolves executables from is writable from a sandbox. Every entry of the server's PATH and every prefix the binary resolver probes, with each symlink on the way, is found once at start (scanHostExecutables), and every sandbox the manager wraps can neither create, replace, delete nor rename their direct children, the links leading to them, or the package a linked command resolves into, nor rename the directories above them. The trees below the direct children (an SDK's bin/cache, a node version's lib/node_modules) stay writable, so installs into those directories fail inside a sandbox with EPERM (npm i -g, corepack enable, pipx/uv tool install, cargo install, go install, dart pub global activate when their bin directory is on the server's PATH, switching a linked version with fnm default or fvm global), while repo-local installs and npx-style runs are unaffected. Residuals: code a launcher loads from beyond those directories (an SDK's bin/cache, a version-managed interpreter's library) remains writable, so the host runs no such tool unconfined while agents are sandboxed; a command installed on the host after start is fully protected only from the next start; on Linux the same rules are bwrap binds, unverified, and a missing directory there stays creatable.
  • Every home path a sandbox may not read it may not write either (one list feeds both), and the start-up files of the server user's shells and sessions (.zshenv, .zlogin, .bash_login, fish and nushell config, systemd user units, autostart entries, .pam_environment and the rest of homeRcDenyRels) are write-denied in every mode.
  • Adapter detection (adapter.detectOne, adapter.detectAll) runs only the binary the adapter registry names, looked up by adapter id; a client cannot choose what the host executes, and an unknown id is refused before anything starts.
  • Only the server owner opens the host shell. Every other terminal runs under the agent policy inside the workspace's own directories (a cwd outside them is refused, never replaced), and only the person who opened a terminal can read, write, resize or kill it. An environment's start and process terminals run on the host, so writing to, resizing or closing one takes what environment.ensure takes in that space: write on every repository it exposes, each readable through the caller's own forge sign-in (mayDriveTerminal). To anyone else, either kind of id looks unknown.
  • The sandbox posture is decided once at boot (HostExecutionPosture): native, off (the owner turned it off with --sandbox off, so every member's agent runs unconfined on this host), or unavailable (no backend). Under unavailable a run starts only when its accountable person is the server owner (the acting user; for automation the human accountableHuman resolves); anyone else is refused before a credential is minted, a lease taken or a process started, with sandbox_unavailable (HostExecutionGate, called in DispatchSession.run right after the run log opens). With no owner recorded nothing counts as the owner's. The startup exposure line carries sandbox=native|off|unavailable.
  • The eval kernel, the debug adapter and its debuggee, language servers and the project checker start only through the run's ToolProcessLauncher: inside the conversation's enclosure when it has one, otherwise under SandboxManager.wrap with the run's own spec (language servers get a per-run session with no loopback ports). debug attach reaches only the run's lease ports (loopbackPorts) and is refused before anything starts otherwise. A repository's .venv or node_modules/.bin is used only when the launcher is confined, the project root never resolves above the run's working directory, and a repository cannot name a language-server command (no lsp.json is read).
  • A run's tool sandbox sessions (bash/eval, language servers, shell hooks) are its own and are released when the run ends on every path; a debug session's sandbox lives until the debug session ends, at most its 30-minute TTL. A server that sandboxes agents but has no sandbox manager starts no tool process and no bash command (RefusingToolProcessLauncher); the host is never a fallback.
  • An ACP one-shot (a title, /btw, /handoff, /goal) runs inside the dispatch sandbox in its own session when the server sandboxes agents, unconfined when the owner turned sandboxing off, and with no sandbox only for a request the server owner is accountable for; otherwise it is skipped (OneShotConfinement). The tool-less claude -p and in-process harness one-shots start no tool and are unchanged. A pull request's golden tests in Review Studio follow the same rule.
  • Agent shell hooks are host configuration, read only from <data dir>/_agent_hooks/<workspace id>/<agent slug>/hooks.json, which no client op, run or member terminal can write (the folder is outside every workspace's storage and every sandbox hides the data dir). A hooks block in a working tree or an agent's config folder is dropped with a notice naming that file. Hook paths are relative and must resolve inside the folder with symlinks followed. Each hook starts as a tool process of its run (sandboxed like the others, its folder readable and executable only), as argv with no shell, and receives only the allowlisted child environment, never the run's lease or credentials. A refused or unreadable pre-tool gate denies every tool call. A stop hook can only continue a turn with a message (exit 2 with text on stdout, cut to 2,000 characters, at most 3 times in a run); any other outcome, a failure or timeout included, lets the turn end, so a broken stop hook cannot keep a run alive. A preCompact hook can only add up to 1,000 characters to the compaction's focus. Neither approves a tool call, changes the run's tools or reaches its lease. On Claude Code both arrive through the run gateway (/agent/hooks/stop, /agent/hooks/pre-compact), authenticated by the run's lease, and run as the other hooks do.
  • A refused run carries its refusal code (sandbox_unavailable) on the turn's error and on the run log's errorCode, so clients localize by code.
  • Copy-on-write provisioning must not write branches, registrations or FETCH_HEAD into source checkouts. No silent git-worktree fallback where rift is supported; Windows is the explicit backend exception. Required native failures are fatal, not degraded operation.
  • Each macOS sandbox session gets a private TMPDIR (/private/tmp/cc-*, mode 0700, created exclusively, removed with the session) that the wrapped command exports itself. process-exec is denied in the shared temp trees (/private/tmp, /private/var/folders, matched by their resolved spelling) and re-opened only in that TMPDIR and for the sandbox's own tool literals. Unix-socket bind, listen and connect are allowed only inside it. TCP listening stays denied: Seatbelt cannot confine a listener to loopback, so a listen allow would also open an inbound LAN channel around the egress allowlist.
  • macOS denies process-exec under $HOME. Toolchain install trees under it (SandboxPolicyResolver.homeToolchainExecRels plus their env/XDG relocations: corepack, npx/dlx caches, node version managers, Playwright browsers, rustup/cargo, Go, fvm/pub-cache, pyenv/uv/pipx, rbenv/sdkman, mise/asdf, ~/.local/bin) are re-opened beneath that deny. Only existing trees strictly inside the home qualify, never the home itself. The always-dangerous exec denies are emitted after them, so no toolchain tree re-opens rm or sudo. Every other path under $HOME stays non-executable.
  • Server-provisioned disposable overlays/worktrees carry implicit local execution authority; creating a new conversation or entering a subdirectory does not ask again. Only server-derived writable roots qualify, never a tool-selected cwd, read-only mount, original checkout or durable fallback directory. Existing explicit denials survive; a denied descendant prevents an implicit grant of its parent. This does not relax write protection, network rules or push approval.
  • Restricted native macOS egress is denied except for the session's HTTP/SOCKS proxies, registered loopback service ports and DNS IPC. Local IP permission is limited to network-bind: allowing all network* operations on a local IP also admits direct outbound connections. Removing proxy variables or using a client that ignores them must not bypass the domain allowlist. Allowed SOCKS tunnels retain their live socket subscription and any buffered payload across the handshake. Real-process tests cover HTTP/SOCKS policy, direct IPv4/IPv6 denial, network-off and the reachable approval endpoint.
  • Restricted QEMU argv uses restrict=on, loopback-only hostfwd, read-only base plus per-session overlay, and no -virtfs/-fsdev. Egress passes through guestfwd to SandboxHttpProxy/SandboxSocksProxy on host loopback.
  • Restricted smolvm argv uses --outbound-localhost-only, one --allow-host per admitted host, and broker credentials via --secret-file, not persisted environment values. Docker Hub image-maintenance hosts join the same gate.
  • Only an install-owner-confirmed restart sets RigSpec.unrestrictedNetwork. QEMU omits restrict=on, smolvm uses bare --net, proxy policy widens too, and the UI retains a warning. Pin both restricted/unrestricted argv paths in tests.
  • Android/iOS are host-managed with host networking; do not advertise them as enclosed or offer an unenforceable egress switch. Developer commands remain device/simulator argv, never a host shell.
  • Guests receive only per-VM broker secrets for short-lived, scoped, per-operation tokens: allowlisted, rate-limited and revoked at close. No durable provider credential enters an enclosure. RigSpec.forgeTokenScope is fixed at open: a human-opened terminal rig gets write (bounded by that member's forge access); an agent-opened rig gets read, because a guest credential helper cannot tell a push from a fetch. An agent eval kernel attaches only to a running exec rig whose scope is read (RigService.admitsKernel), so a human terminal rig's write helper never meets a model-driven interpreter.
  • A rig opened in a space is that space's machine. Seeing it (session list, frames, sound, browser state, ports, clipboard and file reads) takes the space read gate; driving it (opening one in the space, input, control, lifecycle, port forwarding, clipboard writes, drops, microphone) takes a write grant and the caller's own forge read on every repository the space exposes. One RigAccess enforces both for the RPC ops, the live streams and the HTTP lanes (/rig/stream, /rig/clipboard, /rig/files), which refuse when it is missing. A rig bound to no space reaches no worktree and is open to every workspace member. Environment terminal output and terminal port ops run the space gate before the stream opens.
  • A rig carrying a person's own credentials (RigSpec.credentialHolder: their terminal machine, or any machine opened for them whose egress reaches a forge) is driven only by that person and by runs that act for them alone; others the space admits may watch it, and refusals carry data.kind: rig_holder_only. Somebody else's terminal machine answers as if it did not exist, as their terminal sessions do. On a rig carrying a person's credentials, reading the guest's files and clipboard (GET /rig/files, GET /rig/clipboard) is the holder's alone, like driving it, while frames, sound, state and the port list stay with everyone the space admits; and a terminal session a person opened answers its port ops and port stream to anyone else as if it did not exist, as the session itself does. Workspace admins and the server owner do not override the holder rule.
  • An agent run reaches only the rigs of the space its lease names: the rig tools force space_id from the attested run grant, refuse callers that are not runs, list only that space's rigs, and answer a rig of another space or of no space exactly as a missing one.
  • RigService.act blocks agent mutations during human control. Input is attributed and sequenced transactionally. Guest capture is unprivileged; QEMU input is injected via the hypervisor. Clipboard crossing requires per-user/per-direction permission before reading/transferring.
  • enclosureControl is denied in read-only modes. SandboxBackend.microvm is probe-gated and cannot downgrade to a host shell. Bound lifetimes/resources, recover only owned devices, and tear down owned machines at shutdown. Boot artifacts are checksum/digest-pinned; control sockets are private and reject symlinked namespaces. See enclosure operational constraints.

Code mode

Code mode (repl; ARCH.md) runs JavaScript the model wrote, on every run of a server whose runner passed its boot self-test ("Who decides"). Treat every script as hostile: a model steered by a prompt injection in a file, a tool result or a web page writes the script. What the design holds against such a script is below.

Threat model. A script must not reach the host (files, network, processes, other runners, the environment) and must not do anything through a tool that the same call made directly would not be allowed to do. Its load on the server is what "Limits" below bounds, apart from what that paragraph names as not bounded by code mode, and the worst case is the one it states; what it asks of a person is at most 10 approval cards and 10 questions ("Waiting on a person"). Every call it starts is a row of its record unless the record's finish fails ("Audit" below). A call refused before it starts is refused to the script and is no row: one past the call limit, one whose arguments are over 1 MiB or hold more than 16,384 values, a question past the tenth. What a call's tool does after the script has ended is in the server log, not the record. A script can do what the run's tools allow, except the tools and arguments held back from scripts (below): code mode adds no authority, and a tool that records who acted on an approval takes that from the run's grant, never from an argument (create_approval, decide_approval, comment_approval; a call no run is attested for is refused). It does add volume: one script makes up to its call limit of calls with no model turn between them.

Confinement. The runner, cc_codemode, is one process per script, started through ChildProcess with no inherited environment ({'PATH': ''}, plus SYSTEMROOT on Windows), stdio on pipes and no other descriptor. It is not inside the agent sandbox; it confines itself before it reads its first frame, reports the result in ready.lockdown, and the host kills it before sending the script unless the level is full. full means every required control of its OS was applied and verified and no optional control failed (exit 3 otherwise). The controls, the Linux system call allowlist and the macOS profile are listed in the runner README.

  • Linux: inherited descriptors closed, READ_IMPLIES_EXEC cleared, no_new_privs, every capability dropped and read back (a runner started as root keeps none in its effective, permitted, inheritable or ambient sets; the bounding set is cleared too when the runner holds CAP_SETPCAP), not dumpable, rlimits (no core, no file writes, no processes, 3 descriptors, 3 GiB address space, CPU 135 s soft / 140 s hard), and a seccomp allowlist (all threads, kill on violation) holding stdio reads and writes, non-executable memory management (madvise limited to the advice values the allocators use), futex waits and wakes (private and shared; no priority-inheritance or requeue operations), the static clocks (realtime and boot time among them, never another process's or thread's CPU clock) and gettimeofday, its own process and thread ids, getrandom, tgkill to itself with SIGABRT, sigaction for SIGSEGV and SIGBUS only (so a fault ends the runner with its own signal), signal return, masks and alternate stacks, sched_yield, restart_syscall, and exit; the README lists each with its condition. Landlock is applied where the kernel has it and is optional (a kernel without it leaves the level full; a failure after the kernel offered it does not): the allowlist has no call that names a path, opens a socket, signals another process or spawns, so it already denies everything Landlock would. A unit test pins the allowlist by system call number, and landlock_alone_denies_files_network_and_signals tests Landlock on its own in case the allowlist ever widens.
  • macOS: before the profile, the inherited Mach ports are cut off and read back (exception ports, registered ports, the bootstrap and debug control ports), so a crash handler a parent set on the task or its threads, or launchd through the inherited bootstrap port, cannot be messaged (a host-level crash handler still receives crashes). Then a (deny default) Seatbelt profile that also denies process information, file existence tests, code signing operations, JIT, system and I/O Registry information, host and processor-set MIG routines, the routines that would fetch a removed port again, and the listed syscall-unix calls (among them other processes' groups and sessions, leaving the server's process group, kernel event queues, memory pressure, login name, audit and kernel tracing); rlimits for no core, no file writes and CPU 135 s soft / 140 s hard, and none for processes, descriptors or address space: the profile refuses process creation and file opens instead, and the heap is bounded by the QuickJS allocator, with the CPU and wall-clock kills behind it.
  • The self-test. cc_codemode --self-test applies the lockdown, attempts what it must deny (files, network, processes, plus per-OS probes such as other processes' CPU clocks, a denied madvise advice and, where the kernel has it, Landlock on its own on Linux, and process arguments, process groups, kernel event queues, Mach lookups, inherited ports and signals on macOS) and runs 13 real sessions, including the CPU, memory, output, cancel and script-error endings. On Linux each probe runs the way production does, with the filter applied while a second thread is already running (one helper thread where production has two; the Landlock probe runs before the filter, on purpose). The server runs it at every boot.
  • Build. QuickJS-NG's C code is compiled with the stack protector on every platform and with fortified libc calls on Linux; the Rust code has neither. Return-address signing is in force for QuickJS-NG's functions on aarch64 Linux, on processors with pointer authentication; Control Flow Guard covers the whole Windows image (not run). The release executable contains no build machine paths: the build fails if it does, and every staging and packaging step checks again (cc_codemode_verify, which also requires a release build), whatever built or cached the runner, and the server's boot self-test refuses a runner that does not report "build":"release".

Fail closed. A bundle without the runner does not boot: like any missing required native library, it is a boot refusal of one line naming what is missing and where it was looked for, exit 78, with nothing left running. The natives are checked before the server opens, creates or migrates any database or writes any file in the data directory (the directory itself may have been created by then, empty and owner-only), so a broken install leaves the owner's data as it was; a data directory that cannot be created or is not a directory is a refusal of one line too (exit 78), and any other error the boot raises before the server is ready ends it with one line and exit 70 (a port already in use with exit 1), its stack going to the log file when one is open by then, while an error raised outside the boot's own awaits (in a timer or a callback the boot started) goes to the guarded zone, which logs it and does not end the process; pair and connect check them before any database too and refuse the same way. A failed self-test, and a passing one that does not report "build":"release" (a debug build, or a runner that does not say), make code mode unavailable on that host (no run gets repl, and codeMode.status says why) and never runs a script with less isolation; there is no fallback interpreter, PATH lookup or switch that weakens it. Availability is live (CodeRunnerLiveAvailability): when a runner fails to launch for a reason that is not its script's (it cannot be spawned, it exits before ready, its ready is malformed or names another protocol, or it reports less than full lockdown; a handshake that only times out does not count, and the script is sent only after a valid ready), the server runs the self-test again, at most once a minute and never twice at once. A failing re-test makes code mode unavailable with that self-test's reason; the cause can lie outside the server (a runner killed before ready, processes exhausted for a moment), so while scripts are off for that reason the next read of availability runs the self-test again (at most once a minute, never twice at once) and a pass turns them back on. Each change is logged once in the startup line's words (code_mode=unavailable, then code_mode=available), and MCP clients are told their tool list changed (ServerCodeMode.availabilityChanges). Both lines are warnings of one line each, so the owner sees them at the default log level; they and the status reason have secrets redacted and every control, line or direction character taken out first (oneLogLine, then printableText). A change comes at most once a minute, and each makes every connected MCP client list its tools again; a run of the built-in agent that started while scripts were off has no repl for its life, and an MCP run that called repl meanwhile stays on direct calls. A boot self-test that failed keeps code mode off until a restart. No refusal or error a model or a run's record receives names a host path (scrubHostPaths): codeMode.status shows the reason with paths removed (as far as the next sentences say), and the server log keeps them. When the server itself fails under repl (an exception before a script starts, under a nested call, or while a run's workspace limits are read), the model and the workspace's members read fixed text and the exception goes to the server log only. The reason codeMode.status shows names no path the server knows (the runner, its directories and install directories, the data and temporary directories, the home directory: knownHostPaths), whatever those names hold, nor any path under them. Any other absolute path (POSIX, ~, a Windows drive, UNC, a file: URL) is replaced by pattern, up to the next quote, bracket, : , , or plain word: such a path whose own name holds one of those marks can leave its tail, and a regular expression or an HTTP path written alone is replaced as if it were a path. Other URLs, globs and words with slashes are left as they are, except that a :/ inside a URL starts a path, and a word that only starts like a known path is replaced with it. The MCP surface reads availability on every call; a harness run decides its surface when it starts, so a run that already has repl keeps it and its next script is refused unavailable. A script refused for a reason no other script would have escaped (CodeExecutionErrorKind.withdrawsScripts: unavailable, server_busy, audit_unavailable, shutdown, start, lockdown, execution_id, no_run_log, space_gone, catalog) takes no tool away: for the rest of its run the run calls its script-only tools directly. A script that queued for a runner is refused server_busy once it has waited half its wall clock, so a busy server ends in this fallback rather than in a script that runs out of time; and a tool catalog that does not fit in the runner's 8 MiB init frame is refused catalog before a runner starts (RunnerStartFrames.encode). The fallback is one-way: one such refusal, a single busy moment included, is not undone when the server is idle again (on the harness the run keeps repl and its tools stay directly callable; on MCP the run stays without repl while the server remembers it), so a burst of load moves every run caught in it to direct calls and takes no tool but repl from any. On the harness the run's ReplLane (a subagent binds its own) records the withdrawal, repl's result asks for it (HarnessToolResult.withdrawsScripts), the loop moves the script-only tools into the deferred set (_ToolCatalog.withdrawScripts) and search_tools loads them, while repl stays, so a later script may still run; on MCP the run-log id joins ReplMcpTool.withdrawn (at most 1,024 runs, the oldest forgotten first, which then goes back to scripts), the run is listed every tool but repl, and notifications/tools/list_changed goes to every connected client once, when the run is new to the set (McpScriptSurface.scriptRunsChanged); that notification also covers the run it pushed out, whose redirect comes back. So on MCP "the rest of the run" holds while the server remembers the run among the last 1,024. The fallback passes the same mode filter, gate and approval as any direct call, so it widens nothing. A refusal the script or the model's call decides (the script's error, its limits, its size, run_busy, a denied call, any way the runner ends once the script runs) never triggers it. Where the runner is looked for (CC_CODEMODE_RUNNER, a development override, and CC_NATIVE_LIB_DIR) is read only from the process environment, never from .env, so a .env that moves the other native libraries does not move the runner. The last place looked, <data dir>/codemode/, follows --data-dir/CC_SERVER_DATA_DIR, which .env may set; whoever sets the data directory already holds the database and every secret. Agent sandboxes cannot write the runner's directories (SandboxManager(extraHostExecutableDirs:)), so a run cannot plant a runner through its sandbox. An environment the server owner approved to run on the host is the exception: its compose file is read from the space's worktree at each start and a trusted stack's binds outside the worktree are only warned about, so whoever can change the space's branch can bind the runner's directories into a container; that is host execution the owner approved, and a definition a workspace admin saves can only run in a rig, which mounts the space's worktrees read-only and nothing else. Workspace limits that cannot be read give the run no repl (running under the defaults could exceed limits an admin lowered), an approval with no approver denies, a script that cannot be recorded does not run, and a value --code-mode-max-processes or --code-mode-max-heap-mb (or its variable) does not accept stops the server at start (exit 78), naming what it accepts; any flag the server does not know is ignored. A variable name a refusal quotes (an exported provider secret) is printed with every character outside printable ASCII as its code point, saying when one does not print. A value or a path a refusal echoes (a flag's or a variable's value, the data directory, a database or identity file, a file system or URL error) is printed with every control, format, separator, non-ASCII space and blank character as its code point, keeping letters, accents and symbols outside ASCII so a path still reads as itself, and is cut to 80 characters for a value, 300 for an operating system error or a finding (why a data directory is unusable, why a database is damaged, why CC_CONNECT_URL is refused, the error that ends a boot or a command) and 1,024 for a path. Every value, path and name a refusal or a start line quotes has secrets redacted before it is made printable and cut, so no part of a token across the cut shows, and every line the server binaries print outside their logger (a refusal, the line an error before ready ends the process with, the shutdown line, what pair and connect print) is redacted as a whole before it is made printable (every log line is redacted too). Two outputs are not redacted: pair prints the pairing key it made, and the deep link and QR code that carry it, as they are, and agent-run hands a command's own output and the gateway's answers back to the run process that started it.

No credentials. The runner holds no token, no environment, no file and no socket. It sees the script, the limits, the catalog of tool names and schemas it may call, and the stored values of its conversation and agent (store/load; subagents get none). Tool results reach it only as replies to its own calls.

Nested calls. A script's tools.<id>(args) goes back through the surface's one gate: on the harness ToolReentry into _ToolGate.run (arguments, lookup on the run's admitted surface, for a script's call the refusal of an argument the tool refuses it (scriptArgumentRefusal) and of a call too long to audit whole ("Audit"), pre-tool hook, approval, execution under the deadline and cancellation, post-tool hook, completion-contract ledger), on MCP McpToolDispatcher.callNested into the same _gate a tools/call passes. The harness gate stops waiting for a tool at the call's deadline, which does not run while that call waits on a person, and at the script's end, and settles the call then, so a script never waits on a tool the gate gave up on; the tool's cancellation token is cancelled, which stops a tool that watches it (a bash command's process is killed) and not one that does not. A call given up on after its tool started keeps its status (timed_out or cancelled) and gate decision, and its row says the tool was still running, as an MCP call outliving its script does; how the tool ended afterwards is logged with the execution id and call number. The script's catalog is the run's admitted surface after the mode filter, minus tools whose scriptCallable is false: on the harness repl, eval, task, the vibe_* verbs, checkpoint, rewind, compact and search_tools; on MCP 31 tools: repl, the catalogue searches, every tool that starts, messages or assigns work to another agent run (ticket assignment, delegation and comments included), creates, decides or comments on an approval, proposes or changes policy, installs or changes skills, creates a runtime profile or leaves plan mode, and the two that end the run or its goal (submit_output, complete_goal). repl's description is generated from that catalog (ReplToolDescription.build) and declares no tool: it names the direct tools a script may also call, with what each returns (resultNote), and counts the first-party tools by namespace. It never lists or counts an external or workspace MCP server's tools, so no server's tool names or descriptions reach it, and connecting or disconnecting one leaves its bytes unchanged. The same holds for what the MCP endpoint tells an agent CLI at initialize (McpRunToolSurface.instructions): a run with repl reads how its script-only tools are reached and an index of the first-party ones by name, in at most 4,096 characters, and never an external server's tool name. In tools/list only the server marks tools to load upfront (_meta anthropic/alwaysLoad, on repl and the direct tools of an attested run): a _meta that an external server sends with its own tools is dropped, so no server can put its definitions into every request. No such server's namespace is builtin, control-center or script: a server with one of those names, or with a name starting external-, compared without regard to case or surrounding white space, is given the prefix external- (ScriptToolNamespace.external, on both lanes and in a bridged tool's [server] label), so its tools are always external, and no tool can be in the script namespace, which names the script's own functions. A tool a script may call can still refuse a script an argument, before the approval step so the refusal raises no card (scriptArgumentRefusal): create_ticket refuses assignee, because assigning a ticket starts the assignee's run. A tool that causes only an ordinary workspace event (a ticket status change, a pull request, an environment start) stays callable, and automation that reacts to that event reacts as it would to the same call made directly. Every tool on both surfaces states its decision: packages/cc_server_core/test/code_mode/script_callable_pin_test.dart reads every tool class off its source (a class that extends, mixes in or implements a tool), fails on a tool missing from its lists or deciding differently and on a scriptCallable declaration it cannot read, and checks that the tools the harness registry and the test server's MCP registry build answer as pinned. A tool with no source of its own follows a rule: an external or workspace MCP server's tool is callable and asks for approval as a direct call of it does, as an exec tool (nothing gives BridgedMcpTool a tier resolver, so no server's tools get another tier today), and a wrapper answers for the tool it wraps. What spares such a tool's card spares a script's call and a direct one alike: on MCP the owner's approval mode (mcp.client.setApprovalMode yolo) or a person's 8-hour approval of that tool from its card, which every later call reads again; in a harness run neither is read and its card offers nothing to remember: it runs without a card when the run's mode profile pins it as a verb, and otherwise is refused in a space that only proposes (proposeOnly) and runs without a card in one set to act freely (autonomy.setForSpace actFreely), and is refused without asking when no approver is connected; anywhere else each such call of a script is one of its 10 asks. A harness run's secret proves nothing on the MCP endpoint (AgentRunGrant.mcpEndpoint) or on Claude Code's hook route (AgentRunGrant.claudeHook, set only for a Claude Code run, whose CLI installs that hook): both refuse it as a secret that names no run and log that once per run and route, so a command a script runs can neither reach a tool there outside the gate nor raise a card through the hook. A call's row and the summary the model reads carry the decision that let its tool act or stopped it, whoever asked: a tool that guards itself (bash, whose command runner asks the action guard and the command net) reports what its own guard decided (HarnessToolResult.guardVerdict), so a card a person approved reads approved, and a card a person declined, a refusal without a card after a decline or past the card limit, and a policy denial inside the tool read denied with the reason. A card the run's gateway raises for a request a bash command makes while it runs (a push, a commit signature, an environment command) labels that call the same way when the request names the command (X-CC-Agent-Call, one live token): a declined or refused request makes the call denied, an approved one approved. A request that names no live command (a process that dropped or borrowed the token, or one still running after its command returned) labels no call; the token authenticates nothing, so a process in the sandbox can also mislabel another call of the same run, which changes a record's label and no decision. A nested call's context has no reentry, so a script cannot start a script. Code calls tools only through repl: an eval cell has no way to call one (tool is not defined in a cell), and a script cannot call eval. The doom-loop guard counts direct calls only; a script's calls are bounded by its call limit instead.

Waiting on a person. An approval card or question raised by a script's call says it comes from a script the agent is running and lets the person open that script in the transcript; on both clients the link and the folding of a script's calls land only on a script's own row (repl) with that call id. While one of its calls waits on a person, the script's wall clock pauses and no further call of the script starts: the script can only compute, within its CPU budget, which keeps running. At most 10 of one script's calls reach a person for approval and at most 10 questions are asked (ScriptApprovalBudget, CodeModeLimits.maxQuestions): a gate counts an ask before it awaits the card, in the same step as its check of the budget, and gives it back when no card went up (the policy answered, a standing approval covered the call), so asks that arrive together cannot pass the limit; a card the gate's resolution did not foresee (the policy changed before the check) takes the same step just before it goes up (ActionGuardService.check's beforeCard), so it too is counted or refused without a card. Once a person declines one call, the script's later calls that need approval are refused without asking, and audited as denials with that reason; a card already counted before the decline still goes up and is answered on its own. Only a person's answer is a decision about a script's calls. A card nobody answered (its deadline passed, it expired or was withdrawn, the host shut down) refuses that one call and its ask stays counted toward the script's limit, but it is not a decline: the script's next call that needs approval asks again. It never approves anything (ScriptApprovalBudget.answered(unanswered:), GuardVerdict.unanswered). Such a card is recorded as unanswered: the model is told nobody answered (kUnansweredCardReason), the run records no person's verdict, and the audit row carries guard_decisions.unanswered, covered by the hash chain, so it is never read as a decline. On a harness run only, while a script of the run is running, every card the run's gateway raises (a push, a commit signature or an environment command one of the run's commands makes) counts against that script's budget and obeys its decline, whichever command sent it: the X-CC-Agent-Call header (filled from CC_AGENT_CALL_TOKEN) authenticates nothing and plays no part in charging; it only names the command a gateway request comes from, so the script's clock pauses while that command's push waits for approval. Each script of the run then in flight is charged; a run's subagents share its lease, so two scripts can be in flight at once, and a decline of a gateway card then refuses the later approval asks of both, their own nested calls included. A script on the MCP endpoint (an agent CLI's run) gets no such hold: the gateway's cards for that run's commands are charged to no script. A process a script started that asks after the script ended is a direct call by rule: its card is charged to no script. A card whose call stopped waiting (the script ended or was cancelled) is withdrawn, and an answer that arrives after that is audited as a denial and approves nothing. A runner waiting on a person gives its slot back while the parked pool (four times the slot cap) has room and its workspace holds less than its share of that pool ("Limits").

The run's past. A script reads its run's past only through history, outputs and loadOutput, which the host binds to the calling run: a main run reads its own conversation's transcript and the outputs stored for its conversation and agent, a subagent its own run's turns and the outputs it stored itself. No argument names a workspace, conversation, run or scope. These reads pass the same space rule as get_messages: a run whose space the person it acts for cannot read is refused. One history() call pages in the database and, whatever the conversation's size, reads at most 200 messages' stored facts, 50 row segments and the text of 50 rows (16,384 characters each, 128 KiB in all); it returns at most 50 rows and 64 KiB of row text. start is the previous page's next_start, an opaque string (0 or none for the first page) that a page whose scan window ended first also sets, with fewer rows or none; it names a message's place and id, so a deleted message between pages skips or repeats nothing. loadOutput returns 16,384 characters of an output. A script reads at most 100 times and 4 MiB in total, and a run's scripts 16 MiB on either lane (on the MCP endpoint one usage per run log, dropped when the run settles). The time counts against the workspace's lookup budget. On the MCP endpoint (Claude Code, ACP) a script's history() reads the conversation of the run its attested scope proves, under the same space rule; Control Center keeps no tool outputs of those runs, so outputs(), loadOutput() and keep() refuse there. A Claude Code subagent calls with its parent run's scope and reads what that run reads. keep(value, label) writes to the run's output store only when the script completes: at most 1 MiB a value, 64 values and 16 MiB a run. A read-only run's scripts may read stored values but not change them: store() throws and keep() is refused. Everything the run writes to the output store (its over-budget repl results and the tool outputs its loop cut) goes under a scope of its own, <agent>#ro:<runId>, which the worker never reads or lists and which is cleared when the run ends. The run reads that scope first and then the worker's, so a worker's cut output whose handle history() shows loads through loadOutput and read_output, and outputs() lists both. Nothing a reviewer computes reaches the worker's later runs.

Protocol and availability. The host refuses a runner of another protocol (now 2) at its self-test (--version) and at every ready, saying to reinstall the application or server bundle; code mode is then unavailable, and the server still boots. A run is told to call a tool from a script only when it has repl (CodeExecutionPort.availability), on every transport; otherwise every tool's form is direct.

Limits. Defaults and workspace ceilings: wall clock 300 s / 1,500 s (the host kills the runner; timed_out), CPU 30 s / 120 s (the interpreter's interrupt handler ends the script at its budget and a watchdog thread half a second of CPU past it; timed_out, kind cpu), heap 256 MiB / 1 GiB (memory_exceeded), 500 / 5,000 nested calls (further calls are refused to the script), 8 / 32 read calls in flight, 10,000 / 50,000 output tokens (the rest goes to read_output). Fixed: 256 KiB source, 512 KiB stack, 1 MiB and 16,384 values (objects, arrays, members and other values together) of call arguments, 4 MiB nested result (a tool's JSON text reaches the script decoded only when it holds at most 131,072 values, otherwise as the text; the text of an external MCP server's tool result is first cut at 256 Ki characters, BridgedMcpTool.maxResultChars, with a note appended saying so, and cut text reaches the script as text that no longer parses, while its structured content reaches the script, with its strings sanitised like any result, when its JSON fits in that size and is dropped when it does not), 16 MiB interpreter output (output_exceeded), 2,000 store operations, 256 KiB per stored value and 1 MiB per conversation and agent, 4 images to the model. A script's lookups (searchTools, describeTool, describeNamespace) are answered on the server's main isolate, so the host bounds them before any work (ScriptLookups): a query of at most 1,024 UTF-16 units, a name or namespace of at most 256, limit 0 to 50 (a value past a bound rejects that call with an error naming the bound, and one of the wrong type, such as a limit that is not a whole number, with an error naming the type), and at most 200 lookups and 2 s of server time together per script, each lookup timed whole; past that budget every further lookup is refused unanswered ("lookup budget used up"), so one script's lookups hold the isolate for at most 2 s plus one lookup. All scripts of one workspace also share a bucket of 2,000 ms of lookup time, given back at 250 ms per second (WorkspaceLookupBuckets); while it is empty their lookups are refused. A script's start work (its catalog and init frame) is outside both budgets. An unknown name is answered with suggestions built from names only, each compared on its first 64 characters, and a type that would take more than 20,000 units of rendering work or 16,000 characters reads unknown /* too large to show */. One tool search index (ToolIndex) holds at most 1,048,576 UTF-16 units of descriptions and argument names whatever the catalog's size: each tool gets an equal share of it (never more than 4,096 description characters plus 64 argument names of 64; a longer argument name is left out, not cut), spent on its argument names first and then on its description's head, while every tool's name is always indexed (up to 256 characters), so a tool is found by its name in a catalog of any size; the script's own functions are indexed whole beside them, outside the total, so searchTools finds them at any size too. One index is built per distinct tool set as indexed and shared by every script, harness search_tools, MCP search_tool_bm25 and run with that set (ToolIndex.shared; search_tool_bm25 is a tool of the MCP endpoint only, and no surface of the built-in agent offers it, endpointOnlyTools); at most 8 are kept, the least recently used dropped first. The descriptions in one ALL_TOOLS share 1,048,576 UTF-16 units equally (ScriptCatalog.maxAllToolsDescriptionUnits; a longer one is cut and ends in …), while id, name and namespace stay whole and describeTool returns the whole description. The model may lower its wall clock and output budget, never raise them. The server owner bounds the runner slots (--code-mode-max-processes, default min(16, 2 × cores)); each workspace holds at most the cap less a quarter of it (at least one less, from a cap of 2), so no one workspace takes every slot, though two busy workspaces can together leave a third none until one frees; waiting scripts are admitted round-robin across workspaces. A run with its subagents (one run tree, CodeExecutionRequest.runTree; a run on the MCP endpoint is a tree of its own) holds at most half of its workspace's share (CodeRunnerSlots.treeShare, at least one: 6 of 12 at the default cap of 16), and a freed slot goes to the oldest waiter whose workspace and tree both have room, so the run's further scripts wait while scripts of the workspace's other runs pass them; a queued script's wait counts against its own wall clock, down to its floor of 1 s, and one that has waited half of it is refused ("Fail closed"). The share is per run with its subagents only: a run that starts another run (delegation, hand-off, consult, retry) gives that run a tree of its own, so a run that keeps starting runs is bounded only by its workspace's share. A script waiting on a person gives its slot back while the parked pool (four times the cap) and its workspace's share of the pool (the pool less a quarter) have room; once the person answers, its wall clock runs again while it waits for a slot, and a script that has not got one back within half of the clock it had left at the answer ends timed_out with the kind server_busy, its record finished once and its calls kept, and its run calls its script-only tools directly from then on ("Fail closed"). A script that has less than twice the wall clock's floor of 1 s left when the person answers gets no such bound and ends at its own deadline; a script already cancelled, or on a server that is shutting down, when its bound runs out ends as cancelled or with the kind shutdown, never server_busy. While any call of a script waits on a person, no further nested call or models.* batch of that script starts, parked or not; the calls it sends meanwhile start in the order they came once no wait is open and it holds a slot again, and they count against the call limit when they arrive. Calls already started when the wait begins go on, each within the time the script had left when it started. A runner whose script waits on a person is not paused; it starts no tool but can still compute in its own process until its CPU budget is spent, so in the worst case every runner that exists (cap + parked pool) computes at once, each on one thread and within its CPU budget. --code-mode-max-heap-mb clamps every heap; its default, 1024, is the workspace ceiling and clamps nothing. The worst case the server commits to: runners = cap + parked pool = 5 × cap (80 at the default cap of 16), each with up to the heap clamp of interpreter heap (80 GiB at the defaults) and up to its CPU budget on one thread, all at once (80 threads × 120 s at the ceiling). On the server's own heap, per runner, in memory, not as JSON (decoded JSON can take far more than its text: one MiB of [{},{},…] about 82 MiB): up to 64 MiB of replies the runner has not read (stdin_stalled past it); the call arguments not yet answered, weighed by what they take decoded (JsonShape.weight, an upper bound measured per shape), up to 64 MiB plus the one call that crosses it, at most 7.5 MiB (the host stops reading the runner at 64 MiB, and frames it already read wait undecoded; a call over 16,384 values is refused before it is decoded); the results of its calls in flight while it waits for its slot back, kept as their JSON bytes, not decoded (in-flight limit × 4 MiB: 32 MiB by default, 128 MiB at the ceiling); its record's call rows without results (arguments redacted to 8 KiB of UTF-8, errors to 500 characters, at most two bytes a character in memory: about 10 MiB at 500 calls, 95 MiB at 5,000); up to 24 Mi characters of output (16 Mi and one frame past it; at most 4 bytes a character, so 96 MiB, about 100 MiB with its items); up to 6 MiB of store writes (1 MiB of values and 2,000 keys); its question records (each keeps at most 8 KiB of question, 8 KiB of answer and 64 options of 512 bytes: under 2 MiB for ten); on the harness, the loop's record of the script's calls (under 1 MiB); and the transcript rows of its calls while the run's turn streams (NestedCallRows, applied where a run keeps events: a preview of at most 8 KiB of arguments and 8 KiB of result per call, measured as stored JSON, and at most 256 KiB of previews across the script, past which a row keeps only its tool name and status; no nested images, read attachments or partial output: at most 1.6 MiB in memory at 500 calls and 11 MiB at 5,000, freed when the turn ends). A call keeps neither its arguments once its tool has them nor its decoded result once it has settled; the reply carries the result's bytes. That is at most about 290 MiB per runner at the default limits and 480 MiB at the workspace ceilings, so about 23 GiB and 37.5 GiB across 80 runners, of which the loop records and transcript rows are about 210 MiB and 960 MiB. On disk, per script, beyond its record: its transcript rows, kept with the conversation (at most 0.8 MiB at 500 calls, 5.6 MiB at 5,000), its run-log lines, kept with the run (runs/<run>.ndjson: at most 512 KiB of previews, since a row's result is logged twice, plus about 0.5 KiB a line: about 0.75 MiB at 500 calls, 3 MiB at 5,000), and the guard audit rows of its calls, appended to the workspace's guard_decisions chain: each audited action summary is stored at most 16 KiB plus a short marker ("Audit"), about 17 KiB a row in the database with the row's other columns, so about 8.2 MiB at the default call limit of 500 and 82 MiB at the workspace ceiling of 5,000. The rows a script's commands raise through the run gateway (each environment command, push or signing check) come on top, each up to the same size, and code mode does not bound how many one call raises, as for a direct command. Not bounded by code mode, and not new: a turn keeps the rows of every script it runs (each bounded as above) and of its direct calls (in full) until it ends, so what a turn holds grows with how many calls it makes; and a client that reads slowly queues every transcript update of the run in its subscription, as on any RPC stream, until it drains or disconnects (what it queues are those rows). Two short-lived amounts come on top: a frame is weighed before it is decoded (the weighing keeps only the three members the host reads, type, args and value, so it holds nothing that grows with the frame) and decoded only when it takes at most 32 MiB (a heavier frame ends the session, except that a return value that would take more is kept as the text the runner wrote, undecoded), one frame at a time per isolate; and a tool's JSON text result is decoded for the script only when it is at most 8 MiB and 131,072 values, at most about 60 MiB. The surface keeps it as its text, and it is decoded only inside a synchronous encode (the surface's size check, the reply's bytes), so however many calls settle together, one is decoded at a time per isolate (a result the tool built as structured content is not decoded from text; it is bounded only by the 4 MiB check once encoded). Every figure here is a live bound, what can be reachable at once; the process's resident size can sit above them until the collector runs, since each decoded result is garbage once its reply is encoded. Measured in one script: 500 results just under the item limit, settled one after another, raised the peak by about 204 MiB (87 MiB when the script returned), and by about 221 MiB when they settled at once (the runner, holding them decoded in its own heap, ended memory_exceeded after 81). The runner flag lowers all of it, the heap flag only the interpreter heap; the workspace limits lower the rest. A parked runner lives at most its wall clock plus 10 approval cards × 1 hour plus 10 questions × 30 minutes: 15 h 25 min at the 1,500 s wall-clock ceiling, during which it starts no tool while a person has not answered. A workspace's sweep of stale records ("Audit") has no timeout of its own: one that hangs, with the database, holds every script that arrives in that workspace for its whole wall clock, and each is then refused server_busy without a record. Kernel backstops: CPU rlimit kill at 140 s, and a script past its wall clock that the runner does not end is killed 15 s later (unresponsive).

Runner output is hostile input. CodeSandboxProcess ends the script as sandbox_error and kills the runner on any frame over 8 MiB, over 32 MiB once decoded (weighed before it is decoded; a return value that would take more is kept as the text the runner wrote instead), non-UTF-8 or too deeply nested JSON (the depth also read before decoding), unknown frame types or fields, repeated or skipped call ids, more calls or store traffic than allowed, call names over 256 bytes, images that are not PNG, JPEG, GIF or WebP up to 5 MiB with valid base64 and matching magic bytes, anything after done, or more than 64 MiB of replies left unread (stdin_stalled). Past 64 MiB of unanswered call arguments, weighed by what they take decoded, the host stops reading the runner's output until replies drain, and frames it had already read wait undecoded; a call whose arguments hold more than 16,384 values is refused to the script as that call's error without its arguments being decoded, and the script goes on; the wall-clock kill and the kill of an unresponsive runner fire on time while it does. Stored values are charged at their compact JSON, the measure the runner applies, from the values loaded at the start on. What a runner prints for its version reaches the startup line, codeMode.status and the log only when its self-test passed, as one line of at most 80 printable ASCII characters. Its stderr reaches a result or a record only as a tail of at most 300 characters, with secrets redacted, host paths replaced as the status reason's are, and control, bidirectional and invisible characters taken out (oneLogLine, scrubHostPaths). The runner's stats (CPU, peak heap) are recorded as reported and enforce nothing; the status never comes from the name the script gave its error.

Call positions. Each call frame may carry at, the line and column in the script the call was made from (runner README), so the clients can draw the script's structure. It is a display hint from the process that runs model-written code, and nothing that decides reads it. The host accepts it only as two integers naming the first code unit of a character on one of the script's lines (ScriptLines.siteOf); anything else ends the script as a protocol violation (sandbox_error), and a frame without at simply has no position. A position is kept in two places only: the call's record row (code_execution_calls.site_line/site_column) and its transcript row (ToolSegment.callSite). It never reaches the gate, policy, an approval card, a guard audit row, a digest, a fingerprint or executedContent (NestedCallRequest.site); two scripts that make the same calls from different places raise the same cards and the same audit rows. The runner takes the position from the engine's structured call sites, never from a stack string, so a function's name cannot forge one; it ignores frames of code made with eval or Function and the script's own Error.stackTraceLimit. A script can still choose where its calls are written, and a call the runtime makes for it (a then callback, setTimeout) has no position. A script that holds U+2028 or U+2029 gets no positions at all, because the engine counts those as line breaks in code but not in comments.

Audit. Every admitted script is recorded in its workspace before it starts (code_executions, status running) and finished at most once (compare-and-set): source, output, console, limits, lockdown report, engine version, and one row per nested call with its gate decision, approval wait and arguments, in which SensitiveArguments replaces the value of every argument whose key names free text or a secret (content, body, message, text, token, secret, psk, password, authorization, api_key, credential, matched case-insensitively on part of the key) with ‹redacted› and leaves every other value as written: a token inside a bash command, a debug expression or an argv is kept. The record cuts a call's arguments, after that redaction, at 8 KiB and ends them with a marker naming their full size (CodeExecutionCall.boundArguments); a script's transcript rows and run-log lines are previews (NestedCallRows, "Limits"), and text cut for one is redacted up to 4 KiB past the cut first, so a secret that straddles the cut keeps no prefix unless it runs more than 4 KiB past it. The guard audit (guard_decisions) is not cut for what a script's calls run. Every script-callable tool of the exec tier, or that spawns a process or runs on the host, states what a call of it runs (executedContent, pinned in script_executed_content_pin_test.dart) or that it runs nothing it is handed: bash its command, debug the program and arguments it launches or the expression it evaluates, environment_exec its argv, environment_run_task its task and extra arguments, and mobile_use shell and ios_use spawn their argv, an argv as its JSON list; eval, which a script cannot call, states its cell the same way, so a cell the model runs directly is audited whole. Such a call is audited as <tool>: <what it runs>, with argsDigest over what it runs. A call a repl script makes, on either surface, whose summary (the tool's name, : and what it runs, an argv as its escaped JSON) is over 16 KiB is refused before the owner's pre-tool hook on the harness is handed it and before policy, a card or anything runs, as an error the script can catch ("The command is N bytes; a command a script runs takes at most 16,384. Write long content to a file and run that."), and the refusal is audited. So what every such call a script made was handed to run is whole in the guard audit; what that in turn runs (a program file a debug launch names, a file a bash command runs) is not. That does not hold for a tool of an external or workspace MCP server: the server decides what its arguments mean and nothing marks which of them it runs, so no content is audited or bounded, and its call has no guard audit row at all except when a standing approval spares its card or a script's approval budget refuses it; its arguments are in the record, cut at 8 KiB. Nor does it hold for what the run gateway checks while a script runs (a push, or a cc-env or docker compose command a script's process runs): those checks carry no script origin and are not refused for their size, and their rows are cut like any other. Nor, by design, does it hold for text a script types or passes as an option, which is as often a password as a command: the type action of computer_use, app_use, browser_use, mobile_use and ios_use, browser_use fill, the clipboard_write of computer_use, app_use and browser_use that a paste key then types, the key and hold_key actions, and environment_up options, which reach a definition's commands as CC_ENV_OPT_<KEY> and opt.<key>, are audited under the tool's name alone, with their arguments in the script's record up to its 8 KiB cut and text redacted, so a script can run text through a focused terminal or a definition's option without that text being in the audit, as a direct call can. Other text a script hands these tools to act on is audited the same way, by the tool's name alone with its arguments in the record (not redacted): the url of browser_use navigate and of mobile_use and ios_use open_url (an absolute URL or an app deep link), and the path of mobile_use install_apk and ios_use install_app. None of this holds in an evaluation campaign's built-in arm, the one evaluation backend that offers repl (BuiltinEvaluationBackend, when CC_CODEMODE_RUNNER names a runner that passes its self-test): no call its scripts make is refused for its size or audited in guard_decisions, bash included (LocalEvaluationCommandRunner has neither check), and no code_executions record is kept (EvaluationCodeRunner drops every write), so the attempt's transcript and tool events are its only record. Each check the run gateway makes passes what it is about to run (the command line, or the push with every ref it names) as what runs, so its row's name is that once, not repeated, and its argsDigest covers all of it, cut or not; a check with nothing handed to it to run (signing a commit, push discovery, a fetch) has a short name of its own and no digest. What a direct call ran is in its transcript row. Every verdict's audit row, whichever tool asked, stores the summary whole up to 16 KiB and past that its first 16 KiB, cut on a character boundary, with a marker stating its full length (GuardDecision.boundActionName, in GuardAuditSink). For a row written since this bound, length, never text, tells a cut row: a name longer than 16,384 bytes was cut, and one at or under it is whole whatever it says, even when it ends in text shaped like the marker. A row an earlier server wrote, before the bound, is whole at any length, and no column says which server wrote a row: only its occurred_at against when the server was upgraded, which the table does not record, tells the two apart. A row's argsDigest, when its check passed a command or what runs, hashes all of it either way, and the chain's hash covers the row as stored, so rows stored whole before the bound still verify. A row's run_id is the run's agent_run_logs id whoever wrote it (the harness gate, a command's own check, the MCP dispatcher, the run gateway), so a script's rows and the rows its commands raise through the gateway join on it. An audited summary and what its digest covers are stored as given, never redacted, and nothing shortens them but each store's own cut (16 KiB on a row's name, 8 KiB on a call row's arguments): a token inside a command, a cell, a debugger expression or an environment or device command is in guard_decisions and its SIEM copy as written, and so in the transcript, the call row's command or code argument and the record's source and output; only the run log and text cut for a preview are redacted. A denial's log line and blocked-action event carry at most 2 KiB of the summary. The writes of one record (begin, a row per settled call, finish) go through one ordered queue, and the finish writes only the rows no earlier write recorded. Call rows are insert-only; a row the store refuses is logged with why. A call still unsettled when its script ended is recorded as cancelled with a detail saying how far it got: not started, at its gate, or, when the surface reported that its tool started (NestedCallRequest.onToolStarted), with its tool still running and the gate decision it passed. How it ends afterwards is logged with the execution id and call number, its error as one line of at most 500 characters with control and bidirectional characters replaced, and never added to the record. Once the runner's end is handled nothing else is added to the record before the finish, so the result the model gets states the same calls with the same statuses as the record. A finish that fails closes the record as sandbox_error/host_error without its output and remaining rows, and is logged; if that write fails too, the record stays running until the next boot. At boot, once the server holds its port, every record still running is finished as server_stopped, whatever its start time, and the log says how many in how many workspaces (nothing when there were none). No script is admitted into a workspace that may still hold such records: one that arrives before its workspace was swept waits within its wall clock and is refused server_busy past it, and a workspace whose sweep failed is swept again for each script that arrives, which is refused (audit_unavailable, with a reason that sends the owner to the server log, logged once) until a sweep succeeds. Nothing stops a second server on the same data directory and another port from doing that to the live records of the first: there is no data-directory lock. A run with no run log gets no repl, and a script of a run whose space was deleted is refused (space_gone) and does not run. Refusals before a script starts (busy, too large, unavailable, space gone) are logged and counted, not saved. Members read records through codeMode.listExecutions/getExecution; a record from a space the reader cannot open is filtered out of lists and refused by id, and records are deleted with their run or space. The JSON readers refuse a value this build does not know instead of defaulting it: a call row with an unknown gate decision (CodeExecutionCall.fromJson, which the clients read a record with) throws rather than reading as no decision, and a script tool descriptor with an unknown tier or effect (ScriptToolDescriptor.fromJson) throws rather than reading as read or with fewer effects, which would gate it more loosely. The store's own row mapper reads gate_decision with NestedCallGateDecision.tryParse (code_execution_mapper.dart); the column's CHECK constraint admits only known decisions, so it reads none it does not know.

Who decides. Nobody switches code mode on or off. A run of the built-in agent, and an attested agent CLI run with a run-log id on the MCP endpoint, has repl exactly when this server's runner passed its boot self-test and its latest self-test passed ("Fail closed"), and the server is not the public demo build (apps/cc_demo_server, where code mode is unavailable with the reason a public demo runs no scripts). A run of the built-in agent with no workspace, no run-log row or unreadable workspace limits gets no repl either and calls its tools directly. On MCP, a run with no run-log id is not listed repl and calls its tools directly (McpRunToolSurface.hasRepl); a repl call from it is refused by ReplMcpTool before anything is admitted, in plain text (the call names no run, or the run has no run log); a script whose run-log id is set but whose row is missing is refused at admission (no_run_log, when begin finds no agent_run_logs row). Workspace admins set only the limits: codeMode.setWorkspaceSetting takes code_mode_limits and refuses any other key (code_mode_unknown_setting), and workspace_settings.set refuses code_mode_limits. The server owner bounds runner slots (--code-mode-max-processes, at least 1) and the heap of one script (--code-mode-max-heap-mb, at least 16 MiB). A server owner who wants no scripts at all has no switch for it: cc_server does not boot without its runner, and only the demo build runs none. No action policy can deny repl on either lane: it is of the read tier and declares no action class, so the harness gate asks for no approval for it (_requiresApproval) and the MCP dispatcher runs the action guard only for a tool with declared classes. On the harness the owner's preToolUse hook sees a repl call like any other and can deny it (_ToolGate.run); on the MCP lane no hook sees it, because the hook Claude Code installs matches only its own guarded tools (AgentRunGateway.guardedClaudeTools). A custom subagent's tools: allowlist can leave repl out, for that child only (CustomSubagentProfile.filterTools).

Not claimed. The Windows confinement (a per-launch, less-privileged AppContainer with one capability, controlCenterCodeModeRunner, a job object, process mitigations including forced address randomisation, the Microsoft-signed-only image policy and shadow stacks where available, both optional and never required, and imports from System32 only) has never run; it is type-checked only. The installer grants the capability read and execute on cc_codemode.exe (--grant-runner-access); that step has not run either, and Inno Setup does not check its exit code, so a failed grant shows at the first launch, which fails with runner_access and names the command to run. It is separate from the agent sandbox, which Windows does not have. On macOS, code running natively in the runner (which a script reaches only through a memory-safety bug) can still tell whether a pid exists, through kill(pid, 0) and csops, and read that process's code-signing flags: Seatbelt checks both after the kernel looks the pid up, and a rule by system call number does not stop them. It can also call host-port routines the profile does not list, and macOS lets an unprivileged process set no memory ceiling of its own, so native memory outside the QuickJS allocator is bounded only by the CPU and wall-clock kills and the system's own memory-pressure kills. IBT, BTI and user shadow stacks are compiled into QuickJS-NG on Linux but not in force, because the executable as a whole does not carry the marking. Timing and cache side channels, kernel bugs reachable through the allowed calls, and memory-safety bugs in QuickJS-NG are contained only by the lockdown, not prevented. Code mode does not narrow what a run's tools can do. A script can cause the same workspace events a direct call causes (a ticket, a message, a pipeline trigger), as many times as its call limit allows. The models.* embedding calls run on the server's shared embedding worker (two script batches at a time).

Host environments

An environment definition runs commands on the server host as the server's OS user, with its Docker and cloud sessions. That is operator identity.

  • Trust. Members trigger, admins author definitions that run entirely in a rig, and only the server owner saves or approves one that runs anything on the host. A definition runs on the host (EnvironmentDefinition.runsOnHost) when it has host placement, a check that runs a command, or a provision/archive task (these run in the space's worktree on the host whatever the placement). environments.setDefinition and environments.approveSource judge the validated definition with overrides applied and refuse anyone else with server_owner_required before anything is written. The approval is data only the server sets (host_approved_by): it records the server owner when they save a definition that runs on the host, is cleared when a save leaves it off the host, and is never read from a client. It is checked against the current owner before every host start, readmission, setup, check, worktree task and pull request head sync, so a definition with no approval, or a previous owner's, is refused with environment.host_unapproved however it reached the table. Input to an approved environment's processes follows the rules below. environments.setDefinition is admin-only, gated by processSpawn and audited. The validator runs again at read time, before anything reaches a process. Anyone below admin reads definitions with env values and overrides replaced by a placeholder, and a save carrying that placeholder is refused rather than written over the real values. environment.watch, watchLogs, watchRuns and messaging.watchSpaceProvisioningLog need a read grant on every repo the space exposes.
  • Branches never choose what runs. Definitions live in the workspace database. An in-repo definition is read only from the default branch and takes effect only after an admin approves its blob hash: merge rights are not the admin role. The tools still run branch code, which is why policy.forkPrs exists.
  • Fork PRs. rig runs the compose file in a microVM with no host socket, no operator credentials and an egress allowlist. Worktrees are shared read-only at the host level with a guest-side overlay for writes, so a stack can't plant .git hooks or config: a nested read-only .git mount was tried and guest root could remove it. Host git on those worktrees runs with hardening flags and refuses if .git config, hooks, attributes or its pointer changed. Rigs never mount a source checkout. On host placement every code-running entry re-checks admission, including a crash restart and boot recovery, an approval covers one head sha, and a moved fork head stops the environment. worktree.syncToPrHead refuses while a fork environment is on the host, so a member can't move the head under it. approval needs an admin for each start. deny refuses. seedFiles are never copied for a fork, and provision/archive tasks are skipped unless the policy is rig.
  • Compose preflight. On a fork at host placement, service, build and top-level Compose keys pass an allowlist, so a key nobody has read is refused. Also refused: privileged, host or container: namespaces, a Docker socket bind, devices, volumes_from, binds, build contexts and env_files outside the space's worktrees, build.ssh, secrets and configs from a file, external or out-of-project volumes and networks, capabilities beyond a short harmless list, and any security_opt but no-new-privileges. On trusted spaces whatever reaches past the container warns, and the allowlist doesn't apply. Remote include is refused. up runs from the resolved model written to the state directory, owner-only because it holds interpolated values, so a container editing the worktree's compose file can't change what starts. Every other driver call goes by project name and reads no file.
  • Commands. Verbs are argv, so option values never pass through a shell, and placeholders never expand inside shell bodies. The validator also refuses a placeholder in inline script text (sh -c, python -c, node -e and the like) and env keys that change what a process loads (LD_*, DYLD_*, GIT_*, BASH_ENV, PYTHONPATH and the like). NODE_OPTIONS is refused unless it sets only heap limits. CC never runs sudo or interactive logins itself, and never answers a prompt: a command that exits 3 (an answer is needed) or 4 (a sign-in ran out) stops for a person, and the environment reads blocked, not failed. On exit 3, a CLI verb the definition lists as interactive can instead carry on inside the same start, on a terminal tab: the verb's own argv from the approved definition, never a command the tool printed; only when the start came from a person's own client that said someone is there (attended on environment.ensure and environment.reset, honoured for a user principal only), with no agent, MCP, pipeline, PR-sync or boot-recovery route; never in a fork space and only at host placement; and after the same host-approval check as any start. The tool asks for itself, and the answer goes to the PTY. The terminal ends with the verb, after 20 minutes with no one finishing it, or when the environment is stopped, torn down or its space released. The audit trail records that a line was sent, never its text, for owned sessions and at a password prompt in a shell.
  • Output is untrusted. Tool output can't become an arbitrary URL: an endpoint must be loopback, *.localhost or under the definition's declared domain.
  • Agents never get the Docker socket. cc-env, the docker shim and declared pass-through tools post to the agent run gateway, which takes the space from the run's lease, forces the environment's name, requires pass-through paths to resolve inside the run's worktrees, and applies the action policy before running a real binary with argv. Commands the gateway starts on the host itself (a definition's pass-through tools and the docker compose shim) belong to the space's environment definition and are refused with environment.host_unapproved unless the current server owner approved that definition; cc-env commands go through the environment service's own approval chokepoints. The docker shim reaches only the compose project of the space's environment on this host, by name (-p), with no compose file (a rig-placed environment is not reached on the host), and runs from the environment's state directory, never a worktree, so no compose file or .env an agent wrote is in compose's current directory. The sub-command is one of ps, logs, exec, port, restart, top, and after it only a per-sub-command allowlist of options is accepted, each spelled out on its own (kAgentComposeOptions), so -f, -p, --project-directory, --env-file or --profile are refused wherever they appear. A pass-through tool is a binary the approved definition declares, its leading arguments must match one of the definition's allow[].argv prefixes, and the options its denyFlags name are refused in every spelling (--flag=value, -Xvalue, inside a bundle; one parser, readOption, serves both); the rest of its arguments are the agent's, bounded by what the owner approved.
  • Host execution prompts. Everything an agent starts that runs on the host (environment lifecycle, tasks, exec, compose, pass-through) carries ActionClass.hostExecution, which prompts by default and is denied in read-only modes. The code that runs is the worktree's, which the agent can edit, so allowing it silently would be a way out of the sandbox. MCP environment tools and app_use force space_id and agent_id from the run. The docker shim's limits are listed above. Pass-through commands carry hostExecution whatever they map to: the binary starts in the agent's worktree, where a read can load code. eval, debug, lsp and lsp_rename declare hostExecution only when their launcher is unconfined (posture off or unavailable); confined, eval and debug declare processSpawn. Diagnostics after a write never start an unconfined language server.
  • MCP callers prove who they are. /mcp and /sse accept only a live run secret (X-CC-Agent-Run, from a loopback peer; its scope is the gateway's attested grant and nothing the request says) or the server MCP token (Authorization: Bearer: 32 random bytes minted at first start, readable and rotatable by the server owner only, never clearable). No request header names a workspace, user or agent. Before either is checked, a request a web page could have made is refused: a non-loopback Origin, a Host that is neither this listener's loopback address nor the server's public host, or a POST that is not JSON. Agents receive only their run secret, never the token. environment_* and app_use additionally set requiresRunGrant, so the owner's token alone cannot call them.
  • Personal MCP servers stay the owner's. MCP servers discovered in the server OS user's own tool configs (Claude, Codex, Cursor, Gemini, VS Code, Windsurf, OpenCode, .mcp.json), and the ones the owner adds in Settings (mcp.client.saveServer, kept in mcp_personal_servers.json with values in secrets.json), act with that user's identity and credentials. They are bridged only into runs the server owner is accountable for, decided once per run from HostExecutionGate.ownerAccountable; with no answer, or a failed one, the run gets none: not their tools, not their names. The built-in harness gets them in its registry; a Claude Code run gets them from the MCP endpoint only because its run grant carries that decision (AgentRunGrant.personalMcp → McpCallScope.personalMcp). The owner's MCP token and paired devices never list, call or search them, and their resources and prompts are not re-exposed.
  • Workspace MCP servers belong to the workspace. A workspace admin configures them (mcpServers.*, stored in the workspace database; environment and header values in secrets.json, write-only, never returned). Every run in that workspace gets their tools and no run elsewhere does: the registry keeps one layer per workspace and the MCP endpoint picks it from the run grant, never from a header or argument (McpToolView). The owner's token and paired devices see none. A stdio server runs on the host as the server's OS user, so it starts only once the current server owner approved it (host_approved_by, rechecked on every connect; the owner saving it approves it; mcpServers.approve is owner-only); any edit by someone else that changes how a server is launched or reached drops the approval, and an imported workspace file arrives unapproved. Until approved, an http/sse server connects only to public addresses, resolved once and pinned (pinnedPermittedConnection, the media proxy's rule), so an admin cannot point the host at its own loopback or private network. Bridged names stay within 43 characters so Claude Code's mcp__control-center__ prefix keeps them under the model API's 64.
  • Router isolation. Loopback gives a shared listener no caller identity. Browser rigs reach the router through a lane that belongs to their workspace, and a route in another workspace, or a rig dev domain nobody can place in this one, answers 502. Sandboxed agents never get the router port: they reach their lease's ports through loopbackPorts and their own environment's hostnames through the run's proxy, which pins each name to that endpoint's own loopback port. Pins carry plain HTTP only: CONNECT to a pinned name is refused, because a tunnel can carry any Host or SNI. Tool-owned domains are not pinned at all, since a tool's shared proxy serves every environment by SNI.
  • Native editors. A program the server starts on its own display runs as the server's OS user outside any sandbox, so listing and launching host editors (ide.detectEditors, ide.openPrInEditor, ide.openSpaceWorktree) is the server owner's, and even for them a pull request is opened only from a repository linked to the workspace whose pull requests they may read and whose path is served (requirePrRepoByFullName, RepoPathGuard.admit).
  • Embedded editor. code-server runs as the server's OS user (terminal, tasks, debuggers, extensions, a port proxy to host loopback), so every codeServer.* op and watch is server-owner only (server_owner_required), and identity.me.can_use_host tells the client up front. Each proxy capability is bound to the device and user that opened it; anyone else gets the same 403 as an unknown session. VS Code's workspace trust stays on and task.allowAutomaticTasks is off: the owner answers VS Code's own trust prompt per folder, and a repository's tasks never start on open.

Credentials never reach sandboxes or clients through any of these paths.

Desktop windows

app_use is the one agent surface that acts outside a sandbox or VM on the host: it captures and sends input to a real window on the server's screen, which needs macOS Screen Recording and Accessibility granted to Control Center. That is a deliberate trade so that any framework works, with these limits:

  • cc_window checks every capture and input against the environment's process tree in the native layer, and refuses roots at PID 1, itself or its ancestors. An agent sees the window, not the desktop, and can't click another app. Foreground typing checks focus again before each character and stops when it moves.
  • Launching a window and sending input each go through the action policy; agent launches default to ask.
  • RigService.act rejects agent input while a human holds control.
  • Windows stay on a display, so the operator can always see what an agent is doing.

Audit integrity

Guard-decision hashes canonicalize timestamps to the UTC Unix-second precision persisted by SQLite. Verification still detects changed, reordered or removed decisions. A hash that does not verify is reported as a failure, never rewritten or accepted as intact.

Server-level operations have their own trail: server_audit (global database) records every audited op that is not scoped to a workspace and is not a read, with the caller (user, device, address), the op, the names of its arguments (never their values) and the outcome. The newest 20,000 rows are kept. Both trails are read through one table, the audit log (audit.watchLog). The server re-resolves who may read what on every frame: the server owner reads server_audit, and each person reads the user_activity of every registered workspace they administer, with hidden PR entries redacted per workspace (PrDataGate). Asking for a trail by key never widens that set. A demotion or removal drops the workspace on the next frame.

Network boundaries

  • Non-loopback server binds require TLS (--tls-cert/--tls-key), or explicit --insecure behind a trusted TLS-terminating proxy.
  • First-party client sessions require Noise_NNpsk0_25519_ChaChaPoly_SHA256 on both direct WebSockets and the broker relay, including loopback. A device's 32-byte PSK authenticates admission; a transcript-bound Ed25519 signature authenticates the server and its saved fingerprint pin. Missing identity, changed pins, unsupported versions, tampering, replay and out-of-order records fail closed.
  • Every connection uses fresh X25519 ephemeral keys and separate directional traffic keys. Ordered counters, periodic rekeying and record limits bound key use. Reconnection starts a new handshake, never resumes old counters or replays an interrupted transfer. Key destruction is best-effort in Dart/browser runtimes, not a guarantee of physical memory erasure. On native runtimes the traffic keys move at session start into one worker isolate that seals and opens every record (NoiseRecordCipher); the handshake's copies are destroyed and the copies in transit zeroed. Requests reach the worker in order and each direction's counter lives with its key, so a reordered, tampered or unanswered record still closes the session. The web runs the same code inline.
  • RPC, terminal input/output and sensitive resource bodies share this secure session. Media/fonts, meeting audio, workspace logos, blobs, backup transfers, soundscapes, rig streams/files/clipboard and embedded editor HTTP/WebSockets use the bounded resource tunnel. Their public HTTP routes return 426; signed URLs alone cannot open a readable network lane. Existing signatures, registered-workspace checks, membership and operation-specific roles still apply. Every fetch of a member-chosen URL (the media and font proxy, a Connect origin, agent web fetch, web push) refuses every address that is not globally reachable, embedded-IPv4 forms included (one isNonPublicAddress), and dials only the address it judged, again on each redirect hop, so a second DNS answer is never used. A viewer's forge credential travels only over https and only to its own host.
  • Resource cancellation closes network producers; shared media fetches remain live only while another consumer needs them. Server admission counts actual handlers until they finish, including work unwinding after cancellation. Device revocation/expiry closes attached sessions; membership changes cancel active resource transfers and subsequent requests reauthorize.
  • Native URL consumers use a capability-scoped loopback facade. Browser URL consumers use an in-memory Service Worker/MessagePort facade; decrypted response bodies are not put in CacheStorage. Embedded browser editors share the app origin and use live, connection-owned resource capabilities. The editor frontend and enabled extensions are trusted client code. The server-launched editor extension has a separate capability-protected private loopback report/command bridge; this is trusted endpoint IPC, not a public HTTP exception.
  • Random production invitations redeem through Noise before returning a device PSK. SSO and public-demo handoffs encrypt credentials to a client-held X25519 recipient key using HKDF and AES-256-GCM. Login/bootstrap origins and client-code delivery remain trusted: an active origin or TLS terminator that replaces the initial page/key can compromise that bootstrap. Unsolicited SAML uses a short-lived, single-use browser-bound grant and an explicit sealed claim, not a plaintext credential redirect.
  • The signaling broker relays ciphertext without seeing the PSK. Rooms are invite-gated, capacity-bounded, byte-paced and reaped when idle; room ID alone grants no access. It still sees IP addresses, room/peer identifiers, admission material, record sizes, timing and connection lifetime. It can deny service; encryption does not hide traffic analysis. See broker protocol.
  • The trusted plaintext endpoints are the paired client and the chosen cc_server, including its execution environment. A hosted server operator, compromised endpoint, authorized recipient or configured model/forge provider can still see data it handles. This transport feature does not encrypt databases/backups at rest, erase previously downloaded data, or seal independent MCP, fleet-worker, webhook or provider protocols. TLS remains required for their transport, public metadata, bootstrap and web-code delivery. No independent cryptographic audit is claimed.

Browser push alerts

Web Push is a separate outbound notification channel, not a plaintext exception to the first-party RPC/resource tunnel. Registrations belong to the authenticated active paired device and user; another device cannot read or remove their subscription secrets. VAPID and subscription material stays in owner-private server secrets, with restrictive permissions set before file contents are written.

Only allowlisted push-provider HTTPS endpoints are admitted. Delivery resolves and pins public addresses, rejects private/loopback/link-local targets and redirects, and rechecks device status, workspace membership, recipient targeting and space/repository visibility immediately before the external request. Revocation removes registrations; losing workspace access suppresses delivery even if a browser still holds its local subscription.

Encrypted payloads contain generic alert categories and scoped navigation identifiers, not message previews, approval commands or credentials. The provider still sees endpoint, traffic size and timing. Notification clicks navigate to the first-party origin and do not grant authority; opening content reauthorizes against the server. Quiet/category preferences control delivery, while OS permission and supported PWA installation remain browser requirements.

Usage analytics

Usage analytics are a separate outbound channel to an Umami instance (https://analytics.alev.dev/ by default), not part of the first-party tunnel. Collection is opt-in and server-owned: telemetry.usage_analytics in the server settings must be true, which only the server operator can set (telemetry.setUsageAnalytics, ServerAuthority.serverOwner; refused on the public demo). Every client reads telemetry.config / telemetry.watch and sends nothing until that config has arrived and allows it. Debug and profile builds send only when the server's environment (or .env) sets CC_ANALYTICS_DEBUG=1, which travels in the config as debug_builds_allowed; it lifts the build gate, never the operator's switch. The server's own reporting also honours DO_NOT_TRACK=1, and a demo server does not report at all.

  • No PII by construction. Events are built only from the AnalyticsEvents tracking plan. AnalyticsPropertyPolicy then drops any string that is not a short token (free text, paths, URLs, email addresses), any string under a key naming personal or free-form data (*_name, email, path, title, prompt, content, token, …) and any ID-shaped string that was not wrapped in AnalyticsId. Message bodies, titles, shell commands, search queries, repository and branch names, file paths and logins are never recorded; dynamic command-palette IDs report only their kind.
  • Pseudonymous IDs. Entity, user and device IDs are replaced by an HMAC-SHA256 under the install's telemetry.pseudonym_salt (truncated to 80 bits). The salt is minted per install and delivered to authenticated clients so all surfaces hash alike. It is never sent to the provider. Wiping the data directory mints a new salt and install ID, which unlinks earlier data.
  • What the provider still sees. The requesting IP address (Umami derives country and region and does not store the address), the User-Agent (the browser's own on web; an OS-family/version string on native) and request timing. Nothing in an event authorizes anything.

Dependencies

dependency-audit.yml runs weekly, fails on pub.dev advisories and retracted/discontinued dependencies, and reports outdated packages. Native source/provenance and packaging requirements are documented under cc_natives.

There aren't any published security advisories