Prompt Details
Model
Chat - (gpt-5.6)
Token size
3,843
Example input
[DESCRIBE THE SOFTWARE, APPLICATION, SERVICE, OR PLATFORM]: An e-commerce platform that allows customers to place orders, make payments, and receive order confirmations.
[DESCRIBE THE ERRORS, FAILURES, INCIDENTS, OR FAILURE PATTERNS]: Payment succeeds, but the application times out before recording the payment result and updating the order status.
[DESCRIBE HOW THE SYSTEM CURRENTLY DETECTS AND HANDLES ERRORS]: The application retries the payment request automatically up to 3 times.
[DESCRIBE SERVICES, DATABASES, APIs, QUEUES, CLOUD SERVICES, THIRD-PARTY SYSTEMS, AND OTHER DEPENDENCIES]: Web application → Order Service → PostgreSQL database → Payment Gateway → Notification Service.
[DESCRIBE WHAT THE RECOVERED SYSTEM MUST ACHIEVE AFTER A FAILURE]: Recover uncertain payment states safely, prevent duplicate charges, restore the correct order state, and notify the customer.
Example output
🏗️ PHASE 1 - SOFTWARE FAILURE CONTEXT RECONSTRUCTION
System Context
FACT
The system is an e-commerce order-processing platform.
The known workflow is:
Customer
↓
Web Application
↓
Order Service
↓
Payment Gateway
↓
PostgreSQL
↓
Notification Service
Critical workflow:
Create Order
→ Initiate Payment
→ Receive Payment Result
→ Update Order
→ Send Confirmation
The primary failure occurs when the payment gateway may have processed the payment, but the application does not receive or persist the result.
Critical Operations
1. Create order.
2. Initiate payment.
3. Persist payment state.
4. Update order state.
5. Send order confirmation.
6. Recover uncertain payment state.
Failure-Sensitive Components
Payment Gateway
Order Service
PostgreSQL
Network communication between application and payment gateway
Notification Service
Retry mechanism
Known Constraints
FACT
Payment can potentially succeed even if the application experiences a timeout.
Duplicate charging must be prevented.
PostgreSQL stores order state.
The current system retries payment up to 3 times.
Unknowns
UNKNOWN
Whether the payment gateway supports idempotency keys.
Whether payment status can be queried independently.
Whether payment authorization and capture are separate.
Whether database transactions cover order/payment state transitions.
Whether notifications are asynchronous.
Whether payment gateway webhooks exist.
Assumptions
ASSUMPTION
The payment provider exposes some mechanism for checking payment status.
This must be validated before implementation.
---
🔎 PHASE 2 - ERROR & FAILURE TAXONOMY
Failure Type Recoverability Blast Radius
Payment timeout Transient / uncertain Potentially recoverable Single order
Payment gateway outage Dependency failure Temporarily recoverable Many orders
Invalid payment request Permanent/business failure Not retryable Single order
Database failure Infrastructure failure Potentially recoverable Multiple orders
Duplicate payment request State/idempotency failure Preventable Financial
Notification failure Dependency failure Usually recoverable Customer communication
Important classification
A payment timeout must not automatically mean payment failed.
The system may actually be in:
PAYMENT_SUCCEEDED
OR
PAYMENT_FAILED
OR
PAYMENT_UNKNOWN
Therefore:
PROPOSED DESIGN
Introduce an explicit:
PAYMENT_UNKNOWN
state.
This prevents the system from incorrectly retrying an operation whose actual external outcome is unknown.
---
🔍 PHASE 3 - FAILURE DETECTION ARCHITECTURE
Detection Signals
The system should monitor:
Payment API timeout
Connection failure
HTTP error
Gateway response
Database update failure
Payment webhook
Payment-status query
Order/payment state mismatch
Detection states
No Error
↓
Detected Error
↓
Suspected Failure
↓
Confirmed Failure
For payment timeout:
Payment Request Sent
↓
No Response
↓
DETECTED ERROR
↓
Outcome Unknown
The system must not immediately transition to:
PAYMENT_FAILED
Recovery success
Recovery is successful only when the system verifies something such as:
Payment Gateway Status = SUCCESS
+
Database Payment State = SUCCESS
+
Order State = CONFIRMED
STRICT RULE
No response from the payment API is not evidence that the payment failed.
---
🧠 PHASE 4 - ERROR DIAGNOSIS & ROOT-CAUSE ANALYSIS
Observed Symptom
FACT
Application receives a timeout while waiting for the payment gateway.
Possible Causes
1. Payment gateway is slow.
2. Network connection failed.
3. Payment gateway processed payment but response was lost.
4. Payment gateway rejected payment but response was lost.
5. Application timeout is shorter than gateway processing time.
6. Payment gateway is unavailable.
Root-Cause Hypotheses
Hypothesis Evidence Required Confidence
Network timeout Network telemetry UNKNOWN
Gateway processed payment but response was lost Gateway payment status UNKNOWN
Gateway never processed request Gateway logs/status UNKNOWN
Application timeout too aggressive Timing metrics UNKNOWN
Important distinction
SYMPTOM:
Payment API timeout
TRIGGER:
Network/API request exceeded timeout
POSSIBLE ROOT CAUSE:
Gateway/network/application latency
CONTRIBUTING FACTOR:
No confirmed external payment state
AMPLIFIER:
Automatic retries without idempotency
CONSEQUENCE:
Potential duplicate charge
The retry mechanism itself can become an amplifier.
---
♻️ PHASE 5 - RECOVERY ELIGIBILITY ANALYSIS
Payment Timeout
PROPOSED DESIGN
Do not immediately retry the payment operation.
First:
Timeout
↓
Mark PAYMENT_UNKNOWN
↓
Check payment status
Recovery options
Recovery Appropriate? Condition
Retry payment Conditional Idempotency guaranteed
Query payment status Yes Gateway supports status lookup
Fail fast No Payment outcome remains unknown
Fallback provider Conditional Business and payment architecture support it
Rollback Limited External payment cannot necessarily be rolled back automatically
Compensation/refund Conditional Payment succeeded but order cannot complete
Human escalation Yes Automated state resolution fails
Critical safety condition
Never execute:
Timeout
→ New Payment
unless duplicate execution is proven safe.
---
⏱️ PHASE 6 - RETRY & BACKOFF ARCHITECTURE
The current behavior is:
Payment Request
↓
Retry 1
↓
Retry 2
↓
Retry 3
This is potentially dangerous.
Proposed architecture
For an uncertain payment outcome:
Payment Timeout
↓
DO NOT immediately retry charge
↓
Query Payment Status
↓
┌───────────────┐
↓ ↓
SUCCESS FAILED
↓ ↓
Confirm Controlled retry
Order if safe
Retry Condition
Retry only when:
Error is classified as retryable.
Payment outcome is known to be unsuccessful, OR
Idempotency mechanism guarantees duplicate safety.
Retry Limit
PROPOSED DESIGN
Use a finite retry budget.
Example:
Maximum status checks: 3
Maximum payment retries: 1
These numbers are proposed examples and require validation against gateway behavior.
Backoff
Use:
Exponential Backoff + Jitter
Example:
1st attempt → short delay
2nd attempt → longer delay
3rd attempt → longer delay
Stop Conditions
Stop retrying when:
Payment succeeds.
Payment fails permanently.
Retry deadline expires.
Idempotency cannot be guaranteed.
Gateway indicates a permanent error.
Recovery state becomes inconsistent.
---
🧩 PHASE 7 - FALLBACK & DEGRADATION ARCHITECTURE
Possible fallback:
Primary Payment Gateway
↓
Failure
↓
Alternative Payment Provider
However:
PROPOSED DESIGN
Do not automatically switch providers for an uncertain payment transaction.
Why?
The first provider may already have charged the customer.
Example:
Gateway A
↓
Customer charged
↓
Response lost
↓
System assumes failure
↓
Gateway B charged
Result:
DOUBLE CHARGE
Safer fallback
Use:
Payment Status Recovery
↓
Resolve Gateway A State
↓
Only then consider alternative processing
Alternative fallback
Allow:
Order Pending Payment
instead of forcing immediate failure.
This gives the system time to reconcile the payment state.
---
💾 PHASE 8 - STATE, TRANSACTION & DATA RECOVERY
Define explicit states:
ORDER_CREATED
↓
PAYMENT_PENDING
↓
PAYMENT_UNKNOWN
↓
PAYMENT_CONFIRMED
↓
ORDER_CONFIRMED
Failure state:
PAYMENT_UNKNOWN
must be treated differently from:
PAYMENT_FAILED
State model
State Meaning
PAYMENT_PENDING Payment request is being processed
PAYMENT_UNKNOWN External result cannot currently be determined
PAYMENT_SUCCESS Payment provider confirms success
PAYMENT_FAILED Provider confirms failure
PAYMENT_REQUIRES_REVIEW Automated reconciliation failed
Recovery sequence
Payment Unknown
↓
Query Provider
↓
Provider SUCCESS
↓
Persist Payment SUCCESS
↓
Update Order CONFIRMED
↓
Send Notification
If payment succeeded but database update failed:
Provider = SUCCESS
Database = PENDING
This is a reconciliation problem.
PROPOSED DESIGN
A reconciliation worker should identify and repair this state.
---
🔐 PHASE 9 - IDEMPOTENCY & DUPLICATE EXECUTION CONTROL
This is one of the most important controls.
Proposed idempotency key
Generate:
payment_id / order_id
or another unique transaction identifier.
Example:
Order ID:
ORD-100245
Payment Idempotency Key:
PAY-ORD-100245
Every retry uses the same idempotency key.
Never generate a new payment identity for every retry.
Duplicate protection
Potential controls:
Payment idempotency key
Database unique constraint
Payment transaction ID
Request ID
Gateway transaction reference
Deduplication table
Duplicate scenario
Request 1
↓
Gateway processes payment
↓
Response lost
Retry
↓
Same idempotency key
↓
Gateway recognizes existing transaction
This is safer than:
Retry
↓
New payment transaction
UNKNOWN
Whether the actual gateway supports this must be validated.
---
🌐 PHASE 10 - DEPENDENCY & CASCADE RECOVERY
Payment Gateway Failure
Potential signals:
Timeout rate increases.
Connection errors increase.
Gateway returns 5xx.
Gateway health/status indicates outage.
Circuit breaker
PROPOSED DESIGN
If gateway failures exceed a defined threshold:
CLOSED
↓
Repeated failures
↓
OPEN
↓
Stop sending normal payment traffic
↓
HALF-OPEN
↓
Controlled test request
↓
CLOSED
The exact threshold requires production evidence.
Cascade prevention
Without protection:
Gateway Slow
↓
Requests timeout
↓
Application retries
↓
Traffic increases
↓
Gateway becomes slower
↓
More timeouts
↓
More retries
This creates a feedback loop.
Control:
Retry Budget
+
Circuit Breaker
+
Timeouts
+
Jitter
+
Concurrency Limits
---
🔄 PHASE 11 - RECOVERY ORCHESTRATION
Recovery State Machine
PAYMENT_PENDING
↓
PAYMENT_REQUESTED
↓
├── SUCCESS ─────→ PAYMENT_CONFIRMED
│
├── FAILURE ─────→ PAYMENT_FAILED
│
└── TIMEOUT
↓
PAYMENT_UNKNOWN
↓
STATUS CHECK
↙ ↘
SUCCESS FAILED
↓ ↓
CONFIRMED Controlled Retry
↓
Payment
If status cannot be established:
PAYMENT_UNKNOWN
↓
Recovery Deadline
↓
PAYMENT_REQUIRES_REVIEW
↓
Human / Operations Review
Recovery Loop Prevention
Do not allow:
UNKNOWN
↓
RETRY
↓
UNKNOWN
↓
RETRY
↓
UNKNOWN
↓
RETRY forever
Instead:
UNKNOWN
↓
Recovery Budget
↓
Escalation
---
📊 PHASE 12 - OBSERVABILITY & RECOVERY VERIFICATION
Track:
Recovery Metrics
Payment timeout count
Payment unknown count
Payment recovery success rate
Payment recovery latency
Status-query count
Payment retry count
Duplicate-payment prevention events
Reconciliation failures
Human escalations
Compensation/refund events
Gateway error rate
Correlation
Every operation should be traceable through:
Request ID
+
Order ID
+
Payment ID
+
Idempotency Key
+
Recovery Attempt ID
Example:
Order: ORD-100245
Payment: PAY-100245
Recovery: REC-78451
This allows engineers to reconstruct:
Original Request
→ Failure
→ Recovery Decision
→ Recovery Action
→ Validation
---
🧪 PHASE 13 - FAILURE INJECTION & RECOVERY TESTING
Test 1 - Payment Timeout
Initial Condition
Order is in:
PAYMENT_PENDING
Failure Injection
Payment gateway delays response beyond application timeout.
Expected Detection
Timeout detected
Expected Recovery
PAYMENT_UNKNOWN
→ Query payment status
Expected Recovered State
If provider says success:
PAYMENT_CONFIRMED
ORDER_CONFIRMED
Validation
Exactly one payment transaction exists.
Order status is correct.
Customer receives confirmation.
Failure Criteria
Duplicate payment.
Incorrect order status.
Payment marked failed without evidence.
---
Test 2 - Duplicate Request
Failure Injection
Send the same payment request twice with the same idempotency key.
Expected Result
Only one payment transaction should be created.
---
Test 3 - Database Failure
Payment succeeds but database becomes unavailable.
Expected:
Payment Gateway = SUCCESS
Database = UNKNOWN/PENDING
Recovery:
Reconciliation Worker
↓
Query payment
↓
Repair database state
---
Test 4 - Recovery Action Failure
Payment status lookup itself fails.
Expected:
PAYMENT_UNKNOWN
↓
Retry status lookup within bounded budget
↓
Still unresolved
↓
PAYMENT_REQUIRES_REVIEW
No unlimited retries.
---
⚠️ PHASE 14 - RECOVERY RISK & BLAST-RADIUS ANALYSIS
Failure Recovery Action Secondary Risk Control
Payment timeout Retry Duplicate charge Idempotency
Gateway outage Retry Retry storm Backoff + circuit breaker
DB failure Reconciliation State mismatch Transaction + reconciliation
Unknown payment Alternative provider Double payment Resolve original state first
Notification failure Retry notification Duplicate notification Notification idempotency
Repeated recovery failure Automatic retry Infinite loop Recovery budget
Highest-risk recovery scenario
Payment outcome unknown
↓
System retries with new transaction
↓
Original payment succeeded
↓
Second payment succeeds
Result:
Potential duplicate charge
Therefore, payment recovery should prioritize state resolution and idempotency before retrying the financial operation.
---
🛠️ PHASE 15 - RECOVERY HARDENING & IMPLEMENTATION ROADMAP
Improvement 1 - Introduce PAYMENT_UNKNOWN
Problem
Timeout currently may be interpreted as failure.
Proposed Change
Add explicit uncertain-payment state.
Architecture Impact
Payment state machine becomes more accurate.
Testing
Test timeout with both:
Provider success
Provider failure
Success Criteria
No uncertain transaction is incorrectly classified as failed.
---
Improvement 2 - Add Idempotency
Problem
Automatic retries may duplicate payment attempts.
Proposed Change
Use stable idempotency keys.
Dependencies
Payment provider must support appropriate idempotency behavior.
Testing
Send duplicate requests.
Success Criteria
Only one financial transaction is created.
---
Improvement 3 - Add Reconciliation
Problem
External payment state and database state can diverge.
Proposed Change
Create reconciliation workflow.
External Payment State
↕
Internal Payment State
Success Criteria
Known mismatches are detected and safely resolved.
---
Improvement 4 - Add Recovery Budgets
Problem
Recovery can continue indefinitely.
Proposed Change
Define:
Maximum attempts
Maximum recovery duration
Maximum status checks
Escalation threshold
Success Criteria
No uncontrolled recovery loop exists.
---
Improvement 5 - Add Recovery Observability
Problem
Recovery behavior cannot be trusted without measurement.
Proposed Change
Track recovery lifecycle metrics and correlation IDs.
Success Criteria
Engineers can reconstruct every recovery attempt.
---
✅ PHASE 16 - FINAL SOFTWARE ERROR RECOVERY ARCHITECTURE REPORT
1. Executive Summary
The central failure scenario is a payment timeout where the external payment outcome is unknown.
The safest architecture is not:
Timeout → Retry Payment
Instead:
Timeout
→ Mark Payment Unknown
→ Determine External Payment State
→ Validate State
→ Update Internal State
→ Resume Order Processing
→ Escalate if State Cannot Be Safely Determined
The architecture prioritizes:
Financial correctness
Idempotency
State consistency
Bounded recovery
Explicit validation
Human escalation
---
2. System & Failure Context
Known architecture:
Customer
↓
Web Application
↓
Order Service
↓
PostgreSQL
↓
Payment Gateway
↓
Notification Service
The exact implementation details remain partially unknown.
---
3. Failure Taxonomy
Primary failure:
Payment timeout with uncertain external outcome.
Secondary failures:
Gateway outage
Network failure
Database failure
Duplicate execution
Notification failure
State inconsistency
---
4. Root-Cause Analysis
The timeout itself is the observed symptom.
The actual root cause may be:
Network failure
Gateway latency
Gateway processing delay
Application timeout
Gateway outage
Additional telemetry is required to determine the actual cause.
---
5. Recovery Eligibility Matrix
Failure Recovery Type Preconditions Stop Condition Validation Escalation
Payment timeout Status reconciliation Gateway status available Recovery budget exhausted Provider state + DB state Yes
Confirmed payment failure Controlled retry Retryable error + idempotency Retry limit reached Payment status Yes
Gateway outage Delay/retry Retryable outage Circuit breaker open Successful request Yes
DB failure Reconciliation Payment reference exists Recovery deadline DB/payment consistency Yes
Notification failure Retry Notification idempotency Retry budget exhausted Delivery state Optional
Duplicate request Deduplication Stable transaction ID Duplicate detected One transaction If unresolved
---
6. Retry & Backoff Strategy
Use:
Bounded Retry
+
Exponential Backoff
+
Jitter
+
Retry Budget
+
Timeout Deadline
+
Idempotency
Never:
Unlimited Retry
---
7. Fallback & Degradation Strategy
Preferred fallback for uncertain payments:
Do not switch payment providers immediately.
Resolve original payment state first.
If state remains unresolved:
Order Pending
→ Customer/Operations Review
This is safer than silently processing another payment.
---
8. State & Data Recovery Architecture
Recommended state model:
PENDING
↓
PROCESSING
↓
UNKNOWN
↓
├── SUCCESS
│ ↓
│ CONFIRMED
│
└── FAILURE
↓
FAILED
Unknown state must not be treated as failure.
---
9. Idempotency & Duplicate-Control Strategy
Every payment attempt should have a stable transaction identity.
Recommended controls:
Idempotency key
Unique payment ID
Gateway transaction reference
Database uniqueness constraint
Duplicate detection
Recovery attempt ID
---
10. Dependency Recovery Architecture
Payment gateway failures should be controlled using:
Timeout
+
Retry Budget
+
Backoff
+
Jitter
+
Circuit Breaker
+
Concurrency Control
The payment gateway's actual capabilities must be validated before implementation.
---
11. Recovery State Machine
┌──────────────┐
│PAYMENT_PENDING│
└──────┬───────┘
↓
┌──────────────┐
│ PROCESSING │
└──────┬───────┘
↓
┌──────────────┐
│ RESULT │
└──────┬───────┘
┌────┼────┐
↓ ↓ ↓
SUCCESS FAIL TIMEOUT
↓ ↓ ↓
CONFIRMED FAILED UNKNOWN
↓
STATUS CHECK
↙ ↘
SUCCESS FAILURE
↓ ↓
CONFIRMED CONTROLLED
RECOVERY
↓
ESCALATION
---
12. Recovery Observability Architecture
Track:
Recovery attempts
Recovery duration
Recovery success rate
Retry count
Timeout count
Unknown-payment count
Reconciliation failures
Duplicate detection
Escalations
Compensation/refund events
Every recovery event should be correlated with:
Order ID
Payment ID
Request ID
Recovery ID
Idempotency Key
---
13. Failure Testing Strategy
Minimum recovery test suite:
1. Payment timeout + payment succeeded.
2. Payment timeout + payment failed.
3. Payment timeout + status unavailable.
4. Duplicate payment request.
5. Database unavailable after successful payment.
6. Gateway outage.
7. Recovery action timeout.
8. Repeated recovery failure.
9. Concurrent recovery attempts.
10. Notification failure.
Each test must verify both:
Recovery Action
+
Final State Correctness
---
14. Recovery Risk Register
Risk Trigger Impact Recovery Risk Control Validation
Duplicate charge Retry after timeout Financial High Idempotency Transaction count
Retry storm Gateway outage System overload High Backoff + circuit breaker Retry metrics
State mismatch DB failure Incorrect order state High Reconciliation State comparison
Silent degradation Fallback Customer confusion Medium Explicit status User-state validation
Recovery loop Repeated failures Resource exhaustion High Recovery budget Attempt count
Stale payment state Delayed provider data Incorrect order state Medium Reconciliation Provider verification
---
15. Implementation Roadmap
Priority 1
Implement:
PAYMENT_UNKNOWN
+
Idempotency
+
Explicit State Machine
Priority 2
Implement:
Payment Status Reconciliation
+
Bounded Recovery
+
Recovery Validation
Priority 3
Implement:
Circuit Breaker
+
Retry Budget
+
Backoff/Jitter
+
Concurrency Controls
Priority 4
Implement:
Recovery Observability
+
Failure Injection Tests
+
Operational Escalation
The exact priority should be adjusted after validating the existing architecture and payment-provider capabilities.
---
16. Recovery Readiness Checklist
[ ] Payment timeout is distinguished from payment failure.
[ ] PAYMENT_UNKNOWN state exists.
[ ] Idempotency mechanism is implemented or validated.
[ ] Duplicate payment detection exists.
[ ] Retry limits are defined.
[ ] Retry stop conditions are defined.
[ ] Backoff and jitter are implemented where appropriate.
[ ] Recovery deadlines exist.
[ ] Recovery loops are prevented.
[ ] Payment status can be reconciled.
[ ] Database/payment inconsistencies can be detected.
[ ] Recovery success is explicitly validated.
[ ] Human escalation exists.
[ ] Recovery metrics are available.
[ ] Recovery attempts are traceable.
[ ] Failure-injection tests exist.
[ ] Recovery actions have defined success criteria.
---
17. Open Questions & Unknowns
UNKNOWN
1. Does the payment provider support idempotency keys?
2. Does the provider expose payment-status lookup?
3. Are webhooks available?
4. Does the database transaction include payment-state updates?
5. Can payments be reversed/refunded automatically?
6. How long can a payment remain in an uncertain state?
7. Are payment operations authorization-only or immediate capture?
8. Is the notification system idempotent?
9. Can multiple recovery workers process the same order concurrently?
10. What are the actual business RTO/RPO requirements?
These must be answered before final production implementation.
---
18. Final Architecture Recommendations
The core recovery architecture should be:
PAYMENT REQUEST
↓
SUCCESS ─────────→ VALIDATE → CONFIRM ORDER
│
↓
TIMEOUT
↓
PAYMENT_UNKNOWN
↓
RESOLVE EXTERNAL STATE
↓
┌────┴─────┐
↓ ↓
SUCCESS FAILURE
↓ ↓
VALIDATE SAFE RETRY
↓ ↓
CONFIRM VALIDATE
ORDER ↓
CONFIRM/FAIL
↓
RECOVERY EXHAUSTED
↓
HUMAN ESCALATION
The most important architectural principle is:
An error recovery system should recover the system's state, not merely repeat the failed operation. 🔐
In this example, the critical question is not simply "Did the API request fail?" but "What actually happened to the payment, and can we prove the recovered state is correct?" 🛠️
By purchasing this prompt, you agree to our terms of service
GPT-5.6
Software Error Recovery Architect transforms software failure scenarios into a structured, implementation-ready recovery architecture covering error classification, recovery strategies, retries, fallbacks, state recovery, rollback, compensation, idempotency, dependency failures, observability, testing, and production resilience.
Turn unpredictable software failures into controlled, testable, and recoverable engineering workflows.
👉 Use the prompt below to architect a complete software error re
...more
Added over 1 month ago
