Closed-Loop Barrier Safety Layer
Implementation & benchmark of arXiv:2607.28830 — Closed-Loop Model-Based Control Barrier Functions with Application to Robust Flight Envelope Protection
Source paper: Closed-Loop Model-Based Control Barrier Functions with Application to Robust Flight Envelope Protection arXiv:2607.28830 ⓘ · analyzed Aug 31, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Attach a quadratic-program safety filter to a neural policy that outputs a desired reference rather than directly replacing the underlying stabilizing controller. The filter uses a model of the complete closed-loop dynamics to make the smallest reference modification satisfying a control-barrier inequality, allowing aggressive neural behavior while preventing violations of state constraints.
Formulas
Mathematical statement
Let $x\in\mathbb{R}^{n}$ be the plant state, $r\in\mathbb{R}^{q}$ the reference supplied to a fixed low-level controller, and $\dot{x}=F(x,r)$ the identified or analytical closed-loop dynamics after substituting the controller into the plant. Let the safe set be $S=\{x:h(x)\geq0\}$, where $h:\mathbb{R}^{n}\to\mathbb{R}$ is continuously differentiable. For $\alpha(s)=\gamma s$ with $\gamma>0$, enforce $\nabla h(x)^{\mathsf T}F(x,r)+\gamma h(x)\geq0$. Given a neural command $r_{\mathrm{nn}}$, compute the least-invasive filtered reference by minimizing a positive-definite weighted command deviation subject to the barrier inequality and reference bounds. If model error satisfies $|\nabla h(x)^{\mathsf T}(F(x,r)-\widehat F(x,r))|\leq\varepsilon(x)$, use the robust margin $\nabla h^{\mathsf T}\widehat F+\gamma h\geq\varepsilon$. Exact feasibility implies forward invariance of the safe set.
Implementation notes
1. Integration point: use a neural policy $r_{\mathrm{nn}}=\pi_\theta(o)$ to generate a reference for an existing stabilizing controller $u=K(x,r)$. Construct or identify the complete closed-loop vector field $\widehat F(x,r)=f(x)+g(x)K(x,r)$, rather than filtering the raw actuator command. Place the QP between the neural policy and the low-level controller. Define one barrier function for every state limit, for example $h_i(x)=x_{i,\max}-x_i$ and $h_i(x)=x_i-x_{i,\min}$, and solve all inequalities jointly. 2. Pseudocode: compute $r_{\mathrm{nn}}=\pi_\theta(o)$; evaluate $h_i(x)$, $\nabla h_i(x)$, and $\widehat F(x,r)$; solve $\min_r\|r-r_{\mathrm{nn}}\|_W^2/2$ subject to $\nabla h_i(x)^\mathsf{T}\widehat F(x,r)+\gamma_i h_i(x)\geq\varepsilon_i(x)$ and reference bounds; send $r^\star$ to $K$. If infeasible, add slacks $s_i\geq0$ and minimize $\|r-r_{\mathrm{nn}}\|_W^2+\rho\sum_i s_i^2$, while logging slack violations. 3. Compute from the mechanism: barrier values, gradients, closed-loop model predictions, QP solutions, and chosen $\gamma_i$. Estimate empirically: model-error margins $\varepsilon_i(x)$ from held-out transition residuals, using a high quantile of $|\nabla h_i^\mathsf{T}(F-\widehat F)|$. Differentiable training can use implicit differentiation through the QP; a forward-only filter is sufficient for the first test. 4. First cheap experiment: train PPO or SAC on a 2D point-mass task with position and velocity limits, comparing an unfiltered policy, raw-action CBF filtering, and closed-loop-reference filtering with the same nominal controller. Sweep $\gamma$, $W$, and the robustness margin. The prediction is that the robust filtered system has minimum measured barrier value $h_{\min}\geq-\delta$, where $\delta$ is set by solver tolerance and residual-bound violations. Near the boundary, $\|r^\star-r_{\mathrm{nn}}\|$ should increase sharply; away from it, the correction should be approximately zero and nominal settling behavior should be unchanged. Increasing $\gamma$ should reduce recovery time with an approximate exponential law $h(t)\sim e^{-\gamma t}h(0)$, while increasing correction magnitude and potentially reducing QP feasibility.
Verification
Stage 1 · Toy mechanism gate: Passed ✓
Stage 2 · Mechanism transferred to benchmark: Not reproduced ✗
Stage 2 · Practical benchmark result: Inconclusive
Methodology: 8 paired seeds, permutation test (p<0.05) against a learning-rate-tuned baseline. How verification works
Stage 1 — Mechanism check agent confidence 9/10
Built an analytic closed-loop reference CBF-QP filter for a scalar reference-tracking plant, including robust model-error margins and baseline comparison. The mechanism manifested: filtered minimum h remained positive (0.0496) while the unfiltered baseline reached -0.4255; the activation threshold matched prediction 1.8367 vs 1.8358; and measured log-decay slopes matched -gamma within 0.0011 across gamma=0.25, 0.5, 1, and 2. The robust-margin check produced zero true barrier residual under a known model error of 0.037.
- Agent confidence
- 9/10
- Baseline
- Unfiltered aggressive reference: minimum h=-0.4255 for r_nn=1.5; across r_nn=[1.1,1.3,1.5], minima=[-0.0454,-0.2355,-0.4255].
- Idea
- Closed-loop CBF projection: minimum h=0.0496 for all tested aggressive references; activation threshold predicted 1.8367, observed 1.8358; exponential log-slope absolute errors were [1.6e-5, 6.3e-5, 2.5e-4, 1.0e-3] for gamma=[0.25,0.5,1,2].
Limitations: This is a deterministic scalar toy rather than a trained neural policy or 2D RL task. It uses an exact analytical closed-loop model and Euler simulation, tests one upper state barrier, and does not benchmark QP runtime, learned model residual estimation, infeasibility slacks, multidimensional reference weighting, or sim-to-real performance.
How to run: python3 barrier_experiment.py
Stage 2 — Benchmark vs. tuned baseline (arXiv:2607.28830)
Ahead of the baseline (−27.9%) but not statistically significant (p=0.0617, wins 6 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0.0021
- Idea mean
- 0.0015
- Effect (Δ)
- -0.0006 (−27.9%; negative = idea better)
- Wins
- 6 / 8 paired seeds
- p-value
- 0.0617 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- ±30.1%
- Mechanism
- Not confirmed ✗
- Practical effect
- Inconclusive
- Baseline tuning
- swept over 3 configs
Only the built-in dynamics pendulum track was tested; no RL policy optimization, raw-actuator CBF comparator, model-error estimation, slack-feasibility analysis, QP runtime, or multi-barrier state-limit experiment was included. The initial run had a tensor-shape bug and was discarded; the reported result is from the corrected rerun.
How to run: python3 stage2_bench.py
Verdict computed by deterministic test code from paired-seed statistics — not by the language model.
Stage 2 — Benchmark latest Failed ✗
Agent confidence: 9/10
Built the closed-loop reference CBF filter around the shared rnn_small pendulum model and evaluated it end-to-end on the structurally matched dynamics track. The idea reduced test MSE from 0.0021058194 to 0.0015174076 (delta -0.0005884118; 6/8 wins), but the paired permutation p-value was 0.06165, so this is a promising but non-significant signal rather than a verified win. The trained-model mechanism signature was confirmed: filtering activated on 3.0% of test cases, with mean correction 0.0012075 and improved minimum reference barrier from -0.3358750 to -0.2456284.
- Baseline
- Best lr=0.006; full 8-seed MSE mean=0.002105819425196387, std=0.000389436566226016
- Idea
- Best lr=0.006, gamma=1.0; full 8-seed MSE mean=0.0015174075815593824, std=0.0006241853888836538
Benchmark result
Ahead of the baseline (−27.9%) but not statistically significant (p=0.0617, wins 6 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0.0021
- Idea mean
- 0.0015
- Effect (Δ)
- -0.0006 (−27.9%; negative = idea better)
- Wins
- 6 / 8 paired seeds
- p-value
- 0.0617 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- ±30.1%
- Mechanism
- Not confirmed ✗
- Practical effect
- Inconclusive
- Baseline tuning
- swept over 3 configs
Only the built-in dynamics pendulum track was tested; no RL policy optimization, raw-actuator CBF comparator, model-error estimation, slack-feasibility analysis, QP runtime, or multi-barrier state-limit experiment was included. The initial run had a tensor-shape bug and was discarded; the reported result is from the corrected rerun.
How to run: python3 stage2_bench.py
Artifacts
- barrier_experiment.py 4.5 KB View Raw
- bench_report.json 4.3 KB View Raw
- report.md 1.5 KB View
- report_bench_2026-08-31T110047.md 6.3 KB View
- results.json 2.0 KB View Raw
- stage2_bench.py 4.5 KB View Raw