[core] Phase 1: core, edge and differential tests #2

Manually merged
mnovak merged 27 commits from core/phase-1 into main 2026-11-07 16:46:58 +01:00
Owner

Phase 1 (core and engine) from docs/ROADMAP.md §6: 27 commits.

What is in it

  • Repo hygiene: .gitignore, and a versioned pre-commit hook in .githooks/. It rejects binaries, private keys in many formats and files over 5,000,000 bytes. Enable it once with git config core.hooksPath .githooks.
  • crates/core: host-file schema with typed errors, plus the edge compiler and the Caddy JSON compiler. Both compilers are deterministic, with golden files.
  • crates/edge: Pingora 0.9.1 with rustls. It covers SNI certificates, health checks, websockets, header rules with secrets from $CREDENTIALS_DIRECTORY, Authelia-compatible forward-auth that fails closed, and ACME via instant-acme. The access log truncates IPs to /24 and /48.
  • tests/diff: 60 requests sent to Ianitor and Caddy 2.11.7. 0 differ; 10 named known divergences, each matching one exact case. Two deliberately broken compilers are caught.
  • tests/support: shared test fixtures.
  • Roadmap: §8 answers 1, 2, 3 and 5; §9 Status; §10 Handover.

Verification

  • WSL2 Debian: cargo fmt --check and clippy -D warnings are clean.
  • cargo test --workspace: 86 passed, 0 failed. Per target: core compile 13, schema 46; edge unit 11, forward_auth 5, secrets 3, upstreams 4, acme_pebble 1; diff 2; testkit 1.
  • Hook self-test: 55/55 in WSL, 54/54 in Git Bash.
  • Windows: core and edge unit tests run. Each Linux-only target runs one explicit skip test.
  • Independent QC, two rounds: found 2 blockers, 3 major, 7 minor and several nits. All are fixed, with tests written first, except the ones listed below. QC re-ran its own reproductions and mutations against the fixes.

Adversarial self-review

  1. The Phase 1 "Done" gate is not fully met. ROADMAP §6 asks for Let's Encrypt staging. ACME is proven only against Pebble, and staging needs a public domain. Status says so, and Mark has to decide.

  2. rustls is "experimental" in Pingora. The fallback is the openssl feature, local to edge. Until testssl.sh and h2spec run in phase 4, TLS correctness rests on the diff suite alone.

  3. Slowloris is open on the public listeners. There is no overall header deadline: edge keeps a slow connection past 90 s, while Caddy closes it at 60 s. This matters before edge faces the internet. It is listed for phase 4, but it could be argued it belongs before the two-week run beside Caddy.

  4. A DNS lookup per request has no cache. Lookups have a 3 s deadline, but a timed-out lookup still holds a blocking-pool thread. A burst against a host with dead DNS could exhaust the pool.

  5. The diff suite is HTTP/1.1 only, and auth is a mock. It covers no HTTP/2, no real Authelia, no HTTPS upstreams and no ACME config on the Caddy side. Parity is proven only for what the corpus contains.

  6. New validation rules go beyond the roadmap, added to keep the engines identical:

    • no secrets in response headers
    • no { or } in literal header values
    • one upstream scheme per host
    • no * in header names
    • files must be named <hostname>.toml
    • 1 MiB and 64-upstream caps

    They are reasonable, but they are decisions §3 didn't list.

  7. Edge is stricter than Caddy on misbehaving auth servers (KD-4 to KD-10, fail-closed 502), and answers 400 where Caddy answers 404 on absolute-form mismatches. These are deliberate. The KD rules compare status codes only.

  8. CLAUDE.md promises things that don't exist yet: nix build, nix flake check, packages/ui, tests/fuzz, deploy/nixos and deploy/test-access.sh.

  9. The commit prefixes [repo], [tests], [docs] and [diff] aren't crate or app names, as CLAUDE.md asks.

  10. A roadmap contradiction surfaced by the UI design (Handover, needs Mark): §1.6 lists the engine as a rebuild-only change, while §3 and §4 switch it at runtime.

Nothing is deployed and the server is unchanged.

Phase 1 (core and engine) from docs/ROADMAP.md §6: 27 commits. ## What is in it - **Repo hygiene:** `.gitignore`, and a versioned pre-commit hook in `.githooks/`. It rejects binaries, private keys in many formats and files over 5,000,000 bytes. Enable it once with `git config core.hooksPath .githooks`. - **`crates/core`:** host-file schema with typed errors, plus the edge compiler and the Caddy JSON compiler. Both compilers are deterministic, with golden files. - **`crates/edge`:** Pingora 0.9.1 with rustls. It covers SNI certificates, health checks, websockets, header rules with secrets from `$CREDENTIALS_DIRECTORY`, Authelia-compatible forward-auth that fails closed, and ACME via instant-acme. The access log truncates IPs to /24 and /48. - **`tests/diff`:** 60 requests sent to Ianitor and Caddy 2.11.7. 0 differ; 10 named known divergences, each matching one exact case. Two deliberately broken compilers are caught. - **`tests/support`:** shared test fixtures. - **Roadmap:** §8 answers 1, 2, 3 and 5; §9 Status; §10 Handover. ## Verification - **WSL2 Debian:** `cargo fmt --check` and `clippy -D warnings` are clean. - **`cargo test --workspace`:** 86 passed, 0 failed. Per target: core compile 13, schema 46; edge unit 11, forward_auth 5, secrets 3, upstreams 4, acme_pebble 1; diff 2; testkit 1. - **Hook self-test:** 55/55 in WSL, 54/54 in Git Bash. - **Windows:** core and edge unit tests run. Each Linux-only target runs one explicit skip test. - **Independent QC, two rounds:** found 2 blockers, 3 major, 7 minor and several nits. All are fixed, with tests written first, except the ones listed below. QC re-ran its own reproductions and mutations against the fixes. ## Adversarial self-review 1. **The Phase 1 "Done" gate is not fully met.** ROADMAP §6 asks for Let's Encrypt staging. ACME is proven only against Pebble, and staging needs a public domain. Status says so, and Mark has to decide. 2. **rustls is "experimental" in Pingora.** The fallback is the `openssl` feature, local to edge. Until testssl.sh and h2spec run in phase 4, TLS correctness rests on the diff suite alone. 3. **Slowloris is open on the public listeners.** There is no overall header deadline: edge keeps a slow connection past 90 s, while Caddy closes it at 60 s. This matters before edge faces the internet. It is listed for phase 4, but it could be argued it belongs before the two-week run beside Caddy. 4. **A DNS lookup per request has no cache.** Lookups have a 3 s deadline, but a timed-out lookup still holds a blocking-pool thread. A burst against a host with dead DNS could exhaust the pool. 5. **The diff suite is HTTP/1.1 only, and auth is a mock.** It covers no HTTP/2, no real Authelia, no HTTPS upstreams and no ACME config on the Caddy side. Parity is proven only for what the corpus contains. 6. **New validation rules go beyond the roadmap,** added to keep the engines identical: - no secrets in response headers - no `{` or `}` in literal header values - one upstream scheme per host - no `*` in header names - files must be named `<hostname>.toml` - 1 MiB and 64-upstream caps They are reasonable, but they are decisions §3 didn't list. 7. **Edge is stricter than Caddy on misbehaving auth servers** (KD-4 to KD-10, fail-closed 502), and answers 400 where Caddy answers 404 on absolute-form mismatches. These are deliberate. The KD rules compare status codes only. 8. **CLAUDE.md promises things that don't exist yet:** `nix build`, `nix flake check`, `packages/ui`, `tests/fuzz`, `deploy/nixos` and `deploy/test-access.sh`. 9. **The commit prefixes `[repo]`, `[tests]`, `[docs]` and `[diff]`** aren't crate or app names, as CLAUDE.md asks. 10. **A roadmap contradiction surfaced by the UI design** (Handover, needs Mark): §1.6 lists the engine as a rebuild-only change, while §3 and §4 switch it at runtime. Nothing is deployed and the server is unchanged.
mnovak added 27 commits 2026-11-07 16:46:48 +01:00
mnovak manually merged commit db43af24a6 into main 2026-11-07 16:46:58 +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#2