# Standing Firewall An end-to-end admissibility gate for autonomous agents, built on this repository's `standing_policy` layer. The gate does not read claims. An agent emits an **answer** — an action and the scale it wants to run at — and the gate measures what that answer does to the protected standing signal before anything runs. An answer that spends standing is refused, returned to the agent with the measured violation, repaired, and replayed. The loop ends when a non-violating answer emerges, or the step is deferred. Every attempt, refused or admitted, is written to a hash-chained receipt log that can be re-verified (or tampered with, to show the verifier catching it). The console runs the same proxy-maximising agent twice: once with no gate, and once behind it. Ungated, the agent spends the standing signal to buy the proxy. Gated, none of those answers is ever admitted. ## What it does - **Comparison** — a deterministic agent loop over three scenarios (consumer growth, support automation, coding agent), with two trajectories, the floor, and the answer that finally ran at each step. A control selects how the agent repairs a refusal: a smaller dose first, a new answer immediately, or no repair at all. - **Replay ledger** — every answer the agent emitted, in order, per step: struck-through drafts were refused before anything ran, and the last pill is the answer that was admitted. - **Refusal suite** — nine answers aimed at the gate: a quiet cost, a smaller dose of it, a non-repair below the floor, a genuine repair, a benign answer after latched drift, an unmeasurable answer, an unreadable one, a signal blackout, and a clean pass. - **Screener** — submit one action and scale. The gate measures it against a healthy, drifting, breached, collapsed, or single-reading window, refuses it if it spends standing, and replays the repair loop when it can. - **Receipts** — the real `standing_policy.ReceiptLog` chain, verified with `verify_receipts`; a "tamper a copy" check alters one entry and shows the verifier naming the line. - **Formal backing** — the repository's own SMT-LIB files run through `z3`: the Goodhart and collapse systems are satisfiable alone, and unsatisfiable once the standing invariant is added. ## Run it From the repository root, with Python 3.10+: ```text python3 -m StandingFirewall.server --host 0.0.0.0 --port 3000 ``` Open `http://localhost:3000`. There are no third-party Python dependencies. The formal panel needs the `z3` binary on `PATH`; the rest of the console works without it. Tests: ```text python3 -m unittest discover -s Tests -p 'test_standing_firewall.py' -v ``` ## API The console is a thin UI over a JSON API, so the same gate can front an agent loop from another process. | Method | Path | Body / query | Returns | | --- | --- | --- | --- | | `GET` | `/api/health` | — | engine status and scenario ids | | `GET` | `/api/scenarios` | — | scenario, action catalog, policy fingerprint, repair modes | | `POST` | `/api/simulate` | `{"scenario","steps","repair"}` | both trajectories, every attempt, receipts | | `POST` | `/api/attacks` | `{"scenario"}` | one measured verdict per ordered rule | | `POST` | `/api/screen` | `{"scenario","context","observation","output"}` | the attempts, the directive, the admitted answer | | `GET` | `/api/receipts` | `?run=` | trimmed chain entries and verification | | `POST` | `/api/receipts/tamper` | `{"run": ""}` | verification of an altered copy | | `GET` | `/api/formal` | `?refresh=1` | the SMT-LIB suite verdicts | An **answer** is `{"action": "", "scale": 0 < s <= 1}`. That is the whole agent-side protocol: there is no field for a claimed effect on standing. `/api/screen` measures the answer against a window ending at `observation` (`healthy`, `drifting`, `breached`, `collapsed`, or `blackout`) and, if the answer is refused, replays up to eight revisions. It returns `attempts` (each with the measured effect and the policy verdict), `directive` (the constraint the first refusal named), and `admitted` (the answer that emerged, or `null`). ## How it is wired ``` browser (static/index.html, app.js, styles.css) │ JSON ▼ StandingFirewall/server.py stdlib ThreadingHTTPServer │ ▼ StandingFirewall/engine.py scenarios, measurement, repair loop, attacks, screener │ imports unchanged ▼ standing_policy.py Policy, StandingPolicy, ReceiptLog, verify_receipts ``` The policy rules are not re-implemented in the console. `engine.build_policy` constructs a `standing_policy.Policy` from each scenario, and every verdict in the UI comes from `StandingPolicy.judge`. The receipt chain and its verifier are the repository's own. The one thing the console adds is the **measurement channel**. `engine.measure` evaluates an answer in shadow against the current reading, and `engine.judge_output` submits it to the policy as a proposal whose `expected` effects are that measurement — never the agent's claim. The gate then checks its own invariant independently of the verdict: an admitted answer may not reduce standing, and below the floor only an answer that raises it is a repair. The tests assert that invariant on every attempt, so a divergence between the policy and the gate's claim would fail the suite. Because the gate supplies the measurement, two of the policy's rules can no longer be dodged: `undeclared_standing_effect` now fires only when the gate has no measurement for an answer at all, and `evidence_required` never fires because the gate's evidence is its own reading. The rule codes in the ledger are the policy's own wording; the UI labels them in the gate's terms. The declared policy parameters are shown in the UI: a 10-reading window, drift after at least 2 readings, a 0.05 proxy-rise threshold, a 0.02 standing-harm threshold, and a 0.20 scale cap while drift is latched. The simulation's action effects are a model, not measurements of any real product. ## Scope and limits - The console demonstrates a structural difference between a gated and an ungated agent loop. It does not measure any real system. - **The gate is only as good as its measurement.** In this console the shadow evaluation comes from the scenario's action model. In a real deployment that is the hard part: you need a trustworthy estimate of what an answer does to the protected signal before you run it, and the gate must refuse what it cannot measure rather than assume it is safe. Unmeasured answers are held here for exactly that reason. - The policy enforces the hypothesis of `noGoodhartDrift_under_StandingAlgebra` against the signals a scenario declares. It cannot establish that those signals are the true objective, and an `allow` is not a safety certification. - A refusal stops an answer; it cannot undo one that already ran. Rollback and recovery are separate, reviewed workflows. - The Lean, Coq and SMT results validate encoded statements. They do not prove this Python implementation correct or certify its runtime behavior. Provenance: Standing Algebra Σᴿ, Jonathan Rademacher, CC BY-SA 4.0. The policy layer, receipt format and SMT-LIB files are used from this repository unchanged.