lean_ctx/core/context_prefetch/
mod.rs1pub fn warm_predictions<T>(_paths: &[String], _cache: Option<&T>) {}
8
9pub fn plan_after_triage(_task_class: &str) {}
11
12pub fn warmed_count() -> u64 {
14 0
15}
16
17pub fn skipped_count() -> u64 {
19 0
20}
21
22#[derive(Debug, Clone)]
24pub struct PrefetchEntry {
25 pub path: String,
26 pub score: f64,
27}
28
29#[derive(Debug, Clone, Default)]
31pub struct PrefetchPlan {
32 pub files: Vec<PrefetchEntry>,
33}
34
35pub struct FileTrajectory {
37 paths: Vec<(String, u32)>,
38 capacity: usize,
39}
40
41impl FileTrajectory {
42 pub fn new(capacity: usize) -> Self {
43 Self {
44 paths: Vec::new(),
45 capacity,
46 }
47 }
48
49 pub fn record(&mut self, path: &str) {
50 if let Some(entry) = self.paths.iter_mut().find(|(p, _)| p == path) {
51 entry.1 += 1;
52 } else {
53 if self.paths.len() >= self.capacity {
54 self.paths.remove(0);
55 }
56 self.paths.push((path.to_owned(), 1));
57 }
58 }
59
60 pub fn predict(&self, top_k: usize) -> Vec<(String, f64)> {
61 let mut scored: Vec<(String, f64)> = self
62 .paths
63 .iter()
64 .map(|(path, count)| (path.clone(), *count as f64))
65 .collect();
66 scored.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap_or(std::cmp::Ordering::Equal));
67 scored.truncate(top_k);
68 scored
69 }
70}
71
72pub fn build_prefetch_plan(
74 trajectory: &FileTrajectory,
75 _exclude: &[String],
76 top_k: usize,
77 _min_score: f64,
78) -> PrefetchPlan {
79 let files = trajectory
80 .predict(top_k)
81 .into_iter()
82 .map(|(path, score)| PrefetchEntry { path, score })
83 .collect();
84 PrefetchPlan { files }
85}
86
87pub fn record_file_read(_path: &str) {}
89
90pub fn is_prefetch_prediction(_path: &str) -> bool {
92 false
93}