Skip to content

Use persisted sync intervals as fallback on startup#885

Open
mlw wants to merge 1 commit intomainfrom
mlw/sync-init-with-persisted-intervals
Open

Use persisted sync intervals as fallback on startup#885
mlw wants to merge 1 commit intomainfrom
mlw/sync-init-with-persisted-intervals

Conversation

@mlw
Copy link
Copy Markdown
Contributor

@mlw mlw commented Mar 31, 2026

This makes it so that on startup, if sync fails or the server doesn't set sync interval values, previously persisted intervals will be used.

@mlw mlw added this to the 2026.3 milestone Mar 31, 2026
@mlw mlw requested a review from a team as a code owner March 31, 2026 10:46
@github-actions github-actions bot added configurator Issues or PRs related to the configurator / Santa configuration comp/santasyncservice Issues or PRs related to the sync protocol lang/objc++ PRs modifying files in ObjC++ comp/common size/m Size: medium labels Mar 31, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 31, 2026

📝 Walkthrough

Walkthrough

This PR modifies full sync interval handling across the sync manager, configurator, and preflight logic. When the server omits or sends 0 for fullSyncInterval, the system now falls back to a persisted daemon-provided interval instead of compile-time defaults. A new property stores the daemon interval during initialization and is updated when the server provides values.

Changes

Cohort / File(s) Summary
Interval Fallback Handling
Source/common/SNTConfigurator.mm, Source/santasyncservice/SNTSyncManager.mm, Source/santasyncservice/SNTSyncPreflight.mm
Core logic changes: SNTConfigurator now treats interval == 0 as "not provided" by clearing the key. SNTSyncManager adds persistedFullSyncInterval property to store daemon-provided interval read during initialization, uses it as fallback in timer rescheduling when server omits value, and updates it during preflight. SNTSyncPreflight only sets fullSyncInterval when server provides positive value (not 0).
Test Coverage
Source/santasyncservice/SNTSyncManagerTest.mm, Source/santasyncservice/SNTSyncTest.mm
New test property persistedFullSyncInterval added to test category. Tests verify: (1) daemon interval is captured during initialization, (2) persisted interval is retained when server omits fullSyncInterval, and (3) persisted interval is updated when server provides value.

Sequence Diagram(s)

sequenceDiagram
    participant Init as Initialization Flow
    participant Daemon as Daemon (XPC)
    participant SM as SNTSyncManager
    participant Preflight as Preflight Handler
    participant Server as Server

    Init->>Daemon: synchronousRemoteObjectProxy<br/>(fullSyncInterval callback)
    Daemon-->>SM: callback(daemonInterval)
    SM->>SM: persistedFullSyncInterval = daemonInterval
    Note over SM: Stores daemon-provided interval<br/>as fallback

    SM->>SM: Schedule full sync timer<br/>using persistedFullSyncInterval

    rect rgba(100, 150, 200, 0.5)
    Note over Preflight,Server: Preflight Sync
    Preflight->>Server: Request sync state
    Server-->>Preflight: fullSyncInterval = X
    Preflight->>SM: Update syncState with interval
    end

    rect rgba(150, 100, 200, 0.5)
    Note over Preflight,Server: Server Omits Interval
    Preflight->>Server: Request sync state
    Server-->>Preflight: fullSyncInterval = nil/0
    Preflight->>SM: fullSyncInterval not set
    SM->>SM: Falls back to<br/>persistedFullSyncInterval
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request has no description provided by the author, making it impossible to assess whether the intent aligns with the changeset. Add a clear description explaining the purpose, motivation, and impact of using persisted sync intervals as fallback on startup.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main objective: using persisted sync intervals as fallback on startup, which aligns with all the changes across SNTConfigurator, SNTSyncManager, SNTSyncPreflight, and test files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mlw/sync-init-with-persisted-intervals

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/common comp/santasyncservice Issues or PRs related to the sync protocol configurator Issues or PRs related to the configurator / Santa configuration lang/objc++ PRs modifying files in ObjC++ size/m Size: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant