Skip to content

refactor(agents): fold single-consumer runtime owners - #177005

Merged
steipete merged 1 commit into
mainfrom
deslop/z25-33-runtime-owners-20261015
Oct 19, 2026
Merged

steipete merged 1 commit into
mainfrom
deslop/z25-33-runtime-owners-20261015

Conversation

@steipete

@steipete steipete commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Agent preparation and attempt finalization pass data through private modules with one production consumer, leaving redundant exported implementation surfaces.

User Impact

No user-visible change. Public contracts, prompt bytes, lazy imports, authorization, transcript writes and completion evidence remain unchanged. Phase E is untouched.

Why This Change Was Made

Move ACP metadata overlay into the metadata owner, run/conversation preparation into session preparation, tool-search planning into the tool catalog, trajectory classification into attempt finalization, and the active policy gate into prompt preparation. Fold the sole-consumer transcript tool scanners into the usage parser, which now traverses content once for both calls and results. Remove the retired modules and their argument-projection packets. Retained tests now exercise the production owner rather than keeping private helpers exported.

This is the runtime-area slice of a materialized 84-file single-consumer family, split by area under campaign rule 11. Its reply, UI and plugin siblings remain separate for CI attribution. This slice removes 248 net production lines across 15 production paths, 29 total paths after conflict repair; tests/support and exact shrink-only inventory rows are excluded. An unused exported reply-tag return type also becomes module-private; the scanner itself remains separate to keep its 680-line consumer within the file cap.

Measured production delta: +377/-625 against main 572cb278b243dcde95875e671f7ef4355c39a188. Migrated tests/support: +515/-451 (64 net added). Obsolete assertion/mock/native-test inventory rows: four removed, with no expanded allowance.

Best-effort tradeoffs accepted

  • No authorization or failure-handling guard is removed. All source authorization, cancellation, tool visibility/execution/replay distinctions, durable-progress evidence, interruption-over-error precedence and non-deliverable terminal errors remain.
  • The trace-artifact evidence projection remains after the existing model-completed event; removing the classification packet does not move that observation earlier.
  • ACP persisted ownership and synthetic conversation prompt preparation retain their existing semantics; the folds introduce no new compatibility or recovery path.
  • Policy gating still fails closed, clones untrusted hook context, skips settled-turn finalization, and persists only the same redacted idempotent message through owned transcript admission. The public phase tests now run registered policy handlers and an actual guarded in-memory session manager; no helper mock can fabricate the block or persistence outcome.
  • Tool accounting preserves every supported call spelling, trimmed names, primary-alias precedence, first-mirror suppression, repeated calls, exact result types and explicit error flags from the completed fix(usage): preserve tool calls and count loaded interval messages #149547 accounting repair. Standalone tool-result roles retain their separate one-result path. No price, usage, persistence or schema contract changes.
  • Finalization consumes the required boolean emptyAssistantReplyIsSilent directly instead of comparing it with true. Its production caller supplies a computed boolean; non-boolean internal inputs contradict the existing type contract and receive no extra defensive equality check.

Evidence

Complete source/caller and migrated-test inspection and smallest-complete-cut pass completed. Before conflict repair, independent P0–P2 review of the entire 247-line candidate completed scoped-clean, including final source verification. An earlier unfinished review was stopped before assessment to remove an obsolete assertion allowance and use the existing object-record coercion boundary instead of moving a cast into the parser. Canonical formatting and whitespace checks passed.

Frozen/prefer-offline setup completed in 1m 2.7s using the existing pnpm store with isolated application state. No tracked manifest, lockfile or generated-file changes resulted. Targeted native types passed eleven owner/consumer test roots after fixing the hook fixture's two owned unknown-message type errors with the existing record guard; no cast, assertion, timeout or production behavior changed.

Initial focused proof reached seven files: 198 unique cases passed and one manual ACP elicitation fixture failed its short polling assertion before status publication. The unchanged isolated case then passed (14.5s), which is not proof of repair or inherited failure. An exploratory event-gate fixture change did not produce a verdict and was dropped; the original test and all its assertions remain unchanged. No timeout, retry or skip was added. The initial failure remains disclosed, not relabeled green.

Serial completion proof passed all five previously unreached owner suites: ACP metadata 3, prefix stability 5, prompt/finalization 30, session preparation 22, plus the 14-case suppression suite. This adds 60 distinct owner passes to the original 198; suppression is not double-counted. Five canonical shards took 1,156s on the shared host. Metadata/prefix/attempt shards were dominated by transform/import cost; session preparation took 244s, including about 86s exercising real metadata/skills/plugin/session composition. The migrated tests intentionally exercise those owners instead of restoring private production seams. CI seconds are pending.

Normal type-aware lint found one owned redundant required-boolean comparison in the folded finalization code. After its direct-boolean correction, the finalization owner passed all 12 cases and suppression all 14 again; targeted native types passed all eleven roots with no diagnostics. Those two canonical test shards took 432s, with finalization's 343s dominated by worker compilation (96%). Fresh whole-candidate independent P0–P2 review after this correction completed scoped-clean with final source verification. The one-file typed-lint replay passed; the other fifteen surviving lint targets had no findings. Changed-check planning completed in dry-run mode only, without executing broad gates. Runtime cycle check passed with zero value cycles; Madge passed with zero cycles. Whitespace and retired-path reference checks passed. The serial final proof pipeline exited successfully.

GitHub reported the first draft head conflicting. The repair rebases onto main 572cb278b243dcde95875e671f7ef4355c39a188, retaining Goal continuation after prepared conversation options and before return (#174211), requester recovery identity/custody (#157806), prompt tool-surface persistence, and Gateway publication-failure coverage. Refreshed frozen/prefer-offline setup completed in 24.2s after main's pinned dependency update; no tracked generated, manifest or lockfile changes resulted. Targeted native types passed twelve affected owner/consumer roots, including Goal continuation. Fresh whole-candidate P0–P2 review of the resolved candidate completed scoped-clean with final source verification.

Conflict-focused proof passed all 152 cases across six files: Gateway ownership 34, Goal continuation 53, prefix stability 5, prompt phase 18, session preparation 28, and suppression 14. Canonical shard wall times total 1,577.12s on the shared host. Gateway's 720.25s was 94% transform work; session preparation's 144.24s included 23% actual metadata/skills/plugin/session composition, which verifies the real preparation owner rather than reintroducing private test seams. This passing rebase run does not establish a repair or inherited cause for the separately disclosed ACP fixture failure. Conflict-focused type-aware lint passed all five affected files without diagnostics. Runtime and Madge cycle checks both passed with zero cycles, staged whitespace passed, and the serial proof pipeline completed successfully.

Exact-head PR CI is the broad proof; no local broad suite/build/E2E/whole-graph checker or operator-state access is claimed.

CI attribution

On exact head db822d2fa3eb82da3c467a7c0a4c93c75dc0fbcd, completed CI run 39211942571's control-ui-performance job 117927530723 fails the new-session boot budget: 1,050,273 B against 1,050,000 B. The job itself builds and compares base 0b702b5508545fb70fa5b3c4e72930c3004f26ab and candidate merge 5ad0899b917af86955e3f8c488ae092c5106ecd6: both produce exactly 1,050,273 B and 20 requests (+0 B, +0 requests). Chat boot and both route CSS totals are also unchanged. This is inherited by direct same-job base comparison, not inferred from the separately listed scheduled-main chat-budget signature. The performance checker, budgets, capture and UI sources are untouched. No rerun or budget/baseline change is requested. The last six completed scheduled-main runs and coordinator failure registry were checked before attribution. All 236 exact-head check runs were enumerated: no checks remain pending, and the only other failure is aggregate job 117929480460, whose log names only this performance leaf. All selected tests, types, lint, build and security checks passed. Earlier cancelled administrative jobs have successful same-head successors. The native inherited-failure exception will retain the failure table and tested merge; failed CI is not called green.

@clawsweeper

clawsweeper Bot commented Oct 19, 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 scripts Repository scripts agents Agent runtime and tooling size: XL labels Oct 19, 2026
@clawsweeper clawsweeper Bot added 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 Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR folds private runtime helpers into their production consumers and migrates their tests.

Example: A policy blocks run-1 with “Request blocked.”

  • Before: A separate helper prevents model submission and records one redacted blocked-turn message across retries.
  • After: Prompt preparation performs the same blocking and idempotent recording directly.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The source-equivalent folds and migrated contracts are coherent; confidence in execution rests on reported focused tests rather than supplied shipped-entry-point evidence.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored refactor is outside the ordinary contributor proof gate; supplied validation reports exercise production owners in process, and the inspected historical accounting screenshots do not prove this revision.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: No user-visible defect is claimed; redundant private surfaces increase runtime maintenance cost.
Reason: Maintainer authorship establishes direction, and inspection confirms a complete owner consolidation without new public contracts, configuration, or persistence formats.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this maintainer-directed refactor consolidates existing owners without an identified introduced correctness defect.

Priority: P3
Reviewed head: 62d8a2c250ee3fbd936b4d5aab5d9c8de99c57d2

Before merge

  • Complete next step - Resolve the reported merge conflict while preserving newer main behavior, mark this PR ready when intended, and obtain required CI on the resulting head.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped CLI or Gateway execution of this revision is supplied; the reported owner-level tests support the refactor but do not establish end-to-end execution.
Agent review details

How this fits together

Agent preparation consumes session, routing, tool-policy, and hook context; prompt execution submits admitted requests, finalization records completion evidence, and usage parsing reads transcript accounting.

flowchart TD
  A[Agent ingress] --> B[Session preparation]
  B --> C[Tool catalog]
  C --> D[Prompt preparation]
  D --> E[Model transport]
  E --> F[Attempt finalization]
  D --> G[Owned transcript]
  G --> H[Usage accounting]
Loading

Technical review

Best possible solution:

Land the owner folds after resolving the reported conflict while preserving newer main behavior and passing required checks.

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

This PR addresses redundant private implementation surfaces rather than a reported runtime failure; source inspection confirms the extracted paths and their consumers.

Is this the best way to solve the issue?

The defect is unnecessary private forwarding and projection surfaces. The invariant is unchanged routing, prompt content, authority checks, transcript writes, and completion accounting. Direct folds into the existing consumers provide the smallest complete cutover, with no replacement manager or parallel implementation.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Introduced change inspected: Reviewed the pinned merge-base-to-head hunks, removed implementations, receiving owners, callers, and migrated tests; the folds preserve the existing decision branches. (62d8a2c250ee)
  • Policy gate preserves its boundary: Prompt preparation retains the settled-finalization exclusion, shared fail-closed hook gate, redacted idempotency key, owned transcript admission, and skipped model submission. (src/agents/embedded-agent-runner/run/attempt-prompt-phase.ts:264, 62d8a2c250ee)
  • Accounting repair retained: The combined scanner preserves primary-alias precedence, first-mirror suppression, repeated calls, supported call spellings, and exact result/error rules established by fix(usage): preserve tool calls and count loaded interval messages #149547. (src/infra/session-cost-usage-pricing.ts:82, 62d8a2c250ee)
  • Historical media inspected: All four prepared screenshots show the earlier accounting PR's original/fixed loader comparison; they support its historical behavior contract, not execution of this revision.
  • Current main still has the extracted paths: Fetched main retains the seven production modules retired here, so this structural contribution is not already implemented there. (d51ef6ac2b72)
  • Reported conflict and draft state: GitHub confirms this reviewed head is a draft with mergeable=false and mergeable_state=dirty; newer main also changes session preparation near the folded return path. (src/agents/command/session-preparation.ts:393, 62d8a2c250ee)

PR surface

Source -247, Tests +64, Other -4. Total -187 across 29 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 15 376 623 -247
Tests 11 515 451 +64
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 3 0 4 -4
Total 29 891 1078 -187

Review metrics

Metric Value Why it matters
Production versus test delta Production +376/-623; tests/support +515/-451 Production shrinks by folding existing implementations; the test growth migrates distinct contracts to production-owner boundaries.

Labels

Label changes:

  • add P3: This is internal maintenance with no intended user-visible behavior change or demonstrated urgent regression.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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 maintenance with no intended user-visible behavior change or demonstrated urgent regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 October 19, 2026, 2:18 AM ET / 06:18 UTC.

@steipete
steipete force-pushed the deslop/z25-33-runtime-owners-20261015 branch from 62d8a2c to db822d2 Compare October 19, 2026 06:46
@steipete
steipete marked this pull request as ready for review October 19, 2026 06:47
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T06:51:50.051521Z db822d2 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete

steipete commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Exact-head inherited-failure attribution for db822d2fa3eb82da3c467a7c0a4c93c75dc0fbcd, CI 39211942571, attempt 1.

All 236 check runs were enumerated. No checks remain pending. All selected tests, types, lint, build and security checks passed, including security-fast job 117927530682. The only failures are:

Job Attribution and proof
control-ui-performance (117927530723) Inherited. The job builds actual base 0b702b5508545fb70fa5b3c4e72930c3004f26ab and tested merge 5ad0899b917af86955e3f8c488ae092c5106ecd6 using the same toolchain. Both produce exactly 1,050,273 B new-session boot JS and 20 requests, exceeding the unchanged 1,050,000 B budget by 273 B. The log explicitly reports +0 B and +0 requests. Chat and CSS totals are also identical. The complete UI tree and both performance-check scripts are byte-identical between those revisions.
openclaw/ci-gate (117929480460) Downstream aggregate only. Its log names control-ui-performance as its sole selected failing leaf.

Cancelled earlier dispatch/context jobs have successful same-head successors: dispatch117927070269/117929156712 and context117927072155/117929157242. They are superseded administrative runs, not missing product proof.

Before attribution, the coordinator registry and last six completed scheduled-main runs were checked: 39205204421,39200477526,39195750293,39191176869,39186683798,39183785855. Their older chat-budget signature is not claimed to match this new-session failure; the actual same-job base rebuild supplies the direct evidence.

The tested merge Git object is retained and verified with exactly the ordered parents above: base0b702b550854, head db822d2. The native inherited-only admin exception is authorized by the z25 campaign and retains the exact-head review, failed attempt, source objects and hashed job logs. No CI rerun, budget/baseline change, retries, skips, or security/review waiver is involved. This is not a green-CI claim.

Local conflict proof passed twelve native type roots,152 focused cases, normal type-aware lint and both zero-cycle checks. The earlier ACP fixture failure remains disclosed in the PR; its passing unchanged replay did not prove repair or inheritance. Independent whole-candidate review completed scoped-clean with final source verification.

Campaign rule 10 fallback: two native scripts/pr merge-run attempts passed merge verification but exhausted GitHub's 60-second mergeability-settle deadline. Both explicitly confirmed a pre-dispatch abort, no merge request, no outcome ref, and released operation locks. The second attempt's process group and notification holders have exited. The exact reviewed head remains unchanged and open, with no auto-merge request. A fresh complete check-run census retains only the two attributed failures above and superseded administrative cancellations. The pinned squash API fallback bypasses the stalled submission tool only; it does not claim green CI or waive security, review, or behavior gates.

@steipete
steipete merged commit 190b485 into main Oct 19, 2026
241 of 248 checks passed
@steipete
steipete deleted the deslop/z25-33-runtime-owners-20261015 branch October 19, 2026 07:33
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL 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.

1 participant