feat(server): add Tokio UDP runtime #81

Merged
Lochnair merged 4 commits from feat/server-tokio-runtime into main 2026-08-13 04:35:06 +00:00
Lochnair commented 2026-08-12 18:39:01 +00:00 (Migrated from github.com)

Summary

  • Adds a reusable Tokio-native Server that binds one UDP listener around one ServerCore.
  • Adds caller-controlled graceful shutdown and scheduled idle-session maintenance.
  • Treats per-packet send failures and short sends as reply loss without terminating the listener.
  • Adds real loopback OPEN/ECHO/CLOSE coverage with both raw protocol packets and irtt-client::AsyncClient.

Runtime model

  • One sequential core/event loop runs per socket, with no per-datagram tasks or locks.
  • Receive and core failures may stop Server::run; send failures drop only that reply.
  • Explicit-address binds are the source-address-safe supported path.
  • Wildcard multi-homed source selection remains future work pending pktinfo support.

Clean-room / scope

  • No upstream source, tests, history, or binaries were inspected or run, and no protocol evidence changed.
  • No CLI server applet, DSCP socket policy, or full ServerFill policy is included.

Verification

  • cargo fmt --all -- --check
  • CARGO_TARGET_DIR=/private/tmp/irtt-rs-server-runtime-target cargo check --workspace --all-targets --all-features --locked
  • CARGO_TARGET_DIR=/private/tmp/irtt-rs-server-runtime-target cargo test --workspace --all-targets --all-features --locked
  • CARGO_TARGET_DIR=/private/tmp/irtt-rs-server-runtime-target cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • RUSTDOCFLAGS="-D warnings" CARGO_TARGET_DIR=/private/tmp/irtt-rs-server-runtime-target cargo doc -p irtt-proto -p irtt-client -p irtt-server --all-features --no-deps
  • cargo tree -p irtt-server --edges normal
  • git diff --check main...HEAD
## Summary - Adds a reusable Tokio-native `Server` that binds one UDP listener around one `ServerCore`. - Adds caller-controlled graceful shutdown and scheduled idle-session maintenance. - Treats per-packet send failures and short sends as reply loss without terminating the listener. - Adds real loopback OPEN/ECHO/CLOSE coverage with both raw protocol packets and `irtt-client::AsyncClient`. ## Runtime model - One sequential core/event loop runs per socket, with no per-datagram tasks or locks. - Receive and core failures may stop `Server::run`; send failures drop only that reply. - Explicit-address binds are the source-address-safe supported path. - Wildcard multi-homed source selection remains future work pending pktinfo support. ## Clean-room / scope - No upstream source, tests, history, or binaries were inspected or run, and no protocol evidence changed. - No CLI server applet, DSCP socket policy, or full `ServerFill` policy is included. ## Verification - `cargo fmt --all -- --check` - `CARGO_TARGET_DIR=/private/tmp/irtt-rs-server-runtime-target cargo check --workspace --all-targets --all-features --locked` - `CARGO_TARGET_DIR=/private/tmp/irtt-rs-server-runtime-target cargo test --workspace --all-targets --all-features --locked` - `CARGO_TARGET_DIR=/private/tmp/irtt-rs-server-runtime-target cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` - `RUSTDOCFLAGS="-D warnings" CARGO_TARGET_DIR=/private/tmp/irtt-rs-server-runtime-target cargo doc -p irtt-proto -p irtt-client -p irtt-server --all-features --no-deps` - `cargo tree -p irtt-server --edges normal` - `git diff --check main...HEAD`
chatgpt-codex-connector[bot] (Migrated from github.com) reviewed 2026-08-12 18:43:00 +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: 85c432fcf8

ℹ️ 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:** `85c432fcf8` <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>
@@ -46,0 +52,4 @@
send failure (including a short send) drops only that reply and must not stop
the listener. Core state is not rolled back after a transport send failure.
- Runtime maintenance calls the core's expiry hook. It must not inspect session
internals or grow a second expiry rule.
chatgpt-codex-connector[bot] (Migrated from github.com) commented 2026-08-12 18:43:01 +00:00

P2 Badge Update the obsolete packet-driven expiry guidance

This new runtime-maintenance rule contradicts the later section of the same scoped guidance, which still says expiry is packet-driven until a runtime exists and that a future Tokio slice may add scheduled sweeps. Because contributors and agents are required to follow this document, leaving both models documented makes the implemented lifecycle policy ambiguous; update the older section as part of this runtime change.

AGENTS.md reference: crates/irtt-server/AGENTS.md:L205-L213

Useful? React with 👍 / 👎.

**<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Update the obsolete packet-driven expiry guidance** This new runtime-maintenance rule contradicts the later section of the same scoped guidance, which still says expiry is packet-driven until a runtime exists and that a future Tokio slice may add scheduled sweeps. Because contributors and agents are required to follow this document, leaving both models documented makes the implemented lifecycle policy ambiguous; update the older section as part of this runtime change. AGENTS.md reference: [crates/irtt-server/AGENTS.md:L205-L213](https://github.com/Lochnair/irtt-rs/blob/85c432fcf87f22bdf0b0b25cc9038edb927b28e5/crates/irtt-server/AGENTS.md#L205-L213) Useful? React with 👍 / 👎.
@@ -0,0 +1,287 @@
//! Tokio UDP orchestration around [`ServerCore`](crate::ServerCore).
chatgpt-codex-connector[bot] (Migrated from github.com) commented 2026-08-12 18:43:01 +00:00

P2 Badge Poll shutdown while send_to is pending

When outbound UDP backpressure makes send_to return Pending, this inner .await stops polling the outer select!, including the shutdown future and maintenance timer. A shutdown request can therefore hang indefinitely, and idle sessions are not reclaimed until the socket becomes writable; select the cancellation signal alongside the send or otherwise bound/cancel the send wait.

AGENTS.md reference: AGENTS.md:L77-L77

Useful? React with 👍 / 👎.

**<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Poll shutdown while send_to is pending** When outbound UDP backpressure makes `send_to` return `Pending`, this inner `.await` stops polling the outer `select!`, including the shutdown future and maintenance timer. A shutdown request can therefore hang indefinitely, and idle sessions are not reclaimed until the socket becomes writable; select the cancellation signal alongside the send or otherwise bound/cancel the send wait. AGENTS.md reference: [AGENTS.md:L77-L77](https://github.com/Lochnair/irtt-rs/blob/85c432fcf87f22bdf0b0b25cc9038edb927b28e5/AGENTS.md#L77-L77) Useful? React with 👍 / 👎.
chatgpt-codex-connector[bot] (Migrated from github.com) reviewed 2026-08-12 18:53:57 +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: 41e39bd5b9

ℹ️ 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:** `41e39bd5b9` <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>
@@ -63,3 +65,4 @@ pub use config::{
};
chatgpt-codex-connector[bot] (Migrated from github.com) commented 2026-08-12 18:53:57 +00:00

P2 Badge Update the repository-wide runtime status

This new current-scope statement says Tokio UDP orchestration is implemented, but the repository-wide architecture guidance still says the Tokio runtime is unimplemented and expiry remains packet-driven. Contributors following that required guidance will receive an obsolete lifecycle model, so update the root status alongside these crate-level docs. Fresh evidence beyond the earlier scoped-guidance comment is that the scoped file is now corrected while the root guidance remains stale.

AGENTS.md reference: AGENTS.md:L60-L60

Useful? React with 👍 / 👎.

**<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Update the repository-wide runtime status** This new current-scope statement says Tokio UDP orchestration is implemented, but the repository-wide architecture guidance still says the Tokio runtime is unimplemented and expiry remains packet-driven. Contributors following that required guidance will receive an obsolete lifecycle model, so update the root status alongside these crate-level docs. Fresh evidence beyond the earlier scoped-guidance comment is that the scoped file is now corrected while the root guidance remains stale. AGENTS.md reference: [AGENTS.md:L60-L60](https://github.com/Lochnair/irtt-rs/blob/41e39bd5b95da2296283fd6b5954ebd0469846eb/AGENTS.md#L60-L60) Useful? React with 👍 / 👎.
Sign in to join this conversation.