A stray commit buried multiple levels deep cost me months
4 hours ago
- Programmer is responsible for messy transaction handling; frameworks and requirements are not to blame.
- Do not manually commit or use transactions outside the DB abstraction layer; it should own all commits.
- Avoid passing DB model objects outside the DB layer to prevent silent writes.
- Use AST analysis or linters (like flake8) to ban manual commits, session access, and transaction usage outside DB layer.
- LLM can be used in CI to check if DB layer returns DB models instead of domain models.
- Consider duplicating code for atomic multi-writes to keep atomicity visible.
- Recommended book: Domain-Driven Design.