TSTier SlateAll templates
  1. Home
  2. Templates
  3. Code review

Collaboration

Code review - the comment is on a line that moved

What it takes to keep a conversation attached to code that is rewritten underneath it while the conversation is still going.

  • System design
  • core
  • 9 step walkthrough
  • 5 tables
Own this board 400 creditsPractise as an interview

The first act plays here. Owned once with credits, never a subscription.

Share

  • Facebook
  • X

What this board gets wrong on purpose

The tension

Comments are re-anchored by mapping the old head to the new one through an interdiff, with a context hash as the fallback and an "outdated" marker when both fail - and roughly 9% of comments go outdated on a typical force-push, at which point they are collapsed, unread and effectively deleted by the interface rather than by anybody deciding to delete them. Approvals have the same anchoring problem and the board deliberately does NOT solve it the same way: an approval is stored against a head_oid, and dismissing it on every push is correct and is turned off by most teams within a month because it is annoying, which leaves an approval attesting to code nobody approved. Then the merge gate: requiring a branch to be up to date before merging is the only way to catch two changes that pass separately and fail together, and it serialises the entire repository - so the board adds a speculative merge queue, whose batches are held in memory by one process, and a deploy or a crash in the middle of a batch throws away every build in it and re-runs the lot.

Practise this as an interview

Take Code review - the comment is on a line that moved as a timed system design interview on a blank board - on your own, with the requirements to check yourself against, or with a candidate you invite.

Practise this as an interview

Start here

Why this design

Code review looks like a workflow - propose, discuss, approve, merge - and the workflow is an afternoon. The real problem is that the code under discussion is replaced while the discussion is still going: every force-push moves the lines that comments and approvals were attached to, and every merge invalidates the green build of every other open change. Interviewers use it to see whether you notice that a comment is anchored to bytes in a commit rather than to a line number, and whether you can reason about a merge gate that is correct without serialising a whole repository. Teams that build review tools spend most of their effort on exactly these two things.

What you will learn

  • How a comment is anchored - blob hash, side, line and a context hash - and why the file path is deliberately not its identity.
  • How an interdiff (old head against new head) re-places most comments by pure arithmetic, when the bounded context-hash search takes over, and why roughly 9% are marked outdated rather than guessed.
  • Why an approval should be stored against a head_oid, and what quietly breaks when teams stop dismissing approvals on push.
  • Why the merge gate reads stored check verdicts and never calls CI live.
  • Why "up to date before merge" serialises a busy repository into 114 hours of work a day, and how a speculative merge queue batches six changes to fit it into 19.
  • Why the storage bill is CI logs at a petabyte a year rather than review rows at eleven terabytes, and how retention keeps it at 19 TB.

How to read this board

  1. Diagram, left to right: PEOPLE, then THE PROPOSAL (a push becomes two hashes), then CI · LOUD, AND NOT ON THE COMMENT PATH.
  2. Then the wide middle band, ANCHORS · WHERE DID LINE 42 GO - the actual subject of the board - and the right-hand column: THE GATE · WHAT MUST BE TRUE and AFTER · WHO IS NOW BLOCKED. Press play for the nine-step walkthrough.
  3. Page 1 · Requirements - the decisions to force before drawing: rewriting, outdated comments, stale approvals, up-to-date merges.
  4. Pages 2 and 3 · Capacity and Storage - why re-anchoring is two cores, why the merge queue is the real bottleneck, and why logs are the storage bill.
  5. Page 4 · Availability - the merge queue as the only live state, and the misplaced comment as the failure with no alert.
  6. Page 5 · How it works - one force-push told end to end, then Page 6 · Deployment plan, including draining the queue and shadowing resolver changes.
  7. Finally the DATA MODEL at the bottom: five tables, where the anchor is a third of the comment row and all of the work.

1 · Requirements

Ask these before drawing anything

  • May the branch be rewritten, or only appended to? Append-only makes anchoring almost trivial and makes the history unreadable. Every team picks rewriting and then meets this board.
  • What should happen to a comment on a line that no longer exists? There is no correct answer. Pick between "silently move it somewhere plausible" and "say it is outdated", and know that the second one means nobody reads it again.
  • Does an approval survive a new push? The honest answer is no. The popular answer is yes. Decide deliberately, because the difference is whether an approval is evidence or decoration.
  • Must a branch be up to date with the target before merging? Yes catches the two-changes-that-pass-separately failure and serialises the repository. No is faster and lets that failure through. This is the single biggest performance decision here.
  • How many required checks, and who may make a check required? A required check with a flaky runner is a repository-wide outage with no incident channel.
  • Are comments threaded, and can a thread be resolved by anyone or only by its author? This changes what "unresolved" means in the merge gate, which is the one place it has teeth.
  • How long are CI logs kept? This is the entire storage bill of the product and it is usually decided by nobody.
  • Is review required for every change, including reverts during an incident? The break-glass path should be designed, logged and loud - not discovered at 3am.

Functional

  • Propose a change as a branch against a target, with a description and a diff.
  • Comment on a specific line of a specific file, in a thread, and resolve it.
  • Survive a branch update: comments follow their code where it can be found, and are marked outdated where it cannot.
  • Approve or request changes, recorded against the exact head that was reviewed.
  • Run required checks per head commit and report their state.
  • Merge only when the gate is satisfied, with a recorded reason when it is bypassed.

Non-functional

  • Diff render for a 400-file change: p95 under 1.5 s, cached thereafter.
  • Re-anchoring after a push: p95 under 3 s for 50 comments, and it must be idempotent - running it twice on the same pair of heads produces the same anchors.
  • A comment, once posted, is never lost. Being marked outdated is not loss; being dropped because the re-anchor threw is.
  • The merge gate is evaluated from stored facts only, never from a live CI query. A gate that depends on an external service being up is an outage waiting for a deploy freeze.
  • 99.9% for reading and commenting. 99.5% for merging: a blocked merge is annoying, a wrong merge is not recoverable by retrying.

Out of scope

  • The version control system itself - the branch update is this board’s input.
  • Running the builds. This board queues them and reads their verdicts.
  • Static analysis and suggestion bots, which arrive here as ordinary comments and have the same anchoring problem in a louder voice.

The rest of this board

Preview of the Code review system design board: 16 components joined by 21 connections. The labelled board opens in Tierslate.
Board preview

Available on Tier Slate

This page publishes the question. The answer — 5 more written pages, a 9-step narrated walkthrough and a 5-table schema — is the board itself, and it opens in Tierslate.

  • 5written pages
  • 9walkthrough steps
  • 5tables42 columns

5 pages behind this one

  • Capacity estimation
  • Storage estimation
  • Availability
  • How it works
  • Deployment plan
Open this board in TierslateBrowse every board

Related system design templates

Several people editing one thing without losing an edit. 7 more collaboration templates:

  • Calendar scheduling system design - Why a meeting time is computed from rules and guesses rather than read from a table, and what that costs.
  • Collaborative editor system design - How two people type into one document at the same time without either of them losing a character.
  • Version control system design - Why history is a graph rather than a list, and what that costs at merge, at fetch and at garbage collection.
  • Whiteboard sync system design - Why a shared canvas is mostly a broadcast problem, and what happens to a shape that two people grab at once.
  • Kanban board system design - How cards are reordered with fractional ranks instead of renumbering, and how live updates reach every viewer.
  • File sync system design - How files sync across devices by chunk and version, and what a conflict looks like when two laptops were offline.
  • Multiplayer game server system design - Why an authoritative server with client prediction hides latency, and how a tick rate sets cost and fairness.
Open the Code review board in TierslateAll collaboration templatesAll 100 system design templates
Tierslate

tierslate.com

HomeTemplatesGuidesCompareAboutUI mockupsPrivacyTerms