Skip to content

Part 9 · Blueprint 54

Cloud File Sync & Sharing Service

14 min reading · Sources · Editorial review pending

Last-writer wins can erase independent offline edits.

More
20px
Reading list
Page details

Published date · Last edited:

Draft edition. Editorial review and supplementary reading recommendations are still being completed.

Format: Architecture walkthrough. Prerequisites: the beginner bootcamp. Chapter prerequisites: Idempotency Keys & Distributed Retries, Time, Clocks & Distributed Ordering: Lamport to TrueTime, Distributed Blob & Object Storage (Amazon S3 Scale).

Sixty-second mental model

Problem: Last-writer wins can erase independent offline edits.

Use: Use content hashes and preserve conflicting versions explicitly.

Design boundary: Synchronize file versions across devices without silently overwriting concurrent edits. Stable file identity, content chunks, manifests and deletion history are separate responsibilities.

Layer 1 · Intuition

Hypothetical scenario: Northwind is designing file synchronization. Maya represents product requirements, Dev implementation and Priya reliability. The team must agree what one chunk means and which component owns the file version history.

Think of devices exchanging versioned folder manifests. Separate the requester from file version history, then identify the retained evidence needed after failure.

Authority
The entitled state owner.
Invariant
A rule preserved across concurrency and failures.

Architecture and worked reasoning

Design boundary: Synchronize file versions across devices without silently overwriting concurrent edits. Stable file identity, content chunks, manifests and deletion history are separate responsibilities.

Responsibilities on the request path

File synchronization: responsibilities and request directionSynchronize file versions across devices without silently overwriting concurrent edits. Stable file identity, content chunks, manifests and deletion history are separate responsibilities.Device journalChunk storeVersion manifestSync reconciler
Synchronize file versions across devices without silently overwriting concurrent edits. Stable file identity, content chunks, manifests and deletion history are separate responsibilities.

Workload and limiting resource

Hypothetical 100 MB file split into 4 MB chunks has 25 chunks. If exactly two chunks change, transferring those chunks sends 8 MB rather than 100 MB, excluding metadata. This assumes fixed chunk boundaries do not shift; content-defined chunking has different costs/behavior.

Keep the units attached to each intermediate result. The assumptions above describe a hypothetical exercise, not observed vendor capacity. A real capacity decision also needs a measured service curve, skew, recovery traffic and an explicit admission policy for overload.

Mutation or publication path

File synchronization: mutation boundaryHash and upload missing immutable chunks. Then: Publish a new manifest conditional on its base version. Then: Record deletions/moves as versioned namespace changes.Step 1
Hash and upload missing immutable chunks.
Step 2
Publish a new manifest conditional on its base version.
Step 3
Record deletions/moves as versioned namespace changes.
Hash and upload missing immutable chunks. Then: Publish a new manifest conditional on its base version. Then: Record deletions/moves as versioned namespace changes.
  1. Hash and upload missing immutable chunks.
  2. Publish a new manifest conditional on its base version.
  3. Record deletions/moves as versioned namespace changes.

Observation and recovery path

File synchronization: observation boundaryFetch changes after the device cursor. Then: Download only missing chunks. Then: Surface or merge concurrent manifests under an explicit policy.Step 1
Fetch changes after the device cursor.
Step 2
Download only missing chunks.
Step 3
Surface or merge concurrent manifests under an explicit policy.
Fetch changes after the device cursor. Then: Download only missing chunks. Then: Surface or merge concurrent manifests under an explicit policy.
  1. Fetch changes after the device cursor.
  2. Download only missing chunks.
  3. Surface or merge concurrent manifests under an explicit policy.

Failure that changes the decision

Hypothetical scenario: An offline device returns after deletion history was collected and recreates an intentionally removed file. Define cursor expiry and resynchronization policy.

Attempt this decision before reading the explanation

Does identical file content imply identical file identity?

No. Two files can share bytes while having different ownership, names and histories. Deduplicate content without collapsing namespace identity or permissions.

Supporting mechanism analysis

Hypothetical scenario: Northwind. Maya represents product, Dev implementation and Priya reliability. The following workflow develops the underlying mechanism.

Hypothetical scenario. A Northwind editor remains offline while the server creates snapshots and retires old context. Their permission is revoked before reconnect. Dev proposes merging every operation that names the known document. Priya asks whether old causal knowledge grants current access.

Maya: “Can we still interpret its operations, and is that principal permitted to submit them now?”

Specify the supported offline horizon, retained synchronization context and behavior outside that horizon. Keep convergence, accepted-operation authority and business validity distinct. The offline duration is a selected teaching assumption, not an existing product promise.

Before you continue: Does a snapshot of visible text necessarily preserve everything an offline merge needs?

The selected protocol can require identities, dependencies or deletion evidence beyond that text. Establish the retained context and supported return path explicitly.

This avoids confusing interpretability with permission. Choose a defined resynchronization response when either requirement is not satisfied.

Offline support requires more than storing a client’s latest text. The chosen merge protocol can need operation identities, dependencies, deletion evidence or other context. Retiring that information changes which returning replicas can reconcile safely. Specify the supported horizon and the response when a client falls outside it.

A full resynchronization may be appropriate after that horizon, but it needs a policy for the user’s unaccepted local edits. Preserve them for a deliberate review or reapplication workflow where possible. Do not label locally composed changes accepted merely because the client retained a document copy.

Hypothetical worked example. Retain the baseline selected two hundred operations per second and one hundred bytes of logical operation payload. Arrival payload is 200 × 100 = 20,000 bytes per second. For a selected twenty-four-hour offline horizon, time is 24 × 60 × 60 = 86,400 seconds.

Uncompressed payload across that horizon is 20,000 × 86,400 = 1,728,000,000 bytes, or 1.728 decimal GB. This excludes identifiers beyond the chosen payload, snapshots, indexes, replicas and physical allocation. It is not a measurement of Yjs or another CRDT’s encoding.

If a client returns after thirty hours while the declared support horizon is twenty-four, it is 30 − 24 = 6 hours outside that contract. A new snapshot does not independently prove that the six-hour gap is recoverable. Use the protocol’s supported full-resync or explicit conflict workflow instead of discarding dependencies and hoping the text still looks right.

Hypothetical scenario. Snapshot S summarizes accepted operations through a causal frontier. An offline client still holds an operation naming an element deleted before S. If the server discarded the element's identity and necessary mapping, accepting that operation as though the history were complete may corrupt interpretation or resurrect deleted content.

Causal stability requires assumptions about which replicas or clients may still submit relevant old operations. An indefinitely offline client prevents unconditional reclamation under some models. Define a retention horizon and require a resnapshot or explicit rebase when the client falls behind it. A rebase is a user-visible interpretation step, not proof that the original operation means exactly the same thing.

Authorization applies before old work is admitted. A revoked client cannot regain edit authority because its CRDT operations converge. Keep the accepted-operation set and current permission rule separate from snapshot transport. Preserve operation identity across reconnect to suppress duplicates, and make an unresolved stale-base edit visible rather than silently dropping it.

Yjs documents its shared types, updates and provider separation . Inspect the chosen persistence and synchronization behavior before specifying compaction or restore. A generic CRDT label does not establish compatible history retention, application durability or current document permission.

Deletion and compaction need particular care. Logical deletion markers or retained identifiers can be necessary for interpreting later offline operations. Garbage collection depends on the chosen algorithm and knowledge about participants, not simply elapsed age.

Hypothetical failure scenario. A user edits offline, then loses access to the document. On reconnect, a synchronization endpoint merges their operations without checking current permission because the client once possessed a valid document state.

Replication context proves neither continuing identity nor continuing authority. Validate permission at the accepted-operation boundary and define how rejected offline edits are presented to their author. The client may retain local content, but it cannot force the shared document to accept it.

Snapshots and synchronization caches can also disclose restricted content. Scope read access and history retention explicitly. An invitation revoked today cannot retroactively erase every copy already delivered, so keep that limit distinct from preventing future synchronization.

“A CRDT means no conflicts matter.” It provides particular convergence semantics. User intent, application invariants and permissions still require decisions.

“A snapshot replaces the synchronization protocol.” A snapshot records state, but clients still need compatible context to reconcile edits or a declared full-resync path.

“Receiving the same operations is enough.” Interpretation, dependencies and algorithm rules determine the result. Raw arrival order is not a universal correctness rule.

Select a maintained implementation whose actual data model matches the product. Begin with plain text or a clearly defined structured object, then test concurrent insertion, deletion, undo, reconnect and long-offline behavior. Explain unsupported merges rather than pretending every conflict has a natural answer.

Monitor accepted and rejected operations, synchronization lag, replay cost, snapshot compatibility and history growth. Exercise restore with offline clients still holding old state. Recovery that produces readable text but cannot interpret those clients is incomplete.

Reject a custom merge algorithm built from timestamps and string offsets unless its requirements and correctness argument are genuinely established. Reject unlimited offline history without storage and permission semantics. Use explicit version conflicts when they better fit the business.

The operation-size example is a hypothetical payload budget, not a measurement of a particular replicated object. Metadata, snapshots and retained history change storage demand. Convergence applies under the selected operation model; permission and policy approval still need independent authoritative decisions.

Layer 3 · Internals

File synchronization needs a manifest connecting file identity and version to content chunks. Content hashes let devices avoid transferring chunks already present, while a Merkle-style hierarchy can identify changed subtrees without comparing every byte. A hash proves byte identity under the hash assumptions; it does not prove permission to retrieve those bytes. Scope content-addressed lookup and deduplication to the intended security boundary.

Two offline devices can both edit the same base version. Preserve both changes or apply a format-aware merge with declared semantics; timestamps alone cannot establish that one edit supersedes the other. Renames and deletions need identity and tombstone rules rather than being inferred only from current paths. A crash between writing chunks and publishing a manifest must not make a partial file appear complete. Background cleanup must retain chunks referenced by supported historical versions and active transfers. State whether a completed sync means local durability, cloud acceptance or convergence across all currently connected devices.

Trade-offs and limits

ApproachProvidesRequires
Whole-file transferSimple integrity and publication boundaries.Large edits can resend mostly unchanged bytes.
Content-defined or fixed chunk reuseReduces transfer for unchanged content.Chunk manifests, privacy scope and garbage collection add state.

Recovery decision

Hypothetical scenario: An offline device returns after deletion history was collected and recreates an intentionally removed file. Define cursor expiry and resynchronization policy.

No. Two files can share bytes while having different ownership, names and histories. Deduplicate content without collapsing namespace identity or permissions.

Write your design before revealing the review

Does identical file content imply identical file identity?

Evidence you can explain in your own design

Drafts and self-review are stored only in this browser. They are separate from reading completion.

Compare your decision

No. Two files can share bytes while having different ownership, names and histories. Deduplicate content without collapsing namespace identity or permissions.

An offline device returns after deletion history was collected and recreates an intentionally removed file. Define cursor expiry and resynchronization policy.

Check your understanding

Does identical file content imply identical file identity?

No. Two files can share bytes while having different ownership, names and histories. Deduplicate content without collapsing namespace identity or permissions.

How would you recover from this failure: An offline device returns after deletion history was collected and recreates an intentionally removed file. Define cursor expiry and resynchronization policy.

Start with the exact boundary that failed. Hash and upload missing immutable chunks. Publish a new manifest conditional on its base version. Record deletions/moves as versioned namespace changes. Then recover evidence through the observation path: Fetch changes after the device cursor. Download only missing chunks. Surface or merge concurrent manifests under an explicit policy. Preserve the distinction between a confirmed state change and an unavailable response.

Which assumption in the worked calculation would a burst or concentrated tenant invalidate first?

Hypothetical 100 MB file split into 4 MB chunks has 25 chunks. If exactly two chunks change, transferring those chunks sends 8 MB rather than 100 MB, excluding metadata. This assumes fixed chunk boundaries do not shift; content-defined chunking has different costs/behavior. Recompute the affected resource rather than multiplying unrelated storage and network budgets by the same factor. Synchronize file versions across devices without silently overwriting concurrent edits. Stable file identity, content chunks, manifests and deletion history are separate responsibilities.

Which component in this topology could be removed from a smaller first deployment?

Device journal, Chunk store, Version manifest, Sync reconciler name responsibilities, not a requirement for separate processes. Co-locate responsibilities when their transaction, trust and capacity boundaries permit it. Hash and upload missing immutable chunks.

What evidence must a caller have before relying on the observation path?

Fetch changes after the device cursor. Download only missing chunks. Surface or merge concurrent manifests under an explicit policy. No. Two files can share bytes while having different ownership, names and histories. Deduplicate content without collapsing namespace identity or permissions.

45-minute interview rubric

  1. 00–05: scope chunk and file version history.
  2. 05–12: identify the limiting resource and derive the domain workload above, retaining units and assumptions.
  3. 12–28: draw file version history, numbered writes and reads.
  4. 28–40: challenge recovery: Use content hashes and preserve conflicting versions explicitly.
  5. 40–45: defend file_id placement, observations and remaining assumptions.

Go deeper

Decision log

Use content hashes and preserve conflicting versions explicitly.

Preserve chunk identity and file version history ownership.

Revisit changed workload, observations or recovery objectives.