feat(ecology): make photosynthesis regions playable on DEV
Foundation / checks (ecs) (push) Successful in 2m19s
Foundation / checks (deploy) (push) Successful in 4m47s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 16m48s
Foundation / checks (network) (push) Canceled after 16m46s
Foundation / checks (postgres) (push) Canceled after 16m47s
Foundation / checks (client) (push) Canceled after 16m53s
Foundation / checks (tsan) (push) Canceled after 14m33s
Foundation / checks (ecs) (push) Successful in 2m19s
Foundation / checks (deploy) (push) Successful in 4m47s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 16m48s
Foundation / checks (network) (push) Canceled after 16m46s
Foundation / checks (postgres) (push) Canceled after 16m47s
Foundation / checks (client) (push) Canceled after 16m53s
Foundation / checks (tsan) (push) Canceled after 14m33s
ADR-0176 and schema 57 admit raw cellular bundle 13 (rules 11 on owner format 9) through parser-local normalization to bundle 12, and a fenced no-tick 12 -> 13 upgrade that declares the region's light; recovery reads the light from the target and re-derives the whole target from the source. The resumable cellular-v8 opening provisions a cellular-v7 genesis, one empty tick and the durable upgrades to bundle 13. Session v12 adds the owner's captured light and the producers it can see to its perception, and lets offers name photosynthesis; older sessions keep their layouts and never receive photosynthesis candidates. The client draws chloroplasts by efficiency, shows sunlight in the HUD and offers photosynthesis cards. DEV now provisions and serves region 9 with the trial light; region 8 stays stored but unserved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -486,6 +486,62 @@ void v11_perception_carries_deposits() {
|
||||
std::get<CellularLifeEnded>(*decode_session(ended_bytes)) == ended);
|
||||
}
|
||||
|
||||
// ADR-0176: v12 is v11 plus captured light and visible producers in the owner's view, and
|
||||
// capability 7 (photosynthesis) in offers. Earlier versions refuse both.
|
||||
void v12_perception_carries_light_and_producers() {
|
||||
CellularLifeDiagnostics d;
|
||||
d.reserve_energy_pj = 9;
|
||||
d.light_pj = 1'600;
|
||||
CellularPerception view{77, 7, {}, d};
|
||||
view.deposits.push_back(
|
||||
{9, 9'000, 400, 1'200, CellularDepositShape::pool, false, {1, 2, 3, 4, 5}});
|
||||
view.producers.push_back({5, 100});
|
||||
view.producers.push_back({41, 1'000});
|
||||
const auto bytes = encode_session(SessionMessage{view}, session_protocol_v12);
|
||||
CHECK(bytes.size() == session_header_bytes + 18 + 64 + 40 + 16 + 26 + std::size_t{2} * 16);
|
||||
std::uint16_t version{};
|
||||
const auto decoded = decode_session(bytes, &version);
|
||||
CHECK(decoded && version == session_protocol_v12 &&
|
||||
std::get<CellularPerception>(*decoded) == view);
|
||||
// v11 has room for neither light nor producers.
|
||||
CHECK(encode_session(SessionMessage{view}, session_protocol_v11).empty());
|
||||
auto plain = view;
|
||||
plain.producers.clear();
|
||||
plain.diagnostics->light_pj = 0;
|
||||
CHECK(!encode_session(SessionMessage{plain}, session_protocol_v11).empty());
|
||||
CHECK(std::get<CellularPerception>(*decode_session(
|
||||
encode_session(SessionMessage{plain}, session_protocol_v12))) == plain);
|
||||
// Producers ascend by organism with an efficiency in 1..1000; reserved bytes are zero.
|
||||
auto unordered = view;
|
||||
std::swap(unordered.producers[0], unordered.producers[1]);
|
||||
CHECK(encode_session(SessionMessage{unordered}, session_protocol_v12).empty());
|
||||
auto excessive = view;
|
||||
excessive.producers[1].photosynthesis_per_thousand = 1'001;
|
||||
CHECK(encode_session(SessionMessage{excessive}, session_protocol_v12).empty());
|
||||
auto bad = bytes;
|
||||
bad[bytes.size() - 1] = 1; // Last producer's reserved byte.
|
||||
CHECK(!decode_session(bad));
|
||||
bad = bytes;
|
||||
bad[bytes.size() - 7] = 0xFF; // Last producer's efficiency high byte.
|
||||
CHECK(!decode_session(bad));
|
||||
// A cleared view carries no producers.
|
||||
CHECK(decode_session(encode_session(SessionMessage{CellularPerception{78, 0, {}, std::nullopt}},
|
||||
session_protocol_v12)));
|
||||
// Offers name photosynthesis only from v12.
|
||||
CellularMutationOffer offer{90, 7, 3, 80, {}};
|
||||
CellularOfferedCandidate candidate{};
|
||||
candidate.operator_id = 31;
|
||||
candidate.capability = 7;
|
||||
candidate.effect = 2;
|
||||
candidate.parameter = 100;
|
||||
offer.candidates.push_back(candidate);
|
||||
const auto offered = encode_session(SessionMessage{offer}, session_protocol_v12);
|
||||
CHECK(!offered.empty() && std::get<CellularMutationOffer>(*decode_session(offered)) == offer);
|
||||
CHECK(encode_session(SessionMessage{offer}, session_protocol_v11).empty());
|
||||
offer.candidates[0].capability = 8;
|
||||
CHECK(encode_session(SessionMessage{offer}, session_protocol_v12).empty());
|
||||
}
|
||||
|
||||
int main() {
|
||||
try {
|
||||
round_trip_and_version_gate();
|
||||
@@ -499,6 +555,7 @@ int main() {
|
||||
v10_mutation_offer_is_owner_only_and_canonical();
|
||||
v10_effects_and_life_end_are_owner_only();
|
||||
v11_perception_carries_deposits();
|
||||
v12_perception_carries_light_and_producers();
|
||||
std::puts(
|
||||
"PASS cellular protocol: v6 intention, v7 action, v8-v10 perception/action framing");
|
||||
} catch (const std::exception& error) {
|
||||
|
||||
Reference in New Issue
Block a user