ops-gate
Let an AI agent fix your servers without handing it a root shell.
An agent that runs production needs root for real work: read logs, free a full disk, restart a stuck app. Giving it sudo or a shell means one bad prompt can do anything. ops-gate gives the agent a short menu instead:
- Read verbs run at once, repair verbs run within a rate limit, and approval verbs run only with a human's signed, single-use approval for that exact command on that exact server.
- One TOML table defines every verb. The gate checks each call against it, and the sudoers rules are generated from the same table, so the two can never drift apart.
- The agent can propose a new table, but it only takes effect once an approver signs the table that is merged on
main. - It's about 500 lines of Python with one dependency (
cryptography), so it can be audited in an afternoon.
Used in production by RetroSpeedLab
RetroSpeedLab is a game studio run by AI agents (suite). Its maintainer agent keeps two Dokku servers healthy through ops-gate, and every example here is its real table (examples/retrospeedlab/verbs.toml):
agent → ssh maintainer-ops@main "app-logs retro-speedlab-backend 120" # read: runs
agent → ssh maintainer-ops@main "prune-images 96" # repair: at most 3 an hour
agent → ssh maintainer-ops@main "restart retro-speedlab-maintainer" # refused: it may not restart itself
agent → ssh maintainer-ops@main "vacuum-journal 500M" # refused: needs approval
owner → clicks Approve in Discord; the backend signs "vacuum-journal 500M" for main, valid 14 minutes
agent → ssh maintainer-ops@main "vacuum-journal 500M approval=…" # runs once, then the token is spent
How it works
agent ──ssh──▶ authorized_keys: command="ops-gate serve"
│ plain words only; verb, arguments and approval checked against verbs.toml
│ per-class rate limit; signed approval verified and spent
▼
sudo --non-interactive -- <the verb's fixed argv> (sudoers generated from verbs.toml)
A verb is a fixed argv with typed arguments (integer with bounds, choice, or an app name from your platform's app list):
[verbs.app-logs]
class = "read"
limit = "reads"
about = "The last lines of one Dokku app's logs, at most 500."
arguments = ["app", "lines"]
steps = [["/usr/bin/dokku", "logs", "{app}", "--num", "{lines}"]]
An approval is an Ed25519 signature over the purpose, host, exact words, expiry and nonce. The gate refuses it if it is forged, expired, valid for too long, for another host, for different words, or already used.
Quickstart
sudo python3 -m venv /opt/ops-gate && sudo /opt/ops-gate/bin/pip install ops-gate
sudo ln -s /opt/ops-gate/bin/ops-gate /usr/local/bin/ops-gate
ops-gate keygen approver.key # keep the private key with your approver; prints the public key
ops-gate sudoers verbs.toml | sudo tee /etc/sudoers.d/maintainer-ops && sudo visudo --check
# /etc/ops-gate/{verbs.toml,host,approver.pub}; the agent's key in ~maintainer-ops/.ssh/authorized_keys:
# restrict,command="/usr/local/bin/ops-gate serve" ssh-ed25519 AAAA…
ops-gate approve --key approver.key --table verbs.toml --host main vacuum-journal 500M
Your backend signs approvals in code with ops_gate.approval.sign_run(key, purpose, host, words, expiry). Signed table updates are pulled by ops-gate update (a systemd timer) from /etc/ops-gate/approvals-url, checked against the sudoers rules with visudo, then installed.
Development
uv sync && uv run ruff check && uv run mypy && uv run pytest
The acceptance scenarios in tests/features/gate.feature describe the gate's behaviour in plain language.
MIT © datenwissenschaften. Built by Dr. Franke Datenwissenschaften: AI agents and data platforms that run in production.
Metadata
Release files for ops-gate 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ops_gate-0.1.1.tar.gz | 11.4 kB | With provenance | Details for ops_gate-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ops_gate-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for ops_gate-0.1.1-py3-none-any.whl |
Total release size: 25.1 kB
Release files / ops_gate-0.1.1.tar.gz
| Download URL | ops_gate-0.1.1.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b5394cef143da64b51a839534f1722cef8fadca3705dac3f18c9b098b30adc0
|
|
BLAKE2b-256 checksum How to use checksums |
fcd56804a8218f9c6cc4e052d984194d28e5498010a7eb569618b848777e4232
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.
Transparency logRelease files / ops_gate-0.1.1-py3-none-any.whl
| Download URL | ops_gate-0.1.1-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a9dba14ed5c666f40d615b025686fb8511d8da0d28497f40257b13923288ffb5
|
|
BLAKE2b-256 checksum How to use checksums |
4202fe28dd3b0ed14ee86c73fbea4e208ca14013b2a87a57844461821b65f377
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.
Transparency logSecurity for ops-gate 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ops_gate-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.