Files
aevolution/include/evo/server/lifecycle/cellular_schedule.hpp
T
dingo aff35863ce
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m35s
Foundation / checks (tsan) (push) Failing after 17m51s
Foundation / checks (network) (push) Successful in 21m13s
Foundation / checks (client) (push) Successful in 22m19s
Foundation / checks (postgres) (push) Successful in 48m25s
Foundation / checks (checks) (push) Failing after 50m8s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
M12.4: keep cellular wildlife ticking and retain scheduling debt
2026-10-17 12:24:19 -04:00

41 lines
1.8 KiB
C++

#pragma once
#include "evo/server/lifecycle/cellular_lives.hpp"
#include <cstdint>
#include <expected>
namespace evo::server {
// Unowned descendants progress without sessions. Owned active/lingering cells
// need ticks to enter/finish suspension; suspended cells alone need none.
// Historical profiles without offline freeze are not opted into unattended work.
[[nodiscard]] bool cellular_unattended_tick_needed(const CellularLives& state) noexcept;
enum class CellularScheduleError : std::uint8_t { clock_regression, head_regression, authority };
struct CellularScheduleStatus {
bool due{};
std::uint64_t debt{}, max_debt{};
std::uint64_t head_age_us{}; // Since the last confirmed head change/recovery.
};
// Pure local pacing, not an authority or durable admission queue. The caller
// supplies monotonic microseconds and only the CONFIRMED head. One due tick may
// be attempted per poll. Rejected work does not consume debt. Authority loss,
// restart or absence of tick demand pauses wall-time (ADR-0133); committed
// intervals and uncertain outcomes remain the fenced host's responsibility.
class CellularTickSchedule {
public:
[[nodiscard]] std::expected<CellularScheduleStatus, CellularScheduleError>
observe(std::uint64_t now_us, std::uint64_t epoch, std::uint64_t committed_tick, bool needed,
bool authoritative);
void defer(std::uint64_t now_us) noexcept;
[[nodiscard]] CellularScheduleStatus status() const noexcept;
private:
bool observed_{}, anchored_{};
bool have_receipt_{}, was_authoritative_{};
std::uint64_t last_us_{}, origin_us_{}, origin_tick_{}, head_{}, epoch_{}, retry_us_{};
std::uint64_t receipt_us_{}, receipt_tick_{}, receipt_epoch_{};
CellularScheduleStatus status_;
};
} // namespace evo::server