Skip to content

refactor(plugins): consolidate lifecycle hook dispatch - #119429

Merged
steipete merged 1 commit into
mainfrom
codex/loc-0804-plugins-luem8u
Aug 5, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/loc-0804-plugins-luem8u

Conversation

@steipete

@steipete steipete commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Plugin lifecycle observation hooks repeated the same dispatch wrapper 17 times, increasing maintenance cost and the risk of inconsistent hook behavior. This is part of a maintainer-requested project-wide production LOC reduction campaign.

Why This Change Was Made

Route equivalent observation hooks directly through the existing typed lifecycle dispatcher while preserving every published hook signature, including the pairing hook indexed-access spelling required by the Plugin SDK API contract.

User Impact

No operator-visible behavior change; plugin event ordering, timeout handling, error isolation, and public types are unchanged. Removes 130 production lines.

Evidence

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 5, 2026
@steipete
steipete marked this pull request as ready for review August 5, 2026 02:47
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 4, 2026, 11:03 PM ET / August 5, 2026, 03:03 UTC.

ClawSweeper review

What this changes

This PR replaces 17 repeated plugin lifecycle observation-hook wrappers with equivalent typed properties that delegate directly to the shared dispatcher.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

No blocking correctness or security finding: the refactor preserves every lifecycle method’s typed call into the existing dispatcher. The protected maintainer label and pending exact-head build artifact check require owner review before merge.

Priority: P3
Reviewed head: dbb20e7941a1bb0d3f5262fccaff6e49e1b31d6c
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow, behavior-preserving refactor with retained lifecycle coverage and no actionable review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-labeled, behavior-preserving internal refactor has focused lifecycle coverage and supplied remote validation; no separate operator-visible proof is applicable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-labeled, behavior-preserving internal refactor has focused lifecycle coverage and supplied remote validation; no separate operator-visible proof is applicable.
Evidence reviewed 5 items PR implementation: The PR-head facade retains each observation hook’s literal name, typed event/context arguments, and Promise<void> return while delegating to the same void dispatcher.
Dispatcher invariant: The shared dispatcher still performs registry lookup, parallel invocation, timeout handling, error isolation, and awaits all handlers; the PR does not alter it.
Current-main comparison: The plugin hook file is unchanged between the PR base and supplied current main, so current main has not independently superseded this refactor.
Findings None None.
Security None None.

How this fits together

The plugin hook runner receives lifecycle events from agents, channels, sessions, and the gateway, then dispatches them to registered plugin handlers. This change only shortens the runner facade; dispatch behavior and plugin-facing signatures remain in place.

flowchart LR
  A[Agent, channel, and gateway events] --> B[Plugin hook runner]
  B --> C[Typed lifecycle dispatcher]
  C --> D[Registered plugin handlers]
  D --> E[Plugin observations and side effects]
Loading

Decision needed

Question Recommendation
Should this protected maintainer-owned lifecycle refactor proceed once its exact-head build-artifacts check completes? Proceed after exact-head checks: Confirm the completed build-artifacts result and merge the behavior-preserving cleanup.

Why: The maintainer label requires explicit human handling even though no code-level blocker was found.

Before merge

  • Add real behavior proof - Not applicable: This maintainer-labeled, behavior-preserving internal refactor has focused lifecycle coverage and supplied remote validation; no separate operator-visible proof is applicable.
  • Resolve merge risk (P1) - The exact-head build-artifacts check was still running, and the branch is behind current main; refresh the merge and validation state before landing.
  • Complete next step (P2) - No mechanical repair is needed; the protected maintainer label and unfinished exact-head check require owner confirmation.
Agent review details

Security

None.

PR surface

Source -130. Total -130 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 68 198 -130
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 68 198 -130

Review metrics

Metric Value Why it matters
Production versus test LOC production +68/-198 (net -130), tests 0 The single-file cleanup materially reduces repeated production code without expanding behavior or test surface.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep a single typed dispatcher and merge this net-negative facade cleanup after the owner confirms the exact-head checks and merge result.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep a single typed dispatcher and merge this net-negative facade cleanup after the owner confirms the exact-head checks and merge result.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR refactors existing dispatch code rather than reporting a user-facing failure; focused lifecycle suites cover the affected methods.

Is this the best way to solve the issue?

Yes. Direct typed facade properties preserve the public signatures while retaining one canonical dispatcher for ordering, timeout, and error policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 22de30f99821.

Labels

Label changes:

  • add P3: This is a behavior-preserving internal cleanup with no reported operator impact.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-labeled, behavior-preserving internal refactor has focused lifecycle coverage and supplied remote validation; no separate operator-visible proof is applicable.

Label justifications:

  • P3: This is a behavior-preserving internal cleanup with no reported operator impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-labeled, behavior-preserving internal refactor has focused lifecycle coverage and supplied remote validation; no separate operator-visible proof is applicable.

Evidence

What I checked:

  • PR implementation: The PR-head facade retains each observation hook’s literal name, typed event/context arguments, and Promise return while delegating to the same void dispatcher. (src/plugins/hooks.ts:1632, dbb20e7941a1)
  • Dispatcher invariant: The shared dispatcher still performs registry lookup, parallel invocation, timeout handling, error isolation, and awaits all handlers; the PR does not alter it. (src/plugins/hooks.ts:697, 7a0a4c5f2a3b)
  • Current-main comparison: The plugin hook file is unchanged between the PR base and supplied current main, so current main has not independently superseded this refactor. (src/plugins/hooks.ts:1626, 22de30f99821)
  • Existing behavioral coverage: Focused suites directly exercise LLM, message, session, subagent, gateway, cron, and pairing lifecycle dispatches. (src/plugins/wired-hooks-llm.test.ts:10, 1b499e2c3ca1)
  • Feature provenance: Blame attributes the original wrapper and dispatcher lines to the same recent plugin-hook implementation, making the PR author the clearest current-area routing candidate. (src/plugins/hooks.ts:1004, 7a0a4c5f2a3b)

Likely related people:

  • steipete: Introduced the current dispatcher and the wrappers this PR consolidates, and authored the proposed refactor. (role: recent area contributor; confidence: high; commits: 7a0a4c5f2a3b, dbb20e7941a1; files: src/plugins/hooks.ts)
  • vincentkoc: Recent history includes substantial hook execution and subagent lifecycle work in the same runner. (role: adjacent plugin lifecycle contributor; confidence: medium; commits: 80707db7abef, 8530edb057ed; files: src/plugins/hooks.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 1f3d45b into main Aug 5, 2026
186 of 191 checks passed
@steipete
steipete deleted the codex/loc-0804-plugins-luem8u branch August 5, 2026 03:11
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 5, 2026
* origin/main: (22 commits)
  refactor(plugins): consolidate lifecycle hook dispatch (#119429)
  fix(ci): stabilize TUI PTY proof ownership (#119420)
  test(system-agent): reduce suite setup overhead (#119424)
  fix(ui): keep session rail pill status from overlapping the headline (#119397)
  fix(discord): avoid doctor runtime loading (#119391)
  fix(media): decouple playback cache retention (#119417)
  fix(slack): infer upload filename extensions from MIME types (#119399)
  refactor(channels): unify configured binding resolution (#119414)
  refactor(google-meet): unify gateway and tool dispatch (#119413)
  test(state): reuse legacy database fixtures (#119423)
  fix(reset): preserve bootstrap guidance for dynamic models (#119179)
  fix(chutes): honor serving context limits (#119196)
  refactor(status): consolidate scan projections and lazy loaders (#119412)
  fix(status): status --all slows down with missing plugins (#119203)
  refactor(gateway): consolidate usage reporting and caches (#119409)
  perf(gateway): keep reload and recovery machinery off gateway cold start (#119094)
  fix(cli): align TaskFlow controller columns for wide text (#118801)
  fix: make startup migration restart guidance install-neutral (#119406)
  fix(ci): preserve cache warmer shard envelopes (#119403)
  fix(sessions): preserve compatible auth profiles on model changes (#117550)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant