|
9 | 9 | store and forwards ``transaction()`` / ``read_snapshot()`` to the underlying |
10 | 10 | :class:`ControllerDB`. |
11 | 11 |
|
12 | | -Dependency chain:: |
| 12 | +Dependency chain (target state):: |
13 | 13 |
|
14 | 14 | db.py — connections, migrations, transaction context managers |
15 | 15 | schema.py — table DDL, row dataclasses, projections |
16 | 16 | stores.py — depends on { db, schema }; per-entity stores |
17 | | - transitions.py — depends on stores; never calls db.py directly |
18 | | -
|
19 | | -Stores are the only place outside of ``db.py`` / ``schema.py`` that build |
20 | | -SQL strings for the controller tables. ``transitions.py`` uses the store |
21 | | -API; other callers (``service.py``, ``controller.py``) are migrated |
22 | | -later as the pattern proves out. |
23 | | -
|
24 | | -The layer is introduced incrementally. Phase 1 (this module as it stands) |
25 | | -adds the scaffolding and folds the previous ``EndpointRegistry`` in as |
26 | | -:class:`EndpointStore`. Subsequent phases move per-entity SQL out of |
27 | | -``transitions.py`` into the relevant store class. |
| 17 | + transitions.py — depends on stores; stores own the SQL |
| 18 | +
|
| 19 | +The layer is introduced incrementally. The current state is mid-migration: |
| 20 | +``EndpointStore`` and ``JobStore`` are populated, while ``TaskStore``, |
| 21 | +``TaskAttemptStore``, ``WorkerStore``, ``DispatchQueueStore`` and |
| 22 | +``ReservationStore`` are still empty skeletons. ``ControllerTransitions`` |
| 23 | +keeps a temporary ``self._db`` backdoor for SQL that has not yet been |
| 24 | +moved (tasks, workers, dispatch queue, reservations, the ``meta`` table, |
| 25 | +worker-attribute cache). That backdoor is removed in a later phase once |
| 26 | +every entity has a store. |
28 | 27 | """ |
29 | 28 |
|
30 | 29 | from __future__ import annotations |
|
50 | 49 |
|
51 | 50 |
|
52 | 51 | # Store read methods accept either a write cursor or a read snapshot. Writes |
53 | | -# require ``TransactionCursor`` explicitly so static typing prevents issuing |
54 | | -# mutations through a read-only snapshot. |
| 52 | +# require ``TransactionCursor`` explicitly so a ``QuerySnapshot`` can't be |
| 53 | +# accidentally passed to a mutating API. (This alias does *not* prevent a store |
| 54 | +# read method from issuing writes internally — it just polices the caller-side |
| 55 | +# direction. A read-only ``Protocol`` would be stricter; not yet worth the |
| 56 | +# plumbing.) |
55 | 57 | Tx = TransactionCursor | QuerySnapshot |
56 | 58 |
|
57 | 59 |
|
|
0 commit comments