Skip to content

Authenticated override for availability / min-notice on create and reschedule #270

Open

Description

@portfoliomanufaktur

validateBookingTime and validateRescheduleTime enforce min notice, max future days and the host's availability windows for every caller. For anonymous bookers that is right.

Request: an opt-in flag for authenticated host/admin requests (e.g. "skip_availability": true on POST /v1/bookings and PATCH /v1/bookings/{id}/reschedule) that skips those three checks. The atomic double-booking check stays in place.

Use case: one-off appointments agreed by phone outside regular hours, which still need the calendar event, video link and confirmation mail.

Happy to send a PR if the direction is fine.

Activity

  1. pullfrog commented on Nov 23, 2026

    @pullfrog
    Contributor
  2. shockalotti commented on Nov 23, 2026

    @shockalotti
    Contributor

    Thanks — the capability is right, the shape isn't yet. I'd take this, but not as a caller-controlled boolean on a public endpoint.

    The problem with skip_availability: true as proposed

    POST /v1/bookings accepts an API key or an OAuth token, and both authenticate as a workspace user — including ordinary members. So the flag would let any member book outside every host's hours, with nothing recorded about who did it. On a single-operator instance that costs nothing; on a team it's a silent way around the availability rules the team agreed on, and it's very hard to walk back once people rely on it.

    What I'd accept as a first slice

    1. Owner/admin only. A member sending the flag gets a 403, even though they're authenticated. If you're the only user, you'll never notice the restriction.
    2. Log it. The booking records that availability was bypassed and by whom. Otherwise "why does this meeting exist at 22:00?" has no answer six months later.
    3. Keep the double-booking check, exactly as you said — this skips min-notice, max-future and availability windows, never the conflict check.
    4. Decide reschedule explicitly, which is the part most likely to get missed. A booking created outside hours has to either accept the same flag when it's moved, or be refused with a clear message. Silently failing to reschedule it would be confusing, and silently allowing it would leak the bypass into a second endpoint.

    The framing I'd use

    This isn't "skip validation" — it's "create a booking the public calendar would never have offered". That's an admin action with an audit trail, not a request parameter anyone can set. Same flag, different contract, and it's the contract that makes it safe.

    One question before you start

    How do you call the API today — an owner API key, or a member account? That determines whether the admin-only gate needs a separate admin endpoint or can stay a field on POST /v1/bookings.

    Worth noting: availability overrides already exist and can open a specific date, but they mutate the public availability, so they don't substitute for this — they'd expose the widened hours to everyone. Your use case is genuinely different.

    If that shape works for you, say so and I'll write it up as the spec in this issue so the PR is measured against it rather than against the original wording.

  3. portfoliomanufaktur commented on Nov 24, 2026

    @portfoliomanufaktur
    ContributorAuthor
  4. portfoliomanufaktur commented on Nov 24, 2026

    @portfoliomanufaktur
    ContributorAuthor

    That shape works for me: owner/admin only, logged, and the conflict check stays. For reschedule I'd prefer the same flag under the same gate, since moving such a booking from the CRM is part of the use case; a clear refusal without the flag is fine.

    To your question: I call the API with an owner API key. I'm the only user on this instance, so there is no member account involved, and a field on POST /v1/bookings would be enough for me.

    Please go ahead and write it up as the spec.

  5. shockalotti commented on Nov 27, 2026

    @shockalotti
    Contributor

    Spec: skip_availability for owner/admin bookings

    Agreed shape, written down so a PR can be measured against it. This is the first slice only.

    Request surface

    • POST /v1/bookings — new optional boolean skip_availability, default false.
    • The reschedule endpoint — the same field, same gate, same meaning.
    • MCP create_booking — same field, so the two paths do not diverge (they already share createBookingForSlug).

    Who may use it

    Owner or admin only. A member sending it gets 403, not 400: they are authenticated and allowed to call the endpoint, just not to skip availability. Silent ignore is not acceptable — it would create the booking and look like it worked.

    What it skips, and what it does not

    Skips, for this request only:

    • minimum notice
    • maximum future days
    • the host's availability windows (weekly rules and date overrides)

    Does not skip:

    • the atomic double-booking / overlap check in booking.Service.Create — unchanged, still the last word
    • host resolution, required/optional host rules, calendar busy checks, questions, payment

    Implementation constraint

    The bypass is a parameter threaded through validateBookingTime / validateRescheduleTime, not a second code path. Those functions already take the routing mode and pools; adding one argument keeps every caller honest and stops a future entry point from forgetting the flag. A parallel "skip" function would drift within a release.

    Audit

    The booking must record that availability was bypassed and by whom. One column is enough:

    bookings.availability_override_by TEXT NOT NULL DEFAULT ''   -- user id; '' = no bypass
    

    Presence implies the bypass; the value names the actor; created_at already dates it. Written in the same insert as the booking, so it cannot drift from the fact it describes.

    Without this, "why does this meeting exist at 22:00?" has no answer six months later.

    Reschedule

    • Rescheduling a booking created with the override, without the flag → refuse with a clear, specific message ("this booking was created outside availability; resend with skip_availability"). Not a generic slot error, and not a silent success.
    • With the flag and the right role → allowed, and it rewrites availability_override_by to the actor doing the move.

    Not in this slice

    • Any UI control. The public booking page never sends it; an admin control can come later.
    • Bypassing the conflict check, ever.
    • Retroactive editing of ordinary bookings.

    Tests that matter

    1. Member + flag → 403, no booking created.
    2. Owner + flag, outside hours → 201, booking exists, availability_override_by set.
    3. Owner + flag, overlapping an existing booking → still rejected (conflict check intact).
    4. Owner without the flag, outside hours → existing refusal, unchanged.
    5. Reschedule of an override booking without the flag → specific refusal; with the flag → succeeds.

    Two notes from the report that shaped this

    • The reporter calls the API with an owner API key and is the only user, so the role gate costs him nothing.
    • Availability overrides already exist but mutate public availability, so they would expose the widened hours to everyone. They are not a substitute, which is why this is a separate mechanism.
  6. portfoliomanufaktur commented on Nov 28, 2026

    @portfoliomanufaktur
    ContributorAuthor

    Thanks, this matches our use case (owner API key, single user), and keeping the overlap check as the last word is exactly right.

    One question on reschedule: our bookings go out with the normal reschedule link. If a booking was created with skip_availability and the guest later uses the public reschedule page to move it into a regular, available slot, would that be refused as well? For us the ideal behaviour would be: moving into a slot that passes normal validation works without the flag and clears availability_override_by; only moving to a time outside availability needs the flag and the role.

    Calendar busy checks staying in place is fine for us.

  7. shockalotti commented on Nov 30, 2026

    @shockalotti
    Contributor

    Good catch — that's a flaw in the spec above, and your rule is better. Amending the reschedule section:

    The gate depends on the target time, not on the booking's history.

    • Moving an override-created booking into a time that passes normal validation → allowed without the flag, by anyone holding a valid reschedule link, and availability_override_by is cleared.
    • Moving it to a time outside availability → needs skip_availability plus the owner/admin role, same as creation.
    • With the flag and the role → allowed, and availability_override_by is rewritten to the actor doing the move.

    This is simpler than what I wrote, and it means the column answers "where does this booking currently sit" rather than "where was it first placed".

    The trade-off, stated plainly: clearing it on a normal move loses the record that the booking originated outside availability. If someone later asks "why was this booked at 22:00 back in March", the answer is gone once the guest has moved it. I think that's the right trade for a first slice — the column describes the current placement, and a proper audit log is the honest way to keep origin history if we ever need it. Say if you'd rather keep origin, because that changes the shape (two fields, not one).

    Updated test list:

    1. Member + flag on create → 403, no booking created.
    2. Owner + flag outside hours → 201, booking exists, availability_override_by set.
    3. Owner + flag, overlapping an existing booking → still rejected (conflict check intact).
    4. Owner without the flag, outside hours → existing refusal, unchanged.
    5. Guest reschedules an override booking into an available slot without the flag → succeeds, availability_override_by cleared.
    6. Reschedule of an override booking to an unavailable time without the flag → specific refusal, not a generic slot error.
    7. Reschedule with the flag and owner role to an unavailable time → succeeds, actor recorded.
  8. portfoliomanufaktur commented on Dec 1, 2026

    @portfoliomanufaktur
    ContributorAuthor

    That works for me, and one field is enough. I don't need origin history in Calnode: my CRM keeps its own audit trail per appointment and gets every reschedule via webhook, so "where does this booking currently sit" is exactly the right meaning for the column. The test list covers my cases.

    One sequencing question, following your note in #269: if POST /v1/bookings doesn't read credentials today, the owner/admin check for skip_availability on REST depends on the same optional-auth work as internal. Is that the plan, i.e. this lands on MCP create_booking first and on REST together with step 2 of #269?

  9. shockalotti commented on Dec 1, 2026

    @shockalotti
    Contributor

    Yes — your read is right, and it's worth being explicit because it affects when you can start.

    On REST, "is this caller owner/admin" requires knowing who the caller is, and POST /v1/bookings currently doesn't look at credentials at all. So skip_availability on REST depends on exactly the same optional-auth work as internal. Neither can land on REST before it.

    The plan:

    1. MCP create_booking first. MCP already authenticates and already carries the caller's role, so the owner/admin check there needs no new plumbing — just the flag and the role gate on top of the validation parameter. That means the feature is usable and tested before the REST middleware exists.
    2. REST with optional auth, together with step 2 of Internal event types: bookable via authenticated API, hidden from public pages #269. Same middleware serves both features, which is the main argument for doing them in one pass rather than two.

    Nothing else about your spec changes: one column, clearance on a normal reschedule, conflict check untouched, specific refusal when the flag is missing on an unavailable target.

    Practical upshot for you: if you want to send a PR, start with the MCP path. It is small, it exercises the whole spec (owner gate, availability_override_by, the reschedule rule through reschedule_booking), and it doesn't touch the public endpoint. The REST half can follow once the middleware is designed and reviewed — and if you get the MCP half in first, the REST half becomes a thin addition rather than a rewrite.

  10. shockalotti commented on Dec 1, 2026

    @shockalotti
    Contributor

    Decision: yes please — go ahead with a PR for the MCP half only. The spec comment above is the acceptance criteria, not a sketch, so if anything in it looks wrong now is the moment to say so.

    Scope, so the PR stays reviewable:

    1. skip_availability on MCP create_booking and reschedule_booking only. No REST, no public booking page, no admin UI.
    2. Owner/admin only. A member sending it is refused and no booking is created.
    3. availability_override_by (nullable, user id) written in the same insert as the booking when the bypass is used. Cleared when a later normal reschedule moves the booking into a valid slot — the column means "where this booking currently sits", as we agreed.
    4. The double-booking / overlap check is untouched. That is the one rule this must never bypass.
    5. Rescheduling such a booking to an unavailable target without the flag gets a specific refusal, not a generic slot error.
    6. Tests: the seven cases in the amendment, as far as they are reachable without REST.

    Two practical notes:

    • Migration number: take the next free number above the highest already on main — numbers are assigned by open order and goose refuses to boot if a migration lands below the highest merged. Check ls internal/db/migrations/ against origin/main at the moment you branch, not when you started reading this. 00075 is taken by the visibility change currently in review.
    • created_by: not yours. That arrives with the authenticated-REST work (Internal event types: bookable via authenticated API, hidden from public pages #269 step 2), so keep this PR to the one column.

    What I'll do at review: read the diff against the six points above, run the full suite, and exercise it on a real instance — owner with the flag outside hours, member refused, overlap still rejected, and the reschedule clearance. If it does what the spec says, I'll say so plainly.

    If you'd rather land it in two commits (create path, then reschedule) so each is reviewable on its own, that works too — say which you prefer when you open it.

  11. shockalotti commented on Dec 1, 2026

    @shockalotti
    Contributor

    Amending the go-ahead with the project's conditions. One correction to what I said above, because I got it wrong: do not pick the migration number yourself. Numbers are assigned by the PRs agent at open time, and the open queue currently holds 00075–00078. My earlier "take the next free above main" would have had you collide. Leave it out of the first commit, or use a placeholder, and ask for the number when you open — you'll get the next free one.

    The rest, as acceptance criteria:

    1. MCP only. create_booking and reschedule_booking. No REST, no public endpoint, no admin UI — REST waits for Internal event types: bookable via authenticated API, hidden from public pages #269 step 2.
    2. It skips the availability and slot checks only. The conflict check is untouched: a booking that collides with an existing one still fails even with the flag. Please include an explicit test that an override request which conflicts is still refused — that is the test most likely to be forgotten and the failure most expensive to ship.
    3. The owner/admin gate comes from the MCP caller's identity, checked server-side. Never from a request field. A payload asserting its own privilege must not be able to grant it.
    4. availability_override_by records the acting user, not a reason. Two questions so the column doesn't drift into something it isn't:
      • Do you also store a timestamp, or is bookings.created_at sufficient? If you store one, say what it means — when the override was used, not when the booking was created.
      • It must not become a free-text note field. If you want an operator comment, that is a different column and a different conversation.
    5. Refusal must be explicit. A non-owner sending skip_availability is rejected, not silently ignored — a silent ignore creates the booking and looks like it worked.

    Everything else from the spec above stands: one column, clearance on a normal reschedule, specific refusal when the flag is missing on an unavailable target.

    On process: this stays your PR. If it stalls or drifts from the spec, it goes to an in-house dev agent rather than being quietly patched by whoever is reviewing — so if you hit something ambiguous, ask in the PR rather than guessing. Reviews on it will be against these points, and I'll exercise it on a real instance before it merges.

  12. shockalotti commented on Dec 1, 2026

    @shockalotti
    Contributor

    Correction on two points — PRs is right and I was wrong, so please use this rather than what I said above.

    Migration number: 00080. Ignore my "take the next free above main" line. Numbers are assigned by the PRs agent against the open queue, not against main, because a lower number landing after a higher one leaves a gap and goose refuses to boot. The queue right now is 00075 #281, 00076 #283, 00077 #285, 00078 #286, 00079 #287 — so #270 is 00080. Use that, and don't merge before those land.

    availability_override_by is in scope for this PR, not deferred. I said "keep this to the one column" meaning created_by — my phrasing was ambiguous. To be explicit:

    Still the test I will look for first: with skip_availability on, a booking that collides with an existing one is still refused. Everything else in the list stands.

  13. shockalotti commented on Dec 1, 2026

    @shockalotti
    Contributor

    Final test set — this supersedes the earlier list. Six cases, and they're what review will run against:

    1. Create, conflict refusal. create_booking with skip_availability on a time that collides with an existing booking → refused, no row created.
    2. Reschedule, conflict refusal. The same on reschedule_booking. Separate path, so it gets its own test — a reschedule could bypass a check the create path enforces.
    3. Unauthorised refusal. A caller who is not owner or admin sends skip_availability → explicitly rejected, no booking created. Not silently ignored.
    4. Authorised success is recorded. An authorised override that succeeds leaves availability_override_by set to the acting user.
    5. Reschedule to an unavailable target without the flag → specific refusal, not a generic slot error.
    6. Normal reschedule clears it. A reschedule into a valid slot without the flag succeeds and clears availability_override_by.

    Why 4 and 6 matter as much as the refusals: the failure modes are symmetric. If the flag is silently ignored, a booking gets created that should not have been. If it's silently accepted and dropped on the way to the insert, the override happens but nothing records who did it — and tests 1-3 and 5 all still pass, because they only check refusals. Test 4 is the one that catches it.

  14. portfoliomanufaktur commented on Dec 1, 2026

    @portfoliomanufaktur
    ContributorAuthor

    Thanks for the clear spec. Confirming before I start:

    • Scope: MCP create_booking and reschedule_booking only, owner/admin gate from the MCP caller's identity checked server-side, explicit refusal for anyone else, overlap check untouched.
    • Migration 00080, and the PR won't merge before 00075–00079 land.
    • The six tests from your final list, including the conflict refusal on both create and reschedule, and test 4 checking that availability_override_by is actually written.

    On your question about a timestamp: no separate timestamp from my side. One column holding the acting user is enough for my case, and the CRM records when it requested an override on its own side. created_at would not cover an override used on a later reschedule, so if you want that visible in Calnode itself, I'd suggest a separate availability_override_at meaning "when the override was last used". I'm happy to leave it out to keep the PR to one column.

    I'll open it as two commits (create path, then reschedule) and ask in the PR if anything is ambiguous.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions