feat(admin): session windows in SQL, opened from the admin portal (schema 62)
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m33s
Foundation / postgres-tools (push) Successful in 2m14s
Foundation / server-image (push) Successful in 5m21s
Foundation / image (push) Successful in 6m18s

The dev session window moves from Git to SQL (ADR-0087 amendment): the admin
portal opens, extends (30 min to 4 h from now) and closes it, and the cellular
region re-reads it every 5 s with --session-window-source db. No push, sync or
restart per window; a closed window keeps the region running instead of
crash-looping.

- Schema 62: append-only session_windows (4 h cap, no rewrites),
  load_session_window_v1 for the runtime group, admin_set_session_window_v1
  and admin_session_windows_v1 for a dedicated admin group role, granted and
  audited each migration run when EVO_PG_ADMIN_ROLE is set (aevolution_admin in
  DEV). Schema 61's views are revoked from the runtime group.
- RegionSessions admission switch: while closed every Hello is refused before
  signature work and closing closes open sessions (new sessions were still
  admitted after expiry before).
- Admin API: GET/POST /api/regions/<n>/session-window, window state in the
  regions list; the portal's session-window card with history.
- Git: REGION_SESSION_WINDOW and the pre-push refresh rule are removed; the
  policy check requires the database source and refuses a committed window.

Needs the new image and the aevolution_admin role (with the portal's login in
aevolution-admin-pg) before a sync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-27 15:13:02 -04:00
co-authored by Claude Opus 5.5
parent 510ecaee80
commit 46c106409e
31 changed files with 807 additions and 93 deletions
+28
View File
@@ -1,5 +1,6 @@
#include "evo/server/session_window.hpp"
#include <cstdio>
#include <optional>
#include <string>
using evo::server::SessionWindow;
@@ -52,5 +53,32 @@ int main() {
CHECK(close.has_value());
close->close();
CHECK(!close->accepting(1'001));
// ADR-0087 amendment: the database feed. No record keeps sessions closed.
using Feed = evo::server::SessionWindowFeed;
using Change = Feed::Change;
Feed feed;
CHECK(feed.observe(std::nullopt, now) == Change::none && !feed.accepting(now));
CHECK(feed.observe(Feed::Record{"adm-1", 1'200}, now) == Change::opened);
const auto& admitted = feed.window();
CHECK(feed.accepting(1'100) && admitted && admitted->deadline_seconds() == 1'200);
// Re-reading the same record changes nothing; a newer activation extends.
CHECK(feed.observe(Feed::Record{"adm-1", 1'200}, 1'150) == Change::none);
CHECK(feed.observe(Feed::Record{"adm-2", 5'000}, 1'150) == Change::opened);
CHECK(feed.accepting(1'250) && admitted && admitted->activation_id() == "adm-2");
// Its own deadline still closes it, and the same record cannot reopen it.
CHECK(!feed.accepting(5'000));
CHECK(feed.observe(Feed::Record{"adm-2", 5'000}, 4'000) == Change::none);
CHECK(!feed.accepting(4'001));
// A closing record closes; an expired or over-long newer one is refused and stays closed.
CHECK(feed.observe(Feed::Record{"adm-3", 9'000}, 6'000) == Change::opened);
CHECK(feed.observe(Feed::Record{"adm-4", std::nullopt}, 6'001) == Change::closed);
CHECK(!feed.accepting(6'002));
CHECK(feed.observe(Feed::Record{"adm-5", 6'000}, 6'010) == Change::refused);
CHECK(feed.observe(Feed::Record{"adm-6", 6'010 + 14'401}, 6'010) == Change::refused);
CHECK(!feed.accepting(6'011));
// A record that disappears (a restored database) closes the window.
CHECK(feed.observe(Feed::Record{"adm-7", 7'000}, 6'100) == Change::opened);
CHECK(feed.observe(std::nullopt, 6'101) == Change::closed && !feed.accepting(6'102));
return 0;
}