Skip to content

refactor(agent-runner): split run leaf ownership - #122148

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

steipete merged 2 commits into
mainfrom
steipete/run-leaf-ownership-splits

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two grandfathered embedded-run owners mixed independent policy and lifecycle concepts in oversized modules and tests, requiring four max-lines suppressions. This is wave 3 PR 1 of the simplification campaign, following the wave 1/2 ownership splits in #121929, #121974, #121995, and #122002.

Why This Change Was Made

This behavior-neutral refactor extracts payload tool-warning policy into tool-error-warning.ts, and separates model-call observation, lifecycle, and stream-proxy ownership behind the existing diagnostic entrypoint. Matching oversized tests are split along the same concepts. Existing public imports and mock seams remain on payloads.ts and attempt.model-diagnostic-events.ts.

The planned argument-repair split is intentionally excluded: its structured-message tool-name normalizer is shared by the proposed parser and stream owners, so the approved single-export seam would require either a second internal export or a non-verbatim adapter. The work order's escape hatch keeps that file, suppression, and baseline entry unchanged.

Module line counts after the split:

  • payloads.ts: 552
  • tool-error-warning.ts: 392
  • payloads.errors.test.ts: 474
  • tool-error-warning.test.ts: 730
  • attempt.model-diagnostic-events.ts: 219
  • attempt.model-diagnostic-observation.ts: 391
  • attempt.model-diagnostic-lifecycle.ts: 440
  • diagnostic stream/observation/lifecycle tests: 418 / 732 / 611

The four completed production/test suppressions and their config/max-lines-baseline.txt entries are removed.

User Impact

None. Reply payload text, warning policy, diagnostic event ordering, trace propagation, hook behavior, byte accounting, stream cleanup, and public exports are unchanged.

Evidence

  • Focused Vitest, one invocation across 12 affected split and consumer files: 3 shards, 12 files, 469 tests passed.
  • node scripts/check-changed.mjs: passed all selected core, core-test, lint, dead-export, formatting, architecture, and tooling gates locally after no remote backend was available.
  • pnpm build: passed in 14m12s; no INEFFECTIVE_DYNAMIC_IMPORT warning.
  • pnpm check:import-cycles: 0 runtime value cycles.
  • pnpm check:madge-import-cycles: 0 cycles.
  • pnpm plugin-sdk:surface:check: passed; 152 public entrypoints and 4,866 public exports unchanged.
  • pnpm check:max-lines-ratchet --base origin/main: passed with 956 grandfathered suppressions; this branch removes four entries.
  • Targeted per-file oxlint and git diff --check: passed.
  • Final structured autoreview against origin/main: clean, no accepted/actionable findings.

Raw move-aware classification from git diff --numstat origin/main...HEAD:

  • Production: +1,276 / -1,175 (net +101), consisting of moved bodies plus module contracts and composition wiring.
  • Tests: +2,138 / -1,928 (net +210), consisting of moved cases plus per-file fixtures/imports.
  • Tooling baseline: +0 / -4.

@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 16:50
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 11, 2026
@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
@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 12:55 PM ET / 16:55 UTC.

ClawSweeper review

What this changes

The PR splits embedded agent-run tool-warning policy and model-call diagnostic lifecycle/observation logic into smaller modules while preserving the existing public entrypoints and tests.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking source-level defect found: the split keeps the existing diagnostic and payload entrypoints while moving their private policy and lifecycle bodies into focused owners. Keep this maintainer-authored PR open for its normal final merge-result and exact-head CI checks.

Priority: P3
Reviewed head: 4746d2a9330e253805da626249d1f907f161c0e8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The split has a coherent owner boundary and no identified correctness defect; final confidence depends on the pending exact-head CI and merge-result validation.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, behavior-preserving internal refactor is appropriately supported by focused ownership tests and final CI rather than contributor-side real-world 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, behavior-preserving internal refactor is appropriately supported by focused ownership tests and final CI rather than contributor-side real-world proof.
Evidence reviewed 6 items Stable diagnostic facade: The branch keeps the existing wrapper as the entrypoint and composes the extracted lifecycle and observation owners behind it.
Stable payload boundary: The payload builder delegates warning construction to the extracted owner while retaining duplicate-warning suppression and payload metadata assembly at the channel-payload boundary.
Caller coverage: Normal attempt execution and compaction both continue to enter the same diagnostic wrapper, so the extraction does not create a second runtime path.
Findings None None.
Security None None.

How this fits together

Embedded agent runs wrap model streams to emit diagnostics and turn final results into channel reply payloads. This change reorganizes the private helpers behind those two boundaries without changing their callers.

flowchart LR
  A[Model stream] --> B[Diagnostic entrypoint]
  B --> C[Lifecycle owner]
  B --> D[Observation owner]
  C --> E[Events and hooks]
  A --> F[Reply payload builder]
  F --> G[Tool warning policy]
  G --> H[Channel reply payload]
Loading

Before merge

  • Resolve merge risk (P1) - The PR is behind the supplied current main SHA and its full CI matrix is still running; merge only after GitHub evaluates the final merge result and required checks for the exact head.
  • Complete next step (P2) - No concrete repair is needed; this open maintainer-authored refactor should proceed through its normal final CI and merge checks.
Agent review details

Security

None.

PR surface

Source +101, Tests +210, Other -4. Total +307 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 5 1276 1175 +101
Tests 5 2138 1928 +210
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 4 -4
Total 11 3414 3107 +307

Review metrics

Metric Value Why it matters
Production vs test delta production net +101; tests net +210; tooling baseline -4 The PR body’s move-aware classification shows modest composition/import growth while removing four max-lines baseline entries.

Stored data model

Persistent data-model change detected: serialized state: src/agents/embedded-agent-runner/run/attempt.model-diagnostic-observation.ts, vector/embedding metadata: src/agents/embedded-agent-runner/run/attempt.model-diagnostic-events.ts, vector/embedding metadata: src/agents/embedded-agent-runner/run/attempt.model-diagnostic-lifecycle.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the existing two entrypoints as composition facades, keep warning, observation, and lifecycle state in their extracted private owners, and land after final exact-head validation.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the existing two entrypoints as composition facades, keep warning, observation, and lifecycle state in their extracted private owners, and land after final exact-head validation.

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

Not applicable: the PR reorganizes existing internal ownership rather than repairing a reported user-facing failure.

Is this the best way to solve the issue?

Yes: extracting the private policy and lifecycle seams while preserving the callers’ established entrypoints is the narrowest maintainable way to remove the max-lines debt.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 82ba647673f9.

Labels

Label changes:

  • add P3: This is behavior-neutral internal maintainability cleanup rather than a user-facing defect or feature.
  • 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, behavior-preserving internal refactor is appropriately supported by focused ownership tests and final CI rather than contributor-side real-world proof.

Label justifications:

  • P3: This is behavior-neutral internal maintainability cleanup rather than a user-facing defect or feature.
  • 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, behavior-preserving internal refactor is appropriately supported by focused ownership tests and final CI rather than contributor-side real-world proof.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Recent blame for both normal-run and compaction diagnostic-wrapper call sites points to this agent-runner refactor commit. (role: recent agent-runner contributor; confidence: high; commits: b30e0dc4c640; files: src/agents/embedded-agent-runner/run/attempt-stream.ts, src/agents/embedded-agent-runner/compaction-session-execution.ts)
  • steipete: This branch and the cited earlier merged ownership-split series establish sustained ownership of the simplification campaign. (role: adjacent refactor contributor; confidence: medium; commits: 91e8c9e5b331, 4746d2a9330e; files: src/agents/embedded-agent-runner/run/payloads.ts, src/agents/embedded-agent-runner/run/attempt.model-diagnostic-events.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 self-assigned this Aug 11, 2026
@steipete
steipete merged commit cc9119e into main Aug 11, 2026
185 of 186 checks passed
@steipete
steipete deleted the steipete/run-leaf-ownership-splits branch August 11, 2026 17:08
@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 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