Files
aevolution/include/evo/biology/cellular_step.hpp
T
dingoandClaude Opus 5.5 e74bdf286b
Foundation / checks (ecs) (push) Successful in 2m15s
Foundation / checks (deploy) (push) Successful in 3m53s
Foundation / checks (tsan) (push) Successful in 9m46s
Foundation / checks (client) (push) Failing after 13m47s
Foundation / checks (network) (push) Successful in 19m5s
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 19m34s
Foundation / checks (postgres) (push) Canceled after 19m28s
Freeze offline cells, linger, suspend and resume them
M11.7 (ADR-0128): a frozen step intent, set by the server for every owned life
whose account holds no session, leaves the cell unchanged but engulfable. Owner
format 6 / rules 5 track presence: lingering for 200 ticks, then suspended out of
the world without aging; an unfrozen intent resumes it in place or at the nearest
clear spot within three extents. Bundle v6, schema v38 and the cellular-v4
opening carry it. The server refuses an offline account's carried actions, ticks
while anyone lingers, and skips suspended cells in replication and perception.

Also fixes the TSan failure of CI run 374: the rules-4 owner test read the bud
through a reference into a replaced state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 07:50:45 -04:00

60 lines
2.4 KiB
C++

#pragma once
#include "evo/biology/cellular_habitat.hpp"
#include <cstdint>
#include <optional>
namespace evo::biology {
struct CellularStepIntent {
CellularIntent movement{};
std::optional<CellularPatchAddress> intake_target;
// ADR-0124: take one smaller contacted cell after every life's step (rules 3 only).
// Exclusive with an intake target; the server chooses the prey.
bool engulf{};
// ADR-0125: fund and place one wildlife bud after the tick's mutations (rules 4 only).
// Exclusive with an intake target and with engulfment; the owner decides everything.
bool bud{};
// ADR-0128: the owner is offline; the cell does nothing this tick (no maintenance,
// movement, intake or heat) but can still be engulfed. Exclusive with every other field.
bool frozen{};
auto operator<=>(const CellularStepIntent&) const = default;
};
enum class CellularStepError : std::uint8_t {
invalid_tick,
unsupported_rate_period,
insufficient_maintenance,
overflow,
motion
};
enum class CellularIntakeStatus : std::uint8_t { not_requested, acquired, missing, out_of_contact };
enum class CellularMovementStatus : std::uint8_t {
not_requested,
moved,
blocked,
insufficient_reserve
};
// Complete detached candidate for one 50 ms life tick. Maintenance is charged
// first; unaffordable motion leaves the cell stationary, then one targeted patch
// may be absorbed at the resulting position. Publication owns the final swap.
struct CellularStepCandidate {
std::uint64_t begin_tick{}, end_tick{};
CellularPosition position;
accounting::Inventory reserve_after;
accounting::Inventory heat_after;
accounting::Picojoules maintenance_cost{}, movement_cost{};
CellularMovementStatus movement_status{CellularMovementStatus::not_requested};
CellularIntakeStatus intake_status{CellularIntakeStatus::not_requested};
std::optional<CellularPatchUptakeProposal> intake;
auto operator<=>(const CellularStepCandidate&) const = default;
};
[[nodiscard]] std::expected<CellularStepCandidate, CellularStepError>
propose_cellular_step(std::uint64_t begin_tick, CellularArea area, CellularPosition position,
std::uint32_t extent_um, CellularStepIntent intent,
accounting::Inventory reserve, accounting::Inventory heat,
const MetabolicBudget& budget, const CellularHabitat& habitat) noexcept;
} // namespace evo::biology