fix(v2): enforce M1 runtime persistence invariants

This commit is contained in:
2026-07-27 19:42:41 +02:00
parent 45a526a1e9
commit 15f8794029
7 changed files with 188 additions and 39 deletions
+21 -2
View File
@@ -35,9 +35,28 @@ Observed results:
- Frontend typecheck/build: passed.
- Disposable database removed after verification.
## Review-Fix RED/GREEN
RED commit: `45a526a test(v2): prove runtime dispatch and persistence invariants`
The focused M1 command exited 1 with five intended failures: role dispatch was absent, migrate did not dispatch Alembic, database roles accepted an unmigrated DB, persisted ORM IDs had no default, and migration connections had no shared SQLite configurator.
GREEN verification after implementing the missing behavior:
- CLI dispatch and `migrate upgrade` tests passed.
- Unmigrated worker startup was rejected before its handler ran.
- Persisted User and Repository IDs were UUIDv7.
- Generated and non-UTC supplied timestamps reloaded as aware UTC.
- Alembic connection observation reported `foreign_keys=1`, `journal_mode=wal`, and `busy_timeout=7000`.
- Baseline active-execution index, schedule uniqueness, and execution checks were present.
- Focused M1 suite: `19 passed`.
- Fast unit/contract suite: `30 passed`.
- Alembic upgrade/downgrade/upgrade, Ruff, strict mypy, frontend typecheck/build, forbidden-v1 scan, and `git diff --check`: passed.
## Hand Review
- Baseline revision contains explicit `op.create_table`, constraints, foreign keys, and indexes for all 14 v2 entities; it does not call `create_all`.
- SQLite connections enable foreign keys, WAL, and a bounded busy timeout.
- Runtime and Alembic share one SQLite connection configurator; lock waiting uses the driver timeout rather than interpolated PRAGMA SQL.
- Startup compares the database Alembic revision with the current script head and rejects unmigrated databases.
- Runtime roles are explicit CLI subcommands; no role starts another role in M1.
- Every ORM identity has a UUIDv7 default; every persisted datetime uses the aware-UTC normalizing type.
- Runtime roles are explicit CLI subcommands and dispatch only after the schema gate; `migrate` invokes Alembic directly.