Skip to content

refactor: modularize ClawSweeper and preserve validated fix checkouts - #979

Merged
steipete merged 1 commit into
mainfrom
codex/clawsweeper-modular-entrypoint
Jul 31, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/clawsweeper-modular-entrypoint

Conversation

@steipete

@steipete steipete commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Break the 32,347-line src/clawsweeper.ts monolith into focused modules for shared types, automation policy, strict decision parsing, fence-aware review Markdown, durable review comments, same-repository PR reference extraction, PR ratings, and safe command dispatch. The entrypoint drops to 28,910 lines while retaining its public API and existing close/repair safety gates.
  • Replace the sprawling command if/else ladder with an own-property-checked command registry that preserves asynchronous execution, unknown-command failures, and action-ledger finalization.
  • Fix the real failed OpenClaw issue-implementation run 30650015178: Codex successfully produced and reviewed the fix, then its review reran pnpm check:changed, rewrote ignored TypeScript build caches, and tripped target checkout changed after validation before PR publication. Reviews now default to a genuinely read-only sandbox and reuse the validation proof that already passed.
  • Keep autogenerated OpenClaw issue PRs create-only: intake hard-codes CLAWSWEEPER_ALLOW_MERGE=0, generated PRs do not receive automerge authority, and comment routing still requires manual merge.

Production evidence

Validation

  • pnpm run check: https://github.com/openclaw/clawsweeper/actions/runs/30653677687 (green; Linux production runner, full coverage suite, builds, lint, format checks).
  • 132 focused protected-label, decision-parser, review-history, PR-rating, command-dispatch, and read-only repair-review regression tests passed.
  • 48 duplicate-reference and PR-close-coverage proof regression tests passed, including cross-repository Markdown-link spoofing and unchanged-head safety gates.
  • The hermetic production automerge workflow is green: https://github.com/openclaw/clawsweeper/actions/runs/30653674986.
  • Fresh Codex full-tree review before commit: The extracted modules preserve existing behavior, command dispatch handles synchronous and asynchronous commands correctly, and the focused builds and relevant tests pass. No actionable regressions were identified in the changed files.
  • Fresh Codex full-tree review of committed origin/main...abc389bcca75f3c03abef29fa1ca72b5556ce176: The extracted modules preserve existing behavior, command dispatch maintains the previous CLI semantics, and the repair-review changes enforce the intended read-only validation boundary. Focused tests, workflow tests, formatting checks, and TypeScript compilation passed. Both independent local Codex reviews had every PR blob available and inspected the complete current-head diff; they were not limited by the exact-review worker's partial-clone sandbox.

Current-head real runtime proof

Executed on current head abc389bcca75f3c03abef29fa1ca72b5556ce176 using the actual runCodexReview function from both origin/main and the compiled PR-head executor. A real local Git target checkout contained a tracked source file and ignored .artifacts/tsgo-cache/test-root.tsbuildinfo; its validation gate ran before each real review invocation. The harness executed a separate Codex subprocess, returned a real structured clean review, and compared the tracked/index plus ignored-cache checkout binding before and after review.

Control, actual current-main executor under GITHUB_ACTIONS=true:

review sandbox: danger-full-access
review model: gpt-5.6-sol
review reasoning: model_reasoning_effort="xhigh"
validated ignored cache before review: 529d00fa62cf54a8b2279399069f76dd5e33043a636b47491b28d574caca26ab
ignored cache after review:           8f942ee2d9c32771217f7b9b5502bc3bd1d7808087b5bc12239feb1acbcfe19b
review status: clean
validated checkout changed: true
validation replay explicitly forbidden: false
ignored-cache mutation explicitly forbidden: false

Treatment, actual compiled executor on PR head abc389bcca75f3c03abef29fa1ca72b5556ce176:

review sandbox: read-only
review model: gpt-5.6-sol
review reasoning: model_reasoning_effort="xhigh"
validated ignored cache before review: 529d00fa62cf54a8b2279399069f76dd5e33043a636b47491b28d574caca26ab
ignored cache after review:           529d00fa62cf54a8b2279399069f76dd5e33043a636b47491b28d574caca26ab
review status: clean
validated checkout changed: false
validation replay explicitly forbidden: true
ignored-cache mutation explicitly forbidden: true

The actual current-main executor reproduces the precise failing production transition (clean review followed by changed ignored checkout state); the actual current-head executor preserves the exact validated checkout and returns a clean review. The model/reasoning flags are carried through the real review invocation. No generated OpenClaw issue PR is granted automerge authority.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Jul 31, 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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jul 31, 2026
@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 2:18 PM ET / 18:18 UTC.

ClawSweeper review

What this changes

This PR extracts ClawSweeper’s decision, review-comment, reference, rating, type, and command-dispatch helpers into focused modules while changing repair reviews to use a read-only Codex sandbox and preserve already-validated target checkouts.

Merge readiness

⚠️ Needs maintainer review before merge - 3 items remain

Keep this PR open for normal merge review. Its copied current-head control/treatment transcript is meaningful real-behavior proof for the checkout-preservation fix, but this review checkout could not materialize the complete 12-file diff from its unreachable promisor remote, so the broad extraction still needs a fresh full-diff review before landing.

Priority: P2
Reviewed head: abc389bcca75f3c03abef29fa1ca72b5556ce176

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The runtime proof is concrete and current-head-specific, while the broad refactor remains only partially reviewable in this environment because required Git objects could not be fetched.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body contains copied current-head live output from the actual runCodexReview control and treatment paths, including sandbox selection, before/after ignored-cache hashes, checkout-binding results, and clean structured reviews. The treatment shows the validated checkout remains unchanged; redact any private paths or credentials if this proof is reposted.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body contains copied current-head live output from the actual runCodexReview control and treatment paths, including sandbox selection, before/after ignored-cache hashes, checkout-binding results, and clean structured reviews. The treatment shows the validated checkout remains unchanged; redact any private paths or credentials if this proof is reposted.
Evidence reviewed 6 items Current-main behavior: Current main selects danger-full-access for Codex repair reviews when GITHUB_ACTIONS=true, which matches the reported mechanism whereby a review can mutate an ignored build-cache artifact after validation.
Review execution boundary: Current main passes the configured review sandbox directly to the real Codex subprocess and records structured review output, so changing the default sandbox affects the production repair-review path rather than only a test helper.
Current command semantics: Current main uses a command ladder that captures command failures, finalizes action-ledger events, and rethrows afterward; the PR’s new dispatcher must preserve this behavior around the extracted handlers.
Findings None None.
Security None None.

How this fits together

ClawSweeper’s CLI turns GitHub item data into review, repair, and apply-lane decisions, then records workflow outcomes in its action ledger. The changed repair path runs validation and a Codex review against a target checkout before it can create a proposed fix PR.

flowchart LR
  A[GitHub item and repair job] --> B[Repair validation]
  B --> C[Validated target checkout]
  C --> D[Read-only Codex review]
  D --> E[Checkout binding check]
  E --> F[Fix PR decision]
  G[CLI command] --> H[Command registry]
  H --> I[Action ledger finalization]
Loading

Before merge

  • Resolve merge risk (P1) - The PR relocates central decision parsing, review-comment handling, PR-reference extraction, ratings, shared types, and CLI dispatch; a partial-clone failure prevented a complete equivalence review of those extracted implementations.
  • Resolve merge risk (P1) - The read-only repair-review default changes production automation behavior. The supplied runtime proof is strong, but merge review should confirm that all supported runner environments still accept the intended Codex sandbox configuration.
  • Complete next step (P2) - The repair proof is adequate, but a reviewer needs a checkout with the complete current-head diff before approving this broad core refactor; no discrete automated repair is established.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Refactor scope 12 files changed; 5,507 additions and 4,804 deletions Most changed lines relocate central automation behavior, so complete behavioral-equivalence review matters before merge.
Runtime comparison 2 real review invocations The PR body contrasts current main with the compiled PR head using the actual repair-review executor and ignored-cache binding checks.

Merge-risk options

Maintainer options:

  1. Refresh full-diff review before merge (recommended)
    Review the complete current-head extraction in an environment with all PR blobs available, then merge if the existing command, decision, and repair contracts remain equivalent.
  2. Split the reliability repair
    If full-refactor review cannot be completed promptly, land the focused read-only review and validation-reuse change separately from the module extraction.
  3. Pause the branch
    Pause this PR rather than merge the broad extraction without a reviewable complete diff.

Technical review

Best possible solution:

Land the checkout-preservation safeguard together with the modularization only after a reviewer with all current-head blobs verifies that the extracted modules preserve the entrypoint’s prior APIs, command failure semantics, and repair-lane behavior.

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

Yes, with medium confidence: the PR body provides a concrete current-main control using the actual repair-review function, and current source confirms that GitHub Actions selects a writable review sandbox. This read-only checkout could not independently rerun or fully inspect the PR-head harness.

Is this the best way to solve the issue?

Yes for the reported checkout mutation: a read-only review sandbox plus explicit reuse of completed validation targets the observed post-validation cache write without widening repair authority. Full-diff review is still needed to establish that the accompanying module extraction is the safest way to carry it.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body contains copied current-head live output from the actual runCodexReview control and treatment paths, including sandbox selection, before/after ignored-cache hashes, checkout-binding results, and clean structured reviews. The treatment shows the validated checkout remains unchanged; redact any private paths or credentials if this proof is reposted.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body contains copied current-head live output from the actual runCodexReview control and treatment paths, including sandbox selection, before/after ignored-cache hashes, checkout-binding results, and clean structured reviews. The treatment shows the validated checkout remains unchanged; redact any private paths or credentials if this proof is reposted.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded production-automation reliability improvement with no supplied evidence of an active emergency outage.
  • merge-risk: 🚨 compatibility: The PR extracts shared parsing, comments, references, ratings, types, and command dispatch from the main entrypoint.
  • merge-risk: 🚨 automation: It changes the production repair-review sandbox and validation-review sequencing.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body contains copied current-head live output from the actual runCodexReview control and treatment paths, including sandbox selection, before/after ignored-cache hashes, checkout-binding results, and clean structured reviews. The treatment shows the validated checkout remains unchanged; redact any private paths or credentials if this proof is reposted.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body contains copied current-head live output from the actual runCodexReview control and treatment paths, including sandbox selection, before/after ignored-cache hashes, checkout-binding results, and clean structured reviews. The treatment shows the validated checkout remains unchanged; redact any private paths or credentials if this proof is reposted.

Evidence

What I checked:

  • Current-main behavior: Current main selects danger-full-access for Codex repair reviews when GITHUB_ACTIONS=true, which matches the reported mechanism whereby a review can mutate an ignored build-cache artifact after validation. (src/repair/execute-fix-artifact.ts:242, 3637a9424ec2)
  • Review execution boundary: Current main passes the configured review sandbox directly to the real Codex subprocess and records structured review output, so changing the default sandbox affects the production repair-review path rather than only a test helper. (src/repair/execute-fix-artifact.ts:3187, 3637a9424ec2)
  • Current command semantics: Current main uses a command ladder that captures command failures, finalizes action-ledger events, and rethrows afterward; the PR’s new dispatcher must preserve this behavior around the extracted handlers. (src/clawsweeper.ts:32254, 3637a9424ec2)
  • Feature provenance: The repair executor’s most recent locally available relevant history is fix: restore automatic high-confidence OpenClaw bug repairs, authored by Peter Steinberger on July 31, 2026; the PR head is a direct child of current main and is not contained in main. (src/repair/execute-fix-artifact.ts:242, 3d2a878f6e2a)
  • Current-head runtime proof: The PR body includes copied live control/treatment output from the actual runCodexReview path: current main changes the ignored cache after a clean review, while the compiled PR-head executor reports read-only, unchanged cache hashes, validated checkout changed: false, and a clean review. (src/repair/execute-fix-artifact.ts:242, abc389bcca75)
  • Review infrastructure limitation: Attempting to inspect the complete base-to-head diff failed because this partial clone required promisor objects and its GitHub remote could not resolve. The target worktree remained clean, but the full extracted-module implementations were not locally reviewable.

Likely related people:

  • steipete: Peter Steinberger authored the latest locally available repair-lane change and authored the current PR commit, tying this account to both the existing behavior and the proposed repair. (role: recent repair-lane contributor and PR author; confidence: high; commits: 3d2a878f6e2a, abc389bcca75; files: src/repair/execute-fix-artifact.ts, src/clawsweeper.ts)

Rank-up moves

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

  • Obtain a fresh review from a checkout that can materialize all current-head blobs, with particular attention to exported-module contracts and action-ledger finalization.

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-07-31T18:08:32.197Z sha abc389b :: needs real behavior proof before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 31, 2026
@steipete
steipete merged commit 16f01b2 into main Jul 31, 2026
34 checks passed
@steipete
steipete deleted the codex/clawsweeper-modular-entrypoint branch July 31, 2026 18:20
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. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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