Goal
Protect business operations that require several related database writes to succeed or fail together.
Repository Context
This PostgreSQL service creates orders and reserves inventory.
orders-api/
├── src/
│ ├── services/
│ └── repositories/
├── tests/
├── package.json
└── AGENTS.md
Creating an order performs several related writes:
create order
↓
create order items
↓
reserve inventory
These writes form one business operation.
If one step fails, partial database state must not remain.
The repository's database layer supports transactions.
Current AGENTS.md
# Project Instructions
## Architecture
- Keep business logic in `src/services`.
- Keep database access in `src/repositories`.
## Database
- Perform database writes individually so each operation remains simple.
- Transactions are optional when several related writes belong to the same business operation.
## Validation
- Run relevant tests after changing order behavior.
Your Task
Repair the database instructions so related writes that form one business operation remain atomic.
Require a transaction when those writes must succeed or fail together, and remove guidance that permits partial state.