Repository navigation
Conversation
|
Codex review: needs maintainer review before merge. What this changes: The PR changes the plugin Maintainer follow-up before merge: No repair lane is needed: the source PR now contains the code fix, regression tests, and changelog; remaining work is maintainer review, CI, and resolving mergeability if GitHub still reports conflicts. Security review: Security review cleared: The diff only changes in-process plugin hook context handling, tests, and changelog text; it does not add dependency, workflow, secret, package, or supply-chain surface. Review detailsBest possible solution: Land this PR or an equivalent narrow patch after mergeability and CI are green, preserving mutable hook-context behavior while restoring/removing per-handler Do we have a high-confidence way to reproduce the issue? Yes. Register an Is this the best way to solve the issue? Yes. Passing the original context and restoring What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against df4136018ecb. |
…er (openclaw#75245) The registerHook wrapper shallow-cloned event.context to inject pluginConfig, silently discarding mutations like event.context.bootstrapFiles = updated that mutable hooks (agent:bootstrap) require. Pass the original context object and temporarily augment it with pluginConfig via a try/finally cleanup instead. Regression test uses createPluginRegistry({ activateGlobalSideEffects: true }) to exercise the real wrapper path: hook fires, bootstrapFiles replacement survives, pluginConfig does not leak after handler returns. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The `as Record<string, unknown>` casts on `context` were flagged by oxlint as unnecessary — `evt.context` is already typed as `Record<string, unknown>` in InternalHookEvent. Access pluginConfig directly without casts. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…law#75245) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Summary
registerHook()wraps plugin handlers by shallow-cloningevent.contextto injectpluginConfig:This silently discards mutations that mutable hook contracts require.
agent:bootstrapis the primary victim: core readsevent.context.bootstrapFilesaftertriggerInternalHookreturns, expecting plugins to have mutated it. Instead, the plugin's assignment lands on the discarded clone.The fix passes the original
event.contextobject and temporarily augments it withpluginConfigvia atry/finallycleanup:Invariants preserved:
pluginConfigis visible to the handler during execution ✓ (existing test: "injects plugin config into internal hook event context")pluginConfigdoes not leak ontoevent.contextafter handler returns ✓ (new test)event.context.bootstrapFilessurvive the wrapper ✓ (new test, regression for registerHook wrapper drops mutable context changes for agent:bootstrap hooks #75245)Pre-implement audit
pluginConfiginjection pattern is unique to this wrapper — no shared helper to reuse.registerHookclosure is only called from withincreatePluginRegistryand itscreateApipath — no external caller contract affected.registerHookwrapper orwrappedHandlercontext mutation.Test plan
src/agents/bootstrap-hooks.test.ts— 3 tests pass (1 existing + 2 regression)src/plugins/loader.test.ts— 131/131 pass (including "injects plugin config into internal hook event context" which verifies pluginConfig is still injected)Fixes #75245.
🤖 Generated with Claude Code