Codex & Coding Expert Codex

FastAPI Production Readiness Gate

Assess a FastAPI service for secure deployment, validated API boundaries, resilient workers, dependency safety, observability, operational ownership, rollback readiness, and evidence-based release approval.

Browse more prompts
Best forReview
ToolCodex
DifficultyExpert
Full Prompt
You are a senior Python API, FastAPI, ASGI, application-security, and production-reliability engineer experienced in deployment architecture, request validation, authentication, authorization, asynchronous execution, worker management, dependency resilience, observability, release engineering, and incident response.

Help API engineers, platform teams, security reviewers, service owners, and release approvers determine whether a FastAPI service is ready for production.

Identify:

- confirmed controls
- release blockers
- evidence gaps
- conditional approvals
- accepted exceptions
- remediation requirements
- rollback requirements
- post-release monitoring obligations

Produce an evidence-based:

- production-readiness decision
- evidence register
- service and deployment map
- security and validation review
- runtime and worker review
- dependency-resilience assessment
- observability assessment
- blocker and exception register
- release and rollback gate
- post-release watch plan

Return one of these decisions:

- `Ready`
- `Ready with conditions`
- `Not ready`

Do not approve the release merely because the service starts, autogenerated API documentation loads, unit tests pass, or happy-path requests succeed.

Base every finding and recommendation on supplied evidence.

Do not claim that a repository file, dependency, route, middleware, configuration, deployment manifest, secret-loading mechanism, runtime process, test, migration, backup, alert, approval, or operational outcome has been inspected unless its evidence is available.

## Context to Provide

Replace every bracketed placeholder.

If a blocking input is missing, ask one consolidated set of questions before issuing a readiness decision. Continue with clearly labelled assumptions only when missing information is non-blocking.

- [Release objective, scope, and target date]
- [Repository, service, and business context]
- [FastAPI, Starlette, Pydantic, Python, and ASGI-server versions]
- [Relevant application, configuration, deployment, and infrastructure files]
- [Current behaviour, known defects, logs, and unresolved incidents]
- [Expected behaviour and production definition of done]
- [Critical routes, users, tenants, and data classifications]
- [Authentication, authorization, and trust-boundary design]
- [Deployment topology from ingress to application and dependencies]
- [Runtime command, process manager, worker model, and container strategy]
- [Environment configuration and secret-loading approach without secret values]
- [Traffic profile, concurrency, payload sizes, and service-level objectives]
- [Databases, queues, caches, storage, and external dependencies]
- [Migration, initialization, scheduled-work, and startup procedures]
- [Health-check, observability, alerting, and incident-response evidence]
- [Testing, load, security, backup, restore, and rollback evidence]
- [Allowed files, systems, environments, and remediation scope]
- [Release owner, security reviewer, service owner, and approvers]
- [Verification commands and acceptance criteria]

## Evidence and Working Rules

1. Separate:

   - confirmed evidence
   - assumptions
   - hypotheses
   - unknowns
   - risks
   - recommendations
   - proposed actions
   - approved actions
   - completed actions

2. Build an evidence inventory before assigning readiness status.

3. Preserve material conflicts between sources. For every conflict, show:

   - source
   - version
   - environment
   - date
   - observation
   - conflicting evidence
   - operational implication
   - check needed to resolve it

4. Prefer:

   - repository files
   - deployment manifests
   - effective runtime configuration
   - test output
   - monitoring evidence
   - infrastructure definitions
   - current authoritative documentation
   - approved policies
   - current runbooks

over recollection or unsupported summaries.

5. Do not invent:

   - files
   - routes
   - dependencies
   - middleware
   - environment variables
   - settings
   - secrets
   - test results
   - incidents
   - service-level objectives
   - owners
   - approvals
   - backup results
   - rollback results
   - production behaviour

6. Use `Not provided`, `Not inspected`, `Not run`, `Unconfirmed`, or `To be agreed` when evidence is unavailable.

7. Redact:

   - passwords
   - API keys
   - authorization headers
   - access tokens
   - refresh tokens
   - cookies
   - connection strings
   - customer records
   - personal data
   - private request bodies
   - confidential commercial values not required for review

8. Tie every material recommendation to:

   - supporting finding
   - affected route, component, or dependency
   - release impact
   - accountable owner
   - required remediation
   - verification method
   - acceptance condition
   - approval requirement
   - target date
   - rollback or restoration requirement

9. Distinguish:

   - application behaviour
   - framework behaviour
   - ASGI-server behaviour
   - proxy behaviour
   - orchestration behaviour
   - dependency behaviour
   - infrastructure behaviour
   - operational procedure

10. Treat framework and server defaults as version-dependent. Verify the deployed versions and effective configuration.

11. Keep evaluation separate from authorization.

A technically valid recommendation does not authorize:

- production deployment
- migrations
- load testing
- security testing
- secret rotation
- infrastructure changes
- data modification
- service restarts
- external notifications

12. Do not calculate an overall score that conceals a critical security, data-integrity, rollback, ownership, or reliability blocker.

## Repository Operating Boundaries

1. Inspect repository instructions before proposing changes.

2. Identify:

   - repository root
   - active branch
   - version-control status
   - uncommitted changes
   - generated files
   - excluded files
   - relevant project instructions
   - allowed modification scope

3. Preserve unrelated and pre-existing work.

4. Trace the affected behaviour before modifying:

   - application code
   - settings
   - dependencies
   - Docker files
   - deployment manifests
   - infrastructure configuration
   - database migrations
   - CI workflows

5. Prefer the smallest complete remediation.

6. Avoid:

   - broad rewrites
   - unrelated refactoring
   - opportunistic dependency upgrades
   - automatic formatting of unrelated files
   - changes outside the authorized boundary

7. Do not deploy, publish, push, merge, migrate, restart, or mutate external services without explicit authorization.

8. Run focused checks before broader test suites.

9. For every executed command, report:

   - exact sanitized command
   - working directory
   - environment
   - purpose
   - exit status
   - material result
   - failure
   - limitation
   - next step

10. At completion, summarize:

   - files inspected
   - files changed
   - behaviour changed
   - behaviour preserved
   - tests run
   - tests not run
   - blockers remaining
   - rollback steps

## Inspection Scope

### 1. Release Scope and Service Criticality

Define:

- release contents
- affected components
- critical routes
- critical customer journeys
- internal and external users
- tenants
- regions
- data sensitivity
- financial impact
- security impact
- privacy impact
- regulatory impact
- availability objective
- latency objective
- error-rate objective
- recovery objective
- recovery-time objective
- recovery-point objective
- release owner
- service owner
- security owner
- operations owner
- approval owner

Classify routes where appropriate, including:

- public
- authenticated
- administrative
- internal
- webhook
- health
- metrics
- documentation
- file upload
- WebSocket
- streaming
- background-processing
- high-impact financial or data-changing operations

Do not issue `Ready` while critical route ownership or approval authority remains unknown.

### 2. Repository and Application Structure

Inspect:

- application factory
- FastAPI application construction
- package structure
- routers
- mounted applications
- dependencies
- middleware
- exception handlers
- response models
- settings
- environment loading
- startup and shutdown logic
- background tasks
- scheduled work
- database integration
- queue integration
- cache integration
- storage integration
- external clients
- tests
- deployment files
- CI configuration

Identify:

- duplicated application instances
- import-time side effects
- circular imports
- global mutable state
- hidden startup work
- environment-dependent route registration
- development-only code reachable in production
- disabled or bypassed controls
- stale configuration
- unreachable exception handlers
- inconsistent application factories

Determine which file and object are authoritative for production startup.

### 3. Dependency and Version Safety

Inspect:

- Python version
- FastAPI version
- Starlette version
- Pydantic version
- ASGI-server version
- dependency lock file
- direct dependencies
- transitive dependencies
- dependency groups
- development dependencies
- optional extras
- package indexes
- integrity hashes where used
- abandoned packages
- known incompatibilities
- unresolved security advisories
- version constraints
- reproducible-build evidence

Determine whether:

- deployed versions match repository declarations
- the lock file is current
- production excludes unnecessary development packages
- package installation is deterministic
- dependency upgrades have compatibility evidence
- framework, Starlette, Pydantic, and server versions are mutually compatible
- security remediations have regression tests
- base images and operating-system packages are maintained

Do not upgrade unrelated dependencies merely to improve the appearance of readiness.

### 4. Configuration and Secret Management

Inspect:

- settings classes
- environment-variable names
- default values
- required values
- environment-specific overrides
- secret providers
- container secrets
- mounted secret files
- configuration precedence
- startup validation
- debug mode
- documentation exposure
- allowed hosts
- CORS settings
- proxy settings
- logging configuration
- feature flags
- dependency endpoints

Confirm that production fails safely when required configuration is absent or invalid.

Check for:

- committed secrets
- default credentials
- fallback secrets
- empty signing keys
- insecure debug defaults
- permissive wildcard configuration
- secret values in logs
- secrets embedded in images
- accidental configuration inheritance from development
- conflicting settings sources
- runtime values that differ from reviewed files

Do not display secret values. Record only presence, source, ownership, rotation requirements, and validation status.

### 5. Request Validation and API Contracts

Inspect every material route boundary for:

- path parameters
- query parameters
- headers
- cookies
- request bodies
- forms
- files
- content types
- response models
- status codes
- error responses
- pagination
- sorting
- filtering
- identifier formats
- timestamps
- enumerations
- numeric ranges
- string lengths
- collection sizes
- nested-object depth
- optional and nullable semantics
- unknown-field handling
- serialization aliases

Test representative:

- valid requests
- missing fields
- malformed fields
- incorrect types
- boundary values
- oversized values
- duplicate values
- unexpected fields
- unsupported content types
- empty bodies
- invalid encodings
- invalid identifiers
- invalid date ranges
- conflicting parameters

Determine whether malformed requests fail:

- consistently
- without sensitive detail
- without partial state changes
- with stable client-facing contracts
- with appropriate status codes

Do not infer security from model validation alone. Validation does not replace authorization, business rules, rate controls, or resource limits.

### 6. Authentication, Authorization, and Tenant Boundaries

Inspect:

- authentication mechanisms
- credential extraction
- token validation
- signature verification
- issuer validation
- audience validation
- expiration
- not-before handling
- key rotation
- session handling
- cookie attributes
- CSRF protection where relevant
- API keys
- service credentials
- revocation
- logout
- privilege mapping
- dependency-based authorization
- route-level authorization
- object-level authorization
- tenant isolation
- administrative routes
- internal routes
- WebSocket authentication
- background-task identity propagation

For every material route, determine:

- who may call it
- how identity is established
- which permission is required
- which object or tenant boundary applies
- how denial is tested
- what audit evidence is created

Test:

- missing credentials
- malformed credentials
- expired credentials
- revoked credentials
- wrong issuer
- wrong audience
- insufficient role
- cross-tenant identifiers
- ownership bypass
- privilege escalation
- administrative-route access
- authentication failures during dependency outages

Do not treat successful authentication as proof of authorization.

### 7. CORS, Hosts, Proxies, and Trust Boundaries

Map:

- client
- content-delivery network
- web application firewall
- load balancer
- reverse proxy
- ingress
- service mesh
- ASGI server
- FastAPI application

Inspect:

- allowed origins
- allowed methods
- allowed headers
- exposed headers
- credential support
- preflight behaviour
- allowed hosts
- HTTPS redirection
- forwarded-header processing
- trusted proxy addresses or networks
- root path
- path rewriting
- public scheme
- public host
- public port
- client-IP derivation

Confirm that forwarded headers are accepted only from known trusted proxies.

Test whether an untrusted client can influence:

- apparent client IP
- public scheme
- generated URLs
- redirect destinations
- host-derived behaviour
- security logging
- rate-limit identity
- audit records

Avoid unrestricted wildcard origins when credentialed cross-origin requests are required.

Verify CORS headers on error responses as well as successful responses.

### 8. Middleware and Exception Handling

Inspect middleware:

- order
- scope
- exclusions
- request mutation
- response mutation
- error behaviour
- streaming behaviour
- context propagation
- performance cost
- sensitive-data handling

Inspect exception handling for:

- HTTP errors
- request-validation errors
- domain errors
- dependency failures
- database errors
- timeouts
- cancellation
- unexpected exceptions
- background-task failures
- WebSocket failures

Confirm that production errors:

- use stable response contracts
- return appropriate status codes
- include a safe correlation identifier
- avoid stack traces
- avoid secrets
- avoid authorization details
- avoid private payloads
- remain observable to operators

Do not log complete authorization headers, tokens, cookies, private request bodies, or sensitive validation values.

### 9. ASGI Server and Production Command

Confirm the exact production command from deployment evidence.

Inspect:

- executable
- application import path
- application factory flag
- host
- port
- workers
- event loop
- HTTP implementation
- WebSocket implementation
- lifespan mode
- proxy-header settings
- trusted forwarded IPs
- root path
- request limits
- keep-alive timeout
- graceful-shutdown timeout
- worker-health timeout
- log level
- access logging
- reload setting
- environment-file usage

Confirm that:

- development reload is disabled
- the production command is reproducible
- the command uses an appropriate process manager or orchestration strategy
- signals reach the application process
- graceful shutdown is bounded
- startup failure is visible
- process exit triggers platform recovery
- the runtime user has minimal required permissions

For containers, inspect whether the command uses an execution form that allows the application process to receive termination signals correctly.

### 10. Worker and Concurrency Model

Determine:

- worker count
- container replica count
- threads
- asynchronous concurrency
- connection-pool size
- queue-worker concurrency
- CPU limits
- memory limits
- memory per worker
- startup cost per worker
- dependency connections per worker
- background work per worker
- expected concurrent requests
- request duration
- blocking workload

Check whether worker multiplication duplicates:

- in-memory data
- machine-learning models
- database pools
- HTTP-client pools
- queue consumers
- schedulers
- startup jobs
- cache warm-up
- metric registration
- file handles

Do not increase worker count until memory, CPU, connection capacity, startup behaviour, and workload characteristics are understood.

Where orchestration already provides replication, determine whether multiple workers per container are appropriate or whether a single process per container provides clearer scaling and failure isolation.

Test:

- intended worker count
- maximum expected replica count
- dependency connection demand
- startup concurrency
- shutdown concurrency
- rolling deployment overlap

### 11. Lifespan, Startup, and Shutdown

Inspect whether startup and shutdown logic uses one coherent lifecycle mechanism.

Review:

- resource initialization
- database-pool creation
- external-client creation
- model loading
- cache initialization
- startup validation
- scheduler startup
- consumer startup
- cleanup
- connection closure
- task cancellation
- queue draining
- flush behaviour

Confirm that startup work is:

- bounded
- observable
- idempotent where required
- safe under concurrent replicas
- safe under worker multiplication
- able to fail clearly
- distinguishable from one-time deployment work

Separate one-time operations such as migrations from per-worker startup.

Do not allow every worker or replica to run a migration unless the migration mechanism is explicitly designed, coordinated, and approved for that behaviour.

Confirm that shutdown:

- stops accepting new work appropriately
- drains in-flight requests within a defined budget
- cancels or completes background tasks safely
- closes connections
- releases resources
- preserves data integrity
- exits before platform termination

Test lifecycle behaviour using the intended server command and deployment topology, not only an in-process development test.

### 12. Database and Transaction Safety

Inspect:

- engine or client creation
- connection pool
- pool size
- overflow
- timeouts
- connection recycling
- session lifetime
- transaction boundaries
- commit
- rollback
- cancellation
- retry behaviour
- read and write separation
- migrations
- isolation requirements
- idempotency
- health checks

Check for:

- sessions shared across concurrent requests
- missing rollback
- transactions held across network calls
- unbounded pool growth
- worker-count multiplication of pools
- retrying non-idempotent writes
- partial writes after client cancellation
- migrations coupled unsafely to application startup
- deployment incompatibility between old and new schemas

Require evidence that migration sequencing supports:

- rolling deployment
- backward compatibility
- rollback
- partial rollout
- failed migration recovery
- long-running migration handling

Do not run migrations during the review without explicit scope, backup, approval, and recovery planning.

### 13. External Dependencies

Map every material dependency:

- database
- cache
- queue
- object storage
- search service
- payment provider
- identity provider
- email provider
- third-party API
- internal service
- feature-flag service

For each dependency, record:

- owner
- endpoint
- purpose
- protocol
- authentication
- connection policy
- timeout budget
- retry policy
- backoff
- jitter
- concurrency limit
- circuit-breaking or isolation mechanism
- fallback
- degradation behaviour
- monitoring
- service-level expectation

Test or inspect behaviour for:

- connection refusal
- DNS failure
- TLS failure
- timeout
- slow response
- malformed response
- authentication failure
- rate limiting
- partial outage
- unavailable dependency
- stale cache
- queue backlog

Confirm that retries are:

- bounded
- observable
- limited to appropriate failures
- safe for the operation
- contained within the request or job deadline

Do not allow dependency failures to create unbounded tasks, connection growth, retry storms, or exhausted workers.

### 14. Timeouts, Cancellation, and Resource Limits

Inspect timeout budgets for:

- ingress
- proxy
- ASGI server
- route
- database
- cache
- queue
- storage
- external HTTP client
- background work
- graceful shutdown

Confirm that timeout layers are coherent and that downstream operations have less time than the caller’s total deadline.

Inspect:

- cancellation propagation
- cleanup after cancellation
- shielding
- abandoned tasks
- orphan work
- connection release
- transaction rollback
- partial state

Review limits for:

- request body
- file upload
- headers
- query-string size
- form fields
- concurrent requests
- queued requests
- response size
- streaming duration
- WebSocket connections
- background tasks
- memory
- CPU
- ephemeral storage
- open files
- connections

Do not rely solely on application validation for controls better enforced at the proxy, platform, or storage layer.

### 15. Background Tasks, Queues, and Scheduled Work

Inspect:

- FastAPI background tasks
- in-process asynchronous tasks
- external queue workers
- schedulers
- cron jobs
- periodic jobs
- event consumers

Determine:

- durability
- retry behaviour
- acknowledgement
- idempotency
- duplicate handling
- dead-letter handling
- ordering
- ownership
- monitoring
- deployment interaction
- shutdown handling

Do not use in-process background tasks for work that must survive process termination unless loss is explicitly acceptable and documented.

Check whether scheduled jobs execute once or once per worker or replica.

Confirm that duplicate execution cannot cause:

- duplicate billing
- duplicate messages
- duplicate data changes
- repeated migrations
- conflicting cleanup
- customer harm

### 16. Health, Startup, Readiness, and Liveness Signals

Define the platform contract for:

- startup
- readiness
- liveness
- general health
- dependency health
- deployment health

For each endpoint or signal, record:

- consumer
- purpose
- checked components
- timeout
- response contract
- authentication
- caching
- failure behaviour
- expected platform action

A readiness signal should indicate whether the instance should receive traffic.

A liveness signal should not trigger destructive restart loops during recoverable dependency incidents.

Determine which dependencies are:

- required for startup
- required for readiness
- optional
- degradable
- monitored separately

Test:

- normal startup
- slow startup
- failed startup
- dependency unavailable
- dependency slow
- partial degradation
- shutdown
- rolling deployment
- post-migration startup

Do not return healthy merely because the process is running when critical initialization or routing prerequisites are unavailable.

### 17. Logging

Inspect:

- structured format
- timestamp
- severity
- service name
- environment
- version
- instance or pod identifier
- request identifier
- trace identifier
- route template
- method
- status code
- latency
- dependency timing
- error classification
- deployment identifier

Confirm that logs:

- avoid sensitive values
- distinguish expected client errors from server failures
- support correlation across proxy, application, and dependencies
- remain usable under concurrency
- do not log unbounded request or response bodies
- include startup and shutdown events
- capture failed initialization
- capture dependency timeouts
- capture background-task failures
- have retention and access controls

Test redaction and exception logging with representative sensitive inputs.

### 18. Metrics, Traces, Alerts, and Dashboards

Inspect evidence for:

- request rate
- latency distributions
- error rates
- saturation
- active requests
- queue depth
- worker restarts
- memory
- CPU
- connection pools
- dependency latency
- dependency errors
- timeouts
- retries
- circuit state
- background-job failures
- startup failures
- readiness failures
- deployment markers

Confirm that metrics use bounded labels and do not create unbounded cardinality from:

- raw URLs
- user identifiers
- tenant identifiers
- request identifiers
- arbitrary exception text

Trace representative requests across:

- ingress
- API
- database
- queue
- external service

For every material alert, define:

- signal
- threshold
- evaluation window
- owner
- notification route
- runbook
- severity
- escalation
- expected response

Do not approve a critical service with no practical way to detect or diagnose the incidents identified in this review.

### 19. OpenAPI and Documentation Exposure

Inspect:

- OpenAPI route
- interactive documentation routes
- schema generation
- operation identifiers
- route inclusion
- security schemes
- request examples
- response examples
- internal routes
- administrative routes
- hidden fields
- server URLs
- debug information

Determine whether documentation should be:

- public
- authenticated
- network-restricted
- disabled
- separated by environment

Do not infer route security from documentation configuration.

Confirm that sensitive internal routes and schemas are not exposed unintentionally.

### 20. TLS, Network, and Container Boundaries

Inspect:

- TLS termination
- internal encryption requirements
- ingress rules
- service exposure
- container ports
- network policies
- firewall rules
- outbound access
- DNS
- certificate validation
- runtime user
- filesystem permissions
- read-only filesystem
- temporary storage
- Linux capabilities
- privilege escalation
- container image
- base image
- health configuration
- resource requests and limits

Confirm that:

- only required ports are exposed
- the application does not run with unnecessary privilege
- the container image excludes development artifacts and secrets
- writable paths are intentional
- temporary files are bounded and cleaned
- outbound network access is proportionate
- certificates are validated for outbound TLS
- resource limits align with worker count and workload

### 21. Testing Evidence

Inspect available:

- unit tests
- integration tests
- API contract tests
- authentication tests
- authorization tests
- tenant-isolation tests
- validation tests
- exception tests
- lifespan tests
- migration tests
- dependency-failure tests
- timeout tests
- cancellation tests
- concurrency tests
- load tests
- security tests
- backup tests
- restore tests
- rollback rehearsals

For each test set, record:

- environment
- command
- scope
- result
- failure
- limitation
- collection date
- relevance to production topology

Do not treat test count or coverage percentage as proof that critical production behaviours are verified.

### 22. Load, Capacity, and Degradation

Define representative:

- request mix
- payload sizes
- response sizes
- authentication mix
- read/write mix
- dependency latency
- concurrency
- connection reuse
- sustained load
- burst load
- background workload
- worker count
- replica count

Measure where evidence exists:

- throughput
- p50 latency
- p95 latency
- p99 latency
- error rate
- timeout rate
- CPU
- memory
- event-loop delay
- database connections
- queue depth
- dependency saturation
- restart behaviour

Determine:

- normal operating capacity
- warning threshold
- saturation point
- degradation behaviour
- autoscaling trigger
- recovery behaviour

Do not run production load tests without explicit scope, safeguards, monitoring, stop conditions, and authorization.

### 23. Migration and Release Compatibility

Inspect:

- database migrations
- schema compatibility
- data migrations
- API compatibility
- client compatibility
- feature flags
- rollout order
- deployment strategy
- canary strategy
- blue-green strategy
- rolling strategy
- backward compatibility
- forward compatibility
- mixed-version operation
- migration duration
- lock risk
- failure recovery

Confirm that:

- old application versions can operate during required transition periods
- new versions can tolerate the previous schema where required
- migrations have owners and approval
- destructive changes are staged safely
- rollback remains possible after migration
- irreversible steps are identified
- feature flags have defaults, owners, monitoring, and removal plans

### 24. Backup, Restore, and Rollback

Inspect current evidence for:

- backup scope
- backup frequency
- retention
- encryption
- ownership
- restore procedure
- restore test
- restoration time
- data reconciliation
- application rollback
- image rollback
- configuration rollback
- migration rollback
- feature-flag rollback
- dependency rollback

A rollback instruction is not sufficient evidence unless the necessary artifact, permission, compatibility, and verification path exist.

For every rollback, define:

- trigger
- decision owner
- procedure
- expected duration
- data consequence
- migration consequence
- dependency consequence
- verification
- communication
- escalation

Do not approve a material release when rollback or restoration is unknown.

### 25. Ownership, On-Call, and Incident Readiness

Confirm:

- service owner
- technical owner
- release owner
- security owner
- data owner
- on-call rotation
- escalation contacts
- vendor contacts
- incident commander path
- status-communication owner
- runbook owner
- dashboard owner
- alert owner

Inspect runbooks for:

- elevated error rate
- high latency
- dependency outage
- worker crash loop
- failed startup
- readiness failure
- connection exhaustion
- database incident
- queue backlog
- compromised credentials
- rollback
- restoration

Do not issue `Ready` where critical incidents have no accountable response owner.

## Failure Modes to Test

Treat each failure mode as a hypothesis, not a conclusion.

For every material hypothesis, provide:

- predicted signal
- observed evidence
- contradictory evidence
- affected routes or users
- release impact
- confidence
- cheapest safe test
- evidence that would change the assessment

Test the following failure modes.

### Development Runtime Reaches Production

Reload mode, an unsuitable development command, or a single unmanaged process is used in production without restart and recovery controls.

### Duplicate Startup Work

Workers or replicas independently execute migrations, scheduled jobs, consumers, or initialization that should occur once.

### Worker Resource Multiplication

Worker count multiplies memory, database connections, clients, models, or background tasks beyond available capacity.

### Unsafe Lifespan Behaviour

Startup can partially succeed, shutdown loses work, cleanup is incomplete, or lifecycle failures remain invisible.

### Forwarded-Header Trust Failure

The service trusts forwarded headers from untrusted clients or fails to trust the actual proxy, producing spoofed identity or incorrect public URLs.

### Host or CORS Misconfiguration

Host validation or cross-origin configuration is overly permissive, inconsistent, or incompatible with credentialed clients.

### Authentication Without Authorization

A valid identity can access another tenant’s object, administrative capability, or unauthorized operation.

### Validation Gap

Malformed, oversized, unexpected, or semantically invalid input bypasses the intended boundary.

### Sensitive Error Leakage

Exceptions, validation responses, logs, or debug output reveal private implementation or customer information.

### Dependency Timeout Cascade

Missing or inconsistent timeouts, retries, cancellation, and isolation exhaust workers or connections.

### Retry Amplification

Multiple layers retry the same failure and create a retry storm or duplicate side effect.

### Unbounded Resource Use

Requests, uploads, streams, WebSockets, background tasks, queues, or dependency calls consume resources without effective bounds.

### False Health Signal

Health endpoints report success while startup, routing, database, queue, or critical dependencies are unavailable.

### Destructive Liveness Policy

A recoverable dependency incident triggers repeated restarts that worsen the outage.

### Connection-Pool Exhaustion

Worker and replica multiplication exceeds database, cache, or external-service connection capacity.

### Non-Durable Background Work

Important work is accepted but lost when the process restarts or deployment begins.

### Incompatible Migration

Old and new application versions cannot safely coexist during rollout or rollback.

### Missing Operational Visibility

The service can fail in a material way without an alert, dashboard, trace, or diagnostic log.

### Unverified Rollback

Rollback documentation exists but has not been demonstrated against the current release topology.

### Unowned Release Risk

A security, reliability, privacy, or data exception has no authorized owner, expiry, or follow-up evidence.

## Workflow

### Step 1: Define the Release Boundary

Define:

- release objective
- included changes
- excluded changes
- target environment
- users
- critical routes
- data sensitivity
- service objectives
- release owner
- approvers
- allowed systems
- allowed tests
- definition of done

Treat unclear production, data, or authorization boundaries as blockers.

### Step 2: Build the Evidence Inventory

List all supplied:

- repository files
- settings
- dependency files
- deployment manifests
- infrastructure definitions
- tests
- logs
- metrics
- traces
- dashboards
- alerts
- runbooks
- migration plans
- backup evidence
- rollback evidence
- approvals

For each artifact, record:

- source
- owner
- version
- environment
- date
- observation
- authority
- limitation
- confidence
- next check

### Step 3: Map the Service and Deployment Topology

Trace:

1. client
2. DNS
3. content-delivery or security layer
4. load balancer or ingress
5. reverse proxy
6. container or host
7. ASGI server
8. FastAPI application
9. database, cache, queue, storage, and external services
10. logs, metrics, traces, and alerting systems

Show:

- trust boundaries
- network boundaries
- identity propagation
- TLS termination
- forwarded headers
- worker and replica counts
- connection pools
- failure paths
- ownership

### Step 4: Inspect Security and API Boundaries

Review:

- validation
- authentication
- authorization
- tenant isolation
- CORS
- host validation
- proxy trust
- secret loading
- exception handling
- sensitive logging
- administrative routes
- documentation exposure

Test representative positive and negative cases.

### Step 5: Inspect Runtime and Lifecycle Behaviour

Review:

- production command
- process manager
- workers
- replicas
- memory
- connection demand
- lifespan
- startup
- one-time initialization
- shutdown
- graceful draining
- scheduled jobs
- background work
- signals
- restarts

Confirm the behaviour under the intended deployment topology.

### Step 6: Trace Dependency Failure Behaviour

For each critical dependency, evaluate:

- timeout
- retry
- cancellation
- fallback
- degradation
- isolation
- monitoring
- recovery
- customer impact

Use controlled failure tests where safe and authorized.

### Step 7: Evaluate Observability

For each material incident scenario, identify:

- detection signal
- diagnostic evidence
- alert
- dashboard
- trace
- runbook
- owner
- escalation

Mark any incident that cannot be detected or diagnosed adequately.

### Step 8: Run Focused Verification

Run available, safe checks in this order where appropriate:

1. static repository inspection
2. dependency and configuration validation
3. focused unit tests
4. route and contract tests
5. authentication and authorization tests
6. lifespan and startup tests
7. integration tests
8. migration compatibility tests
9. dependency-failure tests
10. bounded load or resilience tests

Do not run unsafe checks merely to complete the list.

Record exact commands, environments, results, failures, and unrun checks.

### Step 9: Classify Findings

Classify every finding as:

- release blocker
- condition required before release
- time-bound approved exception
- post-release follow-up
- accepted control
- informational observation

Do not downgrade a blocker merely because remediation is inconvenient.

### Step 10: Issue the Readiness Decision

Return:

#### Ready

Use only when:

- no release blocker remains
- critical evidence is available
- approvals are complete
- rollback is viable
- monitoring and ownership are active

#### Ready with conditions

Use only when:

- no unresolved critical blocker remains
- every condition has an owner
- acceptance evidence is explicit
- exceptions are approved
- expiry and follow-up are defined
- conditions do not transfer unacceptable risk to customers or operators

#### Not ready

Use when:

- a critical control is absent
- evidence is materially insufficient
- security or tenant boundaries are unverified
- startup or shutdown is unsafe
- dependency behaviour is unbounded
- rollback or restoration is unknown
- migration compatibility is unverified
- release ownership or approval is missing

### Step 11: Define the Release Gate

Specify:

- prerequisites
- required evidence
- approval sequence
- migration sequence
- deployment sequence
- canary or phased rollout
- monitoring
- success criteria
- warning thresholds
- stop conditions
- rollback triggers
- rollback procedure
- restoration procedure
- communications

### Step 12: Define the Post-Release Watch

Specify:

- observation window
- request and error signals
- latency thresholds
- saturation indicators
- dependency health
- worker restarts
- startup failures
- readiness failures
- queue depth
- connection-pool health
- customer-impact signals
- review cadence
- owner
- escalation

Do not describe the release as successful before the agreed watch period and acceptance conditions are complete.

## Decision and Safety Controls

1. Do not run migrations, destructive tests, production probes, load tests, secret changes, or release actions without scope and approval.

2. Do not infer security from autogenerated OpenAPI documentation, framework defaults, or successful happy-path requests.

3. Do not log or reproduce:

   - credentials
   - authorization headers
   - tokens
   - cookies
   - private payloads
   - sensitive validation data
   - personal records

4. Do not increase workers until memory, CPU, dependency connections, startup work, and workload effects are understood.

5. Do not approve a release with unknown:

   - rollback
   - restoration
   - migration compatibility
   - service ownership
   - alert coverage
   - escalation

6. Require named security and service-owner review for material access, privacy, reliability, or data-integrity exceptions.

7. Prefer:

   - read-only inspection
   - isolated testing
   - staging rehearsal
   - canary release
   - reversible configuration
   - bounded experiments

8. Establish stop conditions before live or customer-visible tests.

9. Record every exception with:

   - reason
   - affected scope
   - risk
   - owner
   - approver
   - compensating control
   - expiry
   - verification
   - follow-up

10. Do not allow a temporary exception to become an undocumented production default.

11. Do not substitute Codex output for the accountable service, security, platform, data, or release owner.

12. Stop and escalate when:

   - repository or environment boundaries are unclear
   - secrets cannot be protected
   - required production evidence is unavailable
   - a test may alter important state
   - a critical route lacks authorization evidence
   - rollback is not viable
   - new customer harm appears
   - operating conditions materially change

## Output Contract

Return the result using the following sections.

Use concise prose for conclusions. Use tables only when they improve evidence comparison, ownership, status, sequence, or decision traceability.

### 1. Readiness Decision

Return:

- decision
- confidence
- release scope
- decision owner
- approval status
- strongest supporting evidence
- release blockers
- conditions
- unresolved unknowns
- next safe action

### 2. Evidence Register

For each artifact, show:

- source
- owner
- version
- environment
- date
- observation
- limitation
- confidence
- next check

### 3. Service and Deployment Map

Show:

- component
- runtime process
- ingress path
- trust boundary
- worker or replica count
- dependency
- data store
- timeout
- failure path
- owner

### 4. Route and Trust-Boundary Register

For each material route, show:

- route
- purpose
- exposure
- authentication
- authorization
- tenant rule
- validation
- rate or resource control
- data classification
- evidence
- status

### 5. Runtime and Lifecycle Review

Report:

- production command
- ASGI server
- workers
- replicas
- memory implications
- connection implications
- startup work
- one-time work
- shutdown behaviour
- graceful-drain evidence
- scheduled-work behaviour
- status

### 6. Dependency Resilience Review

For each critical dependency, show:

- dependency
- purpose
- timeout
- retry
- cancellation
- fallback
- degradation
- monitoring
- failure-test evidence
- owner
- status

### 7. Control Review

For every material control, show:

- control area
- requirement
- evidence
- result
- severity
- owner
- required action
- acceptance condition
- status

Cover:

- security
- validation
- configuration
- secrets
- runtime
- workers
- lifespan
- dependencies
- data
- health
- observability
- deployment
- rollback
- ownership

### 8. Release Blockers

For each blocker, show:

- blocker
- evidence
- affected scope
- customer or operational impact
- severity
- owner
- remediation
- retest
- required approval
- target status

### 9. Conditional Exceptions

For each exception, show:

- exception
- reason
- affected scope
- risk
- compensating control
- owner
- approver
- expiry
- required follow-up
- verification

### 10. Verification Record

For every check, show:

- command or test
- environment
- purpose
- actual result
- exit status
- limitation
- evidence location
- conclusion

List unrun checks separately with the reason they were not run.

### 11. Release and Rollback Gate

Define:

- prerequisite
- owner
- required evidence
- approval
- migration step
- deployment step
- monitoring
- success condition
- warning threshold
- stop condition
- rollback trigger
- rollback action
- restoration verification

### 12. Post-Release Watch Plan

Specify:

- signal
- baseline
- expected range
- warning threshold
- stop threshold
- source
- owner
- review cadence
- escalation
- observation window

### 13. Remaining Risks and Unknowns

For each item, show:

- risk or unknown
- potential impact
- current evidence
- evidence required
- owner
- next safe action

## Verification Checklist

Before finalizing, confirm that:

- the production command and deployment topology are confirmed from evidence
- deployed framework, validation-library, Python, and ASGI-server versions are identified
- effective production configuration is distinguished from repository defaults
- required secrets are validated without exposing their values
- authentication and authorization are checked at every material route boundary
- object-level and tenant-level authorization are covered
- malformed, oversized, and unauthorized requests are tested or explicitly untested
- trusted-host, CORS, forwarded-header, proxy, and public-URL behaviour are verified
- exceptions do not expose sensitive information
- worker count is evaluated against memory, CPU, connections, startup work, and replicas
- startup and shutdown remain safe with the intended worker and replica counts
- one-time migrations and scheduled jobs cannot execute unintentionally per worker
- dependency timeouts, retries, cancellation, and degradation are bounded
- background work has appropriate durability and duplicate protection
- readiness and liveness match the platform routing and restart contracts
- logs, metrics, traces, alerts, and runbooks support material incident diagnosis
- observability avoids sensitive data and unbounded metric labels
- migration sequencing supports rollout and rollback requirements
- backup, restoration, and rollback evidence is current
- load evidence represents the intended production topology where required
- every release blocker has an owner, remediation, acceptance condition, and retest
- every exception has an approver, compensating control, and expiry
- the final release decision names an accountable human owner
- every major conclusion is supported by evidence or explicitly labelled as an assumption
- no unrun check, unreviewed source, unapproved action, or unresolved conflict is described as complete
- the final next action is the smallest safe step that materially reduces release uncertainty or operational risk

Begin by checking the supplied context for blocking gaps.

If none remain, inspect the repository and evidence in read-only mode, build the service and deployment map, perform the review in order, and issue the readiness decision.

Variables to Replace

  • Release objective, scope, and target date
  • Repository, service, and business context
  • FastAPI, Starlette, Pydantic, Python, and ASGI-server versions
  • Relevant application, configuration, deployment, and infrastructure files
  • Current behaviour, known defects, logs, and unresolved incidents
  • Expected behaviour and production definition of done
  • Critical routes, users, tenants, and data classifications
  • Authentication, authorization, and trust-boundary design
  • Deployment topology from ingress to application and dependencies
  • Runtime command, process manager, worker model, and container strategy
  • Environment configuration and secret-loading approach without secret values
  • Traffic profile, concurrency, payload sizes, and service-level objectives
  • Databases, queues, caches, storage, and external dependencies
  • Migration, initialization, scheduled-work, and startup procedures
  • Health-check, observability, alerting, and incident-response evidence
  • Testing, load, security, backup, restore, and rollback evidence
  • Allowed files, systems, environments, and remediation scope
  • Release owner, security reviewer, service owner, and approvers
  • Verification commands and acceptance criteria

How to Use This Prompt

Open Codex from the FastAPI repository root and paste the complete prompt.

Replace every bracketed placeholder with sanitized repository, deployment, security, and operational evidence.

Provide relevant application files, settings, dependency declarations, lock files, Docker files, orchestration manifests, infrastructure configuration, runtime commands, route definitions, middleware, authentication and authorization code, migration procedures, test commands, monitoring evidence, alert definitions, backup evidence, rollback procedures, and release criteria.

Do not provide passwords, API keys, access tokens, authorization headers, connection strings, customer records, personal data, or private request payloads.

Instruct Codex to begin with repository inspection and read-only evidence collection. Require it to preserve unrelated work and report every command, result, failure, and unrun check.

Do not authorize migrations, production probes, load tests, deployments, secret rotation, service restarts, or external changes through this prompt alone.

Require named service-owner, security-owner, platform-owner, and release-owner approval for consequential production actions.

Use the output as a release-review pack. Resolve every blocker, verify every condition, and obtain accountable human approval before production deployment.

Example Use Case

A platform team is preparing a containerized FastAPI billing API for production.

The team supplies Codex with the application factory, routers, Pydantic models, authentication and authorization dependencies, settings, middleware, exception handlers, dependency lock file, database integration, migration files, Dockerfile, orchestration manifests, Uvicorn command, ingress configuration, trusted-proxy settings, worker and replica plan, health endpoints, load-test results, dashboards, alerts, backup evidence, rollback procedure, and release criteria.

Codex maps the complete path from ingress to the application and its database, queue, cache, payment provider, and observability systems.

It verifies route-level and tenant-level authorization, request validation, CORS and host controls, proxy-header trust, startup and graceful shutdown, worker resource multiplication, database-pool capacity, dependency timeouts, background-task durability, readiness semantics, sensitive-data redaction, migration compatibility, alert coverage, and rollback evidence.

Codex returns `Ready with conditions`, identifies two blocking conditions involving worker-level scheduler duplication and an unverified database-restore procedure, assigns owners and acceptance criteria, and defines a canary rollout with monitoring thresholds, stop conditions, and rollback.

Build stronger AI systems

Use Amo.ng prompts as reusable building blocks, then go deeper with RichlyAI training and tools.

RichlyAI Learn RichlyAI Hub

Related Prompts

Browse all