Skip to content

refactor(hooks): classify events without loading the registry - #203017

Merged
vincentkoc merged 1 commit into
mainfrom
refactor/internal-hook-event-contracts
Nov 21, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
refactor/internal-hook-event-contracts

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Fixes #202938

What Problem This Solves

Event classification through the hook facade loads the runtime registry.

User Impact

No intended behavior change; SDK exports and dispatch stay unchanged.

Why This Change Was Made

Move unchanged contracts/predicates to the existing event-contract owner and migrate callers.

Evidence

  • 86 tests, five typegraphs, lint/format, signed hooks and full source review passed.
  • Cold regression: BASE production overlay fails; restored HEAD passes, with HEAD tests/tooling.
  • SDK declaration/mapper checks and Slack/Telegram package consumers passed.
  • CI passed at ebbd64e9: Build dist, CLI smokes, built-artifact and selected package-boundary checks passed. Native-policy/published-driver packaging skipped.

@vincentkoc vincentkoc self-assigned this Nov 21, 2026
@clawsweeper

clawsweeper Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M labels Nov 21, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 21, 2026
@clawsweeper

clawsweeper Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR moves hook event contracts and predicates into the existing event-contract module so classification avoids loading the runtime registry.

Example: A bootstrap hook classifies an agent:bootstrap event with workspaceDir /tmp and bootstrapFiles [].

  • Before: Importing the predicate through the hook facade also loads the registry and logging runtime.
  • After: The facade loads the event-contract module and returns the same classification.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The source change is focused and appears correct, but its new regression, affected consumers, build, and emitted declarations lack execution evidence.
Proof confidence 🦪 silver shellfish (2/6) This behavior-preserving internal refactor requires no shipped user-flow demonstration; its dependency and compatibility checks remain pending validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Hook modules load registry and logging machinery merely to classify bootstrap events; no user-visible malfunction is established.
Reason: The maintainer-authored direction is explicit, and the implementation creates a cleaner dependency boundary using an existing owner without changing supported behavior.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this maintainer-authored draft open: the focused refactor addresses an existing dependency boundary, and source review found no introduced defect.

Priority: P3
Reviewed head: ebbd64e9ad603803188934e36a7343e7ebecd3cf

Before merge

  • Complete next step - The PR author should establish base-red/head-green cold-facade behavior, run affected hook/bootstrap/mapper/session-patch suites and targeted checks, and validate the build plus emitted SDK mapper compatibility.

Findings

None.

Agent review details

How this fits together

Bootstrap handlers consume event predicates through the hook facade; registration, dispatch, enablement, and session-source redaction remain in the runtime owner.

flowchart LR
  A[Bootstrap event] --> B[Hook handler]
  B --> C[Hook facade]
  C --> D[Event contracts and predicates]
  E[Event producers] --> F[Hook runtime registry]
  F --> B
Loading

Technical review

Best possible solution:

Keep event facts and classification in the existing contract owner while preserving the facade, runtime semantics, and public mapper compatibility.

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

Current-main source directly establishes facade-to-runtime loading; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch uses the existing contract owner, removes the replaced declarations and predicate exports, and updates all discovered consumers without adding parallel machinery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c7dfdfc32087.

Provenance checked

  • Event contracts and predicates keeps the original intent (97d1b88: The existing event-contract module was extracted to break runtime dependency cycles; moving unchanged specific contracts and pure predicates extends that separation.)
  • Bootstrap predicate behavior keeps the original intent (28f8b7b: The original guard classifies bootstrap events using their family, action, workspace directory, and bootstrap-file array; those checks are preserved.)
  • Hook facade keeps the original intent (e2ec828: The facade was narrowed to its production-used predicate and handler alias during unused-export cleanup; this PR retains that surface.)
  • Dispatch and mapper ownership keeps the original intent (1514b7c: The earlier consolidation preserved hook payload shapes, ordering, and public facades; runtime and mapper bodies remain unchanged here.)

Testing

Proof path: none.

Security

None.

Evidence

What I checked:

  • Direction and scope: The maintainer-authored linked issue explicitly requests this move, preserves runtime responsibilities, and requires public mapper compatibility: Keep hook event predicates independent of registry loading #202938.
  • Pinned introduction: The introduced hunks move the declarations and predicates unchanged, retarget their consumers, and leave registration, dispatch, redaction, and caller bodies unchanged. (src/hooks/internal-hook-types.ts:64, ebbd64e9ad60)
  • Current main retains the coupling: Current main still reexports the bootstrap predicate from internal-hooks.ts, whose evaluation initializes shared handler state and a logger. (src/hooks/hooks.ts:5, c7dfdfc32087)
  • Public boundary retained: The public hook-runtime barrel retains its registry and mapper exports; moved payload shapes remain identical in source, while emitted declaration compatibility is explicitly pending. (src/plugin-sdk/hook-runtime.ts:6, ebbd64e9ad60)
  • Regression coverage proposed: The new cold-facade test makes runtime loading throw and then imports the real facade; existing predicate assertions are moved rather than duplicated. (src/hooks/internal-hook-types.test.ts:109, ebbd64e9ad60)
  • Validation remains pending: The full PR body lists focused suites, base-red/head-green regression execution, targeted checks, build, and emitted SDK validation as pending; exact-head CI shows skipped build, test, and typecheck jobs rather than execution coverage. (ebbd64e9ad60)

Likely related people:

  • Vincent Koc: Raw commit 97d1b88 adds src/hooks/internal-hook-types.ts:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 97d1b88e3faa; files: src/hooks/internal-hook-types.ts)
  • Peter Steinberger: Raw commit 2e8ad07 adds src/hooks/internal-hooks.ts:145 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2e8ad07c2cf5; files: src/hooks/internal-hooks.ts)
  • Masato Hoshino: Raw commit e7ca90e adds src/hooks/internal-hook-types.ts:4 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: e7ca90e3afaf; files: src/hooks/internal-hook-types.ts)

PR surface

Source 0, Tests +39. Total +39 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 7 151 151 0
Tests 4 91 52 +39
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 242 203 +39

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #202938
Summary: This PR implements the linked issue's explicitly scoped dependency separation.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P3: This is internal dependency cleanup with no demonstrated user-visible failure or claimed performance improvement.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P3: This is internal dependency cleanup with no demonstrated user-visible failure or claimed performance improvement.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete the focused regression, consumer, build, and declaration validation already identified in the PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 21, 2026, 4:06 AM ET / 09:06 UTC.

@vincentkoc
vincentkoc marked this pull request as ready for review November 21, 2026 10:00
@vincentkoc
vincentkoc merged commit 25b89de into main Nov 21, 2026
242 checks passed
@vincentkoc
vincentkoc deleted the refactor/internal-hook-event-contracts branch November 21, 2026 10:22
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Nov 21, 2026
…3044

* origin/main:
  fix(ci): decouple boundary fixture from timing inventory (#203026)
  fix(ci): shard capable compatibility UI targets (#203042)
  perf(agents): restore selected subagent payloads once (#203039)
  fix: keep standalone context from completing QA tool steps
  perf(sessions): reuse sealed ownership for context projections (#203040)
  refactor(hooks): separate event predicates from hook registry (#203017)
  fix(ci): align update export audits with their consumers (#203030)
  fix: keep cold baseline checks within the existing heap limit
vincentkoc added a commit that referenced this pull request Nov 21, 2026
* feat: open shared sessions in their source Control UI

* feat: open shared sessions in their source Control UI

OpenClaw-Publication: a3826b6b-5899-8ff2-a1b5-84961c64219f

* Merge remote-tracking branch 'origin/main' into land/open-original-203044

* origin/main:
  fix(ci): decouple boundary fixture from timing inventory (#203026)
  fix(ci): shard capable compatibility UI targets (#203042)
  perf(agents): restore selected subagent payloads once (#203039)
  fix: keep standalone context from completing QA tool steps
  perf(sessions): reuse sealed ownership for context projections (#203040)
  refactor(hooks): separate event predicates from hook registry (#203017)
  fix(ci): align update export audits with their consumers (#203030)
  fix: keep cold baseline checks within the existing heap limit

* fix(session-share): accept the runtime config snapshot in the source link resolver

The stored-session link resolver took a mutable config, so the plugin's readonly
runtime snapshot failed production and test typechecks. Accept the snapshot type.

Document the real Open original setup: allow the link command on the receiver
Gateway, set the source Control UI origin, reinstall the source node with all
three commands, then approve the widened surface. Move the section ahead of
Security boundary and add a troubleshooting entry.

Assert through the Gateway catalog list that a provider-supplied link survives
streamed and final rows, and drop the menu unit test the browser fixture covers.

* Merge remote-tracking branch 'origin/main' into land/open-original-203044

* origin/main:
  refactor(test): remove duplicate token startup wait case (#203087)
  fix: keep Plugin SDK declarations within the build limit
  fix(ci): remove unused hook type exports (#203074)
  fix(test): exercise the sign-in callback path guard (#203075)
  refactor(tts): separate caption eligibility from text helpers (#203068)
  test: reuse worker preload options (#203058)
  refactor(test): share Bun native-policy test launcher (#203064)
  fix(cron): a chat-created automation's failure notice reaches that chat (#203056)
  refactor(test): remove duplicate claw origin rejection case (#203067)
  refactor(channels): move chunk-mode lookup to streaming readers (#203047)
  refactor: separate skill queries from workspace discovery (#203045)
  fix: resume new chat turns in retained tasks after a restart
  refactor: separate usage pricing preparation from formatting (#203043)
  fix: avoid repeated filesystem probes before agent turns (#203057)
  perf(agents): preserve sealed history during endpoint compaction (#203037)
  fix(test): give deferred identity fixtures read scope (#203053)
  refactor(test): remove redundant channel catalog facade (#203052)
  refactor(cli): isolate daemon port presentation (#203020)
  refactor(cron): isolate CLI input parsing (#203031)

* chore(plugin-sdk): record the approved session-discussion surface growth

Open original adds two exports to openclaw/plugin-sdk/session-discussion: the
stored-session Control UI path resolver and the session path parser. Raise the
public export and callable budgets by two for them.

Use neutral fixtures for the rejected-origin and rejected-query URL tests so the
fixtures do not resemble credentials; the same rejections are covered.

Co-authored-by: Vincent Koc <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 22, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 22, 2026
* feat: open shared sessions in their source Control UI

* feat: open shared sessions in their source Control UI

OpenClaw-Publication: a3826b6b-5899-8ff2-a1b5-84961c64219f

* Merge remote-tracking branch 'origin/main' into land/open-original-203044

* origin/main:
  fix(ci): decouple boundary fixture from timing inventory (openclaw#203026)
  fix(ci): shard capable compatibility UI targets (openclaw#203042)
  perf(agents): restore selected subagent payloads once (openclaw#203039)
  fix: keep standalone context from completing QA tool steps
  perf(sessions): reuse sealed ownership for context projections (openclaw#203040)
  refactor(hooks): separate event predicates from hook registry (openclaw#203017)
  fix(ci): align update export audits with their consumers (openclaw#203030)
  fix: keep cold baseline checks within the existing heap limit

* fix(session-share): accept the runtime config snapshot in the source link resolver

The stored-session link resolver took a mutable config, so the plugin's readonly
runtime snapshot failed production and test typechecks. Accept the snapshot type.

Document the real Open original setup: allow the link command on the receiver
Gateway, set the source Control UI origin, reinstall the source node with all
three commands, then approve the widened surface. Move the section ahead of
Security boundary and add a troubleshooting entry.

Assert through the Gateway catalog list that a provider-supplied link survives
streamed and final rows, and drop the menu unit test the browser fixture covers.

* Merge remote-tracking branch 'origin/main' into land/open-original-203044

* origin/main:
  refactor(test): remove duplicate token startup wait case (openclaw#203087)
  fix: keep Plugin SDK declarations within the build limit
  fix(ci): remove unused hook type exports (openclaw#203074)
  fix(test): exercise the sign-in callback path guard (openclaw#203075)
  refactor(tts): separate caption eligibility from text helpers (openclaw#203068)
  test: reuse worker preload options (openclaw#203058)
  refactor(test): share Bun native-policy test launcher (openclaw#203064)
  fix(cron): a chat-created automation's failure notice reaches that chat (openclaw#203056)
  refactor(test): remove duplicate claw origin rejection case (openclaw#203067)
  refactor(channels): move chunk-mode lookup to streaming readers (openclaw#203047)
  refactor: separate skill queries from workspace discovery (openclaw#203045)
  fix: resume new chat turns in retained tasks after a restart
  refactor: separate usage pricing preparation from formatting (openclaw#203043)
  fix: avoid repeated filesystem probes before agent turns (openclaw#203057)
  perf(agents): preserve sealed history during endpoint compaction (openclaw#203037)
  fix(test): give deferred identity fixtures read scope (openclaw#203053)
  refactor(test): remove redundant channel catalog facade (openclaw#203052)
  refactor(cli): isolate daemon port presentation (openclaw#203020)
  refactor(cron): isolate CLI input parsing (openclaw#203031)

* chore(plugin-sdk): record the approved session-discussion surface growth

Open original adds two exports to openclaw/plugin-sdk/session-discussion: the
stored-session Control UI path resolver and the session path parser. Raise the
public export and callable budgets by two for them.

Use neutral fixtures for the rejected-origin and rejected-query URL tests so the
fixtures do not resemble credentials; the same rejections are covered.

Co-authored-by: Vincent Koc <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep hook event predicates independent of registry loading

1 participant