Configuration API
The configuration module handles loading, parsing, and serializing the .ninety-nine.toml configuration file.
Loading
load_config
#![allow(unused)]
fn main() {
pub fn load_config(project_root: &Path) -> Result<Config, NinetyNineError>
}
Searches for .ninety-nine.toml in the given project root directory. Returns Config::default() if the file does not exist.
Errors: Returns ConfigParse if the file exists but contains invalid TOML, or ConfigIo if the file cannot be read.
default_config_toml
#![allow(unused)]
fn main() {
pub fn default_config_toml() -> Result<String, NinetyNineError>
}
Serializes Config::default() to pretty-printed TOML. Used by the init command.
backoff_base_delay
#![allow(unused)]
fn main() {
pub fn backoff_base_delay(strategy: &BackoffStrategy) -> Duration
}
Extracts the initial delay from a backoff strategy.
| Strategy | Base Delay |
|---|---|
None | 0ms |
Linear { delay_ms } | delay_ms |
Exponential { base_ms, .. } | base_ms |
Fibonacci { start_ms, .. } | start_ms |
Config Model
Config
Top-level configuration struct. All fields have sensible defaults.
#![allow(unused)]
fn main() {
pub struct Config {
pub detection: DetectionConfig,
pub retry: RetryConfig,
pub quarantine: QuarantineConfig,
pub storage: StorageConfig,
pub reporting: ReportingConfig,
}
}
DetectionConfig
Controls flakiness detection behavior.
#![allow(unused)]
fn main() {
pub struct DetectionConfig {
pub min_runs: u32,
pub confidence_threshold: f64,
pub window_size: u32,
pub parallel_runs: u32,
pub duration_regression: Option<DurationRegressionConfig>,
}
}
| Field | Default | Description |
|---|---|---|
min_runs | 10 | Minimum iterations per test |
confidence_threshold | 0.95 | Statistical confidence required to classify as flaky |
window_size | 100 | Maximum historical runs to consider |
parallel_runs | 3 | Number of concurrent test executions |
duration_regression | None | Duration regression tuning; None applies the defaults (enabled, 10-run history, 2 standard deviations) |
RetryConfig
Controls test retry behavior on failure.
#![allow(unused)]
fn main() {
pub struct RetryConfig {
pub unit_test_retries: u32,
pub backoff_strategy: BackoffStrategy,
pub max_retry_time_secs: u64,
}
}
| Field | Default | Description |
|---|---|---|
unit_test_retries | 2 | Maximum retries per failing test; every attempt is recorded as its own run |
backoff_strategy | Exponential(100ms, 2.0x, 5000ms) | Delay strategy between retries |
max_retry_time_secs | 300 | Time limit for a single test execution (seconds) |
BackoffStrategy
#![allow(unused)]
fn main() {
pub enum BackoffStrategy {
None,
Linear { delay_ms: u64 },
Exponential { base_ms: u64, factor: f64, max_ms: u64 },
Fibonacci { start_ms: u64, max_ms: u64 },
}
}
QuarantineConfig
Controls automatic and manual test quarantine.
#![allow(unused)]
fn main() {
pub struct QuarantineConfig {
pub enabled: bool,
pub auto_quarantine: bool,
pub threshold: QuarantineThreshold,
}
}
| Field | Default | Description |
|---|---|---|
enabled | true | Enable quarantine system |
auto_quarantine | false | Automatically quarantine tests exceeding thresholds |
QuarantineThreshold
#![allow(unused)]
fn main() {
pub struct QuarantineThreshold {
pub consecutive_failures: u32,
pub failure_rate: f64,
pub flakiness_score: f64,
}
}
| Field | Default | Description |
|---|---|---|
consecutive_failures | 3 | Consecutive failures before quarantine |
failure_rate | 0.20 | Failure rate threshold (20%) |
flakiness_score | 0.15 | Bayesian score threshold |
StorageConfig
#![allow(unused)]
fn main() {
pub struct StorageConfig {
pub backend: StorageBackendType,
pub retention_days: u32,
pub sqlite: Option<SqliteConfig>,
pub postgres: Option<PostgresConfig>,
}
}
| Field | Default | Description |
|---|---|---|
backend | Sqlite | Storage backend to use |
retention_days | 90 | Days to retain test run data |
StorageBackendType
#![allow(unused)]
fn main() {
pub enum StorageBackendType {
Sqlite,
Postgres,
}
}
SqliteConfig
#![allow(unused)]
fn main() {
pub struct SqliteConfig {
pub database_path: PathBuf,
}
}
Default path: $XDG_DATA_HOME/ninety-nine/ninety-nine.db
PostgresConfig
#![allow(unused)]
fn main() {
pub struct PostgresConfig {
pub connection_string: String,
pub pool_size: u32,
}
}
ReportingConfig
#![allow(unused)]
fn main() {
pub struct ReportingConfig {
pub console: ConsoleOutputConfig,
}
pub struct ConsoleOutputConfig {
pub summary_only: bool, // default: false
}
}
DurationRegressionConfig
#![allow(unused)]
fn main() {
pub struct DurationRegressionConfig {
pub enabled: bool,
pub min_history_runs: u32,
pub threshold: DurationThreshold,
}
pub enum DurationThreshold {
Multiplier(f64),
StdDev(f64),
}
}
See the Configuration Reference for TOML examples.