Test: Six known bugs in one pull request Run: codex-rules-1 Tool: Codex CLI 0.145.0, model gpt-5.6-sol (codex review --base main, reasoning xhigh) Condition: Rules written in README Time: 76 s Planted bugs found: 6 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 found 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 implementation violates several explicitly documented behaviors, including inclusive expiration dates, case-insensitive storage, error propagation, and nonnegative totals. It also introduces shared mutable tag state and an injectable SQL lookup that can forge arbitrary discounts. Full review comments: - [P1] Parameterize the discount-code lookup — shop/codes.py:32-34 When `apply_code` receives user-controlled input, this interpolation allows a quote/`UNION` payload to return an attacker-selected kind, amount, and validity window instead of raising `InvalidCode`, enabling arbitrary discounts; ordinary codes containing apostrophes also produce a SQLite syntax error. Bind the upper-cased code as a SQL parameter. - [P1] Clamp discounted totals at zero — shop/codes.py:45-48 When a fixed discount exceeds the subtotal, this returns a negative cart total—for example, a 500-cent code on a 200-cent cart returns -300. This violates the documented nonnegative-total guarantee and can propagate an invalid amount to checkout. - [P2] Propagate failures while loading the CSV — shop/codes.py:27-28 When the path is missing or unreadable, the blanket handler silently returns even though `load_codes` explicitly promises that an unreadable file is an error. It also hides malformed rows and database failures, potentially leaving callers to continue with an empty or partially populated code table. - [P2] Normalize CSV codes before insertion — shop/codes.py:23-24 When a CSV contains a lowercase or mixed-case code, it is stored verbatim, while `find_code` always queries for its uppercase form. Consequently, a valid row such as `save10` cannot be found using either `save10` or `SAVE10`, contrary to the case-insensitive contract; codes should be upper-cased before storage. - [P2] Accept codes on their end date — shop/codes.py:40-42 When `today` equals `ends`, the strict `< ends` check rejects the code even though the documented validity window includes both the start and end dates. Use an inclusive comparison for the upper bound. - [P2] Allocate a separate tags list for each line — shop/cart.py:9-12 When callers omit `tags`, every line and every cart shares this one mutable default list. Applying a code to one cart therefore duplicates tags across its default-tagged lines and causes subsequently added lines—even in another cart—to start as `discounted`; create a fresh list for each call instead.