Repository navigation
fix(plugins): surface blocked hook registrations in health views - #135492
Closed
zeroaltitude wants to merge 10 commits into
Closed
zeroaltitude wants to merge 10 commits into
zeroaltitude wants to merge 10 commits into
Conversation
…rtup warn A blocked typed-hook registration was a single startup `warn` and nothing else. `api.on()` returns `void`, so the plugin never learns it was refused and keeps behaving as though its handler is live. Measured cost: a non-bundled plugin's `before_prompt_build` handler was refused at every gateway start for four days without anyone noticing, because the plugin looked healthy from its own logs and the only evidence had scrolled past. Two changes. 1. Distinguish the accidental refusal from the deliberate ones. Refusing a conversation hook because a non-bundled plugin has no `plugins.entries.<id>.hooks.allowConversationAccess` setting *at all* is nobody's decision — it silently disables a handler the operator never asked to disable — so it is now `level: "error"`, with a message naming the exact config path, the remedy (`: true` plus a Gateway restart), the acknowledge-instead option (`: false`), and the two commands that verify it. The two explicit operator denials (`allowPromptInjection=false`, and bundled with `allowConversationAccess=false`) stay at `warn` with their original wording: deliberate configuration is not an error. 2. Make the refusal outlive startup. `PluginRegistry.blockedHooks` records each refusal structurally (plugin, hook, reason, severity, config path, message), and the two existing plugin-health surfaces render it: a `Blocked plugin hooks` section in `/status plugins` (via `StatusPluginHealthSnapshot`, errors sorted first, capped at 8 with an overflow line) and a `Blocked hooks` section in `openclaw plugins inspect <id> --runtime`, scoped to that plugin. The compact `⚠️ Plugins:` line counts only `error`-severity refusals so deliberate config does not become a permanent warning chip. Diagnostics already reported in the new section are suppressed from the `Diagnostics` list, mirroring how channel-setup failures already behave. No new mechanism was added — there is no `openclaw plugins status` subcommand; these are the surfaces that exist. Production growth is justified by a capability that could not be expressed more simply: the refusal boundary had no observable state at all, so there was nothing for an operator or agent to query. One trap closed along the way: `registryContainsRuntimePluginIds` scans every registry array for owning plugin ids to decide whether a cached registry can be reused. `blockedHooks` entries carry a `pluginId` but represent hooks that are *not* live, so the field is skipped there alongside `diagnostics` — otherwise a refusal would make its plugin look loaded. Validation (from the topic worktree, all green): - `pnpm tsgo:core` — clean - `pnpm tsgo:core:test` — clean - `pnpm config:schema:check` — `[base-config-schema] ok` - `pnpm plugin-sdk:api:check` — `OK docs/.generated/plugin-sdk-api-baseline.sha256` - `pnpm oxlint <touched files>` — clean - `git diff --check` — clean - `OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 pnpm check:changed` — exit 0 across all 26 lanes (Crabbox delegation is unavailable on this host, so the gate was run locally) - `pnpm vitest run` over the 9 touched suites — 305/305 passed Regression coverage: the escalated implicit-deny path (all 9 conversation hooks refused at `error`, message asserted to contain the config path, remedy, and both verify commands), both un-escalated explicit denials asserted to stay `warn`, the new status section (compact counting, detailed rendering, diagnostic suppression, the 8-entry cap), the runtime collector, inspect-report scoping, the CLI section, and the registry-reuse skip. Out of scope and left for a maintainer decision: changing `api.on()` to return a registration outcome, and whether prompt-injection-only hooks should be gated by `allowConversationAccess` at all. Beads: openclaw-2mx
…ook-registrations
Resolutions:
- manifest-types.ts: union of both sides' diagnostic codes; adopted the
more precise name 'hook-registration-blocked' over the branch's vaguer
'hook-blocked' (renamed across all 5 call sites).
- registry-registrars-tools-hooks.ts: adopted main's 'hookName' throughout.
The branch still used 'effectiveHookName', a deactivate -> gateway_stop
alias remap that main deliberately removed (see compat/registry-records.ts:
'The deprecated api.on("deactivate", ...) hook alias was removed').
Fixes a severity bug present on BOTH candidate branches: the implicit-deny
check 'origin !== "bundled" && access !== true' also matches an explicit
'false', so a deliberate denial on a non-bundled plugin was reported as an
error, tagged conversation-access-missing, with copy telling the operator a
key they had already set was unset. The explicit-false check now runs first
and applies regardless of origin.
Also lifts the consequence wording from the sibling branch onto every refusal
message ('the handler is not registered and will never run').
Validation:
- pnpm tsgo:core -> exit 0, 0 errors
- pnpm vitest run src/plugins/loader.test.ts -> 184 passed
- pnpm vitest run status-plugin-health, plugins/status, plugins-cli.list,
active-runtime-registry -> 95 passed
- new regression test confirmed to FAIL against the pre-fix ordering
('expected conversation-access-missing to be conversation-access-denied')
- silent-drop sweep: no symbol present on main is missing from the merged
registrar file; additions are exactly blockTypedHook, configPath,
formatImplicitConversationAccessBlockDiagnostic
- oxlint on all touched files clean; git diff --check clean
…rtup A plugin whose hook policy refused a registration still loads and still reports as healthy, so nothing at startup states that part of it is dead. Nobody reads a single diagnostic in the startup scroll — that is how a refused conversation hook stayed invisible for days. Summarizes error-severity refusals next to the existing failure summary, reading `registry.blockedHooks` rather than re-scanning diagnostics, so the structured registry record stays the single source of truth. Error severity only: warn-level refusals are denials the operator wrote themselves and already print at their own level. Validation: - pnpm tsgo:core -> exit 0, 0 errors - pnpm vitest run src/plugins/plugin-graceful-init-failure.test.ts -> 7 passed - pnpm vitest run src/plugins/loader.test.ts -> 184 passed - oxlint clean; git diff --check clean
…ook-registrations
…ook-registrations Main removed the entire deprecated-typed-hook diagnostic mechanism: formatDeprecatedTypedHookDiagnostic, isDeprecatedPluginHookName, DEPRECATED_PLUGIN_HOOKS and LEGACY_SUBAGENT_SPAWNING_HOOK_COMPAT are all gone from main (0 hits repo-wide). Our side still carried the formatter and its call site, which would have referenced symbols that no longer exist. Accepted main's removal and dropped both. Our contribution is unaffected and NOT superseded - main has zero hits for blockedHooks, hook-registration-blocked, conversation-access-missing, conversation-access-denied and PluginBlockedHookReason - so the registry record, the severity calibration, and the explicit-false fix all remain ours. Validation: - pnpm tsgo:core -> 0 errors - loader.test.ts + status-plugin-health.test.ts -> 208 passed
…ook-registrations
Import-list conflict in loader.hooks-and-runtime.test-utils.ts: main added writeFixtureText/writeFixtureJson/pluginManifest/channelPluginSource to the same import block where this branch had added writeBundledPlugin. Resolved as a union, but verified rather than assumed: writeBundledPlugin is still exported (loader.test-harness.ts:206), and counting usages with the conflict block excluded shows all five are genuinely referenced in this file — writeBundledPlugin x1 from this branch's added test, and main's four at x12/x12/x5/x4. pnpm tsgo passes.
# Conflicts: # src/cli/plugins-cli.list.test.ts
…ook-registrations
…j9a) `npx oxfmt --check` flagged this one over-long line in the branch's own test helper; running the formatter wraps the `registry.diagnostics.filter(...)` callback. Pre-existing on the branch, not introduced by the `origin/main` merge — the merge is what made anyone run the gate over it. Found while refreshing this branch for the 2026-08-31 integration rotation. Co-Authored-By: Claude <[email protected]>
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Closing this PR because the author has more than 20 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
A plugin hook refused by policy currently produces one startup warning and then disappears from every health surface. The plugin still looks healthy even though part of its behavior is dead; one refused conversation hook remained unnoticed for four days.
Why This Change Was Made
Blocked hook registrations become structured registry facts with plugin, hook, reason, severity, configuration path, and remediation text.
/status pluginsandopenclaw plugins inspect <id> --runtimerender those facts. Missing conversation-access configuration is an error because nobody chose the denial; explicit operator denials remain warnings. Refused hooks are excluded from “loaded plugin” ownership checks.User Impact
Operators can query persistent evidence of disabled plugin capabilities and receive the exact configuration path needed to fix or acknowledge the refusal.
Evidence
The production incident was a non-bundled
before_prompt_buildhook refused on every restart for four days while its plugin appeared healthy. Regression coverage spans policy classification, structured registry storage, startup summary, CLI inspection, status rendering, overflow ordering, graceful initialization, and registry reuse. Validation on head2f1c4f71649includes core and core-test typechecks, config and plugin-SDK checks, focused plugin suites, lint/format, and diff validation.Known follow-up before merge: current main’s max-lines ratchet must be satisfied in the touched
status.test.tssurface without suppressing the rule.Written by Tank (Claude), an AI agent operated by Eddie Abrams (zeroaltitude).