feat(biology): genome schema 6 movement arrangement and derived handling
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
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 4m26s
Foundation / postgres-tools (push) Successful in 19s
Foundation / image (push) Successful in 3m57s
Foundation / server-image (push) Successful in 4m2s

Schema 6 genomes carry the body's movement arrangement for mutations 001-010 as
reference-point indices (100 = founder): output, efficiency, burst, steering,
streamlining, braking, anchor, coasting and colony drive. It is encoded after the
capability records and covered by the digest; older schemas refuse it, so their
capability tables and mutation catalogs are unchanged. Development version 6 and
founder 5 serve rules 12.

derive_cellular_handling scales the tuned founder handling by the arrangement:
output scales thrust, braking reverse thrust, steering turning; streamlining lowers
forward drag and coasting both drags. Full-output costs follow the metabolic
budget's movement cost times output over efficiency. Shed output or a missing
movement capability leaves only passive drift. Refreshes the DEV session window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-21 16:39:09 -04:00
co-authored by Claude Opus 5.5
parent ab5df35c3f
commit 2bffbc2095
16 changed files with 285 additions and 20 deletions
+78
View File
@@ -1,4 +1,6 @@
#include "evo/accounting/rates.hpp"
#include "evo/biology/cellular_tuning.hpp"
#include "evo/biology/founder.hpp"
#include <cstdio>
#include <fstream>
@@ -125,6 +127,81 @@ void founder_handling() {
CHECK(handling.thrust_cost.value == 1'000 && handling.reverse_cost.value == 900);
}
Genome founder_genome(const MovementArrangement& arrangement, bool movement = true) {
const auto founder = primitive_founder(1, 1, primitive_founder_v5);
check(founder.has_value());
GenomeDraft draft{2, 2, 6, {1}, {}, genome_schema_v6, arrangement};
for (const auto& record : founder->capabilities())
if (movement || record.kind != Capability::movement)
draft.capabilities.push_back(record);
const auto genome = Genome::create(draft);
check(genome.has_value());
return *genome;
}
CellularHandling handling_of(const Genome& genome) {
const auto budget = metabolic_budget(genome, {1'000, 0}, {293'150, {}});
check(budget.has_value());
const auto handling = derive_cellular_handling(genome, *budget, v0());
check(handling.has_value());
return *handling;
}
void derived_handling() {
const auto founder = primitive_founder(1, 1, primitive_founder_v5);
CHECK(founder && founder->movement_arrangement() == founder_movement_arrangement);
const auto budget = metabolic_budget(*founder, {1'000, 0}, {293'150, {}});
CHECK(budget);
const auto base = handling_of(*founder);
// The founder arrangement reproduces the tuned founder handling exactly.
const auto full =
*evo::accounting::per_tick(budget->movement.value, 50'000, evo::accounting::Rounding::up);
CHECK(base == founder_cellular_handling(v0(), {full}, {full}));
CHECK(full > 0);
auto a = founder_movement_arrangement;
a.output = 105; // 001: more thrust, costing more per tick.
const auto strong = handling_of(founder_genome(a));
CHECK(strong.thrust_q10 == 21'504 && strong.thrust_cost.value > base.thrust_cost.value);
CHECK(strong.reverse_thrust_q10 == base.reverse_thrust_q10);
a = founder_movement_arrangement;
a.efficiency = 105; // 002: same thrust, cheaper.
const auto economical = handling_of(founder_genome(a));
CHECK(economical.thrust_q10 == base.thrust_q10 &&
economical.thrust_cost.value < base.thrust_cost.value);
a = founder_movement_arrangement;
a.steering = 105; // 004
CHECK(handling_of(founder_genome(a)).turn == 3'439);
a = founder_movement_arrangement;
a.streamlining = 105; // 005: forward drag only.
const auto straight = handling_of(founder_genome(a));
CHECK(straight.forward_drag_ppm == 90'631 && straight.lateral_drag_ppm == 95'163);
a = founder_movement_arrangement;
a.braking = 105; // 006
CHECK(handling_of(founder_genome(a)).reverse_thrust_q10 == 21'504);
a = founder_movement_arrangement;
a.coasting = 105; // 008: both drags at 100/105, about 95.24%.
const auto coaster = handling_of(founder_genome(a));
CHECK(coaster.forward_drag_ppm == 90'631 && coaster.lateral_drag_ppm == 90'631);
a = founder_movement_arrangement;
a.output = 0; // 009: shed propulsion drifts but cannot thrust or turn.
const auto shed = handling_of(founder_genome(a));
CHECK(shed.thrust_q10 == 0 && shed.reverse_thrust_q10 == 0 && shed.turn == 0);
CHECK(shed.thrust_cost.value == 0 && shed.forward_drag_ppm == base.forward_drag_ppm);
CHECK(handling_of(founder_genome(founder_movement_arrangement, false)).thrust_q10 == 0);
const auto old = primitive_founder(1, 1, primitive_founder_v4);
CHECK(old);
const auto old_budget = metabolic_budget(*old, {1'000, 0}, {293'150, {}});
CHECK(old_budget && !derive_cellular_handling(*old, *old_budget, v0()));
}
// The checked-in DEV tuning file must parse; CTest passes its path when it is present.
void repository_file(const char* path) {
std::ifstream file(path, std::ios::binary);
@@ -145,6 +222,7 @@ int main(int argc, char** argv) {
comments_separators_and_whitespace();
refusals();
founder_handling();
derived_handling();
if (argc > 1)
repository_file(argv[1]);
} catch (const std::exception& error) {
+2 -2
View File
@@ -174,12 +174,12 @@ void rule_versions_and_invalid_growth() {
v3->structure_density == v2->structure_density &&
v3->maintenance_per_kilogram == v2->maintenance_per_kilogram &&
development_rate_microseconds(3) == development_rate_microseconds(2));
for (const auto version : {0U, 6U, 99U}) {
for (const auto version : {0U, 7U, 99U}) {
const auto missing = rules_for(version);
CHECK(!missing && missing.error() == DevelopmentError::unsupported_rules);
}
auto source = draft();
source.development_version = 6; // Version 5 exists since rules 11 (ADR-0175).
source.development_version = 7; // Version 6 exists since rules 12.
const auto future = build(source);
const auto derived = derive_phenotype(future, {1000, 0}, temperate);
CHECK(!derived && derived.error() == DevelopmentError::unsupported_rules);
+49 -2
View File
@@ -362,10 +362,10 @@ void schema_v2_rates() {
v1.capabilities[4].parameter = 1'000'001;
reject(v1, GenomeError::parameter_out_of_range);
auto unknown = founder();
unknown.schema_version = 6; // Schema 5 exists since rules 11 (ADR-0175).
unknown.schema_version = 7; // Schema 6 exists since rules 12.
reject(unknown, GenomeError::unsupported_version);
auto bytes = Genome::create(founder())->encode();
bytes[8] = 6; // Schema field; decode refuses before the checksum matters.
bytes[8] = 7; // Schema field; decode refuses before the checksum matters.
CHECK(!Genome::decode(bytes) &&
Genome::decode(bytes).error() == GenomeError::unsupported_version);
}
@@ -397,6 +397,52 @@ void moves_preserve_validity() {
static_assert(std::is_copy_constructible_v<Genome>);
static_assert(std::is_copy_assignable_v<Genome>);
}
// Schema 6 (rules 12): the movement arrangement is required, encoded after the capability
// records, covered by the digest, and refused before schema 6.
void schema_v6_movement_arrangement() {
auto draft = founder();
draft.schema_version = genome_schema_v6;
draft.development_version = 6;
reject(draft, GenomeError::parameter_out_of_range); // Missing arrangement.
draft.movement_arrangement = founder_movement_arrangement;
const auto genome = Genome::create(draft);
CHECK(genome && genome->movement_arrangement() == founder_movement_arrangement);
const auto bytes = genome->encode();
const auto decoded = Genome::decode(bytes);
CHECK(decoded && *decoded == *genome);
CHECK(bytes.size() == 36 + 4 + 3 * 9 + 18 + 16);
auto changed = draft;
changed.movement_arrangement->steering = 105;
const auto other = Genome::create(changed);
CHECK(other && other->content_digest() != genome->content_digest());
auto tampered = bytes;
tampered[36 + 4 + 3 * 9] ^= 1U; // First arrangement byte; the checksum catches it.
CHECK(!Genome::decode(tampered));
auto truncated = bytes;
truncated.erase(truncated.end() - 18, truncated.end() - 16);
CHECK(!Genome::decode(truncated));
for (auto bad : {MovementArrangement{1'001, 100, 0, 100, 100, 100, 0, 100, 0},
MovementArrangement{100, 0, 0, 100, 100, 100, 0, 100, 0},
MovementArrangement{100, 100, 0, 100, 100, 100, 0, 0, 0}}) {
auto refused = draft;
refused.movement_arrangement = bad;
reject(refused, GenomeError::parameter_out_of_range);
}
// Shed output and absent modules are valid.
auto shed = draft;
shed.movement_arrangement = MovementArrangement{0, 100, 0, 100, 100, 100, 0, 100, 0};
CHECK(Genome::create(shed));
auto early = founder();
early.schema_version = genome_schema_v5;
early.development_version = 5;
early.movement_arrangement = founder_movement_arrangement;
reject(early, GenomeError::parameter_out_of_range);
}
} // namespace
int main() try {
founders_and_ancestry();
@@ -408,6 +454,7 @@ int main() try {
frozen_record_compatibility();
schema_v2_rates();
moves_preserve_validity();
schema_v6_movement_arrangement();
std::cout << "PASS genome schema, ancestry, development graph and canonical encoding\n";
return 0;
} catch (const std::exception& e) {
+2 -2
View File
@@ -385,12 +385,12 @@ void rules_fail_closed() {
const auto m3 = metabolic_rules_for(3);
CHECK(m2 && m3 && m3->movement_per_kilogram == m2->movement_per_kilogram &&
m3->intake_energy_per_kilogram == m2->intake_energy_per_kilogram);
for (const auto version : {0U, 6U, 99U}) {
for (const auto version : {0U, 7U, 99U}) {
const auto missing = metabolic_rules_for(version);
CHECK(!missing && missing.error() == DevelopmentError::unsupported_rules);
}
auto source = draft();
source.development_version = 6;
source.development_version = 7;
const auto future = build(source);
const auto refused = metabolic_budget(future, {1000, 0}, temperate);
CHECK(!refused && refused.error() == DevelopmentError::unsupported_rules);
+1 -1
View File
@@ -315,7 +315,7 @@ void invalid_contexts_are_refused() {
// An unsupported development version leaves no eligible operator at all,
// because every successor fails to derive a budget.
auto source = draft();
source.development_version = 6;
source.development_version = 7;
const auto future = build(source);
const auto empty = mutation_candidates(future, context(1));
CHECK(!empty && empty.error() == MutationError::no_candidates);