feat(vault-sync): opt-in symlink following#17
Open
LinuxIsCool wants to merge 2 commits intoregen-prodfrom
Open
feat(vault-sync): opt-in symlink following#17LinuxIsCool wants to merge 2 commits intoregen-prodfrom
LinuxIsCool wants to merge 2 commits intoregen-prodfrom
Conversation
…SYMLINKS Adds a new env flag VAULT_SYNC_FOLLOW_SYMLINKS (default: false) that enables vault sync to follow symlinks in the Shared/ folder to their target files. This allows users to symlink external files (e.g., journal entries, research docs) into the shared folder without copying, keeping a single source of truth. Safety guards: - Disabled by default — zero behavioral change without the flag - Uses Path.resolve(strict=True) to catch circular/broken symlinks - Blocks resolved paths under /etc, /root, /proc, /sys - Only affects outbound scanning — incoming files never overwrite symlinks - Relative path in the sync protocol uses the symlink name, not the target Three scan sites updated: - reconcile scan (line ~711): reconcile hash comparison - main scan loop (line ~918): file discovery + read + hash - apply guard (line ~1125): comment-only, behavior preserved Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ly_forget guard Two critical fixes from code review: 1. Replace blocklist with allowlist for symlink target validation. Previously blocked only /etc, /root, /proc, /sys — insufficient. Now requires resolved target to be under vault_root, $HOME, or explicitly configured VAULT_SYNC_SYMLINK_ALLOWED_ROOTS (colon-separated). 2. Add symlink guard to _apply_forget(). Previously, incoming FORGET events could delete user-managed symlinks via Path.unlink(). Now skips symlinks with a warning log, consistent with _apply_new_or_update. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
VAULT_SYNC_FOLLOW_SYMLINKSenv flag (default:false) to allow vault sync to follow symlinks in theShared/folderMotivation
When sharing files between KOI-net peers, users currently must copy files into
~/Documents/Notes/Shared/. This creates stale duplicates when the source file is updated elsewhere (e.g., a journal entry managed by another tool).Symlink support lets users
ln -s /path/to/source.md ~/Documents/Notes/Shared/source.mdand have vault sync read through the symlink to the target content. The sync protocol uses the symlink name as the relative path, not the target path — so peers see the file at the expected location.Safety guards
Path.resolve(strict=True)OSError)/etc,/root,/proc,/sysrel_pathfrom symlink nameChanges
api/vault_sync.py(1 file, +61 -8):FOLLOW_SYMLINKSfromVAULT_SYNC_FOLLOW_SYMLINKSenv var_resolve_if_symlink(path, vault_root)— safe resolution with guardsUsage
Test plan
darrenzalDB role for full suite)FOLLOW_SYMLINKS=false(default)VAULT_SYNC_FOLLOW_SYMLINKS=true.mdfile inShared/is picked up by scan when flag is enabled/etc/passwdis blocked🤖 Generated with Claude Code