## Concurrency Business Conflict (High)

### Trigger Signals

Start this detection when the following code characteristics appear:
- Read-modify-write sequence (query first, then modify, then save, e.g., `get → calculate → save`)
- "Create if not exists" pattern (`if (!exists) { create }`)
- Deduction operations on exhaustible resources such as inventory/balance/quota
- Scenarios where the same field is updated by multiple sources

### Judgment Process

1. **Identify read-modify-write sequences**: `Read` extracts query operations and write operations in the function, marking whether a "read value → calculate based on value → write back" pattern exists
2. **Check concurrency protection**: For read-modify-write sequences, `Read` checks whether any of the following protections exist:
   - Pessimistic lock (`SELECT ... FOR UPDATE`, `LOCK TABLE`)
   - Optimistic lock (`UPDATE ... WHERE version = ?`, and version obtained at read time)
   - Atomic operations (`INCREMENT`, `DECREMENT`, `compareAndSet`)
   - Distributed lock (only applicable for non-database scenarios)
3. **Check "create if not exists" fallback**: `Read` confirms whether this pattern has:
   - Database unique constraint to prevent concurrent duplicate creation
   - Distributed lock to prevent race conditions
4. **Assess race risk**: `find_references` checks whether callers of related functions are high-concurrency entry points (HTTP handlers, message consumers), confirming race risk level

### Evidence Construction

After confirming a defect, the output must include:
- Read-modify-write sequence (query location, calculation logic, write-back location, with file:line number)
- Concurrency scenario description (which concurrent requests would trigger the race)
- Missing protection measures (locks/constraints that should exist but do not)
- Business impact (specific consequences of overselling, over-allocation, duplicate creation)

### Exclusions

- Low-frequency operations (admin backend configuration, scheduled tasks)
- Already has database unique constraints completely preventing duplicate creation
- Data initialization with extremely low operation frequency and no concurrency possibility
