Loop 003 — Two barbers: choose a barber or No preference; each barber sees their own day
2026-11-15 · The shop can now run with two (or more) barbers. Clients pick a barber or keep "No preference" on the first screen and are told who they got. Each barber has their own passcode and lands on their own day.
Why
The shop is hiring a second barber. Clients choose a barber, or 'no preference', when they book; each barber sees their own day on their phone.
This was a test run with the owner unavailable. Every new choice is assumed (D21–D31 in DECISIONS.md). The owner gave no names, so the barbers are placeholders: "Sam" and "Alex".
What changed
- Barbers in
shop.config.json. Each has an id, a name clients see, and optional own hours (a part-time new hire). Without a list the shop has one barber and looks exactly as before: no barber choice, no names. - Client: choose a barber, or not. Chips above the day strip: No preference (default), Sam, Alex. They are plain links, so they work without JavaScript, and they add no screen. No preference shows every time at which someone is free.
- Who gets a No preference booking. The free barber with the fewest bookings that day, then the first in the list. The confirmation, the manage page and the calendar file say "with Sam" or "with Alex".
- When the chosen barber is off or full, the day shows "Off" or "Full", and the page says so with one button: "See 18 free times with any barber".
- Never double-booked, per barber. SQLite now allows one active booking per barber per slot. Three clients sending the same time at once to two barbers get exactly two bookings and one "pick another time" page. A trigger refuses a booking without a barber.
- Each barber has their own passcode. The passcode alone says who signs in (no user name field). Sign-in lands on "Your day" with the barber's name at the top; a colleague's day is one tap. The first barber may keep using the old
ADMIN_PASSCODE. - Block time: Only me, or Whole shop. "Only me" is the default. A personal day off hides only that barber's times; a whole-shop block hides everyone's and lists every booking it covers, with the barber's name.
- Safe upgrade. A Loop 002 data file is upgraded on start in one transaction: old bookings go to the first barber, old blocks stay whole-shop. Startup stops with a clear message if a barber has no passcode, two share one, or upcoming bookings belong to a barber who was removed from the list.
Screenshots (Chromium, 390 px, real app)
Checks
| Command | Result | Notes |
|---|---|---|
npm run check (before building) | passed | Loop 002 review: 56/56 tests. |
npm run test:e2e (before building) | passed | Loop 002 review: 5/5 in Chromium. |
npm run format:check, npm run lint, npm run typecheck | passed | Zero warnings. The first lint run found 6 errors in new code (test style, one needless Number()); fixed. |
npm test | passed | 88/88 (32 new in test/barbers.test.ts): config and passcode validation, per-barber hours, personal and shop blocks, union of free times, assignment order, upgrade of a Loop 002 file, startup refusals, HTTP booking with each barber and No preference, a race of three clients for two barbers, sign-in per barber, cross-site and signed-out refusals, logs without names. |
npm run test:e2e | passed | 7/7 in Chromium at 390×844. The 5 earlier tests run on a one-barber shop (unchanged behaviour). 2 new tests on the two-barber shop.config.json, one with JavaScript disabled. |
lint_diagrams | passed | 6 diagrams in ARCHITECTURE.md and PRODUCT.md. A first ER diagram was flagged by the line-based checker and redrawn as a flowchart. |
| GitHub Actions CI | not run | No remote; the owner said never push. |
What is left
- The owner confirms or changes every assumed choice, including the real barber names and ids, the second barber's hours, the No preference rule and equal rights for both barbers (D21–D31), and the earlier D1–D20.
- Moving a booking to another barber is not built: call, cancel, rebook.
- Clients are still not told when a block or a barber cancel affects them (no messages).
- Not hosted, and CI has never run. Back up the data file before the first start of this version.
- No automated accessibility scan; 7 moderate dev-only
npm auditadvisories in the lint toolchain.