Reliable AI Task Streaming Backend
Project description
taskbridge-fastapi
taskbridge-fastapi is the reusable backend package for TaskBridge.
It is designed to be embedded into host FastAPI applications rather than replace their app shell.
Integration model
Host applications own:
FastAPI()app construction- auth and middleware
- startup and shutdown lifecycle
- infrastructure adapters for task registry, event store, and executor
TaskBridge provides:
- typed models and errors
- abstract interfaces
- service orchestration layer
- router builders and dependency hooks
- a Redis Streams event-store adapter with replay-safe
eventIdsemantics - typed backend stream runtime settings for WebSocket and SSE
- library-owned SSE runtime helpers so hosts do not implement transport loops
Host transport integration
Host applications should not implement transport loops directly.
taskbridge-fastapi now provides:
- HTTP polling route builder
- WebSocket route builder
- SSE runtime helper/route builder
- typed transport runtime settings
Hosts are expected to provide only:
- auth resolution
- ownership policy
- task registry / executor / event store adapters
- route path customization
- domain-specific create-task preprocessing
That means host apps should avoid handwritten StreamingResponse generators for
task streaming, Last-Event-ID replay loops, SSE heartbeat formatting, and
transport-specific wait tuning when a TaskBridge helper already covers the case.
Observability and ops
The package includes host-overridable observability hooks:
MetricsSinkabstraction (NoOpMetricsSinkby default)- structured application logs via
log_structured(...)helper - readiness probe composition for dependency health (
CompositeReadinessProbe)
Default metrics emitted by backend flow:
task_starts_totalstreams_activefallbacks_totalreplays_totalduplicates_totalcancels_totaltask_failures_total
Structured logs include correlation fields when available:
taskIdeventIdclientRequestIduserIdtransportoutcome
Security integration
Host applications authenticate requests and map them into AuthContext via
AuthContextResolver.
TaskBridge provides:
OwnershipPolicyfor create/read/cancel/subscribe authorization- enumeration-safe task reads for foreign task ids
UploadPolicyfor host-defined attachment quotas and rate decisions
Reference patterns for JWT and internal service auth are documented in
docs/security-integration.md.
Observability wiring and readiness examples are documented in
docs/observability-ops.md.
Retention defaults
RedisEventStoreSettings now includes operational retention defaults:
max_stream_length=1000stream_ttl_seconds=86400cleanup_interval_seconds=3600
Host applications can override these values per environment (dev/staging/prod).
Developer workflow
Run commands from this package directory:
uv run pytestuv run ruff checkuv run ruff formatuv run ruff format --check
For repository-level documentation and docs generation commands, see ../../docs/documentation/index.md.
Phase 11 test matrix
Primary test areas:
- unit/service coverage in
tests/test_models.py,tests/test_services.py,tests/test_redis_event_store.py - route and contract checks in
tests/test_http_api.py,tests/test_ws_api.py,tests/test_fastapi_contract.py - integration flow checks in
tests/test_integration_flow.py - protocol contract validation in
tests/test_protocol_contracts.py
Reference matrix details live in tests/README.md.
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 taskbridge_fastapi-0.1.0.tar.gz.
File metadata
- Download URL: taskbridge_fastapi-0.1.0.tar.gz
- Upload date:
- Size: 100.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3721f99cefc3b174a2d8eb61eaf578eee6d40ab8c8a2959463757ace45758ab
|
|
| MD5 |
bc8ddd7134cc58a699f9a2d6e46d515b
|
|
| BLAKE2b-256 |
7a6984a1dadb73b47b2263b9211f723c808447ed936b4fc674aeca6cd74609dd
|
File details
Details for the file taskbridge_fastapi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: taskbridge_fastapi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 36.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9dabc466a2ea06f0b87f91a4e407b3e3d87a01ce5795366fc91e04752069a788
|
|
| MD5 |
74a6c58b8e5f05b90154cdf24a029e07
|
|
| BLAKE2b-256 |
d7e7c828529d910dfc9e2f568ec94b4fe30a983970cb8cd510f926f668468f03
|