All challengesCHALLENGE 18 OF 25

Protect Transaction Atomicity

Keep related database operations atomic.

Advanced

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.

Code exampleMarkdown
orders-api/
├── src/
│   ├── services/
│   └── repositories/
├── tests/
├── package.json
└── AGENTS.md

Creating an order performs several related writes:

Code exampleMarkdown
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

Code exampleMarkdown
# 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.

YOUR AGENTS.mdEdit the Current AGENTS.md shown in the challenge
AGENTS.mdMarkdown
Loading editor…

Sign in to save progress across devices.

Your answer is checked locally against the challenge rules. No AI is used for evaluation.