Skip to main content

aft/
config.rs

1use std::path::PathBuf;
2
3/// Runtime configuration for the aft process.
4///
5/// Holds project-scoped settings and tuning knobs. Values are set at startup
6/// and remain immutable for the lifetime of the process.
7#[derive(Debug, Clone)]
8pub struct Config {
9    /// Root directory of the project being analyzed. `None` if not scoped.
10    pub project_root: Option<PathBuf>,
11    /// How many levels of call-graph edges to follow during validation (default: 1).
12    pub validation_depth: u32,
13    /// Hours before a checkpoint expires and is eligible for cleanup (default: 24).
14    pub checkpoint_ttl_hours: u32,
15    /// Maximum depth for recursive symbol resolution (default: 10).
16    pub max_symbol_depth: u32,
17    /// Seconds before killing a formatter subprocess (default: 10).
18    pub formatter_timeout_secs: u32,
19    /// Seconds before killing a type-checker subprocess (default: 30).
20    pub type_checker_timeout_secs: u32,
21    /// Whether to auto-format files after edits (default: true).
22    pub format_on_edit: bool,
23    /// Whether to auto-validate files after edits (default: false).
24    /// When "syntax", only tree-sitter parse check. When "full", runs type checker.
25    pub validate_on_edit: Option<String>,
26    /// Per-language formatter overrides. Keys: "typescript", "python", "rust", "go".
27    /// Values: "biome", "prettier", "deno", "ruff", "black", "rustfmt", "goimports", "gofmt", "none".
28    pub formatter: std::collections::HashMap<String, String>,
29    /// Per-language type checker overrides. Keys: "typescript", "python", "rust", "go".
30    /// Values: "tsc", "biome", "pyright", "ruff", "cargo", "go", "staticcheck", "none".
31    pub checker: std::collections::HashMap<String, String>,
32    /// Whether to restrict file operations to within `project_root` (default: false).
33    /// When true, write-capable commands reject paths outside the project root.
34    pub restrict_to_project_root: bool,
35}
36
37impl Default for Config {
38    fn default() -> Self {
39        Config {
40            project_root: None,
41            validation_depth: 1,
42            checkpoint_ttl_hours: 24,
43            max_symbol_depth: 10,
44            formatter_timeout_secs: 10,
45            type_checker_timeout_secs: 30,
46            format_on_edit: true,
47            validate_on_edit: None,
48            formatter: std::collections::HashMap::new(),
49            checker: std::collections::HashMap::new(),
50            restrict_to_project_root: false,
51        }
52    }
53}