System Design Atlas

Collaborative documents with offline edits

04 / 10Worked example

Change commands and retries

How does a stable change identity prevent dual or contradictory acceptance?

Scale alone does not ensure consistent retry behaviour. This proposed API binds the role, business object, change payload and expected state to each new intent. An idempotency key identifies the same intent after a response is lost.

Starting point Test document hotspots separately from overall load.

Assumptions for the example case

Our own fictitious example design: A text document with a character sequence and comments; several devices per person; deterministic merging; server-side checked permissions during synchronization. Figures and quality goals are illustrative test assumptions. Outside are table formulas, encrypted end-to-end cooperation and automatic content conflict resolution.

Retries and new intent

Synchronization envelope · Operation instead of document overwriting

OperationD-91 · O-91 · Base position · X
Operation → AnnahmeRight + byte number
AcceptanceConfirmed/Rejected
identically confirmedO-91 with Z → conflictrejected → locally exportable

The same operation identity returns the existing confirmation; different content causes a conflict and cannot silently become valid.

O-91 is sent again. Compare identity and canonical payload. X is accepted once; Z under the same identity is rejected.

Proposed domain API contracts

  1. POST/documents/{id}/changes

    Submit offline change for acceptance.

    Input
    Editor identity, D-91, G-91, device counter, O-91, parent reference, character operation and canonical content up to 65536 UTF-8 bytes.
    Result
    Confirmed change identity when current write permission allows it. A missing dependency leaves the change waiting; revoked permission or a changed retry causes rejection.
    Retry behaviour
    An identical operation by the same authorised role on the same object, using the same key and canonical payload, returns the stored original result. A changed payload under that key is rejected. External result identifiers are durably deduplicated after authentication; new intents check the current version again.
  2. POST/documents/{id}/grants

    Change write permissions.

    Input
    Document owner, D-91, target person, role, expected permissions version, reason and key.
    Result
    New rights version applies atomically to the following change acceptance; historically confirmed changes are preserved.
    Retry behaviour
    An identical operation by the same authorised role on the same object, using the same key and canonical payload, returns the stored original result. A changed payload under that key is rejected. External result identifiers are durably deduplicated after authentication; new intents check the current version again.
  3. GET/documents/{id}/sync

    Read confirmed changes since the known revision.

    Input
    Authorized identity,D-91, device reference and last confirmed change state.
    Result
    Missing accepted changes or snapshot with full revision watermark; local unconfirmed work remains separate.
    Retry behaviour
    Repeating a read creates no business effect; the returned current state may change between requests.

Protect change identity

Protect change identity

Compare identity and canonical payload.

O-91 is sent again.

X is accepted once; Z under the same identity is rejected.

Alternative considered
Only counter progress overlooks manipulated repetition.
Trade-off
Metadata must be retained.
Reassess
Device change requires regulated new identity.

Terms in this step

Protect change identity
X is accepted once; Z under the same identity is rejected.

Try it yourself

Send O-91 with X twice and then with Z. Predict text effect and conflict.

A hint for your attempt

Use the specific entities and conditions from this step. The two solution parts distinguish the decision from its evidenced outcome.

Compare with a possible solution
First part of the solution
X is accepted exactly once under O-91.
Second part of the solution
Z under the same identity is rejected; a real new change needs a new stable identity.

Apply to your project

Which corresponding assumption in your project would you check first? Use as an occasion: Device change requires a regulated new identity.

Step 5 Examined: Check rights upon acceptance.