# Security

Forge is development software. It has no security certification and no production release. To report a vulnerability, see [SECURITY.md](../SECURITY.md).

## Source is data, execution is not

Capture and analysis read untrusted repository bytes. They never run imports, hooks, manifests or package scripts. Source text, comments, Markdown and provider metadata stay data, including text written to address an agent. Rendered Markdown omits raw HTML and runs no JavaScript.

A check or Playbook runs repository code under your OS account. Lanes, Git worktrees, MCP credentials do not confine the file system, processes, network or other agent tools. There is no sandbox. Checks use the clean environment described below, and logs can contain anything the command prints. Local run records and exit codes are observations. Code with your OS authority can forge them.

### Hosted check authorization

Queueing a hosted check requires current project owner or contributor access and ownership of the selected runner (`runner.actor` must match the caller). Project ownership alone does not authorize queueing on another person's runner. Contributor proposals run on the owner's computer only when that runner's owner queues them. Runner polling and claiming enforce the same ownership rule, including for retained requests created before it was enforced; those requests are not rewritten.

**Private projects run only in private runner repositories, unless the owner accepts public logs.** A GitHub Actions run's logs, test names, paths and printed output are as visible as the repository it runs in, so a private project (any project not marked public, including one imported from a private GitHub repository) never runs checks in a runner repository that is not private; GitHub's `internal` visibility counts as not private. Three points enforce it with the GitHub App access Forge already has, and each refuses with `RUNNER_REPOSITORY_PUBLIC` and both fixes (connect a private runner repository, or the owner's opt-in below): `configure-runner` reads the repository's visibility before saving the setting; each dispatch reuses one visibility read per repository for 5 minutes, then reads GitHub again, and refuses before any workflow starts; and every runner call checks the `repository_visibility` claim GitHub signs into the run's OIDC token, before any plan, source or result is exchanged, so a repository made public after connecting is refused at its next check even inside those 5 minutes. A refused check settles `runner-unavailable` with that reason. The project owner (only the owner; never a member or a coordination-only agent credential) may accept public check logs for a runner with `publicLogs:true` on `configure-runner` ([GitHub Actions checks](operations/github-actions-checks.md)); the acceptance names that one repository, and while it is set every check receipt and runner view says plainly that check logs are public. Public projects and opted-in runners are not checked and make no extra call. Cost: no extra Convex call per check (the read rides the existing dispatch reservation and observation); private projects add one GitHub call per runner repository per 5 minutes.

**Private submodules need the owner's allowlist.** A check gets a read token for a private submodule repository only when the project owner allowed that repository with `configure-runner` `submodules` (owner only; empty by default). Allowing a repository grants every change that reaches a check, from any member or agent who can land one, read access to that repository's contents: the check's own commands can read and print it. On a run whose check logs are public (`publicLogs:true`, or a run repository GitHub's signed OIDC claims do not show as private) a repository is read only when the owner allowed it with `"public-logs"`, because printed content is then public. Anything else is refused with the owner's exact command ([GitHub Actions checks](operations/github-actions-checks.md#submodules-in-checks)).

The GitHub Actions plan step verifies the pinned Candidate tree before publishing
the same-run artifact. Run jobs verify tree bytes only when the check declares an
`actions.setup` program, with checks before and after setup. Other run jobs rely
on the plan step's verification and the same-run artifact. See
[GitHub Actions checks](operations/github-actions-checks.md).

Only the request's creator, the runner's current owner or the project owner may cancel or update a request, and each must still have current project write access. Revoked contributors and read-only viewers cannot queue, cancel or update checks, including retries. Result updates retain the original request, runner and run pins and terminal-result reconciliation. Reports remain observations rather than execution attestations. The canonical owner listener accepts recheck requests only from the current project owner.

### Clean check environments

Every check, including Playbook steps and event automations, starts with private empty `HOME`/`USERPROFILE`, `XDG_CONFIG_HOME`, `XDG_CACHE_HOME`, `XDG_DATA_HOME`, `XDG_STATE_HOME` and temporary directories under its private run directory. `TMPDIR`, `TEMP` and `TMP` point there. These directories are removed with the disposable workspace; interrupted or changed workspaces retain them until ordinary check-workspace cleanup. Saved `nforge login`, npmrc and cloud/CLI configuration are not discovered through the user's HOME or XDG paths.

The environment allowlist is `PATH`, `LANG`, locale names matching `^LC_[A-Z_]+$`, `TZ`, `TERM`, and Windows tool lookup settings `SystemRoot`, `WINDIR`, `PATHEXT`. Forge's runtime controls `FORGE_GIT_TIMEOUT_MS`, `FORGE_CHECK_FULL`, `FORGE_CHECK_SCOPED`, `FORGE_MAX_CONCURRENT_CHECKS`, `FORGE_CHECK_QUEUE_DIR`, `FORGE_DISK_WARN_GB` and `FORGE_DISK_BLOCK_GB` are also forwarded. Forge sets `CI=true`, the private directory paths, `npm_config_userconfig` and `npm_config_globalconfig` to private empty configuration locations, and `npm_config_cache` to a dedicated shared content cache at `~/.cache/nanthai-forge/check-npm-cache`. That cache is separate from the user's npm cache and configuration and receives no npmrc auth. Each run also gets transient dedicated caches beside it for other ecosystems, one directory per project (`GOMODCACHE`, `GOCACHE`, `PIP_CACHE_DIR`, `UV_CACHE_DIR`, `NUGET_PACKAGES`, Maven `-Dmaven.repo.local` via `MAVEN_ARGS`); `CARGO_HOME` and `GRADLE_USER_HOME`, which read executable configuration, are fresh directories inside the run with only the project's downloaded content linked in, so configuration a check writes does not outlive it. Only when present at their default location, the toolchain homes `RUSTUP_HOME`, `PYENV_ROOT`, `MISE_DATA_DIR` and `ASDF_DATA_DIR` are passed too. These hold downloaded packages and installed toolchains, never credentials, are not part of the recorded environment or its fingerprint, and a declared `env` passthrough of the same name overrides them. See [self-hosted runner](operations/self-hosted-runner.md#toolchains-and-caches-in-checks). The paths still identify the runner's home location. Node/npm create their own runtime variables when invoked; ambient `NODE_OPTIONS` and npm configuration are not inherited.

Everything else is absent by default, including `FORGE_AUTH_TOKEN`, `FORGE_AGENT_TOKEN`, other `FORGE_*` credentials, `GH_TOKEN`, `GITHUB_TOKEN`, `NPM_TOKEN`, `AWS_*` and `CONVEX_DEPLOY_KEY`. This is an allowlist, so new credential variable names are absent too.

The runner supplies its own `FORGE_CHECK_CHANGES`, `FORGE_CHECK_BASE`, `FORGE_CHECK_HEAD`, `FORGE_CHECK_SELECTION`, for interaction runs `FORGE_CHECK_INTERACTION` and, for a check that declares shards, `FORGE_CHECK_PART` and `FORGE_CHECK_SHARD` (with `_INDEX` and `_TOTAL`). These describe the pinned check input and output paths; they do not inherit ambient values, even when declared for passthrough. Unavailable comparison input leaves the corresponding comparison variables absent. The allowlisted controls above remain ordinary runtime settings, so a clean check is not expected to have zero `FORGE_*` variables.

A check definition may explicitly declare `env: ["NAME"]` and/or `credentials: ["TOKEN_NAME"]`. Both pass exactly those variables from the runner process, including credential variables if explicitly selected; `credentials` labels sensitive passthrough separately. Missing variables stay absent. Explicit selections can override generated defaults, including HOME or npm configuration. Declarations are canonicalized and included in the definition digest. Values are used transiently and are not copied into Work metadata, environment fingerprints or receipts. Definitions and receipts show the names; arbitrary command output may still disclose values. These declarations do not resolve or reveal Secret Objects: those remain available only through their existing controlled broker operations.

Declaring `env: ["HOME"]` restores home-relative access to all files under that HOME; it does not also restore `USERPROFILE`, XDG settings or cloud credential variables. Declaring `credentials: ["AWS_SHARED_CREDENTIALS_FILE"]` instead exposes that configured file path while leaving HOME private and other `AWS_*` variables absent. Neither declaration grants filesystem authority: the process already runs with the user's OS rights.

The same clean environment, with no passthrough, applies to the repository-chosen commands Forge runs on your machine outside a check: the dependency install at `start` (and when a sync changes the lockfile), and every command of a local `preflight` (static checks, the build step, package commands and the test runner). One environment is built per install or preflight run and removed when it ends; it also passes corepack's own home (`COREPACK_HOME`, `~/.cache/node/corepack`) when it exists, so the pnpm and Yarn versions corepack already fetched are not fetched again. A repository's declaration of install scripts (`install.scripts` in `forge.json`, `enableScripts` in `.yarnrc.yml`, a package allowlist) is only a request that `start` shows: scripts run when `start` passes `installScripts:true` or this machine's `installScripts` setting accepts requests ([shareDependencies](parallel-work-defaults.md#sharedependencies)). Local preflight runs a build-tool wrapper the tree commits (`gradlew`, `mvnw`) only when the project declares `"preflight": {"wrappers": true}`; otherwise it runs `gradle` or `mvn` from `PATH`.

Definitions without declarations continue to execute in the clean environment. Failed runs record a value-free “may need env passthrough: X” suggestion listing omitted parent environment names; it is diagnostic, not proof of the failure's cause. Environment fingerprints cover the clean runtime policy and allowlisted settings, not undeclared external inputs or passthrough values.

Clean environment isolation prevents ambient discovery through inherited settings. Repository code still has the user's OS authority: it can read known absolute paths, discover the account home through OS APIs, access other processes or the network, and alter shared cache contents. It cannot be claimed unable to read a credential file by every route. Strong protection from hostile code requires separate OS isolation. Upgrade the local runner to obtain this behavior; older binaries retain their previous execution behavior.

`tests/check-environment.test.mjs` exercises real local checks against synthetic HOME files: SSH keys, AWS configuration, saved Forge/GCloud configuration, npmrc and dotenv files. It verifies default read failures, omitted credential variables, exact-name and HOME/file-path opt-ins, and the known-absolute-path boundary without reading real credentials. Source capture excludes newly encountered `.env.local` files; clean environments do not scrub secrets already retained in source or printed by a command.

Handing a secret to arbitrary code lets that code leak it.

**Hosted Actions checks.** On GitHub-hosted Linux runners each Candidate child runs as a separate unprivileged user (`forge-check`) in a private mount namespace that hides the runner's home except the check's own folders and read-only toolchains, so it cannot read the runner's credentials or the supervisor's environment or use `sudo`. Where that user cannot be set up the check fails setup by name, unless the project owner's runner configuration allows shared mode (`configure-runner` `isolation:"shared"`, for macOS or Windows self-hosted runners); the receipt's `check.isolation` says which mode a landing's check ran in. Independently of that, a hosted Actions pass needs the CI provider's own success record, outputs come only from the planning step and caches are saved only before the check step from downloads that run no repository code. See [what Actions evidence attests](operations/github-actions-checks.md#what-actions-evidence-attests).

## Secret scan at landing

Every hosted landing check scans the paths its composed Candidate changes from the composition base, before project code runs. Forge's own executors do it (the GitHub Actions planning job and self-hosted machine runners), so it works with any configured check command. Paths already on main are not rescanned.

It looks for known credential shapes (private key blocks with a key body, AWS access key ids, GitHub, GitLab, Slack, npm, Google, Anthropic, OpenAI, Convex deployment and SendGrid tokens, live `sk_`/`rk_` keys) and for a random-looking value assigned to a secret-named key (`token`, `secret`, `password`, `api_key`, …; mixed values of at least 24 characters, or random hex/lowercase values of at least 32; non-secret hash assignments still pass). Repeated-character placeholders and documented `…EXAMPLE` values are not findings. Files over 1 MiB and links are skipped; smaller files scan even with NUL bytes. Assignment names and whitespace are bounded, and assignment lines over 8 KiB are skipped.

A finding fails the check like a failing test: the landing stops with `CHECK_FAILED`, and the notice names the file, line, kind and a 16-character fingerprint, never the value. The fingerprint is a salted SHA-256 of path, kind and value. At most 20 findings are listed, with a count of the rest.

From a Lane checkout, preflight can report the same findings early for changed saved files it can verify locally against observed main. When main has an allow file, the preview needs a locally verifiable copy within its 1 MiB file bound. The hosted check still scans the composed Candidate with the full allow file from the composition base.

Remove a real credential first, and rotate it at its provider. Saves run the same scan first (see [secret scan at save](security.d/sections/0510-secret-scan-at-save-and-owner-purge.md)), so a finding here is usually a shape added since or a value saved before. If it reached a Lane save, the project owner can purge that save's bytes.

If a finding is not a secret, override it with an entry in `.forge-secret-allow.json` at the repository root: `{"allow":[{"fingerprint":"…","path":"…","reason":"…"}]}`. The notice prints the exact entry for each finding with an empty `reason`; paste it into the `allow` list and write why. An entry needs a non-empty reason and covers only that value in that path. Entries count only from main (the composition base), never from the change under check, so a change cannot allow its own finding: land the entry on its own first, then land the change. A change that adds both a finding and its matching entry still fails, and its notice says so. This file is a root file, so changing it always rechecks in full.

Who sees an override: every landing that adds or edits an entry sends the project owners one alert on the landing alert channel (email or webhook, the same settings as stall alerts), and its receipt carries `secretAllowAdded`. Both name the receipt, the submission, the path, the fingerprint and the reason, never the value; a reason that itself looks like a credential is withheld. An entry that matches a finding added in the same landing is labelled as a self-allow. If the allow file changed but no Forge executor diffed it (a bring-your-own check, an older runner or no check), the receipt and the alert say the entries are unknown. Removing an entry is not an override and sends nothing. Accepted history also records who allowed what, when and why, and the Actions planning log shows how many findings each check allowed from main. Today an override never blocks a landing by itself; `secretAllowReview` in `src/secret-allow.ts` is the hook for a project policy that requires a person for agent-added entries (approvals, Issue 517523cf). To require owner review now, add `.forge-secret-allow.json` to the project's `acceptance.protectedPaths`; Forge's own project does.

The scan is a guard, not a guarantee: it does not see encoded or split values, text in skipped files, history that landed before it, or local (not hosted) checks. A future private-file audience (Issue 6bd7ddb1) will be skipped by one flag (`isPrivate` in `src/secret-scan.ts`); until then every changed file is public to the scan. Cost: no Convex calls, no vendor and nothing when idle; it reads only bytes the check already downloaded (the machine runner reads one extra State manifest for the base; when the change edits the allow file and main has one, both runners may read main's allow file, one small object). A landing that adds or edits an allow entry adds one scheduled alert delivery at publication, computed from the run plan and changed paths publication already reads; other landings add nothing. Each eligible changed file is read once.

## Secret scan at save and owner purge

On a public project any signed-in person can read a saved Lane, so a credential has to be stopped before the save stores it. A save, `land --save` included, runs the [landing scanner](security.d/sections/0500-secret-scan-at-landing.md) on its changed files after capture and before any upload. It uses the same patterns, the same 1 MiB file bound and the same allow entries: those in `.forge-secret-allow.json` on the Lane's base (main) State, never the Lane's own edit of that file. A finding refuses the save with `SECRET_FOUND`. Nothing is uploaded, no save row is written and the staged capture is dropped. The reply names path, line, kind and fingerprint, never the value. It also carries the exact allow entry for a false positive, and in `next` and `command` the same save to run once the file is fixed. The CLI and MCP replies are the same object. Cost: no Convex call or network I/O. CPU grows with the changed bytes (about 13 to 20 MB/s on a laptop; a 10-file save adds about 5 ms). The scan reads one State manifest and one allow file from this machine's object store. Idle cost is nothing.

If a credential the scanner does not know still reached a save, the project owner can purge it. On the Lane page, an opened changed file shows **Purge saved bytes…** to the owner only, and only before the Lane lands. The owner types PURGE (`projectSavePurge:purge`; browser only, never a device credential). The purge compares the Lane head with the Lane's base, or one save's head with the State it was saved over. The server checks the selection:

- It refuses a path that comparison did not change, a link, an empty file, and bytes that current main holds at any path. A landed leak needs its history rewritten, not a save purge.
- It refuses a large file stored in chunks. Purge covers files stored whole.
- It refuses if main moved while it checked, or if another purge in the project is still deleting bytes.

Then, in one transaction, it:

- marks each object row purged;
- drops the Lane's built Git commit;
- schedules the Lane snapshot purge;
- writes the receipt (`projectSavePurges`, one row per operation id);
- writes a tombstone message in the Lane's thread that says what was purged, when and by whom.

From that moment every read through the single object lookup returns `PURGED`, naming when and by which purge: checkout, diff, show, Git Lane fetches, compose and the GitHub mirror. Catalog compaction keeps the purged row. A Git build that started before the purge is not cached.

A State's physical manifest maps files straight to stored bytes, past that lookup. Once a project has a purge, checkouts, check runners and source grants stop using physical manifests and read through the catalog path instead. That costs one indexed read per such request, and reads in that project get a little slower.

After the mark, the action deletes the raw R2 objects and the Git commit chunks. It zeroes a packed member's byte range in its upload pack; the rewrite carries If-Match on the ETag it read, and the pack's other members still verify by their own digests. Then it marks the receipt done. A retry with the same operation id returns the same receipt and finishes any R2 work left. The same id with another selection is refused.

Limits: copies already downloaded to a machine, a CI log or a fork stay where they are, so always rotate the credential. The purge removes the bytes, not the State that names them. A later save of the Lane that still holds the file cannot be read either, so save it without that file. The same bytes in another Lane are purged too (one object), but only this Lane's Git commit and snapshots are dropped. Landing trial merges and source workers that read a physical manifest fail on the zeroed bytes instead of naming PURGED.

## Access is checked before retrieval

Project roles (owner, write, read), what each may do and where each check runs are in [project access](access.md); one resolver, `convex/projectRole.ts`, reads membership for every check.

Durable source-worker and mirror continuation reads bind legacy Convex file IDs
to a live `projectObjects` owner row before fetching bytes. Foreign, unknown,
removed and unregistered references fail with `SOURCE_REF_UNOWNED`; a cursor
containing an ID does not prove ownership. Old continuations without owner rows
need migration before resumption. This legacy check costs at most one indexed
lookup and one internal query per read. Project-scoped `r2source:` reads retain
their digest/size verification and add no Convex calls.

What the GitHub App can write to a repository, and when, is in [GitHub App](operations/github-app.md#what-the-app-can-push-and-when). Each token names explicit permissions; the mirror adds `workflows: write` only to a step whose plan touches `.github/workflows/`, or to an unverified bootstrap step whose changed paths are not yet known (requesting both there costs no extra GitHub call, while a contents-only token would stop the mirror on a workflow change). Forge sign-in, GitHub App installation and a person's repository entitlement are separate. Every read of private imported source, graph or export checks current policy and current provider entitlement. Policy is rechecked after provider calls. A saved snapshot, an old grant or a download never creates new access.

Paths, counts, search results and relationships derived from source are part of the visibility boundary.

- **Named readers and reader teams** share a whole private import. Both the importer and the reader need current GitHub entitlement.
- **Source Zones and scoped agent grants** expose selected pinned files and a graph built from only those files. The source text can still mention hidden files, so filtering cannot promise that visible code reveals nothing about hidden code.
- **Scoped agent grants** are time-limited bearer tokens. They allow source reads only: no Work writes, execution, documents or secrets. Expiry, revocation and the creator's entitlement are checked on every read. Refreshing never widens scope. A token represents the owner, not a verified process. Grants cannot limit other tools, files, network or spend.
- **Hosted contributors** get whole-project access through their own flow. A contributor can download the full source archive and return a proposal. Contributors may create Intents, and add notes or change status on Intents they created or are assigned. Creator and assignment lookups use authenticated account IDs in the selected Work generation, with original hosted creation events retained as creator evidence; Lane session labels grant no authority. Revoking contributor access or removing an assignment takes effect on the next write, including retries. Proposal list, detail and download reads follow project visibility. They cannot change project policy; Channel acceptance follows the autonomy rules below.
- **Per-member Lanes and landings** follow the GitHub norm: a contributor changes only their own Lanes (save, sync, abandon, complete, reopen, compose into a Candidate), and their own landing submissions and Candidates (submit, cancel). The project owner may act on anyone's; the action is recorded under the owner's own account. An Intent cascade run by a contributor closes only that contributor's Lanes. A decision record names the caller's account (or `account/slug` for the caller's own agent session), never a client-chosen name; a client that knows its session refuses a decision naming another session's slug. Provider log links are https only: any other stored or provider-sent link shows as no link. Forge's own stall and abandon follow-ups keep the authority of the action that started them.

Signed-out in-page reads of a public project share one budget per project (Convex exposes no client address), set in `convex/abuseLimits.ts` (120 calls a minute); over it they fail with `RATE_LIMITED` and a retry time, and signing in avoids it. Signed-out availability is shared across visitors of a project; exhaustion affects that shared audience, while signed-in reads stay independent. New stored objects count against per-object (100 MiB), per-project (50 GiB or 4,000,000 objects) and per-account (100 GiB or 10,000,000 objects) storage quotas in the same file and fail with `QUOTA_EXCEEDED` when a reservation would pass them; nothing from that request is reserved. The read budget costs one point read and one write per signed-out request; the quota costs one point read and one write per upload batch that reserves new objects, plus one more of each when a project's new usage is added to its account total (every 1,000 objects or 256 MiB per counter shard). Snapshot uploads reserve their new physical object bytes against the same project/account quota before signing PUTs. Each new snapshot reservation adds one counter read/write, plus the existing account roll-up when due; an unchanged tree or replay reserves nothing. Nothing runs while idle.

A contributor membership has 300 fresh check operations, 300 compositions and
300 submissions per UTC day. Each operation id charges once in its creation
transaction; a replay still reconciles at the cap, and failed transactions charge
nothing. The counters reset in place on the first operation of a new day. Owners
are exempt. A new contributor operation adds one indexed membership read and one
fixed-size patch; the owner landing path adds no calls, reads or writes, and idle
work schedules nothing. This bounds request counts, not provider bills or CI minutes.
The counts use `min(300 existing board posts/member/day, 50 GiB / 100 MiB) = 300`;
at the $0.002 serving target that is $0.60 per request class/day in target units.

Downloaded data cannot be recalled. GitHub readers of a full repository already have that access independently of Forge.

After GitHub access is lost, an importer can still list and delete their own imports. That cleanup metadata does not allow reading source, graphs, exports or Restore. Permanent deletion removes objects that only that project owned, and keeps shared objects and minimal receipts. It does not purge provider backups or downloaded copies.

Project invitations never perform recipient email lookup at creation and never grant on sign-in. The signed-in invitee explicitly accepts a pending invitation using their account (for a handle) or unique current verified email (for an address). Unverified, cleared, ambiguous and wrong-account bindings cannot accept; a forwarded link grants nothing. Invitations expire after seven days, and ended invitations cannot send again. The person can decline or block an inviter across projects. Device credentials cannot answer for them. Invitation mail has its own off-by-default switch, verified-sender requirement and transactionally checked limits; see [access](access.md#invitations).

## CLI device credentials

Device approval issues a Forge-signed JWT with audience `forge-cli`, not the approving browser's Clerk session JWT. The server stores only code/token hashes plus device metadata, approving subject, scope, expiry and revocation state. The server derives unpredictable device secrets and short user codes from a login nonce under its private key; start retries reconcile without storing plaintext codes. Codes expire after ten minutes. A decision is single-use and bound to its approving account. Redemption is single-use; retries with the same operation ID reconcile the original credential. Polls are spaced five seconds apart; approval lookups/decisions allow ten attempts per account per minute. New login starts default to 120 per minute per deployment (retries of a started login do not count); over the limit, `/auth/device/start-v2` answers HTTP 429 `slow_down` (interval 60 seconds) and writes nothing. Device names are 1 to 80 characters. Code hash comparisons use constant-time crypto verification.

Device credentials cannot reveal Secret Object plaintext, permanently delete Secret Objects or projects, run any account cleanup (Account → Your data is person-only, including its inventory, export and receipts), or register a machine runner and receive its signing key. The owner person uses the browser for these operations. To delete projects from a terminal, a device prepares a bulk request (`nforge host ROOT --delete-projects …`, at most 100 projects, 30-minute expiry). The request holds the exact frozen list and deletes nothing until the owner person approves it once on the web. Approval re-checks each project and skips any that changed. Device and agent sign-ins cannot approve or retry it, and another account reads it as not found. Copying a browser token into the terminal is not needed or recommended. `nforge host ROOT --delete-project …` calls the same permanent-deletion mutation and is refused with `PROJECT_UNAVAILABLE` when authenticated by `nforge login`, including CLI scope. Existing browser account JWT overrides retain person authority. Existing broker use, secret names and runner operation retain their current access rules. Secret Object creation, rotation, grants, disabling and trash follow the account write rule. Adding contributors, inviting people and granting reader access from a device credential opens an exact membership approval request, even before the first landing. The owner person approves or declines it on the approve page; approving applies only that request. A held action returns `PROJECT_UNAVAILABLE` with its approval link and wait command. Retry the original command after the approval to reconcile it. Revoking access remains available to agents. Deploy the membership approval readers and web page first, then the request writer. Set the default-off rollout flag `FORGE_MEMBER_APPROVAL_REQUESTS=1` only after those readers are present. Until then, device membership additions refuse with `PROJECT_UNAVAILABLE`; the owner person can still grant access directly.

While both browser sign-ins are available, a linked Convex Auth session and its
existing Clerk account can review the same bulk-delete request. Approval checks
the signed-in Forge account and each selected project’s current owner.

CLI credentials expire after 30 days and are revocable from account settings or logout. Existing approvals use browser re-login. A stable device that has not renewed within 30 days after its sign-in lapses (at most about 60 days unused) must be approved again; every device is re-approved after 12 months. This is not exact last-command inactivity and adds no activity write; explicit login still opens the browser. Stable sign-in generations, selected-project scopes and source settings narrow the existing person authority. Sign-out retains the key, name and settings; removal revokes the approval and deletes its display name, settings, public key and code under the approved central policy, allowing later approval of the same key. Every approval writes a next-visit account notice. New or expired approvals require a fresh browser sign-in or a session-bound passkey/GitHub check within ten minutes. Ending other browser sessions offers to sign out all devices too. See [the access contract](access-contract.md#stable-device-approvals). The CLI stores credentials in a user-owned `0600` file; it never prints the token. Windows stores no permission bits: there the file's privacy comes from the user profile's access list. Environment overrides remain available. `FORGE_AUTH_TOKEN` is bound to the origin in `FORGE_DEPLOYMENT_URL`; when that is absent, only the saved default deployment or an origin with a saved login may use it. A checkout cannot select a new token destination. Hosted checkout origins must use HTTPS or HTTP loopback. Every public backend function checks Forge credential revocation, expiry, approving subject and scope. Queries and mutations check on every call. Actions also recheck before returning, but reuse a positive check for up to 30 seconds within one server process, so new action calls observe revocation, settings changes and new sign-in generations within 30 seconds. An action admitted before a settings change can finish with its original settings. Reuse never extends its own deadline or credential/approval expiry. Signed credential markers retain these checks while issuer configuration changes. Existing current project, contributor, GitHub and source policies still apply. Coordination-only credentials cannot read source, exchange checkpoints or change hosted Work. A CLI credential is bearer authority for the selected scope, not a process identity or sandbox. Self-revocation can be retried after revocation and cannot grant access.

New public Convex functions must use `convex/cliServer.ts` registration helpers (coordination variants only for coordination endpoints). The registration contract has a negative test to catch bypasses. Keep the private CLI signing key server-side; replacing it invalidates outstanding credentials once Convex refreshes its JWKS cache. Login starts and renewals share the existing 120/minute deployment-wide budget, including unknown-key renewals, after a [per-visitor limit](security.d/sections/0810-per-visitor-limits.md) of 10 a minute and 30 an hour; known-operation retries are not charged again. Expired device-login rows are deleted, up to four per new login start, so pending login storage stays proportional to recent logins without a scheduled job. Issued credentials and account approval-attempt rows are not deleted automatically.

The approval page `/device` (the earlier `/-/device` address redirects to it) follows these rules through one name component and one link-code helper (`web/src/device`). They show facts the server knows (access, lifetime, expiry) first. The device name is chosen by the terminal, so it is shown last, quoted and marked as not verified, with control and direction characters removed and a length cap; it is never a heading. A code that arrives in a link leaves the address as soon as the page loads, so it is not in the address bar, browser history or the sign-in return address; the page keeps it in that tab's session storage for at most the code's ten minutes. Such a code is never shown on the page, and Approve stays disabled until the code from the terminal is typed again, including for a remembered device; the server requires that same code and refuses request-only approval; Deny is never gated. `nforge login` links to `/device`, and a test fails if the link names a page the web app does not serve. Only the stable device flow starts a sign-in; the earlier `/auth/device/start` answers HTTP 426 with the command to update the CLI and stores nothing. The page tells an expired code (`AUTH_EXPIRED`) from one that already has a decision (`AUTH_CODE_USED`) by the server's error code, not by its wording; a code that was decided in another tab opens its card and says whether it was approved or denied, and a code past its expiry stops offering Approve and Deny.

## Downloads and public viewing

Cloning and downloading from Forge require sign-in, including public projects. Git ref
listings and fetches, bulk State reads and source packs refuse anonymous callers before
history, pack or object IO. Git replies with HTTP 401 and a sign-in instruction; a public
project with a GitHub mirror names that mirror as its anonymous clone route. Signed-in
public readers retain source access. Full Work archives still require owner or contributor
membership.

Public project pages, file rendering, Items and receipts remain available for viewing.
The public file viewer returns rendered file pages and derived path/map data to signed-in
readers; signed-out visitors get the same pages through the cached public read, under their
[per-visitor limit](security.d/sections/0810-per-visitor-limits.md) and the project's signed-out read budget. Raw object signing, descriptors and checkpoint plans
require sign-in, so the view response contains no storage URLs or archive plan. Viewing
necessarily delivers text to the browser; it cannot prevent saving displayed content.
Forge's archive export authenticates before any object IO, including after a cached view.
Legacy Codescape snapshot downloads also require sign-in. No raw-file or ZIP download
control is currently implemented in Code.

**Public discovery reads** (explore, profiles, a public project's front page and sitemap) use the site's edge cache. The backend `/public/v1/…` route requires `FORGE_PUBLIC_READ_SECRET` from the site Worker, compared as fixed-length SHA-256 digests; missing or wrong keys return 401 before any database operation. Set the same key on the site Worker and Convex, never in a browser build. Direct unauthenticated attempts still invoke the Convex HTTP action, but do no query, mutation or DB I/O: this is not a deployment-wide HTTP traffic or spend ceiling. Local browser development uses `VITE_FORGE_WEB_URL` to reach the deployed site cache instead of bypassing it.

The site uses `FORGE_WEB_URL` for its own origin. The sitemap backend requires `FORGE_WEB_URL`. Case, percent-encoding and slash variants of public page paths redirect (308) to their canonical spelling before any read, keeping the query. The edge copy is keyed by the canonical path alone and the proxy never forwards the query, so a bare address and its query variants share one cache identity and return the same response on a hit or miss.

Before a read reaches the backend, the site checks Cloudflare's rate-limit binding (app pages, redirects and edge hits are never counted; a public front page over the limit is the plain app without share tags): 60 requests per 60 seconds per address, counted separately in each Cloudflare location. Over it, the site answers 429 with `Retry-After: 60`. This is a best-effort backstop, not a ceiling: Cloudflare documents the counts as approximate and per location, and on dev one address sent 86 sequential, then 300 and 500 parallel requests without a single 429 (a 5-per-10-seconds probe refused 3 of 52). The limits that hold sit behind it: the backend's [per-visitor windows](security.d/sections/0810-per-visitor-limits.md), the project's signed-out read budget, the backend key, the edge cache and the deployment's spend limit. A cold public read costs one HTTP action plus one query and, for a stale activity note, at most one mutation. Cache hits make zero Convex executions; idle costs zero calls. The cache is per location, so a page costs about one cold read per cache period in each location that serves it; parallel cold requests may each read before the first copy is stored. The site does not retry upstream requests.

Raw dot-segment requests are normalized by Cloudflare before Forge code runs: on dev a raw `/./explore` reached `/explore`. A browser or `fetch` normalizes dot segments before sending, so use a raw HTTP path (`curl --path-as-is`) to verify this boundary. Do not broaden routing, decode repeatedly or forward a path outside `/public/v1/`. Paths that reach the Worker outside the public root get a nonempty HTML 404 without a backend read; private app places get the app shell. Ordinary public-data 404s keep a nonempty JSON body. No malformed path is turned into a 5xx by canonicalization.

Public data stays fresh at the edge for 30 seconds, with no stale-while-revalidate; browser responses revalidate. The HTML reads the backend directly through the same Worker helper, avoiding stacked JSON/HTML cache ages. Making a project private, hiding an Item or Initiative, switching the plan to members-only or switching Lane titles off can leave a previously public response reusable for at most 30 seconds after the last pre-change read completes. There is no purge call on a setting change. Already downloaded copies and open-page data are not recalled. Missing and failed backend reads use 30-second Cache API envelopes; JSON/sitemap visitors retain the real 404 or error status. HTML front pages instead serve the bundled plain SPA shell when public metadata, settings or cache access are unavailable. Worker responses get the enforced security headers (`site/headers.ts`), independent of an upstream page. The envelope is per location, expires without a timer and does not rely on caching an HTTP 5xx response.

Every viewer without a project role follows `convex/publicVisibility.ts`, signed in or not. `cliServer` query registration filters plan rows, bodies, comments, historical versions, reaction counts and Lane titles; journal re-entry applies the same filter. Members retain exact reads. The compact Plan settled pages retain positions without Item visibility metadata, so role-less Plan viewers use the existing bounded exact-root fallback; raw internal Plan page collections are not returned to role-less viewers. A non-member read reuses the current roots already loaded by the page. A selected history/comment Item and its parent/Initiative need at most four additional indexed root documents inside that same query, shared across the page; there is no board scan or extra Convex function call. Missing current roots fail closed; aggregate member planning totals are omitted from the workspace response. The public project page reads one compact week/main summary, ≤101 Lane marks, ≤3×300 open plan roots plus ≤200 Initiatives; explore ≤200 listed rows, profiles ≤100 and the sitemap ≤1,000. Missing, private and removed projects share one 404. Signed-out code and history (Item 4c164732) are `/public/v1/code/HANDLE/SLUG/…`, GET only, every argument in the path: a history page reads ≤25 receipts (≤256 KB) and leaves every actor out, so no person, Lane or Item id is returned; an address the source read would refuse (an unsafe or too-deep path) is a 404 before any function runs; a folder or file page is the members' source read with no identity, charged to the visitor's [limit](security.d/sections/0810-per-visitor-limits.md) and then the project's signed-out read budget, with the same checkpoint pins and access checks around the bytes; refusals and the budget keep their codes across function calls (404, uncached 429). A signed-in caller without a role on a private project gets `PROJECT_UNAVAILABLE` before any source lookup, the same answer as a missing project. Public JSON labels member text as data, never instructions. Weekly activity uses seven UTC day buckets in the existing main summary read/write, without a new landing call or document write. Before a full week of recorded coverage, counts say “recorded this week”; historical receipts are never loaded or silently estimated. Explore's cached activity note is written at most once per project per ten minutes when read. Stars require a signed-in person; only the owner person changes the Lane-title opt-in or sees stargazers.

`FORGE_PUBLIC_ABUSE_BUDGETS` accepts only `{ "deviceStartsPerMinute": 120 }` (a positive
integer override). The approved default is 120 starts per minute without any setting.
There is no anonymous clone budget or counter. Device starts use one point counter
read/write; accepted retries consume no additional start. Once sign-ins go through the
site, each visitor has its own [limit](security.d/sections/0810-per-visitor-limits.md) before this shared counter,
so one caller can no longer exhaust new-login availability alone. This is not an edge
traffic or total-spend ceiling. Signed-in Git retains the existing Worker caps. No landing
call, source byte placement or idle work changes.

GitHub Actions OIDC verification caches the fixed issuer’s keys for ten minutes,
shares in-flight refreshes, and refreshes for an unknown key at most once a minute.
Unverified token fields never choose a key endpoint. Source paths reject Windows
stream, device and filesystem alias spellings on every platform.

## Per-visitor limits

Signed-out source reads and device sign-in have a limit per visitor, so one noisy client cannot spend the budget every
other visitor shares (Item b6588425, owner numbers 2026-11-22). A visitor is a keyed hash of its network address.

| What | Per visitor | Outer limit (unchanged) |
| --- | --- | --- |
| Signed-out code reads that miss the site cache (folder, file page, changes, touched) | 60 an hour | 120 a minute per public project |
| Device sign-in starts and renewals, together | 10 a minute and 30 an hour | 120 a minute per deployment |

**Which paths go through the site.** Convex never sees a client address, so these requests pass the site's edge, which
reads the address from the platform's own request context:

- Signed-out code and history already go through the cached public read (`site/public-read.ts`, then
  `/public/v1/code/…`). On a cache miss the site Worker, and the code Worker behind file pages, forward the hash.
  The members' source actions (`projectCodeBrowse:read`, the rendered `projectSourceReview:read`) now refuse signed-out
  callers with `PROJECT_UNAVAILABLE`, so a client cannot skip the limit by calling Convex directly. No signed-out page
  used them. Signed-in reads are unchanged.
- `nforge login` and sign-in renewal post to `/auth/device/start-v2` and `/auth/device/renew` on the site
  (`site/device-auth.ts`), which forwards the request unchanged with the hash. The CLI still signs for the
  backend origin and tries it first; a backend that requires the site answers `421 use_site` with the site's origin, and
  the CLI sends the same signed request there once. An environment without the setting answers directly, as before.

**How the hash is keyed.** The edge computes HMAC-SHA256 over `forge-client-v1`, a zero byte and the address under
`FORGE_CLIENT_HASH_KEY`, which only the site holds; Convex stores only the 64-character hash. IPv6 is keyed by its /64,
an IPv4-mapped address as IPv4. The address is never stored, logged, forwarded or put in an error. Without the key,
stored hashes cannot be matched to addresses by trying them. A /64 is one subscriber's usual allocation; a holder of a
whole /48 still gets one budget per /64, which the outer limits then bound. Rotating the key resets every visitor's
window.

**Trust.** Convex accepts the hash only from the site: on `/public/v1/…` with the existing `FORGE_PUBLIC_READ_SECRET`,
on the device routes with `FORGE_SITE_DEVICE_KEY` (both compared as fixed-length digests). Once
`FORGE_SITE_DEVICE_KEY` is set on Convex, a direct start or renewal, or one with a wrong key, gets `421 use_site` and
runs nothing; a visitor key in the request JSON is ignored. A site that sends no hash (an older edge) is not charged
per visitor; the project and deployment budgets still apply. Addresses behind one NAT share a budget, as on GitHub.

**Refusals.** An over-limit read answers `429 RATE_LIMITED`, uncached, with "Signed-out reads from your network are at
their limit of 60 an hour. Sign in (nforge login) or retry in N min." An over-limit sign-in answers `429 slow_down` with
the wait in `interval` and a sentence the CLI shows. A refusal writes nothing: an over-limit visitor spends none of the
outer budget, and a call the outer budget refuses is not charged to the visitor.

**Cost.** Cache hits make no Convex call, as before (each is one site Worker request on the free plan); idle costs nothing. On a miss or a sign-in start the
charge runs inside the mutation that already serves it: one point read and one write on `deviceAttempts`, and a refusal
only the read. A new visitor's first row also deletes up to two expired rows (`by_expiresAt`), so rotating addresses
cannot grow the table; there is no job. No Convex call, table or CLI dependency is added. Code history, project, profile,
explore and sitemap reads are queries with no mutation to charge, so they carry no per-visitor count: they stay bounded
by the 30-second cache per address and location, the project's signed-out read budget and the site's best-effort
platform backstop of 60 a minute per IP and location ([public viewing](security.d/sections/0800-downloads-and-public-viewing.md)).

**Added latency (measured from one client in Europe on 2026-11-23, Cloudflare site).** Hashing costs about 18 µs per
request. A cache hit adds nothing. A sign-in start or renewal adds one site round trip: the site answered in a median
of 0.54 s to first byte on a new connection (0.49 s after TLS) against 0.09 s for a static file, so about 0.45 s for the
Worker, which runs near the visitor, and its hop to Convex. That is about 0.3 s more than the earlier Netlify function,
which ran next to Convex. Once the backend requires the site, the CLI's first direct call is the refusal round trip
(dev Convex median 294 ms server, 335 ms total). Sign-ins run once per login and renewals once per 30 days.

**Settings.** Site: `FORGE_CLIENT_HASH_KEY` and `FORGE_SITE_DEVICE_KEY` (with the existing `FORGE_CONVEX_SITE_URL` and
`FORGE_PUBLIC_READ_SECRET`). Convex: `FORGE_SITE_DEVICE_KEY`, the same value. The public code Worker forwards the hash
once redeployed. Roll out in this order: release the CLI, set both site settings and deploy the site, then set the
Convex setting; it switches device sign-in to the site, and unsetting it switches back. A CLI older than this release
gets the `421` sentence and must update (`nforge update`), so set the Convex setting only after the release has been
out. Rotating `FORGE_SITE_DEVICE_KEY` means changing it on both sides together; sign-ins fail with `use_site` in the gap.
A self-hosted site must point `FORGE_CONVEX_SITE_URL` at the same backend origin its CLIs use (`FORGE_HTTP_URL`),
because the signed proof names that origin. Not covered: signed-out CI output reads over the Convex client remain
charged only to the project budget.

## Web response headers

The hosted web app is sent with `X-Frame-Options: DENY`, an enforced `Content-Security-Policy`, `X-Content-Type-Options: nosniff`, `Referrer-Policy: no-referrer`, HSTS and a restrictive `Permissions-Policy`, set in `site/headers.ts` (as `_headers` for static files and on every site Worker response). The policy allows scripts only from the site, the inline theme script's hash, WebAssembly, Clerk and Cloudflare Turnstile (no `'unsafe-inline'` or `'unsafe-eval'` scripts), and forbids framing (`frame-ancestors 'none'`), plugins and a changed base URL. Zod runs jitless in the browser (`web/src/zod-jitless.ts`) so it never evaluates strings. `tests/web-headers.test.mjs` checks the block, that the inline theme script's hash matches `web/index.html`, and that the web entry loads the jitless setting first.

## Autonomy authority

Local CLI and MCP Channel acceptance, including the legacy Work command, is classified as an agent action. Embedded `WorkService` callers supply a trusted `AcceptanceActor` constructor context; command JSON cannot promote itself to a person. Direct native/Git acceptance uses the same policy checks. Local settings are owned by the OS user: any process with that user's filesystem authority can change them. `FORGE_ACTOR` is a self-declared label for local allowlists, not authentication or a sandbox. Use scoped device credentials for agents that require hosted policy enforcement.

Hosted policy changes require the current project owner. Forge has no general project maintainer role today; a guidance-maintainer assignment authorizes guidance only. Contributors may read policy and propose Candidates. Checked publication follows the project automatic-acceptance and exact-check rules, or explicit approval by the owner person. The owner chooses unchecked person acceptance in **Settings → Landing & checks → Who can land without a check**: **Owner only** (default), **Owner and chosen people or teams**, or **Owner and all write members**. People are picked by Forge handle and stored by account; teams are existing owner-managed teams, picked by name. A newly picked person must have current project write membership. Being listed or joining a listed team never grants write access: the person must still be a project write member when the final landing transaction runs. Removing write access, downgrading to read, leaving the selected team, or removing that team takes effect immediately, with no cleanup job. Agent credentials never receive this bypass, including the owner's and a selected person's credentials. Protected-path review and other existing acceptance rules still apply. Changes use the existing policy history, with Undo in Landing & checks. Browser account sessions count as people. Forge device credentials with `cli` scope count as agents and follow the project policy; `coordination` scope can never accept or set policy. A client actor/session label is not authority. Existing browser account JWT overrides retain browser authority, so use scoped device login for agents that need policy enforcement.

Private and public contributors follow the same check, review and protected-path rules.
Unchecked person acceptance follows the owner's selection above; agent credentials
always require an exact passing check. Explicit owner approval still reviews a
contributor's exact attempt. Receipts mark checked contributor self-acceptance as
automatic and permitted unchecked acceptance as a person's explicit action. An explicit owner-approval glob list replaces built-in
globs while retaining every defined check and setup entry file.

The server selects the landing check: the definition named `verify`, or the sole
definition when there is only one. Check-based publication with multiple definitions without `verify` requires
an explicit owner-person acceptance; unchecked person acceptance still follows
the selection above. Both solo and shared-batch publication
recheck this current selection; a submitted check id does not choose the gate.

The final hosted mutation is the unchecked-landing authority for web, CLI, MCP and agents. It rechecks current policy, caller authority and credential scope after source/evidence preparation. Checked landings, including disjoint evidence reuse, skip unchecked membership/team lookups entirely: zero additional calls, reads or writes; idle cost remains zero. Exact-Candidate passing checks, protected-path review and accepted-head preservation apply to automatic acceptance even on existing custom projects. Records include actor, policy, checked Candidate/run, action summary and undo instructions. Hosted run evidence is local-owner provenance and can be forged by that execution owner; policy does not create an independent execution attestation. Uploaded local policy never replaces hosted settings. All writers must be upgraded before a restrictive local policy is stored; format 11 prevents an older writer from ignoring it.

## Secrets for checks

Today, check definitions declare environment variable names in `env` and sensitive
names in `credentials`. Both select values already present in the runner process;
they do not fetch Secret Objects. Missing variables remain absent, rather than
failing setup by name. A CI secret must be exposed to that runner process by the
CI configuration. Forge does not perform a separate machine-key setup today.
Definition digests and receipts carry names, never values. Commands can still
print values into their CI logs; the future sealed-secret masking contract is
not implemented. See [clean check environments](#clean-check-environments).

The rebuilt **Settings → Secrets** page is value-free and currently shows that
sealed secrets are not connected. Its metadata-only interface covers names in
Development and Checks, holders, waiting computers, rotation state and recent
changes. It makes no secret reads or writes. There is no value field, reveal
control or public sample-data route. Proposed CLI commands are marked Proposed;
holder removal and sharing settings await the protocol.

The replacement store is sealed Development and Checks sets, tracked by Item
`41a0df87`. Slice 1 implements the owner's Development device, value entry from a
hidden prompt or stdin, name-only list/remove commands and `run` delivery. Other
recipients, sharing, proposals, passkey recovery, machine keys, Checks execution,
import and Secret Object retirement remain unimplemented. Gate A passed; Gate B
is a separate code review after sharing. No database-wide confidentiality claim
applies while legacy Secret Objects and their server keyring remain.

### Sealed Development core

`nforge secret set NAME [--file]`, `nforge secret list`, `nforge secret rm NAME`
and `nforge secret repin` use a stable device sign-in. Values never belong in
arguments or replies. `--file` makes the stdin/prompt value a file-shaped secret;
`run` supplies its private temporary path. Stdin bytes are kept exactly, including
any trailing newline. Agent markers and non-interactive input permit new names
only; changes/removals require a person until the proposals slice. The server's
storage gate requires the owner account's unrestricted stable device credential;
value authority is the owner device signature in the verified roster. Legacy
Secret Objects keep their existing owner-person gate.

Device signing and agreement keys are independent. Their account binding, set
keys, wraps, padded values, hiding value commitments, per-name change signatures,
roster history, former signers, tombstones and signed heads use purpose-separated
format-v1 frames. Project/account protocol IDs are independently derived from the
Forge IDs, with separate purpose labels; a server-supplied protocol ID is never
accepted as the requested project's identity. Known-answer fixtures cover these
layouts independently of the signing implementation.

Dropping a tombstone can raise the set's version floor while existing live names
keep their versions. A new change starts one above the higher of the name's
current version and the floor of the verified head used for the write, including
any compaction in that write.

Device secret keys are kept in a private file: 0600, in a 0700 configuration
folder, outside projects and Lanes. On macOS (`/usr/bin/security`) and on Linux
with a session bus (`secret-tool`), that file (`device.kc`) is AES-256-GCM
encrypted under a random 32-byte key held only in the OS keychain. The key reaches
the tool through stdin, never in arguments: an interactive-mode command line for
`security`, the secret input for `secret-tool store`. A command reads it once and
keeps it in memory for its lifetime; pin updates rewrite only the encrypted file.
An existing plain `device.bin` moves after the keychain returns the stored key and
the encrypted file decrypts to the same keys and pin counter; only then is the
plain file removed. Any failure keeps or writes the plain file, removes any
keychain item it wrote, and retries a day later. If both files exist (an
unfinished move, or a plain copy restored from a backup or sync), the record with
the higher pin counter wins; a plain file for a different device is refused and
both are kept; when the keychain cannot be read, the plain file is used and the
encrypted copy is kept. Each keychain call is killed after 5 seconds and runs
without a terminal, so a headless run cannot hang on an unlock or access prompt.
Once keys are only behind the keychain, a session that cannot read it (SSH, cron,
a sandbox without the session bus or `securityd`) fails with
`SECRETS_KEYCHAIN_UNAVAILABLE` and never creates new keys. To use such sessions,
run one command from the desktop session with `FORGE_SECRET_KEYCHAIN=off`: it
moves the keys back to the private file, deletes the keychain item, and no later
move happens while the setting is off. Unsupported systems and tests keep the
private file. Only absolute tool paths are used. Re-login retains these keys.
What the keychain protects: an item that `security` creates trusts
`/usr/bin/security` itself (Apple's security(1) manual: "By default, the
application which creates an item is trusted to access its data without
warning"), so any process running as your user can read it by running that tool.
An unlocked Linux Secret Service collection likewise answers any process on your
session bus. The keychain therefore protects device keys against copies of the
disk, backups and synced folders, not against an agent or other process running as
your user. Local keys are binary buffers and are not passed in process arguments.

Pins are MAC-authenticated per project/kind, with an account/device index and a
counter kept beside the device keys. Writers use one exclusive lock file with
PID, process-start marker and random token; only a dead holder's matching token
may be reclaimed. Lock contents are fsynced before an exclusive hard-link
publication; dead reclaim gates are recoverable, and incomplete legacy locks
become reclaimable after 30 seconds. Completed candidate files left by a crashed
holder are swept only when their token matches and their recorded process is
dead; live, incomplete or unidentifiable candidates are preserved. Readers use atomic snapshots and re-read
under that lock before
reporting lost trust. Writes use private temporary files, fsync and atomic rename.
Device-key startup removes unpublished device-key temporary files under the same
lock, preserving the published key file.
Network calls never hold the lock, and a response is re-verified against the latest
pin before publication. Unchanged verification changes no pin, index or counter.
Restoring one kind after index or counter recovery keeps every unchecked sibling
kind lost until it is restored independently. Lost-kind identity survives later
writes, and rebuilding never resets counters below an earlier publication.
These file-store/lock deviations remain explicit Gate B review items.

A local retry journal retains only the exact sealed request while its outcome is
unknown, in 0600 files within the same 0700 configuration folder. Journal writes
share the pin lock and use temporary files, fsync and atomic rename. Acceptance
immediately compacts a request to a value-free receipt (operation ID, project,
name, action and accepted head hash); confirmed refusals delete it. The cap is
64 entries, each at most 768 KiB (48 MiB total). Oldest confirmed receipts go
first; unresolved requests are never silently dropped. A full unresolved journal
returns `SECRETS_JOURNAL_FULL`. Run `nforge secret resolve --operation-id UUID`
for each retained unknown operation: a matching change signature in the verified
current head confirms it; otherwise a person may explicitly discard that local
request, including when current access is unavailable. Cancelling keeps it. A
discarded operation ID must never be reused; repeat a missing change with a new
operation. This provides a way out of a full journal without silently dropping
unknown requests. Agent entry points cannot approve discards. Replaying a retained
confirmed receipt rechecks current access and writes no secret. A supplied retry
value must match the retained ciphertext, or the original confirmed head while
that exact head is current; otherwise `WORK_OPERATION_REUSED` refuses it. Use
`secret resolve` to inspect a confirmed receipt without supplying a value. An
unknown replay uses its original sealed
bytes; if the server's 50-event window can no longer establish the outcome, it
returns `SECRETS_WRITE_UNKNOWN`, never an automatic new seal. Run
`nforge secret list` to see the current head, then repeat the change as a new
operation if it is missing. This bounded local journal is also a Gate B item.

Deleting or restoring old pin files does not reset first-contact trust. A person
can use `secret repin` only when loading that project/kind under the lock reports
`SECRETS_PIN_LOST`, to confirm a view signed by this device after seeing its
date, device fingerprints and the possibility that it is older. Other cases need
a holder confirmation in the sharing slice. Rebuilding one project's trust keeps
other missing projects marked as lost. A rebuild checks this device's own head
signature with the public key from its local key store and starts at that signed
roster; it does not require this device to have created the set.

The verifier refuses a first-seen set without an explicit typed journey anchor;
served roster bytes or a copied public device entry grant no trust. The owner
CLI supplies only its locally held device identity as an own-genesis anchor:
that device must be the sole genesis entry and the signature chain must walk
from it. Retrying a retained sealed request checks this device's own signature
on that saved request against its locally held public key. Rebuilds verify
this device's own signed head. Checks
first contact uses an explicit genesis anchor named by trusted Development.
Development also uses its trusted Checks genesis pointer to verify the old set
in a signed Checks replacement proof when this device has no Checks pin. That
proof opens no Checks values. Current revocation markers apply to every step
being verified. For a walk from genesis that includes the full walked history,
so a marker for an early signer can prevent a fresh reader from verifying it.
Roster transitions are built with the same reconstruction and authority checks
that every reader runs; the genesis roster is kept apart and only the latest 64
transitions are retained, so a pin further behind gets `SECRETS_PIN_TOO_OLD`
with its pin unchanged. A step never removes or lowers its own signer, so a
device leaves a set through another device of that set. The rule
that each Checks owner's account has a full owner device in Development is
checked on the final Checks roster against this device's trusted Development,
not on each earlier step, so an honest co-owner's later removal does not lock
out lagging or new readers. The account in a device entry is asserted by that
device's own key, so this rule is a consistency check, not a trust boundary: a
listed Checks owner can add a device that claims an eligible account, and its
authority ends only when a Checks step removes it. Residual: a device whose Checks pin predates the
removal of a Checks owner device, or that walks Checks from genesis without a
code, can be shown a forked Checks history by that removed device with the
server's help, even when the removed device's account has since left
Development. A holder accepts it and may seal new Checks values to the forger;
a non-holder sees names only.
A passkey contact needs a person-signed checkpoint
with matching roster bytes and the public keys derived locally from its seed;
a listed person entry alone grants no trust. A missing checkpoint or a walk
outside retained history requires holder confirmation. A device that joined
Development automatically uses the `automatic-join` anchor (Sealed Automatic
join); other joined devices without a confirmed anchor remain refused. Code
sharing, passkey browser delivery and Checks delivery are not available yet. Pins protect subsequent reads, including the
ciphertext-only offline cache. A compromised server can withhold records or keep
an offline device on its last verified view. No decrypted cache is written.

### Sealed Automatic join

A new Development set starts in Automatic sharing (owner decision 2); an owner can
switch it to Confirm. Automatic exists for Development only: the CLI checks the
kind with a constant, and the server refuses a join request for Checks or
Production with `SECRETS_NOT_ALLOWED`. A Checks recipient always needs a person.

When a write member's device with no Development pin runs `nforge run` or any
sealed read, and its account has no device in the set, it posts one join request
(`sealedSecrets:join`) and stops with `SECRETS_WAITING`, printing its own
fingerprint. The request carries the device's public keys and its signed account
binding, nothing else; display text is `new device`. The server decodes it with
the same portable code the CLI uses and stores it only when it names this project
and the caller's account, the caller is a write member on a stable device sign-in,
the stored roster is in Automatic mode, and the account has no entry. It keeps one
request per account (a newer device replaces it, the same bytes are a replay) and
at most 32. Only a roster step clears requests: the one that adds that device,
one that gives its account an entry, or one that leaves Automatic (which clears
all of them).

On its next sealed read, an owner device that holds Development plans one share per
waiting request, re-checking every field it signs: the device is not in the roster,
its former list or a removal marker; its account has no entry; the entry is a
member device added automatically (role member, `how` auto), never an owner, a
machine or a person entry; its fingerprint matches no listed, removed or planned
device. Machines and person keys never wrap. A device shares at most three times a
day, reserved under the local lock before any wrap is built, so concurrent runs
cannot exceed it. The new entry, the
transition, the set-key wrap and the next signed head go in one write. Every other
holder derives the notice from the signed step, so a server cannot hide the share
from a holder without forking that holder's history. The wrapping device keeps its
notice, naming the project, the fingerprint and Undo, across restarts and agent
commands until it is shown on a person's terminal. A share Forge refuses, reports
as not stored or never confirms stays recorded as unconfirmed: it keeps its daily
slot and its notice, because the set key left in that request. A refusal pauses
automatic sharing on that device for a day.

The joining device's next read accepts the served roster through an
`automatic-join` anchor only when it is Development in Automatic mode, its own
local join record exists, and the roster lists this device, with its own keys and
account, as an automatic member. Its pin records `confirmed: tofu`. Its first run
prints its fingerprint and its account's devices; later reads list them again when
they change. Every other first contact keeps needing an explicit anchor.

Undo is `nforge secret unshare FINGERPRINT` (an automatic device) or the full
32-hex device id (any device), run by a person on an owner device:
one write removes the device and re-keys the set (new set key, every value
re-sealed, a wrap per remaining recipient), then prints the names to rotate at
their provider, because the key was handed over. Repeating it after an unknown
outcome reports the device as already removed and prints the same list. See Sealed removal and rotate list for the other routes.

Residual, accepted with owner decision 2: the joining device trusts that first
roster on first use. A compromised server can show it a fake Development set built
for it and, separately, add a device of its own for any account that has no device
yet; the only cross-check is the fingerprint the waiting device, its first run and
the holder's notice print, 40 bits that a server grinding keys (about 2^40 tries)
can match. Keep in Development only credentials the team could
rotate in an afternoon. A tofu pin never upgrades itself (a rebuild from the
device's own head keeps it when its signed entry was added automatically), Checks
never accepts this anchor, and a tofu Development pin is refused as the trusted
Development for any Checks read. `SECRETS_WAITING` is not retried in a loop: each
try reads the whole set.

A sealed write whose arguments fail the server's argument check (an older CLI
against a newer server) stops with `CLI_UPDATE_REQUIRED`: nothing was stored, the
retry journal drops the request, and the change is repeated as a new operation
after `nforge update`.

### Sealed codes, confirmed pins and roster repair

A device that has no trusted way to a set uses a four-word code with a two-word reply
(design 4.13). There are four purposes: add a device, raise a member device to owner,
make a Development device a Checks proposer, and re-pin a lost or too-old view. The
requester fixes the roster view it holds before it draws a 16-byte nonce. The code is
the first 44 bits of scrypt (N=2^17, r=8, p=1) over the framed request, read as four
words from the fixed 2,048-word BIP-39 English list (MIT notice in `src/sealed-words.ts`).
The reply is the first 22 bits of SHA-256 over what the holder signed, read as two words.
Typed words match by whole word or 4-letter prefix, in any case. Input that does not parse
costs no attempt. A wrong entry costs one, and the third closes that side
(`SECRETS_CODE_CLOSED`). A closed request keeps no nonce; the person starts a new one.

The holder must be a person (`PERSON_REQUIRED`) at a terminal with a confirmed pin of the
same set. It approves only on its own current roster, from a server read verified in that
process, and each read approves once; a Checks approval also needs a fresh Development read. A
stored, offline, already used or self-written pin is refused (`SECRETS_NOT_ALLOWED`).
A request at any other roster version or hash is refused (`SECRETS_CODE_ROSTER_MISMATCH`)
and the new device starts a new request after both read again. An older view the holder
once trusted is refused too: it could still list a device removed since. Only on a
matching code does the holder sign the transition, proposer head or re-pin statement. The
requester checks the signature, then derives the reply from those exact bytes. A staged
approval on any other roster gives a different reply. Only a matched reply mints a code
anchor for the verifier, and the anchor is what the holder signed: for add and raise the
roster after the approved step, for proposer and re-pin the roster the signed head names.
The verifier requires the served chain to pass through that roster; an older one is
`SECRETS_ROLLBACK`. Proposer and re-pin also treat the holder's head as a floor: a lower
head is `SECRETS_ROLLBACK`, and another hash at that version is `SECRETS_FORK`. A re-pin replaces only a lost or too-old pin. A pin
that still verifies is never replaced (`SECRETS_NOT_ALLOWED`). "Too old" is judged
against the holder-confirmed view, which must be more than 64 roster versions ahead,
never against the served history alone. A server that drops one transition cannot make
a healthy pin replaceable. A readable old pin also stays a floor
(`SECRETS_ROLLBACK`). Before typing, the holder sees what a match grants: the request's
claimed account handle, its device name and fingerprint, and the role it would get. The
account is the request's own claim, so it is shown, not trusted.

Every Checks and Production pin records how it was confirmed: `code`, `holder`, `machine`
or `none`. A pin from a walk-only Checks genesis anchor is `none`. It shows names but
opens no wrap (`SECRETS_CODE_NEEDED`). Its holder cannot approve a code, propose a value
or post a join request. Approving needs a `code` or `holder` pin. Wraps are made only
from a key the verifier opened on a confirmed base, or at genesis. A code upgrades the pin only after the reply
matches. Code paths enforce the proposal and join gates (`requireConfirmedBase`). A
source guard test fails in either of two cases: code that builds a proposal or join
skips the gate, or a new wrap producer or code-anchor minter appears unreviewed. Adding any
Checks or Production recipient needs a person, both in the transition builder and in the
holder approval.

Repair (GB-08 d5). A Checks or Production roster can break the cross-set rule because
of a later Development change, with no Checks write at all. Its values stay refused on
read (`SECRETS_ROSTER_REFUSED`). One write is then allowed. A person on a full owner device
of that set repairs it: the device's own account must still have a Development owner
device, and its pin must come from at or before the breaking roster. Repair verification
runs every check except the final cross-set rule. The result is never pinned, never
handed to `run` or `list`, and never cached. The set key is opened only to re-seal. The
repair removes each offending device and everything it added, transitively through
`addedBy`, unless the person keeps an entry by name. A kept name must match exactly one
entry in the roster, or the person names it by id. An offending device is never kept.
Proposer approvals that a removed device made are dropped. Values that a removed device
wrote are listed for review. The repair also drops pending proposals and
re-keys in the same signed step: a new key, every value re-sealed with its version,
signature and commitment kept, a wrap for every remaining recipient, and a new head the
repairer signs. Readers, including fresh ones, walk through the broken roster to the
repaired one. A healthy roster has nothing to repair (`SECRETS_NOT_ALLOWED`). If no
Checks owner device passes the rule, the error names the only way out: replace the
Checks set from a Development owner device (4.18). Members then confirm their proposer
code again.

These are client foundations. The sharing commands that drive them ship in later slices.

### Sealed removal and rotate list

Removing an entry from a sealed set is one owner-device write that removes it and
re-keys the set: a new set key, every value re-sealed with its version, epoch,
author and signature kept, a wrap for each remaining recipient, and the next head.
A removed device cannot open anything written from then on. It keeps what it
already opened, so every removal prints the rotate list: the names it could open,
to rotate at their provider. A person runs it; an agent is refused with
`PERSON_REQUIRED`.

There are three routes to that one write:

- `nforge secret unshare FINGERPRINT` removes an automatic device (guard 7), and
  `nforge secret unshare DEVICE_ID` (the full 32-hex id) removes any entry.
- When a person loses write access to the project (an owner removes them, lowers
  them to read, or they leave), the server marks every entry of their account in
  each sealed set of the project and drops their waiting join request, in the same
  mutation. Holders see the marker on their next read, with the fingerprints. The
  next `nforge secret set` or `nforge secret rm` by a person on an owner device
  removes the marked entries and re-keys before its own change, and prints the
  rotate list. `nforge secret unshare --marked` does the same at once. An agent's
  write is refused with `SECRETS_REKEY_PENDING` while markers name entries, and
  automatic sharing waits until they are removed.
- A team change marks the same way: removing a member or the member leaving the
  team, unlinking a write team or lowering it to read, and deleting the team. Each
  member who has an entry or a waiting join request and no longer writes the
  project is marked; a member who still writes through a direct grant or another
  write team is not. Removing or leaving marks in the same mutation. Unlinking or
  lowering checks the first 100 team members in the same mutation and the rest in
  scheduled steps of 100. Deleting is the exception: the team stops granting at
  once, and its purge marks each write link's members in steps of 100 before that
  link goes. In both delayed cases the people already lack write access, so they
  cannot read a sealed set meanwhile.
- Trashing a project revokes every grant but the owner's, and a restore brings
  none back, so the trash marks every other account its sealed sets list (an
  entry or a waiting join request) in the same mutation. The markers outlive the
  restore: a marked device opens nothing even if its person is invited back, and
  the owner's next person write removes and re-keys. Machine entries name no
  account and are never marked. Permanent deletion purges the sets and their
  history with the project's rows.
- Ending one device's sign-in from elsewhere marks that device alone, so a lost
  laptop is removed and re-keyed on the next owner write and its rotate list is
  printed. Signing a device out in Account settings, or removing it there or from
  the device, marks it in each project where that sign-in is linked to a sealed
  device, and drops its waiting join request. The first four projects are marked
  in the same mutation and the rest in scheduled steps of four; the sign-in has
  already ended, so the device cannot read a set meanwhile. The server links a
  sign-in when it writes a sealed set or asks to join one, and a device that only
  reads links itself once per project after its first verified read, when the
  read reply says it has no link yet. Only an entry of the sign-in's own account
  is marked. `nforge logout` on the device itself marks nothing: the person holds
  the device and its keys stay for its next sign-in. The set's last unmarked owner
  device is never marked, because no device could act on it. "Sign out
  everywhere" with devices (Account settings, by passkey or a fresh GitHub check)
  marks every sealed entry of the account, owner devices included, in every
  project where one of its swept sign-ins is linked, including sign-ins already
  ended by `nforge logout`; a sign-in issued after it started is kept. It is
  issued from a browser, which holds no sealed device, so no device is spared as
  the issuer. When the account holds every owner device of a set, that leaves
  none unmarked, so the device at hand clears its own mark: sign it in again
  (`nforge login`) and approve it in the browser that pressed "Sign out
  everywhere", after a fresh passkey or GitHub check there; the approval page and
  the checkbox hover say so. That action ended every other browser session of the
  account, the lost laptop's included, and keeps only the issuing one (the GitHub
  route keeps the fresh session it opens in that tab, and a GitHub check from it
  hands the role to its new session). The role lasts a week. A device approved in any other
  browser stays marked, so whoever holds the lost laptop signing in first clears
  nothing. Only an owner-role entry of the account is cleared, only while no owner
  device of the set is unmarked and the account still writes the project, so at
  most one sign-in per set is cleared; the set records it, so the sweep's later
  marking steps leave it alone, even after a write. Its next owner write removes
  the other marked devices and re-keys, with the rotate list. An approval that
  runs before the sweep's marks reach a set, or from a sign-in not yet linked
  there, clears nothing in it: the device reads the refusal and is approved again. A later sweep or an operator
  suspension voids the issuing browser, and a new sweep makes its own browser the
  issuer: if the issuing browser was signed out meanwhile, sign out everywhere
  again from the browser at hand. Residual: anyone who passes the account's own
  passkey or GitHub check can also sign out everywhere and become the issuer; a
  lost laptop holding a synced passkey or a live GitHub session is that case, so
  remove its passkey and end its GitHub sessions first. Approving a device code
  someone else sends you in the issuing browser clears that device, as for any
  device sign-in. Marking runs in scheduled steps, and
  the result is the same in any order.
  suspension signs devices out and marks none: it is a reversible switch. A device that
  was marked and signs in again reads `SECRETS_ROSTER_REFUSED` saying Forge
  marked it, until an owner device removes it. After that it is shared again:
  automatically under Automatic when its account has no other device in the set,
  otherwise from that account's other device with a code. One sign-in tracks at
  most 100 projects; at that bound links to deleted projects are dropped, and a
  sealed write or join in a further project is refused with `SECRETS_NOT_ALLOWED`.
- A marker that names no entry of the roster asks for nothing. A marker on the
  holder itself or on a machine is never acted on: the notice names a machine,
  and only `nforge secret unshare DEVICE_ID` removes it. A marker on another device
  of the holder's own account is acted on like any other (a lost laptop of the
  same person).
- Only an owner device removes another account's entry, marked or not. A write
  member's device removes only its own account's entries, so no roster step ever
  depends on a marker, which the server clears with the step that acts on it.

Markers are a request: the server changes no signed record itself. A removed person
cannot read the set from Forge at all, because the read checks project write
access. Removing a person also drops their waiting join request, and the server
refuses an automatic addition whose join request is no longer waiting, so a share a
holder signed from an earlier read cannot add a device of someone who has just left.

Residual: holders act on a marker without asking. A compromised server can mark a
member who is still in the project, and the next person write removes that member's
entries in a signed step; adding them back needs a code (an account left with no
device counts as new under Automatic). Every holder sees each marker on its reads and
each removal it made. A compromised server can also mark another device of the
writer's own account, which is removed the same way, and can mark the last owner
device (the last-owner rule is the server's, which a compromised server can skip),
leaving the set with no device that can read it. It cannot make a device remove
itself, and cannot stop a removal from re-keying.

The rotate list is derived from signed records only: each live name whose value has
not changed since a removed device's last epoch, with that device's fingerprint.
`nforge secret list` prints it on standard error until each value is changed, which
seals it at a later epoch and takes the name off. Nothing is stored for it. A removed
machine or person key has no former-signer record, so its rotate list is printed
only when it is removed.

The server's markers reach Development, Checks and Production. Checks and
Production removal (owner devices and machines, in the cross-set order of design
d1) arrives with Checks delivery; today only Development converts markers.

Cost: removing a write member adds one indexed read for their grant, one per set
kind (at most three) and one patch per set it marks; removing a reader adds only the
grant read. A team change adds, per project it gives write to, one empty
indexed read per set kind when the project has no sealed set, and reads no team
member. Only a project with a set reads team members, at most 100 per mutation,
and checks write access only for the members its sets list. Trashing a project
adds one empty indexed read per set kind when it has no sealed set; with sets, it
reads no grant or member and patches each set it marks. Ending a device sign-in
that never wrote or joined a sealed set reads nothing more; one with links reads
each linked project's set kinds (at most three each) and patches each set it
marks. "Sign out everywhere" adds no read to its sweep pages. It covers every
swept sign-in with links, including ones signed out earlier, and marks each
(project, device) pair of a page once, in steps of up to 100 pairs (at most one
step per swept sign-in); each step reads the set kinds of four projects at a
time and patches each set it marks. The sweep start writes its issuing browser and
epoch on the account row it already patches. A device approval reads nothing
more unless it is in that browser with a fresh check and the device has links;
then it reads each linked project's set kinds (four projects in the approval,
the rest in scheduled steps of four that re-read the account row), the project
row and its write check only for a set it clears, and patches each such set. The
approval page reads the account row once for a known device with links. A sealed write or join patches its sign-in once, the first time per project
and device, and reads nothing more. A read tells an unlinked sign-in so from its
credential row, already read; that device then makes one link call per project,
once (one set read and one patch). A removal write is one read and one write, at
most once per marked batch. Idle costs nothing.

### Sealed storage gate

The sealed write mutation takes the project, set kind, operation ID, the signed
payload, the genesis roster on a first write and at most one roster transition.
Everything else it stores comes from the payload. It decodes the payload with the
same strict schemas and portable format code the CLI uses (`src/sealed-portable.ts`
has no Node built-ins, so it runs inside a Convex mutation) and derives the head
hash, head and roster versions and set ID from it. The head and roster must name
this project, kind and set, and the head must carry its roster's version and hash.
The compare-and-swap compares the head's own previous-head hash with the stored
head. A first write needs the all-zero previous hash and stores its own
version-one roster as genesis, which never changes.

The server keeps the history ring. It appends a write's transition only when it
starts at the stored roster's version and hash and ends at the signed head's
roster, and only when its delta is that change: every removed device is absent
from the signed roster and every added one is present. A roster change without its
transition is refused, and a client never supplies the ring. A first head starts an
empty ring. The ring keeps the newest 64 steps that fit its 128 KiB record.

Removal markers and join requests are server-owned fields of the set record. A head
write cannot carry markers or proposals, or nested previous or related replies with
their own markers; the replacement flow will fill those from the server's markers on
the old set. Every read reply returns the server's
markers and join requests, including an unchanged-cache reply. A transition that
removes a device clears that device's marker, and one that adds a device clears its
join request; a step also drops requests it made stale (an account that now has an
entry, or every request once Development leaves Automatic). Nothing else in a head
write changes them. Join requests are posted
by the join mutation (Sealed Automatic join); markers are placed when a person
loses write access to the project (Sealed removal and rotate list).

The record transport header must round-trip as exact UTF-8, so the decode refuses
invalid bytes and a byte-order mark the same way in Node and in Convex, with no
decoder options.

Roster entry checks test each X25519 key with a fixed public probe scalar. X25519
clamps every scalar to a multiple of the cofactor, so a fixed scalar refuses each
low-order key exactly as a random one would, and the check needs no random source.

The server opens no value, holds no key and does not yet check signatures. It
accepts writes only from the project owner's stable device sign-in. Member
writes stay off until the server also verifies the public signatures with the
same code. Clients verify every reply in full and rely on none of these checks.

### Run process boundary

`nforge run [--root ROOT] [--set development|checks] [--only A,B] [--show] -- COMMAND [ARGS...]`
resolves the containing clone or Lane root. The CLI reference is generated from
its help at site build time. There is no plaintext stub-input flag or alternate
secret store. Development uses the same verification entry point for network and
cached records. Checks delivery remains outside this slice.

The process boundary enforces these rules:

- Only names in the root `.env.example` can be injected; `--only` can narrow them.
  The file must be a regular file with exactly that spelling. A symbolic link or
  directory fails with `SECRETS_ENV_EXAMPLE_NOT_FILE` before reading the provider
  or starting a child. A case-only spelling such as `.ENV.example` is reported by
  name and contributes no names. It accepts `NAME`, `NAME=value`, `export NAME=value`, blank lines and
  comments, including inline comments. Example values are ignored; duplicate
  names are used once. Refusals and missing-value/not-yet-listed notices name the
  variable and never its value. A missing file supplies no names.
- Names match `[A-Z][A-Z0-9_]{0,63}`. Release-owned deny, routing and credential
  exception lists live in `src/secret-names.ts`; they are not complete. The order
  is exact deny, exact exception, exact routing, the single Cargo token exception
  pattern, deny patterns, routing patterns, then plain names. Thus
  `CARGO_REGISTRIES_X_TOKEN` passes while its `_INDEX` and `_CREDENTIAL_PROVIDER`
  neighbours do not; `NPM_CONFIG_PROXY` is denied, and `PIP_INDEX_URL` and
  `NODE_EXTRA_CA_CERTS` are routing. Routing writes require a person in the
  shared name validator. Its value-free write boundary prints one line for each
  exempt publish-token name written to Development: it is a publish token and
  belongs in Checks. `NODE_ENV`, ordinary names and writes to Checks produce no
  such notice; using a token through `run` produces none. Set uses this boundary; import and proposal apply remain pending.
- The inherited environment wins, including case-insensitive comparison on
  Windows. Before injection the child loses Forge credentials and session
  material: every `FORGE_*` and `NFORGE_*` name and known agent session id, except
  `FORGE_GIT_TIMEOUT_MS`, `FORGE_CHECK_FULL`, `FORGE_CHECK_SCOPED`,
  `FORGE_MAX_CONCURRENT_CHECKS`, `FORGE_CHECK_QUEUE_DIR`, `FORGE_DISK_WARN_GB` and
  `FORGE_DISK_BLOCK_GB`. These are runtime controls, not credentials.
- Checks machine delivery requires `--only` or a supervisor declaration. This
  limits what is handed over. A same-user child can still read its parent's
  startup environment; this process boundary is not OS isolation.
- Piped stdout and stderr mask injected values of at least eight characters as
  `[secret:NAME]`: raw, URL-encoded, JSON-escaped, hex, base64 and base64url at all
  three alignments. Multiline values are masked whole and line by line (lines
  shorter than eight characters pass). Each stream keeps at most the longest
  encoded form minus one byte across chunks. An agent marker, agent entry point
  or MCP keeps masking enabled even with a terminal. A person can use `--show`;
  an agent cannot. Masking stops accidents, can test a guess, and cannot prevent
  code deliberately disclosing a value.
- File values use a private folder outside the tree and declared kept-output
  paths, under `/dev/shm` on Linux or the private temporary area elsewhere.
  Folders are `0700`, files `0600`. Normal exit, startup failure and handled
  signals remove the folder; the next run also sweeps folders whose owner
  process is gone, including after SIGKILL. Live or unknown owners are retained.
  No value file is written into source, caches or archives. Buffers supplied by
  the provider are cleared after delivery.

New policy presets and projects without a stored policy protect root
`.env.example` by default, through the existing protected-path approval rules.
The match includes case variants; other protected globs retain their existing
case sensitivity. An owner's explicit `acceptance.protectedPaths` list wins and
can opt out. No existing stored policy is rewritten. Per-added-name owner alerts
are still part of the later import/landing slice, including when approval is off.

These helpers add no hosted calls, database I/O, retained records or idle work.
Masking memory scales with value encodings and one carry per stream; file bytes
are temporary only. The scriptable test backend records synthetic replies and
conditional writes. The hostile-server harness exercises the real verifier with signed synthetic
fixtures; this does not replace Gate B. The per-added-name owner-alert acceptance case is separately deferred
to slice 3, including alerts when protected-path approval is off.

### Secrets screen trust boundaries

The route inherits the signed-in project frame. Its current provider is a local
unavailable stub, with zero Convex calls, DB I/O, storage writes or idle work.
Fixtures are confined to tests. A later server adapter must authorize current
project write access before returning names, holders or history, including on a
public project; browser state is not authorization. It must project only the
metadata contract, never values, envelopes, ciphertext or keys. Failed reads must
not render raw server errors, retain another project's data or preserve names
after access is revoked. The screen's forbidden state renders no cached metadata.

Metadata is untrusted text: React escapes displayed strings, never renders it as
HTML, and clipboard actions construct quoted name-only commands without executing
them. The clipboard is an explicit user-action boundary. No secret metadata is
written to local storage, logs, receipts or a URL. This screen is not evidence of
the future database/backup no-value guard, cryptographic revocation, hostile-server
protection, output masking or the export/retirement sequence. Those need the gated
protocol, its adversarial tests and security review before they can be claimed.

## Secret Objects

A Secret Object is an encrypted credential with versions and six independent capabilities: discover, names, use, reveal, modify and delegate.

- Versions are sealed with AES-256-GCM under the keyring in `FORGE_SECRET_KEYS`.
- The only broker operation reads one fixed GitHub repository and ref. It rejects redirects and returns only the commit SHA, version and time. Policy and version are rechecked after the provider call.
- Checks, Playbooks and repository code never receive a stored secret.
- Delegated grants depend on the current authority of every issuing delegate in their chain. Revoking a delegate also revokes their transitive grants; expiry invalidates the chain immediately, before scheduled cleanup. Re-granting access does not restore revoked descendants; restoring them requires new explicit grants. Revocation confirmation previews the affected recipients and capabilities, pinned to the policy revision; cascaded removals are audited without values.
- Successful use, reveal and configuration changes are audited without the value. Denied and failed attempts are not stored.
- Backend administrators, the keyring owner, the OS and GitHub stay trusted.
- Recovery needs the original keys. Losing an old key makes its versions unreadable.

Devices need write access to all projects to create, rotate, grant, disable or
move a Secret Object to trash. Permanent deletion requires the owner person in a
Forge browser. Existing object capabilities still govern each operation.

Dotenv import creates a Secret Object and a value-free example file. It does not erase committed history or rotate the provider's credential. Rotate an exposed credential at GitHub first.

## What archives contain

Full source and Work archives hold complete retained history, run logs and selected build outputs. Listing and downloading full Work archives, checkpoints and legacy exchange parts requires current owner or contributor membership, including on public projects; reader grants and public visibility do not grant archive access. Plain accepted-source clones use State/source reads and do not need the Work checkpoint. They are not filtered by Zones and are not scanned for committed credentials (the landing scan sees only each landing's changed paths). Treat them as private. Git bundles and accepted-source clones carry full tracked history, including any committed secret.

Restoring an archive writes only named regular files into a fresh directory. It runs no hooks and does not start recorded checks. Interrupted runs stay interrupted. Ignored credential files and local configuration are not part of recovery. Hashes show the bytes are intact. They do not show who wrote them or confine execution.

Imported Git authors, timestamps and signatures are unverified claims. Comparing Candidates disables Git external diff, textconv and lazy fetch. Merging a contribution bundle copies and hash-checks it without hooks, alternates, network or credentials.

Netlify draft delivery publishes the build files you pick, using your local Netlify login. It does not run code from the target project. A successful upload says nothing about application health.

Hosted record projections and check-output reads redact local machine paths and local browser links. New owner presence and header reports redact these fields before retaining their delivery payloads. Personal cleanup lists check current GitHub and Forge access before returning repository locations, retaining cleanup identities after access loss. Actor labels require current project membership or server-retained evidence of an ended membership; cached names and imported actor declarations alone do not establish membership. Removed imports disappear from personal saved views and interests immediately. Server-retained membership provenance (not a name) survives membership removal, giving a quiet former-member label in activity, sessions and review attribution; Forge stores no provider display name, and default device, runner and machine labels never come from the hostname.

Full Work/evidence object and archive exchange still retains original bytes, which can include local paths. Generic redaction changes recorded command digests and conflicts with original local metadata during reconciliation; full transport redaction is not implemented in the current contract. Previously pinned deliveries retain their original retry bytes. Record projections do not rewrite stored rows or immutable objects. Displayed check commands can be redacted while their definition and environment digests continue to identify local originals.

Hosted Intent generation migration accepts unified Work formats 16 and 18. It
stages the replacement index before selecting it, retains the previous generation
and original backup/journal, and retries against concurrent journal or checkpoint
changes. Format 18 preserves landing entries and batches. Native and Git exchange
carry unified Intents, including those without a Lane, without down-projecting
them to legacy execution records. Deploy these hosted readers before upgrading
exchange writers or requesting hosted Intent migration.

## Passkey handles

The current Forge handle is the passkey sign-in name. The server applies the
same handle syntax and reserved destinations as account settings. A successful
registration claims its chosen handle in the same transaction, and an existing
Forge handle cannot register a second account. Existing accounts can add a
first passkey under their own handle. Changing a handle also changes its passkey
sign-in name; old URL aliases stay reserved and do not sign in. Identifier-first
sign-in retains the existing handle availability responses; it returns no
additional account profile or provider information.

## Passkey request budgets

Passkey challenge starts have a deployment-wide allowance of 120 per fixed
60-second window and 6 per exact handle. Passkey sign-up finish attempts have
an allowance of 20 per window and 3 per handle. Autofill has no handle yet and
shares the global start allowance. Convex supplies no client address, so the
global budgets are shared across visitors. These are interim defaults; the
phase 8 sign-up admission policy remains an owner decision.

The server charges in the ceremony's mutation and returns the existing
`RATE_LIMITED` error before any writes when an allowance is exhausted. Two
rows in the existing attempt-counter table reset on demand and contain at most
120 and 20 handle counters respectively. Neither rows nor per-handle entries
grow across windows; there is no polling, cleanup worker or idle work.

## Attaching account sign-in methods

An existing-provider session can enroll a passkey on that exact Forge account.
The Devices screen reads display metadata from the account index in 20-key
pages. It automatically reads another page when more keys are present.
Each action verifies the session is active with its provider; each granting
mutation checks the caller's issuer, account and session proof. Existing passkeys
confirm additions. A live Convex Auth session can attach GitHub after passkey
confirmation when present and the library's completed state/PKCE round trip.
Only the provider-attested numeric id is used. App and component identity
ownership are checked transactionally; conflicting accounts are never merged.
Successful grants and their secret-free audit receipts commit together. Retry
receipts prevent duplicate grants; GitHub tickets remain single-use.

These browser flows do not establish ownership of non-provider agent/bot keys.
Existing CLI access remains; long-term renewal and the deliberately unmatched
accounts need owner review before removal. Clerk remains configured. See
[the linking runbook](development.md#attach-sign-in-methods-to-an-existing-account)
for proof boundaries, retries, scale and the migration exclusion.

### Current verified addresses in the rebuilt sign-in

Each GitHub sign-in replaces both the address and verified flag from its current
profile. If GitHub reports no verified address, Forge clears the old address and
flag, including on the linking path. Each such write also records when GitHub
confirmed the address. The age applies only where access is granted (recipient lookup
for invitations, and invitation acceptance): those ignore an address
not confirmed in the last 90 days (counted from account creation for older rows)
until the next GitHub sign-in or link refreshes it. Protections that grant nothing
keep using the address at any age: invitation-mail suppression still finds the
account's blocks and revocations, and blocking still records the address. A passkey-only account has no
email-based invitation authority. The browser identity resolver supplies these fields from
the already-read account row, never from a stale token claim.

New-account recipient lookup uses an exact normalized verified address and refuses
ambiguous matches. Explicit invitation acceptance rechecks that unique current binding;
no unverified address accepts an email invitation. The retained provider path remains
until its separate removal checklist is complete. Browser-session management
checks the live session and a fresh account-bound passkey or GitHub proof before
revoking other sessions; no session id supplied by a client selects another
account's sessions.

Team email invitations check the exact current verified native binding and the
configured legacy provider comparison only when the recipient accepts; the
accepting transaction rechecks the native binding. Creation stores a pending
address without looking up any recipient. The owner's pending list shows the
typed target and state. Project membership also uses explicit acceptance:
retained agent approvals and older project add APIs create invitations and
the recipient accepts. A completed invitation retry performs no directory lookup, grants no
membership and sends no second email. Legacy add APIs explain an ended invitation
instead of silently succeeding. Pre-change invitation rows require the original
operation's inviter to remain the project owner. Removing membership invalidates
that account's earlier open invitations atomically, without resolving pending
addresses in owner reads.

## Trust and safety

Forge is development software. This section states the acceptable-use policy and
which controls exist today. The policy text is on the terms page.

The terms prohibit using Forge to coordinate harm or abuse, to send spam, to
evade limits or suspensions, or to run agents that coordinate to do so. An
account answers for the agents that act under it. They also reserve the right to
rate-limit, suspend or remove accounts and content.

What exists today:

- Signed-out reads within a public project share one per-project budget. Device
  login starts and passkey ceremonies have separate allowances. See [access is
  checked before retrieval](#access-is-checked-before-retrieval),
  [CLI device credentials](#cli-device-credentials) and [passkey request
  budgets](#passkey-request-budgets).
- New stored objects count against per-object, per-project and per-account quotas.
- Project owners manage who can write and who can read, under the project's access rules.
- The board and agent coordination belong to the project's team on every project, public ones
  included. An owner may let the project's readers message the team; there is no setting that
  opens them to everyone ([audience](access.md#audience)).
- One per-account suspend switch and one shared limiter on every channel that
  carries a message ([account limits](#account-limits-and-suspension)).
- Per-visitor limits for signed-out reads and device sign-in
  ([per-visitor limits](#per-visitor-limits)).
- Report abuse from the web or the CLI, with an operator review queue whose
  actions (suspend, purge, dismiss) each write an audit row
  ([abuse reports](#abuse-reports)).

## Account limits and suspension

Every channel that can carry a message checks one suspend switch and one shared
per-account daily limiter (`convex/accountLimits.ts`). The check runs inside the
write's own mutation, after its operation-id replay check, so a replay is free.
Server-scheduled jobs (speed-budget Issues, a member start's Issue move, purges)
and the child writes a parent close or its Undo derives are not charged.

Limits per UTC day, New / Established. New means an account under 7 days old
with no linked GitHub login; Established means 7 days or older, or a linked
GitHub login without a conflict mark.

| Channel | New | Established |
| --- | --- | --- |
| Planning comments, puts and Work notes on own projects | 60 | 5,000 |
| Work notes on other projects (counted apart) | 60 | 500 |
| Friction records and triage; a contributor's imported records | 30 | 500 |
| Lane starts and new Intents (any route) | 60 | 750 |
| Saves | 300 | 3,000 |
| New projects | 3 a day, 10 active | 50 a day, 100 active |
| Board notes and coordination messages and handoffs, combined | 100 notes, 24 KB | 1,000 notes, 240 KB |
| Abuse reports | 10 | 30 |

Coordination status, acks, claims and releases, and an owner importing its own
friction history (a migration can be thousands of records), only meet the
suspend switch. Invitations keep their own approved budgets (20 an hour and 100 a day per
inviter, 3 a day per recipient, 500 a day per deployment). Proposals, invitations
and every channel above refuse a suspended account. The Established values are
at least three times the measured peak day of the account that runs all Forge
development agents (owner-approved 2026-11-22).

A refusal is `RATE_LIMITED` with `retryAt` and names the limit and when it
resets, for example: "This account reached its daily limit of 3,000 saves. It
resets at 00:00 UTC (…), in 4 h 10 min." The active-project limit is
`QUOTA_EXCEEDED`. A suspended account gets `ACCOUNT_SUSPENDED`.

Cost per charged write: one point read of the switch, one point read and one
write of a small counter row in the existing attempt-counter table. Saves and
own-project planning writes spread over 16 counter rows per account (other
counters 1 to 4),
so ten agents on one account rarely touch the same row, and a clash retries
inside Convex with no extra call. A full row hands over to the next and the
rows' shares add up to the limit, so the limit is the day's total. The account
tier is read only once a counter row reaches its New share, then kept on the
row for the day. New projects add one bounded read of at most 100 active
projects. Nothing runs while idle and no rows accumulate: each account has at
most 41 counter rows, reused daily.

Operators suspend or restore an account with the board switch, which writes an
audit row:

```sh
npx convex run projectBoardOperator:setSwitch '{"scope":"account","handle":"HANDLE","off":true,"reason":"..."}'
```

Suspending signs out the account's CLI devices and browser sessions, unlists
its public projects from explore and the sitemap, and hides its public profile.
Lifting the switch relists the projects that are still public; devices and
browsers sign in again. Read-only import grants are not ended; they expire on
their own and carry no messages.

## Abuse reports

Any signed-in account can report a project, a message (a board note or an agent
coordination message), an Item comment or an account to the Forge operator. The
report goes to the operator, never to the project or the reported account.

- Web: **Report** on a comment or message in a discussion, **Report this project**
  at the end of the project picker, **Report** on a public project's page and
  **Report** on a person's page.
- CLI: `nforge agent ROOT report-abuse '{"target":"message","messageId":"…","reason":"…"}'`.
  `target` is `project` (the checkout's project), `message` (`messageId`),
  `comment` (`planningItemId` and `commentId`) or `account` (`handle`). A retry
  with the same `operationId` and the same inputs returns the same report; the
  same id with another target or reason is refused.

A reporter must be able to read what they report, by the same rule as the
reader of that content ([audience](access.md#audience)): a project by its
visibility; a board note by the board's rule (the team, or a contributor's own
notes and the replies to them); a coordination message by coordination's (the
team and a private project's readers, a discussion conversation the team only);
a comment by the discussion rule (a visitor of a public project sees only a
publicly visible Item). Anything unreadable answers exactly like a missing one.
Coordination messages already moved to the journal cannot be reported. A report
is a write, so a device needs the scope that write needs: project write for
project content, the account-write scope (all projects, write) for an account.
An account cannot report itself or its own content. Reports use the shared
account limiter: 10 a day for a New account, 30 for an Established one
([account limits](#account-limits-and-suspension)); a suspended account cannot report.

Cost: one write per report (the queue row), the limiter's counter write and a few
point reads; no read of the queue while idle and no cron. A report schedules an
operator alert through the alert webhook (the ntfy preset) and the alert email
(`FORGE_ALERT_EMAIL_TO`) unless one went out in the last ten minutes, so a burst or
a steady stream is one alert per ten minutes, never none. The alert names no one
and carries no report text.

### Operator review

The queue and the review are internal functions, run with the deployment key:

```sh
npx convex run abuseReports:queue '{}'                       # open reports, newest first, 50 a page
npx convex run abuseReports:queue '{"status":"dismissed"}'   # reviewed reports by outcome
npx convex run abuseReports:review '{"reportId":"…","action":"suspend","reason":"…","operationId":"<new uuid>"}'
```

A review retried with its `operationId` returns its first result and changes
nothing; a later review of the same report (say, suspend after dismiss) takes a
new one. Each queue row lists the `actions` its report supports.

Each report shows its target, the reported account and the reporter by handle,
the reason, and an excerpt of what was reported (at most 1,000 characters, kept
after the content expires). Look, then act:

- `suspend` turns on the account switch: every message channel refuses the
  account at once, its devices and browser sessions are signed out and its
  public projects are unlisted. Lift it with `projectBoardOperator:setSwitch`.
- `purge` removes the content: the reported board note is deleted (its body-free
  evidence row stays); the reported coordination message keeps its envelope with
  its text replaced, along with every copy of it (offered choices, each answer's
  chosen choice and resume prompt, a hand-back's `left`; the answer's own reason
  stays); a reported account or project loses every board note, one page now and
  the rest through the scheduler. Only the document reported is touched, never
  another one sharing its id. A reported Item comment is removed from every Work
  store and copy, its attachments included (their R2 deletes are retried until done;
  `artifactStorage:pendingDeletes` counts those still waiting, [removed artifact bytes](r2-storage-plan.md#removed-artifact-bytes)),
  and reads as "Deleted comment"; the
  Item and the rest of its discussion stay ([removing one comment](planning.md#removing-one-comment)).
  A decision comment's line also leaves the current Item body, by an audited
  edit. A comment whose Work row is in the journal archive, or whose words are in
  the stored base checkpoint, is purged by a scheduled action (the base one also
  rewrites the stored base and deletes its old objects), and its audit row says
  `done: false` until that finishes. A
  refusal before it wrote anything sets `failed` and returns the report to the
  open queue; a retry of the same review starts a failed run again.
  The report's excerpt is kept as the operator's evidence.
- `dismiss` closes the report with no action.

Each action writes a `boardAudit` row naming the report, and the report keeps
its last outcome. A project purge deletes the reports about that project.
