Cellular rules 8: pools and bubbles fed by contact (ADR-0136 step A)
Foundation / checks (checks) (push) Successful in 47m40s
Foundation / checks (client) (push) Successful in 17m27s
Foundation / checks (deploy) (push) Successful in 4m17s
Foundation / checks (ecs) (push) Successful in 4m31s
Foundation / checks (network) (push) Successful in 22m1s
Foundation / checks (tsan) (push) Successful in 13m10s
Foundation / checks (postgres) (push) Successful in 20m54s
Foundation / image (push) Successful in 4m15s
Foundation / postgres-tools (push) Successful in 5m32s
Foundation / server-image (push) Successful in 7m15s

Square patches invited camping and left the space between them empty. Rules 8 run on a
format-2 habitat of deposits:
- pools and single-nutrient bubbles at free micrometre centres, each with a stable id
  and a contact radius; the cellular-v7 opening scatters bubbles reproducibly from the
  genesis commit (three in ten in loose clumps) and lists pools with --pool;
- every cell drains what it touches, up to its intake rate per tick, with no target; a
  pool gives at most a quarter of that rate; an emptied deposit disappears;
- a dead cell's detritus breaks into one bubble per non-empty channel;
- wildlife swims to the nearest non-empty deposit and feeds by touch.

Bundle v9 (habitat 2) and schema v43 admit it. Session v11 carries the owner's 512
nearest deposits (id, centre, radius, shape, a drained flag and 16-bit amount codes)
instead of patches; every other cellular message is v10's. The client asks for v11,
draws bubbles (nutrient-coloured, pulsing while drained, popping when gone) and pools as
puddles, slows near food and sends no feed target; the HUD summarises food in range.
Earlier rules, regions and v10 clients are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-17 00:38:21 -04:00
co-authored by Claude Opus 5.5
parent 1d9af1d28e
commit be69cae652
35 changed files with 1311 additions and 112 deletions
+58
View File
@@ -1,10 +1,13 @@
#include "evo/network/session_protocol.hpp"
#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <limits>
#include <source_location>
#include <stdexcept>
#include <string>
#include <utility>
namespace {
using namespace evo::network;
@@ -429,6 +432,60 @@ void v10_mutation_offer_is_owner_only_and_canonical() {
}
} // namespace
// ADR-0136 (v11): the owner's view carries pools and bubbles by ascending id, with 16-bit
// amount codes; v10 never carries deposits and v11 never carries square patches.
void v11_perception_carries_deposits() {
CHECK(deposit_amount_code(0) == 0 && deposit_amount_value(0) == 0);
CHECK(deposit_amount_value(deposit_amount_code(1)) == 1);
for (const std::uint64_t value :
{std::uint64_t{7}, std::uint64_t{1'000}, std::uint64_t{123'456'789},
std::uint64_t{5'000'000'000}, std::numeric_limits<std::uint64_t>::max()}) {
const auto back = deposit_amount_value(deposit_amount_code(value));
CHECK(back <= value && value - back <= value / 256); // Within 0.4 %.
CHECK(deposit_amount_code(back) == deposit_amount_code(value));
}
CellularLifeDiagnostics d;
d.reserve_energy_pj = 9;
CellularPerception view{77, 7, {}, d};
view.deposits.push_back({3,
1'500,
2'500,
30,
CellularDepositShape::bubble,
true,
{deposit_amount_code(4'000'000), 0, 0, 0, 0}});
view.deposits.push_back(
{9, 9'000, 400, 1'200, CellularDepositShape::pool, false, {1, 2, 3, 4, 5}});
const auto bytes = encode_session(SessionMessage{view}, session_protocol_v11);
CHECK(bytes.size() == session_header_bytes + 18 + 64 + 40 + std::size_t{2} * 26);
std::uint16_t version{};
const auto decoded = decode_session(bytes, &version);
CHECK(decoded && version == session_protocol_v11 &&
std::get<CellularPerception>(*decoded) == view);
// v10 cannot carry deposits; v11 cannot carry patches.
CHECK(encode_session(SessionMessage{view}, session_protocol_v10).empty());
auto patched = view;
patched.patches.push_back({0, 0, 1, {}});
CHECK(encode_session(SessionMessage{patched}, session_protocol_v11).empty());
// Ids must ascend; a zero id or unknown shape is refused on both sides.
auto unordered = view;
std::swap(unordered.deposits[0], unordered.deposits[1]);
CHECK(encode_session(SessionMessage{unordered}, session_protocol_v11).empty());
auto bad = bytes;
bad[session_header_bytes + 122 + 14] = 7; // First entry's shape.
CHECK(!decode_session(bad));
bad = bytes;
bad[session_header_bytes + 122 + 15] = 2; // First entry's drained flag.
CHECK(!decode_session(bad));
// A cleared view and the other v10 messages are unchanged in v11.
CHECK(decode_session(encode_session(SessionMessage{CellularPerception{78, 0, {}, std::nullopt}},
session_protocol_v11)));
const CellularLifeEnded ended{41, 7, CellularDeathReason::starved};
const auto ended_bytes = encode_session(SessionMessage{ended}, session_protocol_v11);
CHECK(!ended_bytes.empty() &&
std::get<CellularLifeEnded>(*decode_session(ended_bytes)) == ended);
}
int main() {
try {
round_trip_and_version_gate();
@@ -441,6 +498,7 @@ int main() {
v10_mutation_choice_is_a_strict_reliable_action();
v10_mutation_offer_is_owner_only_and_canonical();
v10_effects_and_life_end_are_owner_only();
v11_perception_carries_deposits();
std::puts(
"PASS cellular protocol: v6 intention, v7 action, v8-v10 perception/action framing");
} catch (const std::exception& error) {