Test: Six known bugs in one pull request Run: codex-rules-2 Tool: Codex CLI 0.145.0, model gpt-5.6-sol (codex review --base main, reasoning xhigh) Condition: Rules written in README Time: 64 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 discount implementation violates several documented behaviors, including case-insensitive loading, inclusive end dates, nonnegative totals, and loader error propagation. It also introduces shared mutable tag state and an injectable SQL lookup that can accept unknown codes. Full review comments: - [P1] Parameterize the code lookup — shop/codes.py:33-33 When `code` contains SQL syntax, interpolating it directly into the query allows an unknown value such as `x' OR 1=1 --` to select an existing discount, while an ordinary apostrophe can raise `sqlite3.OperationalError` instead of `InvalidCode`. Use a bound query parameter for the normalized code. - [P2] Raise code-loading failures — shop/codes.py:27-28 When the CSV path is missing or unreadable, this catch returns successfully with an empty database, contradicting the documented requirement that an unreadable file is an error. It also hides malformed rows and database failures, so callers cannot detect that loading failed. - [P2] Normalize loaded code keys — shop/codes.py:24-24 If a CSV contains `save10`, it is stored lowercase while `find_code` always searches for `SAVE10`; SQLite's default text equality is case-sensitive, so neither casing can retrieve the advertised case-insensitive code. Normalize `row["code"]` to uppercase before inserting it. - [P2] Treat the end date as inclusive — shop/codes.py:41-41 When `today` equals `ends`, this comparison rejects the code even though the documented validity period includes both the start and end dates. The upper comparison must allow equality. - [P2] Clamp discounted totals at zero — shop/codes.py:48-48 When a fixed discount exceeds the subtotal, such as 500 cents off a 100-cent cart, this returns `-400`, violating the documented guarantee that totals never go below zero. The result should be clamped to zero. - [P2] Allocate a separate default tag list — shop/cart.py:9-9 Every call to `add` that omits `tags` reuses the same list object. Applying a code to one cart therefore adds `"discounted"` to unrelated lines in other carts, including lines created later; use a `None` default and allocate a list per line.