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
+55
View File
@@ -3509,3 +3509,58 @@ were not executed remotely. Port-forward reachability of the pod-loopback listen
is the documented design, not yet observed. M8-dev/stage remains not passed. The
connected desktop run was hidden/software-rendered; no human visual check of remote
mode. Intentions have no biological effect by design.
## M9.4–M9.7 review corrections — 2026-10-02
Responds to the review of `bb0412c..8e31932` (`.cache/reviews/M9.4-M9.7-review.md`,
not in Git). All five findings were confirmed against the code and fixed:
1. **[P1] TLS retry lost queued frames.** `TlsChannel::send` is replaced by a bounded
(1 MiB) `queue` + `flush`: an interrupted record is retried with identical
arguments, later frames wait behind it, `close()` flushes before close_notify, a
full queue returns `backpressure` without queuing. Server and client route every
frame through it. Regression (`interrupted_writes`): zero progress and partial
progress then zero, frames queued during the stall, both directions, exact ordered
sequences; close while stalled; backpressure.
2. **[P1] Carrier ids aliased.** Carriers are server-issued `'I','N' | 48-bit epoch |
64-bit ordinal`; the client sequence is kept separately. Epochs beyond 48 bits are
refused at Hello; ordinal exhaustion stops carrying. ADR-0083's low-32-bit packing
is withdrawn. Regression (`carriers_never_alias`): sequences 1 and 2^32+1 get
distinct ids; `not_committed` and `committed` reach their own sequences.
3. **[P2] Grants reusable after restart.** New durable `GrantLedger` (fsync before
Welcome, atomic prune on open, fail closed on corruption/I-O/65536 entries), loaded
into admission by a replacement process; `--session-grant-ledger` (dev:
`/objects/dev-session-grants.v1`). Regressions: restart with the same ledger
refuses the consumed grant and admits a fresh one; corrupt ledger refuses server
creation; expired entries pruned; and in the end-to-end rehearsal the successor of
a SIGKILLed evo-server refused the first, consumed grant (`closed reason=3`).
4. **[P2] No liveness after Welcome.** Protocol v1 (still undeployed) gains Heartbeat
(type 9) and Close `timeout` (10). Both sides heartbeat after 1 s without output and
treat 5 s of silence as dead (server closes `timeout`, freeing the subject; client
marks stale, reports unknown outcomes, reconnects). Regressions (`liveness`): idle
but healthy session survives 1.5 s with no ticks; a silent server is detected and
reconnected to a fresh baseline; a silent client is closed and its subject reused.
5. **[P1, inherited] ci-client C compiler.** `-DCMAKE_C_COMPILER=clang-19` added; all
other C-enabling fresh configures already name it.
Follow-ups taken: `SessionClient::send` is bounded (256 unresolved, channel queue
capacity) and refuses instead of buffering; unresolved tracking now starts at send,
so a loss before IntentResult is also reported as unknown. The abuse test now floods
through a raw TLS peer (the client can no longer flood) and checks the server's
`rate_limited` decision. Client event-vector bounds remain M9.8 work.
Executed after the fixes: Windows MSVC `network` 1/1 and `client-network` 6/6; Linux
GCC 14 network suite and the **full** PostgreSQL integration suite (all suites,
including the session process test with the ledger and new carrier ids); Clang 19
ASan/UBSan network suite; clang-tidy 19 (warnings as errors) on all changed network,
client and server units (one `string_view::data` finding fixed in the ledger parser);
libFuzzer on the amended codec, 523,479 runs in 61 s, no crash or canonicality abort;
repository format, CI selector fixtures and deploy policy (67 objects, 0 failures).
End-to-end rehearsal: durable ack, SIGKILL, successor Ready in 3472 ms at epoch 2,
grants kept across two `server_shutdown` refusals, second durable ack, consumed grant
refused by the successor, Windows evo-client welcomed (`session=2 epoch=2`), successor
drained with `exit 0`.
Not done: the reviewer's own reproduction binaries target the removed `send` API and
were not rebuilt; equivalent regressions above replace them. The `ci-client` Docker
image and Gitea pipeline were not rerun here, and no cluster operation was performed.