Skip to content

Undo identifies a file by path only: a file replaced after an operation is overwritten or cut by its undo #239

Open

Description

@hyperpolymath

Found on 2026-11-17 while fixing redo in #231. Confirmed on that branch with a probe; no redo is involved.

Reproductions

  • f holds old; /bin/echo hi > f; another file is renamed over f; undo leaves f holding old. The replacement is overwritten.
  • f holds 10 bytes; /bin/echo hi >> f; a 28-byte file is renamed over f; undo cuts the replacement to 10 bytes.

The replacement can happen at any time between the operation and its undo, from another process or from an external command run in the shell.

Fix direction

Record with each operation what it left at the path (a content hash, or device and inode), and have undo refuse, with a clear error, when the path no longer holds that. The same check applies to redo.

This changes the persisted history record, so it must be coordinated with #230 (blob store, versioned migration). Old history files must still load.

Related

  • Two review threads on Fix redo: redone operations keep their undo data, and redo restores what the operation produced #231 (on replace_through and append_through) were left open pointing at this.
  • hyperpolymath/januskey's reversible-core OperationMetadata already has this shape (content_hash, new_content_hash). Use it as a reference, not a dependency (see .claude/CLAUDE.md).
  • More generally, every operation checks its preconditions by path before it acts. Doing operations through directory and file handles instead of paths would close that class; that is a larger change than this issue.

Done means

  • The two reproductions end with the replacement file untouched and a clear error from undo.
  • An old-format history file still loads and undoes (fixture test).
  • In impl/rust-cli: cargo fmt --check, cargo clippy --all-targets --all-features -- -D warnings and cargo test pass. Commits signed.

Wider than this repository

The same question applies to hyperpolymath/januskey: does its undo verify new_content_hash before it writes? This has not been checked.

Activity

  1. coderabbitai commented on Nov 17, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #232 - Runtime holes: 13 of 15 closed, by containment through a directory handle and a fixed session root [open]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaves incorrectlypriority:p2Normal - queue itscope:repoConfined to this repositorysecurity

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions