Skip to content

Commit 05c4944

Browse files
committed
refactor: split feedback eval command helpers
Separate feedback input loading from report emission so the command entrypoint stays focused on wiring the two phases together. Made-with: Cursor
1 parent 198ff4c commit 05c4944

4 files changed

Lines changed: 49 additions & 21 deletions

File tree

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
- [ ] `src/commands/misc/discussion/selection.rs`: split file loading/ID repair from selection rules.
9292
- [ ] `src/commands/misc/changelog.rs`: evaluate splitting changelog collection from output formatting.
9393
- [ ] `src/commands/eval/command.rs`: separate CLI option prep, fixture execution, and report lifecycle.
94-
- [ ] `src/commands/feedback_eval/command.rs`: separate input loading from report/output orchestration.
94+
- [x] `src/commands/feedback_eval/command.rs`: separate input loading from report/output orchestration.
9595

9696
### Review pipeline backlog
9797

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,19 @@
1+
#[path = "command/load.rs"]
2+
mod load;
3+
#[path = "command/report.rs"]
4+
mod report;
5+
16
use anyhow::Result;
27
use std::path::PathBuf;
38

4-
use super::input::load_feedback_eval_input;
5-
use super::report::{
6-
build_feedback_eval_report, print_feedback_eval_report, write_feedback_eval_report,
7-
};
9+
use load::load_feedback_eval_or_bail;
10+
use report::emit_feedback_eval_report;
811

912
pub async fn feedback_eval_command(
1013
input_path: PathBuf,
1114
output_path: Option<PathBuf>,
1215
confidence_threshold: f32,
1316
) -> Result<()> {
14-
let loaded = load_feedback_eval_input(&input_path).await?;
15-
if loaded.comments.is_empty() {
16-
anyhow::bail!(
17-
"No accepted/rejected feedback examples found in {}",
18-
input_path.display()
19-
);
20-
}
21-
22-
let report = build_feedback_eval_report(&loaded, confidence_threshold.clamp(0.0, 1.0));
23-
print_feedback_eval_report(&report);
24-
25-
if let Some(path) = output_path.as_deref() {
26-
write_feedback_eval_report(&report, path).await?;
27-
}
28-
29-
Ok(())
17+
let loaded = load_feedback_eval_or_bail(&input_path).await?;
18+
emit_feedback_eval_report(&loaded, output_path.as_deref(), confidence_threshold).await
3019
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use anyhow::Result;
2+
use std::path::Path;
3+
4+
use super::super::input::load_feedback_eval_input;
5+
use super::super::LoadedFeedbackEvalInput;
6+
7+
pub(super) async fn load_feedback_eval_or_bail(path: &Path) -> Result<LoadedFeedbackEvalInput> {
8+
let loaded = load_feedback_eval_input(path).await?;
9+
if loaded.comments.is_empty() {
10+
anyhow::bail!(
11+
"No accepted/rejected feedback examples found in {}",
12+
path.display()
13+
);
14+
}
15+
16+
Ok(loaded)
17+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use anyhow::Result;
2+
use std::path::Path;
3+
4+
use super::super::report::{
5+
build_feedback_eval_report, print_feedback_eval_report, write_feedback_eval_report,
6+
};
7+
use super::super::LoadedFeedbackEvalInput;
8+
9+
pub(super) async fn emit_feedback_eval_report(
10+
loaded: &LoadedFeedbackEvalInput,
11+
output_path: Option<&Path>,
12+
confidence_threshold: f32,
13+
) -> Result<()> {
14+
let report = build_feedback_eval_report(loaded, confidence_threshold.clamp(0.0, 1.0));
15+
print_feedback_eval_report(&report);
16+
17+
if let Some(path) = output_path {
18+
write_feedback_eval_report(&report, path).await?;
19+
}
20+
21+
Ok(())
22+
}

0 commit comments

Comments
 (0)