| 1 | # Current |
| 2 | |
| 3 | > Keep this file short. One active step, one ordered backlog. Completed work moves to |
| 4 | > [progress.md](progress.md). If this file starts reading like a changelog, it has |
| 5 | > drifted — that's exactly what went wrong last time. |
| 6 | |
| 7 | ## Active: Milestone 1 — Identity, thin |
| 8 | |
| 9 | **Goal:** the app knows who you are. An unclaimed installation is claimed through |
| 10 | `/setup`, and the resulting owner can log in and out. Enough identity to hang a profile |
| 11 | page off, and no more. |
| 12 | |
| 13 | **Explicitly out of scope** — these are Milestone 7: multi-user registration, |
| 14 | invite codes, `RegistrationPolicy`, organisation management UI, roles beyond owner. |
| 15 | |
| 16 | ### Steps |
| 17 | |
| 18 | - [x] Domain: typed IDs, `Email`, `PasswordHash`, `User`, `Organization`, |
| 19 | `Membership`, `Role`, `Actor`, `DomainError` |
| 20 | - [x] Domain: repository traits — `UserRepository`, `OrgRepository`, |
| 21 | `MembershipRepository` |
| 22 | - [x] Infrastructure: in-memory implementations (these are what make use cases |
| 23 | testable without a database) |
| 24 | - [x] Application: `PasswordHasher` port + Argon2 adapter, stub hasher for tests |
| 25 | - [x] Domain: `SetupToken` — one-time claim secret, constant-time comparison |
| 26 | - [x] Application: `claim_instance` use case — token-gated, creates org → user → |
| 27 | owner membership, returns the owner signed in |
| 28 | - [x] Application: `login` use case — verifies credentials, returns an `Actor` |
| 29 | - [ ] Infrastructure: migrations `001`–`003`, SQLite implementations |
| 30 | - [ ] Infrastructure: `sessions` table + session storage |
| 31 | - [ ] Boot: mint and print a `SetupToken` when unclaimed; register it in app context |
| 32 | - [ ] Web: `/setup` claim page; every other route redirects there while unclaimed |
| 33 | - [ ] Web: login page, logout, `current_actor(cx)` helper |
| 34 | - [ ] `/api/me` — first `/api` route, proves the use case layer has two consumers |
| 35 | |
| 36 | ### Done when |
| 37 | |
| 38 | A fresh database prints a setup token at boot; `/setup` with that token creates the |
| 39 | owner and signs them in; logging out and back in works; `/api/me` returns that |
| 40 | identity. |
| 41 | |
| 42 | ### Watch for |
| 43 | |
| 44 | - **`__Host-` cookies need a secure context.** Topcoat's session cookie is |
| 45 | `__Host-`-prefixed and `Secure`. Browsers treat `http://localhost` as trustworthy so |
| 46 | dev over plain HTTP *should* work — verify this as soon as the login page exists, |
| 47 | because if it's wrong, login fails silently and looks like a bug in our code. |
| 48 | - **CSRF.** `SameSite=Lax` blocks cross-site POSTs, which covers the common case. |
| 49 | Whether forms also want tokens is an open decision, not a default to pick quietly. |
| 50 | - **Claim is TOCTOU.** `is_claimed` then write is not atomic; the `UNIQUE` constraints |
| 51 | on email and org name are what actually serialise concurrent claims. Integration-test |
| 52 | this once SQLite lands. |
| 53 | - **Foreign key ordering.** The org must be saved before the user — attempt #2 had to |
| 54 | fix this in both `bootstrap_owner` and `register_user`. See |
| 55 | [progress.md](progress.md#identity). |
| 56 | - **Bootstrap must be idempotent.** It runs on every boot, not just the first. |
| 57 | - Never log or `Debug`-print a password. `PasswordHash` is opaque on purpose. |
| 58 | |
| 59 | ## Backlog |
| 60 | |
| 61 | Ordered. Pull from the top. |
| 62 | |
| 63 | 1. **Milestone 2 — Profile page.** `/{owner}` becomes the real home page, replacing |
| 64 | the Milestone 0 placeholder. The frame the rest of the product hangs in. |
| 65 | 2. **Milestone 3 — Writing.** Posts, markdown rendering, `/{owner}/{slug}`. |
| 66 | *Open question: is writing actually the first portfolio feature, or is it |
| 67 | projects/showcases?* |
| 68 | 3. **Milestone 4 — Repo model.** `Repository` entity, `Visibility`, `create_repo`, |
| 69 | bare repo on disk at `{data_dir}/{org}/{repo}.git`. Watch the DB-plus-filesystem |
| 70 | atomicity problem — see [architecture.md](architecture.md#db-plus-filesystem-writes). |
| 71 | 4. **Milestone 5 — Git over HTTP.** `git http-backend` subprocess, PATs over HTTP |
| 72 | Basic. See [0001](decisions/0001-git-over-http-not-ssh.md). |
| 73 | |
| 74 | ## Open questions |
| 75 | |
| 76 | - **Topcoat is early** (v0.5.0, first released 2026-07-22, breaking changes expected |
| 77 | by its own authors). Expect churn that isn't feature work. |
| 78 | - Body size limits will reject large pushes at Milestone 5 — `topcoat-router` has a |
| 79 | `body_limit` layer that needs raising on the git routes. Recorded here because it |
| 80 | will surface as a confusing failure rather than a clear one. |
| 81 | - Topcoat ships Tailwind without Node, which reopens the design system attempt #1 |
| 82 | dropped purely to avoid an npm build step — see [ui.md](ui.md). |
| 83 | |
| 84 | ## Routing findings (Milestone 0) |
| 85 | |
| 86 | - **Topcoat 0.5 requires rustc ≥ 1.95.** On an older toolchain `cargo add topcoat` |
| 87 | silently resolves to an empty `topcoat v0.0.0` placeholder instead of failing. Local |
| 88 | stable is now 1.97.1. |
| 89 | - `Router::builder().discover()` collects `#[page]`-annotated items **at link time**, |
| 90 | so pages can live in any module. Layering is our choice, not the framework's. |
| 91 | - `module_router!` derives each URL from the module tree rather than a path string. |
| 92 | Still deferred — Steid's URL space is parameterised at the root (`/{owner}`, |
| 93 | `/{owner}/{repo}`), which means `path_param!` declarations inside route modules. |
| 94 | Worth designing at Milestone 2 when the profile page makes it concrete. |
| 95 | - Path and query params are read from `Cx` via `path_param!` / `#[query_params]`, not |
| 96 | injected as handler arguments. Parses are memoized per request. |
| 97 | - Layouts wrap by path prefix and nest outermost-first, and a layout can catch a page's |
| 98 | `NotFoundError` to render a branded 404. |
| 99 | - `HOST` / `PORT` configure the bind address, so `STEID_LISTEN_ADDR` is gone. |
| 100 | - `Body` is a boxed `http_body::Body` used for both requests and responses, with |
| 101 | `into_data_stream()` to read and `Body::new()` to wrap a stream — pack data can |
| 102 | stream both directions without buffering. This is what makes Milestone 5 viable. |