fiberd for Python
The Python SDK. fiberd.template is for code that runs inside a fiber, such as an AI agent. fiberd.client is for callers of fiberd, such as the activator that asks for one.
Install
pip install fiberd
The wheels are for CPython 3.14 or later on Linux, x86_64 or aarch64, with glibc 2.28 or later. Anywhere else pip builds the sdist. On Linux that needs a C compiler, the Python headers and cargo. The build needs no network. Off Linux it builds without the extension. There fiberd.client works and fiberd.template raises ImportError when used.
Template
A template warms up once and forks a fiber for every Clone. Call init() first, do the warm-up, then serve(on_fiber).
import json
import fiberd.template as ft
ft.init() # first line, before any thread
# Your own slow setup goes here (imports, model weights, config). It runs
# once, and every fiber is a fork of this process, born with it loaded.
with open("prompts.json") as fp:
prompts = json.load(fp)
def on_fiber(f: ft.Fiber) -> int: # runs in the fiber
task = json.loads(f.payload) # the bytes the caller sent with the Clone
def handle(conn):
question = conn.recv(4096).decode()
conn.sendall(f"{prompts[task['kind']]} {question}".encode())
f.serve(handle) # listens on f.endpoint, reports ready, hands each connection over
return 0
ft.serve(on_fiber)
fiberd-template pkg.module:on_fiber runs a module the same way, with init() before the import.
A Fiber carries fence, fence_parts, endpoint, kind (unix, tcp or handoff), payload, session, env, incarnation and backend (fork or gvisor). listen() returns a bound socket for an author who runs their own server, ready() reports to fiberd once listening, in every incarnation, parking is set when fiberd asks for a park and park() answers it once nothing is served, and stopping is set when the fiber is asked to stop. @ft.on_incarnation runs a function in every copy of the template, after random and OpenSSL are reseeded. The rules serve() enforces, and why, are in docs/design/sdk.md.
A handoff fiber listens on nothing. f.serve(handle) works the same there. Each conn is an ssl.SSLSocket, with TLS terminated under the grant's identity and the bound caller's certificate the one the handshake admits, as f.accept() returns it.
on_fiber may be async def. Then await f.serve_async(handler) serves an async def handler(reader, writer), and async for reader, writer in f.connections() is the async twin of accept().
Client
A caller holds a signed grant and asks a home for fibers under it. pip install 'fiberd[client]' adds grpcio and protobuf, which a template never needs.
import time
from fiberd.client import Client, Shed, Deferred
def clone(c, jwt, session):
while True:
try:
return c.clone(jwt, session=session, payload=b'{"task":1}') # a Fiber, with id, fence, endpoint and kind
except Shed as e: # the home is busy, retry after the hint
time.sleep(e.retry_after)
with Client.dial_tls("home:7443", cert="me.pem", key="me-key.pem", ca="ca.pem") as c:
try:
f = clone(c, jwt, "conv-42")
except Deferred as e: # this home cannot serve it, take the ordinary path or go to e.preferred_home
raise SystemExit(f"deferred: {e.reason}")
with f.dial() as sock: # its unix or tcp endpoint
sock.sendall(b"hello\n")
c.park(f) # checkpoint it and free its place
f = clone(c, jwt, "conv-42") # kind RESUME, under the next fence
c.release(f, discard=True) # end it, and drop its parked delta
c.discard(jwt, "conv-42") drops a parked session by name when no fiber of it runs, and its next clone is a CREATE. A session the home does not know raises NotFound. A running one is the raw INVALID_ARGUMENT error, so release its fiber instead.
Client.dial(addr) is the plaintext form for a home started with -insecure-plaintext. A handoff fiber is reached with f.dial_handoff(cert, key), which sends its routing key as the server name, admits only the fiber's certificate from the Clone in the handshake and checks its key pin after it. TierGap, NotFound, NoWorkspace and QuotaExceeded are the other typed outcomes, and any other failure is the grpc.RpcError as raised. c.watch() yields one status per grant as the home publishes it. fiberd.client.aio.Client has the same methods as coroutines, with watch and download as async iterators. The token is accepted as a string or a callable that returns one, and it is never stored, logged or shown by a repr.
A fiber whose grant has a disk_budget_bytes has a workspace, mounted at /workspace inside it. The file calls move files in and out of a running fiber's workspace.
with open("dataset.csv", "rb") as src:
c.upload(f, "in/dataset.csv", src) # sized by fstat, sent in chunks of at most 1 MiB
c.upload(f, "config.json", b'{"k":1}', mode=0o600) # a FileInfo, with path, size, mode and sha256
with c.download(f, "out/result.bin") as d: # NotFound or NoWorkspace raise here, not on the first read
print(d.info.size)
result = b"".join(d)
for entry in c.list_files(f, "out"): # one directory, not recursive
print(entry.path, entry.size, entry.directory)
upload takes bytes or a binary file. A stream that can neither fstat nor seek needs size=. A source that ends early or holds more than its size raises ValueError, and fiberd keeps no file. A grant without a workspace raises NoWorkspace, and a file over the disk budget raises QuotaExceeded, which is not a shed. The aio client's upload also takes an async iterable of bytes with size=.
Build and test
The extension needs Linux, a C toolchain and cargo. In the dev container, from the repository root.
make python-test # build the extension in place and run the unit tests
make conform-proc-python # C1-C10 against the reference template, fiberd.template.ref
make conform-gvisor-python # the same on gVisor, from a rootfs hack/python/rootfs.sh builds with CPython in it
make conform-runc-python # and on runc, from the same rootfs
make python-dist # the sdist, a wheel built from it, and the unit tests against that wheel
The same template serves on proc, runc and gVisor. On runc and gVisor it runs from a root filesystem that holds the interpreter and the package, which hack/python/rootfs.sh <dir> builds from the dev image for those runs.
Elsewhere, pip install -e 'sdk/python[client]' cryptography builds it with what the client's tests import, and python3 -m pytest sdk/python runs the unit tests, which start no process.
Metadata
Release files for fiberd 0.4.0
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 |
|---|---|---|---|---|
| fiberd-0.4.0.tar.gz | 1.1 MB | With provenance | Details for fiberd-0.4.0.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fiberd-0.4.0-cp314-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl | CPython 3.14 | abi3 | Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 | Details for fiberd-0.4.0-cp314-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
| fiberd-0.4.0-cp314-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl | CPython 3.14 | abi3 | Linux glibc 2.28+ ARM64, Linux glibc 2.17+ ARM64 | Details for fiberd-0.4.0-cp314-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
Total release size: 2.0 MB
Release files / fiberd-0.4.0.tar.gz
| Download URL | fiberd-0.4.0.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a1f1c53a7da005cb6eeec6abf059b2539095811271187c447720b600158afa6
|
|
BLAKE2b-256 checksum How to use checksums |
81e7ef4bbcee186221a5abeb0435ca5bd0c35503d23f330303edaca03e9f0f5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 7, 2026.
Transparency logRelease files / fiberd-0.4.0-cp314-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | fiberd-0.4.0-cp314-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 414.3 kB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
7d4b08ebda21b0b99b18ad84814fa55d1678b266cc6723adfa1927f38a318c3a
|
|
BLAKE2b-256 checksum How to use checksums |
6732cc872c8caaf89b6079964463f6c20288823e8ceeea34b8ffdec5a5b4194e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 7, 2026.
Transparency logRelease files / fiberd-0.4.0-cp314-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | fiberd-0.4.0-cp314-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 410.8 kB |
| Tags | CPython 3.14 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
207f4107e1776fcab85895e48ea73a4df0096580e72c79b690b9c8b371751e5a
|
|
BLAKE2b-256 checksum How to use checksums |
88d2feb4a416dd00ce5c9c602eac0391761c7a2f2e56361ee9ffc402f9c087ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 7, 2026.
Transparency logSecurity for fiberd 0.4.0
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
All 3 files in this release have been uploaded with provenance metadata.
Attestation for fiberd-0.4.0.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 7, 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.