steid

@jamesgill /

steid/plans/decisions/0011-home-is-an-instance-setting.md
Markdown4.3 KBRendered·Source·Blame·History·Raw
1# 0011 — The instance's owner is whichever organisation home points at
2
3**Status:** accepted · **Date:** 2026-09-27
4
5## Context
6
7[0010]0010-single-tenant-vcs-not-portfolio.md says an instance belongs to one owner,
8and that the owner is a person or an organisation chosen at initial setup. Nothing in
9the code said which. The root URL guessed: it forwarded a signed-in visitor to their own
10profile and everybody else to `sole_owner_handle` — the handle of the only user, when
11there is exactly one. That works for one person and cannot describe "this Steid is
12Acme's", which is the customer 0010 names.
13
14Three facts constrain the answer. Every handle is already an `Organization` row, a
15person's included, so there is nothing to invent. `orgs.kind` was proposed by
16[0003]0003-scoped-urls.md and dropped by [0004]0004-root-handles-grouped-routes.md,
17which makes "is this personal" an open question rather than a column. And
18`instance_owner` — the predicate the backup surface uses — deliberately answers `false`
19for everybody the moment a second user exists, so it cannot be what gates a change to
20the front door.
21
22## Decision
23
24**The instance's owner is whichever organisation `home` points at**, and `home` is an
25instance-level setting: one nullable `home_org_id` in a single-row `instance_settings`
26table, chosen in the setup wizard and changeable at `/{handle}/settings`.
27
28Four things follow, and are part of the decision:
29
301. **Unset falls back to the sole owner**, so every existing instance keeps the front
31 door it had and the migration changes nothing until somebody picks.
322. **Several organisations per instance are allowed**, and any signed-in user may create
33 one. That is not multi-tenancy: they share one database, one owner and one set of
34 people. Exactly one of them is home.
353. **Personal versus organisation is derived, not stored** — an organisation is personal
36 exactly when some user's `personal_org_id` points at it.
374. **The root lands on home for everyone**, signed in or not, and `orgs` and
38 `organizations` are reserved handles.
39
40Setting home requires owning the organisation being pointed at.
41
42## Alternatives considered
43
44- **A `home_org_id` column on `orgs`.** — Null on every row but one, so "which is home"
45 becomes a scan, and nothing stops two rows claiming it.
46- **A `kind` column on `orgs`** (`personal` | `shared`), as 0003 wanted. — A second
47 source of truth for something `users.personal_org_id` already says. It can disagree
48 with the foreign key; a derived answer cannot.
49- **Gate `set_home` on `instance_owner`.** — That predicate answers `false` for everybody
50 once a second user exists, which would make the front door unsettable on exactly the
51 instances that most need to set it.
52- **Keep the root sending signed-in visitors to their own page.** — Right for one
53 person, wrong for a company: a member landing on themselves rather than on their
54 employer's repositories is the front door pointing somewhere private.
55- **Make the owner a *user* rather than an organisation.** — Then "Acme Inc" needs a
56 fake person to be, and every URL below it is that person's. The handle namespace is
57 already shared; the owner may as well be the thing that holds repositories.
58
59## Consequences
60
61- **Makes easy:** saying what an instance is for, in one row and one sentence; a
62 provisioned machine arriving already pointed at its customer's organisation
63 (`STEID_OWNER_ORG`); moving the front door without renaming anybody.
64- **Makes hard:** anything that wants two front doors. There is one root and one home.
65- **Opens:** nothing lists the organisations a person belongs to, so a second one is
66 easy to create and hard to find until milestone 7's members work lands. There is no
67 way to *unset* home, only to move it. And `set_home`'s rule is a placeholder for the
68 instance-level role that does not exist yet — when it arrives, this is one of the
69 bodies that changes, beside `instance_owner`.
70- **Reservable-too-late risk, taken now:** `orgs` and `organizations` were reserved while
71 nobody held them, which 0004 says is the only moment it is free.
72- **Reversible** cheaply while unreleased: the table is additive and the fallback means
73 deleting the feature restores the old behaviour exactly. Once instances have chosen a
74 home, reversing it moves their front door.