Skip to content

refactor(queue): remove single-use helper indirection - #129108

Merged
steipete merged 1 commit into
mainfrom
codex/refactor-infra-utils-b6df91fd
Aug 25, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/refactor-infra-utils-b6df91fd

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Maintainer-requested simplification of the internal queue owner: overflow summaries, UTF-16-safe previews, and collect-mode draining each passed through a private helper used by only one caller, duplicating argument shapes and obscuring where queue behavior actually lives.

Why This Change Was Made

Keep the existing exported queue-helper boundaries and move their implementations directly into the functions that own summary rendering and cross-channel collect decisions. Fold single-use text elision into the existing summary-line owner. This removes three private indirections and 41 production lines without changing signatures, output, ordering, reservation behavior, or error propagation.

User Impact

No user-visible behavior change. Queue overflow summaries, safe Unicode truncation, individual cross-channel delivery, protected in-flight work, and TUI queued prompts keep the same behavior with less internal code.

Evidence

  • node scripts/run-vitest.mjs src/utils/queue-helpers.test.ts src/auto-reply/reply/queue.collect.test.ts src/auto-reply/reply/queue.in-flight.test.ts src/tui/embedded-backend.test.ts — 224 tests passed across four owner, auto-reply, and TUI caller suites.
  • OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1 node scripts/check-changed.mjs -- src/utils/queue-helpers.ts — passed all changed-file guards, production and test typechecks, lint, and owner-boundary checks. The unchanged production/full-tree/script dead-export scans separately passed on the initial run; the retry skipped only their already-green duplicate after correcting isolated UI dependency resolution.
  • git diff --check
  • Fresh structured Codex autoreview: no accepted/actionable findings.
  • Independent source review: no findings; all exported contracts and caller-visible behavior preserved.
  • Production: +22/-63 (net -41); tests unchanged.

AI-assisted, maintainer-requested refactor.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 25, 2026
@steipete
steipete marked this pull request as ready for review August 25, 2026 07:29
@steipete steipete closed this Aug 25, 2026
@steipete steipete reopened this Aug 25, 2026
@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 Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 4:20 AM ET / 08:20 UTC.

ClawSweeper review

What this changes

The PR inlines private queue-summary, Unicode-preview, and collect-drain helpers into their exported queue owners without changing the public helper API.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No actionable defect found in this focused refactor; current main still retains the three private indirections. This maintainer-authored, maintainer-labeled PR needs explicit maintainer handling and exact-head merge-gate confirmation; likely related people are @steipete (high) and Vincent Koc (medium).

Priority: P3
Reviewed head: 7088565dc76cf4ff9955eb481ad95cfb9a622f7d
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused, net-negative, and source-consistent with its callers and tests; landing remains a maintainer and exact-head-gate decision.
Proof confidence 🌊 off-meta tidepool Not applicable: This repository-member PR is an internal refactor, so the external-contributor real-behavior-proof gate does not apply; its body supplies focused test evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This repository-member PR is an internal refactor, so the external-contributor real-behavior-proof gate does not apply; its body supplies focused test evidence.
Evidence reviewed 6 items Changed summary owner: The PR-head exported summary function contains the former private renderer's dropped-count guard, default title/pluralization, ordered summary lines, and join operation.
Changed collect owner: The inlined collect step still skips before mutation, sets forced individual mode before the awaited drain for cross-channel work, and returns the same result union.
Caller and behavior coverage: The auto-reply caller still consumes the unchanged result union to keep mixed delivery individual, while helper tests cover summary rendering, UTF-16-safe truncation, skip, drain, and cross-channel force-mode behavior.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/utils/queue-helpers.test.ts

Result: PASS (completed)

node scripts/run-vitest.mjs src/utils/queue-helpers.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-129108-MlFL5e/target$ node scripts/run-vitest.mjs src/utils/queue-helpers.test.ts
node scripts/run-vitest.mjs src/utils/queue-helpers.test.ts
[test] starting test/vitest/vitest.unit-fast.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129108-MlFL5e/target

 ✓  unit-fast  src/utils/queue-helpers.test.ts (15 tests) 8ms

 Test Files  1 passed (1)
      Tests  15 passed (15)
   Start at  08:20:55
   Duration  386ms (transform 175ms, setup 98ms, import 123ms, tests 8ms, environment 0ms)

[test] passed 1 Vitest shard in 11.45s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-129108-MlFL5e/target$ node scripts/run-vitest.mjs src/utils/queue-helpers.test.ts



































Assertions:

  • PASS expect_output: Test Files

How this fits together

Queue helpers turn pending queue state into overflow prompts and decide whether collected messages must drain individually. Auto-reply and the embedded TUI consume those results to preserve delivery order and render queued-message prompts.

flowchart LR
A[Queued messages] --> B[Queue helpers]
B --> C[Overflow summary]
B --> D[Collect-drain decision]
C --> E[Prompt for agent]
D --> F[Auto-reply delivery]
E --> G[Embedded TUI]
F --> G
Loading

Decision needed

Question Recommendation
Should this maintainer-requested queue simplification be merged once the exact resulting head has a clean merge and required checks? Approve after exact-head gates: Accept the behavior-preserving cleanup after GitHub confirms the clean merge result and required checks for the final head.

Why: The author is a repository member and the PR carries the protected maintainer label, so this workflow must leave the landing choice to a maintainer.

Before merge

  • Resolve merge risk (P1) - The branch is behind main; if it is rebased, use the resulting exact head for the normal clean-merge and CI confirmation.
  • Complete next step (P2) - No repair is indicated; explicit maintainer approval and exact-head merge-gate confirmation are the remaining actions.
Agent review details

Security

None.

PR surface

Source -41. Total -41 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 22 63 -41
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 22 63 -41

Review metrics

Metric Value Why it matters
Production versus tests production -41, tests 0 The PR removes private indirection without growing the tested behavior surface.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Merge the net-negative inlining only after the exact resulting head remains cleanly mergeable and passes the repository’s required checks.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Merge the net-negative inlining only after the exact resulting head remains cleanly mergeable and passes the repository’s required checks.

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

Not applicable: this is a behavior-preserving internal refactor, not a report of a failing user flow.

Is this the best way to solve the issue?

Yes: the code moves each single-use private implementation into its actual owner while preserving the summary, truncation, and collect-drain sequences shown by callers and tests.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7d9cb48804e4.

Labels

Label justifications:

  • P3: This is a low-risk internal cleanup with no claimed user-visible behavior change.
  • 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 repository-member PR is an internal refactor, so the external-contributor real-behavior-proof gate does not apply; its body supplies focused test evidence.

Evidence

What I checked:

  • Changed summary owner: The PR-head exported summary function contains the former private renderer's dropped-count guard, default title/pluralization, ordered summary lines, and join operation. (src/utils/queue-helpers.ts:28, 7088565dc76c)
  • Changed collect owner: The inlined collect step still skips before mutation, sets forced individual mode before the awaited drain for cross-channel work, and returns the same result union. (src/utils/queue-helpers.ts:275, 7088565dc76c)
  • Caller and behavior coverage: The auto-reply caller still consumes the unchanged result union to keep mixed delivery individual, while helper tests cover summary rendering, UTF-16-safe truncation, skip, drain, and cross-channel force-mode behavior. (src/auto-reply/reply/queue/drain.ts:1325, 7088565dc76c)
  • Current-main comparison: Current main has no change to this file relative to the PR base, so it still contains the pre-refactor helper indirection and does not already implement this cleanup. (src/utils/queue-helpers.ts:28, 7d9cb48804e4)
  • Feature history: History shows Peter Steinberger created and repeatedly refactored the shared queue helpers; Vincent Koc also carried recent queue-helper cleanup. (src/utils/queue-helpers.ts:27, 1aa4d3a6f0d6)
  • Dependency boundary: The diff only rearranges internal code around existing imports; it adds no dependency, external API, Codex-runtime, or protocol contract signal. (src/utils/queue-helpers.ts:1, 7088565dc76c)

Likely related people:

  • steipete: History records the original shared-helper work and several subsequent queue refactors, including this PR head. (role: shared queue-helper author and recent area contributor; confidence: high; commits: c7ae5100fae4, 1aa4d3a6f0d6, b22deada9e86; files: src/utils/queue-helpers.ts)
  • Vincent Koc: Recent queue-helper refactors include dead-summary-reset removal and delivery-queue helper cleanup. (role: recent adjacent contributor; confidence: medium; commits: c09ed1954fcd, 60e8d4f0210b; files: src/utils/queue-helpers.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm the clean merge result and required checks on the exact head that would land.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-25T07:36:33.877Z sha 7088565 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 0497cd9 into main Aug 25, 2026
491 of 496 checks passed
@steipete
steipete deleted the codex/refactor-infra-utils-b6df91fd branch August 25, 2026 08:29
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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