ADR-005: Keep Finance workflow outcomes separate from Order status
Finance reports cleanup outcomes and tracks its own saga lifecycle while Ordering remains authoritative for Order completion and cancellation.
1. Context & Problem
Post-checkout processing involves several distinct outcomes owned by different capabilities: basket cleanup, Order business status, Finance workflow progress, and email delivery. Treating a Finance workflow outcome—such as a cleanup failure or retry timeout—as the Order’s business status would create competing owners for the Order lifecycle.
Only Ordering can decide and declare that an Order is completed or cancelled. This retrospective ADR records Finance’s side of that ownership boundary alongside the related Ordering decision.
2. Business Value
- Single source of truth for orders: Business stakeholders, customer support, and downstream consumers always look to Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle, creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs as the sole authority for Order status.
- Protection against accidental cancellations: Technical cleanup delays or coordination timeouts never silently override an Order’s business state.
- Independent system ownership: Finance and Ordering can evolve, deploy, and recover independently without sharing a coupled state machine or database.
- Honest operational visibility: Keeping workflow progress distinct from Order status prevents misleading reporting on payments, fulfillment, or customer outcomes.
3. How It Works
- Finance owns coordination only: Finance tracks whether post-checkout steps (basket cleanup and notification triggers) succeeded, failed, or timed out, while Ordering owns the Order’s business status.
- Basket cleanup success: Finance notifies Ordering that cleanup succeeded. Ordering logs that result without completing the Order, and Finance keeps its workflow open waiting for Ordering’s explicit completion or cancellation decision.
- Basket cleanup failure: Finance closes its workflow with a basket-deletion failure outcome and informs Ordering. Ordering may soft-delete the matching Order record if it exists, without changing the Order’s business status.
- Coordination timeout exhaustion: When Finance exhausts its placement retries, it marks only its internal workflow as cancelled—not the Order itself.
- Authoritative Order updates: Only when Ordering publishes an explicit completed or cancelled status update does Finance close its workflow as completed or cancelled and request the corresponding customer notification (when recipient details allow).
4. Trade-offs & Lessons Learned
Alternatives Considered
- Mapping Finance cancellation directly to Order cancellation: Would make status labels look uniform, but would escalate a local retry timeout into a business Order cancellation without Ordering’s approval or workflow.
- Treating basket deletion success as Order completion: Clearing a shopping basket is only one step of post-checkout coordination and does not prove the Order is complete.
- Merging Finance and Order lifecycles into one shared state machine: Would reduce apparent state differences, but would tightly couple ownership and failure recovery across independently deployed systems.
Operational Realities & Support Lessons
- Divergent states are normal: An Order can legitimately remain in a new state while its Finance workflow has failed or been cancelled. Likewise, Ordering soft-deleting an Order record is distinct from changing its business status.
- Side-by-side observability required: Monitoring dashboards and support tooling must show Finance workflow state and Order status as separate facts correlated by Order ID, never treating Finance state names as Order transitions.
- Avoid false inferences: A timeout-triggered cancellation email does not confirm that Ordering cancelled the purchase, and none of Finance’s coordination outcomes imply payment settlement, shipping execution, or confirmed email delivery.
- Respect service boundaries during recovery: Cross-service incidents must be resolved through explicit workflows and messages—never by manually editing another service’s database.
5. Technical Reference
Ownership & Command Mapping
| Outcome / Event | Finance Action & Saga State | Ordering Effect |
|---|---|---|
| Basket cleanup succeeds | Sends Acknowledge basket deletion completedCommandv1.0.0Acknowledge basket deletion completedReports Finance's successful basket-cleanup outcome to Order API without changing the Order's business status. Ownercommerce-fulfillment-teamSchemaDiagramOpen docs; saga stays open awaiting Order lifecycle event. | Logs cleanup result without completing the Order. |
| Basket cleanup fails | Sets saga to BasketDeletionFailed, completes saga, sends Handle basket deletion failedCommandv1.0.0Handle basket deletion failedReports Finance's failed basket-cleanup outcome so Order API can
soft-delete the affected Order.
Ownercommerce-fulfillment-teamSchemaDiagramOpen docs. | Soft-deletes matching Order if it exists, without changing its business status (e.g., Order may remain New). |
| Timeout retries exhausted | Sets saga to Cancelled, completes saga; does not cancel the Order. | Order status unaffected (can remain New). |
| Explicit Order completed/cancelled event | Completes corresponding saga handler and requests notification if recipient details permit. | Authoritative status owned by Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle, creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs. |
Key Implementation Rules
- Authoritative source: Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle,
creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs is the single authority for Order completion and cancellation; related decision recorded in
adr-003-separate-order-status-from-finance-saga(1.0.0). - Non-implication guarantee: Coordination outcomes (
DeleteBasketCompleteCommand,DeleteBasketFailedCommand, sagaCancelled, or notification commands) do not establish payment settlement, shipping execution, or email delivery.