Skip to main content
Pylon’s plugin system is a Rust trait registered inside the runtime at boot. It’s how the built-ins (rate_limit, tenant_scope, owner_stamp, csrf) are wired. Be clear about the current state before you reach for it:
  • There is no dynamic plugin loading and no manifest.plugins array. Built-ins are registered in the runtime’s Rust code. To ship your own, you build a custom runtime that registers it.
  • Most needs don’t require a plugin. App logic belongs in server functions + policies; schema-level automation is covered by tenant_scope / owner_stamp / behaviors.
  • The SDK exports a definePlugin({ name, entities, hooks }) helper, but the runtime does not consume its output yet — TS-authored plugins aren’t wired. Treat it as a placeholder, not a supported path.

When to write one

The Plugin trait

The real trait (pylon_plugin::Plugin). Every method has a default no-op impl — override only what you need:
Note there is no unified before_write/after_write with a WriteOp enum — insert / update / delete are separate hooks.

PluginError

Rejections carry a code, message, and HTTP status (it’s a struct, not an enum):

Example: a before-insert plugin

The pattern the built-ins use — mutate data before it lands:

Example: a per-request gate

on_request_with_meta runs before dispatch and receives the peer IP — this is how rate_limit buckets anonymous callers:

Example: adding an HTTP route

routes() returns PluginRoutes; the router matches them after its built-in routes by method + path prefix. The handler receives (body, path, auth) and returns (status, body):

Registering with the runtime

Plugins are added to a PluginRegistry at boot — the same place the built-ins are registered:
There is no name-to-constructor lookup from a manifest, and no runtime-loaded plugin bundle. To ship your own today you fork the runtime (crates/runtime) and add your reg.register(...) call, then build your own pylon binary from it. That’s the honest state — a dynamic/loadable plugin path and a wired definePlugin are on the roadmap.

Testing

The trait is plain Rust — no harness needed:

Reference: the built-ins

Read the real built-ins in crates/plugin/src/builtin/ as templates:
  • Before-write data mutationtenant_scope.rs, owner_stamp.rs
  • Per-request gaterate_limit.rs, csrf.rs
  • External-service integrationai_proxy.rs
Pick the closest match and adapt.