Repository navigation
refactor(codex): deslop Codex plugin sixth pass - #160912
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 September 29, 2026, 2:21 AM ET / 06:21 UTC (Revision 5). ClawSweeper reviewWhat this changesThe branch simplifies Codex plugin auth, tools, sessions, catalog, and native subagent code, and makes remote connection monitoring reconnect when a leased client has already closed. Merge readiness⛔ Blocked before merge - 1 item remains Keep open. Current main and the latest release still miss the close-before-subscription case, and the earlier merged cleanup passes do not contain this distinct repair. The introduced hunks are available for review; no definite patch defect emerged. Priority: P2 Review scores
Verification
How this fits togetherThe Codex plugin connects OpenClaw agent turns to a Codex app-server while OpenClaw retains session, tool, and transcript responsibilities. Plugin configuration and client events feed the connection monitor, which either continues using the client or reacquires it. flowchart LR
A[Plugin configuration] --> C[Codex connection monitor]
B[Codex app-server client] --> C
C --> D{Client closed?}
D -->|Yes| E[Release lease]
E --> F[Reconnect client]
F --> B
D -->|No| G[Continue agent work]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -589, Tests +28, Other -1. Total -562 across 64 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep the connection monitor’s recorded-close check in its existing owner and land the cleanup through normal exact-head review while preserving native protocol and session-authority contracts. Do we have a high-confidence way to reproduce the issue? Yes. Current main waits only for future close callbacks, and the focused test closes the client before subscription; this read-only review did not execute the test. Is this the best way to solve the issue? Yes. Checking recorded close state at the monitor’s subscription boundary is a narrow repair, and the inspected refactors retain their existing owners and guards. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2aed86671065. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
Consolidate shell projections, native binding and recovery plumbing, policy fingerprints, catalog adapters, and command/auth forwarding while preserving wire and transcript contracts. Recover remote connection monitoring when a leased client closes before the health observer subscribes. The regression fails on the original owner and passes with the repair.
Keep the original configuration readers and endpoint-copy loop, preserve JSON-object narrowing without casts, and collect app tool aliases directly into the existing deduplication set. Remove the obsolete assertion allowance after its cast was deleted.
bd73e14 to
84b1c0c
Compare
Move the unchanged email predicate and catalog request snapshot type into dependency leaves and migrate all callers. Fix the two Madge cycles found by CI without changing runtime logic or wire contracts.
* refactor(codex): deslop Codex plugin sixth pass Consolidate shell projections, native binding and recovery plumbing, policy fingerprints, catalog adapters, and command/auth forwarding while preserving wire and transcript contracts. Recover remote connection monitoring when a leased client closes before the health observer subscribes. The regression fails on the original owner and passes with the repair. * refactor(codex): retain typed loops and explicit config readers Keep the original configuration readers and endpoint-copy loop, preserve JSON-object narrowing without casts, and collect app tool aliases directly into the existing deduplication set. Remove the obsolete assertion allowance after its cast was deleted. * refactor(codex): keep shared command and catalog contracts acyclic Move the unchanged email predicate and catalog request snapshot type into dependency leaves and migrate all callers. Fix the two Madge cycles found by CI without changing runtime logic or wire contracts.
What Problem This Solves
Remove redundant Codex plugin coordination and projection code left after the earlier five cleanup passes, and fix a connection-health observer that can miss an already-closed client.
User Impact
Remote Codex connections resume reconnecting when the leased client closes before the health observer subscribes. The remaining changes are internal refactoring: app-server protocol usage,
openaiauth/runtime/catalog routes, native subagent lifecycle and authority, and transcript/tool bytes remain unchanged. No configuration, schema, retention, permission, dependency, or update behavior changes.Why This Change Was Made
Recent merged subtree history and name-only diffs were read first, including #156297, #157080, #158613, #159225, and #159726. The size-first sweep began with untouched production files over 150 lines, then covered the remaining production owners.
BELOW-THRESHOLD-PR-READY. 589 net production LOC removed (595 added, 1,184 deleted), plus 35 added/7 deleted test lines and one removed assertion allowance. The complete size-sorted coverage log includes every hand-authored production file over 200 lines: 196 TypeScript files and the runtime manifest. All smaller production modules, including the two new shared modules, were read.
Fixes Found Along the Way
The connection-health monitor previously waited only for future close notifications. A client could close after acquisition's last check but before the observer registered, leaving the monitor waiting indefinitely. The waiter now consumes the client's recorded close state before subscribing. A regression uses a real in-memory client and fake timers; it fails on the original owner with one acquisition instead of two and passes with the repair.
Validation caught and corrected an eager retry-helper import, an obsolete assertion allowance, a narrowing-losing array filter, and guard-incompatible reader/map rewrites. Original owner code was retained where the rewrite added no sound improvement. Hosted CI also found two new Madge cycles. Moving the unchanged email predicate and request snapshot type below their consumers removes both cycles; runtime and Madge checks now both report zero. No assertion, timeout, or retry policy was weakened.
Evidence
Current candidate
ca5e43df0e1d56e631f82997d67b97912eabe2a8, based on6d644f2780502b3e760e869f4cfa33407e9b7585. The conflict with #160879 was resolved by retaining main's replacement command tests; our displaced hunk only removed an unused argument expectation from a retired test. Production patches were preserved by the rebase (git range-diff), then the two CI cycle fixes were independently reviewed and verified.Current-head hosted CI is green, including
openclaw/ci-gateand the security-sensitive review. The previous head's architecture failure was caused by this PR and was fixed in source; its cancelled sibling jobs are not counted as passing evidence.All tests, checks, and builds ran through the repository wrapper on Blacksmith Testbox. Final proof used
tbx_01m3nptkxabrj21mjvbtha1d7k(lease run); verified source tree3187d129dd3fb27b243fe1ffe52fc2751bf6d119matches the candidate tree. Full runtime proof usedtbx_01m3njgemzdr0wmkkecx31qpmhon the same refreshed base before the unchanged predicate/type relocation. Both leases are stopped. The wrapper results, rather than the bootstrap Actions conclusion, are the execution evidence.pnpm test:extensions:batch codexpnpm check:architecturenode scripts/check-changed.mjs --base origin/main --head HEADnode scripts/run-vitest.mjs— final account/catalog/registration and import selections listed belowpnpm buildpnpm plugin-sdk:api:diff --base origin/main --head HEADFinal selected test paths:
extensions/codex/src/command-account.test.ts,extensions/codex/src/commands.test.ts,extensions/codex/src/session-catalog-native-authority.test.ts,extensions/codex/src/session-catalog-request-lifetime.test.ts,extensions/codex/registration-imports.test.ts,src/infra/fs-safe-import-boundary.test.ts,test/plugin-extension-import-boundary.test.ts,test/test-helper-extension-import-boundary.test.ts, andtest/scripts/extension-import-boundary-checker.test.ts.The full suite preceded only the final unchanged-body/type relocation. Final affected tests, architecture, changed-file checks, build and API comparison passed on the exact candidate tree. The new connection-health regression failed on the original owner with one acquisition instead of the expected reconnect, then passed with the fix. Changed-file measurements using
pnpm test <file> --maxWorkers=1: connection health 8 tests/38.27 s wall; plugin activation 19/27.83 s; conversation control 18/37.51 s. The new regression uses fake timers and an in-memory native client, with no process/Gateway boot or added real wait. On current-head CI, reported case durations sum to 2.467 s for the 8 connection-health cases, 0.127 s for 19 activation cases, and 2.590 s for 18 conversation-control cases; the new reconnect regression itself reports 0.017 s. The containing health, activation, and conversation jobs took 262, 201, and 193 seconds respectively, including setup and sibling files. Other test changes remove only retired input assertions and a test-only revision accessor.Independent review completed through P2; the final correction and cycle-fix reviews are scoped-clean. No accepted/actionable findings remain. The observed-turn fallback concern was rejected with current caller/history evidence: #159179 removed its sole supplying
readTaskcaller, and neither remaining history-recovery caller supplies the option. Pre-abort and stdio concerns were verified against retained caller/entry guards.The latest ClawSweeper source review found no actionable code or security findings and explicitly found no stored-data format or schema change. Its remaining compatibility checklist is a path-classification false positive:
migration/apply.ts:130only drops the unused transientauthSource.authPathfield;migration/auth.ts:162still reads credentials through the same SDK owner usingcodexHome, and model-cache reads are unchanged.computer-use-readiness.ts:101shares returned status-object construction; retry, repair, and storage operations are unchanged. No schema, stored bytes, transactions, durability, retention, permissions, or upgrade behavior changed. Existing migration/auth and Computer Use tests are included in the passing full Codex batch. The automated checklist still shows blocked; this source-backed assessment rejects that item rather than claiming the bot cleared it.Lease lifecycle
All leases used Blacksmith Testbox with one active command per lease.
tbx_01m3mzres9yzde9xac33z1t3mmexpired before proof; stop confirmed it was already stopped.tbx_01m3n44qem7dkfk49fkq5mfs07failed warmup and stopped automatically.tbx_01m3n4h7qdv3kj8s1p84djagkrsupplied the regression negative control and focused tests, then was explicitly stopped.tbx_01m3n8dxq539dfqm6dkzy9qj0vsupplied the first full proof and later expired; completed state and stop were reconciled.tbx_01m3nfbf4s5e51sq59ds98zbpssupplied the initial final-tree changed checks and was stopped. After conflict refresh,tbx_01m3njgemzdr0wmkkecx31qpmhsupplied fresh full proof and was stopped.tbx_01m3nptkxabrj21mjvbtha1d7ksupplied the final cycle repair proof and was stopped. No active lease remains.Expired leases, failed warmup and interrupted snapshot preparation are excluded from passing evidence. No release, live Gateway change, or flaky-test workaround.
Personally inspected sibling Codex Rust contracts
Inspected sibling revision
8f38d5a877da8c5c2c0b5158e72bb5f2290a3157before implementation:codex-rs/app-server-protocol/src/protocol/common.rs:507-620: request/method ownership and serialization.codex-rs/app-server-protocol/src/protocol/v2/thread.rs:62-180,354-480,1209-1254,1378-1458,1535-1547,1649-1735andthread_data.rs:204-293: start/resume configuration, native process identity, catalog fields, nullable metadata, and pagination.codex-rs/app-server-protocol/src/protocol/v2/turn.rs:167-334: literal input, turn overrides, steering preconditions, and interruption IDs.codex-rs/app-server-protocol/src/protocol/v2/item.rs:252-380,1432-1486,1544-1679,v2/mcp.rs:755-804,864-895, andcodex-rs/protocol/src/dynamic_tools.rs:11-78: native item and tool output shapes, approval and elicitation contracts.codex-rs/core/src/tools/handlers/multi_agents/send_input.rs:45-145,close_agent.rs:65-145,core/src/agent/control/legacy.rs:8-115,core/src/agent/control.rs:661-721, andcore/src/context/subagent_notification.rs:21-45: accepted submissions, previous-status close results, awaited shutdown, and classified child-result delivery.codex-rs/app-server-transport/src/transport/mod.rs:231-269,transport/websocket.rs:331-388, andapp-server/src/request_processors/environment_processor.rs:16-27: definite pre-enqueue overload rejection, socket lifetime, and environment registration.codex-rs/app-server-protocol/src/protocol/v2/account.rs:18-40,60-106,331-344,608-620,696-704,v2/plugin.rs:128-194,250-263,v2/apps.rs:31-64,175-185, andv2/config.rs:386-405: authentication, sparse usage facts, installed versus catalog metadata, and effective configuration.codex-rs/connectors/src/app_tool_policy.rs:166-230,hooks/src/engine/discovery.rs:775-808,app-server/src/request_processors/config_processor.rs:203-213, andapp-server-protocol/src/protocol/v2/model.rs:38-64,119-151,170-182: policy precedence, exact hook fingerprints, configured-provider capabilities, and model projections.codex-rs/protocol/src/protocol.rs:3115-3128,3220-3248,message-history/src/lib.rs:62-66,cli/src/login.rs:443-497, andapp-server-protocol/src/protocol/v2/feedback.rs:11-29: native metadata, history records, local login probing, and diagnostics identity.No new direct
@openclaw/*imports or Plugin SDK surface expansion.Complete size-sorted production coverage
Baseline:
5c30c9afcb5ec0d27085cbecce199ca986e532f5. Every hand-authored production TypeScript file and runtime manifest over 200 baseline lines, sorted by size. All smaller production modules were also read. Generated protocol schema artifacts were preserved unchanged and audited through their protocol/validator owners and sibling Rust definitions.extensions/codex/src/app-server/native-subagent-monitor.tsextensions/codex/src/app-server/shared-client.tsextensions/codex/src/app-server/auth-bridge.tsextensions/codex/src/app-server/approval-bridge.tsextensions/codex/src/app-server/side-question.tsextensions/codex/src/supervision-tools.tsextensions/codex/src/app-server/client.tsextensions/codex/src/app-server/computer-use.tsextensions/codex/src/app-server/dynamic-tools.tsextensions/codex/src/app-server/elicitation-bridge.tsextensions/codex/src/app-server/runtime-artifact.tsextensions/codex/src/app-server/dynamic-tool-build.tsextensions/codex/openclaw.plugin.jsonextensions/codex/src/app-server/session-binding.tsextensions/codex/src/migration/session-binding-sidecars.tsextensions/codex/src/app-server/client-runtime.tsextensions/codex/src/app-server/turn-router.tsextensions/codex/src/app-server/protocol.tsextensions/codex/src/app-server/event-projector-assistant.tsextensions/codex/src/session-catalog-index.tsextensions/codex/src/app-server/compact.tsextensions/codex/src/app-server/inference-proxy.tsextensions/codex/src/app-server/context-engine-projection.tsextensions/codex/src/app-server/session-binding-record.tsextensions/codex/src/app-server/attempt-startup.tsextensions/codex/src/app-server/thread-requests.tsextensions/codex/src/app-server/run-attempt-tool-setup.tsextensions/codex/src/app-server/dynamic-tool-execution.tsextensions/codex/src/app-server/thread-lifecycle-run.tsextensions/codex/src/app-server/run-attempt-active-turn.tsextensions/codex/src/app-server/plugin-thread-config.tsextensions/codex/src/app-server/event-projector-tool-transcript.tsextensions/codex/src/app-server/run-attempt-finalize.tsextensions/codex/src/app-server/plugin-inventory.tsextensions/codex/src/app-server/event-projector.tsextensions/codex/src/node-cli-sessions.tsextensions/codex/src/conversation-binding-preparation.tsextensions/codex/src/app-server/rate-limits.tsextensions/codex/src/app-server/native-hook-relay.tsextensions/codex/src/app-server/scheduled-app-authority.tsextensions/codex/src/app-server/thread-lifecycle-io.tsextensions/codex/src/session-catalog-list-operation.tsextensions/codex/src/app-server/native-subagent-submission-owner.tsextensions/codex/src/app-server/thread-supervision.tsextensions/codex/src/app-server/run-attempt-prompt.tsextensions/codex/src/app-server/run-attempt-resources.tsextensions/codex/src/app-server/native-subagent-model-source.tsextensions/codex/src/app-server/inference-routing.tsextensions/codex/src/app-server/run-attempt-connection.tsextensions/codex/src/migration/auth.tsextensions/codex/src/app-server/bounded-turn.tsextensions/codex/src/app-server/config-options.tsextensions/codex/src/command-plugins-management.tsextensions/codex/src/migration/plan.tsextensions/codex/src/app-server/event-projector-tool-progress.tsextensions/codex/src/app-server/event-projector-events.tsextensions/codex/src/migration/source.tsextensions/codex/src/app-server/sandbox-exec-server/http.tsextensions/codex/src/command-handler-actions.tsextensions/codex/src/command-handler-bindings.tsextensions/codex/src/session-catalog-control.tsextensions/codex/src/session-catalog-parsing.tsextensions/codex/src/app-server/app-inventory-cache.tsextensions/codex/src/native-thread-tool.tsextensions/codex/harness.tsextensions/codex/src/conversation-binding.tsextensions/codex/src/app-server/sandbox-exec-server/filesystem.tsextensions/codex/src/app-server/sandbox-exec-server.tsextensions/codex/src/session-catalog.tsextensions/codex/src/app-server/native-subagent-submission-call.tsextensions/codex/src/app-server/thread-lifecycle-warm.tsextensions/codex/src/app-server/native-subagent-model-input.tsextensions/codex/src/app-server/event-projector-native-tool-lifecycle.tsextensions/codex/src/app-server/sandbox-exec-server/processes.tsextensions/codex/src/app-server/computer-use-service.tsextensions/codex/src/app-server/sandbox-exec-server-node-relay.tsextensions/codex/src/app-server/request.tsextensions/codex/src/session-catalog-adoption.tsextensions/codex/src/app-server/attempt-context.tsextensions/codex/src/command-diagnostics.tsextensions/codex/src/migration/apply.tsextensions/codex/src/app-server/native-process-authority.tsextensions/codex/src/app-server/transport-process-snapshot.tsextensions/codex/src/app-server/thread-lifecycle-preflight.tsextensions/codex/src/app-server/settled-turn-projection.tsextensions/codex/src/command-plugins-readiness.tsextensions/codex/src/command-formatters.tsextensions/codex/src/command-diagnostics-support.tsextensions/codex/src/app-server/startup-binding.tsextensions/codex/src/app-server/run-attempt-turn-request.tsextensions/codex/src/session-catalog-rollouts.tsextensions/codex/index.tsextensions/codex/src/app-server/config-reviewer-policy.tsextensions/codex/src/app-server/remote-workspace-media.tsextensions/codex/src/command-rpc.tsextensions/codex/src/app-server/transport-process-containment.tsextensions/codex/src/app-server/event-projector-tool-items.tsextensions/codex/src/app-server/inference-dispatch.tsextensions/codex/src/app-server/native-subagent-history-recovery.tsextensions/codex/src/app-server/run-attempt-server-requests.tsextensions/codex/src/app-server/protocol-validators.tsextensions/codex/src/app-server/transcript-mirror.tsextensions/codex/src/session-catalog-node-continue.tsextensions/codex/src/command-handler-args.tsextensions/codex/src/app-server/attempt-steering.tsextensions/codex/src/conversation-control.tsextensions/codex/src/command-handlers.tsextensions/codex/src/command-account.tsextensions/codex/src/app-server/transcript-mirror-write.tsextensions/codex/src/app-server/run-attempt-runtime.tsextensions/codex/src/session-catalog-diagnostics.tsextensions/codex/src/app-server/computer-use-marketplace.tsextensions/codex/src/app-server/upstream-fork-boundary.tsextensions/codex/src/app-server/transcript-history-projection.tsextensions/codex/src/app-server/canonical-session-fork.tsextensions/codex/src/node-exec-server.runtime.tsextensions/codex/src/app-server/sandbox-exec-server/fs-policy.tsextensions/codex/src/app-server/event-projector-result.tsextensions/codex/src/migration/native-task-assignments.tsextensions/codex/src/app-server/native-subagent-parent-owner.tsextensions/codex/src/app-server/native-subagent-close-owner.tsextensions/codex/src/session-cli.tsextensions/codex/src/app-server/user-input-bridge.tsextensions/codex/src/app-server/native-subagent-completion-delivery.tsextensions/codex/src/session-catalog-node-adoption.tsextensions/codex/src/app-server/turn-params.tsextensions/codex/src/app-server/thread-lifecycle-adoption.tsextensions/codex/src/app-server/plugin-thread-app-admission.tsextensions/codex/src/app-server/attempt-workspace-context.tsextensions/codex/src/session-catalog-homes.tsextensions/codex/src/session-catalog-terminal.tsextensions/codex/src/app-server/native-skill-isolation.tsextensions/codex/src/app-server/transport-websocket.tsextensions/codex/src/app-server/config-parsing.tsextensions/codex/src/app-server/protocol-control-plane.tsextensions/codex/src/app-server/event-projector-media.tsextensions/codex/src/app-server/canonical-fork-preparation.tsextensions/codex/src/app-server/shared-client-lifecycle.tsextensions/codex/src/app-server/config-security.tsextensions/codex/src/session-catalog-index-state.tsextensions/codex/src/app-server/sandbox-exec-server/sandbox-child.tsextensions/codex/src/app-server/plugin-activation.tsextensions/codex/src/app-server/thread-ownership.tsextensions/codex/src/app-server/run-attempt-notification-controller.tsextensions/codex/src/app-server/computer-use-readiness.tsextensions/codex/src/app-server/usage-limit-error.tsextensions/codex/src/session-catalog-listing.tsextensions/codex/src/app-server/managed-binary.tsextensions/codex/src/app-server/upstream-session-fork.tsextensions/codex/src/app-server/session-permission-policy.tsextensions/codex/src/app-server/attempt-client-cleanup.tsextensions/codex/src/app-server/launch-args.tsextensions/codex/src/app-server/plugin-thread-config-deadline.tsextensions/codex/src/app-server/native-subagent-monitor-types.tsextensions/codex/src/app-server/compact-lifecycle.tsextensions/codex/src/app-server/computer-use-unified.tsextensions/codex/src/app-server/desktop-generation.tsextensions/codex/src/doctor.tsextensions/codex/src/app-server/run-attempt-turn-start.tsextensions/codex/src/app-server/request-attempt.tsextensions/codex/src/migration/cli-credentials.tsextensions/codex/src/app-server/run-attempt-start.tsextensions/codex/src/app-server/run-attempt-cleanup.tsextensions/codex/src/app-server/native-subagent-turn-observation.tsextensions/codex/src/app-server/run-attempt-context.tsextensions/codex/src/app-server/run-attempt-turn-state.tsextensions/codex/src/session-upstream-activity.tsextensions/codex/src/session-catalog-projection.tsextensions/codex/doctor-contract-api.tsextensions/codex/src/plugin-marketplace-discovery.tsextensions/codex/src/app-server/native-subagent-admission-custody.tsextensions/codex/src/app-server/config-requirements.tsextensions/codex/src/app-server/plugin-approval-roundtrip.tsextensions/codex/src/app-server/transport.tsextensions/codex/src/app-server/dynamic-tool-catalog.tsextensions/codex/src/session-catalog-index-events.tsextensions/codex/src/app-server/cyber-failover.tsextensions/codex/src/app-server/native-mcp-app.tsextensions/codex/src/app-server/transport-process-registration.tsextensions/codex/src/app-server/native-subagent-recovery-coordinator.tsextensions/codex/src/app-server/native-subagent-model-lookup.tsextensions/codex/src/conversation-binding-hooks.tsextensions/codex/src/app-server/session-retirement.tsextensions/codex/src/app-server/server-requests.tsextensions/codex/src/app-server/native-subagent-delivery-receipts.tsextensions/codex/src/session-catalog-events.tsextensions/codex/src/app-server/run-attempt-lifecycle-controller.tsextensions/codex/src/app-server/native-subagent-notification-routing.tsextensions/codex/src/app-server/plugin-metadata-cache.tsextensions/codex/src/command-handler-scope.tsextensions/codex/src/app-server/native-subagent-assignment-inventory.tsextensions/codex/src/session-catalog-native-page.tsextensions/codex/src/command-plugin-config.tsextensions/codex/src/app-server/native-subagent-notification.tsextensions/codex/src/app-server/desktop-generation-fingerprint.tsextensions/codex/src/app-server/event-projector-reasoning.tsextensions/codex/src/command-plugins-runtime.tsAdditional small shared modules introduced after the CI cycle check:
command-account-email.ts(3 lines) andsession-catalog-request-types.ts(27 lines), both READ. They own the unchanged shared predicate and request type without a reverse dependency on their consumers. All consumers were migrated; no forwarding re-export remains.