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_activitysampler) caught one, at 450/s, as an 8 s WAL-flush stall: all 28 backends waited inIO:WalSyncorLWLock:WALWriteon 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 % lenre-renews a session within the same second once it wraps while opens grow the list. The issuer correctly refuses that renewal asNotNewer(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_acquireand 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'sfulltotal 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.
-
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 ÷ 750plus 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 toplans/archive/, nav to Archive, and Amendment 12’s xref is repointed. Thencargo xtask plan-lint --done <i3b> --allow-open 1303 --allow-open 2760. -
Release notes and tracking. A CHANGELOG
Changedentry. After merge, comment the SHA on #2760 and update the epic.
-
-
B1 (w2)
fix(xtask): rotate the harness’s renewals through every session(#2785).-
Sessions. In
senders.rs,Sessiongainsrevoked: AtomicBool, which revocation sets while keeping itsswap_removefrom the list. It also gainsrenewed_at: AtomicI64, the whole-secondiatof 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(aparking_lot::Mutex<VecDeque<Arc<Session>>>, addingparking_lot.workspace = truetoxtask/Cargo.toml) feeds renewals; opens push to its back. A renewal walks from the front, drops revoked sessions, takes the first eligible one, sets itsrenewed_atand 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_waitedcount goes in the record; it is 0 at the model’s populations. -
Tests, on the
Rotationwith 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.
-
-
-
B2 (w3)
chore(xtask): let G7 see relay tails and disk pressure(#2784, re-scoped by T4).-
Reading pressure.
xtask/src/sysmon.rsgainsparse_psi_totals(thesomeandfulltotal=, µs) besideparse_psi_some_avg10. It gets a no-panic proptest besideparse_psi_never_panicsand a fixed-text test. -
Recording it. In
measure.rs,Snapshotreads the totals, andMeasuredaddsio_some_shareandio_full_share(Option<f64>).RelayMeasureadds each direction’s p99 (Holds::quantile(990)) andover_limit(the overflow bucket’s count). -
One G7 predicate.
gates.rsgainscould_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.validityfolds it over a cell’s repetitions.cells.rsjudges each saturation step with it in place ofrelays_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.
-
-
B3 (w3)
feat(db): test an issuer connection only once it has idled(#2787).-
canopy-db.
DbPoolOptsgainsacquire_test: AcquireTest { Always (default), IdleFor(Duration) }.connect_withmapsIdleFor(d)totest_before_acquire(false)plus abefore_acquirethat pings when the pureneeds_ping(meta.idle_for, d)says so. -
The issuer’s pools. In
registry.rs,issuer_pool_optssetsIdleFor(1 s), andadmin_pool_optssetsAlwaysexplicitly, since it derives from the issuer’s. -
The harness.
report.rs'AcquireTestbecomesAlways | StaleOnly, withStaleOnlyreplacingOff; its proptest strategy follows. The replica reportsissuer_pool_opts(size).acquire_test. -
Unit tests: canopy-db’s
needs_pingat its edge, andIdleForbuilding a pool withget_test_before_acquire() == false;registry.rs'issuer_pool_opts_carry_…assertingIdleFor(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 fromissuer_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 concurrentClientStatusMemoreads over aPgClientStatuson that pool. All four fail with the store’s typed error, and the next read succeeds on a new backend.
-
-
Docs:
shared-crates.adoc'DbPoolOptsfields;security-operations.adoc› canopy-identity key registry (the issuer pool);configuration-reference.adoc'IDENTITY_DB_MAX_CONNECTIONSrow.
-
-
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):
-
Readiness:
--cells idle-probe,design,peak. Its G1–G7 must pass: T3 changes production pooling, and Stage A rests on these gates. -
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
fullshare exceeds 1 %, afix(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.
-
-
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_limitand IO shares at each give-out; and design and peak delegation p99 after T3. -
The guide. The guide’s
#identity-sizingtable and its Round trip bullet are refreshed. -
Closing. This plan closes
Done (YYYY-MM-DD) — !Naftercargo xtask plan-lint --done <i3b2> --allow-open 1303, plus any cited issue still open. Stage B’s CHANGELOG entries all go underChanged: 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
somebut notfull, 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=requiredfor 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:
Notes folded in: header fields and labels; |
2 |
not stated (the maintainer’s other vendor) |
not stated |
7 findings (1 P1, 6 P2), all fixed in-plan:
|