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
+5 -4
View File
@@ -12,7 +12,7 @@ message re-encodes to identical bytes (fuzz-tested).
|---|---|---|---|
| 0 | magic | u32 | `0x53445645` (bytes `E V D S`) |
| 4 | version | u16 | exactly 1, otherwise `unsupported_version` |
| 6 | type | u8 | 1..8, otherwise `unknown_type` |
| 6 | type | u8 | 1..9, otherwise `unknown_type` |
| 7 | flags | u8 | 0, otherwise `reserved_flags` |
| 8 | length | u32 | payload bytes, <= 262144 (`oversized`) |
| 12 | payload | bytes | exactly `length`; short `truncated`, extra `trailing_bytes` |
@@ -30,15 +30,16 @@ Payload decoders also reject truncation, trailing bytes, out-of-range enum bytes
| 4 | IntentResult | S->C | sequence u64, status u8 (0..7), server_tick u64 |
| 5 | EnvironmentView | S->C | view header, environment presentation |
| 6 | OrganismView | S->C | view header, organism presentation |
| 7 | Close | both | reason u8 (0..9) |
| 7 | Close | both | reason u8 (0..10) |
| 8 | IntentOutcome | S->C | sequence u64, finality u8 (0 committed_no_effect, 1 not_committed), tick u64, commit_sequence u64; committed requires commit_sequence != 0, not_committed requires tick = commit_sequence = 0 |
| 9 | Heartbeat | both | empty (length 0); sent after 1 s without other output; 5 s of silence closes with `timeout` |
IntentStatus: 0 admitted, 1 unknown_session, 2 stale_epoch, 3 expired,
4 invalid_vector, 5 replayed, 6 outside_window, 7 rate_limited.
CloseReason: 0 normal, 1 unsupported_version, 2 malformed, 3 unauthenticated,
4 expired, 5 duplicate_session, 6 stale_epoch, 7 rate_limited, 8 server_shutdown,
9 capacity. Type 8 and reason 9 were added in M9.7 before any v1 peer was
deployed (ADR-0083); later changes require a new version.
9 capacity, 10 timeout. Types 8-9 and reasons 9-10 were added in M9.7 before any v1
peer was deployed (ADR-0083); later changes require a new version.
View header (40 bytes): session, epoch, server_tick, commit_watermark, baseline (u64).