Skip to content

Undo through symbolic links: rm is undone as a regular file; a redirection through a dangling link is undone by deleting the link #234

Open

Description

@hyperpolymath

Found on 2026-11-17 while fixing redo in #231. The Rust shell records the wrong undo data when a command acts through a symbolic link. Two defects remain, each confirmed with a probe test in a temporary sandbox root. A third (chmod/chown through a symlink recording the link's own mode and owner) was fixed in #231.

Defects

  1. rm on a symlink is undone as a regular file. apply_rm in impl/rust-cli/src/commands.rs reads the content through the link and removes the link; undo writes a regular file.
  2. A redirection through a dangling symlink is undone by deleting the link. ln -s target link; /bin/echo hi > link creates target and records CreateFile "link". In impl/rust-cli/src/redirection.rs, setup_output_redirect uses path.exists(), which is false for a dangling link. Undo removes link and leaves target.

What to do

  • Decide and document one rule: operate on the link itself, or resolve it and record the real path.
  • Apply it to rm and to redirections. chmod and chown already resolve the link.
  • Add regression tests. impl/rust-cli/tests/redo_roundtrip_tests.rs has a whole-sandbox snapshot harness (mod laws) and a proptest over random command sequences that leaves out symbolic links because of these defects (see the comment on command_line()). Add ln -s back once fixed.

Done means

  • The two reproductions restore the original state exactly.
  • The random-sequence test passes with symlinks included.
  • In impl/rust-cli: cargo fmt --check, cargo clippy --all-targets --all-features -- -D warnings and cargo test pass. Commits signed.

Notes

  • If Fix redo: redone operations keep their undo data, and redo restores what the operation produced #231 has not merged, base the work on its branch claude/busy-brahmagupta-lqyiyq: the apply_* functions and the test harness come from it.
  • hyperpolymath/januskey's reversible-core FileMetadata (is_symlink, symlink_target) is a useful reference for what to record. It must not be added as a dependency here (see .claude/CLAUDE.md).
  • Do not claim the shell is production-ready or formally verified end to end.

Activity

  1. added
    bugSomething is broken or behaves incorrectly
    scope:repoConfined to this repository
    on Nov 17, 2026
  2. 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]
    #231 - Fix redo: redone operations keep their undo data, and redo restores what the operation produced [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 repository

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions