Repository navigation
Description
Needs your OK: this decides what the per-person limit counts, what the setting is called, who counts as one person, how a sign-up over the limit is refused, and what participants read when it is. Nobody using the app meets the limit until #315 or #317 lets organizers set it. Swap pipeline:proposed for pipeline:ready to have it built.
Part of #312.
What happens
- Nothing enforces the limit.
SignupSettingsSchemainsrc/schemas/signups.tshasmaxCommitmentsPerParticipant, an optional positive whole number. Nothing reads it.commitParticipantToSlot(behindcommitToSlot) andupdateOwnCommitmentinsrc/services/commitments.tsnever check it, so one email address can take every spot on a signup. - Nothing sets it either. The web app has no control. The AI connector refuses it and hides it (
UNREAD_SETTINGSinsrc/mcp/tools/signups-read.ts, from fix(mcp): stop offering a per-person limit that nothing enforces #318 and Refuse and hide signup settings nothing reads in the MCP tools #353). Only the REST API still stores it (POST /api/signups,PATCH /api/signups/[id]), and that was never documented. - The name counts the wrong thing. Since Call the quantity field Spots and cap it at the spots left #291 one sign-up can hold several spots. A limit of 2 sign-ups would still let one person take 5 spots on one slot.
- A race that exists today. Two first sign-ups from the same new email, on different slots, at the same moment: each request locks only its own slot, neither finds a participant, and both insert one. The second insert hits the
participants_signup_emailunique index. Nothing catches that, sohandle()insrc/lib/api-response.tsreturns a 500. A per-person count has the same gap, because it must lock the person's row before counting. - Since Let organizers make the participant email optional #378, some people have no email. Each sign-up without an email gets a participant of its own, so there is nothing to count it against. A move keeps its participant (Keep the same participant when someone moves to another slot #379).
- The participant is found without a lock.
commitParticipantToSlotfinds an existing participant with a plain select and renames them only after every check has passed, so nothing is written for a refused sign-up. A count made after that select would not be under a lock. - The participant pages have no words for this refusal.
participantErrorCopy(src/app/s/[slug]/participant-error.ts) words everyconflictthroughconflictMessage. On the sign-up sheet that always says "You're already signed up for this slot.", and on the edit page "This spot can't be changed any more." Neither is true of a limit refusal. Letting the refusal fall through instead gets the sheet's generic "Something went wrong, so you're not signed up yet. Try again."
Fix, in outline
- The setting. Rename it
maxSpotsPerParticipant, still an optional positive whole number. Add a reader next torequiresEmailinsrc/schemas/signups.ts,spotsPerParticipantLimit(settings), that returns the limit or null, and null for settings that fail to parse. - What counts. The sum of
quantityover that participant's sign-ups in this signup that hold a place (holdsPlace: confirmed or tentative). Cancelled, moved and organizer-removed sign-ups don't count.remainingis the limit less that sum, never below 0. - Signing up and moving (
commitParticipantToSlot), when a limit is set:- Lock the person. The select that finds an existing participant by email takes
for no key update(the locklockSignupForWriteexplains), so the row stays locked to the end. It is the same statement, so it costs no query. A move passes itsparticipantId: select that row the same way. The move's old sign-up is already cancelled in the same transaction, so the count leaves it out. - Check, after the capacity check. Count the person's spots and refuse when the spots asked for are more than
remaining. A new participant holds nothing, so theirremainingis the limit and no count is needed.
- Lock the person. The select that finds an existing participant by email takes
- A new participant, limit or not. Insert with
on conflict (signup_id, email_lower) do nothing returning id. If no row comes back, another request made this participant meanwhile, on another slot. Find that row as an existing one is found (locked when a limit is set), then carry on as for an existing one. Writeparticipant.createdonly when the insert made the row. This also fixes the 500 above. - Raising the quantity in
updateOwnCommitment(same slot): after the slot and commitment locks, lock the participant and count everything except this sign-up.remainingthere is the most this sign-up may hold, ascapacity_full'sremainingis on that path. - Lock order. The participant comes last on every path: slot then participant when signing up; slot, commitment, participant when raising; old commitment, new slot, participant when moving. Add the participant to the lock-order note above
lockSignupForWriteinsrc/services/locks.ts. - The edit page's maximum.
editLimitsForCommitmentalso capsmaxQuantityat the limit less the spots the person's other sign-ups hold. Pass it the commitment'sparticipantId, which the edit page already has fromgetOwnCommitment. The closed case stays as it is. - The refusal.
conflict, withdetails: { reason: 'spots_per_participant', limit, remaining }, an Englishmessagefor API callers such as "You can take up to 2 spots on this signup.", and a suggestion. Addspots_per_participanttoErrorReasoninsrc/lib/errors.ts, documented in the list above the type as the others are. Don't usecapacity_full:capacityMessageand the commit dialog read itsdetails.remainingas the slot's spots left. - Its words, on both participant pages. A
limitMessageinsrc/app/s/[slug]/limit-message.ts, besidecapacityMessage, picked by code anddetails.reasonand built fromdetails.limitanddetails.remaining.participantErrorCopyasks it beforeconflictMessage, so aconflictwithout that reason still reads as it does now. Addlimitto itsApiErrorLike. New messages go underparticipant.errors.limitinsrc/messages/en.json, with ICU plurals written as thecapacitymessages write theirs:- Sign-up sheet, none left: "One person can take up to 2 spots on this signup, and you already have that many." Suggestion: "To take this one, give back or cancel a spot using the link in your confirmation email."
- Sign-up sheet, some left: "You can take 1 more spot on this signup." Suggestion: the existing "Ask for 1 instead." or "Ask for 3 or fewer." (
capacity.askForOne,capacity.askForOrFewer). - Edit page, raising the number of spots: with
remainingof 1 or less, "One person can take up to 2 spots on this signup, so you can't add more here." and "Keep the number you have." (keepNumber). Otherwise "One person can take up to 4 spots on this signup, so you can have at most 3 here." and "Ask for 3 or fewer." - Swedish in the same PR. Translate them with the
translateskill (.claude/skills/translate/SKILL.md, participant audience), mark them, and commit the rewrittensrc/messages/en.d.json.ts.
- Telemetry. Record the refusal with
safeRecordAttemptFailed, or the move'sonRefused, with reasonspots_per_participant,requestedandremaining. Add the reason to thecommitment.attempt_failedrow indocs/telemetry.md. - The connector. Rename the key in
UNREAD_SETTINGS, soupdate_signupstill refuses it and results still hide it. Reword the comment above it, and the one aboveSparseSettingsSchemainsrc/mcp/tools/signups-write.ts, which both name the old key: the setting is read now, but stays hidden until The AI connector can't set or show the per-person spot limit #317 gives it back.
Watch for
-
Tests that use the old name. Rename the key and keep the cases:
- the sparse-merge tests in
src/services/signups.db.test.ts; src/mcp/tools/signups-write.test.ts,src/mcp/tools/read.test.tsandsrc/mcp/tools.db.test.ts;- the edit link's "none of the signup's other settings" tests in
src/services/commitments.db.test.tsandsrc/app/api/commitments/[id]/route.db.test.ts. They set the key on a signup and check the answer never names it, so rename it in their settings and in their regex, or they stop checking the setting stays private.
UNREAD_SETTINGSusessatisfies, so typecheck fails until it is renamed there too. - the sparse-merge tests in
-
The query budget.
budgets.jsoncapsPOST /api/slots/[id]/commitmentsat 14 statements, and 12 without an email. The budget test's signups have no limit, and with no limit the sign-up must send no extra statement. The insert withon conflictis still one. -
The idempotent retry returns the first sign-up before any check. Keep it first: the first try got through.
-
slotStateAfterCanceldecides whether a cancelled sign-up's page suggests signing up again. It doesn't know the person, so with a limit set it can suggest a sign-up that is then refused. Leave it, and say so in its comment. -
The commit dialog rewrites a slot's spots left only from
capacity_full(commit-dialog.tsx). Keep it that way, so a limit refusal never changes what the slot shows. -
No link to their sign-ups in the refusal.
conflict-message.tssays why: anyone who knows an email address could then take over that person's spot. Update its comment, which says aconflicton the sign-up sheet always means the same email already holds this slot. -
Signing up for a second slot with the same email and a new name renames the earlier sign-up too #847 (ready) gives each sign-up its own name, and changes the same participant lookup, rename and commitment insert in
commitParticipantToSlot. Whichever lands second has a merge there. -
Translate OpenSignup into German, not switched on yet #1060 (open PR) adds a German catalog that isn't switched on yet. If it merges first, translate the new messages into German too, as
docs/translating.mdasks of a language with a catalog that hasn't shipped. -
Organizers can only remove people (Organizers can remove one person from a slot #377), not add them. If adding is built later, it should use this check.
-
CHANGELOG line, for the REST setting's new name and the new
details.reason.
Choices this makes
- Count spots, not sign-ups. Default: spots, the sum of
quantity. Since Call the quantity field Spots and cap it at the spots left #291 a count of sign-ups doesn't limit what people take. - Rename to
maxSpotsPerParticipant. Default: rename. Values saved under the old name, by the connector before fix(mcp): stop offering a per-person limit that nothing enforces #318 or through the REST API, are then never enforced, so nobody is refused by a limit an organizer set weeks ago and forgot. The schema drops unknown keys, so the old key leaves a row at its next settings save. No migration. - One person is one participant. One email address on this signup, in any case. Default: accept what follows. Someone using two addresses gets two allowances. A parent who signs up two children with one address shares one allowance between them. Addresses aren't checked, so a sign-up under someone else's address counts against theirs. Someone who leaves an optional email blank is a new person each time, so the limit only caps that one sign-up's spots. The help page in Organizers can't set a per-person spot limit in the web app #315 says so.
conflictwith adetails.reason, not a new code. Default as above. The codes are a closed enum shared with the REST API and the connector.- Say how many spots they have left. Default: yes, in
details.remainingand in the sign-up sheet's words, because without it the person can't fix the request. It tells anyone who types an address how many spots that address holds on this signup. Accepted, because the same-slot refusal already tells them that an address holds a slot. - This PR words the refusal. Default: yes, on both participant pages, in English and Swedish, so a limit set through the REST API never reaches a participant as "Something went wrong". Participants aren't told about a signup's per-person spot limit until they're refused #316 then only tells people about the limit before they meet it.
- The words. Default: the messages above.
- Hidden from the connector until The AI connector can't set or show the per-person spot limit #317. Default: yes, so this change alone shows organizers nothing new.
Done when
- DB tests in
src/services/commitments.db.test.ts:- a sign-up within the limit succeeds; one over it is refused with
conflictanddetails.reason, writes only the attempt_failed row, and leaves the participant's name alone details.limitanddetails.remainingare right for a first sign-up, a returning one, a raised quantity and a movePat@example.comandpat@example.comcount as one person- a cancelled, moved or organizer-removed sign-up frees its spots
- raising a quantity and moving to another slot are both checked
editLimitsForCommitmentis capped by the person's spots left- two sign-ups by one person on different slots at once, with a limit that allows only one: exactly one succeeds. Hold the first open with
untilServiceBlockedOn(src/services/testing/locks.ts), notPromise.all. Cover someone who has signed up before and a first sign-up - with no limit, two first sign-ups from one email on different slots both succeed under one participant (this fails on main today)
- a value stored under the old name limits nothing
- with no limit set, nothing else changes
- a sign-up within the limit succeeds; one over it is refused with
- Unit tests:
limit-message.test.tspins each form in English and Swedish;participant-error.test.ts: a limit refusal gets that copy on the sign-up sheet and the edit page, and aconflictwithout a reason still reads "You're already signed up for this slot.";commit-dialog.test.tsx: a limit refusal leaves the slot's spots left alone.
pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm testandpnpm test:dbpass, withbudgets.jsonunchanged.
Rewritten from the original issue for the pipeline, and checked against src/services/commitments.ts, src/services/locks.ts, src/schemas/signups.ts, src/db/schema/participants.ts, src/app/s/[slug]/conflict-message.ts and src/mcp/tools/signups-read.ts on main at 2d4fdfe. https://claude.ai/code/session_016YZ9SUWWJa1udHCjU5fUma
Revised against main at d8787e9: adds a spots_per_participant reason and words the refusal on both participant pages here (moved from #316), lists the edit-link tests that use the old key, and records the privacy trade-off of details.remaining. https://claude.ai/code/session_016YZ9SVTB9qLweVn9KzZpdf
Activity
[-]Enforce the per-person spot limit when someone signs up or changes their sign-up[/-][+]Sign-ups never check the per-person spot limit, so one person can take every spot[/+]richshaw commentedon Nov 18, 2026
Revised the brief against
mainat d8787e9 so it can be approved as written:conflictMessagewould have shown "Something went wrong" on the sign-up sheet and "This spot can't be changed any more" on the edit page. The brief addsspots_per_participanttoErrorReason, and alimitMessagebesidecapacityMessagethat words it on both pages, in English and Swedish. The words were Participants aren't told about a signup's per-person spot limit until they're refused #316's; they move here so this PR ships complete, and Participants aren't told about a signup's per-person spot limit until they're refused #316 now only tells people about the limit up front.remaininghas one meaning on each page. On the sign-up sheet it's the spots the person can still take; on the edit page it's the most this sign-up can hold, ascapacity_fullalready works there. The "over the limit on its own" shortcut now applies only to a new participant, so the number is never a guess.commitments.db.test.tsandsrc/app/api/commitments/[id]/route.db.test.tsset it and check it never leaks. They're listed, regex included.details.remainingtells anyone who types an address how many spots it holds. Default is to accept that, since the same-slot refusal already reveals that an address holds a slot. "One person" now also notes that a parent signing up two children with one address shares one allowance.https://claude.ai/code/session_016YZ9SVTB9qLweVn9KzZpdf
Generated by Claude Code