Skip to content

Move can overwrite destination with an empty loaded Y.Doc #1714

Description

@mokandil

Summary

After a batch of move calls over MCP, 7 of ~40 moved documents were later written to disk as 0-byte files by the server's own auto-save (attributed to OpenKnowledge (service), with no agent or human edit in between). The content was only recoverable from project git history.

Environment

  • ok CLI 0.68.3 (latest on npm is 0.74.1 — not yet retested there)
  • Windows 11, project with GitHub-substrate auto-save commits
  • Client: Claude Code over MCP

What happened

  1. An agent restructured a project (~40 docs) using the MCP move tool, e.g. 12-video-and-content-creation/projects/hermes-remotion-setuparchive/hermes-remotion-setup. Moves completed at 22:52–22:54 local time; the shadow history shows the attributed rename: entry for each.
  2. At 22:59 and 23:03, wip: auto-save entries by OpenKnowledge (service) (empty docs list) appear in the shadow history, and the matching project git auto-save commits show the moved files going to 0 bytes (e.g. archive/hermes-remotion-setup.md | 87 -----).
  3. No write/edit targeted those docs between the move and the truncation.

Shadow history for one affected doc (trimmed):

2026-09-15T22:53:01  claude-code              rename: 12-video-and-content-creation/projects/hermes-remotion-setup -> ...
2026-09-15T22:59:37  OpenKnowledge (service)  wip: auto-save   (docs: [])
2026-09-15T23:03:39  OpenKnowledge (service)  wip: auto-save   (docs: [])

Affected: 7 docs, all moved in the same session (pure renames and renames with link rewrites both affected). ~33 other docs moved in the same batch were fine. One doc that was moved and then immediately edited by the agent was not truncated.

Expected

A moved document keeps its content; auto-save never persists an empty body for a doc that had content on disk.

Suspicion (unverified)

The server may hold an empty/unhydrated Y.Doc under the new docName after a move, which the auto-save later flushes over the file. ~/.ok/logs only contains cli command started lines, so I couldn't confirm server-side.

Workaround

Checkpoint before batch moves; after moving, check for find . -name '*.md' -size 0 and restore from git (git show <commit>^:<path>) via write.

Related, possibly: #1094 (silently discarded writes).

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions