Closed cse-test-sync closed 4 years ago
@thomcc and I talked about how we could integrate Remerge into Desktop last week. Conceptually, it's pretty similar to how the Desktop machinery works today: we need a way to handle resetting sync IDs, feeding incoming records into the store, and uploading outgoing records. The additional meta-collections mean we have to pass those records around, too, but I don't think that complicates things.
Things we can and can't use on Desktop:
sync15
, because m-c vendors all Rust crates, including (AIUI) optional dependencies. This means depending on sync15
will pull in rc_crypto
, viaduct
, and everything else.Cargo.toml
. Most of them are already vendored, too!One way to approach the integration is something like bug 1596322 suggests, and pass cleartext JSON strings back and forth. We'd add a skeleton, subclassable RemergeEngine
to JS (it'll look a lot like BufferedBookmarksEngine
, and add a Rust XPCOM component that takes care of updating the mirror, merging, and fetching staged records for upload.
For the storage part, we can provide a CRUD-style API that also takes JSON strings. (We could reflect it as an XPCOM interface instead, but using interfaces for simple structs like NativeRecord
is super kludgey). On the JS side, we'll provide a wrapper to make this more ergonomic.
Aside: If you're thinking, hey, this sounds a lot like ffi_support
JSON, you're right! XPCOM is an FFI, with additional memory and type safety guarantees. XPCOM methods can take JS objects directly, via in jsval
parameters, but the Rust XPCOM bindings don't support those.
So the integration would look something like:
remerge_sync15
(remerge_rc
?) crate that depends on remerge
and sync15
. This is what we'll use for Fenix and other consumers. This crate will implement sync15::Store
, which take a sync15::IncomingChangeset
and deserializes each sync15::Payload
to the corresponding Remerge type. Outgoing schemas and records will likewise get serialized from a Remerge type to a sync15::Payload
, bundled up in a sync15::OutgoingChangeset
, and uploaded.remerge
directly. This will implement an XPCOM interface that takes JSON strings, and deserializes them to a remerge::RawSchema
or remerge::RawRecord
on the Rust side. After the merge is done, we'll serialize Remerge records to JSON, pass them back to JS via an XPCOM callback, and let the JS Sync implementation encrypt (as-is, without any additional parsing or serializing) and upload them.meta
collection with the schemas and client info.Our glue crate is also going to need to handle:
meta
collection's sync ID ever gets out of step with the main collection.I'll close this issue in favor of the Bugzilla bug, since we'll use that for the prototype, and don't want to fork the discussion. This comment is specifically so we can document the plan in Jira/GH for tracking.
This largely is implementing the algorithm/algorithms for sync and conflict resolution described in the remerge spec.
It also requires implementing vector clocks and the like, if that's not done as part of local storage.
┆Issue is synchronized with this Jira Story ┆Story Points: 3 ┆Epic: chrome.sync.storage (Generic Sync) prototype ┆Sprint: SYNC - end 2019-12-20