Fix M9.4-M9.7 review findings in the dev session stack
- TLS: replace send() with a bounded queue/flush; an interrupted record is retried with identical arguments and later frames wait behind it, so no queued frame is lost or reordered; close() flushes first. - Carriers: server-issued 'I','N' | 48-bit epoch | 64-bit ordinal ids replace the aliasing low-32-bit packing; client sequences are kept separately for replies; out-of-range epochs are refused, never truncated. - Grants: a durable, fsynced, fail-closed consumed-grant ledger (--session-grant-ledger, /objects/dev-session-grants.v1 in dev) keeps single-use grants consumed across process and pod restarts. - Liveness: protocol v1 (undeployed) gains Heartbeat and the timeout close reason; both sides heartbeat when idle and treat 5 s of silence as dead. - Client sends are bounded and unresolved tracking starts at send time. - ci-client configures with an explicit C compiler. Each finding has a regression test; ADR-0083, the schema, operations doc and VALIDATION record the corrections. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,14 +22,14 @@
|
||||
|
||||
namespace evo::server_app {
|
||||
struct SessionOptions {
|
||||
std::string listen, certificate, key, grant_key, environment;
|
||||
std::string listen, certificate, key, grant_key, grant_ledger, environment;
|
||||
[[nodiscard]] bool any() const noexcept {
|
||||
return !listen.empty() || !certificate.empty() || !key.empty() || !grant_key.empty() ||
|
||||
!environment.empty();
|
||||
!grant_ledger.empty() || !environment.empty();
|
||||
}
|
||||
[[nodiscard]] bool complete() const noexcept {
|
||||
return !listen.empty() && !certificate.empty() && !key.empty() && !grant_key.empty() &&
|
||||
!environment.empty();
|
||||
!grant_ledger.empty() && !environment.empty();
|
||||
}
|
||||
};
|
||||
// Intentions ride synthetic inputs, so sessions keep the driver's lookahead short.
|
||||
@@ -65,11 +65,15 @@ class SessionBridge {
|
||||
config.admission.intent_window = session_lookahead_ticks;
|
||||
config.admission.window_ticks = session_lookahead_ticks;
|
||||
config.admission.max_intents_per_window = session_lookahead_ticks;
|
||||
auto server = network::SessionServer::create(std::move(config), std::move(*grant_key));
|
||||
if (!server)
|
||||
return fail(server.error() == network::SessionServerError::listen
|
||||
? "error session-listen"
|
||||
: "error session-credentials");
|
||||
config.grant_ledger = o.grant_ledger;
|
||||
auto server = network::SessionServer::create(std::move(config), std::move(*grant_key),
|
||||
wall_seconds());
|
||||
if (!server) {
|
||||
const auto e = server.error();
|
||||
return fail(e == network::SessionServerError::listen ? "error session-listen"
|
||||
: e == network::SessionServerError::ledger ? "error session-grant-ledger"
|
||||
: "error session-credentials");
|
||||
}
|
||||
bridge.server_ = std::move(*server);
|
||||
std::printf("session listening %u\n", static_cast<unsigned>(bridge.server_->port()));
|
||||
return bridge;
|
||||
@@ -97,12 +101,7 @@ class SessionBridge {
|
||||
if (state != nullptr && facts.ready &&
|
||||
(!published_ || *published_ != s.simulated_tick || epoch_ != s.epoch))
|
||||
publish(community(*state), facts);
|
||||
server_->poll(
|
||||
facts,
|
||||
static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch())
|
||||
.count()),
|
||||
std::chrono::steady_clock::now());
|
||||
server_->poll(facts, wall_seconds(), std::chrono::steady_clock::now());
|
||||
for (const auto& e : server_->take_events())
|
||||
std::printf("session %s %llu subject=%llu reason=%u\n",
|
||||
e.kind == network::SessionEvent::Kind::opened ? "opened"
|
||||
@@ -114,6 +113,11 @@ class SessionBridge {
|
||||
}
|
||||
|
||||
private:
|
||||
static std::uint64_t wall_seconds() {
|
||||
return static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch())
|
||||
.count());
|
||||
}
|
||||
static std::optional<SessionBridge> fail(const char* message) {
|
||||
std::puts(message);
|
||||
return std::nullopt;
|
||||
|
||||
Reference in New Issue
Block a user