Repository navigation
refactor(agents): consolidate session and runtime operations - #166560
Conversation
|
🦞👀 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. |
|
|
Codex review: blocked before merge. Reviewed October 7, 2026, 8:25 AM ET / 12:25 UTC (Revision 4). ClawSweeper reviewWhat this changesThe PR shares repeated agent session, CLI recovery, sandbox, extension, and worktree operations and removes unused private authentication-lock implementations. Merge readiness⛔ Blocked before merge - 2 items remain Keep open: this remains a useful maintainer-authored consolidation that is absent from current main, and the inspected diff introduces no actionable correctness defect. Priority: P3 Review scores
Verification
How this fits togetherOpenClaw’s agent runtime turns admitted requests into model execution, session updates, tool operations, and reply delivery. These changes consolidate internal operations while retaining their existing runtime owners. flowchart TD
A[Admitted agent request] --> B[Session and model preparation]
B --> C[CLI or agent execution]
C --> D[Recovery and settlement]
C --> E[Sandbox file operations]
C --> F[Worktree lifecycle]
D --> G[Session updates and reply delivery]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -556. Total -556 across 44 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Retain one implementation for repeated operations while preserving existing admission, ordering, cancellation, and public-contract differences. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR consolidates existing behavior rather than reporting a failing user flow; no introduced failure was established by source inspection. Is this the best way to solve the issue? Yes: sharing existing internal owners is a maintainable approach, and the inspected hunks preserve the meaningful differences between callers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4ed39a25f674. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Exact-head validation update for CI run 37609156598, attempt 2, completed. Both test shards canceled by the first attempt's fail-fast monitor ( The census contains 220 latest check runs: 92 successful, 125 skipped by workflow/draft/scope selection, one neutral, and the following two failures. The ordinary ready-PR CI run completed its selected work; the original draft-skipped run is not counted as proof.
The separate Local continuation is complete: all nine remaining changed-check commands passed. The final focused tests passed 135 cases across seven files, and final production types and isolated P2 review passed. The earlier full subsystem test evidence and unchanged-baseline capacity failures remain described in the PR body. Merge remains blocked on separate full-tree export proof. The native scan timed out twice locally at its unchanged 600-second limit. A bounded diagnostic reached the existing 16 MiB debug-output cap during workspace discovery and produced no usable export result. The AWS transfer attempt produced no proof and its lease was released; subsequent allocations were refused at the coordinator's 21/20 fleet limit. No task-owned lease remains active. Ordinary PR CI explicitly omits this export scan, so its completed checks do not close this gap. No timeout, output limit, suppression, baseline, ignore, or scope was relaxed. |
f8f826c to
8a866c0
Compare
…w#166560) Consolidate agent session, CLI runner, command, sandbox, and worktree operations through their existing owners. Preserve feature behavior, user-visible text, configuration, protocol, and persisted-data contracts. Remove 556 net production lines across 44 files. Tests remain unchanged; the PR includes the complete deep-pass coverage log for the approved 500–999-line campaign exception. Validation includes the full subsystem test run (two capacity failures reproduced on main), 135 passing final focused cases, production and test types, zero runtime and Madge cycles, SDK checks, isolated review, and clean direct sequential Knip scans. Rebase the unchanged patch onto the terminal UI fixture fix and pass hosted CI on head 8a866c0.
What Problem This Solves
Agent session, CLI, sandbox, command, and worktree runtime paths repeat internal work that can share existing owners.
User Impact
No user-visible change. Features, messages, configuration keys, CLI flags, protocol shapes, and persisted data remain unchanged. No migrations or operator actions are required.
Why This Change Was Made
Share CLI recovery and output handling, sandbox pin preparation and option/list projections, session reload construction and file-stat projection, extension dispatch, catalog snapshots, keybinding definitions, and worktree restore/cleanup operations. Remove unused private asynchronous auth-lock implementations while retaining the public backend contract.
Candidate head:
8a866c08c2b70c2a0b7eb14592d7e72ffb50f6fb. The conflict-free rebase includes main’s terminal font fixture fix; the stable patch ID is unchanged.The final measured delta is 784 added / 1,340 removed: 556 net production lines removed across 44 files. Tests, fixtures, test-support, generated files, and declaration files are excluded; no tests were edited. This is 0.71% of 78,846 baseline production LOC, below the 3% campaign target and 1,000-line normal lane minimum. It uses the explicitly authorized 500–999-line exception with the complete file-by-file coverage log below. The deep pass and implementation exceeded two hours. Candidates with measured growth, changed ordering, expanded subclass APIs, or protected dependencies were removed.
Shared paths retain explicit differences: retry eligibility and budgets, sync/worker authority checks and settlement, authored catalog headers, sequential listing, exact optional fields, abort precedence, and cleanup ordering. No changes touch the protected PR-tooling import closure, state/config-session owners, audit, cron, dependencies, schemas, or changelog.
Evidence
66d898f6662ae0de956d664a141fad2789a3cc9a:service.capacity.test.ts:703:79, “waits beyond five minutes for allocation until release” and “… until abort.” The initial one-second poll expires before the simulated six-minute advance. Test/allocation/lease/backoff blobs match the candidate. The cause of the initial missed observation remains unresolved; no fix is claimed here. Local test phases took 4,182.45s and 2,831.21s; tests are unchanged, so no new test CI cost is introduced.pnpm deadcode:full, the full-tree unused-file scan, and the full-tree scan of all six export categories passed sequentially on a standard Hetzner runner, with no findings (7m14s including setup). The direct commands used the repository's Knip version/configuration without the stage wrapper's 600-second deadline. That lease is released.1b395594318bbd0db6f2467f35b10cc8ac1d30d0preserves the exact patch ID and 556-line reduction. Fresh production types, runtime cycles (0), Madge cycles (0), and all three lint-suppression tests passed. All 44 candidate files, the lock/package/workspace inputs, and Knip configurations are byte-identical across the rebase; the clean pre-rebase Knip proof is retained. Hosted CI on the final exact head passed, including the formerly failing type stripe.Deep-pass production coverage: every assigned file and final disposition
D13 production coverage
Largest-file-first inspection covered the five assigned directories and 370 production modules (78,846 baseline LOC). Tests, fixtures, test-support, generated files, and declaration files are excluded. Protected PR-tooling closure files remain unchanged. The table records final dispositions, including implemented candidates that were rejected. This is coverage evidence, not a claim that every retained line is irreducible.
D13 lead session-runtime coverage
agent-session-prompting.tsagent-session-base.tsagent-session-compaction.tssession-manager-entries.tssdk.tsagent-session-extensions.tsagent-session-models.tsagent-session-tree.tsexec.tscontext-token-pressure.tscompaction/request-budget.tsagent-session-inspection.tsagent-session-types.tsagent-session-execution.tsprovider-config.tsagent-session-utils.tssteering-message-identity.tssession-tool-result-redaction.tscompaction/compaction.tssource-info.tssession-file-parser.tsevent-bus.tsmanual-compaction-preflight.tsprovider-display-names.tsauth-guidance.tsagent-session-transcript.tssession-persistence-deprecation.tshttp-dispatcher.tsqueued-user-message-retirement.tsagent-session.tssession-model-usage.tstelemetry.tsdiagnostics.tsindex.tsfooter-data-provider.tssystem-prompt-metadata.tsmessages.tsbash-executor.tscompaction/runtime.tsslash-commands.tstranscript-turn-error.tscompaction/index.tsdefaults.tsd13 SessionManager persistence coverage
d13 session registry/settings deep pass
d13 session tools and extensions coverage
d13 worktrees deep-pass coverage
service.tsservice-preparation.tssnapshot-restore.tscheckout.tssnapshot-inventory.tssnapshot-exact-state.tsremoval-recovery.tssnapshot-host.tseviction.runtime.tsregistry-run-end.worker.tsremoval-git.tsgc-removal.tsregistry.tsremoval.tsrun-lease.tsbranches.runtime.tsgit.tssnapshot-restore-exact.tseviction.tscapacity.runtime.tsregistry-read.kernel.tscheckout-git-config.tstemplate-cache.tsallocation.tscapacity-owner.tspending-slots.worker.tstemplate-registry.worker.tscapacity.tscheckout-apfs.tsempty-source.tstypes.tscapacity.worker.tsgc-artifacts.tsremoval-recovery-inventory.tsowner-protection.tsfilesystem-refs.native.tstemplate-registry-async.tsgit-worktree-operations.runtime.tsprovisioned-snapshot.tsregistry-run-end.tsprovisioned-files.tsrun-lease-owner.tsrun-end-lifecycle.tsgc-limits.tsregistry-read.tsgit-worktree-operations.tsgit-lock.tsgit-path-inventory.tsfilesystem-native.tsfilesystem-backend.tssnapshot-index-objects.tsremoval-finalization.tsdispatch.worker.tsregistry-retirement.worker.tsprovisioned-file-inspection.tsgit-maintenance.tspreparation-timing.tsgc-progress.tscapacity-store.tscheckout-profiles.tsregistry-retirement.tsbase-ref.tsgc-protection.tspending-slots.tsrun-lease-store.tsprovisioned-snapshot-store.tsrun-lease-store.kernel.tsactivity.tsfilesystem-apfs.native.tsgc-dependencies.tscheckout-policy.tserrors.tscheckout-inspection.tsorphan-paths.tsrepository-paths.tsremoval-errors.tsgc-fingerprint.runtime.tsgc-result.tsname.tsprovisioned-snapshot.worker.tscapacity-contract.tsrun-lease-store.worker.tsservice-list.tssnapshot-exact-state-contract.tsfilesystem-backend.types.tstemplate-registry.tsowner.tsd13 sandbox coverage
D13 CLI runner deep-pass coverage
prepare.tsexecute.tsexecute-plugin.tsexecute-tool-tracking.tscli-run-settlement.tsexecute-process.tsbundle-mcp.tsmodel-call-diagnostics.tscli-run-transcript.tssession-history.tsexecute-events.tshelpers.tscli-live-session-registry.tscli-native-tool-approval.tsexecute-node-claude.tstypes.tsbundle-mcp-codex.tshistory-boundary.tsmcp-grant-context.tsrun-diagnostics.tscli-run-recovery.tsprepare-mcp.tsprompt-context.tsexecute-plugin-watchdog.tsexecute-logging.tsbundle-mcp-gemini.tsclaude-skills-plugin.tsbundle-mcp-claude.tslive-session-fingerprint.tsprepare-tool-policy.tsexecution-target.tstool-authority.tsskills-prompt.tsdelivery-evidence.tsreliability.tsexecute-messaging.tsbefore-agent-reply.tsexit-error.tsexecute-ask-user-deadline.tsno-output-timeout-policy.tsbundle-mcp-runtime.tsmodel-capabilities.tsoutput-error.tsprepare-claude.tsreseed-envelope.tsrun-admission.tsbootstrap-transport.tstoml-inline.tscli-backend-auth-policy.tstool-policy.tscleanup.tsauth-profile-preparation-error.tsexecute-deps.tslog.tsexecute-output-buffer.tssession-binding.types.tsexecute.runtime.tsprepare.runtime.tsd13 command coverage
attempt-execution.tsdelivery.tspost-run.tsrun-embedded-attempt.tssession.tsmodel-selection.tscli-compaction.tsattempt-execution.helpers.tsprepare.tsacp-lifecycle.tsacp-execution.tstranscript-persistence.tssession-store.tssession-preparation.tstypes.tsshared-types.tsmaintenance.tsdelivery-result.tslifecycle.tsassistant-transcript-repair.tscleanup.tsmodel-selection-catalog.tssession-helpers.tscompaction-accounting.tsattempt-auth-selection.tsattempt-execution.shared.tsmodel-ref.tsattempt-callbacks.tscli-compaction-context.tsruntime-loaders.tsingress-diagnostics.tsdelivery-authority.tsclaude-cli-project-dir.tsrun-context.tsmaintenance-budget.tsexplicit-session-key.tsrun-embedded-attempt.types.tsattempt-execution.runtime.tssession-store.runtime.tsdelivery.runtime.ts