refactor: fix flaky test and remove dead code in recent commits
Fixes issues in the last 11 commits:
1. pending_research.rs: Fix flaky test_generate_id_uniqueness
- Replaced random u16 suffix with atomic counter for guaranteed uniqueness
- The timestamp+random approach could collide when generating IDs rapidly
- Now uses static AtomicU32 counter that increments monotonically
2. embedded/adapters/glm.rs: Remove unused in_code_fence field
- Field was written but never read (dead code)
- Removed from struct definition, constructor, and reset()
3. embedded/adapters/glm.rs: Fix orphaned tests
- Two tests (test_strip_code_fences, test_code_fenced_tool_call) were
outside the #[cfg(test)] mod tests block
- Moved closing brace to include them in the test module
All 446 library tests pass.
Agent: fowler
This commit is contained in:
@@ -139,12 +139,15 @@ impl PendingResearchManager {
|
||||
/// Generate a unique research ID
|
||||
pub fn generate_id() -> ResearchId {
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
static COUNTER: AtomicU32 = AtomicU32::new(0);
|
||||
|
||||
let timestamp = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_millis();
|
||||
// Use timestamp + random suffix for uniqueness
|
||||
format!("research_{:x}_{:04x}", timestamp, rand::random::<u16>())
|
||||
let counter = COUNTER.fetch_add(1, Ordering::Relaxed);
|
||||
format!("research_{:x}_{:08x}", timestamp, counter)
|
||||
}
|
||||
|
||||
/// Register a new research task
|
||||
|
||||
Reference in New Issue
Block a user