LIVING SPECIFICATION / MOCK 04

Realtime Collaborative SDLC

Design structured Requirements and Blueprint documents where humans and agents coedit, comment, suggest, publish versions, and survive offline races without losing intent.

30 MINUTES 16 INTERVIEWER TURNS FULL Q & A INTERACTIVE LAB

The problem on the whiteboard

Read this once, then begin aloud. Spend the first two minutes establishing contract, actors, risk and what must remain authoritative.

Design LivingSpec, a multi-tenant collaborative editor for structured Requirements and Blueprints. Humans and AI agents edit concurrently; documents contain typed requirement blocks, acceptance criteria, architecture components and references. Users need presence, comments, suggestions, offline edits, version history, approval, diff and a stable published revision for downstream work orders.
Central design thesis

Use convergent draft operations for availability, but make schema-valid publication a server-authoritative transaction. Draft collaboration and approved truth have intentionally different consistency models.

Scope before components

These are supplied mock numbers for sizing and follow-ups. Say your assumptions before using them.

Workspace 10,000 organizations · 1M documents · 40M structured blocks
Concurrency Up to 150 live editors/agents on one document; 8,000 ops/s global peak
Latency Local echo < 30 ms; remote op p95 < 250 ms; reconnect < 5 s for normal docs
History Seven years of approved revisions; 90 days granular draft ops
Trust No lost accepted edit; published revision schema-valid and immutable

Actors

  • Product manager editing requirements
  • Architect maintaining blueprints
  • Reviewer approving or rejecting suggestions
  • AI agent drafting or proposing a patch
  • Commenter and mentioned teammate
  • Org admin or auditor

Functional scope

  • Structured block editing with real-time presence
  • Comments, anchored threads and suggestions
  • Offline operation and agent patch rebasing
  • Immutable published revisions, diff and approval
  • References and validation across documents

Explicitly out

  • Full source-code editor
  • Video calling
  • Arbitrary pixel-perfect pages
  • Autonomous agent publication
  • Cross-organization public documents

A traceable end-to-end path

Name the authoritative state, derived projections, asynchronous boundaries and the exact point where a business decision becomes durable.

Realtime Collaborative SDLC reference architecture Six stage architecture from Client replica through Published truth. Client replica optimistic echo Realtime edge auth + rooms Op log ordered per doc Materializer snapshots Validator schema + refs Published truth immutable revision audit · policy · metrics · lineage
01 Client replica optimistic echo
02 Realtime edge auth + rooms
03 Op log ordered per doc
04 Materializer snapshots
05 Validator schema + refs
06 Published truth immutable revision

Keys that preserve history

The table is logical, not a mandate for one database. Choose physical stores after access patterns, transactions, retention and rebuildability are clear.

Entity Primary / unique key Important fields and purpose
Document (tenant_id, document_id) type, title, draft_epoch, published_revision, acl_epoch
Block (document_id, block_id) kind, parent_id, rank, attributes, tombstone
Operation (document_id, draft_epoch, actor_id, op_seq) client_op_id, causal_clock, payload, received_at
Snapshot (document_id, draft_epoch, snapshot_seq) state_blob_hash, vector_clock, schema_version
Suggestion (document_id, suggestion_id) base_clock, patch, author, state, decision_version
CommentThread (document_id, thread_id) anchor_block, relative_range, context_hash, state
PublishedRevision (document_id, revision) content_hash, approval_set, source_clock, immutable_body
ReferenceEdge (from_revision, from_block, to_document, to_block) edge_type, resolution_state
WS /v1/docs/{id}/sessions

Join with draft epoch, auth token and last vector clock

snapshot + missing ops
POST /v1/docs/{id}/operations

Batch offline ops; clientOpId dedupe

accepted clock / rejected epoch
POST /v1/docs/{id}/suggestions

Patch against base clock with intent summary

201 {suggestionId,rebaseStatus}
POST /v1/suggestions/{id}/decision

Accept/reject with expected decisionVersion

200 / 409
POST /v1/docs/{id}/publish

Expected draft clock + approvals + idempotency key

201 {revision,contentHash}
GET /v1/docs/{id}/diff?from=&to=

Semantic block diff between immutable revisions

200 {changes}

The complete mock interview

Answers are written in a speakable first-person style. Turn on Practice Mode to hide them, answer aloud, then reveal one at a time.

INTERVIEWER

Design the collaborative product.

CANDIDATE

Candidate · clear top-down answerI see two promises. Drafts should feel instant and keep working offline. Published versions must be fixed, reviewed, and safe for other systems to use. I would design those as separate paths.

Why this mattersThis gives the interviewer a map before any boxes appear, and it makes the system's most important trust decision explicit.

INTERVIEWER

Clarify scope and semantics.

CANDIDATE

Candidate · clear top-down answerVersion one supports structured requirements, comments, suggestions, offline edits, and publishing a fixed revision. People may edit; agents may only suggest. We will not build free-form design tools or automatic code changes yet.

Why this mattersA narrow first release keeps the design realistic. It also shows which tempting features can wait without weakening the core product.

INTERVIEWER

Estimate load and storage.

CANDIDATE

Candidate · clear top-down answerThe peak is 8,000 small edit operations each second, or about 2.8 MB/s. If that peak lasted all day, the raw edit log would be roughly 240 GB/day before copies and indexes. The bigger storage risk is keeping every keystroke forever. I would keep recent edits for fast replay, combine older ones into snapshots, and keep published versions permanently. The calculator deliberately shows the worst case so we can size retention safely.

Why this mattersThe calculation is not about perfect forecasting. It identifies the part most likely to run out of capacity or delay users.

INTERVIEWER

Model the data.

CANDIDATE

Candidate · clear top-down answerThe main records are document, block, edit operation, snapshot, suggestion, comment, approval, and published revision. Blocks get stable IDs so comments and moves keep pointing to the right thing. We read a room by document ID and sequence, reconnect from a client's last sequence, and publish by exact snapshot hash. Presence and cursor positions are temporary and do not belong in the permanent truth.

Why this mattersA small set of records is easier to reason about. Exact versions keep later changes from silently rewriting an earlier decision.

INTERVIEWER

Why a CRDT, and where would you not use it?

CANDIDATE

Candidate · clear top-down answerA conflict-free replicated data type, or CRDT, is a merge method that lets offline edits meet later without losing either side. I would use it for draft text and ordering, but not for publishing, permissions, approvals, or billing.

Why this mattersThe merge tool solves concurrent draft edits, not business authority. Keeping publish and approval transactional prevents “it merged” from being mistaken for “it is valid.”

INTERVIEWER

Walk the architecture.

CANDIDATE

Candidate · clear top-down answerThe client saves an edit locally, sends it to a nearby realtime server, and receives an acknowledgement only after the edit reaches a durable log. Other users see it through the live room. Background workers build snapshots and run document checks. Publishing follows a separate path: validate one snapshot, its references, and its approvals in a database transaction, then create a fixed revision for downstream systems.

Why this mattersTracing one real request proves the boxes connect. It also exposes where we acknowledge success and where a retry may begin.

INTERVIEWER

Deep dive: structured documents create harder conflicts than text. Solve that.

CANDIDATE

Candidate · clear top-down answerText merging is not enough for structured documents. Each edit says what it means: move this block, change this field, or add this link. Moving a block and editing its text can merge, but deleting a required block while another user links to it creates a business conflict. We preserve both edits, show the conflict, and block publishing until a person resolves it. Automatic convergence does not mean the document is semantically valid.

Why this mattersThe deep dive starts only after the basic path is clear. Use one concrete example, then state the speed-versus-correctness choice.

INTERVIEWER

Deep dive: comments and suggestions must survive edits.

CANDIDATE

Candidate · clear top-down answerComments point to a stable block plus positions that move with the text. If the block is deleted, the comment becomes orphaned but is not lost. Suggestions are small edit sets, so people can preview and accept them safely.

Why this mattersAnchors need stable identity plus a clear orphan state. Silently attaching a comment to nearby text would preserve the UI while changing its meaning.

INTERVIEWER

How do consistency and idempotency work?

CANDIDATE

Candidate · clear top-down answerDraft edits may arrive more than once and a little out of order; stable edit IDs make repeats harmless. Publishing is stricter: it checks the exact content hash and approvals in one transaction so only the reviewed version can ship.

Why this mattersUse immediate agreement only for decisions that cannot be ambiguous. Let rebuildable views catch up and always show their freshness.

INTERVIEWER

Failure injection: an agent works offline for 20 minutes while humans restructure the document.

CANDIDATE

Candidate · clear top-down answerAn offline agent returns a suggestion based on an old version, never a full document replacement. Stable block IDs let us apply independent edits. Anything that targets deleted or changed blocks becomes a visible conflict for a person.

Why this mattersA failure answer should name the uncertain state first. Then explain how the system learns the truth before it repeats an action.

INTERVIEWER

What about hot rooms and reconnect storms?

CANDIDATE

Candidate · clear top-down answerFor a very busy document, assign the room to one ordered stream, combine tiny updates into frames, and cap each user's buffer. A slow client gets a fresh snapshot plus missing edits instead of forcing the server to hold unlimited history in memory. Reconnects use randomized delay, and room ownership moves with a numbered lease so two servers cannot both accept writes after failover.

Why this mattersBusy tenants and large jobs need limits. Reserved capacity keeps one customer or one import from delaying everyone else's live work.

INTERVIEWER

Failure injection: two humans approve while an agent changes a required block.

CANDIDATE

Candidate · clear top-down answerApprovals belong to an exact content hash. If an agent changes a required block, the old approval becomes stale. Publishing either writes exactly the reviewed content or fails and asks the user to review again.

Why this mattersAn approval covers exact bytes, not a moving document name. The hash check turns a subtle race into a safe, visible request to review again.

INTERVIEWER

Security and tenant isolation?

CANDIDATE

Candidate · clear top-down answerCheck permission when a user joins, reconnects, publishes, or exports. Every database, cache, room, and log key includes the customer ID. Agent tokens are short-lived and limited to one project, document, and action. Document text is untrusted data, never an instruction to a tool, so an agent cannot gain permission from text someone typed into the document.

Why this mattersSecurity belongs in keys, tokens, workers, and logs. It is not a single box added to the diagram at the end.

INTERVIEWER

How do you observe and evaluate it?

CANDIDATE

Candidate · clear top-down answerMeasure edit acknowledgement time, peer update time, reconnect time, publish conflicts, lost comment anchors, and whether every replica reaches the same result. Launch single-user editing first, then online collaboration, offline work, and finally agents.

Why this mattersMetrics should cover user speed, system safety, and result quality. Rollout starts read-only and earns stronger automation with evidence.

INTERVIEWER

Rollout, trade-offs and traps?

CANDIDATE

Candidate · clear top-down answerOffline support makes the merge logic complex. If offline editing is not important, a simpler server-ordered design may be better. Never use the moving draft as a release input; always publish one fixed revision.

Why this mattersEvery design choice has a cost. Name the simpler alternative and explain which requirement makes the added complexity worth it.

INTERVIEWER

Give me your spoken recap.

CANDIDATE

Candidate · clear top-down answerIn short: drafts are fast, local, and mergeable; published versions are fixed and carefully checked. Stable block IDs preserve meaning, agents only suggest changes, and one strong publish step turns a changing draft into trusted input.

Why this mattersThe recap should repeat the user flow, the main trust rule, the hardest failure, and the most important trade-off—not every component.

Two places to earn the strong hire

These mechanisms are the interview’s differentiators. Be able to redraw each from memory and defend its failure behavior.

01

Deep dive A · Two consistency planes

Draft collaboration optimizes availability and convergence. Publication optimizes reviewability, invariants and stable downstream references.

  1. Optimistic local draft operations
  2. Durable per-document op order
  3. Incremental semantic validation
  4. Content-bound approvals
  5. Serializable immutable publish
02

Deep dive B · Durable anchors

Identity and relative positions survive routine editing; explicit orphan states preserve context when their target disappears.

  1. Stable UUID for every block
  2. CRDT-relative text positions
  3. Context hash for recovery
  4. Orphaned thread history
  5. Suggestion patch rebased as typed intent

Revise, do not hand-wave

When the interviewer injects a fault, restate the violated assumption, change state or protocol, and name the new invariant.

Injection Recovery mechanism Tempting wrong answer
01Duplicate/offline ops actor sequence + clientOpId dedupe Double insert
02Slow client Bound buffer; send catch-up cursor Room memory blow-up
03Hot document Scale fan-out; preserve one logical op order Split brain
04Stale agent patch Rebase preview or explicit conflict Whole-doc overwrite
05Approval race Bind approval to content hash; serializable publish Unreviewed content ships
06ACL revoked Epoch-fence socket and caches Stale connection reads

Calculate before you provision

Use orders of magnitude to expose the bottleneck. State what this simple model omits.

Collaboration storage lab

Tune mock peak operation rate, size and granular retention. The result is a deliberately conservative peak-sustained bound; approved revisions are separate.

Peak-sustained raw operation volume — Change an input to recalculate.
Ops
—
Snapshots
—
Published
—
Indexes
—

Prove quality in production

A system is incomplete without observable user outcomes, staged deployment, rollback and an answer to “how will we know?”

Scoreboard

  • Operation ack and peer latency
  • Acknowledged-op loss (target zero)
  • Convergence hash mismatch
  • Reconnect bytes and duration
  • Publish conflict/validation rate
  • Comment anchor orphan rate

Rollout ladder

  1. 01 Single-user blocks + versioning
  2. 02 Online coediting
  3. 03 Snapshots and reconnect
  4. 04 Comments + stable anchors
  5. 05 Suggestions + agent patches
  6. 06 Offline mode and org-scale hardening

Corrections worth memorizing

Use these as flash cards. The right column is the compact sentence you want available under pressure.

Trap Better move
CRDT = semantic correctness Validate domain invariants separately.
Character-offset comments Use stable block + relative text anchors.
Approval of “latest” Bind it to immutable content hash.
Agent replaces whole doc Require typed patch with base clock.
Presence in the audit log Keep it ephemeral and expiring.
Socket authorized forever Fence sessions with ACL epochs.

Vocabulary without fog

Define the term, then connect it to a concrete invariant in this design. Avoid dropping vocabulary as a substitute for reasoning.

CRDT
Data type whose concurrent operations converge without central conflict resolution.
Causal clock
Metadata describing which operations an edit has observed.
Tombstone
Deletion marker retained long enough for concurrent references to converge.
Canonicalization
Deterministic serialization so equal logical content has the same hash.
Materializer
Consumer that turns an operation log into queryable current state.
Optimistic concurrency
Mutation succeeds only when the caller’s expected version is current.
Relative anchor
Position tied to collaborative text identity rather than fragile integer offset.
Outbox
Rows written with a transaction and later delivered as reliable events.

Close with a decision, not a component list

LivingSpec keeps a highly available convergent draft and a strongly controlled published truth. Clients optimistically apply typed CRDT operations; a document-partitioned log durably orders accepted ops, materializers snapshot and validate them, and ephemeral presence stays outside truth. Stable block IDs preserve moves, comments use relative anchors, and agents submit reviewable patches against base clocks. Publication validates schema, references, approvals and expected content in one transaction, producing an immutable hash. Epoch fencing, dedupe, convergence fuzzing and gradual rollout make human-plus-agent collaboration trustworthy.

Rehearse again