Files
aevolution/include/evo/server/postgres_control_ledger.hpp
T
dingoandClaude Opus 5.5 0bf9901c7f
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m46s
Foundation / checks (postgres) (push) Canceled after 0s
Foundation / checks (tsan) (push) Canceled after 0s
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 3m44s
Foundation / checks (client) (push) Canceled after 3m49s
Foundation / checks (network) (push) Canceled after 1m59s
Add M10.4c evo-server QUIC listener and headless session client
evo-server gains an opt-in M10 listener (--m10-*, QUIC builds only): RegionSessions
with the PostgreSQL control and action ledgers on their own connection under the
host's lease, carried actions submitted to the host and its acknowledgements and
drops turned into outcomes. evo-session-probe is a dev-only headless client. Real
process tests cover intentions, durable action outcomes, SIGKILL before and after
an action's commit, duplicate retries and the probe. The simulated watermark now
reaches every session every tick, so clients always know the server tick.
ADR-0092.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 09:20:55 -04:00

36 lines
1.8 KiB
C++

#pragma once
#include "evo/network/session_control.hpp"
#include "evo/persistence/account_control_store.hpp"
#include "evo/server/pg_slot.hpp"
#include <chrono>
#include <functional>
#include <optional>
#include <utility>
// M10.3c durable account control over the region's PostgreSQL lease (ADR-0091, schema v10).
// Linux only. Owned by the region host's thread, on its own connection slot. `lease`
// returns the host's current region lease, or nothing while it holds none (every call then
// reports `fenced`). Store failures that may have executed or are undecided report
// `unavailable`; the session layer then keeps or closes sessions by its own deadlines.
namespace evo::server {
class PostgresControlLedger final : public network::ControlLedger {
public:
using LeaseSource = std::function<std::optional<persistence::LeaseGrant>()>;
PostgresControlLedger(PgSlot& db, persistence::RegionKey key, LeaseSource lease,
std::chrono::milliseconds duration = std::chrono::milliseconds{20000},
std::chrono::milliseconds timeout = std::chrono::milliseconds{2000})
: db_{&db}, key_{key}, lease_{std::move(lease)}, duration_{duration}, timeout_{timeout} {}
[[nodiscard]] std::expected<network::ControlLease, network::ControlLedgerError>
claim(const network::AccountId& account, std::uint64_t serial, std::uint64_t session) override;
[[nodiscard]] std::expected<std::chrono::milliseconds, network::ControlLedgerError>
renew(const network::AccountId& account, std::uint64_t generation) override;
void release(const network::AccountId& account, std::uint64_t generation) override;
private:
PgSlot* db_;
persistence::RegionKey key_;
LeaseSource lease_;
std::chrono::milliseconds duration_, timeout_;
};
} // namespace evo::server