feat(file-safety): add hermes file-safety check diagnostic command - #18318
Open
googs1025 wants to merge 2 commits into
Open
feat(file-safety): add hermes file-safety check diagnostic command#18318googs1025 wants to merge 2 commits into
hermes file-safety check diagnostic command#18318googs1025 wants to merge 2 commits into
Conversation
When a write tool is rejected, there's no way to tell which rule fired (denylist / sensitive prefix / safe-root / internal cache). This adds a diagnostic so the matched rule is visible. * explain_write_denial(path) -> Optional[str] in agent/file_safety.py * `hermes file-safety check <path> [--json]` subcommand * Exits 1 when read or write is blocked
teknium1
reviewed
Jul 12, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for adding a useful diagnostic surface. Current main still returns generic write-denial messages at tools/file_operations.py:1374-1375, so the capability is still needed, but this branch cannot be salvaged unchanged.
Problems
- Current
agent/file_safety.py:109-142also deniesmcp-tokens/,pairing/, and paths outside any of multiple safe roots. The PR’s replacement omits the first two and calls the removed single-root API; multi-root support landed infa8f1517d. - The proposed report derives
write.allowedonly from that helper (hermes_cli/file_safety_cmd.py:25), whilewrite_filefirst applies_check_sensitive_path()and task-aware cross-profile/mirror guards attools/file_tools.py:633-660and1649-1655. The command can therefore say allowed for a path the tool rejects. - Add
file-safetyto_BUILTIN_SUBCOMMANDS(hermes_cli/main.py:12275-12297) when wiring the modern parser.
Suggested changes
- Rebase the classifier on current
is_write_denied()behavior, including multi-root, MCP-token, and pairing cases. - Either scope the command to that hard classifier or provide a task-aware diagnostic for the full file-tool preflight stack, with tests for each category.
Automated hermes-sweeper review.
| resolved = os.path.realpath(os.path.expanduser(raw_path)) | ||
| write_reason = explain_write_denial(raw_path) | ||
| read_reason = get_read_block_error(raw_path) | ||
| return { |
Contributor
There was a problem hiding this comment.
explain_write_denial() is not the complete write preflight on current main: write_file_tool() also rejects sensitive system/config paths and task-aware cross-profile or sandbox-mirror targets before reaching file operations. Reporting allowed: true here would be misleading unless this command is explicitly scoped to the shared hard deny classifier or evaluates those guards too.
This was referenced Aug 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a write tool is rejected, there's no way to tell which rule fired (denylist / sensitive prefix / safe-root / internal cache). This adds a diagnostic so the matched rule is visible.
hermes file-safety check <path> [--json]subcommandWhat does this PR do?
Related Issue
Fixes #
Type of Change
Changes Made
How to Test
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
hermes --toolsets skills -q "Use the X skill to do Y"Screenshots / Logs