Skip to slide
112 / 221

CH 09 · Data Modeling for Agents · 06/12

Read as one page

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.

Finished this idea?

Your learning progress stays in this browser.