M11.1: genome schema 2 with per-second rates (ADR-0099, segment 2)
Foundation / checks (deploy) (push) Successful in 3m32s
Foundation / checks (ecs) (push) Successful in 1m56s
Foundation / checks (client) (push) Successful in 12m56s
Foundation / checks (network) (push) Successful in 13m46s
Foundation / checks (tsan) (push) Successful in 7m59s
Foundation / checks (checks) (push) Successful in 33m36s
Foundation / checks (postgres) (push) Successful in 45m30s
Foundation / postgres-tools (push) Successful in 20s
Foundation / server-image (push) Successful in 25s
Foundation / image (push) Successful in 2m36s

Movement and ingestion are stored per second in schema 2 (ranges x20). Schema 1 records
stay valid, are never rewritten, and read as exactly x20 via Genome::per_second; drafts
default to schema 1 so existing literals keep their meaning. Development version 1
converts genome rates at its own 50 ms quantum (round down), so phenotypes are
unchanged. Mutation keeps the parent's schema and step; the lineage archive header names
exactly the highest schema held (all-schema-1 archives keep their bytes); the
development-v1 opening names schema 1. No golden changed; two tests that used 2 as an
unknown schema now use the next one. Refresh the dev session window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-09 13:16:55 -04:00
co-authored by Claude Opus 5.5
parent a4c6181540
commit 17fe23e5f0
17 changed files with 385 additions and 56 deletions
+68 -21
View File
@@ -115,30 +115,38 @@ void capability_and_range_rules() {
draft = founder();
draft.capabilities.push_back({Capability::thermal_tolerance, 1, 1U << capability_count});
reject(draft, GenomeError::unknown_capability);
// Every boundary of every declared range, from both sides.
for (std::size_t index = 0; index < capability_count; ++index) {
const auto kind = static_cast<Capability>(index);
const auto& limits = capability_schema[index];
for (const auto value : {limits.minimum, limits.maximum}) {
draft = founder();
// Every boundary of every declared range, from both sides, in each schema's own table.
for (const auto schema : {genome_schema_v1, genome_schema_version}) {
const auto& table = *capability_schema_for(schema);
const auto fresh = [&] {
auto d = founder();
d.schema_version = schema;
return d;
};
for (std::size_t index = 0; index < capability_count; ++index) {
const auto kind = static_cast<Capability>(index);
const auto& limits = table[index];
for (const auto value : {limits.minimum, limits.maximum}) {
draft = fresh();
std::erase_if(draft.capabilities,
[kind](const auto& record) { return record.kind == kind; });
draft.capabilities.push_back({kind, value, limits.mandates});
const auto accepted = Genome::create(draft);
CHECK(accepted && *accepted->parameter(kind) == value);
}
if (limits.minimum > 0) {
draft = fresh();
std::erase_if(draft.capabilities,
[kind](const auto& record) { return record.kind == kind; });
draft.capabilities.push_back({kind, limits.minimum - 1, limits.mandates});
reject(draft, GenomeError::parameter_out_of_range);
}
draft = fresh();
std::erase_if(draft.capabilities,
[kind](const auto& record) { return record.kind == kind; });
draft.capabilities.push_back({kind, value, limits.mandates});
const auto accepted = Genome::create(draft);
CHECK(accepted && *accepted->parameter(kind) == value);
}
if (limits.minimum > 0) {
draft = founder();
std::erase_if(draft.capabilities,
[kind](const auto& record) { return record.kind == kind; });
draft.capabilities.push_back({kind, limits.minimum - 1, limits.mandates});
draft.capabilities.push_back({kind, limits.maximum + 1, limits.mandates});
reject(draft, GenomeError::parameter_out_of_range);
}
draft = founder();
std::erase_if(draft.capabilities,
[kind](const auto& record) { return record.kind == kind; });
draft.capabilities.push_back({kind, limits.maximum + 1, limits.mandates});
reject(draft, GenomeError::parameter_out_of_range);
}
}
@@ -245,7 +253,7 @@ void encoded_record_rules() {
CHECK(!tampered && tampered.error() == GenomeError::digest_mismatch);
// An unsupported schema version fails closed before anything else is read.
auto future = bytes;
future[8] = 2;
future[8] = static_cast<std::uint8_t>(genome_schema_version + 1);
reseal(future);
const auto ahead = Genome::decode(future);
CHECK(!ahead && ahead.error() == GenomeError::unsupported_version);
@@ -313,6 +321,44 @@ void frozen_record_compatibility() {
CHECK(*restored == *genome);
}
// Schema 2 (ADR-0099): rates per second. Schema 1 records stay valid, unrewritten, and
// read as exactly twenty times their per-tick values.
void schema_v2_rates() {
auto v1 = founder();
v1.capabilities.push_back({Capability::movement, 5'000, 0});
v1.capabilities.push_back({Capability::ingestion, 1'000'000, 0}); // Schema 1 maximum.
const auto old = Genome::create(v1);
CHECK(old && old->schema_version() == genome_schema_v1);
CHECK(old->per_second(Capability::movement) == std::uint64_t{100'000});
CHECK(old->per_second(Capability::ingestion) == std::uint64_t{20'000'000});
CHECK(old->per_second(Capability::target_size) == std::uint64_t{5'000}); // Not a rate.
CHECK(!old->per_second(Capability::thermal_tolerance));
auto v2 = v1;
v2.schema_version = genome_schema_version;
v2.capabilities[3].parameter = 100'000; // Movement, per second.
v2.capabilities[4].parameter = 20'000'000;
const auto now = Genome::create(v2);
CHECK(now && now->schema_version() == 2);
CHECK(now->per_second(Capability::movement) == old->per_second(Capability::movement));
CHECK(now->per_second(Capability::ingestion) == old->per_second(Capability::ingestion));
// The same meaning in another schema is another record.
CHECK(now->content_digest() != old->content_digest());
const auto restored = Genome::decode(now->encode());
CHECK(restored && *restored == *now && restored->schema_version() == 2);
// Ranges are per schema: a schema 2 rate may exceed schema 1's per-tick maximum.
v2.capabilities[4].parameter = 20'000'001;
reject(v2, GenomeError::parameter_out_of_range);
v1.capabilities[4].parameter = 1'000'001;
reject(v1, GenomeError::parameter_out_of_range);
auto unknown = founder();
unknown.schema_version = 3;
reject(unknown, GenomeError::unsupported_version);
auto bytes = Genome::create(founder())->encode();
bytes[8] = 3; // Schema field; decode refuses before the checksum matters.
CHECK(!Genome::decode(bytes) &&
Genome::decode(bytes).error() == GenomeError::unsupported_version);
}
void moves_preserve_validity() {
const auto original = Genome::create(founder());
const auto other = Genome::create(descendant());
@@ -349,6 +395,7 @@ int main() try {
canonical_encoding();
encoded_record_rules();
frozen_record_compatibility();
schema_v2_rates();
moves_preserve_validity();
std::cout << "PASS genome schema, ancestry, development graph and canonical encoding\n";
return 0;