Keep one booking correct when requests overlap
Guide an AI through , allowed states, private , and safe retries using one small booking flow.
By the end, you can ask an AI for a booking plan that names the , allowed state changes, ownership rules, and duplicate- checks.
Prepare for this intermediate practice
Review these ideas before combining them in the booking workflow. There is no timer or completion gate.
Step 1: Two different problems
This intermediate capstone uses a rule: a successful immediately reserves one book copy. The same member retrying a is different from two members competing for the last copy. Think of repeating one coat-check ticket versus two people asking for one available coat. One copy must never have two confirmed claims; that always-true rule is an .
Step 2: Give each decision a clear home
The envelope names fields and units: its . A same-action ticket, or , identifies retries; the receiver must store and enforce it. The database checks-and-claims availability together for competing members. A groups work, but its conditions, locks, or isolation strategy must protect the shared rule. Database policies also control who may read or change each .
Step 3: Draw the rulebook before coding
For this example, pending can become approved or cancelled, and those states are final. The diagram is a ; the saved action must enforce it. Ask for a cancellation that checks ownership and current pending status at the moment of the write. An old tab can show an outdated button. Keep temporary screen changes clearly pending until matched to the saved result.
Step 4: Verify overlaps with fictional records
Test one intent sent twice, two distinct members claiming one copy, a committed save with a lost , and cancellation from an old tab after approval. what each screen shows and what is saved. Also test private access as A, B, and signed out. Administrator success cannot prove isolation. Ask for evidence and explicit remaining uncertainties.
Before editing, define this immediate-reservation rule, fields/units, same-intent ticket storage, and allowed status changes. Explain how a database claim preserves one copy under overlapping ; a label alone is not proof. Propose checks for duplicate retry, two competing users, a lost , stale cancellation, and A reading B’s data. Do not deploy. Illustrative before / after (behavior, not ready-to-run code): - Read pending; later write cancelled unconditionally + At write time, require verified owner and current pending status - Fresh ticket for every retry + Same action → same ticket → same saved result
These are behavior sketches, not built-in helper functions. Review contracts, same-action retries, access rules, and state diagrams in the linked lessons before this capstone.
Picture it, then try it
One repeated ticket versus two competing tickets
Showing the same coat-check ticket twice should retrieve one saved result. Two different tickets for the last available item require the clerk to check and claim it together.
Same intent: R7 → saved R7 → retry returns R7 Different intents: R7 ─┐ R8 ─┴→ one copy → one confirmed claim Unsafe: both read available → both save reserved Safe: check-and-claim together → one succeeds
Two people use different valid for one book. Does retry protection decide who gets the book?
Compare your reasoning with the worked answer
No. Same-key protection handles a repeated intent. The database must separately preserve the one-copy rule using an appropriate conditional claim or locking/isolation design. A groups work but does not by its name alone prevent two reads from making conflicting decisions. The losing needs a truthful unavailable result.
Picture it, then try it
Agree on the envelope, including its units
A delivery form must say grams or kilograms. A number without its meaning can be interpreted a hundred times too large or small.
Old response: amountCents: 1250 New response: price: 12.50 (dollars) Readers: checkout + receipt + open old tabs Compatible support → move readers → verify → retire old field
AI says a receipt can guess cents from decimal places. Find a price that makes that rule fail.
Compare your reasoning with the worked answer
A price of 12 dollars can be written as 12, without a decimal point. Names, units, required values, and formats must be explicit. Find affected readers and keep compatible support while moving them. With an , also ask which existing the conflict target matches and which fields it overwrites; a successful write can still replace valuable data.
Sources and further reading
In this practice app, only pending may be cancelled. A second account approves a while an old tab still shows Cancel. What should happen when that tab clicks it?
Choose one answer.