Skip to content

refactor(agents): split subscribe leaf ownership - #122249

Merged
steipete merged 2 commits into
mainfrom
steipete/subscribe-leaf-splits
Aug 11, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/subscribe-leaf-splits

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The embedded-agent subscribe pipeline still concentrated tool-result extraction and assistant-message reconciliation in two oversized modules. That made ownership boundaries difficult to review and kept three max-lines suppressions in place, including the 2,310-line message-handler test.

Why This Change Was Made

Split tool handling into canonical result, media, and messaging-extraction leaves, and split assistant messages into stream projection, reply handoff, update, and lifecycle owners. Existing call sites now import their owner directly; Plugin SDK exports remain available through the same public paths. Event-ordering, partial/final reconciliation, and provider-boundary comments moved with their original bodies.

The small shared-types, callback, raw-stream, and compaction-runtime seams remain separate because they are intentional cycle, fatal-callback, diagnostic-sink, and lazy-persistence boundaries.

Production LOC: +101 net | Tests: +52 net | Ratchet entries: -3

User Impact

No user-visible behavior changes. Maintainers get smaller, acyclic subscribe modules with explicit ownership and no suppressions for either source monolith or the oversized message-handler test.

Evidence

  • Focused subscribe-adjacent Vitest, one invocation: 34 files, 674 tests passed across 4 shards.
  • Core production and core-test typechecks passed.
  • Core lint passed.
  • Both import-cycle checks passed with zero cycles.
  • Plugin SDK surface check passed: 152 public subpaths, 4,868 public exports unchanged.
  • Max-lines ratchet passed with the three entries removed.
  • Full build passed, including Plugin SDK declaration/export verification and Control UI build.
  • Autoreview: clean, no accepted/actionable findings.

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 11, 2026 20:31
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 11, 2026
@steipete
steipete force-pushed the steipete/subscribe-leaf-splits branch from 84ca0b0 to 366fdcc Compare August 11, 2026 20:39
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 5:59 PM ET / 21:59 UTC.

ClawSweeper review

What this changes

The PR splits embedded-agent tool-result extraction and assistant-message subscription handling into smaller owner modules while keeping Plugin SDK export names unchanged.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open: this maintainer-owned refactor remains unique, and no blocking correctness defect was found. The branch is behind current main, so it needs a refreshed merge result and exact-head CI before landing.

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

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The ownership split preserves the public SDK exports and carries focused regression coverage; only current-main integration remains.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal refactor has no claimed user-visible change; focused validation and exact-head CI are the relevant proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored internal refactor has no claimed user-visible change; focused validation and exact-head CI are the relevant proof.
Evidence reviewed 6 items Current main still has the two monoliths: Current main imports reply helpers from the single message handler and tool helpers from the single tool-results module, so the requested ownership split is not already implemented.
Dispatcher preserves ordered event boundary: The PR keeps the existing serialized dispatcher while routing lifecycle and update events to separate leaves; message_end remains awaited through the same scheduling path.
Plugin SDK export contract retained: The public agent-harness runtime continues to export the same messaging, media, error, and sanitizer helpers, only from their new owner modules.
Findings None None.
Security None None.

How this fits together

Embedded-agent subscriptions turn provider message and tool events into ordered agent stream updates and outbound reply payloads. Their helpers are also used by the gateway, CLI runner, system agent, and Plugin SDK runtime.

flowchart LR
  A[Provider and tool events] --> B[Embedded agent subscription]
  B --> C[Tool result leaves]
  B --> D[Assistant message leaves]
  C --> E[Gateway CLI and SDK consumers]
  D --> F[Ordered stream updates]
  D --> G[Outbound replies]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned refactor be refreshed onto current main and landed after exact-head CI passes? Refresh and land: Rebase or use the merge queue, confirm exact-head CI is green, and merge the ownership split.

Why: The protected maintainer label and maintainer authorship require explicit human handling, while the remaining work is integration verification rather than an automated repair.

Before merge

  • Resolve merge risk (P1) - The branch is behind current main; rebase or merge-queue reconciliation must refresh exact-head CI before landing.
  • Complete next step (P2) - This protected maintainer PR has no narrow repair finding; the remaining action is human-owned current-main integration and exact-head verification.
Agent review details

Security

None.

PR surface

Source +326, Tests -169, Other -3. Total +154 across 42 files.

View PR surface stats
Area Files Added Removed Net
Source 27 3191 2865 +326
Tests 14 2149 2318 -169
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 3 -3
Total 42 5340 5186 +154

Review metrics

Metric Value Why it matters
Production versus test LOC production +101 net; tests +52 net; 3 max-lines baseline entries removed The positive production delta is attributable to separating ownership while deleting the two monoliths and their oversized combined test file.

Stored data model

Persistent data-model change detected: serialized state: src/agents/embedded-agent-subscribe.handlers.messages.update-stream-phases.test.ts, vector/embedding metadata: src/agents/embedded-agent-subscribe.handlers.messages.stream-replies.test.ts, vector/embedding metadata: src/agents/embedded-agent-subscribe.handlers.messages.update-commentary.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Rebase or merge-queue the behavior-neutral split onto current main, then land it if the refreshed exact-head checks preserve the public SDK surface and ordered subscription behavior.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Rebase or merge-queue the behavior-neutral split onto current main, then land it if the refreshed exact-head checks preserve the public SDK surface and ordered subscription behavior.

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

Not applicable: this PR reorganizes existing behavior rather than reporting a user-facing defect.

Is this the best way to solve the issue?

Yes: direct leaf imports preserve the existing dispatcher and public SDK contract while removing the oversized ownership hubs; no duplicate replacement path was found.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 459c70e14a2c.

Labels

Label changes:

  • add P3: This is a behavior-neutral maintenance refactor with no reported user-facing regression.
  • 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-authored internal refactor has no claimed user-visible change; focused validation and exact-head CI are the relevant proof.

Label justifications:

  • P3: This is a behavior-neutral maintenance refactor with no reported user-facing regression.
  • 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-authored internal refactor has no claimed user-visible change; focused validation and exact-head CI are the relevant proof.

Evidence

What I checked:

  • Current main still has the two monoliths: Current main imports reply helpers from the single message handler and tool helpers from the single tool-results module, so the requested ownership split is not already implemented. (src/agents/embedded-agent-subscribe.ts:40, 459c70e14a2c)
  • Dispatcher preserves ordered event boundary: The PR keeps the existing serialized dispatcher while routing lifecycle and update events to separate leaves; message_end remains awaited through the same scheduling path. (src/agents/embedded-agent-subscribe.handlers.ts:11, 366fdcc0c6e6)
  • Plugin SDK export contract retained: The public agent-harness runtime continues to export the same messaging, media, error, and sanitizer helpers, only from their new owner modules. (src/plugin-sdk/agent-harness-runtime.ts:215, 366fdcc0c6e6)
  • Refactor provenance: The split was introduced in two focused commits: tool-result ownership first, then assistant-message ownership. (src/agents/embedded-agent-tool-results.ts:1, 366fdcc0c6e6)
  • Main has advanced without replacing this surface: Current main is 18 commits past the PR base; the checked latest commit modifies Gateway worker pacing rather than this subscription split. (src/gateway/worker-environments/placement-turn-claims.ts, 459c70e14a2c)
  • Validation evidence supplied by the PR: The PR reports focused subscription tests, production/test typechecks, lint, import-cycle checks, Plugin SDK surface verification, max-lines ratchet, and a full build; the provided check context records the relevant required checks as successful. (366fdcc0c6e6)

Likely related people:

  • steipete: Authored both ownership-split commits, and local history shows substantial prior contribution to the predecessor subscription modules. (role: refactor author and historical area contributor; confidence: high; commits: c6757d34ec34, 366fdcc0c6e6; files: src/agents/embedded-agent-tool-results.ts, src/agents/embedded-agent-subscribe.handlers.messages.update.ts, src/agents/embedded-agent-subscribe.handlers.messages.lifecycle.ts)
  • Kevin Lin: The checked current-main imports and Plugin SDK export block trace to the recent baseline commit available in the shallow history. (role: recent current-baseline contributor; confidence: medium; commits: 2d0c30fd654e; files: src/agents/embedded-agent-subscribe.ts, src/plugin-sdk/agent-harness-runtime.ts)

Rank-up moves

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

  • Rebase or use the merge queue and obtain exact-head CI for the resulting commit.

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-08-11T21:11:29.911Z sha 366fdcc :: needs maintainer review before merge. :: none

@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 Aug 11, 2026
@steipete steipete self-assigned this Aug 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer landing note: skipping the optional drift-only rebase from the latest ClawSweeper rank-up moves. The PR is MERGEABLE, exact-head hosted CI/Testbox passed at 366fdcc0c6e6a4dce715d6d03d53b06dc4285ff2, and the requested landing policy treats main drift as advisory. Native wrapper prepare completed without a source conflict or head rewrite.

@steipete
steipete merged commit 87b3c0e into main Aug 11, 2026
127 checks passed
@steipete
steipete deleted the steipete/subscribe-leaf-splits branch August 11, 2026 22:04
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 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: XL 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