Build a Booking System for a Coaching Studio
A six-coach studio sells the same hour twice, moves coaches' sessions by an hour when the clocks change, and locks out members who have paid, because its booking page trusts whatever reaches it first. You will build the replacement, from a coach's weekly hours through a monthly plan to a booking that spends a credit, and prove it over a simulated week in which Europe changes its clocks and New York is still a week away from changing its own.
The brief
The client
I run a coaching studio with six coaches and about 140 members, a dozen of them in New York, all on a monthly plan with two or four sessions. Members book through a page that checks the coach's calendar and then saves the booking, so when one coach opened her Saturday mornings, two members were booked into the same 10:00 hour because both pages saw it free before either saved.
After Europe changed its clocks, her Wednesday 09:00 sessions showed as 08:00 on her own calendar, and our New York members saw their own shift a week later. A member who fixed her card after a failed renewal stayed locked out for two days, because the failure notice from our payment provider reached us after the notice that her retry had gone through. A coach's private notes once appeared on a member's page.
I need an hour that is sold once, a plan that decides what a member may book, and a way to prove both before the next coach opens a month.
The problem
Two members who ask for the same hour at the same moment both get it. A failure between recording a booking and taking its credit leaves a spent credit with no booking, or a booking nobody paid for.
A coach's weekly hours drift by an hour when her region changes its clocks. The United States and Europe change on different weekends, so a member in New York sees a different gap to Amsterdam for a week (in autumn 2027, from 31 Oct to 7 Nov 2027).
The payment provider reports renewals by notice. Notices arrive twice, late, out of order or not at all, and the studio acts on each as it arrives, so a failure notice that reaches it after the payment that fixed the problem locks out a member who has paid. A coach's private notes about a member appear on a page that lists "notes" for her. The studio pays for each of these in refunds, apologies and members who leave.
The client's name and figures are invented for this brief; the rules and the failures are ones that real businesses of this kind work with.
The spec
Requirements
- Let a coach publish weekly hours in her own time zone, with buffers between sessions, a minimum notice and holidays.
- Let a member see open slots in her own time zone and book one, with at most one booking able to hold any coach's time.
- Let a member subscribe to a monthly plan that grants session credits, and let the subscription's state decide whether she can book.
- Spend one credit for each booking, taking the credit that expires first, and never leave a booking without its credit or a credit without its booking.
- Let a member or a coach cancel. Keep the credit when the member cancels at least 24 elapsed hours before the start or the coach cancels at any time, and forfeit it otherwise.
- Keep access right when a renewal notice arrives twice, arrives late or out of order, or never arrives, so that access follows what the payment provider says now.
- Expire a credit 90 days after it was granted, and refuse to spend one that has expired.
- Let a coach keep private notes about a member and share homework with her, and keep the private notes away from the member and from everyone but their writer.
- Give a person a copy of her data, or erase it, on request.
- Give an operator one check that reports overlapping bookings, balances that differ from their credit history and confirmed bookings without exactly one spent credit.
Deliverables
- Your repository starts the whole studio with one command and seeds 6 coaches and 140 members, 12 of them in New York.
- A README that takes a reviewer from a fresh clone to a booked session with a spent credit, and a passing consistency check, in 15 minutes, and lists the command for each test.
- A way to play the studio's week faster than real time: move the studio's clock, run a simulator that plays the members, the coaches and the payment provider, and make the provider do each bad thing this brief names (answer slowly, send a notice twice, send a failure after a later payment, send nothing, decline a card that needs its owner, stop).
- Documentation of the studio's interface that a studio's front-end developer could use for availability, slots, subscriptions, bookings, notes, copies of a person's data and erasure.
- A test suite that covers clock changes in two regions, late, repeated and missing payment notices, requests sent at the same moment and not one after another, the studio's process stopped in the middle of work, and a sweep for private note text, plus the results of the simulated run committed to your repository.
- An operations note that says how an operator runs the consistency check, settles subscriptions by hand against the provider, runs credit expiry by hand, moves the studio's clock, and sees why an erasure is blocked.
Out of scope
- One part of the studio being stopped while the rest keeps working. That belongs to Build a Coaching Platform.
- A video provider, a join log and no-show detection. A session is a time the coach and member agree on, and the coach sends her own link. Creating meetings and treating a vendor outage as normal is the larger brief's subject.
- Messaging between sessions, reminders and booking emails. A reminder in the recipient's zone repeats the clock-change lesson from Phase 2.
- Coach payouts, commission, refund reversals and card disputes. The studio pays each coach a fixed fee per session by hand.
- Moving a booking in one action, the emergency pass, group sessions and recurring bookings. A member cancels and books again.
- Coach discovery, search, reviews and syncing with a coach's outside calendar. An outside event that arrives after a member booked the hour would take it away from her.
- Employer-paid engagements. They add a third party to the confidentiality rules; this brief stays with a coach and a member.
- A real payment provider. You build a stand-in so that your tests control when it fails.
- Checking that a payment notice really came from the provider. The brief tests order, repeats and absence, not forgery.
- A login. Each request says who is acting, however you choose to carry that. Do not put this application on the internet.
- A web or mobile app. A documented interface and the simulator stand in for them.
- Tax and VAT, refunds of subscription fees, and the right to withdraw from a contract. The studio refunds by hand in the provider's dashboard, and the brief fixes no tax rule.
- Purging old records. Dutch rules oblige the studio to keep its business records for 7 years (Belastingdienst), so the brief builds no purge and erasure keeps those records, identified by an ID.
Architectural constraints
- Amounts are whole cents in one currency, the euro, and exact to the cent.
- No card number is ever stored. The studio keeps only a label for a card.
- A coach never has two bookings at the same time, and the buffer after a session counts as part of the booking.
- A booking and its credit are never apart: a booking without a spent credit, or a spent credit without a booking, never survives a failure.
- A credit balance is never below zero and always equals the history of grants, spends, restores and expiries behind it. A correction adds a line to that history and never changes one.
- A coach's weekly hours mean the same clock time on her own calendar all year. The 24-hour cancellation cutoff counts elapsed hours, not the same clock time on the day before.
- A member who has paid is never locked out by a notice that is old, repeated or wrong. Access follows what the payment provider reports now.
- A private note is never visible to the member it describes, to any other coach, or in any log.
- A person's personal fields are erased on request, while credit history and booking records stay, identified by an ID.
Prerequisites
You have built one application with a database, in any stack. You have never built anything that two people can book at the same moment, and you do not need to know time zones beyond "they exist". You do not need to know how a coaching studio sells and runs its sessions; the first Phase explains the business and the words the brief uses. Having once chased a bug caused by two requests arriving at the same moment will make Phase 4 familiar. If you want a gentler start in the same domain, Build a Session Pack Tracker comes first. When you finish, Build a Coaching Platform takes the same problems further.
Free to start. An account is what keeps track of the checkpoints you finish.
Work out the studio's rules by hand
Produces two documents worked by hand: a table of every way a booking can end and what its credit does, and the studio's sessions across Europe's and the United States' clock changes. No code yet.
Acceptance criteria
Before you write any code, you write a state table in your repository. Its rows are the states a booking can be in, from an open slot to the end of its credit, and the moves between them. For each move it says what causes it, who acts (the member, the coach or the studio's own schedule) and what is true afterwards, in the past tense ("credit spent", not "spend credit"). It covers a booking that stays confirmed, one the member cancels 24 elapsed hours before the start, one she cancels 23 hours before, and one the coach cancels at any time, and says for each whether the credit comes back.
The document covers three refusals: the hour is already taken, the member has no credit left, and the member's subscription has lapsed. For each one it states what exists afterwards. For all three the answer is no booking and no change to the member's credit history.
It ends with four situations where two things happen at the same moment or one thing is cut short. Each has one sentence saying what must be true afterwards. The situations are two members asking for one coach's 10:00 hour; one member with one credit left asking for two different hours; a failure notice from the payment provider reaching the studio after the notice that her retry succeeded; and the studio's process dying after a booking is recorded and before its credit is spent. Phases 3 and 4 test these sentences.
Architectural guidance
In the old system two members ended up in the same hour. Writing the states, the moves and the refusals as facts makes every moment where two things must agree visible before any code exists. A rule nobody wrote down gets decided by whichever request arrives first.
Acceptance criteria
You write a worked-example document in your repository with literal answers, each checked against the time zone database or a published source and not produced by your own code. It states that Europe changes its clocks on Sunday 28 Mar 2027 and Sunday 31 Oct 2027, that the United States changes on Sunday 14 Mar 2027 and Sunday 7 Nov 2027, and that from 31 Oct to 6 Nov 2027 Amsterdam and New York are 5 hours apart instead of 6.
It gives the answers to these questions for a coach in Europe/Amsterdam, each with the UTC time and the time a member in America/New_York sees: her Wednesday 09:00 session on 10, 17, 24 and 31 Mar 2027, on 27 Oct 2027 and on 3 and 10 Nov 2027; and her Thursday 15:00 session on 28 Oct 2027 and on 4 Nov 2027.
It shows the cancellation cutoff for a Sunday 10:00 session on 31 Oct 2027 in Amsterdam, counted as 24 elapsed hours, and what clock time that is in Amsterdam on Saturday 30 Oct 2027. It shows what happens to a coach's 02:30 start on Sunday 28 Mar 2027 (that time does not exist in Amsterdam that day) and on Sunday 31 Oct 2027 (that time happens twice), and which of the two readings of the second case you will offer members.
Architectural guidance
A clock-change mistake shows up twice a year and only in the week after, so it is cheap to miss and expensive to find. Answers written down first give the later tests something to check the product against that the product did not produce.
Architectural walkthrough
How a coaching studio sells and runs its sessions
The studio has six coaches and about 140 members. A member pays a monthly plan with two or four sessions and books each one on the studio's page, with the coach she chooses. A dozen of the members live in New York.
Each coach sets her own weekly hours in her own time zone, with a gap between sessions, a minimum notice before a booking and days off. A session is a time the coach and the member agree on, and the coach sends her own link. The studio takes the card payment through a payment provider, which sends the studio a notice each month when a plan renews or fails to renew. A coach also keeps private notes about a member and shares homework with her. The studio pays each coach a fixed fee per session by hand.
In a normal month a member books the two or four sessions her plan grants and sometimes cancels one. Twice a year Europe changes its clocks, and the United States changes on a different weekend. In autumn 2027 the two are a week apart, from 31 Oct to 7 Nov 2027.
The words this brief uses:
Session credit: the right to one session. A plan grants credits each month, and a credit expires 90 days after it was granted.
Monthly plan: the subscription a member pays for, with two or four sessions a month.
Subscription state: whether the plan is paid up, which decides whether a member may book.
Renewal notice: the payment provider's message that a renewal went through or failed. It can arrive twice, late, out of order or not at all.
Buffer: the gap a coach keeps after a session. It counts as part of the booking.
Minimum notice: how far ahead a booking must be made.
Clock change: the weekend a region moves its clocks an hour, in spring or autumn.
Elapsed hours: real hours between two moments, which differ from the same clock time on another day in a week when the clocks change.
Private note: a coach's note about a member that only its writer may see.
Erasure: removing a person's personal details on request. The studio still keeps its business records.
Why the rules are worked out by hand
This Phase builds nothing a member will see. Two parts of this brief are easy to get wrong by one hour, and a wrong hour is invisible in the code until a member complains.
A member who cancels a Sunday session 24 hours ahead, in the week the clocks change overnight, keeps or loses her credit depending on whether "a day before" means 24 elapsed hours or the same clock time on the previous day. Those two readings differ by an hour that week. A coach's Wednesday 09:00 sits a different distance from a New York member's morning in the week when one region has changed its clocks and the other has not. Built from a guess, both mistakes surface as a refused credit or a session at the wrong hour.
A booking also has moments where two things must be true together: the hour and the credit, the payment and the access. Writing those moments down before any code exists shows where the old page left a gap, and it gives the later Checkpoints answers that the product did not produce itself.
Publish coach time
Produces people with their time zones, coaches' weekly hours and the open slots each member sees in her own zone, ending in a test that stands on both sides of two regions' clock changes. Nothing can be booked yet.
Acceptance criteria
A coach or a member can be registered with a role (coach or member), a display name, an email address and a time zone, and the registration returns an identifier. Asking for that person afterwards gives back the same four values. The time zone is a region name of the form Area/Location, such as Europe/Amsterdam or America/New_York.
A time zone of CET, +01:00, Amsterdam or an empty value is refused with a message naming the field, and nobody is registered. A role other than coach or member, an email that is already registered (compared without regard to case) and a missing display name are each refused the same way. Asking for a person who does not exist says so.
The studio's seed data creates 6 coaches, all in Europe/Amsterdam, and 140 members, of whom 128 are in Europe/Amsterdam and 12 in America/New_York. Running the seed twice leaves 146 people, not 292.
Architectural guidance
Every later feature turns on a person's time zone. A member whose zone is recorded as a fixed offset such as -05:00 sees the right hour in winter and the wrong one once New York changes its clocks, because an offset is right only while the region stays on that setting. Nobody notices until the weekend it changes.
Acceptance criteria
A coach, acting as herself, publishes her weekly hours: a buffer between sessions in minutes (15 here), a minimum notice in hours (12 here) and a list of weekly windows, each a weekday with a start and an end such as 09:00 and 13:00. Publishing succeeds, and publishing again replaces the earlier hours.
The hours mean the times as she wrote them on her own calendar, in her own time zone. A Wednesday window starting at 09:00 starts at 09:00 on her calendar before and after Europe changes its clocks.
These are refused and change nothing: a time with an offset or a Z (09:00+01:00), a window shorter than 60 minutes (09:00 to 09:30), a start that is not before its end, two windows on one weekday that overlap, a weekday that does not exist, a buffer above 60 minutes and a minimum notice above 72 hours. A member, or another coach, publishing hours for her is refused. Publishing for a person who is not a coach says so.
Stopping the studio's process in the middle of a publish leaves either her old hours or her new ones in force, never a mixture of the two.
Architectural guidance
A coach means "Wednesday at 09:00 where I am". A publish cut short that leaves half of one week's hours and half of another's offers members slots the coach never meant to work.
Acceptance criteria
A member asks for a coach's open slots from 28 Oct 2027 to 28 Oct 2027 and gets a list ordered by start. Each slot is 60 minutes long. It shows its start and end as UTC times such as 2027-10-28T13:00:00Z, and its start in the member's own zone with the offset. The first and last dates are dates in the member's zone, and both days are included.
A coach with a buffer of 0 whose Thursday window is 15:00 to 18:00 in Europe/Amsterdam shows three slots on Thursday 28 Oct 2027. This Checkpoint ignores the buffer and the next one applies it, so the example coach has none and the values below stay true after both. An Amsterdam member sees 28 Oct 2027, 15:00 (+02:00), 16:00 and 17:00 on that date. A New York member sees 28 Oct 2027, 09:00 (-04:00), 10:00 and 11:00, with the same three UTC starts in both answers. On Thursday 4 Nov 2027 the first UTC start is 4 Nov 2027, 14:00 UTC and the New York member sees 4 Nov 2027, 10:00 (-04:00). A window from 15:00 to 17:30 shows two slots, not three, because a session must end inside the window.
A range longer than 14 days is refused, a coach who does not exist is reported as not found, and a coach who has published nothing gets an empty list. Asking twice gives the same answer, and after the coach changes her hours the next answer shows the change.
Architectural guidance
Members in two time zones ask about the same slot and each must see her own local hour without doing the arithmetic herself. A member who sees last week's hour after a clock change turns up at the wrong time, and so does the coach.
Acceptance criteria
With a buffer of 15 minutes and a window of 09:00 to 14:00, the slots start at 09:00, 10:15, 11:30 and 12:45 local time: the gap between session starts is 60 minutes plus the buffer, and the last session ends at 13:45, inside the window. With a buffer of 0 the same window gives five slots, and with a buffer of 60 it gives three (09:00, 11:00 and 13:00).
The studio can be told that "now" is a chosen instant and later returned to real time, and everything in the product obeys it, so no test waits for real time. The operations note says how an operator does this. With a minimum notice of 12 hours and now at 28 Oct 2027, 01:00 UTC, the 15:00 Amsterdam slot (13:00Z, exactly 12 hours away) is open. At 28 Oct 2027, 01:00:01 UTC it is not, while the 16:00 slot is. A slot that starts in the past is never open.
A coach blocks a holiday from 4 Nov 2027 to 5 Nov 2027. The request succeeds and removes every slot whose start falls on those dates in the coach's own zone, whichever zone the member is in. An end date before the start date is refused, and a member blocking a holiday is refused.
Architectural guidance
Minimum notice counts elapsed time from now. A test that waits for real time is slow, and one that cannot reach a Sunday in October can never test a clock change. A holiday is a pair of calendar dates in the coach's place, because her week off starts when her own calendar says it does. The buffer widens the gap between starts so that the next member never arrives while the coach is still finishing the last.
Acceptance criteria
A test with one command, listed in the README, prints the number of cases and 0 failures. It sets the studio's "now" before each case and checks literal expected values from your research, not values produced by the product under test.
A coach in Europe/Amsterdam publishes a Wednesday window starting at 09:00. Europe changes its clocks on Sunday 28 Mar 2027, so Wednesday 24 Mar 2027 gives a UTC start of 24 Mar 2027, 08:00 UTC and Wednesday 31 Mar 2027 gives 31 Mar 2027, 07:00 UTC, and the coach reading her own slots sees 09:00 on both days. In autumn, Wednesday 27 Oct 2027 gives 07:00:00Z and Wednesday 3 Nov 2027 gives 08:00:00Z, and she again sees 09:00.
A member in America/New_York sees that coach's Wednesday session at 03:00:00-05:00 on 10 Mar 2027, at 04:00:00-04:00 on 17 Mar 2027 (the United States changed on 14 Mar 2027 and Europe had not) and at 03:00:00-04:00 on 31 Mar 2027. In autumn she sees 03:00:00-04:00 on 27 Oct 2027, 04:00:00-04:00 on 3 Nov 2027 and 03:00:00-05:00 on 10 Nov 2027.
A window whose only slot starts at 02:30 gives no slot on Sunday 28 Mar 2027, because that time does not exist in Amsterdam that day, and the request still succeeds. On Sunday 31 Oct 2027, when 02:30 happens twice, it gives exactly one slot, the first, at 00:30:00Z. You have run the test against a deliberately wrong version in which the coach's Wednesday session is an hour off on her own calendar after each change, and seen it fail, and the test's documentation records how many cases failed.
Architectural guidance
Literal expected values matter because a test that computes its answer the way the product does agrees with the product's mistakes. Running the test against a version that is known to be wrong shows that it can fail, which is what a pass is worth.
Architectural walkthrough
This Phase builds the first half of the calendar: who the people are, when each coach works, and which slots a member can see. The failure it must survive is a coach's week drifting by an hour when her region changes its clocks.
In the old system, after Europe changed its clocks, a coach's Wednesday session read 08:00 on her own calendar, and a week later New York members saw their own hour shift because the United States changes on a different weekend. A member then arrives an hour early or an hour late, and a coach waits for someone who is not coming. A coach who says "Wednesday 09:00" means 09:00 where she is, in both seasons, without touching her settings.
A member who opens the calendar after the change and sees the old hours has the same problem. This Phase ends with a test that stands on both sides of each clock change with expected values you worked out by hand, because a clock-change fault appears twice a year and never in a test that runs on an ordinary Tuesday.
Sell plans and decide access
Produces a payment provider stand-in that misbehaves on demand, monthly plans, credits and the decision on who may book. No session spends a credit yet.
Acceptance criteria
You have a stand-in for the payment provider that starts with one documented command and keeps behaving while the studio is stopped. The studio reaches it only the way it would reach the real provider.
It behaves like a subscription provider. It charges a member's card for one monthly period when she subscribes and again when each period ends. A period ends on the same day of the next month as the day she subscribed, or on the last day of that month when it is shorter, so a member who subscribes on 31 Jan 2027 is charged again on 28 Feb 2027, 31 Mar 2027 and 30 Apr 2027. A card can be set to work or to decline. A declined renewal is tried 3 times in all, on the due day, 3 days later and 7 days after the due day, and the third decline ends the subscription. A decline that needs the member present, such as her bank asking her to confirm, is never retried. A member can pay an unpaid subscription herself, which charges the card at once, including after the subscription has ended. For every outcome the stand-in sends the studio a notice that says what happened (renewal paid, payment failed or subscription ended), which subscription and period it concerns and when it happened. It waits 5 seconds for the studio's answer and counts anything other than success as not delivered. It can be told to send a notice again.
You can make each of these happen on command, and the README shows the command for each, run with the studio stopped and something of your own receiving the notices: every notice of the next renewal sent twice; a failure notice sent after the paid notice of the retry that succeeded, although the failure happened first; a renewal that sends no notice at all; a decline that needs the member present; a reply to the studio that takes longer than 5 seconds; and the stand-in itself stopped. Without a fault, a working card gets exactly one paid notice for each renewal. Your clock for the stand-in can be moved to the same instant as the studio's.
Architectural guidance
A provider that always answers politely teaches nothing, so build the bad days first, before the code that has to survive them.
Example of the order problem. On day 0 at 09:00 a renewal is declined and the provider writes a failure notice. On day 2 at 14:00 the member fixes her card, the provider charges it and sends a paid notice at once. Straight after, the failure notice goes out. The studio receives paid, then failed, although the failure happened first.
Acceptance criteria
Two plans exist: the 2-session plan, 2 credits for 16000 euro cents (EUR 160.00) a month, and the 4-session plan, 4 credits for 30000 euro cents a month. A member, acting as herself, subscribes to the 2-session plan and the subscription shows as active. Her subscription shows a label for her card, never the card number.
With the stand-in's card set to decline, the same request is accepted but not completed: the subscription shows as waiting for its first payment and she has no credits. Subscribing while she already has a subscription in any state (active, waiting for its first payment, in grace or lapsed) is refused, because a lapsed member returns by paying the subscription she has. A coach, another member's identity or a plan that does not exist is refused and creates nothing.
With the stand-in stopped, the request fails within 6 seconds, says the payment provider is unavailable, and she has no subscription afterwards. A stand-in that answers after more than 5 seconds gives the same result. If the studio's process dies after the provider has charged her and before the studio recorded her subscription, asking again does not charge her a second time.
Architectural guidance
A payment takes seconds and fails in ways nobody sees: slow, declined, unreachable. A member who is charged and shown no subscription writes to the studio the same day. A member shown a subscription that was never paid gets sessions free. A first payment that fails is a fact the studio has to keep, because otherwise she is neither a customer nor a refusal.
Acceptance criteria
After a member's first payment succeeds on the 2-session plan, her balance is 2 credits. Her credit history lists every grant, spend, restore and expiry in order, each with its date, its number of credits and the billing period or booking it belongs to. A grant also shows the date it expires, 90 days of 24 hours after the grant. Her balance is the sum of her history.
A correction adds a line to the history, and nothing edits or deletes an existing line. No request the studio accepts, from a member, a coach or an operator, changes or removes an existing line, and the README shows an attempt at each refused.
Credits for a paid month are granted once however many times the studio learns about the payment. Processing the same payment twice adds the credits once. If the studio's process is stopped after a paid month is recorded and before its credits are added, the credits are added exactly once after the process restarts, and a second restart adds nothing.
Architectural guidance
When a member says she should have 3 credits and the studio can say only that she has 2, nobody can settle it.
Acceptance criteria
The studio answers every well-formed notice from the provider with success within 5 seconds. A message that is not a notice is refused and stores nothing. Receiving the same notice twice leaves one result, and both deliveries are answered with success.
What the studio concludes follows what the provider reports about the subscription when the studio acts, not the claim in the notice. With the provider showing a renewal paid, a late "payment failed" notice for it leaves the member's subscription active and her balance unchanged. A card that was declined, with a retry still due, puts the member in grace (a payment failed and the provider will retry). A subscription the provider will not retry, including a decline that needs her present, lapses. A newly paid period adds the plan's credits once. A subscription waiting for its first payment that is later paid becomes active, and a lapsed subscription that is paid becomes active again. Applying the same conclusion twice changes nothing the second time.
A renewal whose notice never arrives is caught within an hour, without anyone acting, and an operator can trigger the same check by hand. With the "send no notice" behaviour, the balance keeps its old value until the check runs. After one run the plan's credits are added once, and a second run adds nothing.
With the stand-in stopped when a notice is processed, the studio loses nothing: it tries again, up to 5 times, and once the stand-in is back the notice is applied once. A notice that gives up after 5 tries, and one about a subscription the studio does not know, can be seen by an operator, and the operator can have the first kind tried again once the cause is fixed. The unknown subscription is not tried again on its own. Stopping the studio's process in the middle of processing a notice and restarting it ends with the notice applied once: the credits are added once and nothing is doubled.
Architectural guidance
A notice says that something happened, which may not be true any more. Anyone who can reach the studio's notice address can also send a notice that never happened.
Acceptance criteria
The studio can tell whether a member may book, and the member can see the answer. The answer carries whether she may book, the reason, her subscription's state and her balance. An active subscription gives yes, with the reason that it is active. A subscription in grace gives yes, with the reason that it is in grace. A subscription waiting for its first payment gives no, with that reason, and a lapsed one gives no, with that reason. A member with no subscription gives no, with the reason that she has none. The answer changes on the next request after the state changes, with no waiting.
A lapse changes nothing else: her unexpired credits stay in her history and her balance. A member in grace can still book until the provider's final decline, and the first answer after that decline is no.
Starting from a lapsed member, the stand-in's card is set to work and she pays the subscription she has. When the notice has been processed, the answer turns to yes and the new period's credits are granted once. Repeating the notice changes nothing.
Architectural guidance
A member is told whether she may book on more than one screen. If two screens ever disagree, a member who should be in is locked out and nobody can say which screen was right. A member in grace can still book because a declined first try is not yet a lost member: the provider retries on days 3 and 7, and a member who fixes her card on day 2 would otherwise be locked out in between.
Acceptance criteria
A test with one command, listed in the README, prints the number of scenarios, the number of runs and 0 differences, then exits 0. It drives the real stand-in and the real studio with a fixed seed.
There are five scenarios, and each has a reference run that plays the notices once, in the order things happened, processing each straight away. The scenarios are: a member on the 4-session plan who subscribes on 31 Jan 2027 and goes through the first period and 3 clean renewals, on 28 Feb 2027, 31 Mar 2027 and 30 Apr 2027 on the stand-in's clock; a renewal declined on its due day and paid by the member on day 2; a renewal whose third try fails on day 7, followed by the member paying on day 8; a decline that needs the member present, followed by the member paying; and a renewal whose notice is never sent, followed by the hourly check run by hand.
Further runs of each scenario deliver the same notices with every notice sent twice, with a failure notice sent after a later paid notice, at random positions among the notices of other members, and with the studio's process stopped and restarted at a random moment while notices are being processed. For every run the test takes a snapshot of each member: her subscription's state, whether she may book, her credit history (kind, credits and billing period, without identifiers or timestamps) and her balance. A run passes when its snapshot equals the reference snapshot field by field. In the first scenario the final state is active, with 4 grants of 4 credits and a balance of 16. No run grants a billing period twice.
You have run the test against a deliberately wrong version that acts on what a notice says instead of what the provider reports, and seen it fail: the member in the day 7 and day 8 scenario ends lapsed although the provider shows her active. The test's documentation records that output, including the number of differences.
Architectural guidance
One test per rule cannot show that the whole flow holds up under realistic delivery. The claim to test is that the same notices, in any arrangement, leave each member where they would have left her arriving once and in order, and the reference run says where that is. Breaking the product on purpose and watching the test fail is what gives a pass any meaning.
Example of the divergence the test must catch. On day 7 the third try of a renewal is declined and the provider ends the subscription and sends a failure notice. On day 8 the member pays, the provider reactivates the subscription and sends a paid notice. The studio receives the paid notice first and the failure notice second. A studio that believes the late failure notice locks out a member who has paid.
Architectural walkthrough
This Phase builds what a member pays for, how many sessions it entitles her to, and whether she may book right now. The failure it must survive is the payment provider telling the studio the wrong thing at the wrong time.
Providers send a notice at least once, in no guaranteed order, and sometimes not at all. The studio's old system acted on each notice as it arrived, so a failure notice that reached it after the success notice for the retry locked out a member who had paid, for two days. A notice that never comes leaves a member who has paid without her credits until she writes in. A process that dies between learning of a payment and adding its credits gives her nothing, or gives her double when the work is repeated. The first costs a member and a refund, the second costs the studio sessions it was not paid for.
The stand-in for the provider comes first because you cannot test a rule against a provider that behaves. After it, the Phase turns payments into credits, and the studio's decision on who may book follows from what the provider says.
Book with a credit
Produces booking with a credit, one member per coach's hour, cancellation that restores or forfeits the credit, credit expiry and the first consistency check. No notes and no erasure yet.
Acceptance criteria
Open slots now exclude booked time. With now at 20 Oct 2027, 08:00 UTC, a coach whose Tuesday window is 09:00 to 14:00 in Europe/Amsterdam with a 15-minute buffer shows 4 slots on Tuesday 26 Oct 2027. A member in Europe/Amsterdam with an active subscription and 1 credit books the slot starting at 26 Oct 2027, 07:00 UTC, acting as herself. The booking is confirmed, starts at 07:00:00Z and ends at 08:00:00Z, and the coach stays unavailable until the end of her buffer at 08:15:00Z. The member's balance is now 0. The coach's slots for that day are the 3 starting at 10:15, 11:30 and 12:45, and a member in America/New_York sees the same 3 in her own zone.
Each refusal leaves no booking and no change to the credit history, and the slot is still listed afterwards. A member with 0 credits is refused because she has no credit left. A lapsed member holding 1 credit is refused because she may not book and keeps her credit. A lapsed member holding 0 credits gets the same refusal, because access is checked before the balance. A member waiting for her first payment is refused for that reason. A start that is not an open slot, such as 26 Oct 2027, 07:30 UTC, a slot inside a holiday or a slot closer than the minimum notice, is refused because it is not open. A slot that is open by the rules but already booked is refused because the hour is taken. A coach asking to book is refused. Blocking a holiday over an hour that is already booked leaves the booking confirmed.
Stopping the studio's process at any moment while a booking is being made leaves either a confirmed booking with its credit spent, or neither: never a booking without a spent credit and never a spent credit without a booking. You have killed the process at several different moments during a booking, and the README records how many moments you tried and what each left behind.
Architectural guidance
If the process dies between recording a booking and taking its credit, the studio either gives away a session or keeps a credit for a session that does not exist. The first ends in an apology and a refund. The second ends in a free session, and the studio finds out when the numbers do not add up.
Acceptance criteria
A coach never holds two confirmed bookings that overlap, where a booking occupies its session and the buffer after it, up to but not including the end of the buffer. With a booking at 26 Oct 2027, 07:00 UTC occupying the coach until 08:15:00Z, a second booking for the same coach starting at 08:14:00Z is refused. One starting at 08:15:00Z is accepted, and so is one for a different coach at 07:00:00Z. A cancelled booking blocks nothing.
Two members, each with 1 credit, ask for the same coach and the same slot at the same moment, as separate requests. Exactly one booking is confirmed and the other request is refused because the hour is taken. The winner's balance is 0, the loser's is still 1, and the slot is gone from the coach's list. One member sending the same booking request twice at the same moment gets one booking and spends one credit.
The test has to be able to lose. You have run it against a deliberately wrong copy that lets two requests arriving together both succeed, and seen it confirm two bookings for one hour. The README records that output next to the passing one.
A coach who republishes her hours with a buffer of 0 after a booking at 09:00 (which blocks her until 10:15) is not offered a 10:00 slot, because the existing booking keeps the buffer it was made with.
Architectural guidance
Two requests that arrive together can each find the hour free. Buffers make it harder than one session per hour, because sessions 75 minutes apart must still not touch.
Acceptance criteria
A member books a coach's Sunday session at 10:00 in Europe/Amsterdam on 31 Oct 2027, which is 31 Oct 2027, 09:00 UTC, and cancels it as herself. The cutoff is 24 elapsed hours before the start, 30 Oct 2027, 09:00 UTC, which is Saturday 11:00 in Amsterdam because the clocks change overnight.
With now at exactly 30 Oct 2027, 09:00 UTC the cancellation succeeds and reports the credit as restored. Her balance rises by 1 and her history shows one restored credit for that booking. With now at 30 Oct 2027, 09:00:01 UTC the outcome is forfeited: the balance is unchanged and nothing is restored. At 30 Oct 2027, 08:30 UTC, which is Saturday 10:30 in Amsterdam and 24.5 elapsed hours before the start, the credit is restored. At 30 Oct 2027, 09:30 UTC, 23.5 hours before, it is forfeited. A rule that compares "the same time on the day before" forfeits at 08:30Z, because it puts the cutoff at Saturday 10:00 in Amsterdam, and the test must catch that.
A coach who cancels a confirmed booking gets the credit restored at any time, including 10 minutes before the start. A coach who blocked a holiday over a booked hour cancels that booking herself the same way. A person who is neither the booking's member nor its coach is refused, and an unknown booking is reported as not found. Cancelling a booking that is already cancelled succeeds with the original outcome and changes nothing else. The member and the coach cancelling the same booking at the same moment restore one credit, not two.
After a cancellation the hour is listed in the coach's slots again, and another member books it. A restored credit keeps the expiry date of the grant that the original spend used. Stopping the studio's process in the middle of a cancellation leaves the booking either confirmed with its credit still spent, or cancelled with its credit settled as decided, never cancelled with the credit left unresolved.
Architectural guidance
Twenty-four hours before a session means 24 elapsed hours. A clock change between the cancellation and the session makes the wall-clock reading wrong by an hour, so the studio forfeits a credit the member was entitled to keep, or restores one she was not. A coach and a member who both press cancel produce two refunds for one booking if nothing stops it. A restored credit keeps its original expiry because a fresh 90 days would let a member extend her credits by booking and cancelling in a loop.
Acceptance criteria
A member subscribes to the 4-session plan with now at 2 Aug 2027, 12:00 UTC, so her grant of 4 credits expires at 31 Oct 2027, 12:00 UTC: 90 days of 24 hours, which is 13:00 in Amsterdam because the clocks changed on that day. She books one session against it, leaving 3 unused credits.
Expired credits are removed within a day without anyone acting, and an operator can run the expiry by hand. With now at 31 Oct 2027, 11:59:59 UTC it removes nothing. With now at 31 Oct 2027, 12:00 UTC it removes the 3 unused credits, her balance goes from 3 to 0 and her history shows one expiry of 3. Running it again changes nothing. The spent credit is not touched and the booking it paid for stays confirmed.
With two grants, the older one expires first and the newer one is untouched until its own expiry. A grant with all 4 credits spent expires nothing. A lapsed member's unused credits expire on the same schedule as anyone else's.
A credit whose expiry has passed cannot be spent even if the expiry has not run yet. With now at 31 Oct 2027, 12:00 UTC and the expiry not yet run, a member whose only unused credits are in that grant is refused because she has no credit left, and her history is unchanged. Her balance catches up the next time the expiry runs. A booking request and the expiry arriving at the same moment for a member's last credit end with either the booking made and nothing expired, or the credit expired and the booking refused, never both, and her balance is never -1.
A restored credit can arrive after its grant expired. In the same setup, the one session she booked is for 2 Nov 2027 and was booked on 25 Oct 2027 against that grant. The coach cancels it at 1 Nov 2027, 08:00 UTC. Her history shows the restored credit with the grant's original expiry and, at once, the expiry of that credit. Her balance is still 0.
Architectural guidance
Credits expire so that a member cannot bank a year of sessions and spend them all in one month, and the expiry is counted in elapsed time from the grant, the same way the cancellation cutoff is. A credit that expires at noon but is only removed by the next daily run is, for hours, a credit the member can spend without the studio having intended it. A spend and an expiry that both count the same credit leave a balance of -1 and a member who booked a session the studio did not sell her.
Acceptance criteria
A test with one command, listed in the README, prints the number of scenarios, the number of rounds and 0 failures, then exits 0. Every competing request is sent by its own client, and all of them are released together by a shared start signal.
The first scenario is the popular hour. In each of 20 rounds, 12 members who each hold 1 credit ask to book the same coach and the same slot at the same moment. In every round exactly 1 booking is confirmed and 11 requests are refused because the hour is taken. The 11 refused members still hold 1 credit and the winner holds 0. Afterwards the round has 1 confirmed booking and 1 spent credit.
The second scenario is the last credit. In each of 20 rounds, one member holding exactly 1 credit asks for two different hours of the same coach at the same moment, and then for two different coaches. Exactly one request is confirmed and the other is refused because she has no credit left. Her balance is 0 and never -1, and one booking exists.
The third scenario is the double click. In each of 20 rounds, one member sends the same booking request twice at the same moment. One booking is confirmed and one credit is spent.
You have run the tests against two deliberately wrong versions and watched them fail. In one, two requests for the same hour can both succeed, and the first scenario shows more than one booking confirmed. In the other, two requests can spend the same credit, and the second scenario shows two bookings confirmed or a balance of -1. The test's documentation records both outputs, including how many rounds failed.
An operator can run one consistency check that prints one line per rule with a count and succeeds only when every count is 0. The rules are: coaches with overlapping confirmed bookings; members whose balance differs from their credit history or is negative; and confirmed bookings that do not hold exactly one spent credit. A forfeited booking holds a spent credit and is not confirmed, so it is not reported. After the tests the check succeeds. You have planted each violation once by whatever means your build allows (an overlapping booking, a balance that differs from its history, a confirmed booking with its spent credit removed) and seen the check fail and print the offending identifiers. The README records the three outputs.
Architectural guidance
A race appears only when two requests are in flight at the same moment, so a test that sends them one after another passes whether or not the product handles it. The first sign of the bug is then a member who phones to ask why her booking does not exist, or a coach who finds two people at her door. The consistency check at the end is the backstop for failures no test thought of: it looks at the finished data, not at the code that produced it.
Architectural walkthrough
This Phase finishes the booking side. A member books a coach's hour, the booking spends one credit, a cancellation restores or forfeits that credit, unused credits expire, and one check tells an operator whether the result follows the studio's own rules. The failure it must survive is two things happening at once.
Two members who opened the same Saturday hour on the old booking page were both told they were booked, and the coach had two sessions at 10:00. One of them was turned away at the door or refunded.
Other pairs have the same shape. A coach and a member cancelling one booking in the same second must restore one credit, not two. A booking and an expiry racing for a member's last credit must not both take it. A process that dies between recording a booking and finishing the rest of the work must not leave a half-done booking behind.
Keep notes, honour erasure and prove the run
Produces private notes, a copy of a person's data, erasure, a sweep that fails when a private note escapes, and a simulated run that proves the whole studio. Nothing is added after it.
Acceptance criteria
A person asks for a copy of her data and receives one document with a section for each kind of data the studio holds about her. For a member with a subscription, 2 bookings and 1 shared homework item, it holds her name, email and time zone; her subscription's state, card label and credit history; both bookings; and the homework. It holds the number of private notes written about her and no note text. For a coach it holds her weekly hours, her holidays, her bookings and the notes she wrote. Another person asking for it is refused. A person who does not exist is reported as not found.
Architectural guidance
A person who asks what the studio holds about her and gets half of it has been told something false. Private notes are her coach's words about her, and the document shows how many exist and nothing more, so the copy cannot itself become the leak the studio is trying to prevent.
Acceptance criteria
A person asks to be erased. The request is accepted and shows as requested. Asking again while it is open does not start a second erasure. When it finishes: her name and email are replaced by values that contain nothing of the originals and stay unique, her role and time zone are unchanged, her card label is gone, a coach's weekly hours and holidays are gone so her slots list is empty, and the text of every note and homework item written by or about her is gone, and the counts of notes and homework items are unchanged. Her credit history and bookings stay unchanged, identified by an ID, the consistency check still succeeds, and reading the person shows the replaced name. The erasure shows as done.
A person is never shown as erased while any of her data remains. Stopping the studio's process partway through, at each point you can find, and restarting it ends with every item erased and one finished erasure. The README records how many points you tried. While the erasure is unfinished it shows as requested and her name is still the original.
A person with a future booking is refused: the erasure shows as blocked, saying a future booking exists, and her name and email are unchanged. Whatever was erased before the block stays erased. After she cancels the booking, or after it is past, a new request completes. A person who does not exist is reported as not found.
Credit history and booking records stay because the studio has a legal duty to keep its business records for 7 years under Dutch tax rules (Belastingdienst). The brief builds no purge for them.
Architectural guidance
Erasure has to reach everything the studio holds about a person. A request marked done while a card label or a note remains is a false statement to the person who asked. A process that dies halfway leaves her partly erased, and if nothing notices, she stays that way. A coach whose member's name disappears before a session she has booked faces a stranger, so a future booking has to stop the erasure. Keeping credit history and bookings by ID lets balances and the consistency check stay true after the person's name is gone.
Acceptance criteria
A test with one command, listed in the README, prints the number of notes planted, the number of places scanned and 0 leaks, then exits 0. It runs against the real studio, with its background work running.
The test plants several private notes in realistic sentences, each with a random token inside it, so a match cannot be an accident. It then plays a full flow with those people: bookings, a cancellation, homework shared, a copy of a person's data, an erasure that is blocked and one that completes, and a failing request. For each note it searches for the whole text and for any run of 20 consecutive characters of it.
The places searched are every response sent to anyone other than the coach who wrote the note, including the member's copy of her data and the responses to every other request the flow makes; every line the studio writes to its logs, wherever it runs; everything the studio sends to another system, including the payment provider; and everything an operator can inspect after a failure. The only places allowed to hold the text are the stored notes and the response to the writing coach's own reading of her notes.
You have shown the sweep failing once. In a scratch branch, write the note text into a log line when a note is saved, or add it to the member's copy of her data. The test exits non-zero and prints the place and the number of leaks. The README records that output and the branch is discarded.
Architectural guidance
A leak of private text needs one forgotten line, such as a debug log of a request body or a response that carries a whole record. A review finds it only if the reviewer thinks of that line, and a test that looks at everything leaving the studio finds it without having to. The allowed list is short on purpose, so that anything new that carries text out fails the test until someone decides it should not.
Acceptance criteria
One command, listed in the README, plays Thursday 28 Oct to Thursday 4 Nov 2027, 8 days, against a freshly seeded studio and the real payment stand-in. It plays the members, the coaches and the provider from outside, like real users, moves time with the studio's clock and the stand-in's clock, and uses a fixed seed. A second run with the same seed produces the same counts. It writes a results file that is committed to your repository.
The cast is the seeded studio: 6 coaches and 140 members, 12 of them in America/New_York, each member on the 2-session plan or the 4-session plan in a split you choose and write in the results. One coach also publishes Sunday 10:00. During the run each coach writes a private note about one member she has booked and shares homework with another. Twelve members race for each of 10 popular hours. Each race ends with exactly 1 confirmed booking and 11 refusals because the hour is taken, and the refused members keep their credits.
New York members book a coach's Thursday 15:00 Amsterdam session on 28 Oct 2027 and on 4 Nov 2027. The first is 28 Oct 2027, 13:00 UTC, 09:00 in New York, and the second is 4 Nov 2027, 14:00 UTC, 10:00 in New York, because Europe changes its clocks on 31 Oct 2027 and the United States on 7 Nov 2027. The run asserts that the coach's own view reads 15:00 both times.
The Sunday 31 Oct 2027, 10:00 session (31 Oct 2027, 09:00 UTC) is booked by one member, who cancels at 30 Oct 2027, 09:00 UTC, 24 elapsed hours before, and gets the credit restored. Another member then books the freed hour and cancels at 30 Oct 2027, 10:00 UTC, 23 elapsed hours before, and forfeits it.
Three renewals come due inside the run, because their first periods were bought on 29 Sep, 30 Sep and 2 Oct 2027 on the stand-in's clock, so they renew on 29 Oct, 30 Oct and 2 Nov 2027. One has its failure notice arrive after the success notice, and she ends active with no lock-out. One is a decline that needs the member present, so she lapses, and her booking attempt afterwards is refused because she may not book. One sends no notice, and the hourly check run by hand grants her period's credits once.
The studio's process is stopped twice in the middle of work and restarted. The results name what was in progress each time and show that it finished once, with no duplicate in any credit history and nothing left half-done. One member is erased on Monday 1 Nov 2027 while she has no future booking, and her erasure completes. Another member's erasure on that day is refused as blocked because she has a future booking.
After the run, the consistency check reports 0 for each of: coaches with overlapping bookings; balances that differ from their credit history or are negative; confirmed bookings without exactly one spent credit; bookings made by a lapsed member after her lapse; private note text found in any response to someone else or in any log of the run; and completed erasures that still leave personal data behind. The check from Phase 4 is extended with the last three.
The results file lists the counts of confirmed, refused and cancelled bookings by reason, the credits granted, spent, restored and expired, the two process stops, both erasure outcomes and the output of the consistency check. You have run the simulation once against a copy that behaves like the old booking page, or with a note text written to a log, and seen the consistency check exit non-zero. The README records the output.
Architectural guidance
Each rule was proved alone, and the failures that cost a studio money happen where two rules meet: a clock change under a race, a late notice for a member who is also booking, a process killed while an erasure is in flight. A fixed seed and a controlled clock make a failure repeatable, which is the only way to fix it. Work that is killed after it wrote something and before it finished must neither lose that something nor do it twice, and the consistency check is what shows which.
Architectural walkthrough
This Phase adds the last feature and then proves everything together. A coach keeps private notes about a member and shares homework with her, a person can ask for a copy of her data or for erasure, and a simulated run plays eight days of the studio against everything built so far.
The old system kept notes and homework in one place, so a page that listed "notes" showed a member what her coach had written about her. A note meant for the coach alone, shown to the member it describes, is the failure the studio has already lived once. A leak needs one forgotten line, which is why the test looks at everything that leaves the studio and not only at the code.
Erasure has its own failure: a person told she is erased while some of her data remains has been told something false.
The Phase ends on a simulated run that puts the clock changes, the races, the late notices, the stopped processes and the erasures into one week. Its output is committed so a reviewer sees the result without running it.
Architectural walkthrough
Two people ask for the last hour
A coach opens her Saturday mornings and two members book the same 10:00 hour, because both pages saw it free before either saved. Both are told they are booked. One reaches a coach who already has someone else, and the studio apologises and refunds her. The credit has the same weakness: if the process dies between recording a booking and taking its credit, the studio either gives away a session or keeps a credit for a session that does not exist. Neither shows up until a member phones.
The clock changes under a coach's week
A coach's Wednesday 09:00 reads 08:00 on her own calendar after Europe changes its clocks, and a week later New York members see their own hour shift because the United States changes on a different weekend. Members arrive an hour early or late. The cancellation cutoff has the same trap: in the week the clocks change, "24 hours before" and "the same time yesterday" differ by an hour, and the wrong reading forfeits a credit the member was entitled to keep.
A late notice locks out a member who paid
The payment provider sends notices at least once, in no guaranteed order, and sometimes not at all. A failure notice that reaches the studio after the notice that her retry went through locks out a member who has paid, and she stays locked out until she writes in. A notice that never comes leaves her without the credits she paid for. A process that dies between learning of a payment and adding its credits gives her nothing, or gives her double when the work is repeated.
Two requests at the same moment
Other pairs have the same shape. A coach and a member who cancel one booking in the same second must restore one credit. A booking and the expiry of a member's last credit that arrive together must not both take it. A test that sends these requests one after another passes whether or not the product handles them, so the check to run on your own build is whether the requests were really sent at the same moment.
What a leaked note or a half-erased person costs
A private note shown to the member it describes costs the studio her trust in every note a coach writes afterwards. A person told she has been erased while a card label or a note about her remains has been told something false, and a process that dies halfway leaves her partly erased unless the studio can tell. Check, in your own build, what a sweep of every response, every log line and everything an operator can inspect finds, and what an erasure interrupted at each step leaves behind.
Where it shows if you cut a corner
Four symptoms show a cut corner. Two members arrive for the same 10:00 hour and one is refunded, or a credit is missing for a session that was booked. A coach's Wednesday 09:00 reads 08:00 after Europe changes its clocks, or a member loses a credit she was entitled to keep in the week of the change. A member who paid stays locked out until she writes in, or holds double the credits she paid for. A sweep of the responses and logs finds a private note shown to the member it describes, or a card label for a person who was told she had been erased.