Files
dingo 0a8962b57e
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m28s
Foundation / checks (tsan) (push) Failing after 18m22s
Foundation / checks (network) (push) Successful in 20m38s
Foundation / checks (client) (push) Failing after 21m6s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 46m54s
Foundation / checks (checks) (push) Canceled after 47m3s
M12.4: retain and settle owned population intervals
2026-10-17 17:31:05 -04:00

49 lines
2.1 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,
admission
};
struct CellularScheduleStatus {
bool due{};
bool retry_ready{true}; // Also permits servicing a recovered durable interval with zero debt.
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.
// On a new anchor, previously_admitted_ticks excludes a recovered durable prefix
// from fresh wall-time accounting. It is bounded to 64 and cannot wrap the head.
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, std::uint64_t previously_admitted_ticks = 0);
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