feat(file_safety): support multiple HERMES_WRITE_SAFE_ROOT dirs (fix #49535) - #49557
feat(file_safety): support multiple HERMES_WRITE_SAFE_ROOT dirs (fix #49535)#49557xydigit-zt wants to merge 4 commits into
Conversation
In _read_file() and _detect_external_drift(), the code used strict UTF-8 encoding but only caught OSError/IOError, not UnicodeDecodeError. This caused the memory tool to crash when encountering non-UTF-8 encoded files (e.g., GBK, CP936, Latin-1). Now catches UnicodeDecodeError and returns empty results instead of crashing. Fixes NousResearch#49508
Supports multiple directories separated by ':' (Unix PATH-style). E.g., HERMES_WRITE_SAFE_ROOT=/opt/data:/var/www/html Fixes NousResearch#49535
|
Related: #49535 (the feature request this implements). Core change is multi-root (PATH-style |
Morad37
left a comment
There was a problem hiding this comment.
Clean approach. The colon-separated format makes sense for env vars and the backwards compat is fine since single-path still works. One thing: the existing docs and config templates reference HERMES_WRITE_SAFE_ROOT as a single path. If they show an example, updating it to mention the multi-path format would save someone figuring it out from source.
|
Thanks for the approval! Good point about the docs. I can add a note about the multi-path format. Do you have a specific doc file or section that references HERMES_WRITE_SAFE_ROOT that I should update? Or would you prefer a follow-up PR for the docs? |
Add note about colon-separated multiple directories support.
|
Thanks for the review! I've updated the docs to mention the multi-path format: Changes:
Example: |
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and the Windows separator ';' work correctly. - Add 9 tests covering multi-root behavior: writes inside first/second root, writes outside all roots, trailing/leading/double separators, all-separators edge case, static deny priority, duplicate dedup. - Update hermes_cli/tips.py tip string to mention multiple paths. - Update docs to mention os.pathsep / ; on Windows. Follow-up for salvaged PR NousResearch#49557.
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and the Windows separator ';' work correctly. - Add 9 tests covering multi-root behavior: writes inside first/second root, writes outside all roots, trailing/leading/double separators, all-separators edge case, static deny priority, duplicate dedup. - Update hermes_cli/tips.py tip string to mention multiple paths. - Update docs to mention os.pathsep / ; on Windows. Follow-up for salvaged PR #49557.
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and the Windows separator ';' work correctly. - Add 9 tests covering multi-root behavior: writes inside first/second root, writes outside all roots, trailing/leading/double separators, all-separators edge case, static deny priority, duplicate dedup. - Update hermes_cli/tips.py tip string to mention multiple paths. - Update docs to mention os.pathsep / ; on Windows. Follow-up for salvaged PR NousResearch#49557.
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and the Windows separator ';' work correctly. - Add 9 tests covering multi-root behavior: writes inside first/second root, writes outside all roots, trailing/leading/double separators, all-separators edge case, static deny priority, duplicate dedup. - Update hermes_cli/tips.py tip string to mention multiple paths. - Update docs to mention os.pathsep / ; on Windows. Follow-up for salvaged PR NousResearch#49557.
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and the Windows separator ';' work correctly. - Add 9 tests covering multi-root behavior: writes inside first/second root, writes outside all roots, trailing/leading/double separators, all-separators edge case, static deny priority, duplicate dedup. - Update hermes_cli/tips.py tip string to mention multiple paths. - Update docs to mention os.pathsep / ; on Windows. Follow-up for salvaged PR NousResearch#49557.
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and the Windows separator ';' work correctly. - Add 9 tests covering multi-root behavior: writes inside first/second root, writes outside all roots, trailing/leading/double separators, all-separators edge case, static deny priority, duplicate dedup. - Update hermes_cli/tips.py tip string to mention multiple paths. - Update docs to mention os.pathsep / ; on Windows. Follow-up for salvaged PR NousResearch#49557.
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and the Windows separator ';' work correctly. - Add 9 tests covering multi-root behavior: writes inside first/second root, writes outside all roots, trailing/leading/double separators, all-separators edge case, static deny priority, duplicate dedup. - Update hermes_cli/tips.py tip string to mention multiple paths. - Update docs to mention os.pathsep / ; on Windows. Follow-up for salvaged PR NousResearch#49557.
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and the Windows separator ';' work correctly. - Add 9 tests covering multi-root behavior: writes inside first/second root, writes outside all roots, trailing/leading/double separators, all-separators edge case, static deny priority, duplicate dedup. - Update hermes_cli/tips.py tip string to mention multiple paths. - Update docs to mention os.pathsep / ; on Windows. Follow-up for salvaged PR NousResearch#49557.
Supports multiple directories separated by ':' (Unix PATH-style).
E.g., HERMES_WRITE_SAFE_ROOT=/opt/data:/var/www/html
Testing:
Fixes #49535