Skip to content

feat(policy): close pull requests above 50k changed lines as too large to consider - #1496

Merged
steipete merged 6 commits into
mainfrom
policy/oversized-pr-close
Sep 9, 2026
Merged

steipete merged 6 commits into
mainfrom
policy/oversized-pr-close

Conversation

@steipete

@steipete steipete commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

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-large as the deliberate-large-change escape hatch, and enables the sweep gate by default. AGENTS.md now records this approved exception; other protected labels and repository-specific apply restrictions remain intact.

  • Protected-item policy finding: resolved by documenting the explicit maintainer decision in the canonical policy. The requested authorship/draft behavior is preserved.
  • Freshness finding: fixed with source metadata observations and bounded issue-comment, timeline, inline-comment, and review fingerprints. Only the exact owned comment is excluded, and its write response is verified. Receipts persist across retries; body changes, same-second human comments, repeated pagination identities, and ambiguous initial review edits block closing.
  • Supersession finding: fixed by emitting superseded=true when finalization loses queue authority. The executable workflow test feeds a 409 through the real finalization function and verifies that publication is skipped.
  • Proof finding: expanded with built-CLI final-effect proof through a stateful loopback HTTP GitHub adapter. It observes the service's actual state and filesystem records for both allowed and forbidden closes. The authorized proof scope remains synthetic; no live GitHub close or production dispatch is claimed or performed.

User Impact

The default limit is 50,000 additions plus deletions: 50,000 is admitted and 50,001 is oversized. CLAWSWEEPER_MAX_PR_CHANGED_LINES accepts 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-owned size: accepted-large label do. PR status label synchronization creates the new label.

CLAWSWEEPER_OVERSIZED_PR_CLOSE_ENABLED is default-off for standalone CLI use and defaults to true in the sweep workflow. The shared all close-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>.md until a successful close is archived to closed/. 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 main 31fc0b873 then 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 with threshold: 50000 recorded, and the threshold commits are autoreview scoped-clean against the previously reviewed head.

  • Claim: oversized admission writes the standard metadata-only close proposal without GitHub/Git/model subprocesses, hydration, scanner, or model work; dry-run retains it without mutation; the 29,999-line control reaches normal hydration.
  • Surface: built dist/clawsweeper.js review and apply-decisions, using the exact-event metadata handoff, with a stateful HTTP transport adapter for enabled apply.
  • Fixture: synthetic OWNER-authored draft PR with 45,791 additions, 120,895 deletions, 2,747 files, and a fixed synthetic head; control changes only the line counts to 29,999 additions and zero deletions.
  • Command and environment: Node 24 on macOS and Linux, node scripts/proof-oversized-pr-close.mjs and node scripts/proof-oversized-pr-close-effects.mjs; the harness runs the built CLI with --pr-admission-file, gates disabled, and apply-decisions --dry-run --skip-dashboard --item-number 141913 with isolated items/closed directories. Git/GitHub boundaries are synthetic; enabled-apply requests reach only a loopback HTTP service.
  • Observed: 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 report hydration=0 scanner=0 codex=0; subprocess logs are empty. Apply reports dry-run: oversized PR close proposal retained, with the report still in items and no closed record. The control enters normal issue hydration and stops at CONTROL_REACHED_NORMAL_HYDRATION.
  • Artifact: reproducible harnesses scripts/proof-oversized-pr-close.mjs and scripts/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.
  • Limits: synthetic transport boundaries; no live GitHub close or production workflow dispatch. The control deliberately stops at hydration entry. Separate fake-GitHub apply tests exercise successful comment/close and refusal paths.

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:

Scenario Final service state Close requests Record location
Eligible oversized OWNER draft closed 1 closed
Protected label open 0 items
Ambiguous admission-second comment open 0 items
Stable old comment after a fresh observation closed 1 closed
Exemption added after proposal publication open 0 items
PR body edited after proposal publication open 0 items
Same-second human comment after proposal publication open 0 items
Review summary edited after publication, then apply retried open 0 items

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
$ node scripts/proof-oversized-pr-close.mjs
[review] oversized_pull_request #141913 total=166686 hydration=0 scanner=0 codex=0 report=<proof>/items/141913.md
Metadata: {"additions":45791,"deletions":120895,"changedFiles":2747,"threshold":50000,"head":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"}
Oversized subprocess counts: git=0 gh=0 codex=0; runtime hydration=0 scanner=0 codex=0.
Proposal remains in items; no GitHub mutation.
CONTROL_REACHED_NORMAL_HYDRATION

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 dependencies and options. 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.

@clawsweeper

clawsweeper Bot commented Sep 8, 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.

@steipete
steipete marked this pull request as ready for review September 8, 2026 14:51
@steipete
steipete requested a review from a team as a code owner September 8, 2026 14:52
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. 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 Sep 8, 2026
@clawsweeper

clawsweeper Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 9, 2026, 10:55 AM ET / 14:55 UTC (Revision 5).

ClawSweeper review

What this changes

Adds 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
Reviewed head: 2dc0f34492b736004bc1637042935759402d35ff

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent implementation with sufficient controlled final-effect proof and no remaining blocking finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Current-head Node 24 CLI evidence exercises the admission and apply owners through an isolated HTTP adapter, observing permitted closes and rejected protected or stale decisions before close I/O, including retry recovery. The scope is synthetic final-effect proof, not production GitHub execution.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Current-head Node 24 CLI evidence exercises the admission and apply owners through an isolated HTTP adapter, observing permitted closes and rejected protected or stale decisions before close I/O, including retry recovery. The scope is synthetic final-effect proof, not production GitHub execution.
Evidence reviewed 8 items Applicable repository policy: Read the complete root AGENTS.md. It records the approved oversized-policy exception, requires current behavior proof, and preserves guarded apply and observer-only Bay boundaries. No nested tracked AGENTS.md or matching maintainer-note files were found.
Current-main necessity: Current main's review entry still proceeds into ordinary review preparation without this size-admission branch. The current-main search found no oversized close reason or matching threshold configuration. No replacement appeared in the bounded recent-PR query; the supplied related reference is a motivating PR in another repository, not a same-repository replacement. Historical release-tree inspection was incomplete because required objects were unavailable; no shipped implementation is claimed.
Re-review continuity: The only file changed since the previously reviewed head is CHANGELOG.md, whose introduced entry now says 50,000. The captured PR body identifies the current head and reports repeating both updated CLI harnesses. Its control description still says 29,999, while the inspected harness uses 49,999; both are below the threshold, so this editorial mismatch does not invalidate the admission claim.
Findings None None.
Security None None.

How this fits together

ClawSweeper 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]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test LOC src: +930/-28, net +902; test: +900/-9, net +891 The stated production growth supports shared admission, durable freshness receipts, and guarded apply; proof scripts are excluded from these counts.
Final-effect scenarios 8 scenarios: 2 closes, 6 refusals The recorded CLI proof observes both permitted closes and rejection before the final close request.

Technical review

Best 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.

Labels

Label justifications:

  • P2: This is a bounded review-capacity improvement with explicitly approved close-policy behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Current-head Node 24 CLI evidence exercises the admission and apply owners through an isolated HTTP adapter, observing permitted closes and rejected protected or stale decisions before close I/O, including retry recovery. The scope is synthetic final-effect proof, not production GitHub execution.
  • proof: sufficient: Contributor real behavior proof is sufficient. Current-head Node 24 CLI evidence exercises the admission and apply owners through an isolated HTTP adapter, observing permitted closes and rejected protected or stale decisions before close I/O, including retry recovery. The scope is synthetic final-effect proof, not production GitHub execution.

Evidence

What I checked:

  • Applicable repository policy: Read the complete root AGENTS.md. It records the approved oversized-policy exception, requires current behavior proof, and preserves guarded apply and observer-only Bay boundaries. No nested tracked AGENTS.md or matching maintainer-note files were found. (AGENTS.md:63, 2dc0f34492b7)
  • Current-main necessity: Current main's review entry still proceeds into ordinary review preparation without this size-admission branch. The current-main search found no oversized close reason or matching threshold configuration. No replacement appeared in the bounded recent-PR query; the supplied related reference is a motivating PR in another repository, not a same-repository replacement. Historical release-tree inspection was incomplete because required objects were unavailable; no shipped implementation is claimed. (src/clawsweeper-review-command-workflow.ts:481, 4899f29ef154)
  • Re-review continuity: The only file changed since the previously reviewed head is CHANGELOG.md, whose introduced entry now says 50,000. The captured PR body identifies the current head and reports repeating both updated CLI harnesses. Its control description still says 29,999, while the inspected harness uses 49,999; both are below the threshold, so this editorial mismatch does not invalidate the admission claim. (CHANGELOG.md:205, 2dc0f34492b7)
  • Current-head final-effect proof: The supplied PR-body snapshot, context sourceRevision f74376b8650a5991b91108860b754c4e31fffb0f54d4c0993858ec9075ecab80, records Node 24 CLI execution on the current head. Its eight-scenario results show two eligible closes and zero close requests for protected, ambiguous, late-exemption, body-edit, human-comment, and review-edit/retry cases. The inspected harness runs the production CLI and observes HTTP service state and items/closed records; the loopback server accepts any requested close rather than enforcing policy itself. No production GitHub close is claimed. (scripts/proof-oversized-pr-close-effects.mjs:57, 2dc0f34492b7)
  • Persisted authority and final close guards: Apply persists the activity baseline before publication and the exact owned-comment identity before subsequent reads. The final close boundary repeats size/head/exemption validation and forces activity validation; retries compare the persisted receipt. Missing or changed evidence blocks closing. (src/clawsweeper-apply-close-execution.ts:973, 2dc0f34492b7)
  • Queue supersession and operational compatibility: The oversized shortcut propagates a revoked finalization lease through superseded=true, and bundle publication checks that output. The CLI gate remains default-off; the workflow's default-on behavior and maintainer-authorship exception are explicitly documented. New receipt fields are confined to the new close reason, and Bay retains the existing pending-versus-archived record contract. (.github/workflows/sweep.yml:1493, 2dc0f34492b7)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • brokemac79: 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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-09-08T14:57:30.932Z sha 896a43a :: needs real behavior proof before merge. :: [P1] Preserve the existing protected-item close exemptions | [P1] Retain a freshness receipt across metadata-only comment writes | [P2] Propagate supersession before publishing the oversized result
  • reviewed 2026-09-08T17:22:48.126Z sha be5c571 :: blocked before merge. :: none
  • reviewed 2026-09-08T17:34:23.128Z sha 024629a :: needs maintainer review before merge. :: none
  • reviewed 2026-09-09T14:46:48.912Z sha 88b8e9c :: needs real behavior proof before merge. :: [P3] [P3] Align the changelog with the 50,000-line default

return send({ error: "unexpected mutation" }, 400);
} catch (error) {
response.writeHead(500);
response.end(String(error));
@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. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 8, 2026
@steipete steipete changed the title feat(policy): close pull requests above 30k changed lines as too large to consider feat(policy): close pull requests above 50k changed lines as too large to consider Sep 9, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed 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. labels Sep 9, 2026
@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. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 9, 2026
@steipete
steipete merged commit aabbd98 into main Sep 9, 2026
26 of 30 checks passed
@steipete
steipete deleted the policy/oversized-pr-close branch September 9, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. 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.

2 participants