steid

@jamesgill /

steid/plans/decisions/0003-scoped-urls.md
Markdown4.1 KBRendered·Source·Blame·History·Raw
1# 0003 — Scope every URL under an explicit prefix
2
3**Status:** superseded by [0004]0004-root-handles-grouped-routes.md · **Date:** 2026-08-04
4
5> **Note, 2026-09-27.** The URL scheme recorded here still stands; its justification is
6> now [0010]0010-single-tenant-vcs-not-portfolio.md. The owner's handle — a person or
7> an organisation — is the front door of the instance, not a CV URL. The original text
8> is kept below as written.
9
10> **Superseded the same day.** The scoping principle held, but applying it to the
11> handle itself cost the short profile URL — which is part of the product for a
12> portfolio-first tool. [0004]0004-root-handles-grouped-routes.md keeps handles at the
13> root and groups the *application's* routes instead, which turns out to shrink the
14> denylist to a rarely-changing ten words rather than eliminating it. Kept for the
15> reasoning, which still applies below the handle.
16
17## Context
18
19Milestone 2 introduces the profile page, which fixes the shape of every URL after it.
20Forges conventionally put handles at the root — `/james`, `/james/my-repo` — following
21GitHub, GitLab, and Gitea.
22
23Root-level handles share one namespace with the application's own routes. `/setup`,
24`/login`, `/logout`, and `/api` already exist, and nothing stops a user claiming the
25handle `login`. That forces a reserved-word denylist which must grow every time a
26top-level route is added, and forgetting once means a profile shadows a real route or
27the reverse. It also makes a 404 ambiguous: unknown handle and unknown page are
28indistinguishable.
29
30## Decision
31
32Scope every URL under an explicit prefix. Handles are never at the root.
33
34```
35/user/{handle} personal profile
36/user/{handle}/repos/{name} repository
37/user/{handle}/posts/{slug} writing
38/org/{handle} shared organisation (Milestone 7)
39
40/login /logout /setup /api/... application routes, free to grow
41```
42
43Every segment says what the next one means, at every level. This is a general
44preference, not a one-off: prefer an explicit scope over an implicit one wherever the
45choice arises.
46
47Two prefixes rather than one because in Steid every handle is an `Organization` — a
48user's handle is their personal org's name. `/user/acme-corp` would be wrong once real
49organisations exist. Distinguishing them requires a `kind` discriminator on `orgs`
50(`personal` | `shared`), which is better modelling regardless: the two differ in
51whether they belong to exactly one user.
52
53## Alternatives considered
54
55- **Root handles plus a denylist** (GitHub, Gitea). Shortest URLs and the familiar
56 shape. Rejected: the denylist is unbounded maintenance, and the failure mode is a
57 silent collision rather than an error.
58- **Root handles plus a sigil for system routes** (`/-/login`, as GitLab moved to).
59 One reserved prefix instead of a growing list, and keeps `/james` clean. Rejected as
60 less consistent — it scopes the application's routes but leaves content unscoped, so
61 `/james/my-repo` and `/james/my-post` still share a namespace and can collide with
62 each other.
63- **A single neutral prefix for all handles** (`/o/{handle}`). Avoids needing a `kind`
64 discriminator. Rejected: opaque to read, and the discriminator is worth having on its
65 own merits.
66
67## Consequences
68
69- **No reserved words.** Any top-level route can be added forever without checking a
70 list, and handle validation stays purely about format.
71- **404s are unambiguous.** An unknown handle under `/user/` is a missing user; an
72 unknown top-level path is a missing page.
73- **Content types can't collide with each other.** `/user/james/repos/x` and
74 `/user/james/posts/x` coexist. Root-level schemes have to arbitrate.
75- **URLs are longer, and that costs something real.** `/user/james` is an app URL where
76 `/james` is a CV URL, and Steid is portfolio-first, so this is a genuine trade against
77 the product's own framing. Clone URLs inherit it:
78 `git clone https://host/user/james/repos/steid.git`.
79- **`orgs` needs a `kind` column** before Milestone 7. Adding it at Milestone 2, while
80 there is one row, is free.
81- Expensive to reverse once URLs are public — which is why it is being decided before
82 the first real page rather than after.