T-001: Sim core architecture and skeleton
Goal
Build the foundation every other sim ticket stands on: the data model, the step loop, determinism, checkpoints and speed measurement. You are deciding the architecture. Write it down so that six agents can then work on separate modules at the same time without colliding.
Scope
- World data model in
crates/sim: cells, bonds and organisms as flat arrays laid out for speed and for parallel updates. Stable ids. Cells and bonds are created and removed constantly mid-run, so that must be cheap and must not break references. Params: every tunable number in one serde struct, loadable from TOML and stored in checkpoints. Tuning agents will sweep these values, so each one gets a doc comment giving its meaning, unit and sensible range.- Step pipeline with named stages that later tickets fill in: fields, sensing, control, physics, interactions, metabolism, development, reproduction, bookkeeping. Fixed time step.
- Deterministic randomness. The same seed and params give the identical world on the same build, whatever the thread count.
- Parallelism. Native uses all cores.
wasm32-unknown-unknownruns on one thread. Both from the same code. - Spatial index for neighbour queries, as a shared service. Physics, senses and feeding will all need it.
- Checkpoints. Save and load a whole world to bytes: versioned header, compressed, same format on native and web.
- Just enough physics to prove the loop: position integration, distance bonds, world bounds. T-009 replaces it.
- Read-only view for the viewer: iterate cells (position, radius, colour, opacity, type, organism) and bonds without copying the world.
runner bench: worlds of 10k, 100k and 1M bonded, jiggling cells. Report steps per second on one thread and on all threads. Append results todocs/perf/LOG.md.docs/ARCHITECTURE.md: module map, data layout, step order, determinism rules, checkpoint versioning rules, and how to add a cell type, a field or a stage. State which module each of T-009 to T-019 owns.
Done when
- ☐ Tests pass: same result on 1 thread and on all threads, checkpoint round trip, and "run 200 steps" equals "run 100, save, load, run 100".
- ☐
cargo build -p sim --target wasm32-unknown-unknownsucceeds. - ☐ Benchmark numbers are in
docs/perf/LOG.md, with an honest statement of whether 100k cells runs faster than real time. - ☐
docs/ARCHITECTURE.mdexists and another agent could start T-009 from it alone.
Notes
- Cross-platform bit-for-bit determinism is not required (
docs/DESIGN.mdsection 12). - Prefer few dependencies in
sim. No Bevy. - Generation time is a design choice: say in the architecture doc what one step represents and how many steps you expect a lifetime to be.