Skip to content

feat(invites): invite_delivery 'none' for integrations that send their own invite - #158

Merged
shockalotti merged 3 commits into
Calnode:mainfrom
raccoder-com:feat/invite-delivery-none
Oct 29, 2026
Merged

shockalotti merged 3 commits into
Calnode:mainfrom
raccoder-com:feat/invite-delivery-none

Conversation

@raccoder-com

Copy link
Copy Markdown
Contributor

Problem

We run Calnode with Microsoft 365 calendars and deliberately without Calnode email (no SMTP, no Resend). Our own system polls GET /v1/bookings?scope=all and sends the booker its own confirmation with its own .ics. That is a common shape for anyone embedding Calnode as the scheduling engine behind an existing CRM or mail pipeline.

With the default invite_delivery = 'calendar', the host's Outlook calendar invites the booker, so the booker gets a second message from the host's mailbox whose body is only "Booking ID: " (calendar_event_booking_id). That is the invite the integration wanted to replace.

What we actually want already exists internally: invite_delivery = 'calnode' writes the host events without guests (calendarInvitee returns ""), and with a Noop mailer nothing reaches the booker. But that state is only reachable by editing the database, because switching an event type to calnode is refused unless a sender and a working mailer exist (inviteSenderReady). And an integrator has no way to tell from the booking JSON which channel a booking's invite went out on.

What this changes

A third invite_delivery value, none, shown in the admin UI as Calendar invite → Sent by → No one (you send your own).

  • Host events are guestless, exactly as for calnode (new helper hostEventsGuestless, used by calendarInvitee and applyHostInvite). Google and Microsoft get no attendee, so they email nobody. The reconciler and reassign go through calendarInvitee and follow it without changes.
  • No .ics on any Calnode email to the booker, regardless of the host's calendar (applyInviteDelivery). Note this is stricter than calendar, which attaches Calnode's .ics when the host has no destination calendar.
  • The booker's emails still go out when email is set up, just without an invite. Reasoning: invite_delivery answers "who sends the calendar invite", not "does Calnode email at all". Whether Calnode emails is already decided by the mailer (configured or Noop) and the per-host notification settings. Folding "no email" into this setting would silently switch off reminders and reschedule notices for anyone who has email configured and only wants to own the invite. Operators who want silence keep the no-mailer setup.
  • Host copies behave as for calnode: the booker is left out of the host's .ics and it goes out as PUBLISH, so the host's calendar client never holds the booker as a guest it could re-invite.
  • No sender or mailer is required to select none. The inviteSenderReady check stays on calnode only.
  • Stored per booking like the other two modes. Reschedule, cancel, reassign and the reconciler read the booking's mode, so switching the event type later does not change how existing bookings are updated.

invite_delivery on bookings and webhooks

  • The booking JSON now includes invite_delivery (calendar, calnode or none): GET /v1/bookings, GET /v1/bookings/{id}, the create/reschedule/reassign responses and the MCP tools, which all go through toBookingJSON. It is always present (the column is NOT NULL), with a jsonschema description for MCP.
  • Webhooks can select invite_delivery as a payload field (filled in enrich from the booking row, so every event type carries it without touching each Enqueue call). It is not in defaultFields, because that set is documented as reproducing the original payload and every booking has a value, so adding it there would change every unconfigured webhook. The field is listed in the admin webhooks page.

Naming

none because the column answers "who sends the invite", and the existing values name the sender (calendar, calnode). The answer here is nobody, from Calnode's side. none is also the schema's existing "nothing happened" sentinel (payment_status = 'none', 00037). I considered external, but it implies Calnode knows about or coordinates another sender, which it does not.

Migration notes (00071)

00068 declared the allowed values as a column CHECK, on both event_types and bookings, and SQLite cannot alter a CHECK.

I looked at the precedents before choosing:

  • 00042 rebuilt event_types to widen location_type, with -- +goose NO TRANSACTION and PRAGMA foreign_keys=OFF, because a DROP TABLE with foreign keys on cascades into the children.
  • 00037 explicitly avoided rebuilding bookings for a new status value and added a separate column instead.
  • 00014 / 00063 rebuilt only leaf tables inside the normal transaction.

A rebuild of bookings would have to carry its 23 columns verbatim, recreate five indexes including the double-booking guard idx_bookings_no_double, keep five child tables' foreign keys intact, and run outside a transaction with foreign keys off. There is no precedent for that, and a slip there fails silently. A separate flag column (00037 style) would work but splits one mode across two columns and needs a mapping layer in every query that reads the mode.

The migration instead swaps the column, per table:

ALTER TABLE bookings ADD COLUMN invite_delivery_new TEXT NOT NULL DEFAULT 'calendar'
    CHECK (invite_delivery_new IN ('calendar', 'calnode', 'none'));
UPDATE bookings SET invite_delivery_new = invite_delivery;
ALTER TABLE bookings DROP COLUMN invite_delivery;
ALTER TABLE bookings RENAME COLUMN invite_delivery_new TO invite_delivery;

DROP COLUMN is allowed because nothing else in the schema references invite_delivery: its only CHECK is its own, and no index, trigger, view or foreign key names it. The repo already relies on DROP COLUMN in the Down steps of 00057, 00064, 00065 and 00069. RENAME COLUMN rewrites the CHECK expression along with the name (checked in sqlite_master after migrating: CHECK (invite_delivery IN ('calendar', 'calnode', 'none'))). All of this runs inside goose's normal per-file transaction with foreign keys on; no PRAGMA toggling, and neither table's indexes or child rows are touched.

Trade-offs to be aware of:

  • DROP COLUMN rewrites the table, so it is O(rows), same order as a rebuild, once at startup.
  • invite_delivery moves to the last column position in both tables. No code uses SELECT * or positional inserts on these tables (sqlc is configured but has no generated package in the tree).
  • Down keeps the widened CHECK (as 00042 does) and maps none back to calnode. An older binary treats anything other than calnode as calendar-sent, so leaving none would make the next reschedule or reconcile invite the booker from the host's calendar. calnode keeps the host events guestless; with email configured, the old binary would then attach Calnode's .ics on later updates.

If you would rather have a 00042-style rebuild, or the 00037-style separate column, I'm happy to switch. The column swap seemed the smallest change that keeps a single, honest stored value.

Tests

New tests follow the existing invite_delivery_internal_test.go fixture:

  • TestInviteDelivery_noneNeedsNoEmail: create with none and PATCH calendar → none both succeed with no sender and a Noop mailer; calnode is still refused there.
  • TestInviteDelivery_noneSendsNoInvite: the Graph/Google-like provider gets the event with no attendee; the booker's confirmation is sent and carries no .ics; the host copy does not name the booker.
  • TestInviteDelivery_noneRescheduleAndCancelSendNoInvite: after switching the event type back to calendar and disconnecting the host's calendar (the case where a calendar-sent booking would get Calnode's .ics), reschedule and cancel emails still carry none.
  • TestInviteDelivery_noneReassignInvitesNobody: the moved event is guestless on the new host's calendar, and the booker's notice has no .ics.
  • TestInviteDelivery_reconcilerHealsWithoutInvitingBooker: now runs for calnode and none.
  • TestInviteDelivery_bookingJSONReportsMode: "invite_delivery":"none" on GET /v1/bookings/{id} and GET /v1/bookings?scope=all.
  • TestMigrate_inviteDeliveryNoneKeepsExistingModes (internal/db): from version 70 with seeded calendar/calnode rows, the migration keeps values, child rows and the double-booking index, accepts none, rejects unknown values, and defaults to calendar.
  • TestMigrate_inviteDeliveryNoneDownKeepsEventsGuestless: Down maps none to calnode.
  • TestBuildData_inviteDeliveryIsOptIn (internal/webhook): selectable, carried when selected, not in the default set.

I checked the new handler tests fail when the none branches in applyInviteDelivery and hostEventsGuestless are removed (4 tests and the reconciler subtest go red).

Results on this branch:

go vet ./...                      ok
go test -count=1 ./...            26 packages ok, 1232 tests passed, 0 failed
cd frontend && pnpm check         0 errors, 0 warnings
cd frontend && pnpm build         ok

pnpm test:visual was not run: nothing under frontend/src/lib/components/ui/**, app.css or the theme changed. I also ran the built binary against a fresh database without email configured: creating a none event type returns 201 (calnode returns 400 as before), a public booking returns and lists "invite_delivery":"none", and in the admin editor the new option renders with its explanation and saves (PATCH 200, stored none).

Docs

  • docs/ARCHITECTURE.md: the "Who sends the invite" paragraph covers none, the 00071 column swap and why it is not a rebuild, and the webhook default set note.
  • README.md: one feature line for the invite sender setting.
  • CHANGELOG.md: two entries under Unreleased / Added.

@pullfrog

pullfrog Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

opencode/space-bunny-free isn't in OpenCode's catalog. Pick another model wherever this repo sets it: the Pullfrog console, the workflow's model input or the PULLFROG_MODEL variable. OpenCode suggests beam-free, deepseek-v4.1-flash-free or flint-40b-free.

OpenCode's response
opencode prompt failed: {"name":"UnknownError","data":{"message":"Unexpected server error. Check server logs for details.","ref":"err_a0351184"}} — likely cause: Model not found: opencode/space-bunny-free. Did you mean: beam-free, deepseek-v4.1-flash-free, flint-40b-free?

Pick another model →

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using space-bunny-free (free)

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@raccoder-com

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Oct 19, 2026
@pullfrog

pullfrog Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Warning

Your OpenCode API key has expired and the model you're configured to use is no longer available.

The last 5 Pullfrog runs on Calnode have all failed, so this review did not happen.

OpenCode returns "This API key has expired" for the key stored on your account, and the model "space-bunny-free" is not in their current catalog. No other provider key matches this model and the Router balance is empty, so there is nothing to fall back on.

To fix it:

  1. Replace your OPENCODE_API_KEY on the BYOK tab of your Billing card with a fresh key from OpenCode.
  2. Choose an available OpenCode model for your repo on the model settings page — the catalog now lists beam-free, deepseek-v4.1-flash-free, and glm-5.3-flash-free.

@shockalotti

Copy link
Copy Markdown
Contributor

@pullfrog review this PR

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one stale comment noted below.

Reviewed changes

  • Third invite mode none — booking.InviteByNone is added to the domain constants and normalization, and the create/PATCH validation keeps the sender requirement on calnode alone.
  • Guestless host events — hostEventsGuestless centralizes the calnode/none case for calendarInvitee and applyHostInvite; applyInviteDelivery suppresses the booker's .ics entirely for none.
  • Lifecycle paths — reschedule, cancel, reassign and the reconciler all read the booking's stored mode; reassign's switch handles none explicitly and the new host's event is created guestless.
  • Booking JSON + webhooks — toBookingJSON always emits invite_delivery, and the webhook field is opt-in (not in defaultFields), filled from the booking row in enrich.
  • Migration 00071 — widens the event_types/bookings CHECK via a column swap rather than a table rebuild; the Down maps none back to calnode. I ran go test ./internal/db/, ./internal/handler/ and ./internal/webhook/, plus a standalone SQLite check of the swap with foreign keys on and a child row — values, child rows, the CHECK, and idx_bookings_no_double all survive.
  • Admin UI + docs — the new select option/explanation, webhook field catalog entry, README/CHANGELOG/ARCHITECTURE updates.

ℹ️ One mode-list comment was left on two values

bookableEventType.InviteDelivery's comment still documents only InviteByCalendar/InviteByCalnode, so it now contradicts the widened enum (and the equivalent comments in booking.go, event_type.go and the API error messages, which this PR did update).

Technical details
# Stale invite-delivery comment

## Affected sites
- `internal/handler/booking_handler.go:511` — `bookableEventType.InviteDelivery`'s doc comment still reads `(booking.InviteByCalendar/ByCalnode)`.

## Required outcome
- The comment names all three stored modes, matching `booking.CreateParams.InviteDelivery` and `eventTypeJSON.InviteDelivery`.

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash | 𝕏

@raccoder-com

Copy link
Copy Markdown
Contributor Author

Fixed the stale comment on bookableEventType.InviteDelivery; it now names all three modes.

@shockalotti

Copy link
Copy Markdown
Contributor

Two things happened here, and only one is a problem.

Your code is green. On the new head 1801ae2 every check passes: CI, both builds, the deterministic claims guard (govulncheck/gosec/gitleaks), SBOM and pullfrog.

CLA is blocking, and it is about commit authorship rather than the code. Your two earlier commits are authored as raccoder-com <[email protected]>, which is already covered by the signature on file. The new commit is authored as [email protected], which GitHub cannot map to a login, so the bot treats it as an unsigned committer:

##[error]Committers of Pull Request number 158 have to sign the CLA

Either of these fixes it:

  1. Re-author the new commit with the signed address, keeping the change, then force-push. Smallest change, and what I would do: git commit --amend --author="raccoder-com <[email protected]>".
  2. Add [email protected] to your GitHub account and post the sign comment on this PR.

I cannot merge past the CLA and would not want to, since the signature is what lets us distribute your work. Nothing else is outstanding.

@raccoder-com

Copy link
Copy Markdown
Contributor Author

Re-authored 1801ae2 with the signed address and force-pushed. The commit is now b4e72f1, same tree and message, and the CLA check is green.

shockalotti added a commit to MohammadHadi2031/calnode that referenced this pull request Oct 29, 2026
The append-only guard added in Calnode#161 compares the pull request's ledger with the
tip of the base branch. Signatures are committed to main by the CLA bot, so any
signature added after a PR was opened is absent from its head by construction.
Comparing with today's main calls that "removed" and fails the PR.

That is what happened to Calnode#176, Calnode#179, Calnode#158 and Calnode#159 at once: MohammadHadi2031
signed, the ledger on main grew from 11 to 12 entries, and every PR forked
before that point was reported as revoking his signature. Nothing was removed.

Compare against git merge-base HEAD origin/<base> instead, which only sees
entries the PR's own branch actually had. A shallow clone cannot compute a merge
base, so warn and skip rather than fail closed on an infrastructure limitation.
Checkout now fetches full history for this job; the repository is 8MB.

Verified against the real Calnode#176: base=main tip reports
"MohammadHadi2031 (id 17288524)" as removed and exits 1; base=merge-base
reports nothing and exits 0. A ledger with one signature genuinely deleted
still fails, naming tgrahammer (id 3223680).
@shockalotti

Copy link
Copy Markdown
Contributor

Could you rebase this onto current main? It now conflicts, but only in CHANGELOG.md — everything else auto-merges cleanly, so it should be quick.

Two things worth knowing while you do it:

The check failure is our bug, not yours. I added a CI guard that verifies the CLA signature ledger is append-only, and the first version compared the PR against the tip of main instead of the fork point. Since signatures are committed to main after a PR is opened, it reported signatures added later as "revoked". Fixed in #190. A fresh run after the rebase will pass; re-running the old one will not.

Migration numbering. This PR adds 00071_invite_delivery_none.sql, and #129 also claims 00071. Yours is the one that should keep it, so if that conflict surfaces, take 00071 here.

To be explicit about the review status: the code passed everything else and I've verified the migration behaviour against a copy (row counts, the double-booking index, cascades, FK enforcement, and the down migration mapping none to calnode). Nothing else is outstanding from my side.

…r own invite

Some setups send the booker's confirmation and calendar invite from their own
system and read bookings over the API. Today they have two choices, and both
put a second invite in the booker's inbox: 'calendar' makes the host's
Google/Microsoft calendar invite the booker (from the host's mailbox, with a
body of just "Booking ID: ..."), and 'calnode' requires Calnode's own email.
The only way to get guestless host events and no invite was 'calnode' with no
mailer, which the API refuses to set because the sender check fails.

'none' is that state, supported:

- Host events are written without guests exactly as for 'calnode'
  (hostEventsGuestless), so no provider emails the booker. The reconciler and
  reassign follow it through calendarInvitee.
- No Calnode email to the booker carries an .ics, whatever the host's
  calendar. The booker's emails themselves still go out if email is set up:
  the setting decides who sends the invite, not whether Calnode emails, and
  the mailer and notification settings already own that.
- Host copies behave as for 'calnode' (booker left out, PUBLISH).
- No sender or mailer is required to select it.
- Like the other two modes it is copied onto the booking, and reschedule,
  cancel, reassign and the reconciler read it from there.

Bookings now carry invite_delivery in their JSON (single, list, MCP), always
present, so an integration can tell per booking whether the booker already
holds an invite. Webhooks can select it as a payload field; it stays out of
the default set, which reproduces the original payload.

Migration 00071 widens the 00068 CHECK without a table rebuild. bookings has
never been rebuilt (00037 avoided it for the same reason) and carries five
child tables' foreign keys and the double-booking index; a 00042-style rebuild
would need NO TRANSACTION and foreign_keys=OFF. The CHECK belongs to the
column alone, so the migration adds a widened copy, fills it, drops the old
column and renames the copy, inside goose's normal transaction. Down maps
'none' to 'calnode', which an older binary also treats as guestless.
ARCHITECTURE (who sends the invite, the 00071 column swap, webhook default set), README features, CHANGELOG Unreleased.
@raccoder-com
raccoder-com force-pushed the feat/invite-delivery-none branch from b4e72f1 to d315b63 Compare October 29, 2026 09:14
@raccoder-com

Copy link
Copy Markdown
Contributor Author

Rebased onto main (e130825), now at d315b63. The only conflict was CHANGELOG.md; both entries now sit at the end of Unreleased → Added. The migration keeps 00071, which is still free on main. go vet and go test ./... pass locally.

@shockalotti

Copy link
Copy Markdown
Contributor

Merging this. The backend, migration and webhook field are all verified, and I rehearsed the migration against a copy of production data before agreeing to it: row counts unchanged across all nine tables, every stored invite_delivery preserved, the double-booking index still present and still rejecting duplicates, foreign keys and cascades intact, none accepted while an invalid value is still rejected, and the down migration mapping none to calnode so host events stay guestless.

Two follow-ups we owe you, so it is clear they are ours and not a gap in your work:

  1. The UI wording and guards. We are renaming the mode to "Your own system", adding a confirmation when it is chosen while email is not configured (so nobody picks it by accident and leaves the booker with no email at all), a line saying the setting applies to new bookings only, and a note that with an online location the join link reaches the booker only through your integration via location_value in the webhook.

  2. The release note. This adds migration 00071, so the release that carries it will tell operators to back up before upgrading. The migration rebuilds the invite_delivery column on both bookings and event_types, which takes milliseconds at this data size but is not something to run without a restore point.

Thanks for the careful work on the migration especially, the column swap with the CHECK constraint explained and the down-migration reasoning.

@shockalotti
shockalotti merged commit f4c8006 into Calnode:main Oct 29, 2026
11 checks passed
KitKat31337 pushed a commit to KitKat31337/calnode that referenced this pull request Nov 6, 2026
Follow-up to Calnode#158, which added invite_delivery 'none' without the wording and
`guards agreed when it was designed. Four gaps, all in the event type editor:

- The mode read "No one (you send your own)", a negation that looks like a
  mistake. It is now "Your own system", which reads as a deliberate choice.
- Choosing it while email is not configured emails the booker nothing at all,
  and that is easy to do by accident and impossible to notice later, so it is
  confirmed once. The selection is held back until confirmed, and cancelling
  leaves the previous mode in place.
- A permanent line says the setting applies to new bookings only, because the
  mode is copied onto a booking when it is created and later changes do not
  reach existing ones.
- With an online location the booking still has a join link, and Calnode will
  not send it. The editor now says so and names location_value in the
  booking.created webhook, which is where an integration finds it.

One implementation note: bits-ui keeps the clicked option as its internal
selection even when the bound value is not changed, so after a cancel,
re-picking the same option fired no change event and the dialog never
reappeared. The Select is keyed on a counter that increments when a choice is
declined, which remounts it against the current value. Verified in a browser:
select, cancel, reselect, dialog reopens; confirm, the value applies; an online
location shows the join-link warning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants