M12.2c: qualify the current cellular reference instrument
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m47s
Foundation / checks (tsan) (push) Successful in 13m32s
Foundation / checks (client) (push) Failing after 17m9s
Foundation / checks (network) (push) Successful in 19m58s
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 20m34s
Foundation / checks (checks) (push) Canceled after 20m49s

This commit is contained in:
dingo
2026-10-17 11:44:00 -04:00
parent 8b54e7447a
commit bee57e5829
14 changed files with 737 additions and 3 deletions
+8
View File
@@ -644,6 +644,14 @@ if(BUILD_TESTING)
set_tests_properties(reserve-strata-qualification PROPERTIES TIMEOUT 120)
endif()
add_executable(evo-cellular-reference experiments/resolution/cellular_reference.cpp)
target_link_libraries(evo-cellular-reference PRIVATE evo::lifecycle)
evo_owned_target(evo-cellular-reference)
if(BUILD_TESTING)
add_test(NAME cellular-population-reference COMMAND evo-cellular-reference --verify)
set_tests_properties(cellular-population-reference PROPERTIES TIMEOUT 180)
endif()
add_executable(evo-chunk-layout experiments/world/chunk_layout.cpp)
target_link_libraries(evo-chunk-layout PRIVATE evo::world)
evo_owned_target(evo-chunk-layout)
+6
View File
@@ -105,6 +105,7 @@ ctest --preset release
./build/release/evo-benchmark
./build/release/evo-spatial-benchmark
./build/release/evo-resolution-benchmark
./build/release/evo-cellular-reference --verify
./build/release/evo-chunk-layout
```
@@ -146,6 +147,11 @@ from a public dependency's license.
M4.6 reproduction, measurements and limits: [aggregate budget report](docs/engineering/AGGREGATE_BUDGET.md).
M12.2c's [current cellular reference](docs/engineering/M12_CELLULAR_REFERENCE.md)
checks rules-8 encoded replay and offline closure. `evo-cellular-reference --verify`
runs the short CTest matrix; without arguments it runs the full research matrix
with local cost observations. This is an exact control, not production aggregation.
M5.1 local voxel/address API and scope: [local voxel contract](docs/world/LOCAL_VOXEL_CONTRACT.md).
M5.8 process restart proof and measured costs: [world proof](docs/engineering/WORLD_PROOF.md).
+5
View File
@@ -647,6 +647,11 @@ the later multicellular idea are not ratified game rules.
## M12 - Persistent ecology
2026-10-17: [12.2c rules-8 reference](engineering/M12_CELLULAR_REFERENCE.md)
validates 65,536 individual ticks and 70,656 encoded replay boundaries on MSVC/GCC,
with mutation, birth/death and offline-state coverage. This is the active control;
actual cellular/cohort and target-host qualification remain open before 12.3.
2026-10-17: the maintainer closes M11.9 for now and authorizes M12 continuation.
[Closure/UI review](engineering/M11_9_CLOSURE_AND_UI_REVIEW.md) preserves the
incomplete empirical sample and confirms the current microscope presentation.
+10
View File
@@ -1,5 +1,15 @@
# Project status and next steps
## M12.2c current cellular reference - 2026-10-17
The [rules-8 headless reference](engineering/M12_CELLULAR_REFERENCE.md) passes
eight full cases with matching MSVC/GCC state/coverage outputs. It exercises
funded mutations, wildlife births, starvation and offline suspension with exact
encoded replay at 1/16/64-tick partitions. Native Release CTest passes 71/71,
with clang-format/tidy and Linux ASan/UBSan checks. This supplies the current
active control; actual cellular/cohort fidelity and target-host budgets remain
the M12.2 work ahead. M11.9's scoped closure authorizes that continuation.
## M11.9 closed for now; M12 continuation - 2026-10-17
The maintainer explicitly closes M11.9 for now and authorizes proceeding with M12.
@@ -0,0 +1,80 @@
# ADR-0138: Current cellular population reference instrument
## Status
Accepted for isolated M12.2c qualification tooling (2026-10-17). No runtime
aggregation, biological rule, public API, persisted version or golden changes.
M11.9 is closed for now by the maintainer with authorization to continue M12.
## Context
M12.2b repairs a synthetic averaging failure but cannot qualify spatial cellular
ecology. The current implemented baseline is rules 8: schema/development 4,
funded skilled/twin budding, hunting wildlife and finite contact-fed deposits.
ADR-0135 colonies and ADR-0136 infall/photosynthesis remain proposals. A later
population model must be compared against these actual supported cellular rules.
## Decision
Add a headless executable using the existing CellularLives owner as the exact
active reference. It generates player fixture intentions and records accepted
wildlife intentions once. Compare canonical batch encode/decode/replay in parallel
at 1/16/64-tick partitions, all at the existing 50 ms quantum. Partition 1 compares
full canonical state every tick; the other partitions compare at every batch
boundary. Restore checkpoints at completed boundaries and keep all identities,
inventory, archive, mutation eligibility and presence state unchanged.
Declare the instrument before measuring:
- Seeds 0/1 are development and 2/3 held out. Each uses rich and scarce finite
deposits, four equally funded player-origin founders and the rules-8 owner.
- The CTest suite uses 512 ticks per case. The full research run uses 8192;
report observed births, mutations, deaths and suspension rather than assuming
every regime exercises all paths. Report zero-coverage limits explicitly.
- Player fixtures first feed in place, then steer/ask to bud at declared intervals;
earned mutation selections use only the real offer and funded transitions.
Offline intervals freeze controlled lives, while wildlife continues through
the shared intention interface. This is an experiment driver, not a new AI rule.
- Zero tolerance for canonical state, conserved channel totals, demographic or
genome-identity divergence at compared boundaries. No false extinction inferred
from empty local observations. Distinct genome IDs and distinct capability
profiles are reported separately; neither is a species count.
- Record active population, snapshot bytes and local stepping/replay costs, with
verification, codec/restore and biology costs distinguished. These are
workstation observations, not accepted target-host fallback budgets.
No adapter feeds current cellular state into the synthetic strata record. Its
missing spatial/reproductive/deposit state makes such an admission unsupported.
This instrument is the exact control for later paired active/cohort qualification;
passing replay does not establish ecological approximation fidelity or scaling.
## Alternatives considered
Extending the old synthetic fixture with cellular labels would leave its biology
unrepresentative. Treating checkpoint replay as proof of aggregation would confuse
state closure with fidelity. Enabling a runtime selector before either a supported
model or target-host budgets exists remains prohibited by ADR-0041.
## Benefits
The reference follows the current ratified cellular behavior, exercises archive
and offline closure, and is independent of renderer, network, database and clocks
inside the owner. It provides reproducible inputs and observations for future work.
## Costs
Canonical checks, cloning and replay deliberately add measurement overhead.
Short CTests do not establish long unattended ecology or all demographic paths.
## Risks
The driver and owner are deterministic but the reference is not an independently
derived biological model. No approximate cohort, migration, global extinction or
production cost envelope is supplied. Changes to trial rules require a separately
identified reference baseline and preserved earlier evidence.
## Consequences
Run NDEBUG tests, clang-format/tidy and Linux ASan/UBSan. Publish measured coverage
and limits. Keep M12.2 cellular/cohort and target-host qualification open until
actual paired models meet accepted bounds; no automatic tier transition is enabled.
+2
View File
@@ -1,5 +1,7 @@
# Architecture decision records
- [ADR-0138: Current cellular population reference instrument](0138-cellular-population-reference-instrument.md) - M12.2c headless rules-8 control, encoded replay partitions and offline closure; no aggregation qualification.
- [ADR-0134: Exact reserve-strata population experiment](0134-reserve-strata-population-experiment.md) - M12.2b isolated exact-state candidate and predeclared instrument; no runtime tier qualification.
- [ADR-0133: Ecological identity and time evidence](0133-ecological-identity-and-time-evidence.md) - M12.1 engineering evidence, viability/time boundaries and explicit deferrals; no runtime changes or qualified aggregation.
+5
View File
@@ -1,5 +1,10 @@
# Ecology and simulation fidelity
M12.2c's [current cellular reference](../engineering/M12_CELLULAR_REFERENCE.md)
uses implemented rules 8 and validates exact encoded replay/offline closure. It
is the active control for future cohort comparisons, not a qualified approximate
population model. M11.9 is closed for now at the maintainer's direction.
M12.1's current scoped identity/time policy and explicit deferrals are in
[ECOLOGICAL_IDENTITY_AND_TIME](ECOLOGICAL_IDENTITY_AND_TIME.md) and
[ADR-0133](../adr/0133-ecological-identity-and-time-evidence.md). Historical M4
+143
View File
@@ -0,0 +1,143 @@
# M12.2c: Current cellular population reference
## Result - 2026-10-17
The rules-8 exact control passes all eight full cases on MSVC 19.44 and GCC 14.2.
Every tick is compared through 1-tick canonical replay; 16/64-tick partitions
also match at every completed boundary. Each case advances 8192 ticks at 50 ms,
for 65,536 reference ticks and 70,656 compared replay boundaries per platform.
Each replay lane additionally performs 512 explicit checkpoint restores across
the suite. All non-timing output, including final-state fingerprints, matches
between platforms. Conserved totals remain exactly equal to finite opening stock.
This completes M12.2c's reference instrument under
[ADR-0138](../adr/0138-cellular-population-reference-instrument.md), not M12.2's
active/cohort qualification. No approximate population model or automatic tier
selector is introduced. M11.9 is closed for now by the maintainer; it no longer
blocks M12 continuation. See [the scoped closure](M11_9_CLOSURE_AND_UI_REVIEW.md).
Raw outputs: [MSVC](results/m12-2c-cellular-msvc1944.jsonl) and
[GCC](results/m12-2c-cellular-gcc14.jsonl).
## Reference and method
`evo-cellular-reference` links the existing portable lifecycle/biology owner. It
does not depend on renderer, network, database or a running world. The baseline is
owner format 6, rules 8, habitat format 2, schema/development 4 and trace format 3:
percentage mutation steps, skilled/twin budding, hunting wildlife and finite
contact-fed pools/motes. Proposed colonies, infall and photosynthesis are excluded.
Four equally funded player-origin founders start each case. Seeded finite food
has rich and scarce regimes; initial contact food in rich cases is explicitly
funded in the habitat, never credited directly to organisms. Source totals include
nursery, bodies, reserves, deposits and heat. There is no refill or boundary inflow.
Seeds 0/1 are development and 2/3 held out. The driver asks owned cells to feed,
occasionally bud/engulf, and later move; only real earned, affordable mutation
offers are selected. It does not write a successor genome or biological inventory
directly. Wildlife intentions are obtained from the actual shared controller and
recorded once. One controlled founder freezes for 256 ticks per 1024-tick cycle,
passing through linger/suspension and then requesting resume. Surviving frozen
members retain exact position, body, reserve, growth, identity and mutation state.
An engulfed frozen member would still be allowed to die under ADR-0128.
Three replay lanes independently encode/decode the recorded inputs and call the
production replay helper with batch widths 1/16/64. Each comparison is full
canonical byte equality, so it includes archive parent/revision links, identity,
demographics, inventory, eligibility and rate state. Batch partitioning keeps the
fixed tick quantum; it never integrates biology once at a larger timestep.
Checkpoint restoration checks identical bytes again at completed 128-tick boundaries.
This is an in-memory recovery control, not a process/SQL failure drill.
## Observed coverage
| Seed | Split | Food | Wildlife births | Mutations | Deaths | Peak living | Maximum capability profiles |
|---|---|---|---:|---:|---:|---:|---:|
| 0 | development | rich | 0 | 4 | 0 | 4 | 4 |
| 0 | development | scarce | 0 | 0 | 4 | 4 | 1 |
| 1 | development | rich | 1 | 4 | 0 | 5 | 4 |
| 1 | development | scarce | 0 | 0 | 4 | 4 | 1 |
| 2 | holdout | rich | 2 | 4 | 1 | 5 | 4 |
| 2 | holdout | scarce | 0 | 0 | 4 | 4 | 1 |
| 3 | holdout | rich | 1 | 4 | 2 | 4 | 3 |
| 3 | holdout | scarce | 0 | 0 | 4 | 4 | 1 |
Across the suite: four wildlife births, 16 applied mutations, 19 deaths,
10,240 frozen controlled-life ticks and 2240 suspended-life ticks. All observed
deaths are starvation; successful engulfment and blocked resume are **not** covered.
Twin capability is enabled by the rules but these counts do not establish a
successful twin-birth case. Those paths need separate cellular cohort scenarios.
Distinct living genome IDs and distinct capability profiles are separate outputs:
identical founders have different genome IDs without different capabilities.
Neither count is a species. Structural body matter is also reported per channel;
it is not a wet-biomass or climate estimate. A local empty population does not
assert reconciled terminal extinction.
The 512-tick CTest matrix covers mutation, freeze/suspension/resume and state closure,
but no births or deaths in the observed short runs. Rich-case guards require real
mutation and offline-state coverage. The long suite additionally requires at least
one birth and death across its cases, preventing a vacuous all-empty control.
## Local costs and limits
One measurement pass on the Ryzen 7 9800X3D development workstation, Windows x64
MSVC Release and Ubuntu WSL2 GCC Release, without affinity/frequency locks. Total
milliseconds across all 65,536 reference ticks follow; these are observations,
not repeated-sample budgets, per-tick tail latency or production capacity.
| Measured work | MSVC ms | GCC ms |
|---|---:|---:|
| Direct owner stepping | 525.265 | 388.244 |
| Encode/decode/replay, width 1 | 5897.060 | 4883.169 |
| Encode/decode/replay, width 16 | 849.758 | 654.428 |
| Encode/decode/replay, width 64 | 596.156 | 438.871 |
Direct timing excludes experiment input generation, canonical comparisons and
metric collection. Replay timing includes codec work and replay's owner restore;
explicit extra checkpoint checks/comparisons are excluded. Reduced codec overhead
at larger batches is not an aggregation speedup or permission to delay gameplay
outcomes. Only 4-5 simultaneous lives are measured. Peak serialized state is
10,188 bytes; serialized bytes do not measure RSS, scratch or worker memory.
## Reproduce and validation
```powershell
./tools/windows-check.ps1 -Preset release -Action check
./build/release/evo-cellular-reference.exe
```
`--verify` runs the 512-tick matrix without timing. Default is the full 8192-tick
matrix. The declared seeds/regimes/partitions are fixed research inputs.
Linux builds use the same checked-in presets with separate binary directories:
```sh
cmake --preset release -B build/linux-release
cmake --build build/linux-release --target evo-cellular-reference
./build/linux-release/evo-cellular-reference
cmake --preset analysis -B build/linux-analysis
cmake --build build/linux-analysis --target evo-cellular-reference format-check
ctest --test-dir build/linux-analysis -R cellular-population-reference --output-on-failure
cmake --preset asan -B build/linux-asan
cmake --build build/linux-asan --target evo-cellular-reference
ctest --test-dir build/linux-asan -R cellular-population-reference --output-on-failure
```
Executed on final source: native Release **71/71 CTests**, GCC Release reference
CTest, clang-format/tidy 19 with debug reference CTest, and GCC ASan/UBSan reference
CTest (19.51 s, no reports). Tests use runtime checks under NDEBUG. Both full raw
outputs parse as one metadata, eight case and 24 partition records; all non-timing
case/partition fields and final-state fingerprints match across compilers.
## Next qualification boundary
The synthetic reserve strata still cannot represent cellular positions/contact,
deposits, reproductive placement and presence closure. No adapter admits these
states into that model. Use this reference to compare a separately specified
cellular population model, with appropriate diversity/demographic/biomass bounds,
bin/interval sensitivity, unsupported-state admission and active fallback policy.
Measure representative full-region and conversion/recovery costs on the target
host. This small WSL/workstation control does not satisfy those requirements.
M12.3 automatic transitions and later unattended/migration/coupling gates remain
dependent on genuine M12.2 model qualification, not on further M11.9 approval.
+12 -3
View File
@@ -9,7 +9,7 @@ Commit and push each validated scoped segment separately.
| Subset | State | Evidence or condition for completion |
|---|---|---|
| 12.1 | Engineering evidence policy and explicit deferrals documented | ADR-0133, identity/time contract and worked histories; no new game rules or runtime versions. |
| 12.2 | Baseline reproduction (12.2a) and exact-strata instrument (12.2b) complete; cellular qualification open | The old widths remain rejected. The new exact-state experiment matches 83 synthetic trajectories, including 40 held-out cases. M11 paired multi-genome ensembles and target-host fallback budgets remain required. |
| 12.2 | Baseline reproduction (12.2a), exact-strata instrument (12.2b) and rules-8 cellular reference (12.2c) complete; cohort qualification open | The old widths remain rejected. Synthetic exact-state and current cellular controls pass; an actual paired cellular/cohort model and target-host fallback budgets remain required. |
| 12.3 | Blocked on 12.2 | No accepted population model, deterministic durable conversion sample or profile integrating cellular/cohort state. |
| 12.4 | Blocked on 12.2-12.3 | Existing cellular worker pauses without sessions/lingering players; bounded unattended recovery and biological migration escrow remain unimplemented. |
| 12.5 | Blocked on 12.2-12.4 | Finite M6 process fixtures do not qualify coupled persistent cellular/cohort atmosphere/water budgets. |
@@ -30,8 +30,17 @@ passed 69/69 outside the filesystem sandbox. No production model was adopted.
proposed below: [experiment results](M12_RESERVE_STRATA_EXPERIMENT.md), ADR-0134.
It removes the synthetic false-extinction mechanism but often retains one row per
individual. Release CTest passed 70/70, with Linux analysis and ASan/UBSan checks.
Next is the M11 paired cellular instrument and supported-state/model review;
neither exact synthetic fidelity nor workstation costs qualify a production tier.
The rules-8 control below supplies the cellular reference. Supported-state/model
review remains ahead; neither exact synthetic fidelity nor workstation costs
qualify a production tier.
12.2c implements the current rules-8 cellular reference:
[results and scope](M12_CELLULAR_REFERENCE.md), ADR-0138. Eight full cases compare
65,536 individual ticks and 70,656 replay boundaries, retaining mutation, genealogy,
inventory and offline state across encoded replay/checkpoint restore. MSVC/GCC
non-timing outputs agree; native Release CTest passes 71/71. This is an exact
reference control; the paired cellular/cohort model, fuller predation/capacity
matrix and target-host budgets remain open. No automatic tier selector is enabled.
## Architectural conflict and resolution
@@ -1,5 +1,10 @@
# M12.2 population qualification: baseline reproduction
2026-10-17: [M12.2c](M12_CELLULAR_REFERENCE.md) adds the current rules-8 exact
cellular control with encoded replay, funded mutation/birth/death and offline
state evidence. M11.9 is closed for now by the maintainer. The actual cellular
cohort model and target-host budgets remain open.
Follow-up (2026-10-16): [M12.2b](M12_RESERVE_STRATA_EXPERIMENT.md) tests a separate
exact-reserve/age candidate and matches 83 synthetic trajectories on MSVC/GCC.
The baseline rejection below remains valid; no production cellular tier qualifies.
+33
View File
@@ -1,5 +1,38 @@
# Validation report
## 2026-10-17 - M12.2c current cellular reference
ADR-0138 scopes an isolated headless research executable over the current rules-8
CellularLives owner and existing batch codec/replay APIs. No runtime/public API,
simulation version, golden, deployment or world-state changes. M11.9 is closed
for now under the maintainer's separately recorded decision.
Executed on final source:
- MSVC 19.44 Release configure/build, warnings-as-errors, **71/71 CTests** outside
the sandbox (existing filesystem hard-link fixtures require it).
- GCC 14.2 Release instrument build and `cellular-population-reference` CTest.
- `analysis` preset in `build/linux-analysis`, clang-tidy 19 warnings-as-errors,
repository clang-format 19 check and instrument debug CTest (5.28 s).
- `asan` preset in `build/linux-asan`, instrument ASan/UBSan CTest passed (19.51 s),
no reports. The test is the short matrix, not the full long run. No threads added.
- Full 8192-tick matrix on both MSVC and GCC: 8 cases, 24 partition records per
output; 65,536 reference ticks, 70,656 compared replay boundaries, 1536 extra
checkpoint restores per platform. All non-timing records and final-state
fingerprints match; every local comparison is complete canonical byte equality.
- Coverage: 16 mutations, four wildlife births, 19 starvation deaths, 10,240 frozen
controlled-life ticks and 2240 suspended-life ticks. No successful engulfment or
blocked resume observed; twin occurrence is not established by these totals.
- Parsed both JSONL files and checked their matrix counts/non-timing equality;
`git diff --check` and report/ADR relative links checked.
Report, raw files, exact methodology and remaining limits:
[M12_CELLULAR_REFERENCE](M12_CELLULAR_REFERENCE.md). Local costs cover only 4-5
simultaneous lives; they do not establish target-host fallback capacity, p95
worker latency, cellular/cohort fidelity or automatic transitions. No PostgreSQL,
live-region, process-loss, migration, global extinction or regional atmosphere/water
qualification is claimed. M12.2's actual model and target-host gates remain open.
## 2026-10-17 - M11.9 scoped closure and UI review
Recorded the maintainer's explicit closure for now and authorization for M12.
@@ -0,0 +1,33 @@
{"kind":"metadata","instrument":"cellular-reference-1","rules":8,"owner_format":6,"habitat_format":2,"genome_schema":4,"development":4,"trace_format":3,"tick_microseconds":50000,"aggregate_qualified":false,"compiler":"GCC 14.2.0","build":"release"}
{"kind":"cellular_reference","seed":0,"split":"development","regime":"rich","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":2048,"suspended_life_ticks":448,"resume_blocked_ticks":0,"peak_lives":4,"peak_snapshot_bytes":9256,"max_capability_profiles":4,"living_genome_ids":4,"final_owned":4,"final_wildlife":0,"buds":0,"mutations":4,"deaths":0,"engulfed":0,"living_body_matter_fg":[24064000,5376000,2752000,11328000],"final_state_fnv64":9638579933819687275,"direct_step_ns":61384473}
{"kind":"replay_partition","seed":0,"regime":"rich","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":830215206}
{"kind":"replay_partition","seed":0,"regime":"rich","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":107558260}
{"kind":"replay_partition","seed":0,"regime":"rich","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":70047701}
{"kind":"cellular_reference","seed":0,"split":"development","regime":"scarce","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":512,"suspended_life_ticks":112,"resume_blocked_ticks":0,"peak_lives":4,"peak_snapshot_bytes":7336,"max_capability_profiles":1,"living_genome_ids":0,"final_owned":0,"final_wildlife":0,"buds":0,"mutations":0,"deaths":4,"engulfed":0,"living_body_matter_fg":[0,0,0,0],"final_state_fnv64":1699295667085328603,"direct_step_ns":29998235}
{"kind":"replay_partition","seed":0,"regime":"scarce","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":428134301}
{"kind":"replay_partition","seed":0,"regime":"scarce","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":53484934}
{"kind":"replay_partition","seed":0,"regime":"scarce","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":34088197}
{"kind":"cellular_reference","seed":1,"split":"development","regime":"rich","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":2048,"suspended_life_ticks":448,"resume_blocked_ticks":0,"peak_lives":5,"peak_snapshot_bytes":9784,"max_capability_profiles":4,"living_genome_ids":4,"final_owned":4,"final_wildlife":1,"buds":1,"mutations":4,"deaths":0,"engulfed":0,"living_body_matter_fg":[27018000,6003000,3096000,12663000],"final_state_fnv64":13426606922151975847,"direct_step_ns":76184229}
{"kind":"replay_partition","seed":1,"regime":"rich","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":841723066}
{"kind":"replay_partition","seed":1,"regime":"rich","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":121519559}
{"kind":"replay_partition","seed":1,"regime":"rich","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":85090099}
{"kind":"cellular_reference","seed":1,"split":"development","regime":"scarce","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":512,"suspended_life_ticks":112,"resume_blocked_ticks":0,"peak_lives":4,"peak_snapshot_bytes":7336,"max_capability_profiles":1,"living_genome_ids":0,"final_owned":0,"final_wildlife":0,"buds":0,"mutations":0,"deaths":4,"engulfed":0,"living_body_matter_fg":[0,0,0,0],"final_state_fnv64":7259581644046399828,"direct_step_ns":29933257}
{"kind":"replay_partition","seed":1,"regime":"scarce","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":428585067}
{"kind":"replay_partition","seed":1,"regime":"scarce","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":53422199}
{"kind":"replay_partition","seed":1,"regime":"scarce","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":34361984}
{"kind":"cellular_reference","seed":2,"split":"holdout","regime":"rich","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":2048,"suspended_life_ticks":448,"resume_blocked_ticks":0,"peak_lives":5,"peak_snapshot_bytes":10188,"max_capability_profiles":4,"living_genome_ids":3,"final_owned":3,"final_wildlife":2,"buds":2,"mutations":4,"deaths":1,"engulfed":0,"living_body_matter_fg":[20963680,4627920,2407840,9774960],"final_state_fnv64":16793227451803230830,"direct_step_ns":62769142}
{"kind":"replay_partition","seed":2,"regime":"rich","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":764891880}
{"kind":"replay_partition","seed":2,"regime":"rich","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":104146820}
{"kind":"replay_partition","seed":2,"regime":"rich","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":70882914}
{"kind":"cellular_reference","seed":2,"split":"holdout","regime":"scarce","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":512,"suspended_life_ticks":112,"resume_blocked_ticks":0,"peak_lives":4,"peak_snapshot_bytes":7336,"max_capability_profiles":1,"living_genome_ids":0,"final_owned":0,"final_wildlife":0,"buds":0,"mutations":0,"deaths":4,"engulfed":0,"living_body_matter_fg":[0,0,0,0],"final_state_fnv64":7296712214849254814,"direct_step_ns":30324478}
{"kind":"replay_partition","seed":2,"regime":"scarce","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":429596748}
{"kind":"replay_partition","seed":2,"regime":"scarce","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":53437434}
{"kind":"replay_partition","seed":2,"regime":"scarce","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":34424154}
{"kind":"cellular_reference","seed":3,"split":"holdout","regime":"rich","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":2048,"suspended_life_ticks":448,"resume_blocked_ticks":0,"peak_lives":4,"peak_snapshot_bytes":9646,"max_capability_profiles":3,"living_genome_ids":2,"final_owned":2,"final_wildlife":1,"buds":1,"mutations":4,"deaths":2,"engulfed":0,"living_body_matter_fg":[14986000,3315000,1720000,6999000],"final_state_fnv64":16000301371984625830,"direct_step_ns":67120497}
{"kind":"replay_partition","seed":3,"regime":"rich","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":727171137}
{"kind":"replay_partition","seed":3,"regime":"rich","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":106983436}
{"kind":"replay_partition","seed":3,"regime":"rich","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":75175549}
{"kind":"cellular_reference","seed":3,"split":"holdout","regime":"scarce","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":512,"suspended_life_ticks":112,"resume_blocked_ticks":0,"peak_lives":4,"peak_snapshot_bytes":7336,"max_capability_profiles":1,"living_genome_ids":0,"final_owned":0,"final_wildlife":0,"buds":0,"mutations":0,"deaths":4,"engulfed":0,"living_body_matter_fg":[0,0,0,0],"final_state_fnv64":2748579370307818965,"direct_step_ns":30529272}
{"kind":"replay_partition","seed":3,"regime":"scarce","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":432851717}
{"kind":"replay_partition","seed":3,"regime":"scarce","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":53874941}
{"kind":"replay_partition","seed":3,"regime":"scarce","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":34800843}
@@ -0,0 +1,33 @@
{"kind":"metadata","instrument":"cellular-reference-1","rules":8,"owner_format":6,"habitat_format":2,"genome_schema":4,"development":4,"trace_format":3,"tick_microseconds":50000,"aggregate_qualified":false,"compiler":"MSVC 1944","build":"release"}
{"kind":"cellular_reference","seed":0,"split":"development","regime":"rich","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":2048,"suspended_life_ticks":448,"resume_blocked_ticks":0,"peak_lives":4,"peak_snapshot_bytes":9256,"max_capability_profiles":4,"living_genome_ids":4,"final_owned":4,"final_wildlife":0,"buds":0,"mutations":4,"deaths":0,"engulfed":0,"living_body_matter_fg":[24064000,5376000,2752000,11328000],"final_state_fnv64":9638579933819687275,"direct_step_ns":78224200}
{"kind":"replay_partition","seed":0,"regime":"rich","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":1034003200}
{"kind":"replay_partition","seed":0,"regime":"rich","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":137822900}
{"kind":"replay_partition","seed":0,"regime":"rich","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":92601200}
{"kind":"cellular_reference","seed":0,"split":"development","regime":"scarce","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":512,"suspended_life_ticks":112,"resume_blocked_ticks":0,"peak_lives":4,"peak_snapshot_bytes":7336,"max_capability_profiles":1,"living_genome_ids":0,"final_owned":0,"final_wildlife":0,"buds":0,"mutations":0,"deaths":4,"engulfed":0,"living_body_matter_fg":[0,0,0,0],"final_state_fnv64":1699295667085328603,"direct_step_ns":35432900}
{"kind":"replay_partition","seed":0,"regime":"scarce","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":465120200}
{"kind":"replay_partition","seed":0,"regime":"scarce","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":61474400}
{"kind":"replay_partition","seed":0,"regime":"scarce","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":41235300}
{"kind":"cellular_reference","seed":1,"split":"development","regime":"rich","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":2048,"suspended_life_ticks":448,"resume_blocked_ticks":0,"peak_lives":5,"peak_snapshot_bytes":9784,"max_capability_profiles":4,"living_genome_ids":4,"final_owned":4,"final_wildlife":1,"buds":1,"mutations":4,"deaths":0,"engulfed":0,"living_body_matter_fg":[27018000,6003000,3096000,12663000],"final_state_fnv64":13426606922151975847,"direct_step_ns":111506600}
{"kind":"replay_partition","seed":1,"regime":"rich","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":1098198800}
{"kind":"replay_partition","seed":1,"regime":"rich","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":171150200}
{"kind":"replay_partition","seed":1,"regime":"rich","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":125108900}
{"kind":"cellular_reference","seed":1,"split":"development","regime":"scarce","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":512,"suspended_life_ticks":112,"resume_blocked_ticks":0,"peak_lives":4,"peak_snapshot_bytes":7336,"max_capability_profiles":1,"living_genome_ids":0,"final_owned":0,"final_wildlife":0,"buds":0,"mutations":0,"deaths":4,"engulfed":0,"living_body_matter_fg":[0,0,0,0],"final_state_fnv64":7259581644046399828,"direct_step_ns":36022100}
{"kind":"replay_partition","seed":1,"regime":"scarce","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":471529400}
{"kind":"replay_partition","seed":1,"regime":"scarce","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":61559900}
{"kind":"replay_partition","seed":1,"regime":"scarce","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":40987300}
{"kind":"cellular_reference","seed":2,"split":"holdout","regime":"rich","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":2048,"suspended_life_ticks":448,"resume_blocked_ticks":0,"peak_lives":5,"peak_snapshot_bytes":10188,"max_capability_profiles":4,"living_genome_ids":3,"final_owned":3,"final_wildlife":2,"buds":2,"mutations":4,"deaths":1,"engulfed":0,"living_body_matter_fg":[20963680,4627920,2407840,9774960],"final_state_fnv64":16793227451803230830,"direct_step_ns":89797400}
{"kind":"replay_partition","seed":2,"regime":"rich","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":967135300}
{"kind":"replay_partition","seed":2,"regime":"rich","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":142797300}
{"kind":"replay_partition","seed":2,"regime":"rich","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":102065500}
{"kind":"cellular_reference","seed":2,"split":"holdout","regime":"scarce","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":512,"suspended_life_ticks":112,"resume_blocked_ticks":0,"peak_lives":4,"peak_snapshot_bytes":7336,"max_capability_profiles":1,"living_genome_ids":0,"final_owned":0,"final_wildlife":0,"buds":0,"mutations":0,"deaths":4,"engulfed":0,"living_body_matter_fg":[0,0,0,0],"final_state_fnv64":7296712214849254814,"direct_step_ns":36586200}
{"kind":"replay_partition","seed":2,"regime":"scarce","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":476061000}
{"kind":"replay_partition","seed":2,"regime":"scarce","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":63413700}
{"kind":"replay_partition","seed":2,"regime":"scarce","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":41630500}
{"kind":"cellular_reference","seed":3,"split":"holdout","regime":"rich","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":2048,"suspended_life_ticks":448,"resume_blocked_ticks":0,"peak_lives":4,"peak_snapshot_bytes":9646,"max_capability_profiles":3,"living_genome_ids":2,"final_owned":2,"final_wildlife":1,"buds":1,"mutations":4,"deaths":2,"engulfed":0,"living_body_matter_fg":[14986000,3315000,1720000,6999000],"final_state_fnv64":16000301371984625830,"direct_step_ns":101287900}
{"kind":"replay_partition","seed":3,"regime":"rich","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":912555700}
{"kind":"replay_partition","seed":3,"regime":"rich","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":148971700}
{"kind":"replay_partition","seed":3,"regime":"rich","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":110699800}
{"kind":"cellular_reference","seed":3,"split":"holdout","regime":"scarce","ticks":8192,"exact_replay":true,"conservation":true,"offline_frozen_ticks":512,"suspended_life_ticks":112,"resume_blocked_ticks":0,"peak_lives":4,"peak_snapshot_bytes":7336,"max_capability_profiles":1,"living_genome_ids":0,"final_owned":0,"final_wildlife":0,"buds":0,"mutations":0,"deaths":4,"engulfed":0,"living_body_matter_fg":[0,0,0,0],"final_state_fnv64":2748579370307818965,"direct_step_ns":36407900}
{"kind":"replay_partition","seed":3,"regime":"scarce","width":1,"compared_boundaries":8192,"checkpoint_restores":64,"codec_and_replay_ns":472456800}
{"kind":"replay_partition","seed":3,"regime":"scarce","width":16,"compared_boundaries":512,"checkpoint_restores":64,"codec_and_replay_ns":62567500}
{"kind":"replay_partition","seed":3,"regime":"scarce","width":64,"compared_boundaries":128,"checkpoint_restores":64,"codec_and_replay_ns":41827900}
@@ -0,0 +1,362 @@
// ADR-0138: current cellular exact control; no aggregate model or runtime policy.
#include "evo/server/lifecycle/cellular_batch.hpp"
#include "evo/server/lifecycle/cellular_play_summary.hpp"
#include "evo/server/lifecycle/wildlife_controller.hpp"
#include <algorithm>
#include <array>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <expected>
#include <iostream>
#include <memory>
#include <set>
#include <stdexcept>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
namespace {
using namespace evo;
using namespace evo::server;
using accounting::Inventory;
using Owner = std::unique_ptr<CellularLives>;
using Clock = std::chrono::steady_clock;
void require(bool condition, const char* message) {
if (!condition)
throw std::runtime_error(message);
}
template <typename T, typename E> T checked(std::expected<T, E> result, const char* message) {
if (!result)
throw std::runtime_error(std::string{message} + ": " +
std::to_string(static_cast<unsigned>(result.error())));
return std::move(*result);
}
Owner restore(const CellularLives& state) {
return checked(CellularLives::restore(state.snapshot(), state.world(), state.region(),
state.frame(), state.tick()),
"reference restore");
}
std::uint64_t fingerprint(const CellularLives& state) {
std::uint64_t value = 14695981039346656037ULL;
for (const auto byte : state.snapshot())
value = (value ^ byte) * 1099511628211ULL;
return value; // Reproducibility fingerprint only, never an authenticity proof.
}
Owner opening(std::uint64_t seed, bool rich) {
constexpr std::uint32_t side = 6'000;
const auto world = 200 + seed;
const auto endowment = checked(biology::primitive_endowment(biology::primitive_founder_v3),
"reference founder endowment");
auto funding = endowment.body;
funding.energy.value = 4 * (endowment.reserve.energy.value + endowment.construction.value);
for (auto& channel : funding.matter)
channel.value *= 4;
const std::vector<SpawnSite> sites{
{1'000, 1'000}, {1'000, 4'000}, {4'000, 1'000}, {4'000, 4'000}};
auto primitive =
checked(PrimitiveLives::create({world, 1, 1, 17, funding, sites}), "reference nursery");
std::vector<biology::CellularPatch> pools;
for (const auto& site : sites) {
biology::CellularPatch pool;
pool.address = {static_cast<std::uint32_t>(site.x_um),
static_cast<std::uint32_t>(site.y_um)};
pool.radius_um = 500;
pool.source = 18;
pool.stock.energy.value = rich ? 1'000'000'000'000ULL : 0;
for (auto& channel : pool.stock.matter)
channel.value = rich ? 1'000'000'000'000ULL : 1'000;
pools.push_back(pool);
}
Inventory amount{{rich ? 1'000'000ULL : 10'000ULL}, {}};
for (auto& channel : amount.matter)
channel.value = rich ? 100'000 : 10;
auto config = checked(
biology::scatter_deposits({world, 1, 1, side, side, {}}, pools, {64, 19, amount, seed}),
"reference deposits");
if (rich) {
// Explicit finite contact food on each founding site. It is not a reserve grant
// or replenishment; the owner must acquire and spend it through real biology.
for (const auto& site : sites)
for (std::uint32_t channel = 0; channel < 5; ++channel) {
biology::CellularPatch mote;
mote.address = {static_cast<std::uint32_t>(site.x_um) + 10 + channel * 2,
static_cast<std::uint32_t>(site.y_um) + 10};
mote.source = 20;
mote.id = config.next_deposit++;
mote.radius_um = biology::cellular_mote_radius_um;
mote.kind = biology::CellularDepositKind::mote;
if (channel == 0)
mote.stock.energy.value = 1'000'000'000'000ULL;
else
mote.stock.matter[channel - 1].value = 1'000'000'000'000ULL;
config.patches.push_back(mote);
}
std::ranges::sort(config.patches, {}, &biology::CellularPatch::address);
}
auto habitat =
checked(biology::CellularHabitat::create(std::move(config)), "reference habitat");
auto state =
checked(CellularLives::create(*primitive, std::move(habitat), {{side, side}, 0, 293'150},
CellularLivesProfile::foraging),
"reference cellular owner");
require(state->advance_tick(std::span<const CellularLifeIntent>{}).has_value(),
"reference genesis tick");
for (std::uint64_t index = 0; index < 4; ++index) {
LifeRequest request{};
request.account.back() = static_cast<std::uint8_t>(index + 1);
request.action = 1;
const auto identity = 100 + index;
state = checked(state->birth_candidate(
request, {identity, identity, identity, identity, {state->tick()}}),
"reference funded birth");
}
require(state->rules_version() == cellular_lives_foraging_rules &&
state->habitat().config().format == biology::cellular_habitat_deposit_format,
"reference version bundle");
return state;
}
CellularTickIntents inputs(const CellularLives& state, std::uint64_t seed,
const std::set<std::uint64_t>& mutated) {
CellularTickIntents tick;
const auto wildlife = checked(wildlife_intents(state, state.tick() + 1), "reference wildlife");
for (const auto& life : state.lives()) {
CellularLifeIntent intent{life.identity.life, {}};
if (life.account == LifeAccount{}) {
const auto found =
std::ranges::find(wildlife, life.identity.life, &CellularLifeIntent::life_id);
require(found != wildlife.end(), "reference missing wildlife intention");
intent = *found;
} else {
const auto phase = (state.tick() + 1) % 1024;
intent.intent.frozen = life.identity.life == 100 && phase >= 128 && phase < 384;
if (!intent.intent.frozen) {
// Fixture players request real actions; the owner alone admits/funds them.
if ((state.tick() + 1 + life.identity.life) % 100 == 0)
intent.intent.bud = true;
else if ((state.tick() + 1) % 197 == 0)
intent.intent.engulf = true;
else if (state.tick() >= 4096) {
const auto direction = (state.tick() / 64 + life.identity.life + seed) % 4;
constexpr std::array<biology::CellularIntent, 4> directions{
{{1'000, 0}, {0, 1'000}, {-1'000, 0}, {0, -1'000}}};
intent.intent.movement = directions[direction];
}
}
if (!intent.intent.frozen && life.presence == CellularPresence::active &&
!mutated.contains(life.identity.life) && life.mutation.offer) {
const auto genome =
checked(state.archive().find(life.identity.genome), "reference offered genome");
const auto& offer = *life.mutation.offer;
for (std::size_t offset = 0; offset < offer.candidates.size(); ++offset) {
const auto& choice =
offer.candidates[(offset + seed) % offer.candidates.size()];
const auto successor = 1'000'000 + state.tick() * 4 + life.identity.life - 100;
const auto funded =
biology::fund_mutation(genome, offer.context, offer, choice.operator_id,
successor, successor, life.reserve);
if (funded) {
tick.mutations.push_back({life.identity.life, life.mutation.event_index,
life.mutation.offer_tick, successor,
choice.operator_id});
break;
}
}
}
}
tick.lives.push_back(intent);
}
return tick;
}
struct Replay {
std::uint64_t width{};
Owner state;
CellularBatch batch;
std::uint64_t elapsed_ns{}, intervals{}, restores{};
};
void flush(Replay& replay, const CellularLives& reference, bool timing) {
if (replay.batch.ticks.empty())
return;
const auto start = timing ? Clock::now() : Clock::time_point{};
replay.batch.header.world = replay.state->world();
replay.batch.header.region = replay.state->region();
replay.batch.header.frame = replay.state->frame();
replay.batch.header.begin_tick = replay.state->tick();
replay.batch.header.end_tick = reference.tick();
// Stand-in trusted predecessor identities for this in-memory, non-storage instrument.
replay.batch.header.predecessor.fill(1);
replay.batch.header.predecessor_digest.fill(2);
const auto bytes = checked(encode_cellular_batch(replay.batch), "reference trace encode");
const auto decoded = checked(decode_cellular_batch(bytes), "reference trace decode");
require(decoded == replay.batch, "reference trace round trip");
replay.state = checked(replay_cellular_batch(*replay.state, decoded), "reference trace replay");
if (timing)
replay.elapsed_ns += static_cast<std::uint64_t>(
std::chrono::duration_cast<std::chrono::nanoseconds>(Clock::now() - start).count());
require(replay.state->snapshot() == reference.snapshot(), "reference replay state mismatch");
require(replay.state->current_total() == replay.state->opening_total(),
"reference replay conservation");
++replay.intervals;
if (reference.tick() % 128 == 1) {
auto resumed = restore(*replay.state);
require(resumed->snapshot() == replay.state->snapshot(), "reference restart mismatch");
replay.state = std::move(resumed);
++replay.restores;
}
replay.batch.ticks.clear();
}
std::uint64_t profiles(const CellularLives& state) {
std::vector<std::vector<biology::CapabilityRecord>> distinct;
for (const auto& life : state.lives()) {
const auto genome = checked(state.archive().find(life.identity.genome), "reference census");
std::vector<biology::CapabilityRecord> signature{genome.capabilities().begin(),
genome.capabilities().end()};
if (std::ranges::find(distinct, signature) == distinct.end())
distinct.push_back(std::move(signature));
}
return distinct.size();
}
CellularPlaySummary run(std::uint64_t seed, bool rich, std::uint64_t ticks, bool timing) {
auto state = opening(seed, rich);
require(state->lives().size() == 4, "reference must start with four funded founders");
std::array<Replay, 3> replays{{{1, restore(*state), {}, 0, 0, 0},
{16, restore(*state), {}, 0, 0, 0},
{64, restore(*state), {}, 0, 0, 0}}};
std::set<std::uint64_t> mutated;
std::uint64_t direct_ns = 0, frozen_ticks = 0, suspended_ticks = 0, blocked = 0;
std::uint64_t peak_lives = state->lives().size(), peak_bytes = state->snapshot().size();
std::uint64_t max_profiles = profiles(*state);
for (std::uint64_t step = 0; step < ticks; ++step) {
const auto tick = inputs(*state, seed, mutated);
// Retain exact offline biology; presence/linger ticks may change, biology may not.
std::vector<CellularOwnedLife> frozen;
for (const auto& intent : tick.lives)
if (intent.intent.frozen) {
const auto found =
std::ranges::find(state->lives(), intent.life_id,
[](const auto& life) { return life.identity.life; });
require(found != state->lives().end(), "reference frozen identity");
frozen.push_back(*found);
++frozen_ticks;
}
const auto start = timing ? Clock::now() : Clock::time_point{};
const auto executed =
checked(state->advance_tick_with_mutations(tick.lives, tick.mutations),
"reference biological tick");
if (timing)
direct_ns += static_cast<std::uint64_t>(
std::chrono::duration_cast<std::chrono::nanoseconds>(Clock::now() - start).count());
for (const auto& mutation : executed.mutations)
if (mutation.result == CellularMutationResult::applied)
mutated.insert(mutation.life_id);
for (const auto& before : frozen) {
const auto found =
std::ranges::find(state->lives(), before.identity.life,
[](const auto& life) { return life.identity.life; });
if (found != state->lives().end())
require(found->identity == before.identity && found->growth == before.growth &&
found->position == before.position && found->body == before.body &&
found->reserve == before.reserve && found->mutation == before.mutation,
"reference offline biology progressed");
}
for (const auto& feedback : state->last_tick_feedback()) {
suspended_ticks += feedback.presence == CellularPresence::suspended ? 1 : 0;
blocked += feedback.resume_blocked ? 1 : 0;
}
require(state->current_total() == state->opening_total(), "reference conservation");
peak_lives = std::max(peak_lives, static_cast<std::uint64_t>(state->lives().size()));
peak_bytes = std::max(peak_bytes, static_cast<std::uint64_t>(state->snapshot().size()));
max_profiles = std::max(max_profiles, profiles(*state));
for (auto& replay : replays) {
replay.batch.ticks.push_back(tick);
if (replay.batch.ticks.size() == replay.width || step + 1 == ticks)
flush(replay, *state, timing);
}
}
const auto summary = checked(summarize_cellular_play(*state), "reference history summary");
require(state->tick() == ticks + 1, "reference did not complete every requested tick");
if (rich)
require(frozen_ticks > 0 && suspended_ticks > 0 && summary.mutations > 0 &&
max_profiles > 1,
"reference rich fixture missed mutation/offline coverage");
Inventory living_body{};
for (const auto& life : state->lives())
for (std::size_t channel = 0; channel < living_body.matter.size(); ++channel)
living_body.matter[channel].value += life.body.matter[channel].value;
std::cout << "{\"kind\":\"cellular_reference\",\"seed\":" << seed << ",\"split\":\""
<< (seed < 2 ? "development" : "holdout") << "\",\"regime\":\""
<< (rich ? "rich" : "scarce") << "\",\"ticks\":" << ticks
<< ",\"exact_replay\":true,\"conservation\":true,\"offline_frozen_ticks\":"
<< frozen_ticks << ",\"suspended_life_ticks\":" << suspended_ticks
<< ",\"resume_blocked_ticks\":" << blocked << ",\"peak_lives\":" << peak_lives
<< ",\"peak_snapshot_bytes\":" << peak_bytes
<< ",\"max_capability_profiles\":" << max_profiles
<< ",\"living_genome_ids\":" << summary.living_genomes
<< ",\"final_owned\":" << summary.owned << ",\"final_wildlife\":" << summary.wildlife
<< ",\"buds\":" << summary.buds << ",\"mutations\":" << summary.mutations
<< ",\"deaths\":" << summary.deaths << ",\"engulfed\":" << summary.engulfed
<< ",\"living_body_matter_fg\":[" << living_body.matter[0].value << ','
<< living_body.matter[1].value << ',' << living_body.matter[2].value << ','
<< living_body.matter[3].value << ']'
<< ",\"final_state_fnv64\":" << fingerprint(*state)
<< ",\"direct_step_ns\":" << direct_ns << "}\n";
for (const auto& replay : replays)
std::cout << "{\"kind\":\"replay_partition\",\"seed\":" << seed << ",\"regime\":\""
<< (rich ? "rich" : "scarce") << "\",\"width\":" << replay.width
<< ",\"compared_boundaries\":" << replay.intervals
<< ",\"checkpoint_restores\":" << replay.restores
<< ",\"codec_and_replay_ns\":" << replay.elapsed_ns << "}\n";
return summary;
}
} // namespace
int main(int argc, char** argv) try {
if (argc > 2 || (argc == 2 && std::string_view{argv[1]} != "--verify")) {
std::fputs("usage: evo-cellular-reference [--verify]\n", stderr);
return 2;
}
const bool timing = argc == 1;
std::cout << "{\"kind\":\"metadata\",\"instrument\":\"cellular-reference-1\","
"\"rules\":8,\"owner_format\":6,\"habitat_format\":2,\"genome_schema\":4,"
"\"development\":4,\"trace_format\":3,\"tick_microseconds\":50000,"
"\"aggregate_qualified\":false,\"compiler\":\""
#if defined(__clang__)
<< "Clang " << __clang_version__
#elif defined(_MSC_VER)
<< "MSVC " << _MSC_VER
#else
<< "GCC " << __VERSION__
#endif
<< "\",\"build\":\""
#if defined(NDEBUG)
<< "release"
#else
<< "debug"
#endif
<< "\"}\n";
std::uint64_t buds = 0, deaths = 0;
for (std::uint64_t seed = 0; seed < 4; ++seed)
for (const bool rich : {true, false}) {
const auto summary = run(seed, rich, timing ? 8192 : 512, timing);
buds += summary.buds;
deaths += summary.deaths;
}
if (timing)
require(buds > 0 && deaths > 0, "reference long suite missed birth/death coverage");
return 0;
} catch (const std::exception& error) {
std::fprintf(stderr, "%s\n", error.what());
return 1;
}