MCPcopy Create free account
hub / github.com/AIScientists-Dev/Flowtrace / next_seq

Function next_seq

crates/flowtrace-cli/src/reply.rs:65–76  ·  view source on GitHub ↗

Allocate the next seq for this run. Cache-backed: O(1) after first use.

(trace_root: &Path, run_id: &str)

Source from the content-addressed store, hash-verified

63
64/// Allocate the next seq for this run. Cache-backed: O(1) after first use.
65fn next_seq(trace_root: &Path, run_id: &str) -> u32 {
66 let key = (trace_root.to_path_buf(), run_id.to_string());
67 let cache = SEQ_CACHE.get_or_init(|| std::sync::Mutex::new(std::collections::HashMap::new()));
68 let mut guard = cache.lock().unwrap();
69 let last = match guard.get(&key).copied() {
70 Some(v) => v,
71 None => scan_max_seq(&replies_dir(trace_root, run_id)),
72 };
73 let next = last + 1;
74 guard.insert(key, next);
75 next
76}
77
78/// Append a new reply file. Returns the assigned seq and timestamp.
79///

Callers 1

append_replyFunction · 0.85

Calls 2

scan_max_seqFunction · 0.85
replies_dirFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…