# Plugin System

Orxaq's plugin scaffold provides extensibility through a registry-based architecture with lifecycle hooks.

## Plugin Types

| Type | Description |
|------|-------------|
| `algorithm` | Custom causal discovery algorithms |
| `connector` | Data source connectors |
| `skin` | Observatory UI skins |
| `command` | CLI command extensions |
| `provider` | LLM provider integrations |
| `validator` | Custom validation rules |

## Creating a Plugin

Subclass `OrxaqPlugin` and implement the required methods:

```python
from orxaq.kernel.plugins import OrxaqPlugin, PluginMeta, PluginType

class MyPlugin(OrxaqPlugin):
    @property
    def meta(self) -> PluginMeta:
        return PluginMeta(
            name="my-plugin",
            version="1.0.0",
            plugin_type=PluginType.ALGORITHM,
            description="Custom causal discovery algorithm",
        )

    def activate(self) -> None:
        pass

    def deactivate(self) -> None:
        pass

    def on_hook(self, hook, **kwargs):
        pass
```

## Lifecycle Hooks

Plugins can respond to these events:

- `before_discover` / `after_discover` --- causal discovery lifecycle
- `before_simulate` / `after_simulate` --- scenario simulation
- `before_validate` / `after_validate` --- DAG validation
- `on_dag_change` --- World DAG modifications
- `on_engine_start` --- engine initialization

## Loading Plugins

```python
from orxaq.kernel.plugins import PluginLoader, PluginRegistry

registry = PluginRegistry()
loader = PluginLoader(registry)

# Load from a Python file
loader.load_file("path/to/my_plugin.py")

# Load all plugins from a directory
loader.load_directory("plugins/")
```
