Bind cellular actions to replay traces
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 38s
Foundation / checks (ecs) (push) Successful in 1m56s
Foundation / checks (postgres) (push) Failing after 52s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (network) (push) Canceled after 2m28s
Foundation / checks (tsan) (push) Canceled after 9s
Foundation / checks (client) (push) Canceled after 3m8s

This commit is contained in:
dingo
2026-10-10 23:18:32 -04:00
parent 2133e5086e
commit d057e5ba04
5 changed files with 168 additions and 0 deletions
@@ -28,6 +28,12 @@ struct CellularBatch {
std::vector<CellularTickIntents> ticks;
friend bool operator==(const CellularBatch&, const CellularBatch&) = default;
};
struct CellularActionRecord {
std::array<std::uint8_t, 16> account{};
std::uint64_t action_id{};
std::array<std::uint8_t, 24> input{};
friend bool operator==(const CellularActionRecord&, const CellularActionRecord&) = default;
};
inline constexpr std::uint32_t cellular_batch_format = 1;
inline constexpr std::size_t cellular_batch_header_bytes = 112;
@@ -38,6 +44,9 @@ inline constexpr std::size_t max_cellular_batch_bytes = cellular_batch_header_by
max_cellular_batch_ticks * (cellular_batch_tick_header_bytes +
biology::max_cellular_tick_lives * cellular_batch_intent_bytes);
enum class CellularBatchError : std::uint8_t { format, version, scope, state };
inline constexpr std::size_t cellular_action_record_bytes = 48;
inline constexpr std::size_t max_cellular_action_records = 1'024;
enum class CellularActionBlockError : std::uint8_t { format, mismatch };
// Canonical replay input: one bounded, life-ID-ordered intention set per tick.
[[nodiscard]] std::expected<std::vector<std::uint8_t>, CellularBatchError>
@@ -49,4 +58,15 @@ decode_cellular_batch(std::span<const std::uint8_t> bytes);
// Every tick must cover its living set; the caller compares the returned snapshot.
[[nodiscard]] std::expected<std::unique_ptr<CellularLives>, CellularBatchError>
replay_cellular_batch(const CellularLives& base, const CellularBatch& batch);
[[nodiscard]] std::expected<std::vector<std::uint8_t>, CellularActionBlockError>
encode_cellular_action_block(std::span<const CellularActionRecord> actions,
std::uint64_t begin_tick, std::uint64_t end_tick);
[[nodiscard]] std::expected<std::vector<CellularActionRecord>, CellularActionBlockError>
decode_cellular_action_block(std::span<const std::uint8_t> bytes, std::uint64_t begin_tick,
std::uint64_t end_tick);
// Every durable action must match the canonical input for that account's life
// in the corresponding replay tick. An action cannot create a life or intent.
[[nodiscard]] std::expected<void, CellularActionBlockError>
match_cellular_actions_to_trace(const CellularLives& predecessor, const CellularBatch& batch,
std::span<const CellularActionRecord> actions);
} // namespace evo::server