Skip to content

fix: ignore hidden directories during server discovery#259

Open
Copilot wants to merge 8 commits into
mainfrom
copilot/fix-discovery-command-venv-issue
Open

fix: ignore hidden directories during server discovery#259
Copilot wants to merge 8 commits into
mainfrom
copilot/fix-discovery-command-venv-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 17, 2026

Summary

plugboard server discover could fail when the target directory contained a hidden virtualenv such as .venv, because discovery attempted to recurse into and import files from hidden paths. This change makes discovery skip hidden directories while preserving normal module discovery.

Changes

  • Discovery traversal

    • Keep the recursive import walk based on os.walk.
    • Prune hidden directories in place via dirs[:] so discovery does not descend into .venv and similar paths.
    • Simplify module name construction using Path(...).relative_to(...).with_suffix("").
  • Regression coverage

    • Consolidate the discovery coverage into a single parametrized CLI test.
    • Cover package and non-package projects both with and without hidden directories.
    • Verify that visible modules are still discovered and discovery completes without raising when hidden directories are present.

Copilot AI and others added 3 commits May 17, 2026 20:41
Copilot AI changed the title [WIP] Fix discovery command failure when .venv folder is present fix: ignore hidden directories during server discovery May 17, 2026
Copilot AI requested a review from toby-coleman May 17, 2026 20:44
Comment thread plugboard/cli/server/__init__.py
Comment thread tests/unit/test_cli.py Outdated
assert process_route.called


def test_cli_server_discover_ignores_hidden_directories(tmp_path: Path) -> None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Parametrize the existing test to avoid duplication

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in fe09f85 by folding the duplicated coverage into the existing discovery test as a parametrized set of cases.

Copilot AI and others added 2 commits May 17, 2026 21:02
Agent-Logs-Url: https://github.com/plugboard-dev/plugboard/sessions/95e9b248-3b2e-44b6-8916-b2c37aa87c09

Co-authored-by: toby-coleman <13170610+toby-coleman@users.noreply.github.com>
Agent-Logs-Url: https://github.com/plugboard-dev/plugboard/sessions/95e9b248-3b2e-44b6-8916-b2c37aa87c09

Co-authored-by: toby-coleman <13170610+toby-coleman@users.noreply.github.com>
Copilot AI requested a review from toby-coleman May 17, 2026 21:04
Comment thread plugboard/cli/server/__init__.py Outdated
except (ModuleNotFoundError, ImportError, SyntaxError) as e:
logger.warning(f"Failed to import module {module_name}: {e}")

def _walk(current_path: Path) -> None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually keep the inplace update to dirs as it is less code @copilot

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in 58f2032 to restore the os.walk + dirs[:] pruning approach, while keeping the module-name handling a bit cleaner with Path.relative_to(...).with_suffix("").

Copilot AI and others added 2 commits May 17, 2026 21:13
Agent-Logs-Url: https://github.com/plugboard-dev/plugboard/sessions/2d8dca45-18df-4778-8cbe-25c9bccbf641

Co-authored-by: toby-coleman <13170610+toby-coleman@users.noreply.github.com>
Agent-Logs-Url: https://github.com/plugboard-dev/plugboard/sessions/2d8dca45-18df-4778-8cbe-25c9bccbf641

Co-authored-by: toby-coleman <13170610+toby-coleman@users.noreply.github.com>
Copilot AI requested a review from toby-coleman May 17, 2026 21:15
@toby-coleman toby-coleman marked this pull request as ready for review May 17, 2026 21:18
@github-actions
Copy link
Copy Markdown

Benchmark comparison for 97996e58 (base) vs 58f20321 (PR)


------------------------------------------------------------------------------------------------------------------ benchmark: 2 tests -----------------------------------------------------------------------------------------------------------------
Name (time in ms)                                                                         Min                 Max                Mean            StdDev              Median               IQR            Outliers     OPS            Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_benchmark_process_run (pr/.benchmarks/Linux-CPython-3.14-64bit/0001_pr)         420.9185 (1.0)      423.7608 (1.0)      422.0182 (1.0)      1.1293 (1.0)      421.4850 (1.0)      1.5078 (1.0)           1;0  2.3696 (1.0)           5           1
test_benchmark_process_run (main/.benchmarks/Linux-CPython-3.14-64bit/0001_base)     422.6454 (1.00)     434.5691 (1.03)     426.7634 (1.01)     4.7228 (4.18)     425.5294 (1.01)     5.7463 (3.81)          1;0  2.3432 (0.99)          5           1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean

@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

bug: plugboard server discovery command fails if venv is present

2 participants