Skip to content

Commit 4429bde

Browse files
committed
Update documentation to clarify boot hook context and plugin requirements for shared infrastructure
1 parent 13add46 commit 4429bde

3 files changed

Lines changed: 6 additions & 0 deletions

File tree

docs/adrs/025_optional_infrastructure_plugins.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ _Boot behavior_:
3636

3737
Plugin `boot` is a configuration boundary. Boot failures should fail fast so the bot does not continue with partially initialized required infrastructure. Runtime hooks such as `message`, `ready`, moderation observations, command contribution, and strategy contribution may remain isolated so one plugin hook failure does not stop unrelated processing.
3838

39+
The `boot` hook receives shared runtime context as keyword arguments, currently `app:`, `bot:`, and `plugin_registry:`. Plugins should require only the context they need. This keeps lifecycle dependencies explicit without forcing every plugin to depend on the Discord bot, application object, or registry.
40+
3941
_Consequences_:
4042

4143
- Keeps optional services optional without obscuring dependencies

docs/architecture.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ Current hook types include:
179179
- command contribution hook: `commands`
180180
- optional infrastructure capabilities through `capabilities` and `PluginRegistry#capability`
181181

182+
The `boot` hook receives the shared runtime context: `app:`, `bot:`, and `plugin_registry:`. Plugins should require only the keyword arguments they need. For example, infrastructure plugins usually need `app:` or `plugin_registry:`, while delivery-oriented plugins may need `bot:` to interact with Discord outside a single message event.
183+
182184
Plugins that provide shared optional infrastructure should expose it as a named capability, such as `postgres_connection` or `ai_provider`. Domain plugins should consume those capabilities through the registry instead of depending directly on a concrete infrastructure plugin class. Existing named registry helpers may remain as compatibility shims for common capabilities.
183185

184186
The public Ruby namespace is `OpenModBot`.

lib/plugin.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module OpenModBot
22
class Plugin
3+
# Boot receives the shared runtime context: app:, bot:, and plugin_registry:.
4+
# Concrete plugins should require only the keyword arguments they actually use.
35
def boot(**); end
46

57
def ready(**); end

0 commit comments

Comments
 (0)