Repository navigation
feat(policy): close pull requests above 50k changed lines as too large to consider - #1496
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 9, 2026, 10:55 AM ET / 14:55 UTC (Revision 5). ClawSweeper reviewWhat this changesAdds a configurable 50,000-line PR admission limit that avoids expensive review work and produces metadata-based close proposals for guarded apply. Merge readiness✅ Ready for maintainer review This remains a distinct, useful contribution absent from current main. The previous changelog finding is resolved, and the updated proof supports the guarded close path; no blocking correctness finding remains. Priority: P2 Review scores
Verification
How this fits togetherClawSweeper turns GitHub item metadata into review records, then separately applies eligible decisions. This change rejects oversized PRs before detailed review and rechecks their eligibility before publishing and closing. flowchart TD
A[GitHub PR metadata] --> B[Size and exemption check]
B -->|Admitted| C[Normal review]
B -->|Oversized| D[Pending close record]
D --> E[Live eligibility and activity checks]
E -->|Changed or protected| F[Keep open]
E -->|Eligible| G[Publish notice and close]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep one shared admission predicate and the existing apply writer, with persisted freshness receipts and live exemptions controlling every oversized close. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction: this adds policy behavior. The captured CLI proof exercises oversized admission and guarded final effects. Is this the best way to solve the issue? Yes. Reusing a shared predicate and the existing guarded writer avoids competing close implementations, and the supplied evidence covers eligibility changes and retry freshness. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4899f29ef154. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
| return send({ error: "unexpected mutation" }, 400); | ||
| } catch (error) { | ||
| response.writeHead(500); | ||
| response.end(String(error)); |
What Problem This Solves
Oversized pull requests can consume hydration, scanner, and review capacity even when their diffs are too large to consider. The motivating case is openclaw/openclaw#141913: 166,686 changed lines across 2,747 files.
Why This Change Was Made
A shared deterministic predicate now evaluates GitHub PR metadata before structural-cache preflight, review-start publication, hydration, scanning, or model execution. Eligible oversized PRs produce the standard close proposal, with additions, deletions, changedFiles, threshold, and head recorded as metadata evidence.
The exact-event live check uses the built predicate, saves its PR payload, and bypasses target checkout, reactions, reservations, and review-tool setup for oversized items. The shared reviewer consumes that payload; scheduled exact-queue work and shard review reach the same admission policy. ClawSweeper's own build precedes the live check so the workflow executes the compiled predicate.
The existing apply writer owns the close. A runner-owned source snapshot records the pre-fetch observation time, metadata fingerprint, and comment counts; bounded activity receipts then preserve freshness across the exact owned comment write. Its reason-specific metadata path requires complete evidence and revalidates live state, size, threshold, head, lock, exemptions, and non-owned activity immediately before closing. Ambiguous admission-second activity keeps the proposal open, including submitted-review edits that lack their own edit timestamp. The original receipt is persisted before publication and its owned-write identity before subsequent reads, so failed checks cannot lose the baseline on retry. The exact-event shortcut also propagates a revoked finalization lease before bundle publication. Source-review and model provenance are not fabricated. The public notice uses proposal wording until GitHub confirms the close, then the same comment is updated to the successful-close template without replacing a newer canonical review. Other close policies retain their existing safeguards.
Maintainer Policy and Finding Dispositions
The maintainer's resolved policy for this work explicitly includes drafts and OWNER/MEMBER-authored PRs, uses
size: accepted-largeas the deliberate-large-change escape hatch, and enables the sweep gate by default.AGENTS.mdnow records this approved exception; other protected labels and repository-specific apply restrictions remain intact.superseded=truewhen finalization loses queue authority. The executable workflow test feeds a 409 through the real finalization function and verifies that publication is skipped.User Impact
The default limit is 50,000 additions plus deletions: 50,000 is admitted and 50,001 is oversized.
CLAWSWEEPER_MAX_PR_CHANGED_LINESaccepts a positive integer; invalid values fall back to 50,000. Missing size/head metadata admits normally. Drafts and owner/member authorship do not exempt a PR; the existing PR auto-close exemption labels and maintainer-ownedsize: accepted-largelabel do. PR status label synchronization creates the new label.CLAWSWEEPER_OVERSIZED_PR_CLOSE_ENABLEDis default-off for standalone CLI use and defaults to true in the sweep workflow. The sharedallclose-reason filter includes the new reason. Disabled gates, comment-only publication, and dry-run retain a pending proposal. The policy never reopens a PR automatically. Existing protected-label and repository-specific apply restrictions remain in force; the maintainer label alone does not exempt this reason.OpenClaw Bay Impact
Bay has no separately enumerated close-reason vocabulary to update. A pending proposal versus an actual close is represented exactly as for other close reasons: the report remains in
records/<slug>/items/<n>.mduntil a successful close is archived toclosed/. The synthetic apply proof verifies that distinction. Bay remains observer-only; no controls or browser-side GitHub calls are added.Documentation Impact
Added the active oversized PR policy with ownership, source of truth, verified scope, update triggers, configuration, exemptions, and public comment. Linked it from the close-policy index, documentation navigation, and README; added an Unreleased changelog entry.
Evidence
The focused policy tests cover threshold boundaries and configuration, exemptions, metadata records and comments, reason/schema membership, all reviewer entry paths, gate behavior, one-comment close execution, exact-event publication, and live-state rejection before and after comment publication. They also assert that apply performs no PR file, commit, or blob hydration; only bounded activity metadata is read. The workflow test executes its live-item shell with synthetic PR payloads and verifies the shared predicate and skipped setup conditions.
The original head passed full Linux validation and GitHub CI. Follow-up full Linux validation passed with 3,939 unit tests passed / 11 skipped and 5,561 full-check tests passed / 18 skipped, with zero failures. After the final receipt hardening, 31 focused tests, 3 executable workflow/read-scope checks, build, lint, static/docs checks, and both built-CLI proofs passed again on AWS through Crabbox (
cbx_947c60d2e9ab, Node 24.18.1). The integrated tree against main31fc0b873then passed 4,056 unit tests / 11 skipped and 5,692 full-check tests / 18 skipped, with zero failures. Current pre-commit autoreview is scoped-clean.Pre-commit review found no remaining accepted/actionable findings. Earlier findings about complete persisted threshold evidence and honest comment wording across aborted closes were addressed with regression coverage.
Real Behavior Proof
Source head:
2dc0f34492b736004bc1637042935759402d35ff. The built CLI proofs were repeated on this committed head after the threshold moved to 50,000 (the final commit is changelog-only); the 22 policy unit tests, the 152 sweep-workflow tests, and both proof harnesses passed locally withthreshold: 50000recorded, and the threshold commits are autoreview scoped-clean against the previously reviewed head.dist/clawsweeper.js reviewandapply-decisions, using the exact-event metadata handoff, with a stateful HTTP transport adapter for enabled apply.node scripts/proof-oversized-pr-close.mjsandnode scripts/proof-oversized-pr-close-effects.mjs; the harness runs the built CLI with--pr-admission-file, gates disabled, andapply-decisions --dry-run --skip-dashboard --item-number 141913with isolated items/closed directories. Git/GitHub boundaries are synthetic; enabled-apply requests reach only a loopback HTTP service.decision: close,close_reason: oversized_pull_request,action_taken: proposed_close,review_model: none,local_checkout_access: unverified; recorded metadata is{"additions":45791,"deletions":120895,"changedFiles":2747,"threshold":50000,"head":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"}. Runtime logs reporthydration=0 scanner=0 codex=0; subprocess logs are empty. Apply reportsdry-run: oversized PR close proposal retained, with the report still in items and no closed record. The control enters normal issue hydration and stops atCONTROL_REACHED_NORMAL_HYDRATION.scripts/proof-oversized-pr-close.mjsandscripts/proof-oversized-pr-close-effects.mjs; generated transcripts, reports, fixtures, request logs, and service state under.artifacts/oversized-pr-proof/and.artifacts/oversized-effects-proof/. The public close comment is rendered from the recorded size evidence and is below 120 words.The HTTP service accepts a close whenever requested; it does not implement the size or protection policy. These final effects therefore exercise the built CLI guards:
Successful closes retain one owned comment and finish with the requested close wording. Refused closes retain pending wording. The boundary test also verifies that close failure and post-close notice failure preserve the correct items/closed state.
Executed CLI proof excerpt
The control intentionally stops at the synthetic hydration boundary.
CI Integration
The first follow-up CI test merge exposed a clean textual merge with a newer main refactor: the oversized case landed in the extracted close-policy helper with four unbound local references. The PR branch now includes that main revision and qualifies these accesses through
dependenciesandoptions. Both sets of appended workflow tests were retained, and the supersession test uses the shared control-plane helper. Failed job logs were fetched once and the integrated build and full check passed before pushing.Known Gaps
No production closing or workflow dispatch was performed. Local broad validation encountered the known drift-refresh environment failure, cold-build/toolchain problems, process-identity/race contention, and repair-fixture timeouts; focused reruns plus fresh Linux validation provide the current evidence. This PR is published for review and stops before merge.