Repository navigation
perf(review): reuse prior verdict when reviewable content is unchanged - #410
Conversation
The review lane re-runs the full model (codex exec, high reasoning effort) for every due item on a fixed cadence, gated only on time and the review-policy hash. It never checks whether the reviewable content changed, so most re-reviews across the open backlog re-derive an identical verdict from identical input, spending tokens and a worker slot for tens of minutes each. Add a content-addressed skip. On an automatic re-review, compute a content digest of the review-relevant surface (item source revision plus, for PRs, the head sha, base sha, diff, and inline review comments) and skip the model when a prior completed review has a matching digest under an unchanged policy within a 14-day ceiling, carrying the prior verdict forward. Explicit re-review requests, policy changes, content changes, failed priors, and the 14-day ceiling all still run a full review. The digest excludes volatile inputs (item updated_at, live main sha, and ClawSweeper's own comments) so the bot's own writes do not bust the cache. The carry-forward refreshes only liveness fields (reviewed_at, item_updated_at, item_snapshot_hash) and preserves the verdict, last_full_review_at, and review-comment metadata, so the apply lane's changed-since-review protection is unchanged.
|
Codex review: needs maintainer review before merge. Reviewed July 4, 2026, 12:03 PM ET / 16:03 UTC. Summary Reproducibility: not applicable. as a performance PR rather than a bug report. The PR body provides live-output proof and the added tests exercise the skip-versus-spawn decisions. Review metrics: 3 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the cache only after required checks pass and maintainers accept the bounded keep-open staleness, preserving the current close-verdict main-sha guard. Do we have a high-confidence way to reproduce the issue? Not applicable as a performance PR rather than a bug report. The PR body provides live-output proof and the added tests exercise the skip-versus-spawn decisions. Is this the best way to solve the issue? Yes. The current approach is a narrow cache around completed reviews, and the current head now forces close verdicts through a full re-review when the recorded main SHA no longer matches. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cdcb851924a7. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
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
Review history (1 earlier review cycle)
|
A close verdict (for example implemented_on_main) depends on target-branch code that is not in the content digest, because the live main sha advances on every merge and would collapse the cache. Gate cache hits for close verdicts on the stored main_sha matching the current one, so a main-branch change forces a full re-review before any close and a close is never carried across target-branch state it was not verified against. keep_open verdicts still cache on content alone.
|
Addressed the [P1] on target-branch state in 9f76d13. A close verdict can depend on main-branch code (implemented_on_main and similar), which the content digest omits on purpose: the live main sha advances on every merge, so digesting it would collapse the cache. Instead, a cache hit for a close verdict now additionally requires the stored main_sha to equal the current one. If main moved since the review that produced the close, the item takes a full re-review before any close, so a close is never carried across target-branch state it was not verified against. keep_open verdicts still cache on content alone (a stale keep-open only delays a close and is bounded by the 14-day ceiling). Added regression tests: a prior close report cache-misses when main_sha changed, misses when it has no stored main_sha, hits when main is unchanged, and keep_open still hits across main movement. |
…-cache # Conflicts: # src/scheduler-policy.ts # test/review-content-cache.test.ts
Supersede the close/main_sha gate with a structural invariant: the review cache only carries keep_open verdicts, and a close verdict always takes a full re-review. The apply lane only ever closes via a live re-check of current item state and never turns a report's stored verdict into a close, so the sole destructive risk is carrying a stale close forward. Restricting the cache to keep_open removes that surface regardless of what the content digest covers; a carried keep_open is non-destructive (at worst a delayed close, bounded by the 14-day ceiling).
|
Addressed the [P1] on prompt-changing context in bcbab37, and I stepped back on the approach. This is the third finding of the same shape: a stale close carried forward because the content digest omits part of the prompt (first PR review comments, then main state, now closingPullRequests/referencingMergedPullRequests/relatedItems). Chasing digest completeness against the full nested, evolving context is a losing game, so I moved the boundary rather than adding another field. The only destructive automated action is a close, and the apply lane only ever closes via a live re-check of current state (livePullRequestHasNoDiff, pullRequestClosePromotion on currentItemContext()); it never turns a report's stored verdict into a close on its own. So the whole risk is carrying a stale close forward. The cache now only carries keep_open verdicts; a close verdict always takes a full re-review. That removes the destructive surface structurally, independent of what the digest covers, and supersedes the earlier main_sha gate (which only covered main state). A carried keep_open is non-destructive (at worst a delayed close, bounded by the 14-day ceiling and by any content change), so digest coverage is now a freshness concern for keep-open items, not a safety one. Proof (real gate plus a fake codex counting spawns) over [first-ever, unchanged keep-open, changed diff, new review comment, unchanged close]: base spawns 5, patched spawns 4. Only the unchanged keep-open skips; the unchanged close still runs the model. |
…-cache # Conflicts: # src/scheduler-policy.ts # test/review-content-cache.test.ts
…ache # Conflicts: # src/clawsweeper.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7030d564ba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
^^^Codex review is giving me the same review comment seems like
|
openclaw#410) * perf(review): reuse prior verdict when reviewable content is unchanged The review lane re-runs the full model (codex exec, high reasoning effort) for every due item on a fixed cadence, gated only on time and the review-policy hash. It never checks whether the reviewable content changed, so most re-reviews across the open backlog re-derive an identical verdict from identical input, spending tokens and a worker slot for tens of minutes each. Add a content-addressed skip. On an automatic re-review, compute a content digest of the review-relevant surface (item source revision plus, for PRs, the head sha, base sha, diff, and inline review comments) and skip the model when a prior completed review has a matching digest under an unchanged policy within a 14-day ceiling, carrying the prior verdict forward. Explicit re-review requests, policy changes, content changes, failed priors, and the 14-day ceiling all still run a full review. The digest excludes volatile inputs (item updated_at, live main sha, and ClawSweeper's own comments) so the bot's own writes do not bust the cache. The carry-forward refreshes only liveness fields (reviewed_at, item_updated_at, item_snapshot_hash) and preserves the verdict, last_full_review_at, and review-comment metadata, so the apply lane's changed-since-review protection is unchanged. * fix(review): harden content cache safety * harden close-verdict cache against target-branch drift A close verdict (for example implemented_on_main) depends on target-branch code that is not in the content digest, because the live main sha advances on every merge and would collapse the cache. Gate cache hits for close verdicts on the stored main_sha matching the current one, so a main-branch change forces a full re-review before any close and a close is never carried across target-branch state it was not verified against. keep_open verdicts still cache on content alone. * fix(review): invalidate cache on human timeline events * fix(review): bind cache reuse to target head * fix(review): preserve exact dispatch freshness * fix(review): hash full dynamic review context * restrict content cache to keep-open verdicts Supersede the close/main_sha gate with a structural invariant: the review cache only carries keep_open verdicts, and a close verdict always takes a full re-review. The apply lane only ever closes via a live re-check of current item state and never turns a report's stored verdict into a close, so the sole destructive risk is carrying a stale close forward. Restricting the cache to keep_open removes that surface regardless of what the content digest covers; a carried keep_open is non-destructive (at worst a delayed close, bounded by the 14-day ceiling). * fix(review): preserve related review comments * fix(review): refresh issue cache on main changes * fix(review): preserve cache verdict provenance --------- Co-authored-by: Peter Steinberger <[email protected]>
What this changes
Scheduled reviews currently start a fresh high-reasoning Codex process even when the reviewable content is unchanged. This adds a conservative content cache for planned background reviews without reducing the 128-worker pool.
An automatic review can reuse a prior report only when all of these are true:
keep_open;Close verdicts are never cached. They always receive a fresh model review.
Reviewable content
The digest covers the issue or PR source, human timeline activity, closing and related items, the latest release, PR head/base state, diff, commits, and inline review comments. ClawSweeper-owned churn and advisory-label churn are ignored.
Issue cache keys also include the target main SHA because a main-branch fix can change an issue verdict without changing its discussion. PR keys already include their live base SHA.
Prompts remain bounded, but cache freshness does not depend on those bounds: long human timelines and PRs with more than 40 inline comments get full-set revision hashes. A changed middle comment therefore invalidates the cache even when that comment is omitted from the model prompt window.
The cache is self-migrating. Existing reports without the new digest fields take one full review before they can become eligible.
Safety boundaries
keep_openverdicts can be reused. A stale close can never be carried into apply.Proof
pnpm run check: 651 unit, 617 repair, and 1,268 coverage tests passed, plus builds, lint, coverage thresholds, active-surface/limits checks, and formatting.63c5a7d1bd2672c12c198a3f5598d2e1e7db63f8.The original subprocess smoke remains representative: among first review, unchanged keep-open, changed diff, new maintainer comment, and unchanged close, only the unchanged keep-open review skips the model process.