Identity plane split, plan I2a: the call graph, the client model and the delegation token layout (epic &132)
- Context
- Scope
- Design
- Decisions (recorded in ADR-049 Amendment 4, which lands with U1)
- U1: compiled clients and receivers (crates/canopy-auth)
- U2: the observed census (xtask)
- U3: the compiled call graph (crates/canopy-auth/src/identity_policy/call_graph.rs)
- U4: the gate and the generated table (xtask)
- U5: the delegation token layout (crates/canopy-auth/src/identity_policy/delegation.rs)
- Conventions every unit follows
- Units
- Verification
- Review log
Status: Done (2026-10-04) — !1566
Epic: &132 (stage I2 of &130)
Issues: #2641 (w3), #2642 (w5), #2643 (w5), #2644 (w3), #2645 (w5)
MR: feat/identity-call-graph: U1–U5 in order, titled "canopy-identity clients, call graph and delegation layout (#2641, #2642, #2643, #2644, #2645)". Its description relates #1447 and #1448.
The five issues are one deliverable, the compiled policy every later I2 plan reads, so they ship as one MR under the maintainer’s one-MR-per-related-group ruling, one commit per issue. U1’s commit adds this page (Status In progress) and its nav entry. U5’s commit closes the plan.
This is a Design + Scope plan. GitLab owns tracking. The plan freezes when U1 starts.
Context
ADR-049 D4 makes policy code: two compiled tables in canopy-auth, the call graph (which caller may delegate to which target) and the purpose registry. Plan I1b (archive) built the purpose registry for one client, the portal (crates/canopy-auth/src/identity_policy.rs). Stage I2 (&132) builds the user plane on the call graph, so the graph and the clients it names come first.
In the tree today:
-
SystemClienthas one variant,CanopyPortal. No type names canopy-web, canopy-cli or a service as a client, and no type names a receiving service: audiences are strings built byservice_audience. -
The edges exist only as deployment settings. Each service’s config module carries one
<peer>_urlfield per service it calls (services/canopy-snap/src/config.rs:rules_url,verification_url,persons_url,enrollment_url,security_url); canopy-eligibility also readsCANOPY_PROGRAM_URL_<PROGRAM>(services/canopy-eligibility/src/registry.rs), and canopy-cli itstools/canopy-cli/src/config.rsprofile. Together they name 75 service edges and 12 canopy-cli edges. -
The one written record, the caller manifest in authorization inventory, is prose, is gated by nothing, and misses at least 22 edges.
-
Only the system token has a pinned layout (
SystemTokenClaims, Amendment 3 A4). The delegation token D3 describes has no type.
Scope
In scope: U1–U5 below. Nothing mints, validates a delegation token or serves a route.
Out of scope:
-
upstream profiles and id_token verification (I2b);
-
subjects, sessions and federation (I2c);
-
the delegation mint, its receiver validator and its client (I2d);
-
revocation and security administration (I2e);
-
the device flow and DPoP (I2f);
-
the capacity test (I2g);
-
purposes for any sender but the portal, which arrive with each sender’s I3 cut-over (A2), and wiring any sender or receiver (I3, &133).
Design
Decisions (recorded in ADR-049 Amendment 4, which lands with U1)
| # | Decision |
|---|---|
B1 |
Clients.
|
B2 |
Receivers. |
B3 |
The call graph. One compiled table, one row per (caller, target):
|
B4 |
Classifying an edge (D3’s routing rule). Every call on the edge is traced to its origin:
canopy-cli is |
B5 |
The delegation token layout.
|
B6 |
The depth bound. |
B7 |
The census. Edges are observed from the deployment settings that hold peer URLs. A service can call only a peer it has a URL for. The census scans every non-test source file of every service and canopy-cli (not just |
U1: compiled clients and receivers (crates/canopy-auth)
-
crates/canopy-auth/src/identity_policy.rsbecomes a module root over a newidentity_policy/clients.rs, ascrates/canopy-auth/src/identity_client.rssits over its directory. It holdsConfidentialClient,NativeClient,Client,CanopyService(each withas_str,FromStrand serde as the id;strum::EnumIteron the three flat enums only),Client::all(),Client::opens_sessions()(canopy-web and the native clients) andConfidentialClient::service().Clientwraps the other two, so a derivedEnumIterwould yield only its two outer variants with default payloads;Client::all()instead chainsConfidentialClient::iter()andNativeClient::iter()into all 16 identities. -
SystemPurpose.client,SystemTokenClaims.suband.client_id, andClientAssertionClaims.issand.subbecomeConfidentialClient. The rename runs through every Rust user (git grep -l SystemClient — '*.rs'), canopy-portal’stokens.rsand canopy-security’s identity module included. TheCHANGELOG.adocUnreleased bullet namingSystemClientis amended to the new types; archived plans stay frozen. -
Tests:
-
every id round-trips, and near-misses (case, whitespace, a prefix) are refused;
-
Client::all()yields 16 distinct ids, every confidential and native variant exactly once; -
the three id sets are disjoint except where
service()maps a client to its own service’s id, which a test asserts for all 13; -
from_audienceis exact; -
the registry refuses
canopy-clias an unknown client; -
the refusals a second client makes reachable, each with a test:
ClientAuthRefusal::ClientMismatch(services/canopy-security/src/identity/client_auth.rs) and the validator’sRejection::Subject(crates/canopy-auth/src/identity_token.rs); -
the existing tests that use
canopy-webas an unknown id switch to an id no enum compiles.
-
-
Docs: ADR-049 Amendment 4 (B1–B7) and its Status line;
shared-crates.adoc; the registry’sclientrow inconfiguration-reference.adoc(a compiled confidential id; a native id is refused). This page and its nav entry.
U2: the observed census (xtask)
-
cargo xtask call-graph censusprints the observed edges, sorted by sender then target, each with its evidence (file, line, setting).xtask/src/cmd/call_graph.rsholds theArgsand the subcommandscensus,checkanddoc(U4);xtask/src/cmd/call_graph/observed.rsthe extraction. Registered inxtask/src/cmd/mod.rsandxtask/src/main.rsbesideMqTopology. -
Sources, parsed with
synover every non-test.rsfile underservices/<service>/src/andtools/canopy-cli/src/(nested modules such asservices/canopy-eligibility/src/bulk/config.rsincluded), test code excluded throughcrate::test_scopeasxtask/src/cmd/mq_topology.rsdoes:-
every struct field named
<x>_url, wherecanopy-<x>is aCanopyServiceid (U1);self_base_urlis the sender’s own service; -
every string literal naming a
CANOPY_*URL*variable, such as eligibility’sCANOPY_PROGRAM_URL<P>, mapped throughcanopy_reference::Programto its service (CHIP to canopy-medicaid).
-
-
The naming convention the census relies on (a peer’s base URL is a
<peer>_urlfield or aCANOPY_*_URL*variable) is recorded indocs/modules/ROOT/pages/coding-conventions.adoc. -
Not peers, each with a reason in a compiled list:
redirect_url,portal_base_url,oidc_internal_url,identity_internal_url,redis_sessions_url,keycloak_url, and canopy-security’sinternal_url(the issuer’s in-cluster base URL),chain_verify_database_url,chain_verify_tanf_database_urlandchain_verify_medicaid_database_url. Any otherurlstruct field orCANOPY*_URL*literal fails the run, naming its file and line. -
Tests (in-memory sources): a peer field yields an edge, in
config.rsand in a nested module; an unclassified field or variable fails with its location; a#[cfg(test)]field is ignored; the CHIP mapping; the non-peer list; a stable order; a proptest that no field name panics the extractor.
Erratum (2026-10-04): the non-peer list above, taken as written, left 54 production settings unclassified, because it was drawn from the config.rs view before the scan was widened to every source file. As built, the census also classifies a <peer>_base_url field as a peer field (like self_base_url), classifies the environment form of the sender’s own setting (CANOPY_<SENDER>__<SETTING>) by the field rules, and lists twelve more non-peers, each with its reason (HTTP-client base_url copies, canopy-security’s identity_database_url, canopy-web’s template links and two of its fields, and canopy-notices' kill_url). All but identity_database_url are values built at run time, not settings: such an entry covers only a field of an item that does not derive Deserialize, never an environment form, and the three single-site ones only in their own file. No pair changes: the census lists 87 pairs. Its output adds a non-peer summary after the pairs, and names each sender by its crate id, so U4 maps a sender to a Client and reports one that is not compiled.
U3: the compiled call graph (crates/canopy-auth/src/identity_policy/call_graph.rs)
-
One documented
constslice per caller (const CANOPY_WEB: &[Edge], …), each doc comment naming the call sites behind its kinds, andconst CALLERS: [&[Edge]; 16]over them; doc comments on array elements do not compile (unused_doc_comments).pub const MAX_ACT_DEPTH: usize. Functions:edges() → impl Iterator<Item = &'static Edge>,edge(caller, target) → Option<EdgeKind>,may_delegate(caller, target),may_hold_system_token(client, target)anddelegators_of(target). -
The rows start from the table below. The implementer traces every row’s call sites against B4; where a trace contradicts a row, B4 wins, and the commit body names the row and the call site.
Caller Delegation System Both canopy-web
appeals, applications, caps, eligibility, enrollment, medicaid, notices, persons, renewals, reporting, snap, tanf, verification, wic
—
security
canopy-cli
applications, caps, eligibility, medicaid, notices, persons, renewals, rules, security, snap, tanf, wic
—
—
canopy-portal
—
applications, eligibility, enrollment, notices, persons, renewals, security, snap, verification
—
eligibility
caps, tanf, wic
eligibility, rules, security
applications, enrollment, medicaid, persons, renewals, snap, verification
applications
renewals
—
eligibility, persons, verification
appeals
snap
—
applications, enrollment
enrollment
applications
—
—
notices
—
applications, persons
—
renewals
—
enrollment, persons
eligibility
reporting
—
applications, caps, enrollment, persons, renewals
medicaid, snap, tanf
snap
—
rules, security, verification
enrollment, persons
tanf
—
persons, rules, security
—
medicaid
—
persons, rules, security
—
caps, wic
—
rules, security
—
verification
—
—
applications, persons
Two rows carry system work only because a background caller reaches them transitively (B4): applications' postponement saga calls verification, whose handler reads the parent application (
services/canopy-verification/src/api/requests.rs~158), so verification → applications isBoth; reporting’s background worker calls TANF’s service-only batch endpoint, which resolves children’s birth dates through persons (services/canopy-tanf/src/participation/week_standard.rs~133), so tanf → persons isSystem. The census cannot see a kind, so U3’s doc comments must name the originating background caller for everySystemandBothrow reached this way.Erratum (2026-10-04): a call-site trace of all 87 edges, done before U3 started, moved five rows of the table above to what the code does (B4 wins). tanf → persons and renewals → enrollment are
System: no worker or native-client request reaches them. eligibility → caps, tanf and wic areDelegation: the order arm dispatches to any program an order names, but no producer names these three, so a future producer adds the system side as a compiled edge, and until then a system token for them fails closed. The rules carve-out in B4 covers eligibility → rules too: its one call, a corpus-hash read in the admin bulk-run routes, carries no user’s data. More generally, a service’s own bookkeeping inside a user’s request — a call that carries no user’s data to a receiver that admits no user, such as eligibility’s JWKS read and audit ingest, canopy-web’s exchange-audit ingest, and medicaid’s admin sweep — is system work. -
Tests, exhaustive over
Client × CanopyService:-
each pair appears at most once;
-
no
DelegationorBothself-edge; -
canopy-cli’s rows are
Delegationand the portal’sSystem; -
every compiled purpose names a
SystemorBothpair; -
every caller of a
DelegationorBothrow is reachable from a session opener alongDelegationandBothrows, so it can hold a subject token; -
MAX_ACT_DEPTHequals B6’s depth-first count; -
the functions agree with the table;
-
every compiled client calls at least one service.
-
U4: the gate and the generated table (xtask)
-
cargo xtask call-graph check(the default subcommand) runs invalidatebesidemq-topology(xtask/src/cmd/validate.rs), with its ownSTAGESentry inxtask/src/validate_report.rs(call-graph, Blocking,ErrorChainOnly, placed aftermq-topology). The report’s checkpoint and recording methods skip an id the inventory doesn’t list, so without the entry the gate would run unreported and a failure would lose its diagnostics. The inventory count pins andtesting.adoc's stage table follow, and a test asserts a failing check records its diagnostics. It fails on:-
an observed pair that is not compiled;
-
a compiled pair that is not observed (authority nothing uses);
-
drift, in either direction, between
edges()and the table in a new "Compiled call graph" section ofauthorization-inventory.adoc(| caller | target | kind |, one row per edge, sorted as the census sorts).cargo xtask call-graph docprints that table for pasting;xtask/src/cmd/call_graph/doc.rsrenders and parses it.
-
-
It prints, without failing, each
*_AUTHORIZED_EXCHANGER_AZPSentry and canopy-eligibility’sEXCHANGE_TARGETSindocker-compose.ymlthat is not a compiled delegation edge. An azp maps to its client by removing the-exchangersuffix (canopy-web-exchangeris canopy-web); any other azp prints as unmapped. I3 deletes those settings. -
There is no allowlist: an exception is a compiled edge with its doc comment.
-
Tests: fixture diffs in each direction; a proptest that the table renders and parses back to the same edge set; a malformed row fails with its line; the advisories never fail.
-
Docs: the existing prose caller manifest stays, labelled as the running Keycloak-era record until I3 replaces it;
testing.adoc's gate list.
Erratum (2026-10-04): as built, the gate’s comparison and the compose advisories live in xtask/src/cmd/call_graph/check.rs beside doc.rs. The table must also be in census order with one row per pair, the advisories read every CANOPY_<SENDER>__EXCHANGE_TARGETS (canopy-eligibility’s is the only one set), and EdgeKind gains as_str, Display and FromStr for the table’s kind cell, written in lower case. The table’s header row is | Caller | Target | Kind, and a row has exactly three cells, so a trailing pipe is refused.
U5: the delegation token layout (crates/canopy-auth/src/identity_policy/delegation.rs)
-
DELEGATION_TOKEN_MAX_LIFETIME_SECS: i64 = 300. The headertypis the existingSYSTEM_TOKEN_TYPconstant, renamedACCESS_TOKEN_TYPwith no alias, itsCHANGELOG.adocmention amended. -
Newtypes:
SubjectId(Uuid),SessionId(Uuid),RoleName,RoleSet,ProgramSetandActorChain(current actor first).ActorChainserializes as RFC 8693’s nested{"sub": …, "act": {…}}through a typedRawActor { sub: Client, act: Option<Box<RawActor>> }that denies unknown fields; there is noserde_json::Value. The innermost actor carries noactmember at all (#[serde(skip_serializing_if = "Option::is_none")]), since RFC 8693 §4.1 definesactas an object: the leaf fixture is pinned as{"sub":"canopy-web"}, and an explicit"act": nullis refused on parse. -
DelegationTokenClaimsholds B5’s claims (client_id: Client) and is built throughTryFrom<RawDelegationClaims>, so every context-free B5 invariant is a parse error:client_idis the current actor;nbfequalsiat; the chain’s length, opener, middle actors and no-repeat rule; canonical, non-empty sets. Lifetime,iss,audand the last hop’s edge are the I2d validator’s. -
canopy-auth gains
canopy-reference = { workspace = true }. That bringsrust_decimalandutoipainto canopy-auth’s build, both already workspace dependencies; no new crate enters the workspace. -
Tests: the serialization pinned against a fixture;
purpose,scope,cnfand unknown claims refused; the pinned system token never parses as a delegation token and the reverse; each invariant refused on its own; proptests that the claims andActorChainround-trip and that arbitrary input never panics. -
Docs:
shared-crates.adoc. The plan closes here: StatusDone (YYYY-MM-DD) — !N, the page moved todocs/modules/ROOT/pages/plans/archive/with the nav moved as the header says, Amendment 4’s link repointed, andcargo xtask plan-lint --done docs/modules/ROOT/pages/plans/archive/identity-plane-split-i2a.adoc --allow-openfor U1–U5, 1447 and 1448.
Erratum (2026-10-04): as built, client_id and nbf are wire claims but not stored fields. DelegationTokenClaims::client_id() is the chain’s current actor and nbf() is iat, so no value can disagree with them; parsing still refuses a payload whose client_id or nbf differs. The private RawDelegationClaims is the wire form, so only checked claims serialize. Building a part directly returns a typed error: ClaimSetError (empty, repeated or unsorted) for either set, ActorChainError for the chain; a payload’s refusal is the deserializer’s error, whose message names the broken rule. CHANGELOG.adoc never named SYSTEM_TOKEN_TYP, so the rename amends no bullet.
Conventions every unit follows
-
No clock reads, no database and no network in I2a, so every test is a deterministic unit test.
-
Every parser gets a proptest (the census extractor, the ids,
ActorChain, the claims). Errors are thiserror enums in canopy-auth andanyhowwith context in xtask. -
Every unit ships its
CHANGELOG.adocAddedbullet and the doc pages its section names.
Units
-
U1 (w3) —
feat(auth): compile canopy-identity clients and receivers (#2641).identity_policy/clients.rs, the rename, ADR-049 Amendment 4, this page and its nav entry. -
U2 (w5) —
feat(xtask): observe the call graph from peer settings (#2642).xtask/src/cmd/call_graph.rs,xtask/src/cmd/call_graph/observed.rs. -
U3 (w5) —
feat(auth): compile the D4 call graph (#2643).identity_policy/call_graph.rs. -
U4 (w3) —
feat(xtask): gate the call graph against the census (#2644).checkanddoc,xtask/src/cmd/call_graph/doc.rs,validate.rs,authorization-inventory.adoc. -
U5 (w5) —
feat(auth): pin the delegation token claim layout (#2645).identity_policy/delegation.rs, the plan close.
Verification
-
Per unit: fmt; clippy in both profiles; nextest for canopy-auth, canopy-security, canopy-portal and xtask;
rustdoc-private;quality-budgets;feature-builds. -
Per MR: every
validatestage, thengit push(the pre-push battery). -
After merge:
git grep -n SystemClient — '*.rs'is empty;cargo xtask call-graph censuslists 87 pairs;cargo xtask call-graph checkpasses on main.
Review log
| round | vendor | resolved model | verdict |
|---|---|---|---|
1 (2026-10-03) |
Anthropic |
claude-opus-5-5 |
no-ship. Five blockers, all fixed: the census used a type a later unit created, so the clients unit now comes first; the census missed canopy-security’s |
2 (2026-10-04) |
OpenAI |
gpt-6-astra |
no-ship. Five findings and one clarification, all fixed: verification → applications and tanf → persons are |