Skip to content

fix(sync service): fallback to golden snapshot if no init happens#4200

Open
404Wolf wants to merge 3 commits into
mainfrom
wolf/fallback-to-golden
Open

fix(sync service): fallback to golden snapshot if no init happens#4200
404Wolf wants to merge 3 commits into
mainfrom
wolf/fallback-to-golden

Conversation

@404Wolf

@404Wolf 404Wolf commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6ea95224-8313-4db4-9e04-861581de1e26

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The sync-service durable object gains automatic "golden snapshot" seeding: a new first_uninitialized_connection_at timestamp is recorded the first time a /connect request arrives before the document is initialized. The alarm handler checks this timestamp and, after AUTO_INIT_AFTER (15 seconds), seeds the document with an embedded GOLDEN_SNAPSHOT via a new auto_initialize_golden method. To support this, initialize_handler is refactored to delegate to a new initialize_from_bytes helper reused by both paths. In the cloud-storage service, initialize_existing_markdown gains a 3-attempt retry loop with 1-second delays when calling initialize_from_snapshot.

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess relevance to the changeset. Add a description explaining the motivation, implementation details, and context for why this golden snapshot fallback is necessary.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title follows conventional commits format with 'fix:' prefix and is under 72 characters (65 chars), clearly describing the main change of adding golden snapshot fallback.
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.

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


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@rust/sync-service/src/durable_object.rs`:
- Around line 725-738: The doc comment "Gets DocumentState, loading it if
needed" is incorrectly placed above the record_first_uninitialized_connection
function when it should document the document_state function. Move this doc
comment from above record_first_uninitialized_connection to its correct position
above the document_state function. Additionally, add appropriate doc comments
for the new functions record_first_uninitialized_connection and
auto_initialize_golden that accurately describe their functionality instead of
leaving them without documentation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 27085cfd-1421-419a-a1ca-4a393029e7b7

📥 Commits

Reviewing files that changed from the base of the PR and between c1d4a69 and 0e7220d.

📒 Files selected for processing (2)
  • rust/cloud-storage/documents/src/outbound/markdown_init.rs
  • rust/sync-service/src/durable_object.rs

Comment on lines 725 to +738
/// Gets DocumentState, loading it if needed
fn record_first_uninitialized_connection(&self) {
let mut first_uninitialized_connection_at = self
.first_uninitialized_connection_at
.lock("record_first_uninitialized_connection");
if first_uninitialized_connection_at.is_none() {
*first_uninitialized_connection_at = Some(web_time::Instant::now());
}
}

async fn auto_initialize_golden(&self, document_id: &str) -> Result<()> {
info!(document_id, "auto-init: seeding golden snapshot");
self.initialize_from_bytes(document_id, GOLDEN_SNAPSHOT).await
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Misplaced doc comment.

The doc comment /// Gets DocumentState, loading it if needed on line 725 now incorrectly documents record_first_uninitialized_connection instead of document_state (line 740). This appears to be an artifact of inserting the new functions above document_state without moving the existing doc comment.

📝 Suggested fix

Move the doc comment to its correct position and optionally add comments for the new functions:

     Ok(ss)
   }

-  /// Gets DocumentState, loading it if needed
   fn record_first_uninitialized_connection(&self) {
     let mut first_uninitialized_connection_at = self
       .first_uninitialized_connection_at
       .lock("record_first_uninitialized_connection");
     if first_uninitialized_connection_at.is_none() {
       *first_uninitialized_connection_at = Some(web_time::Instant::now());
     }
   }

   async fn auto_initialize_golden(&self, document_id: &str) -> Result<()> {
     info!(document_id, "auto-init: seeding golden snapshot");
     self.initialize_from_bytes(document_id, GOLDEN_SNAPSHOT).await
   }

+  /// Gets DocumentState, loading it if needed
   async fn document_state(&self) -> Result<Arc<DocumentState>> {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rust/sync-service/src/durable_object.rs` around lines 725 - 738, The doc
comment "Gets DocumentState, loading it if needed" is incorrectly placed above
the record_first_uninitialized_connection function when it should document the
document_state function. Move this doc comment from above
record_first_uninitialized_connection to its correct position above the
document_state function. Additionally, add appropriate doc comments for the new
functions record_first_uninitialized_connection and auto_initialize_golden that
accurately describe their functionality instead of leaving them without
documentation.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant