feat(lifecycle): rules 13 owner on format 11 with the revamp tuning file
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (checks) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 3s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m30s
Foundation / postgres-tools (push) Successful in 22s
Foundation / server-image (push) Successful in 4m12s
Foundation / image (push) Successful in 4m40s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (checks) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 3s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m30s
Foundation / postgres-tools (push) Successful in 22s
Foundation / server-image (push) Successful in 4m12s
Foundation / image (push) Successful in 4m40s
Phase 1 of the cellular revamp build plan (ADR-0179). The cellular owner gains rules 13 on owner format 11: an explicit no-tick format-10/rules-12 upgrade declares the region's revamp rules (so far the body's essential upkeep share), existing lives keep their genomes, and founders born afterwards are founder 6 (genome schema 7, development 7). Format 11 is format 10 plus the revamp rules block; it stays undeployed while later phases extend it. The tick, perception and wildlife controller derive budgets with the declared body tuning, which earlier development versions ignore. Revamp tunables live in their own Git file, deploy/kubernetes/region/dev/tuning/cellular-revamp.tuning, parsed by parse_cellular_revamp_tuning with the same format and refusals as the rules-12 file, so images from before rules 13 never meet keys they do not know. Both parsers now share read_tuning_lines; the rules-12 file's behaviour is unchanged. The revamp file is not yet mounted into the region (build plan, phase 6). Tests cover the upgrade and its refusals, mixed founder 5 and founder 6 lives ticking with closure, exact restore and continuation, trace replay, and the new tuning file including the checked-in DEV copy. Refreshes the DEV session window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,7 @@ constexpr std::uint64_t cellular_lives_v7_magic = 0x3730564C43564541ULL; // AEV
|
||||
constexpr std::uint64_t cellular_lives_v8_magic = 0x3830564C43564541ULL; // AEVCLV08
|
||||
constexpr std::uint64_t cellular_lives_v9_magic = 0x3930564C43564541ULL; // AEVCLV09
|
||||
constexpr std::uint64_t cellular_lives_v10_magic = 0x3031564C43564541ULL; // AEVCLV10
|
||||
constexpr std::uint64_t cellular_lives_v11_magic = 0x3131564C43564541ULL; // AEVCLV11
|
||||
constexpr std::size_t cellular_lives_header_bytes = 212;
|
||||
constexpr std::size_t cellular_site_bytes = 8;
|
||||
constexpr std::size_t cellular_life_v1_bytes = 168;
|
||||
@@ -51,6 +52,9 @@ constexpr std::size_t cellular_lives_v9_header_bytes = cellular_lives_v8_header_
|
||||
// its motion state (two velocities, heading, reserved, two carries), 20 bytes.
|
||||
constexpr std::size_t cellular_lives_v10_header_bytes = cellular_lives_v9_header_bytes + 88;
|
||||
constexpr std::size_t cellular_life_motion_bytes = 20;
|
||||
// Format 11 (rules 13, ADR-0179): the revamp rules, so far the essential upkeep share (4) and a
|
||||
// reserved zero (4). Later build phases extend this block before format 11 is deployed.
|
||||
constexpr std::size_t cellular_lives_v11_header_bytes = cellular_lives_v10_header_bytes + 8;
|
||||
|
||||
bool valid_motion(const biology::CellularMotionState& m) noexcept {
|
||||
constexpr std::int64_t carry = biology::cellular_velocity_q10_per_um_s * 1'000'000;
|
||||
@@ -174,11 +178,13 @@ bool subtract_inventory(accounting::Inventory& total, const accounting::Inventor
|
||||
|
||||
std::expected<biology::MetabolicBudget, CellularLivesError>
|
||||
budget_for(const biology::LineageArchive& archive, const CellularOwnedLife& life,
|
||||
std::uint32_t temperature) {
|
||||
std::uint32_t temperature,
|
||||
const biology::BodyTuning& body = biology::default_body_tuning) {
|
||||
const auto genome = archive.find(life.identity.genome);
|
||||
if (!genome)
|
||||
return std::unexpected{CellularLivesError::archive};
|
||||
const auto budget = biology::metabolic_budget(*genome, life.growth, {temperature, {}});
|
||||
const auto budget =
|
||||
biology::metabolic_budget(*genome, life.growth, {temperature, {}}, 1000, body);
|
||||
if (!budget)
|
||||
return std::unexpected{CellularLivesError::biology};
|
||||
return *budget;
|
||||
@@ -609,6 +615,7 @@ struct CellularLives::State {
|
||||
CellularLight light{}; // Format 9 (ADR-0175).
|
||||
accounting::Picojoules captured{}; // Format 9: light credited to reserves so far.
|
||||
CellularLiquidRules liquid{}; // Format 10 (rules 12).
|
||||
CellularRevampRules revamp{}; // Format 11 (rules 13).
|
||||
std::shared_ptr<const biology::CellularFlowField> field; // Generated from `liquid`.
|
||||
|
||||
State(std::uint64_t world_id, std::uint64_t region_id, std::uint64_t frame_id,
|
||||
@@ -967,6 +974,25 @@ CellularLives::liquid_upgrade_candidate(const CellularLiquidRules& rules) const
|
||||
const CellularLiquidRules& CellularLives::liquid_rules() const noexcept {
|
||||
return state_->liquid;
|
||||
}
|
||||
std::expected<std::unique_ptr<CellularLives>, CellularLivesError>
|
||||
CellularLives::revamp_upgrade_candidate(const CellularRevampRules& rules) const {
|
||||
if (state_->format_version != cellular_lives_liquid_format ||
|
||||
state_->rules_version != cellular_lives_liquid_rules)
|
||||
return std::unexpected{CellularLivesError::version};
|
||||
if (!cellular_revamp_valid(rules))
|
||||
return std::unexpected{CellularLivesError::invalid_config};
|
||||
auto candidate = restore(snapshot(), world(), region(), frame(), tick());
|
||||
if (!candidate)
|
||||
return std::unexpected(candidate.error());
|
||||
auto& next = *(*candidate)->state_;
|
||||
next.format_version = cellular_lives_revamp_format;
|
||||
next.rules_version = cellular_lives_revamp_rules;
|
||||
next.revamp = rules;
|
||||
return candidate;
|
||||
}
|
||||
const CellularRevampRules& CellularLives::revamp_rules() const noexcept {
|
||||
return state_->revamp;
|
||||
}
|
||||
const biology::CellularFlowField* CellularLives::flow_field() const noexcept {
|
||||
return state_->field.get();
|
||||
}
|
||||
@@ -1011,7 +1037,9 @@ std::vector<std::uint8_t> CellularLives::snapshot() const {
|
||||
const bool presence = state_->format_version >= cellular_lives_presence_format;
|
||||
const bool inheritance = state_->format_version >= cellular_lives_inheritance_format;
|
||||
const bool lit = state_->format_version >= cellular_lives_light_format;
|
||||
const bool liquid = state_->format_version == cellular_lives_liquid_format;
|
||||
// Format 11 is format 10 with the revamp rules.
|
||||
const bool revamp = state_->format_version == cellular_lives_revamp_format;
|
||||
const bool liquid = revamp || state_->format_version == cellular_lives_liquid_format;
|
||||
const auto life_bytes = liquid ? cellular_life_v6_bytes + 8 + cellular_life_motion_bytes
|
||||
: inheritance ? cellular_life_v6_bytes + 8
|
||||
: state_->format_version == cellular_lives_legacy_format
|
||||
@@ -1025,7 +1053,8 @@ std::vector<std::uint8_t> CellularLives::snapshot() const {
|
||||
: causes ? cellular_corpse_v4_bytes
|
||||
: cellular_corpse_bytes;
|
||||
const bool migration = state_->format_version >= cellular_lives_migration_format;
|
||||
const auto header_bytes = liquid ? cellular_lives_v10_header_bytes
|
||||
const auto header_bytes = revamp ? cellular_lives_v11_header_bytes
|
||||
: liquid ? cellular_lives_v10_header_bytes
|
||||
: lit ? cellular_lives_v9_header_bytes
|
||||
: inheritance ? cellular_lives_v8_header_bytes
|
||||
: migration ? cellular_lives_v7_header_bytes
|
||||
@@ -1055,6 +1084,7 @@ std::vector<std::uint8_t> CellularLives::snapshot() const {
|
||||
: state_->format_version == cellular_lives_engulf_format ? cellular_lives_v4_magic
|
||||
: state_->format_version == cellular_lives_bud_format ? cellular_lives_v5_magic
|
||||
: state_->format_version == cellular_lives_presence_format ? cellular_lives_v6_magic
|
||||
: revamp ? cellular_lives_v11_magic
|
||||
: liquid ? cellular_lives_v10_magic
|
||||
: lit ? cellular_lives_v9_magic
|
||||
: inheritance ? cellular_lives_v8_magic
|
||||
@@ -1121,6 +1151,10 @@ std::vector<std::uint8_t> CellularLives::snapshot() const {
|
||||
const auto cost = state_->liquid.thrust_cost_per_mille;
|
||||
out.put(cost == 1'000 ? 0 : cost, 4);
|
||||
}
|
||||
if (revamp) {
|
||||
out.put(state_->revamp.body.essential_upkeep_per_thousand, 4);
|
||||
out.put(0, 4);
|
||||
}
|
||||
for (const auto site : state_->nursery_config.sites)
|
||||
out.site(site);
|
||||
for (const auto& life : state_->lives) {
|
||||
@@ -1236,7 +1270,8 @@ CellularLives::perceive(std::uint64_t life_id) const {
|
||||
if (life == state_->lives.end())
|
||||
return std::unexpected{CellularLivesError::invalid_life};
|
||||
const auto budget =
|
||||
budget_for(state_->archive, *life, state_->config.ambient_temperature_millikelvin);
|
||||
budget_for(state_->archive, *life, state_->config.ambient_temperature_millikelvin,
|
||||
state_->revamp.body);
|
||||
if (!budget)
|
||||
return std::unexpected{budget.error()};
|
||||
auto view = state_->habitat->perceive(life->position, budget->phenotype.extent);
|
||||
@@ -1373,7 +1408,8 @@ CellularLives::birth_candidate(LifeRequest request, LifeAllocation allocation) c
|
||||
if (living.presence == CellularPresence::suspended)
|
||||
continue; // Out of the world (ADR-0128).
|
||||
const auto living_budget =
|
||||
budget_for(state_->archive, living, state_->config.ambient_temperature_millikelvin);
|
||||
budget_for(state_->archive, living, state_->config.ambient_temperature_millikelvin,
|
||||
state_->revamp.body);
|
||||
if (!living_budget)
|
||||
return std::unexpected{living_budget.error()};
|
||||
const auto separated = [](std::uint64_t left, std::uint64_t right,
|
||||
@@ -1449,6 +1485,7 @@ CellularLives::birth_candidate(LifeRequest request, LifeAllocation allocation) c
|
||||
candidate->state_->captured = state_->captured;
|
||||
candidate->state_->liquid = state_->liquid;
|
||||
candidate->state_->field = state_->field;
|
||||
candidate->state_->revamp = state_->revamp;
|
||||
return candidate;
|
||||
}
|
||||
|
||||
@@ -1473,9 +1510,13 @@ CellularLives::restore(std::span<const std::uint8_t> bytes, std::uint64_t world,
|
||||
// Format 6 carries rules 5, 6 (founder 2) or 7 (founder 3, ADR-0137); no new state.
|
||||
// Format 9 is exactly rules 11; format 8 exactly rules 10.
|
||||
// Format 10 is exactly rules 12.
|
||||
const bool liquid_version = magic == cellular_lives_v10_magic &&
|
||||
format_version == cellular_lives_liquid_format &&
|
||||
rules_version == cellular_lives_liquid_rules;
|
||||
// Format 11 is exactly rules 13, and carries everything format 10 does.
|
||||
const bool revamp_version = magic == cellular_lives_v11_magic &&
|
||||
format_version == cellular_lives_revamp_format &&
|
||||
rules_version == cellular_lives_revamp_rules;
|
||||
const bool liquid_version = revamp_version || (magic == cellular_lives_v10_magic &&
|
||||
format_version == cellular_lives_liquid_format &&
|
||||
rules_version == cellular_lives_liquid_rules);
|
||||
const bool light_version =
|
||||
liquid_version ||
|
||||
(magic == cellular_lives_v9_magic && format_version == cellular_lives_light_format &&
|
||||
@@ -1519,6 +1560,8 @@ CellularLives::restore(std::span<const std::uint8_t> bytes, std::uint64_t world,
|
||||
return std::unexpected(CellularLivesError::format);
|
||||
if (liquid_version && bytes.size() < cellular_lives_v10_header_bytes + 8)
|
||||
return std::unexpected(CellularLivesError::format);
|
||||
if (revamp_version && bytes.size() < cellular_lives_v11_header_bytes + 8)
|
||||
return std::unexpected(CellularLivesError::format);
|
||||
const auto saved_world = in.get();
|
||||
const auto saved_region = in.get();
|
||||
const auto saved_frame = in.get();
|
||||
@@ -1616,6 +1659,12 @@ CellularLives::restore(std::span<const std::uint8_t> bytes, std::uint64_t world,
|
||||
return std::unexpected{CellularLivesError::format};
|
||||
field = std::move(*generated);
|
||||
}
|
||||
CellularRevampRules revamp{};
|
||||
if (revamp_version) {
|
||||
revamp.body.essential_upkeep_per_thousand = static_cast<std::uint32_t>(in.get(4));
|
||||
if (in.get(4) != 0 || !cellular_revamp_valid(revamp))
|
||||
return std::unexpected{CellularLivesError::format};
|
||||
}
|
||||
const auto life_bytes = liquid_version ? cellular_life_v6_bytes + 8 + cellular_life_motion_bytes
|
||||
: inheritance_version ? cellular_life_v6_bytes + 8
|
||||
: legacy ? cellular_life_v1_bytes
|
||||
@@ -1626,7 +1675,8 @@ CellularLives::restore(std::span<const std::uint8_t> bytes, std::uint64_t world,
|
||||
: bud_version ? cellular_corpse_v5_bytes
|
||||
: engulf_version ? cellular_corpse_v4_bytes
|
||||
: cellular_corpse_bytes;
|
||||
const auto expected_size = (liquid_version ? cellular_lives_v10_header_bytes
|
||||
const auto expected_size = (revamp_version ? cellular_lives_v11_header_bytes
|
||||
: liquid_version ? cellular_lives_v10_header_bytes
|
||||
: light_version ? cellular_lives_v9_header_bytes
|
||||
: inheritance_version ? cellular_lives_v8_header_bytes
|
||||
: migration_version ? cellular_lives_v7_header_bytes
|
||||
@@ -1850,6 +1900,7 @@ CellularLives::restore(std::span<const std::uint8_t> bytes, std::uint64_t world,
|
||||
restored->state_->captured = captured;
|
||||
restored->state_->liquid = liquid;
|
||||
restored->state_->field = std::move(field);
|
||||
restored->state_->revamp = revamp;
|
||||
if (!std::ranges::equal(bytes, restored->snapshot()))
|
||||
return std::unexpected{CellularLivesError::noncanonical};
|
||||
return restored;
|
||||
@@ -1946,7 +1997,8 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
|
||||
if (life.presence == CellularPresence::suspended)
|
||||
continue; // Out of the world: no step, no contact (ADR-0128).
|
||||
const auto budget =
|
||||
budget_for(state_->archive, life, state_->config.ambient_temperature_millikelvin);
|
||||
budget_for(state_->archive, life, state_->config.ambient_temperature_millikelvin,
|
||||
state_->revamp.body);
|
||||
if (!budget)
|
||||
return std::unexpected{budget.error()};
|
||||
const auto genome = state_->archive.find(life.identity.genome);
|
||||
@@ -2007,8 +2059,9 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
|
||||
return std::unexpected{CellularLivesError::overflow};
|
||||
found->mutation.fed_energy_credit_pj += acquired;
|
||||
if (!found->mutation.offer) {
|
||||
const auto budget = budget_for(next_archive, *found,
|
||||
state_->config.ambient_temperature_millikelvin);
|
||||
const auto budget =
|
||||
budget_for(next_archive, *found, state_->config.ambient_temperature_millikelvin,
|
||||
state_->revamp.body);
|
||||
if (!budget ||
|
||||
budget->maintenance.value > std::numeric_limits<std::uint64_t>::max() /
|
||||
cellular_mutation_surplus_seconds)
|
||||
@@ -2052,7 +2105,8 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
|
||||
!next_archive.record_death(found->identity.organism, {proposal->end_tick}))
|
||||
return std::unexpected{CellularLivesError::archive};
|
||||
const auto corpse_budget =
|
||||
budget_for(next_archive, *found, state_->config.ambient_temperature_millikelvin);
|
||||
budget_for(next_archive, *found, state_->config.ambient_temperature_millikelvin,
|
||||
state_->revamp.body);
|
||||
if (!corpse_budget)
|
||||
return std::unexpected{corpse_budget.error()};
|
||||
next_corpses.push_back(
|
||||
@@ -2180,7 +2234,8 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
|
||||
const auto temperature = state_->config.ambient_temperature_millikelvin;
|
||||
const auto genome = next_archive.find(cellular_offspring_genome(*parent));
|
||||
const auto expressed = next_archive.find(parent->identity.genome);
|
||||
const auto parent_budget = budget_for(next_archive, *parent, temperature);
|
||||
const auto parent_budget =
|
||||
budget_for(next_archive, *parent, temperature, state_->revamp.body);
|
||||
if (!genome || !expressed || !parent_budget)
|
||||
return std::unexpected{CellularLivesError::archive};
|
||||
const auto transition = biology::fund_offspring(
|
||||
@@ -2261,7 +2316,8 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
|
||||
life.presence = CellularPresence::suspended;
|
||||
} else if (life.presence == CellularPresence::suspended && !frozen) {
|
||||
const auto budget =
|
||||
budget_for(next_archive, life, state_->config.ambient_temperature_millikelvin);
|
||||
budget_for(next_archive, life, state_->config.ambient_temperature_millikelvin,
|
||||
state_->revamp.body);
|
||||
if (!budget)
|
||||
return std::unexpected{budget.error()};
|
||||
const auto spot = resume_position(life, budget->phenotype.extent, next_lives,
|
||||
@@ -2321,7 +2377,8 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
|
||||
other.presence == CellularPresence::suspended)
|
||||
continue;
|
||||
const auto obstacle =
|
||||
budget_for(next_archive, other, state_->config.ambient_temperature_millikelvin);
|
||||
budget_for(next_archive, other, state_->config.ambient_temperature_millikelvin,
|
||||
state_->revamp.body);
|
||||
if (!obstacle)
|
||||
return std::unexpected(obstacle.error());
|
||||
clear = separated(life.position.x_um, other.position.x_um, extent,
|
||||
@@ -2449,7 +2506,8 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
|
||||
input->intent.frozen)
|
||||
continue;
|
||||
const auto budget =
|
||||
budget_for(next->archive, life, next->config.ambient_temperature_millikelvin);
|
||||
budget_for(next->archive, life, next->config.ambient_temperature_millikelvin,
|
||||
next->revamp.body);
|
||||
if (!budget)
|
||||
return std::unexpected{CellularLivesError::biology};
|
||||
const auto energy =
|
||||
|
||||
Reference in New Issue
Block a user