Skip to main content

terok-clearance

terok-clearance

PyPI License: Apache-2.0 REUSE status Quality Gate Status

Live allow/deny prompts for the terok-shield firewall — desktop notifications, varlink hub, verdict helper.

When a hardened terok container hits a blocked outbound destination, the operator sees a desktop notification with Allow and Deny buttons; the chosen verdict is written into the running container's nftables ruleset.

terok ecosystem — terok-clearance turns blocked-traffic events into operator decisions

What is the clearance system

The clearance system is the operator-in-the-loop decision path for terok's egress firewall. It is built from a hub and verdict pair that talk over a varlink Unix socket and surface decisions through the freedesktop Notifications D-Bus interface:

sequenceDiagram
    participant C as Container
    participant S as terok-shield<br/>(nftables)
    participant H as clearance-hub
    participant U as Operator (desktop)
    participant V as clearance-verdict

    C->>S: outbound packet to api.example.com
    S-->>C: REJECT (default-deny)
    S->>H: blocked-connection event<br/>(NFLOG → varlink)
    H->>U: desktop notification<br/>"Allow api.example.com?"
    U->>H: clicks "Allow"
    H->>V: Apply(container, dest, allow)
    V->>S: terok-shield allow … api.example.com
    S-->>S: nft add element …
    S-->>C: subsequent packets pass

The hub and the verdict server are composed in-process by the per-container supervisor that terok-sandbox's OCI hook spawns — one supervisor (and therefore one hub socket) per container. The hub fans events out to whichever operator UIs are subscribed (the terok-clearance-hub clearance terminal tool, the embedded terok-tui screen, a DbusNotifier posting popups on the D-Bus session bus). The verdict server is the only piece that execs terok-shield (which reaches into the container's network namespace), so it sits behind the hub's authz boundary and keeps the privileged exec path isolated.

What it provides

  • Async-first Python API — create_notifier(), Notifier protocol, DbusNotifier, CallbackNotifier, NullNotifier
  • Varlink hub — ClearanceHub, ClearanceClient, EventSubscriber — the subscriber API operator UIs build on (the TUI renders live verdicts through it)
  • Multi-socket subscriber — MultiSocketSubscriber multiplexes the per-container hub sockets at $XDG_RUNTIME_DIR/terok/clearance/<short_id>/hub.sock so a single UI sees the union of every supervisor's event stream
  • Embeddable verdict server — VerdictServer for the per-container supervisor to compose alongside the hub
  • Graceful degradation — NullNotifier is returned when no D-Bus session bus is available, so headless hosts can still run the rest of the stack

Where it sits in the stack

terok-clearance is the user-in-the-loop side-rail of the terok ecosystem. Above it, terok's TUI subscribes to every per-container hub socket to display verdicts in-band; on a desktop session the same events fire freedesktop popups. Below it, the verdict server reaches into terok-shield to mutate the running ruleset. Lifecycle is owned by terok-sandbox's per-container supervisor, which composes the hub and verdict server in-process for every container it watches.

The notification API (create_notifier(), the Notifier protocol) is usable standalone for generic desktop-notification needs.

Requirements

  • Linux with a D-Bus session bus (any desktop environment with a notification daemon) — the package degrades cleanly to a no-op notifier when no bus is reachable
  • Python 3.12+

Installation

pip install terok-clearance

For most users this dependency is pulled in transitively by terok-sandbox. Install it directly only when embedding the API in your own tooling.

Quick start

Send a notification

import asyncio
from terok_clearance import create_notifier


async def main():
    notifier = await create_notifier(app_name="terok")
    action_received = asyncio.Event()

    def on_action(action_key):
        print(action_key)
        action_received.set()

    nid = await notifier.notify(
        "Clearance request",
        "Task alpha wants access to api.github.com:443",
        actions=[("allow", "Allow"), ("deny", "Deny")],
    )
    await notifier.on_action(nid, on_action)

    await action_received.wait()
    await notifier.disconnect()


asyncio.run(main())

CLI tool (development / testing)

terok-clearance-hub notify "Title" "Body"   # one-shot desktop notification
terok-clearance-hub serve                   # run a clearance hub
terok-clearance-hub serve-verdict           # run the verdict helper
terok-clearance-hub clearance               # interactive terminal UI

License

Apache-2.0 — see LICENSES/Apache-2.0.txt.

Metadata

Release files for terok-clearance 0.8.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for terok-clearance 0.8.3
File Size Uploaded Provenance Actions
terok_clearance-0.8.3.tar.gz 261.6 kB With provenance Details for terok_clearance-0.8.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for terok-clearance 0.8.3
File Interpreter ABI Platform Actions
terok_clearance-0.8.3-py3-none-any.whl Python 3 none any Details for terok_clearance-0.8.3-py3-none-any.whl

Total release size: 350.3 kB

Release files / terok_clearance-0.8.3.tar.gz

Download URL terok_clearance-0.8.3.tar.gz
Size 261.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2731b93887b2184dc264e391ca6e7419e763865a58fb51e1d59233a296e34a8f
BLAKE2b-256 checksum
How to use checksums
0c616b53dc4150c6e5f35be27d90117e4193c61bd8a4a759b23d6cdf7d9b431f
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 Nov 17, 2026.

Transparency log

Release files / terok_clearance-0.8.3-py3-none-any.whl

Download URL terok_clearance-0.8.3-py3-none-any.whl
Size 88.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b4edcb6650c926aba3f2b0a9badaaea284ff05d7ba442e1b79c64112baf13108
BLAKE2b-256 checksum
How to use checksums
a0119648779f17c7d8583ded0a42d9d63a0035f74914243a5a4d69955054ea17
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 Nov 17, 2026.

Transparency log

Security for terok-clearance 0.8.3

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.

Select from 2 files

Attestation for terok_clearance-0.8.3.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 Nov 17, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page