---
title: "Choose how fresh each piece of shared data · Agent Wranglers"
url: https://agentwranglers.se/playbook/architecture/system-architecture/consistency-model
id: ARC-89
level: Recommended
updated: 2026-10-27
build: a2a6bdfed830
tokens: 917
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Choose how fresh each piece of shared data must be

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [System architecture](https://agentwranglers.se/playbook/architecture/system-architecture.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: ARC-89
- Level: Recommended
- Chapter: [System architecture](https://agentwranglers.se/playbook/architecture/system-architecture.md)
- Rule: For each piece of data that two parts of the system read, write down the consistency it needs. Choose strong, read-your-writes or eventual, and give the longest delay you accept.
- Check: A data inventory lists each shared table, cache and event stream with its consistency model and the longest delay. A test writes through each read-your-writes path and reads the value back in the same request flow.
- How: Strong consistency means every read sees the latest write. It costs speed and stops writes when a copy is unreachable. Eventual consistency stays fast and available, but a read can return old data for a while. Most data sits between them. A stock count at checkout needs strong reads. A shopper must see their own new review, which is read-your-writes. A product's review count may lag by minutes. Replicas follow [Read from replicas only what may lag](https://agentwranglers.se/playbook/data/caches-and-copies/replica-lag.md), and caches follow [Decide how stale a cache may be](https://agentwranglers.se/playbook/scaling/caching/cache-freshness.md).

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### TypeScript example

```ts
// Read-your-writes: the shopper who just posted reads from the primary
async function reviewsFor(productId: ProductId, viewer: Viewer) {
  const source = viewer.wroteRecently(productId) ? primary : replica;
  return source.query('SELECT * FROM reviews WHERE product_id = $1', [productId]);
}
```

### Python example

```python
# Read-your-writes: the shopper who just posted reads from the primary
def reviews_for(product_id: ProductId, viewer: Viewer) -> list[Review]:
    source = primary if viewer.wrote_recently(product_id) else replica
    return source.query("SELECT * FROM reviews WHERE product_id = %s", (product_id,))
```

## Sources

- [Microsoft: Azure Cosmos DB consistency levels](https://learn.microsoft.com/en-us/azure/cosmos-db/consistency-levels)

## Related rules

- DAT-46 [Read from replicas only what may lag](https://agentwranglers.se/playbook/data/caches-and-copies/replica-lag.md) in Data and databases
- SCL-35 [Decide how stale a cache may be](https://agentwranglers.se/playbook/scaling/caching/cache-freshness.md) in Scaling

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/architecture/system-architecture/consistency-model">Agent Wranglers clean code and architecture playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Check each architecture decision with a fitness function](https://agentwranglers.se/playbook/architecture/system-architecture/fitness-functions.md)
- Next: [Give each outside dependency its own pool](https://agentwranglers.se/playbook/architecture/system-architecture/bulkheads.md)
- [System architecture](https://agentwranglers.se/playbook/architecture/system-architecture.md)
