Skip to content

scopes(fix): Deduplicate symlinked user configs - #620

Open
tony wants to merge 1 commit into
masterfrom
fix/600-symlink-user-scopes
Open

tony wants to merge 1 commit into
masterfrom
fix/600-symlink-user-scopes

Conversation

@tony

@tony tony commented Dec 6, 2026

Copy link
Copy Markdown
Member

Closes #600

Summary

  • Deduplicate resolved real paths across system, user, and project scopes in resolve_sources().
  • Recognize symlinked user and system config chains (~/.vcspull.yaml, ~/.config/vcspull, VCSPULL_CONFIGDIR, ~/.vcspull) in classify_scope().
  • Keep rogue project symlinks pointing at user configs classified as project.
  • Ignore blank VCSPULL_CONFIGDIR and XDG_CONFIG_HOME values in user_config_dirs().
  • Collapse symlinked $HOME realpaths in PrivatePath.

1. Owner and boundary

  • Rule changed and module that owns it: Configuration scope deduplication and symlink classification in src/vcspull/_internal/scopes.py, user config directory resolution in src/vcspull/util.py, and home prefix display normalization in src/vcspull/_internal/private_path.py.
  • Sibling entry points checked (sync/async, CLI/API, single/batch, or N/A): Checked resolve_sources(), classify_scope(), load_scoped_configs(), ensure_config_trusted(), vcspull config ls, and get_config_dir() callers across add, discover, fmt, migrate, import, list, status, search, and sync.
  • Why this belongs here (owner fix, boundary adapter, or single-PR ownership transfer): scopes.py and util.py are the single owners of configuration scope discovery and classification; keeping interactive trust simplification separate (Replace vcspull trust with structural project containment #619) isolates the symlink deduplication defect to its owning resolver.

2. Failure before the fix (N/A for docs, lockfile bumps, or pure refactors)

  • Baseline (<base> commit, or <pre_fix_head> SHA if fixing a defect introduced in this PR): 8419df6 (v1.72.0)
  • Failing input or command and observed failure before the fix: Symlinking ~/.vcspull.yaml to ~/.dot-config/.vcspull.yaml and running vcspull config ls or vcspull sync --dry-run libtmux </dev/null from ~/.dot-config emitted both user ~/.vcspull.yaml and project ~/.dot-config/.vcspull.yaml (untrusted) and aborted with VCSPullError on non-TTY stdin.

3. Verification and tool disclosure

  • Gates run (plus production-only revert check for behavioral fixes, or N/A): uv run ruff format . --check, uv run ruff check ., uv run ty check --error-on-warning --python-version 3.11 ., uv run ty check --error-on-warning --python-version 3.15 ., uv run py.test src/vcspull/util.py src/vcspull/_internal/scopes.py src/vcspull/_internal/private_path.py tests/test_utils.py tests/test_scopes.py tests/cli/test_config.py tests/docs/test_markdown_conventions.py, and the disposable-worktree production revert bite check on tests/test_scopes.py::test_symlinked_home_dotfile_in_dotfiles_repo_loads_once_as_user.
  • .github/workarounds.toml updates (None if none): None
  • Tool use: Antigravity (Gemini) reproduced Symlinked ~/.vcspull.yaml triggers unbounded project trust prompt #600 on v1.72.0, ran a two-round spike ratchet (.git/spike/vcspull-600-symlink-dedup.md), implemented the scopes.py / util.py / private_path.py fix and regression suite, and ran lint, ty, pytest, and test-bite gates.

Test plan

  • Symlinked ~/.vcspull.yaml, ~/.config/vcspull, VCSPULL_CONFIGDIR, ~/.vcspull, and chained dotfiles symlinks resolve once in user scope inside ~/.dot-config (tests/test_scopes.py, tests/cli/test_config.py)
  • Rogue project file and directory symlinks pointing at user configs stay classified as project (tests/test_scopes.py)
  • Blank VCSPULL_CONFIGDIR / XDG_CONFIG_HOME values and symlinked $HOME realpaths resolve cleanly (tests/test_utils.py)
  • Full Python 3.11 / 3.15 matrix in GitHub Actions

why: Symlinking ~/.vcspull.yaml or ~/.config/vcspull into a dotfiles
checkout caused resolve_sources() to re-discover the target file as an
untrusted project config when running inside the dotfiles directory,
and classify_scope() followed leaf symlinks before checking $HOME while
omitting VCSPULL_CONFIGDIR and ~/.vcspull (#600).

what:
- Add expand_home(), resolve_home(), and user_config_dirs() in
  vcspull.util, ignoring blank VCSPULL_CONFIGDIR and XDG_CONFIG_HOME
- Deduplicate resolved real paths across system, user, and project
  scopes in resolve_sources()
- Match lexical candidates against symlink chains of user and system
  config roots in classify_scope() while keeping rogue project symlinks
  classified as project
- Collapse symlinked $HOME realpaths in PrivatePath and cover dotfiles
  and rogue-symlink topologies in tests and docs
@codecov

codecov Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.76712% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.11%. Comparing base (8419df6) to head (9247211).

Files with missing lines Patch % Lines
src/vcspull/_internal/scopes.py 75.55% 13 Missing and 9 partials ⚠️
src/vcspull/util.py 83.33% 6 Missing and 1 partial ⚠️
src/vcspull/_internal/private_path.py 81.81% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #620      +/-   ##
==========================================
- Coverage   85.25%   85.11%   -0.14%     
==========================================
  Files          38       38              
  Lines        7663     7762      +99     
  Branches     1567     1599      +32     
==========================================
+ Hits         6533     6607      +74     
- Misses        751      765      +14     
- Partials      379      390      +11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Symlinked ~/.vcspull.yaml triggers unbounded project trust prompt

1 participant