Start Part 6. This time I tell Codex exactly which architecture I want for closing auctions: a polling close worker → RabbitMQ → a notification worker → a WebSocket popup. We go through two rounds of grilling, get an ADR for the transactional-outbox decision and two proposed slices. Optionally, you run a vague version of the same request in a second chat and compare the two designs.
part-6-async-close-rabbitmq and describe the exact architecture you want: a polling service, a separate notification service, and RabbitMQ between them.FOR SHARE bug.npm start also starts a RabbitMQ container next to Postgres and Redis, and runs two extra worker processes. You will actually run all of that in guide 21; today is planning only, but Codex still reads the Docker setup.The goal of Part 6 is to model a real-world way of triggering workflows. Until now everything in our app happened because a user clicked something. But an auction ending is different: nobody clicks “end”. The clock simply passes endsAt. Some piece of the backend has to notice that on its own, declare the auction closed, work out who won, and tell the people who care. In guide 19 I explained vague vs prescriptive prompts. In guide 17 I was fairly open and let Codex propose the design. Here I am deliberately prescriptive, because I already know the architecture I want, and it is the architecture most real companies use for this kind of job. Three concepts before you read the prompt:
A worker is a backend program that is not a web server. Nobody sends it requests; it runs in the background and does jobs. A polling worker wakes up on a timer, every second in our case, and asks the database one question: “are there any auctions whose endsAt is in the past and that I have not closed yet?” If yes, it closes them and records the winner. If no, it goes back to sleep. Polling is the simplest way to react to time passing. It is a bit wasteful (most checks find nothing), but it is easy to understand, easy to test, and it keeps working after a crash because it just asks again on the next tick.
A message queue is a post box between two programs. One program, the producer, drops a message in (“auction 42 closed, winner is Maya”) and moves on; it does not wait for anyone to read it. Another program, the consumer, picks messages out of the box and acts on them. The two never talk directly, so you can restart, slow down or scale either one without the other noticing. RabbitMQ is a popular, battle-tested message queue server; we run it in Docker like Postgres. When a consumer finishes handling a message, it sends an ack (acknowledgement) and RabbitMQ deletes the message. If the consumer crashes before acking, RabbitMQ assumes the work was not done and hands the same message to a consumer again. That is redelivery, and it is why queues promise at-least-once delivery rather than exactly-once. It also means your consumer must cope with seeing the same message twice; more on that in step 4.
Our second worker is the notification worker. It is the consumer of the queue: it waits for “auction closed” messages. For each one it decides who should be told (the winner, the seller) and then pushes a message to those people's browsers over the WebSocket channel we built in Part 4. The browser receives it and shows a popup. So the full chain is: clock passes → close worker notices → close worker writes to Postgres and produces a message → RabbitMQ → notification worker consumes it → Socket.IO (via the Redis backplane) → browser popup. Five hops, each one small and testable on its own. That is the whole point of splitting it up.
Now click New chat under workshop in the sidebar, check the picker reads 5.6 Sol Medium, and send the prompt. Read it once before sending: every sentence maps to one of the three concepts above. The last line, in capitals, calls the grill-with-docs skill, so Codex grills us and writes the answers into GRILL.md and CONTEXT.md as we go.
copy files from directory 4 to 6 and work out of 6 please once the auction is in the past, I want to trigger a workflow for notifying the winning bid user that the auction has ended. we'll do that with a popup notification on the screen triggered by web socket. the service for polling the auction table for ended auctions will be separated from the service that actually handles and triggers notifications. they will be triggered and bound together via rabbit MQ. GRILL ME WITH DOCS!
The chat gets a name like “Grill auction notifications design”. Codex says it is using the grilling skill to stress-test the workflow and the domain-modeling skill to capture decisions in docs, then copies the Part 4 baseline into part-6-async-close-rabbitmq. It gives a short code audit: auctions only have an ends_at timestamp and no durable “closed” state, and RabbitMQ is already defined in Docker Compose but nothing uses it yet. Then it prints Grill — Round 1: Product semantics with about 9 questions, each followed by a ➡️ recommendation.
The audit is useful on its own: it tells you Codex understood that “ended” is currently just a comparison with the clock, and that we need to turn it into a saved fact in the database.
Grilling, plus the optional second comparison chat in step 2, is a lot of tokens on your API key. If you are watching cost, do the main chat only; the comparison is purely for learning and the course does not depend on it.
I wanted to see what Codex would design without being told the architecture. Would it also reach for two workers and a queue, or would it do something simpler, or something strange? Click New chat under workshop (so you now have two chats open side by side in the sidebar) and send the same request with the opinionated parts removed: no polling, no separate services, no RabbitMQ. Only the goal and the popup. It targets folder 7 so it does not clash with the main chat, which is working in folder 6.
copy files from directory 4 to 7 and work out of directory 7 please once the auction ends, I want to trigger a workflow for notifying the winning bid user that the auction has ended. we'll do that with a popup notification on the screen GRILL ME WITH DOCS!
Why this matters: running two chats with two prompts is the cheapest second opinion you will ever get on a design. In a company you would book a meeting with a senior engineer; here you spend a few minutes of tokens.
A second chat named something like “Grill auction end notifications” asks its own Round 1. In my run the questions were: who declares the auction ended, who exactly counts as the winner, what to do about winners who are offline, where the popup appears, how intrusive it should be, and so on. It writes a GRILL.md into part-7-winner-checkout. You will clean that up in step 8.
This chat writes into part-7-winner-checkout, which must be empty when we start Part 7 in guide 23. Step 8 resets it. Do not skip step 8 if you do this step.
I do not steer this one at all. I am curious what architecture Codex picks when it is left alone, so I simply accept whatever it recommends. In the second chat, send:
take recommend on all
“Take recommend” is the shorthand our grilling skill understands: for every question, use the ➡️ recommendation Codex itself proposed.
It records round 1 in its GRILL.md and moves on to the next round. Reply “take recommend on all” to any later round in this chat as well, until it presents a diagram and slices. Then switch back to the main chat; we compare the two designs in step 8.
Back in the main chat (“Grill auction notifications design”). Codex asks its own questions, and the wording and order will differ from mine, so match by topic, not by number. Here is what my answers decided and why:
endsAt is the business cutoff, and a worker records a durable close afterwards. In other words, the clock decides when bidding stops, but the database row only says “closed” once the worker has processed it.AuctionClosed with no winner. The seller still needs to know it ended.endsAt.1. take recommend 2. take recommend 3. take recommend 4. NO! We must handle idempotency! e.g. take recommend 5. no 6. modal with a modal screen 7. the winner and the auction owner (to see that their auction ended) 8. require dismissal 9. take recommend
Idempotent means “doing it twice has the same result as doing it once”. Pressing a lift button twice does not call two lifts. Because RabbitMQ delivers at-least-once (see step 1), the notification worker will occasionally receive the same “auction 42 closed” message twice: after a network blip, or if the worker crashed just before sending its ack. An idempotent consumer notices “I already handled auction 42” and quietly skips the duplicate, instead of showing the winner two popups. The usual way is to give every message a unique id and record handled ids in the database; before acting, check the record. This one habit separates toy queue code from production queue code.
A modal is a popup window that takes over the page: the rest of the screen dims, and you cannot click anything behind it until you deal with the modal. “Modal” means it changes the page's mode from normal to “answer this first”. Compare it to a toast, the small notice that appears in a corner and disappears by itself. We want a modal here because a won auction is important: the user must see it and must close it deliberately. Answers 6 and 8 together describe exactly that.
“Round 1 is recorded in GRILL.md and the clarified domain language is in CONTEXT.md.” Then Grill — Round 2: Reliability and service boundaries, numbered on from round 1 (Q10–Q18 in my run). The topic has shifted from “what should happen” to “how do we make sure it happens reliably”, which is the right order: product semantics first, plumbing second.
Answer 4 is the one I want you to remember. Any time someone offers you a message queue, your first question is “what happens when a message arrives twice?” If they have no answer, the design is not finished.
Round 2 is about reliability and about which program owns which job. What my answers decided:
SKIP LOCKED, a PostgreSQL option that lets two copies of the worker run at once without grabbing the same rows.10. take recommend 11. take recommend w/ outbox pattern 12. take recommend 13. take recommend 14. take recommend 15. take recommend 16. don't build any of that today 17. take recommend 18. take recommend
Here is the problem. The close worker must do two things: save “auction 42 is closed, winner Maya” in Postgres, and publish a message to RabbitMQ. Those are two different systems, and you cannot wrap both in one database transaction. If the worker saves to Postgres and then crashes before publishing, the auction is closed but nobody is ever told. If it publishes first and then the save fails, people are told about a close that did not happen. The transactional outbox fixes this with a trick: instead of publishing directly, the worker writes the message into an outbox table in the same transaction as the close. Either both rows land or neither does. A separate small loop (the publisher) then reads unpublished outbox rows, sends them to RabbitMQ, and marks them published only once RabbitMQ confirms it has them. If anything crashes in between, the row is still sitting in the outbox and gets sent on the next loop. Nothing is lost; at worst, something is sent twice, which is exactly why the consumer must be idempotent.
Codex records the round and then says something like “One final conflict needs resolution”. In my run it was Q19 – Minimum RabbitMQ reliability: the outbox pattern needs publisher confirms (RabbitMQ telling the publisher “got it”) before an event can be marked published, and that seems to clash with my “don't build any of that today” in Q16. Codex is right to ask; the two answers do look contradictory.
Our AGENTS.md rule caps the grill at two rounds but allows one extra question when there is an obvious conflict in the answers. This is that question. Resolve it so Codex builds exactly what the outbox needs (publisher confirms, because without them the outbox cannot know when a row is safely delivered) and nothing more (no dead-letter queues, no retry schedules):
build only enough to make outbox work. don't do anything else like dead letters right now
Why this matters: scope control is the hardest part of working with a capable agent. It can build everything, so it will offer everything. Your answer draws the line: the minimum that makes the chosen pattern correct, and not one feature beyond that.
“Grilling is complete. The design is captured in GRILL.md, the glossary in CONTEXT.md, and the outbox decision in ADR 0001.” Then a wide Mermaid diagram (⏱️ Auction Close Worker → 🐘 PostgreSQL → 🐇 RabbitMQ → 🔔 Notification Worker → 🔴 Redis → 🔌 Socket.IO → 🌐 Web App), and two proposed slices, similar to:
And the closing line: “Please confirm Slice 1, and I'll implement and verify that slice before stopping for browser review.” Do not confirm yet. Guide 21 starts exactly there.
Notice the split. Slice 1 is everything up to and including the outbox row, with no RabbitMQ consumer at all. Slice 2 is everything from RabbitMQ to the popup. Each slice is testable on its own, and if Slice 1 goes wrong you have not wasted any work on Slice 2.
Codex wrote an ADR for the outbox decision. Click ADR 0001 in Codex's summary to open it in the app, or print it in Terminal with the command below. The * in the filename is a wildcard, so the command works whatever title Codex chose after 0001-.
cat ~/codex-course/workshop/part-6-async-close-rabbitmq/docs/adr/0001-*.md
An ADR is a short text file, usually half a page, that records one lasting architectural choice: what we decided, why, what the alternatives were, and what we knowingly gave up. They live in the repo (here under docs/adr/) and are numbered in order, so a year later a new engineer can read 0001, 0002, 0003 and understand how the system came to look the way it does. The habit matters even more with coding agents: a future Codex session will read these files and respect the decision, instead of “helpfully” replacing the outbox with direct publishing because it looked simpler. Think of an ADR as a note to your future self and to your future agent.
A one-paragraph ADR titled similar to “Publish auction close events through a transactional outbox”: the close worker records the close plus an AuctionClosed outbox row in one PostgreSQL transaction and marks it published only after RabbitMQ confirms. Retries and dead-letter infrastructure are deliberately deferred. The filename may differ slightly; mine was 0001-close-events-through-a-transactional-outbox.md. Check that the “deferred” part is there: that is your step 6 answer, written down so it does not get lost.
If you ran the second chat, open it now and look at its final design. In my run it came up with almost the same architecture, an Auction Close Worker and a Notification Worker, without being told any of it. Impressive, until I found out why: the root AGENTS.md lists exactly those service names in its Mermaid emoji legend. The model had read them as part of its instructions and used them. I had steered it myself without realising. Compare the two chats' diagrams and slice lists, and note any real differences (for example, whether the vague chat also chose a queue, or went for a simpler direct call).
Then put Part 7 back to an empty folder so it is ready for guide 23:
cd ~/codex-course/workshop && rm -rf part-7-winner-checkout && mkdir part-7-winner-checkout && ls -A part-7-winner-checkout | wc -l
What it does: goes to the workshop root, deletes the Part 7 folder with everything the second chat wrote into it (rm -rf), creates a fresh empty folder with the same name (mkdir), then lists its contents including hidden files (ls -A) and counts the lines (wc -l) so you can confirm it is empty.
0: Part 7 is empty again. You can archive the second chat now (hover over it in the sidebar, click the three dots, Archive); you will not need it again.
The lesson: context you forgot about quietly steers the model. AGENTS.md, other docs in the repo, even Git history. When you want a truly independent second opinion, check what the model can see before you trust that it “came up with it on its own”.
Part 4 isn't done? Part 6 starts from Part 4, so catch up Part 4 first with the command below, then begin at step 1.
Want to skip Part 6 entirely? Run the same command with part-6-async-close-rabbitmq in place of the Part 4 folder name. Be aware that the reference Part 6 is the end state of the whole part: both slices fully built as in guide 21, not just this guide's plan. If you skip, still read steps 4, 5 and 7 above, because the concepts come back in Parts 7 and 8.
cd ~/codex-course/workshop && rm -rf part-4-realtime-socketio-redis && cp -R ../reference/part-4-realtime-socketio-redis ./ && git add -A && git commit -m "Catch up: part 4 from reference"
If your grill asked very different questions, that is normal; answer by topic using the lists in steps 4 and 5. If Codex never asked the final conflict question (step 6), it means your round 2 answers did not clash, so simply move on to step 7.