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
+42
View File
@@ -0,0 +1,42 @@
#pragma once
#include "evo/network/admission.hpp"
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <expected>
#include <filesystem>
#include <memory>
#include <span>
#include <utility>
#include <vector>
// Durable record of consumed dev grants (ADR-0083), so a replacement region process
// refuses grants its predecessor already used. Append-only text lines
// "<grant id hex> <expires_at>", flushed and fsynced before the session is welcomed.
// Opening drops expired entries by an atomic rewrite. Corrupt content, I/O failure or
// a full ledger fail closed. Single owner; not a general database.
namespace evo::network {
enum class LedgerError : std::uint8_t { io, corrupt, full };
class GrantLedger {
public:
static constexpr std::size_t max_entries = 65536;
[[nodiscard]] static std::expected<std::unique_ptr<GrantLedger>, LedgerError>
open(const std::filesystem::path& path, std::uint64_t now_seconds);
GrantLedger(const GrantLedger&) = delete;
GrantLedger& operator=(const GrantLedger&) = delete;
~GrantLedger();
// Unexpired entries loaded at open (for SessionAdmission::remember).
[[nodiscard]] std::span<const ConsumedGrant> loaded() const noexcept {
return loaded_;
}
// Durable once this returns success.
[[nodiscard]] std::expected<void, LedgerError> record(ConsumedGrant grant);
private:
GrantLedger(std::FILE* file, std::vector<ConsumedGrant> loaded)
: file_{file}, loaded_{std::move(loaded)}, entries_{loaded_.size()} {}
std::FILE* file_;
std::vector<ConsumedGrant> loaded_;
std::size_t entries_;
};
} // namespace evo::network