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

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:
dingo
2026-10-19 23:04:34 -04:00
co-authored by Claude Opus 5.5
parent 108f29eda5
commit b73ccbae9a
38 changed files with 1106 additions and 140 deletions
+28 -3
View File
@@ -38,12 +38,26 @@ inline constexpr std::uint16_t session_protocol_v10 = 10;
// v11 (ADR-0136 step A) is v10 with the owner's view of pools and bubbles (deposits)
// instead of square patches; every other message is v10's.
inline constexpr std::uint16_t session_protocol_v11 = 11;
// v10 and v11 share every cellular message but the perception's food list.
// v12 (ADR-0176) is v11 plus the owner's captured light and visible producers in its
// perception, and the photosynthesis capability (7) in mutation offers.
inline constexpr std::uint16_t session_protocol_v12 = 12;
// v10, v11 and v12 share every cellular message but the perception's contents.
[[nodiscard]] constexpr bool cellular_v10_family(std::uint16_t version) noexcept {
return version == session_protocol_v10 || version == session_protocol_v11;
return version == session_protocol_v10 || version == session_protocol_v11 ||
version == session_protocol_v12;
}
// Versions whose perception lists pools and bubbles (ADR-0136) instead of square patches.
[[nodiscard]] constexpr bool cellular_deposit_version(std::uint16_t version) noexcept {
return version == session_protocol_v11 || version == session_protocol_v12;
}
// The highest capability a version's mutation offers may name.
[[nodiscard]] constexpr std::uint8_t
cellular_offer_capability_limit(std::uint16_t version) noexcept {
return version == session_protocol_v12 ? 7 : 6;
}
inline constexpr std::size_t max_cellular_perceived_patches = 256;
inline constexpr std::size_t max_cellular_perceived_deposits = 512;
inline constexpr std::size_t max_cellular_perceived_producers = 256;
inline constexpr std::size_t session_address_bytes = 64; // Endpoint or server name field.
inline constexpr std::size_t session_datagram_bytes = 1200; // Whole message, ADR-0089.
inline constexpr std::size_t session_header_bytes = 8;
@@ -230,7 +244,7 @@ struct CellularMutationOffer {
std::vector<CellularOfferedCandidate> candidates;
friend bool operator==(const CellularMutationOffer&, const CellularMutationOffer&) = default;
};
// v10 (ADR-0129): the owner's life ended in ick. Cause 1 starved, 2 engulfed, 0 not
// v10 (ADR-0129): the owner's life ended in `tick`. Cause 1 starved, 2 engulfed, 0 not
// recorded (rules below 3). Death is final; a new life is a new request.
enum class CellularDeathReason : std::uint8_t { unrecorded, starved, engulfed };
struct CellularLifeEnded {
@@ -324,9 +338,18 @@ struct CellularLifeDiagnostics {
// when this cell's genome cannot bud. Independent of tick effects.
std::uint64_t bud_cost_energy_pj{};
std::array<std::uint64_t, 4> bud_cost_matter_fg{};
std::uint64_t light_pj{}; // v12 only (ADR-0176): light this cell captured last tick.
friend bool operator==(const CellularLifeDiagnostics&,
const CellularLifeDiagnostics&) = default;
};
// v12 (ADR-0176): a visible cell that carries photosynthesis, by organism, and its
// efficiency per thousand, so a client can draw its organelles.
struct CellularPerceivedProducer {
std::uint64_t organism{};
std::uint16_t photosynthesis_per_thousand{};
friend bool operator==(const CellularPerceivedProducer&,
const CellularPerceivedProducer&) = default;
};
struct CellularPerception {
std::uint64_t tick{}, life_identity{}; // zero life plus no patches clears the view.
std::vector<CellularPerceivedPatch> patches; // strictly ordered by (x_um, y_um).
@@ -335,6 +358,8 @@ struct CellularPerception {
std::optional<CellularLifeDiagnostics> diagnostics;
// v11 only (then `patches` is empty): pools and bubbles in range, by ascending id.
std::vector<CellularPerceivedDeposit> deposits{};
// v12 only: visible producers by ascending organism.
std::vector<CellularPerceivedProducer> producers{};
friend bool operator==(const CellularPerception&, const CellularPerception&) = default;
};
struct IntentionReceipt {