Skip to content

Edit persistence amplifies writes and self-conflicts during fast typing — serialize per-node writes #1492

Closed

Description

@malibio

Overview

During fast typing, a single node's version number climbs rapidly — meaning many UpdateNode commits fire for what should be one logical edit — and edits can OCC-conflict against the user's own prior keystroke. The 500ms debounce does not prevent this.

Problem Statement

Content edits are debounced, and the coordinator's cancelPending coalesces keystrokes that arrive while waiting. But a keystroke that arrives while an UpdateNode RPC is in flight takes the isExecuting branch and is queued, then re-fired after the RPC returns. Fast typing keeps at least one RPC perpetually in flight, so the queue keeps re-firing — producing one commit per RPC round-trip instead of one per pause (the version churn).

The self-conflict follows from the same path: the OCC version is read from localNode.version at execute time and written back on commit; the queued re-run can read that version stale relative to the prior RPC's confirmation (or have it overwritten by an echo or a pending-move in the gap), sending a stale version that OCC-rejects against the user's own previous write. The accumulated scar tissue (serverConfirmedVersions, the pending-move await, "re-read at execute time" comments) works around this gap rather than closing it.

The debounce didn't help because it guards the scheduling gap, not the in-flight gap, and the queue path explicitly bypasses coalescing while executing.

Proposed Solution

Replace the queue-and-re-fire behavior with a genuine per-node serial writer: while a write for a node is in flight, collapse further edits into a single latest-wins pending write that runs after the prior write's version confirmation lands (so it always reads a confirmed version). This makes a conflict-with-self structurally impossible and makes the debounce a pure UX nicety rather than a correctness crutch. Ties into the reactive-store refactor (persistence/version/optimistic state stop being three hand-synced subsystems).

Acceptance Criteria

  • Typing a word quickly produces a single committed UpdateNode after the pause, not one per RPC round-trip
  • A node's version increments once per coalesced edit, not per keystroke-burst
  • No OCC conflict can occur between two writes to the same node originating from the same client's sequential edits
  • The queued-operation re-fire path is replaced by a latest-wins serial writer that reads the version only after prior confirmation
  • Code passes bun run quality:fix; tests pass (bun run test:all)

Technical Specifications

Reference Files

  • shared-node-store.svelte.ts: packages/desktop-app/src/lib/services/shared-node-store.svelte.ts — SimplePersistenceCoordinator (the isExecuting/queuedOperations re-fire path) and the UpdateNode execute closure (version selection currentNode.version, write-back on commit)
  • Related pattern: ADR-049 (reactivity store)

Implementation Details

  • The commits-per-edit assertion belongs in the Tauri-seam e2e suite (tracked separately)

Dependencies

Related Issues

Activity

  1. malibio commented on Jul 5, 2026

    @malibio
    CollaboratorAuthor

    Related work: the commits-per-edit regression test lives in the Tauri-seam e2e harness (#1499); the outbound-coalescing defense-in-depth is tracked in nodespace-sync (#256).

  2. malibio commented on Jul 6, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 146 test files passed, 3939 tests passed

  3. self-assigned this
    on Jul 6, 2026
  4. added 2 commits that reference this issue on Jul 6, 2026
    7d157ac
    678a2f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions