refactor(plugins): drop dead bundled-source guard in _discover_all_plugins

The `if key in seen and source == "bundled": continue` check was
unreachable: bundled is scanned before user, so `key in seen` can never
be true while `source == "bundled"`. The "user overrides bundled"
semantics are preserved automatically by the unconditional
`seen[key] = …` on the user pass.

Replaces the dead guard with a one-line comment explaining the
overwrite semantics, so a future contributor adding a third source
(e.g. project plugins) can see at a glance how ordering interacts with
the dict-overwrite. Matches `PluginManager.discover_and_load`'s
"user wins" rule.

Spotted by Copilot in code review on #27161.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Guillaume Meyer 2026-05-16 23:12:18 +00:00 committed by Teknium
parent 8ab8bc2f03
commit 21be7025c5

View file

@ -762,11 +762,12 @@ def _discover_all_plugins() -> list:
except Exception:
pass
key = f"{prefix}/{d.name}" if prefix else manifest_name
if key in seen and source == "bundled":
continue
src_label = source
if source == "user" and (d / ".git").exists():
src_label = "git"
# Bundled is scanned before user, so the user pass overwrites
# bundled entries with the same key — matches
# PluginManager.discover_and_load's "user wins" semantics.
seen[key] = (key, version, description, src_label, d)
continue