Standalone binary that exercises TailMessages on a transcript file, reporting progress and timing. Useful for isolating conversation resolution issues from the full hook pipeline. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
65 lines
2.2 KiB
Rust
65 lines
2.2 KiB
Rust
// Test tool for the conversation resolver.
|
|
// Usage: POC_SESSION_ID=<id> cargo run --bin test-conversation
|
|
// or: cargo run --bin test-conversation -- <transcript-path>
|
|
|
|
use std::time::Instant;
|
|
|
|
fn main() {
|
|
let path = std::env::args().nth(1).unwrap_or_else(|| {
|
|
let session_id = std::env::var("POC_SESSION_ID")
|
|
.expect("pass a transcript path or set POC_SESSION_ID");
|
|
let projects = poc_memory::config::get().projects_dir.clone();
|
|
eprintln!("session: {}", session_id);
|
|
eprintln!("projects dir: {}", projects.display());
|
|
|
|
let mut found = None;
|
|
if let Ok(dirs) = std::fs::read_dir(&projects) {
|
|
for dir in dirs.filter_map(|e| e.ok()) {
|
|
let path = dir.path().join(format!("{}.jsonl", session_id));
|
|
eprintln!(" checking: {}", path.display());
|
|
if path.exists() {
|
|
found = Some(path);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
let path = found.expect("transcript not found");
|
|
path.to_string_lossy().to_string()
|
|
});
|
|
|
|
let meta = std::fs::metadata(&path).expect("can't stat file");
|
|
eprintln!("transcript: {} ({} bytes)", path, meta.len());
|
|
|
|
let t0 = Instant::now();
|
|
let iter = poc_memory::transcript::TailMessages::open(&path)
|
|
.expect("can't open transcript");
|
|
|
|
let mut count = 0;
|
|
let mut total_bytes = 0;
|
|
let mut last_report = Instant::now();
|
|
|
|
for (role, content, ts) in iter {
|
|
count += 1;
|
|
total_bytes += content.len();
|
|
|
|
if last_report.elapsed().as_secs() >= 2 {
|
|
eprintln!(" ... {} messages, {}KB so far ({:.1}s)",
|
|
count, total_bytes / 1024, t0.elapsed().as_secs_f64());
|
|
last_report = Instant::now();
|
|
}
|
|
|
|
if count <= 5 {
|
|
let preview: String = content.chars().take(80).collect();
|
|
eprintln!(" [{}] {} {}: {}...",
|
|
count, &ts[..ts.len().min(19)], role, preview);
|
|
}
|
|
|
|
if total_bytes >= 200_000 {
|
|
eprintln!(" hit 200KB budget at {} messages", count);
|
|
break;
|
|
}
|
|
}
|
|
|
|
let elapsed = t0.elapsed();
|
|
eprintln!("done: {} messages, {}KB in {:.3}s", count, total_bytes / 1024, elapsed.as_secs_f64());
|
|
}
|