Repository navigation
Description
A company whose code lives on GitHub Enterprise Server (its own https://ghe.acme.com) or on GHE.com, GitHub's cloud with data residency (https://acme.ghe.com), can't use fctl. The control plane talks only to api.github.com, agents clone from github.com, and the web app links there. They need one instance-wide setting that points fctl at their GitHub. The GitHub App's flows, webhooks, session tokens, pull request lookups, reviews, agents' git and gh, and every link should then go there.
How it works now
The address github.com is written into every layer:
- The control plane's client.
crates/fctl-control/src/github.rshasAPI = "https://api.github.com"for every REST call (Github::call) and for GraphQL (Github::graphql,/graphqlunder it). It hasWEB = "https://github.com"for the sign-in that connects accounts (authorize_urlandexchange, with PKCE). On GHES, REST is under/api/v3and GraphQL at/api/graphql(REST, GraphQL), so one base URL can't give both. GHE.com serves both APIs fromhttps://api.acme.ghe.com(GitHub's docs). - The bot's identity.
bot_identity(crates/fctl-control/src/spec.rs) looks the bot up with an unauthenticated call tohttps://api.github.com/users/<slug>%5Bbot%5D, and makes<id>+<slug>[bot]@users.noreply.github.com. GHE.com asks for a token even where github.com doesn't (same page). - Installing the apps.
https://github.com/apps/<slug>/installations/newis incrates/fctl-control/src/api/github.rsandapi/projects.rs. The review app'sinstall_urlandsettings_urlare incrates/fctl-domain/src/review_app.rs. GHES's own docs give its install links as/github-apps/<app>/installations/new(GitHub's docs). - Reading what people and agents write.
fctl_domain::repos::parse,parse_remoteandaccounttake only github.com addresses and remotes (crates/fctl-domain/src/repos.rs). So dofctl_domain::pulls::repo_of,named_in(which finds the URLgh pr createprints) andis_github_pull(crates/fctl-domain/src/pulls.rs), and the reading of review bots'github.com/apps/…names (crates/fctl-domain/src/reviews.rs). - Other links the control plane builds. GitHub Issues' links (
crates/fctl-control/src/tickets.rs), and Linear's repository suggestions, which sendhostname: "github.com"(suggestedincrates/fctl-control/src/delegations.rs). - Protocol.
RepoRef::html_urlandRepoRef::clone_urlbuild github.com addresses (crates/fctl-proto/src/session.rs), and a session's spec doesn't say which GitHub it uses. - In the sandbox. fctl-agent writes gh's
hosts.ymlundergithub.com:(write_github_tokens) and sets the credential helper forhttps://github.com(configure_git), both incrates/fctl-agent/src/workspace.rs. The agent's instructions givegit clone https://github.com/<owner>/<name>as their example (crates/fctl-agent/src/prompt.rs). fctl-agent'sgh pr viewruns inside the clone, where gh takes the host from the remote (crates/fctl-agent/src/followed.rs). The default image's gh needs nothing more thanhosts.ymlandGH_HOSTnaming the host. - Hosts. Image builds read repositories through
host.toml'sgithub_api, there "for tests" (crates/fctl-host/src/config.rs,build.rs): a runner's setting, not the instance's. - The web app. It builds
https://github.com/links inweb/src/routes/project.tsx,routes/workspace.tsx,routes/admin.tsx,routes/settings.tsx,components/project/repositories.tsx,components/project/review-repos.tsx,lib/git.ts,lib/schedules.tsandlib/review-bots.ts. Avatars come fromavatars.githubusercontent.com(components/github-avatar.tsx), the only GitHub host that the Content Security Policy'simg-srcallows. That policy lives inweb/public/_headers, a static file built with the app. - The webhook.
POST /api/v1/github/webhookchecksX-Hub-Signature-256and readsX-GitHub-Event(crates/fctl-control/src/api/webhooks.rs). GHES sends the same headers, but it has to reach the control plane. - Configuration.
GithubConfighas no host (crates/fctl-control/src/config.rs), andInstanceInfo.features.githubonly says whether there is an app (crates/fctl-proto/src/api.rs).
How this relates to #375. #375 (agents on GitLab) asks for an ADR that puts GitHub behind a forge-neutral model, with RepoRef gaining an optional forge that defaults to GitHub. GitHub Enterprise is the same forge on another host, so it needs none of that model. It does add the first "where is this forge" field to the spec and to the URLs built from RepoRef. Both should use one shape, a forge host that defaults to github.com, so that self-managed GitLab extends it later rather than adding a second one. #375's first open question, "gitlab.com only at first, or self-managed GitLab instances too (and whether one workspace may use several)?", is this issue's first decision too.
What should happen
- An instance-wide address for its GitHub:
GITHUB_URL(unset: github.com). It's also the first question on Admin → Integrations once Self-hosted instances create their GitHub and Slack apps in a click, without restarts #628 lands. fctl derives the web, REST, GraphQL and git addresses from it;GITHUB_API_URLandGITHUB_GRAPHQL_URLoverride them for setups that differ. - One type in fctl-domain that knows the kind of GitHub builds every URL and reads every reference, in place of the literals above.
- The control plane's client uses it everywhere: app JWTs and installation tokens, the sign-in, installation links, pull request lookups (ADR 0033), reviews and check runs, issues, schedules' events and the bot's identity. The bot's lookup sends the app's token.
- Sessions carry the GitHub (
SessionSpec.github, optional; absent means github.com). fctl-agent clones from it, signs git and gh in there, gives ClaudeGH_HOST, recognizes its pull request URLs and names it in the agent's instructions. Hosts build images through it, nothost.toml'sgithub_api. - Runners say they can (an entry in
HostHello.features), and FleetDO sends a GitHub Enterprise instance's sessions only to those, with a waiting reason otherwise. - The web app reads the address from
GET /api/v1/instance(github_url) and builds every link from it. Avatars come through the control plane, since_headerscan't name a host chosen at runtime. - Linear's repository suggestions send the instance's host.
- The docs and
docs/llms.txtcover GHES and GHE.com.
Deriving the addresses.
| Web | REST | GraphQL | git and gh | |
|---|---|---|---|---|
| github.com | https://github.com |
https://api.github.com |
https://api.github.com/graphql |
github.com |
| GHES | https://ghe.acme.com |
https://ghe.acme.com/api/v3 |
https://ghe.acme.com/api/graphql |
ghe.acme.com |
| GHE.com | https://acme.ghe.com |
https://api.acme.ghe.com |
https://api.acme.ghe.com/graphql (to confirm) |
acme.ghe.com |
A host under .ghe.com means GHE.com; any other is GHES. Before saving, fctl calls GET {REST}/meta, which tells it whether the address is a GitHub at all (GHE.com answers 401 without a token, which says as much) and, for GHES, its version (installed_version). The address can change only while no workspace has a GitHub account connected, since their repositories, installations and pull requests belong to the old GitHub.
Sessions. SessionSpec.github carries the kind and the four addresses. RepoRef gets host-aware html_url and clone_url, keeping today's for github.com. With it, fctl-agent writes hosts.yml under ghe.acme.com:, sets credential.https://ghe.acme.com.helper, gives Claude GH_HOST=ghe.acme.com, and has named_in recognize https://ghe.acme.com/acme/web/pull/7.
Design and UX
Someone whose code is on GitHub Enterprise should point fctl at it once, and never meet github.com again: every link, install button, command and agent instruction should name their own GitHub.
Admin → Integrations, GitHub, before an app exists. The headline is "Where your code lives". The lead: "Agents clone, push and open pull requests on one GitHub for all of Acme factory. Choose it before creating the GitHub App: the app, and every account that workspaces connect, belong to that GitHub." Three radio cards follow:
- "github.com": "GitHub's own cloud."
- "GitHub Enterprise Server": "Your company's own server", with an Address field (
https://ghe.acme.com). - "GHE.com": "GitHub's cloud with data residency", with a field for the subdomain (
acme) before a fixed.ghe.com.
Beside them, a preview drawn from what's typed: a pull request chip, "acme/web#42 · Retry failed uploads", over ghe.acme.com, and the line git clone https://ghe.acme.com/acme/web. The primary action is "Use ghe.acme.com".
- While fctl checks, the button says "Asking ghe.acme.com which GitHub it is…".
- The answer replaces it: "GitHub Enterprise Server 3.20 at ghe.acme.com". The section moves on to creating the GitHub App there.
- Errors say what follows. "ghe.acme.com didn't answer the control plane (connection refused): fctl reaches GitHub, and GitHub's webhook reaches fctl, so both need a way through your network." "https://ghe.acme.com/api/v3/meta answered 404: is this a GitHub Enterprise Server's address?" A version older than fctl's minimum gets "ghe.acme.com runs GitHub Enterprise Server 3.11; fctl needs 3.16 or later." (Both numbers are examples: the minimum is a decision below.)
Locked. Once accounts are connected, the cards become a sentence, with the reason the address can't change: "Acme factory's GitHub is ghe.acme.com (GitHub Enterprise Server 3.20). Workspaces work in 3 of its accounts: to move to another GitHub, disconnect them first, and their projects lose their repositories."
Everywhere else. Only instance admins see Admin; everyone else meets the host in copy. The workspace's GitHub tab: "Acme's projects use repositories of the accounts on ghe.acme.com that acme-fctl is installed on." Its install buttons open ghe.acme.com. Link labels stay "GitHub", since it's GitHub, and their targets and titles name the host. A queued session that no runner can take says "Waiting for a runner: none online runs a version of fctl that works with GitHub Enterprise. Their owners update them (fctl self update)." The session log says "Cloning acme/web from ghe.acme.com".
CLI.
$ fctl admin github host https://ghe.acme.com
GitHub Enterprise Server 3.20 at https://ghe.acme.com: REST at /api/v3, GraphQL at /api/graphql.
Next: create the GitHub App there (Admin → Integrations, or fctl admin github create).
$ fctl admin github host https://acme.ghe.com
Acme and Web team work in 3 accounts on ghe.acme.com: disconnect them first (fctl admin github remove ACCOUNT WORKSPACE).
$ fctl projects create web --repo https://github.com/acme/web
This instance's GitHub is ghe.acme.com: give acme/web, or its address there.
fctl admin github host alone prints the GitHub in use. --json prints the kind and the four addresses.
States. The first visit preselects github.com, and nothing changes for instances that never choose. Checking, the button holds its label with a spinner. Errors and refusals are above. Waiting: sessions queue for runners that can take them, with the reason above. Long lists: the accounts and repositories lists stay as they are.
- Follow hyperstructure/design's docs:
docs/principles.md;docs/web-app/explaining.mdfor pages that set something up (a headline that names the outcome, a lead built from this place's facts, a preview of the result, one primary action, and who can act);docs/web-app/kit.mdfor controls. - Design every state before building it: the first visit, loading, errors and refusals, waiting, partial setups and long lists.
- Say what happens, plainly, and never leave someone at a disabled control without saying who can act.
- Prototype the main screens with realistic data (
cargo xtask demo's world) and review them before building the rest. - Check both themes, a phone's width, the keyboard, screen readers and reduced motion, and show screenshots in each pull request.
- Give the CLI the same care: readable output,
--json, and errors that say what to do next. - Add or update the pages of hyperstructure/design's docs for each new component, with the reasons behind its choices.
Compatibility
- Versions. Hosts and agents may run one version behind the control plane. One from before ignores
SessionSpec.githuband would clone from github.com, so FleetDO sends a GitHub Enterprise instance's sessions only to runners that announce the feature. Instances on github.com change nothing. - Protocol.
SessionSpec.github,InstanceInfo.github_urland the feature string are new optional fields incrates/fctl-proto, thencargo xtask gen. - D1. No migration while the address is a deployment variable. Stored in D1 alongside the app (Self-hosted instances create their GitHub and Slack apps in a click, without restarts #628), it goes in that issue's new migration.
- Release. The control plane, the host, fctl-agent, the CLI, the web app and the standalone image.
- Docs.
docs/self-hosting.md#connect-github-optional-recommendedgets GHES and GHE.com: the address, and the app created on that GitHub. Alsodocs/architecture.md(GitHub accounts, Repositories, Pull request state and checks),docs/sandbox-images.md(gh's host),docs/cli.mdanddocs/llms.txt. - Privacy policy. With one GitHub per instance, app.fctl.sh stays on github.com, and fctl-site's
legal/privacy.mddoesn't change. If workspaces could choose their own GitHub, its GitHub sections would name the workspace's GitHub. - hyperstructure/sandbox. Nothing, unless the default image's gh is too old for GHE.com: check it.
Decisions for a person
- One GitHub per instance, or one per workspace? A GitHub App lives on one GitHub, so per workspace, each workspace would register its own app there, with Self-hosted instances create their GitHub and Slack apps in a click, without restarts #628's manifest flow. app.fctl.sh could then serve GHE.com companies.
- Which GHES versions? The oldest one GitHub still supports, checked against what fctl relies on: PKCE in the sign-in,
X-GitHub-Api-Version: 2022-11-28, the GraphQL fields of pull request lookups, installation tokens narrowed to repositories and permissions, and the events the app subscribes to. - Does app.fctl.sh offer GHE.com at all? A GHES inside a company's network can't reach app.fctl.sh's webhook or be reached by it, so GHES means a self-hosted control plane.
- Avatars: through the control plane, or none on GitHub Enterprise instances?
- Does
host.toml'sgithub_apistay, for tests, or go?
Refs #375
Related: #628
Session: https://app.fctl.sh/s/ses_01M8450BECFP8DN88R0ZP0N0MS
Activity