Repository navigation
fix(plugins): preserve mutable hook context - #97281
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Codex review: needs maintainer review before merge. Reviewed June 27, 2026, 1:41 PM ET / 17:41 UTC. Summary PR surface: Source +12, Tests +159. Total +171 across 2 files. Reproducibility: yes. Source inspection shows current main clones plugin hook context while documented bootstrap hooks expect mutable context and the bootstrap consumer reads the original event after dispatch. Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the focused registry-wrapper repair after maintainer acceptance of the mutable hook-context contract and normal exact-head CI completion. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main clones plugin hook context while documented bootstrap hooks expect mutable context and the bootstrap consumer reads the original event after dispatch. Is this the best way to solve the issue? Yes, pending maintainer compatibility acceptance. Fixing the generic registry wrapper is narrower than a bootstrap-only workaround or field-by-field merge, and the finally cleanup addresses the pluginConfig leakage concern that caused the clone. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1bdde6695030. Label changesLabel justifications:
Evidence reviewedPR surface: Source +12, Tests +159. Total +171 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
* fix(plugins): preserve mutable hook context * fix(plugins): satisfy hook context lint
* fix(plugins): preserve mutable hook context * fix(plugins): satisfy hook context lint
Closes #75245
What Problem This Solves
Fixes an issue where plugin
registerHook()handlers could mutate theevent.contextobject they received, but core would silently ignore those mutations when the handler ran through the plugin registry wrapper. In practice this brokeagent:bootstrapplugins that replacebootstrapFiles: the plugin logged success, but child runs still received the original bootstrap file set.Why This Change Was Made
The plugin registry wrapper now passes the original mutable hook context object to each handler, temporarily injects that handler's
pluginConfig, and restores/removespluginConfigin afinallyblock after the handler returns. That preserves the documented mutable hook contract while keeping per-handler config isolated so one plugin's config does not leak into later handlers.AI-assisted: prepared with Codex and verified locally.
User Impact
Plugins that intentionally mutate hook context now work the way the hook contract and docs imply they should. For
agent:bootstrap, bootstrap file replacements/removals now survive into the final injected context used by the agent run, whilepluginConfigremains visible only to the owning handler.Evidence
node scripts/run-vitest.mjs src/plugins/loader.test.ts -t "injects plugin config into internal hook event context"node scripts/run-vitest.mjs src/plugins/loader.test.ts -t "preserves plugin hook context mutations for bootstrap hooks"node scripts/run-vitest.mjs src/plugins/loader.test.ts -t "runs consecutive plugin hook handlers with shared mutable context but isolated plugin config"node scripts/run-vitest.mjs src/agents/bootstrap-hooks.test.tsnpm run tsgo:test:srcnode scripts/run-oxlint.mjs src/plugins/registry.tsnode_modules\.bin\oxfmt.cmd --check --threads=1 src/plugins/registry.ts src/plugins/loader.test.tsgit diff --checkReal loader proof with temporary local plugins loaded through
loadOpenClawPluginsand redacted paths:Not run:
pnpm check/pnpm check:changedlanes were not run in this worktree; focused source tests, lint/format, andtsgo:test:srcwere used instead.