AFALS asks how far the assumptions behind a safety guarantee can be stretched before the
guarantee breaks. The system under test is an adaptive cruise controller (ACC) wrapped by a
Responsibility-Sensitive Safety (RSS) layer, which is collision-free if its assumptions hold:
bounded reaction latency, exact measurements, a lead vehicle that never brakes harder than
b_max_brake, and an ego vehicle that can always brake with at least b_min_brake.
Instead of searching only over traffic scenarios, AFALS searches over violations of these assumptions (actuation delay, actuator lag, sensor latency, noise, bias, dropout, excess lead braking, reduced ego braking), and compares search methods — uniform random, Latin hypercube, CMA-ES, TPE (Bayesian optimization) and simulated annealing — at finding collisions under an equal simulation budget, and at finding the smallest assumption violation that causes a collision.
Left: the smallest assumption violation that makes the controller crash, found by five search methods (lower is better; CMA-ES and TPE separate from the rest). Right: actuation delay against gap bias; the black line is where the controller starts to fail, and only a small corner near nominal is safe.
| What is tested | An adaptive cruise controller with a Responsibility-Sensitive Safety layer, in lead-braking and cut-in scenarios |
| What is searched | 10 dimensions of assumption violation (delay, lag, latency, noise, bias, dropout, lead and ego braking) |
| Search methods | Random, Latin hypercube, CMA-ES, Bayesian optimisation (TPE), simulated annealing; 30 repetitions of 1,000 simulations each |
| Smallest failing violation | CMA-ES median 0.085 against 0.745 for random search (8.8x smaller), significant after Holm correction |
| Where the guarantee breaks first | Ego braking at 3.87 m/s² against the assumed 4; actuation delay of 0.31 s |
| Sanity | 300,000 nominal simulations without a collision; every run reproducible bit for bit from its configuration hash |
The full technical specification is SPEC.md. Decisions made during implementation are in docs/adr/; every study parameter is listed in docs/assumptions.md.
Status: toolkit implemented and tested; full experiments E0–E5 run (5 methods × 30 repetitions × 1000 evaluations per experiment). Results: docs/results.md; generated reports: reports/.
Study defaults: ρ = 0.5 s, b_min_brake = 4 m/s², b_max_brake = 8 m/s² (see docs/assumptions.md).
Details, statistics and caveats are in docs/results.md.
- Nominal guarantee held: 300,000 sanity evaluations across both scenarios and all five methods found no collision with every assumption nominal (empirical, not a proof).
- The guarantee is tight at its assumptions. With the other assumptions nominal, collisions appear at an ego braking capability of 3.87 m/s² (3 % below b_min), at the first actuation delay that pushes total latency past ρ (0.31 s), and at lead braking of 8.5 m/s². Zero-mean measurement noise is the least fragile. These critical values are upper bounds.
- Minimal violation (RQ3): CMA-ES finds the smallest failing violations (median magnitude 0.085 lead brake, 0.088 cut-in), then TPE (0.25, 0.27); annealing, random and LHS reach 0.72–0.87. All CMA-ES and TPE comparisons are significant after Holm correction with large effect sizes.
- Falsification (RQ2) did not discriminate: with the shipped bounds about 77 % of random points already crash, so every method finds a fault within a few evaluations. On cut-in, CMA-ES and TPE are drawn to unsafe starts (precondition violations), which the plain-robustness objective does not penalize.
- Diversity (RQ4) is not answered: the DBSCAN cluster count rewards concentrated search in a 10-dimensional space, so it is reported but not interpreted.
- An experiment YAML references a controller, simulator, scenario, requirement, search space and a list of search methods. It is validated (Pydantic, cross-file checks) and hashed.
- Each run (method × repetition) proposes points in a unit hypercube. Each point is decoded into scenario parameters plus a violation vector, simulated deterministically for each noise seed, and scored by the worst-case minimum bumper gap (robustness, m).
- Failures are classified:
controller_fault(an assumption was violated and the ego crashed),precondition_violated(the scenario itself started unsafe, e.g. a cut-in closer than the RSS distance), orproof_mismatch(a crash with no assumption violated — a critical finding). - The violation magnitude is unit-free: each dimension's excess beyond its assumption threshold is divided by its searched violating range, combined with a p-norm (ADR-010).
- Results go to SQLite (
data/results.db) plus compressed traces;afals analyzecomputes statistics, failure clusters and assumption boundaries;afals reportwrites Markdown + SVG.
The simulator is a one-dimensional longitudinal model with exact constant-acceleration kinematics, a stop clamp, and the exact minimum gap inside each step. A sanity experiment and a property-based test (10,000 random nominal scenarios per scenario type) check that the nominal system never crashes; so far it has not.
Requirements: Python 3.11, Git, uv (pip install uv). Windows 10/11
or Linux.
git clone https://github.com/sriyaaa2003/afals.git && cd afals
uv sync --all-extras # creates .venv from uv.lock
# Windows: .venv\Scripts\Activate.ps1 Linux: source .venv/bin/activate
afals db init # creates ./data/results.db
afals config validate configs/experiments/smoke.yaml
afals run configs/experiments/smoke.yaml # 5 methods x 2 reps x 20 evaluations, seconds
afals status # lists experiment ids
afals analyze <EXP_ID> --kind stats --params configs/analysis/stats.yaml
afals analyze <EXP_ID> --kind clusters --params configs/analysis/clusters.yaml
afals report <EXP_ID> # writes reports/<name>_<hash8>/report.mdInspect one point:
afals simulate configs/experiments/falsify_lead_brake.yaml \
--params '{"v_ego0": 30, "v_lead0": 30, "gap_factor": 0, "t_brake": 2, "brake_duration": 10, "lead_decel": 8, "actuation_delay_s": 0.8, "actuator_lag_tau_s": 0.1, "sensor_latency_s": 0, "gap_noise_std_m": 0, "gap_bias_m": 0, "lead_speed_noise_std_mps": 0, "lead_speed_bias_mps": 0, "dropout_prob": 0, "ego_brake_capability_mps2": 9}' \
--plot trace.svgpip fallback (unlocked, weaker reproducibility): python -m venv .venv, activate,
pip install -e ".[dev]".
| Command | Purpose |
|---|---|
afals db init / db migrate / db check / db checkpoint |
database setup and maintenance |
afals config validate EXP.yaml |
validate and print the resolved config and its hash |
afals simulate EXP.yaml --params JSON [--noise-seed N] [--plot F.svg] [--save-trace F.npz] |
evaluate one physical point |
afals run EXP.yaml [--methods a,b] [--repetitions N] [--workers N] [--parallel-runs N] [--force] |
run an experiment (idempotent, resumable) |
afals status [EXP_ID] [--ids-only] |
experiments and run states |
afals analyze EXP_ID --kind {stats,clusters,boundary_1d,boundary_2d} [--params YAML] [--workers N] |
analyses |
afals report EXP_ID [--out DIR] |
Markdown report |
afals cache stats / afals cache clear [--older-than DAYS] |
evaluation cache |
afals export EXP_ID --format csv --out DIR |
CSV export |
Exit codes: 0 success, 1 internal error, 2 invalid config/arguments, 3 a run FAILED, 4 interrupted (resume with the same command), 5 database/filesystem error, 6 required analysis missing, 7 proof mismatch (nominal failure found).
Global options: --data-dir (default AFALS_DATA_DIR or ./data), --log-level,
--log-format {text,json}. Environment: AFALS_DATA_DIR, AFALS_LOG_LEVEL, AFALS_LOG_FORMAT,
AFALS_WORKERS, AFALS_CONFIG_ROOTS.
See docs/experiment_protocol.md for E0 (sanity), E1 (1D boundaries),
E2/E3 (falsification and minimal violation on lead_brake), E4 (cut_in) and E5 (2D heatmaps),
with commands, expected cost and ablations. Every experiment is identified by the hash of its
resolved configuration; the same config, code version and platform give bit-identical evaluations.
uv run ruff format --check . && uv run ruff check . && uv run mypy src
uv run pytest -m "not slow and not benchmark" # fast suite (~2 min; ~7 min with --cov)
uv run pytest -m slow # 10,000-example nominal property + sanity/positive control
uv run pytest -m benchmark --benchmark-only # opt-in simulation speedMeasured on the development laptop: one 30 s simulation at dt = 0.01 s takes about 25 ms.
- No scikit-learn or matplotlib (ADR-018). Windows Smart App Control on the development
machine blocks their compiled extensions. DBSCAN is implemented on top of SciPy's KD-tree and
figures are written as SVG directly, so reports contain
.svginstead of.png. - Smaller implementation decisions are listed in ADR-015, ADR-016, ADR-017 and ADR-019.
1D longitudinal abstraction (cut-in = a lead appearing in lane); the nominal guarantee is checked
empirically, not proven; boundaries are upper bounds from an approximate inner search; delays are
quantized to dt; all RSS/ACC parameters and search bounds are study choices; results depend on
the fixed noise seeds. See the limitations section of any generated report.
Four studies on the safety validation of automated driving, all on real or realistic data: AFALS (this one), risk-predictors (how much data a safety metric needs), cutin-atlas (parameterizing, clustering and efficiently simulating real cut-ins) and synth-mix (synthetic weather imagery for object detectors).
MIT, see LICENSE.