Repository navigation
refactor(reply): consolidate reply setup and lifecycle handling - #167236
Conversation
Consolidate command projections, runtime presentation, queue settlement, session publication, and delivery accounting while retaining caller-specific authority, recovery, and replay boundaries. Revisit the previous pass with measured shared-core trials and preserve public contracts and output text. Remove 845 net production lines. Migrate only tests bound to retired private presentation/count seams; retain their observable assertions.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Coverage 1 of 3 — rows 1–110 of 407Final head: Paths are relative to
|
Coverage 2 of 3 — rows 111–242 of 407Final head: Paths are relative to
|
Coverage 3 of 3 — rows 243–407 of 407Final head: Paths are relative to
|
|
Codex review: blocked before merge. Reviewed October 8, 2026, 9:16 AM ET / 13:16 UTC. ClawSweeper reviewWhat this changesThis PR consolidates reply preparation, command setup, delivery accounting, and lifecycle cleanup while preserving existing contracts. Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness⛔ Blocked before merge - 2 items remain Keep open: this PR provides useful consolidation of existing reply owners, and no concrete blocking regression was found. Validation is extensive but primarily harness-based and explicitly qualified by revision. Priority: P3 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherOpenClaw’s reply subsystem turns incoming messages and commands into agent runs and outgoing replies. It coordinates session state, authorization, streaming, queued follow-ups, and delivery completion. flowchart TD
A[Incoming message or command] --> B[Reply preparation]
B --> C[Session and authorization checks]
C --> D[Agent execution or command handler]
D --> E[Reply presentation and delivery]
E --> F[Lifecycle settlement]
F --> G[Queued follow-ups]
Technical reviewBest possible solution: Retain the consolidated existing owners and their explicit authorization, delivery, and recovery boundaries. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes behavior-preserving consolidation rather than a reported product bug; validation was assessed from source and recorded evidence. Is this the best way to solve the issue? Yes: the inspected changes reuse existing owners, remove redundant projections, and preserve caller-specific timing and authority checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 47cbd73e6f0e. TestingProof path: in-process harness. Added test files: 11. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfacePR surface statistics unavailable: the file list is incomplete. Stored data modelPersistent data-model change detected: LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment |
|
Compatibility and final CI disposition for The two compatibility checklist items in the completed ClawSweeper review are addressed. A paginated GitHub file inventory contains all 163 changed paths, exactly matching the local merge-base diff. Runtime config and state/schema directories have no changed paths. The two files under
ClawSweeper reported no actionable findings and explicitly found no stored schema, serialized-field contract, default or migration changes. Its automatic compatibility checklist included Main CI run succeeded on this exact head: 64 successful jobs / 24 planned skips, including All three earlier failures on this head were owned PR-body metadata failures, individually attributed below. They were corrected by restoring the required authored template sections; the subsequent context check passed. No source push, main-red attribution or admin exception was used.
The complete check-run census contains no cancellations or failed zero-step jobs. Historical draft/unselected jobs are explicitly skipped; current selected CI finished successfully. The source tree remains |
…claw#167236) * refactor(auto-reply): share reply state and handler cores Consolidate command projections, runtime presentation, queue settlement, session publication, and delivery accounting while retaining caller-specific authority, recovery, and replay boundaries. Revisit the previous pass with measured shared-core trials and preserve public contracts and output text. Remove 845 net production lines. Migrate only tests bound to retired private presentation/count seams; retain their observable assertions. * fix(auto-reply): complete shared helper validation * test: align reply registry and session fixture cleanup * refactor(reply): finish approval route consolidation * test(reply): isolate model auth and complete logger fixtures * refactor(reply): clarify callback bindings
Brings the branch onto current main; GitHub reported it CONFLICTING. inbound-meta.ts conflicted because main rewrote the helpers this branch had moved out of it: openclaw#157000, openclaw#161129, openclaw#164547 and openclaw#166085 trimmed the file, openclaw#158028 dropped its max-lines suppression, and openclaw#167236 merged the transcript sanitizers into sanitizeTranscriptText. The split is re-applied on main's code rather than on the branch's older copies: - inbound-meta.text.ts holds main's normalizePromptMetadataString, normalizePromptMetadataStringArray, sanitizePromptBody, truncateBodyHeadTail and sanitizeTranscriptText, moved verbatim. - inbound-meta.current-message.ts builds both projections with sanitizeTranscriptText(..., "body") in place of the branch's sanitizeTranscriptBody; the inline projection keeps main's bare header. - inbound-meta.ts is main's file minus the moved helpers. - config/max-lines-baseline.txt takes main's side, which already dropped the inbound-meta.ts entry. The carrier projection stays in its own module: get-reply-run.media-only.test.ts and followup-turn-admission.test.ts mock ./inbound-meta.js with closed factories, and prompt-prelude.ts must not import the projection through them.
…167236) openclaw#167236 consolidated reply setup and lifecycle. Kept ours on its shapes: - FollowupRun.run is now Pick<RunEmbeddedAgentParams> & {...}: our drainsContinuationDelegateQueue and traceparent ride the extension block. - AgentTurnParams: sessionKey/runtimePolicySessionKey moved into the shared context upstream; our hookTrigger stays. - get-reply-run-admission: upstream's traced rebuildPromptBodies with our block-text mapping; our refreshSystemEventPromptBodies no longer double-traces. - agent-runner-core cleanup keeps the preserved post-compaction delegate re-stage; RunReplyAgentParams keeps isContinuationWake (replyOperation moved upstream). - agent-runner-execution uses upstream's buildReplyMediaContextParams; our line-cap extraction agent-runner-execution-reply-media.ts is deleted. - continuation fallback-candidate fixture: presentation now takes presentPartialReply (classify/sanitize folded upstream). Field-use counts for hookTrigger, drainsContinuationDelegateQueue, traceparent, isContinuationWake, sessionContinuationTraceparent unchanged across the merge. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
…atile-map guard Upstream openclaw#167236 (absorbed at step 7, 3239e30) moved four reply-run registry fields out of the resolveGlobalSingleton initializer into module-level `replyRunState.field ??= new ...()` assignments, and removed activeSessionIdsByKey. The guard only recognized initializer properties, so those maps became invisible and their allowlist entries reported "missing" (red since step 7, carried by checkpoint 23e9574). - Recognize module-level `??=` property assignments whose right side constructs a Map/Set/WeakMap; report a field declared both ways once. - Drop the allowlist entry for the removed activeSessionIdsByKey. - Review clearOperationByOperation, previously invisible in the same form. Control: with the `??=` branch disabled the guard reports the four lazy fields missing again. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
Head:
0cbd6f542c1a80a7d9e5ebd0121bb6335e07041c. Local gates passed on staged tree6fc7e092b47e026314b037d6b6577a2a1194c7ac, now committed unchanged at this head. Hosted CI remains the merge gate.What Problem This Solves
Reply handling repeats command setup, state projections, delivery decisions and queue lifecycle bookkeeping across related paths.
User Impact
No user-visible change. Features, configuration, command flags, reply text, protocol fields, persisted data and public APIs retain their contracts.
Why This Change Was Made
This pass shares common work with the existing owners, removes redundant registry mirrors and parameter threading, and narrows internal APIs while preserving distinct authorization, delivery and recovery contracts.
Against
35e5f4ab9818deb9347e2ec87c38aee8c05b3e05, the candidate removes 853 net production lines (+1,851/−2,704 across 149 production files; 163 total changed paths), excluding tests, fixtures, support, generated files and declarations. The pass uses the campaign's 500–999-line coverage exception after more than two hours of implementation and measured trials. The complete, untruncated 407-file record covers retained changes, rejected trials and unchanged files: coverage 1 of 3, coverage 2 of 3, coverage 3 of 3.Evidence
Differential checks passed for 635,760 media layouts, 18,144 coalescer cases including synchronous reentry, 9,475 delivery routes, 56 exact timestamp comparisons, 382 RGBA/PNG byte comparisons and 130 audit-terminal output/error comparisons. Complete
FollowupRunstructural equality passed native TypeScript in 16.968s against the rebased base, with 45 input hashes and 43 Git bindings. Final body-only corrections preserve the relevant declarations; this equality receipt predates those corrections.69b79a01; no final-head full-build claim69b79a01; predates the four lint corrections69b79a01; private-route source/tests are unchanged in the final head69b79a01; runner/waiter inputs unchanged by final correctionsbb6520a7; predates the four compiler-guided body corrections0cbd6f54The build returned success but reported startup JavaScript gzip 364.9 KiB / 373,654 B against 364.7 KiB / 373,454 B. That warning/violation remains recorded without attribution or waiver. The final full changed-check passed production/core/root type graphs, all three Knip scans with 0 entries, core/script/root-test lint and every later guard. Earlier attempts exposed the now-removed production route export and four corrected lint findings; an earlier full-tree scan timed out at 600s (605s reported). Those earlier attempts are retained as failure history, not passing proof. Earlier Linux consumer evidence was 160/160 across 9 files and remains qualified as prior-revision evidence.
Fixture repairs and regression evidence
Ambient provider authentication contaminated three model-menu fixture expectations. With synthetic child-only OpenAI aliases, the original whole file reproduced 3 failures / 42 passes in 155.329s; clearing both aliases in the fixture produced 45/45 under the same environment in 172.688s. All 65 assertions remain unchanged, and existing Vitest/runner cleanup restores the environment. Production authentication policy is unchanged.
An incomplete logger mock exposed only
warn; the real scheduler requiresdebugandtrace, producing 586 unhandled exceptions while the fixture's own cases passed. The replacement implements the complete typed logger, including recursivechild, retains all 48 assertions, and uses typedimportOriginalto preserve real module exports. The final export-preserving form received a fresh review with no P0–P2 findings and completed the shared-project run with 3,946 passes / 1 existing skip, zero unhandled errors, 614.211s. That result precedes the final four body-only lint corrections and is reused with their separate 416-test boundary proof. Native mock-baseline pruning removes exactly the obsolete row (10,377 → 10,376) without adding an allowance.The CLI delegation fixture also invoked real cold WhatsApp threading lookup (91.713s primary versus 1ms fallback; authentication 113ms). A file-owned fake registry passed both cases in 5.583s / 5.622s (wrapper 345.61s) with all four assertions and the existing 120s test / 180s hook budgets intact. Registry cleanup has a failing-before/passing-after control: the existing producer/observer pair received
[]instead of[false]under old cleanup (1 pass / 1 fail, 114.30s), then passed 2/2, 109.76s with three added assertions and no new child run, timer, timeout, retry or skip.SDK and failure qualification
The refreshed formal SDK comparison 35e5f4a → 69b79a0 is non-empty: 131 reachable-declaration hash changes, with 0 entrypoint additions/removals and 0 exported declaration/kind changes. Exactly two blocks changed: the independently proved
FollowupRuntype composition and internal registry waiter/mirror-map representation. Conservative whole-module declaration hashing names the registry block*; neitherReplyRunWaiternorreplyRunStateis an SDK/package export or public parameter/return shape. The public chain ends in unchangedReplyOperation; public barrels/contracts are unchanged. Details are attached to the report's first canonical export, not evidence that onlyAgentHarnessis affected. No acknowledgement override was used. The final four corrections rename three private callback parameters and consume an already-normalized boolean directly; they change production bodies but preserve exported declarations, API signatures and import edges. The earlier SDK result is reused on that qualified basis; no formal final-head rerender is claimed.The original memory timeout/ownership mismatch, queue-removal failure and first-parent module-identity timeout remain recorded despite unchanged replays passing; no production repair or inherited-main failure is inferred from those replays. Earlier compaction delays likewise remain unexplained despite 82/82 passing on Testbox. A separate earlier native-slash failure was the SQLite WAL integrity guard killing a worker after unsafe fixture directory deletion, not an OOM; upstream fix
3deadc13f06is retained unchanged. Required explicit returns, shared-helper mock exports and exact shrink-only baselines were repaired without weakening assertions; the corrected followup fixture passed 36/36, with a normal single-worker command measured at 28.15s on Linux.Integrated review left no accepted findings; a command-alias finding was rejected with source evidence. The route/CLI, fixture and final four-file lint corrections received fresh independent reviews with no P0–P2 findings. Required formatting expands the session persistence object by six lines, reflected in the final 853-line reduction. The protected-path inventory union covers 1,866 paths, with 0 intersections and 0 new suppressions. Final local changed-check, suppression and cycle gates passed. Earlier full-project/build/API results retain the source qualifications above. Exact-head hosted CI and its job-level attribution remain the landing gate; hosted CI timing will be recorded when available.