[control] Phase 2: control plane #3

Manually merged
mnovak merged 0 commits from control/phase-2 into main 2026-11-07 20:03:36 +01:00
Owner

Phase 2 of docs/ROADMAP.md: the control plane.

What is in it

  • crates/control: routes repo through the git binary (bare repo, cleared environment, hex-checked ids, exactly ianitor.toml + hosts/<hostname>.toml).
  • Apply: journaled apply: validate → compile → commit → edge trial reload → 60 s watch of touched hosts → keep or revert. It also covers undo/redo, restore, push with retry and crash recovery.
  • Share links and API tokens: share links (HMAC tokens with epoch, password mixed into the MAC, deny list outside git) and API tokens (SHA-256 at rest, cross-process lock).
  • REST API: on loopback, with OpenAPI, --dev mode, docs/api.md and docs/ui-api.md.
  • crates/edge: in-process config swap (arc-swap) with self-reverting trials over an admin Unix socket. It also adds share-link cookies, visitor pages, a password throttle and an epoch floor.
  • crates/core: share tokens, the strict path-prefix check, the exact host-file loader and error codes.
  • tests/diff: the diff suite after each of six applies.
  • ROADMAP: §8.4 answered with load numbers; Status and Handover updated.

Verification (WSL2 Debian, head of this branch)

  • Tests: cargo test --workspace: 175 passed, 0 failed, 0 ignored.

    Crate Passed Breakdown
    core 86 unit 2, compile 13, routes 8, schema 45, share 18
    edge 43 unit 15, acme_pebble 1, forward_auth 5, reload 5, secrets 3, share_links 7, share_throttle 3, upstreams 4
    control 42 unit 6, api 5, apply 25, stores 6
    diff 3 diff 2, apply_sequence 1
    testkit 1
  • Lint and hook: cargo fmt --check and clippy --all-targets -D warnings are clean. The hook self-test passes 55/55.

  • Reload under load: a reload every 100 ms gave 0 errors and 0 resets at 32, 64 and 128 clients (ROADMAP §8.4).

Adversarial self-review

Four QC rounds attacked this branch. Each finding came with a failing test where possible, and every Major was fixed with its test committed red first.

  • Round 1:
    • A password throttle that forged ids could flush.
    • A CLI token revoke lost to a concurrent server write.
    • A pause lost on a full disk.
    • Revocation epoch rollback.
    • Plus 10 minor problems: encoded .. escapes, credentials echoed in errors, a lost confirm answer, idempotency races and others.
  • Round 2: a failed Restore could still drop the unsaved pause. Plus mint-epoch ordering, URL redaction, Unicode look-alikes, and an epoch floor that did not survive an edge restart.
  • Round 3: the files-retry way out ran outside the apply lock and could load a Restore config that failed its watch. Plus an over-strict path rule and the cause of a port-race test flake.
  • Round 4: PASS. The two minors it found (invisible characters hiding a dot-only segment, and clashing temporary file names) are fixed.

Where I still distrust it:

  • Real dependencies: push to a real Gitea over HTTPS (askpass), systemd LoadCredential and a real Authelia were never exercised; local stand-ins were used.
  • Lost confirm: a lost confirm answer from edge is tested only indirectly, by stopping edge, not by an answer that arrives late.
  • Test hooks in release: the crash and write-failure hooks are compiled into release builds, gated only by environment variables. A Nix build without them is planned for phase 3.
  • Share links: they work only on Pingora; under the Caddy fallback a visitor gets the normal sign-in.
  • Open flake: apply_sequence once timed out waiting for Caddy on the chunked-body case; the cause was not found.
  • Not measured: a release build, HTTP/2 and websockets across reloads.
  • Decisions waiting for Mark:
    • The deny list sits outside the compiled config.
    • ROADMAP §3's "password hash" wording.
    • The scope growth.
    • All listed in the Handover, (f)–(h).

Deployed

Nothing. The server is unchanged.

Phase 2 of docs/ROADMAP.md: the control plane. ## What is in it - **crates/control:** routes repo through the `git` binary (bare repo, cleared environment, hex-checked ids, exactly `ianitor.toml` + `hosts/<hostname>.toml`). - **Apply:** journaled apply: validate → compile → commit → edge trial reload → 60 s watch of touched hosts → keep or revert. It also covers undo/redo, restore, push with retry and crash recovery. - **Share links and API tokens:** share links (HMAC tokens with epoch, password mixed into the MAC, deny list outside git) and API tokens (SHA-256 at rest, cross-process lock). - **REST API:** on loopback, with OpenAPI, `--dev` mode, docs/api.md and docs/ui-api.md. - **crates/edge:** in-process config swap (arc-swap) with self-reverting trials over an admin Unix socket. It also adds share-link cookies, visitor pages, a password throttle and an epoch floor. - **crates/core:** share tokens, the strict path-prefix check, the exact host-file loader and error codes. - **tests/diff:** the diff suite after each of six applies. - **ROADMAP:** §8.4 answered with load numbers; Status and Handover updated. ## Verification (WSL2 Debian, head of this branch) - **Tests:** `cargo test --workspace`: 175 passed, 0 failed, 0 ignored. | Crate | Passed | Breakdown | |:--|--:|:--| | core | 86 | unit 2, compile 13, routes 8, schema 45, share 18 | | edge | 43 | unit 15, acme_pebble 1, forward_auth 5, reload 5, secrets 3, share_links 7, share_throttle 3, upstreams 4 | | control | 42 | unit 6, api 5, apply 25, stores 6 | | diff | 3 | diff 2, apply_sequence 1 | | testkit | 1 | | - **Lint and hook:** `cargo fmt --check` and `clippy --all-targets -D warnings` are clean. The hook self-test passes 55/55. - **Reload under load:** a reload every 100 ms gave 0 errors and 0 resets at 32, 64 and 128 clients (ROADMAP §8.4). ## Adversarial self-review Four QC rounds attacked this branch. Each finding came with a failing test where possible, and every Major was fixed with its test committed red first. - **Round 1:** - A password throttle that forged ids could flush. - A CLI `token revoke` lost to a concurrent server write. - A pause lost on a full disk. - Revocation epoch rollback. - Plus 10 minor problems: encoded `..` escapes, credentials echoed in errors, a lost confirm answer, idempotency races and others. - **Round 2:** a failed Restore could still drop the unsaved pause. Plus mint-epoch ordering, URL redaction, Unicode look-alikes, and an epoch floor that did not survive an edge restart. - **Round 3:** the files-retry way out ran outside the apply lock and could load a Restore config that failed its watch. Plus an over-strict path rule and the cause of a port-race test flake. - **Round 4:** PASS. The two minors it found (invisible characters hiding a dot-only segment, and clashing temporary file names) are fixed. Where I still distrust it: - **Real dependencies:** push to a real Gitea over HTTPS (askpass), systemd LoadCredential and a real Authelia were never exercised; local stand-ins were used. - **Lost confirm:** a lost confirm answer from edge is tested only indirectly, by stopping edge, not by an answer that arrives late. - **Test hooks in release:** the crash and write-failure hooks are compiled into release builds, gated only by environment variables. A Nix build without them is planned for phase 3. - **Share links:** they work only on Pingora; under the Caddy fallback a visitor gets the normal sign-in. - **Open flake:** `apply_sequence` once timed out waiting for Caddy on the chunked-body case; the cause was not found. - **Not measured:** a release build, HTTP/2 and websockets across reloads. - **Decisions waiting for Mark:** - The deny list sits outside the compiled config. - ROADMAP §3's "password hash" wording. - The scope growth. - All listed in the Handover, (f)–(h). ## Deployed Nothing. The server is unchanged.
mnovak added 38 commits 2026-11-07 20:03:21 +01:00
mnovak manually merged commit 1adfa05640 into main 2026-11-07 20:03:36 +01:00
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#3