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
+50 -1
View File
@@ -13,6 +13,35 @@ constexpr std::size_t parent_size = 8;
constexpr std::size_t record_size = 9;
constexpr std::size_t digest_size = 8;
constexpr std::size_t checksum_size = 8;
// Schema 6: nine 16-bit movement indices after the capability records.
constexpr std::size_t arrangement_count = 9;
constexpr std::size_t arrangement_size = arrangement_count * 2;
bool has_arrangement(std::uint32_t schema) noexcept {
return schema >= genome_schema_v6;
}
std::array<std::uint16_t, arrangement_count> indices(const MovementArrangement& a) noexcept {
return {a.output, a.efficiency, a.burst, a.steering, a.streamlining,
a.braking, a.anchor, a.coasting, a.colony_drive};
}
// Required from schema 6 and refused before it. Parts a body cannot lack (efficiency,
// steering, streamlining, braking, coasting) are at least 1; acquired modules and shed
// output may be 0.
bool valid_arrangement(std::uint32_t schema,
const std::optional<MovementArrangement>& arrangement) noexcept {
if (!has_arrangement(schema))
return !arrangement.has_value();
if (!arrangement)
return false;
const auto& a = *arrangement;
for (const auto value : indices(a))
if (value > max_movement_points)
return false;
return a.efficiency != 0 && a.steering != 0 && a.streamlining != 0 && a.braking != 0 &&
a.coasting != 0;
}
// Accidental-corruption detection only, per ADR-0008. Not authenticity.
std::uint64_t checksum(std::span<const std::uint8_t> bytes) noexcept {
@@ -172,6 +201,9 @@ std::vector<std::uint8_t> Genome::body() const {
append(bytes, record.parameter, 4);
append(bytes, record.prerequisites, 4);
}
if (movement_arrangement_)
for (const auto value : indices(*movement_arrangement_))
append(bytes, value, 2);
return bytes;
}
@@ -194,6 +226,9 @@ std::expected<Genome, GenomeError> Genome::create(const GenomeDraft& draft) {
!valid) {
return std::unexpected{valid.error()};
}
if (!valid_arrangement(draft.schema_version, draft.movement_arrangement)) {
return std::unexpected{GenomeError::parameter_out_of_range};
}
Genome genome;
genome.schema_version_ = draft.schema_version;
genome.id_ = draft.id;
@@ -201,6 +236,7 @@ std::expected<Genome, GenomeError> Genome::create(const GenomeDraft& draft) {
genome.development_version_ = draft.development_version;
genome.parents_ = draft.parents;
genome.capabilities_ = std::move(ordered);
genome.movement_arrangement_ = draft.movement_arrangement;
genome.digest_ = digest_of(genome.body());
return genome;
}
@@ -241,8 +277,9 @@ std::expected<Genome, GenomeError> Genome::decode(std::span<const std::uint8_t>
return std::unexpected{GenomeError::duplicate_capability};
}
// An exact length match rejects trailing bytes rather than ignoring them.
const auto arrangement_bytes = has_arrangement(schema) ? arrangement_size : 0;
const auto expected = counted + static_cast<std::size_t>(record_count) * record_size +
digest_size + checksum_size;
arrangement_bytes + digest_size + checksum_size;
if (bytes.size() != expected) {
return std::unexpected{GenomeError::invalid_encoding};
}
@@ -261,10 +298,21 @@ std::expected<Genome, GenomeError> Genome::decode(std::span<const std::uint8_t>
const auto prerequisites = static_cast<std::uint32_t>(reader.read(4));
capabilities.push_back({static_cast<Capability>(kind), parameter, prerequisites});
}
std::optional<MovementArrangement> arrangement;
if (has_arrangement(schema)) {
std::array<std::uint16_t, arrangement_count> read{};
for (auto& value : read)
value = static_cast<std::uint16_t>(reader.read(2));
arrangement = MovementArrangement{read[0], read[1], read[2], read[3], read[4],
read[5], read[6], read[7], read[8]};
}
if (const auto valid = validate(schema, id, origin, development, parents, capabilities);
!valid) {
return std::unexpected{valid.error()};
}
if (!valid_arrangement(schema, arrangement)) {
return std::unexpected{GenomeError::parameter_out_of_range};
}
Genome genome;
genome.schema_version_ = schema;
genome.id_ = id;
@@ -272,6 +320,7 @@ std::expected<Genome, GenomeError> Genome::decode(std::span<const std::uint8_t>
genome.development_version_ = development;
genome.parents_ = std::move(parents);
genome.capabilities_ = std::move(capabilities);
genome.movement_arrangement_ = arrangement;
// The body must reproduce exactly, so a rewritten record is rejected.
const auto digest = digest_of(genome.body());
if (digest != reader.read(digest_size)) {