Skip to content

refactor(acp): remove duplicate runtime lifecycle plumbing - #140163

Merged
steipete merged 1 commit into
mainfrom
codex/acp-deslop-20260906
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/acp-deslop-20260906

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Related: #139685, #139776

What Problem This Solves

ACP/acpx retained duplicate serialization, validation, wrapper-writing, and error-normalization paths after the recent output and cancellation repairs. This maintainer-requested follow-up reduces the code that must stay consistent when maintaining session lifecycle behavior.

Why This Change Was Made

Reuse the existing SDK keyed queue for session initialization and process lease transitions, keeping their lock domains separate. Let the config schema own parsing/defaults, share identical wrapper/root resolution logic, and call the existing capability and error owners directly. Remove the unused raw-config type, redundant casts, one-use forwarding helpers, and duplicate error boundaries.

Production TypeScript: +105 / -337, net −232 lines. Tests: +44 lines covering idle cancellation error causes/identity and persisted error state. The assertion baseline only shrinks. No configuration, protocol, dependency, storage, or public API changes.

User Impact

No intentional behavior change. Existing ACP output delivery, cancellation, session reuse, model selection, wrapper launch, and process cleanup behavior is preserved with fewer duplicate paths.

Evidence

  • Focused ACP control-plane, acpx plugin, and SDK queue suite: 505 tests across 45 files passed.
  • New idle cancellation compatibility cases also pass against the original implementation.
  • Live Codex through the real acpx 0.13.2 runtime and generated wrapper, using isolated temporary state: slow output delivery retained the final response; status/text delivery failures cancelled; subsequent turns reused the same session successfully; abandoning the legacy stream cancelled and allowed reuse.
  • Dependency source checked directly: ACPX handle decoder and fallback, SDK queue ordering/failure cleanup, canonical ACP error normalization; Codex app-server turn interruption, completion notification, and persisted resume metadata.
  • Full pnpm build passed, including generated plugin/SDK declarations and plugin load checks.
  • Fresh independent autoreview through P2: no actionable findings.
  • node scripts/check-changed.mjs passed all selected formatting, core/plugin typechecks, lint, dead-export and repository guards.
  • Exact-head CI run 34038807845 passed.

ClawSweeper follow-up: both pre-merge proof requests are addressed without code changes.

  • Published decoder contract: directly inspected acpx 0.13.2 dist/runtime.js:1799-1821 and the matching tagged decoder source. It returns either null or a record whose agent/name/cwd are nonempty strings and mode is persistent/oneshot. A direct probe of the installed published runtime passed two valid and seven invalid handle cases. The removed cast and checks duplicated this decoder contract.
  • Data-model compatibility: this PR does not change a stored format, schema, migration algorithm, or persisted field. persistMigratedCodexMcpConfig, TOML serialization, isolated-home preparation, generated wrapper contents/filenames, and lease/session record shapes remain intact. The shared writer retains the same mkdir/write/chmod sequence; launch construction reuses the already parsed command. All 27 existing wrapper/auth/migration tests pass on both original and candidate implementations, including legacy Codex command/MCP migration, maintained argv forwarding, isolated-home/rebuild isolation, existing auth preservation, and rejected chmod. Candidate coverage is included in the 505-test run; original-source compatibility runs passed separately. The data-model classification is a false positive for this refactor, so no new migration is needed.

@clawsweeper

clawsweeper Bot commented Sep 6, 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.

@steipete
steipete marked this pull request as ready for review September 6, 2026 14:19
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 6, 2026, 10:34 AM ET / 14:34 UTC.

ClawSweeper review

What this changes

Consolidates ACP session queues, configuration parsing, wrapper creation, and error handling while adding cancellation compatibility tests.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains useful maintainer-requested cleanup beyond the two merged lifecycle repairs. No actionable introduced defect was found in the inspected diff; the protected maintainer PR should remain open.

Priority: P3
Reviewed head: 14567f3ff2237866a36c52c1ed1427a1183aec44

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused consolidation with useful compatibility coverage and no supported blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate, and no material authority change triggers additional proof; its body reports real acpx/Codex delivery, cancellation, and reuse observations relevant to the refactored runtime.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate, and no material authority change triggers additional proof; its body reports real acpx/Codex delivery, cancellation, and reuse observations relevant to the refactored runtime.
Evidence reviewed 9 items Verified introduced scope: The original head has recorded parent d4f67f2. The verified test merge has the pinned base followed by the exact PR head as parents; its resulting changes match the introduced scope. Unrelated endpoint drift was excluded.
Queue semantics preserved: The existing SDK queue serializes each key, preserves task results, continues after rejection, and removes settled tails. The plugin retains distinct queue instances and the original session-key normalization; lease retirement remains inside the lease-local transition.
Configuration and error compatibility: The unchanged schema supplies the same 120-second default, and existing configuration tests cover undefined configuration and an explicit timeout. Canonical error conversion preserves local ACP error identity and wraps generic errors with their original cause; the added idle-cancellation cases check both forms and recorded error state.
Findings None None.
Security None None.

How this fits together

OpenClaw’s ACP control plane routes session commands to the acpx plugin, which launches external coding harnesses. This layer manages session reuse, output, cancellation, and cleanup of owned processes.

flowchart TD
  A[Session commands] --> B[ACP control plane]
  B --> C[acpx plugin]
  D[Validated configuration] --> C
  C --> E[Separate session and lease queues]
  E --> F[External coding harness]
  F --> G[Output and terminal results]
  G --> B
  C --> H[Owned process cleanup]
Loading

Before merge

  • Resolve merge risk (P1) - Reviewer limitation: the published acpx 0.13.2 decoder source was unavailable, leaving its return-shape guarantee independently unchecked.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -232, Tests +44, Other -1. Total -189 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 11 105 337 -232
Tests 1 44 0 +44
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 2 -1
Total 13 150 339 -189

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: extensions/acpx/src/codex-auth-bridge.ts, unknown-data-model-change: extensions/acpx/src/codex-auth-bridge.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep lifecycle serialization and error normalization with their existing shared owners while preserving session identity, configuration defaults, and cleanup predicates.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep lifecycle serialization and error normalization with their existing shared owners while preserving session identity, configuration defaults, and cleanup predicates.

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

Not applicable: this PR proposes behavior-preserving cleanup, and source review identified no concrete introduced failure to reproduce.

Is this the best way to solve the issue?

Yes, the inspected changes reuse existing owners and remove redundant boundaries without changing defaults or storage formats; independent ACPX decoder inspection remains limited.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is maintenance cleanup preserving existing behavior, with no new urgent user-facing defect reported.
  • 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: The supplied MEMBER association exempts this PR from the external-contributor proof gate, and no material authority change triggers additional proof; its body reports real acpx/Codex delivery, cancellation, and reuse observations relevant to the refactored runtime.

Label justifications:

  • P3: This is maintenance cleanup preserving existing behavior, with no new urgent user-facing defect reported.
  • 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: The supplied MEMBER association exempts this PR from the external-contributor proof gate, and no material authority change triggers additional proof; its body reports real acpx/Codex delivery, cancellation, and reuse observations relevant to the refactored runtime.

Evidence

What I checked:

  • Verified introduced scope: The original head has recorded parent d4f67f2. The verified test merge has the pinned base followed by the exact PR head as parents; its resulting changes match the introduced scope. Unrelated endpoint drift was excluded. (b94306a73149)
  • Queue semantics preserved: The existing SDK queue serializes each key, preserves task results, continues after rejection, and removes settled tails. The plugin retains distinct queue instances and the original session-key normalization; lease retirement remains inside the lease-local transition. (src/plugin-sdk/keyed-async-queue.ts:9, 14567f3ff223)
  • Configuration and error compatibility: The unchanged schema supplies the same 120-second default, and existing configuration tests cover undefined configuration and an explicit timeout. Canonical error conversion preserves local ACP error identity and wraps generic errors with their original cause; the added idle-cancellation cases check both forms and recorded error state. (src/acp/control-plane/manager.cancel-session.test.ts:26, 14567f3ff223)
  • Security-sensitive refactoring preserves predicates: Process cleanup combines existing rejection branches without changing their short-circuit order or lease/gateway identity checks. Wrapper writing retains filenames, content generation, permissions handling, and structured launch arguments. No dependency, permission, schema, or public SDK contract change was introduced. (extensions/acpx/src/process-reaper.ts:354, 14567f3ff223)
  • Dependency inspection signal and supplied validation: The captured PR body explicitly claims live Codex execution through acpx 0.13.2 and generated wrappers, plus direct inspection of Codex interruption/completion contracts. It reports preserved slow delivery, cancellation after delivery failures, legacy-stream abandonment, and subsequent session reuse, alongside 505 tests and build/check results. These are contributor-reported observations; this review executed no target code. (extensions/acpx/src/runtime.ts:1529, 14567f3ff223)
  • Direct Codex contract inspection: The sibling checkout’s backing cache remote identifies openai/codex. Personally inspected turn_interrupt_inner: it checks the requested active turn and submits interruption, with non-startup acknowledgement deferred to the abort event. Also inspected interrupted-turn completion notification emission in bespoke_event_handling.rs. (codex-rs/app-server/src/request_processors/turn_processor.rs:1560, 3d2ee51ca2d5)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

@steipete
steipete merged commit 9f87aee into main Sep 6, 2026
267 of 268 checks passed
@steipete
steipete deleted the codex/acp-deslop-20260906 branch September 6, 2026 14:39
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: acpx maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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