Skip to content

fix(audit): exclude virtualenv binaries from reconcile, serialize prompts#110

Merged
CybotTM merged 2 commits into
mainfrom
fix/reconcile-venv-and-prompt
Jul 17, 2026
Merged

fix(audit): exclude virtualenv binaries from reconcile, serialize prompts#110
CybotTM merged 2 commits into
mainfrom
fix/reconcile-venv-and-prompt

Conversation

@CybotTM

@CybotTM CybotTM commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

Two bugs from a real make reconcile-all run with an always-activated ~/.venv on PATH:

  1. Wrong-copy deletion (data loss): venv binaries were counted as installations. classify_install_method has no path rule for venv dirs and fell through to "tool appears in uv tool list" — true because a separate uv-tool install existed — so the venv copy was labeled uv, and removal-by-method ran uv tool uninstall, deleting the user's real uv tools (black, flake8, isort, bandit) while the venv copies survived. The duplicate report then never converged (make update kept flagging 3 duplicates). Virtualenvs are environments, not installations — capability.sh:detect_all_installations already skips them; detect_installations now does too: pyvenv.cfg next to bin/ (catches any env name), conda/virtualenvwrapper name patterns, and symlinks resolving into an env.
  2. Interleaved prompts: bulk_reconcile runs workers in a ThreadPool; every worker printed its Proceed with removal? [y/N] at once and the answers raced for stdin — it looked like "the script is not waiting for input". _confirm_removal is now serialized with a lock.

Tests

  • tests/test_reconcile_venv.py (6 tests, red→green): .venv/bin skipped, pyvenv.cfg detection independent of dir name, conda envs/*/bin skipped, symlink-into-venv skipped, non-venv duplicates still detected, threaded prompt-interleaving reproduction (asserts strict prompt→input→prompt→input ordering)
  • Full suite: 695 passed, 1 skipped; flake8 clean on touched files
  • E2E: audit.py --reconcile --all on the affected machine now reports No duplicate installations detected (previously 3 phantom conflicts every run)

…mpts

make reconcile-all treated binaries inside an activated virtualenv
(~/.venv/bin/black) as duplicate installations. classify_install_method
fell through to 'is the tool in uv tool list' — true for a DIFFERENT
install — so the removal ran uv tool uninstall and deleted the real uv
tool while the venv copy survived, and the duplicate report never
converged. Virtualenvs are environments, not installations; the shell
layer (capability.sh) already skips them.

- detect_installations now skips env bins: pyvenv.cfg next to bin/
  (any env name), conda/virtualenvwrapper name patterns, and symlinks
  resolving into an env
- serialize _confirm_removal with a lock: bulk_reconcile runs in a
  ThreadPool, so all prompts printed at once before any input was read

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Copilot AI review requested due to automatic review settings July 16, 2026 22:37
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Comment thread tests/test_reconcile_venv.py Fixed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

SonarCloud S5443 flags the /tmp path string even though the test never
creates the file; use a neutral path.

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
@sonarqubecloud

Copy link
Copy Markdown

@CybotTM
CybotTM merged commit 557aff8 into main Jul 17, 2026
19 checks passed
@CybotTM
CybotTM deleted the fix/reconcile-venv-and-prompt branch July 17, 2026 05:57
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.

3 participants