-
Notifications
You must be signed in to change notification settings - Fork 15.7k
fix(memory): support symlinks in memory file discovery #2961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
walkDir now follows symbolic links using fs.stat() to determine if the target is a file or directory. This enables: - Symlinked markdown files inside memory/ to be indexed - Symlinked directories inside memory/ to be traversed - Graceful handling of dangling symlinks (silently skipped) Fixes an issue where dirent.isFile() returned false for symlinks, causing them to be excluded from memory search indexing. Cross-platform notes: - Works on Linux/macOS/Windows (symlink support varies by platform) - Windows may require elevated permissions to create symlinks, but reading existing symlinks works without special privileges
|
Symlinking outside of the workspace could introduce a number of problems in terms of security, recurrence, and scoping. Would it maybe be better to add support for custom search paths and force the user to add them manually? Adding explicit, user‑configured search paths is safer than automatically following arbitrary symlinks |
|
Thanks for the feedback! You raise a valid point about security considerations. A few thoughts:
That said, I agree that explicit search paths could be a nice enhancement for power users who want more control. Would you prefer that as a follow-up PR, or should we gate symlink traversal behind a config flag (e.g., |
Yes, but it can lead to unwanted situations where the user thinks it’s symlinking a single directory, but that directory could also contain symlinks, resulting in unwanted/insecure behavior. Or a simple attack where a symlink is created in the workspace to give it access to things outside of the workspace. We could think about hierarchical symlinking in terms of allowing Let's put a pin on the symlinking for a couple of days and i'll get back on this after we've discussed implications Could you do a follow up PR for explicit search paths? thanks! |
Add a `paths` option to `memorySearch` config, allowing users to explicitly specify additional directories or files to include in memory search. Follow-up to openclaw#2961 as suggested by @gumadeiras — instead of auto-following symlinks (which has security implications), users can now explicitly declare additional search paths. - Add `memorySearch.paths` config option (array of strings) - Paths can be absolute or relative (resolved from workspace) - Directories are recursively scanned for `.md` files - Single `.md` files can also be specified - Paths from defaults and agent overrides are merged - Added 4 test cases for listMemoryFiles
Add a `paths` option to `memorySearch` config, allowing users to explicitly specify additional directories or files to include in memory search. Follow-up to moltbot#2961 as suggested by @gumadeiras — instead of auto-following symlinks (which has security implications), users can now explicitly declare additional search paths. - Add `memorySearch.paths` config option (array of strings) - Paths can be absolute or relative (resolved from workspace) - Directories are recursively scanned for `.md` files - Single `.md` files can also be specified - Paths from defaults and agent overrides are merged - Added 4 test cases for listMemoryFiles
Add a `paths` option to `memorySearch` config, allowing users to explicitly specify additional directories or files to include in memory search. Follow-up to #2961 as suggested by @gumadeiras — instead of auto-following symlinks (which has security implications), users can now explicitly declare additional search paths. - Add `memorySearch.paths` config option (array of strings) - Paths can be absolute or relative (resolved from workspace) - Directories are recursively scanned for `.md` files - Single `.md` files can also be specified - Paths from defaults and agent overrides are merged - Added 4 test cases for listMemoryFiles
Add a `paths` option to `memorySearch` config, allowing users to explicitly specify additional directories or files to include in memory search. Follow-up to openclaw#2961 as suggested by @gumadeiras — instead of auto-following symlinks (which has security implications), users can now explicitly declare additional search paths. - Add `memorySearch.paths` config option (array of strings) - Paths can be absolute or relative (resolved from workspace) - Directories are recursively scanned for `.md` files - Single `.md` files can also be specified - Paths from defaults and agent overrides are merged - Added 4 test cases for listMemoryFiles
Add a `paths` option to `memorySearch` config, allowing users to explicitly specify additional directories or files to include in memory search. Follow-up to openclaw#2961 as suggested by @gumadeiras — instead of auto-following symlinks (which has security implications), users can now explicitly declare additional search paths. - Add `memorySearch.paths` config option (array of strings) - Paths can be absolute or relative (resolved from workspace) - Directories are recursively scanned for `.md` files - Single `.md` files can also be specified - Paths from defaults and agent overrides are merged - Added 4 test cases for listMemoryFiles
Add a `paths` option to `memorySearch` config, allowing users to explicitly specify additional directories or files to include in memory search. Follow-up to openclaw#2961 as suggested by @gumadeiras — instead of auto-following symlinks (which has security implications), users can now explicitly declare additional search paths. - Add `memorySearch.paths` config option (array of strings) - Paths can be absolute or relative (resolved from workspace) - Directories are recursively scanned for `.md` files - Single `.md` files can also be specified - Paths from defaults and agent overrides are merged - Added 4 test cases for listMemoryFiles
Summary
walkDirnow follows symbolic links usingfs.stat()to determine if the target is a file or directory. This enables:memory/to be indexedmemory/to be traversedProblem
The current
walkDirimplementation usesdirent.isFile()to check if an entry is a file. However, for symbolic links,dirent.isFile()returnsfalse(the dirent type is "symbolic-link", not "file"), causing symlinks to be excluded from memory search indexing.This is especially relevant for:
memory/Solution
For entries that are symbolic links, we now call
fs.stat()(which follows symlinks) to determine the actual target type:Cross-platform notes
Test plan
Related: #2884