fix(client): make session closing transactional #45

Merged
Lochnair merged 4 commits from fix/transactional-close into main 2026-08-04 06:54:47 +00:00
Lochnair commented 2026-08-04 06:20:20 +00:00 (Migrated from github.com)

Summary

Make synchronous session closing transactional across the blocking client,
threaded singleton, and managed group.

Close transaction

Preencode authenticated close bytes during normal open acceptance and store them
in the active session. Prepare a consuming close commit before adapter work, then
commit protocol state immediately after kernel acceptance.

Failure and rollback behavior

Blocking send failures leave the machine and schedule open and restore negotiated
DSCP best-effort while preserving the original send error. Successful short sends
commit close before reporting the datagram-length mismatch.

Peer-close cleanup

Authenticated peer close remains protocol-authoritative. The blocking adapter
clears its schedule and attempts DSCP cleanup without suppressing returned events
or sending another close packet.

Managed-group behavior

Managed targets use prepare/send/commit without changing shared-socket DSCP.
Failed sends produce failed outcomes without false close commits; peer close
affects only the matching target.

Testing

Adds deterministic regressions for close preparation, HMAC bytes, allocation and
DSCP failures, rollback, retry, short sends, peer cleanup, managed completion,
removal, cancellation, failures, and target isolation.

## Summary Make synchronous session closing transactional across the blocking client, threaded singleton, and managed group. ## Close transaction Preencode authenticated close bytes during normal open acceptance and store them in the active session. Prepare a consuming close commit before adapter work, then commit protocol state immediately after kernel acceptance. ## Failure and rollback behavior Blocking send failures leave the machine and schedule open and restore negotiated DSCP best-effort while preserving the original send error. Successful short sends commit close before reporting the datagram-length mismatch. ## Peer-close cleanup Authenticated peer close remains protocol-authoritative. The blocking adapter clears its schedule and attempts DSCP cleanup without suppressing returned events or sending another close packet. ## Managed-group behavior Managed targets use prepare/send/commit without changing shared-socket DSCP. Failed sends produce failed outcomes without false close commits; peer close affects only the matching target. ## Testing Adds deterministic regressions for close preparation, HMAC bytes, allocation and DSCP failures, rollback, retry, short sends, peer cleanup, managed completion, removal, cancellation, failures, and target isolation.
chatgpt-codex-connector[bot] (Migrated from github.com) reviewed 2026-08-04 06:23:54 +00:00
chatgpt-codex-connector[bot] (Migrated from github.com) left a comment

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef19c45c1f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `ef19c45c1f` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
@@ -401,28 +419,35 @@ impl SessionMachine {
Ok(events)
chatgpt-codex-connector[bot] (Migrated from github.com) commented 2026-08-04 06:23:55 +00:00

P2 Badge Timestamp close events only when sending the request

When a close blocks behind a full UDP send buffer, or socket-option work is delayed, prepare_close() captures at before event reservation, DSCP clearing, and the eventual send/send_to. This makes both blocking-client and managed-group SessionClosed timestamps precede the actual send, despite the public field contract defining at as when the close request was sent; construct or timestamp the event after successful kernel acceptance, immediately before committing the close.

Useful? React with 👍 / 👎.

**<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Timestamp close events only when sending the request** When a close blocks behind a full UDP send buffer, or socket-option work is delayed, `prepare_close()` captures `at` before event reservation, DSCP clearing, and the eventual `send`/`send_to`. This makes both blocking-client and managed-group `SessionClosed` timestamps precede the actual send, despite the public field contract defining `at` as when the close request was sent; construct or timestamp the event after successful kernel acceptance, immediately before committing the close. Useful? React with 👍 / 👎.
Sign in to join this conversation.