Health protocol client for distributed local agents (Varta VLP v0.2).
Project description
Varta — Python client
Production Python client for the Varta
health protocol. Emits 32-byte VLP heartbeats to a varta-watch
observer over Unix Domain Sockets, plaintext UDP, or
ChaCha20-Poly1305-encrypted UDP.
pip install varta # base client (stdlib only)
pip install 'varta[secure]' # adds secure-UDP via `cryptography`
Quickstart
import time
from varta import Varta, Status
with Varta.connect("/run/varta/observer.sock") as agent:
while True:
outcome = agent.beat(Status.OK)
if outcome.is_dropped:
# Observer absent, kernel queue full, peer gone, or disk full.
# Treat as a no-op; the next beat will retry.
pass
time.sleep(0.5)
API parity with varta-client (Rust)
| Rust | Python |
|---|---|
Varta::connect(path) |
Varta.connect(path) |
Varta::connect_udp(addr) |
Varta.connect_udp(addr) |
Varta::connect_secure_udp(addr, key) |
Varta.connect_secure_udp(addr, key) |
Varta::connect_secure_udp_with_master(addr, mkey) |
Varta.connect_secure_udp_with_master(addr, mkey) |
Varta::beat(status, payload) -> BeatOutcome |
Varta.beat(status, payload) -> BeatOutcome |
BeatOutcome::{Sent, Dropped, Failed} |
BeatOutcome (tagged dataclass: .is_sent / .is_dropped / .is_failed) |
DropReason::{KernelQueueFull, NoObserver, PeerGone, StorageFull} |
DropReason (StrEnum) — same four variants |
BeatError { errno, kind } |
BeatError(errno, kind) frozen dataclass |
classify_send_error |
classify_send_error(exc) |
Varta::reconnect, set_reconnect_after |
Same names |
Varta::clock_regressions(), fork_recoveries() |
Same names |
install_panic_handler* |
varta.panic.install_excepthook_* |
Hard invariants
The Python client preserves the Rust client's wire-level contract:
- Non-blocking I/O. Every socket is
setblocking(False). A kernel-queue-full send surfaces asBeatOutcome.dropped(DropReason.KERNEL_QUEUE_FULL), never a block. - Per-emission
os.getpid(). No PID caching — forked children report their own identity on the next beat. Fork auto-recovery refreshes the transport (and, for secure-UDP, re-reads OS entropy) before the frame leaves the child. - Wire-format conformance. The package ships a test that loads
tools/vlp-test-vectors.json(the same fixture the Rust crate verifies against) and asserts byte-equality for every CRC, frame, and AEAD vector. Drift between languages is impossible without breaking both tests in the same PR.
Latency non-goal
Python cannot match the ~1 µs-per-beat budget of the Rust client.
Measured cost on the project's bench host is ~15–30 µs per beat()
including frame allocation, syscall, and outcome dispatch. The Python
client is intended for tooling, batch jobs, web-app sidecars, and
adapters — not for tight inner loops emitting kilo-beats per second.
Secure UDP
pip install 'varta[secure]' pulls in
cryptography, which provides
the ChaCha20-Poly1305 primitive. Without the extra, the secure-UDP
constructors raise an actionable
varta._vlp_secure.CryptographyMissingError at call time. Base
encode/decode and the panic-hook UDS/UDP variants remain stdlib-only.
Panic hook
from varta.panic import install_excepthook_uds
install_excepthook_uds("/run/varta/observer.sock")
# any uncaught exception now emits a Status.CRITICAL beat
Python's sys.excepthook does not fire on hard crashes (SIGSEGV,
SIGABRT). Pass faulthandler_signals=True to also wire
faulthandler.enable() against the bound socket as a side channel for
those events. The output is a Python traceback, not a VLP frame —
useful for postmortem, but not a structured beat.
The Rust accept-degraded-entropy variant is intentionally not
implemented in Python: that feature exists for embedded targets that
lack /dev/urandom; CPython itself does not run on such targets.
See also
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file varta-0.1.0.tar.gz.
File metadata
- Download URL: varta-0.1.0.tar.gz
- Upload date:
- Size: 24.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b029d2ac248d46494483af550296f54562f3104ebceb18ebc43ea9be77a8bf6
|
|
| MD5 |
8c2f08912fd29580aac591a27f68168f
|
|
| BLAKE2b-256 |
bd2a2cfce4d176cec8cba072f2beef9f774c2aa3655ab5d68c22568632cd3a10
|
Provenance
The following attestation bundles were made for varta-0.1.0.tar.gz:
Publisher:
python-publish.yml on aramirez087/varta
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
varta-0.1.0.tar.gz -
Subject digest:
4b029d2ac248d46494483af550296f54562f3104ebceb18ebc43ea9be77a8bf6 - Sigstore transparency entry: 1555200062
- Sigstore integration time:
-
Permalink:
aramirez087/varta@eff161941607d9b9a2fe31bc59c7fb13d2ceb97d -
Branch / Tag:
refs/tags/python-v0.1.0 - Owner: https://github.com/aramirez087
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@eff161941607d9b9a2fe31bc59c7fb13d2ceb97d -
Trigger Event:
push
-
Statement type:
File details
Details for the file varta-0.1.0-py3-none-any.whl.
File metadata
- Download URL: varta-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0bbfb042cdbc78463c4f8724ef03854331b0c4e9a44e57c09d6725f5228a6917
|
|
| MD5 |
d5623da609f2cd07b5e24732d9646813
|
|
| BLAKE2b-256 |
abc674d92f0d20c8a4ec92a4b1f25f45e380dee1d986c1259d14c18e1359e877
|
Provenance
The following attestation bundles were made for varta-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on aramirez087/varta
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
varta-0.1.0-py3-none-any.whl -
Subject digest:
0bbfb042cdbc78463c4f8724ef03854331b0c4e9a44e57c09d6725f5228a6917 - Sigstore transparency entry: 1555200068
- Sigstore integration time:
-
Permalink:
aramirez087/varta@eff161941607d9b9a2fe31bc59c7fb13d2ceb97d -
Branch / Tag:
refs/tags/python-v0.1.0 - Owner: https://github.com/aramirez087
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@eff161941607d9b9a2fe31bc59c7fb13d2ceb97d -
Trigger Event:
push
-
Statement type: