feat(lifecycle): rules 12 liquid owner on format 10 with brake traces
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m23s
Foundation / postgres-tools (push) Successful in 29s
Foundation / server-image (push) Successful in 4m10s
Foundation / image (push) Successful in 4m31s

The cellular owner gains rules 12 on owner format 10: an explicit no-tick
format-9/rules-11 upgrade declares the region's liquid rules (current
configuration, founder handling and deposit motion, from the tuning file and a
seed when the region opens), converts the habitat to format 3 and starts lives at
rest. Founders born afterwards are founder 5 (genome schema 6).

Each tick derives every life's handling from its genome and the declared founder
handling, samples the current at its footprint and steps the shared liquid
motion; afterwards bubbles move with the current and the drift moving cells
induce, and touching bubbles merge. Format 10 persists the rules and each life's
motion state; restore regenerates the identical current field.

Brake is a new step intent, valid only under rules 12, carried in trace 4 as flag
bit 1 (SQL never parses that byte; player action records keep it zero). Tests
cover the upgrade, exact restore, swimming and braking, moving food with fixed
pools, restore continuing a live run, and brake traces replaying exactly. Genomes
from before schema 6 handle as founders. Refreshes the DEV session window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-21 17:28:58 -04:00
co-authored by Claude Opus 5.5
parent 190a66ad5e
commit 3f82795c18
13 changed files with 564 additions and 51 deletions
@@ -3,6 +3,7 @@
#include "evo/biology/cellular_region_step.hpp"
#include "evo/biology/mutation.hpp"
#include "evo/server/lifecycle/cellular_light.hpp"
#include "evo/server/lifecycle/cellular_liquid.hpp"
#include "evo/server/lifecycle/primitive_lives.hpp"
#include <compare>
@@ -55,19 +56,25 @@ inline constexpr std::uint32_t cellular_lives_inheritance_rules = 10;
// Format 9 is format 8 with the region's declared light and cumulative capture.
inline constexpr std::uint32_t cellular_lives_light_format = 9;
inline constexpr std::uint32_t cellular_lives_photosynthesis_rules = 11;
// Rules that retain offspring plans (formats 8 and 9): 10 and 11.
// Rules 12 (Cellular_Region_Movement_Plan.md, ADR-0177): rules 11 with founder 5 (genome
// schema 6, movement arrangement) in a liquid region. Format 10 is format 9 with the declared
// liquid rules and each life's motion state, on a format-3 habitat whose food moves.
inline constexpr std::uint32_t cellular_lives_liquid_format = 10;
inline constexpr std::uint32_t cellular_lives_liquid_rules = 12;
// Rules that retain offspring plans (formats 8 to 10): 10 to 12.
[[nodiscard]] constexpr bool cellular_retained_plans(std::uint32_t rules) noexcept {
return rules == cellular_lives_inheritance_rules ||
rules == cellular_lives_photosynthesis_rules;
rules == cellular_lives_photosynthesis_rules || rules == cellular_lives_liquid_rules;
}
inline constexpr std::uint32_t cellular_growth_per_tick = 5; // Per 50 ms; trial rate.
// The founder a region of these rules creates.
[[nodiscard]] constexpr biology::FounderVersion
cellular_founder_version(std::uint32_t rules) noexcept {
return rules >= cellular_lives_photosynthesis_rules ? biology::primitive_founder_v4
: rules >= cellular_lives_reproduction_rules ? biology::primitive_founder_v3
: rules >= cellular_lives_balance_rules ? biology::primitive_founder_v2
: biology::primitive_founder_v1;
return rules >= cellular_lives_liquid_rules ? biology::primitive_founder_v5
: rules >= cellular_lives_photosynthesis_rules ? biology::primitive_founder_v4
: rules >= cellular_lives_reproduction_rules ? biology::primitive_founder_v3
: rules >= cellular_lives_balance_rules ? biology::primitive_founder_v2
: biology::primitive_founder_v1;
}
// ADR-0137: a bud action also yields a twin with probability reproduction / 2 per thousand
// (founders: 25 %), when the reserve funds it and there is room. Seeded per parent and tick.
@@ -119,7 +126,8 @@ struct CellularOwnedLife {
// Format 6 (ADR-0128): presence and the tick its freeze began (zero while active).
CellularPresence presence{CellularPresence::active};
std::uint64_t frozen_since{};
std::uint64_t offspring_genome{}; // Format 8; older formats retain zero.
std::uint64_t offspring_genome{}; // Format 8; older formats retain zero.
biology::CellularMotionState motion{}; // Format 10; older formats retain zero.
auto operator<=>(const CellularOwnedLife&) const = default;
};
struct CellularOwnedCorpse {
@@ -300,6 +308,14 @@ class CellularLives {
// afterwards can evolve photosynthesis.
[[nodiscard]] std::expected<std::unique_ptr<CellularLives>, CellularLivesError>
photosynthesis_upgrade_candidate(CellularLight light) const;
// Rules 12: explicit no-tick format-9/rules-11 -> format-10/rules-12 upgrade declaring
// the region's liquid rules. The habitat becomes format 3 (every bubble counts one merged
// bubble) and lives start at rest. Founders born afterwards are founder 5.
[[nodiscard]] std::expected<std::unique_ptr<CellularLives>, CellularLivesError>
liquid_upgrade_candidate(const CellularLiquidRules& rules) const;
// Format 10: the declared liquid rules and the current field they generate (null before).
[[nodiscard]] const CellularLiquidRules& liquid_rules() const noexcept;
[[nodiscard]] const biology::CellularFlowField* flow_field() const noexcept;
// Format 9: declared light and the energy captured from it, cumulatively.
[[nodiscard]] const CellularLight& light() const noexcept;
[[nodiscard]] accounting::Picojoules captured_light() const noexcept;