clawsweeper icon indicating copy to clipboard operation
clawsweeper copied to clipboard

refactor(review): git-native PR inspection (replaces prompt-hydrated patch text, per #68)

Open stainlu opened this issue 6 months ago • 2 comments

Following #68's close — confirming the replacement design before opening code so it matches the intended direction.

Plan:

  • Keep the target checkout on main (preserve the read-only invariant — do not materialize the PR as the working tree).
  • Reuse the existing fetchSourcePullRequestHead primitive (src/repair/source-pr-checkout.ts) to fetch refs/pull/<n>/head into a read-only refs/remotes/clawsweeper/... ref — no new parallel helper.
  • Instruct Codex in prompts/review-item.md to inspect via git diff origin/main...<ref> and git show <ref>:path.
  • Slim compactPullFilesForPrompt to file metadata only, dropping patch bodies. Verified .patch is consumed only by the prompt builder; repair/automerge gates run on the decision JSON + live git, so nothing downstream breaks.

Open question I want to get right: the main checkout is --filter=blob:none, so I'd pre-warm the PR diff blobs deterministically under ClawSweeper's control rather than let Codex trigger lazy promisor fetches inside the sandbox.

Net effect: deletes the truncation layer entirely, simpler core bot. @steipete does this match the direction from #68? I'll scope it as refactor(review): off fresh main.

stainlu avatar May 17 '26 03:05 stainlu

Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 14, 2026, 7:36 AM ET / 11:36 UTC.

Summary Keep open: current main still hydrates PR file patch bodies into review context, and the prompt has not moved to the git-native PR inspection contract requested after https://github.com/openclaw/clawsweeper/pull/68 was closed unmerged.

Reproducibility: not applicable. this is a refactor/design issue, not a bug report with runtime reproduction steps. Source inspection is enough to verify that current main still carries hydrated patch text.

Ways to help us reproduce this

  • Add a screenshot or short recording showing the behavior.
  • Add expected vs actual behavior.
  • Share version, platform, channel/provider, and relevant config details.

Next step Maintainer confirmation is needed on the blob pre-warming and prompt contract before this should become implementation work.

Review details

Best possible solution:

Land one focused git-native review-context refactor after maintainer confirmation, preserving the read-only main checkout while making PR diff inspection deterministic and prompt-explicit.

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

Not applicable: this is a refactor/design issue, not a bug report with runtime reproduction steps. Source inspection is enough to verify that current main still carries hydrated patch text.

Is this the best way to solve the issue?

Unclear: the proposed direction is consistent with the related maintainer comment, but the blob pre-warming contract needs maintainer confirmation before implementation.

AGENTS.md: found and applied where relevant.

Remaining risk / open question:

  • The open design question is how to pre-warm blobless-checkout PR diff blobs deterministically without letting Codex trigger uncontrolled lazy promisor fetches.

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

Label changes

Label changes:

  • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

Label justifications:

  • P3: This is a low-risk internal review-lane refactor and prompt-efficiency cleanup, not an urgent user-facing regression.
Evidence reviewed

What I checked:

  • Repository policy read: AGENTS.md was read in full and its conservative, proposal-only review guidance applies to this cleanup review. (AGENTS.md:1, a9b17a1e94ca)
  • Patch bodies still hydrated: The current PR file compactor still includes patch: truncateText(file.patch, 2000), so file metadata has not been slimmed to metadata-only. (src/clawsweeper.ts:4101, a9b17a1e94ca)
  • Review context still uses pull file API output: The review context builder still hydrates PR files through the GitHub pull files window and maps them through compactPullFile, including truncation counts. (src/clawsweeper.ts:5935, a9b17a1e94ca)
  • Reusable PR-head fetch helper exists: fetchSourcePullRequestHead already fetches refs/pull/<n>/head into refs/remotes/clawsweeper/source-pr-<n>, matching the primitive this issue proposes to reuse. (src/repair/source-pr-checkout.ts:83, a9b17a1e94ca)
  • Prompt contract not switched: The review prompt only lists generic read-only git inspection commands; searches found no instruction for git diff origin/main...<ref> or git show <ref>:path. (prompts/review-item.md:32, a9b17a1e94ca)
  • Related PR context: https://github.com/openclaw/clawsweeper/pull/68 was closed unmerged with a maintainer comment saying the review path should move toward Codex inspecting PR branches directly.

Likely related people:

  • steipete: Git blame and recent history point to Peter Steinberger on the current review-context and source-PR helper import, and steipete commented on https://github.com/openclaw/clawsweeper/pull/68 with the direct-branch inspection direction this issue follows. (role: recent area contributor and related design commenter; confidence: medium; commits: cd1594bc3794; files: src/clawsweeper.ts, prompts/review-item.md, src/repair/source-pr-checkout.ts)
  • stainlu: stainlu authored this design issue and the related unmerged performance PR that touched PR file patch budgeting in the review path. (role: proposal author and related PR author; confidence: medium; commits: 20f5662b1fab; files: src/clawsweeper.ts, test/clawsweeper.test.ts)
How this review workflow works
  • 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.

clawsweeper[bot] avatar May 21 '26 11:05 clawsweeper[bot]

Closing as an obsolete design proposal rather than an implemented item.

The current review path still truncates and supplies patch bodies to Codex, but those hunks are no longer prompt-only. Newer deterministic safety gates inspect them for configuration-surface and stored-data-model changes, then persist those results into durable apply guards. Removing patch bodies as proposed here would silently remove safety inputs.

Relevant current code:

  • Patch hydration: https://github.com/openclaw/clawsweeper/blob/5223760bdbf740d01c5409057ad87df28035ffc4/src/clawsweeper.ts#L4093-L4103
  • Prompt serialization: https://github.com/openclaw/clawsweeper/blob/5223760bdbf740d01c5409057ad87df28035ffc4/src/clawsweeper.ts#L6311-L6362
  • Deterministic hunk guards: https://github.com/openclaw/clawsweeper/blob/5223760bdbf740d01c5409057ad87df28035ffc4/src/clawsweeper.ts#L9429-L9537
  • Durable report gates: https://github.com/openclaw/clawsweeper/blob/5223760bdbf740d01c5409057ad87df28035ffc4/src/clawsweeper.ts#L14950-L15027

Git-native inspection can still be reconsidered in a new design, but it must retain or recompute those guards and use each repository's configured target branch rather than assuming origin/main.

steipete avatar Jun 15 '26 13:06 steipete