Files
codex/codex-rs/exec-server/src/noise_relay/mod.rs
T
viyatb-oaiandCodex noreply@openai.com e206c191d6 fix: keep Noise relay runtime lint-clean
Co-authored-by: Codex noreply@openai.com
2026-06-09 16:36:49 -07:00

52 lines
1.9 KiB
Rust

// This stack lands the executor-side relay runtime one layer before the remote
// registration path calls it. Keep this intermediate PR lint-clean without
// hiding dead code once the production call site arrives in the next layer.
#[expect(
dead_code,
reason = "used by the remote Noise opt-in in the next stacked change"
)]
pub(crate) mod environment;
#[expect(
dead_code,
reason = "used by the remote Noise opt-in in the next stacked change"
)]
mod executor_stream;
mod harness;
mod message_framing;
mod ordered_ciphertext;
use tokio_tungstenite::tungstenite::protocol::WebSocketConfig;
use crate::ExecServerError;
pub(crate) use harness::noise_harness_connection_from_websocket;
// This value is already part of the relay wire contract. Keep it stable even
// though the source module now uses the more precise Noise terminology.
#[expect(
dead_code,
reason = "used by the remote Noise opt-in in the next stacked change"
)]
const NOISE_RELAY_RESET_REASON: &str = "secure_relay_protocol_error";
// This bounds allocation in tungstenite before protobuf and Noise record
// validation run. It comfortably fits one maximum Noise record plus metadata.
const MAX_NOISE_RELAY_WEBSOCKET_MESSAGE_SIZE: usize = 256 * 1024;
/// Return the websocket limits required by every Noise relay endpoint.
pub(crate) fn noise_relay_websocket_config() -> WebSocketConfig {
WebSocketConfig::default()
.max_frame_size(Some(MAX_NOISE_RELAY_WEBSOCKET_MESSAGE_SIZE))
.max_message_size(Some(MAX_NOISE_RELAY_WEBSOCKET_MESSAGE_SIZE))
}
fn take_next_sequence(next_seq: &mut u32) -> Result<u32, ExecServerError> {
// Never wrap: relay sequence is the explicit ordering key for an implicit
// Noise nonce. Reusing zero after u32::MAX would be ambiguous and unsafe.
let seq = *next_seq;
*next_seq = next_seq.checked_add(1).ok_or_else(|| {
ExecServerError::Protocol("Noise relay sequence number exhausted".to_string())
})?;
Ok(seq)
}