3 Commits
Author SHA1 Message Date
CatoandClaude 9f12199f98 feat(projects): Loki keeps the code — nobody is sent to GitHub to start (#1154)
Every account but the founder's hit "Connect GitHub and the build carries
on" at the repository step of a kickoff: the server's org token was offered
only to accounts entitled to fleet infrastructure, so a person with an idea
and no GitHub account could plan but never build. Most people arriving at
Loki have no GitHub account and no wish to open one.

Now the org token creates and seeds the repository for every signed-in
account, and Loki keeps the code. The new user_projects.code_custody column
('loki' | 'own') is the safety boundary that lets it: a destructive
org-token write (archive on delete, make private on retire, rewire CD) is
allowed only on a row that says 'loki', and only the two paths that made
the repository with that token may write that value. A repository a person
linked by hand is theirs — their own token or nothing — so "Loki keeps your
code" cannot become a credential aimed at the org's other repositories.
scripts/test/github-org-token.ts pins the rule.

The code stays the person's. Once the site is live, a line beside the Live
link (and Project settings, always) offers to move it to their own GitHub:
POST /api/projects/[id]/handover transfers the repository to their login,
flips custody to 'own' and records the new address. Connecting GitHub is
asked for there and only there, because it is where the code goes.

Copy follows: the kickoff, provisioning, onboarding, the empty projects
list, the quickstart and /pricing say "Loki keeps the code for you, free"
instead of "creates a GitHub repository", and a link into the private org
repository is shown only to a viewer whose credential opens it.


Claude-Session: https://claude.ai/code/session_01CG9dupSVqoXCCqKfBCfd9B

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-11 16:13:23 -07:00
CatoandClaude Opus 5 223a2f0915 fix(github): the org token is for accounts entitled to fleet infrastructure, not every session (#651)
The org write token added in #634 was handed to any signed-in account. It can
create, seed and DELETE repositories in the bitbaum organisation — a
server-held admin credential reachable by whoever holds a session is a
privilege escalation waiting for the first external user, and FleetCrown is
schema-ready for those today.

It is now offered only to accounts already entitled to fleet-owned
infrastructure — founder or explicit allowlist, the same boundary the shared
cloud builder draws (docs/architecture/multitenancy-execution-plan.md). Anyone
else writes with their own GitHub token exactly as before, and if their org
refuses it they get the honest 403 that names both remedies.

`isFleetInfrastructureAllowed` is separate from `getExecutionAccess` on
purpose: that one also reads runner presence, which a GitHub write has no use
for, and "may this account act as the fleet" deserves one name every caller
asks by rather than each re-deriving `isDefault || allowlist`.

Verified: tsc, eslint, scripts/test/github-org-token.ts (extended to pin that
an unentitled account falls back to its own token, never the org's).


Claude-Session: https://claude.ai/code/session_01WSNERoZZqW2TgqbAGHSQZf

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 06:43:21 -07:00
CatoandClaude Fable 5.1 a8a36de68b fix(kickoff): org repos are created with a server-held org token, not the person's OAuth grant (#634)
"Creating the repository" failed for every kickoff on 2026-09-11 with HTTP 403:
the bitbaum organisation restricts OAuth apps, and FleetCrown's app is not
approved there — so the person's OAuth token cannot create in the org, and the
route offered no other way in. Meanwhile the box's own site factory creates
repos in the same org every day, with an org admin's token.

Org writes — create, seed the starter, wire CD (the workflow shim), archive or
delete — now use `GITHUB_ORG_TOKEN` when the server has one, and the person's
token only as the fallback (`src/lib/github-org-token.ts`, one rule, tested).
Identity-scoped reads (the person's repo list, who they are) keep the person's
token. The 403 message names both remedies.

Verified: tsc, eslint, scripts/test/github-org-token.ts.


Claude-Session: https://claude.ai/code/session_01WSNERoZZqW2TgqbAGHSQZf

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-11 04:00:35 -07:00