Test: Six known bugs in one pull request Run: codex-norules-1 Tool: Codex CLI 0.145.0, model gpt-5.6-sol (codex review --base main, reasoning xhigh) Condition: Rules not written Time: 73 s Planted bugs found: 4 of 6 Paths and user names are shortened; nothing else is changed. --- Our matching --- found 1. SQL built with an f-string MISSED 2. codes stored without upper-casing MISSED 3. end date excluded found 4. total below zero found 5. shared mutable default list found 6. exception swallowed other findings: 0 --- The review --- The discount implementation permits SQL injection, can generate negative totals, silently hides import failures, and leaks mutable tag state across items and carts. These are functional and security defects that should be addressed before merging. Full review comments: - [P1] Parameterize the discount-code lookup — shop/codes.py:32-34 When a customer supplies a code containing SQL syntax, interpolation allows the lookup to be altered; for example, `' OR 1=1 --` returns the first valid discount instead of raising `InvalidCode`. Use a parameterized query so untrusted code text cannot bypass validation. - [P1] Prevent fixed discounts from producing negative totals — shop/codes.py:48-48 When a fixed discount exceeds the cart subtotal, this returns a negative total—for example, a 500-cent code applied to a 100-cent cart returns -400. Cap the result at zero or reject discounts that exceed the subtotal to prevent invalid checkout amounts. - [P2] Report and roll back code-load failures — shop/codes.py:27-28 If the CSV is missing or malformed, or a database write fails, `load_codes` silently returns as though loading succeeded. A failure after earlier inserts also leaves a partial transaction visible and potentially commit-able by later work; roll back and propagate or explicitly report the error. - [P2] Allocate a fresh default tag list per item — shop/cart.py:9-9 When `add` is called without explicit tags, every such item and cart shares this single list. `apply_code` therefore adds duplicate `discounted` entries for multiple items and leaks those tags into subsequently created carts; use a `None` default and allocate a new list for each call.