fix(plugin-system): implement register_driver_type and stop discover() aborting on one bad manifest

- driver/registry.py never actually defined register_driver_type, so
  the plugin-system's 'driver plugin registered successfully' scenario
  was unreachable in production (only simulated via test monkeypatch).
  Added a real implementation wired into the existing driver factory
  registry.
- PluginRegistry.discover() only caught PluginValidationError/
  DuplicatePluginError, so a driver-kind manifest that failed wiring
  (DriverRegistryUnavailableError/PluginTargetResolutionError) aborted
  the whole scan, silently skipping co-located tool/skill manifests.
  Now caught and skipped per manifest instead.

openspec: plugin-system capability, archived change cloud-runtime
This commit is contained in:
2026-07-07 08:31:00 +08:00
parent 031b929067
commit 725bf4cd9c
3 changed files with 168 additions and 26 deletions
+20
View File
@@ -42,3 +42,23 @@ def build_driver_factory(
if not builder:
raise ValueError(f"unsupported driver_type: {driver_type}")
return builder(connection_info)
def register_driver_type(driver_type: str, factory: DriverFactoryBuilder) -> None:
"""Register a new ``driver_type`` -> factory-builder mapping.
This is the extension point external code (e.g. ``cloud.plugins``'
driver-kind plugin wiring) uses to add a new driver type without editing
this module. ``factory`` must be a callable accepting a
``connection_info`` dict and returning a ``DriverFactory`` (the same
shape as :func:`build_wda_driver_factory`); once registered,
``build_driver_factory(driver_type, ...)`` can construct drivers of the
new type.
"""
if not driver_type:
raise ValueError("driver_type must be a non-empty string")
if not callable(factory):
raise ValueError(f"factory for driver_type {driver_type!r} must be callable")
if driver_type in SUPPORTED_DRIVER_TYPES:
raise ValueError(f"driver_type {driver_type!r} is already registered")
SUPPORTED_DRIVER_TYPES[driver_type] = factory