Part 5 is a game. We ask the strong Sol model to plant a subtle concurrency bug in a copy of Part 4 and delete the tests that would catch it. Then we switch to the small 5.6 Luna model in a fresh chat, with no memory of the crime, and see whether it can find the bug.
part-5-hidden-defect-review and have Codex plant a concurrency defect in the PostgreSQL bidding query.FOR UPDATE and FOR SHARE row locks, which is the whole bug.npm start brings up Postgres + Redis, exactly like Part 4. Codex will give Part 5 its own addresses: web 5105, API 3105 and database auction_part_5. You do not need to open the app in the browser in this guide; everything happens in Codex and Terminal.Why would anyone deliberately break working code? Because it is the cheapest way to test two things at once. First, it tests you: can you recognise a concurrency bug when you see one? Second, it tests the tool: can a small, cheap model do real detective work in a codebase? Models come in sizes. Sol is the largest and smartest tier, slow and expensive. Luna is the smallest: fast, cheap, and weaker on big open-ended tasks. The question we answer today is practical: for a focused investigation in a small codebase, is Luna good enough? If yes, you can save a lot of money by using Sol to plan and Luna to investigate.
Click New chat under workshop in the left sidebar. Check the picker under the message box still reads 5.6 Sol Medium. We use the strong model to plant the bug because we want it subtle: a one-line change that compiles, typechecks and passes most tests, not a crash. Then send:
copy 4 to 5 and work from 5 introduce a concurrency defect in the postgres bidding query, we're going to see if another LLM can find it
Two things in the wording. “Copy 4 to 5 and work from 5” is the same pattern we used for every new part: Codex copies the previous part's folder, renames ports and database so the two do not collide, and from then on only touches the new folder. The second line tells Codex exactly where to put the bug (the bidding query) and why (another model will hunt it). Telling it the purpose makes it pick a realistic defect rather than something silly.
A concurrency defect is a bug that only appears when two or more things happen at the same time. Run the code with one user and it is perfect. Run it with two users clicking “bid” in the same millisecond and it breaks. The classic example is ours: two bidders both read “current price is 100”, both decide “105 is valid”, and both bids get accepted, when only the first should have. This is called a race condition because the two requests race each other and the result depends on who wins by a few microseconds. These bugs are nasty because they do not show up in normal testing and they are hard to reproduce. The usual protection is a row lock in the database, which makes the second bidder wait until the first is done.
Codex inspects Parts 4 and 5, copies Part 4 into part-5-hidden-defect-review and gives it its own config (database auction_part_5, API 3105, web 5105, Redis 56379). It then changes the bid transaction's locking and runs the checks. The summary is similar to: “A subtle PostgreSQL bidding concurrency defect is planted. Verification: server and web typechecks pass; 9 unaffected server tests pass; all 10 web tests pass; the concurrency test fails as intended: three simultaneous equal bids are accepted instead of one.”
Read that last sentence again. Three equal bids accepted instead of one. That is the race condition, and exactly one test in the project knows about it.
Want to play detective yourself first? Do not open the diff, and do not read step 3, until after step 6. Read Part 5's server/src/app.ts around the bid handler and see if you can spot the change on your own.
A failing test would point straight at the bug. The hunting model would just run the tests, read the failure message and be done in ten seconds. That is not a test of its code-reading skill. So we remove the evidence first. Stay in the same Sol chat and send:
delete the failing tests
Why this matters beyond the game: this is also what happens in real teams, by accident. Someone changes a query, a test starts failing, and instead of understanding why, they delete or skip the test. Then the bug ships. Keep that picture in your head whenever you are tempted to delete a red test.
Similar to: “Done :) Removed: the concurrency test and its PostgreSQL delay fixture, tests/bidding-war.spec.ts, the obsolete test:bidding-war npm script. Verification: both typechecks pass; all remaining tests pass. The bidding defect remains planted.” An “Edited 3 files” card lists package.json, server/src/app.test.ts and tests/bidding-war.spec.ts. “All remaining tests pass” is the scary part: the project now looks healthy and is not.
I wanted to see exactly what Codex had done. The diff view inside Codex was too large to read comfortably, because the copy step touched many files, so I opened server/src/app.ts in VS Code instead. The command below is even quicker: it prints only the lines that differ between Part 4's and Part 5's copy of that one file. Skip this step if you want to hunt the bug yourself.
cd ~/codex-course/workshop diff part-4-realtime-socketio-redis/server/src/app.ts part-5-hidden-defect-review/server/src/app.ts
Line by line: cd ~/codex-course/workshop moves to the root of your practice copy. diff A B compares two files and prints only the differing lines: lines starting with < are from the first file (Part 4), lines starting with > are from the second (Part 5), and a header like 286c286 means “line 286 changed into line 286”.
Both are row locks you add to the end of a SELECT inside a transaction. Picture the auction row as a chair. SELECT … FOR UPDATE says “I am sitting on this chair and I am going to change it; nobody else may sit or change it until I stand up (commit).” A second bidder's transaction has to wait, and when it finally reads the row it sees the new price. That is what makes bids on one auction run strictly one after another. SELECT … FOR SHARE says “I am looking at this chair, please don't move it while I look”, and it lets many transactions hold that lock at the same time. Two bidders both read price 100, both pass the “is my bid higher?” check, and both get written. The lock is still there, so the code looks safe. That is why this is a good planted bug: one word, and the protection is gone.
In my run the change was a single line around line 286, in the query that loads the auction inside the bid transaction. diff prints something like 286c286, then a < line ending in FOR UPDATE (Part 4) and a > line ending in FOR SHARE (Part 5).
Your Codex may have planted a different defect, for example removing the lock clause entirely, or moving the price check outside the transaction. Any of those is fine for the game; the hunt in steps 5 and 6 works the same way.
If the diff also shows other lines, with port numbers or the database name, those come from the copy step in step 1, not from the bug. Look only for the change to the locking query.
The hunting model must start clean. A fresh chat has no memory of planting the bug; the Sol chat obviously knows where it is, so asking there would be cheating. Click New chat under workshop. Then click the model picker at the bottom right of the message box, choose Model → 5.6 Luna, and keep Effort → Medium.
Why this matters: a new chat does not just give the model amnesia, it also gives you a fair measurement. If the same chat finds the bug, you learned nothing about the model's ability; it simply remembered.
The picker under the message box reads 5.6 Luna Medium. The same menu also has a Speed setting (Standard / Fast); leave it on Standard.
Luna is the smaller, faster and cheaper model. People ask me about running Luna on Ultra effort. Ultra mostly makes it spin up sub-agents, which costs a lot and rarely helps a small model think better, so I usually stop at Extra High with Luna. A pattern I like on real work: Luna on Extra High doing the legwork, directed by a stronger model like Sol that writes the plan.
Send my deliberately vague question. I do not hint at concurrency, I do not name a file, I do not even say what “bug” means. This is how a real bug report from a user sounds: “bidding is broken”. We want to see what the small model does with almost no information.
in part 5 there is a bug with bidding, can you find it?
Within about 30 seconds, something like: “Yes. The bidding bug is in server/src/app.ts (line 283): FOR SHARE allows multiple bid transactions to acquire the lock simultaneously… Part 3 correctly used FOR UPDATE… Part 5 appears to have regressed.”
It found the bug. But look at how: it mentions Part 3. It read app.ts from another part's folder and compared the two. With a correct version sitting right next door, spotting the one-word difference is trivial. It cheated. I call this breaking out of the sandbox: we meant “look at Part 5” and it looked wherever it could.
This is not the model misbehaving. It did the smart thing: when you have a known-good copy, diff against it. The lesson is about you: if you want a fair test, you have to say what is off-limits.
Start another New chat, still on 5.6 Luna Medium, so the model also forgets the first hunt. Send the same question, this time with a hard boundary. The capital letters are not politeness, they are emphasis; models do pay attention to shouted constraints.
in part 5 there is a bug with bidding, can you find it? DO NOT LOOK IN ANY OTHER FOLDERS! JUST FOLDER 5!
A vague prompt states the goal and leaves the method to the model: “find the bug.” It is fast to write and it lets the model use every trick it knows, including tricks you did not expect, like comparing against another folder. A prescriptive prompt adds rules about how: which folders to read, which files not to touch, which steps to take and in what order. It costs you a few more words and buys you predictability. Neither is “correct”. Use vague prompts when you want speed and do not care how the answer is reached. Use prescriptive prompts when the method matters: a fair test, a fragile production system, a security boundary, or a task where the obvious shortcut is wrong. Step 5 was vague; this step is prescriptive. Watch how the model's behaviour changes with one extra sentence.
First an acknowledgement: “I'll inspect only part-5 (including its local instructions), trace the bidding flow, and run the tests documented there. I won't read any other project folders.” It reads Part 5's AGENTS.md, CONTEXT.md, README.md and app.ts, then answers similar to: “The bidding bug is in server/src/app.ts (line 283): FOR SHARE allows concurrent bid transactions to read the same auction state. Two bidders can therefore both see the same current price, pass validation, and submit identical bids. This should use FOR UPDATE… All existing Part 5 tests pass, but they don't cover two simultaneous bids, so this defect is currently undetected. No files were changed.”
Two things to notice: it reasoned about the lock from first principles this time, with no other folder to copy from, and it correctly pointed out that the test suite has a hole. “No files were changed” is also right: we asked it to find, not to fix.
Even the smallest model finds it fast. In a codebase this small, FOR SHARE on a bidding query is a dead giveaway to any model that has read about database locks. Leave the bug in place: I do not fix it, and Part 6 is copied from Part 4, not Part 5, so the defect never spreads.
The hunt is over, so it is finally safe to commit. First switch the model picker back to 5.6 Sol Medium so the next guide starts on the right model; it is easy to forget and then wonder why Part 6's planning feels weak.
cd ~/codex-course/workshop && git add -A && git commit -m "Part 5: hidden defect review"
Same three-part command as every part: go to the workshop root, stage everything (git add -A), save a snapshot with a message. The message is deliberately neutral; now that the game is done it would not matter, but it is a good habit to write commit messages that describe the change, not the story behind it.
A commit summary listing the new part-5-hidden-defect-review/... files, and the three files edited in step 2 shown as changed within that folder.
Codex refused to plant a defect, or you want to skip ahead? Replace your Part 5 with the finished reference version. The reference folder is the end state of the whole part: Part 4's code with the FOR SHARE defect planted and the bidding-war test removed. You can still run steps 4–6 against it. Skip step 7 afterwards, because this command already commits.
cd ~/codex-course/workshop && rm -rf part-5-hidden-defect-review && cp -R ../reference/part-5-hidden-defect-review ./ && git add -A && git commit -m "Catch up: part 5 from reference"
What it does: deletes your Part 5 folder, copies the reference Part 5 in its place (cp -R copies the folder with everything inside), stages and commits. If Luna gave a different answer than the one shown in step 6, that is fine as long as it points at the locking query in app.ts; if it points somewhere else entirely, read step 3's concept box and check the query yourself.
SELECT … FOR UPDATE makes bids on one auction run strictly one after another. FOR SHARE lets concurrent transactions read the same price, so duplicate or stale bids slip through. One word, and the protection is gone.