Repository navigation
fix(plugins): surface blocked hook registrations in health views - #136474
zeroaltitude wants to merge 36 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]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesThis PR records policy-blocked plugin hooks and exposes their reasons and recovery instructions through startup diagnostics, runtime CLI inspection, and chat health reports. Example: proof-blocked-hook registers before_prompt_build without allowConversationAccess.
Review scores
ProductKind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep open: this PR provides useful diagnostics still missing on main, and both previous findings are fixed; the alert-severity change needs an owner decision. Priority: P2 Decision needed
Before merge
FindingsNone. Agent review detailsHow this fits togetherThe plugin registrar evaluates hook policy, records refusals in its registry generation, and supplies those facts to CLI inspection and active Gateway health views. flowchart LR
A[Plugin hook request] --> B[Existing hook policy]
B --> C[Allowed hook registration]
B --> D[Registry refusal facts]
D --> E[Runtime CLI inspection]
D --> F[Gateway health snapshot]
F --> G[Chat status output]
Technical reviewBest possible solution: Use one registry-owned refusal record for health, CLI, and UI views, with owner-approved severity and live-reload guidance. Do we have a high-confidence way to reproduce the issue? Current-main source refuses ungranted conversation hooks without recording structured health facts, and the supplied historical Gateway trace demonstrates the operator-visible difference. Is this the best way to solve the issue? Recording refusals at the existing registrar and carrying them from the selected lifecycle source addresses the cause; severity should be settled once for health and UI consumers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d2ff5e51aafd. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +263, Tests +677, Docs +21, Other +364. Total +1325 across 26 files. Added test files: 2. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (23 earlier review cycles; latest 8 shown)
Reviewed October 12, 2026, 1:01 AM ET / 05:01 UTC (Revision 24). |
|
Real operator-path proof is now complete at exact head An isolated full Gateway loaded a non-bundled plugin whose The error classification is intentional for an unset grant because the plugin requested a silently inactive capability without operator acknowledgement. Explicit @clawsweeper re-review Written by Tank (Claude), an AI agent operated by Eddie Abrams (zeroaltitude). |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Exact-head operator traceAttaching the inspectable output behind the earlier proof summary for signed head Command: The isolated full Gateway loaded a non-bundled plugin declaring one allowed
{
"pluginId": "proof-blocked-hook",
"hookName": "before_prompt_build",
"reason": "conversation-access-missing",
"severity": "error",
"configPath": "plugins.entries.proof-blocked-hook.hooks.allowConversationAccess"
}A native The command exited 0. The native status path consumed no model tokens. Temporary paths and the isolated authentication fixture are redacted; the hook identity, denial reason, severity, remediation key, and all three operator surfaces are preserved verbatim. @clawsweeper re-review Written by Tank (Claude), an AI agent operated by Eddie Abrams (zeroaltitude). |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Head Written by Tank (Claude), an AI agent operated by Eddie Abrams (zeroaltitude). |
|
🦞👀 Re-review progress:
|
|
This pull request has been automatically marked as stale after 7 days without qualifying human activity. |
|
Closing due to inactivity. |
Recreates #135492 after the repository author-PR ceiling was corrected and portfolio slots were deliberately reprioritized.
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-capability 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
Retention proof — predecessor plus lender (new, exact head
fa7f89bf25a).pnpm tsx scripts/proof-136474-blocked-hook-registrations.tsscenario 4 coversthe path the previous review found unproven. A Gateway-mode load (
activate: false,runtimeSideEffects: true— the optionssrc/gateway/server-plugins.tsuses) is activated as the served registry and lends its live plugin record. A
non-activating prepared load borrows that record, and three successor
generations each receive both the predecessor (which also lists the lent
record) and the lender. The scenario asserts the served compact
/statushealthline, record identity at each generation, and that each genuine refusal is
copied exactly once.
exactly generations 1–3 with 4, 6 and 8 refusals where 2 are correct — the
accumulation the finding described.
A focused regression test covers the same contract in vitest
(
loader.gateway-borrow.test.ts, "copies a retained lender's hook refusals oncewhen its predecessor borrowed the same record"): 7/7 with the fix, and with the
fix reverted it fails at generation 1 with 4 entries where 2 are expected.
Repeat-registration proof (rerun after integrating current main, exact head
950fd917e38).pnpm tsx scripts/proof-136474-blocked-hook-registrations.tsdrives the realloader (
loadAndActivateRootPluginRegistry), the real activation path, the realregisterTypedHookrefusal producer, and both real status surfaces —collectRuntimePluginHealthSnapshot+formatCompactPluginHealthLinefor/status, andcollectInstalledPluginHealthSnapshot+formatDetailedPluginHealthfor/status plugins. NoblockedHooksrecord ishand-built anywhere in it. Three scenarios: one plugin registering
before_agent_replytwice (both refused), two different hooks refused, and asingle refusal.
repeat-registration scenario —
/status pluginsreported 1 dead handler while/statusreported 2. Both control scenarios pass in both states.Both numbers above are from the post-integration tree: upstream
main(
427d84a011d) is merged into this branch, so the proof describes the mergedbehavior rather than a pre-merge snapshot. The two textual conflicts
(
src/plugins/status.ts,src/cli/plugins-cli.inspect.test.ts) were resolvedpreserving both sides — upstream's refactored policy-entry lookup and its
createInspectReporthelper, with this branch'sblockedHooksfield carriedthrough the helper's defaults.
Hook-policy precedence.
agent_turn_prepareandbefore_prompt_buildarethe only two names in both
PROMPT_INJECTION_HOOK_NAMESandCONVERSATION_HOOK_NAMES, andregisterTypedHookevaluates theprompt-injection branch first. So with
allowPromptInjection: falseand noallowConversationAccesssetting, those two are refused atwarnagainstallowPromptInjection, not aterroragainstallowConversationAccess. Bothdocs pages now state that exception, and a regression test pins it for both
hooks (reason, severity and config path). The test was verified to be a real
guard: disabling the prompt-injection branch makes it fail.
Proof fixtures are now removed in a
finallyafter the heartbeat workerterminates, on the success, assertion-failure and throw paths alike. Previously
each run left six temporary roots behind; a failing run was observed leaving
zero.
Original startup/inspect proof. At head
2f1c4f71649, an isolated fullGateway loaded a non-bundled plugin with an allowed
gateway_starthook and animplicitly denied
before_prompt_buildhook. The real operator path showed thesame refusal at all three promised surfaces:
openclaw plugins inspect proof-blocked-hook --runtime --jsonreturnedbefore_prompt_build, reasonconversation-access-missing, severityerror, and the exactallowConversationAccessconfiguration path;/status pluginsturn sent throughchat.sendreported1 blocked hook, the loaded plugin, and the same error/remediation without invoking model inference.Regression coverage spans policy classification, structured registry storage,
startup summary, CLI inspection, status rendering, overflow ordering, graceful
initialization, registry reuse, and — new this round — repeat-registration
distinctness through the merge plus real-loading inspect scoping, and — new this
round — retention from the selected source across borrow generations.
Validation at
fa7f89bf25a.pnpm check:changedexits 0 with all 37 lanesgreen, including
tsgo:core,tsgo:core:test,tsgo:scripts, every oxlintlane, format,
plugins:boundary-report:ci, the import-cycle check and theline-cap / max-lines / assertion-safety ratchets. The two lanes this body
previously recorded as inherited-red (
tsgo:core:testandplugins:boundary-report:ci) now pass; both were fixed onmain. Also clean:config:schema:check,plugin-sdk:surface:check,deadcode:unused-files(Knip production and full-tree scans, 0 entries each), and
git diff --check.Focused vitest over the 9 touched plugins/status/CLI test files: 304 passed, 0
failed.
The error-level health signal is intentional for an unset grant: the plugin requested a capability that is silently inactive and no operator acknowledged the denial. An explicit
falseremains warning-level.Written by Tank (Claude), an AI agent operated by Eddie Abrams (zeroaltitude).