Skip to content

fix(control): keep GitHub connections to their account, by id - #195

Merged
kalaspuff merged 1 commit into
mainfrom
fctl/121-github-account-ids
Oct 22, 2026
Merged

kalaspuff merged 1 commit into
mainfrom
fctl/121-github-account-ids

Conversation

@fctl-sh

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

Copy link
Copy Markdown
Contributor

A workspace's GitHub connection named the account by its login, and the control plane found the GitHub App's installation by that login each time it minted a session's tokens, linked or created a repository, or looked a pull request up. A login can change hands: when a connected organization or user is renamed or deleted, someone else can take the name and install the app (it is public on app.fctl.sh). The workspace's sessions would then get tokens for the newcomer's repositories of the same names, clone and run their code beside the project's secrets, and push the workspace's work there.

Connections now keep the account they are to by GitHub's id:

  • Migration 0022 adds account_id to workspace_github and github_offers. Connecting an account records it, from the installation the admin's GitHub sign-in found.
  • workspaces::installation finds the installation on the login as before, and uses it only while the login still belongs to the account the workspace connected (fctl_domain::github::binding, with unit tests). Otherwise it refuses: "The GitHub account acme isn't the one this workspace connected: it was renamed or deleted, and its name may be someone else's now. The workspace's admins connect the account again under its GitHub tab, by its name now." Sessions then fail with that reason, and linking or creating repositories answers with it.
  • Everything that uses a connection goes through it: session tokens and their refreshes (spec::github_tokens, which now mints through the installation it checked), linking a project's repository, adding one to a project, creating one, and listing a workspace's repositories.
  • Pull requests: what a lookup or a webhook delivery says reaches only the sessions whose workspace is connected to the account that answered (the installation's account, or the delivery's repository.owner.id), or connected from before ids were kept.
  • Connections from before take the account the first time they are used: that of the installation they recorded, when GitHub still has it (so one whose login changed hands since then is refused), else the one that has the login now. One the old code had already re-pointed at a new owner's installation can't be told apart; its admins can connect the account again to be sure.

docs/architecture.md and docs/security.md describe it.

Verified

The binding rule, and webhook deliveries carrying the owner's id, have unit tests in fctl-domain. The SQL that decides which sessions hear a pull request's state ran against SQLite with the dev schema and migration 0022: a connection to account 77 hears what account 77 says and not account 99, and one from before ids were kept hears either. The dev stack has no GitHub App, so the GitHub calls themselves (GET /orgs/{org}/installation's account.id, GET /app/installations/{id}) weren't exercised here; they use fields GitHub documents for both. cargo xtask check --quick passes.

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

A workspace's connection named a GitHub account by its login, and the
control plane found the app's installation by that login every time it
minted a session's tokens, linked or created a repository, or looked a pull
request up. A login can change hands: when a connected account was renamed
or deleted and someone else took its name and installed the app, the
workspace's sessions would get tokens for the newcomer's repositories of
the same names, and run their code beside the project's secrets.
Connections now keep GitHub's id of the account (workspace_github.account_id,
also in offers), and the control plane uses one only while its login still
belongs to that account (fctl_domain::github::binding); otherwise sessions
fail and links refuse, until the admins connect the account again. What
pull request lookups and webhooks say reaches only sessions whose workspace
is connected to the account that answered. Connections from before take the
account of the installation they recorded, when GitHub still has it, else
the one that has the login, the first time they are used.
@fctl-sh
fctl-sh Bot requested a review from kalaspuff as a code owner October 22, 2026 01:43
@kalaspuff
kalaspuff merged commit 7a62a2c into main Oct 22, 2026
9 checks passed
@kalaspuff
kalaspuff deleted the fctl/121-github-account-ids branch October 22, 2026 01:48
kalaspuff pushed a commit that referenced this pull request Oct 22, 2026
A session's sandbox holds the Claude token of the person it runs as: an
access token that lasts hours, or a `claude setup-token` token that
lasts a year. Every runner of a workspace ran everyone's sessions there,
so each member's token reached every machine the workspace's admins
added. A full Claude sign-in, which passes a long-lived refresh token
through a host, could run on any of those runners too. Members had no
way out: only admins add runners.

Now each member can keep their sessions on machines they control, per
workspace ([ADR
0036](docs/adr/0036-members-run-their-sessions-on-their-own-runners.md)):

- **Only on my runners.** A member's setting in each workspace
(`workspace_members.own_runners`): in the workspace's **Settings →
You**, `fctl workspaces own-runners on|off -w acme`, `PATCH
/api/v1/workspaces/{id}/membership` with `own_runners`. While it's on,
their sessions there run only on runners they registered. Turning it on
stops their sessions running on others' runners, and they resume on
theirs.
- **Members add runners for their own sessions.** A runner added to a
workspace runs everyone's sessions there, or only its owner's
(`runner_workspaces.personal`). Members can now register a machine for a
workspace (`fctl host install --workspace acme`, or the Runners tab), or
add one of theirs. Such a runner runs only their own sessions, which
show the machine nothing they can't already read in the session. Runners
for everyone's sessions still take an admin, and admins can choose
`--personal` too. Adding a runner again changes whose sessions it runs.
Demoting an admin now turns their runners into ones for their own
sessions; before, it took them out of the workspace.
- **One rule.** A session runs as the owner of its Claude connection.
`fctl_domain::schedule::runs_for` decides whether a runner runs a
session (unit tests). FleetDO's scheduling, `spec::runner_serves`
(credentials, uplinks, files, screenshots) and Claude sign-ins all use
it, so a runner that stops running a session gets nothing more for it.
- **Claude sign-ins** run on one of the person's own runners when one is
online. Otherwise they run on a runner that runs their sessions; with
the setting on everywhere, only on their own.
- **Waiting says why.** A queued session that no runner takes says whose
runner it waits for: "Waiting for one of Grace Hopper's runners: their
sessions in this workspace run only on their own, and none of those is
online". It also says when the only runners online run only their
owners' sessions. The note under the task box counts only the runners
that run your sessions.
- **Wire changes are additive.** `Workspace.own_runners`,
`Runner.personal` (the workspaces where it runs only its owner's
sessions), `UpdateMembershipRequest.own_runners`,
`CreateRunnerRequest.personal`, and a new optional body for `PUT
/workspaces/{id}/runners/{runner}` (`AddRunnerRequest`). Hosts and
agents don't change. An older CLI that registers or adds a member's
runner gets one for their own sessions.
- **Migration 0023** adds the two columns. It is numbered after #195's
0022, and the ADR after #194's 0035.

It also corrects copy that said sessions on a runner taken out of a
workspace carry on: they stop and resume elsewhere, and have done so
since #171. The architecture, security, CLI and getting-started docs
describe all of this.

## Screenshots

At 3765a8b, in `cargo xtask dev` as Grace Hopper, a member of the
Development workspace. Dev Owner's `dev-host` runs everyone's sessions;
Grace's `grace-mini` and Ken Thompson's `ken-box` run only their own.
1280 px wide unless noted.

The workspace's Runners tab, light. Before: members could only ask an
admin. After: they register a machine for their own sessions, and the
list marks the runners that run only their owner's sessions.

| Before | After |
|---|---|
| ![Before: the Runners tab for a member, who can only ask an
admin](https://app.fctl.sh/api/v1/published/nrH29cRZ90kfwMT4BGvdeWsXytJaq5SUfbGDWkGzx97/own-before-runners.png)
| ![After: the Runners tab for a member, with a form to register a
machine for their sessions and marked personal
runners](https://app.fctl.sh/api/v1/published/g3cAk9b6qnpEg3YUWCE2yzhLLf0q4kMx24f3bdsZZJ4/own-after-runners.png)
|

The workspace's Settings → You, light, with the new switch off:

| Before | After |
|---|---|
| ![Before: Settings → You without the
switch](https://app.fctl.sh/api/v1/published/7N5S847hyFaD0TKEVEXvBck3MYXgHhJ9AUNxZx5cPzb/own-before-settings.png)
| ![After: Settings → You with the Only on my runners
switch](https://app.fctl.sh/api/v1/published/M2owdgz5HujRWHiiLicwIrrT2wMbW2rmttX6kpO7I49/own-after-settings.png)
|

The switch on, dark:

![After: the Only on my runners switch on, dark
theme](https://app.fctl.sh/api/v1/published/B3A8gLroNMwuPrjyvVKh5F4IbecoAf13e847C6vueTi/own-after-settings-on-dark.png)

With it on and `grace-mini` offline, a new session waits for one of
Grace's runners, though `dev-host` is online:

![After: a queued session waiting for one of Grace Hopper's
runners](https://app.fctl.sh/api/v1/published/AHFay0dCwWsLwrsTgSzKZJs96NMsatLZSk52A5DntHu/own-after-waiting.png)

The note under the home page's task box says the same before she starts
one:

![After: the note under the task box says none of her runners is
online](https://app.fctl.sh/api/v1/published/SFJwaMtizj7TSfylEPrPefuV5JdrJB8bjz80VlZZXMO/own-after-home-note.png)

The Runners tab as the primary admin, who sees whose each runner is and
can take any out:

![After: the Runners tab as an
admin](https://app.fctl.sh/api/v1/published/wv7tw8Ztu7Skf3QfAfRSh1n7inAdKq3J6EVVh0LPn7o/own-after-runners-admin.png)

The Runners tab at 390 px, dark, where the marks wrap whole:

![After: the Runners tab at phone width,
dark](https://app.fctl.sh/api/v1/published/G4PAZ6XSXEjre1lqoDblO8LPQTfyOBk4Kyim6rcGf0h/own-after-runners-390-dark.png)

The app's Settings → Workspaces says which workspaces keep your sessions
on your runners:

![After: Settings → Workspaces marks the
workspace](https://app.fctl.sh/api/v1/published/45nZBxSnnxrejGbNexMQV6ATS5Ce0P8FbqlHjU0aAEz/own-after-app-settings.png)

## Verified

In `cargo xtask dev`, with a second host running as Grace's
`grace-mini`, and Ken as another member:

- **Grace's personal runner took nobody else's sessions.** Ken's
sessions all went to `dev-host` while `grace-mini` sat idle. With
`dev-host` full, his next one waited instead of using hers.
- **Turning the setting on and off.** With it off, Grace's sessions ran
on either runner. Turning it on stopped her session on `dev-host`, and a
message resumed it on `grace-mini`. With `grace-mini` offline, a new
session waited with the reason above; turning the setting off started it
on `dev-host`.
- **Ken's waiting reasons.** With `dev-host` disabled, his session said
the runners online run only their owners' sessions. With `dev-host` out
of the workspace, it said the workspace's runners run only their
owners'. Adding `dev-host` back started it.
- **Demotion.** Grace, made an admin, shared `grace-mini`, and a Ken
session ran there. Demoting her made it hers alone, stopped his session,
and a message resumed it on `dev-host`.
- **Claude sign-ins.** Grace's ran on `grace-mini` though `dev-host` was
online; Ken's on `dev-host`. With Ken's setting on and no runner of his,
his sign-in is refused (503).
- **API rules.** A member registering or adding a runner for everyone's
sessions gets 403, and an admin adding a member's runner gets 403.
Without a body, `PUT …/runners/{runner}` adds a member's runner for
their own sessions.
- **CLI.** `fctl workspaces own-runners`, `add-runner --personal` (and
again without it), `runners`, `show`, and `fctl host install
--workspace` as a member ("Registered runner ken-box … for your sessions
in Development").

`cargo test -p fctl-domain` (new tests for `runs_for`,
`check_add_runner` and the waiting reasons), the web app's tests
(`runnersOf`, the note, the Runners tab), `cargo xtask check` and a
session through `cargo xtask serve` (`cargo xtask dev --smoke --server
http://localhost:8787`) pass.

One of four pull requests on the issues the security review (#189) left
open, with #193, #194 and #195.

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

---------

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