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:
dingo
2026-10-02 05:44:44 -04:00
co-authored by Claude Opus 5.5
parent 8e319322f4
commit c588be237c
26 changed files with 934 additions and 193 deletions
+9
View File
@@ -4,6 +4,7 @@
#include <cstddef>
#include <cstdint>
#include <expected>
#include <span>
#include <vector>
// Server-side session admission for the M9.6 dev session (ADR-0082). Transport-
@@ -17,6 +18,10 @@ struct DevGrantClaims {
world::WorldIdentity world;
std::uint64_t region{}, issued_at{}, expires_at{}; // Server clock, seconds.
};
// A grant already used to open a session, remembered until it expires.
struct ConsumedGrant {
std::uint64_t grant_id{}, expires_at{};
};
class DevGrantKey;
// Only DevGrantKey::verify constructs this, so admission cannot be handed
// unauthenticated claims by accident.
@@ -68,6 +73,10 @@ class SessionAdmission {
[[nodiscard]] IntentResult admit(const IntentMessage& intent, std::uint64_t server_tick,
std::uint64_t now_seconds);
[[nodiscard]] std::expected<void, AdmissionError> close(std::uint64_t session);
// Restores grants consumed before a restart (from a durable ledger), so a replacement
// host refuses them too. Expired entries are skipped; too many fail closed.
[[nodiscard]] std::expected<void, AdmissionError>
remember(std::span<const ConsumedGrant> consumed, std::uint64_t now_seconds);
// New ownership epoch: existing sessions become stale and must reconnect.
[[nodiscard]] std::expected<void, AdmissionError> advance_epoch(std::uint64_t epoch);
[[nodiscard]] std::size_t sessions() const noexcept {