Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions codex-rs/core/src/entropy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use std::fmt::Debug;
use std::ops::Range;
use std::sync::Arc;
use std::time::Instant;
use std::time::SystemTime;

/// Source of randomness (UUIDs, random numbers).
Expand All @@ -23,8 +22,6 @@ pub trait RandomSource: Send + Sync + Debug {

/// Source of time.
pub trait Clock: Send + Sync + Debug {
/// Returns a monotonic instant (for measuring durations).
fn now(&self) -> Instant;
/// Returns wall-clock time.
fn wall_time(&self) -> SystemTime;
/// Returns milliseconds since Unix epoch.
Expand Down Expand Up @@ -67,10 +64,6 @@ impl RandomSource for SystemRandomSource {
pub struct SystemClock;

impl Clock for SystemClock {
fn now(&self) -> Instant {
Instant::now()
}

fn wall_time(&self) -> SystemTime {
SystemTime::now()
}
Expand Down Expand Up @@ -121,15 +114,6 @@ pub fn entropy_uuid() -> String {
.unwrap_or_else(|_| uuid::Uuid::new_v4().to_string())
}

/// Helper to access the task-local monotonic clock.
///
/// Falls back to `Instant::now()` when called outside a scoped context.
pub fn entropy_now() -> Instant {
ENTROPY
.try_with(|e| e.clock.now())
.unwrap_or_else(|_| Instant::now())
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -163,14 +147,6 @@ mod tests {
}
}

#[test]
fn system_clock_now_is_monotonic() {
let clock = SystemClock;
let t1 = clock.now();
let t2 = clock.now();
assert!(t2 >= t1, "Clock should be monotonic");
}

#[test]
fn system_clock_unix_millis_is_reasonable() {
let clock = SystemClock;
Expand All @@ -186,7 +162,6 @@ mod tests {
// Should not panic and should produce valid output
let uuid = providers.random.uuid();
assert!(!uuid.is_empty());
let _ = providers.clock.now();
}

// Test helper for deterministic testing
Expand Down
5 changes: 2 additions & 3 deletions codex-rs/core/src/tools/parallel.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::future::Future;
use std::sync::Arc;

use crate::entropy::entropy_now;
use std::time::Instant;
use futures::future::BoxFuture;
use tokio::sync::RwLock;
use tokio_util::either::Either;
Expand Down Expand Up @@ -80,7 +79,7 @@ impl ToolCallRuntime {
let turn = Arc::clone(&self.turn_context);
let tracker = Arc::clone(&self.tracker);
let lock = Arc::clone(&self.parallel_execution);
let started = entropy_now();
let started = Instant::now();

let dispatch_span = trace_span!(
"dispatch_tool_call",
Expand Down