agent_memgc/domain/
memory.rs1use crate::domain::finding::LinterFinding;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct InstructionBlock {
6 pub line_start: usize,
7 pub line_end: usize,
8 pub heading: Option<String>,
9 pub text: String,
10 pub backticked_paths: Vec<String>,
11}
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct LinterReport {
15 pub target_file: String,
16 pub total_lines: usize,
17 pub findings: Vec<LinterFinding>,
18 pub errors_count: usize,
19 pub warnings_count: usize,
20 pub info_count: usize,
21 pub estimated_wasted_tokens: usize,
22 pub cache_clean: bool,
23}
24
25impl LinterReport {
26 pub fn new(target_file: String, total_lines: usize, findings: Vec<LinterFinding>) -> Self {
27 let mut errors = 0;
28 let mut warnings = 0;
29 let mut infos = 0;
30 let mut wasted_tokens = 0;
31 let mut cache_clean = true;
32
33 for f in &findings {
34 match f.severity {
35 crate::domain::finding::Severity::Error => errors += 1,
36 crate::domain::finding::Severity::Warning => warnings += 1,
37 crate::domain::finding::Severity::Info => infos += 1,
38 }
39
40 match f.rule {
41 crate::domain::finding::RuleCode::MGC001 => wasted_tokens += 25,
42 crate::domain::finding::RuleCode::MGC002 => wasted_tokens += 60,
43 crate::domain::finding::RuleCode::MGC003 => cache_clean = false,
44 crate::domain::finding::RuleCode::MGC004 => wasted_tokens += 35,
45 }
46 }
47
48 Self {
49 target_file,
50 total_lines,
51 findings,
52 errors_count: errors,
53 warnings_count: warnings,
54 info_count: infos,
55 estimated_wasted_tokens: wasted_tokens,
56 cache_clean,
57 }
58 }
59
60 pub fn has_errors(&self) -> bool {
61 self.errors_count > 0
62 }
63}