Skip to content

feat(review): carry re-review finding history and flag late findings - #384

Merged
steipete merged 7 commits into
openclaw:mainfrom
yetval:feat/rereview-finding-continuity
Jul 4, 2026
Merged

steipete merged 7 commits into
openclaw:mainfrom
yetval:feat/rereview-finding-continuity

Conversation

@yetval

@yetval yetval commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

ClawSweeper edits one durable review comment in place. Each re-review therefore erased the visible record of earlier findings, so later reviewers could rediscover unchanged concerns one cycle at a time. The pipeline also could not distinguish a genuinely new regression from a finding that was already visible on an earlier reviewed head.

Fix

This branch adds a compact, versioned review-history ledger to pull-request review comments and carries that history into later review prompts.

  • Retain the latest eight completed cycles while preserving the exact lifetime cycle total.
  • Record review time, reviewed SHA, verdict, and all detailed review findings.
  • Keep same-cycle comment sync idempotent.
  • Preserve the latest completed cycle through stale-head status updates; reject placeholder and failed cycles.
  • Use one section-aware finding parser for both the latest and earlier cycles, excluding priority bullets from risk and next-step sections.
  • Expose earlier cycles and completed-cycle count to the reviewer.
  • Require reviewers to compare against earlier SHAs before classifying a finding as late.
  • Round-trip the optional lateFinding signal through schema, reports, and durable comments.

The parser accepts only the exact locally rendered ledger structure. Before appending local history and automation markers, comment rendering neutralizes every model-authored ClawSweeper control marker, including case and whitespace variants. That prevents untrusted review text from forging history, status, verdict, or action controls on both keep-open and close paths.

User impact

Contributors and maintainers get one durable comment that explains how the review evolved instead of losing prior cycles. Re-review prompts can verify resolved findings, avoid serial rediscovery, and identify unchanged-code late findings with actual Git history. Issue comments remain unchanged.

Real behavior proof

Ran a redacted two-cycle dry-run under Node 24 against the built production dist/clawsweeper.js render/extract path. The input deliberately included unrelated P1/P2 bullets in risk and next-step sections. The second production render retained the first real finding in its durable ledger, and the next-review context carried the earlier cycle while exposing no false current findings:

=== production durable comment history block ===
<details>
<summary>Review history (1 earlier review cycle)</summary>

<!-- clawsweeper-review-history v=1 total=1 -->
- reviewed 2026-07-04T06:00:00.000Z sha cycle1abc :: found issues before merge. :: [P1] Preserve the first-cycle finding

</details>

=== production next-review context ===
{
  "reviewedSha": "cycle2def",
  "findings": [],
  "earlierReviewCycles": [
    {
      "reviewedAt": "2026-07-04T06:00:00.000Z",
      "sha": "cycle1abc",
      "verdict": "found issues before merge.",
      "findings": ["[P1] Preserve the first-cycle finding"]
    }
  ],
  "completedReviewCycles": 2
}

The real exact-item ClawSweeper review at d98977d2 then found that the latest-cycle branch still used the old broad scanner. Head 1a51be649d removes that scanner, makes both latest and earlier cycles use the section-aware parser, and adds an integration assertion with risk/next-step priority bullets.

Evidence

  • node --test test/review-history.test.ts test/apply-label-sync.test.ts — 30 passing on the final code.
  • Fresh full unit lane before the final narrow fix — 584/584 passing.
  • Exact-head d98977d2 CI: pnpm check, Windows launcher, CodeQL, and Socket all passed; final-head CI is the merge gate.
  • Build plus direct source/test lint and formatting passed on the final code.
  • Fresh final-fix autoreview: no accepted or actionable findings; patch correct at 0.88 confidence.

Coverage includes forged-marker injection, case/whitespace variants, close-comment rendering, detailed findings beyond the compact summary cap, risk/next-step exclusion from latest and earlier cycles, capped history totals, stale/failed cycles, idempotent sync, prompt/schema continuity, and apply comment-sync integration.

@clawsweeper

clawsweeper Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed July 4, 2026, 3:15 AM ET / 07:15 UTC.

Summary
The PR adds a versioned PR review-history ledger to durable ClawSweeper comments, feeds prior cycles into re-review prompts, adds a lateFinding schema field, and covers the render/parse/apply paths with focused tests.

Reproducibility: yes. for the patch defect by source inspection: a legacy durable comment with a public-body clawsweeper-verdict marker before the real footer would be consumed by reviewHistoryCycleFromCommentBody. I did not run a live apply mutation repro.

Review metrics: 2 noteworthy metrics.

  • Changed surface: 7 files, +1053/-52. The PR touches runtime review/apply plumbing plus docs, prompt, schema, and tests, so it changes automation behavior rather than only presentation.
  • New parser coverage: 1 new parser module and 1 new 570-line test file. The feature relies on durable comment parsing, so focused coverage is central to merge safety.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Harden legacy previous-comment marker parsing and add a regression with a forged public-body marker before the real footer.
  • [P2] Wait for exact-head pnpm check on 1a51be649d826cc8bdff728cc679531a491a0523 to complete before merge.

Risk before merge

  • [P1] Legacy durable comments rendered before this PR may contain unneutralized model-authored ClawSweeper markers; the new history conversion can treat the first such marker as trusted state.
  • [P1] The PR intentionally makes durable PR comments a versioned parseable state surface, which needs maintainer acceptance because it becomes a compatibility contract for future review runs.
  • [P1] The final-head pnpm check job was still in progress in the inspected GitHub run, so maintainers should wait for that exact-head gate before merge.

Maintainer options:

  1. Harden legacy marker parsing first (recommended)
    Update the history conversion to use only the trusted locally rendered footer marker, or reject unsafe legacy comments, and add a regression with a forged public-body marker before the real footer.
  2. Accept the public-state contract after review
    Maintainers can accept durable PR comments as a versioned state surface once the legacy marker gap is fixed and exact-head checks are green.
  3. Pause the ledger format
    If durable comments should remain display-only for now, pause or close this PR and keep re-review history out of the public comment contract.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Harden review-history conversion to trust only the locally rendered footer marker when extracting reviewed_at/sha from existing durable comments, and add a regression with a legacy comment containing a forged public-body clawsweeper marker before the real footer.

Next step before merge

  • [P2] A narrow automated repair can harden legacy marker extraction and add the missing regression; maintainer acceptance of the durable comment state contract remains separate.

Security
Needs attention: The diff improves marker neutralization for newly rendered comments, but legacy durable comments can still contribute forged marker attributes to the new review-history ledger.

Review findings

  • [P2] Use the trusted footer marker for legacy review comments — src/review-history.ts:184-205
Review details

Best possible solution:

Harden legacy marker extraction, keep the strict ledger parser and tests, then merge only after maintainers accept durable PR comments as parseable review-history state and exact-head checks pass.

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

Yes for the patch defect by source inspection: a legacy durable comment with a public-body clawsweeper-verdict marker before the real footer would be consumed by reviewHistoryCycleFromCommentBody. I did not run a live apply mutation repro.

Is this the best way to solve the issue?

No, not until legacy marker extraction is hardened. The ledger design is otherwise narrow, but the previous-comment conversion needs to trust the footer/local marker instead of the first marker in the full body.

Full review comments:

  • [P2] Use the trusted footer marker for legacy review comments — src/review-history.ts:184-205
    reviewHistoryCycleFromCommentBody records the first clawsweeper-verdict or clawsweeper-action marker it sees in the previous durable comment. Existing comments rendered before this PR were not neutralized, so a model-authored marker in the public body before the real footer can poison the ledger's SHA/reviewed_at and later late-finding comparisons. Parse the trusted footer/last valid local marker, or reject unsafe legacy comments instead.
    Confidence: 0.82

Overall correctness: patch is incorrect
Overall confidence: 0.82

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add merge-risk: 🚨 security-boundary: The diff handles hidden ClawSweeper control markers and currently leaves a legacy marker-trust path that can poison review-history state.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body and maintainer comments include redacted production-path dry-run output plus focused test, unit, CI, CodeQL, Socket, build, lint, and autoreview evidence for the intended render/extract behavior.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: This is a bounded review/apply automation improvement with limited blast radius but concrete maintainer-visible workflow impact.
  • merge-risk: 🚨 compatibility: The PR turns durable PR review comments into a versioned parseable state format that future ClawSweeper runs depend on.
  • merge-risk: 🚨 automation: The PR changes review-history data carried into later reviewer prompts and apply comment sync behavior.
  • merge-risk: 🚨 security-boundary: The diff handles hidden ClawSweeper control markers and currently leaves a legacy marker-trust path that can poison review-history state.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body and maintainer comments include redacted production-path dry-run output plus focused test, unit, CI, CodeQL, Socket, build, lint, and autoreview evidence for the intended render/extract behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and maintainer comments include redacted production-path dry-run output plus focused test, unit, CI, CodeQL, Socket, build, lint, and autoreview evidence for the intended render/extract behavior.
Evidence reviewed

Security concerns:

  • [medium] Legacy public-body markers can poison history state — src/review-history.ts:184
    The new history extraction scans existing durable comments from the top and accepts the first verdict/action marker, so pre-PR comments that include unneutralized model-authored control markers can supply false reviewed SHA or timestamp data.
    Confidence: 0.78

Acceptance criteria:

  • [P1] node --test test/review-history.test.ts test/apply-label-sync.test.ts.
  • [P1] pnpm run check.

What I checked:

  • Repository policy read: AGENTS.md was read fully and applied because this PR changes ClawSweeper review/apply automation and durable review comments. (AGENTS.md:1, d7d856dd6e3b)
  • Current main lacks the requested feature: Current main has previous review context plumbing but no lateFinding, review-history, earlierReviewCycles, completedReviewCycles, or Review history implementation across the searched source, prompt, docs, schema, and tests. (d7d856dd6e3b)
  • Ledger render path: At PR head, the keep-open renderer builds the local history block, neutralizes model-authored public text, then appends the locally rendered ledger so future comments should not be forgeable through new model text. (src/clawsweeper.ts:14649, 1a51be649d82)
  • Strict ledger parser: The new parser validates marker attributes, surrounding details/summary structure, line format, cycle cap, and total count before accepting a review-history ledger. (src/review-history.ts:100, 1a51be649d82)
  • Legacy marker trust gap: The new reviewMarkerAttribute scans an existing comment from the top and returns the first verdict/action marker, so a pre-PR durable comment containing a model-authored marker before the real footer can supply the ledger SHA and reviewed timestamp. (src/review-history.ts:184, 1a51be649d82)
  • Focused regression coverage: Tests cover section-scoped finding extraction, forged marker neutralization in newly rendered comments, stale/failed cycles, idempotent sync, capped totals, and prompt/schema continuity, but not legacy unneutralized comments with forged public-body markers before the footer. (test/review-history.test.ts:199, 1a51be649d82)

Likely related people:

  • Jhacarreiro: Git blame ties the existing extractLatestClawSweeperReview and durable keep-open rendering paths to merged work associated with Clarify offline default branch planning #320. (role: introduced current-main review context behavior; confidence: high; commits: 6990a7a407b7; files: src/clawsweeper.ts)
  • steipete: PR metadata shows steipete authored the current branch hardening commits for accurate history, forged marker rejection, local review controls, and section-scoped findings. (role: branch hardening contributor and adjacent owner; confidence: high; commits: f93a50722861, 89c3799f6039, d98977d2f031; files: src/clawsweeper.ts, src/review-history.ts, test/review-history.test.ts)
  • yetval: Current-main history shows yetval authored a recent merged apply/review label-sync fix, and this PR builds on that automation area. (role: recent adjacent contributor; confidence: medium; commits: 279d3bd60f3b; files: src/clawsweeper.ts, test/apply-label-sync.test.ts)
  • hxy91819: Current-main history shows adjacent stale review comment sync overwrite work in the same apply/comment-sync surface. (role: recent adjacent contributor; confidence: medium; commits: f7e8b13d0eb3; files: src/clawsweeper.ts, test/clawsweeper.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

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.

Comment thread src/review-history.ts Fixed
@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. 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. and removed 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 2, 2026
@steipete steipete self-assigned this Jul 4, 2026
yetval and others added 6 commits July 3, 2026 22:35
…syncs

ClawSweeper edits one durable review comment in place, so every re-review
sync erased what earlier cycles found and the reviewer model only ever saw
the latest cycle. Reviews could then surface one previously visible concern
per cycle across many cycles without any accountability.

PR keep-open comment syncs now carry a compact review-history ledger of
earlier cycles (reviewed-at, head sha, verdict, finding titles) inside the
durable comment, capped at eight cycles and deduped on re-syncs of the same
review. The review context exposes the parsed ledger as
previousClawSweeperReview.earlierReviewCycles plus a completedReviewCycles
count. The review prompt now requires re-review continuity: verify prior
findings first, report every remaining blocking concern in one pass, and
mark findings on previously reviewed unchanged code with the new optional
reviewFindings lateFinding flag, which round-trips through reports and
renders in the durable comment.
CodeQL flagged the marker-attribute regex as polynomial on repeated
unclosed marker prefixes. Replace it with the same indexOf-based linear
comment scan the main module uses for HTML markers.
@steipete
steipete force-pushed the feat/rereview-finding-continuity branch from 9ee80d1 to d98977d Compare July 4, 2026 06:51
@steipete

steipete commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 4, 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: the existing ClawSweeper review comment will be edited in place when the review finishes.

@steipete

steipete commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Land-ready proof for 1a51be649d826cc8bdff728cc679531a491a0523:

The first live exact-item review found that latest-cycle extraction still used the legacy broad priority-bullet scanner. 1a51be649d removes that duplicate scanner, routes latest and earlier cycles through the same section-aware parser, and adds the missing integration assertion. The final live review verified the fix on the exact head.

@steipete

steipete commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 4, 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: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. and removed 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 Jul 4, 2026
@steipete
steipete merged commit 4db0631 into openclaw:main Jul 4, 2026
12 checks passed
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
…penclaw#384)

* feat(review): carry re-review finding history across durable comment syncs

ClawSweeper edits one durable review comment in place, so every re-review
sync erased what earlier cycles found and the reviewer model only ever saw
the latest cycle. Reviews could then surface one previously visible concern
per cycle across many cycles without any accountability.

PR keep-open comment syncs now carry a compact review-history ledger of
earlier cycles (reviewed-at, head sha, verdict, finding titles) inside the
durable comment, capped at eight cycles and deduped on re-syncs of the same
review. The review context exposes the parsed ledger as
previousClawSweeperReview.earlierReviewCycles plus a completedReviewCycles
count. The review prompt now requires re-review continuity: verify prior
findings first, report every remaining blocking concern in one pass, and
mark findings on previously reviewed unchanged code with the new optional
reviewFindings lateFinding flag, which round-trips through reports and
renders in the durable comment.

* fix(review): scan review markers linearly instead of with a lazy regex

CodeQL flagged the marker-attribute regex as polynomial on repeated
unclosed marker prefixes. Replace it with the same indexOf-based linear
comment scan the main module uses for HTML markers.

* fix(review): skip status comments in review history

* fix(review): preserve accurate re-review history

* fix(review): reject forged history markers

* fix(review): trust only local review controls

* fix(review): keep previous findings section-scoped

---------

Co-authored-by: Peter Steinberger <[email protected]>
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. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. 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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants