Skip to main content

Module exit_codes

Module exit_codes 

Source
Expand description

Standardized exit codes for dcg commands.

These codes are stable and documented for agent/robot mode consumption. See ADR-002 for the design rationale.

§Exit Code Contract

CodeConstantMeaning
0EXIT_SUCCESSSuccess / Allow
1EXIT_DENIEDCommand denied/blocked
2EXIT_WARNINGWarning (with –fail-on warn)
3EXIT_CONFIG_ERRORConfiguration error
4EXIT_PARSE_ERRORParse/input error
5EXIT_IO_ERRORIO error

§Usage

use dcg::exit_codes::{EXIT_SUCCESS, EXIT_DENIED};

fn main() {
    let result = evaluate_command("rm -rf /");
    std::process::exit(if result.is_denied() {
        EXIT_DENIED
    } else {
        EXIT_SUCCESS
    });
}

Constants§

EXIT_CONFIG_ERROR
Configuration error (invalid config file, missing required config).
EXIT_DENIED
Command was denied/blocked by a security rule.
EXIT_IO_ERROR
IO error (file not found, permission denied, network error).
EXIT_PARSE_ERROR
Parse/input error (invalid JSON, malformed command).
EXIT_SUCCESS
Command completed successfully (allowed, passed, healthy).
EXIT_WARNING
Command triggered a warning (with –fail-on warn).

Traits§

ToExitCode
Trait for converting evaluation results to exit codes.

Functions§

exit_with
Exit the process with the given exit code.
to_exit_code
Convert an exit code constant to std::process::ExitCode.