Practise this: Ship a change in a second stack
Clone the starter: https://github.com/codeprepdev/agentic-engineering-lab-5-ship-a-change-in-a-second-stack. It is the order service behind a florist's till and the florists' phone app, in Python with the standard library only, on SQLite. That is backend and data work, the second stack for most frontend, mobile, QA and infrastructure engineers. If backend or data is your own specialty, do the lab anyway, and hold yourself to the explanation you would want from an outsider. Run python3 -m unittest discover and python3 scripts/check_migrations.py, then read the README, AGENTS.md, db/AGENTS.md and .github/CODEOWNERS before any agent sees the ticket.
The ticket, in full:
Noor (shop manager): The gift message is buried in the order's extras. Can the till show it on the order list, with who last changed it, and let staff fix a typo before the card is written?
Today the message sits in orders.extras, a JSON field, as gift_message. Noor's change needs it in a column of its own.
1. Name the risks, then ask the owner. This change is in the backend and data specialties, so the risks to ask about are migrations, backfills, transactions, idempotency and N+1 queries. Have the agent explain the repository's write path and what runs in production that the tests do not exercise. Then find the owner of the schema from .github/CODEOWNERS and write one question in OWNER-QUESTION.md: what you are about to do, what you have already checked, and the thing only the owner can tell you. Keep it short enough to answer in two minutes. Write it before you read on.
2. The owner's answer. The data team replied in their channel:
- "Every change to an order writes a row to
order_eventsin the same transaction. The nightly export and the customer emails read onlyorder_events." - "The till and the phone app resend a write after ten seconds with the same
Request-Idheader. A resend gets the first answer and changes nothing;shop/requests.pydoes that." - "No copying inside a migration. Copy through
shop/batch.py, as its own backfill, under its own job name." - "The till's home screen lists up to 300 orders. It makes two queries today. Keep it at a fixed number however many orders there are."
- "Leave
extrasalone. We remove the old field in a later change, once the copy is proven."
Put what they told you where the next agent will read it: AGENTS.md or db/AGENTS.md.
3. Brief the agent and build. The change has four parts:
- a migration in
migrations/that adds a nullablegift_messagecolumn toorders; PUT /orders/<id>/gift-messageinshop/api.py, body{"message": "..."}, with theStaff-IdandRequest-Idheaders the other writes take; it saves the column and records an event of the staff member's change;GET /ordersgives each ordergift_message(the column, or the old field for an order the backfill has not reached) andgift_message_by, the name of the staff member who last changed it, ornull;- a backfill,
shop/backfills/gift_message.py, withrun(conn, batch_size=500), copying old messages into the column under the job namegift_message, and leaving alone any order whose column is already set.
Put the owner's answers and the check commands in the brief. When the data team's check fails, fix the migration, never the check. Their files (scripts/check_migrations.py, shop/batch.py and the first three migrations) stay exactly as they are.
4. Explain it back with the agent off. Close the session and write EXPLAIN-BACK.md with five headings: What it does, What could break, How we would know, How to undo it and What I still do not know, with a few sentences under each. If you cannot write the first four, go back to the code before you go on.
Get python3 scripts/check_migrations.py and python3 -m unittest discover both passing, with the output in front of you, then upload the repository folder. The .git folder is left out, so the hidden tests mark what they find in your files. On fresh databases of their own, they test the migration and the data team's check, the list with and without the backfill, the save and its event (including when one of the two fails), a resent request, the list's query count at 3 orders and at 300, and the backfill: what it copies, what it leaves, and whether it resumes. They also check that the data team's files are unchanged, that the starter's tests are all still there with none skipped, and that your three written files have their parts. The tests cannot judge what your question and your explanation say; the owner of the schema could.
Open the lab · needs a free Tarmac account to have your work marked