Skip to content

Sign-ups never check the per-person spot limit, so one person can take every spot #313

Open

Description

@richshaw

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. SignupSettingsSchema in src/schemas/signups.ts has maxCommitmentsPerParticipant, an optional positive whole number. Nothing reads it. commitParticipantToSlot (behind commitToSlot) and updateOwnCommitment in src/services/commitments.ts never 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_SETTINGS in src/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_email unique index. Nothing catches that, so handle() in src/lib/api-response.ts returns 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. commitParticipantToSlot finds 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 every conflict through conflictMessage. 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 to requiresEmail in src/schemas/signups.ts, spotsPerParticipantLimit(settings), that returns the limit or null, and null for settings that fail to parse.
  • What counts. The sum of quantity over 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. remaining is 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 lock lockSignupForWrite explains), so the row stays locked to the end. It is the same statement, so it costs no query. A move passes its participantId: 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 their remaining is the limit and no count is needed.
  • 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. Write participant.created only 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. remaining there is the most this sign-up may hold, as capacity_full's remaining is 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 lockSignupForWrite in src/services/locks.ts.
  • The edit page's maximum. editLimitsForCommitment also caps maxQuantity at the limit less the spots the person's other sign-ups hold. Pass it the commitment's participantId, which the edit page already has from getOwnCommitment. The closed case stays as it is.
  • The refusal. conflict, with details: { reason: 'spots_per_participant', limit, remaining }, an English message for API callers such as "You can take up to 2 spots on this signup.", and a suggestion. Add spots_per_participant to ErrorReason in src/lib/errors.ts, documented in the list above the type as the others are. Don't use capacity_full: capacityMessage and the commit dialog read its details.remaining as the slot's spots left.
  • Its words, on both participant pages. A limitMessage in src/app/s/[slug]/limit-message.ts, beside capacityMessage, picked by code and details.reason and built from details.limit and details.remaining. participantErrorCopy asks it before conflictMessage, so a conflict without that reason still reads as it does now. Add limit to its ApiErrorLike. New messages go under participant.errors.limit in src/messages/en.json, with ICU plurals written as the capacity messages 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 remaining of 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 translate skill (.claude/skills/translate/SKILL.md, participant audience), mark them, and commit the rewritten src/messages/en.d.json.ts.
  • Telemetry. Record the refusal with safeRecordAttemptFailed, or the move's onRefused, with reason spots_per_participant, requested and remaining. Add the reason to the commitment.attempt_failed row in docs/telemetry.md.
  • The connector. Rename the key in UNREAD_SETTINGS, so update_signup still refuses it and results still hide it. Reword the comment above it, and the one above SparseSettingsSchema in src/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.ts and src/mcp/tools.db.test.ts;
    • the edit link's "none of the signup's other settings" tests in src/services/commitments.db.test.ts and src/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_SETTINGS uses satisfies, so typecheck fails until it is renamed there too.

  • The query budget. budgets.json caps POST /api/slots/[id]/commitments at 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 with on conflict is still one.

  • The idempotent retry returns the first sign-up before any check. Keep it first: the first try got through.

  • slotStateAfterCancel decides 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.ts says why: anyone who knows an email address could then take over that person's spot. Update its comment, which says a conflict on 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.md asks 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.
  • conflict with a details.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.remaining and 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 conflict and details.reason, writes only the attempt_failed row, and leaves the participant's name alone
    • details.limit and details.remaining are right for a first sign-up, a returning one, a raised quantity and a move
    • Pat@example.com and pat@example.com count 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
    • editLimitsForCommitment is 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), not Promise.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
  • Unit tests:
    • limit-message.test.ts pins 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 a conflict without 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 test and pnpm test:db pass, with budgets.json unchanged.

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

  1. added
    enhancement
    on Sep 27, 2026
  2. changed the title [-]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[/+] on Oct 30, 2026
  3. added
    pipeline:ux
    on Oct 30, 2026
  4. richshaw commented on Nov 18, 2026

    @richshaw
    OwnerAuthor

    Revised the brief against main at d8787e9 so it can be approved as written:

    https://claude.ai/code/session_016YZ9SVTB9qLweVn9KzZpdf


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpipeline:proposedpipeline:ux

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions