improving async fastapi sqlmodel skill

This commit is contained in:
John Lancaster
2026-07-26 17:57:55 -05:00
parent b6393f1222
commit 4818e86a1e
13 changed files with 197 additions and 291 deletions
@@ -66,13 +66,13 @@ roles = await user.awaitable_attrs.roles
## Practical Enforcement Model
Use phased enforcement:
Require explicit I/O behavior on every async ORM path:
1. High-traffic and latency-sensitive routes: enforce explicit eager loading.
2. Background tasks and less critical paths: track and progressively tighten.
3. Add review checks to prevent newly introduced implicit-load hotspots.
1. Define loader options for relationships and deferred columns needed by the operation.
2. Use `refresh()` or awaitable attributes only when the additional query is deliberate and visible.
3. Add review checks that reject unplanned lazy-load paths.
This keeps modernization pragmatic while reducing hidden I/O over time.
This keeps event-loop behavior predictable and makes query boundaries reviewable from the code.
---
@@ -99,9 +99,3 @@ This keeps modernization pragmatic while reducing hidden I/O over time.
- Tests verify expected data is present without hidden secondary query surprises.
- Regression tests exist for routes previously affected by implicit-load failures.
---
## Migration Notes
- Start advisory: target high-risk paths first.
- As coverage improves, elevate selected rules to mandatory in code review policy.