Identity plane split, plan I3b2: the three-replica minimum and one replica’s margin (epic &133)

Status: Done (2026-10-09) — !1582
Epic: &133 (stage I3 of &130)
Issues: #2786 (A1, w2, closes #2760); #2785 (B1, w2); #2784 (B2, w3); #2787 (B3, w3); #2788 (B4, w2)
Branches and MRs: Stage A docs/three-replica-minimum, "canopy-identity’s three-replica minimum (#2760, #2786)"; Stage B fix/one-replica-margin, "canopy-identity one replica’s margin (#2784, #2785, #2787, #2788)".

Stage B ships as one MR under the maintainer’s one-MR-per-related-group ruling, as plan I3b did: B4 measures B1–B3 together, so no unit stands alone. Each MR merges once the pre-push battery passes, the maintainer’s standing rule while CI is broken upstream. This is a Design + Scope plan: GitLab owns tracking, and the plan freezes when A1 starts. T1–T5 are this plan’s decisions (ADR-049 Amendment 13); "G1"–"G7" are Amendment 10’s gates.

Context

Plan I3b made canopy-identity pass every capacity gate: G1 at 12.4 ms (closing #2759), and G6 never at its ceiling. It ended blocked on #2760: one replica alone did not reliably carry the peak (1206 requests a second). It gave out at 1200/s in the final run, and at 900/s in the one re-run. Across five single-replica runs the knee ranged from 750 to 1800/s.

  • Same shape each time. Each give-out filled the issuer pool in bursts (300 or more of a step’s 10 ms samples) while it averaged under half its 28 connections. The writer and the replica’s CPU stayed healthy.

  • One give-out was the disk. A diagnostic run (a 50 ms pg_stat_activity sampler) caught one, at 450/s, as an 8 s WAL-flush stall: all 28 backends waited in IO:WalSync or LWLock:WALWrite on the shared host’s disk.

  • The others left no trace in the commits. The writer’s slow-commit counts at the other failing steps (2–3 over 100 ms) match steps that held.

  • The record had two blind spots. It judged the harness’s relay only to its p95, and kept none of the host’s IO pressure.

  • The renewal 400s are a harness defect (#2785). The renewal index turn % len re-renews a session within the same second once it wraps while opens grow the list. The issuer correctly refuses that renewal as NotNewer (F5).

#2760 allowed either answer: "one replica carries the peak, or the guide’s replica count rises to one that does". Two replicas at the peak are the peak cell, the one-down case at three replicas. They passed G3 and G6 in every valid run, with the pool averaging about 6.5 of 28.

The maintainer decided (2026-10-08) on both, staged:

  • Stage A closes #2760 now on the three-replica minimum, taking it off the switch’s preconditions (T5).

  • Stage B (non-blocking) widens one replica’s margin and looks for the burst source. It drops the per-acquire ping (T3), now the maintainer’s call; plan I3b’s call 4 dropped it only on F2’s trigger.

Decisions (ADR-049 Amendment 13, T1–T5; land with A1)

  • T1. Minimum three replicas. R − 1 becomes two replicas carrying the peak, which the peak cell measures (G3, G6). The saturation cell stays informational: one replica’s knee is recorded, not gated. This replaces the one-replica reading of R − 1, which came from Amendment 10 P2 and P4’s arithmetic at R = 2 and from plan I3b’s maintainer call 1. A deployment runs max(3, ⌈peak ÷ 603⌉ + 1) replicas.

  • T2. The defaults stand: the pool at 28 and the window at 2 ms.

    • Amendment 10 P2’s rate-limit defaults, sized at R = 2, are conservative at R = 3. At the peak, with two canopy-web pods, the per-IP limit needs 14 010 (default 30 000), canopy-web 28 020 (60 000) and onward 8 100 (18 000).

    • The pool stays 28 because Stage B measures one replica against it.

  • T3. The issuer pool tests a connection only once it has idled 1 s or more, through sqlx before_acquire and canopy-db. This saves about two round trips a delegation. The admin pool and the writer keep their own tests. Amends Amendment 12 S9.

    • After a database restart or failover, a broken connection idle under 1 s is lent. The operation on it fails (503) instead of the connection being replaced.

    • When that operation is a shared memo’s single-flight read (the client-status memo, client_status.rs:166–169, or the JWKS memo), every caller waiting on it fails with it, admin requests included.

    • It fails once per broken connection: sqlx closes a broken connection on release. Its blast radius is bounded by the failover window, not the pool size.

  • T4. G7 sees past p95, and the disk.

    • Each relay direction’s p99 must be at most half the stated round trip plus 1 ms.

    • The host’s IO pressure (/proc/pressure/io's full total over the window) must be at most 1 % of the window. An unreadable PSI is not judged, and the row names it.

    • The record keeps each direction’s p99, its holds at or past the 7 ms bucket limit, and both IO-pressure shares. Amends Amendment 12 S6.

  • T5. K1’s preconditions. #2759 and #2760 are closed. The switch still waits on I3c–I3f, the external security review, and the issuance log’s retention or archival (#1303), which the deployment guide makes a cut-over prerequisite.

Units

Every commit goes through the J1–J8 review.

  1. A1 (w2) docs(adr): set canopy-identity’s minimum at three replicas (#2786; closes #2760).

    • ADR. Amendment 13 (T1–T5) before == References, and the Status line. A dated pointer line goes in Amendment 10 (after P1) and in Amendment 12’s as-built.

    • Guide. In deployment-guide.adoc:

      • the replicas paragraph says three is the minimum, sized max(3, ⌈peak ÷ 603⌉ + 1) in place of "peak ÷ 750 plus one", with one replica’s knee (750–1800/s) informational;

      • the connection budget adds the deployment total (3 × 47; 3 × 49 with the verifier);

      • the Limits bullet adds T2’s three-replica figures;

      • #identity-sizing's table is unchanged.

    • This page and its nav entry.

    • Plan I3b closes Done (YYYY-MM-DD) — !1580, with an erratum: #2760 closed by Amendment 13, the issue’s own alternative. The page moves to plans/archive/, nav to Archive, and Amendment 12’s xref is repointed. Then cargo xtask plan-lint --done <i3b> --allow-open 1303 --allow-open 2760.

    • Release notes and tracking. A CHANGELOG Changed entry. After merge, comment the SHA on #2760 and update the epic.

  2. B1 (w2) fix(xtask): rotate the harness’s renewals through every session (#2785).

    • Sessions. In senders.rs, Session gains revoked: AtomicBool, which revocation sets while keeping its swap_remove from the list. It also gains renewed_at: AtomicI64, the whole-second iat of its last renewal, set when a renewal is taken, not when it is answered. A session is eligible when that second is before the current one.

    • The rotation. A Rotation (a parking_lot::Mutex<VecDeque<Arc<Session>>>, adding parking_lot.workspace = true to xtask/Cargo.toml) feeds renewals; opens push to its back. A renewal walks from the front, drops revoked sessions, takes the first eligible one, sets its renewed_at and pushes it to the back at once. An in-flight session is then never taken again within its second, whatever order answers arrive in.

    • When no session is eligible, a renewal waits until the next second, its latency measured from its schedule as always. A renewals_waited count goes in the record; it is 0 at the model’s populations.

    • Tests, on the Rotation with an injected clock:

      • a_renewal_takes_every_live_session_once_before_any_twice, with opens and revocations interleaved;

      • an_in_flight_renewal_is_not_taken_again_in_its_second, with overlapping renewals, one stalled, and the clock advanced past the second;

      • a_renewal_with_no_eligible_session_waits_for_the_next_second.

  3. B2 (w3) chore(xtask): let G7 see relay tails and disk pressure (#2784, re-scoped by T4).

    • Reading pressure. xtask/src/sysmon.rs gains parse_psi_totals (the some and full total=, µs) beside parse_psi_some_avg10. It gets a no-panic proptest beside parse_psi_never_panics and a fixed-text test.

    • Recording it. In measure.rs, Snapshot reads the totals, and Measured adds io_some_share and io_full_share (Option<f64>). RelayMeasure adds each direction’s p99 (Holds::quantile(990)) and over_limit (the overflow bucket’s count).

    • One G7 predicate. gates.rs gains could_judge(&Measured) → Judgement, naming the reasons any condition broke. It covers every G7 condition: release build, generator lag, host CPU, the in-flight cap, the relay’s median, p95 and p99, and IO pressure. validity folds it over a cell’s repetitions. cells.rs judges each saturation step with it in place of relays_held(), and a step’s INVALID message names the broken conditions.

    • Tests:

      • a_relay_tail_past_its_bound_invalidates_the_cell (a 2 % tail at +2 ms, p95 in bounds);

      • io_pressure_past_its_bound_invalidates_the_cell;

      • an_unread_io_pressure_is_not_judged;

      • a_saturation_step_is_judged_by_every_g7_condition (a lagging generator or a hit cap invalidates a step).

    • Docs: tooling/xtask-catalog.adoc's G7.

  4. B3 (w3) feat(db): test an issuer connection only once it has idled (#2787).

    • canopy-db. DbPoolOpts gains acquire_test: AcquireTest { Always (default), IdleFor(Duration) }. connect_with maps IdleFor(d) to test_before_acquire(false) plus a before_acquire that pings when the pure needs_ping(meta.idle_for, d) says so.

    • The issuer’s pools. In registry.rs, issuer_pool_opts sets IdleFor(1 s), and admin_pool_opts sets Always explicitly, since it derives from the issuer’s.

    • The harness. report.rs' AcquireTest becomes Always | StaleOnly, with StaleOnly replacing Off; its proptest strategy follows. The replica reports issuer_pool_opts(size).acquire_test.

    • Unit tests: canopy-db’s needs_ping at its edge, and IdleFor building a pool with get_test_before_acquire() == false; registry.rs' issuer_pool_opts_carry_… asserting IdleFor(1 s); the_admin_pool_keeps_its_acquire_test.

    • Infra tests, in services/canopy-security/tests/identity_registry_test.rs, on a one-connection issuer pool built from issuer_pool_opts:

      • an_issuer_connection_idle_past_a_second_is_pinged_before_lending: kill the backend, idle 1 s, then acquire and query on a new backend;

      • a_broken_connection_idle_under_a_second_fails_its_shared_read_once: kill the backend, then at once start four concurrent ClientStatusMemo reads over a PgClientStatus on that pool. All four fail with the store’s typed error, and the next read succeeds on a new backend.

    • Docs: shared-crates.adoc' DbPoolOpts fields; security-operations.adoc › canopy-identity key registry (the issuer pool); configuration-reference.adoc' IDENTITY_DB_MAX_CONNECTIONS row.

  5. B4 (w2) docs(adr): record one replica’s margin (#2788).

    • Runs, on a reloaded devstack at the defaults, seed 541770337227324816 (plan I3b’s, for comparison):

      1. Readiness: --cells idle-probe,design,peak. Its G1–G7 must pass: T3 changes production pooling, and Stage A rests on these gates.

      2. Calibration, from that run’s demonstrably healthy windows only. A window counts when every G7 condition but IO holds, its cell’s gates pass, and the writer recorded no commit over 100 ms.

        • If such a window’s IO full share exceeds 1 %, a fix(xtask) commit raises the bound to twice the largest such share, capped at 5 %, and step 1 restarts once.

        • If a healthy window still exceeds the bound, or the cap would be passed, calibration stops and is filed: "the capacity run cannot judge IO on this host".

        • The bound in force is recorded.

      3. Informational: --cells saturation, three times.

    • INVALID outcomes:

      • A readiness cell still INVALID after two re-runs files "the capacity run is INVALID on this host" under &133, and this plan becomes Blocked (#N).

      • A readiness gate that fails is filed under &133 as a switch blocker, since it would undo Stage A’s evidence, and this plan becomes Blocked (#N).

      • A saturation run still INVALID after two re-runs is recorded and does not block.

    • Amendment 13’s as-built records each saturation run’s knee and peak step; the relay p99, over_limit and IO shares at each give-out; and design and peak delegation p99 after T3.

    • The guide. The guide’s #identity-sizing table and its Round trip bullet are refreshed.

    • Closing. This plan closes Done (YYYY-MM-DD) — !N after cargo xtask plan-lint --done <i3b2> --allow-open 1303, plus any cited issue still open. Stage B’s CHANGELOG entries all go under Changed: B3 for the product, B1 and B2 for the harness.

Outcomes

  • Stage A: #2760 closes and plan I3b is Done. The switch still waits on I3c–I3f, the external review and #1303 (T5).

  • Stage B is Done when B1–B4 merge and B4’s readiness run passes every G1–G7 gate. Otherwise it is Blocked (#N), per B4’s INVALID outcomes.

    • One replica’s margin, from the informational saturation runs, does not decide Stage B.

    • The as-built either names the burst source (a relay tail or IO pressure that G7 now catches), or shows give-outs persisting with both clean, which is then filed under &133.

    • If one replica carries the peak in 3 of 3 valid saturation runs, the as-built says so. Lowering the minimum to two is a separate decision.

Scope

In: the minimum replica count, the issuer pool’s acquire test, G7’s tail and disk conditions, and the harness’s renewals.

Out:

  • merging the jti insert and the session read into one call;

  • synchronous_commit;

  • Redis;

  • the pool’s default (T2);

  • every I3c–I3g concern.

Risks

  • The PSI bound is unproven both ways.

    • A disk stall that leaves other tasks runnable may show in some but not full, so both are recorded.

    • Pressure the database under test causes cannot be told from a neighbour’s, so a self-inflicted disk limit reads INVALID rather than as a give-out. INVALID never passes a readiness gate: repeated, it blocks and is filed.

    • Calibration uses only healthy windows, with a 5 % cap, so a stall cannot raise its own bound.

  • T3 under failover: each broken connection fails its operation once, and a shared memo read fails all its waiters, admin requests included. B3’s two infra tests cover the idle path and the dead-connection path with concurrent callers.

Verification

  • Per unit: fmt; clippy with validate’s flags; nextest for the touched crates (CANOPY_TEST_INFRA=required for canopy-db and canopy-security); quality-budgets; db-pools; plan-lint; check-docs.

  • Per MR: the pre-push battery.

  • B4: the records named in the as-built.

Errata

  • Erratum (2026-10-09): B1’s rotation queues a newly opened session behind those already renewed, so its fairness is "no session taken again before every session live at its previous take", which the test asserts.

  • Erratum (2026-10-09): B3 adds DbPoolOpts::to_pool_options, so the infra tests build an issuer-shaped pool from connect options. The dead-connection test asserts one database failure and the other three calls shared-or-fresh, not four failures: a server-ended connection fails at once, so callers arriving after it read afresh. Waiter sharing is pinned by the memo’s own tests.

  • Erratum (2026-10-09): B4’s first readiness run judged both loaded cells INVALID on the 1 % IO bound, though the peak cell’s windows were healthy at 1.03–1.13 %, its own load. The calibration rule set 2.25 % (twice 1.127 %, rounded down) in a fix(xtask) commit, and step 1 restarted once. The restarted run’s peak cell was INVALID at 4.10 % IO; its re-run, gated on a quiet host, passed. A further commit makes the saturation summary name every broken G7 condition, not "relay".

  • Erratum (2026-10-09): after two of the three saturation runs proved INVALID on the shared host, the maintainer ruled (2026-10-09) to record them as they stand rather than wait for a quiet host. Each run is recorded in Amendment 13’s as-built. The pool’s short bursts persisted with the relay and IO both within bounds, so their source is filed (#2790), as the Outcomes require.

Review log

Round Vendor Resolved model Verdict

1

Anthropic

Claude Opus 5.5 (fresh subagent)

no-ship. Five blockers, all fixed in-plan:

  • the PSI parser’s proptest;

  • Stage B’s one-MR reason, titles and branches;

  • no !N in the body;

  • B4 measures the design cell and refreshes the Round trip bullet;

  • A1’s --allow-open list;

  • the PSI calibration windows and fallback commit.

StaleOnly replaces Off.

Notes folded in: header fields and labels; cells.rs' step validity; an unread PSI not judged; over_limit; B3’s tests, pins and docs; Stage B’s CHANGELOG and close-out; the archived xref and pointer lines; the replica formula and Limits figures; T1’s citation; T3 as the maintainer’s call; T4’s two-way risk; parking_lot; the seed.

2

not stated (the maintainer’s other vendor)

not stated

7 findings (1 P1, 6 P2), all fixed in-plan:

  • B4’s readiness run must pass G1–G7 after T3, or it blocks and is filed;

  • calibration from healthy windows only, with a 5 % cap, a stop condition and the bound recorded;

  • per-session second eligibility for renewals, set when taken, with a wait when none is eligible and overlapping-renewal tests;

  • T3’s failure bound covers shared memo reads, with a dead-connection test with concurrent callers;

  • one complete G7 predicate for cells and saturation steps;

  • separate INVALID outcomes for readiness and informational runs;

  • T5 keeps #1303 as a cut-over prerequisite.

Edit this page · default