Skip to content

Emit integration.auth.succeeded so notifiers can edge-detect grant health - #1525

Merged
kody-bot merged 3 commits into
mainfrom
cursor/integration-auth-succeeded
Aug 18, 2026
Merged

kody-bot merged 3 commits into
mainfrom
cursor/integration-auth-succeeded

Conversation

@kody-bot

@kody-bot kody-bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

Intent

Give packages a success signal for OAuth grants so they can store working ↔ failed health in package storage instead of a 24-hour cooldown. Today only integration.auth.failed exists, so a notifier cannot tell “still broken” from “broke again after a reconnect.”

Summary

  • Dispatch integration.auth.succeeded after a successful host-side token refresh and after /connect/oauth persists tokens.
  • Payload is metadata-first: connection snapshot, source (refresh | oauth_connect), trusted account_url. No tokens or secrets.
  • Every successful attempt emits. The platform still does not coalesce repeats; packages edge-detect.
  • Document the topic next to integration.auth.failed and add it to subscription list/dispatch keywords.

event-notifier will subscribe and replace its 24h per-connection dedup with stored health in a follow-up publish (not in this repo).

Testing

Preview manual test on https://kody-pr-1525.kody-a99.workers.dev as user-me:

  • Signed in; /account/integrations.json is empty (0 apps / 0 connections).

  • /guides/package-subscriptions documents integration.auth.succeeded with source: refresh | oauth_connect.

  • /guides/oauth mentions succeeded alongside failed.

  • /connect/oauth?provider=google renders the connect persist page.

  • CodeRabbit: no actionable comments. Ready-for-review CI all green.

  • npx vitest run --project node-unit on token-refresh, package-subscriptions, and account-secrets suites (19 passed).

  • GitHub CI on f6d0369e: all 11 checks passed.

  • Focused node-unit suites passed again after oxfmt.

  • Published @kentcdodds/event-notifier 0a0b46a and dry-ran the health matrix (working→failed notifies, failed→failed skips). No live Discord posts.

System changes

System recap — extends existing primitives (medium risk)

Mode: recap · Base: main @ 5f4f8ce5 · Head: f6d0369e

Classification: extends — integrations gains a sibling success topic; /connect/oauth persist and subscription discovery wire it through.

Primitives touched

Primitive Group Impact
integrations assistant extends — emit integration.auth.succeeded on refresh and connect persist
app-ui surfaces composes — /connect/oauth persist fans out the new topic
saved-packages assistant composes — list/dispatch keywords include the new topic

System map

Successful OAuth refresh and connect persist fan out integration.auth.succeeded to the owning user's subscribed packages.

Legend: green = composes (wiring only) · amber = extended by this PR · red = new primitive · gray = context (unchanged, included only when an edge crosses it).

flowchart LR
	appUi["app-ui<br/>Browser app"]:::touched
	integrations["integrations<br/>OAuth integrations"]:::extended
	savedPackages["saved-packages<br/>Saved packages"]:::touched
	appUi -->|"POST /account/secrets.json connect_oauth persist"| integrations
	integrations -->|"integration.auth.succeeded fan-out"| savedPackages
	classDef touched fill:#1a7f37,color:#fff
	classDef extended fill:#9a6700,color:#fff
	classDef added fill:#cf222e,color:#fff
	classDef untouched fill:#57606a,color:#fff
Loading

Change flow

sequenceDiagram
	participant Refresh as refreshIntegrationTokens
	participant Connect as /connect/oauth persist
	participant Dispatch as package subscriptions
	participant Pkg as notifier package
	Refresh->>Dispatch: succeeded (source refresh)
	Connect->>Dispatch: succeeded (source oauth_connect)
	Refresh-->>Dispatch: failed (existing topic)
	Dispatch->>Pkg: invoke declared handler
	Note over Pkg: store working/failed in packageStorage
Loading

Before / after

// before: failed only
event: 'integration.auth.failed'

// after: failed + succeeded
event: 'integration.auth.succeeded'
source: 'refresh' | 'oauth_connect'
account_url: string

Summary by CodeRabbit

  • New Features

    • Added integration.auth.succeeded notifications for successful OAuth connections and token refreshes.
    • Events include integration metadata, source, account URL, and timestamp without exposing credentials.
    • Added subscription filtering, delivery, and idempotency support for successful authentication events.
    • Updated package and MCP subscription capabilities to recognize the new event topic.
  • Documentation

    • Expanded OAuth, subscriptions, integration, and synthetic-event guidance with success-event details and examples.
    • Clarified failure-event behavior and notification handling.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@cursor[bot], you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 minutes

Limit details: You’ve used all 2 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 76949ab5-29ce-4c2e-94cb-6a608955dafd

📥 Commits

Reviewing files that changed from the base of the PR and between f6d0369 and 8322ebb.

📒 Files selected for processing (11)
  • docs/contributing/architecture/integrations.md
  • docs/contributing/packages-and-manifests.md
  • docs/guides/oauth.md
  • docs/guides/package-subscriptions.md
  • docs/use/packages.md
  • docs/use/synthetic-event-dispatch.md
  • packages/worker/src/app/handlers/account-secrets.ts
  • packages/worker/src/integrations/package-subscriptions.node.test.ts
  • packages/worker/src/integrations/package-subscriptions.ts
  • packages/worker/src/integrations/token-refresh.node.test.ts
  • packages/worker/src/integrations/token-refresh.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 64cb9024-5a09-402f-bb37-df1af2d23881

📥 Commits

Reviewing files that changed from the base of the PR and between 5f4f8ce and f6d0369.

📒 Files selected for processing (15)
  • docs/contributing/architecture/integrations.md
  • docs/contributing/packages-and-manifests.md
  • docs/guides/README.md
  • docs/guides/oauth.md
  • docs/guides/package-subscriptions.md
  • docs/use/packages.md
  • docs/use/synthetic-event-dispatch.md
  • packages/worker/src/app/handlers/account-secrets.node.test.ts
  • packages/worker/src/app/handlers/account-secrets.ts
  • packages/worker/src/integrations/package-subscriptions.node.test.ts
  • packages/worker/src/integrations/package-subscriptions.ts
  • packages/worker/src/integrations/token-refresh.node.test.ts
  • packages/worker/src/integrations/token-refresh.ts
  • packages/worker/src/mcp/capabilities/packages/list-package-subscriptions.ts
  • packages/worker/src/mcp/capabilities/packages/package-subscription-dispatch.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The PR adds integration.auth.succeeded events for successful OAuth connections and token refreshes. It adds shared dispatch infrastructure, metadata-only payloads, tests, capability discovery, and documentation.

Changes

Integration authentication event delivery

Layer / File(s) Summary
Shared authentication event dispatch
packages/worker/src/integrations/package-subscriptions.ts, packages/worker/src/integrations/package-subscriptions.node.test.ts
Adds the success topic, shared connection types, metadata-only payloads, topic filtering, account URLs, idempotency keys, and fan-out tests.
Successful token refresh emission
packages/worker/src/integrations/token-refresh.ts, packages/worker/src/integrations/token-refresh.node.test.ts
Dispatches success events after token metadata persistence and supports waitUntil or awaited scheduling.
Successful OAuth connection emission
packages/worker/src/app/handlers/account-secrets.ts, packages/worker/src/app/handlers/account-secrets.node.test.ts
Dispatches oauth_connect success events after OAuth persistence and tests user, platform, and rejected-scope behavior.
Documentation and capability updates
docs/contributing/..., docs/guides/..., docs/use/..., packages/worker/src/mcp/capabilities/packages/*
Documents the success topic, payload, delivery behavior, synthetic dispatch example, and subscription discovery filters.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to f6d03

This change adds success notifications for completed OAuth refresh and connection flows without introducing an actionable merge-blocking risk; it is merge-ready after normal checks and review.

Possibly related PRs

Suggested reviewers: kentcdodds

Sequence Diagram(s)

sequenceDiagram
  participant OAuthHandler
  participant TokenRefresh
  participant PackageSubscriptions
  participant SubscribedPackage
  OAuthHandler->>PackageSubscriptions: dispatch OAuth connection success
  TokenRefresh->>PackageSubscriptions: dispatch refresh success
  PackageSubscriptions->>SubscribedPackage: deliver metadata-only event
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: emitting integration.auth.succeeded so notifiers can detect grant health transitions.
Description check ✅ Passed The description includes all required sections and clearly explains the intent, implementation, testing, and system impact.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/integration-auth-succeeded

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kody-bot
kody-bot marked this pull request as ready for review August 18, 2026 21:07
@github-actions

github-actions Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-1525.kody-a99.workers.dev

Worker: kody-pr-1525
Runtime worker: kody-pr-1525-runtime (https://kody-pr-1525-runtime.kody-a99.workers.dev)
D1: kody-pr-1525-db
KV: kody-pr-1525-oauth-kv

Mocks:

cursoragent and others added 3 commits August 18, 2026 21:30
Packages can store working/failed health themselves instead of
time-window dedup. The platform still emits every classified
attempt and does not coalesce repeats.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@cursor
cursor Bot force-pushed the cursor/integration-auth-succeeded branch from f6d0369 to 8322ebb Compare August 18, 2026 21:30
@kody-bot
kody-bot merged commit c629b06 into main Aug 18, 2026
11 checks passed
@kody-bot
kody-bot deleted the cursor/integration-auth-succeeded branch August 18, 2026 21:37
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