Skip to content

Commit a0c125b

Browse files
committed
Docs for a newcomer: a diagram, plain words for not now and handing over, @check on its own, answering instead of the model, the run options in one table
1 parent d836649 commit a0c125b

2 files changed

Lines changed: 278 additions & 190 deletions

File tree

‎CLAUDE.md‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,8 @@ by whoever knows something new. A machine is three plain Python things.
3232
class is a real `str` enum (`Order.paid == "paid"`, usable as a Pydantic type) whose members
3333
keep their description, kind, tags and handler. The description is required; it's the state's
3434
definition. `handler=` is the one handler that decides where an entity goes from the state
35-
(`States.handler`); a final state has none. `tags=` makes a state a queue: `progress_all(tag)` and `due(tag)` try only the
36-
entities in a state carrying the tag, so one worker does one kind of work (`Machine._tagged`;
37-
a tag no state carries raises `MachineError`). `agfsm due` and `progress_all` take `--tag`.
38-
`progress_all(limit=)` (`--limit`) stops after that many moves, oldest entity first; an
39-
entity that doesn't move or raises doesn't count. `due(entities=)` and
40-
`progress_all(entities=)` try only those ids, oldest first (`Machine._waiting`), for a
41-
caller whose own data says which entities could move.
35+
(`States.handler`); a final state has none. `tags=` makes a state a queue (see *Narrowing a
36+
run* below).
4237
- **Handlers** (`handlers.py`): a state has exactly one, and it has no name: the state identifies
4338
it. `Handler` is the abstract base, with `run(entity, targets)` and three attributes the machine
4439
reads: `reads_only` (`due` may run it), `decided_by` (who its moves are logged under,
@@ -72,6 +67,16 @@ reachable. Then:
7267
| `graph()` | states (each with its handler's `label`) and edges as data |
7368
| `on_move(listener)` | adds a listener, called with the `Move` after every move and start; returns it, so it decorates |
7469

70+
**Narrowing a run.** `due` and `progress_all` take three narrowings, and the CLI passes the
71+
first two as `--tag` and `--limit`:
72+
73+
- `tag`: only the entities in a state carrying the tag, so one worker does one kind of work
74+
(`Machine._tagged`; a tag no state carries raises `MachineError`).
75+
- `limit=` (`progress_all` only): stops after that many moves, oldest entity first; an entity
76+
that doesn't move or raises doesn't count.
77+
- `entities=`: only those ids, oldest first (`Machine._waiting`), for a caller whose own data
78+
says which entities could move.
79+
7580
**A listener is told once the move is committed.** `start` and `_apply` hand the move to
7681
`_announce`, which gives the backend's `on_commit` a callback: outside a lock it runs at once,
7782
inside one when the outermost lock's writes commit, and never if they are undone (a savepoint
@@ -204,10 +209,11 @@ Every backend keeps the same two things and the same rule: `move`, called inside
204209
rewrites the entity's current-state row and appends its log row, and both commit when the lock
205210
is released.
206211

207-
`0003_no_step_name` dropped the log's `step` column, which named what is now a state's handler. The SQLAlchemy backend's `create_tables()`
208-
only makes what's missing, so a database it made earlier keeps the column, nullable and unused,
209-
until whoever owns it drops it. `0002_only_real_moves` deleted the refused log rows and dropped
210-
`applied`, `reason` and `version`. An app whose migration writes those columns through the historical models declares `run_before = [("agentic_fsm", "0002_only_real_moves")]`.
212+
The SQLAlchemy backend's `create_tables()` only makes what's missing and never alters a table, so
213+
a column a Django migration drops from the log (`0003_no_step_name`'s `step`) stays, nullable
214+
and unused, in a database it made earlier, until whoever owns it drops it. An app whose own
215+
migration writes the log's dropped `applied`, `reason` or `version` columns through the
216+
historical models declares `run_before = [("agentic_fsm", "0002_only_real_moves")]`.
211217

212218
## Tests
213219

0 commit comments

Comments
 (0)