11// SPDX-License-Identifier: GPL-3.0-or-later
22
3+ //! # Execution Modes
4+ //!
5+ //! This module provides the core execution patterns for Bear's operation modes.
6+ //! It defines traits and implementations for the producer-consumer pattern
7+ //! used throughout the application.
8+
39mod execution;
410
511use crate :: intercept:: environment;
@@ -8,16 +14,19 @@ use crate::{args, config, output};
814use std:: process:: ExitCode ;
915use std:: sync:: Arc ;
1016
11- /// Represent the modes the application can run in.
17+ /// Represents the application execution modes.
18+ ///
19+ /// Bear supports three user-facing modes:
20+ /// - **Intercept only**: Capture build commands and write them to a file for later analysis.
21+ /// - **Semantic only**: Read previously captured build commands from a file and analyze them.
22+ /// - **Combined**: Capture build commands and analyze them in real-time.
1223///
13- /// To the user the modes are:
14- /// - intercept only: capture build commands and write them to a file.
15- /// - semantic only: read build commands from a file and analyze them.
16- /// - combined: capture build commands and analyze them in one go.
24+ /// Internally, this enum distinguishes between:
25+ /// - `Intercept`: Modes that execute build commands while capturing events (intercept-only and combined)
26+ /// - `Replay`: Modes that process previously captured events (semantic-only)
1727///
18- /// This representation of the mode is based on if we are intercepting the build commands
19- /// or if we are replaying them. If we are analyzing the build events or just writing them
20- /// to a file is not relevant for the mode itself, but rather for the configuration.
28+ /// The distinction between writing raw events vs. performing semantic analysis
29+ /// is handled by the consumer configuration, not the mode itself.
2130pub enum Mode {
2231 Intercept ( execution:: Interceptor , args:: BuildCommand ) ,
2332 Replay ( execution:: Replayer ) ,
@@ -88,11 +97,11 @@ impl Mode {
8897 }
8998 }
9099
91- /// It actually runs the application mode.
100+ /// Runs the application mode.
92101 ///
93- /// This is when the build command is executed in the intercept mode or
94- /// when the event file is read in the replay mode. These errors are all
95- /// run-time errors, the user were passing valid arguments and configurations .
102+ /// This executes the build command in intercept mode or reads the event file in replay mode.
103+ /// All errors returned are runtime errors that occur after valid arguments and configuration
104+ /// have been provided .
96105 pub fn run ( self ) -> ExitCode {
97106 let status = match self {
98107 Self :: Intercept ( interceptor, command) => interceptor. run ( command) ,
0 commit comments