# `store.action_spans_stores`

Action writes more than one store.

Area 6, [Reads and writes](../topics/reads-and-writes.md); not declinable; the next step is usually the human's.

An action writes one store, counting the actions it calls, so moving an
entity can break an action that never names it:





```jadpo
use ordering/entities { Cart, Order }
use ordering/actions { clear_cart }

action checkout(cart: Cart) -> Order {
    var order: Order = Order.create {
        set: {}
    }
    clear_cart(cart)
    return order
}
```

```text
error: `checkout` writes two stores
 --> domains/ordering/actions/checkout.jadpo:8:5
  |
8 |     clear_cart(cart)
  |     ^^^^^^^^^^^^^^^^ store `carts`
  reason: An action's writes, and those of the actions it calls, commit as one, in one store's transaction; `checkout` writes `Order` (store `main`), and here it calls `clear_cart`, which writes `Cart` (store `carts`).
  next: Write `Cart` in a subscriber to an event `checkout` emits, or keep `Cart` in store `main` (human)
  rule: store.action_spans_stores
  help: https://jadpo.dev/docs/errors/store.action_spans_stores

check failed: 1 error, 5 files
```
