Skip to content

scopes,cli(refactor): Replace project trust with containment - #621

Open
tony wants to merge 1 commit into
fix/600-symlink-user-scopesfrom
refactor/619-structural-project-containment
Open

tony wants to merge 1 commit into
fix/600-symlink-user-scopesfrom
refactor/619-structural-project-containment

Conversation

@tony

@tony tony commented Dec 6, 2026

Copy link
Copy Markdown
Member

Closes #619

Stacked on #620 (fix/600-symlink-user-scopes).

Summary

  • Replace interactive project trust prompts with structural directory containment.
  • Skip out-of-directory project configs with one warning line on human output.
  • Suppress skip warnings on --json and --ndjson streams.
  • Remove vcspull trust, --trust-project, VCSPULL_YES, and the trusted-directories state file.
  • Add ADR 0002, migration notes, changelog entries, and documentation redirects.

1. Owner and boundary

  • Rule changed and module that owns it: Structural project containment in src/vcspull/_internal/scopes.py and src/vcspull/config.py (load_scoped_configs(), project_config_contained()), CLI flag and subcommand removal across src/vcspull/cli/, and architecture decision record docs/project/adr/0002-structural-project-containment.md.
  • Sibling entry points checked (sync/async, CLI/API, single/batch, or N/A): Checked load_scoped_configs(), known_entries_for_writer(), project_config_contained(), vcspull config ls, list, status, search, sync, worktree, fmt (single-file and --all), migrate (single-file and --all), discover, add (including --alias attach preflight), and import across all six remote services.
  • Why this belongs here (owner fix, boundary adapter, or single-PR ownership transfer): scopes.py and config.py own scope resolution and containment policy, while CLI subcommands forward report=False on machine-readable --json and --ndjson streams.

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): fix/600-symlink-user-scopes (scopes(fix): Deduplicate symlinked user configs #620)
  • Failing input or command and observed failure before the fix: Running vcspull list or vcspull sync --all non-interactively inside a directory tree containing an out-of-directory .vcspull.yaml aborted the entire command with VCSPullError (exit 1) instead of skipping the project file and loading user and contained project configurations, and interactive runs printed unbounded destination prompts backed by mutable $XDG_STATE_HOME/vcspull/trusted state.

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 --python-version 3.11 --error-on-warning ., uv run ty check --python-version 3.15 --error-on-warning ., uv run sphinx-build -W -b html docs docs/_build/html, uv run python scripts/runtime_dep_smoketest.py, uv run pytest, and the disposable-worktree production revert check on tests/test_scopes.py and tests/cli/test_config.py.
  • .github/workarounds.toml updates (None if none): None
  • Tool use: Antigravity (Gemini) compared uv and mise configuration models, ran a two-round spike ratchet for Replace vcspull trust with structural project containment #619, authored ADR 0002 and the containment refactor across src/, docs/, MIGRATION, CHANGES, and tests/, and ran all verification gates.

Design decisions

  • Enforce structural containment on upward-walked project .vcspull.* files (escaping_destinations()) rather than interactive prompts and $XDG_STATE_HOME/vcspull/trusted, matching uv's declarative workspace model; unlike mise, vcspull has no shell cd hook and executes no templates or scripts from YAML.
  • Reject bounded destination previews on top of vcspull trust: truncating the prompt hides most escaping paths while keeping non-TTY exit 1 failures and persistent directory grants.
  • Reject loading escaping project files unconditionally: an unchecked .vcspull.yaml inside a cloned repository could target ~/.ssh/ or displace user entries outside its checkout.
  • Keep system, user (including symlinked dotfiles from scopes(fix): Deduplicate symlinked user configs #620), and explicit -f / --file manifests unrestricted on disk.

Verification

Before:

$ vcspull list
vcspull: ~/work/proj/.vcspull.yaml would check repositories out outside its directory (~/.ssh/evil) and there is no terminal to confirm on. Run 'vcspull trust ~/work/proj' to allow it, pass --trust-project, or use --no-project to skip project configs.

After:

$ vcspull list
skipping ~/work/proj/.vcspull.yaml: project configs cannot target paths outside ~/work/proj (pass -f ~/work/proj/.vcspull.yaml or link it in user config)
• flask → ~/work/proj/vendor/flask
• click → ~/work/proj/vendor/click

Zero remaining matches for removed trust symbols across src/ and tests/:

$ rg -n "trust_project|VCSPULL_YES|ensure_config_trusted|create_trust_subparser|trust_command" src/ tests/
$ rg -n "trust_state_file|read_trusted|trust_directory|untrust_directory|requires_trust" src/ tests/

Test plan

  • load_scoped_configs() skips escaping project files with one warning line while loading user and contained project scopes (tests/test_scopes.py)
  • vcspull list --json suppresses escaping-project skip warnings on stdout and emits valid JSON (tests/cli/test_config.py)
  • vcspull config ls marks escaping project files as (outside directory, skipped) (tests/cli/test_config.py)
  • vcspull fmt --all --write skips escaping project files and discover --yes refuses to modify an escaping project file without -f (tests/cli/test_config.py)
  • Removed vcspull trust and --trust-project spellings exit 2 (tests/cli/test_config.py)
  • Zero matches for removed trust flags, state helpers, and subcommands in src/ and tests/
  • Strict Sphinx build (sphinx-build -W) including ADR 0002 and cli/trust.html redirect
  • Full Python 3.11 / 3.15 matrix in GitHub Actions

why: vcspull is a declarative VCS synchronizer with no shell hook or
template execution, so interactive directory trust prompts, non-TTY
VCSPullError aborts, and mutable $XDG_STATE_HOME/vcspull/trusted state
added friction without buying anything structural containment cannot
provide (#619).

what:
- Enforce structural project containment in load_scoped_configs() and
  project_config_contained(), skipping out-of-directory project files
  with a one-line warning (suppressed on --json / --ndjson streams)
- Remove vcspull trust, --trust-project, VCSPULL_YES,
  ensure_config_trusted(), and the trusted-directories state file
- Report skipped project files in vcspull config ls as
  (outside directory, skipped)
- Add ADR 0002, redirect cli/trust.md to configuration/scopes.md, and
  update CLI/config docs, MIGRATION, CHANGES, and tests
@codecov

codecov Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.36364% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.09%. Comparing base (9247211) to head (48214e0).

Files with missing lines Patch % Lines
src/vcspull/cli/add.py 20.00% 3 Missing and 1 partial ⚠️
src/vcspull/cli/migrate.py 0.00% 0 Missing and 1 partial ⚠️
src/vcspull/config.py 94.73% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                       Coverage Diff                       @@
##           fix/600-symlink-user-scopes     #621      +/-   ##
===============================================================
- Coverage                        85.11%   85.09%   -0.03%     
===============================================================
  Files                               38       38              
  Lines                             7762     7690      -72     
  Branches                          1599     1589      -10     
===============================================================
- Hits                              6607     6544      -63     
+ Misses                             765      760       -5     
+ Partials                           390      386       -4     

☔ 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.

1 participant