Skip to content

fix(gmail): harden OAuth watch ownership lifecycle - #82

Open
bsbds wants to merge 7 commits into
feat/user-oauth-owner-foundationfrom
feat/gmail-oauth-watch-lifecycle
Open

fix(gmail): harden OAuth watch ownership lifecycle#82
bsbds wants to merge 7 commits into
feat/user-oauth-owner-foundationfrom
feat/gmail-oauth-watch-lifecycle

Conversation

@bsbds

@bsbds bsbds commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Stack 2/5. Depends on xorbitsai/xagent#1588. Merge after the owner-aware OAuth foundation and before actor-owned credential creation in PR #78.

Summary

  • move every Gmail OAuth lookup, trigger binding, scan, provisioning, callback, release, and reconciliation path to the ordinary owner namespace
  • reject actor-owned credentials during Gmail service construction and watch provisioning
  • enforce exact Gmail trigger, watch, OAuth-account, provider, and user ownership
  • preserve Gmail history cursors when ownership validation fails
  • retain local watch tracking when a remote Gmail watch cannot be stopped safely
  • expose ownership mismatches through durable failure state, warning logs, and degradation signals
  • capture account identity before transition locking to avoid post-commit ORM reloads while the advisory-lock connection is held
  • detect orphan, cross-user, non-Gmail, and nonordinary watch rows during rollout

Scope

This PR contains the complete Gmail ownership boundary and lifecycle hardening, including the Gmail-specific ordinary-consumer tests and rollout checks. The owner-aware schema, query helpers, non-Gmail scoping, and SQLite migration recovery remain in PR xorbitsai#1588.

Verification

  • focused Gmail, ordinary-consumer, OAuth ownership, and migration suites passed: 179 passed and 4 PostgreSQL-only tests skipped locally
  • full pre-commit suite passed
  • all previously reviewed Gmail code and test files remain byte-identical to the prior combined Gmail head 033c47432b920aeac86b5c7d3a8140361ed062d2
  • the only changes relative to that prior combined head are the inherited foundation migration repair, its tests and documentation, and merged main updates
  • no migration or schema implementation is introduced by this PR-local diff

Rollout

Land this PR before enabling any downstream writer that creates actor-owned OAuth credentials. PR #78 remains based on this branch so actor-owned rows cannot coexist with owner-blind Gmail behavior.

@bsbds
bsbds force-pushed the feat/gmail-oauth-watch-lifecycle branch from 9f8bc74 to 4987415 Compare August 23, 2026 07:35
Require ordinary Gmail accounts across lifecycle paths, route legacy callbacks by mailbox, and prevent invalid rows from blocking retries. Move the rollout integrity gate before worker restart and add regression coverage.
bsbds added 5 commits August 23, 2026 18:02
Refresh matching Gmail OAuth rows in place and retain sibling mailbox connections so watch and trigger bindings keep valid primary keys.
Synchronize stale mailbox resource IDs from the verified watch state before generic callback authorization so valid events fire without weakening cross-provider resource checks.
Persist cleanup failures, retry unreferenced teardown in the bounded sweep, converge on already-absent resources, and release supported legacy mailbox bindings.
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.

1 participant