2.9 KiB
2.9 KiB
M1 Runtime and Metadata Evidence
RED
Commit: 8f78484 test(v2): define runtime and metadata contracts
Command:
.venv/bin/python -m pytest tests/unit/test_config.py tests/integration/test_migrations.py -q
Observed result: exit 2 during collection because backup_tool.clock did not exist. This proves the test-only commit preceded runtime implementation.
GREEN
Migration gate executed against a disposable absolute SQLite database:
cd backend
BACKUP_TOOL_DATABASE_URL=sqlite+aiosqlite:////absolute/path/.m1-gate.db ../.venv/bin/python -m alembic upgrade head
BACKUP_TOOL_DATABASE_URL=sqlite+aiosqlite:////absolute/path/.m1-gate.db ../.venv/bin/python -m alembic downgrade base
BACKUP_TOOL_DATABASE_URL=sqlite+aiosqlite:////absolute/path/.m1-gate.db ../.venv/bin/python -m alembic upgrade head
../.venv/bin/python -m pytest ../tests/unit/test_config.py ../tests/integration/test_migrations.py -q
cd ..
make check
Observed results:
- Alembic upgrade, downgrade, and second upgrade each exited 0.
- Focused M1 suite:
13 passed. - Fast unit/contract suite:
28 passed. - Ruff check/format and strict mypy: passed.
- 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 upgradetests 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, andbusy_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 callcreate_all. - 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.
- 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;
migrateinvokes Alembic directly.