Skip to content

Undo does not restore file and directory modes, or a variable's exported flag #235

Open

Description

@hyperpolymath

Found on 2026-11-17 while fixing redo in #231. Each case was reproduced in a temporary sandbox root.

Defects

  1. rm f where f is mode 0600, then undo: f comes back 0644. apply_rm in impl/rust-cli/src/commands.rs records only the content. Ownership is not recorded either. A private file becomes readable by others after an undo.
  2. rmdir d where d is mode 0700, then undo: d comes back 0755. apply_rmdir records no undo data.
  3. X=1; export X; unset X; undo: X is restored but is no longer exported. apply_unset_variable in impl/rust-cli/src/state.rs records only the previous value. The same gap means the undo record of an assignment cannot hold the export flag (an open review thread on Fix redo: redone operations keep their undo data, and redo restores what the operation produced #231).

Where the tests are

impl/rust-cli/tests/redo_roundtrip_tests.rs, mod laws, scenarios(): three scenarios are marked undo_is_exact: false for these defects.

Design constraint

Operation.undo_data is an opaque Vec<u8> persisted in the history file, decoded per operation type by undo() and rollback_transaction(). Old history files must still load and undo, so a new layout must be distinguishable from the old one. Add a fixture test for an old-format file.

Read #230 first: its plan moves deleted-file contents to a blob store and may change the record format. Coordinate with it, and say in the PR which you did.

Done means

  • The three undo_is_exact: false flags become true and every_operation_round_trips still passes.
  • 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.

Notes

Activity

  1. coderabbitai commented on Nov 17, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #230 - Stress-suite repair and a crash-safe history journal (two steps still open, not ready to merge) [open]
    #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