Skip to content

refactor(review): split the review prompt by item kind and render repository rules from profiles - #1784

Merged
obviyus merged 3 commits into
mainfrom
prompt-split-templates
Oct 9, 2026
Merged

obviyus merged 3 commits into
mainfrom
prompt-split-templates

Conversation

@obviyus

@obviyus obviyus commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

What

Split the item review prompt by item kind, and render repository-specific rules from the repository profile.

  • prompts/review-item.md is now the shared core. Issue reviews add prompts/review-item-issue.md, and PR reviews add prompts/review-item-pr.md.
  • instructions/pr-review-rules.md is folded into the PR template as its ## Review Rules section. The standalone file, the reviewRulesText() loader, and its cache are deleted. Findings discipline rule 3 is deleted because the PR template's re-review paragraph already states the same lateFinding contract.
  • ### Close reasons is rendered from prompts/review-close-reasons.md, filtered by profile.applyCloseRules[item.kind]. A repository with no close reason for the kind gets one "keep the item open" line.
  • oversized_pull_request is removed from the model-side schema enum. The host synthesizes that decision (clawsweeper-oversized-pr-policy.ts), and the parser still accepts it for stored and host-made decisions.
  • OpenClaw-only rules move into the built-in OpenClaw profile: promptNote (shared: changelog is release-owned) and a new typed kindPromptNotes (PR: surface-stat metrics, locale branches, request_behavior_proof, telegramVisibleProof, Doctor examples for implementer-owned decisions; issue: VISION.md, maturity scorecards). They render in a new ## Repository Policy section.
  • The clawhub-only close sentence and the hardcoded OpenClaw changelog sentence in nextStep are deleted: the rendered close reasons and the profile own them. One generic release-note sentence stays in the core.
  • LOC contradiction fixed: the OpenClaw note now says the production-vs-test LOC metric is the only size metric to add, and total additions/deletions stay banned.
  • REVIEW_POLICY_VERSION → 2026-10-09-policy-v37. The policy hash now covers all four prompt sources.

Why

Audit SlopPrompt findings 1, 2, 7 and 8 (Row 6):

  • Finding 1: issue reviews loaded the full PR-only prompt and OpenClaw-only blocks; non-OpenClaw repos got Telegram, maturity, and request_behavior_proof rules that cannot apply.
  • Finding 2: the close-reason contract lived in prompt prose and in profile allowlists, and they disagreed (oversized_pull_request was in the enum but described nowhere; profile kind filters silently skipped closes that the prose allowed).
  • Finding 7: pr-review-rules.md had no other consumer and restated the re-review contract.
  • Finding 8: the OpenClaw note banned additions/deletions while the prompt asked for a production-vs-test LOC metric.

Proof

pnpm run check: static checks, build, lint, and 6947 tests pass. Two tests in test/repair/command-proof-consumer.test.ts timed out (120 s/180 s) while three live reviews ran in parallel; that file passes alone (29/29). This is a load flake, not a prompt change.

Static prompt size (empty context, chars):

Target Kind main this PR
openclaw/openclaw issue 79,183 45,547 (−42%)
openclaw/openclaw PR 97,050 89,520 (−8%)
openclaw/clawhub issue 77,847 32,943
openclaw/clawhub PR 95,714 76,691
steipete/camsnap issue 77,766 31,095
steipete/camsnap PR 95,633 74,195

Real hosted-like runs (review_prompt_chars): issue #167557 102,349 → 68,709; PR #167567 128,228 → 120,585; PR #167560 154,420 → 146,777.

Mechanical equivalence (grep counts):

  • Prompt loaders: reviewPromptTemplate + reviewRulesText (2) → reviewPromptTemplates (1).
  • Close-reason bullets: 16 in review-item.md → 16 in review-close-reasons.md, moved verbatim. Rendered per profile and kind: openclaw issue 14, openclaw PR 13, clawhub issue 1, camsnap 0. New test: the rendered openclaw issue ∪ PR reasons plus none equal the schema closeReason enum.
  • Schema closeReason enum: 18 → 17 values (oversized_pull_request removed).
  • OpenClaw-only strings in steipete/camsnap issue/PR prompts: telegram-e2e-userbot 1/1 → 0/0, request_behavior_proof 1/1 → 0/0, maturity-scores.yaml 1/1 → 0/0, VISION.md 2/2 → 0/0. OpenClaw PR prompt keeps all of them through the profile.
  • ## Review Rules section in issue prompts: absent before and after; PR prompts: present before and after.

Comment rendering: I re-rendered all 15 saved real reports (prompt-rest, prompt-lean, prompt-dump, async-proof/, retire-proof/, /tmp/rules-slice/*) with main dist and branch dist. The output is byte-identical.

Live reviews, gpt-6.1-sol, clawsweeper-review sandbox, --local-only, main vs this branch:

Item Decision Findings Rating (proof/patch/overall) Labels Proof Telegram
PR #167567 (Telegram, external) keep_open = none = C/B/C = P1 = mock_only, needs contributor = needed =
PR #167560 (external) keep_open = P2 "Restrict the new refusal to finite tool selections" = C/C/C = P2, merge-risk compatibility = mock_only = not_needed =
Issue #167557 keep_open = n/a NA = P0, impact:ux-release-blocker, maturity:stable = not_applicable = not_needed =

Differences:

  • #167560 adds the review metric "Production versus test LOC: production +26/-1; tests +54/-22". This is the intended result of the finding 8 fix: the LOC metric is now allowed and the totals ban stays.
  • #167560 testingReview.proofPath changed from in_process_harness to unit_only. Rating, finding and readiness did not change. This is run-to-run judgement variance on the PR's added tests, not a prompt change; that rule moved verbatim.
  • #167557: the first branch run set realBehaviorProof.evidenceKind: none because the new issue paragraph said so. Commit 9d5f281 restores not_applicable, and the rerun matches main on every field.

Codex review dispositions

codex review --base main: no actionable findings.

Merge Danger

  • Door: two-way. Revert restores the single template. The policy bump causes one re-review wave either way.
  • Blast radius: every item review prompt in every target repository; the model-side closeReason enum. Apply-side close validation, the parser, and comment rendering are unchanged.

@clawsweeper

clawsweeper Bot commented Oct 9, 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.

@clawsweeper clawsweeper Bot added 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. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Split review guidance into shared, issue, and PR templates, and select repository-specific guidance and close reasons from repository profiles.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, focused refactor supported by real CLI comparisons and no actionable correctness finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body records real local-only CLI reviews using gpt-6.1-sol in the clawsweeper-review sandbox, exercising the changed assembler for issue and PR inputs with smaller payloads and preserved central review outcomes. Stored oversized decisions remain parseable and report rendering is unchanged; no persisted-format migration is required. Hosted publication is outside the demonstrated scope.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
User problem: Reviews receive irrelevant instructions for other item kinds and repositories, increasing payload size and conflicting guidance.
Reason: The split removes demonstrated prompt overhead and aligns model guidance with existing profile restrictions. Prior merged contributions establish the author's ownership of the review-prompt area.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still loads the combined prompt, and the introduced split preserves the review safeguards without an actionable patch defect.

Priority: P3
Reviewed head: b2de985a22a9698ca9e83214d005a10984b8db93

Before merge

None.

Findings

None.

Agent review details

How this fits together

ClawSweeper assembles repository policy and GitHub item evidence into instructions for its reviewer model. The resulting decision feeds review comments and separately guarded maintenance automation.

flowchart TD
  A[GitHub item and evidence] --> B[Review prompt assembler]
  C[Shared review guidance] --> B
  D[Issue or PR template] --> B
  E[Repository profile] --> F[Enabled guidance and close reasons]
  F --> B
  B --> G[Reviewer model]
  G --> H[Structured review decision]
Loading

Technical review

Best possible solution:

Keep one shared prompt assembler with item-specific templates and profile-owned policy, while preserving the existing apply safeguards and stored report format.

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

Not applicable to this refactor; source comparison establishes the unnecessary cross-kind guidance, and reported live reviews exercise the replacement composition.

Is this the best way to solve the issue?

Yes: the existing assembler and repository profiles remain the owners, with no parallel review path or change to apply authorization.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 552822607e72.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit 197df62 adds src/clawsweeper-review-runtime.ts:511 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 197df625648b; files: src/clawsweeper-review-runtime.ts)

Review metrics

Metric Value Why it matters
Production versus test LOC production +74/-39; tests +119/-95 The modest production growth supports template composition and profile selection while removing the former loader.

Labels

Label changes:

  • add P3: This is a bounded review-prompt maintenance improvement without an established urgent user-facing regression.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is a bounded review-prompt maintenance improvement without an established urgent user-facing regression.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

Reviewed October 9, 2026, 1:29 AM ET / 05:29 UTC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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