Plugin Dependencies
A plugin can declare ordered dependencies on other plugins. The loader resolves them topologically before falling back to the existing priority integer for tie-breaks within each layer.
See also: Plugin Distribution, Backend Hooks.
Why
Hook order is observable: an onContextReady handler that reads branch_overrides only sees a useful value if branch_switching has already populated it. Before this field, ordering was coupled to a single global priority: int shared by every plugin — collisions were silent and forced magic numbers.
Declaring dependencies: ["branch_switching"] makes the constraint explicit, self-documenting, and verified at load time.
Where to Declare
Two equivalent surfaces:
1. Distributable Plugin (plugin.yaml)
name: my_plugin
version: 1.0.0
has_backend: true
entry_module: my_plugin.plugin
entry_class: MyPlugin
priority: 50
dependencies:
- branch_switching
- permission_bridge
The dependencies field is part of PluginPackageManifest (src/codumentor/plugins/package.py). Default is [] — existing manifests need no change.
2. Built-in or Inline (meta)
class MyPlugin:
meta = {
"name": "my_plugin",
"version": "1.0.0",
"priority": 50,
"dependencies": ["branch_switching"],
}
The loader reads meta["dependencies"] for in-tree plugins. Same semantics as plugin.yaml.
3. Per-deployment Override (codumentor.yaml)
plugins:
- module: codumentor.plugins.my_plugin
class: MyPlugin
dependencies: ["branch_switching"]
A dependencies entry in codumentor.yaml overrides whatever the plugin's meta (or external manifest) declared. Use this sparingly — it lets a deployment fix a load-order bug without rebuilding the plugin, but it also drifts from upstream.
Resolution Rules
- Topological sort first. Each plugin appears after every plugin it depends on, transitively.
- Priority within a layer. Plugins whose dependencies are all satisfied at the same point sort by
priorityinteger (lower number runs first —priority: 4registers beforepriority: 6), preserving the pre-existing behaviour for plugins that don't declaredependencies. - Names match
meta["name"]. A dependency string"branch_switching"must match another loaded plugin'smeta["name"](or external manifestname).
Required Dependencies
dependencies buys ordering only. When your plugin must not run at all without
another one, because running without it would be unsafe and not just less
useful, list that plugin under required_dependencies as well:
class ScmPushPlugin:
meta = {
"name": "scm_push",
"dependencies": ["workspace_isolation", "user_secrets"],
"required_dependencies": ["workspace_isolation"],
}
# plugin.yaml
required_dependencies:
- workspace_isolation
- A required dependency is also an ordering edge; you need not repeat it under
dependencies. - If any active plugin's required dependency is not an active plugin on the same host, startup is refused. This covers a dependency that is not listed under
plugins:, isenabled: false, is excluded from the build, or failed to import, instantiate or register. The error names both plugins:Plugin configuration is invalid: plugin 'scm_push' requires plugin 'workspace_isolation', which is not loaded …. A dependent that is itselfenabled: falserequires nothing. - Plugins the host already holds (the built-ins) satisfy it too.
- The per-deployment
dependencies:override incodumentor.yamlcannot remove a requirement. To run without the dependency, disable the dependent plugin. - The error is a
StartupConfigError(codumentor/startup_errors.py). Every entry point (API server, TUI, CLI query, an agent loading its own host) reports it and exits. None of them degrades to a partial plugin set. workspace_isolationis special in one more way: an active plugin that requires it counts as a request for isolation inplugins/utils.isolation_requested. So sandboxes that follow isolation (external_agenttier auto, MCPsandbox.mode: auto) refuse rather than run on the host, even on a host the loader check did not build. The loader applies the same request check at the end of loading: if isolation is requested (an active plugin requires it, or the config lists and enablesworkspace_isolation) but the plugin is not live because it failed to import, instantiate or register, startup is refused withIsolationLoadError(aStartupConfigError) naming the cause. Seedoc/security/subprocess-execution-isolation.md§A3.
Why this exists: the security review of 2026-11-07 (WS9-1) found scm_push
loading without workspace_isolation after a single warning line. The agent
shell, users' ! commands and external agents then ran on the host.
Keep requirements for that kind of case. A plugin that only degrades without
the other one (scm_push without user_secrets simply has no push credentials)
should keep it under dependencies.
Current declarations:
| Plugin | dependencies (soft) | required_dependencies |
|---|---|---|
scm_push | workspace_isolation, user_secrets | workspace_isolation |
branch_switching | workspace_isolation (runs without it: checkout is global, with a warning) | — |
doc_editor, xlsx_editor, pptx_editor | workspace_files | — |
media_generation | user_secrets, workspace_files | — |
task_tools, goals | task_runtime | — |
thinking_modes | model_profiles | — |
conversation_management | episodic_memory | — |
redmine, gitea_pr, jenkins, external_agent, telegram, database (plugin.yaml) | user_secrets | — |
Failure Modes
The failures are treated differently, and the difference matters when you
decide which kind of edge to declare:
| Situation | Severity | What happens |
|---|---|---|
dependencies entry is not loaded | Soft — startup continues | The edge is dropped and the loader logs Plugin 'my_plugin' declares dependency 'foo', which is not among the loaded plugins; ignoring (plugin will load at default ordering for its layer). Your plugin still loads, ordered only by priority within its layer. |
required_dependencies entry is not an active plugin | Fatal — startup refused | PluginDependencyError (a StartupConfigError) naming the plugin and the missing dependency. See Required Dependencies. |
workspace_isolation listed and enabled but failed to load (import, build exclusion, instantiation, registration) | Fatal — startup refused | IsolationLoadError (a StartupConfigError) naming the plugin and the cause. A missing bwrap is not this case: the plugin loads and fails closed per turn. |
| Dependency graph has a cycle | Fatal — startup aborts | ValueError: Plugin dependency cycle detected: a -> b -> a. Break the cycle by removing one edge (often one direction was unintended). |
A missing dependency is not fatal. Declaring an edge on a plugin a given
deployment happens not to run costs you a warning line, not a failed startup —
so declaring the edge is the right call whenever the ordering genuinely matters
to you. What you do not get is a guarantee: the dependency being absent is
exactly the case where your handler runs without the state it wanted.
So an edge buys you ordering, not presence. Pair it with a runtime check for
anything you actually read — peek at ctx["scratchpad"] for the key the other
plugin populates, or ask a collect point,
and degrade gracefully when the answer is empty.
When Not to Use
- Pure event listeners with no shared state. If your hook does its work entirely from
payload, ordering doesn't matter — leavedependenciesempty and letprioritydecide. - Presence requirements.
dependenciescannot express "X must be installed": a missing entry is only a warning. If running without X would be unsafe, userequired_dependencies. If your plugin is merely unusable without X, check for it at first use and fail loudly there.
Optional integrations are not on this list. If your plugin works fine without
X but must run after X when X is present, declaring the edge is correct: you get
the ordering where X exists and a warning where it doesn't.
Example: workspace_files → branch_switching (deferred)
workspace_files will eventually merge with the permalink rewrite pipeline so locally-modified or generated files get correct download links. That merger consumes branch_overrides from branch_switching, so the merged plugin will declare:
meta = {
"name": "workspace_files",
"dependencies": ["branch_switching"],
}
Today workspace_files runs with dependencies: [] simply because the consumer code
isn't wired up yet: there is nothing to order against. The edge can be added the
moment the consumer lands — deployments that run without branch_switching
(selfdev configs commonly do) will log one warning and carry on, so nothing has
to wait for universal availability.