Skip to content

Migrate webhook-driven connectors onto scheduleDrain; extend the primitive - #265

Merged
KrisBraun merged 1 commit into
mainfrom
feat/migrate-connectors-schedule-drain
Jul 5, 2026
Merged

Migrate webhook-driven connectors onto scheduleDrain; extend the primitive#265
KrisBraun merged 1 commit into
mainfrom
feat/migrate-connectors-schedule-drain

Conversation

@KrisBraun

Copy link
Copy Markdown
Contributor

Follow-up to #263: makes scheduleDrain the real implementation everywhere, not just the documented pattern.

SDK extensions (things the migration itself surfaced)

  • handlerArgs — extra serializable arguments appended after the ids slice (handler(ids, ...handlerArgs)), for per-scope drains such as a per-channel key whose handler needs the channel id.
  • Partial-failure contract — the handler may return { retry: ids }: just those ids stay pending with bumped attempt counters; the rest of the slice is released. Previously a handler could only fail the whole slice.

Both additive; changeset included. 17 drain tests.

Migrations

ConnectorModeNotes
Gmail, Google (mail)signal-onlyHistory cursor remains the work source; drain replaces the hand-wired coalescing task.
MS Teams, Slacksignal-only per channel (handlerArgs)Sync window now computed at drain time in the handler — the webhook path writes no state at all (previously one sync_state write per notification).
Outlook Mail, Outlook (mail)id-mode + retryDeletes the connector's hand-rolled pending-key machinery entirely. Probe failures retry per-id with attempt caps; drafts/excluded/hard-deleted ids are released. One-time upgrade() migration re-records pre-drain pending ids; already-queued callbacks re-record through the same path, so nothing in flight is lost across the deploy.

Net: the four connectors that each hand-built coalescing/bounding/bookkeeping now share the platform implementation — new connectors get it from the checklist + one method.

Also fixes the pre-existing Slack syncCustomEmoji test failure (tool mock was missing scheduleRecurring).

Tests

twister 17, gmail 107, google 64, slack 28 (now fully green), outlook-mail 46 (drain-handler, migration, and wiring tests rewritten for the platform drain); ms-teams + outlook composite typecheck (no vitest harness in those packages).

🤖 Generated with Claude Code

Extends the drain primitive with the two capabilities the migration
surfaced, then moves every notification-driven connector onto it:
SDK:
- scheduleDrain accepts handlerArgs (extra serializable args appended
after the ids slice) so per-scope drains — e.g. a per-channel key —
can carry the scope to the handler.
- The handler may return { retry: ids } to report PARTIAL failure: just
those ids stay pending with bumped attempt counters while the rest of
the slice is released.
Connectors:
- Gmail + combined Google (mail): signal-only scheduleDrain replaces
the hand-wired coalescing task; the history cursor remains the source
of work.
- MS Teams + Slack: per-channel signal-only drains with handlerArgs.
The sync window is now computed at drain time inside the handler, so
the webhook path no longer writes any state.
- Outlook Mail + combined Outlook (mail): the hand-rolled pending-key
machinery is replaced by id-mode scheduleDrain with the retry
contract (probe failures retry per-id; drafts/excluded/deleted ids
are released). A one-time upgrade() migration re-records pre-drain
pending ids and clears the old state; already-queued callbacks
re-record their ids through the same path.
Also fixes the Slack syncCustomEmoji test's incomplete tool mock
(missing scheduleRecurring), which failed independently of any change.
@KrisBraun
KrisBraun merged commit 3736d0d into mainJul 5, 2026
1 check passed
@KrisBraun
KrisBraun deleted the feat/migrate-connectors-schedule-drain branch July 5, 2026 03:33
@plot-app-builderplot-app-builderBot mentioned this pull request Jul 5, 2026
Sign up for freeto 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.

1 participant

@KrisBraun