Add M10.3b session login over QUIC
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 3m13s
Foundation / checks (client) (push) Successful in 12m12s
Foundation / checks (network) (push) Successful in 8m56s
Foundation / checks (tsan) (push) Successful in 7m42s
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 19m14s
Foundation / checks (checks) (push) Canceled after 31m28s

Session protocol v1 session messages (Hello with grant, Welcome, Refresh,
RefreshResult, Close with reasons) on the QUIC reliable stream. RegionSessions
verifies grants with the issuer public keys and admits them through SessionControl:
a newer grant closes the account's old connection as superseded, expiry and epoch
advances close sessions, every close is announced and flushed. RegionSessionClient
logs in, refreshes in place and reports why a session ended. ADR-0091.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-03 21:12:00 -04:00
co-authored by Claude Opus 5.5
parent 01b4b06a09
commit 7956143cd8
17 changed files with 1262 additions and 7 deletions
+49
View File
@@ -0,0 +1,49 @@
# M10 session protocol, version 1 (session messages)
Login and session control over the QUIC reliable stream (ADR-0090 transport, ADR-0091
identity). Implemented by `encode_session`/`decode_session`
(include/evo/network/session_protocol.hpp), `RegionSessions` (server) and
`RegionSessionClient` (client). Each message is one framed QUIC reliable message.
Integers little-endian. Every message has a fixed length for its type; any other length,
magic, version, nonzero flags, unknown type or out-of-range value is refused, and the
server then sends Close (`unsupported_version` for another version, otherwise
`protocol`) and closes the connection. Later M10 segments add types in a new version.
## Header (8 bytes)
| Offset | Size | Field | Rule |
|---|---|---|---|
| 0 | 4 | magic | bytes `EVSN` |
| 4 | 2 | version | 1 |
| 6 | 1 | type | 1..5 below |
| 7 | 1 | flags | 0 |
## Messages
| Type | Direction | Payload | Size |
|---|---|---|---|
| 1 Hello | client -> server | required_features u32 (0), grant (session-grant-v1, 160 bytes) | 164 |
| 2 Welcome | server -> client | session, epoch, world, frame, region, expires_at, server_seconds (u64 each; session and epoch nonzero) | 56 |
| 3 Refresh | client -> server | newer grant for the same account (160 bytes) | 160 |
| 4 RefreshResult | server -> client | status u8 (0 accepted, else a close reason value), expires_at u64 | 9 |
| 5 Close | either | reason u8 | 1 |
Close reasons (wire 1..13): 1 client_closed, 2 superseded, 3 expired, 4 stale_epoch,
5 unauthenticated, 6 wrong_scope, 7 stale_grant, 8 rate_limited, 9 capacity,
10 protocol, 11 timeout, 12 unsupported_version, 13 shutdown. Value 255
(`connection_lost`) is local only and never sent.
## Sequence and rules
- The client sends Hello first, as soon as the pinned QUIC connection is up. The server
closes with `timeout` if no Hello arrives within 5 s of connecting, and refuses any
other first message with `protocol`.
- Region-wide attempts are counted before the signature is checked (`rate_limited`).
The grant must verify with one of the region's issuer keys (`unauthenticated`) for the
region's environment (`wrong_scope`), then pass session control: world/region scope,
lifetime, expiry, serial (`stale_grant`), per-account attempts and capacity.
- Welcome confirms the session; `expires_at` is the grant's expiry. A newer grant for an
account with an open session closes that session's connection with `superseded`.
- Refresh renews the open session with a newer grant; a refusal leaves the session and
its expiry unchanged. The server closes a session with `expired` when its expiry
passes, and every session with `stale_epoch` when the region's ownership epoch advances.
- Close is followed by closing the connection (the server waits up to 1 s for delivery).
A client that closes its connection without Close is treated as `client_closed`.
- Reconnecting needs a new connection and a newer grant (ADR-0089).