Skip to slide
Chapter 9 · Data Modeling for Agents
82 / 191

CHAPTER 09 · Data Modeling for Agents · 5 / 11

State machines with explicit status fields

Anything asynchronous or multi-step needs an explicit status field that names each state. Documents move processing → ready → error; extraction cells move pending → generating → done → error; changes move pending → accepted/rejected. Benefits:

  • The UI can render the right state (spinner, value, error) directly from the field.
  • Work is resumable: you can find everything still pending and continue.
  • It's a natural seam to make a synchronous flow asynchronous later (move the work to a worker; the status field is already there).

Constrain these fields to their valid values at the database level (a check constraint or enum) so an invalid state can't be written.

← → arrow keys work too