T4: Ianitor anywhere (Linux, Docker, Windows in Caddy mode), branch previews for Fabrica, team sign-in #10

Open
mnovak wants to merge 15 commits from feature/t4-anywhere into main
Owner

T4 of Fabrica's coherence roadmap (docs/32_coherence.md): Ianitor runs for any small team, not only on Mark's NixOS server, and gives Fabrica a preview address for every branch. Builds on domi-pki v1.0.0 (PR #9).

What

  • Branch previews (docs/previews.md): POST /api/v1/previews {project, branch, upstream, ttl} → <branch>--<project>.<preview domain>, with a Domi or Let's Encrypt certificate. Closed by POST /api/v1/previews/close (on merge), DELETE /api/v1/previews/{host}, or by itself when its TTL runs out. A preview is an ordinary host file with a [preview] table, so it goes through validation, both compilers, the diff suite and the commit-confirmed apply.
  • Previews-only tokens (scope = previews): 403 token.scope on every other route. Previews may only point at [previews] upstreams; control's port, Caddy's admin port, unspecified, link-local, multicast and IPv4-mapped addresses never.
  • Hostile names: core preview::label makes one safe LDH label (≤ 62, no -- at positions 3–4), hashing the original where anything was lost, so different branches never share a host; refuses control characters and over-long names.
  • Anywhere: Docker image + compose (edge, control in edge's netns), Linux installer + systemd units, Windows Server installer in Caddy mode (control + Caddy + the trial guard as services; Caddy's admin API on loopback TCP), NixOS services.ianitor.previews. docs/deploy/anywhere.md.
  • Team sign-in without Authelia: setup link, invite links, __Host- session cookie, admin/member roles, Tessera roots with Fundamentum's match code. Authelia still works.
  • UI: Previews screen (see 1 click, close 2), Settings → Team (invite 3), previews-only tokens; sign-in from a link.
  • Diff suite on Windows with drive paths (Pingora in-process vs Windows Caddy 2.11.7), preview hosts in the fixtures. It found one real difference: edge applied response rules to a websocket 101; it no longer does (Caddy never did).
  • Release 0.2.0 prepared: the pipeline builds and tests the Linux tarball, the Windows zip and the image under the signed SHA256SUMS; notes. Not tagged.

Tests (tests first where the risk is)

  • core tests/preview.rs: hostile branch names (unicode, dots, length, IDNA, traversal) → safe labels; no two of 6000 similar branches share a label; the [preview] table must match the host name; compilers ignore it.
  • control tests/previews.rs: a preview token cannot touch non-preview hosts (21 routes refused, no take-over of a non-preview host at the preview's name, only its own file changes); cannot point at admin ports; lifecycle incl. expiry; bad requests.
  • control tests/caddy_mode.rs: a preview answers through Caddy without an edge (admin over TCP, Domi certificate) and is gone after close. tests/team.rs: setup, invites, roles, CSRF, sign-out, last admin.
  • Counts — Linux (Docker CI image): core 112, control 87, diff 4, edge 57, testkit 1. Windows: core 112, control 32 (Linux-only targets are stubs), diff 3 (the real suite), testkit 1. vitest 24.
  • Smoke, end to end with the previews-only token and Fabrica's client script: Windows (installer -NoService, Caddy mode), Docker (compose, Pingora), Linux (installer under systemd in a container). See the ROADMAP handover.

Self-review (adversarial)

  • Scope by path, not by handler: the guard checks the URI path before routing, so a new route is denied to preview tokens by default. Nested paths under /api/v1/previews/ are refused. ✔
  • Allow-list bypasses: URLs are parsed by the same url crate as core, so http://2130706433:20001, 0x7f.1 and [::ffff:127.0.0.1] normalise before the check (loopback → admin-port check; mapped → refused). Names are checked as written: a listed name that resolves to loopback would pass. Documented; admins should list only names they control.
  • Take-over: a branch whose label collides (24-bit hash) with another preview or any non-preview host gets 409 preview.taken; DELETE/close only act on preview hosts. ✔
  • Expiry: the sweeper only closes preview hosts and skips hosts with an apply in flight. A preview's apply that fails its watch leaves no host. ✔
  • Sessions: only hashes on disk; the setup link works once and only while the team is empty; writes need X-Ianitor-UI and a same-origin fetch. The sign-in door is rate-limited server-wide (20/min), so someone spamming it can slow real sign-ins for a minute; acceptable for a 2–10 person team, noted.
  • Windows: Caddy's admin API is loopback TCP; any local process on that machine can reconfigure Caddy. Documented; Unix sockets for Caddy on Windows are not supported by control's client.
  • Admin host: accepted with any port now (Docker publishes 443 elsewhere); the name still guards against DNS rebinding.
  • Not built: Custos approval of admin changes and Tessera sign-in need Custos operations (docs/custos-ticket.md, T4); the overview's health under Caddy-only mode still says Pingora's health is unavailable.
T4 of Fabrica's coherence roadmap (`docs/32_coherence.md`): Ianitor runs for any small team, not only on Mark's NixOS server, and gives Fabrica a preview address for every branch. Builds on domi-pki v1.0.0 (PR #9). ## What - **Branch previews** (`docs/previews.md`): `POST /api/v1/previews {project, branch, upstream, ttl}` → `<branch>--<project>.<preview domain>`, with a Domi or Let's Encrypt certificate. Closed by `POST /api/v1/previews/close` (on merge), `DELETE /api/v1/previews/{host}`, or by itself when its TTL runs out. A preview is an ordinary host file with a `[preview]` table, so it goes through validation, both compilers, the diff suite and the commit-confirmed apply. - **Previews-only tokens** (`scope = previews`): `403 token.scope` on every other route. Previews may only point at `[previews] upstreams`; control's port, Caddy's admin port, unspecified, link-local, multicast and IPv4-mapped addresses never. - **Hostile names**: core `preview::label` makes one safe LDH label (≤ 62, no `--` at positions 3–4), hashing the original where anything was lost, so different branches never share a host; refuses control characters and over-long names. - **Anywhere**: Docker image + compose (edge, control in edge's netns), Linux installer + systemd units, Windows Server installer in **Caddy mode** (control + Caddy + the trial guard as services; Caddy's admin API on loopback TCP), NixOS `services.ianitor.previews`. `docs/deploy/anywhere.md`. - **Team sign-in without Authelia**: setup link, invite links, `__Host-` session cookie, admin/member roles, Tessera roots with Fundamentum's match code. Authelia still works. - **UI**: Previews screen (see 1 click, close 2), Settings → Team (invite 3), previews-only tokens; sign-in from a link. - **Diff suite on Windows** with drive paths (Pingora in-process vs Windows Caddy 2.11.7), preview hosts in the fixtures. It found one real difference: edge applied response rules to a websocket `101`; it no longer does (Caddy never did). - **Release 0.2.0 prepared**: the pipeline builds and tests the Linux tarball, the Windows zip and the image under the signed SHA256SUMS; notes. Not tagged. ## Tests (tests first where the risk is) - core `tests/preview.rs`: hostile branch names (unicode, dots, length, IDNA, traversal) → safe labels; no two of 6000 similar branches share a label; the `[preview]` table must match the host name; compilers ignore it. - control `tests/previews.rs`: a preview token cannot touch non-preview hosts (21 routes refused, no take-over of a non-preview host at the preview's name, only its own file changes); cannot point at admin ports; lifecycle incl. expiry; bad requests. - control `tests/caddy_mode.rs`: a preview answers through Caddy without an edge (admin over TCP, Domi certificate) and is gone after close. `tests/team.rs`: setup, invites, roles, CSRF, sign-out, last admin. - Counts — Linux (Docker CI image): core 112, control 87, diff 4, edge 57, testkit 1. Windows: core 112, control 32 (Linux-only targets are stubs), diff 3 (the real suite), testkit 1. vitest 24. - Smoke, end to end with the previews-only token and Fabrica's client script: Windows (installer `-NoService`, Caddy mode), Docker (compose, Pingora), Linux (installer under systemd in a container). See the ROADMAP handover. ## Self-review (adversarial) - *Scope by path, not by handler*: the guard checks the URI path before routing, so a new route is denied to preview tokens by default. Nested paths under `/api/v1/previews/` are refused. ✔ - *Allow-list bypasses*: URLs are parsed by the same `url` crate as core, so `http://2130706433:20001`, `0x7f.1` and `[::ffff:127.0.0.1]` normalise before the check (loopback → admin-port check; mapped → refused). Names are checked as written: a listed name that resolves to loopback would pass. Documented; admins should list only names they control. - *Take-over*: a branch whose label collides (24-bit hash) with another preview or any non-preview host gets `409 preview.taken`; DELETE/close only act on preview hosts. ✔ - *Expiry*: the sweeper only closes preview hosts and skips hosts with an apply in flight. A preview's apply that fails its watch leaves no host. ✔ - *Sessions*: only hashes on disk; the setup link works once and only while the team is empty; writes need `X-Ianitor-UI` and a same-origin fetch. The sign-in door is rate-limited server-wide (20/min), so someone spamming it can slow real sign-ins for a minute; acceptable for a 2–10 person team, noted. - *Windows*: Caddy's admin API is loopback TCP; any local process on that machine can reconfigure Caddy. Documented; Unix sockets for Caddy on Windows are not supported by control's client. - *Admin host*: accepted with any port now (Docker publishes 443 elsewhere); the name still guards against DNS rebinding. - *Not built*: Custos approval of admin changes and Tessera sign-in need Custos operations (docs/custos-ticket.md, T4); the overview's health under Caddy-only mode still says Pingora's health is unavailable.
mnovak added 15 commits 2026-11-17 22:17:39 +01:00
This pull request has changes conflicting with the target branch.
  • .fabrica/artifex/release.yaml
  • .fabrica/notes/0.2.0.md
  • CLAUDE.md
  • apps/web/src/App.svelte
  • apps/web/src/views/Settings.svelte
  • crates/control/src/dev.rs
  • crates/edge/src/lib.rs
  • docs/ROADMAP.md
  • tests/diff/Cargo.toml
  • tests/diff/tests/diff.rs
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feature/t4-anywhere:feature/t4-anywhere
git checkout feature/t4-anywhere
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/ianitor#10