Freeze offline cells, linger, suspend and resume them
Foundation / checks (ecs) (push) Successful in 2m15s
Foundation / checks (deploy) (push) Successful in 3m53s
Foundation / checks (tsan) (push) Successful in 9m46s
Foundation / checks (client) (push) Failing after 13m47s
Foundation / checks (network) (push) Successful in 19m5s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 19m34s
Foundation / checks (postgres) (push) Canceled after 19m28s

M11.7 (ADR-0128): a frozen step intent, set by the server for every owned life
whose account holds no session, leaves the cell unchanged but engulfable. Owner
format 6 / rules 5 track presence: lingering for 200 ticks, then suspended out of
the world without aging; an unfrozen intent resumes it in place or at the nearest
clear spot within three extents. Bundle v6, schema v38 and the cellular-v4
opening carry it. The server refuses an offline account's carried actions, ticks
while anyone lingers, and skips suspended cells in replication and perception.

Also fixes the TSan failure of CI run 374: the rules-4 owner test read the bud
through a reference into a replaced state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-14 07:50:45 -04:00
co-authored by Claude Opus 5.5
parent e71147f7a6
commit e74bdf286b
25 changed files with 741 additions and 69 deletions
@@ -0,0 +1,80 @@
# ADR-0128: Cellular offline freeze, linger and resume
## Status
Accepted engineering contract for M11.7 (2026-10-14), implementing ADR-0098
decisions 4 and 5. Linger time and resume radius are **trial** values for 11.9.
## Context
A cellular region simulates while any player is present (M11.3). A player who
disconnects leaves an owned cell that keeps paying maintenance, and can starve or
be eaten, while others keep the region ticking: offline progress, which ADR-0098
forbids. ADR-0098 decides the boundary: on logout or a detected disconnect the
organism freezes at once, lingers perceivable and vulnerable for a tunable time
(starting at 10 s), then is suspended out of the world; a reconnect during the
linger resumes in place, and a later resume uses the same spot or the nearest
valid one within a small radius, else the life stays suspended.
## Decision
### The frozen intention
- `CellularStepIntent::frozen` (trace intent byte 13, bit 0) says the life does
nothing this tick. It is exclusive with movement, a target, engulfment and a bud.
Only owned lives may be frozen; wildlife never is.
- The server sets it for every owned life whose account holds no established
session, so the trace records the boundary and replay never consults sessions.
Carried actions of such an account are refused before the tick is built.
- The region step leaves a frozen cell exactly unchanged: no maintenance, movement,
intake, growth or heat. It cannot engulf, but it can be engulfed, and it occupies
space for contact and placement.
### Presence (owner format 6, rules 5)
Each life has a presence and the tick its freeze began:
- **Active**: ordinary. A frozen intent makes it **lingering** from that tick.
- **Lingering**: frozen in place, perceivable and vulnerable. An unfrozen intent
(the player is back) makes it active again in place. After 200 ticks (10 s,
trial) of linger it becomes **suspended** at the end of that tick.
- **Suspended**: out of the world. It keeps its inventory (counted in the region's
conserved totals) but takes no part in the step, perception, replication, contact
or placement, and may hold any intent value only as `frozen`. An unfrozen intent
resumes it: at its own position if that is clear of every cell in the world, else
at the first clear spot found by trying the eight fixed directions at one, two and
three of its own extents from that position (trial radius). With none clear it
stays suspended and the tick reports `resume_blocked`.
- Wildlife is always active. A death decided in a tick is committed before a
presence change in that tick; a dead life never resumes. A mutation choice
reserved before the freeze still publishes at its tick (it was decided before the
boundary); the host admits no choice for a life that is not active.
### Server loop
- The region also ticks while any owned life is lingering, so a linger always
completes and nobody farms safety by leaving others' region empty.
- Suspended lives are skipped by replication and perception.
### Versions
- Owner format 6 adds presence (u8, 7 zero bytes) and the freeze tick (u64) to each
life record; rules 5 are rules 4 plus presence. Openings: `cellular-v4`.
- Version bundle v6 (`{5,6,1,1,1,2,1,2,1}`), normalized like v4 and v5 by schema
v38, which also admits it for format-3 birth traces. The trace format is
unchanged: the flag lives in a byte SQL does not parse.
## Alternatives
- **Remove a suspended life from the owner state:** rejected. A separate list
would need a new trace record for resumes and a second recovery path; keeping it
in the life set with a presence costs 24 trace bytes per tick per suspended life
and keeps one closure.
- **Let sessions drive presence directly in the owner:** rejected; replay must not
depend on live sessions.
## Consequences
Logging out is neither an escape nor a farm: the cell freezes, can still be eaten
for 10 seconds, then leaves the world without aging. Wildlife keeps living while a
region ticks. A region with only suspended players stops ticking, as before.
+1
View File
@@ -28,6 +28,7 @@
- [ADR-0125: Cellular budding and wildlife descendants](0125-cellular-budding-and-wildlife-descendants.md) - M11.5: a bud is v10 action kind 3, paid from the parent's reserve (ADR-0032 investment plus a 30 s provision), placed touching the parent, identified in a region namespace above 2^63, carrying the parent's genome; unowned wildlife driven by a pure deterministic controller whose intentions ride the trace.
- [ADR-0126: PostgreSQL parameter bound for cellular traces](0126-postgres-parameter-bound-for-cellular-traces.md) - each query parameter may hold 4 MiB of text (was 4 KiB, ADR-0059), so every admitted cellular trace (64 ticks of 256 lives as hex bytea) reaches the database in one atomic publication.
- [ADR-0127: Cellular permadeath and restart](0127-cellular-permadeath-and-restart.md) - M11.6: schema v37 marks a published life ended once (`end_cellular_lives`, recorded by the host after the death and again on recovery); one active life per account replaces one life per account, so a dead player starts a new primitive founder; a dead account's stale action no longer refuses the whole tick.
- [ADR-0128: Cellular offline freeze, linger and resume](0128-cellular-offline-freeze-and-resume.md) - M11.7: a frozen step intent (set for owned lives without a session) freezes biology; owner format 6 / rules 5 track presence: lingering for 200 ticks (10 s, trial) perceivable and vulnerable, then suspended out of the world without aging; an unfrozen intent resumes in place or at the nearest clear spot within three extents; bundle v6, schema v38.
- [ADR-0058: Region durability contract](0058-region-durability-contract.md) - accepted M7.1 full checkpoint batches and explicit state closure; storage implementation follows.
+28
View File
@@ -0,0 +1,28 @@
# M11.7: Freeze offline organisms and resume uniquely
An offline player's cell freezes at once, lingers perceivable and vulnerable for
a trial 10 s, then leaves the world without aging until the player returns. The
engineering contract is
[ADR-0128](../adr/0128-cellular-offline-freeze-and-resume.md); the game rules are
ADR-0098 decisions 4 and 5. Client presentation is the maintainer's.
## Segments
| Segment | Affected modules | Acceptance evidence |
|---|---|---|
| 11.7a: frozen intention and presence | Region step, owner format 6 / rules 5, trace flag, bundle v6, schema v38, `cellular-v4` opening | A frozen cell pays nothing and stays put; linger returns to active; 200 frozen ticks suspend without aging; a suspended cell takes no step; exact restore; a stale lingering presence is refused; resume in place or within three extents; frozen intents only in rules 5, only for owned lives, carrying nothing else |
| 11.7b: server boundary | Server tick build, bridge, host | Owned lives without a session are frozen in the trace; their carried actions are refused; the region ticks while anyone lingers; suspended cells are not replicated or perceived; no mutation choice for a non-active life |
## Required checks
- Long offline intervals, repeated disconnects, death at the freeze boundary
(engulfed while lingering), duplicate resume, and wildlife continuing.
- Linux CI PostgreSQL evidence for the v6 bundle and `cellular-v4` provisioning.
## Progress
- 2026-10-14: 11.7a and 11.7b implemented. `rules_five_owner_freezes_lingers_suspends_and_resumes`
covers freeze, linger, return, suspension without aging, restore, the stale
presence refusal, a newborn on the suspended cell's spot and the relocated
resume; the trace round-trips the flag and refuses other flag values; rules 4
refuse a frozen intent; `cellular-v4` provisions on the v6 bundle.
+22
View File
@@ -7423,3 +7423,25 @@ compares the recovered state.
Executed locally: `postgres-check.sh --full` (WSL g++-14 Release, 488 s) passes; g++-14
`-Werror -Wshadow` and clang-tidy-19 on the host, lease store, tests and server
main; clang-format 19.1.5.
## 2026-10-14 — M11.7 offline freeze, linger and resume (CI pending)
ADR-0128: the frozen step intent (trace intent byte 13, bit 0), owner format 6 /
rules 5 presence (active, lingering for 200 ticks, suspended) with resume in place
or within three extents, bundle v6, schema v38 and the `cellular-v4` opening. The
cellular server freezes owned lives whose account holds no session, refuses their
carried actions, keeps ticking while anyone lingers, and skips suspended cells in
replication and perception; the host refuses mutation choices for non-active lives.
Executed locally: `postgres-check.sh --full` (WSL g++-14 Release, 492 s) passes with
schema v38; MSVC Debug 69/69, ASan cellular/budding/mutation/lineage 10/10, network
75/75, client-network 89/89; g++-14
`-Werror -Wshadow` and clang-tidy-19 on the owner, region step, trace codec, host,
persistence, provisioner, tests and server main; clang-format 19.1.5.
## 2026-10-14 — CI run 374 TSan failure (test-only use after free)
Run 374 (e71147f) failed `checks (tsan)`: `cellular-lives-owner` read the bud
through a reference into the owner's previous state after the M11.5d controller
check advanced a tick. The test now reads the current life. ASan locally confirms
the fix; no product code was involved.