Test: Six known bugs in one pull request Run: codex-norules-2 Tool: Codex CLI 0.145.0, model gpt-5.6-sol (codex review --base main, reasoning xhigh) Condition: Rules not written Time: 70 s Planted bugs found: 5 of 6 Paths and user names are shortened; nothing else is changed. --- Our matching --- found 1. SQL built with an f-string found 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: 1 --- The review --- The new discount path permits SQL injection and has several correctness failures involving loading, normalization, shared mutable state, and discount calculation. These can apply unauthorized discounts or produce invalid totals under realistic inputs. Full review comments: - [P1] Parameterize the code lookup — shop/codes.py:33-33 When `code` comes from user input, direct interpolation lets a value such as `x' OR 1=1 --` make the predicate true, causing `fetchone()` to return an unrelated active discount. Bind the normalized code as a SQL parameter instead. - [P2] Propagate failures while loading codes — shop/codes.py:27-28 When the file is missing, malformed, or a database operation fails, this handler reports success with an empty or partially populated database. Partial inserts also remain in the open transaction and can be committed later, so the loader should roll back and propagate the error. - [P2] Normalize codes consistently when loading — shop/codes.py:24-24 A lowercase or mixed-case code in the CSV is inserted verbatim, while every lookup is uppercased; SQLite's default text equality is case-sensitive, so such a code can never be found. Normalize on insertion or use a case-insensitive comparison. - [P2] Create a fresh tag list for each item — shop/cart.py:9-9 Calls that omit `tags` share this single default list across items and carts. Applying a code to two default-tagged lines appends twice to the same object, giving both duplicate `discounted` tags, and later carts inherit those mutations; use a per-call list instead. - [P2] Prevent fixed discounts from producing negative totals — shop/codes.py:48-48 When a valid fixed discount exceeds the cart subtotal, this returns a negative amount (for example, a 500-cent code on a 100-cent cart returns `-400`). A discount should be capped so the payable total cannot fall below zero. - [P2] Reject unknown discount kinds — shop/codes.py:46-48 Any misspelled or unsupported `kind` is silently treated as a fixed discount. For example, a CSV row with `percnet,10` applies 10 cents rather than rejecting the configuration or applying 10 percent; handle `fixed` explicitly and reject other values.