Files
aevolution/docs/adr/0093-m10-snapshots-and-interest.md
T
dingoandClaude Opus 5.5 1819ebc0ab
Foundation / checks (checks) (push) Successful in 32m47s
Foundation / checks (client) (push) Failing after 10m1s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (network) (push) Successful in 11m18s
Foundation / checks (postgres) (push) Successful in 40m20s
Foundation / checks (tsan) (push) Successful in 7m46s
Foundation / postgres-tools (push) Skipped
Foundation / image (push) Skipped
Foundation / server-image (push) Skipped
Switch the engineering client to M10 sessions (M10.5c)
evo-client's remote mode now runs over RegionSessionClient (QUIC, session
v2): snapshot-fed environment and organism views, the camera following the
server's view until the user moves it and then driving the interest, intention
records with a simulated state, and reconnects with the next grant of a bundle.
The launcher reads 160-byte M10 grants and defaults to the dev route.

- quic::resolve_ipv4 shared by the client and evo-session-probe
- evo-session-probe grants: owner-only bundles of 1-64 grants
- evo-server --m10-max-grant-lifetime (dev only, 60..3600 s)
- presets client-network/client-package build QUIC; msquic links the CRT
  fully static; msquic.dll and msquic/OpenSSL licences in the Windows package
- client-remote-session test against a loopback region
- ADR-0093/0091/0086 amendments, M10_CLIENT_SESSIONS guide, validation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 11:57:07 -04:00

8.0 KiB

ADR-0093: M10 snapshots, spatial interest and session protocol v2

Status

Accepted for M10.5 (2026-10-06). Decisions confirmed with the maintainer on 2026-10-06: interest is a client-declared focus capped by the server; snapshots travel as datagram chunks with acknowledgements; 10.5 replicates environment cells plus the organism entity class (currently empty) with a perception boundary; the GUI engineering client moves to M10 sessions within 10.5. Delivery: 10.5a protocol v2 and the replication core (this text), 10.5b server/client wiring, probe and process evidence, 10.5c the GUI client switch (msquic.dll in the package, dev grant files). Each segment amends this ADR.

Context

ADR-0089 fixed per-tick snapshots for entities in interest, a fresh baseline on join, epoch change and loss, at most 4 server baselines of at most 40 ticks per session and 2 on the client, and at most 16 KiB of replication per session per tick; ADR-0090 put superseding state on 1,200-byte QUIC DATAGRAMs. The M9 dev session sent the whole environment view of one slice every tick over TCP (up to 256 cells of about 170 bytes). Session protocol v1 is deployed in evolution-dev and frozen (ADR-0087 amendment). The region has no placed organisms yet; its organism presentation is empty.

Decision (10.5a)

Session protocol v2 (schemas/network/session-v2.md) is v1 plus Interest (stream), SnapshotChunk (datagram) and SnapshotAck (datagram). v1 is no longer accepted: its only deployed client was the development probe.

Interest. A session declares one Z slice, a centre and a radius. The server clamps the radius to 7 (15 x 15 cells, within the 256-cell presentation limit) and filters authoritatively: an entity outside the square or the slice is never encoded. Organisms then pass a perception predicate (the extension boundary for concealment and, later, the controlled organism's senses). Records carry the presentation fields only: no controller, owner, account or player/NPC label exists in them. Interest changes restart from a fresh baseline.

Snapshots. Every tick, each interested session gets snapshot tick: entity-level upserts and removals against the newest snapshot the client acknowledged, or against nothing (a fresh baseline). The server keeps the acknowledged snapshot plus the newest others, at most 4, none older than 40 ticks; an ack for an evicted or another epoch's snapshot is ignored. Changed entities are sent nearest first (Chebyshev distance from the focus). Distant ones (beyond radius 3) refresh at most every 4 ticks (the lower-rate tier); anything not sent keeps the value the client already holds, so the snapshot's state is exactly what the client will have. A snapshot never exceeds 16 KiB: a fresh 225-cell baseline arrives over about two ticks, nearest first. Unchanged ticks send one empty chunk (the per-tick cadence).

Chunks. A snapshot is split into at most 16 self-contained chunks of whole records, each one datagram of at most 1,200 bytes including headers. The client assembles a snapshot when all chunks arrived, applies it to its baseline (one of its 2 newest applied snapshots), validates the result through the presentation constructors and acknowledges it. A lost chunk leaves the snapshot incomplete; the next delta is against the older acknowledged snapshot. At most 4 snapshots are in assembly. Stale, foreign-epoch and unassemblable chunks are ignored; malformed records, a slice mismatch or disagreeing chunk headers are errors.

Consequences and limits

  • Development-reference figures (32 sessions, 40 ticks, a changing row every tick, record size about 114 bytes): at most 16,320 bytes per session per tick, mean 1,404 bytes, 28,800 retained entity states (about 3.5 MB) across all baselines.
  • Entity-level deltas: a changed cell is resent whole. Field-level deltas or quantization are not needed at this size and are left for measurement (10.9).
  • Wiring into RegionSessions, evo-server and the clients is 10.5b; until then v2 messages exist but no server sends snapshots.

M10.5b wiring (2026-10-06)

  • RegionSessions owns the ReplicationServer: replication opens with Welcome and closes with the session; Interest arrives on the stream, SnapshotAck as a datagram. The host calls replicate(tick, source) once per simulated tick; each session's chunks are sized to its connection's current datagram limit (no snapshot while the datagram extension is not negotiated). A refused chunk leaves the snapshot unacknowledged.
  • Default interest: until a client sends its own, a session has the interest the host set: evo-server uses the region's first habitat site with radius 7, so a new session sees the region at once. Clients learn the slice and square from the snapshot itself.
  • evo-server source: for each distinct interest, the habitat sites of the square in the slice are queried from the region's own stores (query_environment, all fields) and copied through present_environment, the same read-only path as the M9 view; organisms stay empty (no placed individuals). A failed query sends an empty source and logs once.
  • Client: RegionSessionClient assembles and acknowledges snapshots, exposes the view and validated presentations, sends Interest, and closes the session (protocol) on a malformed or unpresentable snapshot. Chunks arriving before Welcome are dropped (the channels are not ordered); the next tick resends.
  • Probe: --interest X,Y,Z,R and --snapshots N; one snapshot line per applied snapshot (tick, cells, organisms, bounding square, slice) and snapshot-bytes.
  • Evidence: the test region's default interest holds one habitat site, so the process test shows a one-cell view refreshed every tick (40 chunks, 8,888 bytes in 40 ticks); the 225-cell and 32-session figures come from synthetic sources.

M10.5c engineering client switch (2026-10-06)

  • Remote mode is M10 only. evo-client builds its remote mode with EVO_BUILD_QUIC (presets client-network and client-package now enable it) over RegionSessionClient; the M9.7 TCP session path is no longer used by the GUI (evo-dev-session and the M9 server path keep their own tests). The launcher reads 160-byte M10 grants and defaults to the dev route void.aeternalisgames.com:7400 (ADR-0087); the endpoint is looked up once (IPv4) when Connect is pressed.
  • One connection per grant. A lost or closed session reconnects with the bundle's next grant after a pause that grows from 2 s to 30 s and resets on Welcome (inside the per-account attempt limit). Shutdown or capacity: retry. Refusals before any Welcome (scope, signature, stale or expired grant) fail the launcher; superseded (another client opened a session with a newer grant for the account) fails it at once instead of fighting back; no grant left fails it as exhausted. A new epoch resets the views.
  • Views. The newest applied snapshot feeds the environment and organism layers; a lost session marks them stale. The camera follows the server's default view (re-centred on its square while it fills in, nearest cells first) until the user pans or zooms; from then on the camera centre's voxel, radius 7, in the snapshot's slice is the interest, sent at most every 250 ms and again after each reconnect.
  • Intentions. Sent as datagrams for server tick + 2 when the movement vector changes, at most once per server tick. The Session panel's record shows sent, admitted, rejected, simulated (the watermark covered it: final, never durable, ADR-0092) and unknown (the session ended first). Entries are numbered by the client, since session sequences restart with each session. The panel also shows the simulated watermark, the snapshot (tick, cells, organisms), the interest and snapshot bytes.
  • Evidence: client-remote-session drives apps/evo-client/remote_session.hpp against a loopback region (launcher flow, 225-cell default view, following and the camera interest, admitted then simulated intentions, epoch change with unknown outcomes and reconnect with the next grant, superseded, wrong region, exhausted bundle, unresolvable endpoint).