You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a0c125b
Browse filesBrowse the repository at this point in the historyBrowse files
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
Copy file name to clipboardExpand all lines: CLAUDE.md
+17-11Lines changed: 17 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,13 +32,8 @@ by whoever knows something new. A machine is three plain Python things.
32
32
class is a real `str` enum (`Order.paid == "paid"`, usable as a Pydantic type) whose members
33
33
keep their description, kind, tags and handler. The description is required; it's the state's
34
34
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).
42
37
-**Handlers** (`handlers.py`): a state has exactly one, and it has no name: the state identifies
43
38
it. `Handler` is the abstract base, with `run(entity, targets)` and three attributes the machine
44
39
reads: `reads_only` (`due` may run it), `decided_by` (who its moves are logged under,
@@ -72,6 +67,16 @@ reachable. Then:
72
67
|`graph()`| states (each with its handler's `label`) and edges as data |
73
68
|`on_move(listener)`| adds a listener, called with the `Move` after every move and start; returns it, so it decorates |
74
69
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
+
75
80
**A listener is told once the move is committed.**`start` and `_apply` hand the move to
76
81
`_announce`, which gives the backend's `on_commit` a callback: outside a lock it runs at once,
77
82
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
204
209
rewrites the entity's current-state row and appends its log row, and both commit when the lock
205
210
is released.
206
211
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
0 commit comments