atproto spaces-native appointment scheduling
README.md

Tandem #

An on-protocol 1:1 meeting scheduler on the AT Protocol spaces alpha. Any atproto account can be a host: sign in once and you get a dance card at intandem.space/@your.handle.

Your availability rules, connected calendars, and every booking live as records in a private atproto space on your PDS — this app is a replaceable view over your own data, not a silo. Guests need no account: they open your link, pick an open line on your card, sign their name, and the booking is written to your space.

How availability works #

bookable slots =
    weekly windows (host timezone, DST-safe)
  − busy time from every connected calendar (ICS / CalDAV)
  − existing Tandem bookings
  − buffer, minimum-notice, and horizon rules

Calendars connect with zero OAuth: paste a secret ICS address (Google, Outlook and Fastmail provide one; Proton does on paid plans) or sign in to a CalDAV account with an app password — presets for Apple iCloud and Fastmail, or any other CalDAV server by address. Tandem discovers the account's event calendars (RFC 6764 principal → home → listing) and the host ticks the ones that count; a raw calendar URL still works as the advanced path. Connected accounts stay on the host's book, so Manage calendars re-lists an account and adds or removes calendars without the app password being typed again. No practical limit per card (an abuse ceiling of 50). One broken calendar degrades to a warning, never a blank schedule; busy time is cached per host for five minutes and refreshed in the background.

Bookings can be written back: the host marks one connected CalDAV calendar to receive bookings, and each engagement becomes an event there (guest name, contact, note, a link to the book); striking a booking removes it. Write-back is best-effort — the ledger row and the space record are the booking, the calendar copy follows in the background and is retried — and the server keeps only its state, never the calendar address or password.

Routes #

Route Who What
/@handle anyone A host's public card (/handle and /did:… redirect here)
/@handle/book anyone Sign a line
/admin the host The host's book: calendars, hours, engagements, display name, disconnect
/welcome anyone The landing page; it becomes / once TANDEM_LANDING is set
/ anyone The root host's card until then

On-protocol data #

Space: space.intandem.card (skey self, member-list policy — owner only). Collections:

Collection Contents
…tandem.calendarSource Connected calendars (incl. CalDAV secrets — see caveat)
…tandem.availability Weekly windows + rules (single record, rkey self)
…tandem.booking Bookings, confirmed / cancelled, rkey = the ledger id

Lexicons are in lexicons/; scripts/publish-lexicons-authority.mjs publishes them to the authority account (see DEPLOY.md).

What the server keeps (the trust model) #

Tandem is a server-side actor: it holds each host's OAuth session and acts for them when a guest books. D1 therefore holds, per host:

  • the OAuth session (tokens + DPoP key) and a hashed web-session cookie;
  • a booking ledger — the atomic slot lock and the retry queue for the space copy; it carries guest name/email/note and is purged 30 days after the event (the host's space copy is the durable record);
  • a cache of busy intervals (start/end only, never event details);
  • the host row: DID, verified handle, display name, session state.

Calendar URLs and CalDAV credentials are never copied to D1. Session rows are sealed at rest with a per-host key derived from a Worker secret. The operator can still read the ledger; the mitigation for the session side is that blast radius — scoped tokens the host can revoke at their PDS. Every host can Disconnect Tandem from their book, revoking the grant and closing their card.

A host's token is scoped authority=self: it structurally cannot name another host's space (verified against the live authorization server).

Auth #

Atproto OAuth only — the spaces alpha allows no app passwords. Tandem asks for a granular space: scope (read/write on its three collections in your own space, plus manage rights to create the space). For the authorization server to accept that scope it must resolve the space.intandem.* lexicons: they are published as com.atproto.lexicon.schema records under the authority chaosgreml.in (did:plc:h3wpawnrlptr4534chevddo6, on a non-spaces-alpha PDS) and a _lexicon.intandem.space DNS TXT record points at that DID — see DEPLOY.md. Handles are verified at sign-in and rechecked daily; the DID is the identity.

Token refresh is serialized across Worker isolates with a D1 lease. If a session is revoked or expires for good, the card shows paused and the host signs in again.

Abuse controls #

Bookings are limited to 5/min per IP and 30/min per host, sign-ins to 10/min per IP, via the Workers Rate Limiting binding. A Turnstile challenge on the booking form is available behind TANDEM_TURNSTILE_SITEKEY.

Run it #

npm install
npx wrangler d1 migrations apply tandem --local
npx wrangler dev --var TANDEM_FAKE:1     # http://127.0.0.1:8787 — in-memory store, no PDS

Without TANDEM_FAKE the worker talks to a real PDS; sign in at /admin.

Tests: npm test (interval algebra, DST-safe windows, slots, ICS, connectors, tenancy, lease locks, busy cache, booking ledger, abuse controls). node scripts/worker-smoke.mjs boots wrangler dev in FAKE mode and walks the public and admin flows end to end.

Alpha caveats #

  • The spaces alpha PDS has no backups and no security review. Expect data loss. CalDAV app passwords for calendar providers (e.g. Fastmail) live in your members-only space sealed under a per-host key that only this Tandem deployment holds. At sign-in, Tandem also moves the space's app access from open to an allow list that includes its own client (keeping any apps already listed; best-effort, never blocking sign-in). Still use app passwords you can revoke: Tandem itself must hold the plaintext to talk CalDAV.
  • Guest emails are collected but no notification emails are sent yet.