refactor: deepen Google sync domain modules#1721
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements #1719 by making the Google sync backend easier to navigate by domain responsibility instead of by the overloaded term
sync.The main change is structural: the existing behavior is preserved, but the modules now describe the product flow they own:
Why
The old layout made several different concepts look similar:
synccould mean import, watch lifecycle, notification handling, sync records, event propagation, or user sync health.syncandwatchnames, even when they were setting up Google-specific scenarios.google-sync-health.ts,sync.import.ts, andsync.records.ts.That made the code harder to read and harder to safely change.
What Changed
Event propagation is named by direction
Moved the old direction-specific processors into an explicit event propagation area:
compass-to-google.event-propagation.tsgoogle-to-compass.event-propagation.tscompass-to-google-backfill.tsThis makes the two main event flows easier to distinguish:
Google Import has domain-first names
Renamed the import module family from the old
sync.import.*pattern to:google-import.service.tsgoogle-import.types.tsgoogle-import.util.tsThis makes Import read as its own Google sync lane instead of another generic sync helper.
Google Watch owns watch-specific helpers
Split generic sync/watch utilities into Google Watch modules:
google-watch-token.tsgoogle-watch-timing.tsgoogle-watch-state.tsgoogle-watch-config.tsgoogle-watch-activity.tsThis keeps watch expiration, token decoding, HTTPS capability, active-watch state, and recent Compass activity checks near Google Watch behavior.
Public watch notifications have one ingress module
Added:
public-watch-notification.ingress.tsThis module now owns public Google callback validation and parsing before the controller hands work to Google Watch. That removes Google webhook verification from generic auth middleware and keeps browser/API traffic separate from public Google webhook traffic.
Google sync orchestration uses shorter plumbing names
Renamed the orchestration and plumbing module family to:
google-sync.service.tsgoogle-sync.health.tsgoogle-sync.errors.tsgcal.client.tsThis keeps app-level sync behavior under
google-syncand reservesgcalfor the raw Google Calendar client plumbing.Google sync health moved out of user metadata
Added:
google-sync.health.tsUser metadata now asks this module whether Google sync is healthy instead of directly inspecting sync/watch state. That keeps metadata focused on user-facing state and keeps sync diagnosis in the Google sync domain.
Sync records are behind a repository module
Moved sync record lookup/update/delete behavior into:
sync-records.repository.tsThis replaces the generic query/helper split and makes the storage owner explicit.
Shared utility moved out of sync
Moved the concurrency limiter into common utilities:
common/util/concurrency-limiter.util.tsThe old generic sync utility file is removed.
Test support now uses Google sync language
Renamed/deepened test helpers:
google-sync.driver.tsgoogle-watch.driver.tsController helpers remain focused on request/transport setup, while Google sync drivers describe Google-specific scenarios.
Docs updated
Updated the active docs and file maps so future work starts in the right place, including:
CONTEXT.mddocs/features/google-sync-and-sse-flow.mddocs/development/feature-file-map.mdNaming Convention Used
This PR standardizes on domain-first filenames for the Google sync area:
google-import.*for Google Importgoogle-watch-*for Google Watch behaviorgoogle-sync.*for Google sync orchestration, health, and errorsgcal.client.tsfor raw Google Calendar API client setuppublic-watch-notification.*for the public webhook boundarysync-records.repository.tsfor sync record persistencecompass-to-google.*andgoogle-to-compass.*for event propagation directionThe remaining frontend state names such as
sync.importGCalwere intentionally left alone because they are state shape names, not backend module names.Verification
Ran and passed:
bun run type-checkbun run lintgcal.client.test.tsgoogle-sync.health.test.tsgoogle-sync.service.test.tsgit diff --checkNotes:
bun run lintstill prints the existing repo-wide warning backlog, but exits successfully.user.controller404 failure; the rename-affected backend tests pass.