---
title: Order change checklist
summary: Pre-merge engineering checklist for Ordering API, Finance orchestration, persistence, and contract changes.
version: 1.0.0
type: engineering
order: 2
badges:
  - content: Architecture
    backgroundColor: green
    textColor: green
---

## Purpose & Scope

This checklist defines the mandatory contract, lifecycle, persistence, concurrency, and verification checks for engineers modifying [[service|order-api]] or [[service|order-orchestration]] in the [[domain|ordering]] subdomain. Review it before merging changes to HTTP v1 routes, Kafka messages, [[container|order-database]] schemas, or Redis coordination.

## Visual Reference

The visual below contrasts authoritative [[service|order-api]] status transitions with independent [[service|order-orchestration]] saga states.

<MermaidFileLoader file="mermaids/02-order-change-checklist-diagram-1.mmd" />

_Order Status and Finance Orchestration State Transitions_

## Core Invariants & Design Rules

- **Terminal status immutability:** Only a `New` [[entity|order]] can transition to `Completed` or `Cancelled`; terminal states can never reopen or switch.
- **Locked purchase snapshot:** Each [[entity|order-item]] stores `BookId`, a positive quantity, and checkout unit price (`PriceSale ?? Price`), with the order total equal to the sum of recorded line totals.
- **Authorization & rate-limit boundaries:** Preserve Microsoft Entra ID `customer` and `admin` policies (`ordering_read`, `ordering_write` scopes, admin-only delete and summary endpoints) and `PerUserRateLimit`.
- **Privacy & correlation:** Keep buyer street addresses and personal data out of routine logs and error payloads; correlate checkout and saga traces by `OrderId` and W3C trace context.

:::warning
**Do not conflate soft deletion or saga timeout with `Order.Status = Cancelled`.** [[command|DeleteBasketFailedCommand]] soft-deletes the order while leaving `Status` as `New`, and Finance timeout exhaustion cancels only the `finance-taskhub` orchestration.
:::

## Boundaries & Guarantees

| Concern             | Strategy & Guarantee                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Failure / Edge-Case Behavior                                                                                                                                                                                                                        | Related Resources                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| :------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Persistence**     | EF Core migrations in <ResourceLink id="order-database" type="container">order-database</ResourceLink> use `snake_case` identifiers; Marten event streams and Wolverine outbox/inbox tables commit atomically with `Order` writes.                                                                                                                                                                                                                                                                 | Missing migrations or unaligned Marten event types break audit history (`GET /api/v1/orders/{id}/history`) and projections (`OrderSummary`, `OrderSummaryView`).                                                                                    | <ResourceLink id="order-database" type="container">order-database</ResourceLink>, <ResourceLink id="order" type="entity">order</ResourceLink>, <ResourceLink id="buyer" type="entity">buyer</ResourceLink>                                                                                                                                                                                                                                                                                                                                                                                                       |
| **Caching & Locks** | `order-create:{userId}` (`60s` TTL) guards PostgreSQL `Order` writes; `{METHOD}:{PATH}:{x-request-id}` (`3600s` TTL) deduplicates `POST`/`PATCH` calls.                                                                                                                                                                                                                                                                                                                                            | Duplicate `x-request-id` returns `409 Conflict`; unhandled exceptions or `>= 500` responses clear the idempotency marker so clients can safely retry.                                                                                               | <ResourceLink id="order-cache" type="container">order-cache</ResourceLink>, <ResourceLink id="CreateOrder" type="command">CreateOrder</ResourceLink>                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| **Messaging**       | Outbound events (<ResourceLink id="UserCheckedOutIntegrationEvent" type="event">UserCheckedOutIntegrationEvent</ResourceLink>, <ResourceLink id="OrderStatusChangedToCompleteIntegrationEvent" type="event">OrderStatusChangedToCompleteIntegrationEvent</ResourceLink>, <ResourceLink id="OrderStatusChangedToCancelIntegrationEvent" type="event">OrderStatusChangedToCancelIntegrationEvent</ResourceLink>) and inbound basket-cleanup commands are partitioned by `OrderId` and Pact-verified. | Breaking CloudEvents schemas fail `Ordering-Finance` or `Finance-Ordering` Pact suites or route messages to <ResourceLink id="bookworm.{env}.ordering.dead-letter-queue" type="channel">`bookworm.{env}.ordering.dead-letter-queue`</ResourceLink>. | <ResourceLink id="bookworm.{env}.ordering.user-checked-out" type="channel">`bookworm.{env}.ordering.user-checked-out`</ResourceLink>, <ResourceLink id="bookworm.{env}.ordering.order-status-change-to-complete" type="channel">`bookworm.{env}.ordering.order-status-change-to-complete`</ResourceLink>, <ResourceLink id="bookworm.{env}.ordering.order-status-change-to-cancel" type="channel">`bookworm.{env}.ordering.order-status-change-to-cancel`</ResourceLink>, <ResourceLink id="bookworm.{env}.ordering.dead-letter-queue" type="channel">`bookworm.{env}.ordering.dead-letter-queue`</ResourceLink> |
| **Concurrency**     | Buyer-scoped distributed lock prevents concurrent checkout races; `24h` Redis idempotency guard deduplicates inbound Kafka commands.                                                                                                                                                                                                                                                                                                                                                               | Lock contention aborts the competing checkout attempt cleanly without creating duplicate orders.                                                                                                                                                    | <ResourceLink id="order-api" type="service">order-api</ResourceLink>, <ResourceLink id="order-orchestration" type="service">order-orchestration</ResourceLink>, <ResourceLink id="adr-003-separate-order-status-from-finance-saga" type="adr">adr-003-separate-order-status-from-finance-saga</ResourceLink>                                                                                                                                                                                                                                                                                                     |

## Safe Change & Verification Checklist

<Steps title="Pre-merge verification workflow">
	<Step title="Verify HTTP v1 and gRPC consumer compatibility">
		Update OpenAPI v1 metadata for any changes to `/api/v1/orders`, `/api/v1/buyers`, or
		`/api/v1/dashboard`, and confirm compatibility with [[query|GetBasketGrpc]]
		([[service|basket-api]]) and [[query|GetBooksGrpc]] ([[service|catalog-api]]).
	</Step>
	<Step title="Validate Kafka contracts and Pact suites">
		Keep CloudEvents schemas partitioned by `OrderId` and verify both `Ordering-Finance` and
		`Finance-Ordering` Pact contracts for checkout, completion, cancellation, and basket-cleanup
		messages.
	</Step>
	<Step title="Check lifecycle, snapshot, and persistence invariants">
		Confirm `New` → `Completed` | `Cancelled` immutability, checkout price snapshotting,
		`snake_case` migrations in [[container|order-database]], Marten projection compatibility, and
		`x-request-id` / `order-create:{userId}` guards.
	</Step>
	<Step title="Run formatting, build, and test suites">
		Execute `mise run format`, `mise run build`, and `mise run test` to verify Ordering unit tests,
		architecture tests, and Pact contract tests pass.
	</Step>
</Steps>

## Related Resources

- [[service|order-api]] — Authoritative Ordering REST API
- [[service|order-orchestration]] — Finance post-checkout saga
- [[command|CreateOrder]], [[command|CompleteOrder]], [[command|CancelOrder]], [[command|DeleteOrder]] — Order lifecycle commands
- [[query|GetOrder]], [[query|ListOrders]], [[query|GetBuyer]], [[query|ListBuyers]] — Order and buyer queries
- [[flow|order-lifecycle]], [[diagram|order-lifecycle]] — Order lifecycle flow and visual model
- [[doc|platform/006-api-and-contracts]] — Consolidated HTTP, gRPC, and Kafka contracts
