Skip to content

feat(sync): fetch only the changes the remote's events say moved - #130

Open
PiquelChips wants to merge 1 commit into
feat/sync-fetch-chainsfrom
feat/sync-fetch-cursor
Open

PiquelChips wants to merge 1 commit into
feat/sync-fetch-chainsfrom
feat/sync-fetch-cursor

Conversation

@PiquelChips

Copy link
Copy Markdown
Member

Comparing every change with the remote's makes a fetch that brings nothing grow with history.

Fetch:

  • It brings new acceptances, then the changes that the remote's events say moved since the last fetch. A fetch that brings nothing therefore doesn't grow with history.
  • The events are read first, so what moves while it fetches is fetched again. Statements are traced to their change through the events, then this node's records.

Cursor generation: the cursor is tied to the remote op log's generation, and falls back to a full comparison when it's stale.

  • Each op log now has a generation, a random id made with it. A repository restored from a copy of its records starts a new one.
  • Event pages carry it, and a query naming another generation is refused as expired.

Benchmark (local HTTP): a fetch that brings nothing from 10k changes takes 0.7 ms.

Note

Written by Claude Opus 5.5 in Claude Code (via T3 Code)

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 74222027-5cbc-44cc-9afd-461ca94c4e3c
Commits

Reviewing files that changed from the base of the PR and between 2831876 and 6d1c688.

Files selected for processing: 11

  • README.md
  • apps/origin-src/src/events.rs
  • apps/origin-src/src/index.rs
  • apps/origin-src/src/oplog.rs
  • apps/origin-src/src/service.rs
  • apps/origin-src/src/store/mod.rs
  • apps/origin-src/src/sync.rs
  • apps/origin-src/src/workspace/ops.rs
  • crates/origin-shared/src/api.rs
  • crates/origin-shared/src/event.rs
  • docs/openapi.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@PiquelChips
PiquelChips added this pull request to stack #165 November 22, 2026 14:59
@PiquelChips
PiquelChips force-pushed the feat/sync-fetch-cursor branch from a1ebb3a to 4be9738 Compare November 22, 2026 15:04
@PiquelChips
PiquelChips force-pushed the feat/sync-fetch-cursor branch 2 times, most recently from 74b2bab to a9aaec8 Compare November 22, 2026 18:54
Comparing every change this node knows with the remote's makes a fetch
that brings nothing grow with history. `Sync::fetch` reads the remote's
events since the cursor of the last fetch first, and compares only the
changes they say moved: those with a revision created or a statement
issued about them, or about a statement about them, traced through the
events and then this node's records. Read first, so what moves while it
fetches is fetched again. Without a cursor, or once the remote no longer
keeps its events, every change is compared.

A cursor is a sequence number of the remote's op log, which only means
something in that log: a repository restored from a copy of its records
starts a new one, whose numbers may run behind. So each op log now has a
generation, a random id made with it. Event pages carry it, and a query
naming another generation is refused as expired, which sends the fetch
back to a full comparison.
@PiquelChips
PiquelChips force-pushed the feat/sync-fetch-cursor branch from a9aaec8 to 6d1c688 Compare November 22, 2026 19:20
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