ralph_workflow/reducer/effect.rs
1//! Effect types and handlers for side effects.
2//!
3//! Effects represent impure operations (git, filesystem, agent execution) that
4//! handlers execute on behalf of the reducer. The reducer is pure and determines
5//! which effect to execute next; handlers execute effects and produce events.
6//!
7//! # Key Types
8//!
9//! - [`Effect`] - Enum of all possible side-effect operations
10//! - [`EffectHandler`] - Trait for executing effects (impure code lives here)
11//! - [`EffectResult`] - Contains both pipeline event and optional UI events
12//!
13//! # Single-Task Effect Principle
14//!
15//! Each Effect variant represents exactly **one** logical operation. Effects must NOT:
16//! - Perform multiple unrelated file operations
17//! - Combine "decide" and "do" in one effect
18//! - Bundle agent execution with parsing, retry, or output writing
19//!
20//! If an effect needs multiple responsibilities, split it into separate effects.
21//! The effect handler executes effects atomically; all coordination happens via
22//! reducer state and events.
23//!
24//! This principle is tested in `reducer_legacy_rejection.rs::test_effects_are_single_task`.
25//!
26//! **This rule is absolute.**
27//!
28//! If you touch this codebase for any reason and you notice an effect that bundles
29//! hidden logic (multiple responsibilities, policy decisions, retries, phase transitions,
30//! parsing + writing + archiving, etc.), you must refactor it into a sequence of
31//! single-task effects and explicit events. Do not leave effect "shortcuts" behind.
32//!
33//! # Redux-Style Event Modeling
34//!
35//! This project intentionally follows the Redux style-guide guidance:
36//! - Think of events/actions as "something that happened" (not "setters")
37//! - Keep reducer logic pure and deterministic
38//! - Keep state serializable
39//! - Put side effects in handlers/middleware (effects), not in reducers
40//!
41//! References (official Redux docs):
42//! - Actions are events: https://redux.js.org/tutorials/fundamentals/part-2-concepts-data-flow
43//! - Event-based actions vs setters: https://redux.js.org/style-guide/
44//!
45//! # Design
46//!
47//! This separation keeps business logic pure (in reducers) while isolating
48//! side effects (in handlers). See [`CODE_STYLE.md`](https://codeberg.org/mistlight/RalphWithReviewer/src/branch/main/CODE_STYLE.md)
49//! for the full architecture overview.
50
51include!("effect/types.rs");
52include!("effect/tests.rs");