Files
aevolution/docs/adr/0100-primitive-lives-and-persistent-control.md
T
dingo 48684d30d9
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (client) (push) Failing after 9m57s
Foundation / checks (network) (push) Successful in 13m32s
Foundation / checks (tsan) (push) Successful in 7m56s
Foundation / checks (checks) (push) Successful in 33m49s
Foundation / checks (postgres) (push) Successful in 46m39s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
M11.2b: restore funded life state with canonical closure checks
2026-10-09 18:30:58 -04:00

193 lines
11 KiB
Markdown

# ADR-0100: Primitive lives and persistent control
## Status
Accepted direction for M11.2, 2026-10-09, following M11.1 commit `93e1ab0`.
The maintainer authorized the recommendations and subsequent implementation
choices, with review after the fact and a commit/push between subsections.
Server side only; client UI remains deferred. Implementation progress and limits
are recorded below; acceptance of the design does not claim completed durability.
## Context and architectural conflicts
- `primitive_founder` fixes the schema-2/development-2 genome, not starting
inventory or its source. The first-bud analysis assumes full growth.
- `LineageRegion` closes over exactly the environmental fixture's producer and
consumer. Adding a player to its archive alone correctly fails closure.
- Checkpoint profile 2 declares history profile 1 and genome schema 1. It cannot
silently acquire schema-2 player lives and a variable living set.
- ADR-0092 permits two regions to publish a duplicate no-effect action and retain
the first result. For a spawn, retaining one result would not undo the other
checkpoint's source debit and organism creation.
- ADR-0091 fences account control but does not bind a durable organism. Session
takeover and reconnect must not be treated as new lives.
Per AGENTS.md, implementation must not expand through conflicting contracts.
The proposed resolution is a new cellular profile and an atomic publication
contract for biological actions. Existing fixture/probe contracts remain intact.
## Decision
### Identity and control
Keep account, life, organism and genome identities distinct. Account references
belong to server orchestration and durable metadata, never biology or perceivable
organism state. A world/account has at most one nonterminal life, including a
suspended life. Reconnect resolves it; only an explicit new-life request can
create one, and only when no nonterminal life exists.
The life record names its region and organism. Control requires the current
region lease and account-control generation, after any takeover wait. Taking
control does not move the organism. A login elsewhere routes to its owner;
M10 probe handoff is not organism handoff. Terminal records remain historical.
World-scoped identities need durable allocation and exhaustion checks. Independent
region-local counters cannot guarantee uniqueness. Failed reservations may leave
gaps but never reuse issued identities or publish unfunded organisms.
### Starting body and funding
Accepted for founder-life rules 1; numerical choices are tunable and versioned:
- Every account starts with the same fully grown, undamaged primitive founder.
- Derive body composition and construction energy from development version 2;
do not duplicate biological constants in SQL or server code.
- Give every founder 30 seconds of full-speed demand as energy only: 7,824,000 pJ
with development 2. No spare matter. Phosphorus still binds the first bud at
300, 600 and 901 seconds for the analyzed feeding shares; energy does not buy
missing phosphorus.
- Transfer body material, construction energy and reserve from an explicit finite
spawn inventory. Construction energy goes to heat, not usable reserve.
Allocation, placement or funding failure spends nothing.
- Retain source and creation-event provenance. No automatic replenishment or
account-age/ancestry bonus is implied.
Rejected for this version: local habitat withdrawal or external input per life.
External input must appear in the conservation equation, never as a transfer from
an empty source. These choices determine whether depletion blocks entry and
whether repeated lives inject resources. Starting growth, reserve, placement and
any replenishment must be recorded as rules/tunables, not inferred from fixtures.
Placement uses a bounded, lexicographically ordered list of server-provisioned
habitat sites in region/frame-local integer micrometres. Select the first free
site; validate that 20 um founder squares do not overlap. This is an explicit
initial nursery configuration, not a planet generation or organism movement rule.
The pool has explicit provisioning provenance and no automatic refill. Each
region owns a disjoint pool; inter-region funding is not implied.
### Atomic publication and retries
The authenticated request supplies an action identity, not authoritative biology
or position. Canonical content and the result are retained by world/account/action
id. Exact retry returns that result; changed content conflicts. Retrying an old
successful spawn returns its original life even after that life dies.
Publication atomically validates region authority, account control, expected life
ownership and request uniqueness, then commits:
1. The checkpoint with organism, source debit, reserve and heat.
2. The genome, birth and retained player-origin provenance.
3. Account-to-life and life-to-region/organism bindings.
4. The immutable request/result and required history/outbox records.
Do not reuse no-effect probe conflict handling. If another spawn or takeover wins,
the losing checkpoint must not publish. Its host discards speculative state and
recovers/reconciles before continuing; changing only the reported result is
insufficient. Extend the upgrade/region/account lock order consistently and test
independent connections. Resolve retries before treating them as fresh debits.
Receipts remain provisional. Final creation requires the whole durable transaction.
Unknown outcomes pause dependent work and resolve the original commit id and exact
request, without assuming rollback. Refresh/takeover races must either preserve
valid authorization or reject the entire candidate, never partially bind a life.
### Cellular checkpoint closure
Use a separately versioned profile, not optional player sections in the fixture.
Its bounded canonical codec must validate the following before admission:
| State | Closure |
|---|---|
| Organism/genome, archive and origin | Unique IDs, schema/development versions, birth/death agreement, retained provenance and allocation bounds |
| Body, reserve, reservations, source and heat | Per-channel conservation and exactly one inventory owner |
| Growth, damage, age and implemented timers | Exact values; no recovery defaults or elapsed-time biology |
| Position and region/frame | Valid placement, one owning representation |
| Active, suspend-pending, suspended or dead state | Agreement with durable metadata; dead terminal; offline biology cannot step |
| Implemented action state and randomness | Exact retry/replay state, versioned streams, no fresh retry draws |
| Rules, quantum and bounds | Explicit allowlist; counts/bytes checked before allocation |
Do not add placeholder disease, gestation or mutation state. Later systems must
extend closure before activation. Sessions/grants are reacquired, never restored
as valid authority. Recovery reconciles life/results and checkpoint before
readiness; missing, conflicting or unsupported data quarantines the region.
The profile begins with no organisms; synthetic fixture actors are not adopted as
player-origin wildlife. Provisioning is explicit; recovery never creates a fallback
world. Existing dev-world conversion/deployment is separate. World0 is excluded.
### Scope and compatibility
11.2 establishes creation, durable binding and recovery, with no autonomous
biology on session loss. Locomotion/feeding, mutation, budding, complete death flow
and timed logout/resume remain 11.3-11.7 under ADR-0098. Intermediate work must not
claim a playable lifecycle before those paths are wired and qualified.
Protocol v4 and existing checkpoint profiles stay frozen. Life messages require
an explicit new protocol version with updated headless callers, codecs and network
tests. UI remains deferred; biological presentation gains no ownership labels.
## Alternatives considered
- Widen the two-actor fixture: violates exact living-set closure.
- Persist a life separately after its checkpoint: creates crash windows with
funding but no life, or a life without a recoverable body.
- Spawn on login: retries/takeovers can create extra lives.
- Reuse first-result-wins commits: duplicate biological effects survive.
- Store accounts in genomes: violates the orchestration boundary.
## Benefits
Funding, ancestry, control and retry results describe one recoverable operation.
Existing fixtures remain regression oracles; lives gain explicit state closure.
## Costs and risks
A new profile, publication path and migration are substantial work. Losing
speculative batches needs clear host recovery behavior. Finite funding can refuse
entry; external funding can distort ecology. Archive/record limits need measured
backpressure; history cannot be pruned to admit players. Organism migration is
separate from the proven probe experiment.
## Consequences
Only enable network spawning after the profile/publication integration is proven.
The [delivery plan](../engineering/M11_2_DELIVERY_PLAN.md) lists acceptance evidence.
Existing goldens, simulation versions, schemas and deployed worlds are unchanged.
## 11.2a: Funded creation
`biology::primitive_endowment` derives the full body, energy-only reserve and
435,200 pJ construction price. `server::PrimitiveLives` owns the finite pool,
heat, body/reserve pairs, genome archive, births and request/origin bindings.
It is a portable server orchestration target, independent of transport/database
and outside `evo::simulation`. A detached candidate is swapped only after every
fallible operation succeeds, including ledger and archive admission.
Capacity is 256 retained lives and provisioned sites (engineering bound). Exact
successful retries return the original allocation before checking capacity or
funding. Another action for the same living account is refused. The host supplies
world-allocated identities, never the client. This layer checks local collisions;
world-wide allocation and authorization are enforced in 11.2c/d. Refusals here
are in-memory errors, not durable action outcomes. There are no live ticks or
death/logout transitions yet, so this subsection is not deployable gameplay.
## 11.2b: Creation-state checkpoint codec
The separate [primitive-lives-v1](../../schemas/primitive-lives-v1.md) envelope
retains the explicit opening, sites, founding requests and identities, every
inventory balance and the complete archive. Restore reconstructs a detached
candidate, compares each saved record/balance/history and requires exact canonical
re-encoding. It refuses unknown versions, mismatched region identity, duplicate
life bindings and inconsistent funding. No biological timers exist in this
creation-only version; introducing progression requires a new format first.
Durable publication and session integration remain 11.2c/d.