Skip to content

refactor(agent-runner): split run policy ownership - #122209

Merged
steipete merged 6 commits into
mainfrom
steipete/run-policy-ownership-splits
Aug 11, 2026
Merged

steipete merged 6 commits into
mainfrom
steipete/run-policy-ownership-splits

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two grandfathered embedded-run owners still mixed independent policy concepts in oversized production modules and tests, requiring four max-lines suppressions. This is wave 3 PR 2 of the ownership-split campaign, following #122148.

Why This Change Was Made

This behavior-neutral refactor separates tool-call name resolution, replay sanitization, live stream normalization, and text promotion into distinct owners while preserving the exact wrapper composition order in attempt-stream.ts. It also separates incomplete-turn classification, terminal evidence, payload/liveness resolution, and retry recovery so classification and evidence remain dependency leaves and recovery never depends on resolution.

All callers now import the owning module directly; no compatibility barrels were added. The deferred argument-repair split remains intentionally untouched.

Module line counts after the split:

  • tool-call name / replay / stream / promotion owners: 223 / 520 / 362 / 144
  • incomplete-turn classification / evidence / resolution / recovery owners: 249 / 94 / 328 / 370
  • split focused tests: 219–632 lines

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

User Impact

None. Tool-call replay, promoted IDs, provider transcript validation, tool-result pairing, retry eligibility, delivery evidence, run liveness, and user-visible incomplete-turn messages are unchanged.

Evidence

  • One combined focused Vitest invocation: 4 shards, 20 files, 396 tests passed. This includes all split tests, attempt.test.ts, and three subscribe lifecycle files.
  • Anthropic replay live file loaded under the dedicated live config; 3 authenticated cases skipped because live credentials were not enabled.
  • Post-rebase normalization proof: 6 files, 166 tests passed after carrying the upstream normalizeToolPolicyName rename into the extracted owners.
  • Isolated Linux local-container proof (cbx_ae9fc2af6bf8, tidal-krill): pnpm check:changed passed the selected formatting, dead-export, production/test typecheck, full core lint, boundary, and import-cycle gates; pnpm build passed in 4m21s. Blacksmith Testbox and brokered AWS were unavailable on this host, so this is container proof rather than remote proof.
  • pnpm check:import-cycles: 0 runtime value cycles.
  • pnpm check:madge-import-cycles: 0 cycles.
  • pnpm plugin-sdk:surface:check: 152 public entrypoints and 4,868 public exports unchanged.
  • pnpm check:max-lines-ratchet --base origin/main: passed with 945 grandfathered suppressions; this branch removes four entries.
  • Per-file oxlint, stale-caller/mock-seam searches, and git diff --check: passed.
  • Final structured branch review against origin/main: clean, no accepted/actionable findings.

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

  • Production: +2,315 / -2,245 (net +70), consisting of moved policy bodies plus module contracts and caller repointing.
  • Tests and test support: +7,038 / -6,628 (net +410), consisting of moved cases plus per-file imports and shared fixtures.
  • 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.

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Aug 11, 2026
@steipete
steipete marked this pull request as ready for review August 11, 2026 18:38
@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Aug 11, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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, 3:54 PM ET / 19:54 UTC.

ClawSweeper review

What this changes

The branch splits embedded agent-runner stream and incomplete-turn policy into focused modules, repoints callers, and divides the related tests into dedicated shards.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No remaining blocking patch defect found. The prior serial-test-routing finding is fixed at the latest head; keep this protected maintainer PR open until exact-head checks finish and a maintainer decides to merge.

Priority: P3
Reviewed head: 628ad6511d56b89f96fbc6085b6b23f2bbbd9e1a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The updated branch resolves the prior routing defect and has a coherent owner-boundary split, with exact-head CI still needed before merge.
Proof confidence 🌊 off-meta tidepool Not applicable: This protected maintainer behavior-neutral refactor is supported by targeted test and build evidence; the external-contributor real-setup proof gate does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This protected maintainer behavior-neutral refactor is supported by targeted test and build evidence; the external-contributor real-setup proof gate does not apply.
Evidence reviewed 6 items Prior routing finding repaired: The latest head checks the enumerated incomplete-turn owner before unit-fast routing, so each split test retains the serial project rather than relying on the old nonmatching glob membership.
Routing completeness coverage: The updated test discovers every split incomplete-turn test, requires equality with the owner list, and asserts the dedicated serial config for each file.
Preserved stream composition: The changed stream entry point only repoints the existing replay, normalization, and promotion wrappers to their extracted owners; wrapper installation order remains at the caller.
Findings None None.
Security None None.

How this fits together

Embedded agent runs turn provider stream output into tool calls and decide whether incomplete responses are retried, surfaced to users, or recorded as terminal. Those decisions feed delivery evidence, run liveness, and recovery behavior.

flowchart LR
A[Provider stream] --> B[Tool-call normalization]
B --> C[Embedded run attempt]
C --> D[Incomplete-turn policy]
D --> E[Retry or terminal decision]
E --> F[Delivery and run state]
Loading

Before merge

  • Resolve merge risk (P1) - This changes focused-test routing for stateful runner mocks; merge only after exact-head agent-runtime checks confirm the dedicated serial shard remains selected.
Agent review details

Security

None.

PR surface

Source +260, Tests +251, Other -2. Total +509 across 47 files.

View PR surface stats
Area Files Added Removed Net
Source 22 2511 2251 +260
Tests 23 6879 6628 +251
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 5 7 -2
Total 47 9395 8886 +509

Review metrics

Metric Value Why it matters
Production versus test LOC production +2,315/-2,245 (net +70); tests and test support +7,038/-6,628 (net +410) The modest production growth is attributable to explicit owner boundaries and caller repointing, while most churn is moved and divided coverage.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/agents/embedded-agent-runner/run/attempt-tool-call-replay-sanitization.ts, migration/backfill/repair: src/agents/embedded-agent-runner/run/attempt-tool-call-text-promotion.ts, migration/backfill/repair: src/agents/embedded-agent-runner/run/attempt.tool-call-normalization.ts, serialized state: src/agents/embedded-agent-runner/run.incomplete-turn.classification.test.ts, serialized state: src/agents/embedded-agent-runner/run.incomplete-turn.error-recovery.test.ts, serialized state: src/agents/embedded-agent-runner/run.incomplete-turn.reasoning-recovery.test.ts, and 1 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Complete exact-head routing validation (recommended)
    Merge after the current head's agent-runtime checks confirm the split incomplete-turn tests run through their dedicated serial configuration.

Technical review

Best possible solution:

Preserve the direct extracted-owner imports and enumerated serial test list, then merge after exact-head agent-runtime validation is green.

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

Not applicable: this is a behavior-neutral refactor, and the relevant verification is source-equivalence plus focused test-project routing coverage rather than a user failure reproduction.

Is this the best way to solve the issue?

Yes. The split keeps composition at the existing stream and terminal callers while moving independent policy leaves into direct owners; retaining the oversized monolith or adding a compatibility barrel would not improve the boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7a1d5a86c7ba.

Labels

Label changes:

  • 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 protected maintainer behavior-neutral refactor is supported by targeted test and build evidence; the external-contributor real-setup proof gate does not apply.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P3: This is behavior-neutral internal ownership cleanup rather than a user-facing fix or feature.
  • merge-risk: 🚨 automation: The diff changes focused Vitest project selection for stateful agent-runner tests, so incorrect routing could weaken CI isolation.
  • 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 protected maintainer behavior-neutral refactor is supported by targeted test and build evidence; the external-contributor real-setup proof gate does not apply.

Evidence

What I checked:

  • Prior routing finding repaired: The latest head checks the enumerated incomplete-turn owner before unit-fast routing, so each split test retains the serial project rather than relying on the old nonmatching glob membership. (scripts/test-projects.test-support.mts:3151, 628ad6511d56)
  • Routing completeness coverage: The updated test discovers every split incomplete-turn test, requires equality with the owner list, and asserts the dedicated serial config for each file. (test/scripts/test-projects.test.ts:1020, 628ad6511d56)
  • Preserved stream composition: The changed stream entry point only repoints the existing replay, normalization, and promotion wrappers to their extracted owners; wrapper installation order remains at the caller. (src/agents/embedded-agent-runner/run/attempt-stream.ts:29, 628ad6511d56)
  • Dependency contract inspected: The extracted plain-text promotion owner uses the existing local tool-call-repair public functions and matcher contract; the package exports those APIs from its public index. (packages/tool-call-repair/src/index.ts:1, 7a1d5a86c7ba)
  • Current-main comparison and ownership provenance: Current main still contains the pre-split monolithic incomplete-turn owner, while blame attributes that surface and the latest routing repair to Peter Steinberger; main has not independently absorbed this PR. (src/agents/embedded-agent-runner/run/incomplete-turn.ts:1, 7a1d5a86c7ba)
  • Security surface check: The branch diff contains no workflow, dependency manifest, lockfile, publishing, or secret-handling changes. (628ad6511d56)

Likely related people:

  • steipete: Current-main blame attributes the original owner and the latest serial-routing repair to Peter Steinberger, and this PR's six commits continue that agent-runner ownership work. (role: recent area contributor; confidence: high; commits: 2d69e3979638, 628ad6511d56; files: src/agents/embedded-agent-runner/run/incomplete-turn.ts, scripts/test-projects.test-support.mts, src/agents/embedded-agent-runner/run/attempt-stream.ts)

Rank-up moves

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

  • Wait for exact-head agent-runtime checks to complete successfully.

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-11T19:00:27.555Z sha 0d8a5f6 :: found issues before merge. :: [P2] Route every split incomplete-turn test to its dedicated config

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Aug 11, 2026
@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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 11, 2026
@steipete
steipete merged commit a40df57 into main Aug 11, 2026
130 checks passed
@steipete
steipete deleted the steipete/run-policy-ownership-splits branch August 11, 2026 20:06
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 12, 2026
* refactor(agent-runner): split tool-call normalization ownership

* refactor(agent-runner): split incomplete-turn ownership

* test(agent-runner): hide incomplete-turn test helper

* test(ci): route split incomplete-turn tests

* test(ci): enumerate split incomplete-turn tests

* test(vitest): route split incomplete-turn tests to their serial shard
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 merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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