ADR-0095. The engineering client times presentation with the tick clock: its own marker between ticks, other markers interpolated a few ticks behind (grey when stale). Silence beyond 3 ticks and long-gap holds are stale. A lost session leaves its last view frozen and labelled stale until the reconnect's fresh baseline; nothing is predicted or sent meanwhile. evo-motion-trace --remote measures remote-marker error between two clients through the relay, with a 1.5 s outage (motion-trace-remote-smoke CTest). Prediction errors are recorded only for ticks inputs are scheduled for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5.4 KiB
ADR-0095: M10 tick clock, remote interpolation and session loss
Status
Accepted for M10.7 (2026-10-06). Decisions confirmed with the maintainer on 2026-10-06:
- an adaptive interpolation delay of 2-6 ticks;
- remote markers extrapolate at most 2 ticks, and organisms never;
- on session loss the last view stays frozen, dimmed and labelled stale, and a reconnect starts from a fresh baseline;
- a drift-corrected client tick clock, with sub-tick presentation.
Delivery: 10.7a the headless clock, interpolator and fractional prediction (this text); 10.7b engineering client wiring, the loss view and a two-client trace. Each segment amends this ADR. Presentation only: none of it is authority, and no outcome is invented.
Context
NETWORK_ARCHITECTURE requires remote entities to interpolate buffered snapshots with bounded extrapolation, loss to request a fresh baseline, and death, mutation and reproduction to remain server decisions. M10.6 (ADR-0094) predicts the own probe marker at whole ticks. Other markers are drawn as last replicated, so they step at 20 Hz and jump when a snapshot is lost. No controllable organism moves yet.
Decision (10.7a)
- Tick clock (
include/evo/client/interpolation.hpp). Each observed server tick (watermark or snapshot) slews a local estimate by 10 % of the error. An error beyond 4 ticks snaps forward. The estimate is monotonic between resets and never more than one tick beyond the newest observation, so a silent or paused server freezes it rather than inventing time. Assumes 50 ms ticks; drift of ±4 % stays within 1.5 ticks in tests. - Remote markers are presented at
clock - delay, interpolated linearly between the buffered snapshots around that tick (at most 16 snapshots).- A marker appears at the tick of the snapshot that adds it.
- It is shown unmoved until the tick of the snapshot that removes it: never moved toward a removal.
- Snapshots more than 8 ticks apart are not interpolated across.
- Reordered or duplicate snapshots are ignored.
- Beyond the newest snapshot the replicated held vector continues for at most 2 ticks; then the marker freezes there and is marked stale.
- Adaptive delay. The target is the 90th-percentile gap between received snapshots (last 40) plus one tick, within 2-6. The delay rises toward it at 2 ticks/s and falls at 0.5 ticks/s.
- Organisms are never extrapolated or interpolated: they are shown as replicated (newest snapshot, ADR-0093). A dead or removed organism is therefore never shown moving or as present after its removal.
- Own marker between ticks.
MotionPredictor::predict_between(tick, fraction)interpolates the prediction between two whole ticks for presentation. Error measurement still records whole ticks.
Alternatives considered
- A fixed 2- or 3-tick delay: simpler, but either stutters on lossy links or adds latency on good ones.
- No extrapolation: visible stalls on every lost snapshot.
- Longer extrapolation (4 ticks): larger errors when a remote changes direction.
- Clock from the local timer only: drifts without bound against the server's pacing.
Consequences
- Remote markers are shown 100-300 ms in the past, the own marker in the predicted present. That is the usual split; interactions that need both are later work.
- Extrapolated or stale markers are flagged so the client can draw them differently.
M10.7b client wiring, loss view and traces (2026-10-06)
- Engineering client (
apps/evo-client/remote_session.hpp):- every newly observed server tick (watermark or snapshot) feeds the clock;
- each snapshot's other markers go to the interpolator;
- the own marker is presented at clock + lead, between whole ticks;
- other markers are presented at clock - delay;
- the Session panel shows the delay and the stale count;
- stale markers are drawn grey.
- Silence is stale. The clock freezes one tick past the last observation, so on a silent link the render tick never passes the newest snapshot. Markers are therefore also stale once 3 ticks (150 ms) pass without any observation. A marker held across a gap of more than 8 ticks is stale too.
- Session loss. The last view stays frozen: the own marker at its last authoritative position, all markers stale. The banner reads "STALE (last view, frozen)" and the environment is already stale-encoded. Nothing is predicted or sent. Welcome resets the clock, interpolator and markers (fresh baseline). The server already stops admission and removes the marker when a session closes: no offline progression.
- Error measurement records a prediction only for ticks at or before the newest server tick plus the lead. The clock may run one tick past the newest observation, and inputs for such a tick may still come. Recording it gave false errors, seen as a Windows-only test failure.
- Evidence:
client-remote-session: the frozen stale view and its reset on reconnect; two sessions each seeing the other's marker behind its own predicted view; removal when one leaves.evo-motion-trace --remote, with the CTestmotion-trace-remote-smoke: current markers' 95th percentile within 1 m, the outage mostly shown stale, recovery after it.- Figures in M10_PREDICTION_TRACES.
- Not covered: interpolating organisms (none move; they are shown as replicated and never extrapolated). M10.7 is complete.