Files
hermes-agent/tools
kshitijk4poor a721612bfa fix(file_ops): vet the Delete/Move entry itself, not its parent directory
The previous fold guarded each Delete/Move entry by running
get_write_denied_error on dirname(path). That coordinate is wrong both ways:

- runtime self-protection treats ANCESTORS of the running venv/interpreter
  as protected, so a plain file directly in ~, ~/.hermes, the checkout root
  or the uv python dir could no longer be deleted or moved ("'/Users/x' is a
  protected system/credential file");
- credential-dir prefixes end in os.sep and match via startswith, so the
  bare dir ~/.ssh never matched and a link directly inside ~/.ssh, ~/.aws,
  ~/.gnupg, ... was unlinked/renamed.

The existing classifier gains an entry=True mode (get_write_denied_error /
_classify_write_denial, and is_protected_path(follow=False)) that vets
realpath(parent)/basename — the entry, leaf not dereferenced — in addition
to the resolved target. A file inside a protected dir or prefix is denied;
a file merely beside the venv is allowed. delete_file and move_file make
one entry-mode call per entry instead of the duplicated path+dirname loop.

The new parametrized test covers both directions (plain Delete/Move next to
a monkeypatched runtime venv succeeds; a link in <home>/.ssh is refused with
link and target intact); all four cases fail on the previous fold head.
2026-09-27 01:10:56 +05:30
..