Keep latest-session timestamps increasing under tight loops

The next repo-local sweep target was ROADMAP #73: repeated backlog
sweeps exposed that session writes could share the same wall-clock
millisecond, which made semantic recency fragile and forced the
resume-latest regression to sleep between saves. The fix makes session
timestamps monotonic within the process and removes the timing hack
from the test so latest-session selection stays stable under tight
loops.

Constraint: Preserve the existing session file format while changing only the timestamp source semantics
Rejected: Keep the sleep-based test workaround | hides the real ordering hazard instead of fixing timestamp generation
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Any future session-recency logic must keep `current_time_millis`, ordering tests, and latest-session expectations aligned
Tested: cargo fmt --all --check; cargo clippy --workspace --all-targets -- -D warnings; cargo test --workspace; architect review APPROVE
Not-tested: Cross-process monotonicity when multiple binaries write sessions concurrently
This commit is contained in:
Yeachan-Heo
2026-04-12 10:51:19 +00:00
parent 8f53524bd3
commit 2e34949507
3 changed files with 33 additions and 7 deletions

View File

@@ -3,8 +3,6 @@ use std::path::Path;
use std::path::PathBuf;
use std::process::{Command, Output};
use std::sync::atomic::{AtomicU64, Ordering};
use std::thread;
use std::time::Duration;
use std::time::{SystemTime, UNIX_EPOCH};
use runtime::ContentBlock;
@@ -193,7 +191,6 @@ fn resume_latest_restores_the_most_recent_managed_session() {
older
.save_to_path(&older_path)
.expect("older session should persist");
thread::sleep(Duration::from_millis(2));
let mut newer = workspace_session(&project_dir).with_persistence_path(&newer_path);
newer