After plugin discovery, `rebuild_tool_models()` performs deferred imports of `Image`, `ImageVariant`, `ImageVersion`, and `BakeryConfigDocument` to reconstruct Pydantic discriminated unions with plugin-contributed tool options. This is a circular-import workaround. If config loads before plugins are discovered, tool options fail silently — no error, no warning. Adding a new model that uses `ToolField` requires manually updating the rebuild function with no static guarantee of completeness. Plugins also import from `cli.common`, coupling the plugin system to the CLI layer.
Replace with a plugin registry that config models query at validation time rather than mutating model annotations at import time. This makes initialization order explicit, turns silent failures into loud ones, and makes plugins independently testable.
Files: `config/tools/init.py`, `plugins/`, `config/image/variant.py`, `config/image/version.py`
After plugin discovery, `rebuild_tool_models()` performs deferred imports of `Image`, `ImageVariant`, `ImageVersion`, and `BakeryConfigDocument` to reconstruct Pydantic discriminated unions with plugin-contributed tool options. This is a circular-import workaround. If config loads before plugins are discovered, tool options fail silently — no error, no warning. Adding a new model that uses `ToolField` requires manually updating the rebuild function with no static guarantee of completeness. Plugins also import from `cli.common`, coupling the plugin system to the CLI layer.
Replace with a plugin registry that config models query at validation time rather than mutating model annotations at import time. This makes initialization order explicit, turns silent failures into loud ones, and makes plugins independently testable.
Files: `config/tools/init.py`, `plugins/`, `config/image/variant.py`, `config/image/version.py`