Repository navigation
Description
Goal
Define how plugin code runs and what it can touch. Handlers of official plugins run in-process, but only through a narrow interface (input in, calls through ctx out) so the same plugin could later run out of process. This issue builds the interface and a way to invoke a handler; event delivery and inbound webhooks follow in the next two issues.
Handler interface
A plugin folder may contain handlers.ts exporting named async functions. A handler receives (input, ctx) and returns nothing or a small result. ctx is the only way a handler touches anything:
ctx.settings: the validated settings.ctx.propr: a client limited to the permissions granted to this installation and to the plugin's repository limit. Initial operations: read a pull request, issue or task summary; list recent events; create an issue; create a task for an issue; comment on a pull request or issue; add or remove a label. Each call is checked against the grant and recorded with the plugin id as the actor. A call outside the grant throws and is logged.ctx.http(connectionId?):fetch-like outbound HTTP that only reaches hosts listed in the manifest'soutboundHosts, goes through the existing endpoint policy (HTTPS only, no private or loopback addresses by default, bounded size and time), and injects the named connection's credential. Handlers never receive raw secrets.ctx.state: a small key-value store scoped to the installation (JSON values, size and key-count limits) for cursors and mappings such as "this pull request maps to that chat thread".ctx.log: structured log lines returned to the caller of the handler; values are passed through the existing secret redaction.
Handlers must not import ProPR internals: enforce with a lint rule (restricted imports) for packages/plugins/**, allowing only @propr/shared types and the plugin SDK types.
Invocation
A core function runPluginHandler(installation, handlerName, input) loads the handler from the registry, builds ctx, applies a 30 second timeout and returns outcome, duration, error message and log lines. It never throws to its caller. The next issues call it from the dispatcher, the webhook route and commands.
Plugin test kit
packages/plugins/testing: a fake ctx (recorded propr calls, scripted http responses, in-memory state, captured logs) for plugin unit tests.
Acceptance criteria
- With a fixture plugin:
runPluginHandlerruns a handler, returns its logs and outcome; a throwing handler and a handler that hangs past the timeout return a failed outcome without throwing. ctx.proprrefuses operations outside the granted permissions and outside the repository limit; allowed operations are attributed to the plugin in the audit trail and task events.ctx.httprefuses hosts not inoutboundHosts, private addresses and plain HTTP; credentials are injected and never visible to the handler (sentinel test on handler-visible values and on logs).ctx.stateenforces its size and key-count limits and is deleted on uninstall.- The restricted-imports lint rule fails a fixture plugin that imports a core module.
- Docs: handler interface in
docs/docs/features/plugins.mdand a newdocs/docs/architecture/plugin-runtime.md.
Implementation
- Shared: handler SDK types (
PluginContext, handler input envelopes) inpackages/shared/src/pluginSdk.ts. - Core:
packages/core/src/plugins/pluginContext.ts(scoped client built on existing services,ctx.httponpackages/core/src/extensions/endpointPolicy.ts, state store, logging with redaction) andpluginHandlerRunner.ts. Knex migration for plugin state. - ESLint restricted-imports override for
packages/plugins/**ineslint.config.js. packages/plugins/testingtest kit.- Tests with a fixture plugin in
packages/core/test.
Notes
Depends on the installation state issue. Ordinary task runs stay one-shot: handlers observe and create new work, they never interact with a running task. ProPR runs on SQLite only.
Activity
propr-dev commentedon Nov 14, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-5-53548/claude-opus-5-5-plugin-handlers-sdk-types-20261114-1908-nxn3542-epic-plugin-system-xu8issue-3548-20261114-1908-claude-opus-5-5-nxn🔍 Track Task Execution