Identity plane split, plan I3d: canopy-identity senders (epic &133)

Status: Done (2026-10-09) — !1585
Epic: &133 (stage I3 of &130)
Issues: #2806 (U1, w2); #2807 (U2, w3); #2808 (U3, w5); #2809 (U4, w3); #2810 (U5, w2). Each relates to #2648, which closes at the switch (E8). U1 files #2811.
MR: feat/identity-senders, "canopy-identity senders (#2806 … #2810)".

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. E1–E8 are this plan’s decisions (ADR-049 Amendment 16); R1–R3 are the maintainer’s rulings.

Context

I3a’s stage list gives I3d "every sender’s purposes (A2), client-key loading and settings, the shared clients' token plumbing, the verification adapter routes (#2648); unwired" (plan I3a).

What canopy-auth already holds, unwired:

  • ClientAssertionMinter (A1), SystemTokenSource (system tokens cached per (resource, scope), single-flight, invalidate) and DelegationTokenSource::delegate (onward delegation with a per-request DelegationCache, G9). All in crates/canopy-auth/src/identity_client.rs and identity_client/delegation.rs.

  • I3c’s receiver: Principal and UserPrincipal::delegation() (identity_receiver/principal.rs), and ReceiverSettings (identity_receiver/settings.rs).

  • canopy_signing::load_provisioned_key (D10: through SecretProvider, with no file fallback).

What is missing:

  • Purposes. Only the portal’s 9 exist (identity_policy.rs, PORTAL_PURPOSES). The other 46 System/Both edges in identity_policy/call_graph.rs have none, so the issuer answers invalid_target to every other system-token request.

  • Settings and keys. No setting names a client key, and no type derives the token endpoint.

  • B4’s choice. Nothing picks a call’s token: delegation onward from the request’s user, or a system token.

  • The adapter routes. Verification’s /internal/v1 adapter routes check one shared X-Service-Api-Key (services/canopy-verification/src/api/service_key.rs):

    • IEVS: called by snap’s detached task (services/canopy-snap/src/verification_client.rs);

    • SOLQ: called by eligibility’s determine (services/canopy-eligibility/src/orchestrator.rs, fetch_ssa_solq);

    • SAVE: no production caller.

Maintainer rulings (2026-10-09):

  • R1. Each service purpose holds one scope. Receivers keep checking the edge and the route’s client list (L2, L3).

  • R2. #2648’s decisions are made now, and SOLQ’s admission is compiled. The switch moves the routes and deletes the key.

  • R3. I3d is the sender library only. The shared clients and their call sites (about 45 token fetches and 184 bearer attachments) move at the switch, which keeps K1.

Decisions (ADR-049 Amendment 16, E1–E8; land with U1)

  • E1. Service purposes. Every non-portal System or Both edge (46) gets exactly one purpose, <client>/<target> (A2). Its one scope is its own name, so a purpose cannot drift from its scope.

    • The scope is informational: a receiver checks a system token’s edge (L3) and the route’s client list (L2), never this scope (R1).

    • This amends B7’s last sentence: for a service caller, route-level authority is the route’s client list; only the portal’s purpose scopes carry it.

    • A service_purpose!(Client, "canopy-x", "canopy-y") macro builds each entry, so the name, the audience and the scope come from one pair through concat!.

  • E2. One settings type. ReceiverSettings becomes IdentitySettings, because the receiver and the sender read the same two settings (L6).

    • It moves to crates/canopy-auth/src/identity_settings.rs, with ISSUER_SETTING, INTERNAL_URL_SETTING and its tests. IdentityReceiver::over_http(&IdentitySettings, CanopyService, IdentityHttpClient) moves to identity_receiver/layer.rs, beside IdentityReceiver.

    • It adds token_endpoint() = identity_endpoint(INTERNAL_URL_SETTING, &internal, "token"), which is /identity/token under the internal URL.

    • No alias: the type is pre-1.0 and unwired.

  • E3. The client key. client_key_secret(client) names CANOPY_<SERVICE>IDENTITY_CLIENT_PRIVATE_KEY, where <SERVICE> is the client id without canopy-, upper-cased, with - → _ (for example CANOPY_SNAP…).

    • The key is loaded only through load_provisioned_key (D10).

    • The devstack hands each service its key at the switch (K4). Until then, U5’s proof feeds the generated key file through an in-memory provider.

  • E4. The sender. One IdentitySender per process, for a confidential client that runs as a service, owning one SystemTokenSource and one DelegationTokenSource over one key.

    • IdentitySender::over_http(&IdentitySettings, ConfidentialClient, Arc<dyn KeySigner>, IdentityHttpClient) → Result<Self, SenderError>.

    • IdentitySender::from_secrets(&IdentitySettings, ConfidentialClient, &dyn SecretProvider, IdentityHttpClient) → Result<Self, SenderError>.

    • SenderError:

      • NotAService(ConfidentialClient): the client’s service() is None (canopy-web, canopy-portal; their senders are I3e’s and I3f’s);

      • Key(#[from] ProvisionedKeyError).

  • E5. Origin and kind (B3, B4).

    • Origin<'p>: User(&'p VerifiedDelegation) or System. Origin::of(&'p Principal):

      • a user principal gives User(user.delegation());

      • a system principal, the portal’s included, gives System;

      • detached tasks, background work, durable retries and boot use Origin::System.

    • IdentitySender::calls<'p>(&self, Origin<'p>) → Outbound<'_, 'p> holds the origin and the request’s DelegationCache.

    • Outbound::bearer(&mut self, CanopyService) → Result<Bearer<'_>, SendError> takes the token’s kind from the compiled edge edge(Client::Confidential(client), target):

      • no edge: SendError::NoEdge, and nothing is sent;

      • System: a system token, whatever the origin (rules, audit writes, process-wide reads);

      • Delegation: onward from the user’s token, never narrowed (Narrowing::default()). A system origin is SendError::SystemOrigin, and nothing is sent;

      • Both: by origin.

    • Outbound::system_bearer(&mut self, CanopyService) asks for a system token where B4 makes an in-request call system (bookkeeping, process-wide data). A Delegation-only edge is SendError::NoSystemEdge; no edge is NoEdge.

    • System tokens are always asked for with scope: None (the purpose’s one scope).

    • SendError:

      • NoEdge, SystemOrigin, NoSystemEdge and Timeout, each carrying its target: CanopyService;

      • System(#[from] SystemTokenError);

      • Delegation(#[from] DelegationError).

  • E6. Budget and rejection.

    • The bound: each acquisition is bounded by SENDER_BUDGET = DELEGATION_BUDGET (5.5 s, G10’s floor for a sender’s call) + 1 s for signing and the round trip, with a const assertion that it is at least DELEGATION_BUDGET. The system grant’s 5 s budget fits inside it. Past the bound is SendError::Timeout.

    • Cancel safety: a cancelled system acquisition releases the single flight before counting an attempt, so the next waiter acquires. A cancelled delegation request never reaches the cache, which is written only after the answer.

    • After a receiver’s 401: Outbound::rejected(&mut self, CanopyService) invalidates the target’s system token (invalidate(audience, None)) and removes the request cache’s delegation entry for it. That uses a new DelegationCache::forget(target); each entry now records its target beside the token, since its key is an opaque digest. The call site’s one retry then reacquires (i1b).

    • The sender never retries on its own and never fails open (K1).

  • E7. Bearers.

    • Bearer<'a> is a borrowed &'a DelegationToken or an Arc<str> system token, read only through expose_for_call().

    • Bearer::owned() → OwnedBearer (Zeroizing<String>, with no Clone, Debug or Display) serves a task the request spawns, such as eligibility’s program fan-out.

    • No error carries a token, assertion or body.

  • E8. #2648, the adapter routes (R2).

    • SOLQ joins the delegated table (M1: eligibility reaches it inside a worker’s request on its own credentials). POST /internal/v1/ssa/solq takes Admission::system_from(&[Eligibility]).and_user_roles_via(&[ELIGIBILITY], CASEWORKER_WRITER_ROLES):

      • CMD orders are system;

      • a worker’s determine (canopy-web’s or the CLI’s POST /v1/eligibility/determine) reaches SOLQ inside its request;

      • determine’s bar is the writer bar (post_determine).

    • IEVS translates to system_from(&[Snap]): its one caller, a detached task, on a System edge.

    • SAVE translates to the key’s holders, system_from(&[Eligibility, Snap]). It has no production caller (#2811).

    • At the switch: the four routes move behind the receiver at their own paths (outside the /v1 nest), the key is deleted, and #2648 closes.

    • The delegated-route gate reads /internal/v1/ paths:

      • the census keeps a path that starts with /internal/ as is; today it would prefix /v1;

      • the table reader admits a backticked /v1/ or /internal/v1/ path.

Units

Erratum (2026-10-09): this plan’s decisions were lettered N1–N8, which Amendment 9 already uses; they are E1–E8 here and in ADR-049 Amendment 16 (#2812).

Erratum (2026-10-09): U3 adds Bearer::is_delegation(), which names a bearer’s kind for its Debug and the tests, and makes DelegationToken's compile-time probes crate-visible, so the sender’s tests hold OwnedBearer and Bearer to them; its J1 review asked for both.

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

  1. U1 (w2) docs(adr): record canopy-identity’s senders.

    • ADR-049 Amendment 16 (R1–R3, E1–E8, amending B7), plus the Status line.

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

    • The SAVE issue (#2811), related to #2648.

  2. U2 (w3) feat(auth): compile every service’s system purposes (E1).

    • identity_policy.rs: one const PURPOSES: [SystemPurpose; 55], the portal’s 9 first (unchanged, so tests looking up by audience still find them first), then 46 service_purpose! entries. purposes() returns it.

    • Tests:

      • every_service_system_edge_has_one_purpose: each non-portal System or Both edge has exactly one purpose;

      • a_service_purposes_one_scope_is_its_name;

      • the existing naming, grammar, uniqueness and edge tests now cover 55;

      • a_pair_without_a_purpose_finds_none keeps its Delegation-only pair (Web → Persons).

    • Docs: shared-crates.adoc.

  3. U3 (w5) feat(auth): add the canopy-identity sender (E2–E7).

    • New module: identity_settings.rs, with ReceiverSettings moved and renamed.

    • New module: identity_sender.rs (+ identity_sender/tests.rs).

    • Updated:

      • identity_receiver.rs (re-exports, docs);

      • identity_receiver/layer.rs (over_http);

      • identity_client/delegation.rs (forget, an entry’s target);

      • lib.rs re-exports;

      • crates/canopy-test-lib/tests/identity_receiver_test.rs (the renamed type).

    • Test seams:

      • make identity_client::tests and identity_client::delegation::tests pub(crate), with their Endpoint, spawn and key helpers;

      • IdentitySender::with_budget(self, Duration) → Self is #[cfg(test)] pub(crate).

    • Tests:

      • The edge and origin matrix: an eligibility sender on the delegation mock (whose answers extend the chain by canopy-eligibility, and which the system source also accepts). It reads each request’s grant_type off the mock’s recorded forms:

        • Rules (System) by either origin → client credentials;

        • Caps (Delegation): user → token exchange, system → SystemOrigin with no request;

        • Persons (Both): by origin;

        • Notices (no edge) → NoEdge with no request;

        • system_bearer(Caps) → NoSystemEdge.

      • Timeout: the system mock’s stall gate makes bearer Timeout at a short budget. Once the gate opens, the next call acquires.

      • Rejection: rejected makes the next system and delegation call reacquire (the mock’s hit count rises by one each).

      • from_secrets: a missing key is Key(ProvisionedKeyError::Missing) naming CANOPY_ELIGIBILITY__IDENTITY_CLIENT_PRIVATE_KEY, and a provisioned PEM builds.

      • client_key_secret gives each service client’s name.

      • canopy-web and canopy-portal are NotAService.

      • OwnedBearer exposes the bearer’s string.

      • The settings tests are moved, plus token_endpoint().

    • Docs: shared-crates.adoc; CHANGELOG.adoc Changed for the rename.

  4. U4 (w3) feat(auth): admit SOLQ by canopy-identity (E8).

    • delegated_routes.rs: the SOLQ row, citing services/canopy-verification/src/api/ssa.rs (handle_query). The count test goes to 120. the_deliberate_rows_keep_their_decisions pins SOLQ’s arms.

    • xtask:

      • census.rs path_of keeps a value starting with /internal/, with a fixture test registering paths::SSA_SOLQ as /internal/v1/ssa/solq;

      • doc.rs cells_in admits /internal/v1/ beside /v1/, with the reader’s refusal test extended (a backticked /internal/x is still refused).

    • Docs:

      • the regenerated table (cargo xtask delegated-routes doc);

      • in authorization-inventory.adoc, the cross-cutting bullet on the /internal/v1 surface (the one naming fetch_ssa_solq's x-service-api-key) gains a sentence: the switch re-admits the four routes by canopy-identity, per Amendment 16 E8 (#2648). The route rows stay as today’s code;

      • shared-crates.adoc's "119 routes" → 120.

  5. U5 (w2) test(auth): prove the sender on the devstack identity plane.

    • The test file: crates/canopy-test-lib/tests/identity_sender_test.rs, following identity_receiver_test.rs:

      • a broker() that returns None when infrastructure_available() is false, so the battery, which requires the devstack, runs the tests;

      • a probe behind IdentityReceiver::over_http for a given receiver and admission.

    • The tests:

      • Snap, system: snap’s sender, keyed from the broker’s keys directory through a one-secret provider (client_key_secret(Snap)), takes a system token for verification by Origin::System. The probe admits it under system_from(&[Snap]), and it carries the purpose canopy-snap/canopy-verification with that scope.

      • Eligibility, onward: the broker mints jane.doe’s delegation for eligibility, and an IdentityTokenValidator for eligibility verifies it into a Principal. Eligibility’s sender delegates onward to verification. The probe admits it under SOLQ’s compiled admission, with the actor chain canopy-eligibility, canopy-web and jane.doe’s realm subject.

      • Snap, user origin on a System edge: a delegation addressed to snap, sent through snap’s sender for verification, gets a system token (E5).

    • Close:

      • CHANGELOG.adoc Added;

      • Amendment 16’s as-built record;

      • the plan Done and archived;

      • plan-lint --done with --allow-open for #2806–#2810, #2648 and #2811;

      • after merge, close the units, comment on #2648, and update the epic.

Scope

In: the purposes, the settings rename, the key loader, the sender, SOLQ’s row and the gate’s path rule, the devstack proof, the SAVE issue.

Out:

  • The switch (I3g): wiring the sender into any client or service; moving the shared clients and their call sites; the ServiceSettings fields; handing services their keys; moving the adapter routes; deleting the shared key.

  • canopy-web’s sender, its session form and its system read (I3e).

  • The portal’s sender and canopy-cli (I3f).

  • A sender circuit breaker or metrics: the ADR names none.

Risks

  • A purpose’s scope reads as a grant it is not. E1 and the B7 amendment say it is informational, and a test holds it equal to the purpose name, so no one adds meaning to it unnoticed.

  • B4’s origin is wrong at a call site. The edge rule refuses the impossible pairs locally (NoEdge, SystemOrigin, NoSystemEdge). The rest is the switch’s call-site review, run against I3g’s battery as real users.

  • The rename touches I3c’s public type. It is unwired and pre-1.0. The CHANGELOG notes it.

Verification

  • Per unit: fmt; clippy with validate’s flags; nextest for canopy-auth (U2–U4), xtask (U4) and canopy-test-lib (U5); quality-budgets, plan-lint and check-docs; cargo xtask delegated-routes check (U4).

  • U5: run on a devstack whose canopy-security is built from the branch (cargo xtask dev reload), since the issuer serves the new purposes only from U2’s code.

  • Per MR: the pre-push battery.

Review log

Round Vendor Resolved model Verdict

1

Anthropic

Claude Opus 5.5 (fresh subagent)

no-ship. One blocker, fixed in-plan: B1, U4’s doc targets named a paragraph and a note that don’t exist (now the inventory’s /internal/v1 bullet and shared-crates.adoc's count).

Notes folded in: U5 follows the battery’s infrastructure_available() pattern, not #[ignore]; U3’s test seams and the mock pairing; forget records an entry’s target; the open signatures and errors; U3’s missed files; a 55-entry purpose array; the 5.5 s floor gets a 1 s margin; cancel safety stated per source; R2’s wording; the B7 amendment; U5’s issuer rebuild.

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

Edit this page · default