Skip to main content

agent_memgc/domain/
finding.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
4pub enum RuleCode {
5    /// Dead file path or missing script reference in agent instructions
6    MGC001,
7    /// Semantic contradiction between two conflicting directives
8    MGC002,
9    /// Volatile instruction header breaking prompt prefix cache
10    MGC003,
11    /// Redundant or duplicate instruction wasting agent context
12    MGC004,
13}
14
15impl RuleCode {
16    pub fn as_str(&self) -> &'static str {
17        match self {
18            RuleCode::MGC001 => "MGC001",
19            RuleCode::MGC002 => "MGC002",
20            RuleCode::MGC003 => "MGC003",
21            RuleCode::MGC004 => "MGC004",
22        }
23    }
24
25    pub fn title(&self) -> &'static str {
26        match self {
27            RuleCode::MGC001 => "Dead Path Reference",
28            RuleCode::MGC002 => "Semantic Directive Contradiction",
29            RuleCode::MGC003 => "Prompt-Cache Prefix Invalidation",
30            RuleCode::MGC004 => "Duplicate / Redundant Rule",
31        }
32    }
33}
34
35#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
36pub enum Severity {
37    Error,
38    Warning,
39    Info,
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
43pub struct LinterFinding {
44    pub rule: RuleCode,
45    pub severity: Severity,
46    pub line: usize,
47    pub target: String,
48    pub message: String,
49    pub suggestion: Option<String>,
50    pub fixable: bool,
51}