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:
@@ -37,7 +37,8 @@ enum class TlsError : std::uint8_t {
|
||||
peer_verification,
|
||||
transport,
|
||||
closed,
|
||||
record
|
||||
record,
|
||||
backpressure
|
||||
};
|
||||
enum class TlsProgress : std::uint8_t { done, want_io };
|
||||
class TlsChannel {
|
||||
@@ -50,9 +51,17 @@ class TlsChannel {
|
||||
TlsChannel& operator=(const TlsChannel&) = delete;
|
||||
~TlsChannel();
|
||||
[[nodiscard]] std::expected<TlsProgress, TlsError> handshake();
|
||||
// Zero means "would block". Errors latch until destruction.
|
||||
[[nodiscard]] std::expected<std::size_t, TlsError> send(std::span<const std::uint8_t> bytes);
|
||||
// Outbound plaintext is queued, never handed to the caller to retry: a record that
|
||||
// TLS could not finish writing is retried with identical arguments (Mbed TLS
|
||||
// requires this), and newly queued bytes wait behind it. Bounded; a full queue
|
||||
// returns `backpressure` and queues nothing. Errors latch until destruction.
|
||||
static constexpr std::size_t max_queued_bytes = std::size_t{1} << 20;
|
||||
[[nodiscard]] std::expected<void, TlsError> queue(std::span<const std::uint8_t> bytes);
|
||||
// Writes queued plaintext until done or the transport would block.
|
||||
[[nodiscard]] std::expected<TlsProgress, TlsError> flush();
|
||||
[[nodiscard]] std::size_t queued() const noexcept;
|
||||
[[nodiscard]] std::expected<std::size_t, TlsError> receive(std::span<std::uint8_t> bytes);
|
||||
// Flushes queued plaintext first, then sends close_notify (want_io until both done).
|
||||
[[nodiscard]] std::expected<TlsProgress, TlsError> close();
|
||||
// Negotiated "TLSv1.3" and suite name after a completed handshake.
|
||||
[[nodiscard]] std::string_view version() const noexcept;
|
||||
|
||||
Reference in New Issue
Block a user