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
+15 -2
View File
@@ -95,6 +95,19 @@ class PluginTargetResolutionError(RuntimeError):
"""Raised when a plugin target cannot be resolved to a callable."""
# Exception types `register()` can raise for a single bad manifest (validation
# failure, name conflict, or driver-wiring failure). `discover()` catches only
# these so one bad manifest is skipped/logged, per spec's "malformed manifest
# file is skipped, not fatal" resilience intent -- anything else propagates as
# a genuine programmer error.
_PLUGIN_REGISTRATION_FAILURES = (
PluginValidationError,
DuplicatePluginError,
DriverRegistryUnavailableError,
PluginTargetResolutionError,
)
class PluginRegistry:
"""Validates, persists, and wires plugins discovered or submitted directly."""
@@ -128,7 +141,7 @@ class PluginRegistry:
try:
self.register(manifest)
result.registered.append(manifest)
except (PluginValidationError, DuplicatePluginError) as exc:
except _PLUGIN_REGISTRATION_FAILURES as exc:
result.errors.append(
f"entry-point plugin {manifest.name!r}: {exc}"
)
@@ -137,7 +150,7 @@ class PluginRegistry:
try:
self.register(manifest)
result.registered.append(manifest)
except (PluginValidationError, DuplicatePluginError) as exc:
except _PLUGIN_REGISTRATION_FAILURES as exc:
result.errors.append(
f"manifest-file plugin {manifest.name!r}: {exc}"
)