# 0011 — The instance's owner is whichever organisation home points at

**Status:** accepted · **Date:** 2026-09-27

## Context

[0010](0010-single-tenant-vcs-not-portfolio.md) says an instance belongs to one owner,
and that the owner is a person or an organisation chosen at initial setup. Nothing in
the code said which. The root URL guessed: it forwarded a signed-in visitor to their own
profile and everybody else to `sole_owner_handle` — the handle of the only user, when
there is exactly one. That works for one person and cannot describe "this Steid is
Acme's", which is the customer 0010 names.

Three facts constrain the answer. Every handle is already an `Organization` row, a
person's included, so there is nothing to invent. `orgs.kind` was proposed by
[0003](0003-scoped-urls.md) and dropped by [0004](0004-root-handles-grouped-routes.md),
which makes "is this personal" an open question rather than a column. And
`instance_owner` — the predicate the backup surface uses — deliberately answers `false`
for everybody the moment a second user exists, so it cannot be what gates a change to
the front door.

## Decision

**The instance's owner is whichever organisation `home` points at**, and `home` is an
instance-level setting: one nullable `home_org_id` in a single-row `instance_settings`
table, chosen in the setup wizard and changeable at `/{handle}/settings`.

Four things follow, and are part of the decision:

1. **Unset falls back to the sole owner**, so every existing instance keeps the front
   door it had and the migration changes nothing until somebody picks.
2. **Several organisations per instance are allowed**, and any signed-in user may create
   one. That is not multi-tenancy: they share one database, one owner and one set of
   people. Exactly one of them is home.
3. **Personal versus organisation is derived, not stored** — an organisation is personal
   exactly when some user's `personal_org_id` points at it.
4. **The root lands on home for everyone**, signed in or not, and `orgs` and
   `organizations` are reserved handles.

Setting home requires owning the organisation being pointed at.

## Alternatives considered

- **A `home_org_id` column on `orgs`.** — Null on every row but one, so "which is home"
  becomes a scan, and nothing stops two rows claiming it.
- **A `kind` column on `orgs`** (`personal` | `shared`), as 0003 wanted. — A second
  source of truth for something `users.personal_org_id` already says. It can disagree
  with the foreign key; a derived answer cannot.
- **Gate `set_home` on `instance_owner`.** — That predicate answers `false` for everybody
  once a second user exists, which would make the front door unsettable on exactly the
  instances that most need to set it.
- **Keep the root sending signed-in visitors to their own page.** — Right for one
  person, wrong for a company: a member landing on themselves rather than on their
  employer's repositories is the front door pointing somewhere private.
- **Make the owner a *user* rather than an organisation.** — Then "Acme Inc" needs a
  fake person to be, and every URL below it is that person's. The handle namespace is
  already shared; the owner may as well be the thing that holds repositories.

## Consequences

- **Makes easy:** saying what an instance is for, in one row and one sentence; a
  provisioned machine arriving already pointed at its customer's organisation
  (`STEID_OWNER_ORG`); moving the front door without renaming anybody.
- **Makes hard:** anything that wants two front doors. There is one root and one home.
- **Opens:** nothing lists the organisations a person belongs to, so a second one is
  easy to create and hard to find until milestone 7's members work lands. There is no
  way to *unset* home, only to move it. And `set_home`'s rule is a placeholder for the
  instance-level role that does not exist yet — when it arrives, this is one of the
  bodies that changes, beside `instance_owner`.
- **Reservable-too-late risk, taken now:** `orgs` and `organizations` were reserved while
  nobody held them, which 0004 says is the only moment it is free.
- **Reversible** cheaply while unreleased: the table is additive and the fallback means
  deleting the feature restores the old behaviour exactly. Once instances have chosen a
  home, reversing it moves their front door.
