Skip to content

Commit 8443166

Browse files
committed
docs(plugins): anatomy names slug as required for ui plugins and says kernel.use() enforces the contract on both kernels
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016N6xmWt5hYm94ffVEwGH8x
1 parent cb78732 commit 8443166

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

content/docs/plugins/anatomy.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ ObjectStack uses `type` discrimination to optimize runtime behavior, allowing th
6969
* **Behavior:**
7070
* **Passive:** Driven by `plugin-hono-server` (or other HTTP adapters).
7171
* **Static Assets:** Must provide `staticPath` pointing to a build output (e.g., `dist/`).
72-
* **Routing:** Automatically mounted to `/{slug}` with SPA fallback support.
72+
* **Routing:** Must provide `slug`; automatically mounted to `/{slug}` with SPA fallback support.
7373
* **Assets:** Files are served locally under `/{slug}/assets`.
74+
* **Enforced at registration:** a `type: 'ui'` plugin missing `staticPath` or `slug` is refused by `kernel.use()` with `PLUGIN_CONTRACT_VIOLATION` — on `ObjectKernel` and `LiteKernel` alike — so a UI plugin that boots in a `LiteKernel` test harness is one that also boots in production.
7475

7576
### 3. App Plugin (`app`)
7677
* **Role:** Vertical Business Solution.
@@ -259,6 +260,7 @@ Plugins follow a strict three-phase lifecycle managed by the kernel:
259260
└──────────────────────┘
260261
```
261262

263+
0. **kernel.use()** — Registers the plugin. Before storing it, both kernels check the object against the declared plugin contract (`PluginSchema` in `@objectstack/spec`) and refuse one that violates it with `PLUGIN_CONTRACT_VIOLATION`, naming the first violated key — a `type` outside the closed set, a non-URL `homepage`, a `null` on a declared key, or a `type: 'ui'` plugin missing `staticPath` / `slug`. The object is validated, never replaced: what is stored is the very instance you passed in, prototype and all.
262264
1. **init()** — Called during kernel initialization. Register services that other plugins may depend on.
263265
2. **start()** — Called after *all* plugins have initialized. Start servers, connect to databases, or execute main logic.
264266
3. **destroy()** — Called during shutdown, in reverse order. Clean up connections, timers, and resources.

0 commit comments

Comments
 (0)