T-017: Metabolism and the matter cycle
Goal
The economy of the world: where energy and matter come from, what everything costs, and
what happens at death. See docs/DESIGN.md sections 3 and 4.
Scope
- Energy and matter accounting for every organism. Building a cell takes both. Keeping a cell alive takes energy every step.
- Photo cells: light plus dissolved nutrients become energy and matter. Chemo cells: the same from vent chemicals.
- Costs for muscle work, signals, neurons, glow, pigment and growth.
- Starvation and death. Dead bodies become detritus that sinks, can be eaten later, and decays back into dissolved nutrients.
- Decide and record the ageing rule (the design proposes maintenance cost rising with cell age) and whether energy is shared body-wide or flows along bonds.
- A conservation audit: total matter in the world, counted across fields, bodies, eggs and detritus, checked every N steps in debug runs.
Done when
- ☐ The matter audit holds exactly over a long run with births and deaths.
- ☐ A hand-built rooted body with Photo cells sustains itself in light and starves in the dark. A shaded one does worse than an unshaded one.
- ☐ Every cost is in
Paramswith a comment.
Added 2026-12-02: size has to matter through the economy
Read "Scale is free" in docs/DESIGN.md section 5. No cost or income may depend on body
size by rule. Size effects have to come from this: **exchange happens at surfaces, costs are
paid by volume.** Light, dissolved food and vent chemicals reach a cell according to how
exposed it is to the water. Upkeep is paid for all matter.
- Design how exposure is worked out, cheaply enough for the hot path, and record it.
- Extra done-when check: the same cells arranged as a compact ball, a sheet and a branching shape, at several sizes. Report income and upkeep per cell for each. A large compact ball should earn less per cell than a sheet of the same cells.
- Report how long bodies of different sizes take to grow, and how long they last without food.
Added 2026-12-02: what the fields give you (from T-011)
Read docs/ARCHITECTURE.md section 16 first. In short:
- The field grid has 4-unit voxels, so it cannot see inside one voxel. Two cells in the
same voxel get the same light value from
light(p). Light income that is fair between neighbours is your job: compute each cell's exposure and share outlight_budget(voxel)among the cells in it, so the column's light is spent once and only once.light_per_cross_section(p)andlight_shade(voxel)are there to help. - Dissolved nutrients, vent chemicals and vent heat are whole quanta (
u64), 2^24 per unit of mass. Usetake(it gives fair shares when a voxel is overdrawn) andgive. Never convert through floats in a way that loses a quantum: conservation is exact today and must stay exact. FieldsStateis at version 2. If you change what it stores, raise the version.