Files
aevolution/docs/adr/0091-m10-session-identity-and-control.md
T
dingoandClaude Opus 5.5 01b4b06a09
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m47s
Foundation / checks (client) (push) Failing after 9m42s
Foundation / checks (network) (push) Successful in 8m49s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 8m13s
Foundation / checks (tsan) (push) Canceled after 7m13s
Foundation / checks (checks) (push) Canceled after 17m58s
Add M10.3a account-bound session grants and region session control
Provider-independent 128-bit AccountIds; ECDSA P-256 session grants v1 signed by
issuer keys and verified by regions with public keys only, the environment byte
signed so dev grants never verify in stage or World0. Per-account serials make the
newest grant win: replay and older stolen grants are refused, a newer grant replaces
the account's session, and refresh renews in place. Attempt rates and capacities
are bounded. The evo_identity library provides the provider, account directory and
grant issuer interfaces with a dev-only test provider. ADR-0091.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 20:54:04 -04:00

87 lines
5.7 KiB
Markdown

# ADR-0091: M10 session identity, grants and control authority
## Status
Accepted for M10.3 (2026-10-03). Decisions confirmed with the maintainer on 2026-10-03:
ECDSA P-256 grants through Mbed TLS PSA; an identity adapter and grant issuer as a
library (no service, no Steam yet); a newer grant replaces an account's existing
session; unique control backed by a durable per-world control lease. Delivery:
10.3a grants, identity adapter and region session control (this text);
10.3b the QUIC session handshake; 10.3c the durable control lease. Each segment
amends this ADR. The M9 dev path (ADR-0082/0083, protocol v1) is unchanged.
## Context
ADR-0017 and NETWORK_ARCHITECTURE require short-lived world/region/account-scoped
grants, reconnect that cannot duplicate control, secrets kept out of logs, and an
identity provider independent of Steam. ADR-0089 fixed that reconnect is a new grant,
a new session and a fresh baseline, and that no session survives an epoch change.
M9 has only dev grants: HMAC-SHA256, a u64 subject, refusal of a second session per
subject, single use remembered in a file ledger. No account backend exists, and no
controllable organism exists yet (organisms arrive with M11).
## Decision
**Accounts.** `AccountId` is 128 random bits assigned by the account directory and
never derived from a provider id. Providers authenticate a credential to a
`ProviderSubject` (provider kind plus opaque subject); the directory maps subjects to
accounts. Logs and events may carry only `log_label` (the first four id bytes).
**Grant format v1** (schemas/network/session-grant-v1.md): fixed 160 bytes,
`EVO-GRANT` marker, version, environment byte, issuer key id, grant id, account,
per-account serial, world/frame, region, issued/expiry seconds; ECDSA P-256 over
SHA-256 of the first 96 bytes (Mbed TLS 4.1.1 PSA, already pinned; no new dependency).
Issuers hold private keys (`GrantSigningKey`, non-exportable PSA keys); regions hold
only public keys (`GrantVerifier`, at most 8 per environment for rotation), so a
compromised region cannot mint grants. Verification checks the signature before any
claim and then requires the signed environment byte to equal the verifier's.
**Dev cannot reach production, by four independent checks:** M9 dev grants have
another marker and length; a dev-signed session grant carries the dev environment
byte and fails in stage/World0 even if a dev public key were misconfigured there;
`DevTestProvider` (credential `dev-test:<name>`, no secret) cannot be constructed
outside dev; `GrantIssuer` refuses a provider and key from different environments.
**Serials order grants; the newest wins.** The directory issues per-account serials
that strictly increase, with non-decreasing `issued_at`. A region accepts a grant only
if its serial is greater than every serial it accepted for that account. This gives
single use (replay is `stale_grant`) and makes an older unexpired grant, for example a
stolen one, useless once a newer grant was presented. A region remembers an account's
serial until the newest accepted `issued_at` plus its maximum lifetime, after which
every older grant has expired.
**Session control** (`SessionControl`, per region, single owner, transport-neutral):
environment, world, region, lifetime (default maximum 300 s), clock skew (30 s),
expiry and serial checks; at most one session per account. A valid newer grant for an
account that holds a session closes the old session first and reports it as
superseded, so control is never shared and a dropped client reconnects without waiting
for the 5 s liveness timeout. `refresh` renews the session in place with a newer grant
(no reconnect or new baseline); a session closes when its grant expires. An epoch
change closes every session. Bounds: sessions (32), tracked accounts (4,096; full fails
closed rather than forgetting serials), and attempt rates: region-wide attempts before
signature verification (64 per 60 s) and verified attempts per account (4 per 60 s),
counted whether or not accepted. A refused open (capacity) does not consume the grant.
These limits are engineering defaults, not game rules.
**Identity adapter** (`evo_identity`, library): `IdentityProvider`, `AccountDirectory`
(bounded in-memory implementation for tests and tools), `GrantIssuer` (credential to
signed grant, lifetime 1..3600 s). Production providers and a running issuer service
are later work behind these interfaces.
## Alternatives considered
| Option | Disposition |
|---|---|
| HMAC grants per environment | Every region could forge grants for its environment. |
| Ed25519 | Not in Mbed TLS; would need a new crypto dependency. |
| Refuse a second login (M9 behaviour) | A silently dropped client waits for the liveness timeout; kept for M9 only. |
| Per-grant single-use set | Does not stop an older unused grant (stolen) from taking control; serial ordering subsumes it. |
| Grant lifetime as session lifetime without refresh | Short grants would force reconnects and fresh baselines every few minutes. |
## Consequences and limits (10.3a)
- Serials and sessions are in memory: a restarted region process would accept an
already-used, still-unexpired grant again (bounded by the 300 s lifetime), and two
regions of one world could each admit the same account. The durable control lease
(10.3c) closes both. Until then nothing deploys M10 sessions.
- If a newer grant is stolen before its owner presents it, the thief can take control
until the owner presents a still newer grant. Grants travel only inside TLS and are
never logged; revocation (bans) and channel binding are not designed yet.
- Private-key provisioning: `GrantSigningKey::import` takes a raw 32-byte P-256 scalar;
a provisioning tool and secret handling come with the issuer service.