capio
Composable capabilities for Python: resilience, caching, observability, and AI behavior. A capability runtime, not a decorator library.
Capio is the composable capability layer for Python applications. Apply cross-cutting behavior to functions and methods — retries, caching, timeouts, circuit breaking, rate limiting, tracing, metrics, logging, and more — with one uniform, typed API.
Designed for sync and async Python, generator-friendly, backend-agnostic, and fail-safe by default. The architecture is specified in
docs/rfcs/(RFC-000…033).
Status
v0.1.0 — MVP reference implementation (RFC-031). Core capabilities implemented:
retry, cache, timeout, circuit_breaker, rate_limit, trace, metrics, log.
Install
pip install -e ".[dev]"
Quick Start
from capio import use
@use.retry(max_attempts=3, backoff="exponential", jitter=True)
@use.cache(ttl="5m")
@use.timeout(seconds=2)
@use.trace()
def search(query: str) -> list[str]:
...
Capabilities compose as nested scopes; the decorator written highest runs outermost. The composite form is equivalent:
from capio import use
@use(
retry={"max_attempts": 3, "backoff": "exponential", "jitter": True},
cache={"ttl": "5m"},
timeout={"seconds": 2},
trace=True,
)
def search2(query: str) -> list[str]:
...
Async works with the same API:
@use.retry(max_attempts=3)
@use.cache(ttl="30s")
async def fetch(url: str) -> bytes:
...
Capabilities
| Decorator | Capability | Purpose | RFC |
|---|---|---|---|
use.retry |
Retry | Retry failures with backoff + jitter | RFC-017 |
use.cache |
Cache | In-memory cache with TTL | RFC-016 |
use.timeout |
Timeout | Bound execution time | RFC-018 |
use.circuit_breaker |
Circuit Breaker | Fail fast when a dependency is unhealthy | RFC-018 |
use.rate_limit |
Rate Limit | Admission control | RFC-018 |
use.trace |
Trace | Span recording | RFC-019 |
use.metrics |
Metrics | Counters + histograms | RFC-019 |
use.log |
Log | Structured invocation logging | RFC-020 |
Custom capabilities
from capio import Capability
class Audit(Capability):
name = "audit"
priority = 550
def run(self, ctx, call_next):
result = call_next(ctx)
print("audit:", ctx.fn_name, result)
return result
# register and use
from capio.registry import registry
registry.register(Audit)
# from capio import use
# @use.audit()
CLI
capio doctor # environment + plugin smoke check
capio inspect mod.fn # show a decorated function's pipeline
capio graph mod.fn # render pipeline order
capio benchmark # run micro-benchmarks against RFC-027 budgets
capio version # print version
Development
pip install -e ".[dev]"
pytest tests/ -v
ruff check .
Documentation
docs/architecture.md— how Capio is built, code walkthrough and invocation flowdocs/usage.md— the full manual: every capability and configuration option
The normative architecture lives in docs/rfcs/:
- RFC-000 index and reading order
- RFC-001 vision, RFC-002 core concepts, RFC-003
useAPI - RFC-004…024 architecture (runtime, lifecycle, context, config, DI, plugins, backends)
- RFC-025 errors, RFC-026 security, RFC-027 performance, RFC-028 CLI, RFC-029 testing, RFC-030 AI/agents/LLM/MCP, RFC-031 reference implementation, RFC-032 roadmap, RFC-033 migration/FAQ
License
MIT
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 capio-0.1.0.tar.gz.
File metadata
- Download URL: capio-0.1.0.tar.gz
- Upload date:
- Size: 38.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
942362712c4e2b3cf1208eeb8b3a94681ec0741bfc15bce21e5490cbdc113a7e
|
|
| MD5 |
ba7ff86bc2cddd0298cd9a0a89862704
|
|
| BLAKE2b-256 |
25236345d315e1b7b5a38947bfb116d37652cef2d5d42e07f67316e2f1f12ceb
|
File details
Details for the file capio-0.1.0-py3-none-any.whl.
File metadata
- Download URL: capio-0.1.0-py3-none-any.whl
- Upload date:
- Size: 42.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58ef4f71a9fca0527e7e357309d3d8834431844e6eef197667821b024f048269
|
|
| MD5 |
f46f8a002f891221dfa37001ac996165
|
|
| BLAKE2b-256 |
3cc506d7a236e1b8fe998310d1b39f78bdc0e918d480a9a648fae4c983cf70c4
|