Identity plane split, plan I3e2: canopy-web’s session engine (epic &133)

Status: Done (2026-10-09) — !1588
Epic: &133 (stage I3 of &130)
Issues: #2819 (U1, w2); #2820 (U2, w3); #2821 (U3, w5); #2822 (U4, w3); #2823 (U5, w2). Each relates to #2344 and #2345, which close at the switch.
MR: feat/identity-web-session-engine, "canopy-web’s session engine (#2819 … #2823)".

One MR, one commit per issue, under the maintainer’s one-MR-per-related-group ruling. It merges once the pre-push battery passes. This is a Design + Scope plan: GitLab owns tracking, and the plan freezes when U1 starts. V1–V7 are this plan’s decisions (ADR-049 Amendment 18); R3 and R4 are the maintainer’s rulings.

Context

Amendment 17 W1 cut I3e into canopy-auth library stages. The first, plan I3e1, built canopy-web’s upstream relying party. The second is "canopy-web’s sender and session engine".

The maintainer’s rulings (2026-10-09):

  • R3. Split that stage: I3e2 is the session engine; I3e3, planned once I3e2 lands, is canopy-web’s sender (delegation per backend call, the session_stale renew-and-retry, system purposes).

  • R4. The engine’s single-flight state sits behind a store trait in canopy-auth. canopy-web’s Postgres store implements it at the switch, replacing web_session. canopy-auth gains no database dependency.

What exists (all unwired):

  • UpstreamRelyingParty (crates/canopy-auth/src/upstream/relying_party.rs): authorization, redeem, refresh(token, within) → Result<UpstreamGrant, RefreshFailure>, revoke, end_session; UpstreamGrant::refresh_due() → RefreshDue::{At, ShortLived}.

  • FederationClient (crates/canopy-auth/src/identity_client/federation.rs): open(id_token, Option<access_token>), renew(&SessionCredential, RenewalEvidence), revoke(&SessionCredential), each bounded by FEDERATION_REQUEST_TIMEOUT (15 s); FederatedSession with public fields (credential, sid, sub, auth_time, session_ends_at, fresh_until, roles, programs, username).

  • CanopyRefusal (identity_session.rs), NumericDate (upstream/id_token.rs).

canopy-web today (replaced at the switch):

  • A Postgres row claim (#2224, services/canopy-web/src/auth/single_flight.rs): a claim committed before the refresh token is presented; a 30 s lease; commit recovery (classify_commit); a lapsed claim ends the session as refresh_lost; a 3 s request budget.

  • Its waiter awaits the leader with no bound; it presents Keycloak tokens, and its 360 s lead is sized to the exchanger (#2345).

What the ADR binds:

  • D6: re-federate after each upstream refresh and at least every 900 s, single-flight across replicas.

  • F4: a session is fresh until its last validation + 900 s, never after session_ends_at.

  • F5, F6: renewal evidence, grace on upstream_outcome=not_processed, grace_exhausted.

  • Amendment 2: grace only for a refresh the upstream provably did not process.

  • W6: maintenance is due at the earlier of the grant’s refresh lead and canopy-identity’s freshness lead.

  • idp-integration.adoc › "How canopy-web treats each renewal answer".

  • The ADR fixes no freshness-lead number; V3 sets it.

Decisions (ADR-049 Amendment 18, V1–V7; land with U1)

  • V1. Staging (R3, R4). I3e2 is the engine; I3e3 is canopy-web’s sender; then the device-approval and security-admin clients; then the edge forwarder. canopy-web’s store, extractors and handlers stay the switch’s (W1).

  • V2. The record and its store. The module is canopy_auth::identity_web_session.

    • WebSessionRecord has public fields, so a store restores it from its own columns, and no Debug, Clone or Serialize:

      • session: FederatedSession;

      • upstream: UpstreamBinding { issuer: String, client_id: String }: the profile’s exact issuer and client_id at sign-in, from the new UpstreamRelyingParty::binding();

      • upstream_refresh_token: Option<UpstreamRefreshToken>;

      • upstream_id_token: Option<Zeroizing<String>>, the latest id_token, for logout’s id_token_hint;

      • maintain_at: DateTime<Utc>.

    • WebSessionStore is an async_trait that is Send + Sync + 'static, with type Key: Clone + Send + Sync + 'static. Each method takes within: Duration, its bound. The table follows canopy-web’s RefreshStore (services/canopy-web/src/web_session/refresh.rs, sql.rs):

      Method Contract

      view(key) → Result<Option<SessionRow>, StoreFault>

      SessionRow { version: RecordVersion, claim: ClaimState, record: Option<WebSessionRecord> }. record: None means an undecodable row, which reads as no session. An ended session is None.

      claim(key, version, ClaimId, lease) → Result<Claimed, _>

      Only when the row is at version with no claim: sets Live(claim), with the lease on the store’s clock, and answers Claimed::Record(record). Claimed::Undecodable for an undecodable row; Claimed::Nothing otherwise.

      commit(key, ClaimId, &WebSessionRecord) → Result<Option<RecordVersion>, _>

      Only under that claim, live or lapsed: writes the record, increments the version and clears the claim. None means the claim is not in the row.

      release(key, ClaimId) → Result<bool, _>

      Clears its own claim only while the claim is live; the version is unchanged.

      end_claimed(key, ClaimId, reason), end_lapsed(key, ClaimId) → Result<bool, _>

      Ends the session only under that claim; for end_lapsed, only once it has lapsed (RefreshLost).

      end(key, reason) → Result<Option<WebSessionRecord>, _>

      Ends the session unconditionally and answers the record it ended, read and ended in one step (sign-out). An undecodable row ends and answers None.

      end_reason(key) → Result<Option<WebSessionEndReason>, _>

      Why an ended session ended.

      • Every write to a record steps its version.

      • An ended key is never live again.

      • A lapsed claim is never cleared, only ended over.

      • ClaimState::{Free, Live(ClaimId), Lapsed(ClaimId)}. ClaimId is a UUID v7. RecordVersion is a u64 newtype.

      • StoreFault::{Timeout, Unavailable}; an implementation logs its own cause.

      • WebSessionEndReason, each variant with as_str(): the engine writes SignedOut (signed_out), Expired (expired), IdentityRefused (identity_refused), UpstreamEnded (upstream_ended), UpstreamChanged (upstream_changed) and RefreshLost (refresh_lost); a store may also report Superseded (superseded), Idle (idle) and Operator (operator), which canopy-web’s own paths write. The switch replaces canopy-web’s schema outright, so canopy-web’s logout spelling is not kept. The name avoids the crate root’s existing EndReason.

      • Acknowledged writes must survive a failover; that is the deployment’s concern, as today.

  • V3. When a session is maintained.

    • maintain_at is the earliest of these, floored at now + MAINTENANCE_RETRY (30 s):

      • RefreshDue::At(t);

      • fresh_until − FRESHNESS_LEAD (120 s);

      • now + VALIDATION_CADENCE (780 s = FRESHNESS_SECONDS − FRESHNESS_LEAD), which keeps D6’s "at least every 900 s" whatever freshness an answer extends to.

    • Grace looks like a 200. A renewal’s 200 may be canopy-identity’s own grace (F6, when its userinfo call or key fetch is unavailable), which F2 does not mark. An answer whose fresh_until is past now + FRESHNESS_SECONDS + 60 s (D9’s leeway) cannot come from a validation now (F4), so the engine treats it as grace: maintain_at = now + MAINTENANCE_RETRY. A grace that ends sooner is caught by fresh_until − FRESHNESS_LEAD.

    • ShortLived contributes nothing, and is logged at warn, with the lifetime, once per grant received.

    • An outcome that keeps the session without a validation sets maintain_at = now + MAINTENANCE_RETRY. So no commit leaves a session due at once.

    • Maintainable: it holds an upstream refresh token, and now + SERVE_MARGIN < session_ends_at. fresh_until capped at session_ends_at does not end maintenance, since a grace is capped there too (grace_until).

    • Due: maintainable and now ≥ maintain_at.

    • Fresh: while fresh_until > now + SERVE_MARGIN (15 s), which covers canopy-web’s 12 s page budget plus 3 s.

    • Bound: the record’s upstream equals binding().

    • Constants: these are pub in identity_web_session.rs: FRESHNESS_LEAD, VALIDATION_CADENCE, MAINTENANCE_RETRY, SERVE_MARGIN, CLAIM_LEASE, STORE_OP_TIMEOUT (2 s) and COMMIT_RECOVERY_CAP (6 s).

    • Compile-time checks:

      • CLAIM_LEASE (60 s) exceeds the latest a leader’s last store write can land: STORE_OP_TIMEOUT (the claim) + UPSTREAM_TOKEN_TIMEOUT (10 s) + SIGN_DEADLINE (5 s, the renewal’s assertion; made pub(crate) in identity_client.rs) + FEDERATION_REQUEST_TIMEOUT (15 s) + COMMIT_RECOVERY_CAP + STORE_OP_TIMEOUT (Foreign's end) = 40 s. Revocations run after it, outside the lease.

      • FRESHNESS_LEAD > CLAIM_LEASE + SERVE_MARGIN.

  • V4. Serving: current(&self, key, budget) → Result<LiveSession, Unserved>.

    • One absolute deadline, now + budget, covers every operation of the request: reads, polls, the wait on its leader, and its own end_lapsed and end. Each store call is bounded by the lesser of STORE_OP_TIMEOUT and what remains. At the deadline, with whatever outcome is pending, the answer is Pending.

    • The request reads the row, then takes the pure decide(facts, now, deadline_passed) → Decision, in this precedence:

      1. no row, or record: None → NoSession;

      2. not bound → end(UpstreamChanged), answering Ended(UpstreamChanged). Nothing is presented to the configured upstream;

      3. a lapsed claim, fresh or stale → end_lapsed (RefreshLost), answering Ended(RefreshLost); a false re-reads. This is a decision: canopy-web claims only inside its lead, while the engine’s fresh-path leaders claim earlier, and a lapsed holder may have spent the token either way;

      4. fresh: if due and unclaimed → serve, and spawn a detached leader at the row’s version without waiting; otherwise serve;

      5. stale and not maintainable → end(Expired), answering Ended(Expired); None answers NoSession;

      6. the deadline passed → Pending;

      7. stale and not due (a retry is spaced) → Pending;

      8. stale with a live claim → wait (canopy-web’s jittered poll, 20 ms doubling to 160 ms) and re-read;

      9. stale, due and unclaimed → lead.

    • Leading. The request awaits its leader’s Report::{NotClaimed, Committed, Ended(WebSessionEndReason), NoSession, Unconfirmed} until the deadline.

      • Past the deadline it answers Pending, and the leader runs on.

      • NotClaimed returns to the loop: losing the claim is not leading.

      • Ended answers Ended; NoSession answers NoSession.

      • After Committed or Unconfirmed, it re-reads once and serves only a fresh row; otherwise it answers Pending.

      • A request leads at most once.

    • A stale session ends only by these endings, V5’s, or once session_ends_at comes within SERVE_MARGIN. While the upstream or canopy-identity is down it answers Pending: a new sign-in would fail the same way.

    • LiveSession { version: RecordVersion, session: FederatedSession }: no upstream token reaches a handler.

    • Unserved::{NoSession, Ended(WebSessionEndReason), Pending, Store(StoreFault)}.

  • V5. Maintenance (the leader) is a spawned task on its own bounds, never the request’s.

    • It claims at the version with CLAIM_LEASE:

      • Nothing → NotClaimed;

      • Undecodable → release, NoSession;

      • a fault → release best-effort and NotClaimed, never presenting, since the claim may have landed;

      • a claimed record that is not bound → end_claimed(UpstreamChanged), never presenting.

    • With the claimed record it runs refresh(token, UPSTREAM_TOKEN_TIMEOUT). Replace or retain: wherever a row keeps the grant’s tokens, each of the refresh token and the id_token is the grant’s when it has one, else the record’s, since the upstream may answer without rotating either.

      Upstream refresh Renewal Store

      Ok(grant)

      Evidence by UpstreamRelyingParty::renewal() (new pub const fn): IdToken(grant.id_token()) (a missing one is unreachable, since refresh refuses it, and is treated as Ended), or UpstreamAccessToken. Ok(renewed).

      Commit: renewed; replace-or-retain; V3’s maintain_at (grace-aware).

      Ok(grant)

      Refused(SessionEnded | UpstreamRefused | Projection(_) | SubjectSuspended)

      end_claimed(IdentityRefused): canopy-identity has revoked it or never had it.

      Ok(grant)

      Any other failure (503, invalid_request, transport, …).

      Commit: the old identity facts; replace-or-retain; retry maintain_at.

      NotProcessed(_)

      When fresh_until ≤ now + FRESHNESS_LEAD: RenewalEvidence::NotProcessed → Ok(renewed) (grace).

      Commit: renewed; the record’s tokens; retry maintain_at.

      NotProcessed(_)

      When fresh_until is further off: none, since repeated grace never extends (F6) and would only add audit rows.

      Commit: unchanged; retry maintain_at.

      NotProcessed(_)

      The four session-ending refusals.

      end_claimed(IdentityRefused).

      NotProcessed(_)

      Any other failure, GraceExhausted included.

      Commit: unchanged; retry maintain_at.

      Ended(_)

      None.

      end_claimed(UpstreamEnded).

    • Commit recovery is canopy-web’s: at most 2 commits and 3 re-reads within COMMIT_RECOVERY_CAP, classified by a pure classify_commit → Landed / StillOurs / Gone / Foreign / Unreadable.

    • A successor with no home: Gone, or a false from end_claimed, after a successful upstream refresh. The leader reads end_reason and revokes the successor (revoke, 2 s) only for SignedOut or Operator, as canopy-web does (idp-integration.adoc, "an issuer that revokes related tokens could end the session that replaced it"). It reports Ended(reason), or NoSession when the reason is unreadable.

    • Foreign after the token was presented → end(RefreshLost), since the row may still hold the spent token.

    • Identity revocation. Every end the engine writes, whether by a leader or a request, revokes the canopy-identity session with FederationClient::revoke. The revoke runs in a detached task, bounded by UPSTREAM_LOGOUT_TIMEOUT (2 s, a tokio timeout around signing and sending), so a refusal upstream stops canopy-identity minting at once (G5) rather than at fresh_until. The one exception is IdentityRefused, where canopy-identity has already revoked the session or never had it.

    • An unconfirmed commit leaves the claim to lapse.

    • Every store call is bounded by STORE_OP_TIMEOUT.

    • The outcome is one tracing event with a closed outcome field, never a token.

  • V6. Sign-in completion: complete_sign_in(pending, returned_state, code, redirect_uri) → Result<WebSessionRecord, SignInError>.

    • It runs redeem, then open(id_token, access_token only under Userinfo), then records binding() and V3’s maintain_at.

    • canopy-web inserts the record under its own key (the switch).

    • A refused or failed open revokes the grant’s refresh token best-effort (2 s).

    • SignInError::{RelyingParty(RelyingPartyError), Federation(FederationError)}; AuthTimeTooOld is canopy-web’s cue for prompt=login.

  • V7. Sign-out: sign_out(key, post_logout_redirect_uri) → Result<SignedOut, StoreFault>, in canopy-web’s order (local end first). It answers SignedOut { ended: bool, identity_revoked: bool, upstream: UpstreamSignOut::{EndSession(Url), Revoked, RevocationFailed, PromptLogin} }; every variant but EndSession leaves canopy-web to send prompt=login at the next sign-in, and each failure is reported and never blocks.

    1. end(key, SignedOut), which answers the ended record, so a leader’s commit can never fall between a read and the end. A fault → Err, with nothing revoked.

    2. With a record: FederationClient::revoke, within UPSTREAM_LOGOUT_TIMEOUT (2 s).

    3. Upstream, through the configured relying party:

      • A bound record: end_session(record’s id_token, uri); Ok(Some(url)) → EndSession(url); Ok(None) or Err → revoke the record’s upstream refresh token (D6) → Revoked or RevocationFailed, or PromptLogin with no token.

      • No record, or one bound to another upstream: end_session(None, uri), as canopy-web does today for a sign-out with no live session (services/canopy-web/src/auth/mod.rs). Ok(Some(url)) → EndSession(url); otherwise PromptLogin. An old provider’s token is never sent to the configured one.

Units

Every commit goes through the J1–J8 review. Each subject is at most 72 characters with its ` (#N)`.

Erratum (2026-10-09): the contract suite’s SHORT_LEASE is 500 ms, not 50 ms, so a networked store’s round trips find a fresh claim live. V3’s lease sum is 42 s, not 40 s: a foreign row’s end-reason read precedes its end. The engine tests use their own scripted canopy-identity, which echoes the renewal’s credential with now-relative times; identity_client/federation/tests.rs is unchanged. The memory store also gained fail_next_commit(), for the re-commit path. The devstack proof signs in five cast workers, one per test, so the broker’s per-person spacing does not serialize them. The leader’s foreign-row rule covers an end under the claim as well as a commit (ADR-049 Amendment 18’s as-built record).

  1. U1 (#2819, w2) docs(adr): record canopy-web’s session engine.

    • ADR-049 Amendment 18 (R3, R4, V1–V7), plus the Status line.

    • This page (In progress), with the ** Identity Plane Split (epic &130) nav group above the archive line.

  2. U2 (#2820, w3) feat(auth): add the web session record and store contract (V2).

    • New module: crates/canopy-auth/src/identity_web_session.rs (types and trait), with re-exports in lib.rs.

    • Under test-helpers:

      • identity_web_session/memory.rs: MemoryWebSessionStore, a parking_lot::Mutex<HashMap<u64, Row>> with leases on tokio::time::Instant. It copies a record out through SessionCredential::parse(expose_for_wire()) and UpstreamRefreshToken::restore, since the record has no Clone. It offers insert(record) → u64; the test hooks edit(key, FnOnce(&mut WebSessionRecord)) (which steps the version), end_with(key, WebSessionEndReason), drop_next_commit_ack() (the commit lands and answers Timeout), fault_next_claim() (the claim lands and answers Timeout), foreign_clear(key) (clears a claim without stepping the version, the one state no protocol writer leaves), corrupt(key) (the row stops decoding) and delay_ops(Duration) (every call waits first, still within its within); and claim and commit counters.

      • identity_web_session/contract.rs: pub async fn check<S: WebSessionStore>(store: &S, seed: impl AsyncFn(WebSessionRecord) → S::Key, corrupt: impl AsyncFn(&S::Key)) → Result<(), ContractViolation>. corrupt is the adapter’s own way to make a row undecodable, so the suite covers record: None, Claimed::Undecodable and end over an undecodable row. It is lib code, so it uses no panicking macro: ContractViolation names the failed row, and the calling test asserts Ok. It asserts every row of V2’s table and its three invariants, including: the lease lapsing (a 50 ms lease and a sleep); a lapsed claim never re-claimed or released; a foreign claim’s commit answering None; end answering the record once and then None; and end_reason after each end. canopy-web’s store runs it at the switch.

    • Tests: contract::check over the memory store; WebSessionEndReason::as_str pinned; the compile-time probes (no Debug/Clone/Serialize on the record).

    • Docs: shared-crates.adoc.

  3. U3 (#2821, w5) feat(auth): keep web sessions fresh through one leader (V3–V5; #2345’s engine half).

    • Files:

      • identity_web_session/decide.rs: pure maintain_at, decide, classify_commit;

      • identity_web_session/engine.rs: WebSessionEngine<S>, a cheap Clone over an Arc, with new(UpstreamRelyingParty, FederationClient, S) and current;

      • UpstreamRelyingParty::renewal() → RefreshRenewal (pub const fn). The profile loader refuses mixed sources (F9), so it also says whether claims come from userinfo;

      • UpstreamRelyingParty::binding() → UpstreamBinding: the profile’s issuer().as_str() and client_id().as_str(), kept by new;

      • SIGN_DEADLINE made pub(crate).

    • The scripted IdP (upstream/relying_party/tests.rs) and the scripted issuer (identity_client/federation/tests.rs) become pub(crate). The issuer gains a now-relative answer, since its stock answer() dates are fixed in 1970.

    • Every stale-path test sets both fresh_until and maintain_at in the past through edit: a stale session inside its retry spacing answers Pending (V4’s step 7).

    • Tests:

      • Functional:

        • decide's precedence, row by row;

        • fresh and not due posts nothing;

        • fresh and due serves at once, and the detached leader commits (version + 1, fresh_until advanced, token rotated);

        • stale leads and serves within the budget;

        • each row of V5’s table, asserting the store’s record and what was posted;

        • no refresh token: never due; stale → Expired;

        • a stale session inside its retry spacing answers Pending and posts nothing;

        • a grace already granted is not asked for again (no second not_processed renewal);

        • a request that loses the claim waits and serves the winner’s version;

        • a record bound to another issuer or client ends UpstreamChanged, and nothing reaches the scripted IdP;

        • a refresh answering without a new refresh token or id_token keeps the record’s, both after a renewal and after a failed one;

        • a grace capped at session_ends_at stays maintainable, and recovers at the next attempt;

        • a 200 whose fresh_until is past now + FRESHNESS_SECONDS + 60 s schedules a retry, and a validation schedules at most VALIDATION_CADENCE ahead;

        • every engine-written end except IdentityRefused posts one revocation to the scripted issuer.

      • Property: maintain_at ≥ now + MAINTENANCE_RETRY, and, above that floor, ≤ fresh_until − FRESHNESS_LEAD, ≤ now + VALIDATION_CADENCE and ≤ any At(t); decide never serves a stale row, never leads with the budget spent or inside the retry spacing, and never claims over a live or lapsed claim.

      • Concurrency: 16 concurrent current calls on a stale session together post exactly one refresh and one renewal, and so do 16 on a fresh, due one.

      • Fault-injection:

        • a lost commit acknowledgement is recovered as Landed, with no second refresh;

        • a lapsed claim ends the session RefreshLost;

        • a budget shorter than a slow IdP answers Pending, and the leader still commits;

        • a slow store (delay_ops) answers Pending by the deadline, never after it, on the read, the poll and the cleanup paths;

        • a session ended mid-maintenance revokes the successor token for SignedOut and Operator, and not for Superseded; likewise when the renewal is refused after sign-out (end_claimed answers false);

        • a faulted claim presents nothing;

        • Foreign after a presented token ends the session RefreshLost.

    • Docs: shared-crates.adoc; idp-integration.adoc's renewal bullet names the engine.

  4. U4 (#2822, w3) feat(auth): complete sign-ins and sign out through the engine (V6, V7).

    • File: identity_web_session/engine/sign.rs: complete_sign_in and sign_out on WebSessionEngine.

    • Tests:

      • the record a sign-in yields;

      • Userinfo sends the access token at open, and the id_token profile does not;

      • a refused open revokes the grant’s refresh token and surfaces the refusal;

      • sign-out ends first, then posts the federation revoke, then gives the end-session URL with the hint when advertised, or the upstream revoke when not;

      • with no record, sign-out still gives end_session(None)'s URL when advertised, else PromptLogin, and posts no revocation;

      • with a record bound to another upstream, sign-out sends the configured upstream nothing of the record’s;

      • each leg’s failure is reported, not fatal;

      • a store fault revokes nothing.

    • Docs: shared-crates.adoc.

  5. U5 (#2823, w2) test(auth): prove the session engine against the devstack.

    • The test file: crates/canopy-test-lib/tests/web_session_engine_test.rs.

      • It reuses upstream_relying_party_test.rs's construction: the profile, UpstreamHttpClient::resolving, the FederationClient keyed as canopy-web, TokenBroker::upstream_sign_in and Driver::authorise_query.

      • The store is MemoryWebSessionStore (canopy-test-lib’s canopy-auth dependency enables test-helpers).

    • The tests, with jane.doe:

      • complete_sign_in yields a record that current serves;

      • each maintenance test first waits 1.1 s past the open’s second, as upstream_relying_party_test.rs does, so the reissued id_token’s iat is newer;

      • edit sets maintain_at in the past: current serves, and the detached maintenance commits (version + 1, fresh_until advanced) against real Kanidm and canopy-identity;

      • edit sets both fresh_until and maintain_at in the past: 8 concurrent current calls all serve one new version, and Kanidm’s rotating refresh never refuses, so single-flight holds;

      • sign_out → a delegation mint from the captured credential is refused session_ended, and the captured upstream refresh token is Ended;

      • the upstream refresh token, revoked at Kanidm directly, ends the next maintenance UpstreamEnded, and a delegation mint from the captured credential is then refused session_ended: the engine’s identity revocation.

    • Close:

      • CHANGELOG.adoc Added;

      • Amendment 18’s as-built record;

      • the plan Done and archived;

      • plan-lint --done with --allow-open for U1–U5, #2344, #2345, #2521 and #2647;

      • after merge, update the epic.

Scope

In: the record, the store trait, its contract suite and memory store; maintenance (V3–V5); sign-in completion; sign-out; the devstack proof.

Out:

  • The switch: canopy-web’s Postgres store and migration, its extractors, handlers, cookies, CSRF, flow store, metrics, and its mapping of Unserved.

  • I3e3: canopy-web’s sender, the session_stale retry and the engine’s maintain-now entry it needs.

  • Native-session revalidation: the device-approval plan.

  • #2521: encryption at rest.

Risks

  • A lapsed claim ends a fresh session (V4’s step 3): the token may be spent, and Kanidm’s rotation punishes a replay. With a 60 s lease, only a leader that died or lost its store loses its session.

  • A fresh, due session draws one claim attempt per concurrent request; only one wins. That is bounded by the request rate within one claim’s latency.

  • The memory store can diverge from Postgres semantics; the contract suite is the shared gate.

  • The last two minutes of a session: a validation there is capped at session_ends_at, so maintenance retries every 30 s until SERVE_MARGIN, about three renewals per session. That is accepted, so a grace capped there still recovers.

  • Grace detection assumes canopy-web’s clock is within D9’s 60 s of canopy-identity’s. Past that skew, a grace reads as a validation, and VALIDATION_CADENCE still bounds the interval.

  • Repeated grace requests: a deployment whose grace is under FRESHNESS_LEAD, or a session stale through a long upstream outage, asks for grace on each 30 s retry a request triggers. Each adds an audit row, which is accepted.

Verification

  • Per unit: fmt; clippy with validate’s flags; quality-budgets, plan-lint, check-docs and private rustdoc.

  • nextest:

    • canopy-auth with and without test-helpers (U2–U4);

    • cargo xtask test --integration --host -p canopy-test-lib --no-refresh --skip-static (U5).

  • Per MR: the pre-push battery.

Review log

Round Vendor Resolved model Verdict

1

Anthropic

Claude Opus 5.5 (fresh subagent)

no-ship. Two blockers, fixed in-plan:

  • U5’s and U3’s stale tests left maintain_at in the future, so V4’s retry spacing answered Pending;

  • an MR reference outside the Done value.

  • Notes folded in: renewal()'s type; the stored as_str spellings; the issuer’s now-relative answer; the contract suite’s typed failure; the unmapped outcomes; the constants' and U4’s homes; the memory store’s copy and edit's version step; the grace-churn risk.

2

not stated (the maintainer’s other vendor)

not stated

8 findings (1 P1, 6 P2, 1 P3), fixed in-plan:

  • a grace capped at session_ends_at no longer ends maintenance;

  • the record keeps its upstream binding, checked before any refresh, revocation or hinted logout (UpstreamChanged);

  • a grace answered as a 200 is detected, and VALIDATION_CADENCE caps the interval;

  • every engine-written end revokes the canopy-identity session;

  • one absolute deadline covers every waiter operation;

  • sign-out with no record still offers end_session(None);

  • replace-or-retain on both renewal branches;

  • the contract suite’s corrupt hook.

The maintainer shipped after round 2 (2026-10-09).

Edit this page · default