Skip to content

feat: let plugins read models from the project under analysis - #141

Merged
SizzleUnrlsd merged 2 commits into
mainfrom
feat/project-models
Sep 25, 2026
Merged

SizzleUnrlsd merged 2 commits into
mainfrom
feat/project-models

Conversation

@SizzleUnrlsd

Copy link
Copy Markdown
Contributor

Closes #140. This is the engine hook enterprise-validators (CoreTrace-Entreprise/coretrace-python-analyzer-plugins#25) needs, so a project can declare its validators in a file at its root.

Change

  • Plugin.project_models(root) -> Sequence[Model]. It defaults to (), and returns models read from the project under analysis. plugin_models(plugins, root) registers them next to the plugin's own models, under the plugin's name, so a conflict still names both sides.
  • Where it runs. It is called once per directory check, before any module is analysed. With --jobs, each worker calls it with the batch root, so every process sees the same models. A single-file check reads no project.
  • Cache. The models join the model table, which is already in the configuration key. Editing the declaration therefore invalidates cached results; a test covers it.
  • Errors. A model declared wrongly raises ModelError. The command line now lists ModelError among the errors it reports (exit status 2), so a bad declaration gives a message instead of a traceback. This also covers the existing case of two plugins declaring conflicting models.

Verification

  • pytest: 1081 passed. ruff check src tests and mypy are clean.
  • pytest -m regression under Python 3.12: 19 passed, no snapshot changed. No bundled plugin reads the project.
  • Tests. Before the change, 4 of the 5 new tests failed for the right reasons: the declared validator was ignored (hotspot), in-process, in workers and through the cache, and the command line exited with 1 instead of reporting the error. The single-file case was already green, and stays so.
  • Mutation checks. Each of these changes fails at least one test: the project path skipping the hook, workers skipping it, and the command line letting ModelError through.

@SizzleUnrlsd SizzleUnrlsd self-assigned this Sep 25, 2026
@SizzleUnrlsd
SizzleUnrlsd merged commit 8fec5c8 into main Sep 25, 2026
10 checks passed
@SizzleUnrlsd
SizzleUnrlsd deleted the feat/project-models branch September 25, 2026 00:38
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.

Plugins: models read from the project under analysis

1 participant