Skip to content

feat: guard against reserved mloda namespace package roots - #72

Merged
TomKaltofen merged 3 commits into
mainfrom
feat/guard-reserved-namespace
Jun 10, 2026
Merged

feat: guard against reserved mloda namespace package roots#72
TomKaltofen merged 3 commits into
mainfrom
feat/guard-reserved-namespace

Conversation

@TKaltofen

Copy link
Copy Markdown
Collaborator

Closes #71.

Problem

A plugin scaffolded from this template that renames the placeholder/ package root to mloda or mloda_plugins would ship mloda/__init__.py and collapse the shared PEP 420 mloda namespace, making the core framework unimportable for everyone who installs the plugin. Nothing guarded against it.

Change (three layers)

  1. bin/customize.sh rejects the reserved names mloda / mloda_plugins at rename time, mirroring the existing placeholder guard.

  2. tests/test_reserved_namespace.py is the CI gate. It runs in the default tox pytest step (so it covers manual renames that bypass the script, and runs on every scaffolded plugin across the 3.10-3.13 matrix). It fails if:

    • a top-level directory is named mloda / mloda_plugins, or
    • any mloda/__init__.py / mloda_plugins/__init__.py exists anywhere in the source tree (covers src/-style layouts, not just the default where = ["."]; virtualenv/build/cache dirs are pruned so installed deps never trip it).

    The detection logic is unit-tested (root layout, src layout, bare namespace dir, excluded dirs, clean tree).

  3. README.md notes the reserved names in the customization step.

This invariant has no template-repo exemption (neither the template nor any plugin should ever ship mloda/__init__.py), so it lives in the default tox run rather than the placeholder-only env.

Verification

tox passes locally (15 tests; ruff format, ruff check, mypy --strict, bandit all clean).

Review

Implementation was reviewed by two independent deep reviews (Claude Opus + codex). The accepted finding (the guard initially only scanned the repo root and would miss a src/-layout mloda/__init__.py) is addressed by the recursive source-tree scan in the second commit.

🤖 Generated with Claude Code

A plugin scaffolded from this template that renames the package root to
'mloda' or 'mloda_plugins' would ship mloda/__init__.py and collapse the
shared PEP 420 namespace, making the core framework unimportable for anyone
who installs the plugin.

- bin/customize.sh rejects the reserved names at rename time
- tests/test_reserved_namespace.py fails (in default tox / CI) if the repo
  would ship a reserved namespace root
- README notes the reserved names in the customization step

Closes #71
Recursively scan the source tree (pruning venv/build/cache dirs) for a
reserved 'mloda/__init__.py' or 'mloda_plugins/__init__.py', so a src/-style
layout that would still collapse the namespace is caught, not just the
default where=["."] root layout.
@TomKaltofen
TomKaltofen merged commit b4cd0c2 into main Jun 10, 2026
5 checks passed
@TomKaltofen
TomKaltofen deleted the feat/guard-reserved-namespace branch June 10, 2026 08:26
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.

Guard against renaming the package root to a reserved namespace (mloda, mloda_plugins)

2 participants