Skip to main content

z4j framework-free agent bootstrapper (Apache 2.0)

Project description

z4j-bare

PyPI version Python License

License: Apache 2.0 Status: v1.0.0 — first public release.

Framework-free agent runtime for z4j. Ships both as a pure-Python supervisor for standalone workers (no Django / Flask / FastAPI) and as proof that z4j-core is genuinely framework-free — z4j-bare is what every framework adapter is built on top of.

Install

pip install z4j-bare

# Optionally add dev-mode filesystem watcher (for live task-registry
# reloads when tasks.py changes on disk; off in production):
pip install "z4j-bare[watcher]"

What it does

  • AgentRuntime — pure-Python agent runtime, no framework hooks.
  • WebSocket transport with exponential-backoff reconnect.
  • HTTPS long-poll fallback for networks that block WebSocket.
  • Local SQLite buffer (WAL mode, size-capped, crash-safe event storage).
  • Command dispatcher — routes brain commands to registered engine + scheduler adapters.
  • Heartbeat loop with liveness + last-seen stamping.
  • Orchestrator detection — identifies Docker / Kubernetes / systemd / supervisord hosts for restart_worker safety-gating.
  • Per-project HMAC v2 signing using the shared wire-protocol helpers from z4j-core.
  • Process singleton guard — prevents duplicate agents from the same project on one host.
  • CLI: python -m z4j_bare run --config ...

Use cases

  • Celery / RQ / Dramatiq workers not served by a web framework.
  • ML pipelines that run Celery but don't use Django.
  • Containers where the agent runs as its own process, separate from the app.
  • Custom Python scripts that dispatch tasks and want to report lifecycle events to the z4j brain.

Usage — in-process

from celery import Celery
from z4j_bare import install_agent
from z4j_celery import CeleryEngineAdapter

app = Celery("myproject", broker="redis://localhost/0")

agent = install_agent(
    engines=[CeleryEngineAdapter(celery_app=app)],
    brain_url="https://z4j.internal",
    token="z4j_agent_...",
    project_id="ml-pipeline-prod",
)

Usage — standalone process

python -m z4j_bare run \
    --brain-url https://z4j.internal \
    --token $Z4J_TOKEN \
    --project-id ml-pipeline-prod \
    --engine celery \
    --celery-app myproject.celery:app

Reliability contract

Per the z4j safety rule (docs/CLAUDE.md §2.2), the agent must never break the host application:

  • No exception inside the runtime propagates to Celery / Django / FastAPI signal handlers.
  • Network I/O never blocks signal handlers (events queue to an in-memory ring, flushed from a background thread).
  • When the brain is unreachable, events buffer to local SQLite with exponential backoff.
  • Buffer drops oldest events when full; the host app is never slowed or blocked.

Documentation

  • Adapter guide — how z4j-bare composes with engine + framework adapters.
  • Architecture — agent/brain topology, transport layer, reconciliation.
  • Security — threat model, HMAC v2 envelope signing, redaction.

License

Apache 2.0. See LICENSE. z4j-bare installs cleanly into proprietary Python workers — there is no copyleft obligation. The brain server it talks to (z4j-brain) is AGPL-3.0; communicating with it over the network does not subject your worker code to AGPL.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

z4j_bare-1.0.0.tar.gz (70.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

z4j_bare-1.0.0-py3-none-any.whl (64.7 kB view details)

Uploaded Python 3

File details

Details for the file z4j_bare-1.0.0.tar.gz.

File metadata

  • Download URL: z4j_bare-1.0.0.tar.gz
  • Upload date:
  • Size: 70.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.8

File hashes

Hashes for z4j_bare-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d39e6f34007599f6f53049f5c94d799134beb4edfcbe5b7966a2a50d4261b26a
MD5 8f5e996ebb853f4ad1e0fe80b1a56396
BLAKE2b-256 03bf13a0f4c760ca86b2241a3f5f10b41f9a11e59d2bc5eb96818d52395cdf34

See more details on using hashes here.

File details

Details for the file z4j_bare-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: z4j_bare-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 64.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.8

File hashes

Hashes for z4j_bare-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eae7c5d2e05cf38e5d860fbfc46646c3637b80d20e02cff9b1f122ff7255dbcf
MD5 6c3779a7475d60ea59868a5d1123a7aa
BLAKE2b-256 4ca9ed4739490ca6b5444a410c8339bd4712ed1f91642991077815ea086da3e2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page