feat: forward dlq_table + metrics_recorder through the FastAPI OutboxRouter (F8-01)#88
Merged
Merged
Conversation
…Router (F8-01) The FastAPI OutboxRouter built its inner broker internally and didn't expose dlq_table or metrics_recorder, so FastAPI deployments could not enable dead-letter archival or the recorder seam (fetched/lease_lost/nacked_terminal/dlq_written) at all — the operability features a production service needs. Both are plain OutboxBroker.__init__ kwargs that flow through StreamRouter's **connection_kwars (same mechanism as outbox_table), so add them to OutboxRouter.__init__ and forward them through super().__init__. routers stays unforwarded pending a design call (its lifespan/AsyncAPI semantics through the FastAPI router are unsettled) — now the sole open FastAPI item in planning/deferred.md. Test asserts both reach the inner broker and that the forwarded recorder actually fires on the dispatch path under the FastAPI router. Docs corrected (docs/usage/fastapi.md) — this also clears F8-02 (the docs wrongly said observability was unavailable via the router). Pass-3 findings doc + deferred.md updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes F8-01 from the 2026-06-14 pass-3 deep audit (the long-standing deferred FastAPI item).
The FastAPI
OutboxRouterbuilds its innerOutboxBrokerinternally and didn't exposedlq_tableormetrics_recorder, with no handle to inject a pre-built broker — so a FastAPI deployment could not enable the dead-letter queue or the metrics-recorder seam at all (fetched/lease_lost/nacked_terminal/dlq_written). The only path was abandoning the router for a standalone broker.Fix
Both are plain
OutboxBroker.__init__kwargs that flow throughStreamRouter's**connection_kwars(the same mechanism that already carriesoutbox_table), so this is a forwarding change: adddlq_table+metrics_recordertoOutboxRouter.__init__and pass them throughsuper().__init__.routersstays unforwarded — its start/AsyncAPI semantics through the FastAPI lifespan are unsettled (the router already contributes its own subscribers viainclude_router), so it needs a design call. It's now the sole open FastAPI item inplanning/deferred.md.Tests
tests/test_fastapi.py::test_outbox_router_forwards_dlq_table_and_metrics_recorder_to_inner_brokerasserts both kwargs reach the inner broker and that the forwarded recorder actually fires on the dispatch path under the FastAPI router (not just that it's wired). Failed before (router rejecteddlq_table), passes after.just test→ 503 passed, 100% coveragejust lintclean (ruff + ty)Docs
docs/usage/fastapi.md— DLQ + recorder are now documented as available via the router (with an example); onlyrouterslisted as not exposed. This also clears F8-02 (the docs previously claimed observability was unavailable via the router — wrong, since native Prometheus/OTel middleware always worked viaOutboxRouter(middlewares=[...])).planning/deferred.md— FastAPI item narrowed to justrouters.🤖 Generated with Claude Code