refactor(client): make probe sends transactional #42

Merged
Lochnair merged 2 commits from refactor/transactional-probes into main 2026-08-03 18:13:39 +00:00
Lochnair commented 2026-08-03 18:12:33 +00:00 (Migrated from github.com)

Summary

Make every synchronous probe-send path transactional, including the blocking
client, threaded singleton client, and legacy managed group.

Transaction boundary

Probe encoding, stale/collision checks, pending reservation, counter/deadline
arithmetic, schedule preflight, and event capacity reservation occur before the
UDP send. Successful kernel acceptance is followed immediately by infallible
SessionMachine and ProbeSchedule commits.

Presentation timing, datagram-length validation, and event construction occur
only after both authoritative commits.

Failure behavior

Socket failures leave machine and schedule state unchanged. Stale preparations,
sequence collisions, allocation failures, and arithmetic overflows are rejected
before send. Successful short sends commit both states before returning
DatagramLengthMismatch.

Public errors

  • PendingSequenceCollision
  • AllocationFailed
  • StalePreparedProbe
  • DatagramLengthMismatch

All transaction and commit token types remain crate-private.

Testing

Adds focused coverage for pending preflight, allocation mapping, stale
preparations, dropped preparations, counter/deadline overflow, sequence
wrapping, infallible commit behavior, blocking and managed send failures,
successful short sends, shared timestamps, and managed pacing preservation.

The workspace, no-default-feature suite, formatting, Clippy, diff checks, and
independent per-commit verification all pass.

## Summary Make every synchronous probe-send path transactional, including the blocking client, threaded singleton client, and legacy managed group. ## Transaction boundary Probe encoding, stale/collision checks, pending reservation, counter/deadline arithmetic, schedule preflight, and event capacity reservation occur before the UDP send. Successful kernel acceptance is followed immediately by infallible SessionMachine and ProbeSchedule commits. Presentation timing, datagram-length validation, and event construction occur only after both authoritative commits. ## Failure behavior Socket failures leave machine and schedule state unchanged. Stale preparations, sequence collisions, allocation failures, and arithmetic overflows are rejected before send. Successful short sends commit both states before returning DatagramLengthMismatch. ## Public errors - PendingSequenceCollision - AllocationFailed - StalePreparedProbe - DatagramLengthMismatch All transaction and commit token types remain crate-private. ## Testing Adds focused coverage for pending preflight, allocation mapping, stale preparations, dropped preparations, counter/deadline overflow, sequence wrapping, infallible commit behavior, blocking and managed send failures, successful short sends, shared timestamps, and managed pacing preservation. The workspace, no-default-feature suite, formatting, Clippy, diff checks, and independent per-commit verification all pass.
chatgpt-codex-connector[bot] (Migrated from github.com) reviewed 2026-08-03 18:17:45 +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: 9bc2ac90b3

ℹ️ 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:** `9bc2ac90b3` <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>
@@ -348,0 +398,4 @@
}
pub(crate) fn echo_sent_event(
remote: SocketAddr,
chatgpt-codex-connector[bot] (Migrated from github.com) commented 2026-08-03 18:17:45 +00:00

P2 Badge Timestamp probes immediately before sending

When packet encoding, HMAC calculation, allocation, or scheduler preemption delays this preflight, sent_at and the derived timeout_at precede the actual kernel send by the entire delay. This inflates RTT/client-to-server timing and can make a successfully sent probe expire immediately with a short probe_timeout; previously production code sampled the timestamp inside the send closure immediately before socket.send. Keep any early timestamp needed for schedule permission separate from the committed send timestamp, and apply the same correction to send_echo_to_locked_target_at.

Useful? React with 👍 / 👎.

**<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Timestamp probes immediately before sending** When packet encoding, HMAC calculation, allocation, or scheduler preemption delays this preflight, `sent_at` and the derived `timeout_at` precede the actual kernel send by the entire delay. This inflates RTT/client-to-server timing and can make a successfully sent probe expire immediately with a short `probe_timeout`; previously production code sampled the timestamp inside the send closure immediately before `socket.send`. Keep any early timestamp needed for schedule permission separate from the committed send timestamp, and apply the same correction to `send_echo_to_locked_target_at`. Useful? React with 👍 / 👎.
chatgpt-codex-connector[bot] (Migrated from github.com) commented 2026-08-03 18:17:45 +00:00

P2 Badge Stop the send timer before committing state

On every successful probe, send_call is now sampled only after commit_probe_sent and the schedule commit, so the public metric documented as time spent in the socket send call also includes hash-map insertion and history cleanup; when a wrapped sequence removes retained timeout/completion history, that cleanup can scan the configured tracking window and materially distort the aggregated send-call statistics. Capture the elapsed duration immediately after socket.send, as the previous implementation did, and make the analogous change in the managed-group send path.

Useful? React with 👍 / 👎.

**<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Stop the send timer before committing state** On every successful probe, `send_call` is now sampled only after `commit_probe_sent` and the schedule commit, so the public metric documented as time spent in the socket send call also includes hash-map insertion and history cleanup; when a wrapped sequence removes retained timeout/completion history, that cleanup can scan the configured tracking window and materially distort the aggregated send-call statistics. Capture the elapsed duration immediately after `socket.send`, as the previous implementation did, and make the analogous change in the managed-group send path. Useful? React with 👍 / 👎.
Sign in to join this conversation.