Review this pull request for correctness, edge cases, security, performance, readability, maintainability, and missing tests. Group feedback by severity: critical, important, minor, and optional.
Paste into your AI coding agent before starting a task to guide a multi-step workflow.