Skip to content

Commit be568d1

Browse files
committed
refactor: split eval types
Separate eval fixture, pattern, report, and option models so unrelated command, matcher, and reporting changes stop colliding in one types file. Made-with: Cursor
1 parent ab12622 commit be568d1

6 files changed

Lines changed: 206 additions & 184 deletions

File tree

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777

7878
### Commands backlog
7979

80-
- [ ] `src/commands/eval/types.rs`: split fixture, pattern, report, and run-option types if churn keeps touching unrelated structs.
80+
- [x] `src/commands/eval/types.rs`: split fixture, pattern, report, and run-option types if churn keeps touching unrelated structs.
8181
- [x] `src/commands/feedback_eval/types.rs`: separate input payload types from report/output types.
8282
- [x] `src/commands/feedback_eval/input/loading.rs`: split format detection from JSON parsing/loading.
8383
- [x] `src/commands/feedback_eval/input/conversion.rs`: split review-session conversion from label normalization helpers.

src/commands/eval/types.rs

Lines changed: 14 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -1,184 +1,15 @@
1-
use serde::{Deserialize, Serialize};
2-
use std::path::PathBuf;
3-
4-
use crate::core::eval_benchmarks::{
5-
AggregateMetrics as BenchmarkAggregateMetrics, BenchmarkThresholds, Difficulty,
6-
FixtureResult as BenchmarkFixtureResult,
1+
#[path = "types/fixtures.rs"]
2+
mod fixtures;
3+
#[path = "types/options.rs"]
4+
mod options;
5+
#[path = "types/pattern.rs"]
6+
mod pattern;
7+
#[path = "types/report.rs"]
8+
mod report;
9+
10+
pub(super) use fixtures::{EvalFixture, LoadedEvalFixture};
11+
pub use options::EvalRunOptions;
12+
pub(super) use pattern::{EvalExpectations, EvalPattern};
13+
pub(super) use report::{
14+
EvalFixtureResult, EvalReport, EvalRuleMetrics, EvalRuleScoreSummary, EvalSuiteResult,
715
};
8-
9-
#[derive(Debug, Clone, Deserialize, Default)]
10-
pub(super) struct EvalFixture {
11-
#[serde(default)]
12-
pub(super) name: Option<String>,
13-
#[serde(default)]
14-
pub(super) diff: Option<String>,
15-
#[serde(default)]
16-
pub(super) diff_file: Option<PathBuf>,
17-
#[serde(default)]
18-
pub(super) repo_path: Option<PathBuf>,
19-
#[serde(default)]
20-
pub(super) expect: EvalExpectations,
21-
}
22-
23-
#[derive(Debug, Clone)]
24-
pub(super) struct LoadedEvalFixture {
25-
pub(super) fixture_path: PathBuf,
26-
pub(super) fixture: EvalFixture,
27-
pub(super) suite_name: Option<String>,
28-
pub(super) suite_thresholds: Option<BenchmarkThresholds>,
29-
pub(super) difficulty: Option<Difficulty>,
30-
}
31-
32-
#[derive(Debug, Clone, Deserialize, Default)]
33-
pub(super) struct EvalExpectations {
34-
#[serde(default)]
35-
pub(super) must_find: Vec<EvalPattern>,
36-
#[serde(default)]
37-
pub(super) must_not_find: Vec<EvalPattern>,
38-
#[serde(default)]
39-
pub(super) min_total: Option<usize>,
40-
#[serde(default)]
41-
pub(super) max_total: Option<usize>,
42-
}
43-
44-
#[derive(Debug, Clone, Deserialize, Default)]
45-
pub(super) struct EvalPattern {
46-
#[serde(default)]
47-
pub(super) file: Option<String>,
48-
#[serde(default)]
49-
pub(super) line: Option<usize>,
50-
#[serde(default)]
51-
pub(super) contains: Option<String>,
52-
#[serde(default)]
53-
pub(super) contains_any: Vec<String>,
54-
#[serde(default)]
55-
pub(super) matches_regex: Option<String>,
56-
#[serde(default)]
57-
pub(super) severity: Option<String>,
58-
#[serde(default)]
59-
pub(super) category: Option<String>,
60-
#[serde(default)]
61-
pub(super) tags_any: Vec<String>,
62-
#[serde(default)]
63-
pub(super) confidence_at_least: Option<f32>,
64-
#[serde(default)]
65-
pub(super) confidence_at_most: Option<f32>,
66-
#[serde(default)]
67-
pub(super) fix_effort: Option<String>,
68-
#[serde(default)]
69-
pub(super) rule_id: Option<String>,
70-
#[serde(default)]
71-
pub(super) require_rule_id: bool,
72-
}
73-
74-
#[derive(Debug, Clone, Serialize, Deserialize)]
75-
pub(super) struct EvalRuleMetrics {
76-
#[serde(default)]
77-
pub(super) rule_id: String,
78-
#[serde(default)]
79-
pub(super) expected: usize,
80-
#[serde(default)]
81-
pub(super) predicted: usize,
82-
#[serde(default)]
83-
pub(super) true_positives: usize,
84-
#[serde(default)]
85-
pub(super) false_positives: usize,
86-
#[serde(default)]
87-
pub(super) false_negatives: usize,
88-
#[serde(default)]
89-
pub(super) precision: f32,
90-
#[serde(default)]
91-
pub(super) recall: f32,
92-
#[serde(default)]
93-
pub(super) f1: f32,
94-
}
95-
96-
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Default)]
97-
pub(super) struct EvalRuleScoreSummary {
98-
#[serde(default)]
99-
pub(super) micro_precision: f32,
100-
#[serde(default)]
101-
pub(super) micro_recall: f32,
102-
#[serde(default)]
103-
pub(super) micro_f1: f32,
104-
#[serde(default)]
105-
pub(super) macro_precision: f32,
106-
#[serde(default)]
107-
pub(super) macro_recall: f32,
108-
#[serde(default)]
109-
pub(super) macro_f1: f32,
110-
}
111-
112-
#[derive(Debug, Clone, Serialize, Deserialize)]
113-
pub(super) struct EvalFixtureResult {
114-
#[serde(default)]
115-
pub(super) fixture: String,
116-
#[serde(default, skip_serializing_if = "Option::is_none")]
117-
pub(super) suite: Option<String>,
118-
#[serde(default)]
119-
pub(super) passed: bool,
120-
#[serde(default)]
121-
pub(super) total_comments: usize,
122-
#[serde(default)]
123-
pub(super) required_matches: usize,
124-
#[serde(default)]
125-
pub(super) required_total: usize,
126-
#[serde(default, skip_serializing_if = "Option::is_none")]
127-
pub(super) benchmark_metrics: Option<BenchmarkFixtureResult>,
128-
#[serde(default, skip_serializing_if = "Option::is_none")]
129-
pub(super) suite_thresholds: Option<BenchmarkThresholds>,
130-
#[serde(default, skip_serializing_if = "Option::is_none")]
131-
pub(super) difficulty: Option<Difficulty>,
132-
#[serde(default)]
133-
pub(super) rule_metrics: Vec<EvalRuleMetrics>,
134-
#[serde(default)]
135-
pub(super) rule_summary: Option<EvalRuleScoreSummary>,
136-
#[serde(default)]
137-
pub(super) failures: Vec<String>,
138-
}
139-
140-
#[derive(Debug, Clone, Serialize, Deserialize)]
141-
pub(super) struct EvalSuiteResult {
142-
#[serde(default)]
143-
pub(super) suite: String,
144-
#[serde(default)]
145-
pub(super) fixture_count: usize,
146-
#[serde(default)]
147-
pub(super) aggregate: BenchmarkAggregateMetrics,
148-
#[serde(default)]
149-
pub(super) thresholds_enforced: bool,
150-
#[serde(default)]
151-
pub(super) threshold_pass: bool,
152-
#[serde(default)]
153-
pub(super) threshold_failures: Vec<String>,
154-
}
155-
156-
#[derive(Debug, Clone, Serialize, Deserialize)]
157-
pub(super) struct EvalReport {
158-
#[serde(default)]
159-
pub(super) fixtures_total: usize,
160-
#[serde(default)]
161-
pub(super) fixtures_passed: usize,
162-
#[serde(default)]
163-
pub(super) fixtures_failed: usize,
164-
#[serde(default)]
165-
pub(super) rule_metrics: Vec<EvalRuleMetrics>,
166-
#[serde(default)]
167-
pub(super) rule_summary: Option<EvalRuleScoreSummary>,
168-
#[serde(default)]
169-
pub(super) suite_results: Vec<EvalSuiteResult>,
170-
#[serde(default)]
171-
pub(super) threshold_failures: Vec<String>,
172-
#[serde(default)]
173-
pub(super) results: Vec<EvalFixtureResult>,
174-
}
175-
176-
#[derive(Debug, Clone)]
177-
pub struct EvalRunOptions {
178-
pub baseline_report: Option<PathBuf>,
179-
pub max_micro_f1_drop: Option<f32>,
180-
pub min_micro_f1: Option<f32>,
181-
pub min_macro_f1: Option<f32>,
182-
pub min_rule_f1: Vec<String>,
183-
pub max_rule_f1_drop: Vec<String>,
184-
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use serde::Deserialize;
2+
use std::path::PathBuf;
3+
4+
use crate::core::eval_benchmarks::{BenchmarkThresholds, Difficulty};
5+
6+
use super::pattern::EvalExpectations;
7+
8+
#[derive(Debug, Clone, Deserialize, Default)]
9+
pub(in super::super) struct EvalFixture {
10+
#[serde(default)]
11+
pub(in super::super) name: Option<String>,
12+
#[serde(default)]
13+
pub(in super::super) diff: Option<String>,
14+
#[serde(default)]
15+
pub(in super::super) diff_file: Option<PathBuf>,
16+
#[serde(default)]
17+
pub(in super::super) repo_path: Option<PathBuf>,
18+
#[serde(default)]
19+
pub(in super::super) expect: EvalExpectations,
20+
}
21+
22+
#[derive(Debug, Clone)]
23+
pub(in super::super) struct LoadedEvalFixture {
24+
pub(in super::super) fixture_path: PathBuf,
25+
pub(in super::super) fixture: EvalFixture,
26+
pub(in super::super) suite_name: Option<String>,
27+
pub(in super::super) suite_thresholds: Option<BenchmarkThresholds>,
28+
pub(in super::super) difficulty: Option<Difficulty>,
29+
}

src/commands/eval/types/options.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use std::path::PathBuf;
2+
3+
#[derive(Debug, Clone)]
4+
pub struct EvalRunOptions {
5+
pub baseline_report: Option<PathBuf>,
6+
pub max_micro_f1_drop: Option<f32>,
7+
pub min_micro_f1: Option<f32>,
8+
pub min_macro_f1: Option<f32>,
9+
pub min_rule_f1: Vec<String>,
10+
pub max_rule_f1_drop: Vec<String>,
11+
}

src/commands/eval/types/pattern.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
use serde::Deserialize;
2+
3+
#[derive(Debug, Clone, Deserialize, Default)]
4+
pub(in super::super) struct EvalExpectations {
5+
#[serde(default)]
6+
pub(in super::super) must_find: Vec<EvalPattern>,
7+
#[serde(default)]
8+
pub(in super::super) must_not_find: Vec<EvalPattern>,
9+
#[serde(default)]
10+
pub(in super::super) min_total: Option<usize>,
11+
#[serde(default)]
12+
pub(in super::super) max_total: Option<usize>,
13+
}
14+
15+
#[derive(Debug, Clone, Deserialize, Default)]
16+
pub(in super::super) struct EvalPattern {
17+
#[serde(default)]
18+
pub(in super::super) file: Option<String>,
19+
#[serde(default)]
20+
pub(in super::super) line: Option<usize>,
21+
#[serde(default)]
22+
pub(in super::super) contains: Option<String>,
23+
#[serde(default)]
24+
pub(in super::super) contains_any: Vec<String>,
25+
#[serde(default)]
26+
pub(in super::super) matches_regex: Option<String>,
27+
#[serde(default)]
28+
pub(in super::super) severity: Option<String>,
29+
#[serde(default)]
30+
pub(in super::super) category: Option<String>,
31+
#[serde(default)]
32+
pub(in super::super) tags_any: Vec<String>,
33+
#[serde(default)]
34+
pub(in super::super) confidence_at_least: Option<f32>,
35+
#[serde(default)]
36+
pub(in super::super) confidence_at_most: Option<f32>,
37+
#[serde(default)]
38+
pub(in super::super) fix_effort: Option<String>,
39+
#[serde(default)]
40+
pub(in super::super) rule_id: Option<String>,
41+
#[serde(default)]
42+
pub(in super::super) require_rule_id: bool,
43+
}

0 commit comments

Comments
 (0)