Skip to main content

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 eventId semantics
  • typed backend stream runtime settings for WebSocket and SSE
  • library-owned SSE runtime helpers so hosts do not implement transport loops

The important architectural rule is:

  • the host owns application shell and infrastructure;
  • taskbridge-fastapi owns transport semantics and service orchestration;
  • runtime-specific execution belongs in adapter packages such as Temporal.

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

HttpRouteSettings already supports per-endpoint HTTP path overrides. WebSocket mounts can now be customized through WebSocketRouteSettings(websocket_path=...) when a host needs a non-default endpoint such as /ws/tasks.

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.

Minimal integration shape:

from fastapi import FastAPI

from taskbridge.routes_http import build_http_router, install_http_exception_handlers
from taskbridge.routes_ws import build_ws_router

app = FastAPI()
app.include_router(build_http_router())
app.include_router(build_ws_router())
install_http_exception_handlers(app)

Release history for this package lives in backend/taskbridge-fastapi/CHANGELOG.md. The committed pyproject.toml version stays at 0.0.0.dev0; the published version comes from the python-vX.Y.Z tag in CI. Use the repository prepare-release workflow before pushing that tag. Release-bearing PR titles and squash titles must follow Conventional Commits such as fix(backend): ....

Observability and ops

The package includes host-overridable observability hooks:

  • MetricsSink abstraction (NoOpMetricsSink by default)
  • structured application logs via log_structured(...) helper
  • readiness probe composition for dependency health (CompositeReadinessProbe)

Default metrics emitted by backend flow:

  • task_starts_total
  • streams_active
  • fallbacks_total
  • replays_total
  • duplicates_total
  • cancels_total
  • task_failures_total

Structured logs include correlation fields when available:

  • taskId
  • eventId
  • clientRequestId
  • userId
  • transport
  • outcome

Security integration

Host applications authenticate requests and map them into AuthContext via AuthContextResolver.

TaskBridge provides:

  • OwnershipPolicy for create/read/cancel/subscribe authorization
  • enumeration-safe task reads for foreign task ids
  • UploadPolicy for 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=1000
  • stream_ttl_seconds=86400
  • cleanup_interval_seconds=3600

Host applications can override these values per environment (dev/staging/prod).

Documentation map

Use the docs site for the concept-level guide:

  • docs/backend/index.md for backend overview
  • docs/backend/host-integration.md for host ownership and dependency boundaries
  • docs/backend/services-and-routes.md for route/service split
  • docs/backend/security-readiness-observability.md for security and ops hooks
  • docs/backend/state-and-runtime-boundaries.md for durable state and runtime boundaries
  • docs/adapters/temporal.md for the main runtime adapter example

Developer workflow

Run commands from this package directory:

  • uv run pytest
  • uv run ruff check
  • uv run ruff format
  • uv run ruff format --check

For repository-level documentation and docs generation commands, see ../../docs/documentation/index.md.

Reference matrix details live in tests/README.md.

Metadata

Release files for taskbridge-fastapi 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for taskbridge-fastapi 0.2.0
File Size Uploaded
taskbridge_fastapi-0.2.0.tar.gz 106.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for taskbridge-fastapi 0.2.0
File Interpreter ABI Platform
taskbridge_fastapi-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 143.4 kB

Release files / taskbridge_fastapi-0.2.0.tar.gz

Download URL taskbridge_fastapi-0.2.0.tar.gz
Size 106.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d816c7312024411d524869e71b42ec8f788cf83b77b04af6ce7dd2cc39182a91
BLAKE2b-256 checksum
How to use checksums
5ad26463147f5ee39acbc5ca4dfce8218bc799e376443b61338360236457a985
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","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}

Release files / taskbridge_fastapi-0.2.0-py3-none-any.whl

Download URL taskbridge_fastapi-0.2.0-py3-none-any.whl
Size 37.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ea202cb81088d7047c70965ecc383d916d2965981c4ca29025be6537c509dd4
BLAKE2b-256 checksum
How to use checksums
3cb8c7b89095eb2f09102c32a4ec89f88eb105a2b6f37c18ee4790291ebf1d93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","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}

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page