Skip to content

Commit e0a13f2

Browse files
committed
Merge branch 'prodigy-workflow-1763584344460'
2 parents 8e85bdd + c4beed5 commit e0a13f2

File tree

3 files changed

+76
-204
lines changed

3 files changed

+76
-204
lines changed

specs/163-mapreduce-verbosity-control.md

Lines changed: 0 additions & 199 deletions
This file was deleted.

src/cook/execution/mapreduce/coordination/executor.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,12 @@ impl MapReduceCoordinator {
123123
) -> Self {
124124
let result_collector = Arc::new(ResultCollector::new(CollectionStrategy::InMemory));
125125
let job_id = format!("mapreduce-{}", chrono::Utc::now().format("%Y%m%d_%H%M%S"));
126-
let event_logger = Arc::new(EventLogger::new(project_root.clone(), job_id.clone(), None));
126+
let event_logger = Arc::new(EventLogger::new(
127+
project_root.clone(),
128+
job_id.clone(),
129+
None,
130+
verbosity,
131+
));
127132

128133
// Create claude executor using the real implementation
129134
let command_runner = RealCommandRunner::new();

src/cook/execution/mapreduce/event.rs

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,88 @@ pub struct EventLogger {
2929
_project_root: PathBuf,
3030
_job_id: String,
3131
_session_id: Option<String>,
32+
verbosity: u8,
3233
}
3334

3435
impl EventLogger {
3536
/// Create a new event logger
36-
pub fn new(project_root: PathBuf, job_id: String, session_id: Option<String>) -> Self {
37+
pub fn new(
38+
project_root: PathBuf,
39+
job_id: String,
40+
session_id: Option<String>,
41+
verbosity: u8,
42+
) -> Self {
3743
Self {
3844
_project_root: project_root,
3945
_job_id: job_id,
4046
_session_id: session_id,
47+
verbosity,
4148
}
4249
}
4350

44-
/// Log an event
51+
/// Log an event with verbosity control
4552
pub async fn log_event(&self, event: MapReduceEvent) -> Result<()> {
46-
// For now, just log to tracing
47-
tracing::info!("MapReduce event: {:?}", event);
53+
// Always log errors regardless of verbosity
54+
if matches!(event, MapReduceEvent::AgentFailed { .. }) {
55+
tracing::info!("MapReduce event: {:?}", event);
56+
return Ok(());
57+
}
58+
59+
// Only log verbose events in verbose mode (verbosity >= 1)
60+
if self.verbosity >= 1 {
61+
match &event {
62+
MapReduceEvent::AgentCompleted {
63+
agent_id,
64+
item_id,
65+
duration,
66+
cleanup_status,
67+
commits,
68+
json_log_location,
69+
..
70+
} => {
71+
// Truncate commit list if it's too long (unless verbosity >= 2)
72+
let commits_display = if commits.len() > 10 && self.verbosity < 2 {
73+
format!(
74+
"[{:?}, {:?}, ... ({} more)]",
75+
commits.first().unwrap_or(&String::new()),
76+
commits.get(1).unwrap_or(&String::new()),
77+
commits.len() - 2
78+
)
79+
} else {
80+
format!("{:?}", commits)
81+
};
82+
83+
tracing::info!(
84+
"MapReduce event: AgentCompleted {{ agent_id: {:?}, item_id: {:?}, duration: {:?}, cleanup_status: {:?}, commits: {}, json_log_location: {:?} }}",
85+
agent_id,
86+
item_id,
87+
duration,
88+
cleanup_status,
89+
commits_display,
90+
json_log_location
91+
);
92+
}
93+
_ => {
94+
tracing::info!("MapReduce event: {:?}", event);
95+
}
96+
}
97+
} else {
98+
// In default mode, only log phase-level events
99+
match event {
100+
MapReduceEvent::MapPhaseStarted { .. }
101+
| MapReduceEvent::MapPhaseCompleted { .. }
102+
| MapReduceEvent::ReducePhaseStarted { .. }
103+
| MapReduceEvent::ReducePhaseCompleted { .. } => {
104+
tracing::info!("MapReduce event: {:?}", event);
105+
}
106+
// Suppress AgentStarted, AgentCompleted, and AgentFailed in default mode
107+
// (AgentFailed is already handled above and always shown)
108+
MapReduceEvent::AgentStarted { .. }
109+
| MapReduceEvent::AgentCompleted { .. }
110+
| MapReduceEvent::AgentFailed { .. } => {}
111+
}
112+
}
113+
48114
Ok(())
49115
}
50116
}

0 commit comments

Comments
 (0)