Skip to content

feat(api): fetch snapshots by walking them, in bounded parts - #124

Open
PiquelChips wants to merge 1 commit into
feat/server-servefrom
feat/sync-snapshot-fetch
Open

PiquelChips wants to merge 1 commit into
feat/server-servefrom
feat/sync-snapshot-fetch

Conversation

@PiquelChips

Copy link
Copy Markdown
Member

A clone should only fetch the snapshots it reads, and a server should one day decide what each caller may read by path (#6). Fetching trees and blobs by id allows neither.

Snapshots leave by walking them:

  • POST snapshots/fetch walks a snapshot from its root and sends the trees and blobs none of the caller's snapshots holds at the same path, parents first, optionally only under some paths.
  • Store::added does the walk, skipping subtrees a have holds whole without reading them, so the cost follows the size of the change.
  • records/fetch now only fetches records, each followed by the blob it carries (a description, a payload), and refuses blobs and trees.

Bounded answers: a Packer fills packs up to Pack::LIMIT, 64 MiB, in order. A fetch that stops short sets the origin-more header, which the SDK returns as a Part; the caller asks again for the rest. The server reads objects from every core in chunks of a few MiB, and stops once the part is full.

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: 07f9dc62-f7cd-488a-810c-048eeb0e6cd8
Commits

Reviewing files that changed from the base of the PR and between 57f3efb and 5534b14.

Files selected for processing: 10

  • README.md
  • apps/origin-src/src/http.rs
  • apps/origin-src/src/service.rs
  • apps/origin-src/src/store/mod.rs
  • apps/origin-src/src/tree.rs
  • apps/origin-src/tests/http.rs
  • crates/origin-client/src/lib.rs
  • crates/origin-shared/src/api.rs
  • crates/origin-shared/src/pack.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-snapshot-fetch branch from c447fbc to 7d61612 Compare November 22, 2026 15:04
@PiquelChips
PiquelChips force-pushed the feat/sync-snapshot-fetch branch 2 times, most recently from 18768dd to 32e7a55 Compare November 22, 2026 18:54
A clone should only need the snapshots it reads, and a server should be
able to decide what each caller may read by path. So trees and blobs no
longer leave a repository by id: `POST snapshots/fetch` walks a snapshot
from its root and sends the objects none of the caller's snapshots holds
at the same path, parents first, optionally only under some paths.
`Store::added` does the walk, skipping subtrees a `have` holds whole
without reading them, so the cost follows the size of the change.

`records/fetch` now only fetches records: revisions, statements and
acceptances, each followed by the blob it carries (a description, a
payload), and refuses blobs and trees.

Both answers are bounded: a `Packer` fills packs up to `Pack::LIMIT`,
64 MiB, in order, and a fetch that stops short says so with the
`origin-more` header. The SDK returns it as a `Part`; the caller asks
again for what's left, the records after the last one it got, or the
snapshot skipping the objects it got. `Store::read_each` reads the objects
from every core in chunks of a few MiB, so the server stops reading once
the part is full.
@PiquelChips
PiquelChips force-pushed the feat/sync-snapshot-fetch branch from 32e7a55 to 5534b14 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