noCV
PDOC-110 · Exercise larger and changing documents

Reject stale history after replacing the document

Practice briefBugExpert

A delayed keyboard event queues Undo just before a successful import installs another document. The old history entry then restores part of the previous document into the replacement because both documents happen to contain node p1.

Focused work estimate
4h + prerequisites
Priority in the scenario
High
Engineering practice
Concurrency modeling · State transitions · History integrity

Estimated field mix

  • Frontend50%
  • System design30%
  • Quality engineering20%

Field percentages are editorial estimates of the ticket's engineering focus. They total 100%; they are not measured time, proficiency scores, or ownership evidence.

Pattern topics

  • CommandRefactor

    Bind queued editor operations to the session that created them so delayed commands cannot operate on a replacement document with reused node IDs.

  • MementoRefactor

    Give history snapshots an explicit document-session boundary and install replacement content together with a coherent history reset.

Your next step

Review it, then add it to your workspace.

The board opens an editable draft; nothing is saved until you confirm it. Sign-in and workspace permissions apply, and Demo boards remain ephemeral.

Project context

A fictional support team edits reusable troubleshooting documents with paragraphs, links, and nested sections. The browser prototype has separate toolbar and keyboard handlers, an unreliable undo stack, and mutable shared formatting objects. Create a local editor and synthetic documents; no starter assets, rich-text engine, collaborative backend, or production service is supplied.

Setup prerequisites

  • Browser events
  • Immutable updates
  • Accessible form controls

Preceding work

Complete these dependencies, or supply their agreed outputs before taking this ticket.

Acceptance criteria

  • Bind commands and history entries to a document session identity as well as a revision.
  • Replacement import commits document, logical selection, session identity, and history reset as one state transition.
  • Stale queued commands and incompatible snapshots fail without modifying the active document; cancellation preserves the previous session and valid history.

Implementation constraints

  • Build a deterministic event-order harness rather than timing-dependent sleeps; this ticket does not require collaborative editing or remote persistence.

Verification to include

  • Interleave queued Undo, successful import, and duplicate node identities; assert the replacement never receives previous-session content.
  • Fail and cancel imports at each transition boundary, then verify undo remains valid only for the preserved session.

Deliverables

  • Session-bound command/history contract and interleaving regression matrix

Rollout and recovery

Introduce session identities at the local editor boundary and clear incompatible transient history once; preserve saved content separately for recovery.

Value of the work

For the engineer: Practice relating object and state patterns to real UI behavior, including undo semantics, bounded traversal, lifecycle cleanup, and memory tradeoffs.

For the team: Review whether editor changes preserve user work, keep controls consistent, and reduce maintenance effort without concealing document corruption.

Evidence boundaries

Outcome Evidence: Tests, patches, and runbooks are requested deliverables. They become Outcome Evidence only through a qualified Mission and immutable Evidence IDs.

Ownership Evidence: Independent adaptation must be observed under a declared verification policy and cite immutable Evidence IDs. Completing a planning ticket establishes no Ownership Evidence.