Skip to content

feat: limit access tokens, and what agents may do on GitHub - #207

Merged
kalaspuff merged 3 commits into
mainfrom
fctl/133-it-would-be-great-to-be-able-to-create-a
Oct 22, 2026
Merged

kalaspuff merged 3 commits into
mainfrom
fctl/133-it-would-be-great-to-be-able-to-create-a

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Access tokens can now be limited to what they are for, and every session says what its agent may do on GitHub: push (as before), comment (review, comment, label and resolve review threads, no pushes) or read. That covers review agents started from CI that read and comment but can't push, and planner agents that only read.

What changed

What a session's agent may do on GitHub (GithubAccess: push > comment > read)

  • A session asks for a level as it starts (CreateSessionRequest.github_access, fctl run --github, a new picker beside model and effort in the task boxes). It gets at most what its project allows (ProjectSettings.github_access, fctl projects set --github, Agents on GitHub in project settings) and what the token that starts it allows. If it asks for nothing, it gets the most they allow; if it asks for more, it's refused with the reason.
  • GitHub enforces it, not the agent. The session's GitHub token carries the level's permissions (fctl_domain::repos::permissions):
    • comment: pull_requests and issues write, contents read, no workflows;
    • read: one read-only token for every repository.
  • Lowering a project's level reaches running sessions with their next token (within the hour), the same way removing a repository does.
  • fctl-agent pushes nothing for these sessions, moves no work onto session branches, and tells Claude what it may do instead of how to push. The transcript says so as the session starts.
  • Resolving review threads. GitHub only lets tokens that can write contents (and therefore push) resolve review threads. So an agent that comments runs fctl resolve PRRT_… in its sandbox, a new agent call like fctl memory. The control plane checks the thread is on a pull request in a repository the session may write to, then resolves it with a token of its own for that one repository, which it revokes at once and never hands out. ~/AGENTS.md tells comment agents how, with the GraphQL query that lists a pull request's threads.
  • The session page shows a Comments only / Read only chip beside the status and an On GitHub row in the details. Changes says "kept in the sandbox" rather than "not pushed yet". fctl show prints the level too.

Limited access tokens

  • A token can be limited three ways (tokens.scope, fctl_domain::limits::Limits):
    • what it does: read (as a viewer), run (as an editor: start and steer sessions, stop and resume its own, keep memory) or full;
    • where: some workspaces (including projects made later) and/or some projects;
    • the most its sessions' agents may do on GitHub.
  • A limited token reaches projects and sessions only. One rule in the router (limits::allows) refuses everything else before any handler runs: the account, Claude connections, workspaces' people and settings, other tokens, admin. A token handed to CI therefore can't mint itself another one.
  • Its roles are capped in access.rs. A session whose agent may do more on GitHub than the token allows is read-only to that token, with an error that says why. Lists filter its places in SQL, so pages stay full. WebSocket rechecks apply its limits, and it can't open the dashboard feed. Limits hold however the token is sent, as a bearer token or in a cookie.
  • GET /auth/me shows a limited token only whose it is and the token itself.
  • Sessions started by a limited token don't auto-follow, since every finished CI review would otherwise notify its owner.
  • Web: Settings has a new Access tokens section, separate from Devices. Its dialog asks the three questions plus expiry, shows in a sentence what the token will do before it's created, and shows the secret once with a ready-to-run example.
  • CLI: fctl token NAME --access run -p web -w acme --github comment --days 90; fctl tokens lists tokens and what each does; fctl tokens revoke NAME|ID. fctl whoami describes the token in use. Account commands refuse limited tokens clearly instead of showing an empty account.

Docs: a new Automation guide: tokens, GitHub access, a GitHub Actions workflow for review agents (one session per pull request, messaged on new commits), forks and other security caveats, and other recipes (triage, nightly maintenance, planning, dashboards, the API). Also updated: architecture (Access tokens, GitHub access), CLI, security, self-hosting, and ADR 0037.

Compatibility

  • Migration 0024 adds tokens.scope and sessions.github_access. NULL means today's behavior, so existing tokens and sessions don't change.
  • New fields are optional, and the new agent call is a new variant.
  • An older control plane ignores token limits and --github. fctl token revokes a token made without the limits it asked for, and fctl run --github stops a session started without the level it asked for; both say why.
  • Older hosts and agents ignore a session's level. Their agents try to push, and GitHub refuses.
  • An older agent answers fctl resolve with "did not understand the request".

Verification

  • Unit tests:
    • domain: the router rule, role caps, the GitHub level decision, permission sets, stored-limits round trip and fail-closed parsing, the read-only token plan, thread GraphQL parsing, keeping the project setting when an update omits it;
    • agent: prompts for each level, ~/AGENTS.md, a comment agent pushing and moving nothing, the stale write token dropped;
    • CLI: token descriptions;
    • web: token form logic, start choices, the composer picker, the draft, "kept in the sandbox".
  • cargo xtask check --quick passes: fmt, types, Clippy for host and wasm, all Rust tests, 561 web tests.
  • End to end on cargo xtask dev with the CLI:
    • Read token: reads sessions and logs; refused run, token, tokens, projects create, admin and memory writes with "it only reads projects and sessions"; claude status says it can't see the account.
    • Run token, one project, comment cap:
      • its sessions default to comment, and --github push is refused;
      • it doesn't see the other project (Project not found), and doesn't follow its sessions;
      • it can message and stop its own sessions, but can't message, resume or stop a pushing session ("…may at most comment on GitHub, and this session's agent may push: the token only reads it").
    • Workspace token: sees that workspace's projects.
    • Validation: blank or unknown places are refused.
    • Cookie: the read token sent as a cookie is still limited.
    • Project cap: fctl projects set --github read refuses --github push ("This project's agents may at most read on GitHub"), defaults new sessions to read, and an earlier session now shows "reads only".
    • Agent side: a comment session on a public repository got the comment-only system prompt, the transcript line, and the "Review threads" section in ~/AGENTS.md.
      • fctl resolve went sandbox → fctl-agent → host → control plane, which answered "No GitHub App is configured" (the dev stack has none); malformed thread ids are refused.
      • A read session's agent refuses fctl resolve locally.
  • Screenshots via Playwright against the dev stack, both themes, desktop and phone.

Not verified: resolving a thread against real GitHub. The dev stack has no GitHub App, and GitHub doesn't document which App permission resolveReviewThread needs. Several community reports say contents: write, which is what the control plane's token gets; one more report saw the same error but didn't try contents: write. If GitHub refuses, the agent gets GitHub's message and is told to name the threads in its reply instead.

Screenshots

At 36a1395, from the dev stack.

Settings → Access tokens, each with a sentence that says what it does (light):

The access tokens list

The new token dialog, for review agents in one project (light and dark), and on a phone:

Light Dark Phone
The new access token dialog, light The new access token dialog, dark The dialog on a phone, a whole workspace chosen

The token, once (masked here), with a command that uses it:

The new token and how to use it

The task box's new On GitHub list (desktop, light), and on a phone (dark), where it is a symbol in the joined model/effort control:

Desktop Phone
The composer's GitHub access list The composer on a phone

A session whose agent only comments: the chip beside its status, On GitHub in its details, and its commit "kept in the sandbox":

Light Dark
A comment-only session, light A comment-only session, dark

A project's Agents on GitHub setting (dark):

The project setting

Related

Session: https://app.fctl.sh/s/ses_01M5HPGZ4R0NQCXSMFR659JEHJ

fctl-sh Bot added 3 commits October 22, 2026 12:11
Access tokens can be limited to reading, running sessions or everything
their person may, to some workspaces and projects, and in what the agents
of their sessions may do on GitHub. A limited token reaches projects and
sessions only, with its roles there capped.

Sessions' agents push (as before), comment (review, comment and label,
push nothing) or only read on GitHub, as the session asks, within its
project's settings and the token that starts it. The session's GitHub
tokens carry those permissions, fctl-agent pushes nothing for them and
tells Claude, and agents that comment resolve review threads through the
control plane (fctl resolve), since GitHub lets only tokens that can push
do that.
…itHub

Settings has an Access tokens section, whose dialog asks what a token can
do, where, what its sessions' agents may do on GitHub and when it expires,
says what the token will do before it makes it, and shows the secret once
with how to use it. Devices lists browsers and CLI sign-ins on their own.

The task boxes choose what the agent may do on GitHub (push, comment or
read, within the project's setting), the session page says so beside its
status and in its details, and a project's settings hold its agents to
less. The guide in docs/automation.md runs review agents from GitHub
Actions.
The CLI, security and self-hosting docs cover limited access tokens,
fctl run --github, fctl resolve and fctl projects set --github. A token
refuses blank places, which would have left it reaching every project,
and fctl run stops a session that an older control plane started without
the GitHub access it asked for.
@kalaspuff
kalaspuff merged commit 9ced8ea into main Oct 22, 2026
10 checks passed
@kalaspuff
kalaspuff deleted the fctl/133-it-would-be-great-to-be-able-to-create-a branch October 22, 2026 13:01
kalaspuff pushed a commit that referenced this pull request Oct 22, 2026
Follow-ups to #207. A review of #207, by an agent reading the code
without my notes, found one way past the limits, a design gap, and four
smaller issues. I checked each against the code, and this fixes all of
them.

Refs #207

## What changed

1. **A comment-capped token could steer an agent that can push** (the
bypass).
- The old rule decided who may steer a session from its *effective*
access: what it started with, within its project's setting now.
- Lowering a project's setting (a maintainer's change, or the token
itself if it could do everything) made a running push session look
comment-only right away. A token capped at comment could then message
it.
- The sandbox still held a token that pushes, valid for up to an hour,
and its agent still pushed after every turn.
- Now whom a token may steer goes by what the session *started* with
(`SessionRow::started_github`), for both HTTP and socket rechecks.
Tokens and pages keep the effective value.
- The error says why: "…this session's agent started able to push: the
token only reads it."
2. **"Everything" plus a GitHub limit held nothing** (design gap).
- A token that may do everything in its projects can change their setup
script, instructions, image and secrets, and so steer every agent there,
push agents included.
- The control plane now refuses that combination with a clear reason
(`fctl_domain::limits::check`).
- `fctl token --github comment` without `--access` makes a token that
runs sessions.
- The web dialog asks the GitHub question only for "Run sessions", and
says why it's absent for "Everything" (screenshot below).
3. **`GET /auth/me` for a limited token** listed the person's other
email addresses, and whether they have a password, two-factor or
passkeys. It now shows only their name and primary address, as the docs
said.
4. **`GET /workspaces/{id}/avatar`** ignored a token's places, since its
handler checks membership itself. Limited tokens no longer reach it;
nothing that uses them needs it.
5. **Unknown values fail closed.** Values a newer version may store used
to read as the most an agent may do. Now:
- an unknown session or project GitHub access reads as `read` for tokens
and as `push` for steering decisions;
- an unknown `github_access` no longer makes a project's whole settings
unreadable, which had fallen back to defaults that push;
- a stored token limit with a field this version doesn't know reaches
nothing.
6. **`fctl resolve` refusals** named the repository of a thread outside
the session's repositories, and told a missing thread from a foreign
one. Both now get the same answer, which names no repository.

The docs (architecture, CLI, Automation, security) and ADR 0037 say all
of this.

## Verification

- **New unit tests:**
- "Everything" with a GitHub limit is refused, whatever the order of
fields;
  - limits with an unknown field reach nothing;
  - the avatar route and device approval are refused;
- an unknown project GitHub access reads as `read` and keeps the other
settings;
- the web form only asks a token that runs sessions to hold its agents
lower.
- `cargo xtask check --quick` passes: fmt, generated types, Clippy for
host and wasm, all Rust tests, 566 web tests.
- **On `cargo xtask dev`:**
- **Steering:** a comment-capped token was refused on a session that
started able to push. After `fctl projects set -p hello --github
comment`, `fctl show` says the session "reviews and comments", and the
token is still refused.
- **Refusals:** `fctl token x --access full --github comment` is refused
with the reason, and the avatar route answers 403.
- `fctl token x -p hello --github comment` makes a token that runs
sessions.
- `whoami --json` with a limited token shows no other addresses or
sign-in details.

## Screenshots

The new token dialog with **Everything** chosen (light), at 8486659: no
GitHub question, and a sentence that says why.

![The token dialog with Everything
chosen](https://app.fctl.sh/api/v1/published/rwuB5pTmWNbzkyh10rdrgXMhqe0CXYaEGhrHHzTE9Rk/token-everything-light.png)

Session: https://app.fctl.sh/s/ses_01M5HPGZ4R0NQCXSMFR659JEHJ

Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
kalaspuff pushed a commit to hyperstructure/fctl-site that referenced this pull request Oct 22, 2026
Adds fctl's new **Automation** guide to fctl.sh/docs, and updates the
privacy policy for limited access tokens (hyperstructure/fctl#207).

hyperstructure/fctl#207 is merged and fctl's CI pinned it
(`fctl-docs.ref` at 9ced8ea), which this branch now has from `main`, so
the build finds the page: ready to merge. hyperstructure/fctl#209, which
follows #207, changes these docs' wording only; the next pin brings it.

## What changed

- `scripts/docs.mjs`: `docs/automation.md` renders at
`/docs/automation/`, after the CLI in the navigation. It covers access
tokens limited to what they are for, what agents may do on GitHub (push,
comment, read), and review agents from GitHub Actions. Links from other
pages to it now stay on the site. The 404 page's suggestions test lists
it too.
- `legal/privacy.md` (`updated` is already today):
- **Sign-in sessions and tokens**: for an access token you limit,
app.fctl.sh keeps what it may do, the workspaces and projects it
reaches, and what its sessions' agents may do on GitHub.
- **Projects and sessions**: each session keeps what its agent may do on
GitHub, and which access token started it, if one did.
- **Browser storage**: the draft task keeps the GitHub access chosen for
it, beside the project, model and effort level.

## Verification

- `FCTL_DOCS_DIR=<fctl at fctl/133-…> npm run build` renders 9 docs
pages. `/docs/automation/` links to `/docs/architecture/#access-tokens`
and `/docs/cli/`, and the nav lists it on every page.
- `npm run check`: no new findings (the two `!important` warnings in
404.html and 500.html are on main too).
- `node --test scripts/*.test.mjs`: 13 pass.

Session: https://app.fctl.sh/s/ses_01M5HPGZ4R0NQCXSMFR659JEHJ

Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant