Skip to content

feat(api): put records only onto the heads the client saw - #125

Open
PiquelChips wants to merge 1 commit into
feat/sync-snapshot-fetchfrom
feat/sync-conditional-put
Open

PiquelChips wants to merge 1 commit into
feat/sync-snapshot-fetchfrom
feat/sync-conditional-put

Conversation

@PiquelChips

Copy link
Copy Markdown
Member

A push made from a stale view of a change would make it diverge on the server.

Compare-and-swap puts:

  • PUT records?expect=<change>=<head>+<head>,... is refused with a conflict unless each change it names still has those heads when its revisions are published. A refused put publishes no record.
  • The check and the publication hold one lock, Store::lock_pushes. The landing queue takes it too before it publishes a rebase, and checks that the head it rebased is still the change's only one. So a push and a rebase never both move a change. That covers queue rebases too.

What a client needs to push:

  • POST changes/inventory tells a client what the server holds of some changes: their revisions, heads and statements, by id.
  • GET log takes a limit, so a client can check the server has one acceptance without reading the whole chain.

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: c9e5e2dc-4596-488a-987a-899a2c15b1a5
Commits

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

Files selected for processing: 11

  • README.md
  • apps/origin-src/src/http.rs
  • apps/origin-src/src/queue/mod.rs
  • apps/origin-src/src/queue/session.rs
  • apps/origin-src/src/service.rs
  • apps/origin-src/src/store/mod.rs
  • apps/origin-src/src/workspace/mod.rs
  • apps/origin-src/tests/http.rs
  • crates/origin-client/src/lib.rs
  • crates/origin-shared/src/api.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-conditional-put branch 2 times, most recently from 207897d to 34278f4 Compare November 22, 2026 16:40
@PiquelChips
PiquelChips force-pushed the feat/sync-conditional-put branch from 34278f4 to 672666f Compare November 22, 2026 18:54
A push made from a stale view of a change would make it diverge on the
server. `PUT records?expect=<change>=<head>+<head>,...` makes a put a
compare-and-swap: the server checks that each change it names still has
those heads while it publishes the revisions, and refuses with a conflict
otherwise, publishing no record (snapshots, which change nothing, stay).

The check and the publication hold one lock, `Store::lock_pushes`, which
every put of revisions takes, and so does the landing queue before it
publishes a rebase, once the head it rebased is still the change's only
one: a push and a rebase never both move a change. A rebase that finds
the change moved fails with `LandError::Moved`.

`POST changes/inventory` tells a client what the server holds of some
changes, their revisions, heads and statements by id, so it knows what to
send and which heads to expect. And `GET log` takes a `limit`, so a client
can check the server has one acceptance without reading the whole chain.
@PiquelChips
PiquelChips force-pushed the feat/sync-conditional-put branch from 672666f to a706f08 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