Skip to content

refactor(acp): simplify pending operation accounting - #139189

Merged
steipete merged 1 commit into
mainfrom
codex/deslop-acp-queue
Sep 5, 2026
Merged

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

Conversation

@steipete

@steipete steipete commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor
Additional instructions

Keep Allow edits from maintainers enabled for this PR.

What Problem This Solves

Simplifies maintenance of ACP queue diagnostics by removing obsolete per-session bookkeeping whose only remaining consumer reads the total. This is a maintainer-requested internal cleanup.

Why This Change Was Made

Replace the count map with one counter updated by the existing enqueue and settle hooks, preserving the shared queue and async wrapper. Remove the redundant file-header narration and add four assertions to existing manager tests to verify the observable count.

Production: +4/-14, net -10 lines. Tests: +4 lines, with no new test cases or fixtures.

User Impact

No user-visible behavior change. /acp doctor continues to count all running and waiting actor operations. An aborted queued call remains counted until its internal callback settles, and shutdown handle cleanup uses the same counted queue.

Evidence

The same 53 focused tests passed on the original map implementation and the scalar implementation, with the four new assertions present in both runs. They cover manager behavior (27), runtime-handle lifecycle (20), and shared queue behavior (6):

node scripts/run-vitest.mjs src/acp/control-plane/manager.test.ts src/acp/control-plane/manager.runtime-handles.test.ts src/plugin-sdk/keyed-async-queue.test.ts

The added assertions observe a held running turn, a queued successor, complete drain, and a queued caller that has rejected on abort while its predecessor still owns the actor. Existing tests retain coverage for independent-session concurrency, timeout/rejection cleanup, and shutdown cancellation before handle close.

Full changed-file validation passed on the frozen candidate before commit, including core and test typechecks, lint, all unused-export scans, and structural guards:

node scripts/check-changed.mjs --staged

Targeted formatting and whitespace checks passed. Required Codex autoreview through P2, an independent peer review, and a fresh direct review of committed head f18d79a found no actionable issues. The source remained unchanged through verification.

CI 33975370642 passed on the exact head. Its actual tested merge has main 952105ddd981e3339775621a4e5c3dfedde5c9da and head f18d79a4884964b4539edb5a11f66b43e1c8db00 as parents. ClawSweeper found no before-merge items.

@clawsweeper

clawsweeper Bot commented Sep 5, 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 size: XS maintainer Maintainer-authored PR labels Sep 5, 2026
@steipete
steipete marked this pull request as ready for review September 5, 2026 15:37
@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 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 11:44 AM ET / 15:44 UTC.

ClawSweeper review

What this changes

The ACP session manager replaces per-session pending-operation counts with one total counter and adds assertions that preserve existing diagnostic behavior.

Merge readiness

✅ Ready for maintainer review

Keep open as a useful, distinct cleanup. No introduced correctness or security defects were found, and current main still contains the bookkeeping this PR simplifies.

Priority: P3
Reviewed head: f18d79a4884964b4539edb5a11f66b43e1c8db00

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused simplification with useful boundary assertions, reported validation, and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, behavior-neutral refactor is exempt from external-contributor proof requirements; the reported manager, lifecycle, and queue tests exercise the relevant accounting with mocked runtimes, not a live harness.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, behavior-neutral refactor is exempt from external-contributor proof requirements; the reported manager, lifecycle, and queue tests exercise the relevant accounting with mocked runtimes, not a live harness.
Evidence reviewed 11 items Introduced change and merge result: The pinned merge-base-to-head diff contains only the counter simplification and four assertions. The test merge has the pinned main and PR head as its raw parents; its complete file list contains the same two files.
Balanced accounting contract: The shared queue invokes onEnqueue synchronously and onSettle in Promise.finally. The ACP callbacks cannot reject and change the total once in each direction, preserving the previous map sum on success and failure.
Caller, cancellation, and diagnostic boundary: The manager exposes the total only through its observability snapshot. withSessionActor can reject an aborted waiting caller before its queued callback settles; accounting remains attached to that callback, preserving the intentional pending count.
Findings None None.
Security None None.

How this fits together

The ACP session manager coordinates operations for external coding agents, serializing work within each session while allowing different sessions to proceed independently. Its pending-operation total feeds /acp doctor diagnostics.

flowchart TD
  A[Session operations] --> C[Per-session queue]
  B[Shutdown cleanup] --> C
  C --> D[Running and waiting total]
  C --> E[Execute operation]
  E --> F[Success or rejection]
  F --> D
  D --> G[ACP doctor diagnostics]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -10, Tests +4. Total -6 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 14 -10
Tests 1 4 0 +4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 8 14 -6

Review metrics

Metric Value Why it matters
Production versus test footprint Production net -10 lines; tests +4 assertions in existing cases The cleanup removes redundant state without adding a helper, public API, fixture, or competing execution path.

Technical review

Best possible solution:

Keep aggregate accounting at the ACP queue owner while preserving the shared scheduler, cancellation timing, and diagnostic interface.

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

Not applicable: this PR claims a behavior-preserving refactor, not a broken existing workflow; source and assertions support that premise.

Is this the best way to solve the issue?

Yes. Only the aggregate count is consumed, so a scalar removes unnecessary state; adding accounting to the shared SDK queue would broaden the change without serving another caller.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 952105ddd981.

Labels

Label changes:

  • add P3: This is bounded internal cleanup that preserves existing behavior and adds no user-facing capability.
  • 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: This maintainer-authored, behavior-neutral refactor is exempt from external-contributor proof requirements; the reported manager, lifecycle, and queue tests exercise the relevant accounting with mocked runtimes, not a live harness.

Label justifications:

  • P3: This is bounded internal cleanup that preserves existing behavior and adds no user-facing capability.
  • 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: This maintainer-authored, behavior-neutral refactor is exempt from external-contributor proof requirements; the reported manager, lifecycle, and queue tests exercise the relevant accounting with mocked runtimes, not a live harness.

Evidence

What I checked:

  • Introduced change and merge result: The pinned merge-base-to-head diff contains only the counter simplification and four assertions. The test merge has the pinned main and PR head as its raw parents; its complete file list contains the same two files. (src/acp/control-plane/session-actor-queue.ts:6, a00ccc8da2e3)
  • Balanced accounting contract: The shared queue invokes onEnqueue synchronously and onSettle in Promise.finally. The ACP callbacks cannot reject and change the total once in each direction, preserving the previous map sum on success and failure. (src/plugin-sdk/keyed-async-queue.ts:15, f18d79a48849)
  • Caller, cancellation, and diagnostic boundary: The manager exposes the total only through its observability snapshot. withSessionActor can reject an aborted waiting caller before its queued callback settles; accounting remains attached to that callback, preserving the intentional pending count. (src/acp/control-plane/manager.core.ts:527, f18d79a48849)
  • Shutdown and output consumers: Runtime-handle shutdown enqueues closes through the same SessionActorQueue. The doctor handler prints the snapshot's queueDepth directly; neither path requires individual session counts. (src/acp/control-plane/manager.runtime-handle-cache.ts:83, f18d79a48849)
  • Behavioral assertions and existing coverage: The four assertions observe one running operation, a waiting successor, complete drain, and an aborted caller whose callback remains queued. Existing tests cover different-session parallelism and zero pending operations after timeout or rejection. The test helper runs the production manager and queue with mocked runtime and metadata boundaries. (src/acp/control-plane/manager.test.ts:391, f18d79a48849)
  • Current-main necessity: Fetched main still uses pendingBySession and sums its values. Its ACP control-plane and shared queue sources have no changes relative to the pinned merge base. (src/acp/control-plane/session-actor-queue.ts:7, 952105ddd981)

Likely related people:

  • Dallin Romney: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • 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 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Final verification of f18d79a4884964b4539edb5a11f66b43e1c8db00 is complete. CI 33975370642 passed; its actual tested merge has the reviewed head and main 952105ddd981e3339775621a4e5c3dfedde5c9da as parents. The affected queue and manager owners are unchanged across that integration.

All 53 existing manager/lifecycle/queue tests passed before and after, with four added assertions at the running, queued, aborted-caller and drained boundaries. Full changed checks, P2 review, independent peer and separate committed-head review are clean. The completed ClawSweeper review has no before-merge items or rank-up work. This keeps accounting at the existing enqueue/settlement owner and removes 10 production lines, without changing scheduler, cancellation, shutdown or diagnostic contracts. Native stamped review validation passed; proceeding through prepare/merge.

@steipete
steipete merged commit ad58679 into main Sep 5, 2026
252 checks passed
@steipete
steipete deleted the codex/deslop-acp-queue branch September 5, 2026 15:57
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to aniruddhaadak80/openclaw that referenced this pull request Sep 5, 2026
* origin/main: (46 commits)
  fix(gateway): keep chat metadata responsive across auth refresh (openclaw#139192)
  fix(doctor): keep Workshop relocation lint read-only (openclaw#139193)
  perf(ui): retain unchanged forwarded avatar publications (openclaw#139181)
  fix(config): guide exec policy migration repairs (openclaw#139143)
  test(i18n): refresh representative Watch key (openclaw#139197)
  fix(agents): preserve recovered scheduled-run outcomes (openclaw#139037)
  refactor(acp): simplify pending operation accounting (openclaw#139189)
  fix(plugin-sdk): harden account scope for pairing requests and challenges (openclaw#139142)
  perf(gateway): avoid redundant PR landing ancestry checks (openclaw#139186)
  perf(ui): release captured audio cache leases directly (openclaw#139174)
  fix(skills): validate names in library forms (openclaw#139184)
  fix(sessions): reduce cold catalog listing delays (openclaw#139146)
  perf(cron): scan preserved action output once (openclaw#139163)
  fix(agents): keep fresh tool results readable under context pressure (openclaw#139165)
  fix(compaction): heartbeat sessions ignore the active transcript byte cap (openclaw#136533)
  perf(agents): reuse snapshotted web search result rows (openclaw#139162)
  fix(onboarding): keep Tauri setup recoverable and verify model results (openclaw#139140)
  fix(memory): rank indexed sessions by source activity (openclaw#139112)
  perf(terminal): avoid rebuilding sanitized link fallbacks (openclaw#139159)
  perf(agents): bound retained tool result projection data (openclaw#139157)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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: XS 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