WEEK 04 · 2026-08-19 · WED

Google Docs:operation log、concurrent edits 与实时协同 HLD

把 Google Docs 从“同步文本”拆成 operation log、revision/context、transform/rebase、presence/cursor soft state。

今日固定时间表

08:30 wake 只保留起床;学习从 08:50 开始。三块窗口不互相挤占。

08:30 wake起床、早餐、准备白板;不安排预读或算法。
08:50—09:1008:50—10:55 system design
闭卷 HLD — 先定义 Document、Operation、Revision、Session、Presence。
09:10—09:4508:50—10:55 system design
精确原文 — 读 Google Docs requirements/API/HLD 与 Collaborative Edits Breakdown。
09:45—10:2508:50—10:55 system design
机制化白板 — snapshot + op log;submit op 带 baseRevision;服务端 sequencer 分配 new revision;客户端 transform/rebase。
10:25—10:5508:50—10:55 system design
DDIA 决策卡 — 多主冲突、本地优先实时协作和 CRDT/OT 的设计影响。
14:30—16:15NeetCode Tag · Sliding Window
三道题在下方独立算法表执行。
20:30—21:1520:30—21:15 Google Docs 英语 recall:operation log、base revision、concurrent edits、presence。

算法模块

连续单一 NeetCode Sliding Window tag;每天 3 个 NEW slot,每题 30 分钟作答 + 5 分钟证据,正好 105 分钟。每天 timed review = 0,满足不超过 1。

#Problem / modePatternInvariantBug riskTimeSpace
7Max Consecutive Ones II
NEW · 30m solve + 5m evidence
至多一个零的可变窗口窗口内 zeroCount <= 1。第三个零后只缩一次而非缩到合法。O(n)O(1)
8Longest Substring with At Most Two Distinct Characters
NEW · 30m solve + 5m evidence
至多 K 类字符窗口count 中正频次字符数 <= 2。频次归零后未删除 key。O(n)O(1) alphabet
9Longest Substring with At Most K Distinct Characters
NEW · 30m solve + 5m evidence
至多 K 类字符窗口收缩结束后 distinct <= k。k=0;删除左字符时漏减 distinct。O(n)O(k)

闭卷起手

20 分钟闭卷画 loadDocument、submitOperation、subscribeOps、updateCursor;写出 LWW 为什么丢用户意图。

Hello Interview 精确目录

day 页面使用 canonical data-toc-id/H4 anchors;周级 overview 不放小节链接。

项目精确 canonical sectionDisposition今天怎么用
Google DocsUnderstanding the Problemrequired readingcollaborative document surface
Google DocsFunctional Requirementsrequired readingdocuments, concurrent edits, realtime changes, presence
Google DocsNon-Functional Requirementsrequired readinglatency, availability, consistency boundary
Google DocsSet Uprequired readingscope and simplifications
Google DocsPlanning the Approachrequired readingentities/API/HLD sequence
Google DocsDefining the Core Entitiesrequired readingDocument, Operation, Revision, Session, Presence
Google DocsDefining the APIrequired readingload document, submit op, subscribe, cursor
Google DocsHigh-Level Designrequired readingdocument service + op log + websocket broadcast
Google Docs1) Users should be able to create new documents.required readingdocument metadata and initial revision
Google Docs2) Multiple users should be able to edit the same document concurrently.required readingconcurrent operation semantics
Google Docs3) Users should be able to view each other's changes in real-time.required readingoperation broadcast and replay
Google Docs4) Users should be able to see the cursor position and presence of other users.required readingsoft presence, not durable truth
Google DocsCollaborative Edits Breakdowndeep diveH4 breakdown of edit path

DDIA 精确决策卡

只读能改变今天设计决定的小节。

项目问题精确 DDIA subsection改变的系统决定
Google Docs 多人并发编辑为什么不是简单 last-write-wins?Ch6 · 处理写入冲突文档编辑必须保留用户意图,不能用 LWW 丢弃并发操作;需要 OT/CRDT 或服务端 sequencer。
协同编辑的浏览器副本为什么像多主复制?Ch6 · 实时协作、离线优先和本地优先应用本地先应用,异步同步到其他客户端;必须显式处理冲突、回放和撤销。

本日项目 artifacts

脚本、音频、PDF 与 mock evidence 直接从对应日打开。

今日产出、修复与英语 recall

课程角色CORE · requirements/API/data model/HLD
必须交付Google Docs HLD:Document snapshot、Operation log、baseRevision、ack/rebase、presence/cursor state。
修复规则如果用 last write wins 覆盖整篇文档,补 OT/CRDT 或服务端 sequencer 如何保留用户意图。
English recall
English recall: “Collaborative editing stores intent-preserving operations, not just the latest document blob.”
Local study materials
Detailed lecture notes, audio, recall scripts, PDFs, Staff Q&A, and mock packs are archived locally and are intentionally not published on this site.