Preparing your design workspace

Loading the problem and your latest saved attempt…

Hash-Tree Client/Server Synchronization

Design a version-pinned filesystem synchronization service that uses hierarchical hashes to transfer only changed subtrees while preserving deletions, retries, and end-to-end integrity.

Problem statement

For this exercise, assume a server publishes immutable authoritative versions of one hierarchical filesystem snapshot and clients synchronize local mirrors to a selected version. Every snapshot assigns a deterministic content hash to each file and a deterministic directory hash to its ordered direct children.

A client first compares the root hash, then descends only through mismatched subtrees and transfers the changed metadata or file content needed to reproduce the selected server snapshot. Update plans must represent creates, replacements, and explicit deletions.

A retry or reconnect must resume idempotently against the same version, and a client may report success only after rebuilding and verifying the selected root hash. Design the snapshot metadata, hash-tree comparison, planning, transfer, commit, caching, observability, and recovery paths.

Exclude bidirectional editing, conflict resolution, collaboration, arbitrary file sharing, and authoring a particular hash algorithm.

What to build

  1. The server publishes an immutable filesystem snapshot with a stable version, root hash, and complete traversable hash-tree metadata.
  2. A client compares its declared base state with one selected server version and receives a bounded plan that descends only through mismatched subtrees.
  3. The plan and transfer path represent creates, replacements, and explicit deletions and deliver only content or metadata needed to reconstruct the target snapshot.
  4. A client can resume an interrupted plan idempotently and reports completion only after the reconstructed local tree verifies to the selected server root hash.

At scale

  • Assume a snapshot can contain up to 1,000,000 files and directories, while a typical new version changes at most 1 percent of nodes.
  • Assume up to 10,000 concurrent client synchronizations and require a changed-subtree plan within 2 seconds at p95 under normal load.
  • Assume immutable snapshots are retained for 30 days and file-content objects may be deduplicated by content hash across retained snapshots.
  • Assume the service must survive one availability-zone loss without acknowledging a client at an unverified root or losing an already-published snapshot.