diff --git a/docs/adr/0087-dev-session-route.md b/docs/adr/0087-dev-session-route.md index 6277d18..d9a2924 100644 --- a/docs/adr/0087-dev-session-route.md +++ b/docs/adr/0087-dev-session-route.md @@ -45,11 +45,13 @@ mandatory; grants remain bearer tokens. session port. The listener still starts only when sessions are enabled. **Windows.** Sessions and synthetic inputs run only during an operator-opened test window -with automatic expiry (default 30 minutes); always-on simulation waits for an explicit -disposable-world lifecycle and retention. The endpoint (DNS, MetalLB Service) may stay -configured permanently. A small dev-only GitOps configuration holds an activation id, +with automatic expiry. The maintainer decision on 2026-10-05 sets four hours as both the +operator workflow's default and the server's maximum accepted duration; always-on +simulation waits for an explicit disposable-world lifecycle and retention. The endpoint +(DNS, MetalLB Service) may stay configured permanently. A small dev-only GitOps +configuration holds an activation id, the exact world/region identity and an absolute UTC expiry. Operations, via a manually -triggered Gitea workflow: Open (default 30 min), Extend (new explicit expiry), Close +triggered Gitea workflow: Open (default four hours), Extend (new explicit expiry), Close (stop accepting sessions, close existing connections, stop synthetic inputs, drain pending commits) and Status (window, expiry, active sessions, committed tick). Expiry is enforced **inside evo-server**, not by a delayed cleanup job: @@ -92,8 +94,7 @@ pending until applied, with an absolute expiry that delayed sync never shifts (C also needs propagation; the server deadline is the upper bound); keep the existing void HTTP endpoint unless explicitly retired, possibly choosing a dedicated session hostname instead (DNS cannot select by TCP port), before issuing the certificate; confirm the -actual MetalLB pool and client addresses; set the maximum window length and clock -handling before implementing windows. +actual MetalLB pool and client addresses; clock-skew handling remains open. - **Argo delivery.** The aevolution-dev Application has no automated sync, and the policy forbids auto-sync outside the platform app (ADR-0069). A workflow commit alone @@ -103,7 +104,7 @@ handling before implementing windows. - **void namespace.** void.aeternalisgames.com already has an HTTP Ingress (namespace `void`). Pointing internal DNS at the VIP changes what internal clients reach for that name; confirm or retire the existing route. -- Window limits: maximum window length and clock-skew tolerance. +- Clock skew: the four-hour maximum is decided; define the permitted clock-skew tolerance. ## Alternatives considered - ingress-nginx tcp-services or SNI passthrough on 443: couples game sessions to the diff --git a/include/evo/server/session_window.hpp b/include/evo/server/session_window.hpp index d60217d..8e25c1d 100644 --- a/include/evo/server/session_window.hpp +++ b/include/evo/server/session_window.hpp @@ -15,7 +15,7 @@ namespace evo::server { class SessionWindow { public: enum class Error : std::uint8_t { malformed, expired, too_long }; - static constexpr std::uint64_t max_duration_seconds = std::uint64_t{30} * 60; + static constexpr std::uint64_t max_duration_seconds = std::uint64_t{4} * 60 * 60; static std::expected open(std::string_view specification, std::uint64_t now_seconds) { diff --git a/tests/session_window_tests.cpp b/tests/session_window_tests.cpp index f52e60a..b13406c 100644 --- a/tests/session_window_tests.cpp +++ b/tests/session_window_tests.cpp @@ -1,42 +1,56 @@ #include "evo/server/session_window.hpp" -#include +#include #include using evo::server::SessionWindow; +#define CHECK(...) \ + do { \ + if (!(__VA_ARGS__)) { \ + std::fprintf(stderr, "CHECK failed: %s at line %d\n", #__VA_ARGS__, __LINE__); \ + return 1; \ + } \ + } while (false) + int main() { constexpr std::uint64_t now = 1'000; + static_assert(SessionWindow::max_duration_seconds == 4 * 60 * 60); auto opened = SessionWindow::open("dev-42:1200", now); - assert(opened.has_value()); - assert(opened->activation_id() == "dev-42"); - assert(opened->deadline_seconds() == 1200); - assert(opened->accepting(1'199)); - assert(!opened->accepting(1'200)); - assert(opened->closed()); + CHECK(opened.has_value()); + CHECK(opened->activation_id() == "dev-42"); + CHECK(opened->deadline_seconds() == 1200); + CHECK(opened->accepting(1'199)); + CHECK(!opened->accepting(1'200)); + CHECK(opened->closed()); // A restart re-reads the same absolute deadline; it does not get a new duration. auto restarted = SessionWindow::open("dev-42:1200", 1'100); - assert(restarted.has_value()); - assert(restarted->deadline_seconds() == 1200); - assert(!SessionWindow::open("dev-42:1200", 1'200).has_value()); - assert(!SessionWindow::open("dev-42:1200", 1'201).has_value()); + CHECK(restarted.has_value()); + CHECK(restarted->deadline_seconds() == 1200); + CHECK(!SessionWindow::open("dev-42:1200", 1'200).has_value()); + CHECK(!SessionWindow::open("dev-42:1200", 1'201).has_value()); // Delayed application and clock movement cannot extend an expired window. - assert(!SessionWindow::open("dev-43:1200", 1'300).has_value()); - assert(restarted->accepting(1'150)); - assert(restarted->accepting(1'050)); - assert(!restarted->accepting(1'200)); + CHECK(!SessionWindow::open("dev-43:1200", 1'300).has_value()); + CHECK(restarted->accepting(1'150)); + CHECK(restarted->accepting(1'050)); + CHECK(!restarted->accepting(1'200)); - // Invalid activation/deadline forms and excessive windows fail closed. - assert(!SessionWindow::open(":1200", now).has_value()); - assert(!SessionWindow::open("dev space:1200", now).has_value()); - assert(!SessionWindow::open("dev-44:not-a-number", now).has_value()); - assert(!SessionWindow::open("dev-45:3001", now).has_value()); + // Invalid activation/deadline forms and windows over four hours fail closed. + CHECK(!SessionWindow::open(":1200", now).has_value()); + CHECK(!SessionWindow::open("dev space:1200", now).has_value()); + CHECK(!SessionWindow::open("dev-44:not-a-number", now).has_value()); + const auto maximum_deadline = now + SessionWindow::max_duration_seconds; + const auto maximum_window = + SessionWindow::open("dev-45:" + std::to_string(maximum_deadline), now); + CHECK(maximum_window.has_value()); + CHECK(maximum_window->deadline_seconds() == maximum_deadline); + CHECK(!SessionWindow::open("dev-46:" + std::to_string(maximum_deadline + 1), now).has_value()); - auto close = SessionWindow::open("dev-46:1200", now); - assert(close.has_value()); + auto close = SessionWindow::open("dev-47:1200", now); + CHECK(close.has_value()); close->close(); - assert(!close->accepting(1'001)); + CHECK(!close->accepting(1'001)); return 0; }