Skip to content

refactor: shrink ClawSweeper entrypoint by 77% with focused subsystems - #1005

Merged
steipete merged 1 commit into
mainfrom
codex/clawsweeper-subsystem-decomposition
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/clawsweeper-subsystem-decomposition

Conversation

@steipete

@steipete steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Problem

src/clawsweeper.ts had grown to 14,216 lines, mixing command dispatch, report formatting, dashboard state, GitHub hydration, review execution, apply mutation, and retry coordination. The resulting cross-coupled entrypoint made the behavior difficult to understand, review, and change safely.

Changes

  • Reduce src/clawsweeper.ts from 14,216 to 3,277 lines: 10,939 lines removed from the entrypoint (76.9%).
  • Separate item/context hydration, review execution, apply decisions, report orchestration, report rendering, report parsing helpers, dashboard/audit handling, and command/retry operations into focused modules.
  • Retain the existing public/test export surface and preserve mutation-runner ownership, review leases, action-ledger causality, dashboard state, and generated work plans.
  • Keep local review independent, offline, read-only, credential-isolated, and compatible with --local-range.
  • Preserve generated OpenClaw fix PRs as create-only; keep gpt-5.6-sol / xhigh, with merge and auto-merge disabled.
  • Follow extracted source locations in structural regression tests instead of weakening their behavioral assertions.

Real behavior proof

The actual pnpm run local-review command and local-range reviewer were exercised against a committed temporary Git repository. The same proof also generated issue/self-heal jobs and evaluated their real execution gates:

{"actualPackageCommand":"pnpm run local-review","standaloneReviewSucceeded":true,"localRangeReviewSucceeded":true,"committedFilesReviewed":2,"commitsReviewed":1,"gitHubCalls":0,"leakedGitHubCredentials":0,"webSearchDisabled":true,"sandbox":"read-only","isolatedGitHubConfig":true,"generatedAutofixMergeAllowed":false,"legacyAutofixMergeAllowed":false,"legacyIssueMergeAllowed":false,"postFlightAutofixMergeAllowed":false,"replacementPrAutoMergeAllowed":false,"singleItemHydration":true}

Every extracted multiline template was also compared with the original entrypoint's literal contents; all matched exactly.

Verification

  • pnpm run check
  • Focused offline-review, action-ledger, cursor, sweep-status, report-rendering, generated work-plan, retry, and Codex-review-runner tests
  • Fresh independent Codex /review on the uncommitted changes and committed branch

Generated OpenClaw PR openclaw/openclaw#117443 remains open with auto-merge disabled.

@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. 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. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 12:48 PM ET / 16:48 UTC.

ClawSweeper review

What this changes

This PR splits ClawSweeper’s large CLI entrypoint into focused TypeScript modules for review, apply, context hydration, reporting, dashboard/audit, and command operations while preserving the existing public command surface.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR’s prior trailing-whitespace blocker is resolved on the current head, and the reviewed extraction keeps the CLI entrypoint as the composition layer for the existing review, apply, report, and audit workflows. The patch is structurally sound from read-only inspection and includes current real-command proof, but it remains a large automation refactor that should stay open for the in-progress required checks and maintainer landing review.

Priority: P3
Reviewed head: ca5f97a58fc761554fe4f1c086d776b71218bba7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The PR has strong direct command proof and a coherent module split, with the remaining confidence reducer being the unusually broad automation refactor and its still-running checks.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The current PR body includes after-fix terminal output from the actual pnpm run local-review and local-range paths, showing successful isolated read-only operation and the relevant merge-safety gates; redact any private details if refreshed proof is posted.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The current PR body includes after-fix terminal output from the actual pnpm run local-review and local-range paths, showing successful isolated read-only operation and the relevant merge-safety gates; redact any private details if refreshed proof is posted.
Evidence reviewed 5 items Focused subsystem wiring: The current PR head imports and composes dedicated apply, command, hydration, dashboard, item-context, report, and review workflow factories while retaining the entrypoint’s exported compatibility surface.
Review workflow remains encapsulated: The extracted review workflow provides the review command through its factory return path, keeping the entrypoint as orchestration rather than duplicating review execution logic.
Prior whitespace finding resolved: The current PR range has no git-diff whitespace errors; this addresses the previous review cycle’s only P3 finding.
Findings None None.
Security None None.

How this fits together

ClawSweeper’s CLI gathers GitHub item context, runs Codex-backed review, renders durable reports, and conditionally coordinates guarded apply actions. This refactor moves those responsibilities into focused modules while the entrypoint continues to wire commands, state, and workflow safeguards together.

flowchart LR
  A[GitHub items and workflow events] --> B[Context hydration]
  B --> C[Review command workflow]
  C --> D[Decision and report orchestration]
  D --> E[Dashboard and audit state]
  D --> F[Guarded apply decisions]
  F --> G[GitHub actions and ledger]
  H[CLI command dispatch] --> B
  H --> C
  H --> F
Loading

Before merge

  • Resolve merge risk (P1) - This 17-file extraction changes the control boundaries for review, mutation, and durable state; the PR’s current pnpm check and Actions analysis runs should complete successfully on the current head before merge.
  • Complete next step (P2) - No repair lane is appropriate because the patch has no discrete actionable defect; maintainers should review the completed current-head automation evidence before landing.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Entrypoint reduction 10,939 entrypoint lines removed The refactor moves most CLI implementation work into dedicated modules while preserving the entrypoint as composition code.
Review surface 17 files changed; 16,292 added and 12,058 removed The broad relocation warrants completion of the current automation checks despite the focused architectural goal.

Merge-risk options

Maintainer options:

  1. Complete current automation verification (recommended)
    Allow the in-progress pnpm check and Actions analysis to finish on the current head, resolving any regression they identify before merge.
  2. Pause for narrower landing units
    If maintainers want a smaller review surface, pause this broad extraction and land independently verifiable subsystem moves instead.

Technical review

Best possible solution:

Keep the focused module boundaries, land only after the current checks complete on this head, and preserve the existing local-review, ledger, lease, and create-only repair safeguards demonstrated in the PR proof.

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

Not applicable: this PR is a structural refactor rather than a report of failing existing behavior. Its body provides a high-confidence after-change command exercise for the affected local-review paths.

Is this the best way to solve the issue?

Yes. Separating the existing orchestration responsibilities into factory-backed modules is a maintainable way to reduce the entrypoint’s coupling while retaining the established command and safeguard boundaries.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a maintainability refactor with no demonstrated user-facing regression or urgent operational failure.
  • merge-risk: 🚨 automation: The patch relocates review, apply, reporting, and command workflows that govern ClawSweeper automation behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The current PR body includes after-fix terminal output from the actual pnpm run local-review and local-range paths, showing successful isolated read-only operation and the relevant merge-safety gates; redact any private details if refreshed proof is posted.
  • proof: sufficient: Contributor real behavior proof is sufficient. The current PR body includes after-fix terminal output from the actual pnpm run local-review and local-range paths, showing successful isolated read-only operation and the relevant merge-safety gates; redact any private details if refreshed proof is posted.

Evidence

What I checked:

  • Focused subsystem wiring: The current PR head imports and composes dedicated apply, command, hydration, dashboard, item-context, report, and review workflow factories while retaining the entrypoint’s exported compatibility surface. (src/clawsweeper.ts:54, ca5f97a58fc7)
  • Review workflow remains encapsulated: The extracted review workflow provides the review command through its factory return path, keeping the entrypoint as orchestration rather than duplicating review execution logic. (src/clawsweeper-review-command-workflow.ts:373, ca5f97a58fc7)
  • Prior whitespace finding resolved: The current PR range has no git-diff whitespace errors; this addresses the previous review cycle’s only P3 finding. (src/clawsweeper-apply-decision-workflow.ts:4090, ca5f97a58fc7)
  • Current real behavior proof: The PR body records successful execution of the actual local-review command and local-range review against a committed temporary repository, including read-only sandboxing, zero GitHub calls, credential isolation, and disabled generated-PR merge paths. (ca5f97a58fc7)
  • Feature-history provenance: The entrypoint’s recent history is predominantly Peter Steinberger’s modularization and safety work, with adjacent apply/review fixes by Vincent Koc and Martin Cleary. (src/clawsweeper.ts:1, 922ebc673e12)

Likely related people:

  • steipete: Peter Steinberger authored the current refactor and the dominant recent history of the CLI’s modularization, review, and safe-repair behavior. (role: feature owner and recent area contributor; confidence: high; commits: ca5f97a58fc7, 922ebc673e12, 1c9cb5dc6dd2; files: src/clawsweeper.ts, src/clawsweeper-review-command-workflow.ts, src/clawsweeper-apply-decision-workflow.ts)
  • Vincent Koc: Vincent Koc recently changed apply publication-state behavior that this refactor relocates into the extracted apply workflow. (role: recent adjacent contributor; confidence: medium; commits: 0925ecae3787; files: src/clawsweeper.ts, src/clawsweeper-apply-decision-workflow.ts)
  • Martin Cleary: Martin Cleary recently maintained review candidate handling in the same entrypoint surface now moved into focused review modules. (role: recent adjacent contributor; confidence: medium; commits: 0ced0b5e515b; files: src/clawsweeper.ts, src/clawsweeper-review-command-workflow.ts)

Rank-up moves

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

  • Wait for the current pnpm check and Actions analysis results on the present head before landing.

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 (2 earlier review cycles)
  • reviewed 2026-08-01T16:38:41.883Z sha 8d5fa13 :: needs changes before merge. :: [P3] Remove trailing whitespace from extracted apply workflow
  • reviewed 2026-08-01T16:42:42.882Z sha 8d5fa13 :: found issues before merge. :: [P3] Remove trailing whitespace from extracted apply workflow

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. label Aug 1, 2026
@steipete
steipete force-pushed the codex/clawsweeper-subsystem-decomposition branch from 8d5fa13 to ca5f97a Compare August 1, 2026 16:45
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete merged commit dccfa52 into main Aug 1, 2026
9 checks passed
@steipete
steipete deleted the codex/clawsweeper-subsystem-decomposition branch August 1, 2026 16:56
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant