refactor(backend): update event processor#1542
Merged
tyler-dane merged 4 commits intomainfrom Mar 16, 2026
Merged
Conversation
- Introduced the `applyCompassPlan` function to handle various event operations such as creation, updating, and deletion of Compass events. - Added comprehensive unit tests for `applyCompassPlan` to ensure correct behavior across different scenarios, including standalone and recurring events. - Refactored the `CompassEventParser` and `CompassSyncProcessor` to utilize the new plan application logic, enhancing the overall event handling process. - Updated existing tests to align with the new structure and ensure robust coverage of the event synchronization features.
…andling guide - Updated the backend request flow documentation to clarify the processing steps in the `CompassSyncProcessor`. - Revised common change recipes to include new references for recurrence handling and related files. - Added a new document detailing the recurrence handling lifecycle, including structural models, categories, and update scopes for recurring events. - Improved the Google sync and websocket flow documentation to reflect changes in event processing and side effects. - Ensured all relevant files are documented for better understanding of event and task domain models.
- Updated the Compass mutation strings in the codebase to use uppercase naming conventions for consistency. - Adjusted related tests and documentation to reflect these changes, ensuring uniformity across the application. - Enhanced clarity and maintainability of the event handling logic by adhering to a unified naming standard.
7f3d4ca to
b3725f2
Compare
|
|
||
| const nextSyncToken = response.data.nextSyncToken; | ||
|
|
||
| console.log("LATEST CHANGES (from gcal):"); |
Contributor
There was a problem hiding this comment.
Debug console.log left after partial cleanup
Low Severity
This commit removed the label console.log("LATEST CHANGES (from gcal):") but left behind the paired console.log(JSON.stringify(response.data, null, 2)), which dumps the full Google Calendar response payload to stdout. In compass.sync.processor.ts, the analogous pair of console.log statements was fully removed. The inconsistency suggests this line was overlooked during cleanup.
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
Refactor Compass recurrence sync from a lifecycle-heavy parser class into explicit planner/executor layers, and document the recurrence model and sync flow more clearly.
Why
The old
CompassEventParserwas handling too many concerns at once:That made the code branch-heavy and stateful. Most methods depended on hidden mutable state set by
init(), so the actual inputs and invariants were not obvious from the call sites.This change separates those responsibilities so each layer answers one question:
What changed
Compass sync refactor
CompassOperationPlanExplicit plan model
Added internal backend types for the Compass path:
CompassTransitionContextCompassOperationPlanCompassApplyResultCompassMutationGoogleEffectPlanNotable details:
CREATE,UPDATE,DELETE,UPDATE_SERIES,RECREATE_SERIES,TRUNCATE_SERIESdbEvent.gEventIdbefore the incoming payloadgEventIdTRUNCATE_SERIESwhen onlyUNTILchangedRECREATE_SERIESwhen other RRULE semantics changedUPDATE_SERIESwhen no split is neededTests
Docs
Rationale
This refactor reduces hidden state and makes the recurrence path easier to reason about:
The main goal was maintainability, not a product behavior change.
Validation
Ran:
Result:
I also observed the existing Compass recurrence-heavy backend integration suites passing during a broader backend run, although a full clean
yarn test:backendremains noisy in this environment due to unrelated Jest/Mongo setup issues outside this change.Note
Medium Risk
Refactors core event/recurrence sync orchestration and Google side-effect execution, which could subtly change persistence or sync behavior across many transition paths. Risk is mitigated by new unit tests and largely equivalent transition mapping, but regressions would affect recurring events and Google sync.
Overview
Refactors Compass event write processing from a stateful
CompassEventParserlifecycle into an explicit plan/apply/side-effect pipeline:analyzeCompassTransition(...)now builds aCompassOperationPlan,applyCompassPlan(...)executes only Compass DB mutation steps, andCompassSyncProcessorruns Google create/update/delete after successful DB commit.Adds a new recurrence transition/planning model (series update vs truncate vs recreate), including safeguards like clearing recurrence before Google updates when a series becomes standalone and preferring persisted
gEventIdfor delete operations. Updates backend tests to target the new planner/executor boundaries and adjusts integration tests to create initial series viaCompassSyncProcessor.Documentation is expanded/updated with a new
recurrence-handling.mdand refreshed backend/google-sync flow docs to match the new architecture, plus removes some debug logging in the Google notification handler.Written by Cursor Bugbot for commit b3725f2. This will update automatically on new commits. Configure here.