# Current

> Keep this file short. One active step, one ordered backlog. Completed work moves to
> [progress.md](progress.md). If this file starts reading like a changelog, it has
> drifted — that's exactly what went wrong last time.

## Active: 0.8.0 — organisations and home (first slice of milestone 7)

**Goal:** an instance is *for* somebody — a company or a person — and says so at its
root. Organisations become creatable, one of them is the home page, and a new
repository is private unless you say otherwise.

**Out of scope, deliberately:** members and roles UI, invitations, registration, token
scopes, invisible mode. Those are the rest of milestone 7.

### Steps

- [x] `instance_settings` — a single-row table holding `home_org_id`, its domain type,
      port and two implementations
- [x] `create_organization`, `home_handle`, `set_home`, and personal-vs-organisation
      derived from `User.personal_org_id` rather than stored
- [x] Private by default — `Visibility::default()`, the create form, the import form
- [x] `/orgs/new`, organisation settings at `/{handle}/settings`, and the root landing
      on home for everyone
- [x] Setup is three screens: claim, "Who is this Steid for?", done. `?token=` prefills
      the claim field so a claim link can carry it
- [x] `STEID_OWNER_ORG` / `STEID_OWNER_ORG_NAME` on the headless seed, and
      `--owner-org` / `--owner-org-name` on `install.sh`
- [x] Version 0.8.0, [ADR 0011](decisions/0011-home-is-an-instance-setting.md), README
      and runbook

### Done when

A fresh instance can be claimed, told it is Acme's, and land every visitor on `/acme`;
and a provisioned one arrives that way with no wizard at all. **Both verified by hand
on 2026-09-27** — claim → wizard → `/globex` → a repository that defaulted to private →
`/globex/settings` → an anonymous `curl -I /` answering `307 → /globex`; and a second
data dir seeded from the environment landing on `/initech`.

### Open, carried forward

- **No way to unset home**, only to move it. An instance with none falls back to its
  sole owner, which is a state a fresh instance is in rather than one anybody chooses,
  so the button says "make this the home page" and there is no "stop being it".
- **Nothing lists the organisations you belong to.** `/orgs/new` is reachable only by
  typing it: no header link, no list on a person's page. That is milestone 7's members
  work, and until it lands a second organisation is easy to create and hard to find.
- **`/api` says nothing about home.** `InstanceReport` had no natural place for it and
  the brief said not to invent one, so the API is unchanged.
- **The setup pages are unstyled**, as they always have been — plain `<p><label>` markup
  rather than the component set the rest of the app uses. The new wizard screens are
  styled; `/auth/setup` and `/auth/login` still are not.

### Open


- **`MAX_RAW_BYTES` is 10 MiB**, chosen rather than derived. It bounds what one raw
  request can hold in memory, because `GitQuery` reads bytes rather than streaming them.
  Raising it means a handful of concurrent requests can hold that much each.
- **The profile has no links.** `Organization` carries a display name and a bio and
  nothing else, so the design's links row is not backed by data and was left out rather
  than faked. A `links` field plus a settings control is the small feature that fixes it.
- ~~**`create_repo` and `serve_git` read the clock internally**~~ — **closed.** Both take
  a `now`; the [`Clock`](../src/application/port.rs) port covers the one case that cannot
  (webhook delivery, which reads per attempt). **`import_repo` and `run_import` still
  read the clock internally** — a background task that runs for minutes has no caller's
  `now` worth taking, so it is the next `Clock` caller rather than a `now` one.
- **A push touches `updated_at` twice** — once for the advertisement, once for the RPC.
  Harmless, same second, but two writes per push.
- **A licence.** A public repository probably wants one, and the README
  deliberately says nothing about licensing rather than guessing.
- ~~Blocked on a domain transfer~~ — **transferred 2026-08-29**, so Phases 1–6 of the
  deployment runbook are unblocked.
- **(historic) Blocked on a domain transfer** (noted 2026-08-29). `jpgill.dev` is the
  intended host for both the instance and the release downloads; the transfer is in
  flight. Phases 1–6 of the deployment runbook cannot start until DNS resolves, because
  Caddy requests a certificate on startup. Nothing else is blocked by it — the artifact
  is built and verified, and `install.sh` still needs its container dry-run.
- **A domain.** Caddy needs a real hostname to obtain a certificate. This is the one
  blocker that is DNS rather than code.

### Open

- **Whether an absent *public* repository can 404 while private ones still 401.** The
  uniform 401 from [0007](decisions/0007-tokens-over-http-basic.md) is what makes a
  private repository indistinguishable from one that does not exist — but it also turns
  every mistyped URL into "Authentication failed", which cost real time on the first
  deployment. The leak being prevented concerns *private* names only, so answering 404 for
  a repository that would be public if it existed may cost nothing. Needs thought about
  whether that is actually true.
- **Zero-downtime deploys — deferred, deliberately.** `deploy.sh` currently stops the
  service, swaps the binary and starts it: about two seconds. The plan, when it is worth
  building: a systemd **template unit** `steid@.service` where the instance name *is* the
  port, with `/opt/steid/3000` and `/opt/steid/3001` as separate install directories.
  Deploy alternates — install to the idle port, start it, health-check it **directly on
  loopback**, rewrite Caddy's upstream and `caddy reload` (graceful; existing connections
  finish), then stop and disable the old one and enable the new so a reboot brings back
  the right one.

  Two things make this more than a shell script, and they are the reason it is deferred
  rather than half-built:

  - **Both processes share one SQLite database during the overlap.** WAL allows that, and
    Steid's writes are short, so the overlap itself is fine. **Migrations are not.** The
    new binary migrates on boot while the old one is still serving, so any schema change
    that the old binary cannot tolerate — a new `NOT NULL` column, a dropped column —
    breaks the still-live version. That is a constraint on how migrations are written
    (**expand, deploy, contract**), not something the deploy script can solve.
  - **An in-flight `git push` is cut when the old process stops.** `topcoat::start`
    already drains on SIGTERM, so the fix is to stop the old one *after* Caddy has
    repointed and let it finish what it has.

  Worth building when instances belong to other people. At two seconds on one owner's instance,
  it buys nothing today.
- **Scheduled backups** are now `install.sh --backups daily` (off by default) and `steid backup`; the control plane ships them offsite. Historic: `/var/lib/steid` is the whole of the state and copies of it
  exist only because they were taken by hand. This is the largest gap now that the
  instance is live.
- ~~Releases are not served from the instance yet~~ — **served, 2026-09-08**; artefacts at `/srv/steid-dist`, published by `deploy.sh --publish`. What follows is historic: The Caddy blocks are written and
  commented in `deploy/Caddyfile`, and `install.sh`'s `RELEASE_BASE_URL` points at
  `/jamesgill/repos/steid/releases`, but nothing has been rsynced there — so the
  one-command install a stranger would run does not work yet.

### Opened by the section 1 wave

- **Diffs, READMEs and markdown code fences are unhighlighted.** The README goes through
  `web/markdown.rs`, which writes its own `<pre><code>`; wiring `highlight.rs` into it is
  a small follow-up. Blame was the fourth of these and is now done, so the adapter is
  reached from two pages and the pattern for a third is set: build the file's text in
  line order, call `source_lines` **once**, render `Classed` through `Unescaped`.
- ~~`.jsx` is plain~~ — **aliased onto JavaScript.** `highlight.rs` gained an `ALIASES`
  table, consulted only after the syntax set's own answer, so an alias can never
  overrule a real grammar. It has one entry and should stay small.
- **`\r\n` files keep the `\r` inside highlighted markup.** Invisible under
  `white-space: pre`; noted rather than fixed.
- **The blob header does not name the detected language.** It is only visible as colour.

- **No ahead/behind counts on the branches page**, by decision: a `rev-list` per branch
  is twenty forks for twenty branches. Waits for a kept-alive git.
- ~~Neither refs page is paginated~~ — **both page**, 100 rows each, sliced in the use
  case rather than in the port: `for-each-ref` returns every ref in one process, so a
  `limit` there would buy nothing and cost a second call for the count. The settings
  form's default-branch `<select>` asks for `None` and still gets every branch — an
  option missing from it would be a branch nobody could choose.
- **A repository with tags but no branches** says "No branches"; real but exotic, not
  fixture-tested.
- **`web::browse::{encode, timestamp}` are now `pub(super)`**, and `repo_stats` takes
  `handle` and `name` so the sidebar counts can link. `timed_out` has since moved to
  `web::context`, as this said it should.

- **`git grep` output is collected whole before it is capped.** A one-letter query on a
  big repository allocates all of git's output to keep 200 hits. Bounded by the 20 s
  timeout, not by anything deliberate.
- ~~The archive endpoint has no rate limiting~~ — limited (10/client/min). It is outside the read timeout, on
  purpose (a large repository legitimately takes longer to pack). It is the most
  expensive anonymous request in Steid: a full pack per hit. First thing to look at under
  load. A late `git archive` failure is a truncated download, logged like the protocol
  server's.
- ~~Search has no paging~~ — **results page**, ~200 matches a page, **cut at a file
  boundary rather than a line**: a file's matches are one block under its path, so a
  page that ended mid-file would print the heading twice and split what reads as one
  thing. A page holding a 300-match file overshoots instead, which is the right way
  round. A search collects at most `SEARCH_MAX_MATCHES` (1,000) across all its pages —
  paging must not turn a one-letter query into unbounded work, since `git grep` output
  is still collected whole — and past that the page says to narrow the search.
  **Every page re-runs the grep**; there is no cursor a second page could resume from.
  Search still `trim()`s the query, cuts matched lines at 500 characters (which can
  remove the match on a minified line), and ignores `GrepHit::column` when marking.

- **The commit page's timeout state has never been rendered**, like search's and the
  refs pages'. The predicate itself is now `web::context::timed_out`, shared by `refs`,
  `commit` and `blame`; each page still writes its own panel, and `search_repo` still
  answers in the application layer.
- **`Diff::files` is emptied wholesale when the patch is truncated**, falling back to the
  numstat list, so a 10 MiB commit shows no lines rather than the first few files.
  numstat itself could in principle be truncated at ~300,000 changed files.
- **A merge commit is diffed against its first parent only**, and merge rendering was
  compiled, not seen: no fixture contains one.
- **`MAX_RAW_BYTES` now does a second job** as the diff cap; retune both together.
- **`bg-surface` is nearly `bg-background` in light mode**, so a file header reads only
  by its border there. Pre-existing, but the commit page has one per file.
- ~~No paging anywhere in history~~ — **`/log` and a comparison's commit list page**,
  `?page=N`, 50 and 100 a page, with the shared control from [ui.md](ui.md#paging).
  Each costs its page a `rev-list --count`. **A comparison's diff does not page**: it is
  what the whole range changes, so it is the same on page 2 as on page 1, and a range
  wide enough to need paging still renders one diff capped by `MAX_RAW_BYTES`.
- **The compare form's `<datalist>` costs a `list_refs`** rendered inline on every visit.
- ~~Nothing links to a commit by its sha yet~~ — done.

- ~~The blame page has no revision switcher~~ — **added**, and `Switch` in
  `web/browse.rs` now has a `Blame` arm, so switching branch keeps you on blame at the
  same path. It costs the page one `list_refs`, which is what the wave deferred.
- **`BlameCommit::boundary` and `author_name` reach only the tooltip.** The row is sha,
  summary, date and must stay one line. On a multi-user instance the author is the first
  thing to revisit.
- **Blame is the most expensive read in `GitQuery`** and the likeliest to meet the 20 s
  timeout. Nothing but this page calls it. ~~It also pays a second existence check~~ —
  the check is now a line to a running `cat-file`, so the page costs two processes
  rather than five and the double check costs no fork at all.
- ~~Cross-branch links were verified only after the merge~~ — **walked, 2026-09-05**,
  see the integration pass below.

#### The integration pass — 2026-09-05

The five branches merged and run as one app, on a real instance holding Steid's own
history: 9 branches, 2 annotated tags, one public repository and one private. Every
link that crosses a feature boundary was followed in a browser, and **nothing was
broken at a seam.** Landing sha → commit page; log sha → commit; commit's "Browse
files" → tree at that sha and its parent sha → the parent's page; the counts and the
sidebar → branches and tags; a branch row → tree, log and a compare with a real diff
(a merged branch correctly says there is nothing to compare); a search hit's line
number → `blob#L<n>` with the anchor present and landing; `Code · Blame · Raw` in both
directions; blame's sha → the commit page and its line number → the blob anchor;
`zip` and `tar.gz` for `main` and for a tag, both extracting under `steid-<rev>/`.
**A private repository 404s on all eleven routes anonymously** — landing, log,
branches, tags, commit, search, tree, blame, raw, archive, compare. Highlighting still
renders after the blame toggle and the anchor edits landed on the same table: Rust and
TOML coloured, a plain file not. Screenshots of the whole flow in dark and light are
in `target/shots/`.

Two things the pass found, neither a break:

- **The sidebar's Download links can only ever offer the default branch.**
  `clone_block` takes a revision and its doc says the links are "for the revision being
  viewed", but the sidebar renders only on the landing page, which has no `{rev}` — and
  the tree and blob pages, which do, are single-column by design. So a tag's tarball is
  reachable only by typing `/archive/v0.2.0.zip`. Both formats work at both revisions;
  it is the entry point that is missing, and putting it on the tree page means deciding
  whether that page gets a sidebar, which [ui.md](ui.md#the-repository-page) settled the
  other way.
- ~~Blame renders its lines unhighlighted while the blob highlights them~~ — **closed.**
  Blame's code cell now goes through `source_lines`, the blob's own adapter, so the two
  views share classes, caps and plain fallback. Both render the same file to an
  identical set of `hl-` spans, and rows stay 19.5px — the only variance is at a run's
  hairline, which is `border-collapse` splitting that 1px, not the markup.

### Opened by wave 2

Everything struck through here has moved to [progress.md](progress.md); what is left is
what is still open.

- **A rename can strand a directory** if the process dies between the move and the row
  write; same class as create's orphan, and the reconciliation sweep now has two shapes
  to handle. **A rename races**: two renames onto one name both pass the free check and
  the loser gets "name taken" for the wrong reason.
- **Renaming touches nothing that stores the old name outside the row**, which the
  integration pass walked: hooks, their delivery log and issues all followed a rename, and
  the next push's payload named the new repository and URL. A webhook *target* or an issue
  reference would have to be renamed with it.
- **Every use case that rebuilds through `Repository::new()` must carry the fields
  `new()` resets** — `pinned`, `archived`, and now the import trio. `update_repo` was
  missing the trio, which is how a visibility save during a real import ended the import
  as far as Steid was concerned. The next field added to `Repository` outside the
  constructor has the same trap waiting; a builder that took the whole existing row would
  close it for good.
- **The settings page costs a git process** (`branches()`, for the select) — except
  during an import, when it is skipped.
- **The profile's Repositories tab pages at 50**, sliced *after* the visibility filter
  so page 2 is never short by however many private repositories page 1 counted. The
  overview and `/api/…/repos` both ask for the whole list (`None`) and are unchanged.

- **A rejected issue burns a number** (allocated before validation); a gap costs
  nothing next to a reused number. ~~No paging on issue lists~~ — **they page**, 50 a
  page, and the state and label filters travel with the page number (`filtered_url`
  builds all three, with tests). **A label-filtered list is still read whole**: which
  labels an issue wears lives in a second table the list already reads to render its
  pills, so the filter is applied in the use case and the page cut after it — the
  unfiltered path is the one `limit`/`offset` serves.
- **Owner-only issue writes are the single-user assumption showing.** Milestone 7 wants
  anyone to open an issue on a public repository: a change to `writable_repo` only,
  `author_id` is already stored and rendered.
- No labels, assignees, milestones, search, cross-links (`#3` is plain text) or edit
  history. `closed_at` is cleared on reopen. Body cap 65,536 characters, chosen.

- **Imports have no size cap and no concurrency limit.** A 10 GB source fills the disk;
  N submissions are N concurrent clones — the pass ran four at once without trouble, which
  is evidence about a laptop and not about a server. A semaphore in app context is the
  small fix; a disk-space check or `--depth` the other. **No retry control** — the row
  keeps its source, so a Retry button on the failed panel is small. **An import starts
  public** and the settings form can make it private while it runs.
- **DNS is resolved twice** for imports (check, then git); a TTL flip between the two is
  the gap. `.local` (mDNS) is not refused by *import* — `WebhookUrl` does refuse it, and
  the same suffix list would suit both. `is_public` is a denylist of IANA ranges, now
  shared with webhooks in `domain/net.rs`.
- **Search on an importing repository answers 200 with no matches**, where the archive
  and blame routes answer 404 and the panel says what is happening. Nothing is wrong, but
  "no matches in a repository that has no contents yet" is a sentence the page could say.
  The refs pages answer 200 there too; what they render was not read closely.

- **Webhook retries do not survive a restart**; the rows written so far stay. A durable
  queue is a different feature. **DNS rebinding is not closed** for hooks or imports.
- **`webhooks.active` is honoured everywhere but nothing toggles it** (one POST and one
  button). ~~The deliveries page is capped at 50, unpaged~~ — **it pages**, 50 attempts
  a page, and the port gained `count_by_webhook` for the numbers. **Redelivery now reads
  a hook's whole delivery history**: the button can sit on any page, and the attempt
  number it writes counts every attempt the *event* has had — which the old 50-row
  window got wrong as soon as an event fell out of it. Correct, but unbounded on a hook
  with a long history; a `find` by delivery id plus a per-event attempt count would
  close it. `push_events` only grows and has no page: the obvious next use is an
  activity feed.
- ~~**`deliver_push` reads the clock internally**~~ — it takes a `Clock` now. It still
  takes no `Actor`: authorization is settled once in `record_push`.
- **Slow endpoints hold a task ~2.5 minutes per push**, bounded by hooks per repository,
  which nothing caps.
- **`STEID_ALLOW_PRIVATE_WEBHOOKS` is a real hole when it is on**, which is why it is off
  by default, warned about at boot and documented in [runbook.md](runbook.md) beside
  `STEID_INSECURE_COOKIES`. A deployed instance with it set lets anyone who can add a hook
  read its own network's responses off the deliveries page.

#### The paging pass — 2026-09-06

Walked on a real instance on port 3118 holding this repository's own history (182
commits, three branches, two tags) and 62 issues opened through the form:

- `/log` at 182 commits: pages 1, 2 and 4 each say `Showing 51–100 of 182 commits` and
  the like, `?page=400` and `?page=banana` both render page 4 and page 1 rather than an
  error, and a branch force-pushed from 182 commits down to 2 answers a bookmarked
  `?page=4` with those two commits and no control.
- Issues at 62: the state and label filters survive a page (`?label=bug&page=2` says
  "Showing 51–59 of 59 open issues labelled bug"), and the Open/Closed links keep the
  label while dropping the page.
- A comparison of 180 commits pages at 100; search for `let` pages six times over 1,000
  matches with uneven pages, which is the file-boundary cut doing its job; a hook with
  60 seeded deliveries pages at 50. Branches, tags and the profile's one repository
  render no control at all, which is the one-page case.
- **Not walked**: a redelivery from page 2 (it would have sent a real request to the
  hook's endpoint) — the widened read is covered by tests only; and the deliveries rows
  were seeded into SQLite rather than earned by pushes.

Screenshots in `target/shots/`, `paging-*`.

#### The wave 2 integration pass — 2026-09-06

The four branches merged and run as one app on port 3111, holding Steid's own history
with two annotated tags, four imported repositories (ripgrep, cargo, clippy,
rust-analyzer) and a private one. **Two things were broken at a seam, both in the same
place: a use case that rebuilt a `Repository` and dropped a field.** See
[progress.md](progress.md) for the walk and the decisions; the ones that constrain future
work:

- **Issues stay open for writing on an archived repository**, and on an importing one.
  Archiving says the *code* is finished, and an import is about the code arriving; a
  tracker that closed itself because the code was done would be the wrong shape for the
  conversation that follows a release.
- **Rename and Archive are refused while an import is landing**, with the sentence the
  transport gives a push. Both fight the clone for the directory. **Hooks may be added**
  during an import, and the description, visibility and pin form still saves: none of
  those touches the directory.
- **Delete is deliberately outside the write guard.** Deleting is how a stuck import is
  cleared, and the failed panel says so.
- **An import can never land in an archived repository**: it creates a repository, so an
  existing name is refused as taken before anything is cloned.
- **An anonymous POST to a private repository's routes answers 400**, not 404 — the form
  parser refuses a body before any use case runs. It is the same 400 an unknown repository
  gives, so nothing leaks, but the reasoning is the form parser's rather than ours.

### Opened by wave 3

- **A reference is not styled by state** (closed vs open, existing vs not); that needs a
  batch lookup per body, not a query per reference. Cross-repository references
  (`ada/steid#12`) and full Steid URLs are plain text.
- **Fences are highlighted on every render, uncached** — now paid by the README on the
  landing page, the most-visited page, which is where the missing cache shows first.
- ~~Diffs, READMEs and markdown code fences are unhighlighted~~ — READMEs and fences
  done; diffs still plain.

- **Nothing sweeps expired tokens and nothing warns before expiry** (no notification
  channel exists). `GIT_PER_CLIENT = 60` is reasoned, not measured. The git limiter keys
  on `X-Forwarded-For` like the login one, so `STEID_TRUSTED_PROXY` now guards two
  endpoints' worth of question. `list_tokens` and `authenticate_token` take a `now`;
  ~~`create_repo` and `serve_git` still read the clock~~ — all four closed.
- ~~Tokens have no expiry and no last-used timestamp~~ — done.
  ~~No rate limiting on token authentication~~ — done.

- **Feeds**: `?rev=` naming a missing branch answers 200 and empty; issue feed content
  carries Tailwind classes (harmless in a reader, which ignores classes it has no
  stylesheet for); the issue feed orders by `created_at` while entries'
  `<updated>` is `updated_at`; same-second events tie-break by id; no `ETag`,
  `Last-Modified` or rate limit; an importing repository feeds an empty commit list.
- ~~Feed content's cross-links were relative~~ — **absolute now**; `Crossref` carries an
  optional `origin` the feed sets and every page leaves `None`.
- **Steid has no per-page `<title>`**, and a page cannot contribute to `<head>`; see the
  feeds entry in progress.md for the shape of the fix.

- **Labels**: the delete confirm is a client-side `required` checkbox (a direct POST
  bypasses it — a confirm for a person, not an authorization); the labels list is
  unpaged; no bulk labelling, multi-label or "unlabelled" filter; renaming a label
  breaks bookmarked `?label=` URLs; no `/api` surface. ~~The palette lives in both
  `LabelColour::ALL` and `styles.css`~~ — it still does, but a test in `web/labels.rs`
  now reads the stylesheet and asserts the two agree in both directions, so a ninth
  colour cannot be half added.

- **Polish leftovers**: ~~a redelivery beyond the last 50 attempts cannot be made~~ —
  closed, `redeliver` reads the hook's whole history now;
  ~~`redeliver` is the fourth internal clock read~~ — closed; the
  concurrency limit is not a size cap; "Queued" is process-local; a row stuck at
  `importing` because the recording failed cannot be retried until a restart; the
  search switcher costs a `for-each-ref`; `language_of` re-runs `syntax_for`; ~~a handle
  called `orphaned` is never reconciled~~ — it is a reserved handle now, pinned by a
  test beside `QUARANTINE`; nothing
  reconciles a row whose directory is missing.
- ~~An orphaned repo directory is possible~~ — swept aside on boot now.
- ~~The sidebar's Download links can only ever offer the default branch~~ — the tags
  page carries each tag's archives, which closes the entry point.

#### The wave 3 integration pass — 2026-09-06

The six branches — tokens, labels, cross-links, feeds, the polish bundle and paging —
merged and run as one app on port 3119, holding this repository's own history (190
commits, two branches, four tags), 62 issues opened through the form, three labels with
55 issues wearing `bug`, one public repository and one private. **One thing was broken
at a seam, and it was two branches meeting rather than either being wrong**: markdown
cross-links render a path with no host, which is right on a page and wrong in a feed,
where the content is read somewhere else entirely. `Crossref` gained an `origin`; the
page still passes `None`.

What was walked, and held:

- A `#12` and a bare sha in an issue body, and both again in the README on the landing
  page, each landing on the issue and the commit they name.
- Issues at 62 and 55 labelled: `?label=bug&page=2` says "Showing 51–55 of 55 open
  issues labelled bug", the Open/Closed links keep the label and drop the page.
- `/log` at 190 commits pages at 50; `?page=400` clamps to the last page and
  `?page=banana` to the first. The log's Feed link keeps `?rev=`, on a revision and on
  a paged revision, and `commits.atom?rev=older` is that branch's log.
- A token with a 30-day expiry clones and pushes; the tokens page then reads
  `Expires 2026-10-06 · Last used 4 minutes ago`.
- The tags page's `tar.gz` for `v0.3.0` downloads and extracts under `steid-v0.3.0/`.
- Search pages six times over 1,000 matches, the revision switcher carries the query and
  drops the page, and the blob header names Rust and TOML and says nothing for a file
  with no grammar.
- A webhook fired by a real push, then redelivered from its deliveries page: identical
  bytes, a fresh signature, recorded as `try 2` continuing the event's sequence.
- **Anonymous on the private repository 404s on every route**, the new ones included:
  landing, log, `log?page=2`, issues, `issues?label=bug&page=2`, labels, both feeds,
  tags, branches, search and the hooks page. Its name appears nowhere in the owner's
  public activity feed.

Two things the pass found, neither a break:

- **The Feed link on a filtered issue list offers the whole feed.** A feed has no
  filter concept, so a reader who clicks it from `?label=bug` subscribes to everything.
  Either the link should carry the filter or it should say "all issues".
- **`latest_tag` breaks a same-second tie by refname**, so two tags created in the same
  second show the alphabetically-first as "Latest tag". Only reachable from a fixture
  that tags twice in one second; git's own ordering, not ours.

Screenshots in `target/shots/`, `wave3-*`.

### Opened by the kept-alive `cat-file`

- **The pool holds memory nothing measures.** Two `git cat-file` processes per live
  repository, up to 64 of them, each holding its repository's pack indexes open. The
  caps are chosen rather than derived and there is no metric that says what one costs on
  a real instance — the first thing to look at if an instance's resident size surprises
  someone.
- **The pool is unmeasured under concurrency.** Requests serialise per repository per
  stream, which is right for one reader and untested for fifty: a second visitor's tree
  page queues behind the first's. A pool of N processes per repository is the fix if it
  ever shows, and it is a change to `cat_file.rs` alone.
- **A desync is a 500 with no retry.** Deliberate — the stream has lost its place and
  re-asking would answer from a process that is already gone — but it means one bad
  reply fails one request rather than degrading. Nothing has ever produced one outside
  the test that fakes it.
- **The last-commit column re-walks history on every tree page.** One `git log
  --name-only` capped at 500 commits, uncached, and a directory whose entries were all
  last touched beyond that cap pays the cap in full to attribute nothing. Caching it per
  (tree id, directory) would be exact — a directory's history cannot change while its
  tree id does not — and is the obvious next step if a tree page ever feels slow.
- **A merge attributes nothing.** `git log --name-only` prints no file list for a merge
  commit, so a file whose most recent change arrived by merge is attributed to the
  commit inside the branch rather than to the merge. git's answer, and the more useful
  one, but it means the column can name a commit that is not on the branch's first-parent
  line.
- **The column is not on the branches, tags or compare pages**, and nothing else lists
  files, so there is nowhere else it belongs yet. A pull request's file list would be the
  first.
- **`--batch-command` is left on the table** until Ubuntu 22.04 is out of support, at
  which point the pair of processes becomes one. Recorded in the ADR, not urgent.

### Opened by wave 4

**Wave 4 is closed.** Its six seams are done and the whole of it has been walked as one
app — see the pass below. What is left open is listed here.

- **Diff highlighting does not go through the cache**, and a hunk opened inside a
  multi-line string above it colours wrong (asserted, deliberate). **Nothing measures the
  cache** — no hit rate, resident size or eviction count — and it now sits beside two
  more unmeasured caps, the cat-file pool's and the merge cache's. The per-line 32-byte
  overhead is a guess, and so is the merge cache's 128-byte one.
- ~~Highlighting caches nothing~~ — done.

- ~~A followed history count is an uncapped walk~~ — **capped at 500**, the last-commit
  column's number, with `500+` on the page and the paging control offering only the pages
  that were counted. **The cap has never been reached on a real repository**: Steid's own
  longest file history is 52 commits, so only the tests exercise it.
  A path's history still runs two walks per page. A submodule's own commit is never
  resolved; nested `.gitmodules` are not read; the 100-link cap is chosen.
  ~~Rendered markdown headings have no ids~~ — **they do**, slugified and deduplicated,
  and the relative-link resolver now carries the `#fragment` across (found at a seam:
  the ids landed first and the resolver was still dropping fragments). Raw-route images
  are verified in Chrome only; Firefox and Safari may honour `nosniff` for images.
- ~~Submodule rendering was never seen~~ — seen, linked, tested, and walked.

- **Pull requests**: no assignees, reviews, milestones, `/api` or feed; owner-only
  writes (merging must stay owner-only at Milestone 7); the Conversation tab asks git 2–4
  questions per view — ~~and `merge_preview` writes unreferenced objects nothing gc's~~,
  which is now **once per pair of commits** rather than once per view, though the objects
  a first view writes are still unreferenced and still ungarbage-collected; the Commits
  and Files tabs re-run the comparison; squash lists at most 50 subjects; the strategy
  control is a native `<select>`; ~~"Closes #4" does nothing~~ — **it closes the issue and
  comments on it**; ~~the delete-source checkbox defaults on even when the source is the
  default branch~~ — **it opens unticked there**; `Unrelated` and the stale-ref refusal
  are tested, not walked.
- ~~Pull requests carry no labels~~ — **they do**, through a second join table; the
  reasoning is in [progress.md](progress.md). No assignees or milestones still.
- **A merged request's Commits and Files tabs go blank once its source branch is
  deleted.** Both tabs resolve the branches live, so "spike adds no commits to main" is
  what a merged-and-tidied request says about the change it landed. `merge_commit` is the
  one thing stored, which is why the Conversation tab still says what happened. Storing
  the source's head at merge time would fix it and is the same decision as storing a head
  while open, which was deliberately refused — worth revisiting as one question.
- **The last-commit column names the commit inside the branch, not the merge**, so a
  file that arrived by merge attributes to the branch commit rather than to
  "Merge pull request #3". That is `git log --name-only`'s own answer and the existing
  decision (see the cat-file section above), but it is the one place the wave's features
  meet and disagree about what a file's last change *was*. Changing it means walking
  with `-m --first-parent`, which changes what the column means everywhere — a decision,
  not a fix.

#### The wave 4 integration pass — 2026-09-06

The four branches merged, the six seams built, and the result run as one app on a real
instance: this repository pushed with six branches and two tags, plus a purpose-built
fixture repository (a rename, a submodule, a markdown file with headings, a conflicting
pair of branches) and one private repository. Walked in a browser and with `curl`:

- a pull request's **Files changed** shows highlighted diffs, Rust and markdown alike;
- the compare page's **Create pull request** carries both branches into the form, which
  prefills the title from a one-commit branch and opens a request that **merges**;
- a merged request's sha **lands on the commit page**, and the fast-forward merge left
  `main` alone because the box was unticked — which is seam 1, seen in a browser;
- **`Closes #1`** in a merged request's body closed issue 1 and left a comment naming the
  request and the branch it landed on; the `#3` in that comment points at `/issues/3`,
  which 303s to `/pulls/3` — the cross-kind redirect doing its job;
- a file's **History** follows the rename, and each row's sha reaches a commit page whose
  diff is highlighted;
- a rendered markdown file's headings carry ids and the README's
  `docs/notes.md#the-second-section` **lands on the section** — after the fix below;
- a **submodule row** links to `https://github.com/rust-lang/log.git` at its pinned sha;
- a **labelled pull request filters**: `?label=bug` narrows the list and all three state
  counts follow it, and the labels page counts issues and requests apart;
- the tree page's **last-commit column survived `pkill -f 'cat-file --batch'`** — same
  page, same 70 ms, two fresh processes;
- a **conflicted request** costs one `merge-tree`: 43 ms on the first view, ~18 ms
  after, and five more views wrote **no new loose objects**;
- **anonymous on a private repository 404s on every route this wave touched** — fourteen
  GETs and four POSTs, and the two POSTs that answer 400 answer it identically for a
  repository that does not exist, so nothing is leaked.

**One thing broke at a seam and was fixed**: heading ids landed in the renderer while
both relative-link resolvers were still stripping `#fragment` from a rewritten link, so a
README's link to a section of another file went to the top of that file. The fragment is
now carried across.

### Opened by the ops step

- **The operator token has no rotation, expiry or hash at rest**; it lives in
  `/etc/steid/steid.env` at mode 640 and is compared in constant time. Unlike a PAT, and
  worth stating before anyone assumes symmetry.
- **`POST /api/setup` shares `/auth/login`'s limiter**, so a flood of headless claim
  attempts can lock the owner out of the form for a minute. Same secret under attack;
  the right way round, but a coupling.
- **`STEID_TRUSTED_PROXY` assumes one proxy hop**, and nothing checks the flag matches
  reality; no boot warning, because it is correct in the shipped install.
- **`/api/instance` reports no ~~disk,~~ memory or cache numbers**; the unmeasured caps
  would land there. **Disk landed in 0.7.0** — `disk.{data_dir_bytes,
  filesystem_total_bytes, filesystem_free_bytes}`, operator shape only, the walk cached
  for a minute. Memory and the cache sizes are still nowhere: RSS needs a per-platform
  read (`/proc/self/statm` on Linux, nothing portable), and the LRU caches would each
  have to learn to report their own weight.
- `web/instance.rs` holds both routes rather than `web/api.rs`, to keep five branches
  off one file; if `/api` grows, move them.
- ~~Whether to add `STEID_TRUSTED_PROXY`~~ — added.

- **Metrics**: `active_imports` never observed above zero and `cat_file_respawns` only
  unit-tested; no process-level metrics (RSS, fds) and no histograms yet — request
  duration is the obvious next family, buckets need real traffic. **`classify()` is a
  second statement of the URL layout**: a new top-level route shape needs a line there or
  it counts as `page`; a new git subcommand needs a `GIT_COMMANDS` line or counts as `other`.

- **`is_instance_owner` = the sole user**, so the backup download fails closed the day
  Milestone 7 adds a second user. Deliberate; wants an instance-level role then.
- **Nothing sweeps `<data_dir>/.backup`**: a process killed mid-backup leaves a full copy
  of the database there, invisible and as large as the database. A boot sweep beside the
  other three is the fix. **No test covers the backup web route** (404 for a stranger,
  unlink-while-open, headers) — hand-verified only. **A directory destination that does
  not exist is written as a file**, and a never-migrated database gives an ugly error.
- **`--backups daily` was verified against a stubbed `systemctl`**, not real systemd;
  cross-filesystem restore and multi-megabyte archives untested. Backups stay on the same
  machine unless the operator ships them; the control plane will.

- ~~**No password policy anywhere**~~ — **closed**. `domain::Password::new` is the one
  rule: **at least 12 characters, no composition rule**, with a 512-byte ceiling to bound
  Argon2's work. `claim_instance`, `reset_password` and `change_password` all go through
  it, and the setup form, the reset page and the settings page print `Password::RULE`
  itself rather than three paraphrases. **`POST /api/setup` deliberately does not** — a
  short password gets the same opaque 404 as a wrong token, with the reason in the log,
  because a response that named the password would tell a stranger guessing tokens that
  they had guessed one. Existing passwords are never re-checked, so sign-in is unaffected.
- **A forgot hit still costs an SMTP round trip a miss does not** — a send queue closes it.
  **Nothing sweeps `password_resets`** (or `sessions`); one periodic sweep wants both.
- **`/{handle}/settings` and its password POST answer 403, not the wave's 404** —
  pre-existing; the one write-failure mapping from the review closes it.
- **`/auth/login` and `/auth/setup` are still unstyled**, and the reset flow now ends on
  the login page, so restyling them rose in priority.
- TLS submission to a real relay was not exercised (plaintext to a local sink only).

- **`InMemoryGitQuery` is re-exported from `infrastructure::git`** so a dozen use-case
  test modules did not have to change during the wave. Repoint them at
  `git_query::InMemoryGitQuery` and drop the re-export once nothing else is in flight.

- **`labels::encode` is a fourth copy of `urls::encode(v, false)`**; one line to fold.
  **`context.rs` now imports `repo_for` and `profile_for`** from two page modules;
  review step 4 (`web/frame.rs`) should take `owned_repo` with the resolver. `owned_repo`
  and `owned_profile` have no unit tests — they need a `Cx`; there is still no HTTP-level
  test in the tree.
- ~~`/{handle}/settings` and its password POST answer 403~~ — 404 now, with seven others.

- **The forward migration check is untested**: nothing runs the previous release's
  binary against the current schema. A release-script step downloading the last tarball
  would close it; a wave slot, not a test.

- **`claim::sole_owner_handle` still calls `users.sole_user()` directly** — a lookup
  (where `/` redirects), not a predicate; revisit at M7 since both go `None` on a second
  user. **No second-user test exists at the HTTP level** because no registration route
  exists; the in-memory test covers it until the harness lands.

- **`tests/http.rs` cannot render a view** (empty asset bundle), so 303-after-POST and the
  `__Host-` cookie attributes are still hand-verified. Loading the real bundle in tests
  needs `topcoat asset bundle` in the test gate or a checked-in manifest — decide.
- ~~no test can build a `Cx` / no HTTP-level test~~ — `tests/http.rs` exists; four tests.

- ~~`Limiter::Search` is not on the metrics enum~~ — added. **No page renders `TooLarge`**: the five
  that guard on `context::timed_out` would 500 on it with a "took too long" copy that
  would be a lie; extend the shared helper. Both post-merge.
- ~~search page has no rate limit; `run` collects uncapped~~ — done.

### Carried over — small, unblocked

- **A client that disappears mid-request leaves the body-copy task waiting.** The copy
  into git's stdin runs in its own task and nothing cancels it if the connection drops.
  Bounded by the backend exiting and closing the pipe, but not by anything deliberate.
- **No automated test asserts the security headers.** There is no HTTP-level test
  harness, so losing the CSP would be silent. The likeliest regression is someone using
  `insert()` instead of `or_insert()` and flattening the raw endpoint's stricter policy.
- **`cargo audit` has never been run**, and the dependency tree has not been reviewed.
- **A subprocess per git request.** Unlike Milestone 3's once-per-creation, this is on a
  hot path and has not been measured. Milestone 5 is where that bill comes due.
- **Streaming is by construction, not by measurement.** The response body is never
  collected, but no clone large enough to prove it has been run.
- **An orphaned repo directory is possible** if the process dies between the record
  write and the filesystem write, and it then blocks re-creating that name. The durable
  fix is a reconciliation sweep on boot
  ([architecture.md](architecture.md#db-plus-filesystem-writes)); clearing one is a
  manual `rm` today, since repo deletion does not exist.
- **The duplicate-name check races.** The loser is caught by `init_bare` or the unique
  constraint, but surfaces as an opaque storage error rather than "name taken".
- **Bare repos created on macOS carry `ignorecase = true`.** A migration gotcha if the
  data directory ever moves to Linux.
- ~~**Light mode is still untested**~~ — **looked at 2026-09-05** on the repository
  landing page, a tree and a blob, by temporarily flipping the layout's `class="dark"`
  and screenshotting. Nothing was wrong: every colour on these pages already comes from
  a token. The profile, the settings pages and the log have still not been checked, and
  **there is still no way for a visitor to choose** — the layout hardcodes `dark`.
- **The `/log` page's switcher opens with nothing marked current** when no revision is
  in the URL, because `repo_log` still does not report the revision it resolved. Now more
  visible than before, since there is a switcher to look wrong.
- **Task-list items keep their bullet** and footnotes render in place rather than
  collected at the end. Both cosmetic.
- ~~**The landing page now makes 15 `git` processes**~~ — **4 now**, and 115 ms of
  latency has become 31 ms. The fix was 0006's kept-alive `cat-file --batch`, as that
  entry said it would be; see the
  [third amendment](decisions/0006-git-binary-behind-narrow-ports.md#amendment--20260906-stage-2-a-kept-alive-cat-file)
  for the whole before/after table.
- **`count_commits` costs two processes, not one.** It resolves the revision before
  running `rev-list --count`, because `rev-list` is fatal on an empty repository and on
  an unknown branch, and this module's rule is that a non-zero exit from git is always a
  real fault. `--ignore-missing` was tried: it covers a bad object id, not a bad
  revision *name*.
- **`bg-muted` is not a token and never was.** Three `<pre>` blocks used it, so they
  have been rendering with no background at all — silently, exactly as `ui.md` warns
  about classes Tailwind never ships. Fixed on the clone block, the empty-repository
  push snippet and, last, `token.rs`'s new-token block. All three now use `bg-surface`,
  and `bg-muted` appears nowhere in `src/` — only `bg-muted-foreground`, which is real.
- **The licence sniffer reads 1 KiB, not the 200 bytes first sketched.** BSD-2 and
  BSD-3 differ only by a third clause about 900 bytes in. `LICENSE-MIT` and other
  suffixed spellings are not detected: the filename list is deliberately short, because
  every extra candidate is another speculative blob read.
- ~~**A per-file last-commit column is still absent**~~ — **shipped**, on the root and
  on every subdirectory, once the kept-alive `cat-file --batch` it was waiting on
  landed. One `git log --name-only` per listing, not one per entry.
- **Fonts are not loaded.** The theme names Geist and IBM Plex Mono; both fall back
  today. Topcoat's `font-fontsource` feature handles it.
- **The auth pages are unstyled.** `/auth/setup` and `/auth/login` are still bare
  milestone-1 HTML, and the styled top bar now sits right above them making it obvious.
- **The top bar's wordmark says "steid"**, not the owner's identity — see the open
  question at the end of [ui.md](ui.md#the-shell).
- **Light mode is untested.** The palette defines it; nobody has looked at it.
- **No rate limiting** on `/auth/login` or `/auth/setup`.
- **`sweep_expired` is never called**, so expired session rows accumulate. Expiry is
  enforced on read, so this is tidiness, not a hole.
- ~~**CSRF.**~~ — **closed 2026-09-08**,
  [0008](decisions/0008-csrf-double-submit-bound-to-the-session.md). Every form carries
  an HMAC token bound to the session, and `web/csrf_scan.rs` fails the build when a POST
  route forgets it. `SameSite=Lax` and Topcoat's own `OriginLayer` are still the first
  two layers; this is the third. **Login CSRF is still open** — see below.

### Opened by the security review (2026-09-10)

Findings and evidence in [security-2026-09-10.md](security-2026-09-10.md). Seven
findings, all fixed; four things it could not close in one sitting:

- **The search page has no rate limit of its own.** The 4 MiB grep cap bounds the memory,
  not the CPU: `?q=` is still a full `git grep` per request on a page nobody has to be
  signed in to reach, and it is now the most expensive unauthenticated read after the
  archive. A `SearchLimiter` beside `ArchiveLimiter` is mechanical; the numbers are not —
  how many per window, and whether an empty query counts, are a decision rather than a
  default.
- **DNS rebinding is open on both outbound paths.** The webhook sender and the import
  clone both resolve, check every address, and then let the library resolve again. A
  record whose TTL expires in between still gets through. Closing it means pinning the
  address and setting `Host`/SNI by hand, separately for `ureq` and for `git`. Both
  modules say so in their headers.
- **`run` still collects git's output without a byte cap** for everything that is not
  grep or a diff — `log`, `for-each-ref`, `cat-file`. Each is bounded some other way
  (`--max-count`, the ref count, an object size read from its header first), so none is
  reachable in the shape grep was, but the property is incidental rather than enforced.
  Worth a sweep the next time a page asks git something open-ended.
- **An import of a renamed repository now fails rather than following the redirect.**
  The price of `http.followRedirects=false`, taken deliberately. If it turns out to bite
  often, the answer is to resolve the redirect ourselves and re-check the target, not to
  turn it back on.

### Opened by the CSRF work (2026-09-08)

- **Login CSRF is open, knowingly.** `/auth/setup`, `/auth/login`, `/auth/forgot` and
  `/auth/reset/{token}` are exempt because they are submitted signed out and there is no
  session to bind a token to — a double-submit token an attacker can simply fetch
  protects nothing. So an attacker can still force a victim's browser to sign in *as the
  attacker*, which then attributes whatever they do next to the attacker's account.
  `SameSite=Lax` and the `OriginLayer` cover it in any current browser. The real fix is a
  pre-session CSRF cookie with its own lifetime, which is a bigger decision than this
  was; the exemptions and their reasons are in `csrf::EXEMPT`.
- **A restart 403s every form already open on screen**, because the secret is random per
  boot. Deliberate ([0008](decisions/0008-csrf-double-submit-bound-to-the-session.md)),
  and worst in development: `topcoat dev` rebuilds on every edit, so a form left open
  across one refuses on submit. If that becomes annoying, the answer is a persisted
  secret, which is a thing to back up and rotate.
- **`csrf_scan.rs` matches on text, so it can be fooled.** A handler that mentions
  `csrf_verified` in a comment passes; one that spells the route across two lines is not
  seen at all. It is a guard against forgetting, not against trying.
- **The scan's 307 rule is coarse.** It fails a POST handler containing `redirect(`
  anywhere, including in a doc comment. Nothing hits that today.
- **Nothing tests the refusal page itself.** The 403 view was checked in a browser, and
  there is still no HTTP-level harness that could assert it — the same gap item 7 of the
  wave list already names.

### Opened by the organisation review (2026-09-06)

Full findings and an ordered, independently mergeable refactor list are in
[review-2026-09-06-organisation.md](review-2026-09-06-organisation.md). The layer rules
held — domain imports nothing outward, no page writes through a port — so what is open
is shape, not correctness:

- ~~**58 `#[allow(clippy::too_many_arguments)]`**~~ — **63 counted, 38 left.**
  `application::Stores` bundles the `orgs`/`memberships`/`repos` triple that 56
  signatures took, and every allow the change made unnecessary is gone. The 38 that
  remain are genuinely wide signatures — `merge_pull` and `redeliver` at 17 parameters,
  `back_up`, the two `password_reset` writes — not port-threading. Narrowing those is
  review step 11's `GitQuery` split and `merge_pull`'s own shape, not this.
- **Three `write_failure`s that disagree** (`labels.rs` maps `Forbidden` to 404,
  `issues.rs` and `pulls.rs` to 403) and **eight copies of the same ownership guard**
  across `web/`. Both want to live in `web::context`.
- **`web/browse.rs` and `web/repo.rs` are imported by thirteen modules each** for
  formatters, URL builders and the repo frame — none of which is browsing or the repo
  page.
- ~~**PR numbering reaches into `IssueRepository`**~~ — `next_number` is on
  `RepoRepository` now, so `create_pull` no longer holds the issue port at all.
  `merge_pull` still does, and should: `Closes #n` really is an issue write.
- **`/api` has three routes** against 34 POST handlers. ROADMAP.md calls it a standing
  practice; four waves shipped without it, which also cost the check on whether the
  read/write line is in the right place.
- **There is no event concept, only `PushEvent`** — so webhooks and the activity feed
  can only report pushes. A `RepoEvent` log is the shared shape, and deserves an ADR
  before anything consumes the payload.
- **The web layer is the thin spot in testing**: `web/pulls.rs` is 1,870 lines of code
  with 7 tests, `web/labels.rs` 892 with none, and what is untested there is exactly the
  duplicated logic above.
- **Two docs are now out of date.** `architecture.md` still says the reconciliation
  sweep is unwritten (`application/reconcile.rs` writes it) and credits `#[memoize]`
  with earning its keep (there are zero in the tree).

### Opened by the second organisation review (2026-09-10)

Full findings and a re-ranked, independently mergeable step list are in
[review-2026-09-10-organisation.md](review-2026-09-10-organisation.md). Seven of the
first review's thirteen steps landed and did what they promised; what is open is again
shape, plus one trap:

- ~~`csrf_scan` read `web/` non-recursively~~ — recursive since 2026-09-10, with a test.
- **`repo::visible_repo` is a third copy of the visibility rule**, outside
  `application/access.rs` and imported by seven modules. Milestone 7's third role would
  otherwise land in three bodies rather than one.
- **`GitQuery::diff` hands git's stdout across the layer boundary** as `RawDiff`, and
  `application/diff.rs` parses it — the only port that does. One call site.
- **URL builders re-scattered after step 3**: two `commit_url`s, two `compare_url`s, and
  seventeen more `*_url` functions living in the page that first needed them.
- **The composition root and three CLI commands live in `main.rs`**, which has no tests.
  Extracting the builder into the library is the whole prerequisite for an HTTP-level
  harness — `topcoat::serve_until` takes any `Listener` and `TcpListener` is one, checked
  in the vendored crate.
- **`architecture.md` has three stale claims**: `RegistrationPolicy` does not exist,
  `access.rs` is not quite the only place deciding access (`is_instance_owner` in two
  pages, `operator_authorized` in `web/`), and two files are now past the 1,500-line
  test-file threshold with their tests still inline.

### Opened by the access wave (steps 5 and 6)

- **`&Stores::new(&orgs(cx), &memberships(cx), &repos(cx))` is written 60 times in
  `web/`.** Each accessor builds a fresh adapter around the same pool, so it is cheap but
  noisy. A `context::ports(cx)` returning an owned triple with a `.stores()` borrow would
  collapse it; it needs a binding per handler, so it was left out of a mechanical change.
- **`writable_repo` and `changeable_repo` are still two functions for one rule** — one
  layered on `readable_repo`, one resolving directly — kept apart because their callers
  want different things back. `access_tests.rs` pins that they agree on every actor, so
  folding them is now a safe change rather than a risky one.
- **Milestone 7's permission argument has a home but no name.** The predicates are in one
  file and the signatures have room; what they still lack is the third role and the
  permission enum. Nothing here decided its shape.
- ~~**`POST /auth/login` still ends a failed sign-in with `redirect`**~~ — **fixed
  2026-09-08**, along with a *third* instance nobody had spotted: `POST /auth/setup` on
  an already-claimed instance answered `redirect("/")`. `csrf_scan.rs` now fails any POST
  handler that names `redirect(`, so there cannot be a fourth.
- **`Password::MAX_BYTES` is untested against Argon2 itself.** 512 bytes is a bound on
  the work, not a measured one; nobody has timed a 512-byte hash on the deployed
  machine.

## Backlog

Ordered. Pull from the top.

0. ~~**The ops step the control plane needs**~~ — **done 2026-09-08**: all four capabilities plus password reset, the tidy-up refactors, the access module and CSRF are on main; the security review is the next step, then Milestone 7. Historic text follows. Decided in
   [steid-control-plane ADR 0002](../../steid-control-plane/decisions/0002-machine-per-tenant.md)
   (2026-09-08): each managed tenant is its own machine, provisioned by cloud-init
   running `install.sh`. Steid stays unmodified; it must become drivable headlessly.
   Four things, one wave, disjoint files: a headless claim plus a `GET /api/instance`
   reporting version and claimed state; `steid backup` / `steid restore` producing one
   consistent archive (SQLite online backup plus the data directory), with an owner-only
   "Download a backup" on the settings page and an opt-in `--backups daily` timer in
   `install.sh`; a `/metrics` endpoint; releases served from the distribution host
   (closes 5b). Then password reset with email, which Steid sends and the operator
   configures. Self-hosters get the same mechanism as options; managed tenants get it
   scheduled and shipped by the control plane.

0. ~~**The boot-time owner, for the control plane**~~ — **done, 2026-09-13**.
   `STEID_OWNER_EMAIL` + `STEID_OWNER_HANDLE` create the owner before the first request;
   `install.sh --owner-email --owner-handle` writes them. The decisions are in
   [progress.md](progress.md#the-boot-time-owner--done-2026-09-13). `Cargo.toml` and
   `install.sh` say **0.6.0**, and **0.6.0 is now cut and published** — see below.
   Carried forward: **the seeded owner's only way in is `steid reset-password` on the
   box** — a bearer secret in whatever channel it is carried over — which closes at
   Milestone 7's identity; and **nothing in the data says an account was seeded**, which
   is deliberate (no sentinel) but leaves a "you have never set a password" prompt with
   nothing to key on.

0. ~~**Releases move off jpgill.dev**~~ — **done, 2026-09-20**. `install.sh` defaults to
   `https://releases.steid.dev` (S3 behind CloudFront), `deploy.sh --publish` writes
   that host *and* the jpgill.dev mirror, and `--publish-s3-only` cuts a release without
   going near the live site. 0.6.0 is published there — the first version cloud-init can
   install headlessly, which is what the control plane was blocked on. Reasoning in
   [decision 0009](decisions/0009-releases-from-releases-steid-dev.md) and
   [progress.md](progress.md#releases-move-to-releasessteiddev--done-2026-09-20).
   Carried forward: **the mirror is temporary** and goes when the control plane's
   milestone 2 moves this instance onto the fleet — until then a publish writes two
   hosts and can half-succeed; **the mirror for 0.6.0 has not been written yet**, because
   it needs ssh to the author's live box and that is the author's to run
   (`./deploy.sh --publish` or an scp by hand); and **artefacts are still unsigned** —
   a `.sha256` served from the host that served the tarball proves transport, not
   provenance, and that is more visible now the host is a CDN.

0. **Control plane asks, 0.7.0** — **code done 2026-09-26; the publish is the author's**
   (`./deploy.sh --publish`, or `--publish-s3-only` to cut without touching the live
   site). `Cargo.toml`, `Cargo.lock` and `install.sh` say **0.7.0**; no artefact carries
   it yet, and **nothing changes for anybody until it is published**. Three capabilities the managed offering
   needs, cut as one release, asked for by the control plane's
   [milestone 2, phase D0](../../steid-control-plane/plans/current.md). They close two of
   its "Watch for" entries. Steid learns nothing about being managed by any of them —
   each is a mechanism a self-hoster gets on the same terms.
   - **`steid restore --replace`** — the refusal stays the default; the flag is the
     consent. A managed instance is born owned, so it always holds a user and the
     console's restore could otherwise never succeed. Decisions in
     [progress.md](progress.md#control-plane-asks--070).
   - **`install.sh --operator-token <token>`** — so a box never serves with the operator
     surface off. Carried forward: **the value is written unquoted**, so a token
     containing whitespace, `#` or quotes would be read wrong by dotenvy and by systemd's
     `EnvironmentFile` — hex from `openssl rand -hex 32` is the documented shape and the
     only one exercised; and **it was verified against a temporary directory, not a real
     box**, like `--backups daily` before it.
   `cargo audit` is clean of vulnerabilities; **three warnings are tolerated and
   unchanged from 0.6.0** — `bincode` 1.3.3 and `yaml-rust` 0.4.5 unmaintained (both via
   `syntect`) and a yanked `chacha20` 0.10.1 (via `topcoat-session`). None has a fix to
   take. `rustix` was added as a direct dependency for `statvfs` and brings no new crate.
   - **Disk usage on `/api/instance`**, operator shape only:
     `disk: {data_dir_bytes, filesystem_total_bytes, filesystem_free_bytes}`. Carried
     forward: **memory and the cache sizes are still unreported** (see below); the walk
     is **cached for a minute**, so a console that has just grown a volume sees the old
     number for up to that long; and the walk **counts `.replaced-…` and `orphaned/`**,
     which is deliberate but means a replaced instance reads as roughly twice its size
     until somebody deletes the aside directory.

1. **Milestone 6 — Writing.** Posts, markdown, `/{handle}/posts/{slug}`. Open when it
   starts: which markdown crate, and whether raw HTML in markdown is trusted — safe for a
   single author, a stored-XSS hole the moment Milestone 7 adds a second user. A
   repository's README rendering on its page falls out of the same pipeline.

2. **Milestone 7 — Identity, full — has a shape now**, set by the control plane's
   [ADR 0005](../../steid-control-plane/decisions/0005-oidc-only-sign-in-and-organisations-own-instances.md)
   (2026-09-12): a company signs everyone into its instance with its identity
   provider, and an individual's managed instance may do the same with a personal
   Google account. What that asks of this milestone, beyond orgs, invites and a
   registration policy: a `User` with linked **external identities** (issuer, subject,
   verified email) beside an *optional* password hash; an **identity-provider
   configuration** reachable headlessly (`STEID_OIDC_*` env, like every operator
   setting, so self-hosters get the same mechanism by hand); a registration policy
   that can say "anyone from this provider with this hosted domain"; `POST /api/setup`
   able to bind the owner to an external identity rather than a password; and an
   instance-level role, which `is_instance_owner` (= the sole user) already needs.
   The OIDC relying party is a small crate **shared** with the control plane rather
   than copied — the one exception to copy-not-share, because it is security code
   (it exists: `steid-control-plane/crates/steid-oidc`, on `openidconnect`, to be
   extracted when this milestone needs it). OIDC first; SAML is the control plane's
   milestone 9 and lands here after.
   **The registration policy is chosen per instance on the control plane** (its
   domain.md, *Access policy*, 2026-09-13) and delivered headlessly, so it must be
   data, not a compile-time choice: `Open` (password registration), `InviteOnly`,
   `EmailDomain { provider, domain }`, `Provider { issuer, group/claim constraint }`,
   later `Saml`. A self-hoster sets the same thing by env or a settings page.

### Forge feature candidates (surveyed 2026-09-05)

Not yet ordered against Milestone 6. Grouped by what they touch, because the plan is to
run several agents at once and the grouping is what decides what can run together.
**Sections 1 and 2–4 are done; 5–7 are what is left.** Shared hotspots: `GitQuery` in `port.rs` (every
browsing feature appends a method), `git_query.rs`, the repo sub-nav, and `plans/`
itself. New tables touch `sqlite.rs` + `in_memory.rs` and should merge one at a time.

**Sections 1 and 2–4 have now had a wave each. Wave 2 is done** — rename, default
branch, archived, issues, import from a URL, push events and webhooks, all merged and
then walked together as one app; see the integration pass above. **Wave 3 is done too** —
token expiry and last-used, a rate limit on token auth, issue labels, markdown
cross-links and highlighted fences, Atom feeds, paging everywhere, and the wave 2
follow-ups; merged and walked, see the wave 3 pass above.

**Section 1 is done**, the per-file last-commit column included — it was the one thing
left, and the kept-alive `cat-file --batch` it waited for
([0006](decisions/0006-git-binary-behind-narrow-ports.md)) shipped with it. Shipped: the two-column
repository landing page, syntax highlighting, branches and tags pages, archive
download, code search, the commit page, compare, and blame. All eight were merged and
then walked together as one app; see the integration pass above. See
[ui.md](ui.md#the-repository-page) for the layout and the entry-point map, and
[progress.md](progress.md) for what each cost.

1. ~~**Read-only browsing**~~ — **done**, the per-file last-commit column included. It
   was the last thing outstanding and it arrived with the kept-alive `cat-file --batch`
   that [0006](decisions/0006-git-binary-behind-narrow-ports.md) said had to come first.
2. **Repo model** — **done** except **topics and pinned repos on the profile** and the
   **orphan-directory reconciliation sweep on boot**, which now has three shapes to
   handle (a create that died, a rename that died, an import that died). Shipped: rename,
   the default branch setting, the archived flag.
3. **Collaboration**: **issues and labels done**; still open are **pull requests** (needs
   the commit and compare pages, plus a merge on the bare repo) and **milestones** (8+).
4. **Transport and git ops** — **done** for this wave: import from URL, post-receive
   events and webhooks, `REMOTE_USER` passthrough. Still open: **LFS** (not yet) and
   **SSH** (would reverse [0001](decisions/0001-git-over-http-not-ssh.md)).
5. **Identity and auth**: ~~token expiry and last-used~~ · ~~rate limiting on token
   auth~~ · ~~CSRF~~ — CSRF done 2026-09-08, alone, as planned. Still open:
   Milestone 7 multi-user (run alone) · nothing sweeps expired tokens and nothing warns
   before one expires.
6. **The owner's home page**: posts (Milestone 6) · profile links · ~~Atom feeds for commits~~ —
   done in wave 3 (commits, issues and push activity); posts will want one when they
   exist.
7. **Platform and quality**: scheduled backups and served releases (closes 5b) ·
   HTTP-level test harness plus security-header tests and `cargo audit` · `/api`
   coverage for existing use cases · styled auth pages, light mode, fonts.

Process decisions, now answered by the wave rather than open: agents **do** get
worktrees and short-lived branches, which is a deliberate bend in the commit-to-main
rule and worth keeping for a wave; and agents do **not** edit `plans/` — each writes a
handover the merging session folds in, because five agents appending to `current.md`
conflict every time. The integration pass afterwards is not optional: it is the only
place a cross-feature link is ever exercised.

Wave 2 amends one of those: an agent working **alone** — the integration pass is one —
edits `plans/` in the same commits as the code, as CLAUDE.md asks. The no-`plans/` rule is
about concurrent agents, not about agents.

## Open questions

- **Topcoat is early** (v0.5.0, first released 2026-07-22, breaking changes expected
  by its own authors). Expect churn that isn't feature work.
- Topcoat ships Tailwind without Node, which reopens the design system attempt #1
  dropped purely to avoid an npm build step — see [ui.md](ui.md).

## Routing findings (Milestone 0)

- **Topcoat 0.5 requires rustc ≥ 1.95.** On an older toolchain `cargo add topcoat`
  silently resolves to an empty `topcoat v0.0.0` placeholder instead of failing. Local
  stable is now 1.97.1.
- `Router::builder().discover()` collects `#[page]`-annotated items **at link time**,
  so pages can live in any module. Layering is our choice, not the framework's.
- `module_router!` derives each URL from the module tree rather than a path string.
  Still deferred. Application routes now group cleanly (`auth/login`, `api/me`), but
  handles sit at the root ([0004](decisions/0004-root-handles-grouped-routes.md)), so a
  parameterised root segment still has to coexist with static ones. Worth checking how
  `module_router!` handles that before committing to it.
- Path and query params are read from `Cx` via `path_param!` / `#[query_params]`, not
  injected as handler arguments. Parses are memoized per request.
- Layouts wrap by path prefix and nest outermost-first, and a layout can catch a page's
  `NotFoundError` to render a branded 404.
- `HOST` / `PORT` configure the bind address, so `STEID_LISTEN_ADDR` is gone.
- `Body` is a boxed `http_body::Body` used for both requests and responses, with
  `into_data_stream()` to read and `Body::new()` to wrap a stream — pack data can
  stream both directions without buffering. This is what makes Milestone 4 viable.
