Skip to content

refactor(hooks): share optional reply metadata projection - #148641

Merged
vincentkoc merged 1 commit into
mainfrom
refactor/message-hook-reply-projection-20260914
Sep 15, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
refactor/message-hook-reply-projection-20260914

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

This maintainer-requested refactor is part of the approved duplication and complexity reduction deliverable.

Four message-hook projections repeat the same optional reply metadata rules. Updating the generic plugin context, inbound claim context, claim event, and received event separately makes those payload shapes easy to diverge.

User Impact

Defined reply fields retain their existing values and order, including empty strings and false. Absent or undefined top-level fields remain omitted. Nested event metadata continues to include its existing keys even when their values are undefined.

Why This Change Was Made

A private reply-field projection now supplies all four outputs at their original insertion points. It retains the sent-context presence checks before reading fields; the canonical inbound producer already materializes those fields. Trace assignment, conversation resolution, media projection, and internal hook payloads remain unchanged. Production changes are net −13 lines; tests add 89 lines.

Evidence

  • Read the full mapper and focused tests, hook message types, received/sent and outbound delivery callers, the inbound claim dispatch call site, the SDK barrel, and the history that added reply metadata and canonical inbound projection.
  • Added three public shape cases across all four projections: absent fields, explicit undefined, and empty strings with false. They inspect ordered top-level entries and the separate nested metadata keys. A sent-context case records property reads and verifies that absent reply fields are not read. Existing populated reply, trace, media, conversation, and sent-hook cases remain intact.
  • git diff --check passed; the staged classifier selected core lanes without running them. One exact-head P2 review on 6894d3508cd44cbba4fa0f2e5a661e34632538d1 reported no actionable finding. It reviewed the supplied full owner and diff; the isolated environment lacked the remaining repository context and executed no tests.
  • Normal CI and Workflow Sanity passed for 6894d3508cd44cbba4fa0f2e5a661e34632538d1. Selected type, lint, formatter, dependency, and build gates passed.
  • The hooks runtime job passed all 33 mapper cases, including all four added cases, on tested merge 40d3f9119e826c223ab9ae9ddc2115ac69e4b02d. Its mapper source and test blobs match this PR; the hooks group passed 32 files and 403 cases. No live plugin, provider, or channel execution is claimed.

@vincentkoc vincentkoc self-assigned this Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 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 size: S maintainer Maintainer-authored PR labels Sep 15, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 15, 2026 00:18
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 12:13 AM ET / 04:13 UTC (Revision 2).

ClawSweeper review

What this changes

Shares optional reply-field projection across four plugin hook payloads and adds coverage for omitted fields, empty strings, false values, and sent-context property reads.

Merge readiness

✅ Ready for maintainer review

Keep open: this remains a useful, maintainer-requested cleanup absent from current main. The reviewed patch preserves existing payload contracts, and no actionable correctness or security finding remains.

Priority: P3
Reviewed head: 6894d3508cd44cbba4fa0f2e5a661e34632538d1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving refactor with useful boundary coverage and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored internal refactor is exempt from external-contributor live proof. Mapper shape tests and the successful linked CI job support the unchanged payload contract; no live plugin or channel execution is claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored internal refactor is exempt from external-contributor live proof. Mapper shape tests and the successful linked CI job support the unchanged payload contract; no live plugin or channel execution is claimed.
Evidence reviewed 6 items Introduced change preserves payload semantics: The complete mapper and introduced diff preserve field order, defined empty strings and false, and omission of undefined top-level fields. The helper remains private; nested metadata, public signatures, trace handling, and conversation resolution are unchanged.
Existing contract and actual callers: The inbound producer materializes all five reply fields. Received-hook dispatch, inbound claim construction, and outbound hooks consume the existing mapper entry points. The documented reply fields are plugin payload data; this patch does not change runtime instruction projection or depend on the Codex protocol.
Current main and release still contain repeated projection: The mapper is unchanged between the merge base and fetched main. Current main and latest release v2026.9.4 retain separate reply-field projection blocks, so the requested consolidation remains distinct work.
Findings None None.
Security None None.

How this fits together

Message hook mappers turn incoming channel messages and outgoing delivery results into payloads consumed by plugins. This refactor centralizes how existing reply metadata reaches those payloads.

flowchart LR
  A[Incoming channel message] --> C[Canonical message context]
  B[Outgoing delivery result] --> C
  C --> D[Optional reply field projection]
  D --> E[Plugin message context]
  D --> F[Inbound claim and received events]
  E --> G[Plugin hooks]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -13, Tests +89. Total +76 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 27 40 -13
Tests 1 89 0 +89
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 116 40 +76

Review metrics

None.

Technical review

Best possible solution:

Keep one private projection owner for optional reply fields while preserving the existing public hook payloads and their separate nested metadata contract.

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

Not applicable: this is behavior-preserving cleanup, not a reported runtime defect; source inspection confirms the repeated rules on current main.

Is this the best way to solve the issue?

Yes: a private helper at the existing insertion points consolidates the rules without expanding the plugin API or changing its consumers.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a bounded internal refactor that preserves existing behavior and reduces duplicated projection rules.
  • 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: The MEMBER-authored internal refactor is exempt from external-contributor live proof. Mapper shape tests and the successful linked CI job support the unchanged payload contract; no live plugin or channel execution is claimed.

Evidence

What I checked:

  • Introduced change preserves payload semantics: The complete mapper and introduced diff preserve field order, defined empty strings and false, and omission of undefined top-level fields. The helper remains private; nested metadata, public signatures, trace handling, and conversation resolution are unchanged. (src/hooks/message-hook-mappers.ts:324, 6894d3508cd4)
  • Existing contract and actual callers: The inbound producer materializes all five reply fields. Received-hook dispatch, inbound claim construction, and outbound hooks consume the existing mapper entry points. The documented reply fields are plugin payload data; this patch does not change runtime instruction projection or depend on the Codex protocol. Public docs: docs/plugins/hooks/messages.md. (docs/plugins/hooks/messages.md:82, 6894d3508cd4)
  • Current main and release still contain repeated projection: The mapper is unchanged between the merge base and fetched main. Current main and latest release v2026.9.4 retain separate reply-field projection blocks, so the requested consolidation remains distinct work. (src/hooks/message-hook-mappers.ts:356, 3a9d69db306c)
  • Focused validation and test-merge identity: GitHub confirms the linked hooks test job succeeded for the pinned head. Raw test-merge parents match the pinned base followed by the PR head, and both changed file blobs match the head. The captured body reports 33 mapper cases and 403 hooks cases passed; direct log inspection was blocked by the artifact host allowlist. No tests were executed during this read-only review. (src/hooks/message-hook-mappers.test.ts:258, 6894d3508cd4)
  • Relevant merged history: Current-main history identifies RomneyDa's canonical-input and interface-compatibility work. GitHub verifies refactor(hooks): derive canonical inbound projection #141880 merged, but it derives the canonical context type rather than sharing reply-field projection. Some deeper local history objects were unavailable; GitHub commit patches supplied the relevant compatibility context. (src/hooks/message-hook-mappers.ts:237, ff930f541128)
  • Review continuity and protected contribution: The captured prior review covers the same head and contains no findings or published rank-up moves. The author is a MEMBER, the PR carries maintainer protection, and its body explicitly identifies the requested duplication-reduction deliverable. Related fix: carry reply metadata into runtime context #90745 concerns runtime reply-context propagation, not this mapper consolidation. (6894d3508cd4)

Likely related people:

  • RomneyDa: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-15T00:30:41.845Z sha 6894d35 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc merged commit 280b2aa into main Sep 15, 2026
265 checks passed
@vincentkoc
vincentkoc deleted the refactor/message-hook-reply-projection-20260914 branch September 15, 2026 07:07
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 15, 2026
* commit '0945dabbe487213e95e84a72ad1aae3659e0e000': (115 commits)
  fix: omit automation service aliases from squash coauthors (#148883)
  test: restore services typecheck shard headroom (#148885)
  perf(trajectory): avoid native probes for truncation records (#148870)
  improve(gateway): load cron only when reload requests it (#143500)
  fix: resolve issue #146088 — [Bug]: The most recent Linux AppImage does not ship with the correct versions of libs needed to run (#148174)
  refactor(theme): share nonvirtual ANSI color lookup (#148717)
  perf(gateway): scope exact session row topology reads (#148836)
  improve(memory): reduce vector replacement overhead (#148201)
  fix(i18n): keep HTTP headers out of native translations (#147119)
  refactor(plugins): share source-root display formatting (#148646)
  fix(cron): reject blank script paths before mutations (#148787)
  refactor(config): share audit positional scanning (#148643)
  fix(test): restore infrastructure typecheck shard headroom (#148861)
  fix(release): harden package validation fallbacks (#148729)
  refactor(config): share leaf and descendant unset pruning (#148216)
  test: reuse prepared runtime for pristine preflight (#148858)
  fix(ui): settle global model drafts across agent switches (#148843)
  fix(queue): avoid repeated scans when cancelling backlogs (#148754)
  fix(logging): orphaned \\\\?\\ path markers corrupt redacted Windows diagnostics (#147542)
  refactor(hooks): share optional reply metadata projection (#148641)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 16, 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: S 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