Repository navigation
feat(D147): per-request perimeter; customer SQL connection target - #538
Conversation
- ApiDeployment carries auth, direct_admission and spend_lease. The perimeter gate resolves the request's deployment through the app's deployment_context override (called once, with the request), then authenticates against it, admits under its limits, and the spend-lease middleware uses its lease. Without an override the composed deployment applies as before. Routes, the D74 barrier, the scope check, ingest attribution and open-query principal forwarding read the same resolved deployment; every route is built held. - install_browser_origins is public. - SelfHostSettings.query_role_host/query_role_port: where customer SQL connects as the query role; default the database URL's host and port. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F9cMsQBqiW2qU2ow4zeNCm
…ployment Codex round 1: held routes wrap sync dependencies, so a host route's Depends(deployment_context) missed the override and returned the composed deployment. The default now reads the gate's resolved deployment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F9cMsQBqiW2qU2ow4zeNCm
Codex review round 1 (gpt-6.1-sol, max effort)VERDICT: REQUEST_CHANGES
365 focused tests passed, covering default authentication/scopes, admission and held slots, spend leases, CORS, healthz, OpenAPI, attribution, open-query principals, and two-deployment isolation. SQL overrides and configuration docs match; ingestion reuse keys are untouched. The dedicated PG 19 Beta 3 container was removed. No files changed. Disposition (Claude): accepted, fixed in 02fa01aThe public |
…router Codex round 2: an included router's Depends(deployment_context) called the host's override again. The gate now keeps the override as the app's resolver and points the override at the resolved value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F9cMsQBqiW2qU2ow4zeNCm
Codex review round 2 (gpt-6.1-sol, max effort)VERDICT: REQUEST_CHANGES
The direct-route round-1 regression passes. 423 focused tests passed, covering default authentication/scopes, admission and held slots, lease accounting, CORS ordering, healthz, OpenAPI, attribution, principal forwarding, SQL connection overrides, and database isolation. No other findings; reuse keys are untouched. The dedicated PostgreSQL 19 Beta 3 container was removed. No repository files changed. Disposition (Claude): accepted, fixed in cc87fc9On the first request it handles, the gate stores the host's |
… an override Codex round 3: - Held routes replace a dependency's callable with a wrapper, which hid overrides keyed by the original. _HeldOverrides answers FastAPI's lookup by wrapper with the original's override, held when synchronous. - Clearing the deployment_context override returns to the composed deployment instead of reusing the saved resolver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F9cMsQBqiW2qU2ow4zeNCm
Codex review round 3 (gpt-6.1-sol, max effort)VERDICT: REQUEST_CHANGES
The round-2 regression passes. 479 focused tests passed; 40 concurrent requests also confirmed consistent deployment resolution, authentication, D74 checks and lease selection. SQL overrides and configuration docs match; ingestion reuse keys are untouched. The dedicated PostgreSQL 19 Beta 3 container was removed. No repository files changed. Disposition (Claude): both accepted, fixed in 9e6d8a6
|
Codex review round 4 (gpt-6.1-sol, max effort)VERDICT: APPROVE No blocker, major, or minor findings. The latest fixes preserve dependency overrides and restore the composed deployment when its override is removed. Resolution remains once per request and consistent across authentication, admission, leases, routes, D74, scope checks, attribution, and principal forwarding. Default behavior, CORS ordering, healthz, and OpenAPI remain intact. SQL target overrides and docs match. Ingestion reuse keys are untouched. 541 focused tests passed, plus 30 dependency-override comparisons and cancellation probes. The dedicated PostgreSQL 19 Beta 3 container was removed. No repository files changed. |
These are the generic seams the UMC shared API needs: one app serving many deployments, on top of D147.
Public API
Behaviour
request.state. Then it authenticates against that deployment, so a credential for another deployment gets 403, and admits under that deployment's limits. After that, the spend-lease middleware (now always installed, and a pass-through without a lease) applies that deployment's lease._perimeter), ingest attribution and open-query principal forwarding all read the same resolved deployment. The override is called once per request, not once per dependency.build_apiwas composed with applies, so self-host behaviour is unchanged.build_apikeyword arguments are unchanged, and the OpenAPI output is unchanged (verified bytest_openapi_export).SelfHostProfile.api_deployment()returns an empty perimeter;api()fills it from settings withdataclasses.replace./healthzstill bypasses the gate.Tests
test_per_request_perimeter.py: one app, two deployments, chosen by a header resolver.test_engine_settings.py: the query-role connection uses the configured host and port, and otherwise the URL's.Checks
ruff, format, pyright (0), import-linter, unit lane (3097 passed), the DB tests above on PG 19 Beta 3, docs checks
CI (green)
Codex review: round 4 APPROVE (rounds 1-3 dispositions in comments: resolver called once for every router; held routes keep dependency overrides; cleared override returns to the composed deployment)
I have read and agree to the RememberStack Contributor License Agreement v1.0.
🤖 Generated with Claude Code
https://claude.ai/code/session_01F9cMsQBqiW2qU2ow4zeNCm